@design-edito/tools 0.1.44 → 0.1.45

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. package/agnostic/arrays/random-pick/index.js +4 -4
  2. package/agnostic/css/index.js +7 -7
  3. package/agnostic/html/hyper-json/cast/index.js +6 -5
  4. package/agnostic/html/hyper-json/index.js +7 -6
  5. package/agnostic/html/hyper-json/smart-tags/coalesced/add/index.js +6 -5
  6. package/agnostic/html/hyper-json/smart-tags/coalesced/addclass/index.js +6 -5
  7. package/agnostic/html/hyper-json/smart-tags/coalesced/and/index.js +6 -5
  8. package/agnostic/html/hyper-json/smart-tags/coalesced/append/index.js +6 -5
  9. package/agnostic/html/hyper-json/smart-tags/coalesced/at/index.js +6 -5
  10. package/agnostic/html/hyper-json/smart-tags/coalesced/call/index.js +6 -5
  11. package/agnostic/html/hyper-json/smart-tags/coalesced/clone/index.js +6 -5
  12. package/agnostic/html/hyper-json/smart-tags/coalesced/deleteproperties/index.js +6 -5
  13. package/agnostic/html/hyper-json/smart-tags/coalesced/equals/index.js +6 -5
  14. package/agnostic/html/hyper-json/smart-tags/coalesced/getattribute/index.js +6 -5
  15. package/agnostic/html/hyper-json/smart-tags/coalesced/getproperties/index.js +6 -5
  16. package/agnostic/html/hyper-json/smart-tags/coalesced/getproperty/index.js +6 -5
  17. package/agnostic/html/hyper-json/smart-tags/coalesced/if/index.js +6 -5
  18. package/agnostic/html/hyper-json/smart-tags/coalesced/initialize/index.js +6 -5
  19. package/agnostic/html/hyper-json/smart-tags/coalesced/join/index.js +6 -5
  20. package/agnostic/html/hyper-json/smart-tags/coalesced/length/index.js +6 -5
  21. package/agnostic/html/hyper-json/smart-tags/coalesced/map/index.js +6 -5
  22. package/agnostic/html/hyper-json/smart-tags/coalesced/negate/index.js +6 -5
  23. package/agnostic/html/hyper-json/smart-tags/coalesced/notrailing/index.js +6 -5
  24. package/agnostic/html/hyper-json/smart-tags/coalesced/or/index.js +6 -5
  25. package/agnostic/html/hyper-json/smart-tags/coalesced/pickrandom/index.js +6 -5
  26. package/agnostic/html/hyper-json/smart-tags/coalesced/populate/index.js +6 -5
  27. package/agnostic/html/hyper-json/smart-tags/coalesced/print/index.js +6 -5
  28. package/agnostic/html/hyper-json/smart-tags/coalesced/push/index.js +6 -5
  29. package/agnostic/html/hyper-json/smart-tags/coalesced/pusheach/index.js +6 -5
  30. package/agnostic/html/hyper-json/smart-tags/coalesced/recordtoarray/index.js +6 -5
  31. package/agnostic/html/hyper-json/smart-tags/coalesced/removeattribute/index.js +6 -5
  32. package/agnostic/html/hyper-json/smart-tags/coalesced/removeclass/index.js +6 -5
  33. package/agnostic/html/hyper-json/smart-tags/coalesced/renameproperty/index.js +6 -5
  34. package/agnostic/html/hyper-json/smart-tags/coalesced/replace/index.js +6 -5
  35. package/agnostic/html/hyper-json/smart-tags/coalesced/select/index.js +6 -5
  36. package/agnostic/html/hyper-json/smart-tags/coalesced/set/index.js +6 -5
  37. package/agnostic/html/hyper-json/smart-tags/coalesced/setattribute/index.js +6 -5
  38. package/agnostic/html/hyper-json/smart-tags/coalesced/setproperty/index.js +6 -5
  39. package/agnostic/html/hyper-json/smart-tags/coalesced/sorton/index.js +6 -5
  40. package/agnostic/html/hyper-json/smart-tags/coalesced/split/index.js +6 -5
  41. package/agnostic/html/hyper-json/smart-tags/coalesced/spread/index.js +6 -5
  42. package/agnostic/html/hyper-json/smart-tags/coalesced/toarray/index.js +6 -5
  43. package/agnostic/html/hyper-json/smart-tags/coalesced/toboolean/index.js +6 -5
  44. package/agnostic/html/hyper-json/smart-tags/coalesced/toelement/index.js +6 -5
  45. package/agnostic/html/hyper-json/smart-tags/coalesced/toggleclass/index.js +6 -5
  46. package/agnostic/html/hyper-json/smart-tags/coalesced/tonodelist/index.js +6 -5
  47. package/agnostic/html/hyper-json/smart-tags/coalesced/tonull/index.js +6 -5
  48. package/agnostic/html/hyper-json/smart-tags/coalesced/tonumber/index.js +6 -5
  49. package/agnostic/html/hyper-json/smart-tags/coalesced/torecord/index.js +6 -5
  50. package/agnostic/html/hyper-json/smart-tags/coalesced/toref/index.js +6 -5
  51. package/agnostic/html/hyper-json/smart-tags/coalesced/tostring/index.js +6 -5
  52. package/agnostic/html/hyper-json/smart-tags/coalesced/totext/index.js +6 -5
  53. package/agnostic/html/hyper-json/smart-tags/coalesced/transformselected/index.js +6 -5
  54. package/agnostic/html/hyper-json/smart-tags/coalesced/trim/index.js +6 -5
  55. package/agnostic/html/hyper-json/smart-tags/isolated/array/index.js +1 -1
  56. package/agnostic/html/hyper-json/smart-tags/isolated/boolean/index.js +6 -5
  57. package/agnostic/html/hyper-json/smart-tags/isolated/element/index.js +6 -5
  58. package/agnostic/html/hyper-json/smart-tags/isolated/get/index.js +6 -5
  59. package/agnostic/html/hyper-json/smart-tags/isolated/global/index.js +6 -5
  60. package/agnostic/html/hyper-json/smart-tags/isolated/guess/index.js +6 -5
  61. package/agnostic/html/hyper-json/smart-tags/isolated/nodelist/index.js +6 -5
  62. package/agnostic/html/hyper-json/smart-tags/isolated/number/index.js +6 -5
  63. package/agnostic/html/hyper-json/smart-tags/isolated/record/index.js +6 -5
  64. package/agnostic/html/hyper-json/smart-tags/isolated/ref/index.js +6 -5
  65. package/agnostic/html/hyper-json/smart-tags/isolated/string/index.js +6 -5
  66. package/agnostic/html/hyper-json/smart-tags/isolated/text/index.js +6 -5
  67. package/agnostic/html/hyper-json/tree/index.js +6 -5
  68. package/agnostic/html/hyper-json/utils/index.js +6 -5
  69. package/agnostic/html/index.js +22 -21
  70. package/agnostic/html/sanitize/index.js +4 -4
  71. package/agnostic/html/selector-to-element/index.js +4 -4
  72. package/agnostic/html/string-to-nodes/index.js +5 -5
  73. package/agnostic/misc/crossenv/index.js +2 -2
  74. package/agnostic/misc/index.js +20 -20
  75. package/agnostic/misc/lorem-ipsum/index.js +9 -9
  76. package/agnostic/numbers/index.js +3 -3
  77. package/agnostic/objects/index.js +12 -12
  78. package/agnostic/random/index.js +2 -2
  79. package/agnostic/strings/index.js +10 -10
  80. package/chunks/chunk-7DNQ6RM2.js +211 -0
  81. package/chunks/chunk-AQBJ6HNB.js +29 -0
  82. package/chunks/chunk-FHEUGVMU.js +37 -0
  83. package/chunks/chunk-FQD3VK47.js +37 -0
  84. package/chunks/chunk-QAQZEKIF.js +20 -0
  85. package/chunks/chunk-RX3BKRJU.js +2407 -0
  86. package/chunks/chunk-SBAY4ZKE.js +211 -0
  87. package/chunks/chunk-SKBOSWM2.js +35 -0
  88. package/chunks/chunk-TIER4TF4.js +26 -0
  89. package/chunks/chunk-XB3EGDBI.js +127 -0
  90. package/chunks/chunk-YCZQAM7E.js +2407 -0
  91. package/chunks/chunk-ZBBU2P4D.js +28 -0
  92. package/node/files/index.js +3 -3
  93. package/package.json +1 -1
@@ -0,0 +1,2407 @@
1
+ import {
2
+ nullFunc
3
+ } from "./chunk-QAVYONH6.js";
4
+ import {
5
+ Types
6
+ } from "./chunk-XEQ2PBT2.js";
7
+ import {
8
+ any
9
+ } from "./chunk-FHLCPVND.js";
10
+ import {
11
+ array
12
+ } from "./chunk-QAQZEKIF.js";
13
+ import {
14
+ SmartTags
15
+ } from "./chunk-UT2J62LH.js";
16
+ import {
17
+ Serialize
18
+ } from "./chunk-SXRWMH3U.js";
19
+ import {
20
+ Transformer
21
+ } from "./chunk-BKO7GLC2.js";
22
+ import {
23
+ Method
24
+ } from "./chunk-RW7VAKJW.js";
25
+ import {
26
+ insertNode
27
+ } from "./chunk-XA4HVHJ4.js";
28
+ import {
29
+ isInEnum
30
+ } from "./chunk-E6MSDKON.js";
31
+ import {
32
+ recordMap
33
+ } from "./chunk-XNF5MLCQ.js";
34
+ import {
35
+ isRecord
36
+ } from "./chunk-YDIBNEGA.js";
37
+ import {
38
+ Outcome
39
+ } from "./chunk-JMU5PDBD.js";
40
+ import {
41
+ trimEnd,
42
+ trimStart
43
+ } from "./chunk-6XL25OZX.js";
44
+ import {
45
+ replaceAll
46
+ } from "./chunk-ZTDVUXPR.js";
47
+ import {
48
+ Window
49
+ } from "./chunk-RLJOYG64.js";
50
+
51
+ // src/agnostic/html/hyper-json/cast/index.ts
52
+ var Cast;
53
+ ((Cast2) => {
54
+ Cast2.toNull = () => null;
55
+ Cast2.toBoolean = (input) => {
56
+ const { Text: Text2 } = Window.get();
57
+ if (input === null) return false;
58
+ if (typeof input === "boolean") return input;
59
+ if (typeof input === "number") return input !== 0;
60
+ if (typeof input === "string" || input instanceof Text2) {
61
+ const strInput = (0, Cast2.toString)(input);
62
+ if (strInput.trim() === "") return false;
63
+ if (strInput.trim().toLowerCase() === "false") return false;
64
+ return true;
65
+ }
66
+ return true;
67
+ };
68
+ Cast2.toNumber = (input) => {
69
+ const { Text: Text2 } = Window.get();
70
+ if (typeof input === "boolean") return input ? 1 : 0;
71
+ if (typeof input === "number") return input;
72
+ if (typeof input === "string") return parseFloat(`${input}`);
73
+ if (input instanceof Text2) return parseFloat(`${input.textContent}`);
74
+ return 0;
75
+ };
76
+ Cast2.toString = (input) => {
77
+ if (typeof input === "string") return input;
78
+ if (typeof input === "number" || typeof input === "boolean" || input === null) return `${input}`;
79
+ const { Element: Element2, Text: Text2, NodeList } = Window.get();
80
+ if (input instanceof Element2) return input.outerHTML;
81
+ if (input instanceof Text2) return input.textContent ?? "";
82
+ if (input instanceof NodeList) return Array.from(input).map((e) => {
83
+ if (e instanceof Element2) return e.outerHTML;
84
+ return e.textContent;
85
+ }).join("");
86
+ if (Array.isArray(input)) return input.map(Cast2.toString).join("");
87
+ if (input instanceof Method) return `[Method:${input.transformer.name}]`;
88
+ return `{${Object.entries(input).map(([key, val]) => `${key}:"${(0, Cast2.toString)(val)}"`).join(",")}}`;
89
+ };
90
+ Cast2.toText = (input) => {
91
+ const { Text: Text2, document: document2 } = Window.get();
92
+ if (input instanceof Text2) return input.cloneNode(true);
93
+ return document2.createTextNode((0, Cast2.toString)(input));
94
+ };
95
+ Cast2.toElement = (input) => {
96
+ const { Element: Element2, Text: Text2, NodeList, document: document2 } = Window.get();
97
+ if (input instanceof Element2) return input.cloneNode(true);
98
+ const returned = document2.createElement("div");
99
+ if (input instanceof Text2) {
100
+ returned.append(input.cloneNode(true));
101
+ return returned;
102
+ }
103
+ if (input instanceof NodeList) {
104
+ returned.append(...Array.from(input).map((e) => e.cloneNode(true)));
105
+ return returned;
106
+ }
107
+ if (Array.isArray(input)) return returned;
108
+ if (isRecord(input)) return returned;
109
+ returned.innerHTML = `${input}`;
110
+ return returned;
111
+ };
112
+ Cast2.toNodeList = (input) => {
113
+ const { Element: Element2, Text: Text2, NodeList, document: document2 } = Window.get();
114
+ const parentDiv = document2.createElement("div");
115
+ if (input instanceof NodeList) {
116
+ parentDiv.append(...Array.from(input).map((i) => i.cloneNode(true)));
117
+ return parentDiv.childNodes;
118
+ }
119
+ if (input instanceof Element2 || input instanceof Text2) {
120
+ parentDiv.append(input.cloneNode(true));
121
+ return parentDiv.childNodes;
122
+ }
123
+ if (Array.isArray(input)) {
124
+ input.forEach((item) => {
125
+ if (typeof item === "number" || typeof item === "boolean" || item === null) parentDiv.append(`${item}`);
126
+ else if (typeof item === "string" || item instanceof Text2 || item instanceof Element2) parentDiv.append(item);
127
+ else if (item instanceof NodeList) parentDiv.append(...Array.from(item));
128
+ else if (Array.isArray(item)) parentDiv.append(...Array.from((0, Cast2.toNodeList)(item)));
129
+ else parentDiv.append((0, Cast2.toString)(item));
130
+ });
131
+ return parentDiv.childNodes;
132
+ }
133
+ if (isRecord(input)) {
134
+ parentDiv.append((0, Cast2.toString)(input));
135
+ return parentDiv.childNodes;
136
+ }
137
+ parentDiv.innerHTML = `${input}`;
138
+ return parentDiv.childNodes;
139
+ };
140
+ Cast2.toArray = (input) => {
141
+ const { NodeList } = Window.get();
142
+ if (Array.isArray(input)) return [...input];
143
+ if (input instanceof NodeList) return Array.from(input);
144
+ return [input];
145
+ };
146
+ Cast2.toRecord = (input) => {
147
+ const isRecord2 = Utils.Tree.TypeChecks.typeCheck(input, "record");
148
+ if (isRecord2.success) return { ...isRecord2.payload };
149
+ return {};
150
+ };
151
+ })(Cast || (Cast = {}));
152
+
153
+ // src/agnostic/html/hyper-json/smart-tags/isolated/element/index.ts
154
+ var element = SmartTags.makeSmartTag({
155
+ name: "element",
156
+ defaultMode: "isolation",
157
+ isolationInitType: "array",
158
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text"),
159
+ argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "null", "boolean", "number", "string", "text", "element", "nodelist"),
160
+ func: (main, args) => {
161
+ const tagName = Cast.toString(main).trim().toLowerCase();
162
+ const { document: document2, NodeList } = Window.get();
163
+ const elt = document2.createElement(tagName);
164
+ for (const argVal of args) {
165
+ if (argVal instanceof NodeList) elt.append(...Array.from(argVal));
166
+ else if (argVal instanceof Element) elt.append(argVal);
167
+ else elt.append(Cast.toText(argVal));
168
+ }
169
+ return Outcome.makeSuccess(elt);
170
+ }
171
+ });
172
+
173
+ // src/agnostic/html/hyper-json/smart-tags/isolated/get/index.ts
174
+ var get = SmartTags.makeSmartTag({
175
+ name: "get",
176
+ defaultMode: "isolation",
177
+ isolationInitType: "array",
178
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text"),
179
+ argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
180
+ func: (main, _args, { sourceTree }) => {
181
+ const { makeSuccess, makeFailure } = Outcome;
182
+ const { makeTransformationError } = Utils.SmartTags;
183
+ const strName = Cast.toString(main);
184
+ const found = sourceTree.getVariable(strName);
185
+ if (found === void 0) return makeFailure(makeTransformationError(`No variable stored under the name '${strName}'`));
186
+ return makeSuccess(found);
187
+ }
188
+ });
189
+
190
+ // src/agnostic/html/hyper-json/smart-tags/isolated/global/index.ts
191
+ var global = SmartTags.makeSmartTag({
192
+ name: "global",
193
+ defaultMode: "isolation",
194
+ isolationInitType: "array",
195
+ mainValueCheck: (m) => Outcome.makeSuccess(m),
196
+ argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
197
+ func: (_m, _a, { sourceTree }) => {
198
+ const globalObject = sourceTree.options.globalObject ?? {};
199
+ return Outcome.makeSuccess({ ...globalObject });
200
+ }
201
+ });
202
+
203
+ // src/agnostic/html/hyper-json/smart-tags/isolated/guess/index.ts
204
+ var guess = SmartTags.makeSmartTag({
205
+ name: "guess",
206
+ defaultMode: "isolation",
207
+ isolationInitType: "string",
208
+ mainValueCheck: (m) => Outcome.makeSuccess(m),
209
+ argsValueCheck: (a) => Outcome.makeSuccess(a),
210
+ func: (main, args) => {
211
+ const { typeCheck } = Utils.Tree.TypeChecks;
212
+ const { makeSuccess } = Outcome;
213
+ let coalesced = main;
214
+ for (const arg of args) coalesced = Utils.coalesceValues(coalesced, 0, arg);
215
+ const { Text: Text2, Element: Element2, document: document2 } = Window.get();
216
+ if (typeof coalesced !== "string" && !(coalesced instanceof Text2)) return makeSuccess(coalesced);
217
+ const strCoalesced = Cast.toString(coalesced);
218
+ if (strCoalesced.trim().toLowerCase() === "true") return makeSuccess(true);
219
+ if (strCoalesced.trim().toLowerCase() === "false") return makeSuccess(false);
220
+ if (strCoalesced.trim().toLowerCase().match(/^\s*-?\s*(\d+(\.\d*)?|\.\d+)\s*$/)) return makeSuccess(parseFloat(strCoalesced));
221
+ if (strCoalesced.trim().toLowerCase() === "null") return makeSuccess(null);
222
+ try {
223
+ const parsed = JSON.parse(strCoalesced);
224
+ const arrayChecked = typeCheck(parsed, "array");
225
+ const recordChecked = typeCheck(parsed, "record");
226
+ if (arrayChecked.success) return makeSuccess(arrayChecked.payload);
227
+ if (recordChecked.success) return makeSuccess(recordChecked.payload);
228
+ } catch (err) {
229
+ }
230
+ const div = document2.createElement("div");
231
+ div.innerHTML = strCoalesced;
232
+ const divChildren = div.childNodes;
233
+ if (divChildren.length === 0) return makeSuccess(coalesced);
234
+ const validDivChildren = Cast.toNodeList(Array.from(divChildren).filter((e) => {
235
+ if (e instanceof Element2) return true;
236
+ if (e instanceof Text2) return true;
237
+ return false;
238
+ }));
239
+ if (validDivChildren.length > 1) return makeSuccess(validDivChildren);
240
+ const validDivFirstchild = validDivChildren.item(0);
241
+ if (validDivChildren.length === 1 && validDivFirstchild instanceof Element2) return makeSuccess(validDivFirstchild);
242
+ return makeSuccess(coalesced);
243
+ }
244
+ });
245
+
246
+ // src/agnostic/html/hyper-json/smart-tags/isolated/nodelist/index.ts
247
+ var nodelist = SmartTags.makeSmartTag({
248
+ name: "nodelist",
249
+ defaultMode: "isolation",
250
+ isolationInitType: "nodelist",
251
+ mainValueCheck: (m) => Outcome.makeSuccess(m),
252
+ argsValueCheck: (a) => Outcome.makeSuccess(a),
253
+ func: (main, args) => {
254
+ const { document: document2 } = Window.get();
255
+ const returnedParent = document2.createDocumentFragment();
256
+ returnedParent.append(
257
+ ...Array.from(Cast.toNodeList(main)),
258
+ ...Array.from(Cast.toNodeList(args))
259
+ );
260
+ const returned = returnedParent.childNodes;
261
+ return Outcome.makeSuccess(returned);
262
+ }
263
+ });
264
+
265
+ // src/agnostic/html/hyper-json/smart-tags/isolated/number/index.ts
266
+ var number = SmartTags.makeSmartTag({
267
+ name: "number",
268
+ defaultMode: "isolation",
269
+ isolationInitType: "number",
270
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "null", "boolean", "number", "string", "text"),
271
+ argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "null", "boolean", "number", "string", "text"),
272
+ func: (main, args) => {
273
+ const all = [main, ...args];
274
+ const reduced = all.reduce((reduced2, curr) => {
275
+ return reduced2 + Cast.toNumber(curr);
276
+ }, 0);
277
+ return Outcome.makeSuccess(reduced);
278
+ }
279
+ });
280
+
281
+ // src/agnostic/html/hyper-json/smart-tags/isolated/record/index.ts
282
+ var record = SmartTags.makeSmartTag({
283
+ name: "record",
284
+ defaultMode: "isolation",
285
+ isolationInitType: "record",
286
+ mainValueCheck: (i) => Utils.Tree.TypeChecks.typeCheck(i, "record"),
287
+ argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "record"),
288
+ func: (main, args) => Outcome.makeSuccess(args.reduce((reduced, current) => ({
289
+ ...reduced,
290
+ ...current
291
+ }), main))
292
+ });
293
+
294
+ // src/agnostic/html/hyper-json/smart-tags/isolated/ref/index.ts
295
+ var func = (main, _args, { sourceTree }) => {
296
+ const { makeFailure, makeSuccess } = Outcome;
297
+ const { makeTransformationError } = Utils.SmartTags;
298
+ const strMain = Cast.toString(main);
299
+ const resolveFrom = strMain.startsWith("/") ? sourceTree.root : sourceTree;
300
+ const splitted = strMain.split("/").filter((e) => e.trim() !== "").map((e) => {
301
+ const looksLikeNumber = e.match(/^\d+$/igm);
302
+ if (looksLikeNumber === null) return e;
303
+ const parsed = parseInt(e);
304
+ if (Number.isNaN(parsed)) return e;
305
+ return parsed;
306
+ });
307
+ const resolved = resolveFrom.resolve(splitted);
308
+ if (resolved === void 0) return makeFailure(makeTransformationError(`No value was found at path: ${strMain}`));
309
+ if (resolved === sourceTree) return makeFailure(makeTransformationError("A ref node cannot reference itself."));
310
+ if (resolved.parents.includes(sourceTree)) return makeFailure(makeTransformationError("A ref node cannot reference one of its parents."));
311
+ if (sourceTree.parents.includes(resolved)) return makeFailure(makeTransformationError("A ref node cannot reference one of its children."));
312
+ const evaluated = resolved.evaluate();
313
+ const { getType } = Utils.Tree.TypeChecks;
314
+ if (getType(evaluated) === "transformer") {
315
+ const transformer = evaluated;
316
+ return makeSuccess(transformer.toMethod());
317
+ }
318
+ return makeSuccess(evaluated);
319
+ };
320
+ var ref = SmartTags.makeSmartTag({
321
+ name: "ref",
322
+ defaultMode: "isolation",
323
+ isolationInitType: "array",
324
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text"),
325
+ argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
326
+ func
327
+ });
328
+
329
+ // src/agnostic/html/hyper-json/smart-tags/isolated/string/index.ts
330
+ var string = SmartTags.makeSmartTag({
331
+ name: "string",
332
+ defaultMode: "isolation",
333
+ isolationInitType: "string",
334
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "null", "boolean", "number", "string", "text", "element", "nodelist"),
335
+ argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "null", "boolean", "number", "string", "text", "element", "nodelist"),
336
+ func: (main, args) => {
337
+ const all = [main, ...args];
338
+ const reduced = all.reduce((reduced2, curr) => {
339
+ return `${reduced2}${Cast.toString(curr)}`;
340
+ }, "");
341
+ return Outcome.makeSuccess(reduced);
342
+ }
343
+ });
344
+
345
+ // src/agnostic/html/hyper-json/smart-tags/isolated/text/index.ts
346
+ var text = SmartTags.makeSmartTag({
347
+ name: "text",
348
+ defaultMode: "isolation",
349
+ isolationInitType: "text",
350
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "null", "boolean", "number", "string", "text", "element", "nodelist"),
351
+ argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "null", "boolean", "number", "string", "text", "element", "nodelist"),
352
+ func: (main, args) => {
353
+ const all = [main, ...args];
354
+ const reduced = all.reduce((reduced2, curr) => {
355
+ return Cast.toText(`${reduced2}${Cast.toText(curr)}`);
356
+ }, Cast.toText(""));
357
+ return Outcome.makeSuccess(reduced);
358
+ }
359
+ });
360
+
361
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/add/index.ts
362
+ var add = SmartTags.makeSmartTag({
363
+ name: "add",
364
+ defaultMode: "coalescion",
365
+ isolationInitType: "array",
366
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "number", "string", "text"),
367
+ argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "number", "string", "text"),
368
+ func: (main, args) => {
369
+ const numMain = Cast.toNumber(main);
370
+ const numArgs = args.map(Cast.toNumber);
371
+ return Outcome.makeSuccess(numArgs.reduce((reduced, arg) => reduced + arg, numMain));
372
+ }
373
+ });
374
+
375
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/addclass/index.ts
376
+ var addclass = SmartTags.makeSmartTag({
377
+ name: "addclass",
378
+ defaultMode: "coalescion",
379
+ isolationInitType: "array",
380
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "element"),
381
+ argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
382
+ func: (main, args) => {
383
+ main.classList.add(...args.map((arg) => Cast.toString(arg)));
384
+ return Outcome.makeSuccess(main);
385
+ }
386
+ });
387
+
388
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/and/index.ts
389
+ var and = SmartTags.makeSmartTag({
390
+ name: "and",
391
+ defaultMode: "coalescion",
392
+ isolationInitType: "array",
393
+ mainValueCheck: (m) => Outcome.makeSuccess(m),
394
+ argsValueCheck: (a) => Outcome.makeSuccess(a),
395
+ func: (main, args) => {
396
+ const all = [main, ...args];
397
+ const returned = all.every(Cast.toBoolean);
398
+ return Outcome.makeSuccess(returned);
399
+ }
400
+ });
401
+
402
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/append/index.ts
403
+ var append = SmartTags.makeSmartTag({
404
+ name: "append",
405
+ defaultMode: "coalescion",
406
+ isolationInitType: "array",
407
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text", "nodelist", "element", "array"),
408
+ argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text", "nodelist", "element", "array"),
409
+ func: (main, args) => {
410
+ const { makeSuccess } = Outcome;
411
+ const { Text: Text2, Element: Element2, NodeList, document: document2 } = Window.get();
412
+ if (Array.isArray(main)) return makeSuccess([...main, ...args]);
413
+ if (main instanceof Element2) {
414
+ main.append(...Array.from(Cast.toNodeList(args)));
415
+ return makeSuccess(main);
416
+ }
417
+ if (main instanceof NodeList) {
418
+ const frag = document2.createDocumentFragment();
419
+ frag.append(
420
+ ...Array.from(main),
421
+ ...Array.from(Cast.toNodeList(args))
422
+ );
423
+ return makeSuccess(frag.childNodes);
424
+ }
425
+ if (main instanceof Text2) {
426
+ const reducedString = args.reduce((reduced, arg) => {
427
+ return `${reduced}${Cast.toString(arg)}`;
428
+ }, Cast.toString(main));
429
+ return makeSuccess(Cast.toText(reducedString));
430
+ }
431
+ return makeSuccess(args.reduce((reduced, arg) => {
432
+ return `${reduced}${Cast.toString(arg)}`;
433
+ }, main));
434
+ }
435
+ });
436
+
437
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/at/index.ts
438
+ var at = SmartTags.makeSmartTag({
439
+ name: "at",
440
+ defaultMode: "coalescion",
441
+ isolationInitType: "array",
442
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text", "array", "nodelist"),
443
+ argsValueCheck: (a) => {
444
+ const { makeFailure, makeSuccess } = Outcome;
445
+ const { makeArgsValueError } = Utils.SmartTags;
446
+ const { getType, typeCheckMany } = Utils.Tree.TypeChecks;
447
+ if (a.length === 0) return makeFailure(makeArgsValueError("number | string | text", "undefined", 0));
448
+ if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a[1]) ?? "undefined", 1));
449
+ const checked = typeCheckMany(a, "number", "string", "text");
450
+ if (checked.success) return makeSuccess(a);
451
+ return checked;
452
+ },
453
+ func: (main, args) => {
454
+ const { makeFailure, makeSuccess } = Outcome;
455
+ const { makeTransformationError } = Utils.SmartTags;
456
+ const pos = args[0];
457
+ const numPos = Cast.toNumber(pos);
458
+ let found;
459
+ const { NodeList } = Window.get();
460
+ if (typeof main === "string" || Array.isArray(main) || main instanceof NodeList) {
461
+ found = main[numPos];
462
+ } else {
463
+ const strMain = Cast.toString(main);
464
+ found = strMain[numPos];
465
+ }
466
+ if (found === void 0) return makeFailure(makeTransformationError({
467
+ message: "Property does not exist"
468
+ // [WIP] maybe more details here ?
469
+ }));
470
+ return makeSuccess(found);
471
+ }
472
+ });
473
+
474
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/call/index.ts
475
+ var call = SmartTags.makeSmartTag({
476
+ name: "call",
477
+ defaultMode: "coalescion",
478
+ isolationInitType: "array",
479
+ mainValueCheck: (m) => {
480
+ const { makeFailure } = Outcome;
481
+ const { typeCheck, typeCheckMany, getType } = Utils.Tree.TypeChecks;
482
+ const { makeMainValueError } = Utils.SmartTags;
483
+ const isMethodCheck = typeCheck(m, "method");
484
+ if (isMethodCheck.success) return isMethodCheck;
485
+ if (!Array.isArray(m)) return makeFailure({
486
+ expected: "method[]",
487
+ found: getType(m) ?? "undefined"
488
+ });
489
+ const isMethodsArrayCheck = typeCheckMany(m, "method");
490
+ if (isMethodsArrayCheck.success) return isMethodsArrayCheck;
491
+ return makeFailure(makeMainValueError("method | method[]", getType(m) ?? "undefined"));
492
+ },
493
+ argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "array"),
494
+ func: (main, args) => {
495
+ const { makeFailure, makeSuccess } = Outcome;
496
+ const { makeTransformationError } = Utils.SmartTags;
497
+ return makeFailure(makeTransformationError({
498
+ message: "This smart tag should not be used."
499
+ }));
500
+ }
501
+ });
502
+
503
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/clone/index.ts
504
+ var clone = SmartTags.makeSmartTag({
505
+ name: "clone",
506
+ defaultMode: "coalescion",
507
+ isolationInitType: "array",
508
+ mainValueCheck: (m) => Outcome.makeSuccess(m),
509
+ argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
510
+ func: (main) => Outcome.makeSuccess(Utils.clone(main))
511
+ });
512
+
513
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/deleteproperties/index.ts
514
+ var deleteproperties = SmartTags.makeSmartTag({
515
+ name: "deleteproperties",
516
+ defaultMode: "coalescion",
517
+ isolationInitType: "array",
518
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
519
+ argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
520
+ func: (main, args) => {
521
+ const { makeFailure, makeSuccess } = Outcome;
522
+ const { makeTransformationError } = Utils.SmartTags;
523
+ let returned = Utils.clone(main);
524
+ for (const arg of args) {
525
+ const strArg = Cast.toString(arg);
526
+ try {
527
+ returned = deepDeleteProperty(returned, strArg);
528
+ } catch (err) {
529
+ return makeFailure(makeTransformationError(`Cannot access ${strArg} from input record`));
530
+ }
531
+ }
532
+ return makeSuccess(returned);
533
+ }
534
+ });
535
+ function deepDeleteProperty(record2, pathString) {
536
+ const cloned = Utils.clone(record2);
537
+ const pathChunks = pathString.split(".");
538
+ let currentRecord = cloned;
539
+ pathChunks.forEach((chunk, pos) => {
540
+ const isLast = pos === pathChunks.length - 1;
541
+ if (isLast) delete currentRecord[chunk];
542
+ else {
543
+ const found = currentRecord[chunk];
544
+ if (isRecord(found)) currentRecord = found;
545
+ else throw "not a record";
546
+ }
547
+ });
548
+ return cloned;
549
+ }
550
+
551
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/equals/index.ts
552
+ var equals = SmartTags.makeSmartTag({
553
+ name: "equals",
554
+ defaultMode: "coalescion",
555
+ isolationInitType: "array",
556
+ mainValueCheck: (m) => Outcome.makeSuccess(m),
557
+ argsValueCheck: (a) => {
558
+ const [first, ...others] = a;
559
+ if (first === void 0) return Outcome.makeFailure(Utils.SmartTags.makeArgsValueError(
560
+ "value",
561
+ "undefined",
562
+ 0
563
+ ));
564
+ const returned = [first, ...others];
565
+ return Outcome.makeSuccess(returned);
566
+ },
567
+ func: (main, args) => {
568
+ const { Text: Text2 } = Window.get();
569
+ const normalizedMain = main instanceof Text2 ? Cast.toString(main) : main;
570
+ const normalizedArgs = args.map((a) => a instanceof Text2 ? Cast.toString(a) : a);
571
+ return Outcome.makeSuccess(normalizedArgs.every((arg) => arg === normalizedMain));
572
+ }
573
+ });
574
+
575
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/getattribute/index.ts
576
+ var getattribute = SmartTags.makeSmartTag({
577
+ name: "getattribute",
578
+ defaultMode: "coalescion",
579
+ isolationInitType: "array",
580
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "element"),
581
+ argsValueCheck: (a) => {
582
+ const { makeFailure, makeSuccess } = Outcome;
583
+ const { typeCheckMany, getType } = Utils.Tree.TypeChecks;
584
+ const { makeArgsValueError } = Utils.SmartTags;
585
+ if (a.length === 0) return makeFailure(makeArgsValueError("string | Text", "undefined", 0));
586
+ if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a[2]) ?? "undefined", 1));
587
+ const checked = typeCheckMany(a, "string", "text");
588
+ if (checked.success) return makeSuccess(checked.payload);
589
+ return checked;
590
+ },
591
+ func: (main, args) => {
592
+ const name = Cast.toString(args[0]);
593
+ const found = main.getAttribute(name);
594
+ return Outcome.makeSuccess(found);
595
+ }
596
+ });
597
+
598
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/getproperties/index.ts
599
+ var getproperties = SmartTags.makeSmartTag({
600
+ name: "getproperties",
601
+ defaultMode: "coalescion",
602
+ isolationInitType: "array",
603
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
604
+ argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
605
+ func: (main, args) => {
606
+ const reduced = args.reduce((reduced2, curr) => {
607
+ const key = Cast.toString(curr);
608
+ const val = main[key];
609
+ if (val === void 0) return { ...reduced2 };
610
+ return { ...reduced2, [key]: val };
611
+ }, {});
612
+ return Outcome.makeSuccess(reduced);
613
+ }
614
+ });
615
+
616
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/getproperty/index.ts
617
+ var getproperty = SmartTags.makeSmartTag({
618
+ name: "getproperty",
619
+ defaultMode: "coalescion",
620
+ isolationInitType: "array",
621
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
622
+ argsValueCheck: (a) => {
623
+ const { makeFailure, makeSuccess } = Outcome;
624
+ const { makeArgsValueError } = Utils.SmartTags;
625
+ const { getType, typeCheckMany } = Utils.Tree.TypeChecks;
626
+ if (a.length === 0) return makeFailure(makeArgsValueError("string | Text", "undefined", 0));
627
+ if (a.length !== 1) return makeFailure(makeArgsValueError("undefined", getType(a.at(1)) ?? "undefined", 1));
628
+ const checked = typeCheckMany(a, "string", "text");
629
+ if (!checked.success) return checked;
630
+ return makeSuccess(checked.payload);
631
+ },
632
+ func: (main, args) => {
633
+ const { getType } = Utils.Tree.TypeChecks;
634
+ const { makeTransformationError } = Utils.SmartTags;
635
+ const { makeFailure, makeSuccess } = Outcome;
636
+ const [propName] = args;
637
+ const strPropName = Cast.toString(propName);
638
+ try {
639
+ const found = deepGetProperty(main, strPropName);
640
+ const foundType = getType(found);
641
+ if (foundType !== "transformer") return makeSuccess(found);
642
+ return makeFailure(makeTransformationError(`Forbidden access to key: '${strPropName}'`));
643
+ } catch (err) {
644
+ return makeFailure(makeTransformationError(`Impossible to access ${strPropName}`));
645
+ }
646
+ }
647
+ });
648
+ function deepGetProperty(record2, pathString) {
649
+ const pathChunks = pathString.split(".").map((e) => e.trim()).filter((e) => e !== "");
650
+ let currentRecord = record2;
651
+ let returned = currentRecord;
652
+ pathChunks.forEach((chunk, pos) => {
653
+ const isLast = pos === pathChunks.length - 1;
654
+ if (isLast) {
655
+ const val = currentRecord[chunk];
656
+ if (val === void 0) throw "PROP_UNDEFINED";
657
+ returned = val;
658
+ } else {
659
+ const found = currentRecord[chunk];
660
+ if (isRecord(found)) currentRecord = found;
661
+ else throw "NOT_A_RECORD";
662
+ }
663
+ });
664
+ return returned;
665
+ }
666
+
667
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/if/index.ts
668
+ var ifFunc = SmartTags.makeSmartTag({
669
+ name: "if",
670
+ defaultMode: "coalescion",
671
+ isolationInitType: "array",
672
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "boolean"),
673
+ argsValueCheck: (a) => {
674
+ const { makeFailure, makeSuccess } = Outcome;
675
+ const { makeArgsValueError } = Utils.SmartTags;
676
+ if (a.length > 2) return makeFailure(makeArgsValueError("value", "undefined", a.length));
677
+ if (a.length < 2) return makeFailure(makeArgsValueError("undefined", "value", 2));
678
+ return makeSuccess(a);
679
+ },
680
+ func: (main, args) => {
681
+ const [then, otherwise] = args;
682
+ return Outcome.makeSuccess(main ? then : otherwise);
683
+ }
684
+ });
685
+
686
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/initialize/index.ts
687
+ var initialize = SmartTags.makeSmartTag({
688
+ name: "initialize",
689
+ defaultMode: "coalescion",
690
+ isolationInitType: "array",
691
+ mainValueCheck: (m) => Outcome.makeSuccess(m),
692
+ argsValueCheck: (a) => {
693
+ const { makeFailure, makeSuccess } = Outcome;
694
+ const { getType, typeCheck } = Utils.Tree.TypeChecks;
695
+ const { makeArgsValueError } = Utils.SmartTags;
696
+ const first = a[0];
697
+ if (first === void 0) return makeFailure(makeArgsValueError("string | text", "undefined", 0));
698
+ if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a[1]) ?? "undefined", 1));
699
+ const firstChecked = typeCheck(first, "string", "text");
700
+ if (!firstChecked.success) return makeFailure(makeArgsValueError(firstChecked.error.expected, firstChecked.error.found, 0));
701
+ return makeSuccess(a);
702
+ },
703
+ func: (_main, args) => {
704
+ const { makeFailure, makeSuccess } = Outcome;
705
+ const { makeTransformationError } = Utils.SmartTags;
706
+ const { getInitialValueFromTypeName } = Utils.Tree;
707
+ const { isValueTypeName } = Utils.Tree.TypeChecks;
708
+ const firstArg = args[0];
709
+ const strFirstArg = Cast.toString(firstArg).trim().toLowerCase();
710
+ const isValueType = isValueTypeName(strFirstArg);
711
+ if (!isValueType || strFirstArg === "transformer" || strFirstArg === "method") return makeFailure(makeTransformationError(`${strFirstArg} is not a valid type`));
712
+ const initialized = getInitialValueFromTypeName(strFirstArg);
713
+ return makeSuccess(initialized);
714
+ }
715
+ });
716
+
717
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/join/index.ts
718
+ var join = SmartTags.makeSmartTag({
719
+ name: "join",
720
+ defaultMode: "coalescion",
721
+ isolationInitType: "array",
722
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "array", "nodelist"),
723
+ argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
724
+ func: (main, args) => {
725
+ const { makeSuccess } = Outcome;
726
+ const joiner = Cast.toString(args);
727
+ if (Array.isArray(main)) return makeSuccess(main.map(Cast.toString).join(joiner));
728
+ return makeSuccess(Array.from(main).map(Cast.toString).join(joiner));
729
+ }
730
+ });
731
+
732
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/length/index.ts
733
+ var length = SmartTags.makeSmartTag({
734
+ name: "length",
735
+ defaultMode: "coalescion",
736
+ isolationInitType: "array",
737
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "nodelist"),
738
+ argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
739
+ func: (main) => {
740
+ const { makeSuccess } = Outcome;
741
+ const { Text: Text2, NodeList, Element: Element2 } = Window.get();
742
+ if (typeof main === "string" || main instanceof NodeList || main instanceof Text2 || Array.isArray(main)) return makeSuccess(main.length);
743
+ if (main instanceof Element2) return makeSuccess(main.childNodes.length);
744
+ return makeSuccess(Object.keys(main).length);
745
+ }
746
+ });
747
+
748
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/map/index.ts
749
+ var map = SmartTags.makeSmartTag({
750
+ name: "map",
751
+ defaultMode: "coalescion",
752
+ isolationInitType: "array",
753
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "array"),
754
+ argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "method"),
755
+ func: (main, args) => {
756
+ const { makeTransformationError } = Utils.SmartTags;
757
+ let mapped = [];
758
+ for (const val of main) {
759
+ let reduced = val;
760
+ for (const arg of args) {
761
+ const { transformer } = arg;
762
+ const applied = transformer.apply(reduced);
763
+ if (!applied.success) return Outcome.makeFailure(makeTransformationError({
764
+ message: "Subtransformation failure.",
765
+ onTransformed: reduced,
766
+ transformerAt: args.indexOf(arg),
767
+ transformerName: transformer.name,
768
+ transformerInput: reduced,
769
+ transformerOutput: applied
770
+ }));
771
+ reduced = applied.payload;
772
+ }
773
+ mapped.push(reduced);
774
+ }
775
+ return Outcome.makeSuccess(mapped);
776
+ }
777
+ });
778
+
779
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/negate/index.ts
780
+ var negate = SmartTags.makeSmartTag({
781
+ name: "negate",
782
+ defaultMode: "coalescion",
783
+ isolationInitType: "array",
784
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "boolean"),
785
+ argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
786
+ func: (main) => Outcome.makeSuccess(!main)
787
+ });
788
+
789
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/notrailing/index.ts
790
+ var notrailing = SmartTags.makeSmartTag({
791
+ name: "notrailing",
792
+ defaultMode: "coalescion",
793
+ isolationInitType: "array",
794
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text"),
795
+ argsValueCheck: (a) => {
796
+ const { makeSuccess, makeFailure } = Outcome;
797
+ const { makeArgsValueError } = Utils.SmartTags;
798
+ const { getType, typeCheck } = Utils.Tree.TypeChecks;
799
+ if (a.length === 0) return makeSuccess([]);
800
+ if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a[1]) ?? "undefined", 1));
801
+ const [first] = a;
802
+ const firstChecked = typeCheck(first, "string", "text");
803
+ if (!firstChecked.success) return makeFailure(makeArgsValueError(
804
+ firstChecked.error.expected,
805
+ firstChecked.error.found,
806
+ 0
807
+ ));
808
+ return makeSuccess([firstChecked.payload]);
809
+ },
810
+ func: (main, args) => {
811
+ const strMain = Cast.toString(main);
812
+ const firstArg = args[0];
813
+ const strFirstArg = Cast.toString(firstArg ?? "/");
814
+ let strOutput = strMain;
815
+ while (strOutput.endsWith(strFirstArg)) strOutput = strOutput.slice(0, -1);
816
+ if (typeof main === "string") return Outcome.makeSuccess(strOutput);
817
+ return Outcome.makeSuccess(Cast.toText(strOutput));
818
+ }
819
+ });
820
+
821
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/or/index.ts
822
+ var or = SmartTags.makeSmartTag({
823
+ name: "or",
824
+ defaultMode: "coalescion",
825
+ isolationInitType: "array",
826
+ mainValueCheck: (m) => Outcome.makeSuccess(m),
827
+ argsValueCheck: (a) => Outcome.makeSuccess(a),
828
+ func: (main, args) => {
829
+ const all = [main, ...args];
830
+ const returned = all.some(Cast.toBoolean);
831
+ return Outcome.makeSuccess(returned);
832
+ }
833
+ });
834
+
835
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/pickrandom/index.ts
836
+ var pickrandom = SmartTags.makeSmartTag({
837
+ name: "pickrandom",
838
+ defaultMode: "coalescion",
839
+ isolationInitType: "array",
840
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "array"),
841
+ argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
842
+ func: (main) => {
843
+ const { makeSuccess, makeFailure } = Outcome;
844
+ const { makeTransformationError } = Utils.SmartTags;
845
+ const pos = Math.floor(Math.random() * main.length);
846
+ const found = main[pos];
847
+ if (found === void 0) return makeFailure(makeTransformationError("Cannot pick inside empty array"));
848
+ return makeSuccess(found);
849
+ }
850
+ });
851
+
852
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/print/index.ts
853
+ var print = SmartTags.makeSmartTag({
854
+ name: "print",
855
+ defaultMode: "coalescion",
856
+ isolationInitType: "array",
857
+ mainValueCheck: (m) => {
858
+ const { getType } = Utils.Tree.TypeChecks;
859
+ const { makeSuccess, makeFailure } = Outcome;
860
+ const { makeMainValueError } = Utils.SmartTags;
861
+ return getType(m) === "transformer" ? makeFailure(makeMainValueError("Exclude<value, transformer>", "transformer")) : makeSuccess(m);
862
+ },
863
+ argsValueCheck: (a) => Outcome.makeSuccess(a),
864
+ func: (main, args, details) => {
865
+ console.group("print");
866
+ console.log("Main:", main);
867
+ console.log("Args:", ...args);
868
+ console.log("Tree:", details.sourceTree);
869
+ console.groupEnd();
870
+ return Outcome.makeSuccess(main);
871
+ }
872
+ });
873
+
874
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/populate/index.ts
875
+ var populate = SmartTags.makeSmartTag({
876
+ name: "populate",
877
+ defaultMode: "coalescion",
878
+ isolationInitType: "array",
879
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
880
+ argsValueCheck: (a) => {
881
+ const [first, ...others] = a;
882
+ const { makeFailure, makeSuccess } = Outcome;
883
+ const { makeArgsValueError } = Utils.SmartTags;
884
+ const { typeCheck, typeCheckMany, getType } = Utils.Tree.TypeChecks;
885
+ const firstChecked = typeCheck(first, "string", "text", "nodelist", "element");
886
+ if (!firstChecked.success) return makeFailure(makeArgsValueError(
887
+ firstChecked.error.expected,
888
+ firstChecked.error.found,
889
+ 0
890
+ ));
891
+ const othersChecked = typeCheckMany(others, "array");
892
+ if (!othersChecked.success) return makeFailure(makeArgsValueError(
893
+ othersChecked.error.expected,
894
+ othersChecked.error.found,
895
+ othersChecked.error.position + 1
896
+ ));
897
+ for (const [argPos, arg] of Object.entries(othersChecked.payload)) {
898
+ const argPosNum = parseInt(argPos);
899
+ const [first2, second] = arg;
900
+ const firstChecked2 = typeCheck(first2, "string", "text");
901
+ const secondChecked = typeCheck(second, "string", "text");
902
+ if (!firstChecked2.success || !secondChecked.success) return makeFailure(makeArgsValueError(
903
+ "[string | Text, string | Text]",
904
+ `[${getType(first2)}, ${getType(second)}]`,
905
+ argPosNum + 1
906
+ ));
907
+ }
908
+ return makeSuccess(a);
909
+ },
910
+ func: (main, args) => {
911
+ const { makeSuccess, makeFailure } = Outcome;
912
+ const { makeTransformationError } = Utils.SmartTags;
913
+ const record2 = main;
914
+ const [template, ...actions] = args;
915
+ let returnedStr = Cast.toString(template);
916
+ for (const [propName, toReplace] of actions) {
917
+ try {
918
+ const value = deepGetProperty(record2, Cast.toString(propName));
919
+ const replaced = replaceAll(returnedStr, Cast.toString(toReplace), Cast.toString(value));
920
+ returnedStr = replaced;
921
+ } catch (err) {
922
+ return makeFailure(makeTransformationError({
923
+ message: "Something went wrong",
924
+ subTransformerError: err
925
+ }));
926
+ }
927
+ }
928
+ const { Text: Text2, NodeList } = Window.get();
929
+ if (typeof template === "string") return makeSuccess(returnedStr);
930
+ if (template instanceof Text2) return makeSuccess(Cast.toText(returnedStr));
931
+ if (template instanceof NodeList) return makeSuccess(Cast.toNodeList(returnedStr));
932
+ return makeSuccess(Cast.toElement(returnedStr));
933
+ }
934
+ });
935
+
936
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/push/index.ts
937
+ var push = SmartTags.makeSmartTag({
938
+ name: "push",
939
+ defaultMode: "coalescion",
940
+ isolationInitType: "array",
941
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "array"),
942
+ argsValueCheck: (a) => Outcome.makeSuccess(a),
943
+ func: (main, args) => Outcome.makeSuccess([...main, ...args])
944
+ });
945
+
946
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/pusheach/index.ts
947
+ var pusheach = SmartTags.makeSmartTag({
948
+ name: "pusheach",
949
+ defaultMode: "coalescion",
950
+ isolationInitType: "array",
951
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "array"),
952
+ argsValueCheck: (a) => {
953
+ const { makeSuccess, makeFailure } = Outcome;
954
+ const { typeCheck } = Utils.Tree.TypeChecks;
955
+ const { makeArgsValueError } = Utils.SmartTags;
956
+ for (const [argPos, arg] of Object.entries(a)) {
957
+ const numPos = parseInt(argPos);
958
+ const checked = typeCheck(arg, "array");
959
+ if (!checked.success) return makeFailure(makeArgsValueError(
960
+ checked.error.expected,
961
+ checked.error.found,
962
+ numPos
963
+ ));
964
+ }
965
+ return makeSuccess(a);
966
+ },
967
+ func: (main, args) => {
968
+ const returned = [...main];
969
+ for (const arg of args) {
970
+ returned.push(...arg);
971
+ }
972
+ return Outcome.makeSuccess(returned);
973
+ }
974
+ });
975
+
976
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/recordtoarray/index.ts
977
+ var recordtoarray = SmartTags.makeSmartTag({
978
+ name: "recordtoarray",
979
+ defaultMode: "coalescion",
980
+ isolationInitType: "array",
981
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
982
+ argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
983
+ func: (main) => Outcome.makeSuccess(Object.values(main))
984
+ });
985
+
986
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/removeattribute/index.ts
987
+ var removeattribute = SmartTags.makeSmartTag({
988
+ name: "removeattribute",
989
+ defaultMode: "coalescion",
990
+ isolationInitType: "array",
991
+ mainValueCheck: (m) => {
992
+ const { typeCheck, typeCheckMany } = Utils.Tree.TypeChecks;
993
+ if (Array.isArray(m)) return typeCheckMany(m, "element");
994
+ return typeCheck(m, "element");
995
+ },
996
+ argsValueCheck: (a) => {
997
+ const { makeFailure, makeSuccess } = Outcome;
998
+ const { typeCheckMany, getType } = Utils.Tree.TypeChecks;
999
+ const { makeArgsValueError } = Utils.SmartTags;
1000
+ if (a.length === 0) return makeFailure(makeArgsValueError("string | Text", "undefined", 0));
1001
+ if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a[2]) ?? "undefined", 1));
1002
+ const checked = typeCheckMany(a, "string", "text");
1003
+ if (checked.success) return makeSuccess(checked.payload);
1004
+ return checked;
1005
+ },
1006
+ func: (main, args) => {
1007
+ const { makeSuccess } = Outcome;
1008
+ const mainArr = Array.isArray(main) ? main : [main];
1009
+ const mainArrCloned = mainArr.map((e) => Utils.clone(e));
1010
+ const name = Cast.toString(args[0]);
1011
+ mainArrCloned.forEach((e) => e.removeAttribute(name));
1012
+ if (Array.isArray(main)) return makeSuccess(mainArrCloned);
1013
+ return makeSuccess(mainArrCloned[0]);
1014
+ }
1015
+ });
1016
+
1017
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/removeclass/index.ts
1018
+ var removeclass = SmartTags.makeSmartTag({
1019
+ name: "removeclass",
1020
+ defaultMode: "coalescion",
1021
+ isolationInitType: "array",
1022
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "element"),
1023
+ argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
1024
+ func: (main, args) => {
1025
+ main.classList.remove(...args.map((arg) => Cast.toString(arg)));
1026
+ return Outcome.makeSuccess(main);
1027
+ }
1028
+ });
1029
+
1030
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/renameproperty/index.ts
1031
+ var renameproperty = SmartTags.makeSmartTag({
1032
+ name: "renameproperty",
1033
+ defaultMode: "coalescion",
1034
+ isolationInitType: "array",
1035
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
1036
+ argsValueCheck: (a) => {
1037
+ const { makeFailure, makeSuccess } = Outcome;
1038
+ const { typeCheck, typeCheckMany } = Utils.Tree.TypeChecks;
1039
+ const checked = typeCheckMany(a, "string", "text");
1040
+ if (!checked.success) return checked;
1041
+ const [first, second] = a;
1042
+ const firstChecked = typeCheck(first, "string", "text");
1043
+ if (!firstChecked.success) return makeFailure(Utils.SmartTags.makeArgsValueError(
1044
+ firstChecked.error.expected,
1045
+ firstChecked.error.found,
1046
+ 0
1047
+ ));
1048
+ const secondChecked = typeCheck(second, "string", "text");
1049
+ if (!secondChecked.success) return makeFailure(Utils.SmartTags.makeArgsValueError(
1050
+ secondChecked.error.expected,
1051
+ secondChecked.error.found,
1052
+ 0
1053
+ ));
1054
+ return makeSuccess([firstChecked.payload, secondChecked.payload]);
1055
+ },
1056
+ func: (main, args) => {
1057
+ const [oldKey, newKey] = args.map(Cast.toString);
1058
+ const returned = {};
1059
+ Object.entries(main).forEach(([key, value]) => {
1060
+ const targetKey = key === oldKey ? newKey : key;
1061
+ returned[targetKey] = value;
1062
+ });
1063
+ return Outcome.makeSuccess(returned);
1064
+ }
1065
+ });
1066
+
1067
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/replace/index.ts
1068
+ var replace = SmartTags.makeSmartTag({
1069
+ name: "replace",
1070
+ defaultMode: "coalescion",
1071
+ isolationInitType: "array",
1072
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text", "nodelist", "element"),
1073
+ argsValueCheck: (a) => {
1074
+ const { makeFailure, makeSuccess } = Outcome;
1075
+ const { getType, typeCheckMany } = Utils.Tree.TypeChecks;
1076
+ const { makeArgsValueError } = Utils.SmartTags;
1077
+ const expectedStr = "string | Text | NodeListOf<Element | Text> | Element";
1078
+ if (a.length === 0) return makeFailure(makeArgsValueError(expectedStr, "undefined", 0));
1079
+ if (a.length === 1) return makeFailure(makeArgsValueError(expectedStr, "undefined", 1));
1080
+ if (a.length > 2) return makeFailure(makeArgsValueError("undefined", getType(a.at(2)) ?? "undefined", 3));
1081
+ const checked = typeCheckMany(a, "string", "text", "nodelist", "element");
1082
+ if (!checked.success) return checked;
1083
+ return makeSuccess(checked.payload);
1084
+ },
1085
+ func: (main, args) => {
1086
+ const [toReplace, replacer] = args;
1087
+ const strMain = Cast.toString(main);
1088
+ const strToReplace = Cast.toString(toReplace);
1089
+ const strReplacer = Cast.toString(replacer);
1090
+ const strReplaced = replaceAll(strMain, strToReplace, strReplacer);
1091
+ let returned;
1092
+ if (typeof main === "string") {
1093
+ returned = strReplaced;
1094
+ } else if (main instanceof Text) {
1095
+ returned = Cast.toText(strReplaced);
1096
+ } else if (main instanceof Element) {
1097
+ returned = Cast.toElement(strReplaced);
1098
+ } else {
1099
+ returned = Cast.toNodeList(strReplaced);
1100
+ }
1101
+ return Outcome.makeSuccess(returned);
1102
+ }
1103
+ });
1104
+
1105
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/select/index.ts
1106
+ var select = SmartTags.makeSmartTag({
1107
+ name: "select",
1108
+ defaultMode: "coalescion",
1109
+ isolationInitType: "array",
1110
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "nodelist", "element"),
1111
+ argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
1112
+ func: (main, args) => {
1113
+ const selectedFragment = document.createDocumentFragment();
1114
+ if (main instanceof Window.get().Element) {
1115
+ for (const arg of args) {
1116
+ const selector = Cast.toString(arg);
1117
+ const found = main.querySelectorAll(selector);
1118
+ selectedFragment.append(...Array.from(found));
1119
+ }
1120
+ } else {
1121
+ const divWrapper = Window.get().document.createElement("div");
1122
+ divWrapper.append(...Array.from(main));
1123
+ for (const arg of args) {
1124
+ const selector = Cast.toString(arg);
1125
+ const found = divWrapper.querySelectorAll(selector);
1126
+ selectedFragment.append(...Array.from(found));
1127
+ }
1128
+ }
1129
+ const selected = selectedFragment.childNodes;
1130
+ return Outcome.makeSuccess(selected);
1131
+ }
1132
+ });
1133
+
1134
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/set/index.ts
1135
+ var set = SmartTags.makeSmartTag({
1136
+ name: "set",
1137
+ defaultMode: "coalescion",
1138
+ isolationInitType: "array",
1139
+ mainValueCheck: (m) => Outcome.makeSuccess(m),
1140
+ argsValueCheck: (a) => {
1141
+ const { makeFailure, makeSuccess } = Outcome;
1142
+ const { makeArgsValueError } = Utils.SmartTags;
1143
+ const { getType, typeCheck } = Utils.Tree.TypeChecks;
1144
+ const first = a[0];
1145
+ if (first === void 0) return makeFailure(makeArgsValueError("string | text", "undefined", 0));
1146
+ if (a.length > 2) return makeFailure(makeArgsValueError("undefined", getType(a[2]) ?? "undefined", 2));
1147
+ const firstChecked = typeCheck(first, "string", "text");
1148
+ if (!firstChecked.success) return firstChecked;
1149
+ else return makeSuccess(a);
1150
+ },
1151
+ func: (main, args, { sourceTree }) => {
1152
+ const [first, second] = args;
1153
+ const strFirst = Cast.toString(first);
1154
+ sourceTree.setVariable(strFirst, second === void 0 ? main : second);
1155
+ return Outcome.makeSuccess(main);
1156
+ }
1157
+ });
1158
+
1159
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/setattribute/index.ts
1160
+ var setattribute = SmartTags.makeSmartTag({
1161
+ name: "setattribute",
1162
+ defaultMode: "coalescion",
1163
+ isolationInitType: "array",
1164
+ mainValueCheck: (m) => {
1165
+ const { typeCheck, typeCheckMany } = Utils.Tree.TypeChecks;
1166
+ if (Array.isArray(m)) return typeCheckMany(m, "element");
1167
+ return typeCheck(m, "element");
1168
+ },
1169
+ argsValueCheck: (a) => {
1170
+ const { makeFailure, makeSuccess } = Outcome;
1171
+ const { typeCheckMany, getType } = Utils.Tree.TypeChecks;
1172
+ const { makeArgsValueError } = Utils.SmartTags;
1173
+ if (a.length === 0) return makeFailure(makeArgsValueError("string | Text", "undefined", 0));
1174
+ if (a.length > 2) return makeFailure(makeArgsValueError("undefined", getType(a[2]) ?? "undefined", 2));
1175
+ const checked = typeCheckMany(a, "string", "text");
1176
+ if (checked.success) return makeSuccess(checked.payload);
1177
+ return checked;
1178
+ },
1179
+ func: (main, args) => {
1180
+ const mainArr = Array.isArray(main) ? main : [main];
1181
+ const mainArrCloned = mainArr.map((e) => Utils.clone(e));
1182
+ const argsStr = args.map((e) => Cast.toString(e));
1183
+ const [name, value = ""] = argsStr;
1184
+ mainArrCloned.forEach((e) => e.setAttribute(name, value));
1185
+ if (Array.isArray(main)) return Outcome.makeSuccess(mainArrCloned);
1186
+ return Outcome.makeSuccess(mainArrCloned[0]);
1187
+ }
1188
+ });
1189
+
1190
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/setproperty/index.ts
1191
+ var setproperty = SmartTags.makeSmartTag({
1192
+ name: "setproperty",
1193
+ defaultMode: "coalescion",
1194
+ isolationInitType: "array",
1195
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
1196
+ argsValueCheck: (a) => {
1197
+ const { makeFailure, makeSuccess } = Outcome;
1198
+ const { makeArgsValueError } = Utils.SmartTags;
1199
+ const { getType, typeCheck } = Utils.Tree.TypeChecks;
1200
+ if (a.length === 0) return makeFailure(makeArgsValueError("string | Text", "undefined", 0));
1201
+ if (a.length === 1) return makeFailure(makeArgsValueError("value", "undefined", 1));
1202
+ if (a.length !== 2) return makeFailure(makeArgsValueError("undefined", getType(a.at(2)) ?? "undefined", 2));
1203
+ const [first, second] = a;
1204
+ const firstChecked = typeCheck(first, "string", "text");
1205
+ if (!firstChecked.success) return makeFailure(makeArgsValueError(firstChecked.error.expected, firstChecked.error.found, 0));
1206
+ return makeSuccess([firstChecked.payload, second]);
1207
+ },
1208
+ func: (main, args) => {
1209
+ const [key, val] = args;
1210
+ const { makeSuccess, makeFailure } = Outcome;
1211
+ const { makeTransformationError } = Utils.SmartTags;
1212
+ try {
1213
+ const withPropertySet = deepSetProperty(
1214
+ Utils.clone(main),
1215
+ Cast.toString(key),
1216
+ val
1217
+ );
1218
+ return makeSuccess(withPropertySet);
1219
+ } catch (err) {
1220
+ return makeFailure(makeTransformationError(`Impossible to access property :${key}`));
1221
+ }
1222
+ }
1223
+ });
1224
+ function deepSetProperty(record2, pathString, value) {
1225
+ const pathChunks = pathString.split(".");
1226
+ const clone2 = Utils.clone(record2);
1227
+ let currentRecord = clone2;
1228
+ pathChunks.forEach((chunk, pos) => {
1229
+ const isLast = pos === pathChunks.length - 1;
1230
+ if (isLast) {
1231
+ currentRecord[chunk] = value;
1232
+ } else {
1233
+ const found = currentRecord[chunk];
1234
+ if (isRecord(found)) currentRecord = found;
1235
+ else throw "NOT_A_RECORD";
1236
+ }
1237
+ });
1238
+ return clone2;
1239
+ }
1240
+
1241
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/sorton/index.ts
1242
+ var sorton = SmartTags.makeSmartTag({
1243
+ name: "sorton",
1244
+ defaultMode: "coalescion",
1245
+ isolationInitType: "array",
1246
+ mainValueCheck: (m) => {
1247
+ const { makeMainValueError } = Utils.SmartTags;
1248
+ const { getType } = Utils.Tree.TypeChecks;
1249
+ const { makeFailure, makeSuccess } = Outcome;
1250
+ if (!Array.isArray(m)) return makeFailure(makeMainValueError("array<record>", getType(m) ?? "undefined"));
1251
+ for (const [itemPos, itemVal] of Object.entries(m)) {
1252
+ if (isRecord(itemVal)) continue;
1253
+ return makeFailure(makeMainValueError("record", getType(itemVal), `At position ${parseInt(itemPos)} in main value`));
1254
+ }
1255
+ return makeSuccess(m);
1256
+ },
1257
+ argsValueCheck: (a) => {
1258
+ const { makeFailure, makeSuccess } = Outcome;
1259
+ const { makeArgsValueError } = Utils.SmartTags;
1260
+ const { getType, typeCheckMany } = Utils.Tree.TypeChecks;
1261
+ if (a.length === 0) return makeFailure(makeArgsValueError("[string | text]", "[]", 0));
1262
+ if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a[1]) ?? "undefined", 2));
1263
+ const checked = typeCheckMany(a, "string", "text");
1264
+ if (checked.success) return makeSuccess(checked.payload);
1265
+ return checked;
1266
+ },
1267
+ func: (main, args) => {
1268
+ const { makeFailure, makeSuccess } = Outcome;
1269
+ const strPropName = Cast.toString(args[0]);
1270
+ const { getType } = Utils.Tree.TypeChecks;
1271
+ const { makeTransformationError } = Utils.SmartTags;
1272
+ const map2 = main.map((record2) => {
1273
+ const prop = record2[strPropName];
1274
+ const type = getType(prop);
1275
+ return { record: record2, prop, type };
1276
+ });
1277
+ const firstItem = map2[0];
1278
+ if (firstItem === void 0) return makeSuccess([]);
1279
+ const firstItemType = firstItem.type;
1280
+ if (firstItemType === void 0) return makeFailure(makeTransformationError({
1281
+ message: "Invalid property type",
1282
+ onItem: 0,
1283
+ found: firstItemType
1284
+ }));
1285
+ for (const [daytumPos, daytumVal] of Object.entries(map2)) {
1286
+ if (daytumVal.type !== firstItemType) return makeFailure(makeTransformationError({
1287
+ message: "Invalid property type",
1288
+ onItem: parseInt(daytumPos),
1289
+ expected: firstItemType,
1290
+ found: daytumVal.type
1291
+ }));
1292
+ }
1293
+ const sorted = main.sort((a, b) => {
1294
+ const { Text: Text2, NodeList } = Window.get();
1295
+ const aProp = a[strPropName];
1296
+ const bProp = b[strPropName];
1297
+ if (aProp === null) return 0;
1298
+ if (typeof aProp === "boolean") {
1299
+ if (aProp === bProp) return 0;
1300
+ if (aProp) return 1;
1301
+ return -1;
1302
+ }
1303
+ if (typeof aProp === "string") return aProp.localeCompare(Cast.toString(bProp));
1304
+ if (aProp instanceof Text2) return Cast.toString(aProp).localeCompare(Cast.toString(bProp));
1305
+ if (typeof aProp === "number") return aProp - Cast.toNumber(bProp);
1306
+ if (Array.isArray(aProp)) return aProp.length - Cast.toArray(bProp).length;
1307
+ if (aProp instanceof NodeList) return aProp.length - Cast.toNodeList(bProp).length;
1308
+ return 0;
1309
+ });
1310
+ return makeSuccess(sorted);
1311
+ }
1312
+ });
1313
+
1314
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/split/index.ts
1315
+ var split = SmartTags.makeSmartTag({
1316
+ name: "split",
1317
+ defaultMode: "coalescion",
1318
+ isolationInitType: "array",
1319
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text"),
1320
+ argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
1321
+ func: (main, args) => {
1322
+ let strReturnedArr = [Cast.toString(main)];
1323
+ for (const arg of args) {
1324
+ strReturnedArr = strReturnedArr.map((e) => e.split(Cast.toString(arg))).flat();
1325
+ }
1326
+ if (typeof main === "string") return Outcome.makeSuccess(strReturnedArr);
1327
+ return Outcome.makeSuccess(strReturnedArr.map(Cast.toText));
1328
+ }
1329
+ });
1330
+
1331
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/spread/index.ts
1332
+ var spread = SmartTags.makeSmartTag({
1333
+ name: "spread",
1334
+ defaultMode: "coalescion",
1335
+ isolationInitType: "array",
1336
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
1337
+ argsValueCheck: (a) => {
1338
+ const { makeFailure, makeSuccess } = Outcome;
1339
+ const { makeArgsValueError } = Utils.SmartTags;
1340
+ const { getType, typeCheck } = Utils.Tree.TypeChecks;
1341
+ if (a.length === 0) return makeFailure(makeArgsValueError("record", "undefined", 0));
1342
+ if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a.at(1)) ?? "undefined", 1));
1343
+ const [first] = a;
1344
+ const firstChecked = typeCheck(first, "record");
1345
+ if (!firstChecked.success) return makeFailure(makeArgsValueError(firstChecked.error.expected, firstChecked.error.found, 0));
1346
+ return makeSuccess([firstChecked.payload]);
1347
+ },
1348
+ func: (main, args) => Outcome.makeSuccess({ ...main, ...args[0] })
1349
+ });
1350
+
1351
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/toarray/index.ts
1352
+ var toarray = SmartTags.makeSmartTag({
1353
+ name: "toarray",
1354
+ defaultMode: "coalescion",
1355
+ isolationInitType: "array",
1356
+ mainValueCheck: (m) => Outcome.makeSuccess(m),
1357
+ argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1358
+ func: (main) => Outcome.makeSuccess(Cast.toArray(main))
1359
+ });
1360
+
1361
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/toboolean/index.ts
1362
+ var toboolean = SmartTags.makeSmartTag({
1363
+ name: "toboolean",
1364
+ defaultMode: "coalescion",
1365
+ isolationInitType: "array",
1366
+ mainValueCheck: (m) => Outcome.makeSuccess(m),
1367
+ argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1368
+ func: (m) => Outcome.makeSuccess(Cast.toBoolean(m))
1369
+ });
1370
+
1371
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/toelement/index.ts
1372
+ var toelement = SmartTags.makeSmartTag({
1373
+ name: "toelement",
1374
+ defaultMode: "coalescion",
1375
+ isolationInitType: "array",
1376
+ mainValueCheck: (m) => Outcome.makeSuccess(m),
1377
+ argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1378
+ func: (m) => Outcome.makeSuccess(Cast.toElement(m))
1379
+ });
1380
+
1381
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/toggleclass/index.ts
1382
+ var toggleclass = SmartTags.makeSmartTag({
1383
+ name: "toggleclass",
1384
+ defaultMode: "coalescion",
1385
+ isolationInitType: "array",
1386
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "element"),
1387
+ argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
1388
+ func: (main, args) => {
1389
+ for (const arg of args) main.classList.toggle(Cast.toString(arg));
1390
+ return Outcome.makeSuccess(main);
1391
+ }
1392
+ });
1393
+
1394
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/tonodelist/index.ts
1395
+ var tonodelist = SmartTags.makeSmartTag({
1396
+ name: "tonodelist",
1397
+ defaultMode: "coalescion",
1398
+ isolationInitType: "array",
1399
+ mainValueCheck: (m) => Outcome.makeSuccess(m),
1400
+ argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1401
+ func: (m) => Outcome.makeSuccess(Cast.toNodeList(m))
1402
+ });
1403
+
1404
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/tonull/index.ts
1405
+ var tonull = SmartTags.makeSmartTag({
1406
+ name: "tonull",
1407
+ defaultMode: "coalescion",
1408
+ isolationInitType: "array",
1409
+ mainValueCheck: (m) => Outcome.makeSuccess(m),
1410
+ argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1411
+ func: () => Outcome.makeSuccess(null)
1412
+ });
1413
+
1414
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/tonumber/index.ts
1415
+ var tonumber = SmartTags.makeSmartTag({
1416
+ name: "tonumber",
1417
+ defaultMode: "coalescion",
1418
+ isolationInitType: "array",
1419
+ mainValueCheck: (m) => Outcome.makeSuccess(m),
1420
+ argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1421
+ func: (m) => Outcome.makeSuccess(Cast.toNumber(m))
1422
+ });
1423
+
1424
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/torecord/index.ts
1425
+ var torecord = SmartTags.makeSmartTag({
1426
+ name: "torecord",
1427
+ defaultMode: "coalescion",
1428
+ isolationInitType: "array",
1429
+ mainValueCheck: (m) => Outcome.makeSuccess(m),
1430
+ argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1431
+ func: (main) => Outcome.makeSuccess(Cast.toRecord(main))
1432
+ });
1433
+
1434
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/toref/index.ts
1435
+ var toref = SmartTags.makeSmartTag({
1436
+ name: "toref",
1437
+ defaultMode: "coalescion",
1438
+ isolationInitType: "array",
1439
+ mainValueCheck: (m) => Outcome.makeSuccess(m),
1440
+ argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1441
+ func: (main, args, details) => func(Cast.toString(main), args, details)
1442
+ });
1443
+
1444
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/tostring/index.ts
1445
+ var tostring = SmartTags.makeSmartTag({
1446
+ name: "tostring",
1447
+ defaultMode: "coalescion",
1448
+ isolationInitType: "array",
1449
+ mainValueCheck: (m) => Outcome.makeSuccess(m),
1450
+ argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1451
+ func: (m) => Outcome.makeSuccess(Cast.toString(m))
1452
+ });
1453
+
1454
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/totext/index.ts
1455
+ var totext = SmartTags.makeSmartTag({
1456
+ name: "totext",
1457
+ defaultMode: "coalescion",
1458
+ isolationInitType: "array",
1459
+ mainValueCheck: (m) => Outcome.makeSuccess(m),
1460
+ argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1461
+ func: (m) => Outcome.makeSuccess(Cast.toText(m))
1462
+ });
1463
+
1464
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/transformselected/index.ts
1465
+ var transformselected = SmartTags.makeSmartTag({
1466
+ name: "transformselected",
1467
+ defaultMode: "coalescion",
1468
+ isolationInitType: "array",
1469
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "element", "nodelist"),
1470
+ argsValueCheck: (a) => {
1471
+ const { makeFailure, makeSuccess } = Outcome;
1472
+ const { typeCheck, typeCheckMany } = Utils.Tree.TypeChecks;
1473
+ const [first, ...others] = a;
1474
+ const firstChecked = typeCheck(first, "string", "text");
1475
+ if (!firstChecked.success) return makeFailure({ ...firstChecked.error, position: 0 });
1476
+ const othersChecked = typeCheckMany(others, "method");
1477
+ if (!othersChecked.success) return makeFailure({
1478
+ ...othersChecked.error,
1479
+ position: othersChecked.error.position + 1
1480
+ });
1481
+ const returned = [firstChecked.payload, ...othersChecked.payload];
1482
+ return makeSuccess(returned);
1483
+ },
1484
+ func: (main, args) => {
1485
+ const { makeFailure, makeSuccess } = Outcome;
1486
+ const { makeTransformationError } = Utils.SmartTags;
1487
+ const { typeCheck } = Utils.Tree.TypeChecks;
1488
+ const mainClone = Cast.toElement(main);
1489
+ const [selector, ...methods] = args;
1490
+ const selectedElements = Array.from(mainClone.querySelectorAll(Cast.toString(selector)));
1491
+ const transformationMap = new Map(selectedElements.map((s) => [s, Utils.clone(s)]));
1492
+ for (const method of methods) {
1493
+ for (const [selected, value] of Array.from(transformationMap)) {
1494
+ const transformer = method.transformer;
1495
+ const applied = transformer.apply(value);
1496
+ if (!applied.success) return makeFailure(makeTransformationError({
1497
+ // [WIP] maybe a custom makeSubTransformationError ?
1498
+ message: "Subtransformation failure.",
1499
+ onSelected: selected,
1500
+ onTransformed: value,
1501
+ transformerAt: methods.indexOf(method),
1502
+ transformerName: transformer.name,
1503
+ transformerOutput: applied
1504
+ }));
1505
+ transformationMap.set(selected, applied.payload);
1506
+ }
1507
+ }
1508
+ for (const [selected, transformed] of Array.from(transformationMap)) {
1509
+ const transformedChecked = typeCheck(transformed, "element", "nodelist", "text", "string", "number", "boolean", "null");
1510
+ if (!transformedChecked.success) return makeFailure(makeTransformationError({
1511
+ // [WIP] maybe a custom makeBadTransformationOutputError ?
1512
+ message: "Bad transformation output",
1513
+ onSelected: selected,
1514
+ onTransformed: transformed,
1515
+ details: { ...transformedChecked.error }
1516
+ }));
1517
+ const { Element: Element2, NodeList, Text: Text2 } = Window.get();
1518
+ const replacer = transformedChecked.payload;
1519
+ if (replacer instanceof Element2 || replacer instanceof Text2) {
1520
+ insertNode(replacer, "after", selected);
1521
+ selected.remove();
1522
+ } else if (replacer instanceof NodeList) {
1523
+ replacer.forEach((item) => insertNode(item, "before", selected));
1524
+ selected.remove();
1525
+ } else {
1526
+ insertNode(Cast.toText(replacer), "after", selected);
1527
+ selected.remove();
1528
+ }
1529
+ transformedChecked.payload;
1530
+ }
1531
+ if (main instanceof Element) return makeSuccess(mainClone);
1532
+ const safeChildren = Array.from(mainClone.childNodes).filter((e) => e instanceof Element || e instanceof Text);
1533
+ return main instanceof Element ? makeSuccess(mainClone) : makeSuccess(Cast.toNodeList(safeChildren));
1534
+ }
1535
+ });
1536
+
1537
+ // src/agnostic/html/hyper-json/smart-tags/coalesced/trim/index.ts
1538
+ var trim = SmartTags.makeSmartTag({
1539
+ name: "trim",
1540
+ defaultMode: "coalescion",
1541
+ isolationInitType: "array",
1542
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text"),
1543
+ argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1544
+ func: (main) => {
1545
+ return typeof main === "string" ? Outcome.makeSuccess(main.trim()) : Outcome.makeSuccess(Cast.toText(`${main}`.trim()));
1546
+ }
1547
+ });
1548
+
1549
+ // src/agnostic/html/hyper-json/tree/index.ts
1550
+ var Tree;
1551
+ ((_Tree) => {
1552
+ class Tree2 {
1553
+ node;
1554
+ options;
1555
+ parent;
1556
+ parents;
1557
+ pathFromParent;
1558
+ root;
1559
+ isRoot;
1560
+ path;
1561
+ pathString;
1562
+ attributes;
1563
+ isMethod;
1564
+ tagName;
1565
+ smartTagName;
1566
+ smartTagsRegister;
1567
+ smartTagData;
1568
+ mode;
1569
+ isPreserved;
1570
+ isLiteral;
1571
+ isolationInitType;
1572
+ subtrees = /* @__PURE__ */ new Map();
1573
+ static actionAttribute = "_action";
1574
+ static keyAttribute = "_key";
1575
+ static methodAttribute = "_method";
1576
+ static initAttribute = "_init";
1577
+ static modeAttribute = "_mode";
1578
+ static preserveAttribute = "_preserve";
1579
+ static literalAttribute = "_literal";
1580
+ static defaultOptions = {
1581
+ globalObject: {},
1582
+ logger: null,
1583
+ loggerThread: "hyperjson"
1584
+ };
1585
+ static from(nodes, options) {
1586
+ const merged = Utils.Tree.mergeNodes(nodes);
1587
+ return new Tree2(merged, null, null, options);
1588
+ }
1589
+ constructor(node, parent, pathFromParent, options) {
1590
+ const { Element: Element2, Text: Text2, document: document2 } = Window.get();
1591
+ this.resolve = this.resolve.bind(this);
1592
+ this.setVariable = this.setVariable.bind(this);
1593
+ this.getVariable = this.getVariable.bind(this);
1594
+ this.performSafetyChecks = this.performSafetyChecks.bind(this);
1595
+ this.computeValue = this.computeValue.bind(this);
1596
+ this.enforceEvaluation = this.enforceEvaluation.bind(this);
1597
+ this.getCachedValue = this.getCachedValue.bind(this);
1598
+ this.setCachedValue = this.setCachedValue.bind(this);
1599
+ this.getPerformanceData = this.getPerformanceData.bind(this);
1600
+ this.evaluate = this.evaluate.bind(this);
1601
+ this.node = node;
1602
+ this.options = options ?? Tree2.defaultOptions;
1603
+ if (parent !== null && pathFromParent !== null) {
1604
+ this.isRoot = false;
1605
+ this.parent = parent;
1606
+ this.parents = [parent, ...parent.parents];
1607
+ this.pathFromParent = pathFromParent;
1608
+ this.root = this.parent.root;
1609
+ } else {
1610
+ this.isRoot = true;
1611
+ this.parent = null;
1612
+ this.parents = [];
1613
+ this.pathFromParent = null;
1614
+ this.root = this;
1615
+ }
1616
+ this.path = this.isRoot ? [] : [...this.parent.path, this.pathFromParent];
1617
+ this.pathString = `/${this.path.join("/")}`;
1618
+ this.attributes = node instanceof Element2 ? Array.from(node.attributes) : null;
1619
+ if (node instanceof Element2) {
1620
+ const rawTagName = node.tagName.trim().toLowerCase();
1621
+ const hasTrailingUnderscore = rawTagName.endsWith("_");
1622
+ const hasMethodAttribute = this.attributes?.find((attr) => attr.name === Tree2.methodAttribute) !== void 0;
1623
+ const isMethod = hasTrailingUnderscore || hasMethodAttribute;
1624
+ this.isMethod = isMethod;
1625
+ this.tagName = rawTagName;
1626
+ this.smartTagName = hasTrailingUnderscore ? rawTagName.replace(/_+$/g, "") : rawTagName;
1627
+ } else {
1628
+ this.isMethod = false;
1629
+ this.tagName = null;
1630
+ this.smartTagName = null;
1631
+ }
1632
+ this.smartTagsRegister = new Map([
1633
+ any,
1634
+ array,
1635
+ boolean,
1636
+ element,
1637
+ get,
1638
+ global,
1639
+ guess,
1640
+ nodelist,
1641
+ nullFunc,
1642
+ number,
1643
+ record,
1644
+ ref,
1645
+ string,
1646
+ text,
1647
+ add,
1648
+ addclass,
1649
+ and,
1650
+ append,
1651
+ at,
1652
+ call,
1653
+ clone,
1654
+ deleteproperties,
1655
+ equals,
1656
+ getattribute,
1657
+ getproperties,
1658
+ getproperty,
1659
+ ifFunc,
1660
+ initialize,
1661
+ join,
1662
+ length,
1663
+ map,
1664
+ negate,
1665
+ notrailing,
1666
+ or,
1667
+ pickrandom,
1668
+ print,
1669
+ populate,
1670
+ push,
1671
+ pusheach,
1672
+ recordtoarray,
1673
+ removeattribute,
1674
+ removeclass,
1675
+ renameproperty,
1676
+ replace,
1677
+ select,
1678
+ set,
1679
+ setattribute,
1680
+ spread,
1681
+ setproperty,
1682
+ sorton,
1683
+ split,
1684
+ toarray,
1685
+ toboolean,
1686
+ toelement,
1687
+ toggleclass,
1688
+ tonodelist,
1689
+ tonull,
1690
+ tonumber,
1691
+ toref,
1692
+ torecord,
1693
+ tostring,
1694
+ totext,
1695
+ transformselected,
1696
+ trim
1697
+ ]);
1698
+ if (this.smartTagName === null) {
1699
+ this.smartTagData = null;
1700
+ } else {
1701
+ this.smartTagData = this.smartTagsRegister.get(this.smartTagName) ?? null;
1702
+ }
1703
+ const hasModeAttribute = this.attributes?.find((attr) => {
1704
+ return attr.name === Tree2.modeAttribute && Utils.Tree.TypeChecks.isTreeMode(attr.value);
1705
+ });
1706
+ this.mode = hasModeAttribute?.value ?? this.smartTagData?.defaultMode ?? "isolation";
1707
+ const hasLiteralAttribute = this.attributes?.find((attr) => attr.name === Tree2.literalAttribute) !== void 0;
1708
+ this.isLiteral = hasLiteralAttribute;
1709
+ const hasPreservedAttribute = this.attributes?.find((attr) => attr.name === Tree2.preserveAttribute) !== void 0;
1710
+ this.isPreserved = hasPreservedAttribute;
1711
+ const hasInitAttribute = this.attributes?.find((attr) => {
1712
+ if (attr.name !== Tree2.initAttribute) return false;
1713
+ const val = attr.value.trim().toLowerCase();
1714
+ if (!Utils.Tree.TypeChecks.isValueTypeName(val)) return false;
1715
+ if (val === "transformer") return false;
1716
+ if (val === "method") return false;
1717
+ return true;
1718
+ });
1719
+ if (this.mode === "coalescion") {
1720
+ this.isolationInitType = "array";
1721
+ } else {
1722
+ const initAttributeValue = hasInitAttribute?.value;
1723
+ if (initAttributeValue !== void 0) {
1724
+ this.isolationInitType = initAttributeValue;
1725
+ } else if (this.smartTagData !== null) {
1726
+ this.isolationInitType = this.smartTagData?.isolationInitType ?? "array";
1727
+ } else {
1728
+ this.isolationInitType = "nodelist";
1729
+ }
1730
+ }
1731
+ const { childNodes } = node;
1732
+ let positionnedChildrenCount = 0;
1733
+ const mutableSubtrees = /* @__PURE__ */ new Map();
1734
+ Array.from(childNodes).filter((child, _, childNodes2) => {
1735
+ if (child instanceof Element2) return true;
1736
+ if (child instanceof Text2) return true;
1737
+ return false;
1738
+ }).reduce((reduced, child) => {
1739
+ if (reduced.length === 0) return [child];
1740
+ if (child instanceof Element2) return [...reduced, child];
1741
+ const lastReducedItem = reduced[reduced.length - 1];
1742
+ if (lastReducedItem instanceof Element2) return [...reduced, child];
1743
+ const lastReducedTrimmed = trimEnd(lastReducedItem.textContent ?? "");
1744
+ const childTrimmed = trimStart(child.textContent ?? "");
1745
+ const merged = document2.createTextNode(`${lastReducedTrimmed}${childTrimmed}`);
1746
+ const returned = [...reduced];
1747
+ returned.pop();
1748
+ returned.push(merged);
1749
+ return returned;
1750
+ }, []).filter((child) => {
1751
+ if (child instanceof Element2) return true;
1752
+ const textContent = child.textContent ?? "";
1753
+ return textContent.trim() !== "";
1754
+ }).forEach((childNode) => {
1755
+ if (childNode instanceof Text2) {
1756
+ const rawTextContent = childNode.textContent ?? "";
1757
+ const textContent = rawTextContent.replace(/^\s*\n+\s*/, "").replace(/\s*\n+\s*$/, "");
1758
+ const returnedChildNode = document2.createTextNode(textContent);
1759
+ mutableSubtrees.set(
1760
+ positionnedChildrenCount,
1761
+ new Tree2(returnedChildNode, this, positionnedChildrenCount, this.options)
1762
+ );
1763
+ positionnedChildrenCount += 1;
1764
+ } else {
1765
+ const propertyName = childNode.getAttribute(Tree2.keyAttribute);
1766
+ if (propertyName === null) {
1767
+ mutableSubtrees.set(
1768
+ positionnedChildrenCount,
1769
+ new Tree2(childNode, this, positionnedChildrenCount, this.options)
1770
+ );
1771
+ positionnedChildrenCount += 1;
1772
+ } else {
1773
+ mutableSubtrees.set(
1774
+ propertyName,
1775
+ new Tree2(childNode, this, propertyName, this.options)
1776
+ );
1777
+ }
1778
+ }
1779
+ });
1780
+ this.subtrees = mutableSubtrees;
1781
+ }
1782
+ resolve = function(path) {
1783
+ let currentTree = this;
1784
+ for (const chunk of path) {
1785
+ if (chunk === ".") continue;
1786
+ if (chunk === "..") {
1787
+ currentTree = currentTree.parent ?? this;
1788
+ continue;
1789
+ }
1790
+ const { subtrees } = currentTree;
1791
+ const foundSubtree = subtrees.get(chunk);
1792
+ if (foundSubtree === void 0) return void 0;
1793
+ currentTree = foundSubtree;
1794
+ }
1795
+ return currentTree;
1796
+ };
1797
+ // [WIP] variablesStore is actually only used on root Tree
1798
+ variablesStore = /* @__PURE__ */ new Map();
1799
+ setVariable(name, value) {
1800
+ const { root, isRoot, variablesStore } = this;
1801
+ if (!isRoot) return root.setVariable(name, value);
1802
+ variablesStore.set(name, Serialize.serialize(value));
1803
+ }
1804
+ getVariable(name) {
1805
+ const { root } = this;
1806
+ const found = root.variablesStore.get(name);
1807
+ if (found === void 0) return void 0;
1808
+ const deserialized = Serialize.deserialize(found);
1809
+ if (deserialized instanceof Transformer) throw "A transformer should not be stored as a variable, this happening denotes an implementation error.";
1810
+ return deserialized;
1811
+ }
1812
+ performSafetyChecks() {
1813
+ const { node, smartTagData, isMethod, mode, isRoot } = this;
1814
+ const { Text: Text2 } = Window.get();
1815
+ if (node instanceof Text2 || smartTagData === null) {
1816
+ if (isMethod) throw new Error(`A Text or HTMLElement node cannot be used as a method @ ${this.pathString}`);
1817
+ if (mode === "coalescion") throw new Error(`A Text or HTMLElement node cannot be used in coalescion mode @ ${this.pathString}`);
1818
+ }
1819
+ if (isRoot && mode === "coalescion") throw new Error(`The root node cannot be used in coalescion mode @ ${this.pathString}`);
1820
+ }
1821
+ computeValue() {
1822
+ const {
1823
+ isolationInitType,
1824
+ subtrees,
1825
+ node,
1826
+ smartTagData,
1827
+ isMethod,
1828
+ mode,
1829
+ performSafetyChecks
1830
+ } = this;
1831
+ performSafetyChecks();
1832
+ const { Text: Text2 } = Window.get();
1833
+ if (node instanceof Text2) return node.cloneNode(true);
1834
+ const initialInnerValue = Utils.Tree.getInitialValueFromTypeName(isolationInitType);
1835
+ const innerValue = Array.from(subtrees).reduce((reduced, [subpath, subtree]) => {
1836
+ const subvalue = subtree.evaluate();
1837
+ const coalesced = Utils.coalesceValues(reduced, subpath, subvalue);
1838
+ return coalesced;
1839
+ }, initialInnerValue);
1840
+ if (smartTagData === null) {
1841
+ const nodelist2 = Cast.toNodeList(innerValue);
1842
+ const clone2 = node.cloneNode();
1843
+ clone2.append(...Array.from(nodelist2));
1844
+ return clone2;
1845
+ }
1846
+ const { transformer, method } = smartTagData.generator(innerValue, mode, this);
1847
+ if (isMethod) return method;
1848
+ if (mode === "isolation") {
1849
+ const applied = transformer.apply(null);
1850
+ if (applied.success) return applied.payload;
1851
+ throw {
1852
+ error: "Transformation error",
1853
+ details: applied.error,
1854
+ transformer: transformer.name,
1855
+ path: this.pathString
1856
+ };
1857
+ }
1858
+ return transformer;
1859
+ }
1860
+ enforceEvaluation() {
1861
+ const { isPreserved, node, computeValue, isLiteral, attributes } = this;
1862
+ const { Element: Element2 } = Window.get();
1863
+ if (isPreserved) return Utils.clone(node);
1864
+ const evaluated = computeValue();
1865
+ if (!isLiteral) return evaluated;
1866
+ const asLiteral = Utils.toHyperJson(evaluated);
1867
+ if (asLiteral instanceof Element2) attributes?.forEach(({ name, value }) => asLiteral.setAttribute(name, value));
1868
+ return asLiteral;
1869
+ }
1870
+ cachedValue = void 0;
1871
+ getCachedValue() {
1872
+ const { cachedValue } = this;
1873
+ if (cachedValue === void 0) return void 0;
1874
+ const deserialized = Serialize.deserialize(cachedValue);
1875
+ return deserialized;
1876
+ }
1877
+ setCachedValue(evaluated) {
1878
+ this.cachedValue = Serialize.serialize(evaluated);
1879
+ }
1880
+ perfCounters = {
1881
+ evaluations: 0,
1882
+ computeTime: 0,
1883
+ computeTimeAvg: 0,
1884
+ cached: 0,
1885
+ cacheTime: 0,
1886
+ cacheTimeAvg: 0,
1887
+ totalTime: 0
1888
+ };
1889
+ // [WIP] bind this
1890
+ getPerformanceData() {
1891
+ const { subtrees, cachedValue, tagName, perfCounters } = this;
1892
+ const subCounters = [];
1893
+ subCounters.push([this.pathString, {
1894
+ ...perfCounters,
1895
+ tagName: tagName ?? "#text",
1896
+ evaluated: cachedValue
1897
+ }]);
1898
+ subtrees.forEach((subtree) => subCounters.push(...subtree.getPerformanceData()));
1899
+ return subCounters.sort((a, b) => {
1900
+ const aCalls = a[1].evaluations + a[1].cached;
1901
+ const bCalls = b[1].evaluations + b[1].cached;
1902
+ return bCalls - aCalls;
1903
+ });
1904
+ }
1905
+ evaluate() {
1906
+ const start = Date.now();
1907
+ const {
1908
+ getCachedValue,
1909
+ setCachedValue,
1910
+ enforceEvaluation,
1911
+ perfCounters
1912
+ } = this;
1913
+ const cached = getCachedValue();
1914
+ if (cached !== void 0) {
1915
+ const end2 = Date.now();
1916
+ const time2 = end2 - start;
1917
+ perfCounters.cached++;
1918
+ perfCounters.cacheTime += time2;
1919
+ perfCounters.cacheTimeAvg = perfCounters.cacheTime / perfCounters.cached;
1920
+ perfCounters.totalTime = perfCounters.computeTime + perfCounters.cacheTime;
1921
+ return cached;
1922
+ }
1923
+ const evaluated = enforceEvaluation();
1924
+ setCachedValue(evaluated);
1925
+ const end = Date.now();
1926
+ const time = end - start;
1927
+ perfCounters.evaluations++;
1928
+ perfCounters.computeTime += time;
1929
+ perfCounters.computeTimeAvg = perfCounters.computeTime / perfCounters.evaluations;
1930
+ perfCounters.totalTime = perfCounters.computeTime + perfCounters.cacheTime;
1931
+ return evaluated;
1932
+ }
1933
+ }
1934
+ _Tree.Tree = Tree2;
1935
+ })(Tree || (Tree = {}));
1936
+
1937
+ // src/agnostic/html/hyper-json/utils/index.ts
1938
+ var Utils;
1939
+ ((Utils2) => {
1940
+ function clone2(value) {
1941
+ const { Element: Element2, Text: Text2, NodeList, document: document2 } = Window.get();
1942
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null) return value;
1943
+ if (value instanceof Text2) return value.cloneNode(true);
1944
+ if (value instanceof NodeList) {
1945
+ const frag = document2.createDocumentFragment();
1946
+ const nodes = Array.from(value).map((e) => e.cloneNode(true));
1947
+ frag.append(...nodes);
1948
+ return frag.childNodes;
1949
+ }
1950
+ if (value instanceof Element2) return value.cloneNode(true);
1951
+ if (value instanceof Transformer) return Transformer.clone(value);
1952
+ if (value instanceof Method) return Method.clone(value);
1953
+ if (Array.isArray(value)) return [...value.map(clone2)];
1954
+ if (isRecord(value)) return recordMap(value, (prop) => clone2(prop));
1955
+ throw new Error(`Cannot clone value: ${value}`);
1956
+ }
1957
+ Utils2.clone = clone2;
1958
+ function coalesceValues(currentValue, subpath, subvalue) {
1959
+ const { Element: Element2, Text: Text2, NodeList, document: document2 } = Window.get();
1960
+ let actualSubvalue = subvalue;
1961
+ if (actualSubvalue instanceof Transformer) {
1962
+ const transformer = actualSubvalue;
1963
+ const transformationResult = transformer.apply(currentValue);
1964
+ if (!transformationResult.success) {
1965
+ console.warn({ ...transformationResult.error });
1966
+ return currentValue;
1967
+ }
1968
+ const evaluated = transformationResult.payload;
1969
+ if (transformer.mode === "isolation") {
1970
+ actualSubvalue = evaluated;
1971
+ } else {
1972
+ return evaluated;
1973
+ }
1974
+ }
1975
+ if (Array.isArray(currentValue)) return [...currentValue, actualSubvalue];
1976
+ if (currentValue === null) return actualSubvalue;
1977
+ if (typeof currentValue === "boolean") return actualSubvalue;
1978
+ if (typeof currentValue === "number") return actualSubvalue;
1979
+ if (currentValue instanceof Transformer) return actualSubvalue;
1980
+ if (currentValue instanceof Method) return actualSubvalue;
1981
+ if (typeof currentValue === "string") {
1982
+ if (actualSubvalue === null || typeof actualSubvalue === "boolean" || typeof actualSubvalue === "number" || typeof actualSubvalue === "string") return `${currentValue}${actualSubvalue}`;
1983
+ if (actualSubvalue instanceof Text2) return `${currentValue}${actualSubvalue.textContent}`;
1984
+ if (actualSubvalue instanceof Element2) {
1985
+ const frag = document2.createDocumentFragment();
1986
+ frag.append(currentValue, Utils2.clone(actualSubvalue));
1987
+ return frag.childNodes;
1988
+ }
1989
+ if (actualSubvalue instanceof NodeList) {
1990
+ const frag = document2.createDocumentFragment();
1991
+ frag.append(currentValue, ...Array.from(Utils2.clone(actualSubvalue)));
1992
+ return frag.childNodes;
1993
+ }
1994
+ return actualSubvalue;
1995
+ }
1996
+ if (currentValue instanceof Text2) {
1997
+ if (actualSubvalue === null || typeof actualSubvalue === "boolean" || typeof actualSubvalue === "number" || typeof actualSubvalue === "string") return document2.createTextNode(`${currentValue.textContent}${actualSubvalue}`);
1998
+ if (actualSubvalue instanceof Text2) return document2.createTextNode(`${currentValue.textContent}${actualSubvalue.textContent}`);
1999
+ if (actualSubvalue instanceof Element2) {
2000
+ const frag = document2.createDocumentFragment();
2001
+ frag.append(clone2(currentValue), clone2(actualSubvalue));
2002
+ return frag.childNodes;
2003
+ }
2004
+ if (actualSubvalue instanceof NodeList) {
2005
+ const frag = document2.createDocumentFragment();
2006
+ frag.append(clone2(currentValue), ...Array.from(clone2(actualSubvalue)));
2007
+ return frag.childNodes;
2008
+ }
2009
+ return actualSubvalue;
2010
+ }
2011
+ if (currentValue instanceof Element2) {
2012
+ if (actualSubvalue === null || typeof actualSubvalue === "boolean" || typeof actualSubvalue === "number" || typeof actualSubvalue === "string") {
2013
+ const frag = document2.createDocumentFragment();
2014
+ frag.append(clone2(currentValue), `${actualSubvalue}`);
2015
+ return frag.childNodes;
2016
+ }
2017
+ if (actualSubvalue instanceof Text2 || actualSubvalue instanceof Element2) {
2018
+ const frag = document2.createDocumentFragment();
2019
+ frag.append(clone2(currentValue), clone2(actualSubvalue));
2020
+ return frag.childNodes;
2021
+ }
2022
+ if (actualSubvalue instanceof NodeList) {
2023
+ const frag = document2.createDocumentFragment();
2024
+ frag.append(clone2(currentValue), ...Array.from(clone2(actualSubvalue)));
2025
+ return frag.childNodes;
2026
+ }
2027
+ return actualSubvalue;
2028
+ }
2029
+ if (currentValue instanceof NodeList) {
2030
+ if (actualSubvalue === null || typeof actualSubvalue === "boolean" || typeof actualSubvalue === "number" || typeof actualSubvalue === "string") {
2031
+ const frag = document2.createDocumentFragment();
2032
+ frag.append(...Array.from(clone2(currentValue)), `${actualSubvalue}`);
2033
+ return frag.childNodes;
2034
+ }
2035
+ if (actualSubvalue instanceof Text2 || actualSubvalue instanceof Element2) {
2036
+ const frag = document2.createDocumentFragment();
2037
+ frag.append(...Array.from(clone2(currentValue)), clone2(actualSubvalue));
2038
+ return frag.childNodes;
2039
+ }
2040
+ if (actualSubvalue instanceof NodeList) {
2041
+ const frag = document2.createDocumentFragment();
2042
+ frag.append(...Array.from(clone2(currentValue)), ...Array.from(clone2(actualSubvalue)));
2043
+ return frag.childNodes;
2044
+ }
2045
+ return actualSubvalue;
2046
+ }
2047
+ if (typeof subpath === "number") return { ...currentValue };
2048
+ return {
2049
+ ...currentValue,
2050
+ [subpath]: actualSubvalue
2051
+ };
2052
+ }
2053
+ Utils2.coalesceValues = coalesceValues;
2054
+ Utils2.toHyperJson = (value) => {
2055
+ const { document: document2, Element: Element2, Text: Text2, NodeList } = Window.get();
2056
+ if (value instanceof Text2) {
2057
+ const elt2 = document2.createElement("text");
2058
+ elt2.innerHTML = value.textContent ?? "";
2059
+ return elt2;
2060
+ }
2061
+ if (value instanceof Element2) return value.cloneNode(true);
2062
+ if (value instanceof NodeList) {
2063
+ const elt2 = document2.createElement("nodelist");
2064
+ elt2.append(...Array.from(value).map((e) => e.cloneNode(true)));
2065
+ return elt2;
2066
+ }
2067
+ if (value === null) return document2.createElement("null");
2068
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
2069
+ const elt2 = document2.createElement(typeof value);
2070
+ elt2.innerHTML = `${value}`;
2071
+ return elt2;
2072
+ }
2073
+ if (Array.isArray(value)) {
2074
+ const elt2 = document2.createElement("array");
2075
+ elt2.append(...value.map((e) => (0, Utils2.toHyperJson)(e)));
2076
+ return elt2;
2077
+ }
2078
+ if (value instanceof Transformer) return clone2(value.sourceTree.node);
2079
+ if (value instanceof Method) return clone2(value.transformer.sourceTree.node);
2080
+ const elt = document2.createElement("record");
2081
+ Object.entries(value).forEach(([key, val]) => {
2082
+ const hjVal = (0, Utils2.toHyperJson)(val);
2083
+ if (hjVal instanceof Text2) return;
2084
+ hjVal.setAttribute(Tree.Tree.keyAttribute, key);
2085
+ elt.append(hjVal);
2086
+ });
2087
+ return elt;
2088
+ };
2089
+ let Transformations;
2090
+ ((Transformations2) => {
2091
+ let TypeChecks;
2092
+ ((TypeChecks2) => {
2093
+ function getType(value) {
2094
+ if (singleTypeCheck(value, "null")) return "null";
2095
+ if (singleTypeCheck(value, "boolean")) return "boolean";
2096
+ if (singleTypeCheck(value, "number")) return "number";
2097
+ if (singleTypeCheck(value, "string")) return "string";
2098
+ if (singleTypeCheck(value, "element")) return "element";
2099
+ if (singleTypeCheck(value, "text")) return "text";
2100
+ if (singleTypeCheck(value, "nodelist")) return "nodelist";
2101
+ if (singleTypeCheck(value, "method")) return "method";
2102
+ if (singleTypeCheck(value, "array")) return "array";
2103
+ if (singleTypeCheck(value, "record")) return "record";
2104
+ return void 0;
2105
+ }
2106
+ TypeChecks2.getType = getType;
2107
+ TypeChecks2.everyTypeName = [
2108
+ "null",
2109
+ "boolean",
2110
+ "number",
2111
+ "string",
2112
+ "text",
2113
+ "nodelist",
2114
+ "element",
2115
+ "method",
2116
+ "array",
2117
+ "record"
2118
+ ];
2119
+ function singleTypeCheck(value, type) {
2120
+ const { Element: Element2, Text: Text2, NodeList } = Window.get();
2121
+ if (type === "null" && value === null) return true;
2122
+ if (type === "boolean" && typeof value === "boolean") return true;
2123
+ if (type === "number" && typeof value === "number") return true;
2124
+ if (type === "string" && typeof value === "string") return true;
2125
+ if (type === "element" && value instanceof Element2) return true;
2126
+ if (type === "text" && value instanceof Text2) return true;
2127
+ if (type === "nodelist" && value instanceof NodeList) {
2128
+ const children = Array.from(value);
2129
+ return children.every((child) => child instanceof Element2 || child instanceof Text2);
2130
+ }
2131
+ if (type === "method" && value instanceof Method) return true;
2132
+ if (type === "array" && Array.isArray(value)) {
2133
+ const childrenOk = value.every((child) => typeCheck(child, ...TypeChecks2.everyTypeName).success);
2134
+ return childrenOk;
2135
+ }
2136
+ if (type === "record" && isRecord(value)) {
2137
+ const childrenOk = Object.values(value).every((child) => typeCheck(child, ...TypeChecks2.everyTypeName).success);
2138
+ return childrenOk;
2139
+ }
2140
+ return false;
2141
+ }
2142
+ TypeChecks2.singleTypeCheck = singleTypeCheck;
2143
+ function typeCheck(value, ...types) {
2144
+ const matchesOneType = types.some((type) => singleTypeCheck(value, type));
2145
+ if (matchesOneType) return Outcome.makeSuccess(value);
2146
+ return Outcome.makeFailure({
2147
+ expected: types.join(" | "),
2148
+ found: getType(value) ?? "undefined"
2149
+ });
2150
+ }
2151
+ TypeChecks2.typeCheck = typeCheck;
2152
+ function typeCheckMany(values, ...types) {
2153
+ for (const [pos, val] of Object.entries(values)) {
2154
+ const checked = typeCheck(val, ...types);
2155
+ if (checked.success) continue;
2156
+ return Outcome.makeFailure({ position: parseInt(pos), ...checked.error });
2157
+ }
2158
+ return Outcome.makeSuccess(values);
2159
+ }
2160
+ TypeChecks2.typeCheckMany = typeCheckMany;
2161
+ })(TypeChecks = Transformations2.TypeChecks || (Transformations2.TypeChecks = {}));
2162
+ })(Transformations = Utils2.Transformations || (Utils2.Transformations = {}));
2163
+ let Tree2;
2164
+ ((Tree3) => {
2165
+ function mergeNodes(nodes) {
2166
+ const clones = nodes.map((node) => node.cloneNode(true));
2167
+ const allChildren = [];
2168
+ clones.forEach((node) => {
2169
+ const actionAttribute = node.getAttribute(Tree.Tree.actionAttribute)?.trim().toLowerCase();
2170
+ const actionAttrIsValid = isInEnum(Types.Tree.Merge.Action, actionAttribute ?? "");
2171
+ const nodeAction = actionAttrIsValid ? actionAttribute : Types.Tree.Merge.Action.APPEND;
2172
+ const { Element: Element2, Text: Text2 } = Window.get();
2173
+ const children = Array.from(node.childNodes).filter((child) => child instanceof Text2 || child instanceof Element2).map((child) => {
2174
+ if (child instanceof Text2) return { node: child, key: void 0 };
2175
+ const childKey = child.getAttribute(Tree.Tree.keyAttribute) ?? void 0;
2176
+ return { node: child, key: childKey };
2177
+ });
2178
+ if (nodeAction === Types.Tree.Merge.Action.REPLACE) {
2179
+ allChildren.splice(0, allChildren.length);
2180
+ } else if (nodeAction === Types.Tree.Merge.Action.PREPEND) {
2181
+ allChildren.unshift(...children);
2182
+ } else {
2183
+ allChildren.push(...children);
2184
+ }
2185
+ });
2186
+ const mergedChildren = [];
2187
+ allChildren.forEach((childData) => {
2188
+ if (childData.key === void 0) mergedChildren.push(childData);
2189
+ else {
2190
+ const childKey = childData.key;
2191
+ const alreadyMerged = mergedChildren.find((dat) => dat.key === childKey);
2192
+ if (alreadyMerged) return;
2193
+ const toMerge = allChildren.filter((dat) => dat.key === childKey);
2194
+ if (toMerge.length === 0) return;
2195
+ const merged = mergeNodes(toMerge.map((dat) => dat.node));
2196
+ mergedChildren.push({ node: merged, key: childKey });
2197
+ }
2198
+ });
2199
+ const allAttributes = clones.reduce((attributes, node) => [
2200
+ ...Array.from(attributes),
2201
+ ...Array.from(node.attributes)
2202
+ ], []);
2203
+ const outWrapper = clones[0]?.cloneNode() ?? document.createElement("div");
2204
+ allAttributes.forEach((attr) => outWrapper.setAttribute(attr.name, attr.value));
2205
+ outWrapper.append(...mergedChildren.map((e) => e.node));
2206
+ return outWrapper;
2207
+ }
2208
+ Tree3.mergeNodes = mergeNodes;
2209
+ function getInitialValueFromTypeName(name) {
2210
+ const { document: document2 } = Window.get();
2211
+ if (name === "null") return null;
2212
+ if (name === "boolean") return false;
2213
+ if (name === "number") return 0;
2214
+ if (name === "string") return "";
2215
+ if (name === "text") return document2.createTextNode("");
2216
+ if (name === "nodelist") return document2.createDocumentFragment().childNodes;
2217
+ if (name === "element") return document2.createElement("div");
2218
+ if (name === "array") return [];
2219
+ if (name === "record") return {};
2220
+ throw new Error(`Unknown value type name: ${name}`);
2221
+ }
2222
+ Tree3.getInitialValueFromTypeName = getInitialValueFromTypeName;
2223
+ let TypeChecks;
2224
+ ((TypeChecks2) => {
2225
+ function getType(value) {
2226
+ if (singleTypeCheck(value, "null")) return "null";
2227
+ if (singleTypeCheck(value, "boolean")) return "boolean";
2228
+ if (singleTypeCheck(value, "number")) return "number";
2229
+ if (singleTypeCheck(value, "string")) return "string";
2230
+ if (singleTypeCheck(value, "element")) return "element";
2231
+ if (singleTypeCheck(value, "text")) return "text";
2232
+ if (singleTypeCheck(value, "nodelist")) return "nodelist";
2233
+ if (singleTypeCheck(value, "transformer")) return "transformer";
2234
+ if (singleTypeCheck(value, "method")) return "method";
2235
+ if (singleTypeCheck(value, "array")) return "array";
2236
+ if (singleTypeCheck(value, "record")) return "record";
2237
+ return void 0;
2238
+ }
2239
+ TypeChecks2.getType = getType;
2240
+ TypeChecks2.everyTypeName = [
2241
+ "null",
2242
+ "boolean",
2243
+ "number",
2244
+ "string",
2245
+ "text",
2246
+ "nodelist",
2247
+ "element",
2248
+ "transformer",
2249
+ "method",
2250
+ "array",
2251
+ "record"
2252
+ ];
2253
+ function singleTypeCheck(value, type) {
2254
+ const { Element: Element2, Text: Text2, NodeList } = Window.get();
2255
+ if (type === "null" && value === null) return true;
2256
+ if (type === "boolean" && typeof value === "boolean") return true;
2257
+ if (type === "number" && typeof value === "number") return true;
2258
+ if (type === "string" && typeof value === "string") return true;
2259
+ if (type === "element" && value instanceof Element2) return true;
2260
+ if (type === "text" && value instanceof Text2) return true;
2261
+ if (type === "nodelist" && value instanceof NodeList) {
2262
+ const children = Array.from(value);
2263
+ return children.every((child) => child instanceof Element2 || child instanceof Text2);
2264
+ }
2265
+ if (type === "transformer" && value instanceof Transformer) return true;
2266
+ if (type === "method" && value instanceof Method) return true;
2267
+ if (type === "array" && Array.isArray(value)) {
2268
+ const childrenOk = value.every((child) => typeCheck(child, ...TypeChecks2.everyTypeName).success);
2269
+ return childrenOk;
2270
+ }
2271
+ if (type === "record" && isRecord(value)) {
2272
+ const childrenOk = Object.values(value).every((child) => typeCheck(child, ...TypeChecks2.everyTypeName).success);
2273
+ return childrenOk;
2274
+ }
2275
+ return false;
2276
+ }
2277
+ TypeChecks2.singleTypeCheck = singleTypeCheck;
2278
+ function typeCheck(value, ...types) {
2279
+ const matchesOneType = types.some((type) => singleTypeCheck(value, type));
2280
+ if (matchesOneType) return Outcome.makeSuccess(value);
2281
+ return Outcome.makeFailure({
2282
+ expected: types.join(" | "),
2283
+ found: getType(value) ?? "undefined"
2284
+ });
2285
+ }
2286
+ TypeChecks2.typeCheck = typeCheck;
2287
+ function typeCheckMany(values, ...types) {
2288
+ for (const [pos, val] of Object.entries(values)) {
2289
+ const checked = typeCheck(val, ...types);
2290
+ if (checked.success) continue;
2291
+ return Outcome.makeFailure({ position: parseInt(pos), ...checked.error });
2292
+ }
2293
+ return Outcome.makeSuccess(values);
2294
+ }
2295
+ TypeChecks2.typeCheckMany = typeCheckMany;
2296
+ TypeChecks2.isTreeMode = (name) => name === "isolation" || name === "coalescion";
2297
+ TypeChecks2.isValueTypeName = (name) => {
2298
+ const list = [
2299
+ "null",
2300
+ "boolean",
2301
+ "number",
2302
+ "string",
2303
+ "text",
2304
+ "nodelist",
2305
+ "element",
2306
+ "transformer",
2307
+ "method",
2308
+ "array",
2309
+ "record"
2310
+ ];
2311
+ return list.includes(name);
2312
+ };
2313
+ })(TypeChecks = Tree3.TypeChecks || (Tree3.TypeChecks = {}));
2314
+ })(Tree2 = Utils2.Tree || (Utils2.Tree = {}));
2315
+ let SmartTags2;
2316
+ ((SmartTags3) => {
2317
+ SmartTags3.expectEmptyArgs = (args) => {
2318
+ if (args.length === 0) return Outcome.makeSuccess([]);
2319
+ return Outcome.makeFailure({
2320
+ expected: "length: 0",
2321
+ found: `length: ${args.length}`
2322
+ });
2323
+ };
2324
+ SmartTags3.makeMainValueError = (expected, found, details) => ({ expected, found, details });
2325
+ SmartTags3.makeArgsValueError = (expected, found, position, details) => ({ expected, found, position, details });
2326
+ SmartTags3.makeTransformationError = (details) => ({ details });
2327
+ })(SmartTags2 = Utils2.SmartTags || (Utils2.SmartTags = {}));
2328
+ })(Utils || (Utils = {}));
2329
+
2330
+ // src/agnostic/html/hyper-json/smart-tags/isolated/boolean/index.ts
2331
+ var boolean = SmartTags.makeSmartTag({
2332
+ name: "boolean",
2333
+ defaultMode: "isolation",
2334
+ isolationInitType: "boolean",
2335
+ mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "null", "boolean", "number", "string", "text"),
2336
+ argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "null", "boolean", "number", "string", "text"),
2337
+ func: (main, args) => Outcome.makeSuccess([main, ...args].every((item) => Cast.toBoolean(item)))
2338
+ });
2339
+
2340
+ export {
2341
+ boolean,
2342
+ element,
2343
+ get,
2344
+ global,
2345
+ guess,
2346
+ nodelist,
2347
+ number,
2348
+ record,
2349
+ func,
2350
+ ref,
2351
+ string,
2352
+ text,
2353
+ add,
2354
+ addclass,
2355
+ and,
2356
+ append,
2357
+ at,
2358
+ call,
2359
+ clone,
2360
+ deleteproperties,
2361
+ equals,
2362
+ getattribute,
2363
+ getproperties,
2364
+ getproperty,
2365
+ deepGetProperty,
2366
+ ifFunc,
2367
+ initialize,
2368
+ join,
2369
+ length,
2370
+ map,
2371
+ negate,
2372
+ notrailing,
2373
+ or,
2374
+ pickrandom,
2375
+ print,
2376
+ populate,
2377
+ push,
2378
+ pusheach,
2379
+ recordtoarray,
2380
+ removeattribute,
2381
+ removeclass,
2382
+ renameproperty,
2383
+ replace,
2384
+ select,
2385
+ set,
2386
+ setattribute,
2387
+ setproperty,
2388
+ sorton,
2389
+ split,
2390
+ spread,
2391
+ toarray,
2392
+ toboolean,
2393
+ toelement,
2394
+ toggleclass,
2395
+ tonodelist,
2396
+ tonull,
2397
+ tonumber,
2398
+ torecord,
2399
+ toref,
2400
+ tostring,
2401
+ totext,
2402
+ transformselected,
2403
+ trim,
2404
+ Tree,
2405
+ Utils,
2406
+ Cast
2407
+ };