@sugarcube-org/core 0.0.1-alpha.0 → 0.0.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +2 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- var B=Object.defineProperty;var i=(e,n)=>B(e,"name",{value:n,configurable:!0});const u={PARSE:{INVALID_INPUT_TYPE:i(e=>`Invalid input: expected string, got ${e}`,"INVALID_INPUT_TYPE"),JSON_PARSE_ERROR:i(e=>`JSON parsing error: ${e}`,"JSON_PARSE_ERROR")},FLATTEN:{INVALID_TOKEN_NAME:i(e=>`Invalid token name '${e}': cannot contain '.', '{', or '}'`,"INVALID_TOKEN_NAME"),INVALID_NODE_STRUCTURE:i(e=>`Invalid node structure at '${e}': expected object`,"INVALID_NODE_STRUCTURE"),MISSING_INHERITED_TYPE:i(e=>`Token at '${e}' has no type (neither explicit nor inherited)`,"MISSING_INHERITED_TYPE"),UNEXPECTED_ERROR:i(e=>`Unexpected error during flattening: ${e}`,"UNEXPECTED_ERROR")},METADATA:{COLLECTION_ERROR:i(e=>`Error collecting metadata: ${e}`,"COLLECTION_ERROR"),INVALID_EXTENSIONS:i(e=>`Invalid extensions at '${e}': expected object, got ${typeof e}`,"INVALID_EXTENSIONS"),INVALID_DESCRIPTION:i(e=>`Invalid description at '${e}': expected string, got ${typeof e}`,"INVALID_DESCRIPTION")},VALIDATE:{INVALID_TOKEN_STRUCTURE:i(e=>`Invalid token at '${e}'. Each token should have "$type" and "$value" properties`,"INVALID_TOKEN_STRUCTURE"),MISSING_TYPE:i(e=>`Token at '${e}' is missing the "$type" property`,"MISSING_TYPE"),MISSING_VALUE:i(e=>`Token at '${e}' is missing the "$value" property`,"MISSING_VALUE"),UNKNOWN_TOKEN_TYPE:i((e,n)=>`Unknown token type '${e}' at '${n}'. Valid types are: color, dimension, fontFamily, fontWeight, duration, cubicBezier, strokeStyle, border, transition, shadow, gradient, typography`,"UNKNOWN_TOKEN_TYPE"),INVALID_COLOR:i((e,n)=>`Invalid color at '${n}': ${e}. Color should be a valid hex value"`,"INVALID_COLOR"),INVALID_DIMENSION:i((e,n)=>`Invalid dimension at '${n}': ${e}. Dimensions should have a numeric value and unit, like { "value": 16, "unit": "px" }`,"INVALID_DIMENSION"),INVALID_DIMENSION_UNIT:i((e,n)=>`Invalid unit at '${n}': ${e}. Unit must be either "px" or "rem"`,"INVALID_DIMENSION_UNIT"),INVALID_FONT_FAMILY:i((e,n)=>`Invalid font family at '${n}': ${e}. Should be a string or array of strings, like "Arial" or ["Arial", "sans-serif"]`,"INVALID_FONT_FAMILY"),INVALID_FONT_WEIGHT:i((e,n)=>`Invalid font weight at '${n}': ${e}. Should be a number between 1-1000 or a keyword like "thin", "light", "normal", "bold"`,"INVALID_FONT_WEIGHT"),INVALID_DURATION:i((e,n)=>`Invalid duration at '${n}': ${e}. Should be like { "value": 300, "unit": "ms" }`,"INVALID_DURATION"),INVALID_DURATION_UNIT:i((e,n)=>`Invalid unit at '${n}': ${e}. Unit must be "ms" or "s"`,"INVALID_DURATION_UNIT"),INVALID_CUBIC_BEZIER:i((e,n)=>`Invalid cubic bezier at '${n}': ${e}. Should be an array of 4 numbers between 0 and 1`,"INVALID_CUBIC_BEZIER"),INVALID_CUBIC_BEZIER_RANGE:i((e,n)=>`Invalid cubic bezier control points at '${n}': ${e}. X values must be between 0 and 1`,"INVALID_CUBIC_BEZIER_RANGE"),INVALID_STROKE_STYLE:i((e,n)=>`Invalid stroke style at '${n}': ${e}. Should be "solid", "dashed", "dotted", etc.`,"INVALID_STROKE_STYLE"),INVALID_DASH_ARRAY_ITEM:i((e,n)=>`Invalid dash array item at '${n}': ${e}. Should be a string or dimension object like { "value": 4, "unit": "px" }`,"INVALID_DASH_ARRAY_ITEM"),INVALID_STROKE_LINE_CAP:i((e,n)=>`Invalid line cap at '${n}': ${e}. Should be one of: round, butt, square`,"INVALID_STROKE_LINE_CAP"),INVALID_BORDER:i((e,n)=>`Invalid border at '${n}': ${e}. Should have color, width, and style properties`,"INVALID_BORDER"),INVALID_SHADOW:i((e,n)=>`Invalid shadow at '${n}': ${e}. Should have color, offsetX, offsetY properties (blur and spread are optional)`,"INVALID_SHADOW"),INVALID_SHADOW_INSET:i((e,n)=>`Invalid inset value at '${n}': ${e}. Should be true or false`,"INVALID_SHADOW_INSET"),INVALID_TRANSITION:i((e,n)=>`Invalid transition at '${n}': ${e}. Should have duration, delay, and timingFunction properties`,"INVALID_TRANSITION"),INVALID_GRADIENT:i((e,n)=>`Invalid gradient at '${n}': ${e}. Should be an array of color stops with position values between 0 and 1`,"INVALID_GRADIENT"),INVALID_GRADIENT_STOP_POSITION:i((e,n)=>`Invalid gradient stop position at '${n}': ${e}. Position must be between 0 and 1`,"INVALID_GRADIENT_STOP_POSITION"),INVALID_TYPOGRAPHY:i((e,n)=>`Invalid typography at '${n}': ${e}. Should have fontFamily and fontSize (fontWeight, letterSpacing, and lineHeight are optional)`,"INVALID_TYPOGRAPHY"),MISSING_REQUIRED_PROPERTY:i((e,n)=>`Missing required property '${e}' at '${n}'`,"MISSING_REQUIRED_PROPERTY"),MISSING_REQUIRED_PROPERTIES:i((e,n)=>`Missing required properties at '${n}': ${e.join(", ")}`,"MISSING_REQUIRED_PROPERTIES"),INVALID_NUMBER:i((e,n)=>`Invalid number at '${n}': ${e}. Expected a number value`,"INVALID_NUMBER"),INVALID_ARRAY:i((e,n)=>`Invalid array at '${n}': ${e}. Expected an array value`,"INVALID_ARRAY"),MISSING_FLUID_CONFIG:i(e=>`Missing fluid configuration at root level. Token at '${e}' requires fluid viewport settings`,"MISSING_FLUID_CONFIG"),INVALID_FLUID_DIMENSION:i((e,n)=>`Invalid fluid dimension at '${n}': ${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:i((e,n)=>`Invalid viewport configuration at '${n}': ${e}. Viewport config should have min and max dimension values`,"INVALID_VIEWPORT_CONFIG"),MISMATCHED_UNITS:i((e,n,t)=>`Mismatched units at '${t}': min uses '${e}', max uses '${n}'. Both values must use the same unit`,"MISMATCHED_UNITS"),INVALID_FLUID_VALUE_RANGE:i(e=>`Invalid fluid value range at '${e}': min value must be less than max value`,"INVALID_FLUID_VALUE_RANGE"),INVALID_VALUE_TYPE:i((e,n,t)=>`Invalid value type at '${t}': expected ${e}, got ${n}`,"INVALID_VALUE_TYPE")},CONVERT:{UNSUPPORTED_TOKEN_TYPE:i(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:i(e=>`Missing fluid configuration for token at path: ${e}`,"MISSING_FLUID_CONFIG")},RESOLVE:{CIRCULAR_REFERENCE:i((e,n)=>`Circular reference detected: ${e} -> ${n}`,"CIRCULAR_REFERENCE"),REFERENCE_NOT_FOUND:i((e,n)=>`Reference not found: ${n} in ${e}`,"REFERENCE_NOT_FOUND"),TYPE_MISMATCH:i(e=>`Type mismatch in reference resolution at ${e}`,"TYPE_MISMATCH")},GENERATE:{INVALID_CSS_VALUE:i((e,n)=>`Invalid CSS value for property '${e}': ${n}`,"INVALID_CSS_VALUE")}};function K(e){return R(e)}i(K,"flatten");function R(e,n="",t){const r={},o=[];for(const[s,a]of Object.entries(e)){if(s.startsWith("$"))continue;const f=n?`${n}.${s}`:s;if(s.includes(".")||s.includes("{")||s.includes("}")){o.push({path:s,message:u.FLATTEN.INVALID_TOKEN_NAME(s)});continue}if(typeof a!="object"||a===null){o.push({path:f,message:u.FLATTEN.INVALID_NODE_STRUCTURE(f)});continue}const l="$type"in a?a.$type:t;if("$value"in a){if(!l){o.push({path:f,message:u.FLATTEN.MISSING_INHERITED_TYPE(f)});continue}r[f]={$type:l,$value:a.$value,$path:f}}else{const I=R(a,f,l);Object.assign(r,I.tokens),o.push(...I.errors)}}return{tokens:r,errors:o}}i(R,"processTokens");const Q=new Set(["$description","$extensions"]);function c(e){return typeof e=="string"&&e.startsWith("{")&&e.endsWith("}")}i(c,"isReference");function q(e){return typeof e=="object"&&e!==null&&typeof e.query=="string"&&typeof e.value=="string"}i(q,"isFeatureValue");function X(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(q):!1:!0}i(X,"isSimpleCSSProperties");function Z(e){return!!(typeof e=="string"||typeof e=="number"||X(e))}i(Z,"isValidCSSValue");function $(e,n,t,r){return typeof n=="string"&&c(n)?ee(e,n,t,r):Array.isArray(n)?n.map(o=>$(e,o,t,r)):typeof n=="object"&&n!==null?Object.entries(n).reduce((s,[a,f])=>({...s,[a]:$(`${e}.${a}`,f,t,r)}),{}):n}i($,"resolveValue");function J(e){const n={},t=new Set,r=[];for(const[o,s]of Object.entries(e))try{if(!s.$path)continue;n[s.$path]={...s,$resolvedValue:$(s.$path,s.$value,e,t)}}catch(a){const f=a instanceof Error?a.message:String(a);let l,I;f.includes("Circular reference detected")?(l="circular",I=f):f.includes("Reference not found")?(l="missing",I=f):(l="type-mismatch",I=u.RESOLVE.TYPE_MISMATCH(s.$path)),r.push({type:l,path:s.$path,message:I})}return{resolved:n,errors:r}}i(J,"resolve");function ee(e,n,t,r){const o=n.slice(1,-1);if(r.has(o))throw new Error(`Circular reference detected: ${e} -> ${o}`);const s=t[o];if(!s)throw new Error(`Reference not found: ${o} in ${e}`);r.add(o);const a=$(o,s.$value,t,r);return r.delete(o),a}i(ee,"resolveReferenceChain");function p(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}i(p,"quoteFont");const ne={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 b(e){return c(e)?{value:e}:typeof e=="number"?{value:e}:{value:ne[e.toLowerCase()]??e}}i(b,"convertFontWeightToken");function te(e){if(c(e))return{"font-family":e,"font-size":e};const n={"font-family":c(e.fontFamily)?e.fontFamily:Array.isArray(e.fontFamily)?e.fontFamily.map(t=>p(t)).join(", "):p(e.fontFamily),"font-size":c(e.fontSize)?e.fontSize:`${e.fontSize.value}${e.fontSize.unit}`};return e.fontWeight&&(n["font-weight"]=c(e.fontWeight)?e.fontWeight:b(e.fontWeight).value),e.letterSpacing&&(n["letter-spacing"]=c(e.letterSpacing)?e.letterSpacing:`${e.letterSpacing.value}${e.letterSpacing.unit}`),e.lineHeight&&(n["line-height"]=(c(e.lineHeight),e.lineHeight)),n}i(te,"convertTypographyToken");function re(e){if(c(e))return{value:e};const n=(c(e.duration),e.duration),t=c(e.timingFunction)?e.timingFunction:`cubic-bezier(${e.timingFunction.join(", ")})`,r=e.delay&&(c(e.delay),e.delay),o={duration:n,"timing-function":t,...r&&{delay:r}};return{value:[n,t,r].filter(Boolean).join(" "),split:o}}i(re,"convertTransitionToken");function ie(e){return c(e)?{value:e}:{value:`cubic-bezier(${e.join(", ")})`}}i(ie,"convertCubicBezierToken");function oe(e){return c(e)?{value:e}:{value:e}}i(oe,"convertNumberToken");function se(e){return c(e)?{value:e}:{value:e.toString()}}i(se,"convertDurationToken");function h(e){return c(e)?{value:e}:typeof e=="string"?{value:e}:{value:`${e.dashArray.map(t=>c(t)?t:`${t.value}${t.unit}`).join(" ")} ${e.lineCap}`}}i(h,"convertStrokeStyleToken");function ue(e){if(c(e))return{value:e};const n=c(e.width)?e.width:`${e.width.value}${e.width.unit}`,t=(c(e.color),e.color);let r;return typeof e.style=="string"?r=e.style:r=h(e.style).value,{value:`${n} ${r} ${t}`,split:{width:n,style:r,color:t}}}i(ue,"convertBorderToken");function O(e){const n=c(e.offsetX)?e.offsetX:`${e.offsetX.value}${e.offsetX.unit}`,t=c(e.offsetY)?e.offsetY:`${e.offsetY.value}${e.offsetY.unit}`,r=c(e.blur)?e.blur:`${e.blur.value}${e.blur.unit}`,o=c(e.spread)?e.spread:`${e.spread.value}${e.spread.unit}`,s=(c(e.color),e.color),a={color:s,"offset-x":n,"offset-y":t,blur:r,spread:o,...e.inset&&{inset:"inset"}};return{value:`${e.inset?"inset ":""}${n} ${t} ${r} ${o} ${s}`,split:a}}i(O,"convertSingleShadow");function ce(e){if(c(e))return{value:e};if(!Array.isArray(e)){const t=O(e);return{value:t.value,split:[t.split]}}const n=e.map(O);return{value:n.map(t=>t.value).join(", "),split:n.map(t=>t.split)}}i(ce,"convertShadowToken");function ae(e){if(c(e))return{value:e};const n=e.map(t=>({color:(c(t.color),t.color),position:`${t.position}%`}));return{value:`linear-gradient(${n.map(t=>`${t.color} ${t.position}`).join(", ")})`,split:{stops:n}}}i(ae,"convertGradientToken");function fe(e){return c(e)?{value:e}:{value:Array.isArray(e)?e.map(t=>p(t)).join(", "):p(e)}}i(fe,"convertFontFamilyToken");function le(e){return c(e)?{value:e}:{value:`${e.value}${e.unit}`}}i(le,"convertDimensionToken");function Ie(e,n,t){if(e in t.tokens&&t.tokens[e]?.[n]!==void 0)return t.tokens[e][n];const r=e.split(".");for(;r.length>0;){const o=r.join(".");if(o in t.groups&&t.groups[o]&&n in t.groups[o])return t.groups[o][n];r.pop()}return t.root[n]}i(Ie,"getMetadataValue");function P(e,n){return Ie(e,"$extensions",n)?.["com.sugarcube"]}i(P,"getExtensions");function C(e,n){return P(e,n)?.fluid}i(C,"getFluidConfig");function de(e,n){return P(e,n)?.color?.format}i(de,"getColorFormat");function E(e,n=16){switch(e.unit){case"px":return e.value;case"rem":return e.value*n;default:throw new Error(`Unsupported unit: ${e.unit}. Fluid dimensions must use 'px' or 'rem'`)}}i(E,"normalizeToPixels");function Ae(e,n){if(!n?.viewports)throw new Error("Fluid metadata is required for fluid dimensions");const{min:t,max:r}=e,{viewports:o}=n,s=16,a=E(t,s),f=E(r,s),l=E(o.min,s),I=E(o.max,s);if(a===f)return{value:`${a/s}rem`};const g=a/s,_=f/s,V=l/s,W=I/s,L=(_-g)/(W-V),H=-1*V*L+g;return{value:`clamp(${g}rem, ${H.toFixed(2)}rem + ${(L*100).toFixed(2)}vw, ${_}rem)`}}i(Ae,"convertFluidDimension");function $e(e,n){if(c(e))return{value:e};const t=C(n.path,n.metadataMap);if(!t)throw new Error(u.CONVERT.MISSING_FLUID_CONFIG(n.path));return Ae(e,t)}i($e,"convertFluidDimensionToken");function pe(e,n,t){const r=Math.max(e,n,t),o=Math.min(e,n,t);let s=0,a=0;const f=(r+o)/2;if(r!==o){const l=r-o;switch(a=f>.5?l/(2-r-o):l/(r+o),r){case e:s=(n-t)/l+(n<t?6:0);break;case n:s=(t-e)/l+2;break;case t:s=(e-n)/l+4;break}s*=60}return[Math.round(s),Math.round(a*100),Math.round(f*100)]}i(pe,"rgbToHsl");const m=i(e=>Number.isInteger(e)?e.toString():Number(e.toFixed(3)).toString(),"formatNumber"),Ee={hex:{type:"standard",convert:i((e,n,t,r)=>{const o=i(s=>Math.round(s*255).toString(16).padStart(2,"0"),"toHex");return`#${o(e)}${o(n)}${o(t)}${r<1?o(r):""}`},"convert")},rgb:{type:"standard",convert:i((e,n,t,r)=>{const o=[e,n,t].map(s=>Math.round(s*255));return r===1?`rgb(${o.join(", ")})`:`rgba(${o.join(", ")}, ${m(r)})`},"convert")},hsl:{type:"standard",convert:i((e,n,t,r)=>{const[o,s,a]=pe(e,n,t);return r===1?`hsl(${o}, ${s}%, ${a}%)`:`hsla(${o}, ${s}%, ${a}%, ${m(r)})`},"convert")},p3:{type:"conditional",featureQuery:"@supports (color: color(display-p3 1 1 1))",convert:i((e,n,t,r)=>{const o=[e,n,t].map(m).join(" ");return r===1?`color(display-p3 ${o})`:`color(display-p3 ${o} / ${m(r)})`},"convert")}};function me(e,n){if(c(e))return{value:e};const t=de(n.path,n.metadataMap)||"hex";if(t==="hex")return{value:e};const r=Ee[t];if(!r)return{value:e};const o=e.substring(1),s=parseInt(o.substring(0,2),16)/255,a=parseInt(o.substring(2,4),16)/255,f=parseInt(o.substring(4,6),16)/255,l=o.length===8?parseInt(o.substring(6,8),16)/255:1;return r.type==="conditional"?{value:e,featureValues:[{query:r.featureQuery,value:r.convert(s,a,f,l)}]}:{value:r.convert(s,a,f,l)}}i(me,"convertColorToken");const ye={duration:se,number:oe,cubicBezier:ie,color:me,dimension:le,fluidDimension:$e,typography:te,border:ue,shadow:ce,gradient:ae,transition:re,strokeStyle:h,fontFamily:fe,fontWeight:b},F=new Map;function M(e){const n=F.get(e);if(n)return n;const t=e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z])(?=[a-z])/g,"$1-$2").toLowerCase();return F.set(e,t),t}i(M,"toKebabCase");function ge(e,n){const t=ye[e.$type];if(!t)throw new Error(u.CONVERT.UNSUPPORTED_TOKEN_TYPE(e.$type));return{$type:e.$type,$value:e.$value,$path:e.$path,$resolvedValue:e.$resolvedValue,cssProperties:t(e.$value,n)}}i(ge,"convertSingleToken");function Se(e,n){const t={};for(const[r,o]of Object.entries(e)){if(Q.has(r)||o===void 0)continue;const s={metadataMap:n,path:r};if(!("$type"in o))throw new Error(`Token at path ${r} is missing $type property`);if(o.$type==="fluidDimension"&&!n)throw new Error(u.CONVERT.MISSING_FLUID_CONFIG(r));const a=r.split(".").map(M).join("-");t[a]=ge(o,s)}return t}i(Se,"convert");const S="(color: color(display-p3 1 1 1))",Te=[{query:S,test:i(e=>e.$type!=="color"?!1:e.cssProperties.featureValues?.some(t=>t.query===S)??!1,"test"),convertToCSSVars:i((e,n)=>{const r=n.cssProperties.featureValues?.find(o=>o.query===S);return r?[{name:`--${Ne(e)}`,value:r.value}]:[]},"convertToCSSVars")}];function Ne(e){return e.split(".").join("-")}i(Ne,"formatCSSVarPath");function U(e){return typeof e=="number"?e.toString():e.replace(/\{([^}]+)\}/g,(n,t)=>`var(--${t.split(".").map(M).join("-")})`)}i(U,"convertReferenceToCSSVar");function A(e,n){if(!Z(n))throw new Error(u.GENERATE.INVALID_CSS_VALUE(e,String(n)));const t=typeof n=="object"&&"value"in n?U(n.value):U(n);return{name:`--${e}`,value:t}}i(A,"createSingleCSSVar");function De(e,n){if(!("split"in n)||!n.split)return{base:"value"in n?[A(e,n.value)]:Object.entries(n).map(([t,r])=>A(`${e}-${t}`,r))};if(Array.isArray(n.split)){const t=n.split.length>1;return{base:n.split.flatMap((r,o)=>Object.entries(r).map(([s,a])=>{const f=t?`-${o+1}-${s}`:`-${s}`;return A(`${e}${f}`,a)}))}}return{base:Object.entries(n.split).map(([t,r])=>A(`${e}-${t}`,r))}}i(De,"convertSplitTokenToCSSVars");function _e(e){return{name:`--${e}`,value:[`var(--${e}-width)`,`var(--${e}-style)`,`var(--${e}-color)`].join(" ")}}i(_e,"createBorderCSSVar");function x(e,n,t){return[`var(--${e}${n?`-${t+1}`:""}-offset-x)`,`var(--${e}${n?`-${t+1}`:""}-offset-y)`,`var(--${e}${n?`-${t+1}`:""}-blur)`,`var(--${e}${n?`-${t+1}`:""}-spread)`,`var(--${e}${n?`-${t+1}`:""}-color)`].join(" ")}i(x,"createShadowCSSVar");function Ve(e,n,t){if("split"in t){if(e!=="shadow")return e==="border"?_e(n):void 0;if(Array.isArray(t.split)){const r=t.split.length>1,o=t.split.map((s,a)=>x(n,r,a)).join(", ");return{name:`--${n}`,value:o}}return{name:`--${n}`,value:x(n,!1,0)}}}i(Ve,"createCombinedCSSVar");function Le(e,n,t){if(!(n.$type==="typography"||t.includes(n.$type)))return[A(e,n.cssProperties)];const{base:o}=De(e,n.cssProperties),s=Ve(n.$type,e,n.cssProperties);return s?[...o,s]:o}i(Le,"convertTokenToCSSVarSet");function Re(e){const n=`${e.root.selector}{${e.root.vars.map(r=>`${r.name}:${r.value}`).join(";")}}`,t=e.features.map(r=>`@supports ${r.query}{${e.root.selector}{${r.vars.map(o=>`${o.name}:${o.value}`).join(";")}}}`).join("");return n+t}i(Re,"convertCSSVarsToString");async function be(e,n={}){const t=Object.entries(e).filter(([s])=>s!=="$extensions").flatMap(([s,a])=>Le(s,a,n.splitTypes||[])),r=Te.map(s=>{const f=Object.entries(e).filter(([l,I])=>s.test(I)).flatMap(([l,I])=>s.convertToCSSVars(l,I));return f.length>0?{query:s.query,vars:f}:null}).filter(s=>s!==null),o=Re({root:{selector:":root",vars:t},features:r});return he(o)}i(be,"generateCSS");function he(e){return e=e.replace(/{/g,`{
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
2
  `),e=e.replace(/([^{]);/g,`$1;
3
3
  `),e=e.replace(/}(?!$)/g,`
4
4
  }
5
5
 
6
6
  `),e=e.replace(/}$/,`
7
- }`),e}i(he,"formatCSSVars");function Oe(e){const n={root:{},groups:{},tokens:{}},t=[];if(N(e)){const{value:r,errors:o}=T(e,"");n.root=r,t.push(...o)}return v(e,"",n,t),{metadata:n,errors:t}}i(Oe,"collectMetadata");function v(e,n,t,r){for(const[o,s]of Object.entries(e)){if(o.startsWith("$"))continue;const a=n?`${n}.${o}`:o;if(!(typeof s!="object"||s===null)){if(!("$value"in s)&&N(s)){const{value:f,errors:l}=T(s,a);l.length>0&&r.push(...l),t.groups[a]=f}else if("$value"in s&&N(s)){const{value:f,errors:l}=T(s,a);l.length>0&&r.push(...l),t.tokens[a]=f}"$value"in s||v(s,a,t,r)}}}i(v,"collectNodeMetadata");function T(e,n){const t={},r=[];return j(e)?("$extensions"in e&&(typeof e.$extensions!="object"||e.$extensions===null?r.push({path:n,message:u.METADATA.INVALID_EXTENSIONS(n)}):t.$extensions=e.$extensions),"$description"in e&&(typeof e.$description!="string"?r.push({path:n,message:u.METADATA.INVALID_DESCRIPTION(n)}):t.$description=e.$description),{value:t,errors:r}):{value:t,errors:r}}i(T,"extractMetadata");function N(e){return j(e)&&("$extensions"in e||"$description"in e)}i(N,"hasMetadata");function j(e){return typeof e=="object"&&e!==null}i(j,"isValidNode");function Pe(e){return JSON.parse(e)}i(Pe,"parseJson");function y(e,n){const t=[];return(typeof e!="string"||!/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/.test(e))&&t.push({path:n,message:u.VALIDATE.INVALID_COLOR(e,n)}),t}i(y,"validateColor");function d(e,n){const t=[];if(typeof e!="object"||e===null||Array.isArray(e))return t.push({path:n,message:u.VALIDATE.INVALID_DIMENSION(e,n)}),t;const r=e;return"value"in r?typeof r.value!="number"&&t.push({path:`${n}.value`,message:u.VALIDATE.INVALID_NUMBER(r.value,n)}):t.push({path:`${n}.value`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("value",n)}),"unit"in r?(typeof r.unit!="string"||!["px","rem"].includes(r.unit))&&t.push({path:`${n}.unit`,message:u.VALIDATE.INVALID_DIMENSION_UNIT(r.unit,n)}):t.push({path:`${n}.unit`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("unit",n)}),t}i(d,"validateDimension");function Ce(e,n){const t=[];return(typeof e!="number"||isNaN(e))&&t.push({path:n,message:`Invalid number value at ${n}. Expected a number, got ${e}`}),t}i(Ce,"validateNumber");function k(e,n){const t=[];return typeof e=="string"||(Array.isArray(e)?e.every(r=>typeof r=="string")||t.push({path:n,message:u.VALIDATE.INVALID_FONT_FAMILY(e,n)}):t.push({path:n,message:u.VALIDATE.INVALID_FONT_FAMILY(e,n)})),t}i(k,"validateFontFamily");const Fe=["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"];function G(e,n){const t=[];return typeof e=="number"?(e<1||e>1e3)&&t.push({path:n,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,n)}):typeof e=="string"?Fe.includes(e.toLowerCase())||t.push({path:n,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,n)}):t.push({path:n,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,n)}),t}i(G,"validateFontWeight");function D(e,n){const t=[];if(typeof e!="object"||e===null||Array.isArray(e))return t.push({path:n,message:u.VALIDATE.INVALID_DURATION(e,n)}),t;const r=e;return"value"in r?typeof r.value!="number"&&t.push({path:`${n}.value`,message:u.VALIDATE.INVALID_NUMBER(r.value,n)}):t.push({path:`${n}.value`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("value",n)}),"unit"in r?(typeof r.unit!="string"||r.unit!=="ms")&&t.push({path:`${n}.unit`,message:u.VALIDATE.INVALID_DURATION_UNIT(r.unit,n)}):t.push({path:`${n}.unit`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("unit",n)}),t}i(D,"validateDuration");function Y(e,n){const t=[];if(!Array.isArray(e)||e.length!==4||!e.every(r=>typeof r=="number"))t.push({path:n,message:u.VALIDATE.INVALID_CUBIC_BEZIER(e,n)});else{const[r,,o]=e;(r!==void 0&&(r<0||r>1)||o!==void 0&&(o<0||o>1))&&t.push({path:n,message:u.VALIDATE.INVALID_CUBIC_BEZIER_RANGE(e,n)})}return t}i(Y,"validateCubicBezier");function Me(e,n){const t=[];if(e==null)return t.push({path:n,message:u.VALIDATE.INVALID_TYPOGRAPHY(e,n)}),t;if(typeof e!="object"||Array.isArray(e))return t.push({path:n,message:u.VALIDATE.INVALID_TYPOGRAPHY(e,n)}),t;const r=e;if("fontFamily"in r||t.push({path:`${n}.fontFamily`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("fontFamily",n)}),"fontSize"in r||t.push({path:`${n}.fontSize`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("fontSize",n)}),"fontFamily"in r&&!c(r.fontFamily)&&t.push(...k(r.fontFamily,`${n}.fontFamily`)),"fontSize"in r&&!c(r.fontSize)){const o=r.fontSize;typeof o!="object"||!o||Array.isArray(o)?t.push({path:`${n}.fontSize`,message:u.VALIDATE.INVALID_DIMENSION(o,n)}):t.push(...d(o,`${n}.fontSize`))}if("letterSpacing"in r&&!c(r.letterSpacing)){const o=r.letterSpacing;typeof o!="object"||!o||Array.isArray(o)?t.push({path:`${n}.letterSpacing`,message:u.VALIDATE.INVALID_DIMENSION(o,n)}):t.push(...d(o,`${n}.letterSpacing`))}if("fontWeight"in r&&!c(r.fontWeight)&&t.push(...G(r.fontWeight,`${n}.fontWeight`)),"lineHeight"in r&&!c(r.lineHeight)){const o=r.lineHeight;typeof o!="number"&&t.push({path:`${n}.lineHeight`,message:u.VALIDATE.INVALID_NUMBER(o,n)})}return t}i(Me,"validateTypographyObject");function Ue(e,n){return Me(e,n)}i(Ue,"validateTypography");const xe=["solid","dashed","dotted","double","groove","ridge","outset","inset"],ve=["round","butt","square"];function je(e,n){const t=[];if(typeof e!="string"&&typeof e!="object")t.push({path:n,message:u.VALIDATE.INVALID_DASH_ARRAY_ITEM(e,n)});else if(typeof e=="object"&&!c(e)){const r=e;(typeof r.value!="number"||typeof r.unit!="string")&&t.push({path:n,message:u.VALIDATE.INVALID_DIMENSION(r,n)})}return t}i(je,"validateDashArrayItem");function ke(e,n){const t=[];return"dashArray"in e?"lineCap"in e?(Array.isArray(e.dashArray)?e.dashArray.forEach((r,o)=>{t.push(...je(r,`${n}.dashArray[${o}]`))}):t.push({path:`${n}.dashArray`,message:u.VALIDATE.INVALID_ARRAY(e.dashArray,n)}),ve.includes(e.lineCap)||t.push({path:`${n}.lineCap`,message:u.VALIDATE.INVALID_STROKE_LINE_CAP(e.lineCap,n)})):t.push({path:n,message:u.VALIDATE.MISSING_REQUIRED_PROPERTIES(["lineCap"],n)}):t.push({path:n,message:u.VALIDATE.MISSING_REQUIRED_PROPERTIES(["dashArray"],n)}),t}i(ke,"validateCustomStrokeStyle");function w(e,n){const t=[];return typeof e=="string"?xe.includes(e)||t.push({path:n,message:u.VALIDATE.INVALID_STROKE_STYLE(e,n)}):typeof e=="object"&&e!==null&&!Array.isArray(e)?t.push(...ke(e,n)):t.push({path:n,message:u.VALIDATE.INVALID_STROKE_STYLE(e,n)}),t}i(w,"validateStrokeStyle");function Ge(e,n){return typeof e!="object"||e===null||Array.isArray(e)?[{path:n,message:u.VALIDATE.INVALID_DIMENSION(e,n)}]:d(e,n)}i(Ge,"validateBorderWidth");function Ye(e,n){const t=[];if(typeof e!="object"||Array.isArray(e)||e===null)return t.push({path:n,message:u.VALIDATE.INVALID_BORDER(e,n)}),t;const r=e,o=["color","width","style"];for(const s of o)s in r||t.push({path:`${n}.${s}`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY(s,n)});return"color"in r&&!c(r.color)&&t.push(...y(r.color,`${n}.color`)),"width"in r&&!c(r.width)&&t.push(...Ge(r.width,`${n}.width`)),"style"in r&&!c(r.style)&&t.push(...w(r.style,`${n}.style`)),t}i(Ye,"validateBorder");function we(e,n){const t=[];if(typeof e!="object"||Array.isArray(e)||e===null)return t.push({path:n,message:u.VALIDATE.INVALID_TRANSITION(e,n)}),t;const r=e,s=["duration","delay","timingFunction"].filter(a=>!(a in r));return s.length>0&&t.push({path:n,message:u.VALIDATE.MISSING_REQUIRED_PROPERTIES(s,n)}),"duration"in r&&!c(r.duration)&&t.push(...D(r.duration,`${n}.duration`)),"delay"in r&&!c(r.delay)&&t.push(...D(r.delay,`${n}.delay`)),"timingFunction"in r&&!c(r.timingFunction)&&t.push(...Y(r.timingFunction,`${n}.timingFunction`)),t}i(we,"validateTransition");function z(e,n){const t=[];if(typeof e!="object"||e===null)return t.push({path:n,message:u.VALIDATE.INVALID_SHADOW(e,n)}),t;const r=e;"color"in r?c(r.color)||t.push(...y(r.color,`${n}.color`)):t.push({path:`${n}.color`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("color",n)});const o=["offsetX","offsetY","blur","spread"];for(const s of o)s in r?c(r[s])||t.push(...d(r[s],`${n}.${s}`)):t.push({path:`${n}.${s}`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY(s,n)});return"inset"in r&&typeof r.inset!="boolean"&&t.push({path:`${n}.inset`,message:u.VALIDATE.INVALID_SHADOW_INSET(r.inset,n)}),t}i(z,"validateShadowObject");function ze(e,n){const t=[];return Array.isArray(e)?e.forEach((r,o)=>{t.push(...z(r,`${n}[${o}]`))}):typeof e=="object"&&e!==null?t.push(...z(e,n)):t.push({path:n,message:u.VALIDATE.INVALID_SHADOW(e,n)}),t}i(ze,"validateShadow");function We(e,n){const t=[];if(typeof e!="object"||e===null)return t.push({path:n,message:u.VALIDATE.INVALID_GRADIENT(e,n)}),t;const r=e;if("color"in r?c(r.color)||t.push(...y(r.color,`${n}.color`)):t.push({path:`${n}.color`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("color",n)}),!("position"in r))t.push({path:`${n}.position`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("position",n)});else if(!c(r.position)){const o=r.position;typeof o!="number"?t.push({path:`${n}.position`,message:u.VALIDATE.INVALID_NUMBER(o,n)}):(o<0||o>1)&&t.push({path:`${n}.position`,message:u.VALIDATE.INVALID_GRADIENT_STOP_POSITION(o,n)})}return t}i(We,"validateGradientStop");function He(e,n){const t=[];return Array.isArray(e)?(e.forEach((r,o)=>{t.push(...We(r,`${n}[${o}]`))}),t):(t.push({path:n,message:u.VALIDATE.INVALID_ARRAY(e,n)}),t)}i(He,"validateGradient");function Be(e,n){const t=[];if(typeof e!="object"||e===null||Array.isArray(e))return t.push({path:n,message:u.VALIDATE.INVALID_FLUID_DIMENSION(e,n)}),t;const r=e,o=["min","max"];for(const s of o){if(!(s in r)){t.push({path:`${n}.${s}`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY(s,n)});continue}t.push(...d(r[s],`${n}.${s}`))}return t}i(Be,"validateFluidDimension");const Ke={color:i((e,n)=>y(e,n),"color"),dimension:i((e,n)=>d(e,n),"dimension"),fluidDimension:i((e,n)=>Be(e,n),"fluidDimension"),duration:i((e,n)=>D(e,n),"duration"),cubicBezier:i((e,n)=>Y(e,n),"cubicBezier"),fontFamily:i((e,n)=>k(e,n),"fontFamily"),fontWeight:i((e,n)=>G(e,n),"fontWeight"),number:i((e,n)=>Ce(e,n),"number"),strokeStyle:i((e,n)=>w(e,n),"strokeStyle"),typography:i((e,n)=>Ue(e,n),"typography"),border:i((e,n)=>Ye(e,n),"border"),shadow:i((e,n)=>ze(e,n),"shadow"),gradient:i((e,n)=>He(e,n),"gradient"),transition:i((e,n)=>we(e,n),"transition")};function Qe(e,n,t){const r=[];if(!("$type"in e))return[{path:n,message:u.VALIDATE.MISSING_TYPE(n)}];if(!("$value"in e))return[{path:n,message:u.VALIDATE.MISSING_VALUE(n)}];const o=Ke[e.$type];return o?c(e.$value)?[]:(e.$type==="fluidDimension"&&(C(n,t)?.viewports||r.push({path:n,message:u.VALIDATE.MISSING_FLUID_CONFIG(n)})),[...r,...o(e.$value,n)]):[{path:n,message:u.VALIDATE.UNKNOWN_TOKEN_TYPE(e.$type,n)}]}i(Qe,"validateTokenNode");function qe(e,n){const t=[];for(const[r,o]of Object.entries(e))if(!(typeof o!="object"||o===null)&&!(!o.$path||o.$path.startsWith("$"))){if(typeof o!="object"||o===null){t.push({path:r,message:u.VALIDATE.INVALID_TOKEN_STRUCTURE(r)});continue}t.push(...Qe(o,o.$path,n))}return t}i(qe,"validate");export{Oe as collectMetadata,Se as convert,K as flatten,be as generateCSS,Pe as parseJson,J as resolve,qe as validate};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sugarcube-org/core",
3
- "version": "0.0.1-alpha.0",
3
+ "version": "0.0.1-alpha.1",
4
4
  "publishConfig": {
5
5
  "access": "restricted"
6
6
  },