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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,29 +1,44 @@
1
- var ge=Object.defineProperty;var o=(e,t)=>ge(e,"name",{value:t,configurable:!0});import{converter as D,formatHex8 as $e,formatHex as C}from"culori";import ye,{readFile as _,mkdir as Ae,writeFile as R}from"node:fs/promises";import N,{relative as O}from"node:path";import Ee from"fast-glob";import{z as m}from"zod";import{existsSync as j}from"node:fs";function h(e){return typeof e=="string"&&e.startsWith("{")&&e.endsWith("}")}o(h,"isReference");function M(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}`}}o(M,"convertStrokeStyleToken");function Ne(e){if(h(e))return{value:e};const t=h(e.width)?e.width:`${e.width.value}${e.width.unit}`,n=(h(e.color),e.color),r=typeof e.style=="string"?e.style:M(e.style).value;return{value:`${t} ${r} ${n}`}}o(Ne,"convertBorderToken");function V(e){return e===1?"1":e===0?"0":e.toFixed(2)}o(V,"formatAlpha");function F(e,t){try{const n=t==="rgba"?"rgb":t==="hsla"?"hsl":t,r=D(n==="hex"?"rgb":n)(e);if(!r)throw new Error(`Failed to convert color ${e} to ${t}`);switch(n){case"hsl":{if(r.mode!=="hsl")throw new Error("Unexpected color mode");const s=Math.round(r.h??0),i=Math.round((r.s??0)*100),a=Math.round((r.l??0)*100),c=r.alpha;return c!==void 0?`hsl(${s} ${i}% ${a}% / ${V(c)})`:`hsl(${s} ${i}% ${a}%)`}case"oklch":{if(r.mode!=="oklch")throw new Error("Unexpected color mode");const s=r.l??0,i=r.c??0,a=r.h??0,c=r.alpha;return c!==void 0?`oklch(${s.toFixed(3)} ${i.toFixed(3)} ${a.toFixed(1)} / ${c.toFixed(2)})`:`oklch(${s.toFixed(3)} ${i.toFixed(3)} ${a.toFixed(1)})`}case"rgb":{if(r.mode!=="rgb")throw new Error("Unexpected color mode");const s=Math.round((r.r??0)*255),i=Math.round((r.g??0)*255),a=Math.round((r.b??0)*255),c=r.alpha;return c!==void 0?`rgb(${s} ${i} ${a} / ${V(c)})`:`rgb(${s} ${i} ${a})`}case"p3":{if(r.mode!=="p3")throw new Error("Unexpected color mode");const s=r.r??0,i=r.g??0,a=r.b??0,c=r.alpha;return c!==void 0?`color(display-p3 ${s.toFixed(6)} ${i.toFixed(6)} ${a.toFixed(6)} / ${V(c)})`:`color(display-p3 ${s.toFixed(6)} ${i.toFixed(6)} ${a.toFixed(6)})`}default:{const s=D("rgb")(r);return s?s.alpha!==void 0?$e(s):C(s):e}}}catch{const r=D("rgb")(e);return console.warn(`Failed to convert color ${e} to ${t}, falling back to hex`),r?C(r):e}}o(F,"convertHexToColorString");function Te(e,t){if(h(e))return{value:e};const n=t.colorFormat||"hex";try{const r=F(e,n);return n==="p3"?{value:F(e,"hex")||e,featureValues:[{query:"@supports (color: color(display-p3 1 1 1))",value:r||e}]}:{value:r||e}}catch{return console.warn(`Failed to convert color ${e} to ${n}, falling back to hex`),{value:F(e,"hex")}}}o(Te,"convertColorToken");function be(e){return h(e)?{value:e}:{value:`cubic-bezier(${e.join(", ")})`}}o(be,"convertCubicBezierToken");function Se(e){return h(e)?{value:e}:{value:`${e.value}${e.unit}`}}o(Se,"convertDimensionToken");function Le(e){return h(e)?{value:e}:{value:`${e.value}${e.unit}`}}o(Le,"convertDurationToken");const u={LOAD:{NO_FILES_FOUND:o(e=>`No files found matching pattern: ${e}.`,"NO_FILES_FOUND"),INVALID_JSON:o((e,t)=>`Invalid JSON in file ${e}: ${t}`,"INVALID_JSON"),GLOB_ERROR:o((e,t)=>`Error resolving glob pattern ${e}: ${t}`,"GLOB_ERROR")},FLATTEN:{INVALID_TOKEN_NAME:o(e=>`Invalid token name "${e}": Token names cannot contain dots (.), curly braces ({,}), or other special characters`,"INVALID_TOKEN_NAME"),MISSING_DOLLAR_PREFIX:o(e=>`Token at ${e} is using 'value' or 'type' without the required '$' prefix. Use '$value' and '$type' instead.`,"MISSING_DOLLAR_PREFIX")},METADATA:{COLLECTION_ERROR:o(e=>`Error collecting metadata: ${e}`,"COLLECTION_ERROR"),INVALID_EXTENSIONS:o(e=>`Invalid extensions at ${e}: expected object, got ${typeof e}`,"INVALID_EXTENSIONS"),INVALID_DESCRIPTION:o(e=>`Invalid description at ${e}: expected string, got ${typeof e}`,"INVALID_DESCRIPTION")},VALIDATE:{MISSING_TYPE:o(e=>`Token at '${e}' is missing the "$type" property`,"MISSING_TYPE"),UNKNOWN_TOKEN_TYPE:o((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:o((e,t)=>`Invalid color at ${t}: '${e}'. Color should be a valid hex value`,"INVALID_COLOR"),INVALID_DIMENSION:o((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:o((e,t)=>`Invalid unit at ${t}': '${e}'. Unit must be either "px" or "rem"`,"INVALID_DIMENSION_UNIT"),INVALID_FONT_FAMILY:o((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:o((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:o((e,t)=>`Invalid duration at '${t}': ${e}. Should be like { "value": 300, "unit": "ms" }`,"INVALID_DURATION"),INVALID_DURATION_UNIT:o((e,t)=>`Invalid unit at ${t}: "${e}". Unit must be "ms" or "s"`,"INVALID_DURATION_UNIT"),INVALID_CUBIC_BEZIER:o((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:o((e,t)=>`Invalid stroke style at ${t}: "${e}". Should be "solid", "dashed", "dotted", etc.`,"INVALID_STROKE_STYLE"),INVALID_STROKE_LINE_CAP:o((e,t)=>`Invalid line cap at ${t}: "${e}". Should be one of: round, butt, square`,"INVALID_STROKE_LINE_CAP"),INVALID_BORDER:o((e,t)=>`Invalid border at ${t}: "${e}". Should have color, width, and style properties`,"INVALID_BORDER"),INVALID_SHADOW:o((e,t)=>`Invalid shadow at ${t}: "${e}". Should have color, offsetX, offsetY properties (blur and spread are optional)`,"INVALID_SHADOW"),INVALID_SHADOW_INSET:o((e,t)=>`Invalid inset value at ${t}: "${e}". Should be true or false`,"INVALID_SHADOW_INSET"),INVALID_TRANSITION:o((e,t)=>`Invalid transition at ${t}: "${e}". Should have duration, delay, and timingFunction properties`,"INVALID_TRANSITION"),INVALID_GRADIENT:o((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:o((e,t)=>`Invalid gradient stop position at ${t}: "${e}". Position must be between 0 and 1`,"INVALID_GRADIENT_STOP_POSITION"),INVALID_TYPOGRAPHY:o((e,t)=>`Invalid typography at ${t}: "${e}". Should have fontFamily and fontSize (fontWeight, letterSpacing, and lineHeight are optional)`,"INVALID_TYPOGRAPHY"),MISSING_REQUIRED_PROPERTY:o((e,t)=>`Missing required property '${e}' at ${t}`,"MISSING_REQUIRED_PROPERTY"),INVALID_NUMBER:o((e,t)=>`Invalid number at ${t}: "${e}". Expected a number value`,"INVALID_NUMBER"),INVALID_ARRAY:o((e,t)=>`Invalid array at ${t}: "${e}". Expected an array value`,"INVALID_ARRAY"),MISSING_FLUID_CONFIG:o(e=>`Missing fluid configuration. Token at ${e} requires fluid viewport settings.`,"MISSING_FLUID_CONFIG"),INVALID_FLUID_DIMENSION:o((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:o((e,t)=>`Invalid viewport configuration at ${t}: "${e}". Viewport config should have min and max dimension values`,"INVALID_VIEWPORT_CONFIG"),MISMATCHED_UNITS:o((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:o(e=>`Invalid fluid value range at ${e}: min value must be less than max value`,"INVALID_FLUID_VALUE_RANGE"),INVALID_TOKEN_TYPE:o((e,t,n)=>`Invalid token type at ${n}: expected ${e}, got ${t}`,"INVALID_TOKEN_TYPE"),INVALID_TYPE:o((e,t,n)=>`Expected ${e}, received ${typeof t} at ${n}`,"INVALID_TYPE"),INVALID_ENUM_VALUE:o((e,t,n)=>`Expected value to be one of [${e.join(", ")}], but got ${String(t)} at ${n}`,"INVALID_ENUM_VALUE")},RESOLVE:{CIRCULAR_REFERENCE:o((e,t)=>`Circular reference detected: ${e} -> ${t}`,"CIRCULAR_REFERENCE"),REFERENCE_NOT_FOUND:o((e,t)=>`Reference not found: ${e} in ${t}`,"REFERENCE_NOT_FOUND"),TYPE_MISMATCH:o(e=>`Type mismatch in ${e}`,"TYPE_MISMATCH")},GENERATE:{INVALID_CSS_VALUE:o((e,t)=>`Invalid CSS value for property '${e}': ${t}`,"INVALID_CSS_VALUE"),INVALID_VARIABLE_NAME:o((e,t)=>`Invalid CSS variable name at '${e}': ${t}`,"INVALID_VARIABLE_NAME")},CONFIG:{INVALID_JSON:o(e=>`Invalid JSON in config file: ${e}`,"INVALID_JSON"),INVALID_CONFIG:o((e,t)=>`Invalid configuration at ${e}: ${t}`,"INVALID_CONFIG"),DUPLICATE_FILENAMES:o((e,t,n)=>`Duplicate filename "${t}" found in collection "${e}":
2
- ${n.map(r=>` - ${r}`).join(`
3
- `)}`,"DUPLICATE_FILENAMES"),FILE_NOT_FOUND:o(e=>`Cannot read config file at ${e} - check file permissions and path`,"FILE_NOT_FOUND")}};function P(e,t=16){return e.unit==="px"?e.value:e.value*t}o(P,"normalizeToPixels");function De(e,t){const{min:n,max:r}=e,s=t.fluidConfig;if(!s)throw new Error(u.VALIDATE.MISSING_FLUID_CONFIG(t.path??""));const i=16,a=P(n,i),c=P(r,i),l=s.min,f=s.max;if(a===c)return{value:`${a/i}rem`};const p=a/i,d=c/i,I=l/i,g=f/i,y=(d-p)/(g-I),A=-1*I*y+p;return{value:`clamp(${p}rem, ${A.toFixed(2)}rem + ${(y*100).toFixed(2)}vw, ${d}rem)`}}o(De,"convertFluidDimension");function _e(e,t){if(h(e))return{value:e};if(!t.fluidConfig)throw new Error(u.VALIDATE.MISSING_FLUID_CONFIG(t.path??""));return De(e,t)}o(_e,"convertFluidDimensionToken");function T(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}o(T,"quoteFont");function Oe(e){return h(e)?{value:e}:{value:Array.isArray(e)?e.map(n=>T(n)).join(", "):T(e)}}o(Oe,"convertFontFamilyToken");const Ve={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 U(e){return h(e)?{value:e}:typeof e=="number"?{value:e}:{value:Ve[e.toLowerCase()]??e}}o(U,"convertFontWeightToken");function Fe(e){return h(e)?{value:e}:{value:`linear-gradient(${e.map(n=>{const r=(h(n.color),n.color),s=h(n.position)?n.position:`${n.position*100}`;return`${r} ${s}%`}).join(", ")})`}}o(Fe,"convertGradientToken");function ve(e){return h(e)?{value:e}:{value:e}}o(ve,"convertNumberToken");function G(e){const t=h(e.offsetX)?e.offsetX:`${e.offsetX.value}${e.offsetX.unit}`,n=h(e.offsetY)?e.offsetY:`${e.offsetY.value}${e.offsetY.unit}`,r=h(e.blur)?e.blur:`${e.blur.value}${e.blur.unit}`,s=h(e.spread)?e.spread:`${e.spread.value}${e.spread.unit}`,i=(h(e.color),e.color);return`${e.inset?"inset ":""}${t} ${n} ${r} ${s} ${i}`}o(G,"convertSingleShadow");function ke(e){return h(e)?{value:e}:Array.isArray(e)?{value:e.map(G).join(", ")}:{value:G(e)}}o(ke,"convertShadowToken");function W(e){return e?`${e.value}${e.unit}`:"0ms"}o(W,"formatDuration");function we(e){if(h(e))return{value:e};const t=h(e.duration)?e.duration:W(e.duration),n=h(e.timingFunction)?e.timingFunction:`cubic-bezier(${e.timingFunction.join(", ")})`,r=e.delay&&(h(e.delay)?e.delay:W(e.delay));return{value:[t,n,r].filter(Boolean).join(" ")}}o(we,"convertTransitionToken");function xe(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=>T(n)).join(", "):T(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:U(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}o(xe,"convertTypographyToken");const Y={duration:Le,number:ve,cubicBezier:be,color:Te,dimension:Se,fluidDimension:_e,typography:xe,border:Ne,shadow:ke,gradient:Fe,transition:we,strokeStyle:M,fontFamily:Oe,fontWeight:U};function Ce(e,t){const n=Y[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)}}o(Ce,"convertSingleToken");function z(e,t){const n={};for(const[r,s]of Object.entries(e)){if(!s||typeof s!="object")continue;if(!("$type"in s)){n[r]={...s.$description?{$description:s.$description}:{},...s.$extensions?{$extensions:s.$extensions}:{}};continue}if(!Y[s.$type])continue;const i={fluidConfig:t.options?.fluid,colorFormat:t.options?.color,path:s.$path};n[r]=Ce(s,i)}return n}o(z,"convertTokens");function B(e,t){const n={};for(const[r,s]of Object.entries(e)){const i={default:z(s.default,t)};for(const[a,c]of Object.entries(s))a!=="default"&&(i[a]=z(c,t));n[r]=i}return n}o(B,"convert");function Re(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}o(Re,"looksLikeUnprefixedToken");function je(e,t){const n={tokens:{},pathIndex:new Map},r=[];function s(a=[]){const c=[t.collection];return t.theme&&c.push(t.theme),a.length>0&&c.push(a.join(".")),c.join(".")}o(s,"createLookupKey"),(e.$description||e.$extensions)&&(n.tokens[s()]={$description:e.$description,$extensions:e.$extensions});function i(a,c=[],l){if(c.length>0){const d=s(c);n.tokens[d]={$description:a.$description,$extensions:a.$extensions,$path:c.join("."),$source:{collection:t.collection,theme:t.theme,sourcePath:t.sourcePath}}}if("$value"in a)return;const f=a.$type||l,p=Object.keys(a).filter(d=>!d.startsWith("$"));for(const d of p){const I=a[d],g=[...c,d];if(Re(I)){r.push({path:g.join("."),source:t,message:u.FLATTEN.MISSING_DOLLAR_PREFIX(g.join("."))});continue}if(d.includes(".")||d.includes("{")||d.includes("}")){r.push({path:g.join("."),source:t,message:u.FLATTEN.INVALID_TOKEN_NAME(d)});continue}if("$value"in I){const y=s(g),A=g.join(".");n.tokens[y]={...I,$type:I.$type||f,$path:A,$source:{collection:t.collection,theme:t.theme,sourcePath:t.sourcePath},$originalPath:A},n.pathIndex.set(A,y)}else i(I,g,f)}}return o(i,"processNode"),i(e),{tokens:n,errors:r}}o(je,"flattenTree");function H(e){const t={tokens:{},pathIndex:new Map},n=[];for(const r of e){const{tokens:s,errors:i}=je(r.tokens,{collection:r.collection,theme:r.theme,sourcePath:r.sourcePath});Object.assign(t.tokens,s.tokens);for(const[a,c]of s.pathIndex)t.pathIndex.set(a,c);n.push(...i)}return{tokens:t,errors:n}}o(H,"flatten");function v({collection:e,filename:t,separate:n,baseDir:r}){const s=`${t}.variables.css`;return e==="default"?`${r}/${s}`:`${r}/${e}/${s}`}o(v,"getOutputPath");const q=new Map;function Me(e){const t=q.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 q.set(e,n),n}o(Me,"toKebabCase");const K="@supports (color: color(display-p3 1 1 1))";function Pe(e){return e.$type==="typography"}o(Pe,"isTypographyToken");function k(e){return e.split(".").join("-")}o(k,"formatCSSVarPath");function X(e){return typeof e=="number"?e:typeof e!="string"?(console.warn("Unexpected value type in convertReferenceToCSSVar, got:",e),String(e)):e.replace(/\{([^}]+)\}/g,(t,n)=>`var(--${n.split(".").map(Me).join("-")})`)}o(X,"convertReferenceToCSSVar");function Ue(e){const t=e.$cssProperties;if("value"in t)return{name:`--${k(e.$path)}`,value:X(t.value)}}o(Ue,"generateSingleVariable");function Ge(e){return Object.entries(e.$cssProperties).filter(([t,n])=>n!==void 0).map(([t,n])=>({name:`--${k(e.$path)}-${t}`,value:X(n)}))}o(Ge,"generateTypographyVariables");function J(e){if(e.$type!=="color")return[];const t=e.$cssProperties;return"featureValues"in t?t.featureValues?.filter(n=>n.query===K).map(n=>({name:`--${k(e.$path)}`,value:n.value}))??[]:[]}o(J,"generateFeatureVariables");function Z(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(`
1
+ var et=Object.defineProperty;var s=(e,t)=>et(e,"name",{value:t,configurable:!0});import C,{readFile as K,mkdir as fe,writeFile as pe}from"node:fs/promises";import z from"fast-glob";import{join as N,relative as _,basename as de,dirname as he,resolve as me}from"pathe";import{existsSync as D}from"node:fs";import{pathToFileURL as tt}from"node:url";import{z as m}from"zod";const w="_sugarcube.css",q="global",nt="utilities",S=".variables.gen.css",J="tokens",ot="utilities.gen.css",rt="src/styles",st="src/design-tokens",F="sugarcube.config.ts";function I(e){return typeof e=="string"&&e.startsWith("{")&&e.endsWith("}")}s(I,"isReference");function it(e){if(typeof e!="object"||e===null||!("$value"in e))return!1;const t=e.$value;return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Object.keys(t).length>0}s(it,"isCompositeToken");function at(e){return e.$type==="typography"}s(at,"isTypographyToken");function Ie(e){return typeof e=="object"&&e!==null&&"$path"in e&&"$type"in e&&"$resolvedValue"in e}s(Ie,"isResolvedToken");function ct(e,t){return Ie(e)&&e.$type===t}s(ct,"isResolvedTokenOfType");function V(e){return Object.entries(e).sort(([t],[n])=>t.localeCompare(n))}s(V,"deterministicEntries");const ye=new Map;function lt(e){const t=ye.get(e);if(t)return t;const n=e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z])(?=[a-z])/g,"$1-$2").toLowerCase();return ye.set(e,n),n}s(lt,"toKebabCase");function X(e){return e.split(".").join("-")}s(X,"formatCSSVarPath");function Z(e){return typeof e=="number"?e:typeof e!="string"?(console.warn("Unexpected value type in convertReferenceToCSSVar, got:",e),String(e)):e.replace(/\{([^}]+)\}/g,(t,n)=>`var(--${n.split(".").map(lt).join("-")})`)}s(Z,"convertReferenceToCSSVar");function ut(e){const t=e.$cssProperties;if("value"in t)return{name:`--${X(e.$path)}`,value:Z(t.value)}}s(ut,"generateSingleVariable");function ft(e){return Object.entries(e.$cssProperties).filter(([t,n])=>n!==void 0).map(([t,n])=>({name:`--${X(e.$path)}-${t}`,value:Z(n)}))}s(ft,"generateTypographyVariables");function $e(e){if(e.$type!=="color")return[];const t=e.$cssProperties;if(!("featureValues"in t))return[];const n=new Map;for(const o of t.featureValues||[]){n.has(o.query)||n.set(o.query,[]);const r=n.get(o.query);r&&r.push({name:`--${X(e.$path)}`,value:Z(o.value)})}return Array.from(n.entries()).map(([o,r])=>({query:o,vars:r}))}s($e,"generateFeatureVariables");function ge(e){const t=[`${e.selector} {`];if(e.comment&&t.push(` /* ${e.comment} */`),e.vars.length>0){const n=e.vars.map(o=>` ${o.name}: ${o.value};`).join(`
4
2
  `);t.push(n)}return t.push("}"),t.join(`
5
- `)}o(Z,"generateCSSBlock");function We(e){const t=[];e.root.vars.length>0&&t.push(Z({selector:e.root.selector,vars:e.root.vars}));for(const n of e.features){const s=Z({selector:e.root.selector,vars:n.vars}).split(`
3
+ `)}s(ge,"generateCSSBlock");function pt(e){const t=[];e.root.vars.length>0&&t.push(ge({selector:e.root.selector,vars:e.root.vars}));for(const n of e.features){const r=ge({selector:e.root.selector,vars:n.vars}).split(`
6
4
  `).map(i=>` ${i}`).join(`
7
5
  `);t.push(`${n.query} {
8
- ${s}
6
+ ${r}
9
7
  }`)}return t.filter(Boolean).join(`
10
8
 
11
- `)}o(We,"convertCSSVarsToString");function Ye(e){if(Pe(e))return{vars:Ge(e),features:J(e)};const t=Ue(e);return{vars:t?[t]:[],features:J(e)}}o(Ye,"generateVariablesForToken");async function w(e,t={}){const n=Object.entries(e).filter(([c,l])=>c!=="$extensions"&&"$type"in l).map(([c,l])=>Ye(l));let r=":root";t.theme&&t.theme!=="default"&&(r=`[data-theme="${t.theme}"]`);const s=n.flatMap(c=>c.vars),i=n.flatMap(c=>c.features||[]),a=We({root:{selector:r,vars:s},features:i.length?[{query:K,vars:i}]:[]});return a.trim()?{output:[{path:"tokens.variables.css",css:ze(a)}]}:{output:[{path:"tokens.variables.css",css:""}]}}o(w,"generateCSS");function ze(e){return e.endsWith(`
9
+ `)}s(pt,"convertCSSVarsToString");function dt(e){if(at(e))return{vars:ft(e),features:$e(e)};const t=ut(e);return{vars:t?[t]:[],features:$e(e)}}s(dt,"generateVariablesForToken");async function Q(e,t={}){const n=V(e).filter(([u,p])=>u!=="$extensions"&&"$type"in p).map(([u,p])=>dt(p));let o=":root";t.theme&&t.theme!=="default"&&(o=`[data-theme="${t.theme}"]`);const r=n.flatMap(u=>u.vars),i=n.flatMap(u=>u.features||[]),a=new Map;for(const u of i){a.has(u.query)||a.set(u.query,[]);const p=a.get(u.query);p&&p.push(...u.vars)}const c=Array.from(a.entries()).map(([u,p])=>({query:u,vars:p})),l=pt({root:{selector:o,vars:r},features:c});return l.trim()?{output:[{path:"tokens.variables.gen.css",css:ht(l),collection:t.collection??"default"}]}:{output:[{path:"tokens.variables.gen.css",css:"",collection:t.collection??"default"}]}}s(Q,"generateCSS");function ht(e){return e.endsWith(`
12
10
  `)?e:`${e}
13
- `}o(ze,"formatCSSVars");async function Be(e,t){const n=`${t.output.directories.css}/global/variables`,r=[];for(const[s,i]of Object.entries(e)){const a=[];for(const[c,l]of Object.entries(i)){const f=await w(l,{theme:c!=="default"?c:void 0});f.output[0].css.trim()&&a.push(f.output[0].css)}a.length>0&&r.push({path:v({collection:s,filename:"tokens",separate:!1,baseDir:n}),css:`${a.filter(Boolean).join(`
11
+ `}s(ht,"formatCSSVars");async function mt(e,t){const o=`${t.output?.css||"src/styles"}/${q}`,r=[];for(const[i,a]of V(e)){const c=[],l=Object.entries(a).sort(([u],[p])=>u==="default"?-1:p==="default"?1:u.localeCompare(p));for(const[u,p]of l){const d=await Q(p,{theme:u!=="default"?u:void 0,collection:i!=="default"?i:void 0});d.output[0].css.trim()&&c.push(d.output[0].css)}c.length>0&&r.push({path:i==="default"?`${o}/${J}${S}`:`${o}/${i}/${J}${S}`,css:`${c.filter(Boolean).join(`
14
12
  `).trim()}
15
- `})}return r}o(Be,"generateSingleFile");async function He(e,t){const n=`${t.output.directories.css}/global/variables`,r=[];for(const[s,i]of Object.entries(e))if(Object.keys(i).length!==0){for(const[a,c]of Object.entries(i))if(Object.keys(c).length!==0)if(a==="default"){const l=new Map;for(const[f,p]of Object.entries(c)){if(!("$type"in p))continue;const I=p.$source.sourcePath;l.has(I)||l.set(I,{}),l.get(I)[f]=p}for(const[f,p]of l){if(Object.keys(p).length===0)continue;const d=f.split("/").pop()?.replace(/\.json$/,"")??"tokens",g=(await w(p,{})).output[0].css;g.trim()&&r.push({path:v({collection:s,filename:d,separate:!0,baseDir:n}),css:g})}}else{const f=(await w(c,{theme:a})).output[0].css;f.trim()&&r.push({path:v({collection:s,filename:a,separate:!0,baseDir:n}),css:f})}}return r}o(He,"generateSeparateFiles");async function Q(e,t){const n={};for(const[r,s]of Object.entries(e)){n[r]={default:{}},s.default&&(n[r].default=s.default);for(const[i,a]of Object.entries(s))i!=="default"&&a&&(n[r][i]=a);Object.keys(n[r].default).length===0&&Object.keys(n[r]).length===1&&delete n[r]}return t.output.css.separate?{output:await He(n,t)}:{output:await Be(n,t)}}o(Q,"generate");async function ee(e){const t={files:[],errors:[]};for(const n of e)try{const r=!n.includes("*")&&!n.endsWith(".json")?N.join(n,"**/*.json"):n,s=await Ee(r,{absolute:!0,onlyFiles:!0});if(s.length===0){t.errors.push({pattern:n,error:u.LOAD.NO_FILES_FOUND(n)});continue}t.files.push(...s)}catch(r){t.errors.push({pattern:n,error:u.LOAD.GLOB_ERROR(n,r instanceof Error?r.message:"Unknown error")})}return t}o(ee,"resolveFiles");async function te(e){try{const t=await _(e,"utf-8");return JSON.parse(t)}catch(t){throw t instanceof Error&&t instanceof SyntaxError?new Error(u.LOAD.INVALID_JSON(e,t.message)):t}}o(te,"loadTree");function qe(e){const t=new Set;if(e.themes)for(const n of Object.values(e.themes))for(const r of n)t.add(r);return t}o(qe,"collectThemePaths");async function ne(e){const t=[],n=[],r=Array.isArray(e.tokens)?{default:{source:e.tokens,type:"custom"}}:"source"in e.tokens?{default:e.tokens}:e.tokens;for(const[s,i]of Object.entries(r)){const a=qe(i),{files:c,errors:l}=await ee(Array.isArray(i.source)?i.source:[i.source]);if(l.length>0){t.push(...l.map(f=>({file:f.pattern,message:f.error})));continue}for(const f of c){const p=O(process.cwd(),f);if(!a.has(p))try{const d=await te(f),I={collection:s,tokens:d,sourcePath:p};n.push(I)}catch(d){t.push({file:f,message:d instanceof Error?d.message:"Unknown error"})}}if(i.themes)for(const[f,p]of Object.entries(i.themes))try{const{files:d,errors:I}=await ee(p);if(I.length>0){t.push(...I.map(g=>({file:g.pattern,message:g.error})));continue}for(const g of d)try{const y=await te(g),A={collection:s,theme:f,tokens:y,sourcePath:O(process.cwd(),g)};n.push(A)}catch(y){t.push({file:g,message:y instanceof Error?y.message:"Unknown error"})}}catch(d){t.push({file:p.join(", "),message:d instanceof Error?d.message:"Unknown error"})}}return{trees:n,errors:t}}o(ne,"loadTreesFromConfig");async function re(e){const t=[],n=[],r=new Map;for(const[s,{collection:i,theme:a,content:c}]of Object.entries(e)){r.has(i)||r.set(i,new Map);const l=r.get(i);l.has(a)||l.set(a,[]),l.get(a)?.push({content:c,path:s})}for(const[s,i]of r)for(const[a,c]of i)for(const{content:l,path:f}of c)try{const p=JSON.parse(l);t.push({collection:s,theme:a,tokens:p,sourcePath:O(process.cwd(),f)})}catch(p){p instanceof Error?p instanceof SyntaxError?n.push({file:f,message:u.LOAD.INVALID_JSON(f,p.message)}):n.push({file:f,message:p.message}):n.push({file:f,message:"Unknown error"})}return{trees:t,errors:n}}o(re,"loadTreesFromMemory");function oe(e){const t=[],n=[],r=new Set,s=new Map;for(const c of e){const{collection:l,theme:f="default"}=c;r.add(l),s.has(l)||s.set(l,new Set),s.get(l)?.add(f)}const i={};function a(c){const l={default:{}};i[c]=l;const f=s.get(c);if(f)for(const p of f)l[p]={};return l}o(a,"addCollection");for(const c of r)a(c);for(const c of e){const{collection:l,theme:f="default",tokens:p}=c,d=i[l]||a(l);let I=d[f];I||(I=d[f]={});for(const[g,y]of Object.entries(p)){const A=g.replace(`${l}.`,"");I[A]=y}}return{tokens:i,errors:n,warnings:t}}o(oe,"normalizeTokens");function se(e,t){const n=new Map;for(const[r,s]of Object.entries(t)){if(!("$source"in s)){for(const l of e){const f=l.collection;n.has(f)||n.set(f,new Map);const p=n.get(f),d=l.theme;p.has(d)||p.set(d,{}),p.get(d)[r]=s}continue}const i=s.$source.collection,a=s.$source.theme;n.has(i)||n.set(i,new Map);const c=n.get(i);c.has(void 0)||c.set(void 0,{}),a||(c.get(void 0)[r]=s),a&&(c.has(a)||c.set(a,{}),c.get(a)[r]=s)}return e.map(r=>{const s=n.get(r.collection);if(!s)return{collection:r.collection,theme:r.theme,tokens:{}};if(r.theme){const a=s.get(r.theme)||{};return{collection:r.collection,theme:r.theme,tokens:a}}const i=s.get(void 0)||{};return{collection:r.collection,theme:r.theme,tokens:i}})}o(se,"processTrees");function b(e,t,n,r){return typeof t=="string"&&h(t)?Ke(e,t,n,r):Array.isArray(t)?t.map(s=>b(e,s,n,r)):typeof t=="object"&&t!==null?Object.entries(t).reduce((i,[a,c])=>Object.assign(i,{[a]:b(`${e}.${a}`,c,n,r)}),{}):t}o(b,"resolveValue");function ie(e){const t={},n=new Set,r=[];for(const[s,i]of Object.entries(e.tokens))try{if(!("$value"in i)){t[s]=i;continue}const a=i;t[s]={...a,$resolvedValue:b(a.$path,a.$value,e,n)}}catch(a){const c=a instanceof Error?a.message:String(a),l=i,f=l.$path,p=l.$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(f)),r.push({type:d,path:f,source:p,message:I})}return{resolved:t,errors:r}}o(ie,"resolve");function Ke(e,t,n,r){const s=t.slice(1,-1),i=n.pathIndex.get(s);if(!i)throw new Error(u.RESOLVE.REFERENCE_NOT_FOUND(s,e));if(r.has(i)){const l=n.tokens[i];throw!l||!("$path"in l)?new Error(u.RESOLVE.REFERENCE_NOT_FOUND(s,e)):new Error(u.RESOLVE.CIRCULAR_REFERENCE(e,l.$path))}const a=n.tokens[i];if(!a||!("$value"in a))throw new Error(u.RESOLVE.REFERENCE_NOT_FOUND(s,e));r.add(i);const c=b(i,a.$value,n,r);return r.delete(i),c}o(Ke,"resolveReferenceChain");const Xe={isObject:o(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 Ze(e,t,n,r);case"union":return Qe(e,t,n,r);case"array":return et(e,t,n,r);default:return Je(e,t,n,r)}}o($,"validateSchema");function Je(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)??[]}o(Je,"validateSimpleValue");function Ze(e,t,n,r){if(!Xe.isObject(t))return[{path:n,message:e.errorMessage?.(t,n)||u.VALIDATE.INVALID_TYPE("object",t,n),source:r}];const s=[],i=t;if(e.required)for(const a of e.required)a in i||s.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&&s.push(...$(c,i[a],`${n}.${a}`,r));return s}o(Ze,"validateObject");function Qe(e,t,n,r){let s=[],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 e.validate?.(t,n,r)??[];c.length<i&&(s=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}]:s}o(Qe,"validateUnion");function et(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}]}o(et,"validateArray");const S={schema:{type:"string",errorMessage:o((e,t)=>u.VALIDATE.INVALID_COLOR(e,t),"errorMessage"),validate:o((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")}};function tt(e,t,n){return $(S.schema,e,t,n)}o(tt,"validateColor");const L={schema:{type:"number",errorMessage:o((e,t)=>u.VALIDATE.INVALID_NUMBER(e,t),"errorMessage"),validate:o((e,t,n)=>typeof e!="number"||Number.isNaN(e)?[{path:t,message:u.VALIDATE.INVALID_NUMBER(e,t),source:n}]:[],"validate")}};function nt(e,t,n){return $(L.schema,e,t,n)}o(nt,"validateNumber");const E={schema:{type:"object",errorMessage:o((e,t)=>u.VALIDATE.INVALID_DIMENSION(e,t),"errorMessage"),properties:{value:L.schema,unit:{type:"string",validate:o((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 rt(e,t,n){return $(E.schema,e,t,n)}o(rt,"validateDimension");const ae={schema:{type:"union",oneOf:[{type:"string",errorMessage:o((e,t)=>u.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")},{type:"array",errorMessage:o((e,t)=>u.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage"),validate:o((e,t,n)=>e.every(s=>typeof s=="string")?[]:[{path:t,message:u.VALIDATE.INVALID_FONT_FAMILY(e,t),source:n}],"validate")}],errorMessage:o((e,t)=>u.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")}};function ot(e,t,n){return $(ae.schema,e,t,n)}o(ot,"validateFontFamily");const st=["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"],ce={schema:{type:"union",errorMessage:o((e,t)=>u.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),oneOf:[{type:"number",errorMessage:o((e,t)=>u.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:o((e,t,n)=>e<1||e>1e3?[{path:t,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}]:[],"validate")},{type:"string",errorMessage:o((e,t)=>u.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:o((e,t,n)=>st.includes(e.toLowerCase())?[]:[{path:t,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}],"validate")}]}};function it(e,t,n){return $(ce.schema,e,t,n)}o(it,"validateFontWeight");const at=["ms","s"],x={schema:{type:"object",errorMessage:o((e,t)=>u.VALIDATE.INVALID_DURATION(e,t),"errorMessage"),properties:{value:L.schema,unit:{type:"string",validate:o((e,t,n)=>at.includes(e)?[]:[{path:t,message:u.VALIDATE.INVALID_DURATION_UNIT(e,t),source:n}],"validate")}},required:["value","unit"]}};function ct(e,t,n){return $(x.schema,e,t,n)}o(ct,"validateDuration");const le={schema:{type:"array",errorMessage:o((e,t)=>u.VALIDATE.INVALID_CUBIC_BEZIER(e,t),"errorMessage"),validate:o((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[s,,i]=r;return s<0||s>1||i<0||i>1?[{path:t,message:u.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}]:[]},"validate")}};function lt(e,t,n){return $(le.schema,e,t,n)}o(lt,"validateCubicBezier");const ut={schema:{type:"object",properties:{fontFamily:ae.schema,fontSize:E.schema,letterSpacing:E.schema,lineHeight:L.schema,fontWeight:ce.schema},required:["fontFamily","fontSize"],errorMessage:o((e,t)=>u.VALIDATE.INVALID_TYPOGRAPHY(e,t),"errorMessage")}};function ft(e,t,n){return $(ut.schema,e,t,n)}o(ft,"validateTypography");const dt=["solid","dashed","dotted","double","groove","ridge","outset","inset"],pt=["round","butt","square"],ht={type:"object",errorMessage:o((e,t)=>u.VALIDATE.INVALID_STROKE_STYLE(e,t),"errorMessage"),properties:{dashArray:{type:"array",validate:o((e,t,n)=>{const r=e,s=[];return r.forEach((i,a)=>{typeof i!="string"&&s.push(...$(E.schema,i,`${t}.${a}`,n))}),s},"validate")},lineCap:{type:"string",validate:o((e,t,n)=>pt.includes(e)?[]:[{path:t,message:u.VALIDATE.INVALID_STROKE_LINE_CAP(e,t),source:n}],"validate")}},required:["dashArray","lineCap"]},ue={schema:{type:"union",oneOf:[{type:"string",validate:o((e,t,n)=>!dt.includes(e)&&typeof e=="string"?[{path:t,message:u.VALIDATE.INVALID_STROKE_STYLE(e,t),source:n}]:[],"validate")},ht]}};function mt(e,t,n){return $(ue.schema,e,t,n)}o(mt,"validateStrokeStyle");const It={schema:{type:"object",properties:{color:S.schema,width:E.schema,style:ue.schema},required:["color","width","style"],errorMessage:o((e,t)=>u.VALIDATE.INVALID_BORDER(e,t),"errorMessage")}};function gt(e,t,n){return $(It.schema,e,t,n)}o(gt,"validateBorder");const $t={schema:{type:"object",properties:{duration:x.schema,delay:x.schema,timingFunction:le.schema},required:["duration","delay","timingFunction"],errorMessage:o((e,t)=>u.VALIDATE.INVALID_TRANSITION(e,t),"errorMessage")}};function yt(e,t,n){return $($t.schema,e,t,n)}o(yt,"validateTransition");const fe={schema:{type:"object",properties:{color:S.schema,offsetX:E.schema,offsetY:E.schema,blur:E.schema,spread:E.schema,inset:{type:"boolean",errorMessage:o((e,t)=>u.VALIDATE.INVALID_SHADOW_INSET(e,t),"errorMessage")}},required:["color","offsetX","offsetY","blur","spread"],errorMessage:o((e,t)=>u.VALIDATE.INVALID_SHADOW(e,t),"errorMessage")}};function At(e,t,n){const r=[];return Array.isArray(e)?(e.forEach((s,i)=>{r.push(...$(fe.schema,s,`${t}[${i}]`,n))}),r):$(fe.schema,e,t,n)}o(At,"validateShadow");const Et={type:"object",errorMessage:o((e,t)=>u.VALIDATE.INVALID_GRADIENT(e,t),"errorMessage"),properties:{color:{type:"string",validate:S.schema.validate},position:{type:"number",validate:o((e,t,n)=>e<0||e>1?[{path:t,message:u.VALIDATE.INVALID_GRADIENT_STOP_POSITION(e,t),source:n}]:[],"validate")}},required:["color","position"]},Nt={schema:{type:"array",errorMessage:o((e,t)=>u.VALIDATE.INVALID_ARRAY(e,t),"errorMessage"),validate:o((e,t,n)=>{const r=e,s=[];return r.forEach((i,a)=>{s.push(...$(Et,i,`${t}[${a}]`,n))}),s},"validate")}};function Tt(e,t,n){return $(Nt.schema,e,t,n)}o(Tt,"validateGradient");const bt={schema:{type:"object",errorMessage:o((e,t)=>u.VALIDATE.INVALID_FLUID_DIMENSION(e,t),"errorMessage"),properties:{min:E.schema,max:E.schema},required:["min","max"]}};function St(e,t,n){return $(bt.schema,e,t,n)}o(St,"validateFluidDimension");const Lt={color:tt,dimension:rt,fluidDimension:St,duration:ct,cubicBezier:lt,fontFamily:ot,fontWeight:it,number:nt,strokeStyle:mt,typography:ft,border:gt,shadow:At,gradient:Tt,transition:yt};function de(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 s=Lt[r.$type];if(!s){t.push({path:r.$path,message:u.VALIDATE.UNKNOWN_TOKEN_TYPE(r.$type,r.$path),source:r.$source});continue}const i=r;t.push(...s(i.$value,i.$path,i.$source))}return t}o(de,"validate");async function Dt(e,t){const n={load:[],flatten:[],validation:[],resolution:[]},r={normalization:[]},{trees:s,errors:i}=await(t?.loader?.type==="memory"?re(t.loader.data):ne(e));n.load.push(...i);const{tokens:a,errors:c}=H(s);n.flatten.push(...c);const l=de(a);if(n.validation.push(...l),l.length>0)return{output:[],trees:s,errors:n,warnings:r};const{resolved:f,errors:p}=ie(a);n.resolution.push(...p);const d=se(s,f),{tokens:I,warnings:g}=oe(d);r.normalization.push(...g);const y=B(I,e),{output:A}=await Q(y,e);return{output:A,trees:s,errors:n,warnings:r}}o(Dt,"tokensToCSSPipeline");async function _t(e,t){const{trees:n,errors:r}=await(t.loader.type==="memory"?re(t.loader.data):ne(t.loader.paths)),{tokens:s,errors:i}=H(n),a=de(s),{resolved:c,errors:l}=ie(s);return{trees:n,flattenedTokens:s,resolved:c,errors:{load:r,flatten:i,validation:a,resolution:l}}}o(_t,"validationPipeline");async function Ot(e,t,n){const r={normalization:[]},s=se(e,t),{tokens:i,warnings:a}=oe(s);r.normalization.push(...a);const c=B(i,n),{output:l}=await Q(c,n);return{output:l,warnings:r}}o(Ot,"generationPipeline");const pe=m.object({tokens:m.union([m.object({source:m.array(m.string()),type:m.enum(["starter-kit","custom"]),themes:m.record(m.array(m.string())).optional()}),m.record(m.string(),m.object({source:m.array(m.string()),type:m.enum(["starter-kit","custom"]),themes:m.record(m.array(m.string())).optional()}))]),options:m.object({fluid:m.object({min:m.number(),max:m.number()}).strict().optional(),prefix:m.string().optional(),color:m.enum(["hex","rgb","rgba","hsl","hsla","oklch","p3"]).optional()}).optional(),output:m.object({directories:m.object({tokens:m.string(),components:m.string().optional(),css:m.string()}),css:m.object({separate:m.boolean(),manageIndex:m.boolean().optional(),format:m.enum(["css","scss","less"]).optional()})})});function he(e){const t=pe.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const s=r.path.join(".");return u.CONFIG.INVALID_CONFIG(s||"root",r.message)});throw new Error(n.join(`
16
- `))}return Vt(t.data),t.data}o(he,"validateConfig");function me(e){try{const t=JSON.parse(e);return he(t)}catch(t){throw t instanceof SyntaxError?new Error(u.CONFIG.INVALID_JSON(t.message)):t}}o(me,"parseAndValidateConfig");function Vt(e){if(typeof e.tokens=="object")for(const[t,n]of Object.entries(e.tokens)){if(!n.source?.length)continue;const r=new Map;for(const s of n.source){const i=N.basename(s),a=r.get(i)||[];r.set(i,[...a,s])}for(const[s,i]of r)if(i.length>1)throw new Error(u.CONFIG.DUPLICATE_FILENAMES(t,s,i))}}o(Vt,"validateFileNames");async function Ft(e="sugarcube.config.json"){try{const t=await ye.readFile(e,"utf-8");return me(t)}catch(t){throw t instanceof Error&&"code"in t&&t.code==="ENOENT"?new Error(u.CONFIG.FILE_NOT_FOUND(e)):t}}o(Ft,"loadConfig");function vt(e){return"source"in e&&Array.isArray(e.source)}o(vt,"isSingleCollection");function kt(e){return`/**
17
- * THIS FILE IS AUTOMATICALLY GENERATED BY SUGARCUBE FROM YOUR DESIGN TOKENS
18
- * If you edit this file directly, your changes may be lost the next time
19
- * your design tokens are updated or the sugarcube CLI/plugin is run.
20
- *
21
- * To make changes, edit your token files instead.
22
- *
23
- * For more information, see: https://sugarcube.style/docs/generated-files
24
- */
13
+ `,collection:i})}return r}s(mt,"generateSingleFile");async function It(e,t){const o=`${t.output?.css||"src/styles"}/${q}`,r=[];for(const[i,a]of V(e)){if(Object.keys(a).length===0)continue;const c=Object.entries(a).sort(([l],[u])=>l==="default"?-1:u==="default"?1:l.localeCompare(u));for(const[l,u]of c)if(Object.keys(u).length!==0)if(l==="default"){const p=new Map;for(const[d,h]of V(u)){if(!("$type"in h))continue;const $=h.$source.sourcePath;p.has($)||p.set($,{}),p.get($)[d]=h}for(const[d,h]of Array.from(p.entries()).sort(([y],[$])=>y.localeCompare($))){if(Object.keys(h).length===0)continue;const y=d.split("/").pop()?.replace(/\.json$/,"")??"tokens",A=(await Q(h,{collection:i==="default"?void 0:i})).output[0].css;A.trim()&&r.push({path:i==="default"?`${o}/${y}${S}`:`${o}/${i}/${y}${S}`,css:A,collection:i})}}else{const d=(await Q(u,{theme:l,collection:i==="default"?void 0:i})).output[0].css;d.trim()&&r.push({path:i==="default"?`${o}/${l}${S}`:`${o}/${i}/${l}${S}`,css:d,collection:i})}}return r}s(It,"generateSeparateFiles");async function yt(e,t){const n={};for(const[o,r]of Object.entries(e)){n[o]={default:{}},r.default&&(n[o].default=r.default);for(const[i,a]of Object.entries(r))i!=="default"&&a&&(n[o][i]=a);Object.keys(n[o].default).length===0&&Object.keys(n[o]).length===1&&delete n[o]}return t.output?.separate?{output:await It(n,t)}:{output:await mt(n,t)}}s(yt,"generate");async function $t(e,t){const{output:n}=await yt(e,t);return n}s($t,"generateCSSVariables");const f={LOAD:{NO_FILES_FOUND:s(e=>`No files found matching pattern: ${e}.`,"NO_FILES_FOUND"),INVALID_JSON:s((e,t)=>`Invalid JSON in file ${e}: ${t}`,"INVALID_JSON"),GLOB_ERROR:s((e,t)=>`Error resolving glob pattern ${e}: ${t}`,"GLOB_ERROR")},FLATTEN:{INVALID_TOKEN_NAME:s(e=>`Invalid token name "${e}": Token names cannot contain dots (.), curly braces ({,}), or other special characters`,"INVALID_TOKEN_NAME"),MISSING_DOLLAR_PREFIX:s(e=>`Token at ${e} is using 'value' or 'type' without the required '$' prefix. Use '$value' and '$type' instead.`,"MISSING_DOLLAR_PREFIX"),INVALID_TOKEN_NESTING:s(e=>`Token at "${e}" cannot contain child tokens or groups. Only metadata properties (starting with $) are allowed.`,"INVALID_TOKEN_NESTING"),COMPOSITE_TOKEN_MISSING_TYPE:s(e=>`Composite token at '${e}' is missing the required "$type" property. Composite tokens (tokens with object values) must specify their type to define their structure.`,"COMPOSITE_TOKEN_MISSING_TYPE"),CONFLICT_TOKEN_VS_GROUP:s(e=>`Conflict at "${e}": token vs group. A token cannot be replaced by a group (or vice versa).`,"CONFLICT_TOKEN_VS_GROUP"),CONFLICT_INCOMPATIBLE_TYPES:s((e,t,n)=>`Type conflict at "${n}": expected ${e}, got ${t}`,"CONFLICT_INCOMPATIBLE_TYPES")},METADATA:{COLLECTION_ERROR:s(e=>`Error collecting metadata: ${e}`,"COLLECTION_ERROR"),INVALID_EXTENSIONS:s(e=>`Invalid extensions at ${e}: expected object, got ${typeof e}`,"INVALID_EXTENSIONS"),INVALID_DESCRIPTION:s(e=>`Invalid description at ${e}: expected string, got ${typeof e}`,"INVALID_DESCRIPTION")},VALIDATE:{MISSING_TYPE:s(e=>`Token at '${e}' is missing the "$type" property`,"MISSING_TYPE"),UNKNOWN_TOKEN_TYPE:s((e,t)=>`Unknown token type '${e}' at ${t}. Valid types are: color, dimension, fontFamily, fontWeight, duration, cubicBezier, strokeStyle, border, transition, shadow, gradient, typography`,"UNKNOWN_TOKEN_TYPE"),INVALID_COLOR:s((e,t)=>`Invalid color at ${t}: '${e}'. Color should be a valid hex value or W3C color object`,"INVALID_COLOR"),INVALID_DIMENSION:s((e,t)=>`Invalid dimension at '${t}': ${e}. Dimensions should have a numeric value and unit, like { "value": 16, "unit": "px" }`,"INVALID_DIMENSION"),INVALID_DIMENSION_UNIT:s((e,t)=>`Invalid unit at ${t}': '${e}'. Unit must be either "px" or "rem"`,"INVALID_DIMENSION_UNIT"),INVALID_FONT_FAMILY:s((e,t)=>`Invalid font family at '${t}': ${e}. Should be a string or array of strings, like "Arial" or ["Arial", "sans-serif"]`,"INVALID_FONT_FAMILY"),INVALID_FONT_WEIGHT:s((e,t)=>`Invalid font weight at '${t}': ${e}. Should be a number between 1-1000 or a keyword like "thin", "light", "normal", "bold"`,"INVALID_FONT_WEIGHT"),INVALID_DURATION:s((e,t)=>`Invalid duration at '${t}': ${e}. Should be like { "value": 300, "unit": "ms" }`,"INVALID_DURATION"),INVALID_DURATION_UNIT:s((e,t)=>`Invalid unit at ${t}: "${e}". Unit must be "ms" or "s"`,"INVALID_DURATION_UNIT"),INVALID_CUBIC_BEZIER:s((e,t)=>`Invalid cubic bezier at ${t}: "${e}". Should be an array of 4 numbers between 0 and 1`,"INVALID_CUBIC_BEZIER"),INVALID_STROKE_STYLE:s((e,t)=>`Invalid stroke style at ${t}: "${e}". Should be "solid", "dashed", "dotted", etc.`,"INVALID_STROKE_STYLE"),INVALID_STROKE_LINE_CAP:s((e,t)=>`Invalid line cap at ${t}: "${e}". Should be one of: round, butt, square`,"INVALID_STROKE_LINE_CAP"),INVALID_BORDER:s((e,t)=>`Invalid border at ${t}: "${e}". Should have color, width, and style properties`,"INVALID_BORDER"),INVALID_SHADOW:s((e,t)=>`Invalid shadow at ${t}: "${e}". Should have color, offsetX, offsetY properties (blur and spread are optional)`,"INVALID_SHADOW"),INVALID_SHADOW_INSET:s((e,t)=>`Invalid inset value at ${t}: "${e}". Should be true or false`,"INVALID_SHADOW_INSET"),INVALID_TRANSITION:s((e,t)=>`Invalid transition at ${t}: "${e}". Should have duration, delay, and timingFunction properties`,"INVALID_TRANSITION"),INVALID_GRADIENT:s((e,t)=>`Invalid gradient at ${t}: "${e}". Should be an array of color stops with position values between 0 and 1`,"INVALID_GRADIENT"),INVALID_GRADIENT_STOP_POSITION:s((e,t)=>`Invalid gradient stop position at ${t}: "${e}". Position must be between 0 and 1`,"INVALID_GRADIENT_STOP_POSITION"),INVALID_TYPOGRAPHY:s((e,t)=>`Invalid typography at ${t}: "${e}". Should have fontFamily and fontSize (fontWeight, letterSpacing, and lineHeight are optional)`,"INVALID_TYPOGRAPHY"),MISSING_REQUIRED_PROPERTY:s((e,t)=>`Missing required property '${e}' at ${t}`,"MISSING_REQUIRED_PROPERTY"),INVALID_NUMBER:s((e,t)=>`Invalid number at ${t}: "${e}". Expected a number value`,"INVALID_NUMBER"),INVALID_ARRAY:s((e,t)=>`Invalid array at ${t}: "${e}". Expected an array value`,"INVALID_ARRAY"),MISSING_FLUID_CONFIG:s(e=>`Missing fluid configuration. Token at ${e} requires fluid viewport settings.`,"MISSING_FLUID_CONFIG"),INVALID_FLUID_DIMENSION:s((e,t)=>`Invalid fluid dimension at ${t}: "${e}". Fluid dimensions should have min and max values, like { "min": { "value": 16, "unit": "px" }, "max": { "value": 24, "unit": "px" } }`,"INVALID_FLUID_DIMENSION"),INVALID_VIEWPORT_CONFIG:s((e,t)=>`Invalid viewport configuration at ${t}: "${e}". Viewport config should have min and max dimension values`,"INVALID_VIEWPORT_CONFIG"),MISMATCHED_UNITS:s((e,t,n)=>`Mismatched units at ${n}: min uses '${e}', max uses '${t}'. Both values must use the same unit`,"MISMATCHED_UNITS"),INVALID_FLUID_VALUE_RANGE:s(e=>`Invalid fluid value range at ${e}: min value must be less than max value`,"INVALID_FLUID_VALUE_RANGE"),INVALID_TOKEN_TYPE:s((e,t,n)=>`Invalid token type at ${n}: expected ${e}, got ${t}`,"INVALID_TOKEN_TYPE"),INVALID_TYPE:s((e,t,n)=>`Expected ${e}, received ${typeof t} at ${n}`,"INVALID_TYPE"),INVALID_ENUM_VALUE:s((e,t,n)=>`Expected value to be one of [${e.join(", ")}], but got ${String(t)} at ${n}`,"INVALID_ENUM_VALUE")},RESOLVE:{CIRCULAR_REFERENCE:s((e,t)=>`Circular reference detected: ${e} -> ${t}`,"CIRCULAR_REFERENCE"),REFERENCE_NOT_FOUND:s((e,t)=>`Reference not found: ${e} in ${t}. Does ${e} exist?`,"REFERENCE_NOT_FOUND"),TYPE_MISMATCH:s(e=>`Type mismatch in ${e}`,"TYPE_MISMATCH")},GENERATE:{INVALID_CSS_VALUE:s((e,t)=>`Invalid CSS value for property '${e}': ${t}`,"INVALID_CSS_VALUE"),INVALID_VARIABLE_NAME:s((e,t)=>`Invalid CSS variable name at '${e}': ${t}`,"INVALID_VARIABLE_NAME")},CONFIG:{INVALID_JSON:s(e=>`Invalid JSON in config file: ${e}`,"INVALID_JSON"),INVALID_CONFIG:s((e,t)=>`Invalid configuration at ${e}: ${t}`,"INVALID_CONFIG"),DUPLICATE_FILENAMES:s((e,t,n)=>`Duplicate filename "${t}" found in collection "${e}":
14
+ ${n.map(o=>` - ${o}`).join(`
15
+ `)}`,"DUPLICATE_FILENAMES"),FILE_NOT_FOUND:s(e=>e===F?`Cannot find sugarcube config file. Please ensure you have a valid ${F} file in your project root.`:`Cannot find sugarcube config file at "${e}". Please check the path and file permissions.`,"FILE_NOT_FOUND")},UTILITIES:{RESERVED_PREFIX:s((e,t)=>`Cannot use reserved prefix "${e}" for ${t} token type. This prefix is reserved for default utility classes. Please use a custom prefix instead.`,"RESERVED_PREFIX"),DUPLICATE_CLASS_NAME:s((e,t)=>`Ambiguous utility class "${e}" would be generated from multiple token paths: ${t.join(", ")}. This would make it impossible to know which token value should be used when this class is applied in HTML. To fix this, configure one or more paths with custom prefixes to make the intent clear.`,"DUPLICATE_CLASS_NAME"),INVALID_PROPERTY_MAPPING:s(e=>`Invalid property mapping for ${e} token type. When mapping multiple properties, each mapping must include a unique prefix to avoid class name collisions.`,"INVALID_PROPERTY_MAPPING"),DUPLICATE_PREFIX:s((e,t)=>`Duplicate prefix "${e}" found in property mappings for ${t} token type. Each property mapping must have a unique prefix to avoid class name collisions.`,"DUPLICATE_PREFIX"),INVALID_COLLECTION:s((e,t,n)=>`Utility config for '${e}' specifies collection '${t}', but this collection does not exist. Available collections: ${n.join(", ")||"none"}`,"INVALID_COLLECTION"),TOKEN_PATH_CONFLICT:s((e,t)=>`Token path conflict: "${e}" exists in multiple collections (${t}). To resolve this conflict, either:
16
+ 1. Use unique token paths per collection
17
+ 2. Configure utilities to be collection-specific: { source: "color.*", collection: "base" }`,"TOKEN_PATH_CONFLICT"),MISSING_SOURCE:s(e=>`Utility config for '${e}' must have a valid 'source' property`,"MISSING_SOURCE"),INVALID_SOURCE_PATTERN:s((e,t)=>`Utility config for '${e}' has invalid source pattern '${t}'. Only patterns ending with '.*' are supported (e.g., 'color.*', 'font.weight.*').`,"INVALID_SOURCE_PATTERN"),INVALID_DIRECTIONS:s(e=>`Utility config for '${e}' must have 'directions' as an array`,"INVALID_DIRECTIONS"),INVALID_CONFIG_OBJECT:"utilitiesConfig must be an object",INVALID_TOKENS_OBJECT:"tokens must be an object"}};function ee(e){return typeof e=="object"&&e!==null&&"$value"in e}s(ee,"isTokenNode");function gt(e,t,n){for(const[o,r]of Object.entries(t.tokens)){const i=e.tokens[o];if(!ee(r)){if(i&&ee(i)){const d=i;n.push({path:d.$path,source:d.$source,message:f.FLATTEN.CONFLICT_TOKEN_VS_GROUP(d.$path)});continue}e.tokens[o]=r;continue}if(!i){e.tokens[o]=r;continue}if(!ee(i)){n.push({path:r.$path,source:r.$source,message:f.FLATTEN.CONFLICT_TOKEN_VS_GROUP(r.$path)});continue}const c=r,l=i,u=!!c.$type,p=!!l.$type;if(u&&p&&c.$type!==l.$type){n.push({path:c.$path,source:c.$source,message:f.FLATTEN.CONFLICT_INCOMPATIBLE_TYPES(String(l.$type??"unknown"),String(c.$type??"unknown"),c.$path)});continue}e.tokens[o]=r}for(const[o,r]of t.pathIndex)e.pathIndex.set(o,r)}s(gt,"mergeFlattenedInto");function Tt(e){if(typeof e!="object"||e===null||"$value"in e)return!1;const t="value"in e,n="type"in e;if(t&&n)return!0;if(t){const o=e.value;return typeof o=="string"||typeof o=="number"||Array.isArray(o)}return!1}s(Tt,"looksLikeUnprefixedToken");function Et(e,t){const n={tokens:{},pathIndex:new Map},o=[];function r(a=[]){const c=[t.collection];return t.theme&&c.push(t.theme),a.length>0&&c.push(a.join(".")),c.join(".")}s(r,"createLookupKey"),(e.$description||e.$extensions)&&(n.tokens[r()]={$description:e.$description,$extensions:e.$extensions});function i(a,c=[],l){if(c.join("."),c.length>0){const d=r(c);n.tokens[d]={$description:a.$description,$extensions:a.$extensions,$path:c.join("."),$source:{collection:t.collection,theme:t.theme,sourcePath:t.sourcePath}}}const u=Object.keys(a).filter(d=>!d.startsWith("$")),p=a.$type||l;for(const d of u){const h=a[d],y=[...c,d],$=y.join(".");if(Tt(h)){o.push({path:$,source:t,message:f.FLATTEN.MISSING_DOLLAR_PREFIX($)});continue}if(d.includes(".")||d.includes("{")||d.includes("}")){o.push({path:$,source:t,message:f.FLATTEN.INVALID_TOKEN_NAME(d)});continue}if("$value"in h){if(Object.keys(h).filter(Qe=>!Qe.startsWith("$")).length>0){o.push({path:$,source:t,message:f.FLATTEN.INVALID_TOKEN_NESTING($)});continue}if(it(h)&&!h.$type&&!p){o.push({path:$,source:t,message:f.FLATTEN.COMPOSITE_TOKEN_MISSING_TYPE($)});continue}const v=r(y),H=y.join(".");n.tokens[v]={...h,...h.$type||p?{$type:h.$type||p}:{},$path:H,$source:{collection:t.collection,theme:t.theme,sourcePath:t.sourcePath},$originalPath:H},n.pathIndex.set(H,v)}else i(h,y,p)}}return s(i,"processNode"),i(e),{tokens:n,errors:o}}s(Et,"flattenTree");function At(e){const t={tokens:{},pathIndex:new Map},n=[];for(const o of e){const{tokens:r,errors:i}=Et(o.tokens,{collection:o.collection,theme:o.theme,sourcePath:o.sourcePath});n.push(...i),gt(t,r,n)}return{tokens:t,errors:n}}s(At,"flatten");async function Te(e){const t={files:[],errors:[]};for(const n of e)try{const o=!n.includes("*")&&!n.endsWith(".json")?N(n,"**/*.json"):n,r=await z(o,{absolute:!0,onlyFiles:!0});if(r.length===0){t.errors.push({pattern:n,error:f.LOAD.NO_FILES_FOUND(n)});continue}t.files.push(...r)}catch(o){t.errors.push({pattern:n,error:f.LOAD.GLOB_ERROR(n,o instanceof Error?o.message:"Unknown error")})}return t}s(Te,"resolveFiles");async function Ee(e){try{const t=await K(e,"utf-8");return JSON.parse(t)}catch(t){throw t instanceof Error&&t instanceof SyntaxError?new Error(f.LOAD.INVALID_JSON(e,t.message)):t}}s(Ee,"loadTree");function bt(e){const t=new Set;if(e.themes)for(const n of Object.values(e.themes))for(const o of n)t.add(o);return t}s(bt,"collectThemePaths");async function Nt(e){const t=[],n=[];if(!e.tokens)return{trees:[],errors:[]};const o=Array.isArray(e.tokens)?{default:{source:e.tokens}}:"source"in e.tokens?{default:e.tokens}:e.tokens;if(!Object.values(o).some(i=>i.source.some(a=>{try{return z.sync(a).length>0}catch{return!1}})))return{trees:[],errors:[{file:F,message:f.LOAD.NO_FILES_FOUND(Object.values(o).flatMap(i=>i.source).join(", "))}]};for(const[i,a]of Object.entries(o)){const c=bt(a),{files:l,errors:u}=await Te(Array.isArray(a.source)?a.source:[a.source]);if(u.length>0){t.push(...u.map(p=>({file:p.pattern,message:p.error})));continue}for(const p of l){const d=_(process.cwd(),p);if(!c.has(d))try{const h=await Ee(p),y={collection:i,tokens:h,sourcePath:d};n.push(y)}catch(h){t.push({file:p,message:h instanceof Error?h.message:"Unknown error"})}}if(a.themes)for(const[p,d]of Object.entries(a.themes))try{const{files:h,errors:y}=await Te(d);if(y.length>0){t.push(...y.map($=>({file:$.pattern,message:$.error})));continue}for(const $ of h)try{const A=await Ee($),v={collection:i,theme:p,tokens:A,sourcePath:_(process.cwd(),$)};n.push(v)}catch(A){t.push({file:$,message:A instanceof Error?A.message:"Unknown error"})}}catch(h){t.push({file:d.join(", "),message:h instanceof Error?h.message:"Unknown error"})}}return{trees:n,errors:t}}s(Nt,"loadTreesFromConfig");async function St(e){const t=[],n=[],o=new Map;for(const[r,{collection:i,theme:a,content:c}]of Object.entries(e)){o.has(i)||o.set(i,new Map);const l=o.get(i);l.has(a)||l.set(a,[]),l.get(a)?.push({content:c,path:r})}for(const[r,i]of o)for(const[a,c]of i)for(const{content:l,path:u}of c)try{const p=JSON.parse(l);t.push({collection:r,theme:a,tokens:p,sourcePath:_(process.cwd(),u)})}catch(p){p instanceof Error?p instanceof SyntaxError?n.push({file:u,message:f.LOAD.INVALID_JSON(u,p.message)}):n.push({file:u,message:p.message}):n.push({file:u,message:"Unknown error"})}return{trees:t,errors:n}}s(St,"loadTreesFromMemory");function x(e,t,n,o){return typeof t=="string"&&I(t)?Ot(e,t,n,o):Array.isArray(t)?t.map(r=>x(e,r,n,o)):typeof t=="object"&&t!==null?Object.entries(t).reduce((i,[a,c])=>Object.assign(i,{[a]:x(`${e}.${a}`,c,n,o)}),{}):t}s(x,"resolveValue");function Ae(e,t){const n=e.slice(1,-1),o=t.pathIndex.get(n);if(!o)return;const r=t.tokens[o];if(!(!r||!("$value"in r))){if(r.$type)return r.$type;if(typeof r.$value=="string"&&I(r.$value))return Ae(r.$value,t)}}s(Ae,"inferTypeFromReference");function Lt(e){const t={},n=new Set,o=[];for(const[r,i]of Object.entries(e.tokens))try{if(!("$value"in i)){t[r]=i;continue}const a=i;let c=a.$type;!c&&typeof a.$value=="string"&&I(a.$value)&&(c=Ae(a.$value,e)),t[r]={...a,...c?{$type:c}:{},$resolvedValue:x(a.$path,a.$value,e,n)}}catch(a){const c=a instanceof Error?a.message:String(a),l=i,u=l.$path,p=l.$source;let d,h;c.includes("Circular reference detected")?(d="circular",h=c):c.includes("Reference not found")?(d="missing",h=c):(d="type-mismatch",h=f.RESOLVE.TYPE_MISMATCH(u)),o.push({type:d,path:u,source:p,message:h})}return{resolved:t,errors:o}}s(Lt,"resolve");function Ot(e,t,n,o){const r=t.slice(1,-1),i=n.pathIndex.get(r);if(!i)throw new Error(f.RESOLVE.REFERENCE_NOT_FOUND(r,e));if(o.has(i)){const l=n.tokens[i];throw!l||!("$path"in l)?new Error(f.RESOLVE.REFERENCE_NOT_FOUND(r,e)):new Error(f.RESOLVE.CIRCULAR_REFERENCE(e,l.$path))}const a=n.tokens[i];if(!a||!("$value"in a))throw new Error(f.RESOLVE.REFERENCE_NOT_FOUND(r,e));o.add(i);const c=x(i,a.$value,n,o);return o.delete(i),c}s(Ot,"resolveReferenceChain");function b(e){return{success:!0,value:e}}s(b,"success");function T(e){return{success:!1,error:e}}s(T,"error");function te(e){if(typeof e!="object"||e===null)return!1;const t=e;return!(typeof t.colorSpace!="string"||!["oklch","display-p3","srgb","hsl"].includes(t.colorSpace)||!Array.isArray(t.components)||t.components.length!==3||!t.components.every(o=>typeof o=="number"||o==="none")||t.alpha!==void 0&&typeof t.alpha!="number"||t.hex!==void 0&&typeof t.hex!="string")}s(te,"isW3CColorValue");function R(e){const t=[],n=["oklch","display-p3","srgb","hsl"];if(n.includes(e.colorSpace)||t.push(`Unsupported colorSpace: "${e.colorSpace}". Supported color spaces: ${n.join(", ")}.`),!Array.isArray(e.components)||e.components.length!==3)t.push("Components must be an array of exactly 3 numbers.");else if(e.components.forEach((o,r)=>{o!=="none"&&(typeof o!="number"||!Number.isFinite(o))&&t.push(`Component ${r} must be a finite number or "none".`)}),e.colorSpace==="oklch"){const[o,r,i]=e.components;o!=="none"&&(o<0||o>1)&&t.push("OKLCH Lightness (L) must be between 0 and 1 or 'none'."),r!=="none"&&r<0&&t.push("OKLCH Chroma (C) must be >= 0 or 'none'."),i!=="none"&&(i<0||i>=360)&&t.push("OKLCH Hue (H) must be between 0 and 360 (exclusive) or 'none'.")}else if(e.colorSpace==="display-p3"){const[o,r,i]=e.components;o!=="none"&&(o<0||o>1)&&t.push("Display P3 Red component must be between 0 and 1 or 'none'."),r!=="none"&&(r<0||r>1)&&t.push("Display P3 Green component must be between 0 and 1 or 'none'."),i!=="none"&&(i<0||i>1)&&t.push("Display P3 Blue component must be between 0 and 1 or 'none'.")}else if(e.colorSpace==="srgb"){const[o,r,i]=e.components;o!=="none"&&(o<0||o>1)&&t.push("sRGB Red component must be between 0 and 1 or 'none'."),r!=="none"&&(r<0||r>1)&&t.push("sRGB Green component must be between 0 and 1 or 'none'."),i!=="none"&&(i<0||i>1)&&t.push("sRGB Blue component must be between 0 and 1 or 'none'.")}else if(e.colorSpace==="hsl"){const[o,r,i]=e.components;o!=="none"&&(o<0||o>=360)&&t.push("HSL Hue must be between 0 and 360 (exclusive) or 'none'."),r!=="none"&&(r<0||r>100)&&t.push("HSL Saturation must be between 0 and 100 or 'none'."),i!=="none"&&(i<0||i>100)&&t.push("HSL Lightness must be between 0 and 100 or 'none'.")}return e.alpha!==void 0&&(typeof e.alpha!="number"||!Number.isFinite(e.alpha)?t.push("Alpha must be a finite number."):(e.alpha<0||e.alpha>1)&&t.push("Alpha must be between 0 and 1.")),t}s(R,"validateW3CColorValue");function _t(e){const t=R(e);return t.length>0?T(t.join(", ")):b(e)}s(_t,"validateW3CColorValueResult");function Dt(e){const t=_t(e);if(!t.success)return t;const[n,o,r]=e.components,i=e.alpha,a=n==="none"?"none":Number(n.toFixed(4)),c=o==="none"?"none":Number(o.toFixed(4)),l=r==="none"?"none":Number(r.toFixed(4));if(i!==void 0&&i!==1){const u=Number(i.toFixed(4));return b(`oklch(${a} ${c} ${l} / ${u})`)}return b(`oklch(${a} ${c} ${l})`)}s(Dt,"formatW3CColorToOKLCH");const Ft={isObject:s(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObject")};function g(e,t,n,o){if(I(t))return[];switch(e.type){case"object":return vt(e,t,n,o);case"union":return Ct(e,t,n,o);case"array":return wt(e,t,n,o);default:return kt(e,t,n,o)}}s(g,"validateSchema");function kt(e,t,n,o){return e.type!==typeof t?[{path:n,message:e.errorMessage?.(t,n)||f.VALIDATE.INVALID_TYPE(e.type,t,n),source:o}]:e.validate?.(t,n,o)??[]}s(kt,"validateSimpleValue");function vt(e,t,n,o){if(!Ft.isObject(t))return[{path:n,message:e.errorMessage?.(t,n)||f.VALIDATE.INVALID_TYPE("object",t,n),source:o}];const r=[],i=t;if(e.required)for(const a of e.required)a in i||r.push({path:`${n}.${a}`,message:f.VALIDATE.MISSING_REQUIRED_PROPERTY(a,n),source:o});for(const[a,c]of Object.entries(e.properties))a in i&&r.push(...g(c,i[a],`${n}.${a}`,o));return r}s(vt,"validateObject");function Ct(e,t,n,o){let r=[],i=Number.POSITIVE_INFINITY;for(const a of e.oneOf){if(a.type==="string"&&typeof t!="string"||a.type==="object"&&typeof t!="object")continue;const c=g(a,t,n,o);if(c.length===0)return a.validate?.(t,n,o)??[];c.length<i&&(r=c,i=c.length)}return i===Number.POSITIVE_INFINITY?[{path:n,message:f.VALIDATE.INVALID_TYPE(e.oneOf.map(a=>a.type).join(" or "),t,n),source:o}]:r}s(Ct,"validateUnion");function wt(e,t,n,o){return Array.isArray(t)?e.validate?.(t,n,o)??[]:[{path:n,message:e.errorMessage?.(t,n)||f.VALIDATE.INVALID_TYPE("array",t,n),source:o}]}s(wt,"validateArray");const j={schema:{type:"union",oneOf:[{type:"string",validate:s((e,t,n)=>/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/.test(e)?[]:[{path:t,message:f.VALIDATE.INVALID_COLOR(e,t),source:n}],"validate")},{type:"object",required:["colorSpace","components"],properties:{colorSpace:{type:"string"},components:{type:"array"},alpha:{type:"number"},hex:{type:"string"}},validate:s((e,t,n)=>te(e)?R(e).map(r=>({path:t,message:`Invalid color at ${t}: ${r}`,source:n})):[{path:t,message:f.VALIDATE.INVALID_COLOR(e,t),source:n}],"validate")}]}};function Vt(e,t,n){return g(j.schema,e,t,n)}s(Vt,"validateColor");const P={schema:{type:"number",errorMessage:s((e,t)=>f.VALIDATE.INVALID_NUMBER(e,t),"errorMessage"),validate:s((e,t,n)=>typeof e!="number"||Number.isNaN(e)?[{path:t,message:f.VALIDATE.INVALID_NUMBER(e,t),source:n}]:[],"validate")}};function xt(e,t,n){return g(P.schema,e,t,n)}s(xt,"validateNumber");const E={schema:{type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_DIMENSION(e,t),"errorMessage"),properties:{value:P.schema,unit:{type:"string",validate:s((e,t,n)=>typeof e!="string"||!["px","rem"].includes(e)?[{path:t,message:f.VALIDATE.INVALID_DIMENSION_UNIT(e,t),source:n}]:[],"validate")}},required:["value","unit"]}};function Rt(e,t,n){return g(E.schema,e,t,n)}s(Rt,"validateDimension");const be={schema:{type:"union",oneOf:[{type:"string",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")},{type:"array",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage"),validate:s((e,t,n)=>e.every(r=>typeof r=="string")?[]:[{path:t,message:f.VALIDATE.INVALID_FONT_FAMILY(e,t),source:n}],"validate")}],errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")}};function jt(e,t,n){return g(be.schema,e,t,n)}s(jt,"validateFontFamily");const Pt=["thin","hairline","extra-light","ultra-light","light","normal","regular","book","medium","semi-bold","demi-bold","bold","extra-bold","ultra-bold","black","heavy","extra-black","ultra-black"],Ne={schema:{type:"union",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),oneOf:[{type:"number",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>e<1||e>1e3?[{path:t,message:f.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}]:[],"validate")},{type:"string",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>Pt.includes(e.toLowerCase())?[]:[{path:t,message:f.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}],"validate")}]}};function Mt(e,t,n){return g(Ne.schema,e,t,n)}s(Mt,"validateFontWeight");const Ut=["ms","s"],ne={schema:{type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_DURATION(e,t),"errorMessage"),properties:{value:P.schema,unit:{type:"string",validate:s((e,t,n)=>Ut.includes(e)?[]:[{path:t,message:f.VALIDATE.INVALID_DURATION_UNIT(e,t),source:n}],"validate")}},required:["value","unit"]}};function Gt(e,t,n){return g(ne.schema,e,t,n)}s(Gt,"validateDuration");const Se={schema:{type:"array",errorMessage:s((e,t)=>f.VALIDATE.INVALID_CUBIC_BEZIER(e,t),"errorMessage"),validate:s((e,t,n)=>{const o=e;if(o.length!==4||!o.every(a=>typeof a=="number"))return[{path:t,message:f.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}];const[r,,i]=o;return r<0||r>1||i<0||i>1?[{path:t,message:f.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}]:[]},"validate")}};function Wt(e,t,n){return g(Se.schema,e,t,n)}s(Wt,"validateCubicBezier");const Bt={schema:{type:"object",properties:{fontFamily:be.schema,fontSize:E.schema,letterSpacing:E.schema,lineHeight:P.schema,fontWeight:Ne.schema},required:["fontFamily","fontSize"],errorMessage:s((e,t)=>f.VALIDATE.INVALID_TYPOGRAPHY(e,t),"errorMessage")}};function Yt(e,t,n){return g(Bt.schema,e,t,n)}s(Yt,"validateTypography");const Ht=["solid","dashed","dotted","double","groove","ridge","outset","inset"],Kt=["round","butt","square"],zt={type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_STROKE_STYLE(e,t),"errorMessage"),properties:{dashArray:{type:"array",validate:s((e,t,n)=>{const o=e,r=[];return o.forEach((i,a)=>{typeof i!="string"&&r.push(...g(E.schema,i,`${t}.${a}`,n))}),r},"validate")},lineCap:{type:"string",validate:s((e,t,n)=>Kt.includes(e)?[]:[{path:t,message:f.VALIDATE.INVALID_STROKE_LINE_CAP(e,t),source:n}],"validate")}},required:["dashArray","lineCap"]},Le={schema:{type:"union",oneOf:[{type:"string",validate:s((e,t,n)=>!Ht.includes(e)&&typeof e=="string"?[{path:t,message:f.VALIDATE.INVALID_STROKE_STYLE(e,t),source:n}]:[],"validate")},zt]}};function qt(e,t,n){return g(Le.schema,e,t,n)}s(qt,"validateStrokeStyle");const Jt={schema:{type:"object",properties:{color:j.schema,width:E.schema,style:Le.schema},required:["color","width","style"],errorMessage:s((e,t)=>f.VALIDATE.INVALID_BORDER(e,t),"errorMessage")}};function Xt(e,t,n){return g(Jt.schema,e,t,n)}s(Xt,"validateBorder");const Zt={schema:{type:"object",properties:{duration:ne.schema,delay:ne.schema,timingFunction:Se.schema},required:["duration","delay","timingFunction"],errorMessage:s((e,t)=>f.VALIDATE.INVALID_TRANSITION(e,t),"errorMessage")}};function Qt(e,t,n){return g(Zt.schema,e,t,n)}s(Qt,"validateTransition");const Oe={schema:{type:"object",properties:{color:{type:"union",oneOf:[j.schema]},offsetX:E.schema,offsetY:E.schema,blur:E.schema,spread:E.schema,inset:{type:"boolean",errorMessage:s((e,t)=>f.VALIDATE.INVALID_SHADOW_INSET(e,t),"errorMessage")}},required:["color","offsetX","offsetY","blur","spread"],errorMessage:s((e,t)=>f.VALIDATE.INVALID_SHADOW(e,t),"errorMessage")}};function en(e,t,n){const o=[];return Array.isArray(e)?(e.forEach((r,i)=>{o.push(...g(Oe.schema,r,`${t}[${i}]`,n))}),o):g(Oe.schema,e,t,n)}s(en,"validateShadow");const tn={type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_GRADIENT(e,t),"errorMessage"),properties:{color:j.schema,position:{type:"number",validate:s((e,t,n)=>e<0||e>1?[{path:t,message:f.VALIDATE.INVALID_GRADIENT_STOP_POSITION(e,t),source:n}]:[],"validate")}},required:["color","position"]},nn={schema:{type:"array",errorMessage:s((e,t)=>f.VALIDATE.INVALID_ARRAY(e,t),"errorMessage"),validate:s((e,t,n)=>{const o=e,r=[];return o.forEach((i,a)=>{r.push(...g(tn,i,`${t}[${a}]`,n))}),r},"validate")}};function on(e,t,n){return g(nn.schema,e,t,n)}s(on,"validateGradient");const rn={schema:{type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FLUID_DIMENSION(e,t),"errorMessage"),properties:{min:E.schema,max:E.schema},required:["min","max"]}};function sn(e,t,n){return g(rn.schema,e,t,n)}s(sn,"validateFluidDimension");const an={color:Vt,dimension:Rt,fluidDimension:sn,duration:Gt,cubicBezier:Wt,fontFamily:jt,fontWeight:Mt,number:xt,strokeStyle:qt,typography:Yt,border:Xt,shadow:en,gradient:on,transition:Qt};function cn(e){const t=[];for(const[n,o]of Object.entries(e.tokens)){if(typeof o!="object"||o===null||!("$type"in o)||!("$path"in o)||o.$path.startsWith("$"))continue;if(!("$value"in o)){t.push({path:o.$path,message:f.VALIDATE.MISSING_REQUIRED_PROPERTY("$value",o.$path),source:o.$source});continue}const r=an[o.$type];if(!r){t.push({path:o.$path,message:f.VALIDATE.UNKNOWN_TOKEN_TYPE(o.$type,o.$path),source:o.$source});continue}const i=o;t.push(...r(i.$value,i.$path,i.$source))}return t}s(cn,"validate");async function ln(e){const{trees:t,errors:n}=await(e.type==="memory"?St(e.data):Nt(e.config)),{tokens:o,errors:r}=At(t),i=cn(o),{resolved:a,errors:c}=Lt(o);return{trees:t,resolved:a,errors:{load:n,flatten:r,validation:i,resolution:c}}}s(ln,"loadAndResolveTokens");function _e(e){return I(e)?{value:e}:typeof e=="string"?{value:e}:{value:`${e.dashArray.map(n=>I(n)?n:`${n.value}${n.unit}`).join(" ")} ${e.lineCap}`}}s(_e,"convertStrokeStyleToken");function un(e){if(I(e))return{value:e};const t=I(e.width)?e.width:`${e.width.value}${e.width.unit}`,n=(I(e.color),e.color),o=typeof e.style=="string"?e.style:_e(e.style).value;return{value:`${t} ${o} ${n}`}}s(un,"convertBorderToken");function De(e,t="native"){return te(e)?fn(e):b(e)}s(De,"convertColorToString");function fn(e){switch(e.colorSpace){case"oklch":return Dt(e);case"display-p3":return pn(e);case"srgb":return dn(e);case"hsl":return hn(e);default:return T(`Unsupported color space: ${e.colorSpace}. Supported color spaces: oklch, display-p3, srgb, hsl.`)}}s(fn,"formatW3CColorNative");function pn(e){if(e.colorSpace!=="display-p3")return T(`Expected display-p3 color space, got: ${e.colorSpace}`);if(!Array.isArray(e.components)||e.components.length!==3)return T("Display P3 components must be an array of exactly 3 numbers [R, G, B]");const[t,n,o]=e.components,r=e.alpha;if(t!=="none"&&(t<0||t>1))return T("Display P3 Red component must be between 0 and 1 or 'none'");if(n!=="none"&&(n<0||n>1))return T("Display P3 Green component must be between 0 and 1 or 'none'");if(o!=="none"&&(o<0||o>1))return T("Display P3 Blue component must be between 0 and 1 or 'none'");if(r!==void 0&&(r<0||r>1))return T("Alpha must be between 0 and 1");const i=t==="none"?"none":Number(t.toFixed(4)),a=n==="none"?"none":Number(n.toFixed(4)),c=o==="none"?"none":Number(o.toFixed(4));if(r!==void 0&&r!==1){const l=Number(r.toFixed(4));return b(`color(display-p3 ${i} ${a} ${c} / ${l})`)}return b(`color(display-p3 ${i} ${a} ${c})`)}s(pn,"formatW3CColorToP3");function dn(e){if(e.colorSpace!=="srgb")return T(`Expected srgb color space, got: ${e.colorSpace}`);const t=R(e);if(t.length>0)return T(`Invalid W3C color value: ${t.join(", ")}`);const[n,o,r]=e.components,i=e.alpha,a=n==="none"?"none":Math.round(n*255),c=o==="none"?"none":Math.round(o*255),l=r==="none"?"none":Math.round(r*255);if(i!==void 0&&i!==1){const u=Number(i.toFixed(4));return b(`rgb(${a} ${c} ${l} / ${u})`)}return b(`rgb(${a} ${c} ${l})`)}s(dn,"formatW3CColorToRGB");function hn(e){if(e.colorSpace!=="hsl")return T(`Expected hsl color space, got: ${e.colorSpace}`);const t=R(e);if(t.length>0)return T(`Invalid W3C color value: ${t.join(", ")}`);const[n,o,r]=e.components,i=e.alpha,a=n==="none"?"none":Number(n.toFixed(1)),c=o==="none"?"none":Math.round(o),l=r==="none"?"none":Math.round(r);if(i!==void 0&&i!==1){const d=Number(i.toFixed(4)),h=c==="none"?"none":`${c}%`,y=l==="none"?"none":`${l}%`;return b(`hsl(${a} ${h} ${y} / ${d})`)}const u=c==="none"?"none":`${c}%`,p=l==="none"?"none":`${l}%`;return b(`hsl(${a} ${u} ${p})`)}s(hn,"formatW3CColorToHSL");function mn(e,t){if(typeof e=="string"&&I(e))return{value:e};const n=t.colorFallbackStrategy;if(te(e))return In(e,n);const o=De(e,n);return o.success?{value:o.value}:(console.warn(`Failed to convert color ${typeof e=="string"?e:"W3C color object"}: ${o.error}`),{value:typeof e=="string"?e:"#000000"})}s(mn,"convertColorToken");function In(e,t){const n=De(e,t);if(!n.success)return console.warn(`Failed to convert W3C color: ${n.error}`),{value:"#000000"};const o=n.value;if(t==="native")return{value:o};if(e.colorSpace==="srgb"||e.colorSpace==="hsl")return{value:o};if(!e.hex)throw new Error(`${e.colorSpace} colors require a 'hex' fallback when using 'polyfill' strategy. Tip: Switch to 'native' strategy if targeting modern browsers only.`);return{value:e.hex,featureValues:[{query:yn(e.colorSpace),value:o}]}}s(In,"convertW3CColorToken");function yn(e){switch(e){case"oklch":return"@supports (color: oklch(0 0 0))";case"display-p3":return"@supports (color: color(display-p3 1 1 1))";default:throw new Error(`No feature query defined for color space: ${e}`)}}s(yn,"getFeatureQuery");function $n(e){return I(e)?{value:e}:{value:`cubic-bezier(${e.join(", ")})`}}s($n,"convertCubicBezierToken");function gn(e){return I(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(gn,"convertDimensionToken");function Tn(e){return I(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(Tn,"convertDurationToken");function Fe(e,t=16){return e.unit==="px"?e.value:e.value*t}s(Fe,"normalizeToPixels");function En(e,t){const{min:n,max:o}=e,r=t.fluidConfig,i=16,a=Fe(n,i),c=Fe(o,i),l=r.min,u=r.max;if(a===c)return{value:`${a/i}rem`};const p=a/i,d=c/i,h=l/i,y=u/i,$=(d-p)/(y-h),A=-1*h*$+p;return{value:`clamp(${p}rem, ${A.toFixed(2)}rem + ${($*100).toFixed(2)}vw, ${d}rem)`}}s(En,"convertFluidDimension");function An(e,t){return I(e)?{value:e}:En(e,t)}s(An,"convertFluidDimensionToken");function M(e){return["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"].includes(e.toLowerCase())?e:/[\s'"!@#$%^&*()=+[\]{};:|\\/,.<>?~]/.test(e)?`"${e}"`:e}s(M,"quoteFont");function bn(e){return I(e)?{value:e}:{value:Array.isArray(e)?e.map(n=>M(n)).join(", "):M(e)}}s(bn,"convertFontFamilyToken");const Nn={thin:100,hairline:100,"extra-light":200,"ultra-light":200,light:300,normal:400,regular:400,book:400,medium:500,"semi-bold":600,"demi-bold":600,bold:700,"extra-bold":800,"ultra-bold":800,black:900,heavy:900,"extra-black":950,"ultra-black":950};function ke(e){return I(e)?{value:e}:typeof e=="number"?{value:e}:{value:Nn[e.toLowerCase()]??e}}s(ke,"convertFontWeightToken");function Sn(e){return I(e)?{value:e}:{value:`linear-gradient(${e.map(n=>{const o=(I(n.color),n.color),r=I(n.position)?n.position:`${n.position*100}`;return`${o} ${r}%`}).join(", ")})`}}s(Sn,"convertGradientToken");function Ln(e){return I(e)?{value:e}:{value:e}}s(Ln,"convertNumberToken");function ve(e){const t=I(e.offsetX)?e.offsetX:`${e.offsetX.value}${e.offsetX.unit}`,n=I(e.offsetY)?e.offsetY:`${e.offsetY.value}${e.offsetY.unit}`,o=I(e.blur)?e.blur:`${e.blur.value}${e.blur.unit}`,r=I(e.spread)?e.spread:`${e.spread.value}${e.spread.unit}`,i=(I(e.color),e.color);return`${e.inset?"inset ":""}${t} ${n} ${o} ${r} ${i}`}s(ve,"convertSingleShadow");function On(e){return I(e)?{value:e}:Array.isArray(e)?{value:e.map(ve).join(", ")}:{value:ve(e)}}s(On,"convertShadowToken");function Ce(e){return e?`${e.value}${e.unit}`:"0ms"}s(Ce,"formatDuration");function _n(e){if(I(e))return{value:e};const t=I(e.duration)?e.duration:Ce(e.duration),n=I(e.timingFunction)?e.timingFunction:`cubic-bezier(${e.timingFunction.join(", ")})`,o=e.delay&&(I(e.delay)?e.delay:Ce(e.delay));return{value:[t,n,o].filter(Boolean).join(" ")}}s(_n,"convertTransitionToken");function Dn(e){if(I(e))return{"font-family":e,"font-size":e};const t={"font-family":I(e.fontFamily)?e.fontFamily:Array.isArray(e.fontFamily)?e.fontFamily.map(n=>M(n)).join(", "):M(e.fontFamily),"font-size":I(e.fontSize)?e.fontSize:`${e.fontSize.value}${e.fontSize.unit}`};return e.fontWeight&&(t["font-weight"]=I(e.fontWeight)?e.fontWeight:ke(e.fontWeight).value),e.letterSpacing&&(t["letter-spacing"]=I(e.letterSpacing)?e.letterSpacing:`${e.letterSpacing.value}${e.letterSpacing.unit}`),e.lineHeight&&(t["line-height"]=(I(e.lineHeight),e.lineHeight)),t}s(Dn,"convertTypographyToken");const we={duration:Tn,number:Ln,cubicBezier:$n,color:mn,dimension:gn,fluidDimension:An,typography:Dn,border:un,shadow:On,gradient:Sn,transition:_n,strokeStyle:_e,fontFamily:bn,fontWeight:ke};function Fn(e,t){const n=we[e.$type];return{...e.$description?{$description:e.$description}:{},...e.$extensions?{$extensions:e.$extensions}:{},$type:e.$type,$value:e.$value,$path:e.$path,$source:e.$source,$originalPath:e.$originalPath,$resolvedValue:e.$resolvedValue,$cssProperties:n(e.$value,t)}}s(Fn,"convertSingleToken");function Ve(e,t,n){const o={};for(const[r,i]of Object.entries(e)){if(!i||typeof i!="object")continue;if(!("$type"in i)){o[r]={...i.$description?{$description:i.$description}:{},...i.$extensions?{$extensions:i.$extensions}:{}};continue}if(n?.(i.$path)){console.log(`[sugarcube] Skipping invalid token: ${i.$path} (has validation error)`);continue}if(!we[i.$type])continue;const a={fluidConfig:t.transforms.fluid,colorFallbackStrategy:t.transforms.colorFallbackStrategy,path:i.$path,resolvedTokens:e};o[r]=Fn(i,a)}return o}s(Ve,"convertTokens");function kn(e,t,n){const o={};for(const[r,i]of Object.entries(e)){const a={default:Ve(i.default,t,n)};for(const[c,l]of Object.entries(i))c!=="default"&&(a[c]=Ve(l,t,n));o[r]=a}return o}s(kn,"convert");function vn(e){const t=new Set,n=new Map;for(const i of e){const{collection:a,theme:c="default"}=i;t.add(a),n.has(a)||n.set(a,new Set),n.get(a)?.add(c)}const o={};function r(i){const a={default:{}};o[i]=a;const c=n.get(i);if(c)for(const l of c)a[l]={};return a}s(r,"addCollection");for(const i of t)r(i);for(const i of e){const{collection:a,theme:c="default",tokens:l}=i,u=o[a]||r(a);let p=u[c];p||(p=u[c]={});for(const[d,h]of Object.entries(l)){const y=d.replace(`${a}.`,"");p[y]=h}}return{tokens:o}}s(vn,"normalizeTokens");function Cn(e,t){const n=new Map;for(const[o,r]of Object.entries(t)){if(!("$source"in r)){for(const l of e){const u=l.collection;n.has(u)||n.set(u,new Map);const p=n.get(u),d=l.theme;p.has(d)||p.set(d,{}),p.get(d)[o]=r}continue}const i=r.$source.collection,a=r.$source.theme;n.has(i)||n.set(i,new Map);const c=n.get(i);c.has(void 0)||c.set(void 0,{}),a||(c.get(void 0)[o]=r),a&&(c.has(a)||c.set(a,{}),c.get(a)[o]=r)}return e.map(o=>{const r=n.get(o.collection);if(!r)return{collection:o.collection,theme:o.theme,tokens:{}};if(o.theme){const a=r.get(o.theme)||{};return{collection:o.collection,theme:o.theme,tokens:a}}const i=r.get(void 0)||{};return{collection:o.collection,theme:o.theme,tokens:i}})}s(Cn,"processTrees");async function wn(e,t,n,o){const r=Cn(e,t),{tokens:i}=vn(r);return kn(i,n,o?l=>o.some(u=>u.path===l||u.path.startsWith(`${l}.`)):void 0)}s(wn,"processAndConvertTokens");const U=["reset","global","compositions","blocks","utilities"];async function oe(e,t){const n=[],o=await z([N(e,"**/*.css"),N(e,"**/*.scss"),N(e,"**/*.sass"),N(e,"**/*.less")],{ignore:[N(e,w)]});for(const r of o){const i=Vn(r,e);if(i){const a=_(e,r);n.push({path:a,layer:i,relativePath:a})}}return n}s(oe,"discoverAllFiles");function Vn(e,t){const n=_(t,e);if(n.includes("global/")||n.startsWith("global/"))return de(e).includes("reset")?"reset":"global";if(n.includes("compositions/")||n.startsWith("compositions/"))return"compositions";if(n.includes("blocks/")||n.startsWith("blocks/"))return"blocks";if(n.includes("utilities/")||n.startsWith("utilities/"))return"utilities"}s(Vn,"categorizeFile");function xn(e){return e.sort((t,n)=>{const o=U.indexOf(t.layer),r=U.indexOf(n.layer);return o!==r?o-r:t.path.localeCompare(n.path)})}s(xn,"sortFilesByLayer");function Rn(){return`@layer ${U.join(", ")};
18
+ `}s(Rn,"getLayerDefinitions");function xe(e){const t=[];t.push(Rn());const n=e.reduce((o,r)=>{const i=o[r.layer]??[];return o[r.layer]=[...i,r],o},{});for(const o of U){const r=n[o];if(!(!r||r.length===0))for(const i of r)t.push(`@import "${i.path}" layer(${i.layer});`)}return t.join(`
19
+ `)}s(xe,"generateIndexContent");async function jn(e,t){const n=N(e,w),o=await oe(e),r=xn(o),i=xe(r);return await C.writeFile(n,i),_(process.cwd(),n)}s(jn,"generateIndex");async function Pn(e,t){const n=N(e,w);if(!D(n))return!0;try{const o=await C.stat(n),r=await oe(e,t);for(const i of r){const a=N(e,i.path);if(D(a)&&(await C.stat(a)).mtime>o.mtime)return!0}return!1}catch{return!0}}s(Pn,"shouldRegenerateIndex");const Mn=`/*!
20
+ * This file was automatically generated by sugarcube.
21
+ * You should NOT make any changes in this file as it will be overwritten.
22
+ * To make changes, edit your design token files instead.
23
+ * Additionally, you should exclude this file from your linter and/or formatter
24
+ * to prevent it from being checked or modified.
25
+ */
25
26
 
26
- ${e}`}o(kt,"addWarningBanner");function wt(e){return vt(e.tokens)?e.tokens.source:Object.values(e.tokens).flatMap(t=>"source"in t?t.source:[])}o(wt,"getTokenPathsFromConfig");async function xt(e,t=!0,n){for(const r of e){const s=t&&n?kt(r.css):r.css;try{await Ae(N.dirname(r.path),{recursive:!0});let i=!0;if(j(r.path))try{await _(r.path,"utf-8")===s&&(i=!1)}catch{}i&&await R(r.path,s,"utf-8")}catch(i){throw new Error(`Failed to write CSS file ${r.path}: ${i instanceof Error?i.message:"Unknown error"}`)}}return e}o(xt,"writeCSSFilesToDisk");function Ct(e){const t=e.split("/"),n=t.findIndex(s=>s==="variables");if(n===-1||n===t.length-1)return"default";const r=t[n+1];return!r||r.endsWith(".css")?"default":r}o(Ct,"getCollectionFromPath");function Ie(e,t){if(e.includes("/variables/")){const n=Ct(e),r=t.variables.get(n)??[];r.push(e),t.variables.set(n,r)}else e.startsWith("global/")?t.global.push(e):e.startsWith("compositions/")?t.compositions.push(e):e.startsWith("utilities/")&&t.utilities.push(e)}o(Ie,"groupFile");async function Rt(e,t){const n={variables:new Map,global:[],compositions:[],utilities:[]},r=N.join(t,"index.css");let s="";if(j(r)){s=await _(r,"utf-8");const c=s.split(`
27
- `).filter(l=>l.trim().startsWith("@import")).map(l=>l.match(/'([^']+)'/)?.[1]).filter(l=>l!==void 0);for(const l of c)Ie(l,n)}for(const c of e.filter(l=>l.endsWith(".css"))){const l=N.relative(t,c).replace(/\\/g,"/");Ie(l,n)}const i=["reset.css","fonts.css","global-styles.css"];n.global.sort((c,l)=>{const f=i.findIndex(d=>c.endsWith(d)),p=i.findIndex(d=>l.endsWith(d));return f-p});const a=[];for(const[,c]of Array.from(n.variables.entries()).sort())c.length>0&&a.push(...c.sort().map(l=>`@import '${l}';`));return n.global.length>0&&(a.length&&a.push(""),a.push(...n.global.map(c=>`@import '${c}';`))),n.compositions.length>0&&(a.length&&a.push(""),a.push(...n.compositions.sort().map(c=>`@import '${c}';`))),n.utilities.length>0&&(a.length&&a.push(""),a.push(...n.utilities.sort().map(c=>`@import '${c}';`))),`${a.filter(Boolean).join(`
27
+ `,Un=`/*!
28
+ * This file was automatically generated by sugarcube.
29
+ * You should NOT make any changes in this file as it will be overwritten.
30
+ * To make changes, edit your utilities configuration instead.
31
+ * Additionally, you should exclude this file from your linter and/or formatter
32
+ * to prevent it from being checked or modified.
33
+ */
34
+
35
+ `;function G(e){return e.replace(/\r\n/g,`
36
+ `).replace(/\r/g,`
37
+ `).trim()}s(G,"normalizeContent");function Gn(e){return Mn+e}s(Gn,"addWarningBanner");async function Wn(e){for(const t of e){const n=Gn(t.css);try{await fe(he(t.path),{recursive:!0});let o=!0;if(D(t.path))try{const r=await K(t.path,"utf-8");G(r)===G(n)&&(o=!1)}catch{}o&&await pe(t.path,n,"utf-8")}catch(o){throw new Error(`Failed to write CSS file ${t.path}: ${o instanceof Error?o.message:"Unknown error"}`)}}return e}s(Wn,"writeCSSVariablesToDisk");async function Bn(e){for(const t of e){const n=Un+t.css;try{await fe(he(t.path),{recursive:!0});let o=!0;if(D(t.path))try{const r=await K(t.path,"utf-8");G(r)===G(n)&&(o=!1)}catch{}o&&await pe(t.path,n,"utf-8")}catch(o){throw new Error(`Failed to write utility CSS file ${t.path}: ${o instanceof Error?o.message:"Unknown error"}`)}}return e}s(Bn,"writeCSSUtilitiesToDisk");const Re=m.array(m.string()).min(1,"At least one file path must be specified"),re=m.object({source:Re,themes:m.record(Re).optional()}),je=m.record(m.string(),re),Pe=m.object({min:m.number(),max:m.number()}),Me=m.object({source:m.string(),directions:m.union([m.enum(["top","right","bottom","left","x","y","full","all"]),m.array(m.enum(["top","right","bottom","left","x","y","full","all"]))]).optional(),prefix:m.string().optional(),stripDuplicates:m.boolean().optional(),collection:m.string().optional()}),Ue=m.union([Me,m.array(Me)]),Ge=m.object({tokens:m.union([je,re]).optional(),transforms:m.object({fluid:Pe.optional(),colorFallbackStrategy:m.enum(["native","polyfill"]).optional()}).optional(),output:m.object({css:m.string().optional(),components:m.string().optional(),separate:m.boolean().optional()}).optional(),utilities:m.record(m.string(),Ue).optional()}),We=m.object({tokens:m.union([je,re]).optional(),transforms:m.object({fluid:Pe,colorFallbackStrategy:m.enum(["native","polyfill"])}),output:m.object({css:m.string(),components:m.string(),separate:m.boolean()}),utilities:m.record(m.string(),Ue).optional()}),L={output:{css:"src/styles",components:"src/components/ui",separate:!1},transforms:{fluid:{min:320,max:1200},colorFallbackStrategy:"native"}},Yn="default",se="default";function ie(e){const t={tokens:e.tokens,transforms:{fluid:e.transforms?.fluid??L.transforms.fluid,colorFallbackStrategy:e.transforms?.colorFallbackStrategy??L.transforms.colorFallbackStrategy},output:{css:e.output?.css??L.output.css,separate:e.output?.separate??L.output.separate}};return(e.output?.components!==void 0||L.output.components!==void 0)&&(t.output.components=e.output?.components??L.output.components),e.utilities&&(t.utilities=e.utilities),t}s(ie,"fillDefaults");function W(e){const t=Ge.safeParse(e);if(!t.success){const n=t.error.errors.map(o=>{const r=o.path.join(".");return f.CONFIG.INVALID_CONFIG(r||"root",o.message)});throw new Error(n.join(`
38
+ `))}return t.data}s(W,"validateUserConfig");function ae(e){const t=We.safeParse(e);if(!t.success){const n=t.error.errors.map(o=>{const r=o.path.join(".");return f.CONFIG.INVALID_CONFIG(r||"root",o.message)});throw new Error(n.join(`
39
+ `))}return Kn(t.data),t.data}s(ae,"validateInternalConfig");function Be(e){const t=W(e),n=ie(t);return ae(n)}s(Be,"validateConfig");function Hn(e){try{const t=JSON.parse(e);return Be(t)}catch(t){throw t instanceof SyntaxError?new Error(f.CONFIG.INVALID_JSON(t.message)):t}}s(Hn,"parseAndValidateConfig");function Kn(e){if(typeof e.tokens=="object")for(const[t,n]of Object.entries(e.tokens)){if(!n.source?.length)continue;const o=new Map;for(const r of n.source){const i=de(r),a=o.get(i)||[];o.set(i,[...a,r])}for(const[r,i]of o)if(i.length>1)throw new Error(f.CONFIG.DUPLICATE_FILENAMES(t,r,i))}}s(Kn,"validateFileNames");function ce(e="sugarcube.config"){const t=[".ts",".js"];for(const n of t){const o=me(process.cwd(),`${e}${n}`);if(D(o))return o}return null}s(ce,"findConfigFile");function zn(e="sugarcube.config"){return ce(e)!==null}s(zn,"configFileExists");async function Ye(e){try{await import("tsx");const t=tt(e).href,o=await new Function("url","return import(url)")(t);if(o&&typeof o=="object"&&"default"in o)return o.default;throw new Error(f.CONFIG.INVALID_CONFIG("root","Config file must export a default object"))}catch(t){throw t instanceof Error?new Error(f.CONFIG.INVALID_CONFIG("root",t.message)):t}}s(Ye,"loadTSConfig");async function He(e){if(e.endsWith(".ts")||e.endsWith(".js"))return await Ye(e);const n=await C.readFile(e,"utf-8");return JSON.parse(n)}s(He,"loadConfigFile");function Ke(e){if(e)return me(process.cwd(),e);const t=ce();if(!t)throw new Error(f.CONFIG.FILE_NOT_FOUND(F));return t}s(Ke,"resolveConfigPath");async function qn(e){const t=Ke(e);try{const n=await He(t);return{config:W(n),configPath:t}}catch(n){throw n instanceof Error&&"code"in n&&n.code==="ENOENT"?new Error(f.CONFIG.FILE_NOT_FOUND(t)):n instanceof SyntaxError?new Error(f.CONFIG.INVALID_JSON(n.message)):n}}s(qn,"loadUserConfig");async function Jn(e){const t=Ke(e);try{const n=await He(t),o=W(n),r=ie(o);return{config:ae(r),configPath:t}}catch(n){throw n instanceof Error&&"code"in n&&n.code==="ENOENT"?new Error(f.CONFIG.FILE_NOT_FOUND(t)):n instanceof SyntaxError?new Error(f.CONFIG.INVALID_JSON(n.message)):n}}s(Jn,"loadInternalConfig");class ze extends Map{static{s(this,"DefaultMap")}constructor(t){super(),this.factory=t}get(t){let n=super.get(t);return n===void 0&&(n=this.factory(t,this),this.set(t,n)),n}}const Xn=process.env.DEBUG==="true";class Zn{static{s(this,"Instrumentation")}constructor(t=n=>void process.stderr.write(`${n}
40
+ `)){this.defaultFlush=t}#t=new ze(()=>({value:0}));#n=new ze(()=>({value:0n}));#e=[];hit(t){this.#t.get(t).value++}start(t){const n=this.#e.map(r=>r.label).join("//"),o=`${n}${n.length===0?"":"//"}${t}`;this.#t.get(o).value++,this.#n.get(o),this.#e.push({id:o,label:t,namespace:n,value:process.hrtime.bigint()})}end(t){const n=process.hrtime.bigint();if(this.#e.length===0)throw new Error("Timer stack is empty");const o=this.#e.length-1,r=this.#e[o];if(!r)throw new Error("Timer stack is corrupted");if(r.label!==t)throw new Error(`Mismatched timer label: ${t}`);const i=this.#e.pop();if(!i)throw new Error("Timer stack is empty");const a=n-i.value;this.#n.get(i.id).value+=a}report(t=this.defaultFlush){const n=[];let o=!1;for(let r=this.#e.length-1;r>=0;r--){const i=this.#e[r];i&&this.end(i.label)}for(const[r,{value:i}]of this.#t.entries()){if(this.#n.has(r))continue;n.length===0&&(o=!0,n.push("Hits:"));const a=r.split("//").length;n.push(`${" ".repeat(a)}${r} \xD7 ${i}`)}if(this.#n.size>0){o&&n.push(`
41
+ Timers:`);for(const[r,{value:i}]of this.#n){const a=r.split("//").length,c=`${(Number(i)/1e6).toFixed(2)}ms`;n.push(`${" ".repeat(a-1)}${r.split("//").pop()} [${c}] ${this.#t.get(r).value===1?"":`\xD7 ${this.#t.get(r).value}`}`.trimEnd())}}t(`
42
+ ${n.join(`
28
43
  `)}
29
- `}o(Rt,"generateCSSIndex");async function jt({cssOutputDirectory:e,files:t}){const n=t.filter(s=>s.endsWith(".css"));if(n.length===0)throw new Error("No CSS files to manage");const r=N.join(e,"index.css");try{const s=await Rt(n,e);return await R(r,s),r}catch(s){throw new Error(`Failed to manage CSS index file: ${s instanceof Error?s.message:String(s)}`)}}o(jt,"manageCSSIndex");export{pe as configSchema,Ot as generationPipeline,wt as getTokenPathsFromConfig,Ft as loadConfig,jt as manageCSSIndex,me as parseAndValidateConfig,Dt as tokensToCSSPipeline,he as validateConfig,_t as validationPipeline,xt as writeCSSFilesToDisk};
44
+ `)}[Symbol.dispose](){Xn&&this.report()}}const k="--",O="-",Qn=["all","full"],eo={top:"t",right:"r",bottom:"b",left:"l",x:"x",y:"y",full:"",all:""},to={top:"block-start",right:"inline-end",bottom:"block-end",left:"inline-start",x:"inline",y:"block"};function no(e){return eo[e]}s(no,"getDirectionAbbreviation");function qe(e,t){if(t==="full"||t==="all")return e;const n=to[t];return n?`${e}${O}${n}`:e}s(qe,"getLogicalProperty");const oo=["top","right","bottom","left","x","y","full"];function ro(e){return(Array.isArray(e)?e:[e]).flatMap(n=>n==="all"?oo:[n])}s(ro,"expandDirections");function Je(e,t){const o={color:["color"],"background-color":["color"],"border-color":["color"],"font-size":["dimension","fluidDimension"],"font-weight":["fontWeight"],"line-height":["number"],"border-radius":["dimension","fluidDimension"],"border-width":["dimension","fluidDimension"],padding:["dimension","fluidDimension"],margin:["dimension","fluidDimension"],width:["dimension","fluidDimension"],height:["dimension","fluidDimension"],gap:["dimension","fluidDimension"],"font-family":["fontFamily"],"transition-duration":["duration"],"transition-timing-function":["cubicBezier"],"border-style":["strokeStyle"],"box-shadow":["shadow"],"text-shadow":["shadow"],"background-image":["gradient"],opacity:["number"]}[t];return o?o.includes(e):!0}s(Je,"isTokenTypeValidForProperty");const Xe=new WeakMap;function Ze(e){const t=Xe.get(e);if(t)return t;const n=new Map;for(const o of Object.values(e)){if(!("$path"in o))continue;const r=o;n.set(r.$path,r)}return Xe.set(e,n),n}s(Ze,"buildPathIndex");function B(e,t,n){const o=[t.source.replace("*",e),t.source.replace("*",e.split("-").join("."))];if(t.stripDuplicates&&t.prefix){const c=t.source.lastIndexOf(".*");if(c!==-1){const l=t.source.slice(0,c);l&&o.push(`${l}.${t.prefix}.${e}`,`${l}.${t.prefix}.${e.split("-").join(".")}`)}}if(t.collection){const c=n[t.collection];if(!c)return null;const l=c[se];if(!l)return null;const u=Ze(l);for(const p of o){const d=u.get(p);if(d){if(t.property&&d.$type&&!Je(d.$type,t.property))continue;return d.$path.split(".")}}return null}const r=[],i=Object.keys(n).sort();for(const c of i){const l=n[c];if(!l)continue;const u=l[se];if(!u)continue;const p=Ze(u);for(const d of o){const h=p.get(d);if(h){if(t.property&&h.$type&&!Je(h.$type,t.property))continue;r.push({collection:c,token:h});break}}}if(r.length===0)return null;if(r.length>1){const c=r.map(p=>p.collection).join(", "),l=r[0];if(!l)return null;const u=l.token.$path;throw new Error(f.UTILITIES.TOKEN_PATH_CONFLICT(u,c))}const a=r[0];return a?a.token.$path.split("."):null}s(B,"findMatchingToken");function le(e,t){return t.stripDuplicates&&t.prefix&&e.startsWith(`${t.prefix}-`)?e.slice(t.prefix.length+1):e}s(le,"stripDuplicatePrefix");function Y(e,t=""){const n=e??"",o=n||t?O:"";return new RegExp(`^${n}${t}${o}(.+)$`)}s(Y,"createUtilityPattern");function ue(e,t,n){return[Y(t.prefix),r=>{const i=r[1];if(!i)return{};const a=le(i,t),c={...t,property:e},l=B(a,c,n);return l?{[e]:`var(${k}${l.join(O)})`}:{}}]}s(ue,"createSimpleRule");function so(e,t,n,o){if(n==="all")return ue(e,t,o);const r=no(n);return[Y(t.prefix,r),a=>{const c=a[1];if(!c)return{};const l=le(c,t),u={...t,property:e},p=B(l,u,o);return p?{[qe(e,n)]:`var(${k}${p.join(O)})`}:{}}]}s(so,"createDirectionalRule");function io(e,t){return[Y(e),o=>{const r=o[1];if(!r)return{};for(const{property:i,config:a,direction:c,tokens:l}of t){const u=le(r,a),p={...a,property:i},d=B(u,p,l);if(d)return c?{[qe(i,c)]:`var(${k}${d.join(O)})`}:{[i]:`var(${k}${d.join(O)})`}}return{}}]}s(io,"createSmartRule");function ao(e,t,n){const o=t.source.indexOf("."),r=o!==-1?t.source.slice(0,o):t.source;return[Y(r),a=>{const c=a[1];if(!c)return{};const l={...t,property:e},u=B(c,l,n);return u?{[e]:`var(${k}${u.join(O)})`}:{}}]}s(ao,"createDirectTokenPathRule");function co(e,t){if(!e?.source||typeof e.source!="string")throw new Error(f.UTILITIES.MISSING_SOURCE(t));if(e.source.includes("*")&&!e.source.endsWith(".*"))throw new Error(f.UTILITIES.INVALID_SOURCE_PATTERN(t,e.source));if(e.directions&&!Array.isArray(e.directions))throw new Error(f.UTILITIES.INVALID_DIRECTIONS(t))}s(co,"validateUtilityConfig");function lo(e,t){if(!e||typeof e!="object")throw new Error(f.UTILITIES.INVALID_CONFIG_OBJECT);if(!t||typeof t!="object")throw new Error(f.UTILITIES.INVALID_TOKENS_OBJECT);const n=Object.keys(t);for(const[o,r]of Object.entries(e)){const i=Array.isArray(r)?r:[r];for(const a of i)if(a.collection&&!n.includes(a.collection))throw new Error(f.UTILITIES.INVALID_COLLECTION(o,a.collection,n))}}s(lo,"validateInputs");function uo(e,t){lo(e,t);const n=[],o={};for(const[r,i]of Object.entries(e)){const a=Array.isArray(i)?i:[i];for(const c of a)if(co(c,r),c.prefix){const l=c.prefix;o[l]||(o[l]=[]),o[l].push({property:r,config:c,direction:null,tokens:t})}else{const l=ao(r,c,t);n.push(l)}}for(const[r,i]of Object.entries(o))if(i.length===1){const a=i[0];if(!a)continue;const{property:c,config:l,tokens:u}=a;if(l.directions){const p=ro(l.directions);(Array.isArray(l.directions)?l.directions:[l.directions]).includes("all")&&n.push(ue(c,l,u));for(const y of p)Qn.includes(y)||n.push(so(c,l,y,u))}else n.push(ue(c,l,u))}else n.push(io(r,i));return n}s(uo,"convertConfigToUnoRules");function fo(e){return"source"in e&&Array.isArray(e.source)}s(fo,"isSingleCollection");export{Yn as DEFAULT_COLLECTION,L as DEFAULT_CONFIG,st as DEFAULT_DESIGN_TOKENS_PATH,rt as DEFAULT_STYLES_PATH,se as DEFAULT_THEME,ot as DEFAULT_UTILITIES_FILENAME,J as DEFAULT_VARIABLES_FILENAME,f as ErrorMessages,q as GLOBAL_DIR,Zn as Instrumentation,F as SUGARCUBE_CONFIG_FILE,w as SUGARCUBE_FILE,nt as UTILITIES_DIR,S as VARIABLES_FILE_SUFFIX,zn as configFileExists,uo as convertConfigToUnoRules,oe as discoverAllFiles,ie as fillDefaults,ce as findConfigFile,$t as generateCSSVariables,jn as generateIndex,xe as generateIndexContent,We as internalConfigSchema,Ie as isResolvedToken,ct as isResolvedTokenOfType,fo as isSingleCollection,ln as loadAndResolveTokens,Jn as loadInternalConfig,Ye as loadTSConfig,qn as loadUserConfig,Hn as parseAndValidateConfig,wn as processAndConvertTokens,Pn as shouldRegenerateIndex,Ge as userConfigSchema,Be as validateConfig,ae as validateInternalConfig,W as validateUserConfig,Bn as writeCSSUtilitiesToDisk,Wn as writeCSSVariablesToDisk};
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@sugarcube-org/core",
3
- "version": "0.0.1-alpha.5",
3
+ "version": "0.0.1-alpha.7",
4
4
  "publishConfig": {
5
- "access": "public"
5
+ "access": "public",
6
+ "provenance": false
6
7
  },
7
8
  "description": "Core functionality for sugarcube",
8
- "license": "AGPL-3.0",
9
+ "license": "SEE LICENSE IN LICENSE.md",
9
10
  "main": "./dist/index.js",
10
11
  "types": "./dist/index.d.ts",
11
12
  "type": "module",
@@ -17,25 +18,28 @@
17
18
  },
18
19
  "files": [
19
20
  "dist",
20
- "README.md"
21
+ "README.md",
22
+ "LICENSE.md"
21
23
  ],
22
24
  "devDependencies": {
23
- "pkgroll": "^2.5.1",
24
- "tsx": "^4.19.2"
25
+ "pkgroll": "2.5.1"
25
26
  },
26
27
  "dependencies": {
27
- "@types/culori": "^2.1.1",
28
- "culori": "^4.0.1",
29
- "fast-glob": "^3.3.2",
30
- "zod": "^3.21.4"
28
+ "fast-glob": "3.3.2",
29
+ "pathe": "2.0.3",
30
+ "tsx": "4.19.2",
31
+ "zod": "3.21.4"
31
32
  },
32
33
  "scripts": {
33
34
  "build": "pkgroll --minify",
35
+ "build:clean": "rm -rf dist && pkgroll --minify",
34
36
  "dev": "pkgroll --watch",
35
37
  "test": "vitest run",
36
38
  "test:watch": "vitest",
37
39
  "test:coverage": "vitest run --coverage",
38
40
  "test:bench": "vitest bench --no-watch",
41
+ "test:bench:save": "vitest bench --no-watch --outputJson benchmarks/$(date +%Y-%m-%d)-results.json",
42
+ "test:bench:compare": "./scripts/bench-compare.sh",
39
43
  "type-check": "tsc --noEmit"
40
44
  }
41
45
  }