@sugarcube-sh/core 0.1.4 → 0.1.5

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
@@ -500,6 +500,12 @@ type ValidationError = BaseError & {
500
500
  source: TokenSource;
501
501
  };
502
502
 
503
+ /**
504
+ * Strategy for how modifier contexts are output in CSS.
505
+ * - "data-attribute": [data-{name}="{context}"] selector (default)
506
+ * - "prefers-color-scheme": @media (prefers-color-scheme: {context}) wrapper
507
+ */
508
+ type ContextStrategy = "data-attribute" | "prefers-color-scheme";
503
509
  /**
504
510
  * Metadata about a modifier (e.g., theme, density) for CSS generation.
505
511
  * Used to build attribute selectors like [data-theme="dark"].
@@ -513,6 +519,8 @@ type ModifierMeta = {
513
519
  defaultContext: string;
514
520
  /** Available non-default context names. */
515
521
  contexts: string[];
522
+ /** How this modifier's contexts are output in CSS. */
523
+ contextStrategy: ContextStrategy;
516
524
  };
517
525
  /**
518
526
  * Result of running the token processing pipeline.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var nt=Object.defineProperty;var s=(e,t)=>nt(e,"name",{value:t,configurable:!0});import{existsSync as Q}from"node:fs";import rt,{readFile as ee,mkdir as he,writeFile as Ie}from"node:fs/promises";import{pathToFileURL as ot}from"node:url";import{relative as V,resolve as T,isAbsolute as D,dirname as w}from"pathe";import{glob as st}from"tinyglobby";import{resolve as Ee}from"node:path";import{z as l}from"zod";function it(e){return e}s(it,"defineConfig");const A={output:{cssRoot:"src/styles",variablesFilename:"tokens.variables.gen.css",utilitiesFilename:"utilities.gen.css",components:"src/components/ui",themeAttribute:"data-theme"},transforms:{fluid:{min:320,max:1200},colorFallbackStrategy:"native"}},u={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"),TOKEN_MISSING_TYPE:s(e=>`Token at '${e}' is missing "$type". Add "$type" to the token or its parent group.`,"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 DTCG 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"),INVALID_CSS_VALUE_TYPE:s(e=>`CSS value must be a string or number, but received ${e}. This is a bug in sugarcube. Please report it at https://github.com/sugarcube-sh/sugarcube/issues`,"INVALID_CSS_VALUE_TYPE")},CONVERT:{COLOR_CONVERSION_FAILED:s(e=>`Failed to convert color: ${e}. This is a bug in sugarcube. Please report it at https://github.com/sugarcube-sh/sugarcube/issues`,"COLOR_CONVERSION_FAILED")},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)=>`Duplicate filename "${e}":
1
+ var st=Object.defineProperty;var s=(e,t)=>st(e,"name",{value:t,configurable:!0});import{existsSync as Q}from"node:fs";import it,{readFile as ee,mkdir as he,writeFile as Ie}from"node:fs/promises";import{pathToFileURL as at}from"node:url";import{relative as V,resolve as b,isAbsolute as _,dirname as w}from"pathe";import{glob as ct}from"tinyglobby";import{resolve as Ee}from"node:path";import{z as l}from"zod";function ut(e){return e}s(ut,"defineConfig");const A={output:{cssRoot:"src/styles",variablesFilename:"tokens.variables.gen.css",utilitiesFilename:"utilities.gen.css",components:"src/components/ui",themeAttribute:"data-theme"},transforms:{fluid:{min:320,max:1200},colorFallbackStrategy:"native"}},u={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"),TOKEN_MISSING_TYPE:s(e=>`Token at '${e}' is missing "$type". Add "$type" to the token or its parent group.`,"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 DTCG 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"),INVALID_CSS_VALUE_TYPE:s(e=>`CSS value must be a string or number, but received ${e}. This is a bug in sugarcube. Please report it at https://github.com/sugarcube-sh/sugarcube/issues`,"INVALID_CSS_VALUE_TYPE")},CONVERT:{COLOR_CONVERSION_FAILED:s(e=>`Failed to convert color: ${e}. This is a bug in sugarcube. Please report it at https://github.com/sugarcube-sh/sugarcube/issues`,"COLOR_CONVERSION_FAILED")},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)=>`Duplicate filename "${e}":
2
2
  ${t.map(n=>` - ${n}`).join(`
3
3
  `)}`,"DUPLICATE_FILENAMES"),FILE_NOT_FOUND:s(e=>e==="sugarcube.config.ts"?"Cannot find sugarcube config file. Please ensure you have a valid sugarcube.config.ts file in your project root.":`Cannot find sugarcube config file at "${e}". Please check the path and file permissions.`,"FILE_NOT_FOUND"),MULTIPLE_RESOLVERS_FOUND:s(e=>`Multiple resolver files found:
4
4
  ${e.map(t=>` - ${t}`).join(`
@@ -9,24 +9,26 @@ Please specify which one to use:
9
9
  2. Use --resolver flag (generate command only)`,"MULTIPLE_RESOLVERS_FOUND"),NO_CONFIG_OR_RESOLVER:s(()=>`No configuration found. Either:
10
10
  1. Run: npx @sugarcube-sh/cli init
11
11
  2. Create a .resolver.json file
12
- 3. Create a sugarcube.config.ts file`,"NO_CONFIG_OR_RESOLVER")},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"),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"},RESOLVER:{FILE_NOT_FOUND:s(e=>`Cannot read resolver file at "${e}". Please check the path and file permissions.`,"FILE_NOT_FOUND"),INVALID_JSON:s(e=>`Invalid JSON in resolver file: ${e}`,"INVALID_JSON"),INVALID_REFERENCE:s(e=>`Invalid reference "${e}". References must use format #/sets/<name> or #/modifiers/<name>.`,"INVALID_REFERENCE"),INVALID_SOURCE_REFERENCE:s(e=>`Invalid source reference "${e}". Sources can only reference sets (#/sets/<name>), not modifiers.`,"INVALID_SOURCE_REFERENCE"),UNDEFINED_SET:s(e=>`Reference to undefined set "${e}". Define it in the "sets" section first.`,"UNDEFINED_SET"),UNDEFINED_MODIFIER:s(e=>`Reference to undefined modifier "${e}". Define it in the "modifiers" section first.`,"UNDEFINED_MODIFIER"),CIRCULAR_REFERENCE:s(e=>`Circular reference detected at "${e}".`,"CIRCULAR_REFERENCE"),EXTERNAL_FILE_NOT_FOUND:s(e=>`Referenced file not found: ${e}`,"EXTERNAL_FILE_NOT_FOUND"),EXTERNAL_FILE_ERROR:s((e,t)=>`Failed to load "${e}": ${t}`,"EXTERNAL_FILE_ERROR"),INVALID_JSON_POINTER:s((e,t)=>`Invalid JSON pointer "${e}": ${t}`,"INVALID_JSON_POINTER"),DUPLICATE_NAME:s(e=>`Duplicate name "${e}" in resolutionOrder.`,"DUPLICATE_NAME"),MODIFIER_NEEDS_CONTEXTS:"Modifier must have at least one context defined.",MODIFIER_SINGLE_CONTEXT:"Modifier has only one context. Consider using a set instead, or add more contexts.",INVALID_DEFAULT:s((e,t)=>`Default context "${e}" is not defined. Valid contexts: ${t.join(", ")}`,"INVALID_DEFAULT"),UNKNOWN_MODIFIER:s(e=>`Unknown modifier "${e}".`,"UNKNOWN_MODIFIER"),INVALID_CONTEXT:s((e,t,n)=>`Invalid context "${e}" for modifier "${t}". Valid contexts: ${n.join(", ")}`,"INVALID_CONTEXT"),MISSING_REQUIRED_INPUT:s(e=>`Missing required input for modifier "${e}". No default value is defined.`,"MISSING_REQUIRED_INPUT"),INVALID_INPUT_TYPE:s(e=>`Input for modifier "${e}" must be a string.`,"INVALID_INPUT_TYPE"),MALFORMED_REFERENCE:s((e,t)=>`Malformed source reference: { "${e}": "${t}" }. Did you mean { "$ref": "${t}" }?`,"MALFORMED_REFERENCE"),RESOLVER_AS_TOKEN_SOURCE:s(e=>`File "${e}" is a resolver document, not a token file. Resolver documents (version: "2025.10") cannot be used as token sources. Did you mean to reference a specific token file instead?`,"RESOLVER_AS_TOKEN_SOURCE")}};async function te(e){const n=await st(["**/*.resolver.json"],{cwd:e,onlyFiles:!0,absolute:!0,ignore:["**/node_modules/**","**/dist/**","**/build/**","**/out/**","**/.git/**","**/.next/**","**/.nuxt/**","**/.astro/**","**/.cache/**","**/.turbo/**","**/.vercel/**","**/.svelte-kit/**"]});if(n.length===0)return{found:"none"};const[r]=n;return n.length===1&&r?{found:"one",path:V(process.cwd(),r)}:{found:"multiple",paths:n.map(o=>V(process.cwd(),o))}}s(te,"findResolverDocument");function at(e){return Q(Ee(e,"src"))?"src/styles":"styles"}s(at,"getDefaultCssRoot");function ct(e){return Q(Ee(e,"src"))?"src/components/ui":"components/ui"}s(ct,"getDefaultComponentsDir");function k(e,t=process.cwd()){const n=e.output?.cssRoot??at(t),r={resolver:e.resolver,transforms:{fluid:e.transforms?.fluid??A.transforms.fluid,colorFallbackStrategy:e.transforms?.colorFallbackStrategy??A.transforms.colorFallbackStrategy},output:{cssRoot:n,variables:e.output?.variables??`${n}/global`,variablesFilename:e.output?.variablesFilename??A.output.variablesFilename,utilities:e.output?.utilities??`${n}/utilities`,utilitiesFilename:e.output?.utilitiesFilename??A.output.utilitiesFilename,cube:e.output?.cube??n,themeAttribute:e.output?.themeAttribute??A.output.themeAttribute,defaultContext:e.output?.defaultContext,layers:e.output?.layers}};return(e.output?.components!==void 0||A.output.components!==void 0)&&(r.output.components=e.output?.components??ct(t)),e.utilities&&(r.utilities=e.utilities),r}s(k,"fillDefaults");const ye=l.object({min:l.number(),max:l.number()}),$e=l.object({source:l.string(),directions:l.union([l.enum(["top","right","bottom","left","x","y","full","all"]),l.array(l.enum(["top","right","bottom","left","x","y","full","all"]))]).optional(),prefix:l.string().optional(),stripDuplicates:l.boolean().optional()}),ge=l.union([$e,l.array($e)]),Ne=l.object({variables:l.string(),utilities:l.string()}),ut=l.object({resolver:l.string().optional(),transforms:l.object({fluid:ye.optional(),colorFallbackStrategy:l.enum(["native","polyfill"]).optional()}).optional(),output:l.object({cssRoot:l.string().optional(),variables:l.string().optional(),variablesFilename:l.string().optional(),utilities:l.string().optional(),utilitiesFilename:l.string().optional(),cube:l.string().optional(),components:l.string().optional(),themeAttribute:l.string().optional(),defaultContext:l.string().optional(),layers:Ne.optional()}).optional(),utilities:l.record(l.string(),ge).optional()}),ft=l.object({resolver:l.string().optional(),transforms:l.object({fluid:ye,colorFallbackStrategy:l.enum(["native","polyfill"])}),output:l.object({cssRoot:l.string(),variables:l.string().optional(),variablesFilename:l.string(),utilities:l.string().optional(),utilitiesFilename:l.string(),cube:l.string().optional(),components:l.string().optional(),themeAttribute:l.string(),defaultContext:l.string().optional(),layers:Ne.optional()}),utilities:l.record(l.string(),ge).optional()});function ne(e){const t=ut.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const o=r.path.join(".");return u.CONFIG.INVALID_CONFIG(o||"root",r.message)});throw new Error(n.join(`
13
- `))}return t.data}s(ne,"validateSugarcubeConfig");function re(e){const t=ft.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const o=r.path.join(".");return u.CONFIG.INVALID_CONFIG(o||"root",r.message)});throw new Error(n.join(`
14
- `))}return t.data}s(re,"validateInternalConfig");function lt(e){const t=ne(e),n=k(t);return re(n)}s(lt,"validateConfig");function pt(e){return e instanceof Error&&e.message===u.CONFIG.NO_CONFIG_OR_RESOLVER()}s(pt,"isNoConfigError");function oe(e="sugarcube.config"){const t=[".ts",".js"],n=process.cwd();for(const r of t){const o=T(n,`${e}${r}`);if(Q(o))return o}return null}s(oe,"findConfigFile");function dt(e="sugarcube.config"){return oe(e)!==null}s(dt,"configFileExists");async function mt(e){try{if(typeof globalThis.Bun<"u"){const i=ot(e).href,c=await new Function("url","return import(url)")(i);if(c&&typeof c=="object"&&"default"in c)return c.default;throw new Error(u.CONFIG.INVALID_CONFIG("root","Config file must export a default object"))}const{createJiti:n}=await import("jiti"),o=await n(import.meta.url,{interopDefault:!0}).import(e);return o&&typeof o=="object"&&"default"in o?o.default:o}catch(t){throw t instanceof Error?new Error(u.CONFIG.INVALID_CONFIG("root",t.message)):t}}s(mt,"loadTSConfig");async function Se(e){if(e.endsWith(".ts")||e.endsWith(".js"))return await mt(e);const n=await rt.readFile(e,"utf-8");return JSON.parse(n)}s(Se,"loadConfigFile");function ht(e){if(e)return T(process.cwd(),e);const t=oe();if(!t)throw new Error(u.CONFIG.FILE_NOT_FOUND("sugarcube.config.ts"));return t}s(ht,"resolveConfigPath");async function It(e){const t=ht(e);try{const n=await Se(t);return{config:ne(n),configPath:t}}catch(n){throw n instanceof Error&&"code"in n&&n.code==="ENOENT"?new Error(u.CONFIG.FILE_NOT_FOUND(t)):n instanceof SyntaxError?new Error(u.CONFIG.INVALID_JSON(n.message)):n}}s(It,"loadSugarcubeConfig");async function Et(e){const t=e?T(process.cwd(),e):oe();if(t)try{const r=await Se(t),o=ne(r);if(!o.resolver){const c=await te(process.cwd());if(c.found==="one")o.resolver=c.path;else{if(c.found==="multiple")throw new Error(u.CONFIG.MULTIPLE_RESOLVERS_FOUND(c.paths));if(c.found==="none")throw new Error(u.CONFIG.NO_CONFIG_OR_RESOLVER())}}const i=k(o);return{config:re(i),configPath:t}}catch(r){throw r instanceof Error&&"code"in r&&r.code==="ENOENT"?new Error(u.CONFIG.FILE_NOT_FOUND(t)):r instanceof SyntaxError?new Error(u.CONFIG.INVALID_JSON(r.message)):r}const n=await te(process.cwd());if(n.found==="one"){const r={resolver:n.path},o=k(r);return{config:re(o),configPath:n.path}}throw n.found==="multiple"?new Error(u.CONFIG.MULTIPLE_RESOLVERS_FOUND(n.paths)):new Error(u.CONFIG.NO_CONFIG_OR_RESOLVER())}s(Et,"loadInternalConfig");function O(e){return typeof e=="object"&&e!==null&&"$ref"in e&&typeof e.$ref=="string"}s(O,"isReference$1");function se(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="set"}s(se,"isInlineSet");function _(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="modifier"}s(_,"isInlineModifier");async function yt(e){const t=D(e)?e:T(process.cwd(),e),n=w(t),r=await ee(t,"utf-8"),o=JSON.parse(r),i=new Set;for(const a of o.resolutionOrder)if(O(a))be(a.$ref,n,i);else if(se(a))M(a.sources,n,i);else if(_(a))for(const c of Object.values(a.contexts))M(c,n,i);if(o.sets)for(const a of Object.values(o.sets))M(a.sources,n,i);if(o.modifiers)for(const a of Object.values(o.modifiers))for(const c of Object.values(a.contexts))M(c,n,i);return{filePaths:[...i],resolverPath:t}}s(yt,"extractFileRefs");function M(e,t,n){for(const r of e)O(r)&&be(r.$ref,t,n)}s(M,"extractFromSources");function be(e,t,n){if(e.startsWith("#/"))return;const r=e.split("#")[0];if(!r)return;const o=D(r)?r:T(t,r);n.add(o)}s(be,"addFileRef");function h(e){return typeof e=="string"&&e.startsWith("{")&&e.endsWith("}")}s(h,"isReference");function $t(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($t,"isCompositeToken");function gt(e){return e.$type==="typography"}s(gt,"isTypographyToken");function ie(e){return typeof e=="object"&&e!==null&&"$value"in e}s(ie,"isTokenNode");function Nt(e,t,n){for(const[r,o]of Object.entries(t.tokens)){const i=e.tokens[r];if(!ie(o)){if(i&&ie(i)){const d=i;n.push({path:d.$path,source:d.$source,message:u.FLATTEN.CONFLICT_TOKEN_VS_GROUP(d.$path)});continue}e.tokens[r]=o;continue}if(!i){e.tokens[r]=o;continue}if(!ie(i)){n.push({path:o.$path,source:o.$source,message:u.FLATTEN.CONFLICT_TOKEN_VS_GROUP(o.$path)});continue}const c=o,f=i,p=!!c.$type,m=!!f.$type;if(p&&m&&c.$type!==f.$type){n.push({path:c.$path,source:c.$source,message:u.FLATTEN.CONFLICT_INCOMPATIBLE_TYPES(String(f.$type??"unknown"),String(c.$type??"unknown"),c.$path)});continue}e.tokens[r]=o}for(const[r,o]of t.pathIndex)e.pathIndex.set(r,o)}s(Nt,"mergeFlattenedInto");function St(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 r=e.value;return typeof r=="string"||typeof r=="number"||Array.isArray(r)}return!1}s(St,"looksLikeUnprefixedToken");function bt(e,t){const n={tokens:{},pathIndex:new Map},r=[];function o(a=[]){const c=[];return t.context&&c.push(t.context),a.length>0&&c.push(a.join(".")),c.length>0?c.join("."):""}s(o,"createLookupKey"),(e.$description||e.$extensions)&&(n.tokens[o()]={$description:e.$description,$extensions:e.$extensions});function i(a,c=[],f){if(c.join("."),c.length>0){const d=o(c);n.tokens[d]={$description:a.$description,$extensions:a.$extensions,$path:c.join("."),$source:{context:t.context,sourcePath:t.sourcePath}}}const p=Object.keys(a).filter(d=>!d.startsWith("$")),m=a.$type||f;for(const d of p){const I=a[d],E=[...c,d],$=E.join(".");if(St(I)){r.push({path:$,source:t,message:u.FLATTEN.MISSING_DOLLAR_PREFIX($)});continue}if(d.includes(".")||d.includes("{")||d.includes("}")){r.push({path:$,source:t,message:u.FLATTEN.INVALID_TOKEN_NAME(d)});continue}if("$value"in I){if(Object.keys(I).filter(tt=>!tt.startsWith("$")).length>0){r.push({path:$,source:t,message:u.FLATTEN.INVALID_TOKEN_NESTING($)});continue}if($t(I)&&!I.$type&&!m){r.push({path:$,source:t,message:u.FLATTEN.COMPOSITE_TOKEN_MISSING_TYPE($)});continue}if(!I.$type&&!m&&!h(I.$value)){r.push({path:$,source:t,message:u.FLATTEN.TOKEN_MISSING_TYPE($)});continue}const me=o(E),Z=E.join(".");n.tokens[me]={...I,...I.$type||m?{$type:I.$type||m}:{},$path:Z,$source:{context:t.context,sourcePath:t.sourcePath},$originalPath:Z},n.pathIndex.set(Z,me)}else i(I,E,m)}}return s(i,"processNode"),i(e),{tokens:n,errors:r}}s(bt,"flattenTree");function Tt(e){const t={tokens:{},pathIndex:new Map},n=[];for(const r of e){const{tokens:o,errors:i}=bt(r.tokens,{context:r.context,sourcePath:r.sourcePath});n.push(...i),Nt(t,o,n)}return{tokens:t,errors:n}}s(Tt,"flatten");const P=l.string().min(1,"Name cannot be empty").refine(e=>!e.startsWith("$"),"Names must not start with '$' (reserved prefix)").refine(e=>!e.includes("{"),"Names must not contain '{'").refine(e=>!e.includes("}"),"Names must not contain '}'").refine(e=>!e.includes("."),"Names must not contain '.'"),Te=l.object({$ref:l.string().min(1,"$ref cannot be empty")}).passthrough(),ae=l.union([Te,l.record(l.string(),l.unknown())]),Ot=l.object({description:l.string().optional(),sources:l.array(ae),$extensions:l.record(l.string(),l.unknown()).optional()}),Oe=l.record(l.string(),l.array(ae)),At=l.object({description:l.string().optional(),contexts:Oe,default:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}).refine(e=>Object.keys(e.contexts).length>=1,"Modifier must have at least 1 context"),Rt=l.object({type:l.literal("set"),name:P,sources:l.array(ae),description:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}),Dt=l.object({type:l.literal("modifier"),name:P,contexts:Oe,description:l.string().optional(),default:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}).refine(e=>Object.keys(e.contexts).length>=1,"Modifier must have at least 1 context"),_t=l.union([Te,Rt,Dt]),Lt=l.record(P,Ot),vt=l.record(P,At),xt=l.object({version:l.literal("2025.10"),name:l.string().optional(),description:l.string().optional(),sets:Lt.optional(),modifiers:vt.optional(),resolutionOrder:l.array(_t),$schema:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional(),$defs:l.record(l.string(),l.unknown()).optional()});async function Ct(e){const t=D(e)?e:T(process.cwd(),e),n=await Ft(t);if(n.error)return{document:U(),errors:[n.error]};const r=Vt(n.content);if(r.error)return{document:U(),errors:[r.error]};const o=wt(r.data);if(o.errors.length>0)return{document:U(),errors:o.errors};const i=[];return kt(o.document,i),{document:o.document,errors:i}}s(Ct,"parseResolverDocument");async function Ft(e){try{return{content:await ee(e,"utf-8")}}catch{return{error:{path:e,message:u.RESOLVER.FILE_NOT_FOUND(e)}}}}s(Ft,"loadFile");function Vt(e){try{return{data:JSON.parse(e)}}catch(t){const n=t instanceof Error?t.message:"Unknown error";return{error:{path:"resolver",message:u.RESOLVER.INVALID_JSON(n)}}}}s(Vt,"parseJson");function wt(e){const t=xt.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const o=r.path.join(".")||"resolver";return{path:o,message:`Resolver error at ${o}: ${r.message}. See https://sugarcube.sh/docs/resolver`}});return{document:U(),errors:n}}return{document:t.data,errors:[]}}s(wt,"validateSchema$1");function kt(e,t){Mt(e,t),Pt(e,t),jt(e,t)}s(kt,"validateDocument");function Mt(e,t){if(e.modifiers)for(const[n,r]of Object.entries(e.modifiers))Ae(r,`modifiers.${n}`,t);for(let n=0;n<e.resolutionOrder.length;n++){const r=e.resolutionOrder[n];_(r)&&Ae(r,`resolutionOrder[${n}]`,t)}}s(Mt,"validateModifierContexts");function Ae(e,t,n){const r=Object.keys(e.contexts).length;if(r===0){n.push({path:`${t}.contexts`,message:u.RESOLVER.MODIFIER_NEEDS_CONTEXTS});return}r===1&&n.push({path:`${t}.contexts`,message:u.RESOLVER.MODIFIER_SINGLE_CONTEXT}),e.default&&!e.contexts[e.default]&&n.push({path:`${t}.default`,message:u.RESOLVER.INVALID_DEFAULT(e.default,Object.keys(e.contexts))})}s(Ae,"checkModifierContexts");function Pt(e,t){const n=new Set;for(let r=0;r<e.resolutionOrder.length;r++){const o=e.resolutionOrder[r];if(O(o))continue;const i=o.name;n.has(i)&&t.push({path:`resolutionOrder[${r}].name`,message:u.RESOLVER.DUPLICATE_NAME(i)}),n.add(i)}}s(Pt,"validateNameUniqueness");function jt(e,t){for(let n=0;n<e.resolutionOrder.length;n++){const r=e.resolutionOrder[n];if(O(r))Ut(r.$ref,`resolutionOrder[${n}].$ref`,e,t);else if(se(r))j(r.sources,`resolutionOrder[${n}].sources`,t);else if(_(r))for(const[o,i]of Object.entries(r.contexts))j(i,`resolutionOrder[${n}].contexts.${o}`,t)}if(e.sets)for(const[n,r]of Object.entries(e.sets))j(r.sources,`sets.${n}.sources`,t);if(e.modifiers)for(const[n,r]of Object.entries(e.modifiers))for(const[o,i]of Object.entries(r.contexts))j(i,`modifiers.${n}.contexts.${o}`,t)}s(jt,"validateReferences");function j(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if(!o)continue;if(!O(o)){const a=Object.keys(o);if(a.length===1){const c=a[0],f=o[c];typeof f=="string"&&(f.includes("/")||f.endsWith(".json"))&&n.push({path:`${t}[${r}]`,message:u.RESOLVER.MALFORMED_REFERENCE(c,f)})}continue}const i=o.$ref;i.startsWith("#/")&&(i.match(/^#\/sets\/[^/]+$/)||n.push({path:`${t}[${r}].$ref`,message:u.RESOLVER.INVALID_SOURCE_REFERENCE(i)}))}}s(j,"validateSourcesReferences");function Ut(e,t,n,r){if(!e.startsWith("#/"))return;const o=e.slice(2).split("/"),[i,a]=o;if(o.length!==2||!i||!a){r.push({path:t,message:u.RESOLVER.INVALID_REFERENCE(e)});return}if(i==="sets"){n.sets?.[a]||r.push({path:t,message:u.RESOLVER.UNDEFINED_SET(a)});return}if(i==="modifiers"){n.modifiers?.[a]||r.push({path:t,message:u.RESOLVER.UNDEFINED_MODIFIER(a)});return}r.push({path:t,message:u.RESOLVER.INVALID_REFERENCE(e)})}s(Ut,"validateReference");function U(){return{version:"2025.10",resolutionOrder:[]}}s(U,"createEmptyDocument");function Re(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.version==="2025.10"&&Array.isArray(t.resolutionOrder)}s(Re,"isResolverFormat");function De(e,t){return{document:e,basePath:t,visitedRefs:new Set,fileCache:new Map}}s(De,"createResolveContext");async function _e(e,t){if(t.visitedRefs.has(e))return S({},u.RESOLVER.CIRCULAR_REFERENCE(e),e);t.visitedRefs.add(e);try{return e.startsWith("#/")?Gt(e,t):e.includes("#/")?await Bt(e,t):await Wt(e,t)}finally{t.visitedRefs.delete(e)}}s(_e,"resolveReference");function Gt(e,t){const n=e.slice(2),[r,o]=n.split("/");if(!r||!o||n.split("/").length!==2)return S({sources:[]},u.RESOLVER.INVALID_REFERENCE(e));if(r==="sets"){const i=t.document.sets?.[o];return i?{content:i,sourcePath:"#",errors:[]}:S({sources:[]},u.RESOLVER.UNDEFINED_SET(o))}if(r==="modifiers"){const i=t.document.modifiers?.[o];return i?{content:i,sourcePath:"#",errors:[]}:S({contexts:{}},u.RESOLVER.UNDEFINED_MODIFIER(o))}return S({sources:[]},u.RESOLVER.INVALID_REFERENCE(e))}s(Gt,"resolveSameDocumentRef");async function Wt(e,t){const n=D(e)?e:T(t.basePath,e),r=t.fileCache.get(n);if(r)return Re(r)?S({},u.RESOLVER.RESOLVER_AS_TOKEN_SOURCE(n),n):{content:r,sourcePath:n,errors:[]};const o=await Le(n);return o.error?S({},o.error,n):Re(o.content)?S({},u.RESOLVER.RESOLVER_AS_TOKEN_SOURCE(n),n):(t.fileCache.set(n,o.content),{content:o.content,sourcePath:n,errors:[]})}s(Wt,"resolveFileRef");async function Bt(e,t){const[n="",r=""]=e.split("#"),o=D(n)?n:T(t.basePath,n);let i=t.fileCache.get(o);if(!i){const f=await Le(o);if(f.error)return S({},f.error,o);i=f.content,t.fileCache.set(o,i)}const a=r.startsWith("/")?r:`/${r}`,c=Yt(i,a);return c.error?S({},u.RESOLVER.INVALID_JSON_POINTER(a,c.error),o):{content:c.value,sourcePath:o,errors:[]}}s(Bt,"resolveFileFragmentRef");async function Le(e){try{const t=await ee(e,"utf-8");return{content:JSON.parse(t)}}catch(t){if(t.code==="ENOENT")return{error:u.RESOLVER.EXTERNAL_FILE_NOT_FOUND(e)};const n=t instanceof Error?t.message:"Unknown error";return{error:u.RESOLVER.EXTERNAL_FILE_ERROR(e,n)}}}s(Le,"loadJsonFile");function Yt(e,t){if(t===""||t==="/")return{value:e};const n=t.slice(1).split("/").map(o=>o.replace(/~1/g,"/").replace(/~0/g,"~"));let r=e;for(const o of n){if(r===null||typeof r!="object")return{error:"cannot navigate into non-object"};if(Array.isArray(r)){const a=Number.parseInt(o,10);if(Number.isNaN(a)||a<0||a>=r.length)return{error:`invalid array index "${o}"`};r=r[a];continue}const i=r;if(!(o in i))return{error:`property "${o}" not found`};r=i[o]}return{value:r}}s(Yt,"resolveJsonPointer");async function ve(e,t){const n=[],r=[];for(const o of e){if(!O(o)){n.push(o);continue}const i=await _e(o.$ref,t);r.push(...i.errors),i.errors.length===0&&n.push(Kt(i.content,o))}return{resolved:n,errors:r}}s(ve,"resolveSources");function Kt(e,t){const{$ref:n,...r}=t;return Object.keys(r).length===0?e:{...e,...r}}s(Kt,"applyExtending");function S(e,t,n="#"){return{content:e,sourcePath:n,errors:[{path:n,message:t}]}}s(S,"errorResult");function xe(e){return typeof e=="object"&&e!==null&&"$value"in e}s(xe,"isToken");function G(e,t){const n={...e};for(const[r,o]of Object.entries(t)){if(o===void 0)continue;if(r.startsWith("$")){n[r]=o;continue}if(xe(o)){n[r]=o;continue}const i=n[r],a=i!==void 0&&typeof i=="object"&&i!==null&&typeof o=="object"&&o!==null&&!xe(i);n[r]=a?G(i,o):o}return n}s(G,"deepMerge");function Ce(e){const t=[],n=new Set;for(const r of e.resolutionOrder){const o=Ht(r,e,n);o&&(t.push(o),n.add(o.name))}return t}s(Ce,"extractModifiers");function Ht(e,t,n){return O(e)&&e.$ref.startsWith("#/modifiers/")?qt(e.$ref,t,n):_(e)?zt(e,n):null}s(Ht,"extractModifierFromItem");function qt(e,t,n){const r=e.split("/")[2];if(!r||n.has(r))return null;const o=t.modifiers?.[r];return o?{name:r,contexts:Object.keys(o.contexts),default:o.default}:null}s(qt,"extractReferencedModifier");function zt(e,t){return t.has(e.name)?null:{name:e.name,contexts:Object.keys(e.contexts),default:e.default}}s(zt,"extractInlineModifier");function Jt(e,t={}){const n=[],r={},o=Ce(e);if(o.length===0)return Xt(t,n),{valid:n.length===0,errors:n,resolvedInputs:r};const i=new Map(o.map(a=>[a.name,a]));return Zt(t,i,n,r),Qt(o,r,n),{valid:n.length===0,errors:n,resolvedInputs:r}}s(Jt,"validateInputs$1");function Xt(e,t){for(const n of Object.keys(e))t.push({modifier:n,message:u.RESOLVER.UNKNOWN_MODIFIER(n)})}s(Xt,"validateNoModifiersCase");function Zt(e,t,n,r){for(const[o,i]of Object.entries(e)){const a=t.get(o);if(!a){n.push({modifier:o,message:u.RESOLVER.UNKNOWN_MODIFIER(o)});continue}if(typeof i!="string"){n.push({modifier:o,message:u.RESOLVER.INVALID_INPUT_TYPE(o)});continue}if(!a.contexts.includes(i)){n.push({modifier:o,message:u.RESOLVER.INVALID_CONTEXT(i,o,a.contexts)});continue}r[o]=i}}s(Zt,"validateProvidedInputs");function Qt(e,t,n){for(const r of e)t[r.name]===void 0&&(r.default!==void 0?t[r.name]=r.default:n.push({modifier:r.name,message:u.RESOLVER.MISSING_REQUIRED_INPUT(r.name)}))}s(Qt,"applyDefaults");async function Fe(e,t,n={}){const r=Jt(e,n);if(!r.valid)return{tokens:{},sources:[],errors:r.errors.map(a=>({path:a.modifier||"inputs",message:a.message}))};const o=De(e,t),i=en();for(const a of e.resolutionOrder)await tn(a,e,o,r.resolvedInputs,i);return{tokens:i.tokens,sources:i.sources,errors:i.errors}}s(Fe,"processResolutionOrder");function en(){return{tokens:{},sources:[],errors:[]}}s(en,"createProcessingState");async function tn(e,t,n,r,o){if(O(e)){await nn(e,t,n,r,o);return}if(se(e)){await rn(e,n,o);return}_(e)&&await on(e,n,r,o)}s(tn,"processItem");async function nn(e,t,n,r,o){const i=await _e(e.$ref,n);if(i.errors.length>0){o.errors.push(...i.errors);return}const a=e.$ref.split("/")[2];if(a){if(e.$ref.startsWith("#/sets/")){const c=await W(i.content.sources,n,{type:"set",name:a});B(c,o);return}if(e.$ref.startsWith("#/modifiers/")){const c=r[a];if(!c)return;const p=i.content.contexts[c];if(!p)return;const m=await W(p,n,{type:"modifier",name:a,context:c});B(m,o)}}}s(nn,"processReference");async function rn(e,t,n){const r=await W(e.sources,t,{type:"set",name:e.name});B(r,n)}s(rn,"processInlineSet");async function on(e,t,n,r){const o=n[e.name];if(!o)return;const i=e.contexts[o];if(!i)return;const a=await W(i,t,{type:"modifier",name:e.name,context:o});B(a,r)}s(on,"processInlineModifier");async function W(e,t,n){const r=await ve(e,t);let o={};for(const i of r.resolved)o=G(o,i);return{tokens:o,source:{path:"#",...n},errors:r.errors}}s(W,"mergeSources");function B(e,t){t.errors.push(...e.errors),t.tokens=G(t.tokens,e.tokens),t.sources.push(e.source)}s(B,"applyResult");async function sn(e,t){const n=[],r=De(e,t),o=Ce(e),i={};for(const p of o)p.default&&(i[p.name]=p.default);const a=await Fe(e,t,i);n.push(...a.errors);const c=a.tokens,f=[];for(const p of o){const m=new Map,d=p.default??p.contexts[0]??"default";for(const I of p.contexts){if(I===d)continue;const E=await an(e,t,r,p.name,I,n);Object.keys(E).length>0&&m.set(I,E)}f.push({name:p.name,defaultContext:d,contexts:m})}return{base:c,modifiers:f,errors:n}}s(sn,"processForLayeredCSS");async function an(e,t,n,r,o,i){const a=cn(e,r);if(!a)return{};const c=a.contexts[o];if(!c||c.length===0)return{};const f=await ve(c,n);i.push(...f.errors.map(E=>({path:E.path,message:E.message})));let p={};for(const E of f.resolved)p=G(p,E);const m=new Set;Ve(p,"",m);const d=await Fe(e,t,{[r]:o});i.push(...d.errors);const I=structuredClone(p);for(const E of m){const $=un(d.tokens,E);$!==void 0&&fn(I,E,$)}return I}s(an,"processModifierContext");function cn(e,t){if(e.modifiers?.[t])return e.modifiers[t];for(const n of e.resolutionOrder)if(_(n)&&n.name===t)return n}s(cn,"findModifierDefinition");function Ve(e,t,n){for(const[r,o]of Object.entries(e)){if(r.startsWith("$"))continue;const i=t?`${t}.${r}`:r;o&&typeof o=="object"&&"$value"in o?n.add(i):o&&typeof o=="object"&&Ve(o,i,n)}}s(Ve,"collectTokenPaths");function un(e,t){const n=t.split(".");let r=e;for(const o of n){if(r===null||typeof r!="object")return;r=r[o]}return r}s(un,"getTokenAtPath");function fn(e,t,n){const r=t.split(".");let o=e;for(let a=0;a<r.length-1;a++){const c=r[a];if(!c)continue;const f=o[c];if(!f||typeof f!="object")return;o=f}const i=r[r.length-1];i&&(o[i]=n)}s(fn,"updateTokenAtPath");async function ln(e){const t=D(e)?e:T(process.cwd(),e),n=w(t),r=[],o=[],i=V(process.cwd(),t),a=await Ct(t);if(a.errors.length>0)return{trees:[],modifiers:[],errors:a.errors.map(p=>({file:p.path,message:p.message}))};const c=await sn(a.document,n);for(const p of c.errors)r.push({file:p.path,message:p.message});Object.keys(c.base).length>0&&o.push({context:void 0,tokens:c.base,sourcePath:i});const f=[];for(const p of c.modifiers){const m=[];for(const[d,I]of p.contexts)Object.keys(I).length>0&&(o.push({context:`${p.name}:${d}`,tokens:I,sourcePath:i}),m.push(d));f.push({name:p.name,attribute:`data-${p.name}`,defaultContext:p.defaultContext,contexts:m})}return{trees:o,modifiers:f,errors:r}}s(ln,"loadFromResolver");async function pn(e){const t=[],n=[],r=Object.entries(e);r.sort(([,o],[,i])=>{const a=!o.context,c=!i.context;return a&&!c?-1:!a&&c?1:0});for(const[o,{context:i,content:a}]of r)try{const c=JSON.parse(a);t.push({context:i,tokens:c,sourcePath:V(process.cwd(),o)})}catch(c){c instanceof Error?c instanceof SyntaxError?n.push({file:o,message:u.LOAD.INVALID_JSON(o,c.message)}):n.push({file:o,message:c.message}):n.push({file:o,message:"Unknown error"})}return{trees:t,errors:n}}s(pn,"loadTreesFromMemory");function Y(e,t,n,r){return typeof t=="string"&&h(t)?mn(e,t,n,r):Array.isArray(t)?t.map(o=>Y(e,o,n,r)):typeof t=="object"&&t!==null?Object.entries(t).reduce((i,[a,c])=>Object.assign(i,{[a]:Y(`${e}.${a}`,c,n,r)}),{}):t}s(Y,"resolveValue");function we(e,t){const n=e.slice(1,-1),r=t.pathIndex.get(n);if(!r)return;const o=t.tokens[r];if(!(!o||!("$value"in o))){if(o.$type)return o.$type;if(typeof o.$value=="string"&&h(o.$value))return we(o.$value,t)}}s(we,"inferTypeFromReference");function dn(e){const t={},n=new Set,r=[];for(const[o,i]of Object.entries(e.tokens))try{if(!("$value"in i)){t[o]=i;continue}const a=i;let c=a.$type;!c&&typeof a.$value=="string"&&h(a.$value)&&(c=we(a.$value,e)),t[o]={...a,...c?{$type:c}:{},$resolvedValue:Y(a.$path,a.$value,e,n)}}catch(a){const c=a instanceof Error?a.message:String(a),f=i,p=f.$path,m=f.$source;let d,I;c.includes("Circular reference detected")?(d="circular",I=c):c.includes("Reference not found")?(d="missing",I=c):(d="type-mismatch",I=u.RESOLVE.TYPE_MISMATCH(p)),r.push({type:d,path:p,source:m,message:I})}return{resolved:t,errors:r}}s(dn,"resolve");function mn(e,t,n,r){const o=t.slice(1,-1),i=n.pathIndex.get(o);if(!i)throw new Error(u.RESOLVE.REFERENCE_NOT_FOUND(o,e));if(r.has(i)){const f=n.tokens[i];throw!f||!("$path"in f)?new Error(u.RESOLVE.REFERENCE_NOT_FOUND(o,e)):new Error(u.RESOLVE.CIRCULAR_REFERENCE(e,f.$path))}const a=n.tokens[i];if(!a||!("$value"in a))throw new Error(u.RESOLVE.REFERENCE_NOT_FOUND(o,e));r.add(i);const c=Y(i,a.$value,n,r);return r.delete(i),c}s(mn,"resolveReferenceChain");function b(e){return{success:!0,value:e}}s(b,"success");function g(e){return{success:!1,error:e}}s(g,"error");function L(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(r=>typeof r=="number"||r==="none")||t.alpha!==void 0&&typeof t.alpha!="number"||t.hex!==void 0&&typeof t.hex!="string")}s(L,"isDTCGColorValue");function K(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((r,o)=>{r!=="none"&&(typeof r!="number"||!Number.isFinite(r))&&t.push(`Component ${o} must be a finite number or "none".`)}),e.colorSpace==="oklch"){const[r,o,i]=e.components;r!=="none"&&(r<0||r>1)&&t.push("OKLCH Lightness (L) must be between 0 and 1 or 'none'."),o!=="none"&&o<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[r,o,i]=e.components;r!=="none"&&(r<0||r>1)&&t.push("Display P3 Red component must be between 0 and 1 or 'none'."),o!=="none"&&(o<0||o>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[r,o,i]=e.components;r!=="none"&&(r<0||r>1)&&t.push("sRGB Red component must be between 0 and 1 or 'none'."),o!=="none"&&(o<0||o>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[r,o,i]=e.components;r!=="none"&&(r<0||r>=360)&&t.push("HSL Hue must be between 0 and 360 (exclusive) or 'none'."),o!=="none"&&(o<0||o>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(K,"validateDTCGColorValue");function hn(e){const t=K(e);return t.length>0?g(t.join(", ")):b(e)}s(hn,"validateDTCGColorValueResult");function In(e){const t=hn(e);if(!t.success)return t;const[n,r,o]=e.components,i=e.alpha,a=n==="none"?"none":Number(n.toFixed(4)),c=r==="none"?"none":Number(r.toFixed(4)),f=o==="none"?"none":Number(o.toFixed(4));if(i!==void 0&&i!==1){const p=Number(i.toFixed(4));return b(`oklch(${a} ${c} ${f} / ${p})`)}return b(`oklch(${a} ${c} ${f})`)}s(In,"formatDTCGColorToOKLCH");const En={isObject:s(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObject")};function y(e,t,n,r){if(h(t))return[];switch(e.type){case"object":return $n(e,t,n,r);case"union":return gn(e,t,n,r);case"array":return Nn(e,t,n,r);default:return yn(e,t,n,r)}}s(y,"validateSchema");function yn(e,t,n,r){return e.type!==typeof t?[{path:n,message:e.errorMessage?.(t,n)||u.VALIDATE.INVALID_TYPE(e.type,t,n),source:r}]:e.validate?.(t,n,r)??[]}s(yn,"validateSimpleValue");function $n(e,t,n,r){if(!En.isObject(t))return[{path:n,message:e.errorMessage?.(t,n)||u.VALIDATE.INVALID_TYPE("object",t,n),source:r}];const o=[],i=t;if(e.required)for(const a of e.required)a in i||o.push({path:`${n}.${a}`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY(a,n),source:r});for(const[a,c]of Object.entries(e.properties))a in i&&o.push(...y(c,i[a],`${n}.${a}`,r));return o}s($n,"validateObject");function gn(e,t,n,r){let o=[],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=y(a,t,n,r);if(c.length===0)return a.validate?.(t,n,r)??[];c.length<i&&(o=c,i=c.length)}return i===Number.POSITIVE_INFINITY?[{path:n,message:u.VALIDATE.INVALID_TYPE(e.oneOf.map(a=>a.type).join(" or "),t,n),source:r}]:o}s(gn,"validateUnion");function Nn(e,t,n,r){return Array.isArray(t)?e.validate?.(t,n,r)??[]:[{path:n,message:e.errorMessage?.(t,n)||u.VALIDATE.INVALID_TYPE("array",t,n),source:r}]}s(Nn,"validateArray");const H={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:u.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)=>L(e)?K(e).map(o=>({path:t,message:`Invalid color at ${t}: ${o}`,source:n})):[{path:t,message:u.VALIDATE.INVALID_COLOR(e,t),source:n}],"validate")}]}};function Sn(e,t,n){return y(H.schema,e,t,n)}s(Sn,"validateColor");const q={schema:{type:"number",errorMessage:s((e,t)=>u.VALIDATE.INVALID_NUMBER(e,t),"errorMessage"),validate:s((e,t,n)=>typeof e!="number"||Number.isNaN(e)?[{path:t,message:u.VALIDATE.INVALID_NUMBER(e,t),source:n}]:[],"validate")}};function bn(e,t,n){return y(q.schema,e,t,n)}s(bn,"validateNumber");const N={schema:{type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_DIMENSION(e,t),"errorMessage"),properties:{value:q.schema,unit:{type:"string",validate:s((e,t,n)=>typeof e!="string"||!["px","rem"].includes(e)?[{path:t,message:u.VALIDATE.INVALID_DIMENSION_UNIT(e,t),source:n}]:[],"validate")}},required:["value","unit"]}};function Tn(e,t,n){return y(N.schema,e,t,n)}s(Tn,"validateDimension");const On=["solid","dashed","dotted","double","groove","ridge","outset","inset"],An=["round","butt","square"],Rn={type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_STROKE_STYLE(e,t),"errorMessage"),properties:{dashArray:{type:"array",validate:s((e,t,n)=>{const r=e,o=[];return r.forEach((i,a)=>{typeof i!="string"&&o.push(...y(N.schema,i,`${t}.${a}`,n))}),o},"validate")},lineCap:{type:"string",validate:s((e,t,n)=>An.includes(e)?[]:[{path:t,message:u.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)=>!On.includes(e)&&typeof e=="string"?[{path:t,message:u.VALIDATE.INVALID_STROKE_STYLE(e,t),source:n}]:[],"validate")},Rn]}};function Dn(e,t,n){return y(ke.schema,e,t,n)}s(Dn,"validateStrokeStyle");const _n={schema:{type:"object",properties:{color:H.schema,width:N.schema,style:ke.schema},required:["color","width","style"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_BORDER(e,t),"errorMessage")}};function Ln(e,t,n){return y(_n.schema,e,t,n)}s(Ln,"validateBorder");const Me={schema:{type:"array",errorMessage:s((e,t)=>u.VALIDATE.INVALID_CUBIC_BEZIER(e,t),"errorMessage"),validate:s((e,t,n)=>{const r=e;if(r.length!==4||!r.every(a=>typeof a=="number"))return[{path:t,message:u.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}];const[o,,i]=r;return o<0||o>1||i<0||i>1?[{path:t,message:u.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}]:[]},"validate")}};function vn(e,t,n){return y(Me.schema,e,t,n)}s(vn,"validateCubicBezier");const xn=["ms","s"],ce={schema:{type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_DURATION(e,t),"errorMessage"),properties:{value:q.schema,unit:{type:"string",validate:s((e,t,n)=>xn.includes(e)?[]:[{path:t,message:u.VALIDATE.INVALID_DURATION_UNIT(e,t),source:n}],"validate")}},required:["value","unit"]}};function Cn(e,t,n){return y(ce.schema,e,t,n)}s(Cn,"validateDuration");const Fn={schema:{type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FLUID_DIMENSION(e,t),"errorMessage"),properties:{min:N.schema,max:N.schema},required:["min","max"]}};function Vn(e,t,n){return y(Fn.schema,e,t,n)}s(Vn,"validateFluidDimension");const Pe={schema:{type:"union",oneOf:[{type:"string",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")},{type:"array",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage"),validate:s((e,t,n)=>e.every(o=>typeof o=="string")?[]:[{path:t,message:u.VALIDATE.INVALID_FONT_FAMILY(e,t),source:n}],"validate")}],errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")}};function wn(e,t,n){return y(Pe.schema,e,t,n)}s(wn,"validateFontFamily");const kn=["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"],je={schema:{type:"union",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),oneOf:[{type:"number",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>e<1||e>1e3?[{path:t,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}]:[],"validate")},{type:"string",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>kn.includes(e.toLowerCase())?[]:[{path:t,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}],"validate")}]}};function Mn(e,t,n){return y(je.schema,e,t,n)}s(Mn,"validateFontWeight");const Pn={type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_GRADIENT(e,t),"errorMessage"),properties:{color:H.schema,position:{type:"number",validate:s((e,t,n)=>e<0||e>1?[{path:t,message:u.VALIDATE.INVALID_GRADIENT_STOP_POSITION(e,t),source:n}]:[],"validate")}},required:["color","position"]},jn={schema:{type:"array",errorMessage:s((e,t)=>u.VALIDATE.INVALID_ARRAY(e,t),"errorMessage"),validate:s((e,t,n)=>{const r=e,o=[];return r.forEach((i,a)=>{o.push(...y(Pn,i,`${t}[${a}]`,n))}),o},"validate")}};function Un(e,t,n){return y(jn.schema,e,t,n)}s(Un,"validateGradient");const Ue={schema:{type:"object",properties:{color:{type:"union",oneOf:[H.schema]},offsetX:N.schema,offsetY:N.schema,blur:N.schema,spread:N.schema,inset:{type:"boolean",errorMessage:s((e,t)=>u.VALIDATE.INVALID_SHADOW_INSET(e,t),"errorMessage")}},required:["color","offsetX","offsetY","blur","spread"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_SHADOW(e,t),"errorMessage")}};function Gn(e,t,n){const r=[];return Array.isArray(e)?(e.forEach((o,i)=>{r.push(...y(Ue.schema,o,`${t}[${i}]`,n))}),r):y(Ue.schema,e,t,n)}s(Gn,"validateShadow");const Wn={schema:{type:"object",properties:{duration:ce.schema,delay:ce.schema,timingFunction:Me.schema},required:["duration","delay","timingFunction"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_TRANSITION(e,t),"errorMessage")}};function Bn(e,t,n){return y(Wn.schema,e,t,n)}s(Bn,"validateTransition");const Yn={schema:{type:"object",properties:{fontFamily:Pe.schema,fontSize:N.schema,letterSpacing:N.schema,lineHeight:q.schema,fontWeight:je.schema},required:["fontFamily","fontSize"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_TYPOGRAPHY(e,t),"errorMessage")}};function Kn(e,t,n){return y(Yn.schema,e,t,n)}s(Kn,"validateTypography");const Hn={color:Sn,dimension:Tn,fluidDimension:Vn,duration:Cn,cubicBezier:vn,fontFamily:wn,fontWeight:Mn,number:bn,strokeStyle:Dn,typography:Kn,border:Ln,shadow:Gn,gradient:Un,transition:Bn};function qn(e){const t=[];for(const[n,r]of Object.entries(e.tokens)){if(typeof r!="object"||r===null||!("$type"in r)||!("$path"in r)||r.$path.startsWith("$"))continue;if(!("$value"in r)){t.push({path:r.$path,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("$value",r.$path),source:r.$source});continue}const o=Hn[r.$type];if(!o){t.push({path:r.$path,message:u.VALIDATE.UNKNOWN_TOKEN_TYPE(r.$type,r.$path),source:r.$source});continue}const i=r;t.push(...o(i.$value,i.$path,i.$source))}return t}s(qn,"validate");async function zn(e){const{trees:t,modifiers:n,errors:r}=await Jn(e),{tokens:o,errors:i}=Tt(t),a=qn(o),{resolved:c,errors:f}=dn(o);return{trees:t,resolved:c,modifiers:n,errors:{load:r,flatten:i,validation:a,resolution:f}}}s(zn,"loadAndResolveTokens");async function Jn(e){switch(e.type){case"memory":{const t=await pn(e.data);return{trees:t.trees,modifiers:[],errors:t.errors}}case"resolver":{const t=await ln(e.resolverPath);return{trees:t.trees,modifiers:t.modifiers,errors:t.errors}}}}s(Jn,"loadTokens");function x(e,t="native"){return L(e)?Xn(e):b(e)}s(x,"convertColorToString");function Xn(e){switch(e.colorSpace){case"oklch":return In(e);case"display-p3":return Zn(e);case"srgb":return Qn(e);case"hsl":return er(e);default:return g(`Unsupported color space: ${e.colorSpace}. Supported color spaces: oklch, display-p3, srgb, hsl.`)}}s(Xn,"formatDTCGColorNative");function Zn(e){if(e.colorSpace!=="display-p3")return g(`Expected display-p3 color space, got: ${e.colorSpace}`);if(!Array.isArray(e.components)||e.components.length!==3)return g("Display P3 components must be an array of exactly 3 numbers [R, G, B]");const[t,n,r]=e.components,o=e.alpha;if(t!=="none"&&(t<0||t>1))return g("Display P3 Red component must be between 0 and 1 or 'none'");if(n!=="none"&&(n<0||n>1))return g("Display P3 Green component must be between 0 and 1 or 'none'");if(r!=="none"&&(r<0||r>1))return g("Display P3 Blue component must be between 0 and 1 or 'none'");if(o!==void 0&&(o<0||o>1))return g("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=r==="none"?"none":Number(r.toFixed(4));if(o!==void 0&&o!==1){const f=Number(o.toFixed(4));return b(`color(display-p3 ${i} ${a} ${c} / ${f})`)}return b(`color(display-p3 ${i} ${a} ${c})`)}s(Zn,"formatDTCGColorToP3");function Qn(e){if(e.colorSpace!=="srgb")return g(`Expected srgb color space, got: ${e.colorSpace}`);const t=K(e);if(t.length>0)return g(`Invalid DTCG color value: ${t.join(", ")}`);const[n,r,o]=e.components,i=e.alpha,a=n==="none"?"none":Math.round(n*255),c=r==="none"?"none":Math.round(r*255),f=o==="none"?"none":Math.round(o*255);if(i!==void 0&&i!==1){const p=Number(i.toFixed(4));return b(`rgb(${a} ${c} ${f} / ${p})`)}return b(`rgb(${a} ${c} ${f})`)}s(Qn,"formatDTCGColorToRGB");function er(e){if(e.colorSpace!=="hsl")return g(`Expected hsl color space, got: ${e.colorSpace}`);const t=K(e);if(t.length>0)return g(`Invalid DTCG color value: ${t.join(", ")}`);const[n,r,o]=e.components,i=e.alpha,a=n==="none"?"none":Number(n.toFixed(1)),c=r==="none"?"none":Math.round(r),f=o==="none"?"none":Math.round(o);if(i!==void 0&&i!==1){const d=Number(i.toFixed(4)),I=c==="none"?"none":`${c}%`,E=f==="none"?"none":`${f}%`;return b(`hsl(${a} ${I} ${E} / ${d})`)}const p=c==="none"?"none":`${c}%`,m=f==="none"?"none":`${f}%`;return b(`hsl(${a} ${p} ${m})`)}s(er,"formatDTCGColorToHSL");function Ge(e){return h(e)?{value:e}:typeof e=="string"?{value:e}:{value:`${e.dashArray.map(n=>h(n)?n:`${n.value}${n.unit}`).join(" ")} ${e.lineCap}`}}s(Ge,"convertStrokeStyleToken");function tr(e,t){if(h(e))return e;if(L(e)){const n=x(e,t.colorFallbackStrategy);if(!n.success)throw new Error(u.CONVERT.COLOR_CONVERSION_FAILED(n.error));return n.value}return e}s(tr,"convertBorderColor");function nr(e,t){if(h(e))return{value:e};const n=h(e.width)?e.width:`${e.width.value}${e.width.unit}`,r=tr(e.color,t),o=typeof e.style=="string"?e.style:Ge(e.style).value;return{value:`${n} ${o} ${r}`}}s(nr,"convertBorderToken");function rr(e,t){if(typeof e=="string"&&h(e))return{value:e};const n=t.colorFallbackStrategy;if(L(e))return or(e,n);const r=x(e,n);if(!r.success)throw new Error(u.CONVERT.COLOR_CONVERSION_FAILED(r.error));return{value:r.value}}s(rr,"convertColorToken");function or(e,t){const n=x(e,t);if(!n.success)throw new Error(u.CONVERT.COLOR_CONVERSION_FAILED(n.error));const r=n.value;if(t==="native")return{value:r};if(e.colorSpace==="srgb"||e.colorSpace==="hsl")return{value:r};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:sr(e.colorSpace),value:r}]}}s(or,"convertDTCGColorToken");function sr(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(sr,"getFeatureQuery");function ir(e){return h(e)?{value:e}:{value:`cubic-bezier(${e.join(", ")})`}}s(ir,"convertCubicBezierToken");function ar(e){return h(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(ar,"convertDimensionToken");function cr(e){return h(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(cr,"convertDurationToken");function We(e,t=16){return e.unit==="px"?e.value:e.value*t}s(We,"normalizeToPixels");function ur(e,t){const{min:n,max:r}=e,o=t.fluidConfig,i=16,a=We(n,i),c=We(r,i),f=o.min,p=o.max;if(a===c)return{value:`${a/i}rem`};const m=a/i,d=c/i,I=f/i,E=p/i,$=(d-m)/(E-I),de=-1*I*$+m;return{value:`clamp(${m}rem, ${de.toFixed(2)}rem + ${($*100).toFixed(2)}vw, ${d}rem)`}}s(ur,"convertFluidDimension");function fr(e,t){return h(e)?{value:e}:ur(e,t)}s(fr,"convertFluidDimensionToken");function z(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(z,"quoteFont");function lr(e){return h(e)?{value:e}:{value:Array.isArray(e)?e.map(n=>z(n)).join(", "):z(e)}}s(lr,"convertFontFamilyToken");const pr={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 Be(e){return h(e)?{value:e}:typeof e=="number"?{value:e}:{value:pr[e.toLowerCase()]??e}}s(Be,"convertFontWeightToken");function dr(e,t){if(h(e))return e;if(L(e)){const n=x(e,t.colorFallbackStrategy);if(!n.success)throw new Error(u.CONVERT.COLOR_CONVERSION_FAILED(n.error));return n.value}return e}s(dr,"convertGradientColor");function mr(e){return Math.max(0,Math.min(1,e))}s(mr,"clampPosition");function hr(e){return h(e)?`${e}%`:`${mr(e)*100}%`}s(hr,"convertGradientPosition");function Ir(e,t){const n=dr(e.color,t),r=hr(e.position);return`${n} ${r}`}s(Ir,"convertSingleStop");function Ye(e){const t=[];for(const n of e)Array.isArray(n)?t.push(...Ye(n)):t.push(n);return t}s(Ye,"flattenStops");function Er(e,t){return h(e)?{value:e}:{value:`linear-gradient(${Ye(e).map(o=>Ir(o,t)).join(", ")})`}}s(Er,"convertGradientToken");function yr(e){return h(e)?{value:e}:{value:e}}s(yr,"convertNumberToken");function $r(e,t){if(h(e))return e;if(L(e)){const n=x(e,t.colorFallbackStrategy);if(!n.success)throw new Error(u.CONVERT.COLOR_CONVERSION_FAILED(n.error));return n.value}return e}s($r,"convertShadowColor");function Ke(e,t){const n=h(e.offsetX)?e.offsetX:`${e.offsetX.value}${e.offsetX.unit}`,r=h(e.offsetY)?e.offsetY:`${e.offsetY.value}${e.offsetY.unit}`,o=h(e.blur)?e.blur:`${e.blur.value}${e.blur.unit}`,i=h(e.spread)?e.spread:`${e.spread.value}${e.spread.unit}`,a=$r(e.color,t);return`${e.inset?"inset ":""}${n} ${r} ${o} ${i} ${a}`}s(Ke,"convertSingleShadow");function gr(e,t){return h(e)?{value:e}:Array.isArray(e)?{value:e.map(n=>Ke(n,t)).join(", ")}:{value:Ke(e,t)}}s(gr,"convertShadowToken");function He(e){return e?`${e.value}${e.unit}`:"0ms"}s(He,"formatDuration");function Nr(e){if(h(e))return{value:e};const t=h(e.duration)?e.duration:He(e.duration),n=h(e.timingFunction)?e.timingFunction:`cubic-bezier(${e.timingFunction.join(", ")})`,r=e.delay&&(h(e.delay)?e.delay:He(e.delay));return{value:[t,n,r].filter(Boolean).join(" ")}}s(Nr,"convertTransitionToken");function Sr(e){if(h(e))return{"font-family":e,"font-size":e};const t={"font-family":h(e.fontFamily)?e.fontFamily:Array.isArray(e.fontFamily)?e.fontFamily.map(n=>z(n)).join(", "):z(e.fontFamily),"font-size":h(e.fontSize)?e.fontSize:`${e.fontSize.value}${e.fontSize.unit}`};return e.fontWeight&&(t["font-weight"]=h(e.fontWeight)?e.fontWeight:Be(e.fontWeight).value),e.letterSpacing&&(t["letter-spacing"]=h(e.letterSpacing)?e.letterSpacing:`${e.letterSpacing.value}${e.letterSpacing.unit}`),e.lineHeight&&(t["line-height"]=(h(e.lineHeight),e.lineHeight)),t}s(Sr,"convertTypographyToken");const qe={duration:cr,number:yr,cubicBezier:ir,color:rr,dimension:ar,fluidDimension:fr,typography:Sr,border:nr,shadow:gr,gradient:Er,transition:Nr,strokeStyle:Ge,fontFamily:lr,fontWeight:Be};function br(e,t){const n=qe[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(br,"convertSingleToken");function Tr(e,t,n){const r={};for(const[o,i]of Object.entries(e)){if(!i||typeof i!="object")continue;if(!("$type"in i)){r[o]={...i.$description?{$description:i.$description}:{},...i.$extensions?{$extensions:i.$extensions}:{}};continue}if(n?.(i.$path)||!qe[i.$type])continue;const a={fluidConfig:t.transforms.fluid,colorFallbackStrategy:t.transforms.colorFallbackStrategy,path:i.$path,resolvedTokens:e};r[o]=br(i,a)}return r}s(Tr,"convertTokens");function Or(e,t,n){const r={};for(const[o,i]of Object.entries(e))r[o]=Tr(i,t,n);return r}s(Or,"convert");function Ar(e,t){const n={},r=new Set;for(const o of e){const i=o.context??"default";r.add(i)}for(const o of r)n[o]={};for(const o of e){const{context:i,tokens:a}=o,c=i??"default";n[c]||(n[c]={});for(const[f,p]of Object.entries(a))n[c][f]=p}return{tokens:n,defaultContext:t}}s(Ar,"normalizeTokens");function Rr(e,t){const n=new Map;for(const[r,o]of Object.entries(t)){if(!("$source"in o)){for(const c of e){const f=c.context??"";n.has(f)||n.set(f,{});const p=n.get(f);p&&(p[r]=o)}continue}const i=o.$source.context??"";n.has(i)||n.set(i,{});const a=n.get(i);a&&(a[r]=o)}return e.map(r=>{const o=r.context??"",i=n.get(o)||{};return{context:r.context,tokens:i}})}s(Rr,"processTrees");async function Dr(e,t,n,r){const o=Rr(e,t),{tokens:i}=Ar(o);return Or(i,n,r?f=>r.some(p=>p.path===f||p.path.startsWith(`${f}.`)):void 0)}s(Dr,"processAndConvertTokens");function _r(e){return Object.entries(e).sort(([t],[n])=>t.localeCompare(n))}s(_r,"deterministicEntries");const ze=new Map;function Lr(e){const t=ze.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 ze.set(e,n),n}s(Lr,"toKebabCase");function ue(e){return e.split(".").join("-")}s(ue,"formatCSSVarPath");function fe(e){if(typeof e=="number")return e;if(typeof e!="string")throw new Error(u.GENERATE.INVALID_CSS_VALUE_TYPE(typeof e));return e.replace(/\{([^}]+)\}/g,(t,n)=>`var(--${n.split(".").map(Lr).join("-")})`)}s(fe,"convertReferenceToCSSVar");function vr(e){const t=e.$cssProperties;if("value"in t)return{name:`--${ue(e.$path)}`,value:fe(t.value)}}s(vr,"generateSingleVariable");function xr(e){return Object.entries(e.$cssProperties).filter(([t,n])=>n!==void 0).map(([t,n])=>({name:`--${ue(e.$path)}-${t}`,value:fe(n)}))}s(xr,"generateTypographyVariables");function Je(e){if(e.$type!=="color")return[];const t=e.$cssProperties;if(!("featureValues"in t))return[];const n=new Map;for(const r of t.featureValues||[]){n.has(r.query)||n.set(r.query,[]);const o=n.get(r.query);o&&o.push({name:`--${ue(e.$path)}`,value:fe(r.value)})}return Array.from(n.entries()).map(([r,o])=>({query:r,vars:o}))}s(Je,"generateFeatureVariables");function Xe(e){const t=[`${e.selector} {`];if(e.comment&&t.push(` /* ${e.comment} */`),e.vars.length>0){const n=e.vars.map(r=>` ${r.name}: ${r.value};`).join(`
12
+ 3. Create a sugarcube.config.ts file`,"NO_CONFIG_OR_RESOLVER")},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"),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"},RESOLVER:{FILE_NOT_FOUND:s(e=>`Cannot read resolver file at "${e}". Please check the path and file permissions.`,"FILE_NOT_FOUND"),INVALID_JSON:s(e=>`Invalid JSON in resolver file: ${e}`,"INVALID_JSON"),INVALID_REFERENCE:s(e=>`Invalid reference "${e}". References must use format #/sets/<name> or #/modifiers/<name>.`,"INVALID_REFERENCE"),INVALID_SOURCE_REFERENCE:s(e=>`Invalid source reference "${e}". Sources can only reference sets (#/sets/<name>), not modifiers.`,"INVALID_SOURCE_REFERENCE"),UNDEFINED_SET:s(e=>`Reference to undefined set "${e}". Define it in the "sets" section first.`,"UNDEFINED_SET"),UNDEFINED_MODIFIER:s(e=>`Reference to undefined modifier "${e}". Define it in the "modifiers" section first.`,"UNDEFINED_MODIFIER"),CIRCULAR_REFERENCE:s(e=>`Circular reference detected at "${e}".`,"CIRCULAR_REFERENCE"),EXTERNAL_FILE_NOT_FOUND:s(e=>`Referenced file not found: ${e}`,"EXTERNAL_FILE_NOT_FOUND"),EXTERNAL_FILE_ERROR:s((e,t)=>`Failed to load "${e}": ${t}`,"EXTERNAL_FILE_ERROR"),INVALID_JSON_POINTER:s((e,t)=>`Invalid JSON pointer "${e}": ${t}`,"INVALID_JSON_POINTER"),DUPLICATE_NAME:s(e=>`Duplicate name "${e}" in resolutionOrder.`,"DUPLICATE_NAME"),MODIFIER_NEEDS_CONTEXTS:"Modifier must have at least one context defined.",MODIFIER_SINGLE_CONTEXT:"Modifier has only one context. Consider using a set instead, or add more contexts.",INVALID_DEFAULT:s((e,t)=>`Default context "${e}" is not defined. Valid contexts: ${t.join(", ")}`,"INVALID_DEFAULT"),UNKNOWN_MODIFIER:s(e=>`Unknown modifier "${e}".`,"UNKNOWN_MODIFIER"),INVALID_CONTEXT:s((e,t,n)=>`Invalid context "${e}" for modifier "${t}". Valid contexts: ${n.join(", ")}`,"INVALID_CONTEXT"),MISSING_REQUIRED_INPUT:s(e=>`Missing required input for modifier "${e}". No default value is defined.`,"MISSING_REQUIRED_INPUT"),INVALID_INPUT_TYPE:s(e=>`Input for modifier "${e}" must be a string.`,"INVALID_INPUT_TYPE"),MALFORMED_REFERENCE:s((e,t)=>`Malformed source reference: { "${e}": "${t}" }. Did you mean { "$ref": "${t}" }?`,"MALFORMED_REFERENCE"),RESOLVER_AS_TOKEN_SOURCE:s(e=>`File "${e}" is a resolver document, not a token file. Resolver documents (version: "2025.10") cannot be used as token sources. Did you mean to reference a specific token file instead?`,"RESOLVER_AS_TOKEN_SOURCE"),PREFERS_COLOR_SCHEME_INVALID_CONTEXTS:s((e,t)=>`Modifier "${e}" uses prefersColorScheme but has invalid contexts: ${t.join(", ")}. Only "light" and "dark" are supported.`,"PREFERS_COLOR_SCHEME_INVALID_CONTEXTS"),PREFERS_COLOR_SCHEME_EMPTY_NON_DEFAULT:s((e,t)=>`Modifier "${e}" uses prefersColorScheme but the "${t}" context has no sources. Since "${t}" is not the default, it needs token sources to generate the @media (prefers-color-scheme: ${t}) rule.`,"PREFERS_COLOR_SCHEME_EMPTY_NON_DEFAULT")}};async function te(e){const n=await ct(["**/*.resolver.json"],{cwd:e,onlyFiles:!0,absolute:!0,ignore:["**/node_modules/**","**/dist/**","**/build/**","**/out/**","**/.git/**","**/.next/**","**/.nuxt/**","**/.astro/**","**/.cache/**","**/.turbo/**","**/.vercel/**","**/.svelte-kit/**"]});if(n.length===0)return{found:"none"};const[r]=n;return n.length===1&&r?{found:"one",path:V(process.cwd(),r)}:{found:"multiple",paths:n.map(o=>V(process.cwd(),o))}}s(te,"findResolverDocument");function ft(e){return Q(Ee(e,"src"))?"src/styles":"styles"}s(ft,"getDefaultCssRoot");function lt(e){return Q(Ee(e,"src"))?"src/components/ui":"components/ui"}s(lt,"getDefaultComponentsDir");function k(e,t=process.cwd()){const n=e.output?.cssRoot??ft(t),r={resolver:e.resolver,transforms:{fluid:e.transforms?.fluid??A.transforms.fluid,colorFallbackStrategy:e.transforms?.colorFallbackStrategy??A.transforms.colorFallbackStrategy},output:{cssRoot:n,variables:e.output?.variables??`${n}/global`,variablesFilename:e.output?.variablesFilename??A.output.variablesFilename,utilities:e.output?.utilities??`${n}/utilities`,utilitiesFilename:e.output?.utilitiesFilename??A.output.utilitiesFilename,cube:e.output?.cube??n,themeAttribute:e.output?.themeAttribute??A.output.themeAttribute,defaultContext:e.output?.defaultContext,layers:e.output?.layers}};return(e.output?.components!==void 0||A.output.components!==void 0)&&(r.output.components=e.output?.components??lt(t)),e.utilities&&(r.utilities=e.utilities),r}s(k,"fillDefaults");const $e=l.object({min:l.number(),max:l.number()}),ye=l.object({source:l.string(),directions:l.union([l.enum(["top","right","bottom","left","x","y","full","all"]),l.array(l.enum(["top","right","bottom","left","x","y","full","all"]))]).optional(),prefix:l.string().optional(),stripDuplicates:l.boolean().optional()}),ge=l.union([ye,l.array(ye)]),Ne=l.object({variables:l.string(),utilities:l.string()}),pt=l.object({resolver:l.string().optional(),transforms:l.object({fluid:$e.optional(),colorFallbackStrategy:l.enum(["native","polyfill"]).optional()}).optional(),output:l.object({cssRoot:l.string().optional(),variables:l.string().optional(),variablesFilename:l.string().optional(),utilities:l.string().optional(),utilitiesFilename:l.string().optional(),cube:l.string().optional(),components:l.string().optional(),themeAttribute:l.string().optional(),defaultContext:l.string().optional(),layers:Ne.optional()}).optional(),utilities:l.record(l.string(),ge).optional()}),dt=l.object({resolver:l.string().optional(),transforms:l.object({fluid:$e,colorFallbackStrategy:l.enum(["native","polyfill"])}),output:l.object({cssRoot:l.string(),variables:l.string().optional(),variablesFilename:l.string(),utilities:l.string().optional(),utilitiesFilename:l.string(),cube:l.string().optional(),components:l.string().optional(),themeAttribute:l.string(),defaultContext:l.string().optional(),layers:Ne.optional()}),utilities:l.record(l.string(),ge).optional()});function ne(e){const t=pt.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const o=r.path.join(".");return u.CONFIG.INVALID_CONFIG(o||"root",r.message)});throw new Error(n.join(`
13
+ `))}return t.data}s(ne,"validateSugarcubeConfig");function re(e){const t=dt.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const o=r.path.join(".");return u.CONFIG.INVALID_CONFIG(o||"root",r.message)});throw new Error(n.join(`
14
+ `))}return t.data}s(re,"validateInternalConfig");function mt(e){const t=ne(e),n=k(t);return re(n)}s(mt,"validateConfig");function ht(e){return e instanceof Error&&e.message===u.CONFIG.NO_CONFIG_OR_RESOLVER()}s(ht,"isNoConfigError");function oe(e="sugarcube.config"){const t=[".ts",".js"],n=process.cwd();for(const r of t){const o=b(n,`${e}${r}`);if(Q(o))return o}return null}s(oe,"findConfigFile");function It(e="sugarcube.config"){return oe(e)!==null}s(It,"configFileExists");async function Et(e){try{if(typeof globalThis.Bun<"u"){const i=at(e).href,c=await new Function("url","return import(url)")(i);if(c&&typeof c=="object"&&"default"in c)return c.default;throw new Error(u.CONFIG.INVALID_CONFIG("root","Config file must export a default object"))}const{createJiti:n}=await import("jiti"),o=await n(import.meta.url,{interopDefault:!0}).import(e);return o&&typeof o=="object"&&"default"in o?o.default:o}catch(t){throw t instanceof Error?new Error(u.CONFIG.INVALID_CONFIG("root",t.message)):t}}s(Et,"loadTSConfig");async function Se(e){if(e.endsWith(".ts")||e.endsWith(".js"))return await Et(e);const n=await it.readFile(e,"utf-8");return JSON.parse(n)}s(Se,"loadConfigFile");function $t(e){if(e)return b(process.cwd(),e);const t=oe();if(!t)throw new Error(u.CONFIG.FILE_NOT_FOUND("sugarcube.config.ts"));return t}s($t,"resolveConfigPath");async function yt(e){const t=$t(e);try{const n=await Se(t);return{config:ne(n),configPath:t}}catch(n){throw n instanceof Error&&"code"in n&&n.code==="ENOENT"?new Error(u.CONFIG.FILE_NOT_FOUND(t)):n instanceof SyntaxError?new Error(u.CONFIG.INVALID_JSON(n.message)):n}}s(yt,"loadSugarcubeConfig");async function gt(e){const t=e?b(process.cwd(),e):oe();if(t)try{const r=await Se(t),o=ne(r);if(!o.resolver){const c=await te(process.cwd());if(c.found==="one")o.resolver=c.path;else{if(c.found==="multiple")throw new Error(u.CONFIG.MULTIPLE_RESOLVERS_FOUND(c.paths));if(c.found==="none")throw new Error(u.CONFIG.NO_CONFIG_OR_RESOLVER())}}const i=k(o);return{config:re(i),configPath:t}}catch(r){throw r instanceof Error&&"code"in r&&r.code==="ENOENT"?new Error(u.CONFIG.FILE_NOT_FOUND(t)):r instanceof SyntaxError?new Error(u.CONFIG.INVALID_JSON(r.message)):r}const n=await te(process.cwd());if(n.found==="one"){const r={resolver:n.path},o=k(r);return{config:re(o),configPath:n.path}}throw n.found==="multiple"?new Error(u.CONFIG.MULTIPLE_RESOLVERS_FOUND(n.paths)):new Error(u.CONFIG.NO_CONFIG_OR_RESOLVER())}s(gt,"loadInternalConfig");function T(e){return typeof e=="object"&&e!==null&&"$ref"in e&&typeof e.$ref=="string"}s(T,"isReference$1");function se(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="set"}s(se,"isInlineSet");function D(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="modifier"}s(D,"isInlineModifier");async function Nt(e){const t=_(e)?e:b(process.cwd(),e),n=w(t),r=await ee(t,"utf-8"),o=JSON.parse(r),i=new Set;for(const a of o.resolutionOrder)if(T(a))Oe(a.$ref,n,i);else if(se(a))M(a.sources,n,i);else if(D(a))for(const c of Object.values(a.contexts))M(c,n,i);if(o.sets)for(const a of Object.values(o.sets))M(a.sources,n,i);if(o.modifiers)for(const a of Object.values(o.modifiers))for(const c of Object.values(a.contexts))M(c,n,i);return{filePaths:[...i],resolverPath:t}}s(Nt,"extractFileRefs");function M(e,t,n){for(const r of e)T(r)&&Oe(r.$ref,t,n)}s(M,"extractFromSources");function Oe(e,t,n){if(e.startsWith("#/"))return;const r=e.split("#")[0];if(!r)return;const o=_(r)?r:b(t,r);n.add(o)}s(Oe,"addFileRef");function h(e){return typeof e=="string"&&e.startsWith("{")&&e.endsWith("}")}s(h,"isReference");function St(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(St,"isCompositeToken");function Ot(e){return e.$type==="typography"}s(Ot,"isTypographyToken");function ie(e){return typeof e=="object"&&e!==null&&"$value"in e}s(ie,"isTokenNode");function bt(e,t,n){for(const[r,o]of Object.entries(t.tokens)){const i=e.tokens[r];if(!ie(o)){if(i&&ie(i)){const m=i;n.push({path:m.$path,source:m.$source,message:u.FLATTEN.CONFLICT_TOKEN_VS_GROUP(m.$path)});continue}e.tokens[r]=o;continue}if(!i){e.tokens[r]=o;continue}if(!ie(i)){n.push({path:o.$path,source:o.$source,message:u.FLATTEN.CONFLICT_TOKEN_VS_GROUP(o.$path)});continue}const c=o,f=i,p=!!c.$type,d=!!f.$type;if(p&&d&&c.$type!==f.$type){n.push({path:c.$path,source:c.$source,message:u.FLATTEN.CONFLICT_INCOMPATIBLE_TYPES(String(f.$type??"unknown"),String(c.$type??"unknown"),c.$path)});continue}e.tokens[r]=o}for(const[r,o]of t.pathIndex)e.pathIndex.set(r,o)}s(bt,"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 r=e.value;return typeof r=="string"||typeof r=="number"||Array.isArray(r)}return!1}s(Tt,"looksLikeUnprefixedToken");function At(e,t){const n={tokens:{},pathIndex:new Map},r=[];function o(a=[]){const c=[];return t.context&&c.push(t.context),a.length>0&&c.push(a.join(".")),c.length>0?c.join("."):""}s(o,"createLookupKey"),(e.$description||e.$extensions)&&(n.tokens[o()]={$description:e.$description,$extensions:e.$extensions});function i(a,c=[],f){if(c.join("."),c.length>0){const m=o(c);n.tokens[m]={$description:a.$description,$extensions:a.$extensions,$path:c.join("."),$source:{context:t.context,sourcePath:t.sourcePath}}}const p=Object.keys(a).filter(m=>!m.startsWith("$")),d=a.$type||f;for(const m of p){const I=a[m],E=[...c,m],y=E.join(".");if(Tt(I)){r.push({path:y,source:t,message:u.FLATTEN.MISSING_DOLLAR_PREFIX(y)});continue}if(m.includes(".")||m.includes("{")||m.includes("}")){r.push({path:y,source:t,message:u.FLATTEN.INVALID_TOKEN_NAME(m)});continue}if("$value"in I){if(Object.keys(I).filter(ot=>!ot.startsWith("$")).length>0){r.push({path:y,source:t,message:u.FLATTEN.INVALID_TOKEN_NESTING(y)});continue}if(St(I)&&!I.$type&&!d){r.push({path:y,source:t,message:u.FLATTEN.COMPOSITE_TOKEN_MISSING_TYPE(y)});continue}if(!I.$type&&!d&&!h(I.$value)){r.push({path:y,source:t,message:u.FLATTEN.TOKEN_MISSING_TYPE(y)});continue}const me=o(E),Z=E.join(".");n.tokens[me]={...I,...I.$type||d?{$type:I.$type||d}:{},$path:Z,$source:{context:t.context,sourcePath:t.sourcePath},$originalPath:Z},n.pathIndex.set(Z,me)}else i(I,E,d)}}return s(i,"processNode"),i(e),{tokens:n,errors:r}}s(At,"flattenTree");function Rt(e){const t={tokens:{},pathIndex:new Map},n=[];for(const r of e){const{tokens:o,errors:i}=At(r.tokens,{context:r.context,sourcePath:r.sourcePath});n.push(...i),bt(t,o,n)}return{tokens:t,errors:n}}s(Rt,"flatten");const be="sh.sugarcube";function _t(e){if(e?.[be])return e[be]}s(_t,"getSugarcubeExtensions");function Te(e){return _t(e)?.prefersColorScheme===!0?"prefers-color-scheme":"data-attribute"}s(Te,"extractContextStrategy");const P=l.string().min(1,"Name cannot be empty").refine(e=>!e.startsWith("$"),"Names must not start with '$' (reserved prefix)").refine(e=>!e.includes("{"),"Names must not contain '{'").refine(e=>!e.includes("}"),"Names must not contain '}'").refine(e=>!e.includes("."),"Names must not contain '.'"),Ae=l.object({$ref:l.string().min(1,"$ref cannot be empty")}).passthrough(),ae=l.union([Ae,l.record(l.string(),l.unknown())]),Dt=l.object({description:l.string().optional(),sources:l.array(ae),$extensions:l.record(l.string(),l.unknown()).optional()}),Re=l.record(l.string(),l.array(ae)),Lt=l.object({description:l.string().optional(),contexts:Re,default:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}).refine(e=>Object.keys(e.contexts).length>=1,"Modifier must have at least 1 context"),vt=l.object({type:l.literal("set"),name:P,sources:l.array(ae),description:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}),xt=l.object({type:l.literal("modifier"),name:P,contexts:Re,description:l.string().optional(),default:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}).refine(e=>Object.keys(e.contexts).length>=1,"Modifier must have at least 1 context"),Ct=l.union([Ae,vt,xt]),Ft=l.record(P,Dt),Vt=l.record(P,Lt),wt=l.object({version:l.literal("2025.10"),name:l.string().optional(),description:l.string().optional(),sets:Ft.optional(),modifiers:Vt.optional(),resolutionOrder:l.array(Ct),$schema:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional(),$defs:l.record(l.string(),l.unknown()).optional()});async function kt(e){const t=_(e)?e:b(process.cwd(),e),n=await Mt(t);if(n.error)return{document:U(),errors:[n.error]};const r=Pt(n.content);if(r.error)return{document:U(),errors:[r.error]};const o=jt(r.data);if(o.errors.length>0)return{document:U(),errors:o.errors};const i=[];return Ut(o.document,i),{document:o.document,errors:i}}s(kt,"parseResolverDocument");async function Mt(e){try{return{content:await ee(e,"utf-8")}}catch{return{error:{path:e,message:u.RESOLVER.FILE_NOT_FOUND(e)}}}}s(Mt,"loadFile");function Pt(e){try{return{data:JSON.parse(e)}}catch(t){const n=t instanceof Error?t.message:"Unknown error";return{error:{path:"resolver",message:u.RESOLVER.INVALID_JSON(n)}}}}s(Pt,"parseJson");function jt(e){const t=wt.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const o=r.path.join(".")||"resolver";return{path:o,message:`Resolver error at ${o}: ${r.message}. See https://sugarcube.sh/docs/resolver`}});return{document:U(),errors:n}}return{document:t.data,errors:[]}}s(jt,"validateSchema$1");function Ut(e,t){Gt(e,t),Wt(e,t),Bt(e,t)}s(Ut,"validateDocument");function Gt(e,t){if(e.modifiers)for(const[n,r]of Object.entries(e.modifiers))_e(r,`modifiers.${n}`,t);for(let n=0;n<e.resolutionOrder.length;n++){const r=e.resolutionOrder[n];D(r)&&_e(r,`resolutionOrder[${n}]`,t)}}s(Gt,"validateModifierContexts");function _e(e,t,n){const r=Object.keys(e.contexts).length;if(r===0){n.push({path:`${t}.contexts`,message:u.RESOLVER.MODIFIER_NEEDS_CONTEXTS});return}if(r===1&&n.push({path:`${t}.contexts`,message:u.RESOLVER.MODIFIER_SINGLE_CONTEXT}),e.default&&!e.contexts[e.default]&&n.push({path:`${t}.default`,message:u.RESOLVER.INVALID_DEFAULT(e.default,Object.keys(e.contexts))}),Te(e.$extensions)==="prefers-color-scheme"){const i=Object.keys(e.contexts),a=["light","dark"],c=i.filter(d=>!a.includes(d)),f="name"in e?e.name:t.split(".").pop()??t;c.length>0&&n.push({path:`${t}.contexts`,message:u.RESOLVER.PREFERS_COLOR_SCHEME_INVALID_CONTEXTS(f,c)});const p=e.default??i[0];for(const d of i){if(d===p)continue;const m=e.contexts[d];(!m||m.length===0)&&n.push({path:`${t}.contexts.${d}`,message:u.RESOLVER.PREFERS_COLOR_SCHEME_EMPTY_NON_DEFAULT(f,d)})}}}s(_e,"checkModifierContexts");function Wt(e,t){const n=new Set;for(let r=0;r<e.resolutionOrder.length;r++){const o=e.resolutionOrder[r];if(T(o))continue;const i=o.name;n.has(i)&&t.push({path:`resolutionOrder[${r}].name`,message:u.RESOLVER.DUPLICATE_NAME(i)}),n.add(i)}}s(Wt,"validateNameUniqueness");function Bt(e,t){for(let n=0;n<e.resolutionOrder.length;n++){const r=e.resolutionOrder[n];if(T(r))Yt(r.$ref,`resolutionOrder[${n}].$ref`,e,t);else if(se(r))j(r.sources,`resolutionOrder[${n}].sources`,t);else if(D(r))for(const[o,i]of Object.entries(r.contexts))j(i,`resolutionOrder[${n}].contexts.${o}`,t)}if(e.sets)for(const[n,r]of Object.entries(e.sets))j(r.sources,`sets.${n}.sources`,t);if(e.modifiers)for(const[n,r]of Object.entries(e.modifiers))for(const[o,i]of Object.entries(r.contexts))j(i,`modifiers.${n}.contexts.${o}`,t)}s(Bt,"validateReferences");function j(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if(!o)continue;if(!T(o)){const a=Object.keys(o);if(a.length===1){const c=a[0],f=o[c];typeof f=="string"&&(f.includes("/")||f.endsWith(".json"))&&n.push({path:`${t}[${r}]`,message:u.RESOLVER.MALFORMED_REFERENCE(c,f)})}continue}const i=o.$ref;i.startsWith("#/")&&(i.match(/^#\/sets\/[^/]+$/)||n.push({path:`${t}[${r}].$ref`,message:u.RESOLVER.INVALID_SOURCE_REFERENCE(i)}))}}s(j,"validateSourcesReferences");function Yt(e,t,n,r){if(!e.startsWith("#/"))return;const o=e.slice(2).split("/"),[i,a]=o;if(o.length!==2||!i||!a){r.push({path:t,message:u.RESOLVER.INVALID_REFERENCE(e)});return}if(i==="sets"){n.sets?.[a]||r.push({path:t,message:u.RESOLVER.UNDEFINED_SET(a)});return}if(i==="modifiers"){n.modifiers?.[a]||r.push({path:t,message:u.RESOLVER.UNDEFINED_MODIFIER(a)});return}r.push({path:t,message:u.RESOLVER.INVALID_REFERENCE(e)})}s(Yt,"validateReference");function U(){return{version:"2025.10",resolutionOrder:[]}}s(U,"createEmptyDocument");function De(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.version==="2025.10"&&Array.isArray(t.resolutionOrder)}s(De,"isResolverFormat");function Le(e,t){return{document:e,basePath:t,visitedRefs:new Set,fileCache:new Map}}s(Le,"createResolveContext");async function ve(e,t){if(t.visitedRefs.has(e))return S({},u.RESOLVER.CIRCULAR_REFERENCE(e),e);t.visitedRefs.add(e);try{return e.startsWith("#/")?Ht(e,t):e.includes("#/")?await qt(e,t):await Kt(e,t)}finally{t.visitedRefs.delete(e)}}s(ve,"resolveReference");function Ht(e,t){const n=e.slice(2),[r,o]=n.split("/");if(!r||!o||n.split("/").length!==2)return S({sources:[]},u.RESOLVER.INVALID_REFERENCE(e));if(r==="sets"){const i=t.document.sets?.[o];return i?{content:i,sourcePath:"#",errors:[]}:S({sources:[]},u.RESOLVER.UNDEFINED_SET(o))}if(r==="modifiers"){const i=t.document.modifiers?.[o];return i?{content:i,sourcePath:"#",errors:[]}:S({contexts:{}},u.RESOLVER.UNDEFINED_MODIFIER(o))}return S({sources:[]},u.RESOLVER.INVALID_REFERENCE(e))}s(Ht,"resolveSameDocumentRef");async function Kt(e,t){const n=_(e)?e:b(t.basePath,e),r=t.fileCache.get(n);if(r)return De(r)?S({},u.RESOLVER.RESOLVER_AS_TOKEN_SOURCE(n),n):{content:r,sourcePath:n,errors:[]};const o=await xe(n);return o.error?S({},o.error,n):De(o.content)?S({},u.RESOLVER.RESOLVER_AS_TOKEN_SOURCE(n),n):(t.fileCache.set(n,o.content),{content:o.content,sourcePath:n,errors:[]})}s(Kt,"resolveFileRef");async function qt(e,t){const[n="",r=""]=e.split("#"),o=_(n)?n:b(t.basePath,n);let i=t.fileCache.get(o);if(!i){const f=await xe(o);if(f.error)return S({},f.error,o);i=f.content,t.fileCache.set(o,i)}const a=r.startsWith("/")?r:`/${r}`,c=zt(i,a);return c.error?S({},u.RESOLVER.INVALID_JSON_POINTER(a,c.error),o):{content:c.value,sourcePath:o,errors:[]}}s(qt,"resolveFileFragmentRef");async function xe(e){try{const t=await ee(e,"utf-8");return{content:JSON.parse(t)}}catch(t){if(t.code==="ENOENT")return{error:u.RESOLVER.EXTERNAL_FILE_NOT_FOUND(e)};const n=t instanceof Error?t.message:"Unknown error";return{error:u.RESOLVER.EXTERNAL_FILE_ERROR(e,n)}}}s(xe,"loadJsonFile");function zt(e,t){if(t===""||t==="/")return{value:e};const n=t.slice(1).split("/").map(o=>o.replace(/~1/g,"/").replace(/~0/g,"~"));let r=e;for(const o of n){if(r===null||typeof r!="object")return{error:"cannot navigate into non-object"};if(Array.isArray(r)){const a=Number.parseInt(o,10);if(Number.isNaN(a)||a<0||a>=r.length)return{error:`invalid array index "${o}"`};r=r[a];continue}const i=r;if(!(o in i))return{error:`property "${o}" not found`};r=i[o]}return{value:r}}s(zt,"resolveJsonPointer");async function Ce(e,t){const n=[],r=[];for(const o of e){if(!T(o)){n.push(o);continue}const i=await ve(o.$ref,t);r.push(...i.errors),i.errors.length===0&&n.push(Jt(i.content,o))}return{resolved:n,errors:r}}s(Ce,"resolveSources");function Jt(e,t){const{$ref:n,...r}=t;return Object.keys(r).length===0?e:{...e,...r}}s(Jt,"applyExtending");function S(e,t,n="#"){return{content:e,sourcePath:n,errors:[{path:n,message:t}]}}s(S,"errorResult");function Fe(e){return typeof e=="object"&&e!==null&&"$value"in e}s(Fe,"isToken");function G(e,t){const n={...e};for(const[r,o]of Object.entries(t)){if(o===void 0)continue;if(r.startsWith("$")){n[r]=o;continue}if(Fe(o)){n[r]=o;continue}const i=n[r],a=i!==void 0&&typeof i=="object"&&i!==null&&typeof o=="object"&&o!==null&&!Fe(i);n[r]=a?G(i,o):o}return n}s(G,"deepMerge");function Ve(e){const t=[],n=new Set;for(const r of e.resolutionOrder){const o=Xt(r,e,n);o&&(t.push(o),n.add(o.name))}return t}s(Ve,"extractModifiers");function Xt(e,t,n){return T(e)&&e.$ref.startsWith("#/modifiers/")?Zt(e.$ref,t,n):D(e)?Qt(e,n):null}s(Xt,"extractModifierFromItem");function Zt(e,t,n){const r=e.split("/")[2];if(!r||n.has(r))return null;const o=t.modifiers?.[r];return o?{name:r,contexts:Object.keys(o.contexts),default:o.default,$extensions:o.$extensions}:null}s(Zt,"extractReferencedModifier");function Qt(e,t){return t.has(e.name)?null:{name:e.name,contexts:Object.keys(e.contexts),default:e.default,$extensions:e.$extensions}}s(Qt,"extractInlineModifier");function en(e,t={}){const n=[],r={},o=Ve(e);if(o.length===0)return tn(t,n),{valid:n.length===0,errors:n,resolvedInputs:r};const i=new Map(o.map(a=>[a.name,a]));return nn(t,i,n,r),rn(o,r,n),{valid:n.length===0,errors:n,resolvedInputs:r}}s(en,"validateInputs$1");function tn(e,t){for(const n of Object.keys(e))t.push({modifier:n,message:u.RESOLVER.UNKNOWN_MODIFIER(n)})}s(tn,"validateNoModifiersCase");function nn(e,t,n,r){for(const[o,i]of Object.entries(e)){const a=t.get(o);if(!a){n.push({modifier:o,message:u.RESOLVER.UNKNOWN_MODIFIER(o)});continue}if(typeof i!="string"){n.push({modifier:o,message:u.RESOLVER.INVALID_INPUT_TYPE(o)});continue}if(!a.contexts.includes(i)){n.push({modifier:o,message:u.RESOLVER.INVALID_CONTEXT(i,o,a.contexts)});continue}r[o]=i}}s(nn,"validateProvidedInputs");function rn(e,t,n){for(const r of e)t[r.name]===void 0&&(r.default!==void 0?t[r.name]=r.default:n.push({modifier:r.name,message:u.RESOLVER.MISSING_REQUIRED_INPUT(r.name)}))}s(rn,"applyDefaults");async function we(e,t,n={}){const r=en(e,n);if(!r.valid)return{tokens:{},sources:[],errors:r.errors.map(a=>({path:a.modifier||"inputs",message:a.message}))};const o=Le(e,t),i=on();for(const a of e.resolutionOrder)await sn(a,e,o,r.resolvedInputs,i);return{tokens:i.tokens,sources:i.sources,errors:i.errors}}s(we,"processResolutionOrder");function on(){return{tokens:{},sources:[],errors:[]}}s(on,"createProcessingState");async function sn(e,t,n,r,o){if(T(e)){await an(e,t,n,r,o);return}if(se(e)){await cn(e,n,o);return}D(e)&&await un(e,n,r,o)}s(sn,"processItem");async function an(e,t,n,r,o){const i=await ve(e.$ref,n);if(i.errors.length>0){o.errors.push(...i.errors);return}const a=e.$ref.split("/")[2];if(a){if(e.$ref.startsWith("#/sets/")){const c=await W(i.content.sources,n,{type:"set",name:a});B(c,o);return}if(e.$ref.startsWith("#/modifiers/")){const c=r[a];if(!c)return;const p=i.content.contexts[c];if(!p)return;const d=await W(p,n,{type:"modifier",name:a,context:c});B(d,o)}}}s(an,"processReference");async function cn(e,t,n){const r=await W(e.sources,t,{type:"set",name:e.name});B(r,n)}s(cn,"processInlineSet");async function un(e,t,n,r){const o=n[e.name];if(!o)return;const i=e.contexts[o];if(!i)return;const a=await W(i,t,{type:"modifier",name:e.name,context:o});B(a,r)}s(un,"processInlineModifier");async function W(e,t,n){const r=await Ce(e,t);let o={};for(const i of r.resolved)o=G(o,i);return{tokens:o,source:{path:"#",...n},errors:r.errors}}s(W,"mergeSources");function B(e,t){t.errors.push(...e.errors),t.tokens=G(t.tokens,e.tokens),t.sources.push(e.source)}s(B,"applyResult");async function fn(e,t){const n=[],r=Le(e,t),o=Ve(e),i={};for(const p of o)p.default&&(i[p.name]=p.default);const a=await we(e,t,i);n.push(...a.errors);const c=a.tokens,f=[];for(const p of o){const d=new Map,m=p.default??p.contexts[0]??"default";for(const I of p.contexts){if(I===m)continue;const E=await ln(e,t,r,p.name,I,n);Object.keys(E).length>0&&d.set(I,E)}f.push({name:p.name,defaultContext:m,contexts:d,$extensions:p.$extensions})}return{base:c,modifiers:f,errors:n}}s(fn,"processForLayeredCSS");async function ln(e,t,n,r,o,i){const a=pn(e,r);if(!a)return{};const c=a.contexts[o];if(!c||c.length===0)return{};const f=await Ce(c,n);i.push(...f.errors.map(E=>({path:E.path,message:E.message})));let p={};for(const E of f.resolved)p=G(p,E);const d=new Set;ke(p,"",d);const m=await we(e,t,{[r]:o});i.push(...m.errors);const I=structuredClone(p);for(const E of d){const y=dn(m.tokens,E);y!==void 0&&mn(I,E,y)}return I}s(ln,"processModifierContext");function pn(e,t){if(e.modifiers?.[t])return e.modifiers[t];for(const n of e.resolutionOrder)if(D(n)&&n.name===t)return n}s(pn,"findModifierDefinition");function ke(e,t,n){for(const[r,o]of Object.entries(e)){if(r.startsWith("$"))continue;const i=t?`${t}.${r}`:r;o&&typeof o=="object"&&"$value"in o?n.add(i):o&&typeof o=="object"&&ke(o,i,n)}}s(ke,"collectTokenPaths");function dn(e,t){const n=t.split(".");let r=e;for(const o of n){if(r===null||typeof r!="object")return;r=r[o]}return r}s(dn,"getTokenAtPath");function mn(e,t,n){const r=t.split(".");let o=e;for(let a=0;a<r.length-1;a++){const c=r[a];if(!c)continue;const f=o[c];if(!f||typeof f!="object")return;o=f}const i=r[r.length-1];i&&(o[i]=n)}s(mn,"updateTokenAtPath");async function hn(e){const t=_(e)?e:b(process.cwd(),e),n=w(t),r=[],o=[],i=V(process.cwd(),t),a=await kt(t);if(a.errors.length>0)return{trees:[],modifiers:[],errors:a.errors.map(p=>({file:p.path,message:p.message}))};const c=await fn(a.document,n);for(const p of c.errors)r.push({file:p.path,message:p.message});Object.keys(c.base).length>0&&o.push({context:void 0,tokens:c.base,sourcePath:i});const f=[];for(const p of c.modifiers){const d=[];for(const[m,I]of p.contexts)Object.keys(I).length>0&&(o.push({context:`${p.name}:${m}`,tokens:I,sourcePath:i}),d.push(m));f.push({name:p.name,attribute:`data-${p.name}`,defaultContext:p.defaultContext,contexts:d,contextStrategy:Te(p.$extensions)})}return{trees:o,modifiers:f,errors:r}}s(hn,"loadFromResolver");async function In(e){const t=[],n=[],r=Object.entries(e);r.sort(([,o],[,i])=>{const a=!o.context,c=!i.context;return a&&!c?-1:!a&&c?1:0});for(const[o,{context:i,content:a}]of r)try{const c=JSON.parse(a);t.push({context:i,tokens:c,sourcePath:V(process.cwd(),o)})}catch(c){c instanceof Error?c instanceof SyntaxError?n.push({file:o,message:u.LOAD.INVALID_JSON(o,c.message)}):n.push({file:o,message:c.message}):n.push({file:o,message:"Unknown error"})}return{trees:t,errors:n}}s(In,"loadTreesFromMemory");function Y(e,t,n,r){return typeof t=="string"&&h(t)?$n(e,t,n,r):Array.isArray(t)?t.map(o=>Y(e,o,n,r)):typeof t=="object"&&t!==null?Object.entries(t).reduce((i,[a,c])=>Object.assign(i,{[a]:Y(`${e}.${a}`,c,n,r)}),{}):t}s(Y,"resolveValue");function Me(e,t){const n=e.slice(1,-1),r=t.pathIndex.get(n);if(!r)return;const o=t.tokens[r];if(!(!o||!("$value"in o))){if(o.$type)return o.$type;if(typeof o.$value=="string"&&h(o.$value))return Me(o.$value,t)}}s(Me,"inferTypeFromReference");function En(e){const t={},n=new Set,r=[];for(const[o,i]of Object.entries(e.tokens))try{if(!("$value"in i)){t[o]=i;continue}const a=i;let c=a.$type;!c&&typeof a.$value=="string"&&h(a.$value)&&(c=Me(a.$value,e)),t[o]={...a,...c?{$type:c}:{},$resolvedValue:Y(a.$path,a.$value,e,n)}}catch(a){const c=a instanceof Error?a.message:String(a),f=i,p=f.$path,d=f.$source;let m,I;c.includes("Circular reference detected")?(m="circular",I=c):c.includes("Reference not found")?(m="missing",I=c):(m="type-mismatch",I=u.RESOLVE.TYPE_MISMATCH(p)),r.push({type:m,path:p,source:d,message:I})}return{resolved:t,errors:r}}s(En,"resolve");function $n(e,t,n,r){const o=t.slice(1,-1),i=n.pathIndex.get(o);if(!i)throw new Error(u.RESOLVE.REFERENCE_NOT_FOUND(o,e));if(r.has(i)){const f=n.tokens[i];throw!f||!("$path"in f)?new Error(u.RESOLVE.REFERENCE_NOT_FOUND(o,e)):new Error(u.RESOLVE.CIRCULAR_REFERENCE(e,f.$path))}const a=n.tokens[i];if(!a||!("$value"in a))throw new Error(u.RESOLVE.REFERENCE_NOT_FOUND(o,e));r.add(i);const c=Y(i,a.$value,n,r);return r.delete(i),c}s($n,"resolveReferenceChain");function O(e){return{success:!0,value:e}}s(O,"success");function g(e){return{success:!1,error:e}}s(g,"error");function L(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(r=>typeof r=="number"||r==="none")||t.alpha!==void 0&&typeof t.alpha!="number"||t.hex!==void 0&&typeof t.hex!="string")}s(L,"isDTCGColorValue");function H(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((r,o)=>{r!=="none"&&(typeof r!="number"||!Number.isFinite(r))&&t.push(`Component ${o} must be a finite number or "none".`)}),e.colorSpace==="oklch"){const[r,o,i]=e.components;r!=="none"&&(r<0||r>1)&&t.push("OKLCH Lightness (L) must be between 0 and 1 or 'none'."),o!=="none"&&o<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[r,o,i]=e.components;r!=="none"&&(r<0||r>1)&&t.push("Display P3 Red component must be between 0 and 1 or 'none'."),o!=="none"&&(o<0||o>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[r,o,i]=e.components;r!=="none"&&(r<0||r>1)&&t.push("sRGB Red component must be between 0 and 1 or 'none'."),o!=="none"&&(o<0||o>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[r,o,i]=e.components;r!=="none"&&(r<0||r>=360)&&t.push("HSL Hue must be between 0 and 360 (exclusive) or 'none'."),o!=="none"&&(o<0||o>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(H,"validateDTCGColorValue");function yn(e){const t=H(e);return t.length>0?g(t.join(", ")):O(e)}s(yn,"validateDTCGColorValueResult");function gn(e){const t=yn(e);if(!t.success)return t;const[n,r,o]=e.components,i=e.alpha,a=n==="none"?"none":Number(n.toFixed(4)),c=r==="none"?"none":Number(r.toFixed(4)),f=o==="none"?"none":Number(o.toFixed(4));if(i!==void 0&&i!==1){const p=Number(i.toFixed(4));return O(`oklch(${a} ${c} ${f} / ${p})`)}return O(`oklch(${a} ${c} ${f})`)}s(gn,"formatDTCGColorToOKLCH");const Nn={isObject:s(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObject")};function $(e,t,n,r){if(h(t))return[];switch(e.type){case"object":return On(e,t,n,r);case"union":return bn(e,t,n,r);case"array":return Tn(e,t,n,r);default:return Sn(e,t,n,r)}}s($,"validateSchema");function Sn(e,t,n,r){return e.type!==typeof t?[{path:n,message:e.errorMessage?.(t,n)||u.VALIDATE.INVALID_TYPE(e.type,t,n),source:r}]:e.validate?.(t,n,r)??[]}s(Sn,"validateSimpleValue");function On(e,t,n,r){if(!Nn.isObject(t))return[{path:n,message:e.errorMessage?.(t,n)||u.VALIDATE.INVALID_TYPE("object",t,n),source:r}];const o=[],i=t;if(e.required)for(const a of e.required)a in i||o.push({path:`${n}.${a}`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY(a,n),source:r});for(const[a,c]of Object.entries(e.properties))a in i&&o.push(...$(c,i[a],`${n}.${a}`,r));return o}s(On,"validateObject");function bn(e,t,n,r){let o=[],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=$(a,t,n,r);if(c.length===0)return a.validate?.(t,n,r)??[];c.length<i&&(o=c,i=c.length)}return i===Number.POSITIVE_INFINITY?[{path:n,message:u.VALIDATE.INVALID_TYPE(e.oneOf.map(a=>a.type).join(" or "),t,n),source:r}]:o}s(bn,"validateUnion");function Tn(e,t,n,r){return Array.isArray(t)?e.validate?.(t,n,r)??[]:[{path:n,message:e.errorMessage?.(t,n)||u.VALIDATE.INVALID_TYPE("array",t,n),source:r}]}s(Tn,"validateArray");const K={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:u.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)=>L(e)?H(e).map(o=>({path:t,message:`Invalid color at ${t}: ${o}`,source:n})):[{path:t,message:u.VALIDATE.INVALID_COLOR(e,t),source:n}],"validate")}]}};function An(e,t,n){return $(K.schema,e,t,n)}s(An,"validateColor");const q={schema:{type:"number",errorMessage:s((e,t)=>u.VALIDATE.INVALID_NUMBER(e,t),"errorMessage"),validate:s((e,t,n)=>typeof e!="number"||Number.isNaN(e)?[{path:t,message:u.VALIDATE.INVALID_NUMBER(e,t),source:n}]:[],"validate")}};function Rn(e,t,n){return $(q.schema,e,t,n)}s(Rn,"validateNumber");const N={schema:{type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_DIMENSION(e,t),"errorMessage"),properties:{value:q.schema,unit:{type:"string",validate:s((e,t,n)=>typeof e!="string"||!["px","rem"].includes(e)?[{path:t,message:u.VALIDATE.INVALID_DIMENSION_UNIT(e,t),source:n}]:[],"validate")}},required:["value","unit"]}};function _n(e,t,n){return $(N.schema,e,t,n)}s(_n,"validateDimension");const Dn=["solid","dashed","dotted","double","groove","ridge","outset","inset"],Ln=["round","butt","square"],vn={type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_STROKE_STYLE(e,t),"errorMessage"),properties:{dashArray:{type:"array",validate:s((e,t,n)=>{const r=e,o=[];return r.forEach((i,a)=>{typeof i!="string"&&o.push(...$(N.schema,i,`${t}.${a}`,n))}),o},"validate")},lineCap:{type:"string",validate:s((e,t,n)=>Ln.includes(e)?[]:[{path:t,message:u.VALIDATE.INVALID_STROKE_LINE_CAP(e,t),source:n}],"validate")}},required:["dashArray","lineCap"]},Pe={schema:{type:"union",oneOf:[{type:"string",validate:s((e,t,n)=>!Dn.includes(e)&&typeof e=="string"?[{path:t,message:u.VALIDATE.INVALID_STROKE_STYLE(e,t),source:n}]:[],"validate")},vn]}};function xn(e,t,n){return $(Pe.schema,e,t,n)}s(xn,"validateStrokeStyle");const Cn={schema:{type:"object",properties:{color:K.schema,width:N.schema,style:Pe.schema},required:["color","width","style"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_BORDER(e,t),"errorMessage")}};function Fn(e,t,n){return $(Cn.schema,e,t,n)}s(Fn,"validateBorder");const je={schema:{type:"array",errorMessage:s((e,t)=>u.VALIDATE.INVALID_CUBIC_BEZIER(e,t),"errorMessage"),validate:s((e,t,n)=>{const r=e;if(r.length!==4||!r.every(a=>typeof a=="number"))return[{path:t,message:u.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}];const[o,,i]=r;return o<0||o>1||i<0||i>1?[{path:t,message:u.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}]:[]},"validate")}};function Vn(e,t,n){return $(je.schema,e,t,n)}s(Vn,"validateCubicBezier");const wn=["ms","s"],ce={schema:{type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_DURATION(e,t),"errorMessage"),properties:{value:q.schema,unit:{type:"string",validate:s((e,t,n)=>wn.includes(e)?[]:[{path:t,message:u.VALIDATE.INVALID_DURATION_UNIT(e,t),source:n}],"validate")}},required:["value","unit"]}};function kn(e,t,n){return $(ce.schema,e,t,n)}s(kn,"validateDuration");const Mn={schema:{type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FLUID_DIMENSION(e,t),"errorMessage"),properties:{min:N.schema,max:N.schema},required:["min","max"]}};function Pn(e,t,n){return $(Mn.schema,e,t,n)}s(Pn,"validateFluidDimension");const Ue={schema:{type:"union",oneOf:[{type:"string",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")},{type:"array",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage"),validate:s((e,t,n)=>e.every(o=>typeof o=="string")?[]:[{path:t,message:u.VALIDATE.INVALID_FONT_FAMILY(e,t),source:n}],"validate")}],errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")}};function jn(e,t,n){return $(Ue.schema,e,t,n)}s(jn,"validateFontFamily");const Un=["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"],Ge={schema:{type:"union",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),oneOf:[{type:"number",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>e<1||e>1e3?[{path:t,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}]:[],"validate")},{type:"string",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>Un.includes(e.toLowerCase())?[]:[{path:t,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}],"validate")}]}};function Gn(e,t,n){return $(Ge.schema,e,t,n)}s(Gn,"validateFontWeight");const Wn={type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_GRADIENT(e,t),"errorMessage"),properties:{color:K.schema,position:{type:"number",validate:s((e,t,n)=>e<0||e>1?[{path:t,message:u.VALIDATE.INVALID_GRADIENT_STOP_POSITION(e,t),source:n}]:[],"validate")}},required:["color","position"]},Bn={schema:{type:"array",errorMessage:s((e,t)=>u.VALIDATE.INVALID_ARRAY(e,t),"errorMessage"),validate:s((e,t,n)=>{const r=e,o=[];return r.forEach((i,a)=>{o.push(...$(Wn,i,`${t}[${a}]`,n))}),o},"validate")}};function Yn(e,t,n){return $(Bn.schema,e,t,n)}s(Yn,"validateGradient");const We={schema:{type:"object",properties:{color:{type:"union",oneOf:[K.schema]},offsetX:N.schema,offsetY:N.schema,blur:N.schema,spread:N.schema,inset:{type:"boolean",errorMessage:s((e,t)=>u.VALIDATE.INVALID_SHADOW_INSET(e,t),"errorMessage")}},required:["color","offsetX","offsetY","blur","spread"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_SHADOW(e,t),"errorMessage")}};function Hn(e,t,n){const r=[];return Array.isArray(e)?(e.forEach((o,i)=>{r.push(...$(We.schema,o,`${t}[${i}]`,n))}),r):$(We.schema,e,t,n)}s(Hn,"validateShadow");const Kn={schema:{type:"object",properties:{duration:ce.schema,delay:ce.schema,timingFunction:je.schema},required:["duration","delay","timingFunction"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_TRANSITION(e,t),"errorMessage")}};function qn(e,t,n){return $(Kn.schema,e,t,n)}s(qn,"validateTransition");const zn={schema:{type:"object",properties:{fontFamily:Ue.schema,fontSize:N.schema,letterSpacing:N.schema,lineHeight:q.schema,fontWeight:Ge.schema},required:["fontFamily","fontSize"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_TYPOGRAPHY(e,t),"errorMessage")}};function Jn(e,t,n){return $(zn.schema,e,t,n)}s(Jn,"validateTypography");const Xn={color:An,dimension:_n,fluidDimension:Pn,duration:kn,cubicBezier:Vn,fontFamily:jn,fontWeight:Gn,number:Rn,strokeStyle:xn,typography:Jn,border:Fn,shadow:Hn,gradient:Yn,transition:qn};function Zn(e){const t=[];for(const[n,r]of Object.entries(e.tokens)){if(typeof r!="object"||r===null||!("$type"in r)||!("$path"in r)||r.$path.startsWith("$"))continue;if(!("$value"in r)){t.push({path:r.$path,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("$value",r.$path),source:r.$source});continue}const o=Xn[r.$type];if(!o){t.push({path:r.$path,message:u.VALIDATE.UNKNOWN_TOKEN_TYPE(r.$type,r.$path),source:r.$source});continue}const i=r;t.push(...o(i.$value,i.$path,i.$source))}return t}s(Zn,"validate");async function Qn(e){const{trees:t,modifiers:n,errors:r}=await er(e),{tokens:o,errors:i}=Rt(t),a=Zn(o),{resolved:c,errors:f}=En(o);return{trees:t,resolved:c,modifiers:n,errors:{load:r,flatten:i,validation:a,resolution:f}}}s(Qn,"loadAndResolveTokens");async function er(e){switch(e.type){case"memory":{const t=await In(e.data);return{trees:t.trees,modifiers:[],errors:t.errors}}case"resolver":{const t=await hn(e.resolverPath);return{trees:t.trees,modifiers:t.modifiers,errors:t.errors}}}}s(er,"loadTokens");function x(e,t="native"){return L(e)?tr(e):O(e)}s(x,"convertColorToString");function tr(e){switch(e.colorSpace){case"oklch":return gn(e);case"display-p3":return nr(e);case"srgb":return rr(e);case"hsl":return or(e);default:return g(`Unsupported color space: ${e.colorSpace}. Supported color spaces: oklch, display-p3, srgb, hsl.`)}}s(tr,"formatDTCGColorNative");function nr(e){if(e.colorSpace!=="display-p3")return g(`Expected display-p3 color space, got: ${e.colorSpace}`);if(!Array.isArray(e.components)||e.components.length!==3)return g("Display P3 components must be an array of exactly 3 numbers [R, G, B]");const[t,n,r]=e.components,o=e.alpha;if(t!=="none"&&(t<0||t>1))return g("Display P3 Red component must be between 0 and 1 or 'none'");if(n!=="none"&&(n<0||n>1))return g("Display P3 Green component must be between 0 and 1 or 'none'");if(r!=="none"&&(r<0||r>1))return g("Display P3 Blue component must be between 0 and 1 or 'none'");if(o!==void 0&&(o<0||o>1))return g("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=r==="none"?"none":Number(r.toFixed(4));if(o!==void 0&&o!==1){const f=Number(o.toFixed(4));return O(`color(display-p3 ${i} ${a} ${c} / ${f})`)}return O(`color(display-p3 ${i} ${a} ${c})`)}s(nr,"formatDTCGColorToP3");function rr(e){if(e.colorSpace!=="srgb")return g(`Expected srgb color space, got: ${e.colorSpace}`);const t=H(e);if(t.length>0)return g(`Invalid DTCG color value: ${t.join(", ")}`);const[n,r,o]=e.components,i=e.alpha,a=n==="none"?"none":Math.round(n*255),c=r==="none"?"none":Math.round(r*255),f=o==="none"?"none":Math.round(o*255);if(i!==void 0&&i!==1){const p=Number(i.toFixed(4));return O(`rgb(${a} ${c} ${f} / ${p})`)}return O(`rgb(${a} ${c} ${f})`)}s(rr,"formatDTCGColorToRGB");function or(e){if(e.colorSpace!=="hsl")return g(`Expected hsl color space, got: ${e.colorSpace}`);const t=H(e);if(t.length>0)return g(`Invalid DTCG color value: ${t.join(", ")}`);const[n,r,o]=e.components,i=e.alpha,a=n==="none"?"none":Number(n.toFixed(1)),c=r==="none"?"none":Math.round(r),f=o==="none"?"none":Math.round(o);if(i!==void 0&&i!==1){const m=Number(i.toFixed(4)),I=c==="none"?"none":`${c}%`,E=f==="none"?"none":`${f}%`;return O(`hsl(${a} ${I} ${E} / ${m})`)}const p=c==="none"?"none":`${c}%`,d=f==="none"?"none":`${f}%`;return O(`hsl(${a} ${p} ${d})`)}s(or,"formatDTCGColorToHSL");function Be(e){return h(e)?{value:e}:typeof e=="string"?{value:e}:{value:`${e.dashArray.map(n=>h(n)?n:`${n.value}${n.unit}`).join(" ")} ${e.lineCap}`}}s(Be,"convertStrokeStyleToken");function sr(e,t){if(h(e))return e;if(L(e)){const n=x(e,t.colorFallbackStrategy);if(!n.success)throw new Error(u.CONVERT.COLOR_CONVERSION_FAILED(n.error));return n.value}return e}s(sr,"convertBorderColor");function ir(e,t){if(h(e))return{value:e};const n=h(e.width)?e.width:`${e.width.value}${e.width.unit}`,r=sr(e.color,t),o=typeof e.style=="string"?e.style:Be(e.style).value;return{value:`${n} ${o} ${r}`}}s(ir,"convertBorderToken");function ar(e,t){if(typeof e=="string"&&h(e))return{value:e};const n=t.colorFallbackStrategy;if(L(e))return cr(e,n);const r=x(e,n);if(!r.success)throw new Error(u.CONVERT.COLOR_CONVERSION_FAILED(r.error));return{value:r.value}}s(ar,"convertColorToken");function cr(e,t){const n=x(e,t);if(!n.success)throw new Error(u.CONVERT.COLOR_CONVERSION_FAILED(n.error));const r=n.value;if(t==="native")return{value:r};if(e.colorSpace==="srgb"||e.colorSpace==="hsl")return{value:r};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:ur(e.colorSpace),value:r}]}}s(cr,"convertDTCGColorToken");function ur(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(ur,"getFeatureQuery");function fr(e){return h(e)?{value:e}:{value:`cubic-bezier(${e.join(", ")})`}}s(fr,"convertCubicBezierToken");function lr(e){return h(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(lr,"convertDimensionToken");function pr(e){return h(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(pr,"convertDurationToken");function Ye(e,t=16){return e.unit==="px"?e.value:e.value*t}s(Ye,"normalizeToPixels");function dr(e,t){const{min:n,max:r}=e,o=t.fluidConfig,i=16,a=Ye(n,i),c=Ye(r,i),f=o.min,p=o.max;if(a===c)return{value:`${a/i}rem`};const d=a/i,m=c/i,I=f/i,E=p/i,y=(m-d)/(E-I),de=-1*I*y+d;return{value:`clamp(${d}rem, ${de.toFixed(2)}rem + ${(y*100).toFixed(2)}vw, ${m}rem)`}}s(dr,"convertFluidDimension");function mr(e,t){return h(e)?{value:e}:dr(e,t)}s(mr,"convertFluidDimensionToken");function z(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(z,"quoteFont");function hr(e){return h(e)?{value:e}:{value:Array.isArray(e)?e.map(n=>z(n)).join(", "):z(e)}}s(hr,"convertFontFamilyToken");const Ir={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 He(e){return h(e)?{value:e}:typeof e=="number"?{value:e}:{value:Ir[e.toLowerCase()]??e}}s(He,"convertFontWeightToken");function Er(e,t){if(h(e))return e;if(L(e)){const n=x(e,t.colorFallbackStrategy);if(!n.success)throw new Error(u.CONVERT.COLOR_CONVERSION_FAILED(n.error));return n.value}return e}s(Er,"convertGradientColor");function $r(e){return Math.max(0,Math.min(1,e))}s($r,"clampPosition");function yr(e){return h(e)?`${e}%`:`${$r(e)*100}%`}s(yr,"convertGradientPosition");function gr(e,t){const n=Er(e.color,t),r=yr(e.position);return`${n} ${r}`}s(gr,"convertSingleStop");function Ke(e){const t=[];for(const n of e)Array.isArray(n)?t.push(...Ke(n)):t.push(n);return t}s(Ke,"flattenStops");function Nr(e,t){return h(e)?{value:e}:{value:`linear-gradient(${Ke(e).map(o=>gr(o,t)).join(", ")})`}}s(Nr,"convertGradientToken");function Sr(e){return h(e)?{value:e}:{value:e}}s(Sr,"convertNumberToken");function Or(e,t){if(h(e))return e;if(L(e)){const n=x(e,t.colorFallbackStrategy);if(!n.success)throw new Error(u.CONVERT.COLOR_CONVERSION_FAILED(n.error));return n.value}return e}s(Or,"convertShadowColor");function qe(e,t){const n=h(e.offsetX)?e.offsetX:`${e.offsetX.value}${e.offsetX.unit}`,r=h(e.offsetY)?e.offsetY:`${e.offsetY.value}${e.offsetY.unit}`,o=h(e.blur)?e.blur:`${e.blur.value}${e.blur.unit}`,i=h(e.spread)?e.spread:`${e.spread.value}${e.spread.unit}`,a=Or(e.color,t);return`${e.inset?"inset ":""}${n} ${r} ${o} ${i} ${a}`}s(qe,"convertSingleShadow");function br(e,t){return h(e)?{value:e}:Array.isArray(e)?{value:e.map(n=>qe(n,t)).join(", ")}:{value:qe(e,t)}}s(br,"convertShadowToken");function ze(e){return e?`${e.value}${e.unit}`:"0ms"}s(ze,"formatDuration");function Tr(e){if(h(e))return{value:e};const t=h(e.duration)?e.duration:ze(e.duration),n=h(e.timingFunction)?e.timingFunction:`cubic-bezier(${e.timingFunction.join(", ")})`,r=e.delay&&(h(e.delay)?e.delay:ze(e.delay));return{value:[t,n,r].filter(Boolean).join(" ")}}s(Tr,"convertTransitionToken");function Ar(e){if(h(e))return{"font-family":e,"font-size":e};const t={"font-family":h(e.fontFamily)?e.fontFamily:Array.isArray(e.fontFamily)?e.fontFamily.map(n=>z(n)).join(", "):z(e.fontFamily),"font-size":h(e.fontSize)?e.fontSize:`${e.fontSize.value}${e.fontSize.unit}`};return e.fontWeight&&(t["font-weight"]=h(e.fontWeight)?e.fontWeight:He(e.fontWeight).value),e.letterSpacing&&(t["letter-spacing"]=h(e.letterSpacing)?e.letterSpacing:`${e.letterSpacing.value}${e.letterSpacing.unit}`),e.lineHeight&&(t["line-height"]=(h(e.lineHeight),e.lineHeight)),t}s(Ar,"convertTypographyToken");const Je={duration:pr,number:Sr,cubicBezier:fr,color:ar,dimension:lr,fluidDimension:mr,typography:Ar,border:ir,shadow:br,gradient:Nr,transition:Tr,strokeStyle:Be,fontFamily:hr,fontWeight:He};function Rr(e,t){const n=Je[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(Rr,"convertSingleToken");function _r(e,t,n){const r={};for(const[o,i]of Object.entries(e)){if(!i||typeof i!="object")continue;if(!("$type"in i)){r[o]={...i.$description?{$description:i.$description}:{},...i.$extensions?{$extensions:i.$extensions}:{}};continue}if(n?.(i.$path)||!Je[i.$type])continue;const a={fluidConfig:t.transforms.fluid,colorFallbackStrategy:t.transforms.colorFallbackStrategy,path:i.$path,resolvedTokens:e};r[o]=Rr(i,a)}return r}s(_r,"convertTokens");function Dr(e,t,n){const r={};for(const[o,i]of Object.entries(e))r[o]=_r(i,t,n);return r}s(Dr,"convert");function Lr(e,t){const n={},r=new Set;for(const o of e){const i=o.context??"default";r.add(i)}for(const o of r)n[o]={};for(const o of e){const{context:i,tokens:a}=o,c=i??"default";n[c]||(n[c]={});for(const[f,p]of Object.entries(a))n[c][f]=p}return{tokens:n,defaultContext:t}}s(Lr,"normalizeTokens");function vr(e,t){const n=new Map;for(const[r,o]of Object.entries(t)){if(!("$source"in o)){for(const c of e){const f=c.context??"";n.has(f)||n.set(f,{});const p=n.get(f);p&&(p[r]=o)}continue}const i=o.$source.context??"";n.has(i)||n.set(i,{});const a=n.get(i);a&&(a[r]=o)}return e.map(r=>{const o=r.context??"",i=n.get(o)||{};return{context:r.context,tokens:i}})}s(vr,"processTrees");async function xr(e,t,n,r){const o=vr(e,t),{tokens:i}=Lr(o);return Dr(i,n,r?f=>r.some(p=>p.path===f||p.path.startsWith(`${f}.`)):void 0)}s(xr,"processAndConvertTokens");function Cr(e){return Object.entries(e).sort(([t],[n])=>t.localeCompare(n))}s(Cr,"deterministicEntries");const Xe=new Map;function Fr(e){const t=Xe.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 Xe.set(e,n),n}s(Fr,"toKebabCase");function Ze(e,t=4){const n=" ".repeat(t);return e.split(`
15
+ `).map(r=>r.trim()?`${n}${r}`:r).join(`
16
+ `)}s(Ze,"indentCSS");function ue(e){return e.split(".").join("-")}s(ue,"formatCSSVarPath");function fe(e){if(typeof e=="number")return e;if(typeof e!="string")throw new Error(u.GENERATE.INVALID_CSS_VALUE_TYPE(typeof e));return e.replace(/\{([^}]+)\}/g,(t,n)=>`var(--${n.split(".").map(Fr).join("-")})`)}s(fe,"convertReferenceToCSSVar");function Vr(e){const t=e.$cssProperties;if("value"in t)return{name:`--${ue(e.$path)}`,value:fe(t.value)}}s(Vr,"generateSingleVariable");function wr(e){return Object.entries(e.$cssProperties).filter(([t,n])=>n!==void 0).map(([t,n])=>({name:`--${ue(e.$path)}-${t}`,value:fe(n)}))}s(wr,"generateTypographyVariables");function Qe(e){if(e.$type!=="color")return[];const t=e.$cssProperties;if(!("featureValues"in t))return[];const n=new Map;for(const r of t.featureValues||[]){n.has(r.query)||n.set(r.query,[]);const o=n.get(r.query);o&&o.push({name:`--${ue(e.$path)}`,value:fe(r.value)})}return Array.from(n.entries()).map(([r,o])=>({query:r,vars:o}))}s(Qe,"generateFeatureVariables");function et(e){const t=[`${e.selector} {`];if(e.comment&&t.push(` /* ${e.comment} */`),e.vars.length>0){const n=e.vars.map(r=>` ${r.name}: ${r.value};`).join(`
15
17
  `);t.push(n)}return t.push("}"),t.join(`
16
- `)}s(Xe,"generateCSSBlock");function Cr(e){const t=[];e.root.vars.length>0&&t.push(Xe({selector:e.root.selector,vars:e.root.vars}));for(const n of e.features){const o=Xe({selector:e.root.selector,vars:n.vars}).split(`
17
- `).map(i=>` ${i}`).join(`
18
- `);t.push(`${n.query} {
19
- ${o}
18
+ `)}s(et,"generateCSSBlock");function kr(e){const t=[];e.root.vars.length>0&&t.push(et({selector:e.root.selector,vars:e.root.vars}));for(const n of e.features){const r=et({selector:e.root.selector,vars:n.vars});t.push(`${n.query} {
19
+ ${Ze(r)}
20
20
  }`)}return t.filter(Boolean).join(`
21
21
 
22
- `)}s(Cr,"convertCSSVarsToString");function Fr(e){if(gt(e))return{vars:xr(e),features:Je(e)};const t=vr(e);return{vars:t?[t]:[],features:Je(e)}}s(Fr,"generateVariablesForToken");function Vr(e,t,n){if(!e||e==="default")return":root";const r=e.indexOf(":");if(r!==-1){const o=e.slice(0,r),i=e.slice(r+1);return`[${t?.find(f=>f.name===o)?.attribute??`data-${o}`}="${i}"]`}return`[${n.output.themeAttribute}="${e}"]`}s(Vr,"buildSelector");async function wr(e,t,n){const r=_r(e).filter(([m,d])=>m!=="$extensions"&&"$type"in d).map(([m,d])=>Fr(d)),o=Vr(n.context,n.modifiers,t),i=r.flatMap(m=>m.vars),a=r.flatMap(m=>m.features||[]),c=new Map;for(const m of a){c.has(m.query)||c.set(m.query,[]);const d=c.get(m.query);d&&d.push(...m.vars)}const f=Array.from(c.entries()).map(([m,d])=>({query:m,vars:d})),p=Cr({root:{selector:o,vars:i},features:f});return p.trim()?{output:[{path:t.output.variablesFilename,css:kr(p)}]}:{output:[{path:t.output.variablesFilename,css:""}]}}s(wr,"generateCSS");function kr(e){return e.endsWith(`
22
+ `)}s(kr,"convertCSSVarsToString");function Mr(e){if(Ot(e))return{vars:wr(e),features:Qe(e)};const t=Vr(e);return{vars:t?[t]:[],features:Qe(e)}}s(Mr,"generateVariablesForToken");function Pr(e,t,n){if(!e||e==="default")return{selector:":root"};const r=e.indexOf(":");if(r!==-1){const o=e.slice(0,r),i=e.slice(r+1),a=t?.find(f=>f.name===o);return a?.contextStrategy==="prefers-color-scheme"?{selector:":root",wrapper:`@media (prefers-color-scheme: ${i})`}:{selector:`[${a?.attribute??`data-${o}`}="${i}"]`}}return{selector:`[${n.output.themeAttribute}="${e}"]`}}s(Pr,"buildSelector");async function jr(e,t,n){const r=Cr(e).filter(([d,m])=>d!=="$extensions"&&"$type"in m).map(([d,m])=>Mr(m)),o=Pr(n.context,n.modifiers,t),i=r.flatMap(d=>d.vars),a=r.flatMap(d=>d.features||[]),c=new Map;for(const d of a){c.has(d.query)||c.set(d.query,[]);const m=c.get(d.query);m&&m.push(...d.vars)}const f=Array.from(c.entries()).map(([d,m])=>({query:d,vars:m})),p=Ur(o,i,f);return p.trim()?{output:[{path:t.output.variablesFilename,css:Gr(p)}]}:{output:[{path:t.output.variablesFilename,css:""}]}}s(jr,"generateCSS");function Ur(e,t,n){const r=kr({root:{selector:e.selector,vars:t},features:n});return r.trim()?e.wrapper?`${e.wrapper} {
23
+ ${Ze(r)}
24
+ }`:r:""}s(Ur,"generateCSSForSelector");function Gr(e){return e.endsWith(`
23
25
  `)?e:`${e}
24
- `}s(kr,"formatCSSVars");async function Mr(e,t,n){const r=t.output.variables,o=[],i=Object.entries(e).sort(([a],[c])=>!a||a==="default"?-1:!c||c==="default"?1:a.localeCompare(c));for(const[a,c]of i){const f=await wr(c,t,{context:a,modifiers:n});f.output[0].css.trim()&&o.push(f.output[0].css)}return o.length===0?[]:[{path:`${r}/${t.output.variablesFilename}`,css:`${o.filter(Boolean).join(`
26
+ `}s(Gr,"formatCSSVars");async function Wr(e,t,n){const r=t.output.variables,o=[],i=Object.entries(e).sort(([a],[c])=>!a||a==="default"?-1:!c||c==="default"?1:a.localeCompare(c));for(const[a,c]of i){const f=await jr(c,t,{context:a,modifiers:n});f.output[0].css.trim()&&o.push(f.output[0].css)}return o.length===0?[]:[{path:`${r}/${t.output.variablesFilename}`,css:`${o.filter(Boolean).join(`
25
27
  `).trim()}
26
- `}]}s(Mr,"generateSingleFile");async function Pr(e,t,n){const r={};for(const[o,i]of Object.entries(e))Object.keys(i).length>0&&(r[o]=i);return{output:await Mr(r,t,n)}}s(Pr,"generate");async function jr(e,t,n){const{output:r}=await Pr(e,t,n);return r}s(jr,"generateCSSVariables");const C="--",R="-",Ur=["all","full"],Gr={top:"t",right:"r",bottom:"b",left:"l",x:"x",y:"y",full:"",all:""},Wr={top:"block-start",right:"inline-end",bottom:"block-end",left:"inline-start",x:"inline",y:"block"};function Br(e){return Gr[e]}s(Br,"getDirectionAbbreviation");function Ze(e,t){if(t==="full"||t==="all")return e;const n=Wr[t];return n?`${e}${R}${n}`:e}s(Ze,"getLogicalProperty");const Yr=["top","right","bottom","left","x","y","full"];function Kr(e){return(Array.isArray(e)?e:[e]).flatMap(n=>n==="all"?Yr:[n])}s(Kr,"expandDirections");function Hr(e,t){const r={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 r?r.includes(e):!0}s(Hr,"isTokenTypeValidForProperty");const Qe=new WeakMap,v=new Map;function qr(){v.clear()}s(qr,"clearMatchCache");function zr(e){const t=Qe.get(e);if(t)return t;const n=new Map;for(const r of Object.values(e)){if(!("$path"in r))continue;const o=r;n.set(o.$path,o)}return Qe.set(e,n),n}s(zr,"buildPathIndex");function Jr(e){if(e.default)return e.default;const t=Object.keys(e);return t.length>0&&t[0]?e[t[0]]:null}s(Jr,"getDefaultContextTokens");function J(e,t,n){const r=`${t.source}:${t.prefix??""}:${t.property??""}:${e}`;if(v.has(r))return v.get(r)??null;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 f=t.source.slice(0,c);f&&o.push(`${f}.${t.prefix}.${e}`,`${f}.${t.prefix}.${e.split("-").join(".")}`)}}const i=Jr(n);if(!i)return v.set(r,null),null;const a=zr(i);for(const c of o){const f=a.get(c);if(f){if(t.property&&f.$type&&!Hr(f.$type,t.property))continue;const p=f.$path.split(".");return v.set(r,p),p}}return v.set(r,null),null}s(J,"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 X(e,t=""){const n=e??"",r=n||t?R:"";return new RegExp(`^${n}${t}${r}(.+)$`)}s(X,"createUtilityPattern");function pe(e,t,n){return[X(t.prefix),o=>{const i=o[1];if(!i)return{};const a=le(i,t),c={...t,property:e},f=J(a,c,n);return f?{[e]:`var(${C}${f.join(R)})`}:{}}]}s(pe,"createSimpleRule");function Xr(e,t,n,r){if(n==="all")return pe(e,t,r);const o=Br(n);return[X(t.prefix,o),a=>{const c=a[1];if(!c)return{};const f=le(c,t),p={...t,property:e},m=J(f,p,r);return m?{[Ze(e,n)]:`var(${C}${m.join(R)})`}:{}}]}s(Xr,"createDirectionalRule");function Zr(e,t){return[X(e),r=>{const o=r[1];if(!o)return{};for(const{property:i,config:a,direction:c,tokens:f}of t){const p=le(o,a),m={...a,property:i},d=J(p,m,f);if(d)return c?{[Ze(i,c)]:`var(${C}${d.join(R)})`}:{[i]:`var(${C}${d.join(R)})`}}return{}}]}s(Zr,"createSmartRule");function Qr(e,t,n){const r=t.source.indexOf("."),o=r!==-1?t.source.slice(0,r):t.source;return[X(o),a=>{const c=a[1];if(!c)return{};const f={...t,property:e},p=J(c,f,n);return p?{[e]:`var(${C}${p.join(R)})`}:{}}]}s(Qr,"createDirectTokenPathRule");function eo(e,t){if(!e?.source||typeof e.source!="string")throw new Error(u.UTILITIES.MISSING_SOURCE(t));if(e.source.includes("*")&&!e.source.endsWith(".*"))throw new Error(u.UTILITIES.INVALID_SOURCE_PATTERN(t,e.source));if(e.directions&&!Array.isArray(e.directions))throw new Error(u.UTILITIES.INVALID_DIRECTIONS(t))}s(eo,"validateUtilityConfig");function to(e,t){if(!e||typeof e!="object")throw new Error(u.UTILITIES.INVALID_CONFIG_OBJECT);if(!t||typeof t!="object")throw new Error(u.UTILITIES.INVALID_TOKENS_OBJECT)}s(to,"validateInputs");function no(e,t){to(e,t);const n=[],r={};for(const[o,i]of Object.entries(e)){const a=Array.isArray(i)?i:[i];for(const c of a)if(eo(c,o),c.prefix){const f=c.prefix;r[f]||(r[f]=[]),r[f].push({property:o,config:c,direction:null,tokens:t})}else{const f=Qr(o,c,t);n.push(f)}}for(const[o,i]of Object.entries(r))if(i.length===1){const a=i[0];if(!a)continue;const{property:c,config:f,tokens:p}=a;if(f.directions){const m=Kr(f.directions);(Array.isArray(f.directions)?f.directions:[f.directions]).includes("all")&&n.push(pe(c,f,p));for(const E of m)Ur.includes(E)||n.push(Xr(c,f,E,p))}else n.push(pe(c,f,p))}else n.push(Zr(o,i));return n}s(no,"convertConfigToUnoRules");const F=process.env.SUGARCUBE_PERF==="true";class ro{static{s(this,"PerfMonitor")}constructor(t=n=>void process.stderr.write(`${n}
27
- `)){this.defaultFlush=t}#n=0;#t=0;#e=Date.now();#r=null;#o=0;#s(){return Math.round(process.memoryUsage().heapUsed/1024/1024)}#i(){return new Date().toISOString().split("T")[1]?.slice(0,-1)??""}log(t,n){if(!F)return;const r=this.#i(),o=this.#s(),i=o-this.#n;this.#n=o,this.defaultFlush(`[perf ${r}] ${t} ${n?JSON.stringify(n):""} | heap: ${o}MB (${i>=0?"+":""}${i}MB)`)}trackWatcherEvent(t,n){if(!F)return;this.#t++;const r=Date.now(),o=t.split("/").slice(-3).join("/");this.log(`WATCHER EVENT #${this.#t}: ${o}`),r-this.#e>1e4&&(this.log("WATCHER STATS (last 10s)",{events:this.#t,moduleGraphSize:n}),this.#t=0,this.#e=r)}logWatcherSetup(t,n){F&&this.log("WATCHER SETUP: Adding watch pattern",{pattern:t,dir:n})}logModuleGraphStats(t,n,r){F&&this.log(`MODULE GRAPH (${r})`,{modules:t,urls:n})}startMemoryMonitor(){!F||this.#r||(this.log("PERF MONITORING ENABLED - Starting memory monitor"),this.#o=this.#s(),this.#r=setInterval(()=>{const t=this.#s(),n=t-this.#o;Math.abs(n)>5&&(this.log("MEMORY CHANGE",{from:this.#o,to:t,delta:n}),this.#o=t)},5e3))}stopMemoryMonitor(){this.#r&&(clearInterval(this.#r),this.#r=null)}[Symbol.dispose](){this.stopMemoryMonitor()}}class et 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 oo=process.env.DEBUG==="true";class so{static{s(this,"Instrumentation")}constructor(t=n=>void process.stderr.write(`${n}
28
- `)){this.defaultFlush=t}#n=new et(()=>({value:0}));#t=new et(()=>({value:0n}));#e=[];hit(t){this.#n.get(t).value++}start(t){const n=this.#e.map(o=>o.label).join("//"),r=`${n}${n.length===0?"":"//"}${t}`;this.#n.get(r).value++,this.#t.get(r),this.#e.push({id:r,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 r=this.#e.length-1,o=this.#e[r];if(!o)throw new Error("Timer stack is corrupted");if(o.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.#t.get(i.id).value+=a}report(t=this.defaultFlush){const n=[];let r=!1;for(let o=this.#e.length-1;o>=0;o--){const i=this.#e[o];i&&this.end(i.label)}for(const[o,{value:i}]of this.#n.entries()){if(this.#t.has(o))continue;n.length===0&&(r=!0,n.push("Hits:"));const a=o.split("//").length;n.push(`${" ".repeat(a)}${o} \xD7 ${i}`)}if(this.#t.size>0){r&&n.push(`
28
+ `}]}s(Wr,"generateSingleFile");async function Br(e,t,n){const r={};for(const[o,i]of Object.entries(e))Object.keys(i).length>0&&(r[o]=i);return{output:await Wr(r,t,n)}}s(Br,"generate");async function Yr(e,t,n){const{output:r}=await Br(e,t,n);return r}s(Yr,"generateCSSVariables");const C="--",R="-",Hr=["all","full"],Kr={top:"t",right:"r",bottom:"b",left:"l",x:"x",y:"y",full:"",all:""},qr={top:"block-start",right:"inline-end",bottom:"block-end",left:"inline-start",x:"inline",y:"block"};function zr(e){return Kr[e]}s(zr,"getDirectionAbbreviation");function tt(e,t){if(t==="full"||t==="all")return e;const n=qr[t];return n?`${e}${R}${n}`:e}s(tt,"getLogicalProperty");const Jr=["top","right","bottom","left","x","y","full"];function Xr(e){return(Array.isArray(e)?e:[e]).flatMap(n=>n==="all"?Jr:[n])}s(Xr,"expandDirections");function Zr(e,t){const r={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 r?r.includes(e):!0}s(Zr,"isTokenTypeValidForProperty");const nt=new WeakMap,v=new Map;function Qr(){v.clear()}s(Qr,"clearMatchCache");function eo(e){const t=nt.get(e);if(t)return t;const n=new Map;for(const r of Object.values(e)){if(!("$path"in r))continue;const o=r;n.set(o.$path,o)}return nt.set(e,n),n}s(eo,"buildPathIndex");function to(e){if(e.default)return e.default;const t=Object.keys(e);return t.length>0&&t[0]?e[t[0]]:null}s(to,"getDefaultContextTokens");function J(e,t,n){const r=`${t.source}:${t.prefix??""}:${t.property??""}:${e}`;if(v.has(r))return v.get(r)??null;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 f=t.source.slice(0,c);f&&o.push(`${f}.${t.prefix}.${e}`,`${f}.${t.prefix}.${e.split("-").join(".")}`)}}const i=to(n);if(!i)return v.set(r,null),null;const a=eo(i);for(const c of o){const f=a.get(c);if(f){if(t.property&&f.$type&&!Zr(f.$type,t.property))continue;const p=f.$path.split(".");return v.set(r,p),p}}return v.set(r,null),null}s(J,"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 X(e,t=""){const n=e??"",r=n||t?R:"";return new RegExp(`^${n}${t}${r}(.+)$`)}s(X,"createUtilityPattern");function pe(e,t,n){return[X(t.prefix),o=>{const i=o[1];if(!i)return{};const a=le(i,t),c={...t,property:e},f=J(a,c,n);return f?{[e]:`var(${C}${f.join(R)})`}:{}}]}s(pe,"createSimpleRule");function no(e,t,n,r){if(n==="all")return pe(e,t,r);const o=zr(n);return[X(t.prefix,o),a=>{const c=a[1];if(!c)return{};const f=le(c,t),p={...t,property:e},d=J(f,p,r);return d?{[tt(e,n)]:`var(${C}${d.join(R)})`}:{}}]}s(no,"createDirectionalRule");function ro(e,t){return[X(e),r=>{const o=r[1];if(!o)return{};for(const{property:i,config:a,direction:c,tokens:f}of t){const p=le(o,a),d={...a,property:i},m=J(p,d,f);if(m)return c?{[tt(i,c)]:`var(${C}${m.join(R)})`}:{[i]:`var(${C}${m.join(R)})`}}return{}}]}s(ro,"createSmartRule");function oo(e,t,n){const r=t.source.indexOf("."),o=r!==-1?t.source.slice(0,r):t.source;return[X(o),a=>{const c=a[1];if(!c)return{};const f={...t,property:e},p=J(c,f,n);return p?{[e]:`var(${C}${p.join(R)})`}:{}}]}s(oo,"createDirectTokenPathRule");function so(e,t){if(!e?.source||typeof e.source!="string")throw new Error(u.UTILITIES.MISSING_SOURCE(t));if(e.source.includes("*")&&!e.source.endsWith(".*"))throw new Error(u.UTILITIES.INVALID_SOURCE_PATTERN(t,e.source));if(e.directions&&!Array.isArray(e.directions))throw new Error(u.UTILITIES.INVALID_DIRECTIONS(t))}s(so,"validateUtilityConfig");function io(e,t){if(!e||typeof e!="object")throw new Error(u.UTILITIES.INVALID_CONFIG_OBJECT);if(!t||typeof t!="object")throw new Error(u.UTILITIES.INVALID_TOKENS_OBJECT)}s(io,"validateInputs");function ao(e,t){io(e,t);const n=[],r={};for(const[o,i]of Object.entries(e)){const a=Array.isArray(i)?i:[i];for(const c of a)if(so(c,o),c.prefix){const f=c.prefix;r[f]||(r[f]=[]),r[f].push({property:o,config:c,direction:null,tokens:t})}else{const f=oo(o,c,t);n.push(f)}}for(const[o,i]of Object.entries(r))if(i.length===1){const a=i[0];if(!a)continue;const{property:c,config:f,tokens:p}=a;if(f.directions){const d=Xr(f.directions);(Array.isArray(f.directions)?f.directions:[f.directions]).includes("all")&&n.push(pe(c,f,p));for(const E of d)Hr.includes(E)||n.push(no(c,f,E,p))}else n.push(pe(c,f,p))}else n.push(ro(o,i));return n}s(ao,"convertConfigToUnoRules");const F=process.env.SUGARCUBE_PERF==="true";class co{static{s(this,"PerfMonitor")}constructor(t=n=>void process.stderr.write(`${n}
29
+ `)){this.defaultFlush=t}#n=0;#t=0;#e=Date.now();#r=null;#o=0;#s(){return Math.round(process.memoryUsage().heapUsed/1024/1024)}#i(){return new Date().toISOString().split("T")[1]?.slice(0,-1)??""}log(t,n){if(!F)return;const r=this.#i(),o=this.#s(),i=o-this.#n;this.#n=o,this.defaultFlush(`[perf ${r}] ${t} ${n?JSON.stringify(n):""} | heap: ${o}MB (${i>=0?"+":""}${i}MB)`)}trackWatcherEvent(t,n){if(!F)return;this.#t++;const r=Date.now(),o=t.split("/").slice(-3).join("/");this.log(`WATCHER EVENT #${this.#t}: ${o}`),r-this.#e>1e4&&(this.log("WATCHER STATS (last 10s)",{events:this.#t,moduleGraphSize:n}),this.#t=0,this.#e=r)}logWatcherSetup(t,n){F&&this.log("WATCHER SETUP: Adding watch pattern",{pattern:t,dir:n})}logModuleGraphStats(t,n,r){F&&this.log(`MODULE GRAPH (${r})`,{modules:t,urls:n})}startMemoryMonitor(){!F||this.#r||(this.log("PERF MONITORING ENABLED - Starting memory monitor"),this.#o=this.#s(),this.#r=setInterval(()=>{const t=this.#s(),n=t-this.#o;Math.abs(n)>5&&(this.log("MEMORY CHANGE",{from:this.#o,to:t,delta:n}),this.#o=t)},5e3))}stopMemoryMonitor(){this.#r&&(clearInterval(this.#r),this.#r=null)}[Symbol.dispose](){this.stopMemoryMonitor()}}class rt 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 uo=process.env.DEBUG==="true";class fo{static{s(this,"Instrumentation")}constructor(t=n=>void process.stderr.write(`${n}
30
+ `)){this.defaultFlush=t}#n=new rt(()=>({value:0}));#t=new rt(()=>({value:0n}));#e=[];hit(t){this.#n.get(t).value++}start(t){const n=this.#e.map(o=>o.label).join("//"),r=`${n}${n.length===0?"":"//"}${t}`;this.#n.get(r).value++,this.#t.get(r),this.#e.push({id:r,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 r=this.#e.length-1,o=this.#e[r];if(!o)throw new Error("Timer stack is corrupted");if(o.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.#t.get(i.id).value+=a}report(t=this.defaultFlush){const n=[];let r=!1;for(let o=this.#e.length-1;o>=0;o--){const i=this.#e[o];i&&this.end(i.label)}for(const[o,{value:i}]of this.#n.entries()){if(this.#t.has(o))continue;n.length===0&&(r=!0,n.push("Hits:"));const a=o.split("//").length;n.push(`${" ".repeat(a)}${o} \xD7 ${i}`)}if(this.#t.size>0){r&&n.push(`
29
31
  Timers:`);for(const[o,{value:i}]of this.#t){const a=o.split("//").length,c=`${(Number(i)/1e6).toFixed(2)}ms`;n.push(`${" ".repeat(a-1)}${o.split("//").pop()} [${c}] ${this.#n.get(o).value===1?"":`\xD7 ${this.#n.get(o).value}`}`.trimEnd())}}t(`
30
32
  ${n.join(`
31
33
  `)}
32
- `)}[Symbol.dispose](){oo&&this.report()}}async function io(e){for(const t of e)try{await he(w(t.path),{recursive:!0}),await Ie(t.path,t.css,"utf-8")}catch(n){throw new Error(`Failed to write CSS file ${t.path}: ${n instanceof Error?n.message:"Unknown error"}`)}return e}s(io,"writeCSSVariablesToDisk");async function ao(e){for(const t of e)try{await he(w(t.path),{recursive:!0}),await Ie(t.path,t.css,"utf-8")}catch(n){throw new Error(`Failed to write utility CSS file ${t.path}: ${n instanceof Error?n.message:"Unknown error"}`)}return e}s(ao,"writeCSSUtilitiesToDisk");export{A as DEFAULT_CONFIG,so as Instrumentation,ro as PerfMonitor,qr as clearMatchCache,dt as configFileExists,no as convertConfigToUnoRules,it as defineConfig,yt as extractFileRefs,k as fillDefaults,te as findResolverDocument,jr as generateCSSVariables,pt as isNoConfigError,zn as loadAndResolveTokens,Et as loadInternalConfig,It as loadSugarcubeConfig,Dr as processAndConvertTokens,lt as validateConfig,ao as writeCSSUtilitiesToDisk,io as writeCSSVariablesToDisk};
34
+ `)}[Symbol.dispose](){uo&&this.report()}}async function lo(e){for(const t of e)try{await he(w(t.path),{recursive:!0}),await Ie(t.path,t.css,"utf-8")}catch(n){throw new Error(`Failed to write CSS file ${t.path}: ${n instanceof Error?n.message:"Unknown error"}`)}return e}s(lo,"writeCSSVariablesToDisk");async function po(e){for(const t of e)try{await he(w(t.path),{recursive:!0}),await Ie(t.path,t.css,"utf-8")}catch(n){throw new Error(`Failed to write utility CSS file ${t.path}: ${n instanceof Error?n.message:"Unknown error"}`)}return e}s(po,"writeCSSUtilitiesToDisk");export{A as DEFAULT_CONFIG,fo as Instrumentation,co as PerfMonitor,Qr as clearMatchCache,It as configFileExists,ao as convertConfigToUnoRules,ut as defineConfig,Nt as extractFileRefs,k as fillDefaults,te as findResolverDocument,Yr as generateCSSVariables,ht as isNoConfigError,Qn as loadAndResolveTokens,gt as loadInternalConfig,yt as loadSugarcubeConfig,xr as processAndConvertTokens,mt as validateConfig,po as writeCSSUtilitiesToDisk,lo as writeCSSVariablesToDisk};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sugarcube-sh/core",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": false