@salty-css/core 0.3.0 → 0.3.1-fix-respect-media-order.0

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.
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require("../main-DhcbJ5aR.cjs").t().catch(e=>console.error(e));
2
+ require("../main-BBDoJC-i.cjs").t().catch(e=>console.error(e));
package/dist/bin/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as e } from "../main-CDCMeMx3.js";
2
+ import { t as e } from "../main-DlDOV6Qk.js";
3
3
  //#region src/bin/index.ts
4
4
  e().catch((e) => console.error(e));
5
5
  //#endregion
package/dist/bin/main.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../main-DhcbJ5aR.cjs");exports.main=e.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../main-BBDoJC-i.cjs");exports.main=e.t;
package/dist/bin/main.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as e } from "../main-CDCMeMx3.js";
1
+ import { t as e } from "../main-DlDOV6Qk.js";
2
2
  export { e as main };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../salty-compiler-DItIIZ12.cjs");exports.SaltyCompiler=e.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../salty-compiler-C7i9NpS-.cjs");exports.SaltyCompiler=e.t;
@@ -1,2 +1,2 @@
1
- import { t as e } from "../salty-compiler-Cj88Ep29.js";
1
+ import { t as e } from "../salty-compiler-CyQpU98T.js";
2
2
  export { e as SaltyCompiler };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../util/index.cjs"),t=require("../parse-styles-2rwbF9j_.cjs");var n=({animationName:n,params:r,appendInitialStyles:i,...a})=>{let o=async(o={})=>{let s=n||e.toHash(a),c=async()=>{let{duration:e=`500ms`,easing:n=`ease-in-out`,delay:c=`0s`,iterationCount:l=`1`,direction:u=`normal`,fillMode:d=`forwards`,playState:f=`running`}={...r,...o},p=`${s} ${e} ${n} ${c} ${l} ${u} ${d} ${f}`;if(!i)return p;let m=a.from||a[`0%`];return m?`${p};${await t.t(m,``)}`:p},l=Object.entries(a).map(async([e,n])=>{if(!n)return``;let r=await t.t(n,``);return`${/^-?\d+$/.test(e)?`${e}%`:e}{${r}}`}),u=`@keyframes ${s} {${(await Promise.all(l)).join(``)}}`;return Object.assign(c,{toString:c,isKeyframes:!0,animationName:s,css:u,keyframes:a}),c};return Object.assign(o,{_shouldResolve:!0}),o};exports.keyframes=n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../util/index.cjs"),t=require("../parse-styles-PndoToaP.cjs");var n=({animationName:n,params:r,appendInitialStyles:i,...a})=>{let o=async(o={})=>{let s=n||e.toHash(a),c=async()=>{let{duration:e=`500ms`,easing:n=`ease-in-out`,delay:c=`0s`,iterationCount:l=`1`,direction:u=`normal`,fillMode:d=`forwards`,playState:f=`running`}={...r,...o},p=`${s} ${e} ${n} ${c} ${l} ${u} ${d} ${f}`;if(!i)return p;let m=a.from||a[`0%`];return m?`${p};${await t.t(m,``)}`:p},l=Object.entries(a).map(async([e,n])=>{if(!n)return``;let r=await t.t(n,``);return`${/^-?\d+$/.test(e)?`${e}%`:e}{${r}}`}),u=`@keyframes ${s} {${(await Promise.all(l)).join(``)}}`;return Object.assign(c,{toString:c,isKeyframes:!0,animationName:s,css:u,keyframes:a}),c};return Object.assign(o,{_shouldResolve:!0}),o};exports.keyframes=n;
@@ -1,5 +1,5 @@
1
1
  import { toHash as e } from "../util/index.js";
2
- import { t } from "../parse-styles-Bz0otiZ-.js";
2
+ import { t } from "../parse-styles-B5QRCMas.js";
3
3
  //#region src/css/keyframes.ts
4
4
  var n = ({ animationName: n, params: r, appendInitialStyles: i, ...a }) => {
5
5
  let o = async (o = {}) => {
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../generators-eEKEtyAm.cjs");exports.ClassNameGenerator=e.n,exports.StyledGenerator=e.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../generators-BRukX_SQ.cjs");exports.ClassNameGenerator=e.n,exports.StyledGenerator=e.t;
@@ -1,2 +1,2 @@
1
- import { n as e, t } from "../generators-CrK45F8i.js";
1
+ import { n as e, t } from "../generators-Cbt_Ih7F.js";
2
2
  export { e as ClassNameGenerator, t as StyledGenerator };
@@ -1 +1 @@
1
- const e=require("./util/index.cjs"),t=require("./parse-styles-2rwbF9j_.cjs");var n=class{params;buildContext={};constructor(e){this.params=e}get priority(){return 0}get isRoot(){return this.priority===0}get hash(){let{base:t,variants:n,compoundVariants:r,anyOfVariants:i}=this.params;return e.toHash({base:t,variants:n,compoundVariants:r,anyOfVariants:i})}get cssClassName(){return this.hash}get classNames(){let e=new Set([this.cssClassName]),{className:t}=this.params;return typeof t==`string`&&e.add(t),typeof t==`object`&&t.forEach(t=>e.add(t)),this.getTemplateClasses().forEach(t=>e.add(t)),this.buildContext.classNames&&this.buildContext.classNames.forEach(t=>e.add(t)),[...e].join(` `)}get cssFileName(){let{callerName:t}=this.buildContext;return t?`cl_${e.dashCase(t)}-${this.hash}.css`:`${this.hash}.css`}get css(){let{base:e={},variants:n={},compoundVariants:r=[],anyOfVariants:i=[]}=this.params,{config:a}=this.buildContext;return t.t({...e,variants:n,compoundVariants:r,anyOfVariants:i},`.${this.cssClassName}`,a,this.isRoot)}getTemplateClasses(n=this.buildContext.config){if(!n?.templates||!this.params.base||this.priority>0)return[];let r=Object.keys(n.templates);return Object.entries(this.params.base).reduce((n,[i,a])=>{if(!r.includes(i))return n;let o=t.i(a);if(!o||o.path.length===0)return n;let{path:s,variants:c}=o,l=[];for(let t of s){l.push(t);let r=e.dashCase(`${i}-${l.join(`.`)}`);n.push(`t_`+e.toHash(r,4));for(let[t,i]of Object.entries(c)){if(i===!1||i===void 0)continue;let a=i===!0?``:`-${e.dashCase(String(i))}`,o=`${r}-${e.dashCase(t)}${a}`;n.push(`tv_`+e.toHash(o,4))}}return n},[])}_withBuildContext(e){return this.buildContext=e,this}},r=class extends n{_params;constructor(e){super(e),this._params=e}get priority(){return this.params.priority?this.params.priority:0}},i=class extends n{tagName;_params;constructor(e,t){super(t),this.tagName=e,this._params=t}get priority(){return this.params.priority?this.params.priority:this.tagName&&(typeof this.tagName==`function`||typeof this.tagName==`object`)?(this.tagName.generator?.priority||0)+1:0}get clientProps(){let{element:t,as:n,variants:r={},compoundVariants:i=[],anyOfVariants:a=[],defaultVariants:o={},defaultProps:s={},passProps:c}=this.params,l=n??t,{callerName:u,isProduction:d}=this.buildContext,f=new Set([]),p=e=>{let t=o[e];t===void 0?f.add(e):f.add(`${e}=${String(t)}`)};Object.keys(r).forEach(p),i.map(e=>Object.keys(e).forEach(p)),a.map(e=>Object.keys(e).forEach(p));let m=new Set([]);if(this.params.base){let t=JSON.stringify(this.params.base).match(/\{-?props\.([^}]+)\}/gi);t&&t.forEach(t=>{let n=t.replace(/\{(?:-)?props\.([^}]+)\}/gi,`$1`),r=e.dashCase(n);n&&m.add(r)})}return{element:l,hash:this.hash,variantKeys:[...f],propValueKeys:[...m],passProps:c,defaultProps:s,attr:{"data-component-name":d?void 0:u}}}};Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}});
1
+ const e=require("./util/index.cjs"),t=require("./parse-styles-PndoToaP.cjs");var n=class{params;buildContext={};constructor(e){this.params=e}get priority(){return 0}get isRoot(){return this.priority===0}get hash(){let{base:t,variants:n,compoundVariants:r,anyOfVariants:i}=this.params;return e.toHash({base:t,variants:n,compoundVariants:r,anyOfVariants:i})}get cssClassName(){return this.hash}get classNames(){let e=new Set([this.cssClassName]),{className:t}=this.params;return typeof t==`string`&&e.add(t),typeof t==`object`&&t.forEach(t=>e.add(t)),this.getTemplateClasses().forEach(t=>e.add(t)),this.buildContext.classNames&&this.buildContext.classNames.forEach(t=>e.add(t)),[...e].join(` `)}get cssFileName(){let{callerName:t}=this.buildContext;return t?`cl_${e.dashCase(t)}-${this.hash}.css`:`${this.hash}.css`}get css(){let{base:e={},variants:n={},compoundVariants:r=[],anyOfVariants:i=[]}=this.params,{config:a}=this.buildContext;return t.t({...e,variants:n,compoundVariants:r,anyOfVariants:i},`.${this.cssClassName}`,a,this.isRoot)}getTemplateClasses(n=this.buildContext.config){if(!n?.templates||!this.params.base||this.priority>0)return[];let r=Object.keys(n.templates);return Object.entries(this.params.base).reduce((n,[i,a])=>{if(!r.includes(i))return n;let o=t.i(a);if(!o||o.path.length===0)return n;let{path:s,variants:c}=o,l=[];for(let t of s){l.push(t);let r=e.dashCase(`${i}-${l.join(`.`)}`);n.push(`t_`+e.toHash(r,4));for(let[t,i]of Object.entries(c)){if(i===!1||i===void 0)continue;let a=i===!0?``:`-${e.dashCase(String(i))}`,o=`${r}-${e.dashCase(t)}${a}`;n.push(`tv_`+e.toHash(o,4))}}return n},[])}_withBuildContext(e){return this.buildContext=e,this}},r=class extends n{_params;constructor(e){super(e),this._params=e}get priority(){return this.params.priority?this.params.priority:0}},i=class extends n{tagName;_params;constructor(e,t){super(t),this.tagName=e,this._params=t}get priority(){return this.params.priority?this.params.priority:this.tagName&&(typeof this.tagName==`function`||typeof this.tagName==`object`)?(this.tagName.generator?.priority||0)+1:0}get clientProps(){let{element:t,as:n,variants:r={},compoundVariants:i=[],anyOfVariants:a=[],defaultVariants:o={},defaultProps:s={},passProps:c}=this.params,l=n??t,{callerName:u,isProduction:d}=this.buildContext,f=new Set([]),p=e=>{let t=o[e];t===void 0?f.add(e):f.add(`${e}=${String(t)}`)};Object.keys(r).forEach(p),i.map(e=>Object.keys(e).forEach(p)),a.map(e=>Object.keys(e).forEach(p));let m=new Set([]);if(this.params.base){let t=JSON.stringify(this.params.base).match(/\{-?props\.([^}]+)\}/gi);t&&t.forEach(t=>{let n=t.replace(/\{(?:-)?props\.([^}]+)\}/gi,`$1`),r=e.dashCase(n);n&&m.add(r)})}return{element:l,hash:this.hash,variantKeys:[...f],propValueKeys:[...m],passProps:c,defaultProps:s,attr:{"data-component-name":d?void 0:u}}}};Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}});
@@ -1,5 +1,5 @@
1
1
  import { dashCase as e, toHash as t } from "./util/index.js";
2
- import { i as n, t as r } from "./parse-styles-Bz0otiZ-.js";
2
+ import { i as n, t as r } from "./parse-styles-B5QRCMas.js";
3
3
  //#region src/generators/styles-generator.ts
4
4
  var i = class {
5
5
  params;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../generators-eEKEtyAm.cjs");var t=t=>{let n=new e.n(t),r=e=>{let t=new String(e);return Object.assign(t,{get isClassName(){return!0},variant:(e,n)=>r(`${t} ${`${e}-${n}`}`),variants:e=>r(`${t}${Object.entries(e).reduce((e,[t,n])=>(e+=` ${t}-${n}`,e),``)}`.trim()),generator:n}),t};return r(n.cssClassName)};exports.classNameInstance=t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../generators-BRukX_SQ.cjs");var t=t=>{let n=new e.n(t),r=e=>{let t=new String(e);return Object.assign(t,{get isClassName(){return!0},variant:(e,n)=>r(`${t} ${`${e}-${n}`}`),variants:e=>r(`${t}${Object.entries(e).reduce((e,[t,n])=>(e+=` ${t}-${n}`,e),``)}`.trim()),generator:n}),t};return r(n.cssClassName)};exports.classNameInstance=t;
@@ -1,4 +1,4 @@
1
- import { n as e } from "../generators-CrK45F8i.js";
1
+ import { n as e } from "../generators-Cbt_Ih7F.js";
2
2
  //#region src/instances/classname-instance.ts
3
3
  var t = (t) => {
4
4
  let n = new e(t), r = (e) => {
@@ -1,4 +1,4 @@
1
- const e=require("./chunk-CMqjfN_6.cjs"),t=require("./salty-compiler-DItIIZ12.cjs"),n=require("./compiler/helpers.cjs"),r=require("./util/index.cjs"),i=require("./server/index.cjs");let a=require("commander"),o=require("fs"),s=require("path"),c=require("fs/promises"),l=require("child_process"),u=require("ora");u=e.t(u,1);let d=require("ejs");d=e.t(d,1);let f=require("readline/promises");var p=(0,s.join)(process.cwd(),`package.json`),m=async(e=p)=>{let t=await(0,c.readFile)(e,`utf-8`).then(JSON.parse).catch(()=>void 0);if(!t)throw`Could not read package.json file!`;return t},h=async(e,t=p)=>{typeof e==`object`&&(e=JSON.stringify(e,null,2)),await(0,c.writeFile)(t,e)},g=async()=>m(new URL(`../package.json`,``+{}.url)),_={core:e=>`@salty-css/core@${e}`,eslintConfigCore:e=>`@salty-css/eslint-config-core@${e}`},v=e=>{e.scripts||={};let t=e.scripts.prepare;if(t){if(t.includes(`salty-css`))return{changed:!1,pkg:e};e.scripts.prepare=t+` && npx salty-css build`}else e.scripts.prepare=`npx salty-css build`;return{changed:!0,pkg:e}},y=e=>new Promise((t,n)=>{(0,l.exec)(e,e=>{if(e)return n(e);t()})}),b=async(...e)=>{let t=e.map(e=>e.replace(`-D`,``).split(`@`).slice(0,-1).join(`@`).trim()).join(`, `),n=(0,u.default)(`Installing packages: ${t}`).start();await y(`npm install ${e.join(` `)}`),n.succeed(`Installed packages: ${t}`)},x=()=>(0,o.existsSync)((0,s.join)(process.cwd(),`node_modules`,`.bin`,`prettier`));async function S(e){try{if(!x())return;await y(`./node_modules/.bin/prettier --write "${e}"`),t.r.info(`Formatted ${e} with Prettier`)}catch(n){t.r.error(`Error formatting ${e} with Prettier:`,n)}}var C=(e=process.cwd())=>(0,s.join)(e,`.saltyrc.json`),w=async(e=process.cwd())=>await(0,c.readFile)(C(e),`utf-8`).then(JSON.parse).catch(()=>({})),T=async(e=process.cwd())=>(0,c.readFile)(C(e),`utf-8`).catch(()=>void 0),E=async(e=process.cwd())=>(await w(e)).defaultProject,D=(e,t,n,r={})=>{let i=(0,s.join)(t,n.srcDirectory),a={dir:i,framework:n.name,...r};if(e===void 0)return{content:JSON.stringify({$schema:`./node_modules/@salty-css/core/.saltyrc.schema.json`,info:`This file is used to define projects and their configurations for Salty CSS cli. Do not delete, modify or add this file to .gitignore.`,defaultProject:i,projects:[a]},null,2),changed:!0,created:!0};let o=JSON.parse(e),c=o.projects||[];if(c.some(e=>e.dir===i))return{content:e,changed:!1,created:!1};c.push(a),o.projects=[...c];let l=JSON.stringify(o,null,2);return{content:l,changed:l!==e,created:!1}},O=async(e,n,r,i={})=>{let a=C(e),{content:o,changed:s,created:l}=D(await T(e),n,r,i);return s?(l?t.r.info(`Creating file: `+a):t.r.info(`Edit file: `+a),await(0,c.writeFile)(a,o),await S(a),!0):!1},ee=(e,t)=>(e.projects||[]).find(e=>e.dir===t)?.framework,k=(e,t=process.cwd())=>(0,s.join)(t,e===`.`?``:e),A=async e=>{let t=process.cwd(),n=k(e.dir,t),r=(0,s.relative)(t,n)||`.`,i=await m().catch(()=>void 0);if(e.requirePackageJson!==!1&&!i)throw Error(`Salty CSS project must be initialized in a directory with a package.json file.`);return{cwd:t,projectDir:n,relativeProjectPath:r,packageJson:i,rcFile:await w(t),cliVersion:(await g()).version||`0.0.0`,skipInstall:!!e.skipInstall,yes:!!e.yes}},j=(e,r)=>{e.command(`build [directory]`).alias(`b`).description(`Build the Salty-CSS project.`).option(`-d, --dir <dir>`,`Project directory to build the project in.`).option(`--watch`,`Watch for changes and rebuild the project.`).option(`--mode <mode>`,`Build mode: "production" or "development". Defaults to NODE_ENV-based detection.`).action(async function(e=r){t.r.info(`Building the Salty-CSS project...`);let{dir:a=e,watch:s,mode:c}=this.opts();if(c!==void 0&&c!==`production`&&c!==`development`)return t.n(`Invalid --mode "${c}". Expected "production" or "development".`);let l=a??await E();if(!l)return t.n(`Project directory must be provided. Add it as the first argument after build command or use the --dir option.`);let u=k(l),d=new t.t(u,{mode:c});await d.generateCss(),s&&(t.r.info(`Watching for changes in the project directory...`),(0,o.watch)(u,{recursive:!0},async(e,t)=>{if(!t)return console.warn(`File path not provided for change event`);await i.checkShouldRestart(t)?await d.generateCss(!1):n.isSaltyFile(t)&&await d.generateFile(t)}))})},M=[`astro.config.mjs`,`astro.config.ts`,`astro.config.js`,`astro.config.cjs`],N=e=>{for(let t of M){let n=(0,s.join)(e,t);if((0,o.existsSync)(n))return n}return null},te=e=>{let t=e.packageJson;if(!t)return!1;let n={...t.dependencies,...t.devDependencies};return Object.prototype.hasOwnProperty.call(n,`astro`)},P={name:`astro`,srcDirectory:`src`,detect:e=>!!N(e.projectDir)||te(e),runtimePackage:e=>`@salty-css/astro@${e}`,templates:{styled:`astro/styled-file.ts`,component:{styled:`astro/styled-file.ts`,wrapper:`astro/component.astro`,wrapperExt:`.astro`}}},F={name:`react`,srcDirectory:``,detect:()=>!0,runtimePackage:e=>`@salty-css/react@${e}`,templates:{styled:`react/styled-file.ts`,component:{styled:`react/styled-file.ts`,wrapper:`react/vanilla-file.ts`,wrapperExt:`.tsx`}}},I=[P,F],L={astro:P,react:F},R=async e=>{for(let t of I)if(await t.detect(e))return t;return F},z=e=>{if(e)return L[e]},B={"salty.config.ts":()=>Promise.resolve().then(()=>require("./salty.config-B0ZiRpHR.cjs")),"saltygen/index.css":()=>Promise.resolve().then(()=>require("./templates-BGHLaAOm.cjs")),"react/styled-file.ts":()=>Promise.resolve().then(()=>require("./styled-file-BCbAEzBB.cjs")),"react/vanilla-file.ts":()=>Promise.resolve().then(()=>require("./vanilla-file-Z3VsOa_U.cjs")),"astro/styled-file.ts":()=>Promise.resolve().then(()=>require("./styled-file-DorArlCk.cjs")),"astro/component.astro":()=>Promise.resolve().then(()=>require("./astro-component-r0qEcF1p.cjs"))},V=async(e,t)=>{let{default:n}=await B[e]();return{fileName:e,content:d.default.render(n,t)}},H=(e,n)=>{e.command(`generate [file] [directory]`).alias(`g`).description(`Generate a new component file.`).option(`-f, --file <file>`,`File to generate.`).option(`-d, --dir <dir>`,`Project directory to generate the file in.`).option(`-t, --tag <tag>`,`HTML tag of the component.`,`div`).option(`-n, --name <name>`,`Name of the component.`).option(`-c, --className <className>`,`CSS class of the component.`).option(`-r, --reactComponent`,`Generate a wrapper component file alongside the styled definition.`).action(async function(e,i=n){let{file:a=e,dir:o=i,tag:l,name:u,className:d,reactComponent:f=!1}=this.opts();if(!a)return t.n(`File to generate must be provided. Add it as the first argument after generate command or use the --file option.`);if(!o)return t.n(`Project directory must be provided. Add it as the second argument after generate command or use the --dir option.`);let p;try{p=await A({dir:o,requirePackageJson:!1})}catch(e){return t.n(e instanceof Error?e.message:String(e))}let m=z(ee(p.rcFile,p.relativeProjectPath))??await R(p),h=a.split(`/`).slice(0,-1).join(`/`);h&&await(0,c.mkdir)((0,s.join)(p.projectDir,h),{recursive:!0});let g=(0,s.parse)((0,s.join)(p.projectDir,a));g.ext||=`.ts`,g.name.endsWith(`.css`)||(g.name+=`.css`),g.base=g.name+g.ext;let _=(0,s.format)(g);if(await(0,c.readFile)(_,`utf-8`).catch(()=>void 0)!==void 0){t.r.error(`File already exists: `+_);return}let v=r.pascalCase(u||g.base.replace(/\.css\.\w+$/,``));if(f){if(!m.templates.component)return t.n(`--reactComponent is not supported for the ${m.name} framework.`);let e=v+`Component`;v+=`Wrapper`;let n=g.base.replace(/\.css\.\w+$/,``),{content:r}=await V(m.templates.component.wrapper,{tag:l,componentName:e,styledComponentName:v,className:d,fileName:n});g.name=n.replace(/\.css$/,``),g.ext=m.templates.component.wrapperExt,g.base=g.name+g.ext;let i=(0,s.format)(g);t.r.info(`Generating a new file: `+i),await(0,c.writeFile)(i,r),await S(i)}let{content:y}=await V(f&&m.templates.component?m.templates.component.styled:m.templates.styled,{tag:l,name:v,className:d});t.r.info(`Generating a new file: `+_),await(0,c.writeFile)(_,y),await S(_)})},U=e=>{let t=e.trim();return t.startsWith(`-D `)?`${t.slice(3).trim()} (dev)`:t},W=e=>e.map(e=>` + ${U(e)}`).join(`
1
+ const e=require("./chunk-CMqjfN_6.cjs"),t=require("./salty-compiler-C7i9NpS-.cjs"),n=require("./compiler/helpers.cjs"),r=require("./util/index.cjs"),i=require("./server/index.cjs");let a=require("commander"),o=require("fs"),s=require("path"),c=require("fs/promises"),l=require("child_process"),u=require("ora");u=e.t(u,1);let d=require("ejs");d=e.t(d,1);let f=require("readline/promises");var p=(0,s.join)(process.cwd(),`package.json`),m=async(e=p)=>{let t=await(0,c.readFile)(e,`utf-8`).then(JSON.parse).catch(()=>void 0);if(!t)throw`Could not read package.json file!`;return t},h=async(e,t=p)=>{typeof e==`object`&&(e=JSON.stringify(e,null,2)),await(0,c.writeFile)(t,e)},g=async()=>m(new URL(`../package.json`,``+{}.url)),_={core:e=>`@salty-css/core@${e}`,eslintConfigCore:e=>`@salty-css/eslint-config-core@${e}`},v=e=>{e.scripts||={};let t=e.scripts.prepare;if(t){if(t.includes(`salty-css`))return{changed:!1,pkg:e};e.scripts.prepare=t+` && npx salty-css build`}else e.scripts.prepare=`npx salty-css build`;return{changed:!0,pkg:e}},y=e=>new Promise((t,n)=>{(0,l.exec)(e,e=>{if(e)return n(e);t()})}),b=async(...e)=>{let t=e.map(e=>e.replace(`-D`,``).split(`@`).slice(0,-1).join(`@`).trim()).join(`, `),n=(0,u.default)(`Installing packages: ${t}`).start();await y(`npm install ${e.join(` `)}`),n.succeed(`Installed packages: ${t}`)},x=()=>(0,o.existsSync)((0,s.join)(process.cwd(),`node_modules`,`.bin`,`prettier`));async function S(e){try{if(!x())return;await y(`./node_modules/.bin/prettier --write "${e}"`),t.r.info(`Formatted ${e} with Prettier`)}catch(n){t.r.error(`Error formatting ${e} with Prettier:`,n)}}var C=(e=process.cwd())=>(0,s.join)(e,`.saltyrc.json`),w=async(e=process.cwd())=>await(0,c.readFile)(C(e),`utf-8`).then(JSON.parse).catch(()=>({})),T=async(e=process.cwd())=>(0,c.readFile)(C(e),`utf-8`).catch(()=>void 0),E=async(e=process.cwd())=>(await w(e)).defaultProject,D=(e,t,n,r={})=>{let i=(0,s.join)(t,n.srcDirectory),a={dir:i,framework:n.name,...r};if(e===void 0)return{content:JSON.stringify({$schema:`./node_modules/@salty-css/core/.saltyrc.schema.json`,info:`This file is used to define projects and their configurations for Salty CSS cli. Do not delete, modify or add this file to .gitignore.`,defaultProject:i,projects:[a]},null,2),changed:!0,created:!0};let o=JSON.parse(e),c=o.projects||[];if(c.some(e=>e.dir===i))return{content:e,changed:!1,created:!1};c.push(a),o.projects=[...c];let l=JSON.stringify(o,null,2);return{content:l,changed:l!==e,created:!1}},O=async(e,n,r,i={})=>{let a=C(e),{content:o,changed:s,created:l}=D(await T(e),n,r,i);return s?(l?t.r.info(`Creating file: `+a):t.r.info(`Edit file: `+a),await(0,c.writeFile)(a,o),await S(a),!0):!1},ee=(e,t)=>(e.projects||[]).find(e=>e.dir===t)?.framework,k=(e,t=process.cwd())=>(0,s.join)(t,e===`.`?``:e),A=async e=>{let t=process.cwd(),n=k(e.dir,t),r=(0,s.relative)(t,n)||`.`,i=await m().catch(()=>void 0);if(e.requirePackageJson!==!1&&!i)throw Error(`Salty CSS project must be initialized in a directory with a package.json file.`);return{cwd:t,projectDir:n,relativeProjectPath:r,packageJson:i,rcFile:await w(t),cliVersion:(await g()).version||`0.0.0`,skipInstall:!!e.skipInstall,yes:!!e.yes}},j=(e,r)=>{e.command(`build [directory]`).alias(`b`).description(`Build the Salty-CSS project.`).option(`-d, --dir <dir>`,`Project directory to build the project in.`).option(`--watch`,`Watch for changes and rebuild the project.`).option(`--mode <mode>`,`Build mode: "production" or "development". Defaults to NODE_ENV-based detection.`).action(async function(e=r){t.r.info(`Building the Salty-CSS project...`);let{dir:a=e,watch:s,mode:c}=this.opts();if(c!==void 0&&c!==`production`&&c!==`development`)return t.n(`Invalid --mode "${c}". Expected "production" or "development".`);let l=a??await E();if(!l)return t.n(`Project directory must be provided. Add it as the first argument after build command or use the --dir option.`);let u=k(l),d=new t.t(u,{mode:c});await d.generateCss(),s&&(t.r.info(`Watching for changes in the project directory...`),(0,o.watch)(u,{recursive:!0},async(e,t)=>{if(!t)return console.warn(`File path not provided for change event`);await i.checkShouldRestart(t)?await d.generateCss(!1):n.isSaltyFile(t)&&await d.generateFile(t)}))})},M=[`astro.config.mjs`,`astro.config.ts`,`astro.config.js`,`astro.config.cjs`],N=e=>{for(let t of M){let n=(0,s.join)(e,t);if((0,o.existsSync)(n))return n}return null},te=e=>{let t=e.packageJson;if(!t)return!1;let n={...t.dependencies,...t.devDependencies};return Object.prototype.hasOwnProperty.call(n,`astro`)},P={name:`astro`,srcDirectory:`src`,detect:e=>!!N(e.projectDir)||te(e),runtimePackage:e=>`@salty-css/astro@${e}`,templates:{styled:`astro/styled-file.ts`,component:{styled:`astro/styled-file.ts`,wrapper:`astro/component.astro`,wrapperExt:`.astro`}}},F={name:`react`,srcDirectory:``,detect:()=>!0,runtimePackage:e=>`@salty-css/react@${e}`,templates:{styled:`react/styled-file.ts`,component:{styled:`react/styled-file.ts`,wrapper:`react/vanilla-file.ts`,wrapperExt:`.tsx`}}},I=[P,F],L={astro:P,react:F},R=async e=>{for(let t of I)if(await t.detect(e))return t;return F},z=e=>{if(e)return L[e]},B={"salty.config.ts":()=>Promise.resolve().then(()=>require("./salty.config-B0ZiRpHR.cjs")),"saltygen/index.css":()=>Promise.resolve().then(()=>require("./templates-BGHLaAOm.cjs")),"react/styled-file.ts":()=>Promise.resolve().then(()=>require("./styled-file-BCbAEzBB.cjs")),"react/vanilla-file.ts":()=>Promise.resolve().then(()=>require("./vanilla-file-Z3VsOa_U.cjs")),"astro/styled-file.ts":()=>Promise.resolve().then(()=>require("./styled-file-DorArlCk.cjs")),"astro/component.astro":()=>Promise.resolve().then(()=>require("./astro-component-r0qEcF1p.cjs"))},V=async(e,t)=>{let{default:n}=await B[e]();return{fileName:e,content:d.default.render(n,t)}},H=(e,n)=>{e.command(`generate [file] [directory]`).alias(`g`).description(`Generate a new component file.`).option(`-f, --file <file>`,`File to generate.`).option(`-d, --dir <dir>`,`Project directory to generate the file in.`).option(`-t, --tag <tag>`,`HTML tag of the component.`,`div`).option(`-n, --name <name>`,`Name of the component.`).option(`-c, --className <className>`,`CSS class of the component.`).option(`-r, --reactComponent`,`Generate a wrapper component file alongside the styled definition.`).action(async function(e,i=n){let{file:a=e,dir:o=i,tag:l,name:u,className:d,reactComponent:f=!1}=this.opts();if(!a)return t.n(`File to generate must be provided. Add it as the first argument after generate command or use the --file option.`);if(!o)return t.n(`Project directory must be provided. Add it as the second argument after generate command or use the --dir option.`);let p;try{p=await A({dir:o,requirePackageJson:!1})}catch(e){return t.n(e instanceof Error?e.message:String(e))}let m=z(ee(p.rcFile,p.relativeProjectPath))??await R(p),h=a.split(`/`).slice(0,-1).join(`/`);h&&await(0,c.mkdir)((0,s.join)(p.projectDir,h),{recursive:!0});let g=(0,s.parse)((0,s.join)(p.projectDir,a));g.ext||=`.ts`,g.name.endsWith(`.css`)||(g.name+=`.css`),g.base=g.name+g.ext;let _=(0,s.format)(g);if(await(0,c.readFile)(_,`utf-8`).catch(()=>void 0)!==void 0){t.r.error(`File already exists: `+_);return}let v=r.pascalCase(u||g.base.replace(/\.css\.\w+$/,``));if(f){if(!m.templates.component)return t.n(`--reactComponent is not supported for the ${m.name} framework.`);let e=v+`Component`;v+=`Wrapper`;let n=g.base.replace(/\.css\.\w+$/,``),{content:r}=await V(m.templates.component.wrapper,{tag:l,componentName:e,styledComponentName:v,className:d,fileName:n});g.name=n.replace(/\.css$/,``),g.ext=m.templates.component.wrapperExt,g.base=g.name+g.ext;let i=(0,s.format)(g);t.r.info(`Generating a new file: `+i),await(0,c.writeFile)(i,r),await S(i)}let{content:y}=await V(f&&m.templates.component?m.templates.component.styled:m.templates.styled,{tag:l,name:v,className:d});t.r.info(`Generating a new file: `+_),await(0,c.writeFile)(_,y),await S(_)})},U=e=>{let t=e.trim();return t.startsWith(`-D `)?`${t.slice(3).trim()} (dev)`:t},W=e=>e.map(e=>` + ${U(e)}`).join(`
2
2
  `),G=async(e,t,n={})=>{if(t||e.length===0)return;let r=n.input??process.stdin,i=n.output??process.stdout;if(!(n.isTTY??process.stdin.isTTY??!1))throw Error(`Cannot prompt for install confirmation: stdin is not a TTY. Re-run with --yes to install the listed packages without prompting.`);i.write(`The following packages will be installed:\n${W(e)}\n`);let a=(0,f.createInterface)({input:r,output:i,terminal:!1});try{let e=(await a.question(`Proceed? (y/N) `)).trim().toLowerCase();if(e!==`y`&&e!==`yes`)throw Error(`Install cancelled by user.`)}finally{a.close()}},K=async(e,t={})=>{if(t.yes)return!0;let n=t.input??process.stdin,r=t.output??process.stdout;if(!(t.isTTY??process.stdin.isTTY??!1))return!1;let i=t.defaultYes?`(Y/n)`:`(y/N)`,a=(0,f.createInterface)({input:n,output:r,terminal:!1});try{let n=(await a.question(`${e} ${i} `)).trim().toLowerCase();return n===``?!!t.defaultYes:n===`y`||n===`yes`}finally{a.close()}},q=[`src`,`public`,`assets`,`styles`,`css`,`app`],J=[`styles`,`css`,`app`,`pages`],Y=[`index`,`styles`,`main`,`app`,`global`,`globals`],X=[`.css`,`.scss`,`.sass`],Z=async e=>{for(let t of q)for(let n of Y)for(let r of X){let i=(0,s.join)(e,t,n+r);if(await(0,c.readFile)(i,`utf-8`).catch(()=>void 0)!==void 0)return(0,s.relative)(e,i);for(let i of J){let a=(0,s.join)(e,t,i,n+r);if(await(0,c.readFile)(a,`utf-8`).catch(()=>void 0)!==void 0)return(0,s.relative)(e,a)}}},Q=e=>`@salty-css/astro@${e}`,ne=`import saltyIntegration from '@salty-css/astro/integration';
3
3
  `,re=e=>{if(e.includes(`@salty-css/astro`))return{content:null};let t=e,n=!1;return/integrations\s*:\s*\[/.test(t)?(t=t.replace(/integrations\s*:\s*\[/,e=>`${e}saltyIntegration(),`),n=!0):/defineConfig\s*\(\s*\{/.test(t)&&(t=t.replace(/defineConfig\s*\(\s*\{/,e=>`${e}\n integrations: [saltyIntegration()],`),n=!0),n?{content:ne+t}:{content:null,warning:`Could not find a place to add saltyIntegration() in the Astro config. Please add it manually.`}},ie={name:`astro`,detect:e=>N(e.projectDir),plan:async(e,n)=>{let r=await(0,c.readFile)(n,`utf-8`).catch(()=>void 0);if(r===void 0)return null;let i=re(r);if(i.warning&&t.r.warn(i.warning),i.content===null)return null;let a=i.content;return{packages:[`-D ${Q(e.cliVersion)}`],execute:async()=>(t.r.info(`Adding Salty-CSS integration to Astro config: `+n),await(0,c.writeFile)(n,a),await S(n),{changed:!0})}}},ae=[[`projectJs`,`eslint.config.js`],[`rootJs`,`eslint.config.js`],[`projectMjs`,`eslint.config.mjs`],[`rootMjs`,`eslint.config.mjs`],[`projectJson`,`.eslintrc.json`],[`rootJson`,`.eslintrc.json`]],oe=(e,t)=>ae.map(([n,r])=>(0,s.join)(n.startsWith(`root`)?t:e,r)),se=(e,t)=>{if(e.includes(`salty-css`))return{content:null};if(t){let t=`import saltyCss from "@salty-css/eslint-config-core/flat";\n${e}`;if(e.includes(`typescript-eslint`))if(t.includes(`.config(`))t=t.replace(`.config(`,`.config(saltyCss,`);else return{content:null,warning:`Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually.`};else if(t.includes(`export default [`))t=t.replace(`export default [`,`export default [ saltyCss,`);else if(t.includes(`eslintConfig = [`))t=t.replace(`eslintConfig = [`,`eslintConfig = [ saltyCss,`);else return{content:null,warning:`Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually.`};return{content:t}}let n=JSON.parse(e);return n.extends||=[],n.extends.includes(`@salty-css/core`)||n.extends.push(`@salty-css/core`),{content:JSON.stringify(n,null,2)}},ce={name:`eslint`,detect:e=>oe(e.projectDir,e.cwd).find(e=>(0,o.existsSync)(e))??null,plan:async(e,n)=>{let r=await(0,c.readFile)(n,`utf-8`).catch(()=>void 0);if(r===void 0)return t.r.error(`Could not read ESLint config file.`),null;let i=se(r,n.endsWith(`js`));if(i.warning&&t.r.warn(i.warning),i.content===null)return null;let a=i.content;return{packages:[_.eslintConfigCore(e.cliVersion)],execute:async()=>(t.r.info(`Edit file: `+n),await(0,c.writeFile)(n,a),await S(n),{changed:!0})}}},le=[`next.config.js`,`next.config.cjs`,`next.config.ts`,`next.config.mjs`],ue=e=>`@salty-css/next@${e}`,de=e=>{if(e.includes(`withSaltyCss`))return{content:null};let t=e,n=!1;/\splugins([^=]*)=[^[]\[/.test(t)&&(t=t.replace(/\splugins([^=]*)=[^[]\[/,(e,t)=>` plugins${t}= [withSaltyCss,`),n=!0);let r=t.includes(`module.exports`),i=r?`const { withSaltyCss } = require('@salty-css/next');
4
4
  `:`import { withSaltyCss } from '@salty-css/next';
@@ -1,4 +1,4 @@
1
- import { n as e, r as t, t as n } from "./salty-compiler-Cj88Ep29.js";
1
+ import { n as e, r as t, t as n } from "./salty-compiler-CyQpU98T.js";
2
2
  import { isSaltyFile as r } from "./compiler/helpers.js";
3
3
  import { pascalCase as i } from "./util/index.js";
4
4
  import { checkShouldRestart as a } from "./server/index.js";
@@ -177,18 +177,22 @@ var n = (e) => (t) => {
177
177
  return c;
178
178
  }, C = async (e, t = "", i, a = !1) => {
179
179
  if (!e) throw Error("No styles provided to parseStyles function!");
180
- let s = /* @__PURE__ */ new Set(), c = Object.entries(e), h = i?.strict, _ = async ([e, n]) => {
181
- let r = e.trim().replace(/^\?+/g, ""), c = l(r), v = (e, t = ";") => `${c}:${e}${t}`, b = {
180
+ let s = Object.entries(e), c = i?.strict;
181
+ k(s, i, c);
182
+ let h = async ([e, n]) => {
183
+ let r = e.trim().replace(/^\?+/g, ""), s = l(r), _ = [], v = (e) => ({
184
+ value: e,
185
+ nested: _
186
+ }), b = (e, t = ";") => `${s}:${e}${t}`, x = {
182
187
  scope: t,
183
188
  config: i
184
189
  };
185
190
  if (typeof n == "function") try {
186
- return await _([e, n(b)]);
191
+ return await h([e, n(x)]);
187
192
  } catch (e) {
188
- u(h, `Function value for "${r}" threw: ${e?.message ?? e}`);
189
- return;
193
+ return u(c, `Function value for "${r}" threw: ${e?.message ?? e}`), v();
190
194
  }
191
- if (n instanceof Promise) return _([e, await n]);
195
+ if (n instanceof Promise) return h([e, await n]);
192
196
  if (i?.templates && i.templatePaths?.[r]) try {
193
197
  let [e, t] = i.templatePaths[r].split(";;"), a = await import(
194
198
  /* webpackIgnore: true */
@@ -197,14 +201,13 @@ var n = (e) => (t) => {
197
201
  ), o = t.includes("salty.config"), s = o ? a[e].templates : a[e], c = o ? s[r] : s.params[r];
198
202
  if (s && typeof c == "function") {
199
203
  let [e] = await C(await c(n), "");
200
- return e;
204
+ return v(e);
201
205
  }
202
206
  } catch (e) {
203
- console.error(`Error loading template "${r}" from path "${i.templatePaths[r]}"`, e);
204
- return;
207
+ return console.error(`Error loading template "${r}" from path "${i.templatePaths[r]}"`, e), v();
205
208
  }
206
209
  if (i?.templates && i.templates[r]) {
207
- if (a) return;
210
+ if (a) return v();
208
211
  let e = i.templates[r], t = g(n);
209
212
  if (t) {
210
213
  let { path: n, variants: i } = t;
@@ -212,98 +215,68 @@ var n = (e) => (t) => {
212
215
  let t = S(e, n, i, r);
213
216
  if (t) {
214
217
  let [e] = await C(t, "");
215
- return e;
218
+ return v(e);
216
219
  }
217
- console.warn(`Template "${r}" with path of "${n.join(".")}" was not found in config!`);
218
- return;
220
+ return console.warn(`Template "${r}" with path of "${n.join(".")}" was not found in config!`), v();
219
221
  }
220
222
  let a = n.reduce((e, t) => e?.[t], e);
221
223
  if (a) {
222
224
  let [e] = await C(a, "");
223
- return e;
225
+ return v(e);
224
226
  }
225
- console.warn(`Template "${r}" with path of "${n.join(".")}" was not found in config!`);
226
- return;
227
+ return console.warn(`Template "${r}" with path of "${n.join(".")}" was not found in config!`), v();
227
228
  }
228
- console.warn(`Template "${r}" received an unsupported call-site value.`);
229
- return;
229
+ return console.warn(`Template "${r}" received an unsupported call-site value.`), v();
230
230
  }
231
- if (!(r === "compoundVariants" || r === "anyOfVariants") && Array.isArray(n)) return n.length === 0 ? void 0 : _([e, n.join(", ")]);
231
+ if (!(r === "compoundVariants" || r === "anyOfVariants") && Array.isArray(n)) return n.length === 0 ? v() : h([e, n.join(", ")]);
232
232
  if (typeof n == "object") {
233
- if (!n) return;
234
- if (n.isColor || n.isDefineFont) return v(n.toString());
235
- if (r === "defaultVariants") return;
233
+ if (!n) return v();
234
+ if (n.isColor || n.isDefineFont) return v(b(n.toString()));
235
+ if (r === "defaultVariants") return v();
236
236
  if (r === "variants") {
237
237
  let e = Object.entries(n);
238
238
  for (let [n, r] of e) {
239
239
  if (!r) continue;
240
240
  let e = Object.entries(r);
241
- for (let [r, a] of e) a && (await C(a, `${t}.${n}-${r}`, i)).forEach((e) => s.add(e));
241
+ for (let [r, a] of e) a && (await C(a, `${t}.${n}-${r}`, i)).forEach((e) => _.push(e));
242
242
  }
243
- return;
243
+ return v();
244
244
  }
245
245
  if (r === "compoundVariants") {
246
246
  for (let e of n) {
247
247
  let { css: n, ...r } = e;
248
- (await C(n, Object.entries(r).reduce((e, [t, n]) => `${e}.${t}-${n}`, t), i)).forEach((e) => s.add(e));
248
+ (await C(n, Object.entries(r).reduce((e, [t, n]) => `${e}.${t}-${n}`, t), i)).forEach((e) => _.push(e));
249
249
  }
250
- return;
250
+ return v();
251
251
  }
252
252
  if (r === "anyOfVariants") {
253
253
  for (let e of n) {
254
254
  let { css: n, ...r } = e;
255
- (await C(n, `${t}:where(${Object.entries(r).map(([e, t]) => `.${e}-${t}`).join(", ")})`, i)).forEach((e) => s.add(e));
255
+ (await C(n, `${t}:where(${Object.entries(r).map(([e, t]) => `.${e}-${t}`).join(", ")})`, i)).forEach((e) => _.push(e));
256
256
  }
257
- return;
258
- }
259
- if (r === "global") {
260
- (await C(n, "", i)).forEach((e) => s.add(e));
261
- return;
257
+ return v();
262
258
  }
259
+ if (r === "global") return (await C(n, "", i)).forEach((e) => _.push(e)), v();
263
260
  if (r.startsWith("@")) {
264
- p.test(r) && u(h, `At-rule "${r}" is missing its condition (e.g. "@media (min-width: 600px)").`);
261
+ p.test(r) && u(c, `At-rule "${r}" is missing its condition (e.g. "@media (min-width: 600px)").`);
265
262
  let e = m.test(r) ? "" : t, a = `${i?.mediaQueries?.[r] || r} { ${await w(n, e, i)} }`;
266
- s.add(a);
267
- return;
263
+ return _.push(a), v();
268
264
  }
269
- if (Object.keys(n).length === 0) return;
270
- d.test(r) && u(h, `Selector "${r}" looks like a missing-colon typo (did you mean "&:${r.slice(1)}"?).`);
265
+ if (Object.keys(n).length === 0) return v();
266
+ d.test(r) && u(c, `Selector "${r}" looks like a missing-colon typo (did you mean "&:${r.slice(1)}"?).`);
271
267
  let e = D(t, r);
272
- (await C(n, e, i)).forEach((e) => s.add(e));
273
- return;
274
- }
275
- if (r.startsWith("$")) {
276
- u(h, `Property key "${r}" looks like a SCSS variable — Salty does not support those.`);
277
- return;
278
- }
279
- if (r.includes(":")) {
280
- u(h, `Property key "${r}" contains a colon — did you accidentally paste a whole declaration as a key?`);
281
- return;
282
- }
283
- if (n == null) {
284
- u(h, `Property "${r}" has a ${n === void 0 ? "undefined" : "null"} value — skipping.`);
285
- return;
286
- }
287
- if (typeof n == "boolean") {
288
- u(h, `Property "${r}" has a boolean value (${n}) — skipping.`);
289
- return;
290
- }
291
- if (n !== "") {
292
- if (typeof n == "number") {
293
- if (!Number.isFinite(n)) {
294
- u(h, `Property "${r}" has a non-finite numeric value (${n}) — skipping.`);
295
- return;
296
- }
297
- return v(o(c, n, i));
298
- }
299
- if (typeof n != "string") if (n && typeof n == "object" && "toString" in n) n = n.toString();
300
- else {
301
- u(h, `Property "${r}" has an unsupported value type (${typeof n}) — skipping.`);
302
- return;
303
- }
304
- return typeof n == "string" && f.test(n) && u(h, `Property "${r}" value "${n}" contains an unresolved \`\${...}\` — did you forget to interpolate?`), v(n);
268
+ return (await C(n, e, i)).forEach((e) => _.push(e)), v();
305
269
  }
306
- }, v = c.map(_), { modifiers: b } = i || {}, x = [r(), n(b)], T = (await Promise.all(v).then((e) => Promise.all(e.map((e) => x.reduce(async (e, t) => {
270
+ if (r.startsWith("$")) return u(c, `Property key "${r}" looks like a SCSS variable Salty does not support those.`), v();
271
+ if (r.includes(":")) return u(c, `Property key "${r}" contains a colon — did you accidentally paste a whole declaration as a key?`), v();
272
+ if (n == null) return u(c, `Property "${r}" has a ${n === void 0 ? "undefined" : "null"} value — skipping.`), v();
273
+ if (typeof n == "boolean") return u(c, `Property "${r}" has a boolean value (${n}) — skipping.`), v();
274
+ if (n === "") return v();
275
+ if (typeof n == "number") return Number.isFinite(n) ? v(b(o(s, n, i))) : (u(c, `Property "${r}" has a non-finite numeric value (${n}) — skipping.`), v());
276
+ if (typeof n != "string") if (n && typeof n == "object" && "toString" in n) n = n.toString();
277
+ else return u(c, `Property "${r}" has an unsupported value type (${typeof n}) — skipping.`), v();
278
+ return typeof n == "string" && f.test(n) && u(c, `Property "${r}" value "${n}" contains an unresolved \`\${...}\` — did you forget to interpolate?`), v(b(n));
279
+ }, { modifiers: _ } = i || {}, v = [r(), n(_)], b = await Promise.all(s.map(h)), x = await Promise.all(b.map(({ value: e }) => e === void 0 ? Promise.resolve(void 0) : v.reduce(async (e, t) => {
307
280
  let n = await e;
308
281
  if (!n) return n;
309
282
  let r = await t(n);
@@ -311,10 +284,12 @@ var n = (e) => (t) => {
311
284
  let { transformed: i, additionalCss: a } = r, o = "";
312
285
  if (a) for (let e of a) o += await w(e, "");
313
286
  return `${o}${i}`;
314
- }, Promise.resolve(e)))))).filter((e) => e !== void 0).join("\n ");
315
- if (!T.trim()) return Array.from(s);
316
- let E = t ? `${t} {\n\t${T}\n}` : T;
317
- return s.has(E) ? Array.from(s) : [E, ...s];
287
+ }, Promise.resolve(e)))), T = /* @__PURE__ */ new Set();
288
+ for (let { nested: e } of b) for (let t of e) T.add(t);
289
+ let E = x.filter((e) => e !== void 0).join("\n ");
290
+ if (!E.trim()) return Array.from(T);
291
+ let O = t ? `${t} {\n\t${E}\n}` : E;
292
+ return T.has(O) ? Array.from(T) : [O, ...T];
318
293
  }, w = async (e, t, n, r = !1) => (await C(e, t, n, r)).join("\n"), T = (e) => {
319
294
  let t = [], n = 0, r = "";
320
295
  for (let i of e) if (i === "(" || i === "[" ? n++ : (i === ")" || i === "]") && (n = Math.max(0, n - 1)), i === "," && n === 0) {
@@ -331,6 +306,29 @@ var n = (e) => (t) => {
331
306
  let i = [];
332
307
  for (let e of n) for (let t of r) i.push(E(e, t));
333
308
  return i.join(", ");
309
+ }, O = /\((max|min)-width:\s*([\d.]+)(px|r?em)\)/g, k = (e, t, n) => {
310
+ if (!n) return;
311
+ let r = {}, i = {};
312
+ for (let [n, a] of e) {
313
+ let e = n.trim().replace(/^\?+/g, "");
314
+ if (!e.startsWith("@") || typeof a != "object" || !a) continue;
315
+ let o = [...(t?.mediaQueries?.[e] || e).matchAll(O)];
316
+ if (o.length !== 1) continue;
317
+ let [, s, c, l] = o[0], d = parseFloat(c);
318
+ if (s === "max") {
319
+ let t = r[l];
320
+ t && d > t.value && u("warn", `Media query "${e}" (max-width: ${d}${l}) is declared after "${t.key}" (max-width: ${t.value}${l}); wider max-width queries override narrower ones at overlapping widths — order them widest → narrowest.`), (!t || d < t.value) && (r[l] = {
321
+ value: d,
322
+ key: e
323
+ });
324
+ } else {
325
+ let t = i[l];
326
+ t && d < t.value && u("warn", `Media query "${e}" (min-width: ${d}${l}) is declared after "${t.key}" (min-width: ${t.value}${l}); narrower min-width queries are overridden by wider ones at overlapping widths — order them narrowest → widest.`), (!t || d > t.value) && (i[l] = {
327
+ value: d,
328
+ key: e
329
+ });
330
+ }
331
+ }
334
332
  };
335
333
  //#endregion
336
334
  export { u as a, n as c, g as i, C as n, r as o, h as r, i as s, w as t };
@@ -0,0 +1,3 @@
1
+ const e=require("./util/index.cjs"),t=require("./viewport-clamp-CHOyzt37.cjs");var n=e=>t=>{if(typeof t!=`string`||!e)return;let n=t,r=[];return Object.values(e).forEach(e=>{let{pattern:t,transform:i}=e;n=n.replace(t,e=>{let{value:t,css:n}=i(e);return n&&r.push(n),t})}),{transformed:n,additionalCss:r}},r=t=>n=>{if(typeof n==`string`&&/\{[^{}]+\}/g.test(n))return{transformed:n.replace(/\{([^{}]+)\}/g,(...n)=>{let r=e.dashCase(n[1].trim().replaceAll(`.`,`-`));return t&&!t.includes(r)&&console.warn(`Token ${r} might not exist`),r.startsWith(`-`)?`-${r}`:`var(--${r})`})}},i=r(),a=[`top`,`right`,`bottom`,`left`,`min-width`,/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],o=(e,n,r)=>{if(a.some(t=>typeof t==`string`?t===e:t.test(e))){let e=r?.defaultUnit||`px`;if(e.startsWith(`viewport-clamp:`))try{let r=e.split(`:`)[1];return t.t({screenSize:parseInt(r)})(Number(n))}catch(t){throw console.error(t),Error(`Invalid viewport-clamp value: ${e}`)}return`${n}${e}`}return`${n}`},s=[`Webkit`,`Moz`,`ms`,`O`],c=e=>s.some(t=>{if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n>=`A`&&n<=`Z`}),l=t=>t.startsWith(`-`)?t:c(t)?`-${e.dashCase(t)}`:e.dashCase(t),u=(e,t)=>{if(e===!0)throw Error(`[salty-css] ${t}`);e===`warn`&&console.warn(`[salty-css] ${t}`)},d=/^&(hover|focus(-(visible|within))?|active|visited|checked|disabled|enabled|empty|target|first-child|last-child|first-of-type|last-of-type|placeholder|placeholder-shown|root)\b/,f=/\$\{[^}]+\}/,p=/^@(media|supports|container|layer)\s*$/,m=/^@(?:-(?:webkit|moz|o|ms)-)?keyframes\b/,h=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=Object.keys(e);return t.includes(`base`)||t.includes(`variants`)},g=e=>{if(typeof e==`string`){let[t,n]=e.split(`@`,2),r=t.split(`.`).filter(Boolean);if(!r.length)return;let i={};if(n)for(let e of n.split(`&`)){if(!e)continue;let t=e.indexOf(`=`);if(t===-1)i[e.trim()]=!0;else{let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();if(!n)continue;r===`true`?i[n]=!0:r===`false`?i[n]=!1:i[n]=r}}return{path:r,variants:i}}if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e,n=t.name;if(typeof n!=`string`)return;let r=n.split(`.`).filter(Boolean);if(!r.length)return;let i={};for(let[e,n]of Object.entries(t))e!==`name`&&(typeof n==`string`||typeof n==`boolean`)&&(i[e]=n);return{path:r,variants:i}}},_=e=>{if(e!==void 0)return typeof e==`boolean`?String(e):e},v=(e,t)=>{let n=[{node:e,isRich:h(e)}],r=e;for(let e of t){if(typeof r!=`object`||!r)return;let t=r[e];if(t===void 0)return;n.push({node:t,isRich:h(t)}),r=t}return n},y=(e,t)=>{let n=v(e,t);return n?n.some(e=>e.isRich):!1},b=(e,t)=>{for(let[n,r]of Object.entries(e))if(n!==`css`&&t[n]!==_(r))return!1;return!0},x=(e,t)=>{let n=!1;for(let[r,i]of Object.entries(e))if(r!==`css`&&(n=!0,t[r]===_(i)))return!0;return!n},S=(e,t,n,r)=>{let i=v(e,t);if(!i)return;let a=i.map(e=>e.isRich?e.node:e.node&&typeof e.node==`object`&&!Array.isArray(e.node)?Object.keys(e.node).every(t=>e.node[t]&&typeof e.node[t]==`object`&&!h(e.node[t]))?{}:{base:e.node}:{}),o=new Set;for(let e of a)if(e.variants)for(let t of Object.keys(e.variants))o.add(t);for(let e of a)if(e.defaultVariants)for(let t of Object.keys(e.defaultVariants))o.add(t);let s={};for(let e of o){if(e in n){s[e]=_(n[e]);continue}for(let t=a.length-1;t>=0;t--){let n=a[t].defaultVariants?.[e];if(n!==void 0){s[e]=_(n);break}}}for(let[e,i]of Object.entries(n)){if(!o.has(e)){console.warn(`Template "${r}" path "${t.join(`.`)}" has no variant axis "${e}"; ignored.`);continue}let n=_(i),s=!1;for(let t of a)if(t.variants?.[e]&&n!==void 0&&n in t.variants[e]){s=!0;break}!s&&n!==void 0&&a.some(t=>t.variants&&e in t.variants)&&console.warn(`Template "${r}" axis "${e}" has no value "${n}" on path "${t.join(`.`)}"; ignored.`)}let c={};for(let e of a)e.base&&Object.assign(c,e.base);for(let e of Object.keys(s)){let t=s[e];if(t!==void 0)for(let n=a.length-1;n>=0;n--){let r=a[n].variants?.[e]?.[t];if(r){Object.assign(c,r);break}}}for(let e of a){if(e.compoundVariants)for(let t of e.compoundVariants)b(t,s)&&t.css&&Object.assign(c,t.css);if(e.anyOfVariants)for(let t of e.anyOfVariants)x(t,s)&&t.css&&Object.assign(c,t.css)}return c},C=async(e,t=``,i,a=!1)=>{if(!e)throw Error(`No styles provided to parseStyles function!`);let s=Object.entries(e),c=i?.strict;k(s,i,c);let h=async([e,n])=>{let r=e.trim().replace(/^\?+/g,``),s=l(r),_=[],v=e=>({value:e,nested:_}),b=(e,t=`;`)=>`${s}:${e}${t}`,x={scope:t,config:i};if(typeof n==`function`)try{return await h([e,n(x)])}catch(e){return u(c,`Function value for "${r}" threw: ${e?.message??e}`),v()}if(n instanceof Promise)return h([e,await n]);if(i?.templates&&i.templatePaths?.[r])try{let[e,t]=i.templatePaths[r].split(`;;`),a=await import(t),o=t.includes(`salty.config`),s=o?a[e].templates:a[e],c=o?s[r]:s.params[r];if(s&&typeof c==`function`){let[e]=await C(await c(n),``);return v(e)}}catch(e){return console.error(`Error loading template "${r}" from path "${i.templatePaths[r]}"`,e),v()}if(i?.templates&&i.templates[r]){if(a)return v();let e=i.templates[r],t=g(n);if(t){let{path:n,variants:i}=t;if(Object.keys(i).length>0||y(e,n)){let t=S(e,n,i,r);if(t){let[e]=await C(t,``);return v(e)}return console.warn(`Template "${r}" with path of "${n.join(`.`)}" was not found in config!`),v()}let a=n.reduce((e,t)=>e?.[t],e);if(a){let[e]=await C(a,``);return v(e)}return console.warn(`Template "${r}" with path of "${n.join(`.`)}" was not found in config!`),v()}return console.warn(`Template "${r}" received an unsupported call-site value.`),v()}if(!(r===`compoundVariants`||r===`anyOfVariants`)&&Array.isArray(n))return n.length===0?v():h([e,n.join(`, `)]);if(typeof n==`object`){if(!n)return v();if(n.isColor||n.isDefineFont)return v(b(n.toString()));if(r===`defaultVariants`)return v();if(r===`variants`){let e=Object.entries(n);for(let[n,r]of e){if(!r)continue;let e=Object.entries(r);for(let[r,a]of e)a&&(await C(a,`${t}.${n}-${r}`,i)).forEach(e=>_.push(e))}return v()}if(r===`compoundVariants`){for(let e of n){let{css:n,...r}=e;(await C(n,Object.entries(r).reduce((e,[t,n])=>`${e}.${t}-${n}`,t),i)).forEach(e=>_.push(e))}return v()}if(r===`anyOfVariants`){for(let e of n){let{css:n,...r}=e;(await C(n,`${t}:where(${Object.entries(r).map(([e,t])=>`.${e}-${t}`).join(`, `)})`,i)).forEach(e=>_.push(e))}return v()}if(r===`global`)return(await C(n,``,i)).forEach(e=>_.push(e)),v();if(r.startsWith(`@`)){p.test(r)&&u(c,`At-rule "${r}" is missing its condition (e.g. "@media (min-width: 600px)").`);let e=m.test(r)?``:t,a=`${i?.mediaQueries?.[r]||r} { ${await w(n,e,i)} }`;return _.push(a),v()}if(Object.keys(n).length===0)return v();d.test(r)&&u(c,`Selector "${r}" looks like a missing-colon typo (did you mean "&:${r.slice(1)}"?).`);let e=D(t,r);return(await C(n,e,i)).forEach(e=>_.push(e)),v()}if(r.startsWith(`$`))return u(c,`Property key "${r}" looks like a SCSS variable — Salty does not support those.`),v();if(r.includes(`:`))return u(c,`Property key "${r}" contains a colon — did you accidentally paste a whole declaration as a key?`),v();if(n==null)return u(c,`Property "${r}" has a ${n===void 0?`undefined`:`null`} value — skipping.`),v();if(typeof n==`boolean`)return u(c,`Property "${r}" has a boolean value (${n}) — skipping.`),v();if(n===``)return v();if(typeof n==`number`)return Number.isFinite(n)?v(b(o(s,n,i))):(u(c,`Property "${r}" has a non-finite numeric value (${n}) — skipping.`),v());if(typeof n!=`string`)if(n&&typeof n==`object`&&`toString`in n)n=n.toString();else return u(c,`Property "${r}" has an unsupported value type (${typeof n}) — skipping.`),v();return typeof n==`string`&&f.test(n)&&u(c,`Property "${r}" value "${n}" contains an unresolved \`\${...}\` — did you forget to interpolate?`),v(b(n))},{modifiers:_}=i||{},v=[r(),n(_)],b=await Promise.all(s.map(h)),x=await Promise.all(b.map(({value:e})=>e===void 0?Promise.resolve(void 0):v.reduce(async(e,t)=>{let n=await e;if(!n)return n;let r=await t(n);if(!r)return n;let{transformed:i,additionalCss:a}=r,o=``;if(a)for(let e of a)o+=await w(e,``);return`${o}${i}`},Promise.resolve(e)))),T=new Set;for(let{nested:e}of b)for(let t of e)T.add(t);let E=x.filter(e=>e!==void 0).join(`
2
+ `);if(!E.trim())return Array.from(T);let O=t?`${t} {\n\t${E}\n}`:E;return T.has(O)?Array.from(T):[O,...T]},w=async(e,t,n,r=!1)=>(await C(e,t,n,r)).join(`
3
+ `),T=e=>{let t=[],n=0,r=``;for(let i of e)if(i===`(`||i===`[`?n++:(i===`)`||i===`]`)&&(n=Math.max(0,n-1)),i===`,`&&n===0){let e=r.trim();e&&t.push(e),r=``}else r+=i;let i=r.trim();return i&&t.push(i),t},E=(e,t)=>t.includes(`&`)?t.replaceAll(`&`,e):t.startsWith(`:`)?`${e}${t}`:`${e} ${t}`,D=(e,t)=>{if(!e)return t;let n=T(e),r=T(t);if(!r.length)return e;if(n.length<=1&&r.length<=1)return E(n[0]??e,r[0]);let i=[];for(let e of n)for(let t of r)i.push(E(e,t));return i.join(`, `)},O=/\((max|min)-width:\s*([\d.]+)(px|r?em)\)/g,k=(e,t,n)=>{if(!n)return;let r={},i={};for(let[n,a]of e){let e=n.trim().replace(/^\?+/g,``);if(!e.startsWith(`@`)||typeof a!=`object`||!a)continue;let o=[...(t?.mediaQueries?.[e]||e).matchAll(O)];if(o.length!==1)continue;let[,s,c,l]=o[0],d=parseFloat(c);if(s===`max`){let t=r[l];t&&d>t.value&&u(`warn`,`Media query "${e}" (max-width: ${d}${l}) is declared after "${t.key}" (max-width: ${t.value}${l}); wider max-width queries override narrower ones at overlapping widths — order them widest → narrowest.`),(!t||d<t.value)&&(r[l]={value:d,key:e})}else{let t=i[l];t&&d<t.value&&u(`warn`,`Media query "${e}" (min-width: ${d}${l}) is declared after "${t.key}" (min-width: ${t.value}${l}); narrower min-width queries are overridden by wider ones at overlapping widths — order them narrowest → widest.`),(!t||d>t.value)&&(i[l]={value:d,key:e})}}};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return w}});
@@ -1,3 +1,3 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../util/index.cjs"),t=require("../parse-styles-2rwbF9j_.cjs");var n=new Set([`base`,`variants`,`defaultVariants`,`compoundVariants`,`anyOfVariants`]),r=(e,t)=>n.has(e)?!1:!!t&&typeof t==`object`&&!Array.isArray(t),i=async(n,a=[])=>{if(!n)return``;let o=[];if(t.r(n)){let s=n,c=a.map(t=>e.dashCase(String(t))).join(`-`);if(s.base){let n=`t_`+e.toHash(c,4),r=await t.t(s.base,`.${c}, .${n}`);o.push(r)}if(s.variants){for(let[n,r]of Object.entries(s.variants))if(!(!r||typeof r!=`object`))for(let[i,a]of Object.entries(r)){if(!a||typeof a!=`object`)continue;let r=`${c}-${e.dashCase(n)}-${e.dashCase(i)}`,s=await t.t(a,`.${r}, .${`tv_`+e.toHash(r,4)}`);o.push(s)}}for(let[e,t]of Object.entries(s)){if(!r(e,t))continue;let n=await i(t,[...a,e.trim()]);o.push(n)}return o.join(`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../util/index.cjs"),t=require("../parse-styles-PndoToaP.cjs");var n=new Set([`base`,`variants`,`defaultVariants`,`compoundVariants`,`anyOfVariants`]),r=(e,t)=>n.has(e)?!1:!!t&&typeof t==`object`&&!Array.isArray(t),i=async(n,a=[])=>{if(!n)return``;let o=[];if(t.r(n)){let s=n,c=a.map(t=>e.dashCase(String(t))).join(`-`);if(s.base){let n=`t_`+e.toHash(c,4),r=await t.t(s.base,`.${c}, .${n}`);o.push(r)}if(s.variants){for(let[n,r]of Object.entries(s.variants))if(!(!r||typeof r!=`object`))for(let[i,a]of Object.entries(r)){if(!a||typeof a!=`object`)continue;let r=`${c}-${e.dashCase(n)}-${e.dashCase(i)}`,s=await t.t(a,`.${r}, .${`tv_`+e.toHash(r,4)}`);o.push(s)}}for(let[e,t]of Object.entries(s)){if(!r(e,t))continue;let n=await i(t,[...a,e.trim()]);o.push(n)}return o.join(`
2
2
  `)}let s={};for(let[e,t]of Object.entries(n))if(typeof t!=`function`)if(t&&typeof t==`object`){let n=e.trim(),r=await i(t,[...a,n]);o.push(r)}else s[e]=t;if(Object.keys(s).length){let n=a.map(t=>e.dashCase(String(t))).join(`-`),r=await t.t(s,`.${n}, .${`t_`+e.toHash(n,4)}`);o.push(r)}return o.join(`
3
3
  `)},a=e=>Object.keys(e),o=e=>e?Object.entries(e).reduce((e,[t,n])=>(typeof n==`function`?e[t]=`any`:typeof n==`object`&&(e[t]=s(n).map(e=>`"${e}"`).join(` | `)),e),{}):{},s=(e,n=``,i=new Set)=>e?t.r(e)?(n&&i.add(n),Object.entries(e).forEach(([e,t])=>{r(e,t)&&s(t,n?`${n}.${e}`:e,i)}),[...i]):(Object.entries(e).forEach(([e,t])=>{let r=n?`${n}.${e}`:e;return t&&typeof t==`object`?s(t,r,i):i.add(n)}),[...i]):[],c=e=>{let t={};if(!e)return t;for(let[n,r]of Object.entries(e))!r||typeof r!=`object`||typeof r==`function`||u(r,[],t[n]||(t[n]={}),{});return t},l=(e,n)=>{let r={};for(let[t,n]of Object.entries(e))r[t]={...n};if(t.r(n)&&n.variants)for(let[e,t]of Object.entries(n.variants)){r[e]=r[e]||{};for(let n of Object.keys(t))r[e][n]=!0}return r},u=(e,n,i,a)=>{if(!e||typeof e!=`object`||Array.isArray(e))return;let o=l(a,e),s=n.join(`.`);if(n.length&&(t.r(e)||Object.keys(o).length)){let e={};for(let[t,n]of Object.entries(o)){let r=Object.keys(n);e[t]=r.length===1&&r[0]===`true`?`boolean`:r.map(e=>`"${e}"`).join(` | `)}Object.keys(e).length&&(i[s]=e)}if(t.r(e)){for(let[t,a]of Object.entries(e))r(t,a)&&u(a,[...n,t.trim()],i,o);return}for(let[t,r]of Object.entries(e))!r||typeof r!=`object`||Array.isArray(r)||u(r,[...n,t.trim()],i,o)};exports.getTemplateKeys=a,exports.getTemplateTokens=s,exports.getTemplateTypes=o,exports.getTemplateVariantMaps=c,exports.parseAndJoinStyles=t.t,exports.parseStyles=t.n,exports.parseTemplates=i,exports.parseValueModifiers=t.c,exports.parseValueTokens=t.o,exports.parseVariableTokens=t.s,exports.reportParserIssue=t.a;
@@ -1,5 +1,5 @@
1
1
  import { dashCase as e, toHash as t } from "../util/index.js";
2
- import { a as n, c as r, n as i, o as a, r as o, s, t as c } from "../parse-styles-Bz0otiZ-.js";
2
+ import { a as n, c as r, n as i, o as a, r as o, s, t as c } from "../parse-styles-B5QRCMas.js";
3
3
  //#region src/parsers/parse-templates.ts
4
4
  var l = new Set([
5
5
  "base",
@@ -1 +1 @@
1
- {"version":3,"file":"parse-styles.d.ts","sourceRoot":"","sources":["../../src/parsers/parse-styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAWlE;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,GAAU,CAAC,SAAS,MAAM,EAChD,SAAS,CAAC,EACV,qBAAiB,EACjB,SAAS,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC,GAAG,YAAY,GAAG,SAAS,EACvE,uBAAqB,KACpB,OAAO,CAAC,MAAM,EAAE,CAoPlB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAU,CAAC,SAAS,MAAM,EACvD,QAAQ,CAAC,EACT,cAAc,MAAM,EACpB,SAAS,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC,GAAG,SAAS,EACxD,uBAAqB,KACpB,OAAO,CAAC,MAAM,CAGhB,CAAC"}
1
+ {"version":3,"file":"parse-styles.d.ts","sourceRoot":"","sources":["../../src/parsers/parse-styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAWlE;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,GAAU,CAAC,SAAS,MAAM,EAChD,SAAS,CAAC,EACV,qBAAiB,EACjB,SAAS,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC,GAAG,YAAY,GAAG,SAAS,EACvE,uBAAqB,KACpB,OAAO,CAAC,MAAM,EAAE,CAsQlB,CAAC;AAOF,eAAO,MAAM,kBAAkB,GAAU,CAAC,SAAS,MAAM,EACvD,QAAQ,CAAC,EACT,cAAc,MAAM,EACpB,SAAS,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC,GAAG,SAAS,EACxD,uBAAqB,KACpB,OAAO,CAAC,MAAM,CAGhB,CAAC"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../util/index.cjs"),t=require("../parse-styles-2rwbF9j_.cjs");var n=n=>{let r=t=>e.toHash(t),i=async(e,r)=>(await t.n(e,r,n)).join(`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../util/index.cjs"),t=require("../parse-styles-PndoToaP.cjs");var n=n=>{let r=t=>e.toHash(t),i=async(e,r)=>(await t.n(e,r,n)).join(`
2
2
  `);return{className:r,css:i,resolve:async(e,t)=>{let n=r(e);return{className:n,css:await i(e,t||`.${n}`)}},getDynamicStylesCss:i}};exports.defineRuntime=n;
@@ -1,5 +1,5 @@
1
1
  import { toHash as e } from "../util/index.js";
2
- import { n as t } from "../parse-styles-Bz0otiZ-.js";
2
+ import { n as t } from "../parse-styles-B5QRCMas.js";
3
3
  //#region src/runtime/index.ts
4
4
  var n = (n) => {
5
5
  let r = (t) => e(t), i = async (e, r) => (await t(e, r, n)).join("\n");
@@ -1,4 +1,4 @@
1
- const e=require("./chunk-CMqjfN_6.cjs"),t=require("./compiler/helpers.cjs"),n=require("./util/index.cjs"),r=require("./factories/index.cjs"),i=require("./parse-styles-2rwbF9j_.cjs"),a=require("./css/merge.cjs"),o=require("./compiler/get-files.cjs"),s=require("./parsers/index.cjs");let c=require("fs"),l=require("esbuild");l=e.t(l,1);let u=require("path"),d=require("winston"),f=require("fs/promises"),p=require("child_process"),m=require("module");var h=(0,d.createLogger)({level:`debug`,format:d.format.combine(d.format.colorize(),d.format.cli()),transports:[new d.transports.Console({})]}),g=e=>{h.error(e)},_=/^(?:[a-z][a-z0-9+.-]*:)?\/\//i,v=e=>typeof e==`string`?{url:e}:e,y=e=>e.startsWith(`.`)||e.startsWith(`/`)?e:`./${e}`,b=e=>e.split(`\\`).join(`/`),x=(e,t)=>(0,m.createRequire)(t).resolve(e),S=(e,t)=>{let n=(0,u.dirname)(t);(0,c.existsSync)(n)||(0,c.mkdirSync)(n,{recursive:!0}),(0,c.copyFileSync)(e,t)},C=(e,{media:t,supports:n})=>{let r=`@import url('${e}')`;return n&&(r+=` supports(${n})`),t&&(r+=` ${t}`),`${r};`},w=(e,t,r,i={})=>{let a=v(e),{url:o}=a,s=i.resolveModule??x,c=i.copyAsset??S;if(_.test(o)||o.startsWith(`/`))return{rule:C(o,a)};if(o.startsWith(`./`)||o.startsWith(`../`)){let e=(0,u.resolve)((0,u.dirname)(t),o);return{rule:C(y(b((0,u.relative)((0,u.join)(r,`css`),e))),a)}}let l=s(o.startsWith(`~`)?o.slice(1):o,t),d=`${n.toHash(l,6)}-${(0,u.basename)(l)}`;return c(l,(0,u.join)(r,`imports`,d)),{rule:C(`../imports/${d}`,a)}},T=async e=>{let t=await o.getPackageJson(e);if(t)return t.type},E,D=async e=>{if(E)return E;let t=await T(e);return t===`module`?E=`esm`:(t===`commonjs`||{}.url.endsWith(`.cjs`))&&(E=`cjs`),E||`esm`};function O(e){return e?typeof e==`string`?e.replace(/[^\d\w]/g,`.`):O(String(e)):``}var k={"*, *::before, *::after":{boxSizing:`border-box`},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:`100%`,WebkitFontSmoothing:`antialiased`},"img, picture, video, canvas, svg":{display:`block`,maxWidth:`100%`},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:`break-word`},p:{textWrap:`pretty`},"h1, h2, h3, h4, h5, h6":{textWrap:`balance`},a:{color:`currentColor`},button:{lineHeight:`1em`,color:`currentColor`},"input, optgroup, select, textarea":{fontFamily:`inherit`,fontSize:`100%`,lineHeight:`1.15em`}},A=class{projectRootDir;options;importFile=e=>import(`${e}?t=${Date.now()}`);cache={rcFile:null,destDir:null,externalModules:[]};constructor(e,t={}){if(this.projectRootDir=e,this.options=t,typeof process>`u`)throw Error(`SaltyServer can only be used in a Node.js environment.`)}get isProduction(){if(this.options.mode)return this.options.mode===`production`;try{return process.env.NODE_ENV!==`development`}catch{return!1}}readRCFile=async(e=this.projectRootDir)=>{if(this.cache.rcFile)return this.cache.rcFile;if(e===`/`)throw Error(`Could not find .saltyrc.json file`);let t=await(0,f.readFile)((0,u.join)(e,`.saltyrc.json`),`utf-8`).then(JSON.parse).catch(()=>void 0);return t?(this.cache.rcFile=t,t):this.readRCFile((0,u.join)(e,`..`))};getRCProjectConfig=async e=>{let t=await this.readRCFile(e);return t.projects?.find(t=>e.endsWith(t.dir||``))||t.projects?.find(e=>e.dir===t.defaultProject)};getPathFilter=async()=>{let e=await this.getRCProjectConfig(this.projectRootDir);return{include:e?.include,exclude:e?.exclude}};isAllowedSaltyFile=(e,r)=>t.isSaltyFile(e)?n.isPathAllowed(n.normalizePath((0,u.relative)(this.projectRootDir,e)),r):!1;getExternalModules=e=>{if(this.cache.externalModules.length>0)return this.cache.externalModules;let t=(0,c.readFileSync)(e,`utf8`).match(/externalModules:\s?\[(.*)\]/);if(!t)return[];let n=t[1].split(`,`).map(e=>e.replace(/['"`]/g,``).trim());return this.cache.externalModules=n,n};getDestDir=async()=>{if(this.cache.destDir)return this.cache.destDir;let e=await this.getRCProjectConfig(this.projectRootDir),t=(0,u.join)(this.projectRootDir,e?.saltygenDir||`saltygen`);return this.cache.destDir=t,t};generateConfig=async()=>{let e=await this.getRCProjectConfig(this.projectRootDir),t=await this.getDestDir(),n=(0,u.join)(this.projectRootDir,e?.configDir||``,`salty.config.ts`),r=(0,u.join)(t,`salty.config.js`),i=await D(this.projectRootDir),a=this.getExternalModules(n);await l.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:i,external:a});let{config:o}=await this.importFile(r);return{config:o,path:r}};addConfigCache=e=>{try{let t=(0,c.readFileSync)((0,u.join)(this.projectRootDir,`saltygen/cache/config-cache.json`),`utf8`);return t?`globalThis.saltyConfig = ${t};\n\n${e}`:`globalThis.saltyConfig = {};\n\n${e}`}catch{return e}};getConfigCache=async()=>{let e=(0,c.readFileSync)((0,u.join)(await this.getDestDir(),`cache/config-cache.json`),`utf8`);if(!e)throw Error(`Could not find config cache file`);return JSON.parse(e)};getConfig=async()=>{let e=await this.getConfigCache(),t=(0,u.join)(await this.getDestDir(),`salty.config.js`),{config:n}=await this.importFile(t);return a.mergeObjects(n,e)};generateCss=async(e=!0)=>{try{let r=Date.now();this.isProduction?h.info(`Generating CSS in production mode! 🔥`):h.info(`Generating CSS in development mode! 🚀`);let i=[],a=[],o=await this.getDestDir(),s=(0,u.join)(o,`index.css`);e&&((0,c.existsSync)(o)&&(0,p.execSync)(`rm -rf `+o),(0,c.mkdirSync)(o,{recursive:!0}),(0,c.mkdirSync)((0,u.join)(o,`css`)),(0,c.mkdirSync)((0,u.join)(o,`types`)),(0,c.mkdirSync)((0,u.join)(o,`js`)),(0,c.mkdirSync)((0,u.join)(o,`cache`)),(0,c.mkdirSync)((0,u.join)(o,`imports`)));let l=new Set,d=new Set,f=await this.getPathFilter(),{exclude:m}=f,g=this.projectRootDir;async function _(e){let r=[`node_modules`,`saltygen`],i=(0,c.statSync)(e);if(i.isDirectory()){if(r.some(t=>e.includes(t)))return;if(m?.length){let t=n.normalizePath((0,u.relative)(g,e));if(t&&!n.isPathAllowed(t,{exclude:m}))return}let t=(0,c.readdirSync)(e);await Promise.all(t.map(t=>_((0,u.join)(e,t))))}else if(i.isFile()&&t.isSaltyFile(e)&&n.isPathAllowed(n.normalizePath((0,u.relative)(g,e)),f)){l.add(e);let t=(0,c.readFileSync)(e,`utf8`);/define[\w\d]+\(/.test(t)&&d.add(e)}}await _(this.projectRootDir),await this.generateConfigStyles(d);let v={keyframes:[],components:[],classNames:[]};await Promise.all([...l].map(async e=>{let{contents:n}=await this.compileSaltyFile(e,o);for(let[r,i]of Object.entries(n)){let n=await t.resolveExportValue(i,1);n.isKeyframes?v.keyframes.push({value:n,src:e,name:r}):n.isClassName?v.classNames.push({...i,src:e,name:r}):n.generator&&v.components.push({...i,src:e,name:r})}}));let y=await this.getConfig();for(let e of v.keyframes){let{value:t}=e,n=`a_${t.animationName}.css`,r=(0,u.join)(o,`css/${n}`);i.push(n),(0,c.writeFileSync)(r,t.css)}let b={};for(let e of v.components){let{src:t,name:n}=e;b[t]||(b[t]=[]);let r=e.generator._withBuildContext({callerName:n,isProduction:this.isProduction,config:y});a[r.priority]||(a[r.priority]=[]);let i=await r.css;i&&(a[r.priority].push(r.cssFileName),(0,c.writeFileSync)((0,u.join)(o,`css/${r.cssFileName}`),i),y.importStrategy===`component`&&b[t].push(r.cssFileName))}for(let e of v.classNames){let{src:t,name:n}=e;b[t]||(b[t]=[]);let r=e.generator._withBuildContext({callerName:n,isProduction:this.isProduction,config:y}),i=await r.css;i&&(a[r.priority]||(a[r.priority]=[]),a[r.priority].push(r.cssFileName),(0,c.writeFileSync)((0,u.join)(o,`css/${r.cssFileName}`),i),y.importStrategy===`component`&&b[t].push(r.cssFileName))}y.importStrategy===`component`&&Object.entries(b).forEach(([e,t])=>{let r=t.map(e=>`@import url('./${e}');`).join(`
1
+ const e=require("./chunk-CMqjfN_6.cjs"),t=require("./compiler/helpers.cjs"),n=require("./util/index.cjs"),r=require("./factories/index.cjs"),i=require("./parse-styles-PndoToaP.cjs"),a=require("./css/merge.cjs"),o=require("./compiler/get-files.cjs"),s=require("./parsers/index.cjs");let c=require("fs"),l=require("esbuild");l=e.t(l,1);let u=require("path"),d=require("winston"),f=require("fs/promises"),p=require("child_process"),m=require("module");var h=(0,d.createLogger)({level:`debug`,format:d.format.combine(d.format.colorize(),d.format.cli()),transports:[new d.transports.Console({})]}),g=e=>{h.error(e)},_=/^(?:[a-z][a-z0-9+.-]*:)?\/\//i,v=e=>typeof e==`string`?{url:e}:e,y=e=>e.startsWith(`.`)||e.startsWith(`/`)?e:`./${e}`,b=e=>e.split(`\\`).join(`/`),x=(e,t)=>(0,m.createRequire)(t).resolve(e),S=(e,t)=>{let n=(0,u.dirname)(t);(0,c.existsSync)(n)||(0,c.mkdirSync)(n,{recursive:!0}),(0,c.copyFileSync)(e,t)},C=(e,{media:t,supports:n})=>{let r=`@import url('${e}')`;return n&&(r+=` supports(${n})`),t&&(r+=` ${t}`),`${r};`},w=(e,t,r,i={})=>{let a=v(e),{url:o}=a,s=i.resolveModule??x,c=i.copyAsset??S;if(_.test(o)||o.startsWith(`/`))return{rule:C(o,a)};if(o.startsWith(`./`)||o.startsWith(`../`)){let e=(0,u.resolve)((0,u.dirname)(t),o);return{rule:C(y(b((0,u.relative)((0,u.join)(r,`css`),e))),a)}}let l=s(o.startsWith(`~`)?o.slice(1):o,t),d=`${n.toHash(l,6)}-${(0,u.basename)(l)}`;return c(l,(0,u.join)(r,`imports`,d)),{rule:C(`../imports/${d}`,a)}},T=async e=>{let t=await o.getPackageJson(e);if(t)return t.type},E,D=async e=>{if(E)return E;let t=await T(e);return t===`module`?E=`esm`:(t===`commonjs`||{}.url.endsWith(`.cjs`))&&(E=`cjs`),E||`esm`};function O(e){return e?typeof e==`string`?e.replace(/[^\d\w]/g,`.`):O(String(e)):``}var k={"*, *::before, *::after":{boxSizing:`border-box`},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:`100%`,WebkitFontSmoothing:`antialiased`},"img, picture, video, canvas, svg":{display:`block`,maxWidth:`100%`},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:`break-word`},p:{textWrap:`pretty`},"h1, h2, h3, h4, h5, h6":{textWrap:`balance`},a:{color:`currentColor`},button:{lineHeight:`1em`,color:`currentColor`},"input, optgroup, select, textarea":{fontFamily:`inherit`,fontSize:`100%`,lineHeight:`1.15em`}},A=class{projectRootDir;options;importFile=e=>import(`${e}?t=${Date.now()}`);cache={rcFile:null,destDir:null,externalModules:[]};constructor(e,t={}){if(this.projectRootDir=e,this.options=t,typeof process>`u`)throw Error(`SaltyServer can only be used in a Node.js environment.`)}get isProduction(){if(this.options.mode)return this.options.mode===`production`;try{return process.env.NODE_ENV!==`development`}catch{return!1}}readRCFile=async(e=this.projectRootDir)=>{if(this.cache.rcFile)return this.cache.rcFile;if(e===`/`)throw Error(`Could not find .saltyrc.json file`);let t=await(0,f.readFile)((0,u.join)(e,`.saltyrc.json`),`utf-8`).then(JSON.parse).catch(()=>void 0);return t?(this.cache.rcFile=t,t):this.readRCFile((0,u.join)(e,`..`))};getRCProjectConfig=async e=>{let t=await this.readRCFile(e);return t.projects?.find(t=>e.endsWith(t.dir||``))||t.projects?.find(e=>e.dir===t.defaultProject)};getPathFilter=async()=>{let e=await this.getRCProjectConfig(this.projectRootDir);return{include:e?.include,exclude:e?.exclude}};isAllowedSaltyFile=(e,r)=>t.isSaltyFile(e)?n.isPathAllowed(n.normalizePath((0,u.relative)(this.projectRootDir,e)),r):!1;getExternalModules=e=>{if(this.cache.externalModules.length>0)return this.cache.externalModules;let t=(0,c.readFileSync)(e,`utf8`).match(/externalModules:\s?\[(.*)\]/);if(!t)return[];let n=t[1].split(`,`).map(e=>e.replace(/['"`]/g,``).trim());return this.cache.externalModules=n,n};getDestDir=async()=>{if(this.cache.destDir)return this.cache.destDir;let e=await this.getRCProjectConfig(this.projectRootDir),t=(0,u.join)(this.projectRootDir,e?.saltygenDir||`saltygen`);return this.cache.destDir=t,t};generateConfig=async()=>{let e=await this.getRCProjectConfig(this.projectRootDir),t=await this.getDestDir(),n=(0,u.join)(this.projectRootDir,e?.configDir||``,`salty.config.ts`),r=(0,u.join)(t,`salty.config.js`),i=await D(this.projectRootDir),a=this.getExternalModules(n);await l.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:i,external:a});let{config:o}=await this.importFile(r);return{config:o,path:r}};addConfigCache=e=>{try{let t=(0,c.readFileSync)((0,u.join)(this.projectRootDir,`saltygen/cache/config-cache.json`),`utf8`);return t?`globalThis.saltyConfig = ${t};\n\n${e}`:`globalThis.saltyConfig = {};\n\n${e}`}catch{return e}};getConfigCache=async()=>{let e=(0,c.readFileSync)((0,u.join)(await this.getDestDir(),`cache/config-cache.json`),`utf8`);if(!e)throw Error(`Could not find config cache file`);return JSON.parse(e)};getConfig=async()=>{let e=await this.getConfigCache(),t=(0,u.join)(await this.getDestDir(),`salty.config.js`),{config:n}=await this.importFile(t);return a.mergeObjects(n,e)};generateCss=async(e=!0)=>{try{let r=Date.now();this.isProduction?h.info(`Generating CSS in production mode! 🔥`):h.info(`Generating CSS in development mode! 🚀`);let i=[],a=[],o=await this.getDestDir(),s=(0,u.join)(o,`index.css`);e&&((0,c.existsSync)(o)&&(0,p.execSync)(`rm -rf `+o),(0,c.mkdirSync)(o,{recursive:!0}),(0,c.mkdirSync)((0,u.join)(o,`css`)),(0,c.mkdirSync)((0,u.join)(o,`types`)),(0,c.mkdirSync)((0,u.join)(o,`js`)),(0,c.mkdirSync)((0,u.join)(o,`cache`)),(0,c.mkdirSync)((0,u.join)(o,`imports`)));let l=new Set,d=new Set,f=await this.getPathFilter(),{exclude:m}=f,g=this.projectRootDir;async function _(e){let r=[`node_modules`,`saltygen`],i=(0,c.statSync)(e);if(i.isDirectory()){if(r.some(t=>e.includes(t)))return;if(m?.length){let t=n.normalizePath((0,u.relative)(g,e));if(t&&!n.isPathAllowed(t,{exclude:m}))return}let t=(0,c.readdirSync)(e);await Promise.all(t.map(t=>_((0,u.join)(e,t))))}else if(i.isFile()&&t.isSaltyFile(e)&&n.isPathAllowed(n.normalizePath((0,u.relative)(g,e)),f)){l.add(e);let t=(0,c.readFileSync)(e,`utf8`);/define[\w\d]+\(/.test(t)&&d.add(e)}}await _(this.projectRootDir),await this.generateConfigStyles(d);let v={keyframes:[],components:[],classNames:[]};await Promise.all([...l].map(async e=>{let{contents:n}=await this.compileSaltyFile(e,o);for(let[r,i]of Object.entries(n)){let n=await t.resolveExportValue(i,1);n.isKeyframes?v.keyframes.push({value:n,src:e,name:r}):n.isClassName?v.classNames.push({...i,src:e,name:r}):n.generator&&v.components.push({...i,src:e,name:r})}}));let y=await this.getConfig();for(let e of v.keyframes){let{value:t}=e,n=`a_${t.animationName}.css`,r=(0,u.join)(o,`css/${n}`);i.push(n),(0,c.writeFileSync)(r,t.css)}let b={};for(let e of v.components){let{src:t,name:n}=e;b[t]||(b[t]=[]);let r=e.generator._withBuildContext({callerName:n,isProduction:this.isProduction,config:y});a[r.priority]||(a[r.priority]=[]);let i=await r.css;i&&(a[r.priority].push(r.cssFileName),(0,c.writeFileSync)((0,u.join)(o,`css/${r.cssFileName}`),i),y.importStrategy===`component`&&b[t].push(r.cssFileName))}for(let e of v.classNames){let{src:t,name:n}=e;b[t]||(b[t]=[]);let r=e.generator._withBuildContext({callerName:n,isProduction:this.isProduction,config:y}),i=await r.css;i&&(a[r.priority]||(a[r.priority]=[]),a[r.priority].push(r.cssFileName),(0,c.writeFileSync)((0,u.join)(o,`css/${r.cssFileName}`),i),y.importStrategy===`component`&&b[t].push(r.cssFileName))}y.importStrategy===`component`&&Object.entries(b).forEach(([e,t])=>{let r=t.map(e=>`@import url('./${e}');`).join(`
2
2
  `),i=n.toHash(e,6);(0,c.writeFileSync)((0,u.join)(o,`css/f_${n.dashCase((0,u.parse)(e).name)}-${i}.css`),r||`/* Empty file */`)});let x=i.map(e=>`@import url('./css/${e}');`).join(`
3
3
  `),S=`/*!
4
4
  * Generated with Salty CSS (https://salty-css.dev)
@@ -1,7 +1,7 @@
1
1
  import { isSaltyFile as e, resolveExportValue as t, saltyFileExtensions as n } from "./compiler/helpers.js";
2
2
  import { dashCase as r, isPathAllowed as i, normalizePath as a, toHash as o } from "./util/index.js";
3
3
  import { defineTemplates as s } from "./factories/index.js";
4
- import { s as c, t as l } from "./parse-styles-Bz0otiZ-.js";
4
+ import { s as c, t as l } from "./parse-styles-B5QRCMas.js";
5
5
  import { mergeFactories as u, mergeObjects as d } from "./css/merge.js";
6
6
  import { getPackageJson as f } from "./compiler/get-files.js";
7
7
  import { getTemplateTypes as p, getTemplateVariantMaps as m, parseTemplates as h } from "./parsers/index.js";
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "bugs": {
16
16
  "url": "https://github.com/margarita-form/salty-css/issues"
17
17
  },
18
- "version": "0.3.0",
18
+ "version": "0.3.1-fix-respect-media-order.0",
19
19
  "type": "module",
20
20
  "scripts": {
21
21
  "build": "vite build",
@@ -1,3 +0,0 @@
1
- const e=require("./util/index.cjs"),t=require("./viewport-clamp-CHOyzt37.cjs");var n=e=>t=>{if(typeof t!=`string`||!e)return;let n=t,r=[];return Object.values(e).forEach(e=>{let{pattern:t,transform:i}=e;n=n.replace(t,e=>{let{value:t,css:n}=i(e);return n&&r.push(n),t})}),{transformed:n,additionalCss:r}},r=t=>n=>{if(typeof n==`string`&&/\{[^{}]+\}/g.test(n))return{transformed:n.replace(/\{([^{}]+)\}/g,(...n)=>{let r=e.dashCase(n[1].trim().replaceAll(`.`,`-`));return t&&!t.includes(r)&&console.warn(`Token ${r} might not exist`),r.startsWith(`-`)?`-${r}`:`var(--${r})`})}},i=r(),a=[`top`,`right`,`bottom`,`left`,`min-width`,/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],o=(e,n,r)=>{if(a.some(t=>typeof t==`string`?t===e:t.test(e))){let e=r?.defaultUnit||`px`;if(e.startsWith(`viewport-clamp:`))try{let r=e.split(`:`)[1];return t.t({screenSize:parseInt(r)})(Number(n))}catch(t){throw console.error(t),Error(`Invalid viewport-clamp value: ${e}`)}return`${n}${e}`}return`${n}`},s=[`Webkit`,`Moz`,`ms`,`O`],c=e=>s.some(t=>{if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n>=`A`&&n<=`Z`}),l=t=>t.startsWith(`-`)?t:c(t)?`-${e.dashCase(t)}`:e.dashCase(t),u=(e,t)=>{if(e===!0)throw Error(`[salty-css] ${t}`);e===`warn`&&console.warn(`[salty-css] ${t}`)},d=/^&(hover|focus(-(visible|within))?|active|visited|checked|disabled|enabled|empty|target|first-child|last-child|first-of-type|last-of-type|placeholder|placeholder-shown|root)\b/,f=/\$\{[^}]+\}/,p=/^@(media|supports|container|layer)\s*$/,m=/^@(?:-(?:webkit|moz|o|ms)-)?keyframes\b/,h=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=Object.keys(e);return t.includes(`base`)||t.includes(`variants`)},g=e=>{if(typeof e==`string`){let[t,n]=e.split(`@`,2),r=t.split(`.`).filter(Boolean);if(!r.length)return;let i={};if(n)for(let e of n.split(`&`)){if(!e)continue;let t=e.indexOf(`=`);if(t===-1)i[e.trim()]=!0;else{let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();if(!n)continue;r===`true`?i[n]=!0:r===`false`?i[n]=!1:i[n]=r}}return{path:r,variants:i}}if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e,n=t.name;if(typeof n!=`string`)return;let r=n.split(`.`).filter(Boolean);if(!r.length)return;let i={};for(let[e,n]of Object.entries(t))e!==`name`&&(typeof n==`string`||typeof n==`boolean`)&&(i[e]=n);return{path:r,variants:i}}},_=e=>{if(e!==void 0)return typeof e==`boolean`?String(e):e},v=(e,t)=>{let n=[{node:e,isRich:h(e)}],r=e;for(let e of t){if(typeof r!=`object`||!r)return;let t=r[e];if(t===void 0)return;n.push({node:t,isRich:h(t)}),r=t}return n},y=(e,t)=>{let n=v(e,t);return n?n.some(e=>e.isRich):!1},b=(e,t)=>{for(let[n,r]of Object.entries(e))if(n!==`css`&&t[n]!==_(r))return!1;return!0},x=(e,t)=>{let n=!1;for(let[r,i]of Object.entries(e))if(r!==`css`&&(n=!0,t[r]===_(i)))return!0;return!n},S=(e,t,n,r)=>{let i=v(e,t);if(!i)return;let a=i.map(e=>e.isRich?e.node:e.node&&typeof e.node==`object`&&!Array.isArray(e.node)?Object.keys(e.node).every(t=>e.node[t]&&typeof e.node[t]==`object`&&!h(e.node[t]))?{}:{base:e.node}:{}),o=new Set;for(let e of a)if(e.variants)for(let t of Object.keys(e.variants))o.add(t);for(let e of a)if(e.defaultVariants)for(let t of Object.keys(e.defaultVariants))o.add(t);let s={};for(let e of o){if(e in n){s[e]=_(n[e]);continue}for(let t=a.length-1;t>=0;t--){let n=a[t].defaultVariants?.[e];if(n!==void 0){s[e]=_(n);break}}}for(let[e,i]of Object.entries(n)){if(!o.has(e)){console.warn(`Template "${r}" path "${t.join(`.`)}" has no variant axis "${e}"; ignored.`);continue}let n=_(i),s=!1;for(let t of a)if(t.variants?.[e]&&n!==void 0&&n in t.variants[e]){s=!0;break}!s&&n!==void 0&&a.some(t=>t.variants&&e in t.variants)&&console.warn(`Template "${r}" axis "${e}" has no value "${n}" on path "${t.join(`.`)}"; ignored.`)}let c={};for(let e of a)e.base&&Object.assign(c,e.base);for(let e of Object.keys(s)){let t=s[e];if(t!==void 0)for(let n=a.length-1;n>=0;n--){let r=a[n].variants?.[e]?.[t];if(r){Object.assign(c,r);break}}}for(let e of a){if(e.compoundVariants)for(let t of e.compoundVariants)b(t,s)&&t.css&&Object.assign(c,t.css);if(e.anyOfVariants)for(let t of e.anyOfVariants)x(t,s)&&t.css&&Object.assign(c,t.css)}return c},C=async(e,t=``,i,a=!1)=>{if(!e)throw Error(`No styles provided to parseStyles function!`);let s=new Set,c=Object.entries(e),h=i?.strict,_=async([e,n])=>{let r=e.trim().replace(/^\?+/g,``),c=l(r),v=(e,t=`;`)=>`${c}:${e}${t}`,b={scope:t,config:i};if(typeof n==`function`)try{return await _([e,n(b)])}catch(e){u(h,`Function value for "${r}" threw: ${e?.message??e}`);return}if(n instanceof Promise)return _([e,await n]);if(i?.templates&&i.templatePaths?.[r])try{let[e,t]=i.templatePaths[r].split(`;;`),a=await import(t),o=t.includes(`salty.config`),s=o?a[e].templates:a[e],c=o?s[r]:s.params[r];if(s&&typeof c==`function`){let[e]=await C(await c(n),``);return e}}catch(e){console.error(`Error loading template "${r}" from path "${i.templatePaths[r]}"`,e);return}if(i?.templates&&i.templates[r]){if(a)return;let e=i.templates[r],t=g(n);if(t){let{path:n,variants:i}=t;if(Object.keys(i).length>0||y(e,n)){let t=S(e,n,i,r);if(t){let[e]=await C(t,``);return e}console.warn(`Template "${r}" with path of "${n.join(`.`)}" was not found in config!`);return}let a=n.reduce((e,t)=>e?.[t],e);if(a){let[e]=await C(a,``);return e}console.warn(`Template "${r}" with path of "${n.join(`.`)}" was not found in config!`);return}console.warn(`Template "${r}" received an unsupported call-site value.`);return}if(!(r===`compoundVariants`||r===`anyOfVariants`)&&Array.isArray(n))return n.length===0?void 0:_([e,n.join(`, `)]);if(typeof n==`object`){if(!n)return;if(n.isColor||n.isDefineFont)return v(n.toString());if(r===`defaultVariants`)return;if(r===`variants`){let e=Object.entries(n);for(let[n,r]of e){if(!r)continue;let e=Object.entries(r);for(let[r,a]of e)a&&(await C(a,`${t}.${n}-${r}`,i)).forEach(e=>s.add(e))}return}if(r===`compoundVariants`){for(let e of n){let{css:n,...r}=e;(await C(n,Object.entries(r).reduce((e,[t,n])=>`${e}.${t}-${n}`,t),i)).forEach(e=>s.add(e))}return}if(r===`anyOfVariants`){for(let e of n){let{css:n,...r}=e;(await C(n,`${t}:where(${Object.entries(r).map(([e,t])=>`.${e}-${t}`).join(`, `)})`,i)).forEach(e=>s.add(e))}return}if(r===`global`){(await C(n,``,i)).forEach(e=>s.add(e));return}if(r.startsWith(`@`)){p.test(r)&&u(h,`At-rule "${r}" is missing its condition (e.g. "@media (min-width: 600px)").`);let e=m.test(r)?``:t,a=`${i?.mediaQueries?.[r]||r} { ${await w(n,e,i)} }`;s.add(a);return}if(Object.keys(n).length===0)return;d.test(r)&&u(h,`Selector "${r}" looks like a missing-colon typo (did you mean "&:${r.slice(1)}"?).`);let e=D(t,r);(await C(n,e,i)).forEach(e=>s.add(e));return}if(r.startsWith(`$`)){u(h,`Property key "${r}" looks like a SCSS variable — Salty does not support those.`);return}if(r.includes(`:`)){u(h,`Property key "${r}" contains a colon — did you accidentally paste a whole declaration as a key?`);return}if(n==null){u(h,`Property "${r}" has a ${n===void 0?`undefined`:`null`} value — skipping.`);return}if(typeof n==`boolean`){u(h,`Property "${r}" has a boolean value (${n}) — skipping.`);return}if(n!==``){if(typeof n==`number`){if(!Number.isFinite(n)){u(h,`Property "${r}" has a non-finite numeric value (${n}) — skipping.`);return}return v(o(c,n,i))}if(typeof n!=`string`)if(n&&typeof n==`object`&&`toString`in n)n=n.toString();else{u(h,`Property "${r}" has an unsupported value type (${typeof n}) — skipping.`);return}return typeof n==`string`&&f.test(n)&&u(h,`Property "${r}" value "${n}" contains an unresolved \`\${...}\` — did you forget to interpolate?`),v(n)}},v=c.map(_),{modifiers:b}=i||{},x=[r(),n(b)],T=(await Promise.all(v).then(e=>Promise.all(e.map(e=>x.reduce(async(e,t)=>{let n=await e;if(!n)return n;let r=await t(n);if(!r)return n;let{transformed:i,additionalCss:a}=r,o=``;if(a)for(let e of a)o+=await w(e,``);return`${o}${i}`},Promise.resolve(e)))))).filter(e=>e!==void 0).join(`
2
- `);if(!T.trim())return Array.from(s);let E=t?`${t} {\n\t${T}\n}`:T;return s.has(E)?Array.from(s):[E,...s]},w=async(e,t,n,r=!1)=>(await C(e,t,n,r)).join(`
3
- `),T=e=>{let t=[],n=0,r=``;for(let i of e)if(i===`(`||i===`[`?n++:(i===`)`||i===`]`)&&(n=Math.max(0,n-1)),i===`,`&&n===0){let e=r.trim();e&&t.push(e),r=``}else r+=i;let i=r.trim();return i&&t.push(i),t},E=(e,t)=>t.includes(`&`)?t.replaceAll(`&`,e):t.startsWith(`:`)?`${e}${t}`:`${e} ${t}`,D=(e,t)=>{if(!e)return t;let n=T(e),r=T(t);if(!r.length)return e;if(n.length<=1&&r.length<=1)return E(n[0]??e,r[0]);let i=[];for(let e of n)for(let t of r)i.push(E(e,t));return i.join(`, `)};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return w}});