@symbo.ls/scratch 3.2.3 → 3.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/cjs/factory.js +23 -494
  2. package/dist/cjs/index.js +11 -2742
  3. package/dist/cjs/set.js +66 -2060
  4. package/dist/esm/factory.js +43 -0
  5. package/dist/esm/index.js +12 -0
  6. package/dist/esm/set.js +148 -0
  7. package/dist/iife/index.js +2580 -0
  8. package/package.json +25 -15
  9. package/src/set.js +22 -7
  10. package/src/system/color.js +48 -11
  11. package/src/system/font.js +19 -5
  12. package/src/system/reset.js +12 -3
  13. package/src/system/shadow.js +20 -13
  14. package/src/system/spacing.js +63 -56
  15. package/src/system/theme.js +4 -3
  16. package/src/system/timing.js +1 -1
  17. package/src/transforms/index.js +212 -95
  18. package/src/utils/color.js +79 -0
  19. package/src/utils/font.js +54 -14
  20. package/src/utils/sequence.js +94 -39
  21. package/src/utils/sprite.js +2 -2
  22. package/src/utils/unit.js +69 -2
  23. package/src/utils/var.js +1 -2
  24. package/dist/cjs/defaultConfig/animation.js +0 -26
  25. package/dist/cjs/defaultConfig/cases.js +0 -26
  26. package/dist/cjs/defaultConfig/class.js +0 -27
  27. package/dist/cjs/defaultConfig/color.js +0 -28
  28. package/dist/cjs/defaultConfig/document.js +0 -26
  29. package/dist/cjs/defaultConfig/font-family.js +0 -34
  30. package/dist/cjs/defaultConfig/font.js +0 -26
  31. package/dist/cjs/defaultConfig/grid.js +0 -27
  32. package/dist/cjs/defaultConfig/icons.js +0 -28
  33. package/dist/cjs/defaultConfig/index.js +0 -222
  34. package/dist/cjs/defaultConfig/media.js +0 -31
  35. package/dist/cjs/defaultConfig/responsive.js +0 -52
  36. package/dist/cjs/defaultConfig/sequence.js +0 -51
  37. package/dist/cjs/defaultConfig/shadow.js +0 -26
  38. package/dist/cjs/defaultConfig/spacing.js +0 -87
  39. package/dist/cjs/defaultConfig/svg.js +0 -28
  40. package/dist/cjs/defaultConfig/templates.js +0 -26
  41. package/dist/cjs/defaultConfig/theme.js +0 -26
  42. package/dist/cjs/defaultConfig/timing.js +0 -68
  43. package/dist/cjs/defaultConfig/typography.js +0 -72
  44. package/dist/cjs/defaultConfig/unit.js +0 -28
  45. package/dist/cjs/package.json +0 -4
  46. package/dist/cjs/system/color.js +0 -1175
  47. package/dist/cjs/system/document.js +0 -987
  48. package/dist/cjs/system/font.js +0 -1009
  49. package/dist/cjs/system/index.js +0 -2227
  50. package/dist/cjs/system/reset.js +0 -1099
  51. package/dist/cjs/system/shadow.js +0 -1384
  52. package/dist/cjs/system/spacing.js +0 -1338
  53. package/dist/cjs/system/svg.js +0 -1086
  54. package/dist/cjs/system/theme.js +0 -1276
  55. package/dist/cjs/system/timing.js +0 -1213
  56. package/dist/cjs/system/typography.js +0 -1311
  57. package/dist/cjs/tests/index.js +0 -30
  58. package/dist/cjs/transforms/index.js +0 -1613
  59. package/dist/cjs/utils/color.js +0 -333
  60. package/dist/cjs/utils/font.js +0 -69
  61. package/dist/cjs/utils/index.js +0 -1548
  62. package/dist/cjs/utils/sequence.js +0 -1198
  63. package/dist/cjs/utils/sprite.js +0 -579
  64. package/dist/cjs/utils/theme.js +0 -31
  65. package/dist/cjs/utils/unit.js +0 -28
  66. package/dist/cjs/utils/var.js +0 -1040
@@ -1,2227 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJS = (cb, mod) => function __require() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
11
- var __export = (target, all) => {
12
- for (var name in all)
13
- __defProp(target, name, { get: all[name], enumerable: true });
14
- };
15
- var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from))
18
- if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
- }
21
- return to;
22
- };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
- // If the importer is in node compatibility mode or this is not an ESM
25
- // file that has been converted to a CommonJS file using a Babel-
26
- // compatible transform (i.e. "__esModule" has not been set), then set
27
- // "default" to the CommonJS "module.exports" for node compatibility.
28
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
- mod
30
- ));
31
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
-
33
- // ../utils/dist/cjs/index.js
34
- var require_cjs = __commonJS({
35
- "../utils/dist/cjs/index.js"(exports, module2) {
36
- "use strict";
37
- var __defProp3 = Object.defineProperty;
38
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
39
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
40
- var __hasOwnProp3 = Object.prototype.hasOwnProperty;
41
- var __export2 = (target, all) => {
42
- for (var name in all)
43
- __defProp3(target, name, { get: all[name], enumerable: true });
44
- };
45
- var __copyProps2 = (to, from, except, desc) => {
46
- if (from && typeof from === "object" || typeof from === "function") {
47
- for (let key of __getOwnPropNames2(from))
48
- if (!__hasOwnProp3.call(to, key) && key !== except)
49
- __defProp3(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
50
- }
51
- return to;
52
- };
53
- var __toCommonJS2 = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
54
- var index_exports = {};
55
- __export2(index_exports, {
56
- arrayzeValue: () => arrayzeValue3,
57
- copyJavaScriptToClipboard: () => copyJavaScriptToClipboard,
58
- copyStringToClipboard: () => copyStringToClipboard,
59
- fibonacciNumberByIndex: () => fibonacciNumberByIndex,
60
- findClosestNumber: () => findClosestNumber,
61
- findClosestNumberInFactory: () => findClosestNumberInFactory,
62
- formatDate: () => formatDate,
63
- isPhoto: () => isPhoto,
64
- loadCssFile: () => loadCssFile,
65
- loadJavascript: () => loadJavascript,
66
- loadJavascriptFile: () => loadJavascriptFile,
67
- loadJavascriptFileEmbedSync: () => loadJavascriptFileEmbedSync,
68
- loadJavascriptFileSync: () => loadJavascriptFileSync,
69
- loadRemoteCSS: () => loadRemoteCSS,
70
- loadRemoteScript: () => loadRemoteScript,
71
- removeChars: () => removeChars,
72
- toCamelCase: () => toCamelCase2,
73
- toDashCase: () => toDashCase2,
74
- toDescriptionCase: () => toDescriptionCase,
75
- toTitleCase: () => toTitleCase,
76
- toggleFullscreen: () => toggleFullscreen
77
- });
78
- module2.exports = __toCommonJS2(index_exports);
79
- var window22 = globalThis;
80
- var document22 = window22.document;
81
- var isObject2 = (arg) => {
82
- if (arg === null) return false;
83
- return typeof arg === "object" && arg.constructor === Object;
84
- };
85
- var isString2 = (arg) => typeof arg === "string";
86
- var isNumber2 = (arg) => typeof arg === "number";
87
- var isArray2 = (arg) => Array.isArray(arg);
88
- var STATE_METHODS3 = [
89
- "update",
90
- "parse",
91
- "clean",
92
- "create",
93
- "destroy",
94
- "add",
95
- "toggle",
96
- "remove",
97
- "apply",
98
- "set",
99
- "reset",
100
- "replace",
101
- "quietReplace",
102
- "quietUpdate",
103
- "applyReplace",
104
- "applyFunction",
105
- "keys",
106
- "values",
107
- "ref",
108
- "rootUpdate",
109
- "parentUpdate",
110
- "parent",
111
- "__element",
112
- "__depends",
113
- "__ref",
114
- "__children",
115
- "root",
116
- "setByPath",
117
- "setPathCollection",
118
- "removeByPath",
119
- "removePathCollection",
120
- "getByPath"
121
- ];
122
- var PROPS_METHODS3 = ["update", "__element"];
123
- var METHODS3 = [
124
- "set",
125
- "reset",
126
- "update",
127
- "remove",
128
- "updateContent",
129
- "removeContent",
130
- "lookup",
131
- "lookdown",
132
- "lookdownAll",
133
- "getRef",
134
- "getPath",
135
- "setNodeStyles",
136
- "spotByPath",
137
- "keys",
138
- "parse",
139
- "setProps",
140
- "parseDeep",
141
- "variables",
142
- "if",
143
- "log",
144
- "verbose",
145
- "warn",
146
- "error",
147
- "call",
148
- "nextElement",
149
- "previousElement"
150
- ];
151
- var METHODS_EXL3 = [
152
- ...["node", "context", "extends", "__element", "__ref"],
153
- ...METHODS3,
154
- ...STATE_METHODS3,
155
- ...PROPS_METHODS3
156
- ];
157
- var isMobile2 = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
158
- var STATE_METHODS22 = [
159
- "update",
160
- "parse",
161
- "clean",
162
- "create",
163
- "destroy",
164
- "add",
165
- "toggle",
166
- "remove",
167
- "apply",
168
- "set",
169
- "reset",
170
- "replace",
171
- "quietReplace",
172
- "quietUpdate",
173
- "applyReplace",
174
- "applyFunction",
175
- "keys",
176
- "values",
177
- "ref",
178
- "rootUpdate",
179
- "parentUpdate",
180
- "parent",
181
- "__element",
182
- "__depends",
183
- "__ref",
184
- "__children",
185
- "root",
186
- "setByPath",
187
- "setPathCollection",
188
- "removeByPath",
189
- "removePathCollection",
190
- "getByPath"
191
- ];
192
- var PROPS_METHODS22 = ["update", "__element"];
193
- var METHODS22 = [
194
- "set",
195
- "reset",
196
- "update",
197
- "remove",
198
- "updateContent",
199
- "removeContent",
200
- "lookup",
201
- "lookdown",
202
- "lookdownAll",
203
- "getRef",
204
- "getPath",
205
- "setNodeStyles",
206
- "spotByPath",
207
- "keys",
208
- "parse",
209
- "setProps",
210
- "parseDeep",
211
- "variables",
212
- "if",
213
- "log",
214
- "verbose",
215
- "warn",
216
- "error",
217
- "call",
218
- "nextElement",
219
- "previousElement"
220
- ];
221
- var METHODS_EXL22 = [
222
- ...["node", "context", "extends", "__element", "__ref"],
223
- ...METHODS22,
224
- ...STATE_METHODS22,
225
- ...PROPS_METHODS22
226
- ];
227
- var window32 = globalThis;
228
- var document32 = window32.document;
229
- async function toggleFullscreen(opts) {
230
- if (!document.fullscreenElement) {
231
- try {
232
- await (this.node || document).requestFullscreen();
233
- } catch (err) {
234
- console.warn(`Error attempting to enable fullscreen mode: ${err.message} (${err.name})`);
235
- }
236
- } else {
237
- await document.exitFullscreen();
238
- }
239
- }
240
- var findClosestNumber = (number, arr) => {
241
- return (isArray2(arr) ? arr : Object.values(arr)).reduce((prev, curr) => {
242
- return Math.abs(curr - number) < Math.abs(prev - number) ? curr : prev;
243
- });
244
- };
245
- var findClosestNumberInFactory = (val, factory) => {
246
- val = parseFloat(val);
247
- if (isObject2(factory)) factory = Object.values(factory);
248
- return findClosestNumber(val, factory);
249
- };
250
- var formatDate = (timestamp) => {
251
- if (!timestamp) return "";
252
- const d = new Date(timestamp);
253
- const ye = new Intl.DateTimeFormat("en", { year: "numeric" }).format(d);
254
- const mo = new Intl.DateTimeFormat("en", { month: "short" }).format(d);
255
- const da = new Intl.DateTimeFormat("en", { day: "2-digit" }).format(d);
256
- return `${da} ${mo}, ${ye}`;
257
- };
258
- var fibonacciNumberByIndex = function fibonacciNumberByIndex2(n) {
259
- const fib = [0, 1];
260
- for (let i = 2; i <= n; i++) {
261
- fib[i] = fib[i - 1] + fib[i - 2];
262
- }
263
- return fib[n];
264
- };
265
- var loadJavascriptFile = (FILE_URL, async = false, doc = document, type = "text/javascript") => {
266
- return new Promise((resolve, reject) => {
267
- try {
268
- const scriptEle = doc.createElement("script");
269
- scriptEle.type = type;
270
- scriptEle.async = async;
271
- scriptEle.src = FILE_URL;
272
- scriptEle.addEventListener("load", (ev) => {
273
- resolve({
274
- status: true
275
- });
276
- });
277
- scriptEle.addEventListener("error", (ev) => {
278
- reject(
279
- new Error({
280
- status: false,
281
- message: `Failed to load the script ${FILE_URL}`
282
- })
283
- );
284
- });
285
- doc.body.appendChild(scriptEle);
286
- } catch (error) {
287
- reject(error);
288
- }
289
- });
290
- };
291
- var loadJavascriptFileSync = (fileUrl, doc = document, type = "text/javascript") => {
292
- return new Promise((resolve, reject) => {
293
- const scriptEle = doc.createElement("script");
294
- scriptEle.type = type;
295
- scriptEle.src = fileUrl;
296
- const blocker = doc.createElement("div");
297
- blocker.style.cssText = "position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(255,255,255,0.8);z-index:9999;";
298
- doc.body.appendChild(blocker);
299
- scriptEle.onload = () => {
300
- console.log(`Successfully loaded: ${fileUrl}`);
301
- doc.body.removeChild(blocker);
302
- resolve();
303
- };
304
- scriptEle.onerror = () => {
305
- doc.body.removeChild(blocker);
306
- reject(new Error(`Failed to load: ${fileUrl}`));
307
- };
308
- doc.body.appendChild(scriptEle);
309
- });
310
- };
311
- var loadJavascriptFileEmbedSync = (FILE_URL, doc = document, fallback, type = "text/javascript") => {
312
- const xhr = new window.XMLHttpRequest();
313
- xhr.open("GET", FILE_URL, false);
314
- xhr.send();
315
- if (xhr.status === 200) {
316
- const scriptEle = doc.createElement("script");
317
- scriptEle.type = type;
318
- scriptEle.text = xhr.responseText;
319
- doc.body.appendChild(scriptEle);
320
- if (typeof fallback === "function") fallback();
321
- } else {
322
- throw new Error(`Failed to load the script ${FILE_URL}`);
323
- }
324
- };
325
- var loadCssFile = (FILE_URL, async = false, doc = document, type = "text/javascript") => {
326
- return new Promise((resolve, reject) => {
327
- try {
328
- const linkElem = doc.createElement("link");
329
- linkElem.rel = "stylesheet";
330
- linkElem.href = FILE_URL;
331
- linkElem.addEventListener("load", (ev) => {
332
- resolve({
333
- status: true
334
- });
335
- });
336
- doc.head.appendChild(linkElem);
337
- } catch (error) {
338
- reject(error);
339
- }
340
- });
341
- };
342
- var loadJavascript = (body, async = false, doc = document, type = "text/javascript", id = "smbls-script") => {
343
- try {
344
- const scriptEle = doc.createElement("script");
345
- scriptEle.type = type;
346
- scriptEle.async = async;
347
- scriptEle.id = id;
348
- scriptEle.innerHTML = body;
349
- doc.body.appendChild(scriptEle);
350
- } catch (error) {
351
- console.warn(error);
352
- }
353
- };
354
- function loadRemoteScript(url, options = {}) {
355
- const { window: window4 = globalThis } = options;
356
- const { document: document4 = window4.document } = options;
357
- return new Promise((resolve, reject) => {
358
- const existingScript = document4.querySelector(`script[src="${url}"]`);
359
- if (existingScript) {
360
- return resolve(existingScript);
361
- }
362
- const script = document4.createElement("script");
363
- script.src = url;
364
- script.async = options.async === true;
365
- script.type = options.type || "text/javascript";
366
- if (options.id) script.id = options.id;
367
- if (options.integrity) script.integrity = options.integrity;
368
- if (options.crossOrigin) script.crossOrigin = options.crossOrigin;
369
- script.onload = () => {
370
- script.onerror = script.onload = null;
371
- resolve(script);
372
- };
373
- script.onerror = () => {
374
- script.onerror = script.onload = null;
375
- reject(new Error(`Failed to load script: ${url}`));
376
- };
377
- document4.head.appendChild(script);
378
- });
379
- }
380
- async function loadRemoteCSS(url, options = {}) {
381
- const { window: window4 = globalThis } = options;
382
- const { document: document4 = window4.document } = options;
383
- return new Promise((resolve, reject) => {
384
- const existingLink = document4.querySelector(`link[href="${url}"]`);
385
- if (existingLink) {
386
- return resolve(existingLink);
387
- }
388
- const link = document4.createElement("link");
389
- link.href = url;
390
- link.rel = options.rel || "stylesheet";
391
- link.type = "text/css";
392
- link.media = options.media || "all";
393
- if (options.id) link.id = options.id;
394
- if (options.integrity) link.integrity = options.integrity;
395
- if (options.crossOrigin) link.crossOrigin = options.crossOrigin;
396
- link.onload = () => {
397
- link.onerror = link.onload = null;
398
- resolve(link);
399
- };
400
- link.onerror = () => {
401
- link.onerror = link.onload = null;
402
- reject(new Error(`Failed to load stylesheet: ${url}`));
403
- };
404
- document4.head.appendChild(link);
405
- });
406
- }
407
- var isPhoto = (format) => ["jpeg", "gif", "jpg", "png", "tiff", "woff"].includes(format);
408
- var copyStringToClipboard = async (str) => {
409
- try {
410
- await navigator.clipboard.writeText(str);
411
- } catch (err) {
412
- console.warn("Failed to copy text: ", err);
413
- }
414
- };
415
- var copyJavaScriptToClipboard = async (jsCode) => {
416
- try {
417
- const blob = new Blob([jsCode], { type: "text/javascript" });
418
- const clipboardItem = new window.ClipboardItem({ "text/plain": blob });
419
- await navigator.clipboard.write([clipboardItem]);
420
- console.log("JavaScript code copied to clipboard as text/javascript");
421
- } catch (err) {
422
- console.error("Failed to copy JavaScript code: ", err);
423
- }
424
- };
425
- var removeChars = (str) => {
426
- return str.replace(/[^a-zA-Z0-9_]/g, "");
427
- };
428
- var toCamelCase2 = (str) => {
429
- return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
430
- return index === 0 ? word.toLowerCase() : word.toUpperCase();
431
- }).replaceAll(/\s+/g, "");
432
- };
433
- var toTitleCase = (str) => str && str.replace(/\w\S*/g, (txt) => {
434
- return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
435
- });
436
- var toDashCase2 = (val) => val.replace(/[^a-zA-Z0-9]/g, " ").trim().toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
437
- var toDescriptionCase = (str = "") => {
438
- if (typeof str !== "string") return;
439
- const result = str.replace(/([A-Z])/g, " $1");
440
- return result.charAt(0).toUpperCase() + result.slice(1);
441
- };
442
- var arrayzeValue3 = (val) => {
443
- if (isArray2(val)) return val;
444
- if (isString2(val)) return val.split(" ");
445
- if (isObject2(val)) return Object.values(val);
446
- if (isNumber2(val)) return [val];
447
- };
448
- }
449
- });
450
-
451
- // src/system/index.js
452
- var system_exports = {};
453
- __export(system_exports, {
454
- appendSVGSprite: () => appendSVGSprite,
455
- appendSvgIconsSprite: () => appendSvgIconsSprite,
456
- applyDocument: () => applyDocument,
457
- applyHeadings: () => applyHeadings,
458
- applyReset: () => applyReset,
459
- applySpacingSequence: () => applySpacingSequence,
460
- applyTimingSequence: () => applyTimingSequence,
461
- applyTypographySequence: () => applyTypographySequence,
462
- getColor: () => getColor,
463
- getFontFamily: () => getFontFamily,
464
- getFontSizeByKey: () => getFontSizeByKey,
465
- getMediaColor: () => getMediaColor,
466
- getMediaTheme: () => getMediaTheme,
467
- getShadow: () => getShadow,
468
- getSpacingBasedOnRatio: () => getSpacingBasedOnRatio,
469
- getSpacingByKey: () => getSpacingByKey,
470
- getTheme: () => getTheme,
471
- getTimingByKey: () => getTimingByKey,
472
- getTimingFunction: () => getTimingFunction,
473
- runThroughMedia: () => runThroughMedia,
474
- setColor: () => setColor,
475
- setFont: () => setFont,
476
- setFontFamily: () => setFontFamily,
477
- setGradient: () => setGradient,
478
- setMediaTheme: () => setMediaTheme,
479
- setSVG: () => setSVG,
480
- setShadow: () => setShadow,
481
- setSvgIcon: () => setSvgIcon,
482
- setTheme: () => setTheme
483
- });
484
- module.exports = __toCommonJS(system_exports);
485
-
486
- // ../../../domql/packages/utils/dist/esm/globals.js
487
- var window2 = globalThis;
488
- var document2 = window2.document;
489
-
490
- // ../../../domql/packages/utils/dist/esm/node.js
491
- var isDOMNode = (obj) => {
492
- return typeof window2 !== "undefined" && (obj instanceof window2.Node || obj instanceof window2.Window || obj === window2 || obj === document);
493
- };
494
-
495
- // ../../../domql/packages/utils/dist/esm/types.js
496
- var isObject = (arg) => {
497
- if (arg === null) return false;
498
- return typeof arg === "object" && arg.constructor === Object;
499
- };
500
- var isString = (arg) => typeof arg === "string";
501
- var isNumber = (arg) => typeof arg === "number";
502
- var isFunction = (arg) => typeof arg === "function";
503
- var isNull = (arg) => arg === null;
504
- var isArray = (arg) => Array.isArray(arg);
505
- var isObjectLike = (arg) => {
506
- if (arg === null) return false;
507
- return typeof arg === "object";
508
- };
509
- var isUndefined = (arg) => {
510
- return arg === void 0;
511
- };
512
-
513
- // ../../../domql/packages/utils/dist/esm/array.js
514
- var unstackArrayOfObjects = (arr, exclude = []) => {
515
- return arr.reduce(
516
- (a, c) => deepMerge(a, deepClone(c, { exclude }), exclude),
517
- {}
518
- );
519
- };
520
-
521
- // ../../../domql/packages/utils/dist/esm/keys.js
522
- var STATE_METHODS = [
523
- "update",
524
- "parse",
525
- "clean",
526
- "create",
527
- "destroy",
528
- "add",
529
- "toggle",
530
- "remove",
531
- "apply",
532
- "set",
533
- "reset",
534
- "replace",
535
- "quietReplace",
536
- "quietUpdate",
537
- "applyReplace",
538
- "applyFunction",
539
- "keys",
540
- "values",
541
- "ref",
542
- "rootUpdate",
543
- "parentUpdate",
544
- "parent",
545
- "__element",
546
- "__depends",
547
- "__ref",
548
- "__children",
549
- "root",
550
- "setByPath",
551
- "setPathCollection",
552
- "removeByPath",
553
- "removePathCollection",
554
- "getByPath"
555
- ];
556
- var PROPS_METHODS = ["update", "__element"];
557
- var METHODS = [
558
- "set",
559
- "reset",
560
- "update",
561
- "remove",
562
- "updateContent",
563
- "removeContent",
564
- "lookup",
565
- "lookdown",
566
- "lookdownAll",
567
- "getRef",
568
- "getPath",
569
- "setNodeStyles",
570
- "spotByPath",
571
- "keys",
572
- "parse",
573
- "setProps",
574
- "parseDeep",
575
- "variables",
576
- "if",
577
- "log",
578
- "verbose",
579
- "warn",
580
- "error",
581
- "call",
582
- "nextElement",
583
- "previousElement"
584
- ];
585
- var METHODS_EXL = [
586
- ...["node", "context", "extends", "__element", "__ref"],
587
- ...METHODS,
588
- ...STATE_METHODS,
589
- ...PROPS_METHODS
590
- ];
591
-
592
- // ../../../domql/packages/utils/dist/esm/object.js
593
- var __defProp2 = Object.defineProperty;
594
- var __defProps = Object.defineProperties;
595
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
596
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
597
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
598
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
599
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
600
- var __spreadValues = (a, b) => {
601
- for (var prop in b || (b = {}))
602
- if (__hasOwnProp2.call(b, prop))
603
- __defNormalProp(a, prop, b[prop]);
604
- if (__getOwnPropSymbols)
605
- for (var prop of __getOwnPropSymbols(b)) {
606
- if (__propIsEnum.call(b, prop))
607
- __defNormalProp(a, prop, b[prop]);
608
- }
609
- return a;
610
- };
611
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
612
- var merge = (element, obj, excludeFrom = []) => {
613
- for (const e in obj) {
614
- const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, e);
615
- if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__")) {
616
- continue;
617
- }
618
- const elementProp = element[e];
619
- const objProp = obj[e];
620
- if (elementProp === void 0) {
621
- element[e] = objProp;
622
- }
623
- }
624
- return element;
625
- };
626
- var deepMerge = (element, extend, excludeFrom = METHODS_EXL) => {
627
- for (const e in extend) {
628
- const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(extend, e);
629
- if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__")) {
630
- continue;
631
- }
632
- const elementProp = element[e];
633
- const extendProp = extend[e];
634
- if (isObjectLike(elementProp) && isObjectLike(extendProp)) {
635
- deepMerge(elementProp, extendProp, excludeFrom);
636
- } else if (elementProp === void 0) {
637
- element[e] = extendProp;
638
- }
639
- }
640
- return element;
641
- };
642
- var deepClone = (obj, options = {}) => {
643
- const {
644
- exclude = [],
645
- cleanUndefined = false,
646
- cleanNull = false,
647
- window: targetWindow,
648
- visited = /* @__PURE__ */ new WeakMap(),
649
- handleExtends = false
650
- } = options;
651
- const contentWindow = targetWindow || window2 || globalThis;
652
- if (!isObjectLike(obj) || isDOMNode(obj)) {
653
- return obj;
654
- }
655
- if (visited.has(obj)) {
656
- return visited.get(obj);
657
- }
658
- const clone2 = contentWindow ? isArray(obj) ? new contentWindow.Array() : new contentWindow.Object() : isArray(obj) ? [] : {};
659
- visited.set(obj, clone2);
660
- for (const key in obj) {
661
- if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
662
- if (exclude.includes(key) || key.startsWith("__") || key === "__proto__") {
663
- continue;
664
- }
665
- const value = obj[key];
666
- if (cleanUndefined && isUndefined(value) || cleanNull && isNull(value)) {
667
- continue;
668
- }
669
- if (isDOMNode(value)) {
670
- clone2[key] = value;
671
- continue;
672
- }
673
- if (handleExtends && key === "extends" && isArray(value)) {
674
- clone2[key] = unstackArrayOfObjects(value, exclude);
675
- continue;
676
- }
677
- if (isFunction(value) && options.window) {
678
- clone2[key] = contentWindow.eval("(" + value.toString() + ")");
679
- continue;
680
- }
681
- if (isObjectLike(value)) {
682
- clone2[key] = deepClone(value, __spreadProps(__spreadValues({}, options), {
683
- visited
684
- }));
685
- } else {
686
- clone2[key] = value;
687
- }
688
- }
689
- return clone2;
690
- };
691
- var overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new WeakMap()) => {
692
- const excl = opts.exclude || [];
693
- const forcedExclude = opts.preventForce ? [] : ["node", "window"];
694
- if (!isObjectLike(obj) || !isObjectLike(params) || isDOMNode(obj) || isDOMNode(params)) {
695
- return params;
696
- }
697
- if (visited.has(obj)) return visited.get(obj);
698
- visited.set(obj, obj);
699
- for (const e in params) {
700
- if (!Object.hasOwnProperty.call(params, e)) continue;
701
- if (excl.includes(e) || forcedExclude && e.startsWith("__")) continue;
702
- const objProp = obj[e];
703
- const paramsProp = params[e];
704
- if (isDOMNode(paramsProp)) {
705
- obj[e] = paramsProp;
706
- } else if (isObjectLike(objProp) && isObjectLike(paramsProp)) {
707
- obj[e] = overwriteDeep(objProp, paramsProp, opts, visited);
708
- } else if (paramsProp !== void 0) {
709
- obj[e] = paramsProp;
710
- }
711
- }
712
- return obj;
713
- };
714
-
715
- // ../../../domql/packages/utils/dist/esm/env.js
716
- var NODE_ENV = "development";
717
- var isProduction = (env = NODE_ENV) => env === "production";
718
- var isNotProduction = (env = NODE_ENV) => !isProduction(env);
719
-
720
- // ../../../domql/packages/utils/dist/esm/cookie.js
721
- var isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
722
-
723
- // ../../../domql/packages/event/dist/esm/keys.js
724
- var STATE_METHODS2 = [
725
- "update",
726
- "parse",
727
- "clean",
728
- "create",
729
- "destroy",
730
- "add",
731
- "toggle",
732
- "remove",
733
- "apply",
734
- "set",
735
- "reset",
736
- "replace",
737
- "quietReplace",
738
- "quietUpdate",
739
- "applyReplace",
740
- "applyFunction",
741
- "keys",
742
- "values",
743
- "ref",
744
- "rootUpdate",
745
- "parentUpdate",
746
- "parent",
747
- "__element",
748
- "__depends",
749
- "__ref",
750
- "__children",
751
- "root",
752
- "setByPath",
753
- "setPathCollection",
754
- "removeByPath",
755
- "removePathCollection",
756
- "getByPath"
757
- ];
758
- var PROPS_METHODS2 = ["update", "__element"];
759
- var METHODS2 = [
760
- "set",
761
- "reset",
762
- "update",
763
- "remove",
764
- "updateContent",
765
- "removeContent",
766
- "lookup",
767
- "lookdown",
768
- "lookdownAll",
769
- "getRef",
770
- "getPath",
771
- "setNodeStyles",
772
- "spotByPath",
773
- "keys",
774
- "parse",
775
- "setProps",
776
- "parseDeep",
777
- "variables",
778
- "if",
779
- "log",
780
- "verbose",
781
- "warn",
782
- "error",
783
- "call",
784
- "nextElement",
785
- "previousElement"
786
- ];
787
- var METHODS_EXL2 = [
788
- ...["node", "context", "extends", "__element", "__ref"],
789
- ...METHODS2,
790
- ...STATE_METHODS2,
791
- ...PROPS_METHODS2
792
- ];
793
-
794
- // ../../../domql/packages/event/dist/esm/globals.js
795
- var window3 = globalThis;
796
- var document3 = window3.document;
797
-
798
- // src/defaultConfig/index.js
799
- var defaultConfig_exports = {};
800
- __export(defaultConfig_exports, {
801
- ANIMATION: () => ANIMATION,
802
- BREAKPOINTS: () => BREAKPOINTS,
803
- CASES: () => CASES,
804
- CLASS: () => CLASS,
805
- COLOR: () => COLOR,
806
- DEVICES: () => DEVICES,
807
- DOCUMENT: () => DOCUMENT,
808
- FONT: () => FONT,
809
- FONT_FACE: () => FONT_FACE,
810
- FONT_FAMILY: () => FONT_FAMILY,
811
- FONT_FAMILY_TYPES: () => FONT_FAMILY_TYPES,
812
- GRADIENT: () => GRADIENT,
813
- GRID: () => GRID,
814
- ICONS: () => ICONS,
815
- MEDIA: () => MEDIA,
816
- RESET: () => RESET,
817
- SEMANTIC_ICONS: () => SEMANTIC_ICONS,
818
- SEQUENCE: () => SEQUENCE,
819
- SHADOW: () => SHADOW,
820
- SPACING: () => SPACING,
821
- SVG: () => SVG,
822
- SVG_DATA: () => SVG_DATA,
823
- TEMPLATES: () => TEMPLATES,
824
- THEME: () => THEME,
825
- TIMING: () => TIMING,
826
- TYPOGRAPHY: () => TYPOGRAPHY,
827
- UNIT: () => UNIT
828
- });
829
-
830
- // src/defaultConfig/sequence.js
831
- var SEQUENCE = {
832
- "minor-second": 1.067,
833
- "major-second": 1.125,
834
- "minor-third": 1.2,
835
- "major-third": 1.25,
836
- "perfect-fourth": 1.333,
837
- "augmented-fourth": 1.414,
838
- "perfect-fifth": 1.5,
839
- "minor-sixth": 1.6,
840
- phi: 1.618,
841
- // golden-ratio
842
- "major-sixth": 1.667,
843
- "square-root-3": 1.732,
844
- // theodorus
845
- "minor-seventh": 1.778,
846
- "major-seventh": 1.875,
847
- octave: 2,
848
- "square-root-5": 2.23,
849
- // pythagoras
850
- "major-tenth": 2.5,
851
- "major-eleventh": 2.667,
852
- "major-twelfth": 3,
853
- pi: 3.14,
854
- // archimedes
855
- "double-octave": 4
856
- };
857
-
858
- // src/defaultConfig/unit.js
859
- var UNIT = {
860
- default: "em"
861
- };
862
-
863
- // src/defaultConfig/typography.js
864
- var defaultProps = {
865
- browserDefault: 16,
866
- base: 16,
867
- type: "font-size",
868
- ratio: SEQUENCE["minor-third"],
869
- range: [-3, 12],
870
- h1Matches: 6,
871
- lineHeight: 1.5,
872
- subSequence: true,
873
- mediaRegenerate: false,
874
- unit: "em",
875
- templates: {},
876
- sequence: {},
877
- scales: {},
878
- vars: {}
879
- };
880
- var TYPOGRAPHY = defaultProps;
881
-
882
- // src/defaultConfig/font.js
883
- var FONT = {};
884
-
885
- // src/defaultConfig/font-family.js
886
- var FONT_FAMILY = {};
887
- var FONT_FAMILY_TYPES = {
888
- "sans-serif": "Helvetica, Arial, sans-serif, --system-default",
889
- serif: "Times New Roman, Georgia, serif, --system-default",
890
- monospace: "Courier New, monospace, --system-default"
891
- };
892
- var FONT_FACE = {};
893
-
894
- // src/defaultConfig/media.js
895
- var MEDIA = {
896
- tv: "(min-width: 2780px)",
897
- light: "(prefers-color-scheme: light)",
898
- dark: "(prefers-color-scheme: dark)",
899
- print: "print"
900
- };
901
-
902
- // src/defaultConfig/spacing.js
903
- var defaultProps2 = {
904
- base: TYPOGRAPHY.base,
905
- type: "spacing",
906
- ratio: SEQUENCE.phi,
907
- range: [-5, 15],
908
- subSequence: true,
909
- mediaRegenerate: false,
910
- unit: "em",
911
- sequence: {},
912
- scales: {},
913
- vars: {}
914
- };
915
- var SPACING = defaultProps2;
916
-
917
- // src/defaultConfig/color.js
918
- var COLOR = {};
919
- var GRADIENT = {};
920
-
921
- // src/defaultConfig/theme.js
922
- var THEME = {};
923
-
924
- // src/defaultConfig/shadow.js
925
- var SHADOW = {};
926
-
927
- // src/defaultConfig/icons.js
928
- var ICONS = {};
929
- var SEMANTIC_ICONS = {};
930
-
931
- // src/defaultConfig/timing.js
932
- var defaultProps3 = {
933
- default: 150,
934
- base: 150,
935
- type: "timing",
936
- ratio: SEQUENCE["perfect-fourth"],
937
- range: [-3, 12],
938
- mediaRegenerate: false,
939
- unit: "ms",
940
- sequence: {},
941
- scales: {},
942
- vars: {}
943
- };
944
- var TIMING = defaultProps3;
945
-
946
- // src/defaultConfig/document.js
947
- var DOCUMENT = {};
948
-
949
- // src/defaultConfig/responsive.js
950
- var BREAKPOINTS = {
951
- screenL: 1920,
952
- screenM: 1680,
953
- screenS: 1440,
954
- tabletL: 1366,
955
- tabletM: 1280,
956
- tabletS: 1024,
957
- mobileL: 768,
958
- mobileM: 560,
959
- mobileS: 480,
960
- mobileXS: 375
961
- };
962
- var DEVICES = {
963
- screenXXL: [2560, 1440],
964
- screenXL: [2240, 1260],
965
- screenL: [1920, 1024],
966
- screenM: [1680, 1024],
967
- screenS: [1440, 720],
968
- tabletL: [1366, 926],
969
- tabletM: [1280, 768],
970
- tabletS: [1024, 768],
971
- mobileL: [768, 375],
972
- mobileM: [560, 768],
973
- mobileS: [480, 768],
974
- mobileXS: [375, 768]
975
- };
976
-
977
- // src/defaultConfig/cases.js
978
- var CASES = {};
979
-
980
- // src/defaultConfig/animation.js
981
- var ANIMATION = {};
982
-
983
- // src/defaultConfig/svg.js
984
- var SVG = {};
985
- var SVG_DATA = {};
986
-
987
- // src/defaultConfig/templates.js
988
- var TEMPLATES = {};
989
-
990
- // src/defaultConfig/grid.js
991
- var defaultProps4 = {};
992
- var GRID = defaultProps4;
993
-
994
- // src/defaultConfig/class.js
995
- var defaultProps5 = {};
996
- var CLASS = defaultProps5;
997
-
998
- // src/defaultConfig/index.js
999
- var RESET = {};
1000
-
1001
- // src/factory.js
1002
- var CSS_VARS = {};
1003
- var CONFIG = {
1004
- verbose: false,
1005
- useVariable: true,
1006
- useReset: true,
1007
- CSS_VARS,
1008
- ...void 0 || defaultConfig_exports
1009
- };
1010
- var cachedConfig = deepClone(CONFIG);
1011
- var FACTORY = {
1012
- active: "0",
1013
- 0: CONFIG
1014
- };
1015
- var getActiveConfig = (def) => {
1016
- return FACTORY[def || FACTORY.active] || CONFIG;
1017
- };
1018
-
1019
- // src/utils/unit.js
1020
- var isScalingUnit = (unit) => {
1021
- return unit === "em" || unit === "rem" || unit === "vw" || unit === "vh" || unit === "vmax" || unit === "vmin";
1022
- };
1023
-
1024
- // src/utils/color.js
1025
- var colorStringToRgbaArray = (color) => {
1026
- if (color === "") return [0, 0, 0, 0];
1027
- if (color.toLowerCase() === "transparent") return [0, 0, 0, 0];
1028
- if (color[0] === "#") {
1029
- if (color.length < 7) {
1030
- color = "#" + color[1] + color[1] + color[2] + color[2] + color[3] + color[3] + (color.length > 4 ? color[4] + color[4] : "");
1031
- }
1032
- return [
1033
- parseInt(color.substr(1, 2), 16),
1034
- parseInt(color.substr(3, 2), 16),
1035
- parseInt(color.substr(5, 2), 16),
1036
- color.length > 7 ? parseInt(color.substr(7, 2), 16) / 255 : 1
1037
- ];
1038
- }
1039
- if (color.indexOf("rgb") === -1) {
1040
- if (document2 && window2) {
1041
- const elem = document2.body.appendChild(document2.createElement("fictum"));
1042
- const flag = "rgb(1, 2, 3)";
1043
- elem.style.color = flag;
1044
- if (elem.style.color !== flag) {
1045
- document2.body.removeChild(elem);
1046
- return;
1047
- }
1048
- elem.style.color = color;
1049
- if (elem.style.color === flag || elem.style.color === "") {
1050
- document2.body.removeChild(elem);
1051
- return [0, 0, 0, 0];
1052
- }
1053
- color = window2.getComputedStyle(elem).color;
1054
- document2.body.removeChild(elem);
1055
- }
1056
- }
1057
- if (color.indexOf("rgb") === 0) {
1058
- if (color.indexOf("rgba") === -1) color = `${color}, 1`;
1059
- return color.match(/[\.\d]+/g).map((a) => +a);
1060
- }
1061
- return [0, 0, 0, 0];
1062
- };
1063
- var hexToRgbArray = (hex, alpha = 1) => {
1064
- const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16));
1065
- return [r, g, b];
1066
- };
1067
- var rgbArrayToHex = ([r, g, b]) => {
1068
- return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
1069
- };
1070
- var rgbToHSL = (r, g, b) => {
1071
- const a = Math.max(r, g, b);
1072
- const n = a - Math.min(r, g, b);
1073
- const f = 1 - Math.abs(a + a - n - 1);
1074
- const h = n && (a == r ? (g - b) / n : a == g ? 2 + (b - r) / n : 4 + (r - g) / n);
1075
- return [60 * (h < 0 ? h + 6 : h), f ? n / f : 0, (a + a - n) / 2];
1076
- };
1077
- var hslToRgb = (h, s, l, a = s * Math.min(l, 1 - l), f = (n, k = (n + h / 30) % 12) => l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1)) => [f(0), f(8), f(4)];
1078
- var getColorShade = (col, amt) => {
1079
- const num = parseInt(col, 16);
1080
- let r = (num >> 16) + amt;
1081
- if (r > 255) r = 255;
1082
- else if (r < 0) r = 0;
1083
- let b = (num >> 8 & 255) + amt;
1084
- if (b > 255) b = 255;
1085
- else if (b < 0) b = 0;
1086
- let g = (num & 255) + amt;
1087
- if (g > 255) g = 255;
1088
- else if (g < 0) g = 0;
1089
- return ((g | b << 8 | r << 16) + 16777216).toString(16).slice(1);
1090
- };
1091
- var getRgbTone = (rgb, tone) => {
1092
- if (isString(rgb) && rgb.includes("rgb"))
1093
- rgb = colorStringToRgbaArray(rgb).join(", ");
1094
- if (isString(rgb)) rgb = rgb.split(",").map((v) => parseFloat(v.trim()));
1095
- if (isNumber(tone)) tone += "";
1096
- const toHex = rgbArrayToHex(rgb);
1097
- const abs = tone.slice(0, 1);
1098
- if (abs === "-" || abs === "+") {
1099
- const colorShade = getColorShade(toHex, parseFloat(tone));
1100
- return hexToRgbArray(colorShade).join(", ");
1101
- } else {
1102
- const [r, g, b] = rgb;
1103
- const hsl = rgbToHSL(r, g, b);
1104
- const [h, s, l] = hsl;
1105
- const newRgb = hslToRgb(h, s, parseFloat(tone) / 100 * 255);
1106
- return newRgb;
1107
- }
1108
- };
1109
-
1110
- // src/utils/font.js
1111
- var getDefaultOrFirstKey = (LIBRARY, key) => {
1112
- if (LIBRARY[key]) return LIBRARY[key].value;
1113
- if (LIBRARY.default) return LIBRARY[LIBRARY.default].value;
1114
- const hasValue = Object.keys(LIBRARY)[0];
1115
- return hasValue && LIBRARY[hasValue] && LIBRARY[hasValue].value;
1116
- };
1117
- var getFontFormat = (url) => url.split(/[#?]/)[0].split(".").pop().trim();
1118
- var setCustomFont = (name, url, weight) => `
1119
- font-family: '${name}';
1120
- font-style: normal;
1121
- ${weight && `font-weight: ${weight};`}
1122
- src: url('${url}') format('${getFontFormat(url)}');`;
1123
- var setCustomFontMedia = (name, url, weight) => `@font-face {
1124
- ${setCustomFont(name, url, weight)}
1125
- }`;
1126
- var getFontFaceEach = (name, weights) => {
1127
- const keys = Object.keys(weights);
1128
- return keys.map((key) => {
1129
- const { url, fontWeight } = weights[key];
1130
- return setCustomFont(name, url, fontWeight);
1131
- });
1132
- };
1133
-
1134
- // src/utils/sequence.js
1135
- var import_utils5 = __toESM(require_cjs(), 1);
1136
- var numToLetterMap = {
1137
- "-6": "U",
1138
- "-5": "V",
1139
- "-4": "W",
1140
- "-3": "X",
1141
- "-2": "Y",
1142
- "-1": "Z",
1143
- 0: "A",
1144
- 1: "B",
1145
- 2: "C",
1146
- 3: "D",
1147
- 4: "E",
1148
- 5: "F",
1149
- 6: "G",
1150
- 7: "H",
1151
- 8: "I",
1152
- 9: "J",
1153
- 10: "K",
1154
- 11: "L",
1155
- 12: "M",
1156
- 13: "N",
1157
- 14: "O",
1158
- 15: "P",
1159
- 16: "Q",
1160
- 17: "R",
1161
- 18: "S",
1162
- 19: "T"
1163
- };
1164
- var setSequenceValue = (props, sequenceProps) => {
1165
- const { key, variable, value, scaling, index, scalingVariable } = props;
1166
- sequenceProps.sequence[key] = {
1167
- key,
1168
- decimal: ~~(value * 100) / 100,
1169
- val: ~~value,
1170
- scaling,
1171
- index,
1172
- scalingVariable,
1173
- variable
1174
- };
1175
- sequenceProps.scales[key] = scaling;
1176
- sequenceProps.vars[variable] = scaling + sequenceProps.unit;
1177
- };
1178
- var setScalingVar = (key, sequenceProps) => {
1179
- const { base, type, unit } = sequenceProps;
1180
- const defaultVal = (isScalingUnit(unit) ? 1 : base) + unit;
1181
- if (key === 0) return defaultVal;
1182
- const prefix = "--" + (type && type.replace(".", "-"));
1183
- const ratioVar = `${prefix}-ratio`;
1184
- if (key > 0) {
1185
- const prevLetterKey = numToLetterMap[key - 1];
1186
- return `calc(var(${prefix}-${prevLetterKey}) * var(${ratioVar}))`;
1187
- }
1188
- if (key < 0) {
1189
- const nextLetterKey = numToLetterMap[key + 1];
1190
- return `calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar}))`;
1191
- }
1192
- };
1193
- var setSubScalingVar = (index, arr, variable, sequenceProps) => {
1194
- const { type } = sequenceProps;
1195
- const skipMiddle = index === 2 && arr.length === 2;
1196
- const indexMapWithLength = skipMiddle ? index + 1 : index;
1197
- const prefix = "--" + (type && type.replace(".", "-"));
1198
- const subRatioVarPrefix = `${prefix}-sub-ratio-`;
1199
- return `calc(var(${variable}) * var(${subRatioVarPrefix + indexMapWithLength}))`;
1200
- };
1201
- var getSubratioDifference = (base, ratio) => {
1202
- const diff = base * ratio - base;
1203
- const subRatio = diff / 1.618;
1204
- const first = base * ratio - subRatio;
1205
- const second = base + subRatio;
1206
- const middle = (first + second) / 2;
1207
- return [first, middle, second];
1208
- };
1209
- var getSubratio = (base, ratio) => {
1210
- return getSubratioDifference(base, ratio).map((v) => v / base);
1211
- };
1212
- var generateSubSequence = (props, sequenceProps) => {
1213
- const { key, base, value, ratio, variable, index } = props;
1214
- const next = value * ratio;
1215
- const diffRounded = ~~next - ~~value;
1216
- let arr;
1217
- const [first, middle, second] = getSubratioDifference(value, ratio);
1218
- if (diffRounded > 16) arr = [first, middle, second];
1219
- else arr = [first, second];
1220
- arr.forEach((v, k) => {
1221
- const scaling = ~~(v / base * 1e3) / 1e3;
1222
- const newVar = variable + (k + 1);
1223
- const newIndex = index + (k + 1) / 10;
1224
- const scalingVariable = setSubScalingVar(k + 1, arr, variable, sequenceProps);
1225
- const props2 = {
1226
- key: key + (k + 1),
1227
- variable: newVar,
1228
- value: v,
1229
- scaling,
1230
- scalingVariable,
1231
- index: newIndex
1232
- };
1233
- setSequenceValue(props2, sequenceProps);
1234
- });
1235
- };
1236
- var switchSequenceOnNegative = (key, base, ratio) => {
1237
- return base * Math.pow(ratio, key);
1238
- };
1239
- var generateSequence = (sequenceProps) => {
1240
- const { type, base, ratio, range, subSequence } = sequenceProps;
1241
- const n = Math.abs(range[0]) + Math.abs(range[1]);
1242
- const prefix = "--" + (type && type.replace(".", "-")) + "-";
1243
- for (let i = 0; i <= n; i++) {
1244
- const key = range[1] - i;
1245
- const letterKey = numToLetterMap[key];
1246
- const value = switchSequenceOnNegative(key, base, ratio);
1247
- const scaling = ~~(value / base * 100) / 100;
1248
- const variable = prefix + letterKey;
1249
- const scalingVariable = setScalingVar(key, sequenceProps);
1250
- const props = {
1251
- key: letterKey,
1252
- variable,
1253
- value,
1254
- base,
1255
- scaling,
1256
- scalingVariable,
1257
- ratio,
1258
- index: key
1259
- };
1260
- setSequenceValue(props, sequenceProps);
1261
- if (subSequence) generateSubSequence(props, sequenceProps);
1262
- }
1263
- return sequenceProps;
1264
- };
1265
- var getSequenceValue = (value = "A", sequenceProps) => {
1266
- const CONFIG2 = getActiveConfig();
1267
- const { UNIT: UNIT2 } = CONFIG2;
1268
- const {
1269
- sequence,
1270
- unit = UNIT2.default,
1271
- useVariable
1272
- } = sequenceProps;
1273
- if (isString(value) && value.slice(0, 2) === "--") return `var(${value})`;
1274
- const prefix = `--${(0, import_utils5.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
1275
- const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
1276
- const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
1277
- if (value === "none" || value === "auto" || value === "unset" || value === "inherit" || value === "fit-content" || value === "min-content" || value === "max-content" || value.includes("calc") || value.includes("var") || !startsWithDashOrLetter) return value;
1278
- const letterVal = value.toUpperCase();
1279
- const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
1280
- let absValue = isNegative ? letterVal.slice(1) : letterVal;
1281
- let mediaName = "";
1282
- if (absValue.includes("_")) {
1283
- mediaName = "_" + absValue.split("_")[1].toLowerCase();
1284
- absValue = absValue.split("_")[0];
1285
- }
1286
- const varValue = (v) => startsWithDashOrLetterRegex.test(v) ? `var(${prefix}${v}${mediaName})` : v;
1287
- if (absValue.includes("+")) {
1288
- const [first, second] = absValue.split("+");
1289
- const joint = `${varValue(first)} + ${varValue(second)}`;
1290
- return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
1291
- } else if (absValue.includes("*")) {
1292
- const [first, second] = absValue.split("*");
1293
- const joint = `${varValue(first)} * ${varValue(second)}`;
1294
- return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
1295
- } else if (absValue.includes("-")) {
1296
- const [first, second] = absValue.split("-");
1297
- const joint = `${varValue(first)} - ${varValue(second)}`;
1298
- return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
1299
- }
1300
- if (!sequence[absValue] && absValue.length === 2) {
1301
- if (CONFIG2.verbose) console.warn(absValue, "- value is not found because `subSequence` is set to false");
1302
- absValue = absValue.slice(0, 1);
1303
- }
1304
- if (useVariable || CONFIG2.useVariable) {
1305
- const varValue2 = `var(${prefix}${absValue}${mediaName})`;
1306
- return isNegative ? `calc(${varValue2} * -1)` : varValue2;
1307
- }
1308
- const sequenceItem = sequence ? sequence[absValue] : null;
1309
- if (!sequenceItem) return console.warn("can't find", sequence, absValue);
1310
- if (unit === "ms" || unit === "s") {
1311
- return isNegative + sequenceItem.val + unit;
1312
- }
1313
- return isNegative + sequenceItem.scaling + unit;
1314
- };
1315
- var getSequenceValuePropertyPair = (value, propertyName, sequenceProps) => {
1316
- if (typeof value !== "string") {
1317
- const CONFIG2 = getActiveConfig();
1318
- if (CONFIG2.verbose) console.warn(propertyName, value, "is not a string");
1319
- return { [propertyName]: value };
1320
- }
1321
- if (value === "-" || value === "") return {};
1322
- return { [propertyName]: getSequenceValue(value, sequenceProps) };
1323
- };
1324
- var findHeadingLetter = (h1Matches, index) => numToLetterMap[h1Matches - index];
1325
- var findHeadings = (propertyNames) => {
1326
- const { h1Matches, sequence } = propertyNames;
1327
- return new Array(6).fill(null).map((_, i) => {
1328
- const findLetter = findHeadingLetter(h1Matches, i);
1329
- return sequence[findLetter];
1330
- });
1331
- };
1332
-
1333
- // src/utils/var.js
1334
- var applySequenceGlobalVars = (vars, obj, options) => {
1335
- const CONFIG2 = getActiveConfig();
1336
- const { UNIT: UNIT2 } = CONFIG2;
1337
- const unit = obj.unit || UNIT2.default;
1338
- const { base, ratio, type } = obj;
1339
- const prefix = "--" + (type && type.replace(".", "-"));
1340
- vars[`${prefix}-base`] = base;
1341
- vars[`${prefix}-unit`] = unit;
1342
- const ratioVar = `${prefix}-ratio`;
1343
- vars[ratioVar] = ratio;
1344
- const [first, middle, second] = getSubratio(base, ratio);
1345
- vars[`${prefix}-sub-ratio-1`] = `calc(var(${prefix}-ratio) * ${first / ratio})`;
1346
- vars[`${prefix}-sub-ratio-2`] = `calc(var(${prefix}-ratio) * ${middle / ratio})`;
1347
- vars[`${prefix}-sub-ratio-3`] = `calc(var(${prefix}-ratio) * ${second / ratio})`;
1348
- };
1349
- var applySequenceVars = (FACTORY2, options = {}) => {
1350
- const CONFIG2 = getActiveConfig();
1351
- const { UNIT: UNIT2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
1352
- const unit = FACTORY2.unit || UNIT2.default;
1353
- const { mediaRegenerate, sequence, scales } = FACTORY2;
1354
- if (!mediaRegenerate) {
1355
- applySequenceGlobalVars(CSS_VARS2, FACTORY2, options);
1356
- }
1357
- for (const key in sequence) {
1358
- const item = sequence[key];
1359
- const value = (FACTORY2.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
1360
- if (!mediaRegenerate) {
1361
- CSS_VARS2[item.variable + "_default"] = value;
1362
- CSS_VARS2[item.variable] = item.scalingVariable;
1363
- continue;
1364
- }
1365
- if (options.useDefault === false) {
1366
- CSS_VARS2[item.variable] = value;
1367
- } else {
1368
- CSS_VARS2[item.variable + "_default"] = value;
1369
- CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
1370
- }
1371
- }
1372
- };
1373
- var applyMediaSequenceVars = (FACTORY2, media, options = {}) => {
1374
- const CONFIG2 = getActiveConfig();
1375
- const { UNIT: UNIT2, MEDIA: MEDIA2, CSS_VARS: CSS_VARS2 } = CONFIG2;
1376
- const mediaName = media.slice(1);
1377
- const unit = FACTORY2.unit || UNIT2.default;
1378
- const { mediaRegenerate } = FACTORY2;
1379
- const { sequence, scales } = FACTORY2[media];
1380
- const query = MEDIA2[mediaName];
1381
- if (!query && CONFIG2.verbose) console.warn("Can't find media query ", query);
1382
- if (!mediaRegenerate) {
1383
- let underMediaQuery = CSS_VARS2[`@media ${query}`];
1384
- if (!underMediaQuery) underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
1385
- applySequenceGlobalVars(underMediaQuery, FACTORY2[media], options);
1386
- return;
1387
- }
1388
- for (const key in sequence) {
1389
- const item = sequence[key];
1390
- const value = (isScalingUnit(unit) ? scales[key] : sequence[key].val) + unit;
1391
- if (!query && CONFIG2.verbose) console.warn("Can't find query ", query);
1392
- let underMediaQuery = CSS_VARS2[`@media ${query}`];
1393
- if (!underMediaQuery) underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
1394
- underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
1395
- CSS_VARS2[item.variable + "_" + mediaName] = value;
1396
- }
1397
- };
1398
-
1399
- // src/utils/sprite.js
1400
- var isDev = isNotProduction();
1401
- var generateSprite = (icons) => {
1402
- const CONFIG2 = getActiveConfig();
1403
- let sprite = "";
1404
- for (const key in icons) {
1405
- if (CONFIG2.__svg_cache[key]) continue;
1406
- else CONFIG2.__svg_cache[key] = true;
1407
- sprite += icons[key];
1408
- }
1409
- return sprite;
1410
- };
1411
- var parseRootAttributes = (htmlString) => {
1412
- const val = htmlString.default || htmlString;
1413
- if (!isString(val)) {
1414
- if (isDev) console.warn("parseRootAttributes:", val, "is not a string");
1415
- return;
1416
- }
1417
- const match = val.match(/<svg\s+(.*?)>/);
1418
- if (!match || !match[1]) {
1419
- return {};
1420
- }
1421
- const attrString = match[1];
1422
- const attrs = attrString.match(
1423
- /(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm
1424
- );
1425
- return attrs.reduce((acc, attr) => {
1426
- const [key, value] = attr.split("=");
1427
- acc[key] = value.replace(/['"]/g, "");
1428
- return acc;
1429
- }, {});
1430
- };
1431
- var replaceIdsAndUrls = (code, key) => {
1432
- const idRegex = /id="([^"]*)"/;
1433
- const urlRegex = /url\(#([^)]*)\)/g;
1434
- const matches = code.match(/id="([^"]*)"/g);
1435
- let replacedCode = code;
1436
- if (isArray(matches)) {
1437
- matches.forEach(() => {
1438
- const randomKey = Math.floor(Math.random() * 1e5);
1439
- replacedCode = code.replace(idRegex, `id="${key}-${randomKey}"`).replace(urlRegex, `url(#${key}-${randomKey})`);
1440
- });
1441
- }
1442
- return replacedCode;
1443
- };
1444
- var convertSvgToSymbol = (key, code) => {
1445
- const extractAttrs = parseRootAttributes(code);
1446
- const { width, height } = extractAttrs;
1447
- const viewBox = extractAttrs.viewBox || `0 0 ${width || 24} ${height || 24}`;
1448
- const xmlns = "http://www.w3.org/2000/svg";
1449
- const replacedCode = replaceIdsAndUrls(code, key);
1450
- let symbol = replacedCode.replace(
1451
- "<svg",
1452
- `<symbol id="${key}" xmlns="${xmlns}" viewBox="${viewBox}"`
1453
- );
1454
- symbol = symbol.replace(/width="[^"]*"/, "");
1455
- symbol = symbol.replace(/height="[^"]*"/, "");
1456
- symbol = symbol.replace("</svg", "</symbol");
1457
- return symbol;
1458
- };
1459
-
1460
- // src/system/color.js
1461
- var getColor = (value, key, config) => {
1462
- const CONFIG2 = config || getActiveConfig();
1463
- if (!isString(value)) {
1464
- if (CONFIG2.verbose) console.warn(value, "- type for color is not valid");
1465
- return;
1466
- }
1467
- if (value.slice(0, 2) === "--") return `var(${value})`;
1468
- if (key && value[key]) value = value[key];
1469
- const [name, alpha, tone] = isArray(value) ? value : value.split(" ");
1470
- const { COLOR: COLOR2, GRADIENT: GRADIENT2 } = CONFIG2;
1471
- let val = COLOR2[name] || GRADIENT2[name];
1472
- if (!val) {
1473
- if (CONFIG2.verbose) console.warn("Can't find color ", name);
1474
- return value;
1475
- }
1476
- if (key) {
1477
- if (val[key]) val = val[key];
1478
- else if (CONFIG2.verbose) console.warn(value, " - does not have ", key);
1479
- }
1480
- let rgb = val.rgb;
1481
- if (!rgb) {
1482
- return CONFIG2.useVariable ? `var(${val.var})` : val.value;
1483
- }
1484
- if (tone && !val[tone]) {
1485
- rgb = getRgbTone(rgb, tone);
1486
- val[tone] = { rgb, var: `${val.var}-${tone}` };
1487
- }
1488
- if (val[tone]) rgb = val[tone].rgb;
1489
- if (alpha) return `rgba(${rgb}, ${alpha})`;
1490
- return CONFIG2.useVariable ? `var(${val.var})` : `rgb(${rgb})`;
1491
- };
1492
- var getMediaColor = (value, globalTheme, config) => {
1493
- const CONFIG2 = config || getActiveConfig();
1494
- if (!globalTheme) globalTheme = CONFIG2.globalTheme;
1495
- if (!isString(value)) {
1496
- if (CONFIG2.verbose) console.warn(value, "- type for color is not valid");
1497
- return;
1498
- }
1499
- if (value.slice(0, 2) === "--") return `var(${value})`;
1500
- const [name] = isArray(value) ? value : value.split(" ");
1501
- const { COLOR: COLOR2, GRADIENT: GRADIENT2 } = CONFIG2;
1502
- const val = COLOR2[name] || GRADIENT2[name];
1503
- const isObj = isObject(val);
1504
- if (isObj && val.value) return getColor(value, `@${globalTheme}`, config);
1505
- else if (isObj) {
1506
- if (globalTheme) return getColor(value, `@${globalTheme}`, config);
1507
- else {
1508
- const obj = {};
1509
- for (const mediaName in val) {
1510
- const query = CONFIG2.MEDIA[mediaName.slice(1)];
1511
- const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
1512
- obj[media] = getColor(value, mediaName, config);
1513
- }
1514
- return obj;
1515
- }
1516
- } else {
1517
- if (CONFIG2.verbose) console.warn("Can't find color", value);
1518
- return value;
1519
- }
1520
- };
1521
- var setColor = (val, key, suffix) => {
1522
- const CONFIG2 = getActiveConfig();
1523
- if (isString(val) && val.slice(0, 2) === "--") {
1524
- val = getColor(val.slice(2));
1525
- if (!(val.includes("rgb") || val.includes("var") || val.includes("#"))) {
1526
- if (CONFIG2.verbose) console.warn(val, "- referred but does not exist");
1527
- val = val.split(" ")[0];
1528
- }
1529
- }
1530
- if (isArray(val)) {
1531
- return {
1532
- "@light": setColor(val[0], key, "light"),
1533
- "@dark": setColor(val[1], key, "dark")
1534
- };
1535
- }
1536
- if (isObject(val)) {
1537
- const obj = {};
1538
- for (const variant in val) {
1539
- obj[variant] = setColor(
1540
- val[variant],
1541
- key,
1542
- variant.slice(0, 1) === "@" ? variant.slice(1) : variant
1543
- );
1544
- }
1545
- return obj;
1546
- }
1547
- const CSSVar = `--color-${key}` + (suffix ? `-${suffix}` : "");
1548
- const colorArr = colorStringToRgbaArray(val.value || val);
1549
- const [r, g, b, a = 1] = colorArr;
1550
- const alpha = parseFloat(a.toFixed(2));
1551
- const rgb = `${r}, ${g}, ${b}`;
1552
- const value = `rgba(${rgb}, ${alpha})`;
1553
- if (CONFIG2.useVariable) {
1554
- CONFIG2.CSS_VARS[CSSVar] = value;
1555
- }
1556
- return {
1557
- var: CSSVar,
1558
- rgb,
1559
- alpha,
1560
- value
1561
- };
1562
- };
1563
- var setGradient = (val, key, suffix) => {
1564
- const CONFIG2 = getActiveConfig();
1565
- if (isString(val) && val.slice(0, 2) === "--") val = getColor(val.slice(2));
1566
- if (isArray(val)) {
1567
- return {
1568
- "@light": setGradient(val[0], key, "light"),
1569
- "@dark": setGradient(val[0], key, "dark")
1570
- };
1571
- }
1572
- if (isObject(val)) {
1573
- const obj = {};
1574
- for (const variant in val) obj[variant] = setGradient(val[variant], key, variant.slice(0, 1) === "@" ? variant.slice(1) : variant);
1575
- return obj;
1576
- }
1577
- const CSSVar = `--gradient-${key}` + (suffix ? `-${suffix}` : "");
1578
- if (CONFIG2.useVariable) {
1579
- CONFIG2.CSS_VARS[CSSVar] = val.value || val;
1580
- }
1581
- return {
1582
- var: CSSVar,
1583
- value: val.value || val
1584
- };
1585
- };
1586
-
1587
- // src/system/theme.js
1588
- var setThemeValue = (theme) => {
1589
- const value = {};
1590
- const { state, media, helpers, ...rest } = theme;
1591
- const keys = Object.keys(rest);
1592
- keys.map((key) => {
1593
- const conditions = ["color", "Color", "background", "border"];
1594
- const isColor = conditions.some((k) => key.includes(k));
1595
- return value[key] = isColor ? getColor(theme[key]) : theme[key];
1596
- });
1597
- return value;
1598
- };
1599
- var getThemeValue = (theme) => {
1600
- if (theme.value) return theme.value;
1601
- theme.value = setThemeValue(theme);
1602
- return theme.value;
1603
- };
1604
- var getTheme = (value, modifier) => {
1605
- const CONFIG2 = getActiveConfig();
1606
- if (CONFIG2.useVariable) return getMediaTheme(value, modifier);
1607
- const { THEME: THEME2 } = CONFIG2;
1608
- if (isString(value)) {
1609
- const [theme, subtheme] = value.split(" ");
1610
- const isOurTheme = THEME2[theme];
1611
- if (isOurTheme) {
1612
- if (!subtheme && !modifier) return getThemeValue(isOurTheme);
1613
- value = [theme, subtheme || modifier];
1614
- }
1615
- }
1616
- if (isObjectLike(value) && value[1]) {
1617
- const themeName = value[0];
1618
- const subThemeName = value[1];
1619
- const { helpers, media, state } = THEME2[themeName];
1620
- if (media && media[subThemeName]) return getThemeValue(media[subThemeName]);
1621
- if (helpers && helpers[subThemeName]) return getThemeValue(helpers[subThemeName]);
1622
- if (state && state[subThemeName]) return getThemeValue(state[subThemeName]);
1623
- } else if (isObject(value)) return setThemeValue(value);
1624
- };
1625
- var setInverseTheme = (theme, variant, value) => {
1626
- if (isObject(variant)) {
1627
- theme.variants.inverse.value = setThemeValue(variant);
1628
- } else if (variant === true) {
1629
- const { color, background } = value;
1630
- theme.variants.inverse = {
1631
- value: {
1632
- color: background,
1633
- background: color
1634
- }
1635
- };
1636
- }
1637
- };
1638
- var setPseudo = (theme, key, variant, themeValue) => {
1639
- const result = getTheme(variant);
1640
- themeValue[`&:${key}`] = result;
1641
- if (isObject(variant) && !variant.value) variant.value = result;
1642
- };
1643
- var setSelectors = (theme, value) => {
1644
- const { state } = theme;
1645
- if (!state) return;
1646
- const keys = Object.keys(state);
1647
- keys.map((key) => {
1648
- const variant = state[key];
1649
- setPseudo(theme, key, variant, value);
1650
- return theme;
1651
- });
1652
- return theme;
1653
- };
1654
- var setPrefersScheme = (theme, key, variant, themeValue) => {
1655
- const result = getTheme(variant);
1656
- themeValue[`@media (prefers-color-scheme: ${key})`] = result;
1657
- if (isObject(variant) && !variant.value) variant.value = result;
1658
- };
1659
- var setMedia = (theme, value) => {
1660
- const { media } = theme;
1661
- if (!media) return;
1662
- const keys = Object.keys(media);
1663
- keys.map((key) => {
1664
- const variant = media[key];
1665
- if (key === "dark" || key === "light") setPrefersScheme(theme, key, variant, value);
1666
- if (key === "inverse") setInverseTheme(theme, variant, value);
1667
- return theme;
1668
- });
1669
- return theme;
1670
- };
1671
- var setHelpers = (theme, value) => {
1672
- const CONFIG2 = getActiveConfig();
1673
- const { helpers } = theme;
1674
- if (!helpers) return;
1675
- const keys = Object.keys(helpers);
1676
- keys.map((key) => {
1677
- const helper = helpers[key];
1678
- if (isString(helper)) helpers[key] = CONFIG2.THEME[helper];
1679
- else getThemeValue(helpers[key]);
1680
- return theme;
1681
- });
1682
- return theme;
1683
- };
1684
- var setTheme = (val, key) => {
1685
- const CONFIG2 = getActiveConfig();
1686
- if (CONFIG2.useVariable) return setMediaTheme(val, key);
1687
- const { state, media, helpers } = val;
1688
- const value = setThemeValue(val, key);
1689
- const CSSvar = `--theme-${key}`;
1690
- setSelectors(val, value);
1691
- setMedia(val, value);
1692
- setHelpers(val, value);
1693
- return { var: CSSvar, value, state, media, helpers };
1694
- };
1695
- var setMediaTheme = (val, key, suffix, prefers) => {
1696
- const CONFIG2 = getActiveConfig();
1697
- const { CSS_VARS: CSS_VARS2 } = CONFIG2;
1698
- const theme = { value: val };
1699
- if (isObjectLike(val)) {
1700
- for (const param in val) {
1701
- const symb = param.slice(0, 1);
1702
- const value = val[param];
1703
- if (symb === "@" || symb === ":" || symb === ".") {
1704
- const hasPrefers = symb === "@" && param;
1705
- theme[param] = setMediaTheme(value, key, param, prefers || hasPrefers);
1706
- } else {
1707
- const color = getColor(value, prefers);
1708
- const metaSuffixes = [...new Set([prefers, suffix].filter((v) => v).map((v) => v.slice(1)))];
1709
- const varmetaSuffixName = metaSuffixes.length ? "-" + metaSuffixes.join("-") : "";
1710
- const CSSVar = `--theme-${key}${varmetaSuffixName}-${param}`;
1711
- if (CONFIG2.useVariable) {
1712
- CSS_VARS2[CSSVar] = color;
1713
- theme[param] = `var(${CSSVar})`;
1714
- } else {
1715
- theme[param] = color;
1716
- }
1717
- theme[`.${param}`] = { [param]: theme[param] };
1718
- }
1719
- }
1720
- if (theme.background || theme.color || theme.backgroundColor) {
1721
- theme[".inversed"] = {
1722
- color: theme.background || theme.backgroundColor,
1723
- background: theme.color
1724
- };
1725
- }
1726
- }
1727
- if (isString(val) && val.slice(0, 2) === "--") {
1728
- const { THEME: THEME2 } = CONFIG2;
1729
- const value = THEME2[val.slice(2)];
1730
- const getReferenced = getMediaTheme(value, prefers);
1731
- return getReferenced;
1732
- }
1733
- return theme;
1734
- };
1735
- var recursiveTheme = (val) => {
1736
- const CONFIG2 = getActiveConfig();
1737
- const obj = {};
1738
- for (const param in val) {
1739
- const symb = param.slice(0, 1);
1740
- if (isObjectLike(val[param])) {
1741
- if (symb === "@") {
1742
- const query = CONFIG2.MEDIA[param.slice(1)];
1743
- const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
1744
- obj[media] = recursiveTheme(val[param]);
1745
- } else if (symb === ":") {
1746
- obj[`&${param}`] = recursiveTheme(val[param]);
1747
- }
1748
- } else obj[param] = val[param];
1749
- }
1750
- return obj;
1751
- };
1752
- var findModifierFromArray = (val, modifierArray) => {
1753
- const currentMod = modifierArray.shift();
1754
- if (val[currentMod]) return findModifierFromArray(val[currentMod], modifierArray);
1755
- return val;
1756
- };
1757
- var findModifier = (val, modifier) => {
1758
- if (isArray(modifier)) return findModifierFromArray(val, modifier);
1759
- else if (isString(modifier) && val[modifier]) return val[modifier];
1760
- else return val;
1761
- };
1762
- var getMediaTheme = (value, modifier) => {
1763
- const activeConfig = getActiveConfig();
1764
- if (isString(value) && value.slice(0, 2) === "--") {
1765
- value = getMediaTheme(value.slice(2));
1766
- }
1767
- if (!value || !isString(value)) {
1768
- if (activeConfig.verbose) {
1769
- console.warn(`${value} - Theme is not a string`);
1770
- }
1771
- return;
1772
- }
1773
- const [themeName, ...themeModifiers] = isArray(value) ? value : value.split(" ");
1774
- let themeValue = activeConfig.THEME[themeName];
1775
- if (themeValue && (themeModifiers || modifier)) {
1776
- themeValue = findModifier(themeValue, themeModifiers.length ? themeModifiers : modifier);
1777
- }
1778
- const resolvedTheme = recursiveTheme(themeValue);
1779
- return resolvedTheme;
1780
- };
1781
-
1782
- // src/system/font.js
1783
- var import_utils12 = __toESM(require_cjs(), 1);
1784
- var setFont = (val, key) => {
1785
- const CSSvar = `--font-${key}`;
1786
- if (!val || isArray(val) && !val[0]) return;
1787
- const fontFace = val[0] ? getFontFaceEach(key, val) : setCustomFontMedia(key, val.url);
1788
- return { var: CSSvar, value: val, fontFace };
1789
- };
1790
- var getFontFamily = (key, factory) => {
1791
- const CONFIG2 = getActiveConfig();
1792
- const { FONT_FAMILY: FONT_FAMILY2 } = CONFIG2;
1793
- return getDefaultOrFirstKey(factory || FONT_FAMILY2, key);
1794
- };
1795
- var setFontFamily = (val, key) => {
1796
- const CONFIG2 = getActiveConfig();
1797
- const { FONT_FAMILY: FONT_FAMILY2, FONT_FAMILY_TYPES: FONT_FAMILY_TYPES2 } = CONFIG2;
1798
- let { value, type } = val;
1799
- if (val.isDefault) FONT_FAMILY2.default = key;
1800
- if (isObject(value)) value = (0, import_utils12.arrayzeValue)(value);
1801
- const CSSvar = `--font-family-${key}`;
1802
- const str = `${value.join(", ")}, ${FONT_FAMILY_TYPES2[type]}`;
1803
- return { var: CSSvar, value: str, arr: value, type };
1804
- };
1805
-
1806
- // src/system/typography.js
1807
- var runThroughMedia = (FACTORY2) => {
1808
- const CONFIG2 = getActiveConfig();
1809
- const { TYPOGRAPHY: TYPOGRAPHY2, MEDIA: MEDIA2 } = CONFIG2;
1810
- for (const prop in FACTORY2) {
1811
- const isPropMedia = prop.slice(0, 1) === "@";
1812
- const mediaValue = FACTORY2[prop];
1813
- if (!isPropMedia) continue;
1814
- const { mediaRegenerate } = FACTORY2;
1815
- const mediaName = prop.slice(1);
1816
- const { type, base, ratio, range, subSequence, h1Matches, unit } = FACTORY2;
1817
- merge(mediaValue, {
1818
- type,
1819
- base,
1820
- ratio,
1821
- range,
1822
- subSequence,
1823
- h1Matches,
1824
- unit
1825
- });
1826
- const query = MEDIA2[mediaName];
1827
- const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
1828
- TYPOGRAPHY2.templates[media] = {
1829
- fontSize: mediaValue.base / TYPOGRAPHY2.browserDefault + unit
1830
- };
1831
- if (!mediaRegenerate) {
1832
- applyMediaSequenceVars(FACTORY2, prop);
1833
- continue;
1834
- }
1835
- merge(mediaValue, {
1836
- sequence: {},
1837
- scales: {},
1838
- templates: {},
1839
- vars: {}
1840
- });
1841
- generateSequence(mediaValue);
1842
- applyMediaSequenceVars(FACTORY2, prop);
1843
- }
1844
- };
1845
- var applyHeadings = (props) => {
1846
- var _a, _b;
1847
- const CONFIG2 = getActiveConfig();
1848
- if (props.h1Matches) {
1849
- const unit = props.unit;
1850
- const HEADINGS = findHeadings(props);
1851
- const { templates } = props;
1852
- for (const k in HEADINGS) {
1853
- const headerName = `h${parseInt(k) + 1}`;
1854
- const headerStyle = templates[headerName];
1855
- templates[headerName] = {
1856
- fontSize: CONFIG2.useVariable ? `var(${(_a = HEADINGS[k]) == null ? void 0 : _a.variable})` : `${(_b = HEADINGS[k]) == null ? void 0 : _b.scaling}${unit}`,
1857
- margin: headerStyle ? headerStyle.margin : 0,
1858
- lineHeight: headerStyle ? headerStyle.lineHeight : props.lineHeight,
1859
- letterSpacing: headerStyle ? headerStyle.letterSpacing : props.letterSpacing,
1860
- fontWeight: headerStyle ? headerStyle.fontWeight : 900 - k * 100
1861
- };
1862
- }
1863
- }
1864
- };
1865
- var applyTypographySequence = () => {
1866
- const CONFIG2 = getActiveConfig();
1867
- const { TYPOGRAPHY: TYPOGRAPHY2 } = CONFIG2;
1868
- generateSequence(TYPOGRAPHY2);
1869
- applyHeadings(TYPOGRAPHY2);
1870
- applySequenceVars(TYPOGRAPHY2);
1871
- runThroughMedia(TYPOGRAPHY2);
1872
- };
1873
- var getFontSizeByKey = (value) => {
1874
- const CONFIG2 = getActiveConfig();
1875
- const { TYPOGRAPHY: TYPOGRAPHY2 } = CONFIG2;
1876
- return getSequenceValuePropertyPair(value, "fontSize", TYPOGRAPHY2);
1877
- };
1878
-
1879
- // src/system/spacing.js
1880
- var import_utils16 = __toESM(require_cjs(), 1);
1881
- var runThroughMedia2 = (FACTORY2) => {
1882
- for (const prop in FACTORY2) {
1883
- const mediaProps = FACTORY2[prop];
1884
- const isMediaName = prop.slice(0, 1) === "@";
1885
- if (!isMediaName) continue;
1886
- const {
1887
- type,
1888
- base,
1889
- ratio,
1890
- range,
1891
- subSequence,
1892
- h1Matches,
1893
- unit
1894
- } = FACTORY2;
1895
- merge(mediaProps, {
1896
- type,
1897
- base,
1898
- ratio,
1899
- range,
1900
- subSequence,
1901
- h1Matches,
1902
- unit,
1903
- sequence: {},
1904
- scales: {},
1905
- templates: {},
1906
- vars: {}
1907
- });
1908
- generateSequence(mediaProps);
1909
- applyMediaSequenceVars(FACTORY2, prop);
1910
- }
1911
- };
1912
- var applySpacingSequence = () => {
1913
- const CONFIG2 = getActiveConfig();
1914
- const { SPACING: SPACING2 } = CONFIG2;
1915
- generateSequence(SPACING2);
1916
- applySequenceVars(SPACING2);
1917
- runThroughMedia2(SPACING2);
1918
- };
1919
- var getSequence = (sequenceProps) => {
1920
- const CONFIG2 = getActiveConfig();
1921
- const { SPACING: SPACING2 } = CONFIG2;
1922
- if (!sequenceProps) return SPACING2;
1923
- const hasGenerated = Object.keys(sequenceProps.sequence).length > 0;
1924
- return hasGenerated ? sequenceProps : generateSequence(sequenceProps);
1925
- };
1926
- var getSpacingByKey = (value, propertyName = "padding", sequenceProps) => {
1927
- const sequence = getSequence(sequenceProps);
1928
- if (isString(value) && (value.includes("calc") || value.includes("var"))) {
1929
- return { [propertyName]: value };
1930
- }
1931
- const stack = (0, import_utils16.arrayzeValue)(value);
1932
- if (!isArray(stack)) return;
1933
- if (stack.length > 1) {
1934
- let suffix = "";
1935
- if (propertyName === "borderWidth") {
1936
- propertyName = "border";
1937
- suffix = "Width";
1938
- }
1939
- const directions = {
1940
- 2: ["Block", "Inline"],
1941
- 3: ["BlockStart", "Inline", "BlockEnd"],
1942
- 4: ["BlockStart", "InlineEnd", "BlockEnd", "InlineStart"]
1943
- };
1944
- const wrapSequenceValueByDirection = (direction, i) => getSequenceValuePropertyPair(
1945
- stack[i],
1946
- propertyName + direction + suffix,
1947
- sequence
1948
- );
1949
- return directions[stack.length].map((dir, key) => wrapSequenceValueByDirection(dir, key));
1950
- }
1951
- return getSequenceValuePropertyPair(
1952
- value,
1953
- propertyName,
1954
- sequence
1955
- );
1956
- };
1957
- var getSpacingBasedOnRatio = (props, propertyName, val) => {
1958
- const CONFIG2 = getActiveConfig();
1959
- const { SPACING: SPACING2 } = CONFIG2;
1960
- const { spacingRatio, unit } = props;
1961
- const value = val || props[propertyName];
1962
- if (spacingRatio) {
1963
- let sequenceProps = SPACING2[spacingRatio];
1964
- if (!sequenceProps) {
1965
- const { type, base, range, subSequence } = SPACING2;
1966
- sequenceProps = SPACING2[spacingRatio] = merge({
1967
- ratio: spacingRatio,
1968
- type: type + "-" + spacingRatio,
1969
- unit,
1970
- sequence: {},
1971
- scales: {},
1972
- templates: {},
1973
- vars: {}
1974
- }, {
1975
- base,
1976
- range,
1977
- subSequence,
1978
- ratio: SPACING2.ratio,
1979
- unit: SPACING2.unit
1980
- });
1981
- }
1982
- applySequenceVars(sequenceProps, { useDefault: false });
1983
- return getSpacingByKey(value, propertyName, sequenceProps);
1984
- }
1985
- return getSpacingByKey(value, propertyName);
1986
- };
1987
-
1988
- // src/system/shadow.js
1989
- var setShadow = (value, key, suffix, prefers) => {
1990
- const CONFIG2 = getActiveConfig();
1991
- if (isArray(value)) {
1992
- return {
1993
- "@light": setShadow(value[0], key, "light"),
1994
- "@dark": setShadow(value[1], key, "dark")
1995
- };
1996
- }
1997
- if (isObject(value)) {
1998
- const obj = {};
1999
- for (const variant in value) {
2000
- obj[variant] = setShadow(
2001
- value[variant],
2002
- key,
2003
- variant.startsWith("@") ? variant.slice(1) : variant
2004
- );
2005
- }
2006
- return obj;
2007
- }
2008
- if (isString(value) && value.includes(",")) {
2009
- value = value.split(",").map((v) => {
2010
- v = v.trim();
2011
- if (v.startsWith("--")) return `var(${v})`;
2012
- if (getColor(v).length > 2) return getColor(v);
2013
- if (v.includes("px") || v.slice(-2) === "em") return v;
2014
- const arr = v.split(" ");
2015
- if (!arr.length) return v;
2016
- return arr.map((v2) => getSpacingByKey(v2, "shadow").shadow).join(" ");
2017
- }).join(" ");
2018
- }
2019
- const CSSVar = `--shadow-${key}` + (suffix ? `-${suffix}` : "");
2020
- if (CONFIG2.useVariable) {
2021
- CONFIG2.CSS_VARS[CSSVar] = value;
2022
- }
2023
- return {
2024
- var: CSSVar,
2025
- value
2026
- };
2027
- };
2028
- var getShadow = (value, globalTheme) => {
2029
- const CONFIG2 = getActiveConfig();
2030
- if (!globalTheme) globalTheme = CONFIG2.globalTheme;
2031
- if (!isString(value)) {
2032
- if (CONFIG2.verbose) console.warn(value, "- type for color is not valid");
2033
- return;
2034
- }
2035
- if (value.slice(0, 2) === "--") return `var(${value})`;
2036
- const [name] = isArray(value) ? value : value.split(" ");
2037
- const { SHADOW: SHADOW2 } = CONFIG2;
2038
- const val = SHADOW2[name];
2039
- const isObj = isObject(val);
2040
- if (!val) {
2041
- if (CONFIG2.verbose) console.warn("Can't find color ", name);
2042
- return value;
2043
- }
2044
- if (globalTheme) {
2045
- if (val[globalTheme]) return val[globalTheme].value;
2046
- else if (CONFIG2.verbose) console.warn(value, " - does not have ", globalTheme);
2047
- }
2048
- if (isObj && val.value) return val.value;
2049
- if (isObj) {
2050
- const obj = {};
2051
- for (const mediaName in val) {
2052
- const query = CONFIG2.MEDIA[mediaName.slice(1)];
2053
- const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
2054
- obj[media] = val.value;
2055
- }
2056
- return obj;
2057
- }
2058
- if (CONFIG2.verbose) console.warn("Can't find color", value);
2059
- return value;
2060
- };
2061
-
2062
- // src/system/timing.js
2063
- var import_utils20 = __toESM(require_cjs(), 1);
2064
- var applyTimingSequence = () => {
2065
- const CONFIG2 = getActiveConfig();
2066
- const { TIMING: TIMING2 } = CONFIG2;
2067
- generateSequence(TIMING2);
2068
- applySequenceVars(TIMING2);
2069
- };
2070
- var getTimingFunction = (value) => {
2071
- const CONFIG2 = getActiveConfig();
2072
- const { TIMING: TIMING2 } = CONFIG2;
2073
- return TIMING2[value] || TIMING2[(0, import_utils20.toCamelCase)(value)] || value;
2074
- };
2075
- var getTimingByKey = (value, property = "timing") => {
2076
- const CONFIG2 = getActiveConfig();
2077
- const { TIMING: TIMING2 } = CONFIG2;
2078
- return getSequenceValuePropertyPair(
2079
- value,
2080
- property,
2081
- TIMING2
2082
- );
2083
- };
2084
-
2085
- // src/system/document.js
2086
- var applyDocument = () => {
2087
- const CONFIG2 = getActiveConfig();
2088
- const { DOCUMENT: DOCUMENT2, FONT_FAMILY: FONT_FAMILY2, THEME: THEME2, TYPOGRAPHY: TYPOGRAPHY2 } = CONFIG2;
2089
- return merge(DOCUMENT2, {
2090
- theme: THEME2.document,
2091
- fontFamily: getDefaultOrFirstKey(FONT_FAMILY2),
2092
- fontSize: TYPOGRAPHY2.base,
2093
- lineHeight: TYPOGRAPHY2.lineHeight
2094
- });
2095
- };
2096
-
2097
- // src/system/svg.js
2098
- var DEF_OPTIONS = {
2099
- document: document2
2100
- };
2101
- var setSVG = (val, key) => {
2102
- const CONFIG2 = getActiveConfig();
2103
- if (!val) {
2104
- if (CONFIG2.verbose) console.warn("setSVG: val is not defined", key);
2105
- return;
2106
- }
2107
- if (CONFIG2.useSvgSprite) {
2108
- return convertSvgToSymbol(key, val);
2109
- }
2110
- return val;
2111
- };
2112
- var appendSVGSprite = (LIBRARY, options = DEF_OPTIONS) => {
2113
- const CONFIG2 = getActiveConfig();
2114
- const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.SVG;
2115
- for (const key in LIBRARY) lib[key] = CONFIG2.SVG[key];
2116
- appendSVG(lib, options);
2117
- };
2118
- var setSvgIcon = (val, key) => {
2119
- var _a;
2120
- const CONFIG2 = getActiveConfig();
2121
- if (CONFIG2.useIconSprite && !((_a = CONFIG2.SEMANTIC_ICONS) == null ? void 0 : _a[key])) {
2122
- return setSVG(val, key);
2123
- }
2124
- return val;
2125
- };
2126
- var appendSvgIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
2127
- const CONFIG2 = getActiveConfig();
2128
- const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.ICONS;
2129
- for (const key in LIBRARY) lib[key] = CONFIG2.ICONS[key];
2130
- appendSVG(lib, options);
2131
- };
2132
- var createSVGSpriteElement = (options = { isRoot: true }) => {
2133
- if (!document2 || !document2.createElementNS) return;
2134
- const svgElem = document2.createElementNS("http://www.w3.org/2000/svg", "svg");
2135
- if (options.isRoot) {
2136
- svgElem.setAttribute("aria-hidden", "true");
2137
- svgElem.setAttribute("width", "0");
2138
- svgElem.setAttribute("height", "0");
2139
- svgElem.setAttribute("style", "position:absolute");
2140
- svgElem.setAttribute("id", "svgSprite");
2141
- }
2142
- return svgElem;
2143
- };
2144
- var appendSVG = (lib, options = DEF_OPTIONS) => {
2145
- const CONFIG2 = getActiveConfig();
2146
- const doc = options.document || document2;
2147
- if (!doc || !doc.documentElement) {
2148
- if (CONFIG2.verbose) {
2149
- console.warn("To append SVG sprites it should be run in browser environment");
2150
- }
2151
- return generateSprite(lib);
2152
- }
2153
- const exists = doc.querySelector("#svgSprite");
2154
- const SVGsprite = generateSprite(lib);
2155
- if (exists) {
2156
- const tempSVG = createSVGSpriteElement({ isRoot: false });
2157
- tempSVG.innerHTML = SVGsprite;
2158
- exists.append(...tempSVG.children);
2159
- } else {
2160
- const svgSpriteDOM = createSVGSpriteElement();
2161
- if (svgSpriteDOM && svgSpriteDOM.nodeType) {
2162
- svgSpriteDOM.innerHTML = SVGsprite;
2163
- doc.body.prepend(svgSpriteDOM);
2164
- }
2165
- }
2166
- };
2167
-
2168
- // src/system/reset.js
2169
- var applyReset = (reset = {}) => {
2170
- const CONFIG2 = getActiveConfig();
2171
- const { RESET: RESET2, TYPOGRAPHY: TYPOGRAPHY2, DOCUMENT: DOCUMENT2 } = CONFIG2;
2172
- if (RESET2) {
2173
- if (RESET2[":root"]) {
2174
- const configReset = RESET2;
2175
- const configTemplates = TYPOGRAPHY2.templates;
2176
- configReset.body = {
2177
- ...CONFIG2.useDocumentTheme ? getMediaTheme("document", `@${CONFIG2.globalTheme}`) : {},
2178
- ...configTemplates.body
2179
- };
2180
- configReset.h1 = configTemplates.h1;
2181
- configReset.h2 = configTemplates.h2;
2182
- configReset.h3 = configTemplates.h3;
2183
- configReset.h4 = configTemplates.h4;
2184
- configReset.h5 = configTemplates.h5;
2185
- configReset.h6 = configTemplates.h6;
2186
- }
2187
- const { body, ...templates } = TYPOGRAPHY2.templates;
2188
- const globalTheme = CONFIG2.useDocumentTheme ? getMediaTheme("document", `@${CONFIG2.globalTheme}`) : {};
2189
- if (RESET2.html) overwriteDeep(RESET2.html, globalTheme);
2190
- return deepMerge(merge(RESET2, reset), {
2191
- html: {
2192
- position: "absolute",
2193
- // overflow: 'hidden',
2194
- width: "100%",
2195
- height: "100%",
2196
- top: "0",
2197
- left: "0",
2198
- margin: "0",
2199
- WebkitFontSmoothing: "subpixel-antialiased",
2200
- scrollBehavior: "smooth",
2201
- ...globalTheme,
2202
- fontSize: TYPOGRAPHY2.browserDefault + "px",
2203
- fontFamily: DOCUMENT2.fontFamily,
2204
- lineHeight: DOCUMENT2.lineHeight
2205
- },
2206
- body: {
2207
- boxSizing: "border-box",
2208
- height: "100%",
2209
- margin: 0,
2210
- fontFamily: DOCUMENT2.fontFamily,
2211
- fontSize: TYPOGRAPHY2.base / TYPOGRAPHY2.browserDefault + CONFIG2.UNIT.default,
2212
- ...templates,
2213
- ...body
2214
- },
2215
- // form elements
2216
- fieldset: {
2217
- border: 0,
2218
- padding: 0,
2219
- margin: 0
2220
- },
2221
- "select, input": {
2222
- fontFamily: DOCUMENT2.fontFamily
2223
- }
2224
- });
2225
- }
2226
- };
2227
- // @preserve-env