@sugarcube-org/core 0.0.1-alpha.7 → 0.0.1-alpha.9

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.
package/dist/index.d.ts CHANGED
@@ -22,9 +22,22 @@ type FluidConfig = {
22
22
  min: number;
23
23
  max: number;
24
24
  };
25
+ /**
26
+ * Theme configuration can be either:
27
+ * - Simple: string[] of file paths
28
+ * - Nested: { source: string[], modes?: Record<string, string[]> }
29
+ */
30
+ type ThemeConfig = string[] | {
31
+ source: string[];
32
+ /** Mode variations within this theme */
33
+ modes?: Record<string, string[]>;
34
+ };
25
35
  type TokenCollection = {
26
36
  source: string[];
27
- themes?: Record<string, string[]>;
37
+ /** Mode variations (light/dark) - generates [data-mode="..."] selectors */
38
+ modes?: Record<string, string[]>;
39
+ /** Theme variations (color schemes) - generates [data-theme="..."] selectors */
40
+ themes?: Record<string, ThemeConfig>;
28
41
  };
29
42
  /**
30
43
  * Multiple named collections of tokens.
@@ -49,6 +62,10 @@ type UserOutputConfig = {
49
62
  css?: string;
50
63
  components?: string;
51
64
  separate?: boolean;
65
+ /** Attribute name for mode selectors (default: "data-mode") */
66
+ modeAttribute?: string;
67
+ /** Attribute name for theme selectors (default: "data-theme") */
68
+ themeAttribute?: string;
52
69
  };
53
70
  /**
54
71
  * Configuration for output directories (internal config - required fields)
@@ -57,6 +74,10 @@ type OutputConfig = {
57
74
  css: string;
58
75
  components?: string;
59
76
  separate: boolean;
77
+ /** Attribute name for mode selectors */
78
+ modeAttribute: string;
79
+ /** Attribute name for theme selectors */
80
+ themeAttribute: string;
60
81
  };
61
82
  /**
62
83
  * Utilities configuration
@@ -357,26 +378,30 @@ type GradientStop = {
357
378
  type Gradient = GradientStop[];
358
379
 
359
380
  /**
360
- * Source information for a token, tracking its collection and theme.
381
+ * Source information for a token, tracking its collection, theme, and mode.
361
382
  * This metadata helps with error reporting and token organization.
362
383
  */
363
384
  type TokenSource = {
364
385
  /** The collection this token belongs to (e.g., "base", "ui", "marketing") */
365
386
  collection: string;
366
- /** Optional theme name (e.g., "dark", "light", "high-contrast") */
387
+ /** Optional theme name for color scheme variations (e.g., "ocean", "sunset") */
367
388
  theme?: string;
389
+ /** Optional mode name for light/dark variations (e.g., "dark", "light") */
390
+ mode?: string;
368
391
  /** The path to the source file containing this token */
369
392
  sourcePath: string;
370
393
  };
371
394
  /**
372
- * A complete token tree with collection and theme information.
395
+ * A complete token tree with collection, theme, and mode information.
373
396
  * This represents a single token file's contents with its metadata.
374
397
  */
375
398
  type TokenTree = {
376
399
  /** The collection this token tree belongs to (e.g., "base", "ui", "marketing") */
377
400
  collection: string;
378
- /** Optional theme name (e.g., "dark", "light", "high-contrast") */
401
+ /** Optional theme name for color scheme variations (e.g., "ocean", "sunset") */
379
402
  theme?: string;
403
+ /** Optional mode name for light/dark variations (e.g., "dark", "light") */
404
+ mode?: string;
380
405
  /** The actual token data following the W3C design tokens format */
381
406
  tokens: TokenGroup;
382
407
  /** The path to the source file containing these tokens */
@@ -448,18 +473,28 @@ type ConvertedTokens = {
448
473
  [lookupKey: string]: ConvertedToken | NodeMetadata;
449
474
  };
450
475
  /**
451
- * A collection of converted tokens organized by theme.
452
- * Each theme contains its own set of converted tokens.
476
+ * A collection of converted tokens organized by mode (light/dark).
477
+ * Each mode contains its own set of converted tokens.
453
478
  */
454
- type ConvertedThemeTokenSet = {
455
- /** The default theme's tokens */
479
+ type ConvertedModeTokenSet = {
480
+ /** The default mode's tokens (typically light) */
456
481
  default: ConvertedTokens;
457
- /** Additional theme-specific tokens */
458
- [theme: string]: ConvertedTokens;
482
+ /** Additional mode-specific tokens (e.g., dark) */
483
+ [mode: string]: ConvertedTokens;
484
+ };
485
+ /**
486
+ * A collection of converted tokens organized by theme (color scheme).
487
+ * Each theme contains modes (light/dark variations).
488
+ */
489
+ type ConvertedThemeTokenSet = {
490
+ /** The default theme's modes */
491
+ default: ConvertedModeTokenSet;
492
+ /** Additional theme-specific modes (e.g., ocean, sunset) */
493
+ [theme: string]: ConvertedModeTokenSet;
459
494
  };
460
495
  /**
461
- * A collection of converted tokens organized by collection and theme.
462
- * The top-level structure for all converted tokens.
496
+ * A collection of converted tokens organized by collection, theme, and mode.
497
+ * Structure: collection theme mode tokens
463
498
  */
464
499
  type NormalizedConvertedTokens = {
465
500
  [collection: string]: ConvertedThemeTokenSet;
@@ -583,8 +618,10 @@ type LoadedConfig = {
583
618
  type TokenMemoryData = Record<string, {
584
619
  /** The collection name this token belongs to */
585
620
  collection: string;
586
- /** Optional theme name for themed tokens */
621
+ /** Optional theme name for color scheme variations */
587
622
  theme?: string;
623
+ /** Optional mode name for light/dark variations */
624
+ mode?: string;
588
625
  /** The raw token content as a string */
589
626
  content: string;
590
627
  }>;
@@ -921,6 +958,8 @@ declare const DEFAULT_CONFIG: {
921
958
  readonly css: "src/styles";
922
959
  readonly components: "src/components/ui";
923
960
  readonly separate: false;
961
+ readonly modeAttribute: "data-mode";
962
+ readonly themeAttribute: "data-theme";
924
963
  };
925
964
  readonly transforms: {
926
965
  readonly fluid: {
@@ -933,6 +972,7 @@ declare const DEFAULT_CONFIG: {
933
972
 
934
973
  declare const DEFAULT_COLLECTION = "default";
935
974
  declare const DEFAULT_THEME = "default";
975
+ declare const DEFAULT_MODE = "default";
936
976
 
937
977
  declare const ErrorMessages: {
938
978
  readonly LOAD: {
@@ -1018,22 +1058,62 @@ declare const ErrorMessages: {
1018
1058
  declare const userConfigSchema: z.ZodObject<{
1019
1059
  tokens: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodObject<{
1020
1060
  source: z.ZodArray<z.ZodString, "many">;
1021
- themes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1061
+ /** Mode variations (light/dark) - generates [data-mode="..."] selectors */
1062
+ modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1063
+ /** Theme variations (color schemes) - generates [data-theme="..."] selectors */
1064
+ themes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodObject<{
1065
+ source: z.ZodArray<z.ZodString, "many">;
1066
+ modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1067
+ }, "strip", z.ZodTypeAny, {
1068
+ source: string[];
1069
+ modes?: Record<string, string[]> | undefined;
1070
+ }, {
1071
+ source: string[];
1072
+ modes?: Record<string, string[]> | undefined;
1073
+ }>]>>>;
1022
1074
  }, "strip", z.ZodTypeAny, {
1023
1075
  source: string[];
1024
- themes?: Record<string, string[]> | undefined;
1076
+ modes?: Record<string, string[]> | undefined;
1077
+ themes?: Record<string, string[] | {
1078
+ source: string[];
1079
+ modes?: Record<string, string[]> | undefined;
1080
+ }> | undefined;
1025
1081
  }, {
1026
1082
  source: string[];
1027
- themes?: Record<string, string[]> | undefined;
1083
+ modes?: Record<string, string[]> | undefined;
1084
+ themes?: Record<string, string[] | {
1085
+ source: string[];
1086
+ modes?: Record<string, string[]> | undefined;
1087
+ }> | undefined;
1028
1088
  }>>, z.ZodObject<{
1029
1089
  source: z.ZodArray<z.ZodString, "many">;
1030
- themes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1090
+ /** Mode variations (light/dark) - generates [data-mode="..."] selectors */
1091
+ modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1092
+ /** Theme variations (color schemes) - generates [data-theme="..."] selectors */
1093
+ themes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodObject<{
1094
+ source: z.ZodArray<z.ZodString, "many">;
1095
+ modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1096
+ }, "strip", z.ZodTypeAny, {
1097
+ source: string[];
1098
+ modes?: Record<string, string[]> | undefined;
1099
+ }, {
1100
+ source: string[];
1101
+ modes?: Record<string, string[]> | undefined;
1102
+ }>]>>>;
1031
1103
  }, "strip", z.ZodTypeAny, {
1032
1104
  source: string[];
1033
- themes?: Record<string, string[]> | undefined;
1105
+ modes?: Record<string, string[]> | undefined;
1106
+ themes?: Record<string, string[] | {
1107
+ source: string[];
1108
+ modes?: Record<string, string[]> | undefined;
1109
+ }> | undefined;
1034
1110
  }, {
1035
1111
  source: string[];
1036
- themes?: Record<string, string[]> | undefined;
1112
+ modes?: Record<string, string[]> | undefined;
1113
+ themes?: Record<string, string[] | {
1114
+ source: string[];
1115
+ modes?: Record<string, string[]> | undefined;
1116
+ }> | undefined;
1037
1117
  }>]>>;
1038
1118
  transforms: z.ZodOptional<z.ZodObject<{
1039
1119
  fluid: z.ZodOptional<z.ZodObject<{
@@ -1064,14 +1144,20 @@ declare const userConfigSchema: z.ZodObject<{
1064
1144
  css: z.ZodOptional<z.ZodString>;
1065
1145
  components: z.ZodOptional<z.ZodString>;
1066
1146
  separate: z.ZodOptional<z.ZodBoolean>;
1147
+ modeAttribute: z.ZodOptional<z.ZodString>;
1148
+ themeAttribute: z.ZodOptional<z.ZodString>;
1067
1149
  }, "strip", z.ZodTypeAny, {
1068
1150
  css?: string | undefined;
1069
1151
  components?: string | undefined;
1070
1152
  separate?: boolean | undefined;
1153
+ modeAttribute?: string | undefined;
1154
+ themeAttribute?: string | undefined;
1071
1155
  }, {
1072
1156
  css?: string | undefined;
1073
1157
  components?: string | undefined;
1074
1158
  separate?: boolean | undefined;
1159
+ modeAttribute?: string | undefined;
1160
+ themeAttribute?: string | undefined;
1075
1161
  }>>;
1076
1162
  utilities: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
1077
1163
  source: z.ZodString;
@@ -1113,10 +1199,18 @@ declare const userConfigSchema: z.ZodObject<{
1113
1199
  }, "strip", z.ZodTypeAny, {
1114
1200
  tokens?: {
1115
1201
  source: string[];
1116
- themes?: Record<string, string[]> | undefined;
1202
+ modes?: Record<string, string[]> | undefined;
1203
+ themes?: Record<string, string[] | {
1204
+ source: string[];
1205
+ modes?: Record<string, string[]> | undefined;
1206
+ }> | undefined;
1117
1207
  } | Record<string, {
1118
1208
  source: string[];
1119
- themes?: Record<string, string[]> | undefined;
1209
+ modes?: Record<string, string[]> | undefined;
1210
+ themes?: Record<string, string[] | {
1211
+ source: string[];
1212
+ modes?: Record<string, string[]> | undefined;
1213
+ }> | undefined;
1120
1214
  }> | undefined;
1121
1215
  transforms?: {
1122
1216
  fluid?: {
@@ -1129,6 +1223,8 @@ declare const userConfigSchema: z.ZodObject<{
1129
1223
  css?: string | undefined;
1130
1224
  components?: string | undefined;
1131
1225
  separate?: boolean | undefined;
1226
+ modeAttribute?: string | undefined;
1227
+ themeAttribute?: string | undefined;
1132
1228
  } | undefined;
1133
1229
  utilities?: Record<string, {
1134
1230
  source: string;
@@ -1146,10 +1242,18 @@ declare const userConfigSchema: z.ZodObject<{
1146
1242
  }, {
1147
1243
  tokens?: {
1148
1244
  source: string[];
1149
- themes?: Record<string, string[]> | undefined;
1245
+ modes?: Record<string, string[]> | undefined;
1246
+ themes?: Record<string, string[] | {
1247
+ source: string[];
1248
+ modes?: Record<string, string[]> | undefined;
1249
+ }> | undefined;
1150
1250
  } | Record<string, {
1151
1251
  source: string[];
1152
- themes?: Record<string, string[]> | undefined;
1252
+ modes?: Record<string, string[]> | undefined;
1253
+ themes?: Record<string, string[] | {
1254
+ source: string[];
1255
+ modes?: Record<string, string[]> | undefined;
1256
+ }> | undefined;
1153
1257
  }> | undefined;
1154
1258
  transforms?: {
1155
1259
  fluid?: {
@@ -1162,6 +1266,8 @@ declare const userConfigSchema: z.ZodObject<{
1162
1266
  css?: string | undefined;
1163
1267
  components?: string | undefined;
1164
1268
  separate?: boolean | undefined;
1269
+ modeAttribute?: string | undefined;
1270
+ themeAttribute?: string | undefined;
1165
1271
  } | undefined;
1166
1272
  utilities?: Record<string, {
1167
1273
  source: string;
@@ -1180,22 +1286,62 @@ declare const userConfigSchema: z.ZodObject<{
1180
1286
  declare const internalConfigSchema: z.ZodObject<{
1181
1287
  tokens: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodObject<{
1182
1288
  source: z.ZodArray<z.ZodString, "many">;
1183
- themes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1289
+ /** Mode variations (light/dark) - generates [data-mode="..."] selectors */
1290
+ modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1291
+ /** Theme variations (color schemes) - generates [data-theme="..."] selectors */
1292
+ themes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodObject<{
1293
+ source: z.ZodArray<z.ZodString, "many">;
1294
+ modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1295
+ }, "strip", z.ZodTypeAny, {
1296
+ source: string[];
1297
+ modes?: Record<string, string[]> | undefined;
1298
+ }, {
1299
+ source: string[];
1300
+ modes?: Record<string, string[]> | undefined;
1301
+ }>]>>>;
1184
1302
  }, "strip", z.ZodTypeAny, {
1185
1303
  source: string[];
1186
- themes?: Record<string, string[]> | undefined;
1304
+ modes?: Record<string, string[]> | undefined;
1305
+ themes?: Record<string, string[] | {
1306
+ source: string[];
1307
+ modes?: Record<string, string[]> | undefined;
1308
+ }> | undefined;
1187
1309
  }, {
1188
1310
  source: string[];
1189
- themes?: Record<string, string[]> | undefined;
1311
+ modes?: Record<string, string[]> | undefined;
1312
+ themes?: Record<string, string[] | {
1313
+ source: string[];
1314
+ modes?: Record<string, string[]> | undefined;
1315
+ }> | undefined;
1190
1316
  }>>, z.ZodObject<{
1191
1317
  source: z.ZodArray<z.ZodString, "many">;
1192
- themes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1318
+ /** Mode variations (light/dark) - generates [data-mode="..."] selectors */
1319
+ modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1320
+ /** Theme variations (color schemes) - generates [data-theme="..."] selectors */
1321
+ themes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodObject<{
1322
+ source: z.ZodArray<z.ZodString, "many">;
1323
+ modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1324
+ }, "strip", z.ZodTypeAny, {
1325
+ source: string[];
1326
+ modes?: Record<string, string[]> | undefined;
1327
+ }, {
1328
+ source: string[];
1329
+ modes?: Record<string, string[]> | undefined;
1330
+ }>]>>>;
1193
1331
  }, "strip", z.ZodTypeAny, {
1194
1332
  source: string[];
1195
- themes?: Record<string, string[]> | undefined;
1333
+ modes?: Record<string, string[]> | undefined;
1334
+ themes?: Record<string, string[] | {
1335
+ source: string[];
1336
+ modes?: Record<string, string[]> | undefined;
1337
+ }> | undefined;
1196
1338
  }, {
1197
1339
  source: string[];
1198
- themes?: Record<string, string[]> | undefined;
1340
+ modes?: Record<string, string[]> | undefined;
1341
+ themes?: Record<string, string[] | {
1342
+ source: string[];
1343
+ modes?: Record<string, string[]> | undefined;
1344
+ }> | undefined;
1199
1345
  }>]>>;
1200
1346
  transforms: z.ZodObject<{
1201
1347
  fluid: z.ZodObject<{
@@ -1226,14 +1372,20 @@ declare const internalConfigSchema: z.ZodObject<{
1226
1372
  css: z.ZodString;
1227
1373
  components: z.ZodString;
1228
1374
  separate: z.ZodBoolean;
1375
+ modeAttribute: z.ZodString;
1376
+ themeAttribute: z.ZodString;
1229
1377
  }, "strip", z.ZodTypeAny, {
1230
1378
  components: string;
1231
1379
  css: string;
1232
1380
  separate: boolean;
1381
+ modeAttribute: string;
1382
+ themeAttribute: string;
1233
1383
  }, {
1234
1384
  components: string;
1235
1385
  css: string;
1236
1386
  separate: boolean;
1387
+ modeAttribute: string;
1388
+ themeAttribute: string;
1237
1389
  }>;
1238
1390
  utilities: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
1239
1391
  source: z.ZodString;
@@ -1277,6 +1429,8 @@ declare const internalConfigSchema: z.ZodObject<{
1277
1429
  components: string;
1278
1430
  css: string;
1279
1431
  separate: boolean;
1432
+ modeAttribute: string;
1433
+ themeAttribute: string;
1280
1434
  };
1281
1435
  transforms: {
1282
1436
  fluid: {
@@ -1287,10 +1441,18 @@ declare const internalConfigSchema: z.ZodObject<{
1287
1441
  };
1288
1442
  tokens?: {
1289
1443
  source: string[];
1290
- themes?: Record<string, string[]> | undefined;
1444
+ modes?: Record<string, string[]> | undefined;
1445
+ themes?: Record<string, string[] | {
1446
+ source: string[];
1447
+ modes?: Record<string, string[]> | undefined;
1448
+ }> | undefined;
1291
1449
  } | Record<string, {
1292
1450
  source: string[];
1293
- themes?: Record<string, string[]> | undefined;
1451
+ modes?: Record<string, string[]> | undefined;
1452
+ themes?: Record<string, string[] | {
1453
+ source: string[];
1454
+ modes?: Record<string, string[]> | undefined;
1455
+ }> | undefined;
1294
1456
  }> | undefined;
1295
1457
  utilities?: Record<string, {
1296
1458
  source: string;
@@ -1310,6 +1472,8 @@ declare const internalConfigSchema: z.ZodObject<{
1310
1472
  components: string;
1311
1473
  css: string;
1312
1474
  separate: boolean;
1475
+ modeAttribute: string;
1476
+ themeAttribute: string;
1313
1477
  };
1314
1478
  transforms: {
1315
1479
  fluid: {
@@ -1320,10 +1484,18 @@ declare const internalConfigSchema: z.ZodObject<{
1320
1484
  };
1321
1485
  tokens?: {
1322
1486
  source: string[];
1323
- themes?: Record<string, string[]> | undefined;
1487
+ modes?: Record<string, string[]> | undefined;
1488
+ themes?: Record<string, string[] | {
1489
+ source: string[];
1490
+ modes?: Record<string, string[]> | undefined;
1491
+ }> | undefined;
1324
1492
  } | Record<string, {
1325
1493
  source: string[];
1326
- themes?: Record<string, string[]> | undefined;
1494
+ modes?: Record<string, string[]> | undefined;
1495
+ themes?: Record<string, string[] | {
1496
+ source: string[];
1497
+ modes?: Record<string, string[]> | undefined;
1498
+ }> | undefined;
1327
1499
  }> | undefined;
1328
1500
  utilities?: Record<string, {
1329
1501
  source: string;
@@ -1362,4 +1534,4 @@ declare function isSingleCollection(tokens: TokenCollection | TokenCollections):
1362
1534
  declare function isResolvedToken(token: unknown): token is ResolvedToken;
1363
1535
  declare function isResolvedTokenOfType<T extends TokenType>(token: unknown, type: T): token is ResolvedToken<T>;
1364
1536
 
1365
- export { type ArbitraryUtilityValue, type CSSFileOutput, type Candidate, DEFAULT_COLLECTION, DEFAULT_CONFIG, DEFAULT_DESIGN_TOKENS_PATH, DEFAULT_STYLES_PATH, DEFAULT_THEME, DEFAULT_UTILITIES_FILENAME, DEFAULT_VARIABLES_FILENAME, ErrorMessages, type FunctionalCandidate, type FunctionalVariant, GLOBAL_DIR, Instrumentation, type InternalConfig, type LoadedConfig, type NamedUtilityValue, type NormalizedConvertedTokens, type OutputConfig, type PipelineResult, type ResolvedToken, type ResolvedTokens, SUGARCUBE_CONFIG_FILE, SUGARCUBE_FILE, type StaticCandidate, type StaticUtilityPattern, type StaticVariant, type TokenCollection, type TokenCollections, type TokenLoader, type TokenPipelineSource, type TokenTree, UTILITIES_DIR, type UserConfig, type UserOutputConfig, type UtilitiesConfig, type UtilityValue, VARIABLES_FILE_SUFFIX, type Variant, configFileExists, convertConfigToUnoRules, discoverAllFiles, fillDefaults, findConfigFile, generateCSSVariables, generateIndex, generateIndexContent, internalConfigSchema, isResolvedToken, isResolvedTokenOfType, isSingleCollection, loadAndResolveTokens, loadInternalConfig, loadTSConfig, loadUserConfig, parseAndValidateConfig, processAndConvertTokens, shouldRegenerateIndex, userConfigSchema, validateConfig, validateInternalConfig, validateUserConfig, writeCSSUtilitiesToDisk, writeCSSVariablesToDisk };
1537
+ export { type ArbitraryUtilityValue, type CSSFileOutput, type Candidate, DEFAULT_COLLECTION, DEFAULT_CONFIG, DEFAULT_DESIGN_TOKENS_PATH, DEFAULT_MODE, DEFAULT_STYLES_PATH, DEFAULT_THEME, DEFAULT_UTILITIES_FILENAME, DEFAULT_VARIABLES_FILENAME, ErrorMessages, type FunctionalCandidate, type FunctionalVariant, GLOBAL_DIR, Instrumentation, type InternalConfig, type LoadedConfig, type NamedUtilityValue, type NormalizedConvertedTokens, type OutputConfig, type PipelineResult, type ResolvedToken, type ResolvedTokens, SUGARCUBE_CONFIG_FILE, SUGARCUBE_FILE, type StaticCandidate, type StaticUtilityPattern, type StaticVariant, type ThemeConfig, type TokenCollection, type TokenCollections, type TokenLoader, type TokenPipelineSource, type TokenTree, UTILITIES_DIR, type UserConfig, type UserOutputConfig, type UtilitiesConfig, type UtilityValue, VARIABLES_FILE_SUFFIX, type Variant, configFileExists, convertConfigToUnoRules, discoverAllFiles, fillDefaults, findConfigFile, generateCSSVariables, generateIndex, generateIndexContent, internalConfigSchema, isResolvedToken, isResolvedTokenOfType, isSingleCollection, loadAndResolveTokens, loadInternalConfig, loadTSConfig, loadUserConfig, parseAndValidateConfig, processAndConvertTokens, shouldRegenerateIndex, userConfigSchema, validateConfig, validateInternalConfig, validateUserConfig, writeCSSUtilitiesToDisk, writeCSSVariablesToDisk };
package/dist/index.js CHANGED
@@ -1,22 +1,22 @@
1
- var et=Object.defineProperty;var s=(e,t)=>et(e,"name",{value:t,configurable:!0});import C,{readFile as K,mkdir as fe,writeFile as pe}from"node:fs/promises";import z from"fast-glob";import{join as N,relative as _,basename as de,dirname as he,resolve as me}from"pathe";import{existsSync as D}from"node:fs";import{pathToFileURL as tt}from"node:url";import{z as m}from"zod";const w="_sugarcube.css",q="global",nt="utilities",S=".variables.gen.css",J="tokens",ot="utilities.gen.css",rt="src/styles",st="src/design-tokens",F="sugarcube.config.ts";function I(e){return typeof e=="string"&&e.startsWith("{")&&e.endsWith("}")}s(I,"isReference");function it(e){if(typeof e!="object"||e===null||!("$value"in e))return!1;const t=e.$value;return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Object.keys(t).length>0}s(it,"isCompositeToken");function at(e){return e.$type==="typography"}s(at,"isTypographyToken");function Ie(e){return typeof e=="object"&&e!==null&&"$path"in e&&"$type"in e&&"$resolvedValue"in e}s(Ie,"isResolvedToken");function ct(e,t){return Ie(e)&&e.$type===t}s(ct,"isResolvedTokenOfType");function V(e){return Object.entries(e).sort(([t],[n])=>t.localeCompare(n))}s(V,"deterministicEntries");const ye=new Map;function lt(e){const t=ye.get(e);if(t)return t;const n=e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z])(?=[a-z])/g,"$1-$2").toLowerCase();return ye.set(e,n),n}s(lt,"toKebabCase");function X(e){return e.split(".").join("-")}s(X,"formatCSSVarPath");function Z(e){return typeof e=="number"?e:typeof e!="string"?(console.warn("Unexpected value type in convertReferenceToCSSVar, got:",e),String(e)):e.replace(/\{([^}]+)\}/g,(t,n)=>`var(--${n.split(".").map(lt).join("-")})`)}s(Z,"convertReferenceToCSSVar");function ut(e){const t=e.$cssProperties;if("value"in t)return{name:`--${X(e.$path)}`,value:Z(t.value)}}s(ut,"generateSingleVariable");function ft(e){return Object.entries(e.$cssProperties).filter(([t,n])=>n!==void 0).map(([t,n])=>({name:`--${X(e.$path)}-${t}`,value:Z(n)}))}s(ft,"generateTypographyVariables");function $e(e){if(e.$type!=="color")return[];const t=e.$cssProperties;if(!("featureValues"in t))return[];const n=new Map;for(const o of t.featureValues||[]){n.has(o.query)||n.set(o.query,[]);const r=n.get(o.query);r&&r.push({name:`--${X(e.$path)}`,value:Z(o.value)})}return Array.from(n.entries()).map(([o,r])=>({query:o,vars:r}))}s($e,"generateFeatureVariables");function ge(e){const t=[`${e.selector} {`];if(e.comment&&t.push(` /* ${e.comment} */`),e.vars.length>0){const n=e.vars.map(o=>` ${o.name}: ${o.value};`).join(`
1
+ var ot=Object.defineProperty;var s=(e,t)=>ot(e,"name",{value:t,configurable:!0});import x,{readFile as X,mkdir as $e,writeFile as ge}from"node:fs/promises";import Z from"fast-glob";import{join as L,relative as D,basename as Ae,dirname as Te,resolve as be}from"pathe";import{existsSync as F}from"node:fs";import{pathToFileURL as rt}from"node:url";import{z as y}from"zod";const R="_sugarcube.css",Q="global",st="utilities",v=".variables.gen.css",ee="tokens",it="utilities.gen.css",at="src/styles",ct="src/design-tokens",C="sugarcube.config.ts";function $(e){return typeof e=="string"&&e.startsWith("{")&&e.endsWith("}")}s($,"isReference");function ut(e){if(typeof e!="object"||e===null||!("$value"in e))return!1;const t=e.$value;return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Object.keys(t).length>0}s(ut,"isCompositeToken");function lt(e){return e.$type==="typography"}s(lt,"isTypographyToken");function Ee(e){return typeof e=="object"&&e!==null&&"$path"in e&&"$type"in e&&"$resolvedValue"in e}s(Ee,"isResolvedToken");function ft(e,t){return Ee(e)&&e.$type===t}s(ft,"isResolvedTokenOfType");function j(e){return Object.entries(e).sort(([t],[n])=>t.localeCompare(n))}s(j,"deterministicEntries");const Ne=new Map;function pt(e){const t=Ne.get(e);if(t)return t;const n=e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z])(?=[a-z])/g,"$1-$2").toLowerCase();return Ne.set(e,n),n}s(pt,"toKebabCase");function te(e){return e.split(".").join("-")}s(te,"formatCSSVarPath");function ne(e){return typeof e=="number"?e:typeof e!="string"?(console.warn("Unexpected value type in convertReferenceToCSSVar, got:",e),String(e)):e.replace(/\{([^}]+)\}/g,(t,n)=>`var(--${n.split(".").map(pt).join("-")})`)}s(ne,"convertReferenceToCSSVar");function dt(e){const t=e.$cssProperties;if("value"in t)return{name:`--${te(e.$path)}`,value:ne(t.value)}}s(dt,"generateSingleVariable");function ht(e){return Object.entries(e.$cssProperties).filter(([t,n])=>n!==void 0).map(([t,n])=>({name:`--${te(e.$path)}-${t}`,value:ne(n)}))}s(ht,"generateTypographyVariables");function Se(e){if(e.$type!=="color")return[];const t=e.$cssProperties;if(!("featureValues"in t))return[];const n=new Map;for(const o of t.featureValues||[]){n.has(o.query)||n.set(o.query,[]);const r=n.get(o.query);r&&r.push({name:`--${te(e.$path)}`,value:ne(o.value)})}return Array.from(n.entries()).map(([o,r])=>({query:o,vars:r}))}s(Se,"generateFeatureVariables");function Oe(e){const t=[`${e.selector} {`];if(e.comment&&t.push(` /* ${e.comment} */`),e.vars.length>0){const n=e.vars.map(o=>` ${o.name}: ${o.value};`).join(`
2
2
  `);t.push(n)}return t.push("}"),t.join(`
3
- `)}s(ge,"generateCSSBlock");function pt(e){const t=[];e.root.vars.length>0&&t.push(ge({selector:e.root.selector,vars:e.root.vars}));for(const n of e.features){const r=ge({selector:e.root.selector,vars:n.vars}).split(`
3
+ `)}s(Oe,"generateCSSBlock");function mt(e){const t=[];e.root.vars.length>0&&t.push(Oe({selector:e.root.selector,vars:e.root.vars}));for(const n of e.features){const r=Oe({selector:e.root.selector,vars:n.vars}).split(`
4
4
  `).map(i=>` ${i}`).join(`
5
5
  `);t.push(`${n.query} {
6
6
  ${r}
7
7
  }`)}return t.filter(Boolean).join(`
8
8
 
9
- `)}s(pt,"convertCSSVarsToString");function dt(e){if(at(e))return{vars:ft(e),features:$e(e)};const t=ut(e);return{vars:t?[t]:[],features:$e(e)}}s(dt,"generateVariablesForToken");async function Q(e,t={}){const n=V(e).filter(([u,p])=>u!=="$extensions"&&"$type"in p).map(([u,p])=>dt(p));let o=":root";t.theme&&t.theme!=="default"&&(o=`[data-theme="${t.theme}"]`);const r=n.flatMap(u=>u.vars),i=n.flatMap(u=>u.features||[]),a=new Map;for(const u of i){a.has(u.query)||a.set(u.query,[]);const p=a.get(u.query);p&&p.push(...u.vars)}const c=Array.from(a.entries()).map(([u,p])=>({query:u,vars:p})),l=pt({root:{selector:o,vars:r},features:c});return l.trim()?{output:[{path:"tokens.variables.gen.css",css:ht(l),collection:t.collection??"default"}]}:{output:[{path:"tokens.variables.gen.css",css:"",collection:t.collection??"default"}]}}s(Q,"generateCSS");function ht(e){return e.endsWith(`
9
+ `)}s(mt,"convertCSSVarsToString");function yt(e){if(lt(e))return{vars:ht(e),features:Se(e)};const t=dt(e);return{vars:t?[t]:[],features:Se(e)}}s(yt,"generateVariablesForToken");function It(e,t,n){const o=[];return e&&e!=="default"&&o.push(`[${n.output.themeAttribute}="${e}"]`),t&&t!=="default"&&o.push(`[${n.output.modeAttribute}="${t}"]`),o.length>0?o.join(""):":root"}s(It,"buildSelector");async function oe(e,t,n={}){const o=j(e).filter(([p,f])=>p!=="$extensions"&&"$type"in f).map(([p,f])=>yt(f)),r=It(n.theme,n.mode,t),i=o.flatMap(p=>p.vars),a=o.flatMap(p=>p.features||[]),c=new Map;for(const p of a){c.has(p.query)||c.set(p.query,[]);const f=c.get(p.query);f&&f.push(...p.vars)}const u=Array.from(c.entries()).map(([p,f])=>({query:p,vars:f})),l=mt({root:{selector:r,vars:i},features:u});return l.trim()?{output:[{path:"tokens.variables.gen.css",css:$t(l),collection:n.collection??"default"}]}:{output:[{path:"tokens.variables.gen.css",css:"",collection:n.collection??"default"}]}}s(oe,"generateCSS");function $t(e){return e.endsWith(`
10
10
  `)?e:`${e}
11
- `}s(ht,"formatCSSVars");async function mt(e,t){const o=`${t.output?.css||"src/styles"}/${q}`,r=[];for(const[i,a]of V(e)){const c=[],l=Object.entries(a).sort(([u],[p])=>u==="default"?-1:p==="default"?1:u.localeCompare(p));for(const[u,p]of l){const d=await Q(p,{theme:u!=="default"?u:void 0,collection:i!=="default"?i:void 0});d.output[0].css.trim()&&c.push(d.output[0].css)}c.length>0&&r.push({path:i==="default"?`${o}/${J}${S}`:`${o}/${i}/${J}${S}`,css:`${c.filter(Boolean).join(`
11
+ `}s($t,"formatCSSVars");async function gt(e,t){const o=`${t.output?.css||"src/styles"}/${Q}`,r=[];for(const[i,a]of j(e)){const c=[],u=Object.entries(a).sort(([l],[p])=>l==="default"?-1:p==="default"?1:l.localeCompare(p));for(const[l,p]of u){const f=Object.entries(p).sort(([h],[m])=>h==="default"?-1:m==="default"?1:h.localeCompare(m));for(const[h,m]of f){const I=await oe(m,t,{theme:l!=="default"?l:void 0,mode:h!=="default"?h:void 0,collection:i!=="default"?i:void 0});I.output[0].css.trim()&&c.push(I.output[0].css)}}c.length>0&&r.push({path:i==="default"?`${o}/${ee}${v}`:`${o}/${i}/${ee}${v}`,css:`${c.filter(Boolean).join(`
12
12
  `).trim()}
13
- `,collection:i})}return r}s(mt,"generateSingleFile");async function It(e,t){const o=`${t.output?.css||"src/styles"}/${q}`,r=[];for(const[i,a]of V(e)){if(Object.keys(a).length===0)continue;const c=Object.entries(a).sort(([l],[u])=>l==="default"?-1:u==="default"?1:l.localeCompare(u));for(const[l,u]of c)if(Object.keys(u).length!==0)if(l==="default"){const p=new Map;for(const[d,h]of V(u)){if(!("$type"in h))continue;const $=h.$source.sourcePath;p.has($)||p.set($,{}),p.get($)[d]=h}for(const[d,h]of Array.from(p.entries()).sort(([y],[$])=>y.localeCompare($))){if(Object.keys(h).length===0)continue;const y=d.split("/").pop()?.replace(/\.json$/,"")??"tokens",A=(await Q(h,{collection:i==="default"?void 0:i})).output[0].css;A.trim()&&r.push({path:i==="default"?`${o}/${y}${S}`:`${o}/${i}/${y}${S}`,css:A,collection:i})}}else{const d=(await Q(u,{theme:l,collection:i==="default"?void 0:i})).output[0].css;d.trim()&&r.push({path:i==="default"?`${o}/${l}${S}`:`${o}/${i}/${l}${S}`,css:d,collection:i})}}return r}s(It,"generateSeparateFiles");async function yt(e,t){const n={};for(const[o,r]of Object.entries(e)){n[o]={default:{}},r.default&&(n[o].default=r.default);for(const[i,a]of Object.entries(r))i!=="default"&&a&&(n[o][i]=a);Object.keys(n[o].default).length===0&&Object.keys(n[o]).length===1&&delete n[o]}return t.output?.separate?{output:await It(n,t)}:{output:await mt(n,t)}}s(yt,"generate");async function $t(e,t){const{output:n}=await yt(e,t);return n}s($t,"generateCSSVariables");const f={LOAD:{NO_FILES_FOUND:s(e=>`No files found matching pattern: ${e}.`,"NO_FILES_FOUND"),INVALID_JSON:s((e,t)=>`Invalid JSON in file ${e}: ${t}`,"INVALID_JSON"),GLOB_ERROR:s((e,t)=>`Error resolving glob pattern ${e}: ${t}`,"GLOB_ERROR")},FLATTEN:{INVALID_TOKEN_NAME:s(e=>`Invalid token name "${e}": Token names cannot contain dots (.), curly braces ({,}), or other special characters`,"INVALID_TOKEN_NAME"),MISSING_DOLLAR_PREFIX:s(e=>`Token at ${e} is using 'value' or 'type' without the required '$' prefix. Use '$value' and '$type' instead.`,"MISSING_DOLLAR_PREFIX"),INVALID_TOKEN_NESTING:s(e=>`Token at "${e}" cannot contain child tokens or groups. Only metadata properties (starting with $) are allowed.`,"INVALID_TOKEN_NESTING"),COMPOSITE_TOKEN_MISSING_TYPE:s(e=>`Composite token at '${e}' is missing the required "$type" property. Composite tokens (tokens with object values) must specify their type to define their structure.`,"COMPOSITE_TOKEN_MISSING_TYPE"),CONFLICT_TOKEN_VS_GROUP:s(e=>`Conflict at "${e}": token vs group. A token cannot be replaced by a group (or vice versa).`,"CONFLICT_TOKEN_VS_GROUP"),CONFLICT_INCOMPATIBLE_TYPES:s((e,t,n)=>`Type conflict at "${n}": expected ${e}, got ${t}`,"CONFLICT_INCOMPATIBLE_TYPES")},METADATA:{COLLECTION_ERROR:s(e=>`Error collecting metadata: ${e}`,"COLLECTION_ERROR"),INVALID_EXTENSIONS:s(e=>`Invalid extensions at ${e}: expected object, got ${typeof e}`,"INVALID_EXTENSIONS"),INVALID_DESCRIPTION:s(e=>`Invalid description at ${e}: expected string, got ${typeof e}`,"INVALID_DESCRIPTION")},VALIDATE:{MISSING_TYPE:s(e=>`Token at '${e}' is missing the "$type" property`,"MISSING_TYPE"),UNKNOWN_TOKEN_TYPE:s((e,t)=>`Unknown token type '${e}' at ${t}. Valid types are: color, dimension, fontFamily, fontWeight, duration, cubicBezier, strokeStyle, border, transition, shadow, gradient, typography`,"UNKNOWN_TOKEN_TYPE"),INVALID_COLOR:s((e,t)=>`Invalid color at ${t}: '${e}'. Color should be a valid hex value or W3C color object`,"INVALID_COLOR"),INVALID_DIMENSION:s((e,t)=>`Invalid dimension at '${t}': ${e}. Dimensions should have a numeric value and unit, like { "value": 16, "unit": "px" }`,"INVALID_DIMENSION"),INVALID_DIMENSION_UNIT:s((e,t)=>`Invalid unit at ${t}': '${e}'. Unit must be either "px" or "rem"`,"INVALID_DIMENSION_UNIT"),INVALID_FONT_FAMILY:s((e,t)=>`Invalid font family at '${t}': ${e}. Should be a string or array of strings, like "Arial" or ["Arial", "sans-serif"]`,"INVALID_FONT_FAMILY"),INVALID_FONT_WEIGHT:s((e,t)=>`Invalid font weight at '${t}': ${e}. Should be a number between 1-1000 or a keyword like "thin", "light", "normal", "bold"`,"INVALID_FONT_WEIGHT"),INVALID_DURATION:s((e,t)=>`Invalid duration at '${t}': ${e}. Should be like { "value": 300, "unit": "ms" }`,"INVALID_DURATION"),INVALID_DURATION_UNIT:s((e,t)=>`Invalid unit at ${t}: "${e}". Unit must be "ms" or "s"`,"INVALID_DURATION_UNIT"),INVALID_CUBIC_BEZIER:s((e,t)=>`Invalid cubic bezier at ${t}: "${e}". Should be an array of 4 numbers between 0 and 1`,"INVALID_CUBIC_BEZIER"),INVALID_STROKE_STYLE:s((e,t)=>`Invalid stroke style at ${t}: "${e}". Should be "solid", "dashed", "dotted", etc.`,"INVALID_STROKE_STYLE"),INVALID_STROKE_LINE_CAP:s((e,t)=>`Invalid line cap at ${t}: "${e}". Should be one of: round, butt, square`,"INVALID_STROKE_LINE_CAP"),INVALID_BORDER:s((e,t)=>`Invalid border at ${t}: "${e}". Should have color, width, and style properties`,"INVALID_BORDER"),INVALID_SHADOW:s((e,t)=>`Invalid shadow at ${t}: "${e}". Should have color, offsetX, offsetY properties (blur and spread are optional)`,"INVALID_SHADOW"),INVALID_SHADOW_INSET:s((e,t)=>`Invalid inset value at ${t}: "${e}". Should be true or false`,"INVALID_SHADOW_INSET"),INVALID_TRANSITION:s((e,t)=>`Invalid transition at ${t}: "${e}". Should have duration, delay, and timingFunction properties`,"INVALID_TRANSITION"),INVALID_GRADIENT:s((e,t)=>`Invalid gradient at ${t}: "${e}". Should be an array of color stops with position values between 0 and 1`,"INVALID_GRADIENT"),INVALID_GRADIENT_STOP_POSITION:s((e,t)=>`Invalid gradient stop position at ${t}: "${e}". Position must be between 0 and 1`,"INVALID_GRADIENT_STOP_POSITION"),INVALID_TYPOGRAPHY:s((e,t)=>`Invalid typography at ${t}: "${e}". Should have fontFamily and fontSize (fontWeight, letterSpacing, and lineHeight are optional)`,"INVALID_TYPOGRAPHY"),MISSING_REQUIRED_PROPERTY:s((e,t)=>`Missing required property '${e}' at ${t}`,"MISSING_REQUIRED_PROPERTY"),INVALID_NUMBER:s((e,t)=>`Invalid number at ${t}: "${e}". Expected a number value`,"INVALID_NUMBER"),INVALID_ARRAY:s((e,t)=>`Invalid array at ${t}: "${e}". Expected an array value`,"INVALID_ARRAY"),MISSING_FLUID_CONFIG:s(e=>`Missing fluid configuration. Token at ${e} requires fluid viewport settings.`,"MISSING_FLUID_CONFIG"),INVALID_FLUID_DIMENSION:s((e,t)=>`Invalid fluid dimension at ${t}: "${e}". Fluid dimensions should have min and max values, like { "min": { "value": 16, "unit": "px" }, "max": { "value": 24, "unit": "px" } }`,"INVALID_FLUID_DIMENSION"),INVALID_VIEWPORT_CONFIG:s((e,t)=>`Invalid viewport configuration at ${t}: "${e}". Viewport config should have min and max dimension values`,"INVALID_VIEWPORT_CONFIG"),MISMATCHED_UNITS:s((e,t,n)=>`Mismatched units at ${n}: min uses '${e}', max uses '${t}'. Both values must use the same unit`,"MISMATCHED_UNITS"),INVALID_FLUID_VALUE_RANGE:s(e=>`Invalid fluid value range at ${e}: min value must be less than max value`,"INVALID_FLUID_VALUE_RANGE"),INVALID_TOKEN_TYPE:s((e,t,n)=>`Invalid token type at ${n}: expected ${e}, got ${t}`,"INVALID_TOKEN_TYPE"),INVALID_TYPE:s((e,t,n)=>`Expected ${e}, received ${typeof t} at ${n}`,"INVALID_TYPE"),INVALID_ENUM_VALUE:s((e,t,n)=>`Expected value to be one of [${e.join(", ")}], but got ${String(t)} at ${n}`,"INVALID_ENUM_VALUE")},RESOLVE:{CIRCULAR_REFERENCE:s((e,t)=>`Circular reference detected: ${e} -> ${t}`,"CIRCULAR_REFERENCE"),REFERENCE_NOT_FOUND:s((e,t)=>`Reference not found: ${e} in ${t}. Does ${e} exist?`,"REFERENCE_NOT_FOUND"),TYPE_MISMATCH:s(e=>`Type mismatch in ${e}`,"TYPE_MISMATCH")},GENERATE:{INVALID_CSS_VALUE:s((e,t)=>`Invalid CSS value for property '${e}': ${t}`,"INVALID_CSS_VALUE"),INVALID_VARIABLE_NAME:s((e,t)=>`Invalid CSS variable name at '${e}': ${t}`,"INVALID_VARIABLE_NAME")},CONFIG:{INVALID_JSON:s(e=>`Invalid JSON in config file: ${e}`,"INVALID_JSON"),INVALID_CONFIG:s((e,t)=>`Invalid configuration at ${e}: ${t}`,"INVALID_CONFIG"),DUPLICATE_FILENAMES:s((e,t,n)=>`Duplicate filename "${t}" found in collection "${e}":
13
+ `,collection:i})}return r}s(gt,"generateSingleFile");async function At(e,t){const o=`${t.output?.css||"src/styles"}/${Q}`,r=[];for(const[i,a]of j(e)){if(Object.keys(a).length===0)continue;const c=Object.entries(a).sort(([u],[l])=>u==="default"?-1:l==="default"?1:u.localeCompare(l));for(const[u,l]of c){if(Object.keys(l).length===0)continue;const p=Object.entries(l).sort(([f],[h])=>f==="default"?-1:h==="default"?1:f.localeCompare(h));for(const[f,h]of p)if(Object.keys(h).length!==0)if(u==="default"&&f==="default"){const m=new Map;for(const[I,g]of j(h)){if(!("$type"in g))continue;const T=g.$source.sourcePath;m.has(T)||m.set(T,{}),m.get(T)[I]=g}for(const[I,g]of Array.from(m.entries()).sort(([A],[T])=>A.localeCompare(T))){if(Object.keys(g).length===0)continue;const A=I.split("/").pop()?.replace(/\.json$/,"")??"tokens",N=(await oe(g,t,{collection:i==="default"?void 0:i})).output[0].css;N.trim()&&r.push({path:i==="default"?`${o}/${A}${v}`:`${o}/${i}/${A}${v}`,css:N,collection:i})}}else{const m=[];u!=="default"&&m.push(u),f!=="default"&&m.push(f);const I=m.join("-")||"tokens",A=(await oe(h,t,{theme:u!=="default"?u:void 0,mode:f!=="default"?f:void 0,collection:i==="default"?void 0:i})).output[0].css;A.trim()&&r.push({path:i==="default"?`${o}/${I}${v}`:`${o}/${i}/${I}${v}`,css:A,collection:i})}}}return r}s(At,"generateSeparateFiles");async function Tt(e,t){const n={};for(const[o,r]of Object.entries(e)){n[o]={default:{default:{}}};for(const[a,c]of Object.entries(r)){n[o][a]||(n[o][a]={default:{}});for(const[u,l]of Object.entries(c||{}))l&&(n[o][a][u]=l)}Object.values(n[o]).some(a=>Object.values(a).some(c=>Object.keys(c).length>0))||delete n[o]}return t.output?.separate?{output:await At(n,t)}:{output:await gt(n,t)}}s(Tt,"generate");async function bt(e,t){const{output:n}=await Tt(e,t);return n}s(bt,"generateCSSVariables");const d={LOAD:{NO_FILES_FOUND:s(e=>`No files found matching pattern: ${e}.`,"NO_FILES_FOUND"),INVALID_JSON:s((e,t)=>`Invalid JSON in file ${e}: ${t}`,"INVALID_JSON"),GLOB_ERROR:s((e,t)=>`Error resolving glob pattern ${e}: ${t}`,"GLOB_ERROR")},FLATTEN:{INVALID_TOKEN_NAME:s(e=>`Invalid token name "${e}": Token names cannot contain dots (.), curly braces ({,}), or other special characters`,"INVALID_TOKEN_NAME"),MISSING_DOLLAR_PREFIX:s(e=>`Token at ${e} is using 'value' or 'type' without the required '$' prefix. Use '$value' and '$type' instead.`,"MISSING_DOLLAR_PREFIX"),INVALID_TOKEN_NESTING:s(e=>`Token at "${e}" cannot contain child tokens or groups. Only metadata properties (starting with $) are allowed.`,"INVALID_TOKEN_NESTING"),COMPOSITE_TOKEN_MISSING_TYPE:s(e=>`Composite token at '${e}' is missing the required "$type" property. Composite tokens (tokens with object values) must specify their type to define their structure.`,"COMPOSITE_TOKEN_MISSING_TYPE"),CONFLICT_TOKEN_VS_GROUP:s(e=>`Conflict at "${e}": token vs group. A token cannot be replaced by a group (or vice versa).`,"CONFLICT_TOKEN_VS_GROUP"),CONFLICT_INCOMPATIBLE_TYPES:s((e,t,n)=>`Type conflict at "${n}": expected ${e}, got ${t}`,"CONFLICT_INCOMPATIBLE_TYPES")},METADATA:{COLLECTION_ERROR:s(e=>`Error collecting metadata: ${e}`,"COLLECTION_ERROR"),INVALID_EXTENSIONS:s(e=>`Invalid extensions at ${e}: expected object, got ${typeof e}`,"INVALID_EXTENSIONS"),INVALID_DESCRIPTION:s(e=>`Invalid description at ${e}: expected string, got ${typeof e}`,"INVALID_DESCRIPTION")},VALIDATE:{MISSING_TYPE:s(e=>`Token at '${e}' is missing the "$type" property`,"MISSING_TYPE"),UNKNOWN_TOKEN_TYPE:s((e,t)=>`Unknown token type '${e}' at ${t}. Valid types are: color, dimension, fontFamily, fontWeight, duration, cubicBezier, strokeStyle, border, transition, shadow, gradient, typography`,"UNKNOWN_TOKEN_TYPE"),INVALID_COLOR:s((e,t)=>`Invalid color at ${t}: '${e}'. Color should be a valid hex value or W3C color object`,"INVALID_COLOR"),INVALID_DIMENSION:s((e,t)=>`Invalid dimension at '${t}': ${e}. Dimensions should have a numeric value and unit, like { "value": 16, "unit": "px" }`,"INVALID_DIMENSION"),INVALID_DIMENSION_UNIT:s((e,t)=>`Invalid unit at ${t}': '${e}'. Unit must be either "px" or "rem"`,"INVALID_DIMENSION_UNIT"),INVALID_FONT_FAMILY:s((e,t)=>`Invalid font family at '${t}': ${e}. Should be a string or array of strings, like "Arial" or ["Arial", "sans-serif"]`,"INVALID_FONT_FAMILY"),INVALID_FONT_WEIGHT:s((e,t)=>`Invalid font weight at '${t}': ${e}. Should be a number between 1-1000 or a keyword like "thin", "light", "normal", "bold"`,"INVALID_FONT_WEIGHT"),INVALID_DURATION:s((e,t)=>`Invalid duration at '${t}': ${e}. Should be like { "value": 300, "unit": "ms" }`,"INVALID_DURATION"),INVALID_DURATION_UNIT:s((e,t)=>`Invalid unit at ${t}: "${e}". Unit must be "ms" or "s"`,"INVALID_DURATION_UNIT"),INVALID_CUBIC_BEZIER:s((e,t)=>`Invalid cubic bezier at ${t}: "${e}". Should be an array of 4 numbers between 0 and 1`,"INVALID_CUBIC_BEZIER"),INVALID_STROKE_STYLE:s((e,t)=>`Invalid stroke style at ${t}: "${e}". Should be "solid", "dashed", "dotted", etc.`,"INVALID_STROKE_STYLE"),INVALID_STROKE_LINE_CAP:s((e,t)=>`Invalid line cap at ${t}: "${e}". Should be one of: round, butt, square`,"INVALID_STROKE_LINE_CAP"),INVALID_BORDER:s((e,t)=>`Invalid border at ${t}: "${e}". Should have color, width, and style properties`,"INVALID_BORDER"),INVALID_SHADOW:s((e,t)=>`Invalid shadow at ${t}: "${e}". Should have color, offsetX, offsetY properties (blur and spread are optional)`,"INVALID_SHADOW"),INVALID_SHADOW_INSET:s((e,t)=>`Invalid inset value at ${t}: "${e}". Should be true or false`,"INVALID_SHADOW_INSET"),INVALID_TRANSITION:s((e,t)=>`Invalid transition at ${t}: "${e}". Should have duration, delay, and timingFunction properties`,"INVALID_TRANSITION"),INVALID_GRADIENT:s((e,t)=>`Invalid gradient at ${t}: "${e}". Should be an array of color stops with position values between 0 and 1`,"INVALID_GRADIENT"),INVALID_GRADIENT_STOP_POSITION:s((e,t)=>`Invalid gradient stop position at ${t}: "${e}". Position must be between 0 and 1`,"INVALID_GRADIENT_STOP_POSITION"),INVALID_TYPOGRAPHY:s((e,t)=>`Invalid typography at ${t}: "${e}". Should have fontFamily and fontSize (fontWeight, letterSpacing, and lineHeight are optional)`,"INVALID_TYPOGRAPHY"),MISSING_REQUIRED_PROPERTY:s((e,t)=>`Missing required property '${e}' at ${t}`,"MISSING_REQUIRED_PROPERTY"),INVALID_NUMBER:s((e,t)=>`Invalid number at ${t}: "${e}". Expected a number value`,"INVALID_NUMBER"),INVALID_ARRAY:s((e,t)=>`Invalid array at ${t}: "${e}". Expected an array value`,"INVALID_ARRAY"),MISSING_FLUID_CONFIG:s(e=>`Missing fluid configuration. Token at ${e} requires fluid viewport settings.`,"MISSING_FLUID_CONFIG"),INVALID_FLUID_DIMENSION:s((e,t)=>`Invalid fluid dimension at ${t}: "${e}". Fluid dimensions should have min and max values, like { "min": { "value": 16, "unit": "px" }, "max": { "value": 24, "unit": "px" } }`,"INVALID_FLUID_DIMENSION"),INVALID_VIEWPORT_CONFIG:s((e,t)=>`Invalid viewport configuration at ${t}: "${e}". Viewport config should have min and max dimension values`,"INVALID_VIEWPORT_CONFIG"),MISMATCHED_UNITS:s((e,t,n)=>`Mismatched units at ${n}: min uses '${e}', max uses '${t}'. Both values must use the same unit`,"MISMATCHED_UNITS"),INVALID_FLUID_VALUE_RANGE:s(e=>`Invalid fluid value range at ${e}: min value must be less than max value`,"INVALID_FLUID_VALUE_RANGE"),INVALID_TOKEN_TYPE:s((e,t,n)=>`Invalid token type at ${n}: expected ${e}, got ${t}`,"INVALID_TOKEN_TYPE"),INVALID_TYPE:s((e,t,n)=>`Expected ${e}, received ${typeof t} at ${n}`,"INVALID_TYPE"),INVALID_ENUM_VALUE:s((e,t,n)=>`Expected value to be one of [${e.join(", ")}], but got ${String(t)} at ${n}`,"INVALID_ENUM_VALUE")},RESOLVE:{CIRCULAR_REFERENCE:s((e,t)=>`Circular reference detected: ${e} -> ${t}`,"CIRCULAR_REFERENCE"),REFERENCE_NOT_FOUND:s((e,t)=>`Reference not found: ${e} in ${t}. Does ${e} exist?`,"REFERENCE_NOT_FOUND"),TYPE_MISMATCH:s(e=>`Type mismatch in ${e}`,"TYPE_MISMATCH")},GENERATE:{INVALID_CSS_VALUE:s((e,t)=>`Invalid CSS value for property '${e}': ${t}`,"INVALID_CSS_VALUE"),INVALID_VARIABLE_NAME:s((e,t)=>`Invalid CSS variable name at '${e}': ${t}`,"INVALID_VARIABLE_NAME")},CONFIG:{INVALID_JSON:s(e=>`Invalid JSON in config file: ${e}`,"INVALID_JSON"),INVALID_CONFIG:s((e,t)=>`Invalid configuration at ${e}: ${t}`,"INVALID_CONFIG"),DUPLICATE_FILENAMES:s((e,t,n)=>`Duplicate filename "${t}" found in collection "${e}":
14
14
  ${n.map(o=>` - ${o}`).join(`
15
- `)}`,"DUPLICATE_FILENAMES"),FILE_NOT_FOUND:s(e=>e===F?`Cannot find sugarcube config file. Please ensure you have a valid ${F} file in your project root.`:`Cannot find sugarcube config file at "${e}". Please check the path and file permissions.`,"FILE_NOT_FOUND")},UTILITIES:{RESERVED_PREFIX:s((e,t)=>`Cannot use reserved prefix "${e}" for ${t} token type. This prefix is reserved for default utility classes. Please use a custom prefix instead.`,"RESERVED_PREFIX"),DUPLICATE_CLASS_NAME:s((e,t)=>`Ambiguous utility class "${e}" would be generated from multiple token paths: ${t.join(", ")}. This would make it impossible to know which token value should be used when this class is applied in HTML. To fix this, configure one or more paths with custom prefixes to make the intent clear.`,"DUPLICATE_CLASS_NAME"),INVALID_PROPERTY_MAPPING:s(e=>`Invalid property mapping for ${e} token type. When mapping multiple properties, each mapping must include a unique prefix to avoid class name collisions.`,"INVALID_PROPERTY_MAPPING"),DUPLICATE_PREFIX:s((e,t)=>`Duplicate prefix "${e}" found in property mappings for ${t} token type. Each property mapping must have a unique prefix to avoid class name collisions.`,"DUPLICATE_PREFIX"),INVALID_COLLECTION:s((e,t,n)=>`Utility config for '${e}' specifies collection '${t}', but this collection does not exist. Available collections: ${n.join(", ")||"none"}`,"INVALID_COLLECTION"),TOKEN_PATH_CONFLICT:s((e,t)=>`Token path conflict: "${e}" exists in multiple collections (${t}). To resolve this conflict, either:
15
+ `)}`,"DUPLICATE_FILENAMES"),FILE_NOT_FOUND:s(e=>e===C?`Cannot find sugarcube config file. Please ensure you have a valid ${C} file in your project root.`:`Cannot find sugarcube config file at "${e}". Please check the path and file permissions.`,"FILE_NOT_FOUND")},UTILITIES:{RESERVED_PREFIX:s((e,t)=>`Cannot use reserved prefix "${e}" for ${t} token type. This prefix is reserved for default utility classes. Please use a custom prefix instead.`,"RESERVED_PREFIX"),DUPLICATE_CLASS_NAME:s((e,t)=>`Ambiguous utility class "${e}" would be generated from multiple token paths: ${t.join(", ")}. This would make it impossible to know which token value should be used when this class is applied in HTML. To fix this, configure one or more paths with custom prefixes to make the intent clear.`,"DUPLICATE_CLASS_NAME"),INVALID_PROPERTY_MAPPING:s(e=>`Invalid property mapping for ${e} token type. When mapping multiple properties, each mapping must include a unique prefix to avoid class name collisions.`,"INVALID_PROPERTY_MAPPING"),DUPLICATE_PREFIX:s((e,t)=>`Duplicate prefix "${e}" found in property mappings for ${t} token type. Each property mapping must have a unique prefix to avoid class name collisions.`,"DUPLICATE_PREFIX"),INVALID_COLLECTION:s((e,t,n)=>`Utility config for '${e}' specifies collection '${t}', but this collection does not exist. Available collections: ${n.join(", ")||"none"}`,"INVALID_COLLECTION"),TOKEN_PATH_CONFLICT:s((e,t)=>`Token path conflict: "${e}" exists in multiple collections (${t}). To resolve this conflict, either:
16
16
  1. Use unique token paths per collection
17
- 2. Configure utilities to be collection-specific: { source: "color.*", collection: "base" }`,"TOKEN_PATH_CONFLICT"),MISSING_SOURCE:s(e=>`Utility config for '${e}' must have a valid 'source' property`,"MISSING_SOURCE"),INVALID_SOURCE_PATTERN:s((e,t)=>`Utility config for '${e}' has invalid source pattern '${t}'. Only patterns ending with '.*' are supported (e.g., 'color.*', 'font.weight.*').`,"INVALID_SOURCE_PATTERN"),INVALID_DIRECTIONS:s(e=>`Utility config for '${e}' must have 'directions' as an array`,"INVALID_DIRECTIONS"),INVALID_CONFIG_OBJECT:"utilitiesConfig must be an object",INVALID_TOKENS_OBJECT:"tokens must be an object"}};function ee(e){return typeof e=="object"&&e!==null&&"$value"in e}s(ee,"isTokenNode");function gt(e,t,n){for(const[o,r]of Object.entries(t.tokens)){const i=e.tokens[o];if(!ee(r)){if(i&&ee(i)){const d=i;n.push({path:d.$path,source:d.$source,message:f.FLATTEN.CONFLICT_TOKEN_VS_GROUP(d.$path)});continue}e.tokens[o]=r;continue}if(!i){e.tokens[o]=r;continue}if(!ee(i)){n.push({path:r.$path,source:r.$source,message:f.FLATTEN.CONFLICT_TOKEN_VS_GROUP(r.$path)});continue}const c=r,l=i,u=!!c.$type,p=!!l.$type;if(u&&p&&c.$type!==l.$type){n.push({path:c.$path,source:c.$source,message:f.FLATTEN.CONFLICT_INCOMPATIBLE_TYPES(String(l.$type??"unknown"),String(c.$type??"unknown"),c.$path)});continue}e.tokens[o]=r}for(const[o,r]of t.pathIndex)e.pathIndex.set(o,r)}s(gt,"mergeFlattenedInto");function Tt(e){if(typeof e!="object"||e===null||"$value"in e)return!1;const t="value"in e,n="type"in e;if(t&&n)return!0;if(t){const o=e.value;return typeof o=="string"||typeof o=="number"||Array.isArray(o)}return!1}s(Tt,"looksLikeUnprefixedToken");function Et(e,t){const n={tokens:{},pathIndex:new Map},o=[];function r(a=[]){const c=[t.collection];return t.theme&&c.push(t.theme),a.length>0&&c.push(a.join(".")),c.join(".")}s(r,"createLookupKey"),(e.$description||e.$extensions)&&(n.tokens[r()]={$description:e.$description,$extensions:e.$extensions});function i(a,c=[],l){if(c.join("."),c.length>0){const d=r(c);n.tokens[d]={$description:a.$description,$extensions:a.$extensions,$path:c.join("."),$source:{collection:t.collection,theme:t.theme,sourcePath:t.sourcePath}}}const u=Object.keys(a).filter(d=>!d.startsWith("$")),p=a.$type||l;for(const d of u){const h=a[d],y=[...c,d],$=y.join(".");if(Tt(h)){o.push({path:$,source:t,message:f.FLATTEN.MISSING_DOLLAR_PREFIX($)});continue}if(d.includes(".")||d.includes("{")||d.includes("}")){o.push({path:$,source:t,message:f.FLATTEN.INVALID_TOKEN_NAME(d)});continue}if("$value"in h){if(Object.keys(h).filter(Qe=>!Qe.startsWith("$")).length>0){o.push({path:$,source:t,message:f.FLATTEN.INVALID_TOKEN_NESTING($)});continue}if(it(h)&&!h.$type&&!p){o.push({path:$,source:t,message:f.FLATTEN.COMPOSITE_TOKEN_MISSING_TYPE($)});continue}const v=r(y),H=y.join(".");n.tokens[v]={...h,...h.$type||p?{$type:h.$type||p}:{},$path:H,$source:{collection:t.collection,theme:t.theme,sourcePath:t.sourcePath},$originalPath:H},n.pathIndex.set(H,v)}else i(h,y,p)}}return s(i,"processNode"),i(e),{tokens:n,errors:o}}s(Et,"flattenTree");function At(e){const t={tokens:{},pathIndex:new Map},n=[];for(const o of e){const{tokens:r,errors:i}=Et(o.tokens,{collection:o.collection,theme:o.theme,sourcePath:o.sourcePath});n.push(...i),gt(t,r,n)}return{tokens:t,errors:n}}s(At,"flatten");async function Te(e){const t={files:[],errors:[]};for(const n of e)try{const o=!n.includes("*")&&!n.endsWith(".json")?N(n,"**/*.json"):n,r=await z(o,{absolute:!0,onlyFiles:!0});if(r.length===0){t.errors.push({pattern:n,error:f.LOAD.NO_FILES_FOUND(n)});continue}t.files.push(...r)}catch(o){t.errors.push({pattern:n,error:f.LOAD.GLOB_ERROR(n,o instanceof Error?o.message:"Unknown error")})}return t}s(Te,"resolveFiles");async function Ee(e){try{const t=await K(e,"utf-8");return JSON.parse(t)}catch(t){throw t instanceof Error&&t instanceof SyntaxError?new Error(f.LOAD.INVALID_JSON(e,t.message)):t}}s(Ee,"loadTree");function bt(e){const t=new Set;if(e.themes)for(const n of Object.values(e.themes))for(const o of n)t.add(o);return t}s(bt,"collectThemePaths");async function Nt(e){const t=[],n=[];if(!e.tokens)return{trees:[],errors:[]};const o=Array.isArray(e.tokens)?{default:{source:e.tokens}}:"source"in e.tokens?{default:e.tokens}:e.tokens;if(!Object.values(o).some(i=>i.source.some(a=>{try{return z.sync(a).length>0}catch{return!1}})))return{trees:[],errors:[{file:F,message:f.LOAD.NO_FILES_FOUND(Object.values(o).flatMap(i=>i.source).join(", "))}]};for(const[i,a]of Object.entries(o)){const c=bt(a),{files:l,errors:u}=await Te(Array.isArray(a.source)?a.source:[a.source]);if(u.length>0){t.push(...u.map(p=>({file:p.pattern,message:p.error})));continue}for(const p of l){const d=_(process.cwd(),p);if(!c.has(d))try{const h=await Ee(p),y={collection:i,tokens:h,sourcePath:d};n.push(y)}catch(h){t.push({file:p,message:h instanceof Error?h.message:"Unknown error"})}}if(a.themes)for(const[p,d]of Object.entries(a.themes))try{const{files:h,errors:y}=await Te(d);if(y.length>0){t.push(...y.map($=>({file:$.pattern,message:$.error})));continue}for(const $ of h)try{const A=await Ee($),v={collection:i,theme:p,tokens:A,sourcePath:_(process.cwd(),$)};n.push(v)}catch(A){t.push({file:$,message:A instanceof Error?A.message:"Unknown error"})}}catch(h){t.push({file:d.join(", "),message:h instanceof Error?h.message:"Unknown error"})}}return{trees:n,errors:t}}s(Nt,"loadTreesFromConfig");async function St(e){const t=[],n=[],o=new Map;for(const[r,{collection:i,theme:a,content:c}]of Object.entries(e)){o.has(i)||o.set(i,new Map);const l=o.get(i);l.has(a)||l.set(a,[]),l.get(a)?.push({content:c,path:r})}for(const[r,i]of o)for(const[a,c]of i)for(const{content:l,path:u}of c)try{const p=JSON.parse(l);t.push({collection:r,theme:a,tokens:p,sourcePath:_(process.cwd(),u)})}catch(p){p instanceof Error?p instanceof SyntaxError?n.push({file:u,message:f.LOAD.INVALID_JSON(u,p.message)}):n.push({file:u,message:p.message}):n.push({file:u,message:"Unknown error"})}return{trees:t,errors:n}}s(St,"loadTreesFromMemory");function x(e,t,n,o){return typeof t=="string"&&I(t)?Ot(e,t,n,o):Array.isArray(t)?t.map(r=>x(e,r,n,o)):typeof t=="object"&&t!==null?Object.entries(t).reduce((i,[a,c])=>Object.assign(i,{[a]:x(`${e}.${a}`,c,n,o)}),{}):t}s(x,"resolveValue");function Ae(e,t){const n=e.slice(1,-1),o=t.pathIndex.get(n);if(!o)return;const r=t.tokens[o];if(!(!r||!("$value"in r))){if(r.$type)return r.$type;if(typeof r.$value=="string"&&I(r.$value))return Ae(r.$value,t)}}s(Ae,"inferTypeFromReference");function Lt(e){const t={},n=new Set,o=[];for(const[r,i]of Object.entries(e.tokens))try{if(!("$value"in i)){t[r]=i;continue}const a=i;let c=a.$type;!c&&typeof a.$value=="string"&&I(a.$value)&&(c=Ae(a.$value,e)),t[r]={...a,...c?{$type:c}:{},$resolvedValue:x(a.$path,a.$value,e,n)}}catch(a){const c=a instanceof Error?a.message:String(a),l=i,u=l.$path,p=l.$source;let d,h;c.includes("Circular reference detected")?(d="circular",h=c):c.includes("Reference not found")?(d="missing",h=c):(d="type-mismatch",h=f.RESOLVE.TYPE_MISMATCH(u)),o.push({type:d,path:u,source:p,message:h})}return{resolved:t,errors:o}}s(Lt,"resolve");function Ot(e,t,n,o){const r=t.slice(1,-1),i=n.pathIndex.get(r);if(!i)throw new Error(f.RESOLVE.REFERENCE_NOT_FOUND(r,e));if(o.has(i)){const l=n.tokens[i];throw!l||!("$path"in l)?new Error(f.RESOLVE.REFERENCE_NOT_FOUND(r,e)):new Error(f.RESOLVE.CIRCULAR_REFERENCE(e,l.$path))}const a=n.tokens[i];if(!a||!("$value"in a))throw new Error(f.RESOLVE.REFERENCE_NOT_FOUND(r,e));o.add(i);const c=x(i,a.$value,n,o);return o.delete(i),c}s(Ot,"resolveReferenceChain");function b(e){return{success:!0,value:e}}s(b,"success");function T(e){return{success:!1,error:e}}s(T,"error");function te(e){if(typeof e!="object"||e===null)return!1;const t=e;return!(typeof t.colorSpace!="string"||!["oklch","display-p3","srgb","hsl"].includes(t.colorSpace)||!Array.isArray(t.components)||t.components.length!==3||!t.components.every(o=>typeof o=="number"||o==="none")||t.alpha!==void 0&&typeof t.alpha!="number"||t.hex!==void 0&&typeof t.hex!="string")}s(te,"isW3CColorValue");function R(e){const t=[],n=["oklch","display-p3","srgb","hsl"];if(n.includes(e.colorSpace)||t.push(`Unsupported colorSpace: "${e.colorSpace}". Supported color spaces: ${n.join(", ")}.`),!Array.isArray(e.components)||e.components.length!==3)t.push("Components must be an array of exactly 3 numbers.");else if(e.components.forEach((o,r)=>{o!=="none"&&(typeof o!="number"||!Number.isFinite(o))&&t.push(`Component ${r} must be a finite number or "none".`)}),e.colorSpace==="oklch"){const[o,r,i]=e.components;o!=="none"&&(o<0||o>1)&&t.push("OKLCH Lightness (L) must be between 0 and 1 or 'none'."),r!=="none"&&r<0&&t.push("OKLCH Chroma (C) must be >= 0 or 'none'."),i!=="none"&&(i<0||i>=360)&&t.push("OKLCH Hue (H) must be between 0 and 360 (exclusive) or 'none'.")}else if(e.colorSpace==="display-p3"){const[o,r,i]=e.components;o!=="none"&&(o<0||o>1)&&t.push("Display P3 Red component must be between 0 and 1 or 'none'."),r!=="none"&&(r<0||r>1)&&t.push("Display P3 Green component must be between 0 and 1 or 'none'."),i!=="none"&&(i<0||i>1)&&t.push("Display P3 Blue component must be between 0 and 1 or 'none'.")}else if(e.colorSpace==="srgb"){const[o,r,i]=e.components;o!=="none"&&(o<0||o>1)&&t.push("sRGB Red component must be between 0 and 1 or 'none'."),r!=="none"&&(r<0||r>1)&&t.push("sRGB Green component must be between 0 and 1 or 'none'."),i!=="none"&&(i<0||i>1)&&t.push("sRGB Blue component must be between 0 and 1 or 'none'.")}else if(e.colorSpace==="hsl"){const[o,r,i]=e.components;o!=="none"&&(o<0||o>=360)&&t.push("HSL Hue must be between 0 and 360 (exclusive) or 'none'."),r!=="none"&&(r<0||r>100)&&t.push("HSL Saturation must be between 0 and 100 or 'none'."),i!=="none"&&(i<0||i>100)&&t.push("HSL Lightness must be between 0 and 100 or 'none'.")}return e.alpha!==void 0&&(typeof e.alpha!="number"||!Number.isFinite(e.alpha)?t.push("Alpha must be a finite number."):(e.alpha<0||e.alpha>1)&&t.push("Alpha must be between 0 and 1.")),t}s(R,"validateW3CColorValue");function _t(e){const t=R(e);return t.length>0?T(t.join(", ")):b(e)}s(_t,"validateW3CColorValueResult");function Dt(e){const t=_t(e);if(!t.success)return t;const[n,o,r]=e.components,i=e.alpha,a=n==="none"?"none":Number(n.toFixed(4)),c=o==="none"?"none":Number(o.toFixed(4)),l=r==="none"?"none":Number(r.toFixed(4));if(i!==void 0&&i!==1){const u=Number(i.toFixed(4));return b(`oklch(${a} ${c} ${l} / ${u})`)}return b(`oklch(${a} ${c} ${l})`)}s(Dt,"formatW3CColorToOKLCH");const Ft={isObject:s(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObject")};function g(e,t,n,o){if(I(t))return[];switch(e.type){case"object":return vt(e,t,n,o);case"union":return Ct(e,t,n,o);case"array":return wt(e,t,n,o);default:return kt(e,t,n,o)}}s(g,"validateSchema");function kt(e,t,n,o){return e.type!==typeof t?[{path:n,message:e.errorMessage?.(t,n)||f.VALIDATE.INVALID_TYPE(e.type,t,n),source:o}]:e.validate?.(t,n,o)??[]}s(kt,"validateSimpleValue");function vt(e,t,n,o){if(!Ft.isObject(t))return[{path:n,message:e.errorMessage?.(t,n)||f.VALIDATE.INVALID_TYPE("object",t,n),source:o}];const r=[],i=t;if(e.required)for(const a of e.required)a in i||r.push({path:`${n}.${a}`,message:f.VALIDATE.MISSING_REQUIRED_PROPERTY(a,n),source:o});for(const[a,c]of Object.entries(e.properties))a in i&&r.push(...g(c,i[a],`${n}.${a}`,o));return r}s(vt,"validateObject");function Ct(e,t,n,o){let r=[],i=Number.POSITIVE_INFINITY;for(const a of e.oneOf){if(a.type==="string"&&typeof t!="string"||a.type==="object"&&typeof t!="object")continue;const c=g(a,t,n,o);if(c.length===0)return a.validate?.(t,n,o)??[];c.length<i&&(r=c,i=c.length)}return i===Number.POSITIVE_INFINITY?[{path:n,message:f.VALIDATE.INVALID_TYPE(e.oneOf.map(a=>a.type).join(" or "),t,n),source:o}]:r}s(Ct,"validateUnion");function wt(e,t,n,o){return Array.isArray(t)?e.validate?.(t,n,o)??[]:[{path:n,message:e.errorMessage?.(t,n)||f.VALIDATE.INVALID_TYPE("array",t,n),source:o}]}s(wt,"validateArray");const j={schema:{type:"union",oneOf:[{type:"string",validate:s((e,t,n)=>/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/.test(e)?[]:[{path:t,message:f.VALIDATE.INVALID_COLOR(e,t),source:n}],"validate")},{type:"object",required:["colorSpace","components"],properties:{colorSpace:{type:"string"},components:{type:"array"},alpha:{type:"number"},hex:{type:"string"}},validate:s((e,t,n)=>te(e)?R(e).map(r=>({path:t,message:`Invalid color at ${t}: ${r}`,source:n})):[{path:t,message:f.VALIDATE.INVALID_COLOR(e,t),source:n}],"validate")}]}};function Vt(e,t,n){return g(j.schema,e,t,n)}s(Vt,"validateColor");const P={schema:{type:"number",errorMessage:s((e,t)=>f.VALIDATE.INVALID_NUMBER(e,t),"errorMessage"),validate:s((e,t,n)=>typeof e!="number"||Number.isNaN(e)?[{path:t,message:f.VALIDATE.INVALID_NUMBER(e,t),source:n}]:[],"validate")}};function xt(e,t,n){return g(P.schema,e,t,n)}s(xt,"validateNumber");const E={schema:{type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_DIMENSION(e,t),"errorMessage"),properties:{value:P.schema,unit:{type:"string",validate:s((e,t,n)=>typeof e!="string"||!["px","rem"].includes(e)?[{path:t,message:f.VALIDATE.INVALID_DIMENSION_UNIT(e,t),source:n}]:[],"validate")}},required:["value","unit"]}};function Rt(e,t,n){return g(E.schema,e,t,n)}s(Rt,"validateDimension");const be={schema:{type:"union",oneOf:[{type:"string",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")},{type:"array",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage"),validate:s((e,t,n)=>e.every(r=>typeof r=="string")?[]:[{path:t,message:f.VALIDATE.INVALID_FONT_FAMILY(e,t),source:n}],"validate")}],errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")}};function jt(e,t,n){return g(be.schema,e,t,n)}s(jt,"validateFontFamily");const Pt=["thin","hairline","extra-light","ultra-light","light","normal","regular","book","medium","semi-bold","demi-bold","bold","extra-bold","ultra-bold","black","heavy","extra-black","ultra-black"],Ne={schema:{type:"union",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),oneOf:[{type:"number",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>e<1||e>1e3?[{path:t,message:f.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}]:[],"validate")},{type:"string",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>Pt.includes(e.toLowerCase())?[]:[{path:t,message:f.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}],"validate")}]}};function Mt(e,t,n){return g(Ne.schema,e,t,n)}s(Mt,"validateFontWeight");const Ut=["ms","s"],ne={schema:{type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_DURATION(e,t),"errorMessage"),properties:{value:P.schema,unit:{type:"string",validate:s((e,t,n)=>Ut.includes(e)?[]:[{path:t,message:f.VALIDATE.INVALID_DURATION_UNIT(e,t),source:n}],"validate")}},required:["value","unit"]}};function Gt(e,t,n){return g(ne.schema,e,t,n)}s(Gt,"validateDuration");const Se={schema:{type:"array",errorMessage:s((e,t)=>f.VALIDATE.INVALID_CUBIC_BEZIER(e,t),"errorMessage"),validate:s((e,t,n)=>{const o=e;if(o.length!==4||!o.every(a=>typeof a=="number"))return[{path:t,message:f.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}];const[r,,i]=o;return r<0||r>1||i<0||i>1?[{path:t,message:f.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}]:[]},"validate")}};function Wt(e,t,n){return g(Se.schema,e,t,n)}s(Wt,"validateCubicBezier");const Bt={schema:{type:"object",properties:{fontFamily:be.schema,fontSize:E.schema,letterSpacing:E.schema,lineHeight:P.schema,fontWeight:Ne.schema},required:["fontFamily","fontSize"],errorMessage:s((e,t)=>f.VALIDATE.INVALID_TYPOGRAPHY(e,t),"errorMessage")}};function Yt(e,t,n){return g(Bt.schema,e,t,n)}s(Yt,"validateTypography");const Ht=["solid","dashed","dotted","double","groove","ridge","outset","inset"],Kt=["round","butt","square"],zt={type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_STROKE_STYLE(e,t),"errorMessage"),properties:{dashArray:{type:"array",validate:s((e,t,n)=>{const o=e,r=[];return o.forEach((i,a)=>{typeof i!="string"&&r.push(...g(E.schema,i,`${t}.${a}`,n))}),r},"validate")},lineCap:{type:"string",validate:s((e,t,n)=>Kt.includes(e)?[]:[{path:t,message:f.VALIDATE.INVALID_STROKE_LINE_CAP(e,t),source:n}],"validate")}},required:["dashArray","lineCap"]},Le={schema:{type:"union",oneOf:[{type:"string",validate:s((e,t,n)=>!Ht.includes(e)&&typeof e=="string"?[{path:t,message:f.VALIDATE.INVALID_STROKE_STYLE(e,t),source:n}]:[],"validate")},zt]}};function qt(e,t,n){return g(Le.schema,e,t,n)}s(qt,"validateStrokeStyle");const Jt={schema:{type:"object",properties:{color:j.schema,width:E.schema,style:Le.schema},required:["color","width","style"],errorMessage:s((e,t)=>f.VALIDATE.INVALID_BORDER(e,t),"errorMessage")}};function Xt(e,t,n){return g(Jt.schema,e,t,n)}s(Xt,"validateBorder");const Zt={schema:{type:"object",properties:{duration:ne.schema,delay:ne.schema,timingFunction:Se.schema},required:["duration","delay","timingFunction"],errorMessage:s((e,t)=>f.VALIDATE.INVALID_TRANSITION(e,t),"errorMessage")}};function Qt(e,t,n){return g(Zt.schema,e,t,n)}s(Qt,"validateTransition");const Oe={schema:{type:"object",properties:{color:{type:"union",oneOf:[j.schema]},offsetX:E.schema,offsetY:E.schema,blur:E.schema,spread:E.schema,inset:{type:"boolean",errorMessage:s((e,t)=>f.VALIDATE.INVALID_SHADOW_INSET(e,t),"errorMessage")}},required:["color","offsetX","offsetY","blur","spread"],errorMessage:s((e,t)=>f.VALIDATE.INVALID_SHADOW(e,t),"errorMessage")}};function en(e,t,n){const o=[];return Array.isArray(e)?(e.forEach((r,i)=>{o.push(...g(Oe.schema,r,`${t}[${i}]`,n))}),o):g(Oe.schema,e,t,n)}s(en,"validateShadow");const tn={type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_GRADIENT(e,t),"errorMessage"),properties:{color:j.schema,position:{type:"number",validate:s((e,t,n)=>e<0||e>1?[{path:t,message:f.VALIDATE.INVALID_GRADIENT_STOP_POSITION(e,t),source:n}]:[],"validate")}},required:["color","position"]},nn={schema:{type:"array",errorMessage:s((e,t)=>f.VALIDATE.INVALID_ARRAY(e,t),"errorMessage"),validate:s((e,t,n)=>{const o=e,r=[];return o.forEach((i,a)=>{r.push(...g(tn,i,`${t}[${a}]`,n))}),r},"validate")}};function on(e,t,n){return g(nn.schema,e,t,n)}s(on,"validateGradient");const rn={schema:{type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FLUID_DIMENSION(e,t),"errorMessage"),properties:{min:E.schema,max:E.schema},required:["min","max"]}};function sn(e,t,n){return g(rn.schema,e,t,n)}s(sn,"validateFluidDimension");const an={color:Vt,dimension:Rt,fluidDimension:sn,duration:Gt,cubicBezier:Wt,fontFamily:jt,fontWeight:Mt,number:xt,strokeStyle:qt,typography:Yt,border:Xt,shadow:en,gradient:on,transition:Qt};function cn(e){const t=[];for(const[n,o]of Object.entries(e.tokens)){if(typeof o!="object"||o===null||!("$type"in o)||!("$path"in o)||o.$path.startsWith("$"))continue;if(!("$value"in o)){t.push({path:o.$path,message:f.VALIDATE.MISSING_REQUIRED_PROPERTY("$value",o.$path),source:o.$source});continue}const r=an[o.$type];if(!r){t.push({path:o.$path,message:f.VALIDATE.UNKNOWN_TOKEN_TYPE(o.$type,o.$path),source:o.$source});continue}const i=o;t.push(...r(i.$value,i.$path,i.$source))}return t}s(cn,"validate");async function ln(e){const{trees:t,errors:n}=await(e.type==="memory"?St(e.data):Nt(e.config)),{tokens:o,errors:r}=At(t),i=cn(o),{resolved:a,errors:c}=Lt(o);return{trees:t,resolved:a,errors:{load:n,flatten:r,validation:i,resolution:c}}}s(ln,"loadAndResolveTokens");function _e(e){return I(e)?{value:e}:typeof e=="string"?{value:e}:{value:`${e.dashArray.map(n=>I(n)?n:`${n.value}${n.unit}`).join(" ")} ${e.lineCap}`}}s(_e,"convertStrokeStyleToken");function un(e){if(I(e))return{value:e};const t=I(e.width)?e.width:`${e.width.value}${e.width.unit}`,n=(I(e.color),e.color),o=typeof e.style=="string"?e.style:_e(e.style).value;return{value:`${t} ${o} ${n}`}}s(un,"convertBorderToken");function De(e,t="native"){return te(e)?fn(e):b(e)}s(De,"convertColorToString");function fn(e){switch(e.colorSpace){case"oklch":return Dt(e);case"display-p3":return pn(e);case"srgb":return dn(e);case"hsl":return hn(e);default:return T(`Unsupported color space: ${e.colorSpace}. Supported color spaces: oklch, display-p3, srgb, hsl.`)}}s(fn,"formatW3CColorNative");function pn(e){if(e.colorSpace!=="display-p3")return T(`Expected display-p3 color space, got: ${e.colorSpace}`);if(!Array.isArray(e.components)||e.components.length!==3)return T("Display P3 components must be an array of exactly 3 numbers [R, G, B]");const[t,n,o]=e.components,r=e.alpha;if(t!=="none"&&(t<0||t>1))return T("Display P3 Red component must be between 0 and 1 or 'none'");if(n!=="none"&&(n<0||n>1))return T("Display P3 Green component must be between 0 and 1 or 'none'");if(o!=="none"&&(o<0||o>1))return T("Display P3 Blue component must be between 0 and 1 or 'none'");if(r!==void 0&&(r<0||r>1))return T("Alpha must be between 0 and 1");const i=t==="none"?"none":Number(t.toFixed(4)),a=n==="none"?"none":Number(n.toFixed(4)),c=o==="none"?"none":Number(o.toFixed(4));if(r!==void 0&&r!==1){const l=Number(r.toFixed(4));return b(`color(display-p3 ${i} ${a} ${c} / ${l})`)}return b(`color(display-p3 ${i} ${a} ${c})`)}s(pn,"formatW3CColorToP3");function dn(e){if(e.colorSpace!=="srgb")return T(`Expected srgb color space, got: ${e.colorSpace}`);const t=R(e);if(t.length>0)return T(`Invalid W3C color value: ${t.join(", ")}`);const[n,o,r]=e.components,i=e.alpha,a=n==="none"?"none":Math.round(n*255),c=o==="none"?"none":Math.round(o*255),l=r==="none"?"none":Math.round(r*255);if(i!==void 0&&i!==1){const u=Number(i.toFixed(4));return b(`rgb(${a} ${c} ${l} / ${u})`)}return b(`rgb(${a} ${c} ${l})`)}s(dn,"formatW3CColorToRGB");function hn(e){if(e.colorSpace!=="hsl")return T(`Expected hsl color space, got: ${e.colorSpace}`);const t=R(e);if(t.length>0)return T(`Invalid W3C color value: ${t.join(", ")}`);const[n,o,r]=e.components,i=e.alpha,a=n==="none"?"none":Number(n.toFixed(1)),c=o==="none"?"none":Math.round(o),l=r==="none"?"none":Math.round(r);if(i!==void 0&&i!==1){const d=Number(i.toFixed(4)),h=c==="none"?"none":`${c}%`,y=l==="none"?"none":`${l}%`;return b(`hsl(${a} ${h} ${y} / ${d})`)}const u=c==="none"?"none":`${c}%`,p=l==="none"?"none":`${l}%`;return b(`hsl(${a} ${u} ${p})`)}s(hn,"formatW3CColorToHSL");function mn(e,t){if(typeof e=="string"&&I(e))return{value:e};const n=t.colorFallbackStrategy;if(te(e))return In(e,n);const o=De(e,n);return o.success?{value:o.value}:(console.warn(`Failed to convert color ${typeof e=="string"?e:"W3C color object"}: ${o.error}`),{value:typeof e=="string"?e:"#000000"})}s(mn,"convertColorToken");function In(e,t){const n=De(e,t);if(!n.success)return console.warn(`Failed to convert W3C color: ${n.error}`),{value:"#000000"};const o=n.value;if(t==="native")return{value:o};if(e.colorSpace==="srgb"||e.colorSpace==="hsl")return{value:o};if(!e.hex)throw new Error(`${e.colorSpace} colors require a 'hex' fallback when using 'polyfill' strategy. Tip: Switch to 'native' strategy if targeting modern browsers only.`);return{value:e.hex,featureValues:[{query:yn(e.colorSpace),value:o}]}}s(In,"convertW3CColorToken");function yn(e){switch(e){case"oklch":return"@supports (color: oklch(0 0 0))";case"display-p3":return"@supports (color: color(display-p3 1 1 1))";default:throw new Error(`No feature query defined for color space: ${e}`)}}s(yn,"getFeatureQuery");function $n(e){return I(e)?{value:e}:{value:`cubic-bezier(${e.join(", ")})`}}s($n,"convertCubicBezierToken");function gn(e){return I(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(gn,"convertDimensionToken");function Tn(e){return I(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(Tn,"convertDurationToken");function Fe(e,t=16){return e.unit==="px"?e.value:e.value*t}s(Fe,"normalizeToPixels");function En(e,t){const{min:n,max:o}=e,r=t.fluidConfig,i=16,a=Fe(n,i),c=Fe(o,i),l=r.min,u=r.max;if(a===c)return{value:`${a/i}rem`};const p=a/i,d=c/i,h=l/i,y=u/i,$=(d-p)/(y-h),A=-1*h*$+p;return{value:`clamp(${p}rem, ${A.toFixed(2)}rem + ${($*100).toFixed(2)}vw, ${d}rem)`}}s(En,"convertFluidDimension");function An(e,t){return I(e)?{value:e}:En(e,t)}s(An,"convertFluidDimensionToken");function M(e){return["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"].includes(e.toLowerCase())?e:/[\s'"!@#$%^&*()=+[\]{};:|\\/,.<>?~]/.test(e)?`"${e}"`:e}s(M,"quoteFont");function bn(e){return I(e)?{value:e}:{value:Array.isArray(e)?e.map(n=>M(n)).join(", "):M(e)}}s(bn,"convertFontFamilyToken");const Nn={thin:100,hairline:100,"extra-light":200,"ultra-light":200,light:300,normal:400,regular:400,book:400,medium:500,"semi-bold":600,"demi-bold":600,bold:700,"extra-bold":800,"ultra-bold":800,black:900,heavy:900,"extra-black":950,"ultra-black":950};function ke(e){return I(e)?{value:e}:typeof e=="number"?{value:e}:{value:Nn[e.toLowerCase()]??e}}s(ke,"convertFontWeightToken");function Sn(e){return I(e)?{value:e}:{value:`linear-gradient(${e.map(n=>{const o=(I(n.color),n.color),r=I(n.position)?n.position:`${n.position*100}`;return`${o} ${r}%`}).join(", ")})`}}s(Sn,"convertGradientToken");function Ln(e){return I(e)?{value:e}:{value:e}}s(Ln,"convertNumberToken");function ve(e){const t=I(e.offsetX)?e.offsetX:`${e.offsetX.value}${e.offsetX.unit}`,n=I(e.offsetY)?e.offsetY:`${e.offsetY.value}${e.offsetY.unit}`,o=I(e.blur)?e.blur:`${e.blur.value}${e.blur.unit}`,r=I(e.spread)?e.spread:`${e.spread.value}${e.spread.unit}`,i=(I(e.color),e.color);return`${e.inset?"inset ":""}${t} ${n} ${o} ${r} ${i}`}s(ve,"convertSingleShadow");function On(e){return I(e)?{value:e}:Array.isArray(e)?{value:e.map(ve).join(", ")}:{value:ve(e)}}s(On,"convertShadowToken");function Ce(e){return e?`${e.value}${e.unit}`:"0ms"}s(Ce,"formatDuration");function _n(e){if(I(e))return{value:e};const t=I(e.duration)?e.duration:Ce(e.duration),n=I(e.timingFunction)?e.timingFunction:`cubic-bezier(${e.timingFunction.join(", ")})`,o=e.delay&&(I(e.delay)?e.delay:Ce(e.delay));return{value:[t,n,o].filter(Boolean).join(" ")}}s(_n,"convertTransitionToken");function Dn(e){if(I(e))return{"font-family":e,"font-size":e};const t={"font-family":I(e.fontFamily)?e.fontFamily:Array.isArray(e.fontFamily)?e.fontFamily.map(n=>M(n)).join(", "):M(e.fontFamily),"font-size":I(e.fontSize)?e.fontSize:`${e.fontSize.value}${e.fontSize.unit}`};return e.fontWeight&&(t["font-weight"]=I(e.fontWeight)?e.fontWeight:ke(e.fontWeight).value),e.letterSpacing&&(t["letter-spacing"]=I(e.letterSpacing)?e.letterSpacing:`${e.letterSpacing.value}${e.letterSpacing.unit}`),e.lineHeight&&(t["line-height"]=(I(e.lineHeight),e.lineHeight)),t}s(Dn,"convertTypographyToken");const we={duration:Tn,number:Ln,cubicBezier:$n,color:mn,dimension:gn,fluidDimension:An,typography:Dn,border:un,shadow:On,gradient:Sn,transition:_n,strokeStyle:_e,fontFamily:bn,fontWeight:ke};function Fn(e,t){const n=we[e.$type];return{...e.$description?{$description:e.$description}:{},...e.$extensions?{$extensions:e.$extensions}:{},$type:e.$type,$value:e.$value,$path:e.$path,$source:e.$source,$originalPath:e.$originalPath,$resolvedValue:e.$resolvedValue,$cssProperties:n(e.$value,t)}}s(Fn,"convertSingleToken");function Ve(e,t,n){const o={};for(const[r,i]of Object.entries(e)){if(!i||typeof i!="object")continue;if(!("$type"in i)){o[r]={...i.$description?{$description:i.$description}:{},...i.$extensions?{$extensions:i.$extensions}:{}};continue}if(n?.(i.$path)){console.log(`[sugarcube] Skipping invalid token: ${i.$path} (has validation error)`);continue}if(!we[i.$type])continue;const a={fluidConfig:t.transforms.fluid,colorFallbackStrategy:t.transforms.colorFallbackStrategy,path:i.$path,resolvedTokens:e};o[r]=Fn(i,a)}return o}s(Ve,"convertTokens");function kn(e,t,n){const o={};for(const[r,i]of Object.entries(e)){const a={default:Ve(i.default,t,n)};for(const[c,l]of Object.entries(i))c!=="default"&&(a[c]=Ve(l,t,n));o[r]=a}return o}s(kn,"convert");function vn(e){const t=new Set,n=new Map;for(const i of e){const{collection:a,theme:c="default"}=i;t.add(a),n.has(a)||n.set(a,new Set),n.get(a)?.add(c)}const o={};function r(i){const a={default:{}};o[i]=a;const c=n.get(i);if(c)for(const l of c)a[l]={};return a}s(r,"addCollection");for(const i of t)r(i);for(const i of e){const{collection:a,theme:c="default",tokens:l}=i,u=o[a]||r(a);let p=u[c];p||(p=u[c]={});for(const[d,h]of Object.entries(l)){const y=d.replace(`${a}.`,"");p[y]=h}}return{tokens:o}}s(vn,"normalizeTokens");function Cn(e,t){const n=new Map;for(const[o,r]of Object.entries(t)){if(!("$source"in r)){for(const l of e){const u=l.collection;n.has(u)||n.set(u,new Map);const p=n.get(u),d=l.theme;p.has(d)||p.set(d,{}),p.get(d)[o]=r}continue}const i=r.$source.collection,a=r.$source.theme;n.has(i)||n.set(i,new Map);const c=n.get(i);c.has(void 0)||c.set(void 0,{}),a||(c.get(void 0)[o]=r),a&&(c.has(a)||c.set(a,{}),c.get(a)[o]=r)}return e.map(o=>{const r=n.get(o.collection);if(!r)return{collection:o.collection,theme:o.theme,tokens:{}};if(o.theme){const a=r.get(o.theme)||{};return{collection:o.collection,theme:o.theme,tokens:a}}const i=r.get(void 0)||{};return{collection:o.collection,theme:o.theme,tokens:i}})}s(Cn,"processTrees");async function wn(e,t,n,o){const r=Cn(e,t),{tokens:i}=vn(r);return kn(i,n,o?l=>o.some(u=>u.path===l||u.path.startsWith(`${l}.`)):void 0)}s(wn,"processAndConvertTokens");const U=["reset","global","compositions","blocks","utilities"];async function oe(e,t){const n=[],o=await z([N(e,"**/*.css"),N(e,"**/*.scss"),N(e,"**/*.sass"),N(e,"**/*.less")],{ignore:[N(e,w)]});for(const r of o){const i=Vn(r,e);if(i){const a=_(e,r);n.push({path:a,layer:i,relativePath:a})}}return n}s(oe,"discoverAllFiles");function Vn(e,t){const n=_(t,e);if(n.includes("global/")||n.startsWith("global/"))return de(e).includes("reset")?"reset":"global";if(n.includes("compositions/")||n.startsWith("compositions/"))return"compositions";if(n.includes("blocks/")||n.startsWith("blocks/"))return"blocks";if(n.includes("utilities/")||n.startsWith("utilities/"))return"utilities"}s(Vn,"categorizeFile");function xn(e){return e.sort((t,n)=>{const o=U.indexOf(t.layer),r=U.indexOf(n.layer);return o!==r?o-r:t.path.localeCompare(n.path)})}s(xn,"sortFilesByLayer");function Rn(){return`@layer ${U.join(", ")};
18
- `}s(Rn,"getLayerDefinitions");function xe(e){const t=[];t.push(Rn());const n=e.reduce((o,r)=>{const i=o[r.layer]??[];return o[r.layer]=[...i,r],o},{});for(const o of U){const r=n[o];if(!(!r||r.length===0))for(const i of r)t.push(`@import "${i.path}" layer(${i.layer});`)}return t.join(`
19
- `)}s(xe,"generateIndexContent");async function jn(e,t){const n=N(e,w),o=await oe(e),r=xn(o),i=xe(r);return await C.writeFile(n,i),_(process.cwd(),n)}s(jn,"generateIndex");async function Pn(e,t){const n=N(e,w);if(!D(n))return!0;try{const o=await C.stat(n),r=await oe(e,t);for(const i of r){const a=N(e,i.path);if(D(a)&&(await C.stat(a)).mtime>o.mtime)return!0}return!1}catch{return!0}}s(Pn,"shouldRegenerateIndex");const Mn=`/*!
17
+ 2. Configure utilities to be collection-specific: { source: "color.*", collection: "base" }`,"TOKEN_PATH_CONFLICT"),MISSING_SOURCE:s(e=>`Utility config for '${e}' must have a valid 'source' property`,"MISSING_SOURCE"),INVALID_SOURCE_PATTERN:s((e,t)=>`Utility config for '${e}' has invalid source pattern '${t}'. Only patterns ending with '.*' are supported (e.g., 'color.*', 'font.weight.*').`,"INVALID_SOURCE_PATTERN"),INVALID_DIRECTIONS:s(e=>`Utility config for '${e}' must have 'directions' as an array`,"INVALID_DIRECTIONS"),INVALID_CONFIG_OBJECT:"utilitiesConfig must be an object",INVALID_TOKENS_OBJECT:"tokens must be an object"}};function re(e){return typeof e=="object"&&e!==null&&"$value"in e}s(re,"isTokenNode");function Et(e,t,n){for(const[o,r]of Object.entries(t.tokens)){const i=e.tokens[o];if(!re(r)){if(i&&re(i)){const f=i;n.push({path:f.$path,source:f.$source,message:d.FLATTEN.CONFLICT_TOKEN_VS_GROUP(f.$path)});continue}e.tokens[o]=r;continue}if(!i){e.tokens[o]=r;continue}if(!re(i)){n.push({path:r.$path,source:r.$source,message:d.FLATTEN.CONFLICT_TOKEN_VS_GROUP(r.$path)});continue}const c=r,u=i,l=!!c.$type,p=!!u.$type;if(l&&p&&c.$type!==u.$type){n.push({path:c.$path,source:c.$source,message:d.FLATTEN.CONFLICT_INCOMPATIBLE_TYPES(String(u.$type??"unknown"),String(c.$type??"unknown"),c.$path)});continue}e.tokens[o]=r}for(const[o,r]of t.pathIndex)e.pathIndex.set(o,r)}s(Et,"mergeFlattenedInto");function Nt(e){if(typeof e!="object"||e===null||"$value"in e)return!1;const t="value"in e,n="type"in e;if(t&&n)return!0;if(t){const o=e.value;return typeof o=="string"||typeof o=="number"||Array.isArray(o)}return!1}s(Nt,"looksLikeUnprefixedToken");function St(e,t){const n={tokens:{},pathIndex:new Map},o=[];function r(a=[]){const c=[t.collection];return t.theme&&c.push(t.theme),t.mode&&c.push(t.mode),a.length>0&&c.push(a.join(".")),c.join(".")}s(r,"createLookupKey"),(e.$description||e.$extensions)&&(n.tokens[r()]={$description:e.$description,$extensions:e.$extensions});function i(a,c=[],u){if(c.join("."),c.length>0){const f=r(c);n.tokens[f]={$description:a.$description,$extensions:a.$extensions,$path:c.join("."),$source:{collection:t.collection,theme:t.theme,mode:t.mode,sourcePath:t.sourcePath}}}const l=Object.keys(a).filter(f=>!f.startsWith("$")),p=a.$type||u;for(const f of l){const h=a[f],m=[...c,f],I=m.join(".");if(Nt(h)){o.push({path:I,source:t,message:d.FLATTEN.MISSING_DOLLAR_PREFIX(I)});continue}if(f.includes(".")||f.includes("{")||f.includes("}")){o.push({path:I,source:t,message:d.FLATTEN.INVALID_TOKEN_NAME(f)});continue}if("$value"in h){if(Object.keys(h).filter(N=>!N.startsWith("$")).length>0){o.push({path:I,source:t,message:d.FLATTEN.INVALID_TOKEN_NESTING(I)});continue}if(ut(h)&&!h.$type&&!p){o.push({path:I,source:t,message:d.FLATTEN.COMPOSITE_TOKEN_MISSING_TYPE(I)});continue}const A=r(m),T=m.join(".");n.tokens[A]={...h,...h.$type||p?{$type:h.$type||p}:{},$path:T,$source:{collection:t.collection,theme:t.theme,mode:t.mode,sourcePath:t.sourcePath},$originalPath:T},n.pathIndex.set(T,A)}else i(h,m,p)}}return s(i,"processNode"),i(e),{tokens:n,errors:o}}s(St,"flattenTree");function Ot(e){const t={tokens:{},pathIndex:new Map},n=[];for(const o of e){const{tokens:r,errors:i}=St(o.tokens,{collection:o.collection,theme:o.theme,mode:o.mode,sourcePath:o.sourcePath});n.push(...i),Et(t,r,n)}return{tokens:t,errors:n}}s(Ot,"flatten");async function P(e){const t={files:[],errors:[]};for(const n of e)try{const o=!n.includes("*")&&!n.endsWith(".json")?L(n,"**/*.json"):n,r=await Z(o,{absolute:!0,onlyFiles:!0});if(r.length===0){t.errors.push({pattern:n,error:d.LOAD.NO_FILES_FOUND(n)});continue}t.files.push(...r)}catch(o){t.errors.push({pattern:n,error:d.LOAD.GLOB_ERROR(n,o instanceof Error?o.message:"Unknown error")})}return t}s(P,"resolveFiles");async function M(e){try{const t=await X(e,"utf-8");return JSON.parse(t)}catch(t){throw t instanceof Error&&t instanceof SyntaxError?new Error(d.LOAD.INVALID_JSON(e,t.message)):t}}s(M,"loadTree");function Lt(e){const t=new Set;if(e.modes)for(const n of Object.values(e.modes))for(const o of n)t.add(o);if(e.themes)for(const n of Object.values(e.themes))if(Array.isArray(n))for(const o of n)t.add(o);else{for(const o of n.source)t.add(o);if(n.modes)for(const o of Object.values(n.modes))for(const r of o)t.add(r)}return t}s(Lt,"collectVariantPaths");async function _t(e){const t=[],n=[];if(!e.tokens)return{trees:[],errors:[]};const o=Array.isArray(e.tokens)?{default:{source:e.tokens}}:"source"in e.tokens?{default:e.tokens}:e.tokens;if(!Object.values(o).some(i=>i.source.some(a=>{try{return Z.sync(a).length>0}catch{return!1}})))return{trees:[],errors:[{file:C,message:d.LOAD.NO_FILES_FOUND(Object.values(o).flatMap(i=>i.source).join(", "))}]};for(const[i,a]of Object.entries(o)){const c=Lt(a),{files:u,errors:l}=await P(Array.isArray(a.source)?a.source:[a.source]);if(l.length>0){t.push(...l.map(p=>({file:p.pattern,message:p.error})));continue}for(const p of u){const f=D(process.cwd(),p);if(!c.has(f))try{const h=await M(p),m={collection:i,tokens:h,sourcePath:f};n.push(m)}catch(h){t.push({file:p,message:h instanceof Error?h.message:"Unknown error"})}}if(a.modes)for(const[p,f]of Object.entries(a.modes))try{const{files:h,errors:m}=await P(f);if(m.length>0){t.push(...m.map(I=>({file:I.pattern,message:I.error})));continue}for(const I of h)try{const g=await M(I),A={collection:i,mode:p,tokens:g,sourcePath:D(process.cwd(),I)};n.push(A)}catch(g){t.push({file:I,message:g instanceof Error?g.message:"Unknown error"})}}catch(h){t.push({file:f.join(", "),message:h instanceof Error?h.message:"Unknown error"})}if(a.themes)for(const[p,f]of Object.entries(a.themes)){const h=Array.isArray(f)?f:f.source;try{const{files:m,errors:I}=await P(h);if(I.length>0){t.push(...I.map(g=>({file:g.pattern,message:g.error})));continue}for(const g of m)try{const A=await M(g),T={collection:i,theme:p,tokens:A,sourcePath:D(process.cwd(),g)};n.push(T)}catch(A){t.push({file:g,message:A instanceof Error?A.message:"Unknown error"})}}catch(m){t.push({file:h.join(", "),message:m instanceof Error?m.message:"Unknown error"})}if(!Array.isArray(f)&&f.modes)for(const[m,I]of Object.entries(f.modes))try{const{files:g,errors:A}=await P(I);if(A.length>0){t.push(...A.map(T=>({file:T.pattern,message:T.error})));continue}for(const T of g)try{const N=await M(T),nt={collection:i,theme:p,mode:m,tokens:N,sourcePath:D(process.cwd(),T)};n.push(nt)}catch(N){t.push({file:T,message:N instanceof Error?N.message:"Unknown error"})}}catch(g){t.push({file:I.join(", "),message:g instanceof Error?g.message:"Unknown error"})}}}return{trees:n,errors:t}}s(_t,"loadTreesFromConfig");async function Dt(e){const t=[],n=[],o=Object.entries(e);o.sort(([,r],[,i])=>{const a=!r.theme&&!r.mode,c=!i.theme&&!i.mode;return a&&!c?-1:!a&&c?1:0});for(const[r,{collection:i,theme:a,mode:c,content:u}]of o)try{const l=JSON.parse(u);t.push({collection:i,theme:a,mode:c,tokens:l,sourcePath:D(process.cwd(),r)})}catch(l){l instanceof Error?l instanceof SyntaxError?n.push({file:r,message:d.LOAD.INVALID_JSON(r,l.message)}):n.push({file:r,message:l.message}):n.push({file:r,message:"Unknown error"})}return{trees:t,errors:n}}s(Dt,"loadTreesFromMemory");function U(e,t,n,o){return typeof t=="string"&&$(t)?kt(e,t,n,o):Array.isArray(t)?t.map(r=>U(e,r,n,o)):typeof t=="object"&&t!==null?Object.entries(t).reduce((i,[a,c])=>Object.assign(i,{[a]:U(`${e}.${a}`,c,n,o)}),{}):t}s(U,"resolveValue");function Le(e,t){const n=e.slice(1,-1),o=t.pathIndex.get(n);if(!o)return;const r=t.tokens[o];if(!(!r||!("$value"in r))){if(r.$type)return r.$type;if(typeof r.$value=="string"&&$(r.$value))return Le(r.$value,t)}}s(Le,"inferTypeFromReference");function vt(e){const t={},n=new Set,o=[];for(const[r,i]of Object.entries(e.tokens))try{if(!("$value"in i)){t[r]=i;continue}const a=i;let c=a.$type;!c&&typeof a.$value=="string"&&$(a.$value)&&(c=Le(a.$value,e)),t[r]={...a,...c?{$type:c}:{},$resolvedValue:U(a.$path,a.$value,e,n)}}catch(a){const c=a instanceof Error?a.message:String(a),u=i,l=u.$path,p=u.$source;let f,h;c.includes("Circular reference detected")?(f="circular",h=c):c.includes("Reference not found")?(f="missing",h=c):(f="type-mismatch",h=d.RESOLVE.TYPE_MISMATCH(l)),o.push({type:f,path:l,source:p,message:h})}return{resolved:t,errors:o}}s(vt,"resolve");function kt(e,t,n,o){const r=t.slice(1,-1),i=n.pathIndex.get(r);if(!i)throw new Error(d.RESOLVE.REFERENCE_NOT_FOUND(r,e));if(o.has(i)){const u=n.tokens[i];throw!u||!("$path"in u)?new Error(d.RESOLVE.REFERENCE_NOT_FOUND(r,e)):new Error(d.RESOLVE.CIRCULAR_REFERENCE(e,u.$path))}const a=n.tokens[i];if(!a||!("$value"in a))throw new Error(d.RESOLVE.REFERENCE_NOT_FOUND(r,e));o.add(i);const c=U(i,a.$value,n,o);return o.delete(i),c}s(kt,"resolveReferenceChain");function O(e){return{success:!0,value:e}}s(O,"success");function E(e){return{success:!1,error:e}}s(E,"error");function se(e){if(typeof e!="object"||e===null)return!1;const t=e;return!(typeof t.colorSpace!="string"||!["oklch","display-p3","srgb","hsl"].includes(t.colorSpace)||!Array.isArray(t.components)||t.components.length!==3||!t.components.every(o=>typeof o=="number"||o==="none")||t.alpha!==void 0&&typeof t.alpha!="number"||t.hex!==void 0&&typeof t.hex!="string")}s(se,"isW3CColorValue");function G(e){const t=[],n=["oklch","display-p3","srgb","hsl"];if(n.includes(e.colorSpace)||t.push(`Unsupported colorSpace: "${e.colorSpace}". Supported color spaces: ${n.join(", ")}.`),!Array.isArray(e.components)||e.components.length!==3)t.push("Components must be an array of exactly 3 numbers.");else if(e.components.forEach((o,r)=>{o!=="none"&&(typeof o!="number"||!Number.isFinite(o))&&t.push(`Component ${r} must be a finite number or "none".`)}),e.colorSpace==="oklch"){const[o,r,i]=e.components;o!=="none"&&(o<0||o>1)&&t.push("OKLCH Lightness (L) must be between 0 and 1 or 'none'."),r!=="none"&&r<0&&t.push("OKLCH Chroma (C) must be >= 0 or 'none'."),i!=="none"&&(i<0||i>=360)&&t.push("OKLCH Hue (H) must be between 0 and 360 (exclusive) or 'none'.")}else if(e.colorSpace==="display-p3"){const[o,r,i]=e.components;o!=="none"&&(o<0||o>1)&&t.push("Display P3 Red component must be between 0 and 1 or 'none'."),r!=="none"&&(r<0||r>1)&&t.push("Display P3 Green component must be between 0 and 1 or 'none'."),i!=="none"&&(i<0||i>1)&&t.push("Display P3 Blue component must be between 0 and 1 or 'none'.")}else if(e.colorSpace==="srgb"){const[o,r,i]=e.components;o!=="none"&&(o<0||o>1)&&t.push("sRGB Red component must be between 0 and 1 or 'none'."),r!=="none"&&(r<0||r>1)&&t.push("sRGB Green component must be between 0 and 1 or 'none'."),i!=="none"&&(i<0||i>1)&&t.push("sRGB Blue component must be between 0 and 1 or 'none'.")}else if(e.colorSpace==="hsl"){const[o,r,i]=e.components;o!=="none"&&(o<0||o>=360)&&t.push("HSL Hue must be between 0 and 360 (exclusive) or 'none'."),r!=="none"&&(r<0||r>100)&&t.push("HSL Saturation must be between 0 and 100 or 'none'."),i!=="none"&&(i<0||i>100)&&t.push("HSL Lightness must be between 0 and 100 or 'none'.")}return e.alpha!==void 0&&(typeof e.alpha!="number"||!Number.isFinite(e.alpha)?t.push("Alpha must be a finite number."):(e.alpha<0||e.alpha>1)&&t.push("Alpha must be between 0 and 1.")),t}s(G,"validateW3CColorValue");function Ft(e){const t=G(e);return t.length>0?E(t.join(", ")):O(e)}s(Ft,"validateW3CColorValueResult");function Ct(e){const t=Ft(e);if(!t.success)return t;const[n,o,r]=e.components,i=e.alpha,a=n==="none"?"none":Number(n.toFixed(4)),c=o==="none"?"none":Number(o.toFixed(4)),u=r==="none"?"none":Number(r.toFixed(4));if(i!==void 0&&i!==1){const l=Number(i.toFixed(4));return O(`oklch(${a} ${c} ${u} / ${l})`)}return O(`oklch(${a} ${c} ${u})`)}s(Ct,"formatW3CColorToOKLCH");const wt={isObject:s(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObject")};function b(e,t,n,o){if($(t))return[];switch(e.type){case"object":return xt(e,t,n,o);case"union":return Rt(e,t,n,o);case"array":return jt(e,t,n,o);default:return Vt(e,t,n,o)}}s(b,"validateSchema");function Vt(e,t,n,o){return e.type!==typeof t?[{path:n,message:e.errorMessage?.(t,n)||d.VALIDATE.INVALID_TYPE(e.type,t,n),source:o}]:e.validate?.(t,n,o)??[]}s(Vt,"validateSimpleValue");function xt(e,t,n,o){if(!wt.isObject(t))return[{path:n,message:e.errorMessage?.(t,n)||d.VALIDATE.INVALID_TYPE("object",t,n),source:o}];const r=[],i=t;if(e.required)for(const a of e.required)a in i||r.push({path:`${n}.${a}`,message:d.VALIDATE.MISSING_REQUIRED_PROPERTY(a,n),source:o});for(const[a,c]of Object.entries(e.properties))a in i&&r.push(...b(c,i[a],`${n}.${a}`,o));return r}s(xt,"validateObject");function Rt(e,t,n,o){let r=[],i=Number.POSITIVE_INFINITY;for(const a of e.oneOf){if(a.type==="string"&&typeof t!="string"||a.type==="object"&&typeof t!="object")continue;const c=b(a,t,n,o);if(c.length===0)return a.validate?.(t,n,o)??[];c.length<i&&(r=c,i=c.length)}return i===Number.POSITIVE_INFINITY?[{path:n,message:d.VALIDATE.INVALID_TYPE(e.oneOf.map(a=>a.type).join(" or "),t,n),source:o}]:r}s(Rt,"validateUnion");function jt(e,t,n,o){return Array.isArray(t)?e.validate?.(t,n,o)??[]:[{path:n,message:e.errorMessage?.(t,n)||d.VALIDATE.INVALID_TYPE("array",t,n),source:o}]}s(jt,"validateArray");const B={schema:{type:"union",oneOf:[{type:"string",validate:s((e,t,n)=>/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/.test(e)?[]:[{path:t,message:d.VALIDATE.INVALID_COLOR(e,t),source:n}],"validate")},{type:"object",required:["colorSpace","components"],properties:{colorSpace:{type:"string"},components:{type:"array"},alpha:{type:"number"},hex:{type:"string"}},validate:s((e,t,n)=>se(e)?G(e).map(r=>({path:t,message:`Invalid color at ${t}: ${r}`,source:n})):[{path:t,message:d.VALIDATE.INVALID_COLOR(e,t),source:n}],"validate")}]}};function Pt(e,t,n){return b(B.schema,e,t,n)}s(Pt,"validateColor");const W={schema:{type:"number",errorMessage:s((e,t)=>d.VALIDATE.INVALID_NUMBER(e,t),"errorMessage"),validate:s((e,t,n)=>typeof e!="number"||Number.isNaN(e)?[{path:t,message:d.VALIDATE.INVALID_NUMBER(e,t),source:n}]:[],"validate")}};function Mt(e,t,n){return b(W.schema,e,t,n)}s(Mt,"validateNumber");const S={schema:{type:"object",errorMessage:s((e,t)=>d.VALIDATE.INVALID_DIMENSION(e,t),"errorMessage"),properties:{value:W.schema,unit:{type:"string",validate:s((e,t,n)=>typeof e!="string"||!["px","rem"].includes(e)?[{path:t,message:d.VALIDATE.INVALID_DIMENSION_UNIT(e,t),source:n}]:[],"validate")}},required:["value","unit"]}};function Ut(e,t,n){return b(S.schema,e,t,n)}s(Ut,"validateDimension");const _e={schema:{type:"union",oneOf:[{type:"string",errorMessage:s((e,t)=>d.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")},{type:"array",errorMessage:s((e,t)=>d.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage"),validate:s((e,t,n)=>e.every(r=>typeof r=="string")?[]:[{path:t,message:d.VALIDATE.INVALID_FONT_FAMILY(e,t),source:n}],"validate")}],errorMessage:s((e,t)=>d.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")}};function Gt(e,t,n){return b(_e.schema,e,t,n)}s(Gt,"validateFontFamily");const Bt=["thin","hairline","extra-light","ultra-light","light","normal","regular","book","medium","semi-bold","demi-bold","bold","extra-bold","ultra-bold","black","heavy","extra-black","ultra-black"],De={schema:{type:"union",errorMessage:s((e,t)=>d.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),oneOf:[{type:"number",errorMessage:s((e,t)=>d.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>e<1||e>1e3?[{path:t,message:d.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}]:[],"validate")},{type:"string",errorMessage:s((e,t)=>d.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>Bt.includes(e.toLowerCase())?[]:[{path:t,message:d.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}],"validate")}]}};function Wt(e,t,n){return b(De.schema,e,t,n)}s(Wt,"validateFontWeight");const Yt=["ms","s"],ie={schema:{type:"object",errorMessage:s((e,t)=>d.VALIDATE.INVALID_DURATION(e,t),"errorMessage"),properties:{value:W.schema,unit:{type:"string",validate:s((e,t,n)=>Yt.includes(e)?[]:[{path:t,message:d.VALIDATE.INVALID_DURATION_UNIT(e,t),source:n}],"validate")}},required:["value","unit"]}};function Kt(e,t,n){return b(ie.schema,e,t,n)}s(Kt,"validateDuration");const ve={schema:{type:"array",errorMessage:s((e,t)=>d.VALIDATE.INVALID_CUBIC_BEZIER(e,t),"errorMessage"),validate:s((e,t,n)=>{const o=e;if(o.length!==4||!o.every(a=>typeof a=="number"))return[{path:t,message:d.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}];const[r,,i]=o;return r<0||r>1||i<0||i>1?[{path:t,message:d.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}]:[]},"validate")}};function Ht(e,t,n){return b(ve.schema,e,t,n)}s(Ht,"validateCubicBezier");const zt={schema:{type:"object",properties:{fontFamily:_e.schema,fontSize:S.schema,letterSpacing:S.schema,lineHeight:W.schema,fontWeight:De.schema},required:["fontFamily","fontSize"],errorMessage:s((e,t)=>d.VALIDATE.INVALID_TYPOGRAPHY(e,t),"errorMessage")}};function qt(e,t,n){return b(zt.schema,e,t,n)}s(qt,"validateTypography");const Jt=["solid","dashed","dotted","double","groove","ridge","outset","inset"],Xt=["round","butt","square"],Zt={type:"object",errorMessage:s((e,t)=>d.VALIDATE.INVALID_STROKE_STYLE(e,t),"errorMessage"),properties:{dashArray:{type:"array",validate:s((e,t,n)=>{const o=e,r=[];return o.forEach((i,a)=>{typeof i!="string"&&r.push(...b(S.schema,i,`${t}.${a}`,n))}),r},"validate")},lineCap:{type:"string",validate:s((e,t,n)=>Xt.includes(e)?[]:[{path:t,message:d.VALIDATE.INVALID_STROKE_LINE_CAP(e,t),source:n}],"validate")}},required:["dashArray","lineCap"]},ke={schema:{type:"union",oneOf:[{type:"string",validate:s((e,t,n)=>!Jt.includes(e)&&typeof e=="string"?[{path:t,message:d.VALIDATE.INVALID_STROKE_STYLE(e,t),source:n}]:[],"validate")},Zt]}};function Qt(e,t,n){return b(ke.schema,e,t,n)}s(Qt,"validateStrokeStyle");const en={schema:{type:"object",properties:{color:B.schema,width:S.schema,style:ke.schema},required:["color","width","style"],errorMessage:s((e,t)=>d.VALIDATE.INVALID_BORDER(e,t),"errorMessage")}};function tn(e,t,n){return b(en.schema,e,t,n)}s(tn,"validateBorder");const nn={schema:{type:"object",properties:{duration:ie.schema,delay:ie.schema,timingFunction:ve.schema},required:["duration","delay","timingFunction"],errorMessage:s((e,t)=>d.VALIDATE.INVALID_TRANSITION(e,t),"errorMessage")}};function on(e,t,n){return b(nn.schema,e,t,n)}s(on,"validateTransition");const Fe={schema:{type:"object",properties:{color:{type:"union",oneOf:[B.schema]},offsetX:S.schema,offsetY:S.schema,blur:S.schema,spread:S.schema,inset:{type:"boolean",errorMessage:s((e,t)=>d.VALIDATE.INVALID_SHADOW_INSET(e,t),"errorMessage")}},required:["color","offsetX","offsetY","blur","spread"],errorMessage:s((e,t)=>d.VALIDATE.INVALID_SHADOW(e,t),"errorMessage")}};function rn(e,t,n){const o=[];return Array.isArray(e)?(e.forEach((r,i)=>{o.push(...b(Fe.schema,r,`${t}[${i}]`,n))}),o):b(Fe.schema,e,t,n)}s(rn,"validateShadow");const sn={type:"object",errorMessage:s((e,t)=>d.VALIDATE.INVALID_GRADIENT(e,t),"errorMessage"),properties:{color:B.schema,position:{type:"number",validate:s((e,t,n)=>e<0||e>1?[{path:t,message:d.VALIDATE.INVALID_GRADIENT_STOP_POSITION(e,t),source:n}]:[],"validate")}},required:["color","position"]},an={schema:{type:"array",errorMessage:s((e,t)=>d.VALIDATE.INVALID_ARRAY(e,t),"errorMessage"),validate:s((e,t,n)=>{const o=e,r=[];return o.forEach((i,a)=>{r.push(...b(sn,i,`${t}[${a}]`,n))}),r},"validate")}};function cn(e,t,n){return b(an.schema,e,t,n)}s(cn,"validateGradient");const un={schema:{type:"object",errorMessage:s((e,t)=>d.VALIDATE.INVALID_FLUID_DIMENSION(e,t),"errorMessage"),properties:{min:S.schema,max:S.schema},required:["min","max"]}};function ln(e,t,n){return b(un.schema,e,t,n)}s(ln,"validateFluidDimension");const fn={color:Pt,dimension:Ut,fluidDimension:ln,duration:Kt,cubicBezier:Ht,fontFamily:Gt,fontWeight:Wt,number:Mt,strokeStyle:Qt,typography:qt,border:tn,shadow:rn,gradient:cn,transition:on};function pn(e){const t=[];for(const[n,o]of Object.entries(e.tokens)){if(typeof o!="object"||o===null||!("$type"in o)||!("$path"in o)||o.$path.startsWith("$"))continue;if(!("$value"in o)){t.push({path:o.$path,message:d.VALIDATE.MISSING_REQUIRED_PROPERTY("$value",o.$path),source:o.$source});continue}const r=fn[o.$type];if(!r){t.push({path:o.$path,message:d.VALIDATE.UNKNOWN_TOKEN_TYPE(o.$type,o.$path),source:o.$source});continue}const i=o;t.push(...r(i.$value,i.$path,i.$source))}return t}s(pn,"validate");async function dn(e){const{trees:t,errors:n}=await(e.type==="memory"?Dt(e.data):_t(e.config)),{tokens:o,errors:r}=Ot(t),i=pn(o),{resolved:a,errors:c}=vt(o);return{trees:t,resolved:a,errors:{load:n,flatten:r,validation:i,resolution:c}}}s(dn,"loadAndResolveTokens");function Ce(e){return $(e)?{value:e}:typeof e=="string"?{value:e}:{value:`${e.dashArray.map(n=>$(n)?n:`${n.value}${n.unit}`).join(" ")} ${e.lineCap}`}}s(Ce,"convertStrokeStyleToken");function hn(e){if($(e))return{value:e};const t=$(e.width)?e.width:`${e.width.value}${e.width.unit}`,n=($(e.color),e.color),o=typeof e.style=="string"?e.style:Ce(e.style).value;return{value:`${t} ${o} ${n}`}}s(hn,"convertBorderToken");function we(e,t="native"){return se(e)?mn(e):O(e)}s(we,"convertColorToString");function mn(e){switch(e.colorSpace){case"oklch":return Ct(e);case"display-p3":return yn(e);case"srgb":return In(e);case"hsl":return $n(e);default:return E(`Unsupported color space: ${e.colorSpace}. Supported color spaces: oklch, display-p3, srgb, hsl.`)}}s(mn,"formatW3CColorNative");function yn(e){if(e.colorSpace!=="display-p3")return E(`Expected display-p3 color space, got: ${e.colorSpace}`);if(!Array.isArray(e.components)||e.components.length!==3)return E("Display P3 components must be an array of exactly 3 numbers [R, G, B]");const[t,n,o]=e.components,r=e.alpha;if(t!=="none"&&(t<0||t>1))return E("Display P3 Red component must be between 0 and 1 or 'none'");if(n!=="none"&&(n<0||n>1))return E("Display P3 Green component must be between 0 and 1 or 'none'");if(o!=="none"&&(o<0||o>1))return E("Display P3 Blue component must be between 0 and 1 or 'none'");if(r!==void 0&&(r<0||r>1))return E("Alpha must be between 0 and 1");const i=t==="none"?"none":Number(t.toFixed(4)),a=n==="none"?"none":Number(n.toFixed(4)),c=o==="none"?"none":Number(o.toFixed(4));if(r!==void 0&&r!==1){const u=Number(r.toFixed(4));return O(`color(display-p3 ${i} ${a} ${c} / ${u})`)}return O(`color(display-p3 ${i} ${a} ${c})`)}s(yn,"formatW3CColorToP3");function In(e){if(e.colorSpace!=="srgb")return E(`Expected srgb color space, got: ${e.colorSpace}`);const t=G(e);if(t.length>0)return E(`Invalid W3C color value: ${t.join(", ")}`);const[n,o,r]=e.components,i=e.alpha,a=n==="none"?"none":Math.round(n*255),c=o==="none"?"none":Math.round(o*255),u=r==="none"?"none":Math.round(r*255);if(i!==void 0&&i!==1){const l=Number(i.toFixed(4));return O(`rgb(${a} ${c} ${u} / ${l})`)}return O(`rgb(${a} ${c} ${u})`)}s(In,"formatW3CColorToRGB");function $n(e){if(e.colorSpace!=="hsl")return E(`Expected hsl color space, got: ${e.colorSpace}`);const t=G(e);if(t.length>0)return E(`Invalid W3C color value: ${t.join(", ")}`);const[n,o,r]=e.components,i=e.alpha,a=n==="none"?"none":Number(n.toFixed(1)),c=o==="none"?"none":Math.round(o),u=r==="none"?"none":Math.round(r);if(i!==void 0&&i!==1){const f=Number(i.toFixed(4)),h=c==="none"?"none":`${c}%`,m=u==="none"?"none":`${u}%`;return O(`hsl(${a} ${h} ${m} / ${f})`)}const l=c==="none"?"none":`${c}%`,p=u==="none"?"none":`${u}%`;return O(`hsl(${a} ${l} ${p})`)}s($n,"formatW3CColorToHSL");function gn(e,t){if(typeof e=="string"&&$(e))return{value:e};const n=t.colorFallbackStrategy;if(se(e))return An(e,n);const o=we(e,n);return o.success?{value:o.value}:(console.warn(`Failed to convert color ${typeof e=="string"?e:"W3C color object"}: ${o.error}`),{value:typeof e=="string"?e:"#000000"})}s(gn,"convertColorToken");function An(e,t){const n=we(e,t);if(!n.success)return console.warn(`Failed to convert W3C color: ${n.error}`),{value:"#000000"};const o=n.value;if(t==="native")return{value:o};if(e.colorSpace==="srgb"||e.colorSpace==="hsl")return{value:o};if(!e.hex)throw new Error(`${e.colorSpace} colors require a 'hex' fallback when using 'polyfill' strategy. Tip: Switch to 'native' strategy if targeting modern browsers only.`);return{value:e.hex,featureValues:[{query:Tn(e.colorSpace),value:o}]}}s(An,"convertW3CColorToken");function Tn(e){switch(e){case"oklch":return"@supports (color: oklch(0 0 0))";case"display-p3":return"@supports (color: color(display-p3 1 1 1))";default:throw new Error(`No feature query defined for color space: ${e}`)}}s(Tn,"getFeatureQuery");function bn(e){return $(e)?{value:e}:{value:`cubic-bezier(${e.join(", ")})`}}s(bn,"convertCubicBezierToken");function En(e){return $(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(En,"convertDimensionToken");function Nn(e){return $(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(Nn,"convertDurationToken");function Ve(e,t=16){return e.unit==="px"?e.value:e.value*t}s(Ve,"normalizeToPixels");function Sn(e,t){const{min:n,max:o}=e,r=t.fluidConfig,i=16,a=Ve(n,i),c=Ve(o,i),u=r.min,l=r.max;if(a===c)return{value:`${a/i}rem`};const p=a/i,f=c/i,h=u/i,m=l/i,I=(f-p)/(m-h),g=-1*h*I+p;return{value:`clamp(${p}rem, ${g.toFixed(2)}rem + ${(I*100).toFixed(2)}vw, ${f}rem)`}}s(Sn,"convertFluidDimension");function On(e,t){return $(e)?{value:e}:Sn(e,t)}s(On,"convertFluidDimensionToken");function Y(e){return["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"].includes(e.toLowerCase())?e:/[\s'"!@#$%^&*()=+[\]{};:|\\/,.<>?~]/.test(e)?`"${e}"`:e}s(Y,"quoteFont");function Ln(e){return $(e)?{value:e}:{value:Array.isArray(e)?e.map(n=>Y(n)).join(", "):Y(e)}}s(Ln,"convertFontFamilyToken");const _n={thin:100,hairline:100,"extra-light":200,"ultra-light":200,light:300,normal:400,regular:400,book:400,medium:500,"semi-bold":600,"demi-bold":600,bold:700,"extra-bold":800,"ultra-bold":800,black:900,heavy:900,"extra-black":950,"ultra-black":950};function xe(e){return $(e)?{value:e}:typeof e=="number"?{value:e}:{value:_n[e.toLowerCase()]??e}}s(xe,"convertFontWeightToken");function Dn(e){return $(e)?{value:e}:{value:`linear-gradient(${e.map(n=>{const o=($(n.color),n.color),r=$(n.position)?n.position:`${n.position*100}`;return`${o} ${r}%`}).join(", ")})`}}s(Dn,"convertGradientToken");function vn(e){return $(e)?{value:e}:{value:e}}s(vn,"convertNumberToken");function Re(e){const t=$(e.offsetX)?e.offsetX:`${e.offsetX.value}${e.offsetX.unit}`,n=$(e.offsetY)?e.offsetY:`${e.offsetY.value}${e.offsetY.unit}`,o=$(e.blur)?e.blur:`${e.blur.value}${e.blur.unit}`,r=$(e.spread)?e.spread:`${e.spread.value}${e.spread.unit}`,i=($(e.color),e.color);return`${e.inset?"inset ":""}${t} ${n} ${o} ${r} ${i}`}s(Re,"convertSingleShadow");function kn(e){return $(e)?{value:e}:Array.isArray(e)?{value:e.map(Re).join(", ")}:{value:Re(e)}}s(kn,"convertShadowToken");function je(e){return e?`${e.value}${e.unit}`:"0ms"}s(je,"formatDuration");function Fn(e){if($(e))return{value:e};const t=$(e.duration)?e.duration:je(e.duration),n=$(e.timingFunction)?e.timingFunction:`cubic-bezier(${e.timingFunction.join(", ")})`,o=e.delay&&($(e.delay)?e.delay:je(e.delay));return{value:[t,n,o].filter(Boolean).join(" ")}}s(Fn,"convertTransitionToken");function Cn(e){if($(e))return{"font-family":e,"font-size":e};const t={"font-family":$(e.fontFamily)?e.fontFamily:Array.isArray(e.fontFamily)?e.fontFamily.map(n=>Y(n)).join(", "):Y(e.fontFamily),"font-size":$(e.fontSize)?e.fontSize:`${e.fontSize.value}${e.fontSize.unit}`};return e.fontWeight&&(t["font-weight"]=$(e.fontWeight)?e.fontWeight:xe(e.fontWeight).value),e.letterSpacing&&(t["letter-spacing"]=$(e.letterSpacing)?e.letterSpacing:`${e.letterSpacing.value}${e.letterSpacing.unit}`),e.lineHeight&&(t["line-height"]=($(e.lineHeight),e.lineHeight)),t}s(Cn,"convertTypographyToken");const Pe={duration:Nn,number:vn,cubicBezier:bn,color:gn,dimension:En,fluidDimension:On,typography:Cn,border:hn,shadow:kn,gradient:Dn,transition:Fn,strokeStyle:Ce,fontFamily:Ln,fontWeight:xe};function wn(e,t){const n=Pe[e.$type];return{...e.$description?{$description:e.$description}:{},...e.$extensions?{$extensions:e.$extensions}:{},$type:e.$type,$value:e.$value,$path:e.$path,$source:e.$source,$originalPath:e.$originalPath,$resolvedValue:e.$resolvedValue,$cssProperties:n(e.$value,t)}}s(wn,"convertSingleToken");function ae(e,t,n){const o={};for(const[r,i]of Object.entries(e)){if(!i||typeof i!="object")continue;if(!("$type"in i)){o[r]={...i.$description?{$description:i.$description}:{},...i.$extensions?{$extensions:i.$extensions}:{}};continue}if(n?.(i.$path)){console.log(`[sugarcube] Skipping invalid token: ${i.$path} (has validation error)`);continue}if(!Pe[i.$type])continue;const a={fluidConfig:t.transforms.fluid,colorFallbackStrategy:t.transforms.colorFallbackStrategy,path:i.$path,resolvedTokens:e};o[r]=wn(i,a)}return o}s(ae,"convertTokens");function Vn(e,t,n){const o={};for(const[r,i]of Object.entries(e)){const a={default:{default:ae(i.default?.default||{},t,n)}};for(const[c,u]of Object.entries(i)){const l={default:ae(u?.default||{},t,n)};for(const[p,f]of Object.entries(u||{}))p!=="default"&&(l[p]=ae(f,t,n));a[c]=l}o[r]=a}return o}s(Vn,"convert");function xn(e){const t=new Set,n=new Map,o=new Map;for(const u of e){const{collection:l,theme:p="default",mode:f="default"}=u;t.add(l),n.has(l)||n.set(l,new Set),n.get(l)?.add(p);const h=`${l}:${p}`;o.has(h)||o.set(h,new Set),o.get(h)?.add(f)}const r={};function i(u){return r[u]||(r[u]={default:{default:{}}}),r[u]}s(i,"ensureCollection");function a(u,l){return u[l]||(u[l]={default:{}}),u[l]}s(a,"ensureTheme");function c(u,l){return u[l]||(u[l]={}),u[l]}s(c,"ensureMode");for(const u of t){const l=i(u),p=n.get(u);if(p)for(const f of p){const h=a(l,f),m=`${u}:${f}`,I=o.get(m);if(I)for(const g of I)c(h,g)}}for(const u of e){const{collection:l,theme:p="default",mode:f="default",tokens:h}=u,m=i(l),I=a(m,p),g=c(I,f);for(const[A,T]of Object.entries(h)){const N=A.replace(`${l}.`,"");g[N]=T}}return{tokens:r}}s(xn,"normalizeTokens");function ce(e,t){return`${e??""}:${t??""}`}s(ce,"createVariantKey");function Rn(e,t){const n=new Map;for(const[o,r]of Object.entries(t)){if(!("$source"in r)){for(const f of e){const h=f.collection;n.has(h)||n.set(h,new Map);const m=n.get(h);if(!m)continue;const I=ce(f.theme,f.mode);m.has(I)||m.set(I,{});const g=m.get(I);g&&(g[o]=r)}continue}const i=r.$source.collection,a=r.$source.theme,c=r.$source.mode,u=ce(a,c);n.has(i)||n.set(i,new Map);const l=n.get(i);if(!l)continue;l.has(u)||l.set(u,{});const p=l.get(u);p&&(p[o]=r)}return e.map(o=>{const r=n.get(o.collection);if(!r)return{collection:o.collection,theme:o.theme,mode:o.mode,tokens:{}};const i=ce(o.theme,o.mode),a=r.get(i)||{};return{collection:o.collection,theme:o.theme,mode:o.mode,tokens:a}})}s(Rn,"processTrees");async function jn(e,t,n,o){const r=Rn(e,t),{tokens:i}=xn(r);return Vn(i,n,o?u=>o.some(l=>l.path===u||l.path.startsWith(`${u}.`)):void 0)}s(jn,"processAndConvertTokens");const K=["reset","global","compositions","blocks","utilities"];async function ue(e,t){const n=[],o=await Z([L(e,"**/*.css"),L(e,"**/*.scss"),L(e,"**/*.sass"),L(e,"**/*.less")],{ignore:[L(e,R)]});for(const r of o){const i=Pn(r,e);if(i){const a=D(e,r);n.push({path:a,layer:i,relativePath:a})}}return n}s(ue,"discoverAllFiles");function Pn(e,t){const n=D(t,e);if(n.includes("global/")||n.startsWith("global/"))return Ae(e).includes("reset")?"reset":"global";if(n.includes("compositions/")||n.startsWith("compositions/"))return"compositions";if(n.includes("blocks/")||n.startsWith("blocks/"))return"blocks";if(n.includes("utilities/")||n.startsWith("utilities/"))return"utilities"}s(Pn,"categorizeFile");function Mn(e){return e.sort((t,n)=>{const o=K.indexOf(t.layer),r=K.indexOf(n.layer);return o!==r?o-r:t.path.localeCompare(n.path)})}s(Mn,"sortFilesByLayer");function Un(){return`@layer ${K.join(", ")};
18
+ `}s(Un,"getLayerDefinitions");function Me(e){const t=[];t.push(Un());const n=e.reduce((o,r)=>{const i=o[r.layer]??[];return o[r.layer]=[...i,r],o},{});for(const o of K){const r=n[o];if(!(!r||r.length===0))for(const i of r)t.push(`@import "${i.path}" layer(${i.layer});`)}return t.join(`
19
+ `)}s(Me,"generateIndexContent");async function Gn(e,t){const n=L(e,R),o=await ue(e),r=Mn(o),i=Me(r);return await x.writeFile(n,i),D(process.cwd(),n)}s(Gn,"generateIndex");async function Bn(e,t){const n=L(e,R);if(!F(n))return!0;try{const o=await x.stat(n),r=await ue(e,t);for(const i of r){const a=L(e,i.path);if(F(a)&&(await x.stat(a)).mtime>o.mtime)return!0}return!1}catch{return!0}}s(Bn,"shouldRegenerateIndex");const Wn=`/*!
20
20
  * This file was automatically generated by sugarcube.
21
21
  * You should NOT make any changes in this file as it will be overwritten.
22
22
  * To make changes, edit your design token files instead.
@@ -24,7 +24,7 @@ ${n.map(o=>` - ${o}`).join(`
24
24
  * to prevent it from being checked or modified.
25
25
  */
26
26
 
27
- `,Un=`/*!
27
+ `,Yn=`/*!
28
28
  * This file was automatically generated by sugarcube.
29
29
  * You should NOT make any changes in this file as it will be overwritten.
30
30
  * To make changes, edit your utilities configuration instead.
@@ -32,13 +32,13 @@ ${n.map(o=>` - ${o}`).join(`
32
32
  * to prevent it from being checked or modified.
33
33
  */
34
34
 
35
- `;function G(e){return e.replace(/\r\n/g,`
35
+ `;function H(e){return e.replace(/\r\n/g,`
36
36
  `).replace(/\r/g,`
37
- `).trim()}s(G,"normalizeContent");function Gn(e){return Mn+e}s(Gn,"addWarningBanner");async function Wn(e){for(const t of e){const n=Gn(t.css);try{await fe(he(t.path),{recursive:!0});let o=!0;if(D(t.path))try{const r=await K(t.path,"utf-8");G(r)===G(n)&&(o=!1)}catch{}o&&await pe(t.path,n,"utf-8")}catch(o){throw new Error(`Failed to write CSS file ${t.path}: ${o instanceof Error?o.message:"Unknown error"}`)}}return e}s(Wn,"writeCSSVariablesToDisk");async function Bn(e){for(const t of e){const n=Un+t.css;try{await fe(he(t.path),{recursive:!0});let o=!0;if(D(t.path))try{const r=await K(t.path,"utf-8");G(r)===G(n)&&(o=!1)}catch{}o&&await pe(t.path,n,"utf-8")}catch(o){throw new Error(`Failed to write utility CSS file ${t.path}: ${o instanceof Error?o.message:"Unknown error"}`)}}return e}s(Bn,"writeCSSUtilitiesToDisk");const Re=m.array(m.string()).min(1,"At least one file path must be specified"),re=m.object({source:Re,themes:m.record(Re).optional()}),je=m.record(m.string(),re),Pe=m.object({min:m.number(),max:m.number()}),Me=m.object({source:m.string(),directions:m.union([m.enum(["top","right","bottom","left","x","y","full","all"]),m.array(m.enum(["top","right","bottom","left","x","y","full","all"]))]).optional(),prefix:m.string().optional(),stripDuplicates:m.boolean().optional(),collection:m.string().optional()}),Ue=m.union([Me,m.array(Me)]),Ge=m.object({tokens:m.union([je,re]).optional(),transforms:m.object({fluid:Pe.optional(),colorFallbackStrategy:m.enum(["native","polyfill"]).optional()}).optional(),output:m.object({css:m.string().optional(),components:m.string().optional(),separate:m.boolean().optional()}).optional(),utilities:m.record(m.string(),Ue).optional()}),We=m.object({tokens:m.union([je,re]).optional(),transforms:m.object({fluid:Pe,colorFallbackStrategy:m.enum(["native","polyfill"])}),output:m.object({css:m.string(),components:m.string(),separate:m.boolean()}),utilities:m.record(m.string(),Ue).optional()}),L={output:{css:"src/styles",components:"src/components/ui",separate:!1},transforms:{fluid:{min:320,max:1200},colorFallbackStrategy:"native"}},Yn="default",se="default";function ie(e){const t={tokens:e.tokens,transforms:{fluid:e.transforms?.fluid??L.transforms.fluid,colorFallbackStrategy:e.transforms?.colorFallbackStrategy??L.transforms.colorFallbackStrategy},output:{css:e.output?.css??L.output.css,separate:e.output?.separate??L.output.separate}};return(e.output?.components!==void 0||L.output.components!==void 0)&&(t.output.components=e.output?.components??L.output.components),e.utilities&&(t.utilities=e.utilities),t}s(ie,"fillDefaults");function W(e){const t=Ge.safeParse(e);if(!t.success){const n=t.error.errors.map(o=>{const r=o.path.join(".");return f.CONFIG.INVALID_CONFIG(r||"root",o.message)});throw new Error(n.join(`
38
- `))}return t.data}s(W,"validateUserConfig");function ae(e){const t=We.safeParse(e);if(!t.success){const n=t.error.errors.map(o=>{const r=o.path.join(".");return f.CONFIG.INVALID_CONFIG(r||"root",o.message)});throw new Error(n.join(`
39
- `))}return Kn(t.data),t.data}s(ae,"validateInternalConfig");function Be(e){const t=W(e),n=ie(t);return ae(n)}s(Be,"validateConfig");function Hn(e){try{const t=JSON.parse(e);return Be(t)}catch(t){throw t instanceof SyntaxError?new Error(f.CONFIG.INVALID_JSON(t.message)):t}}s(Hn,"parseAndValidateConfig");function Kn(e){if(typeof e.tokens=="object")for(const[t,n]of Object.entries(e.tokens)){if(!n.source?.length)continue;const o=new Map;for(const r of n.source){const i=de(r),a=o.get(i)||[];o.set(i,[...a,r])}for(const[r,i]of o)if(i.length>1)throw new Error(f.CONFIG.DUPLICATE_FILENAMES(t,r,i))}}s(Kn,"validateFileNames");function ce(e="sugarcube.config"){const t=[".ts",".js"];for(const n of t){const o=me(process.cwd(),`${e}${n}`);if(D(o))return o}return null}s(ce,"findConfigFile");function zn(e="sugarcube.config"){return ce(e)!==null}s(zn,"configFileExists");async function Ye(e){try{await import("tsx");const t=tt(e).href,o=await new Function("url","return import(url)")(t);if(o&&typeof o=="object"&&"default"in o)return o.default;throw new Error(f.CONFIG.INVALID_CONFIG("root","Config file must export a default object"))}catch(t){throw t instanceof Error?new Error(f.CONFIG.INVALID_CONFIG("root",t.message)):t}}s(Ye,"loadTSConfig");async function He(e){if(e.endsWith(".ts")||e.endsWith(".js"))return await Ye(e);const n=await C.readFile(e,"utf-8");return JSON.parse(n)}s(He,"loadConfigFile");function Ke(e){if(e)return me(process.cwd(),e);const t=ce();if(!t)throw new Error(f.CONFIG.FILE_NOT_FOUND(F));return t}s(Ke,"resolveConfigPath");async function qn(e){const t=Ke(e);try{const n=await He(t);return{config:W(n),configPath:t}}catch(n){throw n instanceof Error&&"code"in n&&n.code==="ENOENT"?new Error(f.CONFIG.FILE_NOT_FOUND(t)):n instanceof SyntaxError?new Error(f.CONFIG.INVALID_JSON(n.message)):n}}s(qn,"loadUserConfig");async function Jn(e){const t=Ke(e);try{const n=await He(t),o=W(n),r=ie(o);return{config:ae(r),configPath:t}}catch(n){throw n instanceof Error&&"code"in n&&n.code==="ENOENT"?new Error(f.CONFIG.FILE_NOT_FOUND(t)):n instanceof SyntaxError?new Error(f.CONFIG.INVALID_JSON(n.message)):n}}s(Jn,"loadInternalConfig");class ze extends Map{static{s(this,"DefaultMap")}constructor(t){super(),this.factory=t}get(t){let n=super.get(t);return n===void 0&&(n=this.factory(t,this),this.set(t,n)),n}}const Xn=process.env.DEBUG==="true";class Zn{static{s(this,"Instrumentation")}constructor(t=n=>void process.stderr.write(`${n}
40
- `)){this.defaultFlush=t}#t=new ze(()=>({value:0}));#n=new ze(()=>({value:0n}));#e=[];hit(t){this.#t.get(t).value++}start(t){const n=this.#e.map(r=>r.label).join("//"),o=`${n}${n.length===0?"":"//"}${t}`;this.#t.get(o).value++,this.#n.get(o),this.#e.push({id:o,label:t,namespace:n,value:process.hrtime.bigint()})}end(t){const n=process.hrtime.bigint();if(this.#e.length===0)throw new Error("Timer stack is empty");const o=this.#e.length-1,r=this.#e[o];if(!r)throw new Error("Timer stack is corrupted");if(r.label!==t)throw new Error(`Mismatched timer label: ${t}`);const i=this.#e.pop();if(!i)throw new Error("Timer stack is empty");const a=n-i.value;this.#n.get(i.id).value+=a}report(t=this.defaultFlush){const n=[];let o=!1;for(let r=this.#e.length-1;r>=0;r--){const i=this.#e[r];i&&this.end(i.label)}for(const[r,{value:i}]of this.#t.entries()){if(this.#n.has(r))continue;n.length===0&&(o=!0,n.push("Hits:"));const a=r.split("//").length;n.push(`${" ".repeat(a)}${r} \xD7 ${i}`)}if(this.#n.size>0){o&&n.push(`
37
+ `).trim()}s(H,"normalizeContent");function Kn(e){return Wn+e}s(Kn,"addWarningBanner");async function Hn(e){for(const t of e){const n=Kn(t.css);try{await $e(Te(t.path),{recursive:!0});let o=!0;if(F(t.path))try{const r=await X(t.path,"utf-8");H(r)===H(n)&&(o=!1)}catch{}o&&await ge(t.path,n,"utf-8")}catch(o){throw new Error(`Failed to write CSS file ${t.path}: ${o instanceof Error?o.message:"Unknown error"}`)}}return e}s(Hn,"writeCSSVariablesToDisk");async function zn(e){for(const t of e){const n=Yn+t.css;try{await $e(Te(t.path),{recursive:!0});let o=!0;if(F(t.path))try{const r=await X(t.path,"utf-8");H(r)===H(n)&&(o=!1)}catch{}o&&await ge(t.path,n,"utf-8")}catch(o){throw new Error(`Failed to write utility CSS file ${t.path}: ${o instanceof Error?o.message:"Unknown error"}`)}}return e}s(zn,"writeCSSUtilitiesToDisk");const w=y.array(y.string()).min(1,"At least one file path must be specified"),qn=y.union([w,y.object({source:w,modes:y.record(w).optional()})]),le=y.object({source:w,modes:y.record(w).optional(),themes:y.record(qn).optional()}),Ue=y.record(y.string(),le),Ge=y.object({min:y.number(),max:y.number()}),Be=y.object({source:y.string(),directions:y.union([y.enum(["top","right","bottom","left","x","y","full","all"]),y.array(y.enum(["top","right","bottom","left","x","y","full","all"]))]).optional(),prefix:y.string().optional(),stripDuplicates:y.boolean().optional(),collection:y.string().optional()}),We=y.union([Be,y.array(Be)]),Ye=y.object({tokens:y.union([Ue,le]).optional(),transforms:y.object({fluid:Ge.optional(),colorFallbackStrategy:y.enum(["native","polyfill"]).optional()}).optional(),output:y.object({css:y.string().optional(),components:y.string().optional(),separate:y.boolean().optional(),modeAttribute:y.string().optional(),themeAttribute:y.string().optional()}).optional(),utilities:y.record(y.string(),We).optional()}),Ke=y.object({tokens:y.union([Ue,le]).optional(),transforms:y.object({fluid:Ge,colorFallbackStrategy:y.enum(["native","polyfill"])}),output:y.object({css:y.string(),components:y.string(),separate:y.boolean(),modeAttribute:y.string(),themeAttribute:y.string()}),utilities:y.record(y.string(),We).optional()}),_={output:{css:"src/styles",components:"src/components/ui",separate:!1,modeAttribute:"data-mode",themeAttribute:"data-theme"},transforms:{fluid:{min:320,max:1200},colorFallbackStrategy:"native"}},Jn="default",fe="default",pe="default";function de(e){const t={tokens:e.tokens,transforms:{fluid:e.transforms?.fluid??_.transforms.fluid,colorFallbackStrategy:e.transforms?.colorFallbackStrategy??_.transforms.colorFallbackStrategy},output:{css:e.output?.css??_.output.css,separate:e.output?.separate??_.output.separate,modeAttribute:e.output?.modeAttribute??_.output.modeAttribute,themeAttribute:e.output?.themeAttribute??_.output.themeAttribute}};return(e.output?.components!==void 0||_.output.components!==void 0)&&(t.output.components=e.output?.components??_.output.components),e.utilities&&(t.utilities=e.utilities),t}s(de,"fillDefaults");function z(e){const t=Ye.safeParse(e);if(!t.success){const n=t.error.errors.map(o=>{const r=o.path.join(".");return d.CONFIG.INVALID_CONFIG(r||"root",o.message)});throw new Error(n.join(`
38
+ `))}return t.data}s(z,"validateUserConfig");function he(e){const t=Ke.safeParse(e);if(!t.success){const n=t.error.errors.map(o=>{const r=o.path.join(".");return d.CONFIG.INVALID_CONFIG(r||"root",o.message)});throw new Error(n.join(`
39
+ `))}return Zn(t.data),t.data}s(he,"validateInternalConfig");function He(e){const t=z(e),n=de(t);return he(n)}s(He,"validateConfig");function Xn(e){try{const t=JSON.parse(e);return He(t)}catch(t){throw t instanceof SyntaxError?new Error(d.CONFIG.INVALID_JSON(t.message)):t}}s(Xn,"parseAndValidateConfig");function Zn(e){if(typeof e.tokens=="object")for(const[t,n]of Object.entries(e.tokens)){if(!n.source?.length)continue;const o=new Map;for(const r of n.source){const i=Ae(r),a=o.get(i)||[];o.set(i,[...a,r])}for(const[r,i]of o)if(i.length>1)throw new Error(d.CONFIG.DUPLICATE_FILENAMES(t,r,i))}}s(Zn,"validateFileNames");function me(e="sugarcube.config"){const t=[".ts",".js"];for(const n of t){const o=be(process.cwd(),`${e}${n}`);if(F(o))return o}return null}s(me,"findConfigFile");function Qn(e="sugarcube.config"){return me(e)!==null}s(Qn,"configFileExists");async function ze(e){try{await import("tsx");const t=rt(e).href,o=await new Function("url","return import(url)")(t);if(o&&typeof o=="object"&&"default"in o)return o.default;throw new Error(d.CONFIG.INVALID_CONFIG("root","Config file must export a default object"))}catch(t){throw t instanceof Error?new Error(d.CONFIG.INVALID_CONFIG("root",t.message)):t}}s(ze,"loadTSConfig");async function qe(e){if(e.endsWith(".ts")||e.endsWith(".js"))return await ze(e);const n=await x.readFile(e,"utf-8");return JSON.parse(n)}s(qe,"loadConfigFile");function Je(e){if(e)return be(process.cwd(),e);const t=me();if(!t)throw new Error(d.CONFIG.FILE_NOT_FOUND(C));return t}s(Je,"resolveConfigPath");async function eo(e){const t=Je(e);try{const n=await qe(t);return{config:z(n),configPath:t}}catch(n){throw n instanceof Error&&"code"in n&&n.code==="ENOENT"?new Error(d.CONFIG.FILE_NOT_FOUND(t)):n instanceof SyntaxError?new Error(d.CONFIG.INVALID_JSON(n.message)):n}}s(eo,"loadUserConfig");async function to(e){const t=Je(e);try{const n=await qe(t),o=z(n),r=de(o);return{config:he(r),configPath:t}}catch(n){throw n instanceof Error&&"code"in n&&n.code==="ENOENT"?new Error(d.CONFIG.FILE_NOT_FOUND(t)):n instanceof SyntaxError?new Error(d.CONFIG.INVALID_JSON(n.message)):n}}s(to,"loadInternalConfig");class Xe extends Map{static{s(this,"DefaultMap")}constructor(t){super(),this.factory=t}get(t){let n=super.get(t);return n===void 0&&(n=this.factory(t,this),this.set(t,n)),n}}const no=process.env.DEBUG==="true";class oo{static{s(this,"Instrumentation")}constructor(t=n=>void process.stderr.write(`${n}
40
+ `)){this.defaultFlush=t}#t=new Xe(()=>({value:0}));#n=new Xe(()=>({value:0n}));#e=[];hit(t){this.#t.get(t).value++}start(t){const n=this.#e.map(r=>r.label).join("//"),o=`${n}${n.length===0?"":"//"}${t}`;this.#t.get(o).value++,this.#n.get(o),this.#e.push({id:o,label:t,namespace:n,value:process.hrtime.bigint()})}end(t){const n=process.hrtime.bigint();if(this.#e.length===0)throw new Error("Timer stack is empty");const o=this.#e.length-1,r=this.#e[o];if(!r)throw new Error("Timer stack is corrupted");if(r.label!==t)throw new Error(`Mismatched timer label: ${t}`);const i=this.#e.pop();if(!i)throw new Error("Timer stack is empty");const a=n-i.value;this.#n.get(i.id).value+=a}report(t=this.defaultFlush){const n=[];let o=!1;for(let r=this.#e.length-1;r>=0;r--){const i=this.#e[r];i&&this.end(i.label)}for(const[r,{value:i}]of this.#t.entries()){if(this.#n.has(r))continue;n.length===0&&(o=!0,n.push("Hits:"));const a=r.split("//").length;n.push(`${" ".repeat(a)}${r} \xD7 ${i}`)}if(this.#n.size>0){o&&n.push(`
41
41
  Timers:`);for(const[r,{value:i}]of this.#n){const a=r.split("//").length,c=`${(Number(i)/1e6).toFixed(2)}ms`;n.push(`${" ".repeat(a-1)}${r.split("//").pop()} [${c}] ${this.#t.get(r).value===1?"":`\xD7 ${this.#t.get(r).value}`}`.trimEnd())}}t(`
42
42
  ${n.join(`
43
43
  `)}
44
- `)}[Symbol.dispose](){Xn&&this.report()}}const k="--",O="-",Qn=["all","full"],eo={top:"t",right:"r",bottom:"b",left:"l",x:"x",y:"y",full:"",all:""},to={top:"block-start",right:"inline-end",bottom:"block-end",left:"inline-start",x:"inline",y:"block"};function no(e){return eo[e]}s(no,"getDirectionAbbreviation");function qe(e,t){if(t==="full"||t==="all")return e;const n=to[t];return n?`${e}${O}${n}`:e}s(qe,"getLogicalProperty");const oo=["top","right","bottom","left","x","y","full"];function ro(e){return(Array.isArray(e)?e:[e]).flatMap(n=>n==="all"?oo:[n])}s(ro,"expandDirections");function Je(e,t){const o={color:["color"],"background-color":["color"],"border-color":["color"],"font-size":["dimension","fluidDimension"],"font-weight":["fontWeight"],"line-height":["number"],"border-radius":["dimension","fluidDimension"],"border-width":["dimension","fluidDimension"],padding:["dimension","fluidDimension"],margin:["dimension","fluidDimension"],width:["dimension","fluidDimension"],height:["dimension","fluidDimension"],gap:["dimension","fluidDimension"],"font-family":["fontFamily"],"transition-duration":["duration"],"transition-timing-function":["cubicBezier"],"border-style":["strokeStyle"],"box-shadow":["shadow"],"text-shadow":["shadow"],"background-image":["gradient"],opacity:["number"]}[t];return o?o.includes(e):!0}s(Je,"isTokenTypeValidForProperty");const Xe=new WeakMap;function Ze(e){const t=Xe.get(e);if(t)return t;const n=new Map;for(const o of Object.values(e)){if(!("$path"in o))continue;const r=o;n.set(r.$path,r)}return Xe.set(e,n),n}s(Ze,"buildPathIndex");function B(e,t,n){const o=[t.source.replace("*",e),t.source.replace("*",e.split("-").join("."))];if(t.stripDuplicates&&t.prefix){const c=t.source.lastIndexOf(".*");if(c!==-1){const l=t.source.slice(0,c);l&&o.push(`${l}.${t.prefix}.${e}`,`${l}.${t.prefix}.${e.split("-").join(".")}`)}}if(t.collection){const c=n[t.collection];if(!c)return null;const l=c[se];if(!l)return null;const u=Ze(l);for(const p of o){const d=u.get(p);if(d){if(t.property&&d.$type&&!Je(d.$type,t.property))continue;return d.$path.split(".")}}return null}const r=[],i=Object.keys(n).sort();for(const c of i){const l=n[c];if(!l)continue;const u=l[se];if(!u)continue;const p=Ze(u);for(const d of o){const h=p.get(d);if(h){if(t.property&&h.$type&&!Je(h.$type,t.property))continue;r.push({collection:c,token:h});break}}}if(r.length===0)return null;if(r.length>1){const c=r.map(p=>p.collection).join(", "),l=r[0];if(!l)return null;const u=l.token.$path;throw new Error(f.UTILITIES.TOKEN_PATH_CONFLICT(u,c))}const a=r[0];return a?a.token.$path.split("."):null}s(B,"findMatchingToken");function le(e,t){return t.stripDuplicates&&t.prefix&&e.startsWith(`${t.prefix}-`)?e.slice(t.prefix.length+1):e}s(le,"stripDuplicatePrefix");function Y(e,t=""){const n=e??"",o=n||t?O:"";return new RegExp(`^${n}${t}${o}(.+)$`)}s(Y,"createUtilityPattern");function ue(e,t,n){return[Y(t.prefix),r=>{const i=r[1];if(!i)return{};const a=le(i,t),c={...t,property:e},l=B(a,c,n);return l?{[e]:`var(${k}${l.join(O)})`}:{}}]}s(ue,"createSimpleRule");function so(e,t,n,o){if(n==="all")return ue(e,t,o);const r=no(n);return[Y(t.prefix,r),a=>{const c=a[1];if(!c)return{};const l=le(c,t),u={...t,property:e},p=B(l,u,o);return p?{[qe(e,n)]:`var(${k}${p.join(O)})`}:{}}]}s(so,"createDirectionalRule");function io(e,t){return[Y(e),o=>{const r=o[1];if(!r)return{};for(const{property:i,config:a,direction:c,tokens:l}of t){const u=le(r,a),p={...a,property:i},d=B(u,p,l);if(d)return c?{[qe(i,c)]:`var(${k}${d.join(O)})`}:{[i]:`var(${k}${d.join(O)})`}}return{}}]}s(io,"createSmartRule");function ao(e,t,n){const o=t.source.indexOf("."),r=o!==-1?t.source.slice(0,o):t.source;return[Y(r),a=>{const c=a[1];if(!c)return{};const l={...t,property:e},u=B(c,l,n);return u?{[e]:`var(${k}${u.join(O)})`}:{}}]}s(ao,"createDirectTokenPathRule");function co(e,t){if(!e?.source||typeof e.source!="string")throw new Error(f.UTILITIES.MISSING_SOURCE(t));if(e.source.includes("*")&&!e.source.endsWith(".*"))throw new Error(f.UTILITIES.INVALID_SOURCE_PATTERN(t,e.source));if(e.directions&&!Array.isArray(e.directions))throw new Error(f.UTILITIES.INVALID_DIRECTIONS(t))}s(co,"validateUtilityConfig");function lo(e,t){if(!e||typeof e!="object")throw new Error(f.UTILITIES.INVALID_CONFIG_OBJECT);if(!t||typeof t!="object")throw new Error(f.UTILITIES.INVALID_TOKENS_OBJECT);const n=Object.keys(t);for(const[o,r]of Object.entries(e)){const i=Array.isArray(r)?r:[r];for(const a of i)if(a.collection&&!n.includes(a.collection))throw new Error(f.UTILITIES.INVALID_COLLECTION(o,a.collection,n))}}s(lo,"validateInputs");function uo(e,t){lo(e,t);const n=[],o={};for(const[r,i]of Object.entries(e)){const a=Array.isArray(i)?i:[i];for(const c of a)if(co(c,r),c.prefix){const l=c.prefix;o[l]||(o[l]=[]),o[l].push({property:r,config:c,direction:null,tokens:t})}else{const l=ao(r,c,t);n.push(l)}}for(const[r,i]of Object.entries(o))if(i.length===1){const a=i[0];if(!a)continue;const{property:c,config:l,tokens:u}=a;if(l.directions){const p=ro(l.directions);(Array.isArray(l.directions)?l.directions:[l.directions]).includes("all")&&n.push(ue(c,l,u));for(const y of p)Qn.includes(y)||n.push(so(c,l,y,u))}else n.push(ue(c,l,u))}else n.push(io(r,i));return n}s(uo,"convertConfigToUnoRules");function fo(e){return"source"in e&&Array.isArray(e.source)}s(fo,"isSingleCollection");export{Yn as DEFAULT_COLLECTION,L as DEFAULT_CONFIG,st as DEFAULT_DESIGN_TOKENS_PATH,rt as DEFAULT_STYLES_PATH,se as DEFAULT_THEME,ot as DEFAULT_UTILITIES_FILENAME,J as DEFAULT_VARIABLES_FILENAME,f as ErrorMessages,q as GLOBAL_DIR,Zn as Instrumentation,F as SUGARCUBE_CONFIG_FILE,w as SUGARCUBE_FILE,nt as UTILITIES_DIR,S as VARIABLES_FILE_SUFFIX,zn as configFileExists,uo as convertConfigToUnoRules,oe as discoverAllFiles,ie as fillDefaults,ce as findConfigFile,$t as generateCSSVariables,jn as generateIndex,xe as generateIndexContent,We as internalConfigSchema,Ie as isResolvedToken,ct as isResolvedTokenOfType,fo as isSingleCollection,ln as loadAndResolveTokens,Jn as loadInternalConfig,Ye as loadTSConfig,qn as loadUserConfig,Hn as parseAndValidateConfig,wn as processAndConvertTokens,Pn as shouldRegenerateIndex,Ge as userConfigSchema,Be as validateConfig,ae as validateInternalConfig,W as validateUserConfig,Bn as writeCSSUtilitiesToDisk,Wn as writeCSSVariablesToDisk};
44
+ `)}[Symbol.dispose](){no&&this.report()}}const V="--",k="-",ro=["all","full"],so={top:"t",right:"r",bottom:"b",left:"l",x:"x",y:"y",full:"",all:""},io={top:"block-start",right:"inline-end",bottom:"block-end",left:"inline-start",x:"inline",y:"block"};function ao(e){return so[e]}s(ao,"getDirectionAbbreviation");function Ze(e,t){if(t==="full"||t==="all")return e;const n=io[t];return n?`${e}${k}${n}`:e}s(Ze,"getLogicalProperty");const co=["top","right","bottom","left","x","y","full"];function uo(e){return(Array.isArray(e)?e:[e]).flatMap(n=>n==="all"?co:[n])}s(uo,"expandDirections");function Qe(e,t){const o={color:["color"],"background-color":["color"],"border-color":["color"],"font-size":["dimension","fluidDimension"],"font-weight":["fontWeight"],"line-height":["number"],"border-radius":["dimension","fluidDimension"],"border-width":["dimension","fluidDimension"],padding:["dimension","fluidDimension"],margin:["dimension","fluidDimension"],width:["dimension","fluidDimension"],height:["dimension","fluidDimension"],gap:["dimension","fluidDimension"],"font-family":["fontFamily"],"transition-duration":["duration"],"transition-timing-function":["cubicBezier"],"border-style":["strokeStyle"],"box-shadow":["shadow"],"text-shadow":["shadow"],"background-image":["gradient"],opacity:["number"]}[t];return o?o.includes(e):!0}s(Qe,"isTokenTypeValidForProperty");const et=new WeakMap;function tt(e){const t=et.get(e);if(t)return t;const n=new Map;for(const o of Object.values(e)){if(!("$path"in o))continue;const r=o;n.set(r.$path,r)}return et.set(e,n),n}s(tt,"buildPathIndex");function q(e,t,n){const o=[t.source.replace("*",e),t.source.replace("*",e.split("-").join("."))];if(t.stripDuplicates&&t.prefix){const c=t.source.lastIndexOf(".*");if(c!==-1){const u=t.source.slice(0,c);u&&o.push(`${u}.${t.prefix}.${e}`,`${u}.${t.prefix}.${e.split("-").join(".")}`)}}if(t.collection){const c=n[t.collection];if(!c)return null;const u=c[fe];if(!u)return null;const l=u[pe];if(!l)return null;const p=tt(l);for(const f of o){const h=p.get(f);if(h){if(t.property&&h.$type&&!Qe(h.$type,t.property))continue;return h.$path.split(".")}}return null}const r=[],i=Object.keys(n).sort();for(const c of i){const u=n[c];if(!u)continue;const l=u[fe];if(!l)continue;const p=l[pe];if(!p)continue;const f=tt(p);for(const h of o){const m=f.get(h);if(m){if(t.property&&m.$type&&!Qe(m.$type,t.property))continue;r.push({collection:c,token:m});break}}}if(r.length===0)return null;if(r.length>1){const c=r.map(p=>p.collection).join(", "),u=r[0];if(!u)return null;const l=u.token.$path;throw new Error(d.UTILITIES.TOKEN_PATH_CONFLICT(l,c))}const a=r[0];return a?a.token.$path.split("."):null}s(q,"findMatchingToken");function ye(e,t){return t.stripDuplicates&&t.prefix&&e.startsWith(`${t.prefix}-`)?e.slice(t.prefix.length+1):e}s(ye,"stripDuplicatePrefix");function J(e,t=""){const n=e??"",o=n||t?k:"";return new RegExp(`^${n}${t}${o}(.+)$`)}s(J,"createUtilityPattern");function Ie(e,t,n){return[J(t.prefix),r=>{const i=r[1];if(!i)return{};const a=ye(i,t),c={...t,property:e},u=q(a,c,n);return u?{[e]:`var(${V}${u.join(k)})`}:{}}]}s(Ie,"createSimpleRule");function lo(e,t,n,o){if(n==="all")return Ie(e,t,o);const r=ao(n);return[J(t.prefix,r),a=>{const c=a[1];if(!c)return{};const u=ye(c,t),l={...t,property:e},p=q(u,l,o);return p?{[Ze(e,n)]:`var(${V}${p.join(k)})`}:{}}]}s(lo,"createDirectionalRule");function fo(e,t){return[J(e),o=>{const r=o[1];if(!r)return{};for(const{property:i,config:a,direction:c,tokens:u}of t){const l=ye(r,a),p={...a,property:i},f=q(l,p,u);if(f)return c?{[Ze(i,c)]:`var(${V}${f.join(k)})`}:{[i]:`var(${V}${f.join(k)})`}}return{}}]}s(fo,"createSmartRule");function po(e,t,n){const o=t.source.indexOf("."),r=o!==-1?t.source.slice(0,o):t.source;return[J(r),a=>{const c=a[1];if(!c)return{};const u={...t,property:e},l=q(c,u,n);return l?{[e]:`var(${V}${l.join(k)})`}:{}}]}s(po,"createDirectTokenPathRule");function ho(e,t){if(!e?.source||typeof e.source!="string")throw new Error(d.UTILITIES.MISSING_SOURCE(t));if(e.source.includes("*")&&!e.source.endsWith(".*"))throw new Error(d.UTILITIES.INVALID_SOURCE_PATTERN(t,e.source));if(e.directions&&!Array.isArray(e.directions))throw new Error(d.UTILITIES.INVALID_DIRECTIONS(t))}s(ho,"validateUtilityConfig");function mo(e,t){if(!e||typeof e!="object")throw new Error(d.UTILITIES.INVALID_CONFIG_OBJECT);if(!t||typeof t!="object")throw new Error(d.UTILITIES.INVALID_TOKENS_OBJECT);const n=Object.keys(t);for(const[o,r]of Object.entries(e)){const i=Array.isArray(r)?r:[r];for(const a of i)if(a.collection&&!n.includes(a.collection))throw new Error(d.UTILITIES.INVALID_COLLECTION(o,a.collection,n))}}s(mo,"validateInputs");function yo(e,t){mo(e,t);const n=[],o={};for(const[r,i]of Object.entries(e)){const a=Array.isArray(i)?i:[i];for(const c of a)if(ho(c,r),c.prefix){const u=c.prefix;o[u]||(o[u]=[]),o[u].push({property:r,config:c,direction:null,tokens:t})}else{const u=po(r,c,t);n.push(u)}}for(const[r,i]of Object.entries(o))if(i.length===1){const a=i[0];if(!a)continue;const{property:c,config:u,tokens:l}=a;if(u.directions){const p=uo(u.directions);(Array.isArray(u.directions)?u.directions:[u.directions]).includes("all")&&n.push(Ie(c,u,l));for(const m of p)ro.includes(m)||n.push(lo(c,u,m,l))}else n.push(Ie(c,u,l))}else n.push(fo(r,i));return n}s(yo,"convertConfigToUnoRules");function Io(e){return"source"in e&&Array.isArray(e.source)}s(Io,"isSingleCollection");export{Jn as DEFAULT_COLLECTION,_ as DEFAULT_CONFIG,ct as DEFAULT_DESIGN_TOKENS_PATH,pe as DEFAULT_MODE,at as DEFAULT_STYLES_PATH,fe as DEFAULT_THEME,it as DEFAULT_UTILITIES_FILENAME,ee as DEFAULT_VARIABLES_FILENAME,d as ErrorMessages,Q as GLOBAL_DIR,oo as Instrumentation,C as SUGARCUBE_CONFIG_FILE,R as SUGARCUBE_FILE,st as UTILITIES_DIR,v as VARIABLES_FILE_SUFFIX,Qn as configFileExists,yo as convertConfigToUnoRules,ue as discoverAllFiles,de as fillDefaults,me as findConfigFile,bt as generateCSSVariables,Gn as generateIndex,Me as generateIndexContent,Ke as internalConfigSchema,Ee as isResolvedToken,ft as isResolvedTokenOfType,Io as isSingleCollection,dn as loadAndResolveTokens,to as loadInternalConfig,ze as loadTSConfig,eo as loadUserConfig,Xn as parseAndValidateConfig,jn as processAndConvertTokens,Bn as shouldRegenerateIndex,Ye as userConfigSchema,He as validateConfig,he as validateInternalConfig,z as validateUserConfig,zn as writeCSSUtilitiesToDisk,Hn as writeCSSVariablesToDisk};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sugarcube-org/core",
3
- "version": "0.0.1-alpha.7",
3
+ "version": "0.0.1-alpha.9",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": false