@sugarcube-org/core 0.0.1-alpha.1 → 0.0.1-alpha.10
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/LICENSE.md +31 -0
- package/README.md +3 -5
- package/dist/index.d.ts +1330 -125
- package/dist/index.js +41 -6
- package/package.json +27 -5
package/dist/index.js
CHANGED
|
@@ -1,7 +1,42 @@
|
|
|
1
|
-
var K=Object.defineProperty;var n=(e,t)=>K(e,"name",{value:t,configurable:!0});const c={PARSE:{INVALID_INPUT_TYPE:n(e=>`Invalid input: expected string, got ${e}`,"INVALID_INPUT_TYPE"),JSON_PARSE_ERROR:n(e=>`JSON parsing error: ${e}`,"JSON_PARSE_ERROR")},FLATTEN:{INVALID_TOKEN_NAME:n(e=>`Invalid token name '${e}': cannot contain '.', '{', or '}'`,"INVALID_TOKEN_NAME"),INVALID_NODE_STRUCTURE:n(e=>`Invalid node structure at '${e}': expected object`,"INVALID_NODE_STRUCTURE"),MISSING_INHERITED_TYPE:n(e=>`Token at '${e}' has no type (neither explicit nor inherited)`,"MISSING_INHERITED_TYPE"),UNEXPECTED_ERROR:n(e=>`Unexpected error during flattening: ${e}`,"UNEXPECTED_ERROR")},METADATA:{COLLECTION_ERROR:n(e=>`Error collecting metadata: ${e}`,"COLLECTION_ERROR"),INVALID_EXTENSIONS:n(e=>`Invalid extensions at '${e}': expected object, got ${typeof e}`,"INVALID_EXTENSIONS"),INVALID_DESCRIPTION:n(e=>`Invalid description at '${e}': expected string, got ${typeof e}`,"INVALID_DESCRIPTION")},VALIDATE:{INVALID_TOKEN_STRUCTURE:n(e=>`Invalid token at '${e}'. Each token should have "$type" and "$value" properties`,"INVALID_TOKEN_STRUCTURE"),MISSING_TYPE:n(e=>`Token at '${e}' is missing the "$type" property`,"MISSING_TYPE"),MISSING_VALUE:n(e=>`Token at '${e}' is missing the "$value" property`,"MISSING_VALUE"),UNKNOWN_TOKEN_TYPE:n((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:n((e,t)=>`Invalid color at '${t}': '${e}'. Color should be a valid hex value`,"INVALID_COLOR"),INVALID_DIMENSION:n((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:n((e,t)=>`Invalid unit at '${t}': ${e}. Unit must be either "px" or "rem"`,"INVALID_DIMENSION_UNIT"),INVALID_FONT_FAMILY:n((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:n((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:n((e,t)=>`Invalid duration at '${t}': ${e}. Should be like { "value": 300, "unit": "ms" }`,"INVALID_DURATION"),INVALID_DURATION_UNIT:n((e,t)=>`Invalid unit at '${t}': ${e}. Unit must be "ms" or "s"`,"INVALID_DURATION_UNIT"),INVALID_CUBIC_BEZIER:n((e,t)=>`Invalid cubic bezier at '${t}': ${e}. Should be an array of 4 numbers between 0 and 1`,"INVALID_CUBIC_BEZIER"),INVALID_CUBIC_BEZIER_RANGE:n((e,t)=>`Invalid cubic bezier control points at '${t}': ${e}. X values must be between 0 and 1`,"INVALID_CUBIC_BEZIER_RANGE"),INVALID_STROKE_STYLE:n((e,t)=>`Invalid stroke style at '${t}': ${e}. Should be "solid", "dashed", "dotted", etc.`,"INVALID_STROKE_STYLE"),INVALID_STROKE_LINE_CAP:n((e,t)=>`Invalid line cap at '${t}': ${e}. Should be one of: round, butt, square`,"INVALID_STROKE_LINE_CAP"),INVALID_BORDER:n((e,t)=>`Invalid border at '${t}': ${e}. Should have color, width, and style properties`,"INVALID_BORDER"),INVALID_SHADOW:n((e,t)=>`Invalid shadow at '${t}': ${e}. Should have color, offsetX, offsetY properties (blur and spread are optional)`,"INVALID_SHADOW"),INVALID_SHADOW_INSET:n((e,t)=>`Invalid inset value at '${t}': ${e}. Should be true or false`,"INVALID_SHADOW_INSET"),INVALID_TRANSITION:n((e,t)=>`Invalid transition at '${t}': ${e}. Should have duration, delay, and timingFunction properties`,"INVALID_TRANSITION"),INVALID_GRADIENT:n((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:n((e,t)=>`Invalid gradient stop position at '${t}': ${e}. Position must be between 0 and 1`,"INVALID_GRADIENT_STOP_POSITION"),INVALID_TYPOGRAPHY:n((e,t)=>`Invalid typography at '${t}': ${e}. Should have fontFamily and fontSize (fontWeight, letterSpacing, and lineHeight are optional)`,"INVALID_TYPOGRAPHY"),MISSING_REQUIRED_PROPERTY:n((e,t)=>`Missing required property '${e}' at '${t}'`,"MISSING_REQUIRED_PROPERTY"),INVALID_NUMBER:n((e,t)=>`Invalid number at '${t}': ${e}. Expected a number value`,"INVALID_NUMBER"),INVALID_ARRAY:n((e,t)=>`Invalid array at '${t}': ${e}. Expected an array value`,"INVALID_ARRAY"),MISSING_FLUID_CONFIG:n(e=>`Missing fluid configuration at root level. Token at '${e}' requires fluid viewport settings`,"MISSING_FLUID_CONFIG"),INVALID_FLUID_DIMENSION:n((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:n((e,t)=>`Invalid viewport configuration at '${t}': ${e}. Viewport config should have min and max dimension values`,"INVALID_VIEWPORT_CONFIG"),MISMATCHED_UNITS:n((e,t,r)=>`Mismatched units at '${r}': min uses '${e}', max uses '${t}'. Both values must use the same unit`,"MISMATCHED_UNITS"),INVALID_FLUID_VALUE_RANGE:n(e=>`Invalid fluid value range at '${e}': min value must be less than max value`,"INVALID_FLUID_VALUE_RANGE"),INVALID_TOKEN_TYPE:n((e,t,r)=>`Invalid token type at '${r}': expected ${e}, got ${t}`,"INVALID_TOKEN_TYPE"),INVALID_TYPE:n((e,t,r)=>`Expected ${e}, received ${typeof t} at '${r}'`,"INVALID_TYPE"),INVALID_ENUM_VALUE:n((e,t,r)=>`Expected value to be one of [${e.join(", ")}], but got ${String(t)} at ${r}`,"INVALID_ENUM_VALUE")},CONVERT:{UNSUPPORTED_TOKEN_TYPE:n(e=>`Unsupported token type: ${e}. Valid types are: color, dimension, fontFamily, fontWeight, duration, cubicBezier, strokeStyle, border, transition, shadow, gradient, typography`,"UNSUPPORTED_TOKEN_TYPE"),MISSING_FLUID_CONFIG:n(e=>`Missing fluid configuration for token at path: ${e}`,"MISSING_FLUID_CONFIG")},RESOLVE:{CIRCULAR_REFERENCE:n((e,t)=>`Circular reference detected: ${e} -> ${t}`,"CIRCULAR_REFERENCE"),REFERENCE_NOT_FOUND:n((e,t)=>`Reference not found: ${t} in ${e}`,"REFERENCE_NOT_FOUND"),TYPE_MISMATCH:n(e=>`Type mismatch in reference resolution at ${e}`,"TYPE_MISMATCH")},GENERATE:{INVALID_CSS_VALUE:n((e,t)=>`Invalid CSS value for property '${e}': ${t}`,"INVALID_CSS_VALUE")}};function X(e){return O(e)}n(X,"flatten");function O(e,t="",r){const o={},i=[];for(const[s,a]of Object.entries(e)){if(s.startsWith("$"))continue;const u=t?`${t}.${s}`:s;if(s.includes(".")||s.includes("{")||s.includes("}")){i.push({path:s,message:c.FLATTEN.INVALID_TOKEN_NAME(s)});continue}if(typeof a!="object"||a===null){i.push({path:u,message:c.FLATTEN.INVALID_NODE_STRUCTURE(u)});continue}const f="$type"in a?a.$type:r;if("$value"in a){if(!f){i.push({path:u,message:c.FLATTEN.MISSING_INHERITED_TYPE(u)});continue}o[u]={$type:f,$value:a.$value,$path:u}}else{const I=O(a,u,f);Object.assign(o,I.tokens),i.push(...I.errors)}}return{tokens:o,errors:i}}n(O,"processTokens");function l(e){return typeof e=="string"&&e.startsWith("{")&&e.endsWith("}")}n(l,"isReference");function m(e,t,r,o){return typeof t=="string"&&l(t)?Q(e,t,r,o):Array.isArray(t)?t.map(i=>m(e,i,r,o)):typeof t=="object"&&t!==null?Object.entries(t).reduce((s,[a,u])=>({...s,[a]:m(`${e}.${a}`,u,r,o)}),{}):t}n(m,"resolveValue");function Z(e){const t={},r=new Set,o=[];for(const[i,s]of Object.entries(e))try{if(!s.$path)continue;t[s.$path]={...s,$resolvedValue:m(s.$path,s.$value,e,r)}}catch(a){const u=a instanceof Error?a.message:String(a);let f,I;u.includes("Circular reference detected")?(f="circular",I=u):u.includes("Reference not found")?(f="missing",I=u):(f="type-mismatch",I=c.RESOLVE.TYPE_MISMATCH(s.$path)),o.push({type:f,path:s.$path,message:I})}return{resolved:t,errors:o}}n(Z,"resolve");function Q(e,t,r,o){const i=t.slice(1,-1);if(o.has(i))throw new Error(`Circular reference detected: ${e} -> ${i}`);const s=r[i];if(!s)throw new Error(`Reference not found: ${i} in ${e}`);o.add(i);const a=m(i,s.$value,r,o);return o.delete(i),a}n(Q,"resolveReferenceChain");function y(e){return["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"].includes(e.toLowerCase())?e:/[\s'"!@#$%^&*()=+[\]{};:|\\/,.<>?~]/.test(e)?`"${e}"`:e}n(y,"quoteFont");const J={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 v(e){return l(e)?{value:e}:typeof e=="number"?{value:e}:{value:J[e.toLowerCase()]??e}}n(v,"convertFontWeightToken");function ee(e){if(l(e))return{"font-family":e,"font-size":e};const t={"font-family":l(e.fontFamily)?e.fontFamily:Array.isArray(e.fontFamily)?e.fontFamily.map(r=>y(r)).join(", "):y(e.fontFamily),"font-size":l(e.fontSize)?e.fontSize:`${e.fontSize.value}${e.fontSize.unit}`};return e.fontWeight&&(t["font-weight"]=l(e.fontWeight)?e.fontWeight:v(e.fontWeight).value),e.letterSpacing&&(t["letter-spacing"]=l(e.letterSpacing)?e.letterSpacing:`${e.letterSpacing.value}${e.letterSpacing.unit}`),e.lineHeight&&(t["line-height"]=(l(e.lineHeight),e.lineHeight)),t}n(ee,"convertTypographyToken");function te(e){if(l(e))return{value:e};const t=(l(e.duration),e.duration),r=l(e.timingFunction)?e.timingFunction:`cubic-bezier(${e.timingFunction.join(", ")})`,o=e.delay&&(l(e.delay),e.delay),i={duration:t,"timing-function":r,...o&&{delay:o}};return{value:[t,r,o].filter(Boolean).join(" "),split:i}}n(te,"convertTransitionToken");function re(e){return l(e)?{value:e}:{value:`cubic-bezier(${e.join(", ")})`}}n(re,"convertCubicBezierToken");function ne(e){return l(e)?{value:e}:{value:e}}n(ne,"convertNumberToken");function oe(e){return l(e)?{value:e}:{value:e.toString()}}n(oe,"convertDurationToken");function R(e){return l(e)?{value:e}:typeof e=="string"?{value:e}:{value:`${e.dashArray.map(r=>l(r)?r:`${r.value}${r.unit}`).join(" ")} ${e.lineCap}`}}n(R,"convertStrokeStyleToken");function ie(e){if(l(e))return{value:e};const t=l(e.width)?e.width:`${e.width.value}${e.width.unit}`,r=(l(e.color),e.color);let o;return typeof e.style=="string"?o=e.style:o=R(e.style).value,{value:`${t} ${o} ${r}`,split:{width:t,style:o,color:r}}}n(ie,"convertBorderToken");function C(e){const t=l(e.offsetX)?e.offsetX:`${e.offsetX.value}${e.offsetX.unit}`,r=l(e.offsetY)?e.offsetY:`${e.offsetY.value}${e.offsetY.unit}`,o=l(e.blur)?e.blur:`${e.blur.value}${e.blur.unit}`,i=l(e.spread)?e.spread:`${e.spread.value}${e.spread.unit}`,s=(l(e.color),e.color),a={color:s,"offset-x":t,"offset-y":r,blur:o,spread:i,...e.inset&&{inset:"inset"}};return{value:`${e.inset?"inset ":""}${t} ${r} ${o} ${i} ${s}`,split:a}}n(C,"convertSingleShadow");function se(e){if(l(e))return{value:e};if(!Array.isArray(e)){const r=C(e);return{value:r.value,split:[r.split]}}const t=e.map(C);return{value:t.map(r=>r.value).join(", "),split:t.map(r=>r.split)}}n(se,"convertShadowToken");function ae(e){if(l(e))return{value:e};const t=e.map(r=>({color:(l(r.color),r.color),position:`${r.position}%`}));return{value:`linear-gradient(${t.map(r=>`${r.color} ${r.position}`).join(", ")})`,split:{stops:t}}}n(ae,"convertGradientToken");function ce(e){return l(e)?{value:e}:{value:Array.isArray(e)?e.map(r=>y(r)).join(", "):y(e)}}n(ce,"convertFontFamilyToken");function ue(e){return l(e)?{value:e}:{value:`${e.value}${e.unit}`}}n(ue,"convertDimensionToken");function le(e,t,r){if(e in r.tokens&&r.tokens[e]?.[t]!==void 0)return r.tokens[e][t];const o=e.split(".");for(;o.length>0;){const i=o.join(".");if(i in r.groups&&r.groups[i]&&t in r.groups[i])return r.groups[i][t];o.pop()}return r.root[t]}n(le,"getMetadataValue");function F(e,t){return le(e,"$extensions",t)?.["com.sugarcube"]}n(F,"getExtensions");function M(e,t){return F(e,t)?.fluid}n(M,"getFluidConfig");function fe(e,t){return F(e,t)?.color?.format}n(fe,"getColorFormat");function A(e,t=16){switch(e.unit){case"px":return e.value;case"rem":return e.value*t;default:throw new Error(`Unsupported unit: ${e.unit}. Fluid dimensions must use 'px' or 'rem'`)}}n(A,"normalizeToPixels");function de(e,t){if(!t?.viewports)throw new Error("Fluid metadata is required for fluid dimensions");const{min:r,max:o}=e,{viewports:i}=t,s=16,a=A(r,s),u=A(o,s),f=A(i.min,s),I=A(i.max,s);if(a===u)return{value:`${a/s}rem`};const S=a/s,V=u/s,b=f/s,q=I/s,L=(V-S)/(q-b),H=-1*b*L+S;return{value:`clamp(${S}rem, ${H.toFixed(2)}rem + ${(L*100).toFixed(2)}vw, ${V}rem)`}}n(de,"convertFluidDimension");function Ie(e,t){if(l(e))return{value:e};const r=M(t.path,t.metadataMap);if(!r)throw new Error(c.CONVERT.MISSING_FLUID_CONFIG(t.path));return de(e,r)}n(Ie,"convertFluidDimensionToken");function pe(e,t,r){const o=Math.max(e,t,r),i=Math.min(e,t,r);let s=0,a=0;const u=(o+i)/2;if(o!==i){const f=o-i;switch(a=u>.5?f/(2-o-i):f/(o+i),o){case e:s=(t-r)/f+(t<r?6:0);break;case t:s=(r-e)/f+2;break;case r:s=(e-t)/f+4;break}s*=60}return[Math.round(s),Math.round(a*100),Math.round(u*100)]}n(pe,"rgbToHsl");const g=n(e=>Number.isInteger(e)?e.toString():Number(e.toFixed(3)).toString(),"formatNumber"),$e={hex:{type:"standard",convert:n((e,t,r,o)=>{const i=n(s=>Math.round(s*255).toString(16).padStart(2,"0"),"toHex");return`#${i(e)}${i(t)}${i(r)}${o<1?i(o):""}`},"convert")},rgb:{type:"standard",convert:n((e,t,r,o)=>{const i=[e,t,r].map(s=>Math.round(s*255));return o===1?`rgb(${i.join(", ")})`:`rgba(${i.join(", ")}, ${g(o)})`},"convert")},hsl:{type:"standard",convert:n((e,t,r,o)=>{const[i,s,a]=pe(e,t,r);return o===1?`hsl(${i}, ${s}%, ${a}%)`:`hsla(${i}, ${s}%, ${a}%, ${g(o)})`},"convert")},p3:{type:"conditional",featureQuery:"@supports (color: color(display-p3 1 1 1))",convert:n((e,t,r,o)=>{const i=[e,t,r].map(g).join(" ");return o===1?`color(display-p3 ${i})`:`color(display-p3 ${i} / ${g(o)})`},"convert")}};function me(e,t){if(l(e))return{value:e};const r=fe(t.path,t.metadataMap)||"hex";if(r==="hex")return{value:e};const o=$e[r];if(!o)return{value:e};const i=e.substring(1),s=parseInt(i.substring(0,2),16)/255,a=parseInt(i.substring(2,4),16)/255,u=parseInt(i.substring(4,6),16)/255,f=i.length===8?parseInt(i.substring(6,8),16)/255:1;return o.type==="conditional"?{value:e,featureValues:[{query:o.featureQuery,value:o.convert(s,a,u,f)}]}:{value:o.convert(s,a,u,f)}}n(me,"convertColorToken");const ye={duration:oe,number:ne,cubicBezier:re,color:me,dimension:ue,fluidDimension:Ie,typography:ee,border:ie,shadow:se,gradient:ae,transition:te,strokeStyle:R,fontFamily:ce,fontWeight:v},Ae=new Set(["$description","$extensions"]),k=new Map;function x(e){const t=k.get(e);if(t)return t;const r=e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z])(?=[a-z])/g,"$1-$2").toLowerCase();return k.set(e,r),r}n(x,"toKebabCase");function ge(e,t){const r=ye[e.$type];if(!r)throw new Error(c.CONVERT.UNSUPPORTED_TOKEN_TYPE(e.$type));return{$type:e.$type,$value:e.$value,$path:e.$path,$resolvedValue:e.$resolvedValue,cssProperties:r(e.$value,t)}}n(ge,"convertSingleToken");function Te(e,t){const r={};for(const[o,i]of Object.entries(e)){if(Ae.has(o)||i===void 0)continue;const s={metadataMap:t,path:o};if(!("$type"in i))throw new Error(`Token at path ${o} is missing $type property`);if(i.$type==="fluidDimension"&&!t)throw new Error(c.CONVERT.MISSING_FLUID_CONFIG(o));const a=o.split(".").map(x).join("-");r[a]=ge(i,s)}return r}n(Te,"convert");function Ee(e){return typeof e=="object"&&e!==null&&typeof e.query=="string"&&typeof e.value=="string"}n(Ee,"isFeatureValue");function Se(e){return typeof e!="object"||e===null||!("value"in e)||typeof e.value!="string"&&typeof e.value!="number"?!1:"featureValues"in e?Array.isArray(e.featureValues)?e.featureValues.every(Ee):!1:!0}n(Se,"isSimpleCSSProperties");function Ne(e){return!!(typeof e=="string"||typeof e=="number"||Se(e))}n(Ne,"isValidCSSValue");const N="(color: color(display-p3 1 1 1))",he=[{query:N,test:n(e=>e.$type!=="color"?!1:e.cssProperties.featureValues?.some(r=>r.query===N)??!1,"test"),convertToCSSVars:n((e,t)=>{const o=t.cssProperties.featureValues?.find(i=>i.query===N);return o?[{name:`--${De(e)}`,value:o.value}]:[]},"convertToCSSVars")}];function De(e){return e.split(".").join("-")}n(De,"formatCSSVarPath");function j(e){return typeof e=="number"?e.toString():e.replace(/\{([^}]+)\}/g,(t,r)=>`var(--${r.split(".").map(x).join("-")})`)}n(j,"convertReferenceToCSSVar");function $(e,t){if(!Ne(t))throw new Error(c.GENERATE.INVALID_CSS_VALUE(e,String(t)));const r=typeof t=="object"&&"value"in t?j(t.value):j(t);return{name:`--${e}`,value:r}}n($,"createSingleCSSVar");function _e(e,t){if(!("split"in t)||!t.split)return{base:"value"in t?[$(e,t.value)]:Object.entries(t).map(([r,o])=>$(`${e}-${r}`,o))};if(Array.isArray(t.split)){const r=t.split.length>1;return{base:t.split.flatMap((o,i)=>Object.entries(o).map(([s,a])=>{const u=r?`-${i+1}-${s}`:`-${s}`;return $(`${e}${u}`,a)}))}}return{base:Object.entries(t.split).map(([r,o])=>$(`${e}-${r}`,o))}}n(_e,"convertSplitTokenToCSSVars");function Ve(e){return{name:`--${e}`,value:[`var(--${e}-width)`,`var(--${e}-style)`,`var(--${e}-color)`].join(" ")}}n(Ve,"createBorderCSSVar");function U(e,t,r){return[`var(--${e}${t?`-${r+1}`:""}-offset-x)`,`var(--${e}${t?`-${r+1}`:""}-offset-y)`,`var(--${e}${t?`-${r+1}`:""}-blur)`,`var(--${e}${t?`-${r+1}`:""}-spread)`,`var(--${e}${t?`-${r+1}`:""}-color)`].join(" ")}n(U,"createShadowCSSVar");function be(e,t,r){if("split"in r){if(e!=="shadow")return e==="border"?Ve(t):void 0;if(Array.isArray(r.split)){const o=r.split.length>1,i=r.split.map((s,a)=>U(t,o,a)).join(", ");return{name:`--${t}`,value:i}}return{name:`--${t}`,value:U(t,!1,0)}}}n(be,"createCombinedCSSVar");function Le(e,t,r){if(!(t.$type==="typography"||r.includes(t.$type)))return[$(e,t.cssProperties)];const{base:i}=_e(e,t.cssProperties),s=be(t.$type,e,t.cssProperties);return s?[...i,s]:i}n(Le,"convertTokenToCSSVarSet");function Oe(e){const t=`${e.root.selector}{${e.root.vars.map(o=>`${o.name}:${o.value}`).join(";")}}`,r=e.features.map(o=>`@supports ${o.query}{${e.root.selector}{${o.vars.map(i=>`${i.name}:${i.value}`).join(";")}}}`).join("");return t+r}n(Oe,"convertCSSVarsToString");async function ve(e,t={}){const r=Object.entries(e).filter(([s])=>s!=="$extensions").flatMap(([s,a])=>Le(s,a,t.splitTypes||[])),o=he.map(s=>{const u=Object.entries(e).filter(([f,I])=>s.test(I)).flatMap(([f,I])=>s.convertToCSSVars(f,I));return u.length>0?{query:s.query,vars:u}:null}).filter(s=>s!==null),i=Oe({root:{selector:":root",vars:r},features:o});return Re(i)}n(ve,"generateCSS");function Re(e){return e=e.replace(/{/g,`{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
1
|
+
var pt=Object.defineProperty;var s=(e,t)=>pt(e,"name",{value:t,configurable:!0});import{relative as R,isAbsolute as F,resolve as L,dirname as te,join as A,basename as dt}from"pathe";import C,{readFile as V,mkdir as Ie,writeFile as ye}from"node:fs/promises";import{z as l}from"zod";import{existsSync as D}from"node:fs";import mt from"fast-glob";import{pathToFileURL as ht}from"node:url";const k="_sugarcube.css",Ee="global",It="utilities",ge=".variables.gen.css",$e="tokens",yt="utilities.gen.css",Et="src/styles",gt="src/design-tokens",w="sugarcube.config.ts";function h(e){return typeof e=="string"&&e.startsWith("{")&&e.endsWith("}")}s(h,"isReference$1");function $t(e){if(typeof e!="object"||e===null||!("$value"in e))return!1;const t=e.$value;return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Object.keys(t).length>0}s($t,"isCompositeToken");function Nt(e){return e.$type==="typography"}s(Nt,"isTypographyToken");function Ne(e){return typeof e=="object"&&e!==null&&"$path"in e&&"$type"in e&&"$resolvedValue"in e}s(Ne,"isResolvedToken");function St(e,t){return Ne(e)&&e.$type===t}s(St,"isResolvedTokenOfType");function Tt(e){return Object.entries(e).sort(([t],[n])=>t.localeCompare(n))}s(Tt,"deterministicEntries");const Se=new Map;function At(e){const t=Se.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 Se.set(e,n),n}s(At,"toKebabCase");function ne(e){return e.split(".").join("-")}s(ne,"formatCSSVarPath");function re(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(At).join("-")})`)}s(re,"convertReferenceToCSSVar");function bt(e){const t=e.$cssProperties;if("value"in t)return{name:`--${ne(e.$path)}`,value:re(t.value)}}s(bt,"generateSingleVariable");function Ot(e){return Object.entries(e.$cssProperties).filter(([t,n])=>n!==void 0).map(([t,n])=>({name:`--${ne(e.$path)}-${t}`,value:re(n)}))}s(Ot,"generateTypographyVariables");function Te(e){if(e.$type!=="color")return[];const t=e.$cssProperties;if(!("featureValues"in t))return[];const n=new Map;for(const r of t.featureValues||[]){n.has(r.query)||n.set(r.query,[]);const o=n.get(r.query);o&&o.push({name:`--${ne(e.$path)}`,value:re(r.value)})}return Array.from(n.entries()).map(([r,o])=>({query:r,vars:o}))}s(Te,"generateFeatureVariables");function Ae(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(`
|
|
2
|
+
`);t.push(n)}return t.push("}"),t.join(`
|
|
3
|
+
`)}s(Ae,"generateCSSBlock");function Lt(e){const t=[];e.root.vars.length>0&&t.push(Ae({selector:e.root.selector,vars:e.root.vars}));for(const n of e.features){const o=Ae({selector:e.root.selector,vars:n.vars}).split(`
|
|
4
|
+
`).map(i=>` ${i}`).join(`
|
|
5
|
+
`);t.push(`${n.query} {
|
|
6
|
+
${o}
|
|
7
|
+
}`)}return t.filter(Boolean).join(`
|
|
5
8
|
|
|
6
|
-
`),e=e.
|
|
7
|
-
}`),e}n(Re,"formatCSSVars");function Ce(e){const t={root:{},groups:{},tokens:{}},r=[];if(D(e)){const{value:o,errors:i}=h(e,"");t.root=o,r.push(...i)}return P(e,"",t,r),{metadata:t,errors:r}}n(Ce,"collectMetadata");function P(e,t,r,o){for(const[i,s]of Object.entries(e)){if(i.startsWith("$"))continue;const a=t?`${t}.${i}`:i;if(!(typeof s!="object"||s===null)){if(!("$value"in s)&&D(s)){const{value:u,errors:f}=h(s,a);f.length>0&&o.push(...f),r.groups[a]=u}else if("$value"in s&&D(s)){const{value:u,errors:f}=h(s,a);f.length>0&&o.push(...f),r.tokens[a]=u}"$value"in s||P(s,a,r,o)}}}n(P,"collectNodeMetadata");function h(e,t){const r={},o=[];return w(e)?("$extensions"in e&&(typeof e.$extensions!="object"||e.$extensions===null?o.push({path:t,message:c.METADATA.INVALID_EXTENSIONS(t)}):r.$extensions=e.$extensions),"$description"in e&&(typeof e.$description!="string"?o.push({path:t,message:c.METADATA.INVALID_DESCRIPTION(t)}):r.$description=e.$description),{value:r,errors:o}):{value:r,errors:o}}n(h,"extractMetadata");function D(e){return w(e)&&("$extensions"in e||"$description"in e)}n(D,"hasMetadata");function w(e){return typeof e=="object"&&e!==null}n(w,"isValidNode");function Fe(e){return JSON.parse(e)}n(Fe,"parseJson");const Me={isObject:n(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObject")};function d(e,t,r){if(l(t))return[];switch(e.type){case"object":return xe(e,t,r);case"union":return je(e,t,r);case"array":return Ue(e,t,r);default:return ke(e,t,r)}}n(d,"validateSchema");function ke(e,t,r){return typeof t!==e.type?[{path:r,message:e.errorMessage?.(t,r)||c.VALIDATE.INVALID_TYPE(e.type,t,r)}]:e.validate?.(t,r)??[]}n(ke,"validateSimpleValue");function xe(e,t,r){if(!Me.isObject(t))return[{path:r,message:e.errorMessage?.(t,r)||c.VALIDATE.INVALID_TYPE("object",t,r)}];const o=[],i=t;if(e.required)for(const s of e.required)s in i||o.push({path:`${r}.${s}`,message:c.VALIDATE.MISSING_REQUIRED_PROPERTY(s,r)});for(const[s,a]of Object.entries(e.properties))s in i&&o.push(...d(a,i[s],`${r}.${s}`));return o}n(xe,"validateObject");function je(e,t,r){let o=[];for(const s of e.oneOf){const a=d(s,t,r);if(a.length===0)return e.validate?.(t,r)??[];o=o.concat(a)}return[o.reduce((s,a)=>a.path.length>s.path.length?a:s)]}n(je,"validateUnion");function Ue(e,t,r){return Array.isArray(t)?e.validate?.(t,r)??[]:[{path:r,message:e.errorMessage?.(t,r)||c.VALIDATE.INVALID_TYPE("array",t,r)}]}n(Ue,"validateArray");const T={tokenType:"color",schema:{type:"string",errorMessage:n((e,t)=>c.VALIDATE.INVALID_COLOR(e,t),"errorMessage"),validate:n((e,t)=>/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/.test(e)?[]:[{path:t,message:c.VALIDATE.INVALID_COLOR(e,t)}],"validate")}};function Pe(e,t){return d(T.schema,e,t)}n(Pe,"validateColor");const E={tokenType:"number",schema:{type:"number",errorMessage:n((e,t)=>c.VALIDATE.INVALID_NUMBER(e,t),"errorMessage"),validate:n((e,t)=>typeof e!="number"||isNaN(e)?[{path:t,message:c.VALIDATE.INVALID_NUMBER(e,t)}]:[],"validate")}};function we(e,t){return d(E.schema,e,t)}n(we,"validateNumber");const p={tokenType:"dimension",schema:{type:"object",errorMessage:n((e,t)=>c.VALIDATE.INVALID_DIMENSION(e,t),"errorMessage"),properties:{value:E.schema,unit:{type:"string",validate:n((e,t)=>typeof e!="string"||!["px","rem"].includes(e)?[{path:t,message:c.VALIDATE.INVALID_DIMENSION_UNIT(e,t)}]:[],"validate")}},required:["value","unit"]}};function Ye(e,t){return d(p.schema,e,t)}n(Ye,"validateDimension");const Y={tokenType:"fontFamily",schema:{type:"union",errorMessage:n((e,t)=>c.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage"),oneOf:[{type:"string",errorMessage:n((e,t)=>c.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")},{type:"array",validate:n((e,t)=>e.every(o=>typeof o=="string")?[]:[{path:t,message:c.VALIDATE.INVALID_FONT_FAMILY(e,t)}],"validate")}]}};function Ge(e,t){return d(Y.schema,e,t)}n(Ge,"validateFontFamily");const We=["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"],G={tokenType:"fontWeight",schema:{type:"union",errorMessage:n((e,t)=>c.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),oneOf:[{type:"number",errorMessage:n((e,t)=>c.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:n((e,t)=>e<1||e>1e3?[{path:t,message:c.VALIDATE.INVALID_FONT_WEIGHT(e,t)}]:[],"validate")},{type:"string",errorMessage:n((e,t)=>c.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:n((e,t)=>We.includes(e.toLowerCase())?[]:[{path:t,message:c.VALIDATE.INVALID_FONT_WEIGHT(e,t)}],"validate")}]}};function Be(e,t){return d(G.schema,e,t)}n(Be,"validateFontWeight");const ze=["ms","s"],_={tokenType:"duration",schema:{type:"object",errorMessage:n((e,t)=>c.VALIDATE.INVALID_DURATION(e,t),"errorMessage"),properties:{value:E.schema,unit:{type:"string",validate:n((e,t)=>(console.log("value",e),ze.includes(e)?[]:[{path:t,message:c.VALIDATE.INVALID_DURATION_UNIT(e,t)}]),"validate")}},required:["value","unit"]}};function qe(e,t){return d(_.schema,e,t)}n(qe,"validateDuration");const W={tokenType:"cubicBezier",schema:{type:"array",errorMessage:n((e,t)=>c.VALIDATE.INVALID_CUBIC_BEZIER(e,t),"errorMessage"),validate:n((e,t)=>{const r=e;if(r.length!==4||!r.every(s=>typeof s=="number"))return[{path:t,message:c.VALIDATE.INVALID_CUBIC_BEZIER(e,t)}];const[o,,i]=r;return o<0||o>1||i<0||i>1?[{path:t,message:c.VALIDATE.INVALID_CUBIC_BEZIER_RANGE(e,t)}]:[]},"validate")}};function He(e,t){return d(W.schema,e,t)}n(He,"validateCubicBezier");const Ke={tokenType:"typography",schema:{type:"object",properties:{fontFamily:Y.schema,fontSize:p.schema,letterSpacing:p.schema,lineHeight:E.schema,fontWeight:G.schema},required:["fontFamily","fontSize"],errorMessage:n((e,t)=>c.VALIDATE.INVALID_TYPOGRAPHY(e,t),"errorMessage")}};function Xe(e,t){return d(Ke.schema,e,t)}n(Xe,"validateTypography");const Ze=["solid","dashed","dotted","double","groove","ridge","outset","inset"],Qe=["round","butt","square"],Je={type:"object",errorMessage:n((e,t)=>c.VALIDATE.INVALID_STROKE_STYLE(e,t),"errorMessage"),properties:{dashArray:{type:"array",validate:n((e,t)=>{const r=e,o=[];return r.forEach((i,s)=>{typeof i!="string"&&o.push(...d(p.schema,i,`${t}[${s}]`))}),o},"validate")},lineCap:{type:"string",validate:n((e,t)=>Qe.includes(e)?[]:[{path:t,message:c.VALIDATE.INVALID_STROKE_LINE_CAP(e,t)}],"validate")}},required:["dashArray","lineCap"]},B={tokenType:"strokeStyle",schema:{type:"union",oneOf:[{type:"string",errorMessage:n((e,t)=>c.VALIDATE.INVALID_STROKE_STYLE(e,t),"errorMessage"),validate:n((e,t)=>Ze.includes(e)?[]:[{path:t,message:c.VALIDATE.INVALID_STROKE_STYLE(e,t)}],"validate")},Je]}};function et(e,t){return d(B.schema,e,t)}n(et,"validateStrokeStyle");const tt={tokenType:"border",schema:{type:"object",properties:{color:T.schema,width:p.schema,style:B.schema},required:["color","width","style"],errorMessage:n((e,t)=>c.VALIDATE.INVALID_BORDER(e,t),"errorMessage")}};function rt(e,t){return d(tt.schema,e,t)}n(rt,"validateBorder");const nt={tokenType:"transition",schema:{type:"object",properties:{duration:_.schema,delay:_.schema,timingFunction:W.schema},required:["duration","delay","timingFunction"],errorMessage:n((e,t)=>c.VALIDATE.INVALID_TRANSITION(e,t),"errorMessage")}};function ot(e,t){return d(nt.schema,e,t)}n(ot,"validateTransition");const z={tokenType:"shadow",schema:{type:"object",properties:{color:T.schema,offsetX:p.schema,offsetY:p.schema,blur:p.schema,spread:p.schema,inset:{type:"boolean",errorMessage:n((e,t)=>c.VALIDATE.INVALID_SHADOW_INSET(e,t),"errorMessage")}},required:["color","offsetX","offsetY","blur","spread"],errorMessage:n((e,t)=>c.VALIDATE.INVALID_SHADOW(e,t),"errorMessage")}};function it(e,t){const r=[];return Array.isArray(e)?(e.forEach((o,i)=>{r.push(...d(z.schema,o,`${t}[${i}]`))}),r):d(z.schema,e,t)}n(it,"validateShadow");const st={type:"object",errorMessage:n((e,t)=>c.VALIDATE.INVALID_GRADIENT(e,t),"errorMessage"),properties:{color:{type:"string",validate:T.schema.validate},position:{type:"number",validate:n((e,t)=>e<0||e>1?[{path:t,message:c.VALIDATE.INVALID_GRADIENT_STOP_POSITION(e,t)}]:[],"validate")}},required:["color","position"]},at={tokenType:"gradient",schema:{type:"array",errorMessage:n((e,t)=>c.VALIDATE.INVALID_ARRAY(e,t),"errorMessage"),validate:n((e,t)=>{const r=e,o=[];return r.forEach((i,s)=>{o.push(...d(st,i,`${t}[${s}]`))}),o},"validate")}};function ct(e,t){return d(at.schema,e,t)}n(ct,"validateGradient");const ut={tokenType:"fluidDimension",schema:{type:"object",errorMessage:n((e,t)=>c.VALIDATE.INVALID_FLUID_DIMENSION(e,t),"errorMessage"),properties:{min:p.schema,max:p.schema},required:["min","max"]}};function lt(e,t){return d(ut.schema,e,t)}n(lt,"validateFluidDimension");const ft={color:n((e,t)=>Pe(e,t),"color"),dimension:n((e,t)=>Ye(e,t),"dimension"),fluidDimension:n((e,t)=>lt(e,t),"fluidDimension"),duration:n((e,t)=>qe(e,t),"duration"),cubicBezier:n((e,t)=>He(e,t),"cubicBezier"),fontFamily:n((e,t)=>Ge(e,t),"fontFamily"),fontWeight:n((e,t)=>Be(e,t),"fontWeight"),number:n((e,t)=>we(e,t),"number"),strokeStyle:n((e,t)=>et(e,t),"strokeStyle"),typography:n((e,t)=>Xe(e,t),"typography"),border:n((e,t)=>rt(e,t),"border"),shadow:n((e,t)=>it(e,t),"shadow"),gradient:n((e,t)=>ct(e,t),"gradient"),transition:n((e,t)=>ot(e,t),"transition")};function dt(e,t,r){const o=[];if(!("$type"in e))return[{path:t,message:c.VALIDATE.MISSING_TYPE(t)}];if(!("$value"in e))return[{path:t,message:c.VALIDATE.MISSING_VALUE(t)}];const i=ft[e.$type];return i?(e.$type==="fluidDimension"&&(M(t,r)?.viewports||o.push({path:t,message:c.VALIDATE.MISSING_FLUID_CONFIG(t)})),[...o,...i(e.$value,t)]):[{path:t,message:c.VALIDATE.UNKNOWN_TOKEN_TYPE(e.$type,t)}]}n(dt,"validateTokenNode");function It(e,t){const r=[];for(const[o,i]of Object.entries(e))if(!(typeof i!="object"||i===null)&&!(!i.$path||i.$path.startsWith("$"))){if(typeof i!="object"||i===null){r.push({path:o,message:c.VALIDATE.INVALID_TOKEN_STRUCTURE(o)});continue}r.push(...dt(i,i.$path,t))}return r}n(It,"validate");export{Ce as collectMetadata,Te as convert,X as flatten,ve as generateCSS,Fe as parseJson,Z as resolve,It as validate};
|
|
9
|
+
`)}s(Lt,"convertCSSVarsToString");function _t(e){if(Nt(e))return{vars:Ot(e),features:Te(e)};const t=bt(e);return{vars:t?[t]:[],features:Te(e)}}s(_t,"generateVariablesForToken");function Rt(e,t,n){if(!e||e==="default")return":root";const r=e.indexOf(":");if(r!==-1){const o=e.slice(0,r),i=e.slice(r+1);return`[${t?.find(f=>f.name===o)?.attribute??`data-${o}`}="${i}"]`}return`[${n.output.themeAttribute}="${e}"]`}s(Rt,"buildSelector");async function Dt(e,t,n){const r=Tt(e).filter(([m,d])=>m!=="$extensions"&&"$type"in d).map(([m,d])=>_t(d)),o=Rt(n.context,n.modifiers,t),i=r.flatMap(m=>m.vars),a=r.flatMap(m=>m.features||[]),c=new Map;for(const m of a){c.has(m.query)||c.set(m.query,[]);const d=c.get(m.query);d&&d.push(...m.vars)}const f=Array.from(c.entries()).map(([m,d])=>({query:m,vars:d})),p=Lt({root:{selector:o,vars:i},features:f});return p.trim()?{output:[{path:"tokens.variables.gen.css",css:xt(p)}]}:{output:[{path:"tokens.variables.gen.css",css:""}]}}s(Dt,"generateCSS");function xt(e){return e.endsWith(`
|
|
10
|
+
`)?e:`${e}
|
|
11
|
+
`}s(xt,"formatCSSVars");async function vt(e,t,n){const o=`${t.output?.css||"src/styles"}/${Ee}`,i=[],a=Object.entries(e).sort(([c],[f])=>!c||c==="default"?-1:!f||f==="default"?1:c.localeCompare(f));for(const[c,f]of a){const p=await Dt(f,t,{context:c,modifiers:n});p.output[0].css.trim()&&i.push(p.output[0].css)}return i.length===0?[]:[{path:`${o}/${$e}${ge}`,css:`${i.filter(Boolean).join(`
|
|
12
|
+
`).trim()}
|
|
13
|
+
`}]}s(vt,"generateSingleFile");async function Ft(e,t,n){const r={};for(const[o,i]of Object.entries(e))Object.keys(i).length>0&&(r[o]=i);return{output:await vt(r,t,n)}}s(Ft,"generate");async function Ct(e,t,n){const{output:r}=await Ft(e,t,n);return r}s(Ct,"generateCSSVariables");const u={LOAD:{NO_FILES_FOUND:s(e=>`No files found matching pattern: ${e}.`,"NO_FILES_FOUND"),INVALID_JSON:s((e,t)=>`Invalid JSON in file ${e}: ${t}`,"INVALID_JSON"),GLOB_ERROR:s((e,t)=>`Error resolving glob pattern ${e}: ${t}`,"GLOB_ERROR")},FLATTEN:{INVALID_TOKEN_NAME:s(e=>`Invalid token name "${e}": Token names cannot contain dots (.), curly braces ({,}), or other special characters`,"INVALID_TOKEN_NAME"),MISSING_DOLLAR_PREFIX:s(e=>`Token at ${e} is using 'value' or 'type' without the required '$' prefix. Use '$value' and '$type' instead.`,"MISSING_DOLLAR_PREFIX"),INVALID_TOKEN_NESTING:s(e=>`Token at "${e}" cannot contain child tokens or groups. Only metadata properties (starting with $) are allowed.`,"INVALID_TOKEN_NESTING"),COMPOSITE_TOKEN_MISSING_TYPE:s(e=>`Composite token at '${e}' is missing the required "$type" property. Composite tokens (tokens with object values) must specify their type to define their structure.`,"COMPOSITE_TOKEN_MISSING_TYPE"),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)=>`Duplicate filename "${e}":
|
|
14
|
+
${t.map(n=>` - ${n}`).join(`
|
|
15
|
+
`)}`,"DUPLICATE_FILENAMES"),FILE_NOT_FOUND:s(e=>e===w?`Cannot find sugarcube config file. Please ensure you have a valid ${w} 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"),MISSING_SOURCE:s(e=>`Utility config for '${e}' must have a valid 'source' property`,"MISSING_SOURCE"),INVALID_SOURCE_PATTERN:s((e,t)=>`Utility config for '${e}' has invalid source pattern '${t}'. Only patterns ending with '.*' are supported (e.g., 'color.*', 'font.weight.*').`,"INVALID_SOURCE_PATTERN"),INVALID_DIRECTIONS:s(e=>`Utility config for '${e}' must have 'directions' as an array`,"INVALID_DIRECTIONS"),INVALID_CONFIG_OBJECT:"utilitiesConfig must be an object",INVALID_TOKENS_OBJECT:"tokens must be an object"},RESOLVER:{FILE_NOT_FOUND:s(e=>`Cannot read resolver file at "${e}". Please check the path and file permissions.`,"FILE_NOT_FOUND"),INVALID_JSON:s(e=>`Invalid JSON in resolver file: ${e}`,"INVALID_JSON"),INVALID_REFERENCE:s(e=>`Invalid reference "${e}". References must use format #/sets/<name> or #/modifiers/<name>.`,"INVALID_REFERENCE"),INVALID_SOURCE_REFERENCE:s(e=>`Invalid source reference "${e}". Sources can only reference sets (#/sets/<name>), not modifiers.`,"INVALID_SOURCE_REFERENCE"),UNDEFINED_SET:s(e=>`Reference to undefined set "${e}". Define it in the "sets" section first.`,"UNDEFINED_SET"),UNDEFINED_MODIFIER:s(e=>`Reference to undefined modifier "${e}". Define it in the "modifiers" section first.`,"UNDEFINED_MODIFIER"),CIRCULAR_REFERENCE:s(e=>`Circular reference detected at "${e}".`,"CIRCULAR_REFERENCE"),EXTERNAL_FILE_NOT_FOUND:s(e=>`Referenced file not found: ${e}`,"EXTERNAL_FILE_NOT_FOUND"),EXTERNAL_FILE_ERROR:s((e,t)=>`Failed to load "${e}": ${t}`,"EXTERNAL_FILE_ERROR"),INVALID_JSON_POINTER:s((e,t)=>`Invalid JSON pointer "${e}": ${t}`,"INVALID_JSON_POINTER"),DUPLICATE_NAME:s(e=>`Duplicate name "${e}" in resolutionOrder.`,"DUPLICATE_NAME"),MODIFIER_NEEDS_CONTEXTS:"Modifier must have at least one context defined.",MODIFIER_SINGLE_CONTEXT:"Modifier has only one context. Consider using a set instead, or add more contexts.",INVALID_DEFAULT:s((e,t)=>`Default context "${e}" is not defined. Valid contexts: ${t.join(", ")}`,"INVALID_DEFAULT"),UNKNOWN_MODIFIER:s(e=>`Unknown modifier "${e}".`,"UNKNOWN_MODIFIER"),INVALID_CONTEXT:s((e,t,n)=>`Invalid context "${e}" for modifier "${t}". Valid contexts: ${n.join(", ")}`,"INVALID_CONTEXT"),MISSING_REQUIRED_INPUT:s(e=>`Missing required input for modifier "${e}". No default value is defined.`,"MISSING_REQUIRED_INPUT"),INVALID_INPUT_TYPE:s(e=>`Input for modifier "${e}" must be a string.`,"INVALID_INPUT_TYPE"),MALFORMED_REFERENCE:s((e,t)=>`Malformed source reference: { "${e}": "${t}" }. Did you mean { "$ref": "${t}" }?`,"MALFORMED_REFERENCE"),RESOLVER_AS_TOKEN_SOURCE:s(e=>`File "${e}" is a resolver document, not a token file. Resolver documents (version: "2025.10") cannot be used as token sources. Did you mean to reference a specific token file instead?`,"RESOLVER_AS_TOKEN_SOURCE")}};function oe(e){return typeof e=="object"&&e!==null&&"$value"in e}s(oe,"isTokenNode");function Vt(e,t,n){for(const[r,o]of Object.entries(t.tokens)){const i=e.tokens[r];if(!oe(o)){if(i&&oe(i)){const d=i;n.push({path:d.$path,source:d.$source,message:u.FLATTEN.CONFLICT_TOKEN_VS_GROUP(d.$path)});continue}e.tokens[r]=o;continue}if(!i){e.tokens[r]=o;continue}if(!oe(i)){n.push({path:o.$path,source:o.$source,message:u.FLATTEN.CONFLICT_TOKEN_VS_GROUP(o.$path)});continue}const c=o,f=i,p=!!c.$type,m=!!f.$type;if(p&&m&&c.$type!==f.$type){n.push({path:c.$path,source:c.$source,message:u.FLATTEN.CONFLICT_INCOMPATIBLE_TYPES(String(f.$type??"unknown"),String(c.$type??"unknown"),c.$path)});continue}e.tokens[r]=o}for(const[r,o]of t.pathIndex)e.pathIndex.set(r,o)}s(Vt,"mergeFlattenedInto");function kt(e){if(typeof e!="object"||e===null||"$value"in e)return!1;const t="value"in e,n="type"in e;if(t&&n)return!0;if(t){const r=e.value;return typeof r=="string"||typeof r=="number"||Array.isArray(r)}return!1}s(kt,"looksLikeUnprefixedToken");function wt(e,t){const n={tokens:{},pathIndex:new Map},r=[];function o(a=[]){const c=[];return t.context&&c.push(t.context),a.length>0&&c.push(a.join(".")),c.length>0?c.join("."):""}s(o,"createLookupKey"),(e.$description||e.$extensions)&&(n.tokens[o()]={$description:e.$description,$extensions:e.$extensions});function i(a,c=[],f){if(c.join("."),c.length>0){const d=o(c);n.tokens[d]={$description:a.$description,$extensions:a.$extensions,$path:c.join("."),$source:{context:t.context,sourcePath:t.sourcePath}}}const p=Object.keys(a).filter(d=>!d.startsWith("$")),m=a.$type||f;for(const d of p){const I=a[d],y=[...c,d],g=y.join(".");if(kt(I)){r.push({path:g,source:t,message:u.FLATTEN.MISSING_DOLLAR_PREFIX(g)});continue}if(d.includes(".")||d.includes("{")||d.includes("}")){r.push({path:g,source:t,message:u.FLATTEN.INVALID_TOKEN_NAME(d)});continue}if("$value"in I){if(Object.keys(I).filter(lt=>!lt.startsWith("$")).length>0){r.push({path:g,source:t,message:u.FLATTEN.INVALID_TOKEN_NESTING(g)});continue}if($t(I)&&!I.$type&&!m){r.push({path:g,source:t,message:u.FLATTEN.COMPOSITE_TOKEN_MISSING_TYPE(g)});continue}const he=o(y),ee=y.join(".");n.tokens[he]={...I,...I.$type||m?{$type:I.$type||m}:{},$path:ee,$source:{context:t.context,sourcePath:t.sourcePath},$originalPath:ee},n.pathIndex.set(ee,he)}else i(I,y,m)}}return s(i,"processNode"),i(e),{tokens:n,errors:r}}s(wt,"flattenTree");function jt(e){const t={tokens:{},pathIndex:new Map},n=[];for(const r of e){const{tokens:o,errors:i}=wt(r.tokens,{context:r.context,sourcePath:r.sourcePath});n.push(...i),Vt(t,o,n)}return{tokens:t,errors:n}}s(jt,"flatten");async function Pt(e){const t=[],n=[],r=Object.entries(e);r.sort(([,o],[,i])=>{const a=!o.context,c=!i.context;return a&&!c?-1:!a&&c?1:0});for(const[o,{context:i,content:a}]of r)try{const c=JSON.parse(a);t.push({context:i,tokens:c,sourcePath:R(process.cwd(),o)})}catch(c){c instanceof Error?c instanceof SyntaxError?n.push({file:o,message:u.LOAD.INVALID_JSON(o,c.message)}):n.push({file:o,message:c.message}):n.push({file:o,message:"Unknown error"})}return{trees:t,errors:n}}s(Pt,"loadTreesFromMemory");const j=l.string().min(1,"Name cannot be empty").refine(e=>!e.startsWith("$"),"Names must not start with '$' (reserved prefix)").refine(e=>!e.includes("{"),"Names must not contain '{'").refine(e=>!e.includes("}"),"Names must not contain '}'").refine(e=>!e.includes("."),"Names must not contain '.'"),be=l.object({$ref:l.string().min(1,"$ref cannot be empty")}).passthrough();function _(e){return typeof e=="object"&&e!==null&&"$ref"in e&&typeof e.$ref=="string"}s(_,"isReference");function Oe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="set"}s(Oe,"isInlineSet");function x(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="modifier"}s(x,"isInlineModifier");const se=l.union([be,l.record(l.string(),l.unknown())]),Mt=l.object({description:l.string().optional(),sources:l.array(se),$extensions:l.record(l.string(),l.unknown()).optional()}),Le=l.record(l.string(),l.array(se)),Ut=l.object({description:l.string().optional(),contexts:Le,default:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}).refine(e=>Object.keys(e.contexts).length>=1,"Modifier must have at least 1 context"),Wt=l.object({type:l.literal("set"),name:j,sources:l.array(se),description:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}),Gt=l.object({type:l.literal("modifier"),name:j,contexts:Le,description:l.string().optional(),default:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}).refine(e=>Object.keys(e.contexts).length>=1,"Modifier must have at least 1 context"),Bt=l.union([be,Wt,Gt]),Yt=l.record(j,Mt),Kt=l.record(j,Ut),Ht=l.object({version:l.literal("2025.10"),name:l.string().optional(),description:l.string().optional(),sets:Yt.optional(),modifiers:Kt.optional(),resolutionOrder:l.array(Bt),$schema:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional(),$defs:l.record(l.string(),l.unknown()).optional()});async function qt(e){const t=F(e)?e:L(process.cwd(),e),n=await zt(t);if(n.error)return{document:M(),errors:[n.error]};const r=Jt(n.content);if(r.error)return{document:M(),errors:[r.error]};const o=Xt(r.data);if(o.errors.length>0)return{document:M(),errors:o.errors};const i=[];return Zt(o.document,i),{document:o.document,errors:i}}s(qt,"parseResolverDocument");async function zt(e){try{return{content:await V(e,"utf-8")}}catch{return{error:{path:e,message:u.RESOLVER.FILE_NOT_FOUND(e)}}}}s(zt,"loadFile");function Jt(e){try{return{data:JSON.parse(e)}}catch(t){const n=t instanceof Error?t.message:"Unknown error";return{error:{path:"resolver",message:u.RESOLVER.INVALID_JSON(n)}}}}s(Jt,"parseJson");function Xt(e){const t=Ht.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const o=r.path.join(".")||"resolver";return{path:o,message:`Resolver error at ${o}: ${r.message}. See https://sugarcube.sh/docs/resolver`}});return{document:M(),errors:n}}return{document:t.data,errors:[]}}s(Xt,"validateSchema$1");function Zt(e,t){Qt(e,t),en(e,t),tn(e,t)}s(Zt,"validateDocument");function Qt(e,t){if(e.modifiers)for(const[n,r]of Object.entries(e.modifiers))_e(r,`modifiers.${n}`,t);for(let n=0;n<e.resolutionOrder.length;n++){const r=e.resolutionOrder[n];x(r)&&_e(r,`resolutionOrder[${n}]`,t)}}s(Qt,"validateModifierContexts");function _e(e,t,n){const r=Object.keys(e.contexts).length;if(r===0){n.push({path:`${t}.contexts`,message:u.RESOLVER.MODIFIER_NEEDS_CONTEXTS});return}r===1&&n.push({path:`${t}.contexts`,message:u.RESOLVER.MODIFIER_SINGLE_CONTEXT}),e.default&&!e.contexts[e.default]&&n.push({path:`${t}.default`,message:u.RESOLVER.INVALID_DEFAULT(e.default,Object.keys(e.contexts))})}s(_e,"checkModifierContexts");function en(e,t){const n=new Set;for(let r=0;r<e.resolutionOrder.length;r++){const o=e.resolutionOrder[r];if(_(o))continue;const i=o.name;n.has(i)&&t.push({path:`resolutionOrder[${r}].name`,message:u.RESOLVER.DUPLICATE_NAME(i)}),n.add(i)}}s(en,"validateNameUniqueness");function tn(e,t){for(let n=0;n<e.resolutionOrder.length;n++){const r=e.resolutionOrder[n];if(_(r))nn(r.$ref,`resolutionOrder[${n}].$ref`,e,t);else if(Oe(r))P(r.sources,`resolutionOrder[${n}].sources`,t);else if(x(r))for(const[o,i]of Object.entries(r.contexts))P(i,`resolutionOrder[${n}].contexts.${o}`,t)}if(e.sets)for(const[n,r]of Object.entries(e.sets))P(r.sources,`sets.${n}.sources`,t);if(e.modifiers)for(const[n,r]of Object.entries(e.modifiers))for(const[o,i]of Object.entries(r.contexts))P(i,`modifiers.${n}.contexts.${o}`,t)}s(tn,"validateReferences");function P(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if(!o)continue;if(!_(o)){const a=Object.keys(o);if(a.length===1){const c=a[0],f=o[c];typeof f=="string"&&(f.includes("/")||f.endsWith(".json"))&&n.push({path:`${t}[${r}]`,message:u.RESOLVER.MALFORMED_REFERENCE(c,f)})}continue}const i=o.$ref;i.startsWith("#/")&&(i.match(/^#\/sets\/[^/]+$/)||n.push({path:`${t}[${r}].$ref`,message:u.RESOLVER.INVALID_SOURCE_REFERENCE(i)}))}}s(P,"validateSourcesReferences");function nn(e,t,n,r){if(!e.startsWith("#/"))return;const o=e.slice(2).split("/"),[i,a]=o;if(o.length!==2||!i||!a){r.push({path:t,message:u.RESOLVER.INVALID_REFERENCE(e)});return}if(i==="sets"){n.sets?.[a]||r.push({path:t,message:u.RESOLVER.UNDEFINED_SET(a)});return}if(i==="modifiers"){n.modifiers?.[a]||r.push({path:t,message:u.RESOLVER.UNDEFINED_MODIFIER(a)});return}r.push({path:t,message:u.RESOLVER.INVALID_REFERENCE(e)})}s(nn,"validateReference");function M(){return{version:"2025.10",resolutionOrder:[]}}s(M,"createEmptyDocument");function Re(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.version==="2025.10"&&Array.isArray(t.resolutionOrder)}s(Re,"isResolverFormat");function De(e,t){return{document:e,basePath:t,visitedRefs:new Set,fileCache:new Map}}s(De,"createResolveContext");async function xe(e,t){if(t.visitedRefs.has(e))return S({},u.RESOLVER.CIRCULAR_REFERENCE(e),e);t.visitedRefs.add(e);try{return e.startsWith("#/")?rn(e,t):e.includes("#/")?await sn(e,t):await on(e,t)}finally{t.visitedRefs.delete(e)}}s(xe,"resolveReference");function rn(e,t){const n=e.slice(2),[r,o]=n.split("/");if(!r||!o||n.split("/").length!==2)return S({sources:[]},u.RESOLVER.INVALID_REFERENCE(e));if(r==="sets"){const i=t.document.sets?.[o];return i?{content:i,sourcePath:"#",errors:[]}:S({sources:[]},u.RESOLVER.UNDEFINED_SET(o))}if(r==="modifiers"){const i=t.document.modifiers?.[o];return i?{content:i,sourcePath:"#",errors:[]}:S({contexts:{}},u.RESOLVER.UNDEFINED_MODIFIER(o))}return S({sources:[]},u.RESOLVER.INVALID_REFERENCE(e))}s(rn,"resolveSameDocumentRef");async function on(e,t){const n=F(e)?e:L(t.basePath,e),r=t.fileCache.get(n);if(r)return Re(r)?S({},u.RESOLVER.RESOLVER_AS_TOKEN_SOURCE(n),n):{content:r,sourcePath:n,errors:[]};const o=await ve(n);return o.error?S({},o.error,n):Re(o.content)?S({},u.RESOLVER.RESOLVER_AS_TOKEN_SOURCE(n),n):(t.fileCache.set(n,o.content),{content:o.content,sourcePath:n,errors:[]})}s(on,"resolveFileRef");async function sn(e,t){const[n="",r=""]=e.split("#"),o=F(n)?n:L(t.basePath,n);let i=t.fileCache.get(o);if(!i){const f=await ve(o);if(f.error)return S({},f.error,o);i=f.content,t.fileCache.set(o,i)}const a=r.startsWith("/")?r:`/${r}`,c=an(i,a);return c.error?S({},u.RESOLVER.INVALID_JSON_POINTER(a,c.error),o):{content:c.value,sourcePath:o,errors:[]}}s(sn,"resolveFileFragmentRef");async function ve(e){try{const t=await V(e,"utf-8");return{content:JSON.parse(t)}}catch(t){if(t.code==="ENOENT")return{error:u.RESOLVER.EXTERNAL_FILE_NOT_FOUND(e)};const n=t instanceof Error?t.message:"Unknown error";return{error:u.RESOLVER.EXTERNAL_FILE_ERROR(e,n)}}}s(ve,"loadJsonFile");function an(e,t){if(t===""||t==="/")return{value:e};const n=t.slice(1).split("/").map(o=>o.replace(/~1/g,"/").replace(/~0/g,"~"));let r=e;for(const o of n){if(r===null||typeof r!="object")return{error:"cannot navigate into non-object"};if(Array.isArray(r)){const a=Number.parseInt(o,10);if(Number.isNaN(a)||a<0||a>=r.length)return{error:`invalid array index "${o}"`};r=r[a];continue}const i=r;if(!(o in i))return{error:`property "${o}" not found`};r=i[o]}return{value:r}}s(an,"resolveJsonPointer");async function Fe(e,t){const n=[],r=[];for(const o of e){if(!_(o)){n.push(o);continue}const i=await xe(o.$ref,t);r.push(...i.errors),i.errors.length===0&&n.push(cn(i.content,o))}return{resolved:n,errors:r}}s(Fe,"resolveSources");function cn(e,t){const{$ref:n,...r}=t;return Object.keys(r).length===0?e:{...e,...r}}s(cn,"applyExtending");function S(e,t,n="#"){return{content:e,sourcePath:n,errors:[{path:n,message:t}]}}s(S,"errorResult");function Ce(e){return typeof e=="object"&&e!==null&&"$value"in e}s(Ce,"isToken");function U(e,t){const n={...e};for(const[r,o]of Object.entries(t)){if(o===void 0)continue;if(r.startsWith("$")){n[r]=o;continue}if(Ce(o)){n[r]=o;continue}const i=n[r],a=i!==void 0&&typeof i=="object"&&i!==null&&typeof o=="object"&&o!==null&&!Ce(i);n[r]=a?U(i,o):o}return n}s(U,"deepMerge");function Ve(e){const t=[],n=new Set;for(const r of e.resolutionOrder){const o=un(r,e,n);o&&(t.push(o),n.add(o.name))}return t}s(Ve,"extractModifiers");function un(e,t,n){return _(e)&&e.$ref.startsWith("#/modifiers/")?fn(e.$ref,t,n):x(e)?ln(e,n):null}s(un,"extractModifierFromItem");function fn(e,t,n){const r=e.split("/")[2];if(!r||n.has(r))return null;const o=t.modifiers?.[r];return o?{name:r,contexts:Object.keys(o.contexts),default:o.default}:null}s(fn,"extractReferencedModifier");function ln(e,t){return t.has(e.name)?null:{name:e.name,contexts:Object.keys(e.contexts),default:e.default}}s(ln,"extractInlineModifier");function pn(e,t={}){const n=[],r={},o=Ve(e);if(o.length===0)return dn(t,n),{valid:n.length===0,errors:n,resolvedInputs:r};const i=new Map(o.map(a=>[a.name,a]));return mn(t,i,n,r),hn(o,r,n),{valid:n.length===0,errors:n,resolvedInputs:r}}s(pn,"validateInputs$1");function dn(e,t){for(const n of Object.keys(e))t.push({modifier:n,message:u.RESOLVER.UNKNOWN_MODIFIER(n)})}s(dn,"validateNoModifiersCase");function mn(e,t,n,r){for(const[o,i]of Object.entries(e)){const a=t.get(o);if(!a){n.push({modifier:o,message:u.RESOLVER.UNKNOWN_MODIFIER(o)});continue}if(typeof i!="string"){n.push({modifier:o,message:u.RESOLVER.INVALID_INPUT_TYPE(o)});continue}if(!a.contexts.includes(i)){n.push({modifier:o,message:u.RESOLVER.INVALID_CONTEXT(i,o,a.contexts)});continue}r[o]=i}}s(mn,"validateProvidedInputs");function hn(e,t,n){for(const r of e)t[r.name]===void 0&&(r.default!==void 0?t[r.name]=r.default:n.push({modifier:r.name,message:u.RESOLVER.MISSING_REQUIRED_INPUT(r.name)}))}s(hn,"applyDefaults");async function ke(e,t,n={}){const r=pn(e,n);if(!r.valid)return{tokens:{},sources:[],errors:r.errors.map(a=>({path:a.modifier||"inputs",message:a.message}))};const o=De(e,t),i=In();for(const a of e.resolutionOrder)await yn(a,e,o,r.resolvedInputs,i);return{tokens:i.tokens,sources:i.sources,errors:i.errors}}s(ke,"processResolutionOrder");function In(){return{tokens:{},sources:[],errors:[]}}s(In,"createProcessingState");async function yn(e,t,n,r,o){if(_(e)){await En(e,t,n,r,o);return}if(Oe(e)){await gn(e,n,o);return}x(e)&&await $n(e,n,r,o)}s(yn,"processItem");async function En(e,t,n,r,o){const i=await xe(e.$ref,n);if(i.errors.length>0){o.errors.push(...i.errors);return}const a=e.$ref.split("/")[2];if(a){if(e.$ref.startsWith("#/sets/")){const c=await W(i.content.sources,n,{type:"set",name:a});G(c,o);return}if(e.$ref.startsWith("#/modifiers/")){const c=r[a];if(!c)return;const p=i.content.contexts[c];if(!p)return;const m=await W(p,n,{type:"modifier",name:a,context:c});G(m,o)}}}s(En,"processReference");async function gn(e,t,n){const r=await W(e.sources,t,{type:"set",name:e.name});G(r,n)}s(gn,"processInlineSet");async function $n(e,t,n,r){const o=n[e.name];if(!o)return;const i=e.contexts[o];if(!i)return;const a=await W(i,t,{type:"modifier",name:e.name,context:o});G(a,r)}s($n,"processInlineModifier");async function W(e,t,n){const r=await Fe(e,t);let o={};for(const i of r.resolved)o=U(o,i);return{tokens:o,source:{path:"#",...n},errors:r.errors}}s(W,"mergeSources");function G(e,t){t.errors.push(...e.errors),t.tokens=U(t.tokens,e.tokens),t.sources.push(e.source)}s(G,"applyResult");async function Nn(e,t){const n=[],r=De(e,t),o=Ve(e),i={};for(const p of o)p.default&&(i[p.name]=p.default);const a=await ke(e,t,i);n.push(...a.errors);const c=a.tokens,f=[];for(const p of o){const m=new Map,d=p.default??p.contexts[0]??"default";for(const I of p.contexts){if(I===d)continue;const y=await Sn(e,t,r,p.name,I,n);Object.keys(y).length>0&&m.set(I,y)}f.push({name:p.name,defaultContext:d,contexts:m})}return{base:c,modifiers:f,errors:n}}s(Nn,"processForLayeredCSS");async function Sn(e,t,n,r,o,i){const a=Tn(e,r);if(!a)return{};const c=a.contexts[o];if(!c||c.length===0)return{};const f=await Fe(c,n);i.push(...f.errors.map(y=>({path:y.path,message:y.message})));let p={};for(const y of f.resolved)p=U(p,y);const m=new Set;we(p,"",m);const d=await ke(e,t,{[r]:o});i.push(...d.errors);const I={};for(const y of m){const g=An(d.tokens,y);g!==void 0&&bn(I,y,g)}return I}s(Sn,"processModifierContext");function Tn(e,t){if(e.modifiers?.[t])return e.modifiers[t];for(const n of e.resolutionOrder)if(x(n)&&n.name===t)return n}s(Tn,"findModifierDefinition");function we(e,t,n){for(const[r,o]of Object.entries(e)){if(r.startsWith("$"))continue;const i=t?`${t}.${r}`:r;o&&typeof o=="object"&&"$value"in o?n.add(i):o&&typeof o=="object"&&we(o,i,n)}}s(we,"collectTokenPaths");function An(e,t){const n=t.split(".");let r=e;for(const o of n){if(r===null||typeof r!="object")return;r=r[o]}return r}s(An,"getTokenAtPath");function bn(e,t,n){const r=t.split(".");let o=e;for(let a=0;a<r.length-1;a++){const c=r[a];c&&(c in o||(o[c]={}),o=o[c])}const i=r[r.length-1];i&&(o[i]=n)}s(bn,"setTokenAtPath");async function je(e){const t=F(e)?e:L(process.cwd(),e),n=te(t),r=[],o=[],i=R(process.cwd(),t),a=await qt(t);if(a.errors.length>0)return{trees:[],modifiers:[],errors:a.errors.map(p=>({file:p.path,message:p.message}))};const c=await Nn(a.document,n);for(const p of c.errors)r.push({file:p.path,message:p.message});Object.keys(c.base).length>0&&o.push({context:void 0,tokens:c.base,sourcePath:i});const f=[];for(const p of c.modifiers){const m=[];for(const[d,I]of p.contexts)Object.keys(I).length>0&&(o.push({context:`${p.name}:${d}`,tokens:I,sourcePath:i}),m.push(d));f.push({name:p.name,attribute:`data-${p.name}`,defaultContext:p.defaultContext,contexts:m})}return{trees:o,modifiers:f,errors:r}}s(je,"loadFromResolver");function B(e,t,n,r){return typeof t=="string"&&h(t)?Ln(e,t,n,r):Array.isArray(t)?t.map(o=>B(e,o,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}s(B,"resolveValue");function Pe(e,t){const n=e.slice(1,-1),r=t.pathIndex.get(n);if(!r)return;const o=t.tokens[r];if(!(!o||!("$value"in o))){if(o.$type)return o.$type;if(typeof o.$value=="string"&&h(o.$value))return Pe(o.$value,t)}}s(Pe,"inferTypeFromReference");function On(e){const t={},n=new Set,r=[];for(const[o,i]of Object.entries(e.tokens))try{if(!("$value"in i)){t[o]=i;continue}const a=i;let c=a.$type;!c&&typeof a.$value=="string"&&h(a.$value)&&(c=Pe(a.$value,e)),t[o]={...a,...c?{$type:c}:{},$resolvedValue:B(a.$path,a.$value,e,n)}}catch(a){const c=a instanceof Error?a.message:String(a),f=i,p=f.$path,m=f.$source;let d,I;c.includes("Circular reference detected")?(d="circular",I=c):c.includes("Reference not found")?(d="missing",I=c):(d="type-mismatch",I=u.RESOLVE.TYPE_MISMATCH(p)),r.push({type:d,path:p,source:m,message:I})}return{resolved:t,errors:r}}s(On,"resolve");function Ln(e,t,n,r){const o=t.slice(1,-1),i=n.pathIndex.get(o);if(!i)throw new Error(u.RESOLVE.REFERENCE_NOT_FOUND(o,e));if(r.has(i)){const f=n.tokens[i];throw!f||!("$path"in f)?new Error(u.RESOLVE.REFERENCE_NOT_FOUND(o,e)):new Error(u.RESOLVE.CIRCULAR_REFERENCE(e,f.$path))}const a=n.tokens[i];if(!a||!("$value"in a))throw new Error(u.RESOLVE.REFERENCE_NOT_FOUND(o,e));r.add(i);const c=B(i,a.$value,n,r);return r.delete(i),c}s(Ln,"resolveReferenceChain");function T(e){return{success:!0,value:e}}s(T,"success");function $(e){return{success:!1,error:e}}s($,"error");function ie(e){if(typeof e!="object"||e===null)return!1;const t=e;return!(typeof t.colorSpace!="string"||!["oklch","display-p3","srgb","hsl"].includes(t.colorSpace)||!Array.isArray(t.components)||t.components.length!==3||!t.components.every(r=>typeof r=="number"||r==="none")||t.alpha!==void 0&&typeof t.alpha!="number"||t.hex!==void 0&&typeof t.hex!="string")}s(ie,"isW3CColorValue");function Y(e){const t=[],n=["oklch","display-p3","srgb","hsl"];if(n.includes(e.colorSpace)||t.push(`Unsupported colorSpace: "${e.colorSpace}". Supported color spaces: ${n.join(", ")}.`),!Array.isArray(e.components)||e.components.length!==3)t.push("Components must be an array of exactly 3 numbers.");else if(e.components.forEach((r,o)=>{r!=="none"&&(typeof r!="number"||!Number.isFinite(r))&&t.push(`Component ${o} must be a finite number or "none".`)}),e.colorSpace==="oklch"){const[r,o,i]=e.components;r!=="none"&&(r<0||r>1)&&t.push("OKLCH Lightness (L) must be between 0 and 1 or 'none'."),o!=="none"&&o<0&&t.push("OKLCH Chroma (C) must be >= 0 or 'none'."),i!=="none"&&(i<0||i>=360)&&t.push("OKLCH Hue (H) must be between 0 and 360 (exclusive) or 'none'.")}else if(e.colorSpace==="display-p3"){const[r,o,i]=e.components;r!=="none"&&(r<0||r>1)&&t.push("Display P3 Red component must be between 0 and 1 or 'none'."),o!=="none"&&(o<0||o>1)&&t.push("Display P3 Green component must be between 0 and 1 or 'none'."),i!=="none"&&(i<0||i>1)&&t.push("Display P3 Blue component must be between 0 and 1 or 'none'.")}else if(e.colorSpace==="srgb"){const[r,o,i]=e.components;r!=="none"&&(r<0||r>1)&&t.push("sRGB Red component must be between 0 and 1 or 'none'."),o!=="none"&&(o<0||o>1)&&t.push("sRGB Green component must be between 0 and 1 or 'none'."),i!=="none"&&(i<0||i>1)&&t.push("sRGB Blue component must be between 0 and 1 or 'none'.")}else if(e.colorSpace==="hsl"){const[r,o,i]=e.components;r!=="none"&&(r<0||r>=360)&&t.push("HSL Hue must be between 0 and 360 (exclusive) or 'none'."),o!=="none"&&(o<0||o>100)&&t.push("HSL Saturation must be between 0 and 100 or 'none'."),i!=="none"&&(i<0||i>100)&&t.push("HSL Lightness must be between 0 and 100 or 'none'.")}return e.alpha!==void 0&&(typeof e.alpha!="number"||!Number.isFinite(e.alpha)?t.push("Alpha must be a finite number."):(e.alpha<0||e.alpha>1)&&t.push("Alpha must be between 0 and 1.")),t}s(Y,"validateW3CColorValue");function _n(e){const t=Y(e);return t.length>0?$(t.join(", ")):T(e)}s(_n,"validateW3CColorValueResult");function Rn(e){const t=_n(e);if(!t.success)return t;const[n,r,o]=e.components,i=e.alpha,a=n==="none"?"none":Number(n.toFixed(4)),c=r==="none"?"none":Number(r.toFixed(4)),f=o==="none"?"none":Number(o.toFixed(4));if(i!==void 0&&i!==1){const p=Number(i.toFixed(4));return T(`oklch(${a} ${c} ${f} / ${p})`)}return T(`oklch(${a} ${c} ${f})`)}s(Rn,"formatW3CColorToOKLCH");const Dn={isObject:s(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObject")};function E(e,t,n,r){if(h(t))return[];switch(e.type){case"object":return vn(e,t,n,r);case"union":return Fn(e,t,n,r);case"array":return Cn(e,t,n,r);default:return xn(e,t,n,r)}}s(E,"validateSchema");function xn(e,t,n,r){return e.type!==typeof t?[{path:n,message:e.errorMessage?.(t,n)||u.VALIDATE.INVALID_TYPE(e.type,t,n),source:r}]:e.validate?.(t,n,r)??[]}s(xn,"validateSimpleValue");function vn(e,t,n,r){if(!Dn.isObject(t))return[{path:n,message:e.errorMessage?.(t,n)||u.VALIDATE.INVALID_TYPE("object",t,n),source:r}];const o=[],i=t;if(e.required)for(const a of e.required)a in i||o.push({path:`${n}.${a}`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY(a,n),source:r});for(const[a,c]of Object.entries(e.properties))a in i&&o.push(...E(c,i[a],`${n}.${a}`,r));return o}s(vn,"validateObject");function Fn(e,t,n,r){let o=[],i=Number.POSITIVE_INFINITY;for(const a of e.oneOf){if(a.type==="string"&&typeof t!="string"||a.type==="object"&&typeof t!="object")continue;const c=E(a,t,n,r);if(c.length===0)return a.validate?.(t,n,r)??[];c.length<i&&(o=c,i=c.length)}return i===Number.POSITIVE_INFINITY?[{path:n,message:u.VALIDATE.INVALID_TYPE(e.oneOf.map(a=>a.type).join(" or "),t,n),source:r}]:o}s(Fn,"validateUnion");function Cn(e,t,n,r){return Array.isArray(t)?e.validate?.(t,n,r)??[]:[{path:n,message:e.errorMessage?.(t,n)||u.VALIDATE.INVALID_TYPE("array",t,n),source:r}]}s(Cn,"validateArray");const K={schema:{type:"union",oneOf:[{type:"string",validate:s((e,t,n)=>/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/.test(e)?[]:[{path:t,message:u.VALIDATE.INVALID_COLOR(e,t),source:n}],"validate")},{type:"object",required:["colorSpace","components"],properties:{colorSpace:{type:"string"},components:{type:"array"},alpha:{type:"number"},hex:{type:"string"}},validate:s((e,t,n)=>ie(e)?Y(e).map(o=>({path:t,message:`Invalid color at ${t}: ${o}`,source:n})):[{path:t,message:u.VALIDATE.INVALID_COLOR(e,t),source:n}],"validate")}]}};function Vn(e,t,n){return E(K.schema,e,t,n)}s(Vn,"validateColor");const H={schema:{type:"number",errorMessage:s((e,t)=>u.VALIDATE.INVALID_NUMBER(e,t),"errorMessage"),validate:s((e,t,n)=>typeof e!="number"||Number.isNaN(e)?[{path:t,message:u.VALIDATE.INVALID_NUMBER(e,t),source:n}]:[],"validate")}};function kn(e,t,n){return E(H.schema,e,t,n)}s(kn,"validateNumber");const N={schema:{type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_DIMENSION(e,t),"errorMessage"),properties:{value:H.schema,unit:{type:"string",validate:s((e,t,n)=>typeof e!="string"||!["px","rem"].includes(e)?[{path:t,message:u.VALIDATE.INVALID_DIMENSION_UNIT(e,t),source:n}]:[],"validate")}},required:["value","unit"]}};function wn(e,t,n){return E(N.schema,e,t,n)}s(wn,"validateDimension");const Me={schema:{type:"union",oneOf:[{type:"string",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")},{type:"array",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage"),validate:s((e,t,n)=>e.every(o=>typeof o=="string")?[]:[{path:t,message:u.VALIDATE.INVALID_FONT_FAMILY(e,t),source:n}],"validate")}],errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")}};function jn(e,t,n){return E(Me.schema,e,t,n)}s(jn,"validateFontFamily");const Pn=["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"],Ue={schema:{type:"union",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),oneOf:[{type:"number",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>e<1||e>1e3?[{path:t,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}]:[],"validate")},{type:"string",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>Pn.includes(e.toLowerCase())?[]:[{path:t,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}],"validate")}]}};function Mn(e,t,n){return E(Ue.schema,e,t,n)}s(Mn,"validateFontWeight");const Un=["ms","s"],ae={schema:{type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_DURATION(e,t),"errorMessage"),properties:{value:H.schema,unit:{type:"string",validate:s((e,t,n)=>Un.includes(e)?[]:[{path:t,message:u.VALIDATE.INVALID_DURATION_UNIT(e,t),source:n}],"validate")}},required:["value","unit"]}};function Wn(e,t,n){return E(ae.schema,e,t,n)}s(Wn,"validateDuration");const We={schema:{type:"array",errorMessage:s((e,t)=>u.VALIDATE.INVALID_CUBIC_BEZIER(e,t),"errorMessage"),validate:s((e,t,n)=>{const r=e;if(r.length!==4||!r.every(a=>typeof a=="number"))return[{path:t,message:u.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}];const[o,,i]=r;return o<0||o>1||i<0||i>1?[{path:t,message:u.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}]:[]},"validate")}};function Gn(e,t,n){return E(We.schema,e,t,n)}s(Gn,"validateCubicBezier");const Bn={schema:{type:"object",properties:{fontFamily:Me.schema,fontSize:N.schema,letterSpacing:N.schema,lineHeight:H.schema,fontWeight:Ue.schema},required:["fontFamily","fontSize"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_TYPOGRAPHY(e,t),"errorMessage")}};function Yn(e,t,n){return E(Bn.schema,e,t,n)}s(Yn,"validateTypography");const Kn=["solid","dashed","dotted","double","groove","ridge","outset","inset"],Hn=["round","butt","square"],qn={type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_STROKE_STYLE(e,t),"errorMessage"),properties:{dashArray:{type:"array",validate:s((e,t,n)=>{const r=e,o=[];return r.forEach((i,a)=>{typeof i!="string"&&o.push(...E(N.schema,i,`${t}.${a}`,n))}),o},"validate")},lineCap:{type:"string",validate:s((e,t,n)=>Hn.includes(e)?[]:[{path:t,message:u.VALIDATE.INVALID_STROKE_LINE_CAP(e,t),source:n}],"validate")}},required:["dashArray","lineCap"]},Ge={schema:{type:"union",oneOf:[{type:"string",validate:s((e,t,n)=>!Kn.includes(e)&&typeof e=="string"?[{path:t,message:u.VALIDATE.INVALID_STROKE_STYLE(e,t),source:n}]:[],"validate")},qn]}};function zn(e,t,n){return E(Ge.schema,e,t,n)}s(zn,"validateStrokeStyle");const Jn={schema:{type:"object",properties:{color:K.schema,width:N.schema,style:Ge.schema},required:["color","width","style"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_BORDER(e,t),"errorMessage")}};function Xn(e,t,n){return E(Jn.schema,e,t,n)}s(Xn,"validateBorder");const Zn={schema:{type:"object",properties:{duration:ae.schema,delay:ae.schema,timingFunction:We.schema},required:["duration","delay","timingFunction"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_TRANSITION(e,t),"errorMessage")}};function Qn(e,t,n){return E(Zn.schema,e,t,n)}s(Qn,"validateTransition");const Be={schema:{type:"object",properties:{color:{type:"union",oneOf:[K.schema]},offsetX:N.schema,offsetY:N.schema,blur:N.schema,spread:N.schema,inset:{type:"boolean",errorMessage:s((e,t)=>u.VALIDATE.INVALID_SHADOW_INSET(e,t),"errorMessage")}},required:["color","offsetX","offsetY","blur","spread"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_SHADOW(e,t),"errorMessage")}};function er(e,t,n){const r=[];return Array.isArray(e)?(e.forEach((o,i)=>{r.push(...E(Be.schema,o,`${t}[${i}]`,n))}),r):E(Be.schema,e,t,n)}s(er,"validateShadow");const tr={type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_GRADIENT(e,t),"errorMessage"),properties:{color:K.schema,position:{type:"number",validate:s((e,t,n)=>e<0||e>1?[{path:t,message:u.VALIDATE.INVALID_GRADIENT_STOP_POSITION(e,t),source:n}]:[],"validate")}},required:["color","position"]},nr={schema:{type:"array",errorMessage:s((e,t)=>u.VALIDATE.INVALID_ARRAY(e,t),"errorMessage"),validate:s((e,t,n)=>{const r=e,o=[];return r.forEach((i,a)=>{o.push(...E(tr,i,`${t}[${a}]`,n))}),o},"validate")}};function rr(e,t,n){return E(nr.schema,e,t,n)}s(rr,"validateGradient");const or={schema:{type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FLUID_DIMENSION(e,t),"errorMessage"),properties:{min:N.schema,max:N.schema},required:["min","max"]}};function sr(e,t,n){return E(or.schema,e,t,n)}s(sr,"validateFluidDimension");const ir={color:Vn,dimension:wn,fluidDimension:sr,duration:Wn,cubicBezier:Gn,fontFamily:jn,fontWeight:Mn,number:kn,strokeStyle:zn,typography:Yn,border:Xn,shadow:er,gradient:rr,transition:Qn};function ar(e){const t=[];for(const[n,r]of Object.entries(e.tokens)){if(typeof r!="object"||r===null||!("$type"in r)||!("$path"in r)||r.$path.startsWith("$"))continue;if(!("$value"in r)){t.push({path:r.$path,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("$value",r.$path),source:r.$source});continue}const o=ir[r.$type];if(!o){t.push({path:r.$path,message:u.VALIDATE.UNKNOWN_TOKEN_TYPE(r.$type,r.$path),source:r.$source});continue}const i=r;t.push(...o(i.$value,i.$path,i.$source))}return t}s(ar,"validate");async function cr(e){const{trees:t,modifiers:n,errors:r}=await ur(e),{tokens:o,errors:i}=jt(t),a=ar(o),{resolved:c,errors:f}=On(o);return{trees:t,resolved:c,modifiers:n,errors:{load:r,flatten:i,validation:a,resolution:f}}}s(cr,"loadAndResolveTokens");async function ur(e){switch(e.type){case"memory":{const t=await Pt(e.data);return{trees:t.trees,modifiers:[],errors:t.errors}}case"resolver":{const t=await je(e.resolverPath);return{trees:t.trees,modifiers:t.modifiers,errors:t.errors}}}}s(ur,"loadTokens");function Ye(e){return h(e)?{value:e}:typeof e=="string"?{value:e}:{value:`${e.dashArray.map(n=>h(n)?n:`${n.value}${n.unit}`).join(" ")} ${e.lineCap}`}}s(Ye,"convertStrokeStyleToken");function fr(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:Ye(e.style).value;return{value:`${t} ${r} ${n}`}}s(fr,"convertBorderToken");function Ke(e,t="native"){return ie(e)?lr(e):T(e)}s(Ke,"convertColorToString");function lr(e){switch(e.colorSpace){case"oklch":return Rn(e);case"display-p3":return pr(e);case"srgb":return dr(e);case"hsl":return mr(e);default:return $(`Unsupported color space: ${e.colorSpace}. Supported color spaces: oklch, display-p3, srgb, hsl.`)}}s(lr,"formatW3CColorNative");function pr(e){if(e.colorSpace!=="display-p3")return $(`Expected display-p3 color space, got: ${e.colorSpace}`);if(!Array.isArray(e.components)||e.components.length!==3)return $("Display P3 components must be an array of exactly 3 numbers [R, G, B]");const[t,n,r]=e.components,o=e.alpha;if(t!=="none"&&(t<0||t>1))return $("Display P3 Red component must be between 0 and 1 or 'none'");if(n!=="none"&&(n<0||n>1))return $("Display P3 Green component must be between 0 and 1 or 'none'");if(r!=="none"&&(r<0||r>1))return $("Display P3 Blue component must be between 0 and 1 or 'none'");if(o!==void 0&&(o<0||o>1))return $("Alpha must be between 0 and 1");const i=t==="none"?"none":Number(t.toFixed(4)),a=n==="none"?"none":Number(n.toFixed(4)),c=r==="none"?"none":Number(r.toFixed(4));if(o!==void 0&&o!==1){const f=Number(o.toFixed(4));return T(`color(display-p3 ${i} ${a} ${c} / ${f})`)}return T(`color(display-p3 ${i} ${a} ${c})`)}s(pr,"formatW3CColorToP3");function dr(e){if(e.colorSpace!=="srgb")return $(`Expected srgb color space, got: ${e.colorSpace}`);const t=Y(e);if(t.length>0)return $(`Invalid W3C color value: ${t.join(", ")}`);const[n,r,o]=e.components,i=e.alpha,a=n==="none"?"none":Math.round(n*255),c=r==="none"?"none":Math.round(r*255),f=o==="none"?"none":Math.round(o*255);if(i!==void 0&&i!==1){const p=Number(i.toFixed(4));return T(`rgb(${a} ${c} ${f} / ${p})`)}return T(`rgb(${a} ${c} ${f})`)}s(dr,"formatW3CColorToRGB");function mr(e){if(e.colorSpace!=="hsl")return $(`Expected hsl color space, got: ${e.colorSpace}`);const t=Y(e);if(t.length>0)return $(`Invalid W3C color value: ${t.join(", ")}`);const[n,r,o]=e.components,i=e.alpha,a=n==="none"?"none":Number(n.toFixed(1)),c=r==="none"?"none":Math.round(r),f=o==="none"?"none":Math.round(o);if(i!==void 0&&i!==1){const d=Number(i.toFixed(4)),I=c==="none"?"none":`${c}%`,y=f==="none"?"none":`${f}%`;return T(`hsl(${a} ${I} ${y} / ${d})`)}const p=c==="none"?"none":`${c}%`,m=f==="none"?"none":`${f}%`;return T(`hsl(${a} ${p} ${m})`)}s(mr,"formatW3CColorToHSL");function hr(e,t){if(typeof e=="string"&&h(e))return{value:e};const n=t.colorFallbackStrategy;if(ie(e))return Ir(e,n);const r=Ke(e,n);return r.success?{value:r.value}:(console.warn(`Failed to convert color ${typeof e=="string"?e:"W3C color object"}: ${r.error}`),{value:typeof e=="string"?e:"#000000"})}s(hr,"convertColorToken");function Ir(e,t){const n=Ke(e,t);if(!n.success)return console.warn(`Failed to convert W3C color: ${n.error}`),{value:"#000000"};const r=n.value;if(t==="native")return{value:r};if(e.colorSpace==="srgb"||e.colorSpace==="hsl")return{value:r};if(!e.hex)throw new Error(`${e.colorSpace} colors require a 'hex' fallback when using 'polyfill' strategy. Tip: Switch to 'native' strategy if targeting modern browsers only.`);return{value:e.hex,featureValues:[{query:yr(e.colorSpace),value:r}]}}s(Ir,"convertW3CColorToken");function yr(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(yr,"getFeatureQuery");function Er(e){return h(e)?{value:e}:{value:`cubic-bezier(${e.join(", ")})`}}s(Er,"convertCubicBezierToken");function gr(e){return h(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(gr,"convertDimensionToken");function $r(e){return h(e)?{value:e}:{value:`${e.value}${e.unit}`}}s($r,"convertDurationToken");function He(e,t=16){return e.unit==="px"?e.value:e.value*t}s(He,"normalizeToPixels");function Nr(e,t){const{min:n,max:r}=e,o=t.fluidConfig,i=16,a=He(n,i),c=He(r,i),f=o.min,p=o.max;if(a===c)return{value:`${a/i}rem`};const m=a/i,d=c/i,I=f/i,y=p/i,g=(d-m)/(y-I),me=-1*I*g+m;return{value:`clamp(${m}rem, ${me.toFixed(2)}rem + ${(g*100).toFixed(2)}vw, ${d}rem)`}}s(Nr,"convertFluidDimension");function Sr(e,t){return h(e)?{value:e}:Nr(e,t)}s(Sr,"convertFluidDimensionToken");function q(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(q,"quoteFont");function Tr(e){return h(e)?{value:e}:{value:Array.isArray(e)?e.map(n=>q(n)).join(", "):q(e)}}s(Tr,"convertFontFamilyToken");const Ar={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 qe(e){return h(e)?{value:e}:typeof e=="number"?{value:e}:{value:Ar[e.toLowerCase()]??e}}s(qe,"convertFontWeightToken");function br(e){return h(e)?{value:e}:{value:`linear-gradient(${e.map(n=>{const r=(h(n.color),n.color),o=h(n.position)?n.position:`${n.position*100}`;return`${r} ${o}%`}).join(", ")})`}}s(br,"convertGradientToken");function Or(e){return h(e)?{value:e}:{value:e}}s(Or,"convertNumberToken");function ze(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}`,o=h(e.spread)?e.spread:`${e.spread.value}${e.spread.unit}`,i=(h(e.color),e.color);return`${e.inset?"inset ":""}${t} ${n} ${r} ${o} ${i}`}s(ze,"convertSingleShadow");function Lr(e){return h(e)?{value:e}:Array.isArray(e)?{value:e.map(ze).join(", ")}:{value:ze(e)}}s(Lr,"convertShadowToken");function Je(e){return e?`${e.value}${e.unit}`:"0ms"}s(Je,"formatDuration");function _r(e){if(h(e))return{value:e};const t=h(e.duration)?e.duration:Je(e.duration),n=h(e.timingFunction)?e.timingFunction:`cubic-bezier(${e.timingFunction.join(", ")})`,r=e.delay&&(h(e.delay)?e.delay:Je(e.delay));return{value:[t,n,r].filter(Boolean).join(" ")}}s(_r,"convertTransitionToken");function Rr(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=>q(n)).join(", "):q(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:qe(e.fontWeight).value),e.letterSpacing&&(t["letter-spacing"]=h(e.letterSpacing)?e.letterSpacing:`${e.letterSpacing.value}${e.letterSpacing.unit}`),e.lineHeight&&(t["line-height"]=(h(e.lineHeight),e.lineHeight)),t}s(Rr,"convertTypographyToken");const Xe={duration:$r,number:Or,cubicBezier:Er,color:hr,dimension:gr,fluidDimension:Sr,typography:Rr,border:fr,shadow:Lr,gradient:br,transition:_r,strokeStyle:Ye,fontFamily:Tr,fontWeight:qe};function Dr(e,t){const n=Xe[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(Dr,"convertSingleToken");function xr(e,t,n){const r={};for(const[o,i]of Object.entries(e)){if(!i||typeof i!="object")continue;if(!("$type"in i)){r[o]={...i.$description?{$description:i.$description}:{},...i.$extensions?{$extensions:i.$extensions}:{}};continue}if(n?.(i.$path)){console.warn(`[sugarcube] Skipping invalid token: ${i.$path} (has validation error)`);continue}if(!Xe[i.$type])continue;const a={fluidConfig:t.transforms.fluid,colorFallbackStrategy:t.transforms.colorFallbackStrategy,path:i.$path,resolvedTokens:e};r[o]=Dr(i,a)}return r}s(xr,"convertTokens");function vr(e,t,n){const r={};for(const[o,i]of Object.entries(e))r[o]=xr(i,t,n);return r}s(vr,"convert");function Fr(e,t){const n={},r=new Set;for(const o of e){const i=o.context??"default";r.add(i)}for(const o of r)n[o]={};for(const o of e){const{context:i,tokens:a}=o,c=i??"default";n[c]||(n[c]={});for(const[f,p]of Object.entries(a))n[c][f]=p}return{tokens:n,defaultContext:t}}s(Fr,"normalizeTokens");function Cr(e,t){const n=new Map;for(const[r,o]of Object.entries(t)){if(!("$source"in o)){for(const c of e){const f=c.context??"";n.has(f)||n.set(f,{});const p=n.get(f);p&&(p[r]=o)}continue}const i=o.$source.context??"";n.has(i)||n.set(i,{});const a=n.get(i);a&&(a[r]=o)}return e.map(r=>{const o=r.context??"",i=n.get(o)||{};return{context:r.context,tokens:i}})}s(Cr,"processTrees");async function Vr(e,t,n,r){const o=Cr(e,t),{tokens:i}=Fr(o);return vr(i,n,r?f=>r.some(p=>p.path===f||p.path.startsWith(`${f}.`)):void 0)}s(Vr,"processAndConvertTokens");const z=["reset","global","compositions","blocks","utilities"];async function ce(e,t){const n=[],r=await mt([A(e,"**/*.css"),A(e,"**/*.scss"),A(e,"**/*.sass"),A(e,"**/*.less")],{ignore:[A(e,k)]});for(const o of r){const i=kr(o,e);if(i){const a=R(e,o);n.push({path:a,layer:i,relativePath:a})}}return n}s(ce,"discoverAllFiles");function kr(e,t){const n=R(t,e);if(n.includes("global/")||n.startsWith("global/"))return dt(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(kr,"categorizeFile");function wr(e){return e.sort((t,n)=>{const r=z.indexOf(t.layer),o=z.indexOf(n.layer);return r!==o?r-o:t.path.localeCompare(n.path)})}s(wr,"sortFilesByLayer");function jr(){return`@layer ${z.join(", ")};
|
|
16
|
+
`}s(jr,"getLayerDefinitions");function Ze(e){const t=[];t.push(jr());const n=e.reduce((r,o)=>{const i=r[o.layer]??[];return r[o.layer]=[...i,o],r},{});for(const r of z){const o=n[r];if(!(!o||o.length===0))for(const i of o)t.push(`@import "${i.path}" layer(${i.layer});`)}return t.join(`
|
|
17
|
+
`)}s(Ze,"generateIndexContent");async function Pr(e,t){const n=A(e,k),r=await ce(e),o=wr(r),i=Ze(o);return await C.writeFile(n,i),R(process.cwd(),n)}s(Pr,"generateIndex");async function Mr(e,t){const n=A(e,k);if(!D(n))return!0;try{const r=await C.stat(n),o=await ce(e,t);for(const i of o){const a=A(e,i.path);if(D(a)&&(await C.stat(a)).mtime>r.mtime)return!0}return!1}catch{return!0}}s(Mr,"shouldRegenerateIndex");const Ur=`/*!
|
|
18
|
+
* This file was automatically generated by sugarcube.
|
|
19
|
+
* You should NOT make any changes in this file as it will be overwritten.
|
|
20
|
+
* To make changes, edit your design token files instead.
|
|
21
|
+
* Additionally, you should exclude this file from your linter and/or formatter
|
|
22
|
+
* to prevent it from being checked or modified.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
`,Wr=`/*!
|
|
26
|
+
* This file was automatically generated by sugarcube.
|
|
27
|
+
* You should NOT make any changes in this file as it will be overwritten.
|
|
28
|
+
* To make changes, edit your utilities configuration instead.
|
|
29
|
+
* Additionally, you should exclude this file from your linter and/or formatter
|
|
30
|
+
* to prevent it from being checked or modified.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
`;function J(e){return e.replace(/\r\n/g,`
|
|
34
|
+
`).replace(/\r/g,`
|
|
35
|
+
`).trim()}s(J,"normalizeContent");function Gr(e){return Ur+e}s(Gr,"addWarningBanner");async function Br(e){for(const t of e){const n=Gr(t.css);try{await Ie(te(t.path),{recursive:!0});let r=!0;if(D(t.path))try{const o=await V(t.path,"utf-8");J(o)===J(n)&&(r=!1)}catch{}r&&await ye(t.path,n,"utf-8")}catch(r){throw new Error(`Failed to write CSS file ${t.path}: ${r instanceof Error?r.message:"Unknown error"}`)}}return e}s(Br,"writeCSSVariablesToDisk");async function Yr(e){for(const t of e){const n=Wr+t.css;try{await Ie(te(t.path),{recursive:!0});let r=!0;if(D(t.path))try{const o=await V(t.path,"utf-8");J(o)===J(n)&&(r=!1)}catch{}r&&await ye(t.path,n,"utf-8")}catch(r){throw new Error(`Failed to write utility CSS file ${t.path}: ${r instanceof Error?r.message:"Unknown error"}`)}}return e}s(Yr,"writeCSSUtilitiesToDisk");const Qe=l.object({min:l.number(),max:l.number()}),et=l.object({source:l.string(),directions:l.union([l.enum(["top","right","bottom","left","x","y","full","all"]),l.array(l.enum(["top","right","bottom","left","x","y","full","all"]))]).optional(),prefix:l.string().optional(),stripDuplicates:l.boolean().optional()}),tt=l.union([et,l.array(et)]),nt=l.object({resolver:l.string().optional(),transforms:l.object({fluid:Qe.optional(),colorFallbackStrategy:l.enum(["native","polyfill"]).optional()}).optional(),output:l.object({css:l.string().optional(),components:l.string().optional(),themeAttribute:l.string().optional(),defaultContext:l.string().optional()}).optional(),utilities:l.record(l.string(),tt).optional()}),rt=l.object({resolver:l.string().optional(),transforms:l.object({fluid:Qe,colorFallbackStrategy:l.enum(["native","polyfill"])}),output:l.object({css:l.string(),components:l.string().optional(),themeAttribute:l.string(),defaultContext:l.string().optional()}),utilities:l.record(l.string(),tt).optional()}),b={output:{css:"src/styles",components:"src/components/ui",themeAttribute:"data-theme"},transforms:{fluid:{min:320,max:1200},colorFallbackStrategy:"native"}},Kr="default",Hr="default";function ue(e){const t={resolver:e.resolver,transforms:{fluid:e.transforms?.fluid??b.transforms.fluid,colorFallbackStrategy:e.transforms?.colorFallbackStrategy??b.transforms.colorFallbackStrategy},output:{css:e.output?.css??b.output.css,themeAttribute:e.output?.themeAttribute??b.output.themeAttribute,defaultContext:e.output?.defaultContext}};return(e.output?.components!==void 0||b.output.components!==void 0)&&(t.output.components=e.output?.components??b.output.components),e.utilities&&(t.utilities=e.utilities),t}s(ue,"fillDefaults");function X(e){const t=nt.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const o=r.path.join(".");return u.CONFIG.INVALID_CONFIG(o||"root",r.message)});throw new Error(n.join(`
|
|
36
|
+
`))}return t.data}s(X,"validateUserConfig");function fe(e){const t=rt.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const o=r.path.join(".");return u.CONFIG.INVALID_CONFIG(o||"root",r.message)});throw new Error(n.join(`
|
|
37
|
+
`))}return t.data}s(fe,"validateInternalConfig");function ot(e){const t=X(e),n=ue(t);return fe(n)}s(ot,"validateConfig");function qr(e){try{const t=JSON.parse(e);return ot(t)}catch(t){throw t instanceof SyntaxError?new Error(u.CONFIG.INVALID_JSON(t.message)):t}}s(qr,"parseAndValidateConfig");function le(e="sugarcube.config"){const t=[".ts",".js"];for(const n of t){const r=L(process.cwd(),`${e}${n}`);if(D(r))return r}return null}s(le,"findConfigFile");function zr(e="sugarcube.config"){return le(e)!==null}s(zr,"configFileExists");async function st(e){try{await import("tsx");const t=ht(e).href,r=await new Function("url","return import(url)")(t);if(r&&typeof r=="object"&&"default"in r)return r.default;throw new Error(u.CONFIG.INVALID_CONFIG("root","Config file must export a default object"))}catch(t){throw t instanceof Error?new Error(u.CONFIG.INVALID_CONFIG("root",t.message)):t}}s(st,"loadTSConfig");async function it(e){if(e.endsWith(".ts")||e.endsWith(".js"))return await st(e);const n=await C.readFile(e,"utf-8");return JSON.parse(n)}s(it,"loadConfigFile");function at(e){if(e)return L(process.cwd(),e);const t=le();if(!t)throw new Error(u.CONFIG.FILE_NOT_FOUND(w));return t}s(at,"resolveConfigPath");async function Jr(e){const t=at(e);try{const n=await it(t);return{config:X(n),configPath:t}}catch(n){throw n instanceof Error&&"code"in n&&n.code==="ENOENT"?new Error(u.CONFIG.FILE_NOT_FOUND(t)):n instanceof SyntaxError?new Error(u.CONFIG.INVALID_JSON(n.message)):n}}s(Jr,"loadUserConfig");async function Xr(e){const t=at(e);try{const n=await it(t),r=X(n),o=ue(r);return{config:fe(o),configPath:t}}catch(n){throw n instanceof Error&&"code"in n&&n.code==="ENOENT"?new Error(u.CONFIG.FILE_NOT_FOUND(t)):n instanceof SyntaxError?new Error(u.CONFIG.INVALID_JSON(n.message)):n}}s(Xr,"loadInternalConfig");class ct 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 Zr=process.env.DEBUG==="true";class Qr{static{s(this,"Instrumentation")}constructor(t=n=>void process.stderr.write(`${n}
|
|
38
|
+
`)){this.defaultFlush=t}#t=new ct(()=>({value:0}));#n=new ct(()=>({value:0n}));#e=[];hit(t){this.#t.get(t).value++}start(t){const n=this.#e.map(o=>o.label).join("//"),r=`${n}${n.length===0?"":"//"}${t}`;this.#t.get(r).value++,this.#n.get(r),this.#e.push({id:r,label:t,namespace:n,value:process.hrtime.bigint()})}end(t){const n=process.hrtime.bigint();if(this.#e.length===0)throw new Error("Timer stack is empty");const r=this.#e.length-1,o=this.#e[r];if(!o)throw new Error("Timer stack is corrupted");if(o.label!==t)throw new Error(`Mismatched timer label: ${t}`);const i=this.#e.pop();if(!i)throw new Error("Timer stack is empty");const a=n-i.value;this.#n.get(i.id).value+=a}report(t=this.defaultFlush){const n=[];let r=!1;for(let o=this.#e.length-1;o>=0;o--){const i=this.#e[o];i&&this.end(i.label)}for(const[o,{value:i}]of this.#t.entries()){if(this.#n.has(o))continue;n.length===0&&(r=!0,n.push("Hits:"));const a=o.split("//").length;n.push(`${" ".repeat(a)}${o} \xD7 ${i}`)}if(this.#n.size>0){r&&n.push(`
|
|
39
|
+
Timers:`);for(const[o,{value:i}]of this.#n){const a=o.split("//").length,c=`${(Number(i)/1e6).toFixed(2)}ms`;n.push(`${" ".repeat(a-1)}${o.split("//").pop()} [${c}] ${this.#t.get(o).value===1?"":`\xD7 ${this.#t.get(o).value}`}`.trimEnd())}}t(`
|
|
40
|
+
${n.join(`
|
|
41
|
+
`)}
|
|
42
|
+
`)}[Symbol.dispose](){Zr&&this.report()}}const v="--",O="-",eo=["all","full"],to={top:"t",right:"r",bottom:"b",left:"l",x:"x",y:"y",full:"",all:""},no={top:"block-start",right:"inline-end",bottom:"block-end",left:"inline-start",x:"inline",y:"block"};function ro(e){return to[e]}s(ro,"getDirectionAbbreviation");function ut(e,t){if(t==="full"||t==="all")return e;const n=no[t];return n?`${e}${O}${n}`:e}s(ut,"getLogicalProperty");const oo=["top","right","bottom","left","x","y","full"];function so(e){return(Array.isArray(e)?e:[e]).flatMap(n=>n==="all"?oo:[n])}s(so,"expandDirections");function io(e,t){const r={color:["color"],"background-color":["color"],"border-color":["color"],"font-size":["dimension","fluidDimension"],"font-weight":["fontWeight"],"line-height":["number"],"border-radius":["dimension","fluidDimension"],"border-width":["dimension","fluidDimension"],padding:["dimension","fluidDimension"],margin:["dimension","fluidDimension"],width:["dimension","fluidDimension"],height:["dimension","fluidDimension"],gap:["dimension","fluidDimension"],"font-family":["fontFamily"],"transition-duration":["duration"],"transition-timing-function":["cubicBezier"],"border-style":["strokeStyle"],"box-shadow":["shadow"],"text-shadow":["shadow"],"background-image":["gradient"],opacity:["number"]}[t];return r?r.includes(e):!0}s(io,"isTokenTypeValidForProperty");const ft=new WeakMap;function ao(e){const t=ft.get(e);if(t)return t;const n=new Map;for(const r of Object.values(e)){if(!("$path"in r))continue;const o=r;n.set(o.$path,o)}return ft.set(e,n),n}s(ao,"buildPathIndex");function co(e){if(e.default)return e.default;const t=Object.keys(e);return t.length>0&&t[0]?e[t[0]]:null}s(co,"getDefaultContextTokens");function Z(e,t,n){const r=[t.source.replace("*",e),t.source.replace("*",e.split("-").join("."))];if(t.stripDuplicates&&t.prefix){const a=t.source.lastIndexOf(".*");if(a!==-1){const c=t.source.slice(0,a);c&&r.push(`${c}.${t.prefix}.${e}`,`${c}.${t.prefix}.${e.split("-").join(".")}`)}}const o=co(n);if(!o)return null;const i=ao(o);for(const a of r){const c=i.get(a);if(c){if(t.property&&c.$type&&!io(c.$type,t.property))continue;return c.$path.split(".")}}return null}s(Z,"findMatchingToken");function pe(e,t){return t.stripDuplicates&&t.prefix&&e.startsWith(`${t.prefix}-`)?e.slice(t.prefix.length+1):e}s(pe,"stripDuplicatePrefix");function Q(e,t=""){const n=e??"",r=n||t?O:"";return new RegExp(`^${n}${t}${r}(.+)$`)}s(Q,"createUtilityPattern");function de(e,t,n){return[Q(t.prefix),o=>{const i=o[1];if(!i)return{};const a=pe(i,t),c={...t,property:e},f=Z(a,c,n);return f?{[e]:`var(${v}${f.join(O)})`}:{}}]}s(de,"createSimpleRule");function uo(e,t,n,r){if(n==="all")return de(e,t,r);const o=ro(n);return[Q(t.prefix,o),a=>{const c=a[1];if(!c)return{};const f=pe(c,t),p={...t,property:e},m=Z(f,p,r);return m?{[ut(e,n)]:`var(${v}${m.join(O)})`}:{}}]}s(uo,"createDirectionalRule");function fo(e,t){return[Q(e),r=>{const o=r[1];if(!o)return{};for(const{property:i,config:a,direction:c,tokens:f}of t){const p=pe(o,a),m={...a,property:i},d=Z(p,m,f);if(d)return c?{[ut(i,c)]:`var(${v}${d.join(O)})`}:{[i]:`var(${v}${d.join(O)})`}}return{}}]}s(fo,"createSmartRule");function lo(e,t,n){const r=t.source.indexOf("."),o=r!==-1?t.source.slice(0,r):t.source;return[Q(o),a=>{const c=a[1];if(!c)return{};const f={...t,property:e},p=Z(c,f,n);return p?{[e]:`var(${v}${p.join(O)})`}:{}}]}s(lo,"createDirectTokenPathRule");function po(e,t){if(!e?.source||typeof e.source!="string")throw new Error(u.UTILITIES.MISSING_SOURCE(t));if(e.source.includes("*")&&!e.source.endsWith(".*"))throw new Error(u.UTILITIES.INVALID_SOURCE_PATTERN(t,e.source));if(e.directions&&!Array.isArray(e.directions))throw new Error(u.UTILITIES.INVALID_DIRECTIONS(t))}s(po,"validateUtilityConfig");function mo(e,t){if(!e||typeof e!="object")throw new Error(u.UTILITIES.INVALID_CONFIG_OBJECT);if(!t||typeof t!="object")throw new Error(u.UTILITIES.INVALID_TOKENS_OBJECT)}s(mo,"validateInputs");function ho(e,t){mo(e,t);const n=[],r={};for(const[o,i]of Object.entries(e)){const a=Array.isArray(i)?i:[i];for(const c of a)if(po(c,o),c.prefix){const f=c.prefix;r[f]||(r[f]=[]),r[f].push({property:o,config:c,direction:null,tokens:t})}else{const f=lo(o,c,t);n.push(f)}}for(const[o,i]of Object.entries(r))if(i.length===1){const a=i[0];if(!a)continue;const{property:c,config:f,tokens:p}=a;if(f.directions){const m=so(f.directions);(Array.isArray(f.directions)?f.directions:[f.directions]).includes("all")&&n.push(de(c,f,p));for(const y of m)eo.includes(y)||n.push(uo(c,f,y,p))}else n.push(de(c,f,p))}else n.push(fo(o,i));return n}s(ho,"convertConfigToUnoRules");export{Kr as DEFAULT_COLLECTION,b as DEFAULT_CONFIG,Hr as DEFAULT_CONTEXT,gt as DEFAULT_DESIGN_TOKENS_PATH,Et as DEFAULT_STYLES_PATH,yt as DEFAULT_UTILITIES_FILENAME,$e as DEFAULT_VARIABLES_FILENAME,u as ErrorMessages,Ee as GLOBAL_DIR,Qr as Instrumentation,w as SUGARCUBE_CONFIG_FILE,k as SUGARCUBE_FILE,It as UTILITIES_DIR,ge as VARIABLES_FILE_SUFFIX,zr as configFileExists,ho as convertConfigToUnoRules,ce as discoverAllFiles,ue as fillDefaults,le as findConfigFile,Ct as generateCSSVariables,Pr as generateIndex,Ze as generateIndexContent,rt as internalConfigSchema,Ne as isResolvedToken,St as isResolvedTokenOfType,cr as loadAndResolveTokens,je as loadFromResolver,Xr as loadInternalConfig,st as loadTSConfig,Jr as loadUserConfig,qr as parseAndValidateConfig,Vr as processAndConvertTokens,Mr as shouldRegenerateIndex,nt as userConfigSchema,ot as validateConfig,fe as validateInternalConfig,X as validateUserConfig,Yr as writeCSSUtilitiesToDisk,Br as writeCSSVariablesToDisk};
|
package/package.json
CHANGED
|
@@ -1,23 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sugarcube-org/core",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.10",
|
|
4
4
|
"publishConfig": {
|
|
5
|
-
"access": "
|
|
5
|
+
"access": "public",
|
|
6
|
+
"provenance": false
|
|
6
7
|
},
|
|
8
|
+
"description": "Core functionality for sugarcube",
|
|
9
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
7
10
|
"main": "./dist/index.js",
|
|
8
11
|
"types": "./dist/index.d.ts",
|
|
9
12
|
"type": "module",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18.0.0"
|
|
18
|
+
},
|
|
10
19
|
"files": [
|
|
11
20
|
"dist",
|
|
12
|
-
"README.md"
|
|
21
|
+
"README.md",
|
|
22
|
+
"LICENSE.md"
|
|
13
23
|
],
|
|
14
24
|
"devDependencies": {
|
|
15
|
-
"pkgroll": "
|
|
25
|
+
"pkgroll": "2.5.1"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"fast-glob": "3.3.2",
|
|
29
|
+
"pathe": "2.0.3",
|
|
30
|
+
"tsx": "4.19.2",
|
|
31
|
+
"zod": "3.21.4"
|
|
16
32
|
},
|
|
17
33
|
"scripts": {
|
|
18
34
|
"build": "pkgroll --minify",
|
|
35
|
+
"build:clean": "rm -rf dist && pkgroll --minify",
|
|
19
36
|
"dev": "pkgroll --watch",
|
|
20
|
-
"test": "vitest",
|
|
37
|
+
"test": "vitest run",
|
|
38
|
+
"test:watch": "vitest",
|
|
39
|
+
"test:coverage": "vitest run --coverage",
|
|
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",
|
|
21
43
|
"type-check": "tsc --noEmit"
|
|
22
44
|
}
|
|
23
45
|
}
|