@symbo.ls/scratch 3.8.8 → 3.14.0

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 (76) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/defaultConfig/class.js +1 -2
  3. package/dist/cjs/defaultConfig/font-family.js +6 -6
  4. package/dist/cjs/defaultConfig/icons.js +2 -2
  5. package/dist/cjs/defaultConfig/svg.js +2 -2
  6. package/dist/cjs/defaultConfig/timing.js +1 -1
  7. package/dist/cjs/factory.js +72 -12
  8. package/dist/cjs/index.js +6 -4
  9. package/dist/cjs/set.js +113 -52
  10. package/dist/cjs/system/color.js +72 -12
  11. package/dist/cjs/system/document.js +3 -3
  12. package/dist/cjs/system/font.js +14 -14
  13. package/dist/cjs/system/reset.js +34 -7
  14. package/dist/cjs/system/shadow.js +4 -3
  15. package/dist/cjs/system/spacing.js +18 -18
  16. package/dist/cjs/system/svg.js +34 -7
  17. package/dist/cjs/system/theme.js +51 -50
  18. package/dist/cjs/system/timing.js +6 -6
  19. package/dist/cjs/system/typography.js +12 -3
  20. package/dist/cjs/transforms/index.js +4 -4
  21. package/dist/cjs/utils/color.js +1 -1
  22. package/dist/cjs/utils/font.js +3 -1
  23. package/dist/cjs/utils/sequence.js +35 -16
  24. package/dist/cjs/utils/sprite.js +11 -4
  25. package/dist/cjs/utils/var.js +23 -9
  26. package/dist/esm/defaultConfig/class.js +1 -2
  27. package/dist/esm/defaultConfig/font-family.js +6 -6
  28. package/dist/esm/defaultConfig/icons.js +2 -2
  29. package/dist/esm/defaultConfig/svg.js +2 -2
  30. package/dist/esm/defaultConfig/timing.js +1 -1
  31. package/dist/esm/factory.js +72 -12
  32. package/dist/esm/index.js +6 -4
  33. package/dist/esm/set.js +114 -53
  34. package/dist/esm/system/color.js +72 -12
  35. package/dist/esm/system/document.js +3 -3
  36. package/dist/esm/system/font.js +5 -5
  37. package/dist/esm/system/reset.js +34 -7
  38. package/dist/esm/system/shadow.js +4 -3
  39. package/dist/esm/system/spacing.js +3 -3
  40. package/dist/esm/system/svg.js +34 -7
  41. package/dist/esm/system/theme.js +51 -50
  42. package/dist/esm/system/timing.js +2 -2
  43. package/dist/esm/system/typography.js +12 -3
  44. package/dist/esm/transforms/index.js +4 -4
  45. package/dist/esm/utils/color.js +1 -1
  46. package/dist/esm/utils/font.js +3 -1
  47. package/dist/esm/utils/sequence.js +35 -16
  48. package/dist/esm/utils/sprite.js +11 -4
  49. package/dist/esm/utils/var.js +23 -9
  50. package/dist/iife/index.js +728 -302
  51. package/index.js +1 -0
  52. package/package.json +11 -14
  53. package/src/defaultConfig/class.js +2 -1
  54. package/src/defaultConfig/font-family.js +3 -3
  55. package/src/defaultConfig/icons.js +1 -1
  56. package/src/defaultConfig/svg.js +1 -1
  57. package/src/defaultConfig/timing.js +1 -1
  58. package/src/factory.js +85 -13
  59. package/src/index.js +16 -5
  60. package/src/set.js +156 -63
  61. package/src/system/color.js +113 -12
  62. package/src/system/document.js +3 -3
  63. package/src/system/font.js +5 -5
  64. package/src/system/reset.js +41 -8
  65. package/src/system/shadow.js +4 -3
  66. package/src/system/spacing.js +3 -3
  67. package/src/system/svg.js +44 -7
  68. package/src/system/theme.js +87 -64
  69. package/src/system/timing.js +2 -2
  70. package/src/system/typography.js +12 -3
  71. package/src/transforms/index.js +4 -4
  72. package/src/utils/color.js +2 -1
  73. package/src/utils/font.js +7 -1
  74. package/src/utils/sequence.js +46 -29
  75. package/src/utils/sprite.js +15 -4
  76. package/src/utils/var.js +27 -9
@@ -21,19 +21,21 @@ var SmblsScratch = (() => {
21
21
  };
22
22
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
23
 
24
- // ../utils/dist/esm/globals.js
24
+ // ../utils/globals.js
25
25
  var window2, document2;
26
26
  var init_globals = __esm({
27
- "../utils/dist/esm/globals.js"() {
27
+ "../utils/globals.js"() {
28
+ "use strict";
28
29
  window2 = globalThis;
29
30
  document2 = window2.document;
30
31
  }
31
32
  });
32
33
 
33
- // ../utils/dist/esm/node.js
34
+ // ../utils/node.js
34
35
  var isDOMNode;
35
36
  var init_node = __esm({
36
- "../utils/dist/esm/node.js"() {
37
+ "../utils/node.js"() {
38
+ "use strict";
37
39
  init_globals();
38
40
  isDOMNode = (obj) => {
39
41
  return typeof window2 !== "undefined" && (window2.Node && obj instanceof window2.Node || window2.Window && obj instanceof window2.Window || obj === window2 || obj === document);
@@ -41,10 +43,11 @@ var SmblsScratch = (() => {
41
43
  }
42
44
  });
43
45
 
44
- // ../utils/dist/esm/types.js
46
+ // ../utils/types.js
45
47
  var isObject, isString, isNumber, isFunction, isArray, isObjectLike, isDefined;
46
48
  var init_types = __esm({
47
- "../utils/dist/esm/types.js"() {
49
+ "../utils/types.js"() {
50
+ "use strict";
48
51
  isObject = (arg) => {
49
52
  if (arg === null) return false;
50
53
  return typeof arg === "object" && arg.constructor === Object;
@@ -61,10 +64,11 @@ var SmblsScratch = (() => {
61
64
  }
62
65
  });
63
66
 
64
- // ../utils/dist/esm/array.js
67
+ // ../utils/array.js
65
68
  var unstackArrayOfObjects;
66
69
  var init_array = __esm({
67
- "../utils/dist/esm/array.js"() {
70
+ "../utils/array.js"() {
71
+ "use strict";
68
72
  init_object();
69
73
  unstackArrayOfObjects = (arr, exclude = []) => {
70
74
  return arr.reduce(
@@ -75,16 +79,18 @@ var SmblsScratch = (() => {
75
79
  }
76
80
  });
77
81
 
78
- // ../utils/dist/esm/string.js
82
+ // ../utils/string.js
79
83
  var init_string = __esm({
80
- "../utils/dist/esm/string.js"() {
84
+ "../utils/string.js"() {
85
+ "use strict";
81
86
  }
82
87
  });
83
88
 
84
- // ../utils/dist/esm/keys.js
89
+ // ../utils/keys.js
85
90
  var STATE_METHODS, PROPS_METHODS, METHODS, METHODS_EXL;
86
91
  var init_keys = __esm({
87
- "../utils/dist/esm/keys.js"() {
92
+ "../utils/keys.js"() {
93
+ "use strict";
88
94
  STATE_METHODS = /* @__PURE__ */ new Set([
89
95
  "update",
90
96
  "parse",
@@ -154,7 +160,9 @@ var SmblsScratch = (() => {
154
160
  "getContext",
155
161
  "getQuery",
156
162
  "getDB",
157
- "getChildren"
163
+ "getChildren",
164
+ "preventContentUpdate",
165
+ "preventContentRecreate"
158
166
  ]);
159
167
  METHODS_EXL = /* @__PURE__ */ new Set([
160
168
  "node",
@@ -169,10 +177,11 @@ var SmblsScratch = (() => {
169
177
  }
170
178
  });
171
179
 
172
- // ../utils/dist/esm/object.js
173
- var _startsWithDunder, exec, merge, deepMerge, deepClone, overwriteDeep;
180
+ // ../utils/object.js
181
+ var _startsWithDunder, exec, merge, deepMerge, _deepMerge, deepClone, overwriteDeep;
174
182
  var init_object = __esm({
175
- "../utils/dist/esm/object.js"() {
183
+ "../utils/object.js"() {
184
+ "use strict";
176
185
  init_globals();
177
186
  init_types();
178
187
  init_array();
@@ -183,20 +192,12 @@ var SmblsScratch = (() => {
183
192
  if (isFunction(param)) {
184
193
  if (!element) return;
185
194
  if (typeof param.call !== "function") return param;
186
- const result = param.call(
195
+ return param.call(
187
196
  element,
188
197
  element,
189
198
  state || element.state,
190
199
  context || element.context
191
200
  );
192
- if (result && typeof result.then === "function") {
193
- let resolved;
194
- result.then((value) => {
195
- resolved = value;
196
- });
197
- return resolved;
198
- }
199
- return result;
200
201
  }
201
202
  if (param != null && element?.context?.plugins && (isArray(param) || isObject(param) && !isDOMNode(param))) {
202
203
  const plugins = element.context.plugins;
@@ -224,6 +225,15 @@ var SmblsScratch = (() => {
224
225
  return element;
225
226
  };
226
227
  deepMerge = (element, extend, excludeFrom = METHODS_EXL) => {
228
+ return _deepMerge(element, extend, excludeFrom, null);
229
+ };
230
+ _deepMerge = (element, extend, excludeFrom, ancestors) => {
231
+ if (element === extend) return element;
232
+ if (ancestors) {
233
+ for (let i = 0; i < ancestors.length; i += 2) {
234
+ if (ancestors[i] === element && ancestors[i + 1] === extend) return element;
235
+ }
236
+ }
227
237
  const useSet = excludeFrom instanceof Set;
228
238
  for (const e in extend) {
229
239
  if (!Object.prototype.hasOwnProperty.call(extend, e)) continue;
@@ -232,7 +242,10 @@ var SmblsScratch = (() => {
232
242
  const elementProp = element[e];
233
243
  const extendProp = extend[e];
234
244
  if (isObjectLike(elementProp) && isObjectLike(extendProp)) {
235
- deepMerge(elementProp, extendProp, excludeFrom);
245
+ const stack = ancestors || [];
246
+ stack.push(element, extend);
247
+ _deepMerge(elementProp, extendProp, excludeFrom, stack);
248
+ stack.length -= 2;
236
249
  } else if (elementProp === void 0) {
237
250
  element[e] = extendProp;
238
251
  }
@@ -256,8 +269,8 @@ var SmblsScratch = (() => {
256
269
  return visited.get(obj);
257
270
  }
258
271
  const isArr = isArray(obj);
259
- const clone2 = isArr ? [] : {};
260
- visited.set(obj, clone2);
272
+ const clone = isArr ? [] : {};
273
+ visited.set(obj, clone);
261
274
  const excludeSet = exclude instanceof Set ? exclude : exclude.length > 3 ? new Set(exclude) : null;
262
275
  for (const key in obj) {
263
276
  if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
@@ -267,27 +280,27 @@ var SmblsScratch = (() => {
267
280
  if (cleanUndefined && value === void 0) continue;
268
281
  if (cleanNull && value === null) continue;
269
282
  if (isDOMNode(value)) {
270
- clone2[key] = value;
283
+ clone[key] = value;
271
284
  continue;
272
285
  }
273
286
  if (handleExtends && key === "extends" && isArray(value)) {
274
- clone2[key] = unstackArrayOfObjects(value, exclude);
287
+ clone[key] = unstackArrayOfObjects(value, exclude);
275
288
  continue;
276
289
  }
277
- if (isFunction(value) && options.window) {
278
- clone2[key] = contentWindow.eval("(" + value.toString() + ")");
290
+ if (isFunction(value)) {
291
+ clone[key] = value;
279
292
  continue;
280
293
  }
281
294
  if (isObjectLike(value)) {
282
- clone2[key] = deepClone(value, {
295
+ clone[key] = deepClone(value, {
283
296
  ...options,
284
297
  visited
285
298
  });
286
299
  } else {
287
- clone2[key] = value;
300
+ clone[key] = value;
288
301
  }
289
302
  }
290
- return clone2;
303
+ return clone;
291
304
  };
292
305
  overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new WeakMap()) => {
293
306
  if (!isObjectLike(obj) || !isObjectLike(params) || isDOMNode(obj) || isDOMNode(params)) {
@@ -300,7 +313,8 @@ var SmblsScratch = (() => {
300
313
  const forcedExclude = !opts.preventForce;
301
314
  for (const e in params) {
302
315
  if (!Object.prototype.hasOwnProperty.call(params, e)) continue;
303
- if (exclSet && exclSet.has(e) || forcedExclude && _startsWithDunder(e)) continue;
316
+ if (exclSet && exclSet.has(e) || forcedExclude && _startsWithDunder(e))
317
+ continue;
304
318
  const objProp = obj[e];
305
319
  const paramsProp = params[e];
306
320
  if (isDOMNode(paramsProp)) {
@@ -316,117 +330,240 @@ var SmblsScratch = (() => {
316
330
  }
317
331
  });
318
332
 
319
- // ../utils/dist/esm/key.js
333
+ // ../utils/key.js
320
334
  var init_key = __esm({
321
- "../utils/dist/esm/key.js"() {
335
+ "../utils/key.js"() {
336
+ "use strict";
322
337
  }
323
338
  });
324
339
 
325
- // ../utils/dist/esm/env.js
340
+ // ../utils/env.js
326
341
  var NODE_ENV, isProduction, isNotProduction;
327
342
  var init_env = __esm({
328
- "../utils/dist/esm/env.js"() {
343
+ "../utils/env.js"() {
344
+ "use strict";
329
345
  NODE_ENV = process.env.NODE_ENV;
330
346
  isProduction = (env = NODE_ENV) => env === "production";
331
347
  isNotProduction = (env = NODE_ENV) => !isProduction(env);
332
348
  }
333
349
  });
334
350
 
335
- // ../utils/dist/esm/function.js
351
+ // ../utils/function.js
336
352
  var init_function = __esm({
337
- "../utils/dist/esm/function.js"() {
353
+ "../utils/function.js"() {
354
+ "use strict";
338
355
  }
339
356
  });
340
357
 
341
- // ../utils/dist/esm/if.js
358
+ // ../utils/if.js
342
359
  var init_if = __esm({
343
- "../utils/dist/esm/if.js"() {
360
+ "../utils/if.js"() {
361
+ "use strict";
344
362
  }
345
363
  });
346
364
 
347
- // ../utils/dist/esm/log.js
365
+ // ../utils/log.js
348
366
  var init_log = __esm({
349
- "../utils/dist/esm/log.js"() {
367
+ "../utils/log.js"() {
368
+ "use strict";
350
369
  }
351
370
  });
352
371
 
353
- // ../utils/dist/esm/cookie.js
372
+ // ../utils/cookie.js
354
373
  var isMobile;
355
374
  var init_cookie = __esm({
356
- "../utils/dist/esm/cookie.js"() {
375
+ "../utils/cookie.js"() {
376
+ "use strict";
357
377
  isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
358
378
  }
359
379
  });
360
380
 
361
- // ../utils/dist/esm/tags.js
381
+ // ../utils/tags.js
362
382
  var init_tags = __esm({
363
- "../utils/dist/esm/tags.js"() {
383
+ "../utils/tags.js"() {
384
+ "use strict";
364
385
  }
365
386
  });
366
387
 
367
- // ../utils/dist/esm/extends.js
388
+ // ../utils/extends.js
368
389
  var init_extends = __esm({
369
- "../utils/dist/esm/extends.js"() {
390
+ "../utils/extends.js"() {
391
+ "use strict";
370
392
  }
371
393
  });
372
394
 
373
- // ../utils/dist/esm/component.js
395
+ // ../utils/component.js
374
396
  var init_component = __esm({
375
- "../utils/dist/esm/component.js"() {
397
+ "../utils/component.js"() {
398
+ "use strict";
376
399
  }
377
400
  });
378
401
 
379
- // ../utils/dist/esm/props.js
402
+ // ../utils/props.js
380
403
  var init_props = __esm({
381
- "../utils/dist/esm/props.js"() {
404
+ "../utils/props.js"() {
405
+ "use strict";
382
406
  }
383
407
  });
384
408
 
385
- // ../utils/dist/esm/element.js
409
+ // ../utils/element.js
386
410
  var init_element = __esm({
387
- "../utils/dist/esm/element.js"() {
411
+ "../utils/element.js"() {
412
+ "use strict";
388
413
  }
389
414
  });
390
415
 
391
- // ../utils/dist/esm/state.js
416
+ // ../utils/state.js
392
417
  var init_state = __esm({
393
- "../utils/dist/esm/state.js"() {
418
+ "../utils/state.js"() {
419
+ "use strict";
394
420
  }
395
421
  });
396
422
 
397
- // ../utils/dist/esm/scope.js
423
+ // ../utils/scope.js
398
424
  var init_scope = __esm({
399
- "../utils/dist/esm/scope.js"() {
425
+ "../utils/scope.js"() {
426
+ "use strict";
400
427
  }
401
428
  });
402
429
 
403
- // ../utils/dist/esm/triggerEvent.js
430
+ // ../utils/triggerEvent.js
404
431
  var init_triggerEvent = __esm({
405
- "../utils/dist/esm/triggerEvent.js"() {
432
+ "../utils/triggerEvent.js"() {
433
+ "use strict";
406
434
  }
407
435
  });
408
436
 
409
- // ../utils/dist/esm/cache.js
437
+ // ../utils/cache.js
410
438
  var init_cache = __esm({
411
- "../utils/dist/esm/cache.js"() {
439
+ "../utils/cache.js"() {
440
+ "use strict";
412
441
  }
413
442
  });
414
443
 
415
- // ../utils/dist/esm/methods.js
444
+ // ../utils/methods.js
416
445
  var init_methods = __esm({
417
- "../utils/dist/esm/methods.js"() {
446
+ "../utils/methods.js"() {
447
+ "use strict";
418
448
  }
419
449
  });
420
450
 
421
- // ../utils/dist/esm/update.js
451
+ // ../utils/update.js
422
452
  var init_update = __esm({
423
- "../utils/dist/esm/update.js"() {
453
+ "../utils/update.js"() {
454
+ "use strict";
455
+ }
456
+ });
457
+
458
+ // ../utils/projectKeys.js
459
+ var init_projectKeys = __esm({
460
+ "../utils/projectKeys.js"() {
461
+ }
462
+ });
463
+
464
+ // ../utils/browser.js
465
+ var init_browser = __esm({
466
+ "../utils/browser.js"() {
467
+ "use strict";
468
+ }
469
+ });
470
+
471
+ // ../utils/cdn.js
472
+ var init_cdn = __esm({
473
+ "../utils/cdn.js"() {
474
+ "use strict";
475
+ }
476
+ });
477
+
478
+ // ../utils/date.js
479
+ var init_date = __esm({
480
+ "../utils/date.js"() {
481
+ "use strict";
482
+ }
483
+ });
484
+
485
+ // ../utils/detectHeight.js
486
+ var init_detectHeight = __esm({
487
+ "../utils/detectHeight.js"() {
488
+ "use strict";
489
+ }
490
+ });
491
+
492
+ // ../utils/fibonacci.js
493
+ var init_fibonacci = __esm({
494
+ "../utils/fibonacci.js"() {
495
+ "use strict";
496
+ }
497
+ });
498
+
499
+ // ../utils/files.js
500
+ var init_files = __esm({
501
+ "../utils/files.js"() {
502
+ "use strict";
503
+ }
504
+ });
505
+
506
+ // ../utils/load.js
507
+ var init_load = __esm({
508
+ "../utils/load.js"() {
509
+ "use strict";
510
+ }
511
+ });
512
+
513
+ // ../utils/metadata.js
514
+ var init_metadata = __esm({
515
+ "../utils/metadata.js"() {
516
+ "use strict";
517
+ }
518
+ });
519
+
520
+ // ../utils/scaling.js
521
+ var init_scaling = __esm({
522
+ "../utils/scaling.js"() {
523
+ "use strict";
524
+ }
525
+ });
526
+
527
+ // ../utils/sharedLibraries.js
528
+ var init_sharedLibraries = __esm({
529
+ "../utils/sharedLibraries.js"() {
530
+ "use strict";
531
+ }
532
+ });
533
+
534
+ // ../utils/string-extra.js
535
+ var toCamelCase, toDashCase, arrayzeValue;
536
+ var init_string_extra = __esm({
537
+ "../utils/string-extra.js"() {
538
+ "use strict";
539
+ init_types();
540
+ toCamelCase = (str) => {
541
+ if (typeof str !== "string") str = String(str || "");
542
+ return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
543
+ return index === 0 ? word.toLowerCase() : word.toUpperCase();
544
+ }).replace(/\s+/g, "");
545
+ };
546
+ toDashCase = (val) => val.replace(/[^a-zA-Z0-9]/g, " ").trim().toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
547
+ arrayzeValue = (val) => {
548
+ if (isArray(val)) return val;
549
+ if (isString(val)) return val.split(" ");
550
+ if (isObject(val)) return Object.values(val);
551
+ if (isNumber(val)) return [val];
552
+ };
424
553
  }
425
554
  });
426
555
 
427
- // ../utils/dist/esm/index.js
428
- var init_esm = __esm({
429
- "../utils/dist/esm/index.js"() {
556
+ // ../utils/style.js
557
+ var init_style = __esm({
558
+ "../utils/style.js"() {
559
+ "use strict";
560
+ }
561
+ });
562
+
563
+ // ../utils/index.js
564
+ var init_utils = __esm({
565
+ "../utils/index.js"() {
566
+ "use strict";
430
567
  init_key();
431
568
  init_env();
432
569
  init_types();
@@ -451,18 +588,28 @@ var SmblsScratch = (() => {
451
588
  init_cache();
452
589
  init_update();
453
590
  init_triggerEvent();
591
+ init_projectKeys();
592
+ init_browser();
593
+ init_cdn();
594
+ init_date();
595
+ init_detectHeight();
596
+ init_fibonacci();
597
+ init_files();
598
+ init_load();
599
+ init_metadata();
600
+ init_scaling();
601
+ init_sharedLibraries();
602
+ init_string_extra();
603
+ init_style();
454
604
  }
455
605
  });
456
606
 
457
607
  // src/index.js
458
608
  var index_exports = {};
459
609
  __export(index_exports, {
460
- CLASS: () => CLASS,
461
610
  CONFIG: () => CONFIG,
462
- CSS_MEDIA_VARS: () => CSS_MEDIA_VARS,
463
611
  CSS_NATIVE_COLOR_REGEX: () => CSS_NATIVE_COLOR_REGEX,
464
612
  CSS_UNITS: () => CSS_UNITS,
465
- CSS_VARS: () => CSS_VARS,
466
613
  FACTORY: () => FACTORY,
467
614
  VALUE_TRANSFORMERS: () => VALUE_TRANSFORMERS,
468
615
  activateConfig: () => activateConfig,
@@ -482,17 +629,21 @@ var SmblsScratch = (() => {
482
629
  changeGlobalTheme: () => changeGlobalTheme,
483
630
  changeLightness: () => changeLightness,
484
631
  checkIfBoxSize: () => checkIfBoxSize,
632
+ class: () => defaultProps5,
485
633
  color: () => color,
486
634
  colorStringToRgbaArray: () => colorStringToRgbaArray,
487
635
  convertSvgToSymbol: () => convertSvgToSymbol,
636
+ createConfig: () => createConfig,
637
+ cssMediaVars: () => cssMediaVars,
638
+ cssVars: () => cssVars,
488
639
  devices: () => devices,
489
640
  document: () => document3,
490
641
  findHeadingLetter: () => findHeadingLetter,
491
642
  findHeadings: () => findHeadings,
492
643
  font: () => font,
493
- font_face: () => font_face,
494
- font_family: () => font_family,
495
- font_family_types: () => font_family_types,
644
+ fontFace: () => fontFace,
645
+ fontFamily: () => fontFamily,
646
+ fontFamilyTypes: () => fontFamilyTypes,
496
647
  generateSequence: () => generateSequence,
497
648
  generateSequencePosition: () => generateSequencePosition,
498
649
  generateSprite: () => generateSprite,
@@ -541,6 +692,8 @@ var SmblsScratch = (() => {
541
692
  numToLetterMap: () => numToLetterMap,
542
693
  opacify: () => opacify,
543
694
  parseColorToken: () => parseColorToken,
695
+ popConfig: () => popConfig,
696
+ pushConfig: () => pushConfig,
544
697
  reset: () => reset,
545
698
  resolveColorsInGradient: () => resolveColorsInGradient,
546
699
  resolveFileUrl: () => resolveFileUrl,
@@ -549,9 +702,10 @@ var SmblsScratch = (() => {
549
702
  rgbToHSL: () => rgbToHSL,
550
703
  rgbToHex: () => rgbToHex,
551
704
  runThroughMedia: () => runThroughMedia,
705
+ scratchDefaultConfig: () => defaultConfig_exports,
552
706
  scratchSystem: () => system_exports,
553
707
  scratchUtils: () => utils_exports,
554
- semantic_icons: () => semantic_icons,
708
+ semanticIcons: () => semanticIcons,
555
709
  sequence: () => sequence,
556
710
  set: () => set,
557
711
  setActiveConfig: () => setActiveConfig,
@@ -579,10 +733,11 @@ var SmblsScratch = (() => {
579
733
  splitTopLevelCommas: () => splitTopLevelCommas,
580
734
  splitTransition: () => splitTransition,
581
735
  svg: () => svg,
582
- svg_data: () => svg_data,
736
+ svgData: () => svgData,
583
737
  templates: () => templates,
584
738
  theme: () => theme,
585
739
  timing: () => timing,
740
+ toCamel: () => toCamel,
586
741
  transformBackgroundImage: () => transformBackgroundImage,
587
742
  transformBorder: () => transformBorder,
588
743
  transformBorderRadius: () => transformBorderRadius,
@@ -717,7 +872,7 @@ var SmblsScratch = (() => {
717
872
  ];
718
873
 
719
874
  // src/utils/color.js
720
- init_esm();
875
+ init_utils();
721
876
  var colorStringToRgbaArray = (color2) => {
722
877
  if (color2 === "") return [0, 0, 0, 0];
723
878
  if (color2.toLowerCase() === "transparent") return [0, 0, 0, 0];
@@ -909,6 +1064,7 @@ var SmblsScratch = (() => {
909
1064
  return hasValue && LIBRARY[hasValue] && LIBRARY[hasValue].value;
910
1065
  };
911
1066
  var getFontFormat = (url) => {
1067
+ if (typeof url !== "string" || !url) return null;
912
1068
  const ext = url.split(/[#?]/)[0].split(".").pop().trim();
913
1069
  if (["woff2", "woff", "ttf", "otf", "eot"].includes(ext)) return ext;
914
1070
  return null;
@@ -917,7 +1073,8 @@ var SmblsScratch = (() => {
917
1073
  var setFontImport = (url) => `@import url('${url}');`;
918
1074
  var setInCustomFontMedia = (str) => `@font-face { ${str} }`;
919
1075
  var setCustomFont = (name, url, weight, options = {}) => {
920
- const urls = Array.isArray(url) ? url : [url];
1076
+ const rawUrls = Array.isArray(url) ? url : [url];
1077
+ const urls = rawUrls.filter((u) => typeof u === "string" && u);
921
1078
  const srcList = urls.map((u) => {
922
1079
  const format = getFontFormat(u);
923
1080
  const formatStr = format ? ` format('${format}')` : "";
@@ -971,51 +1128,36 @@ var SmblsScratch = (() => {
971
1128
  };
972
1129
 
973
1130
  // src/utils/sequence.js
974
- init_esm();
975
-
976
- // ../smbls-utils/dist/esm/index.js
977
- init_esm();
978
- var toCamelCase = (str) => {
979
- if (typeof str !== "string") str = String(str || "");
980
- return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
981
- return index === 0 ? word.toLowerCase() : word.toUpperCase();
982
- }).replace(/\s+/g, "");
983
- };
984
- var toDashCase = (val) => val.replace(/[^a-zA-Z0-9]/g, " ").trim().toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
985
- var arrayzeValue = (val) => {
986
- if (isArray(val)) return val;
987
- if (isString(val)) return val.split(" ");
988
- if (isObject(val)) return Object.values(val);
989
- if (isNumber(val)) return [val];
990
- };
1131
+ init_utils();
1132
+ init_utils();
991
1133
 
992
1134
  // src/factory.js
993
- init_esm();
1135
+ init_utils();
994
1136
 
995
1137
  // src/defaultConfig/index.js
996
1138
  var defaultConfig_exports = {};
997
1139
  __export(defaultConfig_exports, {
998
- CLASS: () => CLASS,
999
1140
  animation: () => animation,
1000
1141
  breakpoints: () => breakpoints,
1142
+ class: () => defaultProps5,
1001
1143
  color: () => color,
1002
1144
  devices: () => devices,
1003
1145
  document: () => document3,
1004
1146
  font: () => font,
1005
- font_face: () => font_face,
1006
- font_family: () => font_family,
1007
- font_family_types: () => font_family_types,
1147
+ fontFace: () => fontFace,
1148
+ fontFamily: () => fontFamily,
1149
+ fontFamilyTypes: () => fontFamilyTypes,
1008
1150
  gradient: () => gradient,
1009
1151
  grid: () => grid,
1010
1152
  icons: () => icons,
1011
1153
  media: () => media,
1012
1154
  reset: () => reset,
1013
- semantic_icons: () => semantic_icons,
1155
+ semanticIcons: () => semanticIcons,
1014
1156
  sequence: () => sequence,
1015
1157
  shadow: () => shadow,
1016
1158
  spacing: () => spacing,
1017
1159
  svg: () => svg,
1018
- svg_data: () => svg_data,
1160
+ svgData: () => svgData,
1019
1161
  templates: () => templates,
1020
1162
  theme: () => theme,
1021
1163
  timing: () => timing,
@@ -1080,13 +1222,13 @@ var SmblsScratch = (() => {
1080
1222
  var font = {};
1081
1223
 
1082
1224
  // src/defaultConfig/font-family.js
1083
- var font_family = {};
1084
- var font_family_types = {
1225
+ var fontFamily = {};
1226
+ var fontFamilyTypes = {
1085
1227
  "sans-serif": "Helvetica, Arial, sans-serif, --system-default",
1086
1228
  serif: "Times New Roman, Georgia, serif, --system-default",
1087
1229
  monospace: "Courier New, monospace, --system-default"
1088
1230
  };
1089
- var font_face = {};
1231
+ var fontFace = {};
1090
1232
 
1091
1233
  // src/defaultConfig/media.js
1092
1234
  var media = {
@@ -1123,7 +1265,7 @@ var SmblsScratch = (() => {
1123
1265
 
1124
1266
  // src/defaultConfig/icons.js
1125
1267
  var icons = {};
1126
- var semantic_icons = {};
1268
+ var semanticIcons = {};
1127
1269
 
1128
1270
  // src/defaultConfig/timing.js
1129
1271
  var defaultProps3 = {
@@ -1176,7 +1318,7 @@ var SmblsScratch = (() => {
1176
1318
 
1177
1319
  // src/defaultConfig/svg.js
1178
1320
  var svg = {};
1179
- var svg_data = {};
1321
+ var svgData = {};
1180
1322
 
1181
1323
  // src/defaultConfig/templates.js
1182
1324
  var templates = {};
@@ -1187,35 +1329,34 @@ var SmblsScratch = (() => {
1187
1329
 
1188
1330
  // src/defaultConfig/class.js
1189
1331
  var defaultProps5 = {};
1190
- var CLASS = defaultProps5;
1191
1332
 
1192
1333
  // src/defaultConfig/index.js
1193
1334
  var reset = {};
1194
1335
  var vars = {};
1195
1336
 
1196
1337
  // src/factory.js
1197
- var CSS_VARS = {};
1198
- var CSS_MEDIA_VARS = {};
1338
+ var cssVars = {};
1339
+ var cssMediaVars = {};
1199
1340
  var _CONF = defaultConfig_exports;
1200
1341
  var _confLower = {};
1201
1342
  var toCamel = (s) => s.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
1202
- var toUpper = (s) => s.replace(/([A-Z])/g, "_$1").toUpperCase();
1203
1343
  for (const key in _CONF) {
1204
1344
  const lower = key.toLowerCase();
1205
1345
  _confLower[lower] = _CONF[key];
1206
1346
  const camel = toCamel(lower);
1207
1347
  if (camel !== lower) _confLower[camel] = _CONF[key];
1208
1348
  if (lower !== key) _confLower[key] = _CONF[key];
1209
- const upper = toUpper(key);
1210
- if (upper !== key) _confLower[upper] = _CONF[key];
1211
1349
  }
1212
1350
  var CONFIG = {
1213
1351
  verbose: false,
1214
1352
  useVariable: true,
1215
1353
  useReset: true,
1216
1354
  globalTheme: "auto",
1217
- CSS_VARS,
1218
- CSS_MEDIA_VARS,
1355
+ cssVars,
1356
+ cssMediaVars,
1357
+ CSS_VARS: cssVars,
1358
+ CSS_MEDIA_VARS: cssMediaVars,
1359
+ _scratchConfig: true,
1219
1360
  ..._confLower
1220
1361
  };
1221
1362
  var cachedConfig = deepClone(CONFIG);
@@ -1229,7 +1370,15 @@ var SmblsScratch = (() => {
1229
1370
  }
1230
1371
  return FACTORY[def || FACTORY.active];
1231
1372
  };
1373
+ var configStack = [];
1374
+ var pushConfig = (config) => {
1375
+ if (config && config._scratchConfig) configStack.push(config);
1376
+ };
1377
+ var popConfig = () => {
1378
+ configStack.pop();
1379
+ };
1232
1380
  var getActiveConfig = (def) => {
1381
+ if (configStack.length) return configStack[configStack.length - 1];
1233
1382
  return FACTORY[def || FACTORY.active] || CONFIG;
1234
1383
  };
1235
1384
  var setActiveConfig = (newConfig) => {
@@ -1238,6 +1387,54 @@ var SmblsScratch = (() => {
1238
1387
  FACTORY["1"] = deepMerge(newConfig, deepClone(cachedConfig));
1239
1388
  return newConfig;
1240
1389
  };
1390
+ var APP_FLAGS = [
1391
+ "useReset",
1392
+ "useVariable",
1393
+ "useFontImport",
1394
+ "useIconSprite",
1395
+ "useSvgSprite",
1396
+ "useDocumentTheme",
1397
+ "useDefaultIcons",
1398
+ "useDefaultConfig",
1399
+ "verbose",
1400
+ "globalTheme"
1401
+ ];
1402
+ var ALIAS_GROUPS = [
1403
+ ["fontfamily", "fontFamily", "font_family"],
1404
+ ["fontfamilytypes", "fontFamilyTypes"],
1405
+ ["semanticicons", "semanticIcons"],
1406
+ ["svgdata", "svgData"]
1407
+ ];
1408
+ var aliasCaseVariants = (cfg) => {
1409
+ for (const vs of ALIAS_GROUPS) {
1410
+ let merged;
1411
+ for (const v of vs) {
1412
+ const val = cfg[v];
1413
+ if (!isObject(val)) continue;
1414
+ merged = merged ? deepMerge(val, merged) : val;
1415
+ }
1416
+ if (!merged) continue;
1417
+ for (const v of vs) if (isObject(cfg[v])) cfg[v] = merged;
1418
+ }
1419
+ };
1420
+ var createConfig = (name, overrides, { cleanBase = false } = {}) => {
1421
+ const activeBase = cleanBase ? null : getActiveConfig();
1422
+ const base = deepClone(
1423
+ !cleanBase && activeBase && activeBase._scratchConfig ? activeBase : cachedConfig
1424
+ );
1425
+ for (const flag of APP_FLAGS) {
1426
+ delete base[flag];
1427
+ }
1428
+ const cfg = deepMerge(overrides || {}, base);
1429
+ cfg.cssVars = {};
1430
+ cfg.cssMediaVars = {};
1431
+ cfg.CSS_VARS = cfg.cssVars;
1432
+ cfg.CSS_MEDIA_VARS = cfg.cssMediaVars;
1433
+ cfg._scratchConfig = true;
1434
+ aliasCaseVariants(cfg);
1435
+ if (name) FACTORY[name] = cfg;
1436
+ return cfg;
1437
+ };
1241
1438
 
1242
1439
  // src/utils/sequence.js
1243
1440
  var numToLetterMap = {
@@ -1280,7 +1477,8 @@ var SmblsScratch = (() => {
1280
1477
  variable
1281
1478
  };
1282
1479
  sequenceProps.scales[key] = scaling;
1283
- sequenceProps.vars[variable] = scaling + sequenceProps.unit;
1480
+ const varUnit = VIEWPORT_UNITS.has(sequenceProps.unit) ? "rem" : sequenceProps.unit;
1481
+ sequenceProps.vars[variable] = scaling + varUnit;
1284
1482
  };
1285
1483
  var getFnPrefixAndValue = (val) => {
1286
1484
  if (!val.includes("(")) return val;
@@ -1288,11 +1486,14 @@ var SmblsScratch = (() => {
1288
1486
  const value = val.slice(val.indexOf("(") + 1, val.lastIndexOf(")"));
1289
1487
  return [prefix, value];
1290
1488
  };
1489
+ var VIEWPORT_UNITS = /* @__PURE__ */ new Set(["vw", "vh", "vmin", "vmax", "svw", "svh", "lvw", "lvh", "dvw", "dvh"]);
1291
1490
  var setScalingVar = (key, sequenceProps) => {
1292
- const { base, type, unit: unit2 } = sequenceProps;
1491
+ const { base, type, unit: rawUnit } = sequenceProps;
1492
+ const unit2 = VIEWPORT_UNITS.has(rawUnit) ? "rem" : rawUnit;
1293
1493
  const defaultVal = (isScalingUnit(unit2) ? 1 : base) + unit2;
1294
1494
  if (key === 0) return defaultVal;
1295
- const prefix = "--" + (type && type.replace(".", "-"));
1495
+ const vp = sequenceProps.varPrefix ? sequenceProps.varPrefix + "-" : "";
1496
+ const prefix = "--" + vp + (type && type.replace(".", "-"));
1296
1497
  const ratioVar = `${prefix}-ratio`;
1297
1498
  if (key > 0) {
1298
1499
  const prevLetterKey = numToLetterMap[key - 1];
@@ -1300,6 +1501,12 @@ var SmblsScratch = (() => {
1300
1501
  }
1301
1502
  if (key < 0) {
1302
1503
  const nextLetterKey = numToLetterMap[key + 1];
1504
+ const absKey = Math.abs(key);
1505
+ const phiPow = Math.pow(PHI, 2 * absKey);
1506
+ const prevAscKey = numToLetterMap[absKey];
1507
+ if (prevAscKey) {
1508
+ return `max(calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar})), calc(var(${prefix}-${prevAscKey}) / ${phiPow.toFixed(4)}))`;
1509
+ }
1303
1510
  return `calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar}))`;
1304
1511
  }
1305
1512
  };
@@ -1307,7 +1514,8 @@ var SmblsScratch = (() => {
1307
1514
  const { type } = sequenceProps;
1308
1515
  const skipMiddle = index === 2 && arr.length === 2;
1309
1516
  const indexMapWithLength = skipMiddle ? index + 1 : index;
1310
- const prefix = "--" + (type && type.replace(".", "-"));
1517
+ const vp = sequenceProps.varPrefix ? sequenceProps.varPrefix + "-" : "";
1518
+ const prefix = "--" + vp + (type && type.replace(".", "-"));
1311
1519
  const subRatioVarPrefix = `${prefix}-sub-ratio-`;
1312
1520
  return `calc(var(${variable}) * var(${subRatioVarPrefix + indexMapWithLength}))`;
1313
1521
  };
@@ -1351,13 +1559,19 @@ var SmblsScratch = (() => {
1351
1559
  setSequenceValue(props2, sequenceProps);
1352
1560
  });
1353
1561
  };
1562
+ var PHI = 1.618;
1354
1563
  var switchSequenceOnNegative = (key, base, ratio) => {
1355
- return base * Math.pow(ratio, key);
1564
+ if (key >= 0) return base * Math.pow(ratio, key);
1565
+ const absKey = Math.abs(key);
1566
+ const current = base * Math.pow(ratio, key);
1567
+ const normalized = base * Math.pow(ratio, absKey) / Math.pow(PHI, 2 * absKey);
1568
+ return Math.max(current, normalized);
1356
1569
  };
1357
1570
  var generateSequence = (sequenceProps) => {
1358
1571
  const { type, base, ratio, range, subSequence } = sequenceProps;
1359
1572
  const n = Math.abs(range[0]) + Math.abs(range[1]);
1360
- const prefix = "--" + (type && type.replace(".", "-")) + "-";
1573
+ const vp = sequenceProps.varPrefix ? sequenceProps.varPrefix + "-" : "";
1574
+ const prefix = "--" + vp + (type && type.replace(".", "-")) + "-";
1361
1575
  for (let i = 0; i <= n; i++) {
1362
1576
  const key = range[1] - i;
1363
1577
  const letterKey = numToLetterMap[key];
@@ -1398,7 +1612,8 @@ var SmblsScratch = (() => {
1398
1612
  };
1399
1613
  const value = base * Math.pow(ratio, index);
1400
1614
  const scaling = ~~(value / base * 100) / 100;
1401
- const prefix = "--" + (type && type.replace(".", "-")) + "-";
1615
+ const vp = sequenceProps.varPrefix ? sequenceProps.varPrefix + "-" : "";
1616
+ const prefix = "--" + vp + (type && type.replace(".", "-")) + "-";
1402
1617
  const variable = prefix + letterKey;
1403
1618
  const scalingVariable = setScalingVar(index, sequenceProps);
1404
1619
  const props = {
@@ -1439,7 +1654,8 @@ var SmblsScratch = (() => {
1439
1654
  "revert-layer"
1440
1655
  ];
1441
1656
  if (skipArr.includes(value)) return value;
1442
- const prefix = `--${toDashCase(sequenceProps.type.replace(".", "-"))}-`;
1657
+ const vp = sequenceProps.varPrefix ? sequenceProps.varPrefix + "-" : "";
1658
+ const prefix = `--${vp}${toDashCase(sequenceProps.type.replace(".", "-"))}-`;
1443
1659
  const letterVal = value.toUpperCase();
1444
1660
  const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
1445
1661
  let absValue = isNegative ? letterVal.slice(1) : letterVal;
@@ -1486,12 +1702,12 @@ var SmblsScratch = (() => {
1486
1702
  (v) => value.includes(v + " ")
1487
1703
  );
1488
1704
  if (!mathArr.length) return value;
1489
- return mathArr.map((symbol) => {
1490
- const valuesArr = value.split(symbol + " ").map((v) => v.trim());
1491
- const transformedValues = valuesArr.map((v) => {
1492
- return getSequenceValue(v, sequenceProps);
1493
- });
1494
- return transformedValues.join(" " + symbol + " ");
1705
+ const symbolRegex = /(\s*[+\-*/,]\s*)/;
1706
+ const tokens = value.split(symbolRegex);
1707
+ return tokens.map((token) => {
1708
+ const trimmed = token.trim();
1709
+ if (!trimmed || ["+", "-", "*", "/", ","].includes(trimmed)) return token;
1710
+ return getSequenceValue(trimmed, sequenceProps);
1495
1711
  }).join("");
1496
1712
  };
1497
1713
  var getSequenceValuePropertyPair = (value, propertyName, sequenceProps, fnPrefix) => {
@@ -1524,13 +1740,13 @@ var SmblsScratch = (() => {
1524
1740
  };
1525
1741
 
1526
1742
  // src/utils/var.js
1527
- init_esm();
1743
+ init_utils();
1528
1744
  var setVariables = (result, key) => {
1529
1745
  const CONFIG2 = getActiveConfig();
1530
- const { CSS_VARS: CSS_VARS2 } = CONFIG2;
1746
+ const { cssVars: CSS_VARS } = CONFIG2;
1531
1747
  if (isObjectLike(result.value)) {
1532
1748
  } else {
1533
- CSS_VARS2[result.var] = result.value;
1749
+ CSS_VARS[result.var] = result.value;
1534
1750
  }
1535
1751
  };
1536
1752
  var applySequenceGlobalVars = (vars2, obj, options) => {
@@ -1538,7 +1754,8 @@ var SmblsScratch = (() => {
1538
1754
  const { unit: UNIT } = CONFIG2;
1539
1755
  const unit2 = obj.unit || UNIT.default;
1540
1756
  const { base, ratio, type } = obj;
1541
- const prefix = "--" + (type && type.replace(".", "-"));
1757
+ const vp = obj.varPrefix ? obj.varPrefix + "-" : "";
1758
+ const prefix = "--" + vp + (type && type.replace(".", "-"));
1542
1759
  vars2[`${prefix}-base`] = base;
1543
1760
  vars2[`${prefix}-unit`] = unit2;
1544
1761
  const ratioVar = `${prefix}-ratio`;
@@ -1548,65 +1765,78 @@ var SmblsScratch = (() => {
1548
1765
  vars2[`${prefix}-sub-ratio-2`] = `calc(var(${prefix}-ratio) * ${middle / ratio})`;
1549
1766
  vars2[`${prefix}-sub-ratio-3`] = `calc(var(${prefix}-ratio) * ${second / ratio})`;
1550
1767
  };
1768
+ var VIEWPORT_UNITS2 = /* @__PURE__ */ new Set(["vw", "vh", "vmin", "vmax", "svw", "svh", "lvw", "lvh", "dvw", "dvh"]);
1551
1769
  var applySequenceVars = (FACTORY2, options = {}) => {
1552
1770
  const CONFIG2 = getActiveConfig();
1553
- const { unit: UNIT, timing: TIMING, CSS_VARS: CSS_VARS2 } = CONFIG2;
1554
- const unit2 = FACTORY2.unit || UNIT.default;
1771
+ const { unit: UNIT, timing: TIMING, cssVars: CSS_VARS } = CONFIG2;
1772
+ const rawUnit = FACTORY2.unit || UNIT.default;
1773
+ const unit2 = VIEWPORT_UNITS2.has(rawUnit) ? "rem" : rawUnit;
1555
1774
  const { mediaRegenerate, sequence: sequence2, scales } = FACTORY2;
1556
1775
  if (!mediaRegenerate) {
1557
- applySequenceGlobalVars(CSS_VARS2, FACTORY2, options);
1776
+ applySequenceGlobalVars(CSS_VARS, FACTORY2, options);
1558
1777
  }
1559
1778
  for (const key in sequence2) {
1560
1779
  const item = sequence2[key];
1561
1780
  const value = (FACTORY2.type === TIMING.type ? sequence2[key].val : scales[key]) + unit2;
1562
1781
  if (!mediaRegenerate) {
1563
- CSS_VARS2[item.variable + "_default"] = value;
1564
- CSS_VARS2[item.variable] = item.scalingVariable;
1782
+ CSS_VARS[item.variable + "_default"] = value;
1783
+ CSS_VARS[item.variable] = item.scalingVariable;
1565
1784
  continue;
1566
1785
  }
1567
1786
  if (options.useDefault === false) {
1568
- CSS_VARS2[item.variable] = value;
1787
+ CSS_VARS[item.variable] = value;
1569
1788
  } else {
1570
- CSS_VARS2[item.variable + "_default"] = value;
1571
- CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
1789
+ CSS_VARS[item.variable + "_default"] = value;
1790
+ CSS_VARS[item.variable] = `var(${item.variable + "_default"})`;
1572
1791
  }
1573
1792
  }
1574
1793
  };
1575
1794
  var applyMediaSequenceVars = (FACTORY2, media2, options = {}) => {
1576
1795
  const CONFIG2 = getActiveConfig();
1577
- const { unit: UNIT, media: MEDIA, CSS_VARS: CSS_VARS2 } = CONFIG2;
1796
+ const { unit: UNIT, media: MEDIA, cssVars: CSS_VARS } = CONFIG2;
1578
1797
  const mediaName = media2.slice(1);
1579
- const unit2 = FACTORY2.unit || UNIT.default;
1798
+ const mediaConfig = FACTORY2[media2];
1799
+ const rawMediaUnit = mediaConfig.unit || FACTORY2.unit || UNIT.default;
1800
+ const unit2 = VIEWPORT_UNITS2.has(rawMediaUnit) ? "rem" : rawMediaUnit;
1580
1801
  const { mediaRegenerate } = FACTORY2;
1581
- const { sequence: sequence2, scales } = FACTORY2[media2];
1802
+ const { sequence: sequence2, scales } = mediaConfig;
1582
1803
  const query = MEDIA[mediaName];
1583
1804
  if (!query && CONFIG2.verbose) console.warn("Can't find media query ", query);
1584
1805
  if (!mediaRegenerate) {
1585
- let underMediaQuery = CSS_VARS2[`@media ${query}`];
1586
- if (!underMediaQuery) underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
1587
- applySequenceGlobalVars(underMediaQuery, FACTORY2[media2], options);
1806
+ let underMediaQuery = CSS_VARS[`@media ${query}`];
1807
+ if (!underMediaQuery) underMediaQuery = CSS_VARS[`@media ${query}`] = {};
1808
+ applySequenceGlobalVars(underMediaQuery, mediaConfig, options);
1809
+ const parentUnit = FACTORY2.unit || UNIT.default;
1810
+ if (unit2 !== parentUnit && sequence2) {
1811
+ for (const key in sequence2) {
1812
+ const item = sequence2[key];
1813
+ const value = scales[key] + unit2;
1814
+ underMediaQuery[item.variable + "_default"] = value;
1815
+ underMediaQuery[item.variable] = value;
1816
+ }
1817
+ }
1588
1818
  return;
1589
1819
  }
1590
1820
  for (const key in sequence2) {
1591
1821
  const item = sequence2[key];
1592
1822
  const value = (isScalingUnit(unit2) ? scales[key] : sequence2[key].val) + unit2;
1593
1823
  if (!query && CONFIG2.verbose) console.warn("Can't find query ", query);
1594
- let underMediaQuery = CSS_VARS2[`@media ${query}`];
1595
- if (!underMediaQuery) underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
1824
+ let underMediaQuery = CSS_VARS[`@media ${query}`];
1825
+ if (!underMediaQuery) underMediaQuery = CSS_VARS[`@media ${query}`] = {};
1596
1826
  underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
1597
- CSS_VARS2[item.variable + "_" + mediaName] = value;
1827
+ CSS_VARS[item.variable + "_" + mediaName] = value;
1598
1828
  }
1599
1829
  };
1600
1830
 
1601
1831
  // src/utils/sprite.js
1602
- init_esm();
1832
+ init_utils();
1603
1833
  var isDev = isNotProduction();
1604
1834
  var generateSprite = (icons2) => {
1605
1835
  const CONFIG2 = getActiveConfig();
1606
1836
  let sprite = "";
1607
1837
  for (const key in icons2) {
1608
- if (CONFIG2.__svg_cache[key]) continue;
1609
- else CONFIG2.__svg_cache[key] = true;
1838
+ if (CONFIG2.__svgCache[key]) continue;
1839
+ else CONFIG2.__svgCache[key] = true;
1610
1840
  sprite += icons2[key];
1611
1841
  }
1612
1842
  return sprite;
@@ -1657,8 +1887,15 @@ var SmblsScratch = (() => {
1657
1887
  symbol = symbol.replace(/width="[^"]*"/, "");
1658
1888
  symbol = symbol.replace(/height="[^"]*"/, "");
1659
1889
  symbol = symbol.replace("</svg", "</symbol");
1890
+ symbol = expandSvgSelfClosing(symbol);
1660
1891
  return symbol;
1661
1892
  };
1893
+ var SVG_VOID_TAGS = "line|circle|ellipse|rect|polyline|polygon|path|stop|use|image";
1894
+ var SVG_SELF_CLOSING_RE = new RegExp(
1895
+ `<(${SVG_VOID_TAGS})\\b([^>]*?)\\s*/>`,
1896
+ "g"
1897
+ );
1898
+ var expandSvgSelfClosing = (str) => str.replace(SVG_SELF_CLOSING_RE, "<$1$2></$1>");
1662
1899
 
1663
1900
  // src/system/index.js
1664
1901
  var system_exports = {};
@@ -1697,7 +1934,7 @@ var SmblsScratch = (() => {
1697
1934
  });
1698
1935
 
1699
1936
  // src/system/color.js
1700
- init_esm();
1937
+ init_utils();
1701
1938
  var getColor = (value, key, config) => {
1702
1939
  const CONFIG2 = config || getActiveConfig();
1703
1940
  if (!isString(value)) {
@@ -1769,11 +2006,14 @@ var SmblsScratch = (() => {
1769
2006
  const isObj = isObject(val);
1770
2007
  if (isObj && val.value) return getColor(value, `@${globalTheme}`, config);
1771
2008
  else if (isObj) {
2009
+ if (CONFIG2.useVariable && val.var) return `var(${val.var})`;
1772
2010
  if (globalTheme) return getColor(value, `@${globalTheme}`, config);
1773
2011
  else {
1774
2012
  const obj = {};
1775
2013
  for (const mediaName in val) {
2014
+ if (mediaName.charCodeAt(0) !== 64) continue;
1776
2015
  const query = CONFIG2.media[mediaName.slice(1)];
2016
+ if (!query) continue;
1777
2017
  const media2 = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
1778
2018
  obj[media2] = getColor(value, mediaName, config);
1779
2019
  }
@@ -1791,7 +2031,11 @@ var SmblsScratch = (() => {
1791
2031
  val = getColor(rawRef);
1792
2032
  if (!(val.includes("rgb") || val.includes("var") || val.includes("#"))) {
1793
2033
  const parts = rawRef.split(" ");
1794
- const refColor = CONFIG2.color[parts[0]];
2034
+ let refColor = CONFIG2.color[parts[0]];
2035
+ if (refColor && !refColor.value && !refColor.rgb && (isString(refColor) || isArray(refColor) || isObject(refColor))) {
2036
+ CONFIG2.color[parts[0]] = setColor(refColor, parts[0]);
2037
+ refColor = CONFIG2.color[parts[0]];
2038
+ }
1795
2039
  if (refColor && refColor.value) {
1796
2040
  let rgb2 = refColor.rgb;
1797
2041
  const alpha2 = parts[1] !== void 0 ? parts[1] : "1";
@@ -1822,10 +2066,7 @@ var SmblsScratch = (() => {
1822
2066
  }
1823
2067
  }
1824
2068
  if (isArray(val)) {
1825
- return {
1826
- "@light": setColor(val[0], key, "light"),
1827
- "@dark": setColor(val[1], key, "dark")
1828
- };
2069
+ val = { "@light": val[0], "@dark": val[1] };
1829
2070
  }
1830
2071
  if (isObject(val)) {
1831
2072
  const obj = {};
@@ -1836,16 +2077,71 @@ var SmblsScratch = (() => {
1836
2077
  variant.slice(0, 1) === "@" ? variant.slice(1) : variant
1837
2078
  );
1838
2079
  }
2080
+ if (CONFIG2.useVariable) {
2081
+ const vp2 = CONFIG2.varPrefix ? CONFIG2.varPrefix + "-" : "";
2082
+ const adaptiveVar = `--${vp2}color-${key}`;
2083
+ let fallbackValue;
2084
+ const schemeValues = {};
2085
+ for (const variant in obj) {
2086
+ if (variant.charCodeAt(0) !== 64) continue;
2087
+ const scheme = variant.slice(1);
2088
+ const entry = obj[variant];
2089
+ const value2 = entry && (entry.value || entry);
2090
+ if (!value2 || typeof value2 !== "string") continue;
2091
+ schemeValues[scheme] = value2;
2092
+ if (scheme === "light" || fallbackValue === void 0) fallbackValue = value2;
2093
+ }
2094
+ if (fallbackValue !== void 0) {
2095
+ CONFIG2.cssVars[adaptiveVar] = fallbackValue;
2096
+ if (!CONFIG2.cssMediaVars) CONFIG2.cssMediaVars = {};
2097
+ for (const scheme in schemeValues) {
2098
+ const sel = `[data-theme="${scheme}"]`;
2099
+ if (!CONFIG2.cssMediaVars[sel]) CONFIG2.cssMediaVars[sel] = {};
2100
+ CONFIG2.cssMediaVars[sel][adaptiveVar] = schemeValues[scheme];
2101
+ if (scheme === "light" || scheme === "dark") {
2102
+ const mq = `@media (prefers-color-scheme: ${scheme})`;
2103
+ if (!CONFIG2.cssMediaVars[mq]) CONFIG2.cssMediaVars[mq] = {};
2104
+ CONFIG2.cssMediaVars[mq][adaptiveVar] = schemeValues[scheme];
2105
+ }
2106
+ }
2107
+ obj.var = adaptiveVar;
2108
+ }
2109
+ }
1839
2110
  return obj;
1840
2111
  }
1841
- const CSSVar = `--color-${key}` + (suffix ? `-${suffix}` : "");
1842
- const colorArr = colorStringToRgbaArray(val.value || val);
2112
+ const vp = CONFIG2.varPrefix ? CONFIG2.varPrefix + "-" : "";
2113
+ const CSSVar = `--${vp}color-${key}` + (suffix ? `-${suffix}` : "");
2114
+ let resolvedVal = val.value || val;
2115
+ if (isString(resolvedVal) && resolvedVal.includes(".") && !resolvedVal.includes("(")) {
2116
+ const [colorRef, alphaStr] = resolvedVal.split(".");
2117
+ const refColor = CONFIG2.color[colorRef];
2118
+ if (refColor && refColor.rgb) {
2119
+ resolvedVal = `rgba(${refColor.rgb}, ${parseFloat("0." + alphaStr) || 1})`;
2120
+ }
2121
+ }
2122
+ if (isString(resolvedVal) && !resolvedVal.includes("(") && !resolvedVal.startsWith("#")) {
2123
+ const parsed = parseColorToken(resolvedVal);
2124
+ if (parsed && parsed.name && !parsed.passthrough && !parsed.cssVar) {
2125
+ const refColor = CONFIG2.color[parsed.name];
2126
+ if (refColor && !refColor.value && !refColor.rgb && (isString(refColor) || isArray(refColor) || isObject(refColor))) {
2127
+ CONFIG2.color[parsed.name] = setColor(refColor, parsed.name);
2128
+ }
2129
+ const baseColor = CONFIG2.color[parsed.name];
2130
+ if (baseColor && baseColor.rgb) {
2131
+ let rgb2 = baseColor.rgb;
2132
+ if (parsed.tone) rgb2 = getRgbTone(rgb2, parsed.tone);
2133
+ const alphaVal = parsed.alpha ? parseFloat(parsed.alpha) : 1;
2134
+ resolvedVal = `rgba(${rgb2}, ${alphaVal})`;
2135
+ }
2136
+ }
2137
+ }
2138
+ const colorArr = colorStringToRgbaArray(resolvedVal);
1843
2139
  const [r, g, b, a = 1] = colorArr;
1844
2140
  const alpha = parseFloat(a.toFixed(2));
1845
2141
  const rgb = `${r}, ${g}, ${b}`;
1846
2142
  const value = `rgba(${rgb}, ${alpha})`;
1847
2143
  if (CONFIG2.useVariable) {
1848
- CONFIG2.CSS_VARS[CSSVar] = value;
2144
+ CONFIG2.cssVars[CSSVar] = value;
1849
2145
  }
1850
2146
  return {
1851
2147
  var: CSSVar,
@@ -1868,9 +2164,10 @@ var SmblsScratch = (() => {
1868
2164
  for (const variant in val) obj[variant] = setGradient(val[variant], key, variant.slice(0, 1) === "@" ? variant.slice(1) : variant);
1869
2165
  return obj;
1870
2166
  }
1871
- const CSSVar = `--gradient-${key}` + (suffix ? `-${suffix}` : "");
2167
+ const vp = CONFIG2.varPrefix ? CONFIG2.varPrefix + "-" : "";
2168
+ const CSSVar = `--${vp}gradient-${key}` + (suffix ? `-${suffix}` : "");
1872
2169
  if (CONFIG2.useVariable) {
1873
- CONFIG2.CSS_VARS[CSSVar] = val.value || val;
2170
+ CONFIG2.cssVars[CSSVar] = val.value || val;
1874
2171
  }
1875
2172
  return {
1876
2173
  var: CSSVar,
@@ -1879,7 +2176,7 @@ var SmblsScratch = (() => {
1879
2176
  };
1880
2177
 
1881
2178
  // src/system/theme.js
1882
- init_esm();
2179
+ init_utils();
1883
2180
  var CSS_NAMED_COLORS = /* @__PURE__ */ new Set([
1884
2181
  "black",
1885
2182
  "white",
@@ -2037,6 +2334,13 @@ var SmblsScratch = (() => {
2037
2334
  "yellowgreen",
2038
2335
  "rebeccapurple"
2039
2336
  ]);
2337
+ var COLOR_PARAM_TOKENS = ["color", "Color", "background", "Background", "fill", "Fill", "stroke", "Stroke"];
2338
+ var isColorParam = (param) => {
2339
+ for (let i = 0; i < COLOR_PARAM_TOKENS.length; i++) {
2340
+ if (param.includes(COLOR_PARAM_TOKENS[i])) return true;
2341
+ }
2342
+ return false;
2343
+ };
2040
2344
  var setThemeValue = (theme2) => {
2041
2345
  const value = {};
2042
2346
  const { state, media: media2, helpers, ...rest } = theme2;
@@ -2138,16 +2442,17 @@ var SmblsScratch = (() => {
2138
2442
  if (CONFIG2.useVariable) return setMediaTheme(val, key);
2139
2443
  const { state, media: media2, helpers } = val;
2140
2444
  const value = setThemeValue(val, key);
2141
- const CSSvar = `--theme-${key}`;
2445
+ const vp = CONFIG2.varPrefix ? CONFIG2.varPrefix + "-" : "";
2446
+ const CSSvar = `--${vp}theme-${key}`;
2142
2447
  setSelectors(val, value);
2143
2448
  setMedia(val, value);
2144
2449
  setHelpers(val, value);
2145
2450
  return { var: CSSvar, value, state, media: media2, helpers };
2146
2451
  };
2147
2452
  var generateAutoVars = (schemes, varPrefix, CONFIG2) => {
2148
- const { CSS_VARS: CSS_VARS2 } = CONFIG2;
2149
- if (!CONFIG2.CSS_MEDIA_VARS) CONFIG2.CSS_MEDIA_VARS = {};
2150
- const MEDIA_VARS = CONFIG2.CSS_MEDIA_VARS;
2453
+ const { cssVars: CSS_VARS } = CONFIG2;
2454
+ if (!CONFIG2.cssMediaVars) CONFIG2.cssMediaVars = {};
2455
+ const MEDIA_VARS = CONFIG2.cssMediaVars;
2151
2456
  const globalTheme = CONFIG2.globalTheme !== void 0 ? CONFIG2.globalTheme : "auto";
2152
2457
  const result = {};
2153
2458
  const allKeys = /* @__PURE__ */ new Set();
@@ -2155,19 +2460,18 @@ var SmblsScratch = (() => {
2155
2460
  if (schemes[scheme]) for (const k of Object.keys(schemes[scheme])) allKeys.add(k);
2156
2461
  }
2157
2462
  const brokenSchemes = /* @__PURE__ */ new Set();
2158
- if (globalTheme === "auto") {
2159
- for (const param of allKeys) {
2160
- const symb = param.slice(0, 1);
2161
- if (symb === "@" || symb === "." || symb === ":") continue;
2162
- for (const scheme in schemes) {
2163
- if (brokenSchemes.has(scheme)) continue;
2164
- const val = schemes[scheme]?.[param];
2165
- if (val === void 0) continue;
2166
- const color2 = getColor(val, `@${scheme}`);
2167
- if (color2 === void 0) continue;
2168
- if (isString(color2) && /^[a-z][a-zA-Z]+$/.test(color2) && !CSS_NAMED_COLORS.has(color2)) {
2169
- brokenSchemes.add(scheme);
2170
- }
2463
+ for (const param of allKeys) {
2464
+ const symb = param.slice(0, 1);
2465
+ if (symb === "@" || symb === "." || symb === ":") continue;
2466
+ if (!isColorParam(param)) continue;
2467
+ for (const scheme in schemes) {
2468
+ if (brokenSchemes.has(scheme)) continue;
2469
+ const val = schemes[scheme]?.[param];
2470
+ if (val === void 0) continue;
2471
+ const color2 = getColor(val, `@${scheme}`);
2472
+ if (color2 === void 0) continue;
2473
+ if (isString(color2) && /^[a-z][a-zA-Z]+$/.test(color2) && !CSS_NAMED_COLORS.has(color2)) {
2474
+ brokenSchemes.add(scheme);
2171
2475
  }
2172
2476
  }
2173
2477
  }
@@ -2189,38 +2493,31 @@ var SmblsScratch = (() => {
2189
2493
  }
2190
2494
  result[param] = generateAutoVars(subSchemes, `${varPrefix}-${pseudoName}`, CONFIG2);
2191
2495
  } else if (symb !== "@" && symb !== "." && symb !== ":") {
2192
- const autoVar = `--theme-${varPrefix}-${param}`;
2193
- if (globalTheme === "auto") {
2194
- let fallbackColor;
2195
- for (const scheme in schemes) {
2196
- if (brokenSchemes.has(scheme)) continue;
2197
- const val = schemes[scheme]?.[param];
2198
- if (val === void 0) continue;
2199
- const color2 = getColor(val, `@${scheme}`);
2200
- if (color2 === void 0) continue;
2201
- if (scheme === "light" || fallbackColor === void 0) {
2202
- fallbackColor = color2;
2203
- }
2204
- const selector = `[data-theme="${scheme}"]`;
2205
- if (!MEDIA_VARS[selector]) MEDIA_VARS[selector] = {};
2206
- MEDIA_VARS[selector][autoVar] = color2;
2207
- if (scheme === "dark" || scheme === "light") {
2208
- const mq = `@media (prefers-color-scheme: ${scheme})`;
2209
- if (!MEDIA_VARS[mq]) MEDIA_VARS[mq] = {};
2210
- MEDIA_VARS[mq][autoVar] = color2;
2211
- }
2212
- }
2213
- if (fallbackColor !== void 0) {
2214
- CSS_VARS2[autoVar] = fallbackColor;
2496
+ const vp = CONFIG2.varPrefix ? CONFIG2.varPrefix + "-" : "";
2497
+ const autoVar = `--${vp}theme-${varPrefix}-${param}`;
2498
+ const forced = globalTheme && globalTheme !== "auto" ? String(globalTheme).replace(/^'|'$/g, "") : null;
2499
+ let fallbackColor;
2500
+ for (const scheme in schemes) {
2501
+ if (brokenSchemes.has(scheme)) continue;
2502
+ const val = schemes[scheme]?.[param];
2503
+ if (val === void 0) continue;
2504
+ const color2 = getColor(val, `@${scheme}`);
2505
+ if (color2 === void 0) continue;
2506
+ if (forced && scheme === forced || !forced && (scheme === "light" || fallbackColor === void 0)) {
2507
+ fallbackColor = color2;
2215
2508
  }
2216
- } else {
2217
- const forced = String(globalTheme).replace(/^'|'$/g, "");
2218
- const source = schemes[forced]?.[param];
2219
- if (source !== void 0) {
2220
- const color2 = getColor(source, `@${forced}`);
2221
- if (color2 !== void 0) CSS_VARS2[autoVar] = color2;
2509
+ const selector = `[data-theme="${scheme}"]`;
2510
+ if (!MEDIA_VARS[selector]) MEDIA_VARS[selector] = {};
2511
+ MEDIA_VARS[selector][autoVar] = color2;
2512
+ if (scheme === "dark" || scheme === "light") {
2513
+ const mq = `@media (prefers-color-scheme: ${scheme})`;
2514
+ if (!MEDIA_VARS[mq]) MEDIA_VARS[mq] = {};
2515
+ MEDIA_VARS[mq][autoVar] = color2;
2222
2516
  }
2223
2517
  }
2518
+ if (fallbackColor !== void 0) {
2519
+ CSS_VARS[autoVar] = fallbackColor;
2520
+ }
2224
2521
  result[param] = `var(${autoVar})`;
2225
2522
  result[`.${param}`] = { [param]: result[param] };
2226
2523
  }
@@ -2235,7 +2532,7 @@ var SmblsScratch = (() => {
2235
2532
  };
2236
2533
  var setMediaTheme = (val, key, suffix, prefers) => {
2237
2534
  const CONFIG2 = getActiveConfig();
2238
- const { CSS_VARS: CSS_VARS2 } = CONFIG2;
2535
+ const { cssVars: CSS_VARS } = CONFIG2;
2239
2536
  const theme2 = { value: val };
2240
2537
  const isTopLevel = !suffix && !prefers;
2241
2538
  if (isObjectLike(val)) {
@@ -2261,9 +2558,10 @@ var SmblsScratch = (() => {
2261
2558
  const color2 = getColor(value, prefers);
2262
2559
  const metaSuffixes = [...new Set([prefers, suffix].filter((v) => v).map((v) => v.slice(1)))];
2263
2560
  const varmetaSuffixName = metaSuffixes.length ? "-" + metaSuffixes.join("-") : "";
2264
- const CSSVar = `--theme-${key}${varmetaSuffixName}-${param}`;
2561
+ const vp = CONFIG2.varPrefix ? CONFIG2.varPrefix + "-" : "";
2562
+ const CSSVar = `--${vp}theme-${key}${varmetaSuffixName}-${param}`;
2265
2563
  if (CONFIG2.useVariable) {
2266
- if (CONFIG2.useThemeSuffixedVars) CSS_VARS2[CSSVar] = color2;
2564
+ if (CONFIG2.useThemeSuffixedVars) CSS_VARS[CSSVar] = color2;
2267
2565
  theme2[param] = `var(${CSSVar})`;
2268
2566
  } else {
2269
2567
  theme2[param] = color2;
@@ -2336,42 +2634,43 @@ var SmblsScratch = (() => {
2336
2634
  };
2337
2635
 
2338
2636
  // src/system/font.js
2339
- init_esm();
2637
+ init_utils();
2638
+ init_utils();
2340
2639
  var setFont = (val, key) => {
2341
2640
  const CONFIG2 = getActiveConfig();
2342
2641
  const CSSvar = `--font-${key}`;
2343
2642
  if (!val || isArray(val) && !val[0]) return;
2344
- let fontFace;
2643
+ let fontFace2;
2345
2644
  if (val.isVariable) {
2346
2645
  const url = resolveFileUrl(val.url, CONFIG2.files) || val.url;
2347
2646
  if (isGoogleFontsUrl(url)) {
2348
- fontFace = setFontImport(url);
2647
+ fontFace2 = setFontImport(url);
2349
2648
  } else {
2350
- fontFace = setCustomFontMedia(key, url, val.fontWeight, {
2649
+ fontFace2 = setCustomFontMedia(key, url, val.fontWeight, {
2351
2650
  fontStretch: val.fontStretch,
2352
2651
  fontDisplay: val.fontDisplay || "swap"
2353
2652
  });
2354
2653
  }
2355
2654
  } else if (val[0]) {
2356
- fontFace = getFontFaceEach(key, val, CONFIG2.files);
2655
+ fontFace2 = getFontFaceEach(key, val, CONFIG2.files);
2357
2656
  } else {
2358
2657
  const url = Array.isArray(val.url) ? val.url.map((u) => resolveFileUrl(u, CONFIG2.files) || u) : resolveFileUrl(val.url, CONFIG2.files) || val.url;
2359
- fontFace = setCustomFontMedia(key, url, val.fontWeight, {
2658
+ fontFace2 = setCustomFontMedia(key, url, val.fontWeight, {
2360
2659
  fontStyle: val.fontStyle,
2361
2660
  fontDisplay: val.fontDisplay,
2362
2661
  fontStretch: val.fontStretch
2363
2662
  });
2364
2663
  }
2365
- return { var: CSSvar, value: val, fontFace };
2664
+ return { var: CSSvar, value: val, fontFace: fontFace2 };
2366
2665
  };
2367
2666
  var getFontFamily = (key, factory) => {
2368
2667
  const CONFIG2 = getActiveConfig();
2369
- const { font_family: FONT_FAMILY } = CONFIG2;
2668
+ const { fontFamily: FONT_FAMILY } = CONFIG2;
2370
2669
  return getDefaultOrFirstKey(factory || FONT_FAMILY, key);
2371
2670
  };
2372
2671
  var setFontFamily = (val, key) => {
2373
2672
  const CONFIG2 = getActiveConfig();
2374
- const { font_family: FONT_FAMILY, font_family_types: FONT_FAMILY_TYPES } = CONFIG2;
2673
+ const { fontFamily: FONT_FAMILY, fontFamilyTypes: FONT_FAMILY_TYPES } = CONFIG2;
2375
2674
  let { value, type } = val;
2376
2675
  if (val.isDefault) FONT_FAMILY.default = key;
2377
2676
  if (isObject(value)) value = arrayzeValue(value);
@@ -2381,7 +2680,7 @@ var SmblsScratch = (() => {
2381
2680
  };
2382
2681
 
2383
2682
  // src/system/typography.js
2384
- init_esm();
2683
+ init_utils();
2385
2684
  var runThroughMedia = (FACTORY2) => {
2386
2685
  const CONFIG2 = getActiveConfig();
2387
2686
  const { typography: TYPOGRAPHY, media: MEDIA } = CONFIG2;
@@ -2401,12 +2700,21 @@ var SmblsScratch = (() => {
2401
2700
  h1Matches,
2402
2701
  unit: unit2
2403
2702
  });
2703
+ const VIEWPORT_UNITS3 = /* @__PURE__ */ new Set(["vw", "vh", "vmin", "vmax", "svw", "svh", "lvw", "lvh", "dvw", "dvh"]);
2704
+ const inheritedUnit = mediaValue.unit || unit2;
2705
+ const mediaUnit = !mediaValue.unit && VIEWPORT_UNITS3.has(unit2) ? "rem" : inheritedUnit;
2404
2706
  const query = MEDIA[mediaName];
2405
2707
  const media2 = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
2406
2708
  TYPOGRAPHY.templates[media2] = {
2407
- fontSize: mediaValue.base / TYPOGRAPHY.browserDefault + unit2
2709
+ fontSize: mediaValue.base / TYPOGRAPHY.browserDefault + mediaUnit
2408
2710
  };
2409
2711
  if (!mediaRegenerate) {
2712
+ merge(mediaValue, {
2713
+ sequence: {},
2714
+ scales: {},
2715
+ vars: {}
2716
+ });
2717
+ generateSequence(mediaValue);
2410
2718
  applyMediaSequenceVars(FACTORY2, prop);
2411
2719
  continue;
2412
2720
  }
@@ -2454,7 +2762,8 @@ var SmblsScratch = (() => {
2454
2762
  };
2455
2763
 
2456
2764
  // src/system/spacing.js
2457
- init_esm();
2765
+ init_utils();
2766
+ init_utils();
2458
2767
  var runThroughMedia2 = (FACTORY2) => {
2459
2768
  for (const prop in FACTORY2) {
2460
2769
  const mediaProps = FACTORY2[prop];
@@ -2560,7 +2869,7 @@ var SmblsScratch = (() => {
2560
2869
  };
2561
2870
 
2562
2871
  // src/system/shadow.js
2563
- init_esm();
2872
+ init_utils();
2564
2873
  var setShadow = (value, key, suffix, prefers) => {
2565
2874
  const CONFIG2 = getActiveConfig();
2566
2875
  if (isArray(value)) {
@@ -2597,9 +2906,10 @@ var SmblsScratch = (() => {
2597
2906
  }).join(" ");
2598
2907
  }).join(", ");
2599
2908
  }
2600
- const CSSVar = `--shadow-${key}` + (suffix ? `-${suffix}` : "");
2909
+ const vp = CONFIG2.varPrefix ? CONFIG2.varPrefix + "-" : "";
2910
+ const CSSVar = `--${vp}shadow-${key}` + (suffix ? `-${suffix}` : "");
2601
2911
  if (CONFIG2.useVariable) {
2602
- CONFIG2.CSS_VARS[CSSVar] = value;
2912
+ CONFIG2.cssVars[CSSVar] = value;
2603
2913
  }
2604
2914
  return {
2605
2915
  var: CSSVar,
@@ -2641,6 +2951,7 @@ var SmblsScratch = (() => {
2641
2951
  };
2642
2952
 
2643
2953
  // src/system/timing.js
2954
+ init_utils();
2644
2955
  var applyTimingSequence = () => {
2645
2956
  const CONFIG2 = getActiveConfig();
2646
2957
  const { timing: TIMING } = CONFIG2;
@@ -2663,10 +2974,10 @@ var SmblsScratch = (() => {
2663
2974
  };
2664
2975
 
2665
2976
  // src/system/document.js
2666
- init_esm();
2977
+ init_utils();
2667
2978
  var applyDocument = () => {
2668
2979
  const CONFIG2 = getActiveConfig();
2669
- const { document: DOCUMENT, font_family: FONT_FAMILY, theme: THEME, typography: TYPOGRAPHY } = CONFIG2;
2980
+ const { document: DOCUMENT, fontFamily: FONT_FAMILY, theme: THEME, typography: TYPOGRAPHY } = CONFIG2;
2670
2981
  return merge(DOCUMENT, {
2671
2982
  theme: THEME.document,
2672
2983
  fontFamily: getDefaultOrFirstKey(FONT_FAMILY),
@@ -2676,7 +2987,7 @@ var SmblsScratch = (() => {
2676
2987
  };
2677
2988
 
2678
2989
  // src/system/svg.js
2679
- init_esm();
2990
+ init_utils();
2680
2991
  var DEF_OPTIONS = {
2681
2992
  document: document2
2682
2993
  };
@@ -2694,12 +3005,12 @@ var SmblsScratch = (() => {
2694
3005
  var appendSVGSprite = (LIBRARY, options = DEF_OPTIONS) => {
2695
3006
  const CONFIG2 = getActiveConfig();
2696
3007
  const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.svg;
2697
- for (const key in LIBRARY) lib[key] = CONFIG2.svg[key];
3008
+ for (const key in LIBRARY) lib[key] = LIBRARY[key];
2698
3009
  appendSVG(lib, options);
2699
3010
  };
2700
3011
  var setSvgIcon = (val, key) => {
2701
3012
  const CONFIG2 = getActiveConfig();
2702
- if (CONFIG2.useIconSprite && !CONFIG2.semantic_icons?.[key]) {
3013
+ if (CONFIG2.useIconSprite && !CONFIG2.semanticIcons?.[key]) {
2703
3014
  return setSVG(val, key);
2704
3015
  }
2705
3016
  return val;
@@ -2707,7 +3018,7 @@ var SmblsScratch = (() => {
2707
3018
  var appendSvgIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
2708
3019
  const CONFIG2 = getActiveConfig();
2709
3020
  const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.icons;
2710
- for (const key in LIBRARY) lib[key] = CONFIG2.icons[key];
3021
+ for (const key in LIBRARY) lib[key] = LIBRARY[key];
2711
3022
  appendSVG(lib, options);
2712
3023
  };
2713
3024
  var createSVGSpriteElement = (doc, options = { isRoot: true }) => {
@@ -2722,6 +3033,24 @@ var SmblsScratch = (() => {
2722
3033
  }
2723
3034
  return svgElem;
2724
3035
  };
3036
+ var parseSVGSprite = (doc, svgString) => {
3037
+ const DOMParserCtor = typeof DOMParser !== "undefined" ? DOMParser : null;
3038
+ if (DOMParserCtor) {
3039
+ const wrapped = `<svg xmlns="http://www.w3.org/2000/svg">${svgString}</svg>`;
3040
+ const parser = new DOMParserCtor();
3041
+ const parsed = parser.parseFromString(wrapped, "image/svg+xml");
3042
+ if (parsed.querySelector("parsererror")) return null;
3043
+ return parsed.documentElement;
3044
+ }
3045
+ return null;
3046
+ };
3047
+ var moveChildren = (doc, from, to) => {
3048
+ while (from.firstChild) {
3049
+ const child = from.firstChild;
3050
+ to.appendChild(doc.importNode(child, true));
3051
+ child.remove();
3052
+ }
3053
+ };
2725
3054
  var appendSVG = (lib, options = DEF_OPTIONS) => {
2726
3055
  const CONFIG2 = getActiveConfig();
2727
3056
  const doc = options.document || document2;
@@ -2734,8 +3063,11 @@ var SmblsScratch = (() => {
2734
3063
  const exists = doc.querySelector("#svgSprite");
2735
3064
  const SVGsprite = generateSprite(lib);
2736
3065
  const spriteHtml = `<svg aria-hidden="true" width="0" height="0" style="position:absolute" id="svgSprite">${SVGsprite}</svg>`;
3066
+ const parsed = parseSVGSprite(doc, SVGsprite);
2737
3067
  if (exists) {
2738
- if (doc.body.insertAdjacentHTML) {
3068
+ if (parsed) {
3069
+ moveChildren(doc, parsed, exists);
3070
+ } else if (doc.body.insertAdjacentHTML) {
2739
3071
  exists.insertAdjacentHTML("beforeend", SVGsprite);
2740
3072
  } else {
2741
3073
  const tempSVG = createSVGSpriteElement(doc, { isRoot: false });
@@ -2743,7 +3075,13 @@ var SmblsScratch = (() => {
2743
3075
  exists.append(...tempSVG.children);
2744
3076
  }
2745
3077
  } else {
2746
- if (doc.body.insertAdjacentHTML) {
3078
+ if (parsed) {
3079
+ const svgSpriteDOM = createSVGSpriteElement(doc);
3080
+ if (svgSpriteDOM && svgSpriteDOM.nodeType) {
3081
+ moveChildren(doc, parsed, svgSpriteDOM);
3082
+ doc.body.prepend(svgSpriteDOM);
3083
+ }
3084
+ } else if (doc.body.insertAdjacentHTML) {
2747
3085
  doc.body.insertAdjacentHTML("afterbegin", spriteHtml);
2748
3086
  } else {
2749
3087
  const svgSpriteDOM = createSVGSpriteElement(doc);
@@ -2756,7 +3094,7 @@ var SmblsScratch = (() => {
2756
3094
  };
2757
3095
 
2758
3096
  // src/system/reset.js
2759
- init_esm();
3097
+ init_utils();
2760
3098
  var applyReset = (reset2 = {}) => {
2761
3099
  const CONFIG2 = getActiveConfig();
2762
3100
  const { reset: RESET, typography: TYPOGRAPHY, document: DOCUMENT } = CONFIG2;
@@ -2778,10 +3116,28 @@ var SmblsScratch = (() => {
2778
3116
  const { body, ...templates2 } = TYPOGRAPHY.templates;
2779
3117
  const globalTheme = CONFIG2.useDocumentTheme ? getMediaTheme("document") : {};
2780
3118
  if (RESET.html) overwriteDeep(RESET.html, globalTheme);
3119
+ if (TYPOGRAPHY.unit) {
3120
+ const { media: MEDIA } = CONFIG2;
3121
+ for (const key in TYPOGRAPHY) {
3122
+ if (key.charAt(0) !== "@") continue;
3123
+ const mediaTypo = TYPOGRAPHY[key];
3124
+ if (!mediaTypo) continue;
3125
+ if (mediaTypo.unit === TYPOGRAPHY.unit || !mediaTypo.unit) continue;
3126
+ const mediaUnit = mediaTypo.unit;
3127
+ const mediaBase = mediaTypo.base || TYPOGRAPHY.base;
3128
+ const mediaBrowserDefault = mediaTypo.browserDefault || TYPOGRAPHY.browserDefault;
3129
+ const mediaName = key.slice(1);
3130
+ const query = MEDIA[mediaName];
3131
+ if (!query) continue;
3132
+ const mediaKey = "@media " + (query === "print" ? query : "screen and " + query);
3133
+ if (!RESET[mediaKey]) RESET[mediaKey] = {};
3134
+ if (!RESET[mediaKey].html) RESET[mediaKey].html = {};
3135
+ RESET[mediaKey].html.fontSize = mediaBase / mediaBrowserDefault + mediaUnit;
3136
+ }
3137
+ }
2781
3138
  return deepMerge(merge(RESET, reset2), {
2782
3139
  html: {
2783
3140
  position: "absolute",
2784
- // overflow: 'hidden',
2785
3141
  width: "100%",
2786
3142
  height: "100%",
2787
3143
  top: "0",
@@ -2790,7 +3146,7 @@ var SmblsScratch = (() => {
2790
3146
  WebkitFontSmoothing: "subpixel-antialiased",
2791
3147
  scrollBehavior: "smooth",
2792
3148
  ...globalTheme,
2793
- fontSize: TYPOGRAPHY.browserDefault + "px",
3149
+ fontSize: TYPOGRAPHY.unit ? TYPOGRAPHY.base / TYPOGRAPHY.browserDefault + TYPOGRAPHY.unit : TYPOGRAPHY.browserDefault + "px",
2794
3150
  fontFamily: DOCUMENT.fontFamily,
2795
3151
  lineHeight: DOCUMENT.lineHeight
2796
3152
  },
@@ -2806,21 +3162,30 @@ var SmblsScratch = (() => {
2806
3162
  a: {
2807
3163
  color: "currentColor"
2808
3164
  },
2809
- // form elements
3165
+ button: {
3166
+ color: "inherit",
3167
+ font: "inherit",
3168
+ background: "transparent",
3169
+ border: "none",
3170
+ cursor: "pointer",
3171
+ appearance: "none",
3172
+ WebkitAppearance: "none"
3173
+ },
3174
+ "input, select, textarea": {
3175
+ color: "inherit",
3176
+ font: "inherit"
3177
+ },
2810
3178
  fieldset: {
2811
3179
  border: 0,
2812
3180
  padding: 0,
2813
3181
  margin: 0
2814
- },
2815
- "select, input": {
2816
- fontFamily: DOCUMENT.fontFamily
2817
3182
  }
2818
3183
  });
2819
3184
  }
2820
3185
  };
2821
3186
 
2822
3187
  // src/transforms/index.js
2823
- init_esm();
3188
+ init_utils();
2824
3189
  var BORDER_STYLES = /* @__PURE__ */ new Set([
2825
3190
  "none",
2826
3191
  "hidden",
@@ -3003,12 +3368,12 @@ var SmblsScratch = (() => {
3003
3368
  };
3004
3369
 
3005
3370
  // src/set.js
3006
- init_esm();
3371
+ init_utils();
3007
3372
  var setVars = (val, key) => {
3008
3373
  const CONFIG2 = getActiveConfig();
3009
- const { CSS_VARS: CSS_VARS2 } = CONFIG2;
3374
+ const { cssVars: cssVars2 } = CONFIG2;
3010
3375
  const varName = key.startsWith("--") ? key : `--${key}`;
3011
- CSS_VARS2[varName] = val;
3376
+ cssVars2[varName] = val;
3012
3377
  return val;
3013
3378
  };
3014
3379
  var asIs = (val) => val;
@@ -3016,14 +3381,14 @@ var SmblsScratch = (() => {
3016
3381
  color: setColor,
3017
3382
  gradient: setGradient,
3018
3383
  font: setFont,
3019
- font_family: setFontFamily,
3384
+ fontFamily: setFontFamily,
3020
3385
  fontfamily: setFontFamily,
3021
3386
  theme: setTheme,
3022
3387
  icons: setSvgIcon,
3023
- semantic_icons: asIs,
3388
+ semanticIcons: asIs,
3024
3389
  semanticicons: asIs,
3025
3390
  svg: setSVG,
3026
- svg_data: asIs,
3391
+ svgData: asIs,
3027
3392
  typography: asIs,
3028
3393
  shadow: setShadow,
3029
3394
  spacing: asIs,
@@ -3038,12 +3403,14 @@ var SmblsScratch = (() => {
3038
3403
  };
3039
3404
  var setValue = (factoryName, value, key) => {
3040
3405
  const CONFIG2 = getActiveConfig();
3041
- const lowerName = factoryName.toLowerCase();
3042
- const FACTORY2 = CONFIG2[lowerName] || CONFIG2[factoryName];
3043
- if (VALUE_TRANSFORMERS[lowerName]) {
3406
+ const camelName = toCamel(factoryName);
3407
+ const lowerName = camelName.toLowerCase();
3408
+ const FACTORY2 = CONFIG2[camelName] || CONFIG2[lowerName] || CONFIG2[factoryName];
3409
+ const transformer = VALUE_TRANSFORMERS[camelName] || VALUE_TRANSFORMERS[lowerName];
3410
+ if (transformer) {
3044
3411
  try {
3045
- const result = VALUE_TRANSFORMERS[lowerName](value, key);
3046
- FACTORY2[key] = result;
3412
+ const result = transformer(value, key);
3413
+ if (FACTORY2) FACTORY2[key] = result;
3047
3414
  return FACTORY2;
3048
3415
  } catch (error) {
3049
3416
  if (CONFIG2.verbose)
@@ -3056,7 +3423,11 @@ var SmblsScratch = (() => {
3056
3423
  var setEach = (factoryName, props) => {
3057
3424
  const CONFIG2 = getActiveConfig();
3058
3425
  const lowerName = factoryName.toLowerCase();
3059
- const keys = Object.keys(props);
3426
+ const keys = Object.keys(props).sort((a, b) => {
3427
+ const aComposite = isObject(props[a]) || isArray(props[a]) ? 1 : 0;
3428
+ const bComposite = isObject(props[b]) || isArray(props[b]) ? 1 : 0;
3429
+ return aComposite - bComposite;
3430
+ });
3060
3431
  keys.forEach((key) => {
3061
3432
  try {
3062
3433
  return setValue(lowerName, props[key], key);
@@ -3074,33 +3445,59 @@ var SmblsScratch = (() => {
3074
3445
  });
3075
3446
  return CONFIG2[lowerName] || CONFIG2[factoryName];
3076
3447
  };
3077
- var changeGlobalTheme = (newTheme) => {
3078
- const CONFIG2 = getActiveConfig();
3448
+ var changeGlobalTheme = (newTheme, targetConfig) => {
3449
+ const CONFIG2 = targetConfig || getActiveConfig();
3079
3450
  CONFIG2.globalTheme = newTheme;
3080
- if (typeof document !== "undefined" && newTheme && newTheme !== "auto") {
3081
- document.documentElement.setAttribute("data-theme", newTheme);
3082
- }
3083
- for (const key in CONFIG2.CSS_VARS) {
3084
- if (key.startsWith("--theme-")) delete CONFIG2.CSS_VARS[key];
3451
+ const configDoc = CONFIG2.document && CONFIG2.document.documentElement ? CONFIG2.document : null;
3452
+ const targetDoc = configDoc || (typeof document !== "undefined" ? document : null);
3453
+ const targetWin = targetDoc && targetDoc.defaultView || (typeof window !== "undefined" ? window : null);
3454
+ if (targetDoc) {
3455
+ const root = CONFIG2.themeRoot || targetDoc.documentElement;
3456
+ const forced = newTheme && newTheme !== "auto";
3457
+ if (forced) {
3458
+ root.setAttribute("data-theme", newTheme);
3459
+ if (newTheme === "dark" || newTheme === "light") {
3460
+ root.style.colorScheme = newTheme;
3461
+ } else {
3462
+ root.style.colorScheme = "light dark";
3463
+ }
3464
+ } else if (targetWin && targetWin.matchMedia) {
3465
+ const apply = (mq2) => {
3466
+ root.setAttribute("data-theme", mq2.matches ? "dark" : "light");
3467
+ };
3468
+ const mq = targetWin.matchMedia("(prefers-color-scheme: dark)");
3469
+ apply(mq);
3470
+ root.style.colorScheme = "light dark";
3471
+ if (!CONFIG2.__prefersListener) {
3472
+ CONFIG2.__prefersListener = apply;
3473
+ try {
3474
+ mq.addEventListener("change", apply);
3475
+ } catch (e) {
3476
+ mq.addListener(apply);
3477
+ }
3478
+ }
3479
+ } else {
3480
+ root.setAttribute("data-theme", "light");
3481
+ root.style.colorScheme = "light";
3482
+ }
3085
3483
  }
3086
- for (const key in CONFIG2.CSS_MEDIA_VARS) {
3087
- delete CONFIG2.CSS_MEDIA_VARS[key];
3484
+ const themeVarPrefix = CONFIG2.varPrefix ? `--${CONFIG2.varPrefix}-theme-` : "--theme-";
3485
+ for (const key in CONFIG2.cssVars) {
3486
+ if (key.startsWith(themeVarPrefix)) delete CONFIG2.cssVars[key];
3088
3487
  }
3089
- const source = CONFIG2._originalTheme || CONFIG2.theme;
3090
- if (source) {
3091
- const fresh = JSON.parse(JSON.stringify(source));
3092
- CONFIG2.theme = fresh;
3093
- setEach("theme", fresh);
3488
+ for (const key in CONFIG2.cssMediaVars) {
3489
+ delete CONFIG2.cssMediaVars[key];
3094
3490
  }
3095
- if (typeof document !== "undefined" && CONFIG2.CSS_VARS) {
3096
- const sheets = document.styleSheets;
3491
+ if (targetDoc && CONFIG2.cssVars) {
3492
+ const targetSelector = CONFIG2.scopeSelector || ":root";
3493
+ const sheets = targetDoc.styleSheets;
3097
3494
  for (let i = 0; i < sheets.length; i++) {
3098
3495
  try {
3099
3496
  const rules = sheets[i].cssRules;
3100
3497
  for (let j = 0; j < rules.length; j++) {
3101
- if (rules[j].selectorText === ":root") {
3102
- for (const key in CONFIG2.CSS_VARS) {
3103
- rules[j].style.setProperty(key, CONFIG2.CSS_VARS[key]);
3498
+ if (rules[j].selectorText === targetSelector) {
3499
+ for (const key in CONFIG2.cssVars) {
3500
+ rules[j].style.setProperty(key, CONFIG2.cssVars[key]);
3104
3501
  }
3105
3502
  return CONFIG2;
3106
3503
  }
@@ -3113,7 +3510,7 @@ var SmblsScratch = (() => {
3113
3510
  };
3114
3511
  var SET_OPTIONS = {};
3115
3512
  var set = (recivedConfig, options = SET_OPTIONS) => {
3116
- let CONFIG2 = getActiveConfig();
3513
+ let CONFIG2 = options.config || getActiveConfig();
3117
3514
  const {
3118
3515
  version,
3119
3516
  verbose,
@@ -3123,19 +3520,19 @@ var SmblsScratch = (() => {
3123
3520
  useFontImport,
3124
3521
  useIconSprite,
3125
3522
  globalTheme,
3523
+ themeRoot,
3126
3524
  useDocumentTheme,
3127
3525
  useDefaultConfig,
3128
- semanticIcons,
3129
- SEMANTIC_ICONS,
3130
- // deprecated
3131
- semantic_icons: semantic_icons2,
3526
+ semanticIcons: semanticIcons2,
3132
3527
  files,
3528
+ assets,
3133
3529
  ...config
3134
3530
  } = recivedConfig;
3135
3531
  if (options.newConfig) {
3136
3532
  CONFIG2 = setActiveConfig(options.newConfig);
3137
3533
  }
3138
3534
  if (files !== void 0) CONFIG2.files = files;
3535
+ if (assets !== void 0) CONFIG2.assets = assets;
3139
3536
  if (verbose !== void 0) CONFIG2.verbose = verbose;
3140
3537
  if (useVariable !== void 0) CONFIG2.useVariable = useVariable;
3141
3538
  if (useReset !== void 0) CONFIG2.useReset = useReset;
@@ -3144,20 +3541,46 @@ var SmblsScratch = (() => {
3144
3541
  if (useIconSprite !== void 0) CONFIG2.useIconSprite = useIconSprite;
3145
3542
  if (useDocumentTheme !== void 0) CONFIG2.useDocumentTheme = useDocumentTheme;
3146
3543
  if (globalTheme !== void 0) CONFIG2.globalTheme = globalTheme;
3544
+ if (themeRoot !== void 0) CONFIG2.themeRoot = themeRoot;
3147
3545
  if (recivedConfig.useThemeSuffixedVars !== void 0)
3148
3546
  CONFIG2.useThemeSuffixedVars = recivedConfig.useThemeSuffixedVars;
3149
3547
  if (useDefaultConfig !== void 0) CONFIG2.useDefaultConfig = useDefaultConfig;
3150
- const _semanticIcons = semanticIcons || SEMANTIC_ICONS || semantic_icons2;
3151
- if (_semanticIcons !== void 0) {
3152
- CONFIG2.semantic_icons = _semanticIcons;
3153
- CONFIG2.semanticIcons = CONFIG2.semantic_icons;
3154
- CONFIG2.SEMANTIC_ICONS = CONFIG2.semantic_icons;
3155
- }
3548
+ if (semanticIcons2 !== void 0) CONFIG2.semanticIcons = semanticIcons2;
3156
3549
  if (CONFIG2.verbose) console.log(CONFIG2);
3157
- if (typeof document !== "undefined" && CONFIG2.globalTheme && CONFIG2.globalTheme !== "auto") {
3158
- document.documentElement.setAttribute("data-theme", CONFIG2.globalTheme);
3550
+ const setConfigDoc = CONFIG2.document && CONFIG2.document.documentElement ? CONFIG2.document : null;
3551
+ const setTargetDoc = setConfigDoc || (typeof document !== "undefined" ? document : null);
3552
+ const setTargetWin = setTargetDoc && setTargetDoc.defaultView || (typeof window !== "undefined" ? window : null);
3553
+ const setRoot = setTargetDoc && (CONFIG2.themeRoot || setTargetDoc.documentElement);
3554
+ if (setRoot && typeof setRoot.setAttribute === "function") {
3555
+ const forced = CONFIG2.globalTheme && CONFIG2.globalTheme !== "auto";
3556
+ if (forced) {
3557
+ setRoot.setAttribute("data-theme", CONFIG2.globalTheme);
3558
+ if (CONFIG2.globalTheme === "dark" || CONFIG2.globalTheme === "light") {
3559
+ setRoot.style.colorScheme = CONFIG2.globalTheme;
3560
+ } else {
3561
+ setRoot.style.colorScheme = "light dark";
3562
+ }
3563
+ } else if (setTargetWin && setTargetWin.matchMedia) {
3564
+ const apply = (mq2) => {
3565
+ setRoot.setAttribute("data-theme", mq2.matches ? "dark" : "light");
3566
+ };
3567
+ const mq = setTargetWin.matchMedia("(prefers-color-scheme: dark)");
3568
+ apply(mq);
3569
+ setRoot.style.colorScheme = "light dark";
3570
+ if (!CONFIG2.__prefersListener) {
3571
+ CONFIG2.__prefersListener = apply;
3572
+ try {
3573
+ mq.addEventListener("change", apply);
3574
+ } catch (e) {
3575
+ mq.addListener(apply);
3576
+ }
3577
+ }
3578
+ } else {
3579
+ setRoot.setAttribute("data-theme", "light");
3580
+ setRoot.style.colorScheme = "light";
3581
+ }
3159
3582
  }
3160
- if (!CONFIG2.__svg_cache) CONFIG2.__svg_cache = {};
3583
+ if (!CONFIG2.__svgCache) CONFIG2.__svgCache = {};
3161
3584
  const keys = Object.keys(config);
3162
3585
  const keySet = new Set(keys);
3163
3586
  keys.forEach((key) => {
@@ -3166,29 +3589,31 @@ var SmblsScratch = (() => {
3166
3589
  deepMerge(config[lower], config[key]);
3167
3590
  }
3168
3591
  });
3169
- if (config.theme && !CONFIG2._originalTheme) {
3170
- CONFIG2._originalTheme = JSON.parse(JSON.stringify(config.theme));
3171
- }
3172
3592
  keys.map((key) => {
3173
3593
  const lower = key.toLowerCase();
3174
3594
  if (lower !== key && keySet.has(lower)) return;
3175
3595
  return setEach(key, config[key]);
3176
3596
  });
3177
- if (config.typography || config.TYPOGRAPHY) {
3597
+ if (CONFIG2.varPrefix) {
3598
+ if (CONFIG2.typography) CONFIG2.typography.varPrefix = CONFIG2.varPrefix;
3599
+ if (CONFIG2.spacing) CONFIG2.spacing.varPrefix = CONFIG2.varPrefix;
3600
+ if (CONFIG2.timing) CONFIG2.timing.varPrefix = CONFIG2.varPrefix;
3601
+ }
3602
+ if (config.typography) {
3178
3603
  try {
3179
3604
  applyTypographySequence();
3180
3605
  } catch (e) {
3181
3606
  if (CONFIG2.verbose) console.warn("Error applying typography sequence", e);
3182
3607
  }
3183
3608
  }
3184
- if (config.spacing || config.SPACING) {
3609
+ if (config.spacing) {
3185
3610
  try {
3186
3611
  applySpacingSequence();
3187
3612
  } catch (e) {
3188
3613
  if (CONFIG2.verbose) console.warn("Error applying spacing sequence", e);
3189
3614
  }
3190
3615
  }
3191
- if (config.timing || config.TIMING) {
3616
+ if (config.timing) {
3192
3617
  try {
3193
3618
  applyTimingSequence();
3194
3619
  } catch (e) {
@@ -3196,7 +3621,8 @@ var SmblsScratch = (() => {
3196
3621
  }
3197
3622
  }
3198
3623
  applyDocument();
3199
- applyReset();
3624
+ const computedReset = applyReset();
3625
+ if (computedReset) CONFIG2.reset = computedReset;
3200
3626
  return CONFIG2;
3201
3627
  };
3202
3628
  return __toCommonJS(index_exports);