@salty-css/core 0.4.0-feat-include-version-info-in-info-comment.0 → 0.4.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.
Files changed (35) hide show
  1. package/dist/bin/index.cjs +1 -1
  2. package/dist/bin/index.js +1 -1
  3. package/dist/bin/main.cjs +1 -1
  4. package/dist/bin/main.js +1 -1
  5. package/dist/compiler/salty-compiler.cjs +1 -1
  6. package/dist/compiler/salty-compiler.js +1 -1
  7. package/dist/css/keyframes.cjs +1 -1
  8. package/dist/css/keyframes.js +1 -1
  9. package/dist/generators/index.cjs +1 -1
  10. package/dist/generators/index.js +1 -1
  11. package/dist/{generators-BRukX_SQ.cjs → generators-BVhdBePh.cjs} +1 -1
  12. package/dist/{generators-Cbt_Ih7F.js → generators-Drnkwo8s.js} +1 -1
  13. package/dist/instances/classname-instance.cjs +1 -1
  14. package/dist/instances/classname-instance.js +1 -1
  15. package/dist/{main-CqIzdnTQ.cjs → main-BSMjoOQF.cjs} +1 -1
  16. package/dist/{main-Cs7Cc2pG.js → main-XS_jYVof.js} +1 -1
  17. package/dist/{parse-styles-PndoToaP.cjs → parse-styles-B51bN86A.cjs} +2 -2
  18. package/dist/parse-styles-iylx7U1R.js +334 -0
  19. package/dist/parsers/index.cjs +1 -1
  20. package/dist/parsers/index.js +1 -1
  21. package/dist/parsers/parse-styles.d.ts.map +1 -1
  22. package/dist/runtime/index.cjs +1 -1
  23. package/dist/runtime/index.js +1 -1
  24. package/dist/{salty-compiler-RrzY5nL7.js → salty-compiler-CcYVeukN.js} +2 -2
  25. package/dist/{salty-compiler-va3NmtVB.cjs → salty-compiler-PoE9M7kB.cjs} +2 -2
  26. package/dist/util/dash-case.d.ts +1 -1
  27. package/dist/util/dash-case.d.ts.map +1 -1
  28. package/dist/util/index.cjs +1 -1
  29. package/dist/util/index.d.ts +1 -0
  30. package/dist/util/index.d.ts.map +1 -1
  31. package/dist/util/index.js +8 -8
  32. package/dist/util/sanitize-class-name.d.ts +2 -0
  33. package/dist/util/sanitize-class-name.d.ts.map +1 -0
  34. package/package.json +1 -1
  35. package/dist/parse-styles-B5QRCMas.js +0 -334
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require("../main-CqIzdnTQ.cjs").t().catch(e=>console.error(e));
2
+ require("../main-BSMjoOQF.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-Cs7Cc2pG.js";
2
+ import { t as e } from "../main-XS_jYVof.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-CqIzdnTQ.cjs");exports.main=e.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../main-BSMjoOQF.cjs");exports.main=e.t;
package/dist/bin/main.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as e } from "../main-Cs7Cc2pG.js";
1
+ import { t as e } from "../main-XS_jYVof.js";
2
2
  export { e as main };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../salty-compiler-va3NmtVB.cjs");exports.SaltyCompiler=e.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../salty-compiler-PoE9M7kB.cjs");exports.SaltyCompiler=e.t;
@@ -1,2 +1,2 @@
1
- import { t as e } from "../salty-compiler-RrzY5nL7.js";
1
+ import { t as e } from "../salty-compiler-CcYVeukN.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-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
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../util/index.cjs"),t=require("../parse-styles-B51bN86A.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-B5QRCMas.js";
2
+ import { t } from "../parse-styles-iylx7U1R.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-BRukX_SQ.cjs");exports.ClassNameGenerator=e.n,exports.StyledGenerator=e.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../generators-BVhdBePh.cjs");exports.ClassNameGenerator=e.n,exports.StyledGenerator=e.t;
@@ -1,2 +1,2 @@
1
- import { n as e, t } from "../generators-Cbt_Ih7F.js";
1
+ import { n as e, t } from "../generators-Drnkwo8s.js";
2
2
  export { e as ClassNameGenerator, t as StyledGenerator };
@@ -1 +1 @@
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
+ const e=require("./util/index.cjs"),t=require("./parse-styles-B51bN86A.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-B5QRCMas.js";
2
+ import { i as n, t as r } from "./parse-styles-iylx7U1R.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-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
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../generators-BVhdBePh.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-Cbt_Ih7F.js";
1
+ import { n as e } from "../generators-Drnkwo8s.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-va3NmtVB.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-PoE9M7kB.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-RrzY5nL7.js";
1
+ import { n as e, r as t, t as n } from "./salty-compiler-CcYVeukN.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";
@@ -1,3 +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(`
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(t,i=``,a,s=!1)=>{if(!t)throw Error(`No styles provided to parseStyles function!`);let c=Object.entries(t),h=a?.strict;k(c,a,h);let _=async([t,n])=>{let r=t.trim().replace(/^\?+/g,``),c=l(r),v=[],b=e=>({value:e,nested:v}),x=(e,t=`;`)=>`${c}:${e}${t}`,T={scope:i,config:a};if(typeof n==`function`)try{return await _([t,n(T)])}catch(e){return u(h,`Function value for "${r}" threw: ${e?.message??e}`),b()}if(n instanceof Promise)return _([t,await n]);if(a?.templates&&a.templatePaths?.[r])try{let[e,t]=a.templatePaths[r].split(`;;`),i=await import(t),o=t.includes(`salty.config`),s=o?i[e].templates:i[e],c=o?s[r]:s.params[r];if(s&&typeof c==`function`){let[e]=await C(await c(n),``);return b(e)}}catch(e){return console.error(`Error loading template "${r}" from path "${a.templatePaths[r]}"`,e),b()}if(a?.templates&&a.templates[r]){if(s)return b();let e=a.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 b(e)}return console.warn(`Template "${r}" with path of "${n.join(`.`)}" was not found in config!`),b()}let a=n.reduce((e,t)=>e?.[t],e);if(a){let[e]=await C(a,``);return b(e)}return console.warn(`Template "${r}" with path of "${n.join(`.`)}" was not found in config!`),b()}return console.warn(`Template "${r}" received an unsupported call-site value.`),b()}if(!(r===`compoundVariants`||r===`anyOfVariants`)&&Array.isArray(n))return n.length===0?b():_([t,n.join(`, `)]);if(typeof n==`object`){if(!n)return b();if(n.isColor||n.isDefineFont)return b(x(n.toString()));if(r===`defaultVariants`)return b();if(r===`variants`){let t=Object.entries(n);for(let[n,r]of t){if(!r)continue;let t=Object.entries(r);for(let[r,o]of t)o&&(await C(o,`${i}.${`${e.sanitizeClassName(n)}-${e.sanitizeClassName(r)}`}`,a)).forEach(e=>v.push(e))}return b()}if(r===`compoundVariants`){for(let t of n){let{css:n,...r}=t;(await C(n,Object.entries(r).reduce((t,[n,r=``])=>`${t}.${`${e.sanitizeClassName(n)}-${e.sanitizeClassName(r)}`}`,i),a)).forEach(e=>v.push(e))}return b()}if(r===`anyOfVariants`){for(let t of n){let{css:n,...r}=t;(await C(n,`${i}:where(${Object.entries(r).map(([t,n=``])=>`.${`${e.sanitizeClassName(t)}-${e.sanitizeClassName(n)}`}`).join(`, `)})`,a)).forEach(e=>v.push(e))}return b()}if(r===`global`)return(await C(n,``,a)).forEach(e=>v.push(e)),b();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)?``:i,t=`${a?.mediaQueries?.[r]||r} { ${await w(n,e,a)} }`;return v.push(t),b()}if(Object.keys(n).length===0)return b();d.test(r)&&u(h,`Selector "${r}" looks like a missing-colon typo (did you mean "&:${r.slice(1)}"?).`);let t=D(i,r);return(await C(n,t,a)).forEach(e=>v.push(e)),b()}if(r.startsWith(`$`))return u(h,`Property key "${r}" looks like a SCSS variable — Salty does not support those.`),b();if(r.includes(`:`))return u(h,`Property key "${r}" contains a colon — did you accidentally paste a whole declaration as a key?`),b();if(n==null)return u(h,`Property "${r}" has a ${n===void 0?`undefined`:`null`} value — skipping.`),b();if(typeof n==`boolean`)return u(h,`Property "${r}" has a boolean value (${n}) — skipping.`),b();if(n===``)return b();if(typeof n==`number`)return Number.isFinite(n)?b(x(o(c,n,a))):(u(h,`Property "${r}" has a non-finite numeric value (${n}) — skipping.`),b());if(typeof n!=`string`)if(n&&typeof n==`object`&&`toString`in n)n=n.toString();else return u(h,`Property "${r}" has an unsupported value type (${typeof n}) — skipping.`),b();return typeof n==`string`&&f.test(n)&&u(h,`Property "${r}" value "${n}" contains an unresolved \`\${...}\` — did you forget to interpolate?`),b(x(n))},{modifiers:v}=a||{},b=[r(),n(v)],x=await Promise.all(c.map(_)),T=await Promise.all(x.map(({value:e})=>e===void 0?Promise.resolve(void 0):b.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)))),E=new Set;for(let{nested:e}of x)for(let t of e)E.add(t);let O=T.filter(e=>e!==void 0).join(`
2
+ `);if(!O.trim())return Array.from(E);let A=i?`${i} {\n\t${O}\n}`:O;return E.has(A)?Array.from(E):[A,...E]},w=async(e,t,n,r=!1)=>(await C(e,t,n,r)).join(`
3
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}});
@@ -0,0 +1,334 @@
1
+ import { dashCase as e, sanitizeClassName as t } from "./util/index.js";
2
+ import { t as n } from "./viewport-clamp-CRtzRvJ3.js";
3
+ //#region src/parsers/parse-modifiers.ts
4
+ var r = (e) => (t) => {
5
+ if (typeof t != "string" || !e) return;
6
+ let n = t, r = [];
7
+ return Object.values(e).forEach((e) => {
8
+ let { pattern: t, transform: i } = e;
9
+ n = n.replace(t, (e) => {
10
+ let { value: t, css: n } = i(e);
11
+ return n && r.push(n), t;
12
+ });
13
+ }), {
14
+ transformed: n,
15
+ additionalCss: r
16
+ };
17
+ }, i = (t) => (n) => {
18
+ if (typeof n == "string" && /\{[^{}]+\}/g.test(n)) return { transformed: n.replace(/\{([^{}]+)\}/g, (...n) => {
19
+ let r = e(n[1].trim().replaceAll(".", "-"));
20
+ return t && !t.includes(r) && console.warn(`Token ${r} might not exist`), r.startsWith("-") ? `-${r}` : `var(--${r})`;
21
+ }) };
22
+ }, a = i(), o = [
23
+ "top",
24
+ "right",
25
+ "bottom",
26
+ "left",
27
+ "min-width",
28
+ /.*width.*/,
29
+ /^[^line]*height.*/,
30
+ /padding.*/,
31
+ /margin.*/,
32
+ /border.*/,
33
+ /inset.*/,
34
+ /.*radius.*/,
35
+ /.*spacing.*/,
36
+ /.*gap.*/,
37
+ /.*indent.*/,
38
+ /.*offset.*/,
39
+ /.*size.*/,
40
+ /.*thickness.*/,
41
+ /.*font-size.*/
42
+ ], s = (e, t, r) => {
43
+ if (o.some((t) => typeof t == "string" ? t === e : t.test(e))) {
44
+ let e = r?.defaultUnit || "px";
45
+ if (e.startsWith("viewport-clamp:")) try {
46
+ let r = e.split(":")[1];
47
+ return n({ screenSize: parseInt(r) })(Number(t));
48
+ } catch (t) {
49
+ throw console.error(t), Error(`Invalid viewport-clamp value: ${e}`);
50
+ }
51
+ return `${t}${e}`;
52
+ }
53
+ return `${t}`;
54
+ }, c = [
55
+ "Webkit",
56
+ "Moz",
57
+ "ms",
58
+ "O"
59
+ ], l = (e) => c.some((t) => {
60
+ if (!e.startsWith(t)) return !1;
61
+ let n = e.charAt(t.length);
62
+ return n >= "A" && n <= "Z";
63
+ }), u = (t) => t.startsWith("-") ? t : l(t) ? `-${e(t)}` : e(t), d = (e, t) => {
64
+ if (e === !0) throw Error(`[salty-css] ${t}`);
65
+ e === "warn" && console.warn(`[salty-css] ${t}`);
66
+ }, f = /^&(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/, p = /\$\{[^}]+\}/, m = /^@(media|supports|container|layer)\s*$/, h = /^@(?:-(?:webkit|moz|o|ms)-)?keyframes\b/, g = (e) => {
67
+ if (!e || typeof e != "object" || Array.isArray(e)) return !1;
68
+ let t = Object.keys(e);
69
+ return t.includes("base") || t.includes("variants");
70
+ }, _ = (e) => {
71
+ if (typeof e == "string") {
72
+ let [t, n] = e.split("@", 2), r = t.split(".").filter(Boolean);
73
+ if (!r.length) return;
74
+ let i = {};
75
+ if (n) for (let e of n.split("&")) {
76
+ if (!e) continue;
77
+ let t = e.indexOf("=");
78
+ if (t === -1) i[e.trim()] = !0;
79
+ else {
80
+ let n = e.slice(0, t).trim(), r = e.slice(t + 1).trim();
81
+ if (!n) continue;
82
+ r === "true" ? i[n] = !0 : r === "false" ? i[n] = !1 : i[n] = r;
83
+ }
84
+ }
85
+ return {
86
+ path: r,
87
+ variants: i
88
+ };
89
+ }
90
+ if (e && typeof e == "object" && !Array.isArray(e)) {
91
+ let t = e, n = t.name;
92
+ if (typeof n != "string") return;
93
+ let r = n.split(".").filter(Boolean);
94
+ if (!r.length) return;
95
+ let i = {};
96
+ for (let [e, n] of Object.entries(t)) e !== "name" && (typeof n == "string" || typeof n == "boolean") && (i[e] = n);
97
+ return {
98
+ path: r,
99
+ variants: i
100
+ };
101
+ }
102
+ }, v = (e) => {
103
+ if (e !== void 0) return typeof e == "boolean" ? String(e) : e;
104
+ }, y = (e, t) => {
105
+ let n = [{
106
+ node: e,
107
+ isRich: g(e)
108
+ }], r = e;
109
+ for (let e of t) {
110
+ if (typeof r != "object" || !r) return;
111
+ let t = r[e];
112
+ if (t === void 0) return;
113
+ n.push({
114
+ node: t,
115
+ isRich: g(t)
116
+ }), r = t;
117
+ }
118
+ return n;
119
+ }, b = (e, t) => {
120
+ let n = y(e, t);
121
+ return n ? n.some((e) => e.isRich) : !1;
122
+ }, x = (e, t) => {
123
+ for (let [n, r] of Object.entries(e)) if (n !== "css" && t[n] !== v(r)) return !1;
124
+ return !0;
125
+ }, S = (e, t) => {
126
+ let n = !1;
127
+ for (let [r, i] of Object.entries(e)) if (r !== "css" && (n = !0, t[r] === v(i))) return !0;
128
+ return !n;
129
+ }, C = (e, t, n, r) => {
130
+ let i = y(e, t);
131
+ if (!i) return;
132
+ 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" && !g(e.node[t])) ? {} : { base: e.node } : {}), o = /* @__PURE__ */ new Set();
133
+ for (let e of a) if (e.variants) for (let t of Object.keys(e.variants)) o.add(t);
134
+ for (let e of a) if (e.defaultVariants) for (let t of Object.keys(e.defaultVariants)) o.add(t);
135
+ let s = {};
136
+ for (let e of o) {
137
+ if (e in n) {
138
+ s[e] = v(n[e]);
139
+ continue;
140
+ }
141
+ for (let t = a.length - 1; t >= 0; t--) {
142
+ let n = a[t].defaultVariants?.[e];
143
+ if (n !== void 0) {
144
+ s[e] = v(n);
145
+ break;
146
+ }
147
+ }
148
+ }
149
+ for (let [e, i] of Object.entries(n)) {
150
+ if (!o.has(e)) {
151
+ console.warn(`Template "${r}" path "${t.join(".")}" has no variant axis "${e}"; ignored.`);
152
+ continue;
153
+ }
154
+ let n = v(i), s = !1;
155
+ for (let t of a) if (t.variants?.[e] && n !== void 0 && n in t.variants[e]) {
156
+ s = !0;
157
+ break;
158
+ }
159
+ !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.`);
160
+ }
161
+ let c = {};
162
+ for (let e of a) e.base && Object.assign(c, e.base);
163
+ for (let e of Object.keys(s)) {
164
+ let t = s[e];
165
+ if (t !== void 0) for (let n = a.length - 1; n >= 0; n--) {
166
+ let r = a[n].variants?.[e]?.[t];
167
+ if (r) {
168
+ Object.assign(c, r);
169
+ break;
170
+ }
171
+ }
172
+ }
173
+ for (let e of a) {
174
+ if (e.compoundVariants) for (let t of e.compoundVariants) x(t, s) && t.css && Object.assign(c, t.css);
175
+ if (e.anyOfVariants) for (let t of e.anyOfVariants) S(t, s) && t.css && Object.assign(c, t.css);
176
+ }
177
+ return c;
178
+ }, w = async (e, n = "", a, o = !1) => {
179
+ if (!e) throw Error("No styles provided to parseStyles function!");
180
+ let c = Object.entries(e), l = a?.strict;
181
+ A(c, a, l);
182
+ let g = async ([e, r]) => {
183
+ let i = e.trim().replace(/^\?+/g, ""), c = u(i), v = [], y = (e) => ({
184
+ value: e,
185
+ nested: v
186
+ }), x = (e, t = ";") => `${c}:${e}${t}`, S = {
187
+ scope: n,
188
+ config: a
189
+ };
190
+ if (typeof r == "function") try {
191
+ return await g([e, r(S)]);
192
+ } catch (e) {
193
+ return d(l, `Function value for "${i}" threw: ${e?.message ?? e}`), y();
194
+ }
195
+ if (r instanceof Promise) return g([e, await r]);
196
+ if (a?.templates && a.templatePaths?.[i]) try {
197
+ let [e, t] = a.templatePaths[i].split(";;"), n = await import(
198
+ /* webpackIgnore: true */
199
+ /* @vite-ignore */
200
+ t
201
+ ), o = t.includes("salty.config"), s = o ? n[e].templates : n[e], c = o ? s[i] : s.params[i];
202
+ if (s && typeof c == "function") {
203
+ let [e] = await w(await c(r), "");
204
+ return y(e);
205
+ }
206
+ } catch (e) {
207
+ return console.error(`Error loading template "${i}" from path "${a.templatePaths[i]}"`, e), y();
208
+ }
209
+ if (a?.templates && a.templates[i]) {
210
+ if (o) return y();
211
+ let e = a.templates[i], t = _(r);
212
+ if (t) {
213
+ let { path: n, variants: r } = t;
214
+ if (Object.keys(r).length > 0 || b(e, n)) {
215
+ let t = C(e, n, r, i);
216
+ if (t) {
217
+ let [e] = await w(t, "");
218
+ return y(e);
219
+ }
220
+ return console.warn(`Template "${i}" with path of "${n.join(".")}" was not found in config!`), y();
221
+ }
222
+ let a = n.reduce((e, t) => e?.[t], e);
223
+ if (a) {
224
+ let [e] = await w(a, "");
225
+ return y(e);
226
+ }
227
+ return console.warn(`Template "${i}" with path of "${n.join(".")}" was not found in config!`), y();
228
+ }
229
+ return console.warn(`Template "${i}" received an unsupported call-site value.`), y();
230
+ }
231
+ if (!(i === "compoundVariants" || i === "anyOfVariants") && Array.isArray(r)) return r.length === 0 ? y() : g([e, r.join(", ")]);
232
+ if (typeof r == "object") {
233
+ if (!r) return y();
234
+ if (r.isColor || r.isDefineFont) return y(x(r.toString()));
235
+ if (i === "defaultVariants") return y();
236
+ if (i === "variants") {
237
+ let e = Object.entries(r);
238
+ for (let [r, i] of e) {
239
+ if (!i) continue;
240
+ let e = Object.entries(i);
241
+ for (let [i, o] of e) o && (await w(o, `${n}.${`${t(r)}-${t(i)}`}`, a)).forEach((e) => v.push(e));
242
+ }
243
+ return y();
244
+ }
245
+ if (i === "compoundVariants") {
246
+ for (let e of r) {
247
+ let { css: r, ...i } = e;
248
+ (await w(r, Object.entries(i).reduce((e, [n, r = ""]) => `${e}.${`${t(n)}-${t(r)}`}`, n), a)).forEach((e) => v.push(e));
249
+ }
250
+ return y();
251
+ }
252
+ if (i === "anyOfVariants") {
253
+ for (let e of r) {
254
+ let { css: r, ...i } = e;
255
+ (await w(r, `${n}:where(${Object.entries(i).map(([e, n = ""]) => `.${`${t(e)}-${t(n)}`}`).join(", ")})`, a)).forEach((e) => v.push(e));
256
+ }
257
+ return y();
258
+ }
259
+ if (i === "global") return (await w(r, "", a)).forEach((e) => v.push(e)), y();
260
+ if (i.startsWith("@")) {
261
+ m.test(i) && d(l, `At-rule "${i}" is missing its condition (e.g. "@media (min-width: 600px)").`);
262
+ let e = h.test(i) ? "" : n, t = `${a?.mediaQueries?.[i] || i} { ${await T(r, e, a)} }`;
263
+ return v.push(t), y();
264
+ }
265
+ if (Object.keys(r).length === 0) return y();
266
+ f.test(i) && d(l, `Selector "${i}" looks like a missing-colon typo (did you mean "&:${i.slice(1)}"?).`);
267
+ let e = O(n, i);
268
+ return (await w(r, e, a)).forEach((e) => v.push(e)), y();
269
+ }
270
+ if (i.startsWith("$")) return d(l, `Property key "${i}" looks like a SCSS variable — Salty does not support those.`), y();
271
+ if (i.includes(":")) return d(l, `Property key "${i}" contains a colon — did you accidentally paste a whole declaration as a key?`), y();
272
+ if (r == null) return d(l, `Property "${i}" has a ${r === void 0 ? "undefined" : "null"} value — skipping.`), y();
273
+ if (typeof r == "boolean") return d(l, `Property "${i}" has a boolean value (${r}) — skipping.`), y();
274
+ if (r === "") return y();
275
+ if (typeof r == "number") return Number.isFinite(r) ? y(x(s(c, r, a))) : (d(l, `Property "${i}" has a non-finite numeric value (${r}) — skipping.`), y());
276
+ if (typeof r != "string") if (r && typeof r == "object" && "toString" in r) r = r.toString();
277
+ else return d(l, `Property "${i}" has an unsupported value type (${typeof r}) — skipping.`), y();
278
+ return typeof r == "string" && p.test(r) && d(l, `Property "${i}" value "${r}" contains an unresolved \`\${...}\` — did you forget to interpolate?`), y(x(r));
279
+ }, { modifiers: v } = a || {}, y = [i(), r(v)], x = await Promise.all(c.map(g)), S = await Promise.all(x.map(({ value: e }) => e === void 0 ? Promise.resolve(void 0) : y.reduce(async (e, t) => {
280
+ let n = await e;
281
+ if (!n) return n;
282
+ let r = await t(n);
283
+ if (!r) return n;
284
+ let { transformed: i, additionalCss: a } = r, o = "";
285
+ if (a) for (let e of a) o += await T(e, "");
286
+ return `${o}${i}`;
287
+ }, Promise.resolve(e)))), E = /* @__PURE__ */ new Set();
288
+ for (let { nested: e } of x) for (let t of e) E.add(t);
289
+ let D = S.filter((e) => e !== void 0).join("\n ");
290
+ if (!D.trim()) return Array.from(E);
291
+ let k = n ? `${n} {\n\t${D}\n}` : D;
292
+ return E.has(k) ? Array.from(E) : [k, ...E];
293
+ }, T = async (e, t, n, r = !1) => (await w(e, t, n, r)).join("\n"), E = (e) => {
294
+ let t = [], n = 0, r = "";
295
+ for (let i of e) if (i === "(" || i === "[" ? n++ : (i === ")" || i === "]") && (n = Math.max(0, n - 1)), i === "," && n === 0) {
296
+ let e = r.trim();
297
+ e && t.push(e), r = "";
298
+ } else r += i;
299
+ let i = r.trim();
300
+ return i && t.push(i), t;
301
+ }, D = (e, t) => t.includes("&") ? t.replaceAll("&", e) : t.startsWith(":") ? `${e}${t}` : `${e} ${t}`, O = (e, t) => {
302
+ if (!e) return t;
303
+ let n = E(e), r = E(t);
304
+ if (!r.length) return e;
305
+ if (n.length <= 1 && r.length <= 1) return D(n[0] ?? e, r[0]);
306
+ let i = [];
307
+ for (let e of n) for (let t of r) i.push(D(e, t));
308
+ return i.join(", ");
309
+ }, k = /\((max|min)-width:\s*([\d.]+)(px|r?em)\)/g, A = (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(k)];
316
+ if (o.length !== 1) continue;
317
+ let [, s, c, l] = o[0], u = parseFloat(c);
318
+ if (s === "max") {
319
+ let t = r[l];
320
+ t && u > t.value && d("warn", `Media query "${e}" (max-width: ${u}${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 || u < t.value) && (r[l] = {
321
+ value: u,
322
+ key: e
323
+ });
324
+ } else {
325
+ let t = i[l];
326
+ t && u < t.value && d("warn", `Media query "${e}" (min-width: ${u}${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 || u > t.value) && (i[l] = {
327
+ value: u,
328
+ key: e
329
+ });
330
+ }
331
+ }
332
+ };
333
+ //#endregion
334
+ export { d as a, r as c, _ as i, w as n, i as o, g as r, a as s, T as t };
@@ -1,3 +1,3 @@
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(`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../util/index.cjs"),t=require("../parse-styles-B51bN86A.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-B5QRCMas.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-iylx7U1R.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,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
+ {"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;AAYlE;;;;;;;;;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,CAyQlB,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-PndoToaP.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-B51bN86A.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-B5QRCMas.js";
2
+ import { n as t } from "../parse-styles-iylx7U1R.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,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-B5QRCMas.js";
4
+ import { s as c, t as l } from "./parse-styles-iylx7U1R.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";
@@ -244,7 +244,7 @@ var X = {
244
244
  let A = c.map((e) => `@import url('./css/${e}');`).join("\n"), j = `/*!
245
245
  * Generated with Salty CSS (https://salty-css.dev)
246
246
  * Do not edit this file directly
247
- * Version 0.4.0-feat-include-version-info-in-info-comment.0
247
+ * Version 0.4.0
248
248
  */
249
249
  @layer imports, reset, global, templates, fonts, l0, l1, l2, l3, l4, l5, l6, l7, l8;\n\n${[
250
250
  "_imports.css",
@@ -1,9 +1,9 @@
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(`
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-B51bN86A.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)
5
5
  * Do not edit this file directly
6
- * Version 0.4.0-feat-include-version-info-in-info-comment.0
6
+ * Version 0.4.0
7
7
  */
8
8
  @layer imports, reset, global, templates, fonts, l0, l1, l2, l3, l4, l5, l6, l7, l8;\n\n${[`_imports.css`,`_variables.css`,`_reset.css`,`_global.css`,`_templates.css`,`_fonts.css`].filter(e=>{try{return(0,c.readFileSync)((0,u.join)(o,`css`,e),`utf8`).length>0}catch{return!1}}).map(e=>`@import url('./css/${e}')${e===`_imports.css`?` layer(imports)`:``};`).join(`
9
9
  `)}\n${x}`;if(y.importStrategy!==`component`){let e=a.reduce((e,t,r)=>{let i=t.reduce((e,t)=>{let r=(0,u.join)(o,`css`,t),i=(0,c.readFileSync)(r,`utf8`),a=/.*-([^-]+)-\d+.css/.exec(t)?.at(1)||n.toHash(r,6);return e.includes(a)?e:`${e}\n/*start:${a}-${t}*/\n${i}\n/*end:${a}*/\n`},``),a=`l_${r}.css`;return(0,c.writeFileSync)((0,u.join)(o,`css`,a),`@layer l${r} { ${i}\n }`),`${e}\n@import url('./css/${a}');`},``);S+=e}(0,c.writeFileSync)(s,S);let C=Date.now()-r,w=C<200?`🔥`:C<500?`🚀`:C<1e3?`🎉`:C<2e3?`🚗`:C<5e3?`🤔`:`🥴`;h.info(`Generated CSS in ${C}ms! ${w}`)}catch(e){console.error(e)}};generateConfigStyles=async e=>{let t=await this.getDestDir(),o={mediaQueries:[],globalStyles:[],variables:[],templates:[],imports:[],fonts:[]};await Promise.all([...e].map(async e=>{let{contents:n,outputFilePath:r}=await this.compileSaltyFile(e,t);Object.entries(n).forEach(([t,n])=>{n.isMedia?o.mediaQueries.push([t,n]):n.isGlobalDefine?o.globalStyles.push(n):n.isDefineVariables?o.variables.push(n):n.isDefineTemplates?o.templates.push(n._setPath(`${t};;${r}`)):n.isDefineImport?o.imports.push(n._setPath(e)):n.isDefineFont&&o.fonts.push(n)})}));let{config:l,path:d}=await this.generateConfig(),f={...l},{mediaQueries:p}=o;f.mediaQueries=Object.fromEntries(p.map(([e,t])=>[`@${e}`,t]));let m=p.map(([e])=>`'@${e}'`).join(` | `),g=new Set,_=async(e,t=[])=>{if(!e)return[];let r=Object.entries(e).map(async([e,r])=>{let a=async r=>{if(!r)return;if(r instanceof Promise)return await a(await r);if(typeof r==`function`)return await a(await r());if(typeof r==`object`)return await _(r,[...t,e]);let o=O(e),s=n.dashCase(e),c=[...t,o].join(`.`);g.add(`"${c}"`);let l=[...t.map(n.dashCase),s].join(`-`),u=i.s(r);return u?`--${l}: ${u.transformed};`:`--${l}: ${r};`};return await a(r)});return(await Promise.all(r)).flat()},v=async e=>{if(!e)return[];let t=Object.entries(e).map(async([e,t])=>{let n=await _(t);return e===`base`?n.join(``):f.mediaQueries[e]?`${f.mediaQueries[e]} { ${n.join(``)} }`:`${e} { ${n.join(``)} }`});return(await Promise.all(t)).flat()},y=async e=>{if(!e)return[];let t=Object.entries(e).map(async([e,t])=>{let n=Object.entries(t).map(async([t,n])=>{let r=await _(n,[e]);return`${`.${e}-${t}, [data-${e}="${t}"]`} { ${r.join(``)} }`});return(await Promise.all(n)).flat()});return(await Promise.all(t)).flat()},b=(e={})=>({...e,responsive:void 0,conditional:void 0}),x=e=>o.variables.map(t=>e===`static`?b(t._current):t._current[e]),S=a.mergeObjects(b(l.variables),x(`static`)),C=await _(S),T=await v(a.mergeObjects(l.variables?.responsive,x(`responsive`))),E=await y(a.mergeObjects(l.variables?.conditional,x(`conditional`)));(0,c.writeFileSync)((0,u.join)(t,`css/_variables.css`),`:root { ${C.join(``)} ${T.join(``)} } ${E.join(``)}`),f.staticVariables=S,(0,c.writeFileSync)((0,u.join)(t,`css/_global.css`),`@layer global { ${await i.t(a.mergeObjects(l.global,o.globalStyles),``)} }`);let D=(0,u.join)(t,`css/_reset.css`);(0,c.writeFileSync)(D,`@layer reset { ${await i.t(l.reset===`none`?{}:typeof l.reset==`object`?l.reset:k,``)} }`);let A=(0,u.join)(t,`css/_templates.css`),j=a.mergeObjects(l.templates,o.templates),M=await s.parseTemplates(j),N=s.getTemplateTypes(j),P=s.getTemplateVariantMaps(j);(0,c.writeFileSync)(A,`@layer templates { ${M} }`),f.templates=j;let F=(0,u.join)(t,`css/_imports.css`),I=[];for(let e of o.imports){let n=e._path;if(n)for(let r of e._current)try{let{rule:e}=w(r,n,t);I.push(e)}catch(e){let t=typeof r==`string`?r:r.url;h.error(`Failed to resolve defineImport(${JSON.stringify(t)}) from ${n}: ${e.message}`)}}(0,c.writeFileSync)(F,I.join(`
@@ -1,2 +1,2 @@
1
- export declare function dashCase(str: PropertyKey): string;
1
+ export declare function dashCase(str: PropertyKey | boolean): string;
2
2
  //# sourceMappingURL=dash-case.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dash-case.d.ts","sourceRoot":"","sources":["../../src/util/dash-case.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAMjD"}
1
+ {"version":3,"file":"dash-case.d.ts","sourceRoot":"","sources":["../../src/util/dash-case.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,GAAG,MAAM,CAO3D"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(t){return t?typeof t==`string`?t.replace(/\s/g,`-`).replace(/-([a-z])/g,e=>e[1].toUpperCase()):e(String(t)):``}function t(e){return e?typeof e==`string`?e.replace(/[\s.]/g,`-`).replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(e,t)=>(t>0?`-`:``)+e.toLowerCase()):t(String(e)):``}var n=e=>e.replace(/\\/g,`/`),r=new Map,i=e=>{let t=r.get(e);if(t)return t;let i=n(e),a=[];for(let e=0;e<i.length;e++){let t=i[e];if(t===`*`){let t=1;for(;i[e+1]===`*`;)e++,t++;a.push(t>=2?{type:`globstar`}:{type:`star`})}else t===`?`?a.push({type:`single`}):a.push({type:`lit`,char:t})}return r.set(e,a),a},a=(e,t)=>{let r=i(e),a=n(t),o=r.length,s=a.length,c=new Uint8Array((o+1)*(s+1)),l=(e,t)=>{let n=e*(s+1)+t,i=c[n];if(i)return i===2;let u;if(e===o)u=t===s;else{let n=r[e];switch(n.type){case`lit`:u=t<s&&a[t]===n.char&&l(e+1,t+1);break;case`single`:u=t<s&&a[t]!==`/`&&l(e+1,t+1);break;case`star`:u=l(e+1,t)||t<s&&a[t]!==`/`&&l(e,t+1);break;case`globstar`:u=l(e+1,t)||t<s&&l(e,t+1);break}}return c[n]=u?2:1,u};return l(0,0)},o=(e,t)=>t.some(t=>a(t,e)),s=(e,{include:t,exclude:n}={})=>n?.length&&o(e,n)?!1:t?.length?o(e,t):!0;function c(e){return e?typeof e==`string`?e.replace(/\s/g,`-`).replace(/[-_]([a-z0-9])/g,e=>e[1].toUpperCase()).replace(/^[a-z]/,e=>e.toUpperCase()):c(String(e)):``}var l=e=>String.fromCharCode(e+(e>25?39:97)),u=(e,t)=>{let n=``,r;for(r=Math.abs(e);r>52;r=r/52|0)n=l(r%52)+n;return n=l(r%52)+n,n.length<t?n=n.padStart(t,`a`):n.length>t&&(n=n.slice(-t)),n},d=(e,t)=>{let n=t.length;for(;n;)e=e*33^t.charCodeAt(--n);return e},f=(e,t=5)=>u(d(5381,JSON.stringify(e))>>>0,t);exports.camelCase=e,exports.dashCase=t,exports.isPathAllowed=s,exports.matchesAnyGlob=o,exports.matchesGlob=a,exports.normalizePath=n,exports.pascalCase=c,exports.toHash=f;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(t){return t?typeof t==`string`?t.replace(/\s/g,`-`).replace(/-([a-z])/g,e=>e[1].toUpperCase()):e(String(t)):``}function t(e){return e?typeof e!=`string`||typeof e!=`string`?t(String(e)):e.replace(/[\s.]/g,`-`).replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(e,t)=>(t>0?`-`:``)+e.toLowerCase()):``}var n=e=>e.replace(/\\/g,`/`),r=new Map,i=e=>{let t=r.get(e);if(t)return t;let i=n(e),a=[];for(let e=0;e<i.length;e++){let t=i[e];if(t===`*`){let t=1;for(;i[e+1]===`*`;)e++,t++;a.push(t>=2?{type:`globstar`}:{type:`star`})}else t===`?`?a.push({type:`single`}):a.push({type:`lit`,char:t})}return r.set(e,a),a},a=(e,t)=>{let r=i(e),a=n(t),o=r.length,s=a.length,c=new Uint8Array((o+1)*(s+1)),l=(e,t)=>{let n=e*(s+1)+t,i=c[n];if(i)return i===2;let u;if(e===o)u=t===s;else{let n=r[e];switch(n.type){case`lit`:u=t<s&&a[t]===n.char&&l(e+1,t+1);break;case`single`:u=t<s&&a[t]!==`/`&&l(e+1,t+1);break;case`star`:u=l(e+1,t)||t<s&&a[t]!==`/`&&l(e,t+1);break;case`globstar`:u=l(e+1,t)||t<s&&l(e,t+1);break}}return c[n]=u?2:1,u};return l(0,0)},o=(e,t)=>t.some(t=>a(t,e)),s=(e,{include:t,exclude:n}={})=>n?.length&&o(e,n)?!1:t?.length?o(e,t):!0;function c(e){return e?typeof e==`string`?e.replace(/\s/g,`-`).replace(/[-_]([a-z0-9])/g,e=>e[1].toUpperCase()).replace(/^[a-z]/,e=>e.toUpperCase()):c(String(e)):``}var l=e=>e?typeof e==`string`?t(e.replace(/[^a-zA-Z0-9_-]/g,`-`)):l(String(e)):``,u=e=>String.fromCharCode(e+(e>25?39:97)),d=(e,t)=>{let n=``,r;for(r=Math.abs(e);r>52;r=r/52|0)n=u(r%52)+n;return n=u(r%52)+n,n.length<t?n=n.padStart(t,`a`):n.length>t&&(n=n.slice(-t)),n},f=(e,t)=>{let n=t.length;for(;n;)e=e*33^t.charCodeAt(--n);return e},p=(e,t=5)=>d(f(5381,JSON.stringify(e))>>>0,t);exports.camelCase=e,exports.dashCase=t,exports.isPathAllowed=s,exports.matchesAnyGlob=o,exports.matchesGlob=a,exports.normalizePath=n,exports.pascalCase=c,exports.sanitizeClassName=l,exports.toHash=p;
@@ -2,5 +2,6 @@ export * from './camel-case';
2
2
  export * from './dash-case';
3
3
  export * from './glob-match';
4
4
  export * from './pascal-case';
5
+ export * from './sanitize-class-name';
5
6
  export * from './to-hash';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC"}
@@ -5,7 +5,7 @@ function e(t) {
5
5
  //#endregion
6
6
  //#region src/util/dash-case.ts
7
7
  function t(e) {
8
- return e ? typeof e == "string" ? e.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, t) => (t > 0 ? "-" : "") + e.toLowerCase()) : t(String(e)) : "";
8
+ return e ? typeof e != "string" || typeof e != "string" ? t(String(e)) : e.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, t) => (t > 0 ? "-" : "") + e.toLowerCase()) : "";
9
9
  }
10
10
  //#endregion
11
11
  //#region src/util/glob-match.ts
@@ -58,15 +58,15 @@ function c(e) {
58
58
  return e ? typeof e == "string" ? e.replace(/\s/g, "-").replace(/[-_]([a-z0-9])/g, (e) => e[1].toUpperCase()).replace(/^[a-z]/, (e) => e.toUpperCase()) : c(String(e)) : "";
59
59
  }
60
60
  //#endregion
61
- //#region src/util/to-hash.ts
62
- var l = (e) => String.fromCharCode(e + (e > 25 ? 39 : 97)), u = (e, t) => {
61
+ //#region src/util/sanitize-class-name.ts
62
+ var l = (e) => e ? typeof e == "string" ? t(e.replace(/[^a-zA-Z0-9_-]/g, "-")) : l(String(e)) : "", u = (e) => String.fromCharCode(e + (e > 25 ? 39 : 97)), d = (e, t) => {
63
63
  let n = "", r;
64
- for (r = Math.abs(e); r > 52; r = r / 52 | 0) n = l(r % 52) + n;
65
- return n = l(r % 52) + n, n.length < t ? n = n.padStart(t, "a") : n.length > t && (n = n.slice(-t)), n;
66
- }, d = (e, t) => {
64
+ for (r = Math.abs(e); r > 52; r = r / 52 | 0) n = u(r % 52) + n;
65
+ return n = u(r % 52) + n, n.length < t ? n = n.padStart(t, "a") : n.length > t && (n = n.slice(-t)), n;
66
+ }, f = (e, t) => {
67
67
  let n = t.length;
68
68
  for (; n;) e = e * 33 ^ t.charCodeAt(--n);
69
69
  return e;
70
- }, f = (e, t = 5) => u(d(5381, JSON.stringify(e)) >>> 0, t);
70
+ }, p = (e, t = 5) => d(f(5381, JSON.stringify(e)) >>> 0, t);
71
71
  //#endregion
72
- export { e as camelCase, t as dashCase, s as isPathAllowed, o as matchesAnyGlob, a as matchesGlob, n as normalizePath, c as pascalCase, f as toHash };
72
+ export { e as camelCase, t as dashCase, s as isPathAllowed, o as matchesAnyGlob, a as matchesGlob, n as normalizePath, c as pascalCase, l as sanitizeClassName, p as toHash };
@@ -0,0 +1,2 @@
1
+ export declare const sanitizeClassName: (str: PropertyKey | boolean) => string;
2
+ //# sourceMappingURL=sanitize-class-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitize-class-name.d.ts","sourceRoot":"","sources":["../../src/util/sanitize-class-name.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,GAAI,KAAK,WAAW,GAAG,OAAO,KAAG,MAK9D,CAAC"}
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.4.0-feat-include-version-info-in-info-comment.0",
18
+ "version": "0.4.0",
19
19
  "type": "module",
20
20
  "scripts": {
21
21
  "build": "vite build",
@@ -1,334 +0,0 @@
1
- import { dashCase as e } from "./util/index.js";
2
- import { t } from "./viewport-clamp-CRtzRvJ3.js";
3
- //#region src/parsers/parse-modifiers.ts
4
- var n = (e) => (t) => {
5
- if (typeof t != "string" || !e) return;
6
- let n = t, r = [];
7
- return Object.values(e).forEach((e) => {
8
- let { pattern: t, transform: i } = e;
9
- n = n.replace(t, (e) => {
10
- let { value: t, css: n } = i(e);
11
- return n && r.push(n), t;
12
- });
13
- }), {
14
- transformed: n,
15
- additionalCss: r
16
- };
17
- }, r = (t) => (n) => {
18
- if (typeof n == "string" && /\{[^{}]+\}/g.test(n)) return { transformed: n.replace(/\{([^{}]+)\}/g, (...n) => {
19
- let r = e(n[1].trim().replaceAll(".", "-"));
20
- return t && !t.includes(r) && console.warn(`Token ${r} might not exist`), r.startsWith("-") ? `-${r}` : `var(--${r})`;
21
- }) };
22
- }, i = r(), a = [
23
- "top",
24
- "right",
25
- "bottom",
26
- "left",
27
- "min-width",
28
- /.*width.*/,
29
- /^[^line]*height.*/,
30
- /padding.*/,
31
- /margin.*/,
32
- /border.*/,
33
- /inset.*/,
34
- /.*radius.*/,
35
- /.*spacing.*/,
36
- /.*gap.*/,
37
- /.*indent.*/,
38
- /.*offset.*/,
39
- /.*size.*/,
40
- /.*thickness.*/,
41
- /.*font-size.*/
42
- ], o = (e, n, r) => {
43
- if (a.some((t) => typeof t == "string" ? t === e : t.test(e))) {
44
- let e = r?.defaultUnit || "px";
45
- if (e.startsWith("viewport-clamp:")) try {
46
- let r = e.split(":")[1];
47
- return t({ screenSize: parseInt(r) })(Number(n));
48
- } catch (t) {
49
- throw console.error(t), Error(`Invalid viewport-clamp value: ${e}`);
50
- }
51
- return `${n}${e}`;
52
- }
53
- return `${n}`;
54
- }, s = [
55
- "Webkit",
56
- "Moz",
57
- "ms",
58
- "O"
59
- ], c = (e) => s.some((t) => {
60
- if (!e.startsWith(t)) return !1;
61
- let n = e.charAt(t.length);
62
- return n >= "A" && n <= "Z";
63
- }), l = (t) => t.startsWith("-") ? t : c(t) ? `-${e(t)}` : e(t), u = (e, t) => {
64
- if (e === !0) throw Error(`[salty-css] ${t}`);
65
- e === "warn" && console.warn(`[salty-css] ${t}`);
66
- }, 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) => {
67
- if (!e || typeof e != "object" || Array.isArray(e)) return !1;
68
- let t = Object.keys(e);
69
- return t.includes("base") || t.includes("variants");
70
- }, g = (e) => {
71
- if (typeof e == "string") {
72
- let [t, n] = e.split("@", 2), r = t.split(".").filter(Boolean);
73
- if (!r.length) return;
74
- let i = {};
75
- if (n) for (let e of n.split("&")) {
76
- if (!e) continue;
77
- let t = e.indexOf("=");
78
- if (t === -1) i[e.trim()] = !0;
79
- else {
80
- let n = e.slice(0, t).trim(), r = e.slice(t + 1).trim();
81
- if (!n) continue;
82
- r === "true" ? i[n] = !0 : r === "false" ? i[n] = !1 : i[n] = r;
83
- }
84
- }
85
- return {
86
- path: r,
87
- variants: i
88
- };
89
- }
90
- if (e && typeof e == "object" && !Array.isArray(e)) {
91
- let t = e, n = t.name;
92
- if (typeof n != "string") return;
93
- let r = n.split(".").filter(Boolean);
94
- if (!r.length) return;
95
- let i = {};
96
- for (let [e, n] of Object.entries(t)) e !== "name" && (typeof n == "string" || typeof n == "boolean") && (i[e] = n);
97
- return {
98
- path: r,
99
- variants: i
100
- };
101
- }
102
- }, _ = (e) => {
103
- if (e !== void 0) return typeof e == "boolean" ? String(e) : e;
104
- }, v = (e, t) => {
105
- let n = [{
106
- node: e,
107
- isRich: h(e)
108
- }], r = e;
109
- for (let e of t) {
110
- if (typeof r != "object" || !r) return;
111
- let t = r[e];
112
- if (t === void 0) return;
113
- n.push({
114
- node: t,
115
- isRich: h(t)
116
- }), r = t;
117
- }
118
- return n;
119
- }, y = (e, t) => {
120
- let n = v(e, t);
121
- return n ? n.some((e) => e.isRich) : !1;
122
- }, b = (e, t) => {
123
- for (let [n, r] of Object.entries(e)) if (n !== "css" && t[n] !== _(r)) return !1;
124
- return !0;
125
- }, x = (e, t) => {
126
- let n = !1;
127
- for (let [r, i] of Object.entries(e)) if (r !== "css" && (n = !0, t[r] === _(i))) return !0;
128
- return !n;
129
- }, S = (e, t, n, r) => {
130
- let i = v(e, t);
131
- if (!i) return;
132
- 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 = /* @__PURE__ */ new Set();
133
- for (let e of a) if (e.variants) for (let t of Object.keys(e.variants)) o.add(t);
134
- for (let e of a) if (e.defaultVariants) for (let t of Object.keys(e.defaultVariants)) o.add(t);
135
- let s = {};
136
- for (let e of o) {
137
- if (e in n) {
138
- s[e] = _(n[e]);
139
- continue;
140
- }
141
- for (let t = a.length - 1; t >= 0; t--) {
142
- let n = a[t].defaultVariants?.[e];
143
- if (n !== void 0) {
144
- s[e] = _(n);
145
- break;
146
- }
147
- }
148
- }
149
- for (let [e, i] of Object.entries(n)) {
150
- if (!o.has(e)) {
151
- console.warn(`Template "${r}" path "${t.join(".")}" has no variant axis "${e}"; ignored.`);
152
- continue;
153
- }
154
- let n = _(i), s = !1;
155
- for (let t of a) if (t.variants?.[e] && n !== void 0 && n in t.variants[e]) {
156
- s = !0;
157
- break;
158
- }
159
- !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.`);
160
- }
161
- let c = {};
162
- for (let e of a) e.base && Object.assign(c, e.base);
163
- for (let e of Object.keys(s)) {
164
- let t = s[e];
165
- if (t !== void 0) for (let n = a.length - 1; n >= 0; n--) {
166
- let r = a[n].variants?.[e]?.[t];
167
- if (r) {
168
- Object.assign(c, r);
169
- break;
170
- }
171
- }
172
- }
173
- for (let e of a) {
174
- if (e.compoundVariants) for (let t of e.compoundVariants) b(t, s) && t.css && Object.assign(c, t.css);
175
- if (e.anyOfVariants) for (let t of e.anyOfVariants) x(t, s) && t.css && Object.assign(c, t.css);
176
- }
177
- return c;
178
- }, C = async (e, t = "", i, a = !1) => {
179
- if (!e) throw Error("No styles provided to parseStyles function!");
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 = {
187
- scope: t,
188
- config: i
189
- };
190
- if (typeof n == "function") try {
191
- return await h([e, n(x)]);
192
- } catch (e) {
193
- return u(c, `Function value for "${r}" threw: ${e?.message ?? e}`), v();
194
- }
195
- if (n instanceof Promise) return h([e, await n]);
196
- if (i?.templates && i.templatePaths?.[r]) try {
197
- let [e, t] = i.templatePaths[r].split(";;"), a = await import(
198
- /* webpackIgnore: true */
199
- /* @vite-ignore */
200
- t
201
- ), o = t.includes("salty.config"), s = o ? a[e].templates : a[e], c = o ? s[r] : s.params[r];
202
- if (s && typeof c == "function") {
203
- let [e] = await C(await c(n), "");
204
- return v(e);
205
- }
206
- } catch (e) {
207
- return console.error(`Error loading template "${r}" from path "${i.templatePaths[r]}"`, e), v();
208
- }
209
- if (i?.templates && i.templates[r]) {
210
- if (a) return v();
211
- let e = i.templates[r], t = g(n);
212
- if (t) {
213
- let { path: n, variants: i } = t;
214
- if (Object.keys(i).length > 0 || y(e, n)) {
215
- let t = S(e, n, i, r);
216
- if (t) {
217
- let [e] = await C(t, "");
218
- return v(e);
219
- }
220
- return console.warn(`Template "${r}" with path of "${n.join(".")}" was not found in config!`), v();
221
- }
222
- let a = n.reduce((e, t) => e?.[t], e);
223
- if (a) {
224
- let [e] = await C(a, "");
225
- return v(e);
226
- }
227
- return console.warn(`Template "${r}" with path of "${n.join(".")}" was not found in config!`), v();
228
- }
229
- return console.warn(`Template "${r}" received an unsupported call-site value.`), v();
230
- }
231
- if (!(r === "compoundVariants" || r === "anyOfVariants") && Array.isArray(n)) return n.length === 0 ? v() : h([e, n.join(", ")]);
232
- if (typeof n == "object") {
233
- if (!n) return v();
234
- if (n.isColor || n.isDefineFont) return v(b(n.toString()));
235
- if (r === "defaultVariants") return v();
236
- if (r === "variants") {
237
- let e = Object.entries(n);
238
- for (let [n, r] of e) {
239
- if (!r) continue;
240
- let e = Object.entries(r);
241
- for (let [r, a] of e) a && (await C(a, `${t}.${n}-${r}`, i)).forEach((e) => _.push(e));
242
- }
243
- return v();
244
- }
245
- if (r === "compoundVariants") {
246
- for (let e of n) {
247
- let { css: n, ...r } = e;
248
- (await C(n, Object.entries(r).reduce((e, [t, n]) => `${e}.${t}-${n}`, t), i)).forEach((e) => _.push(e));
249
- }
250
- return v();
251
- }
252
- if (r === "anyOfVariants") {
253
- for (let e of n) {
254
- let { css: n, ...r } = e;
255
- (await C(n, `${t}:where(${Object.entries(r).map(([e, t]) => `.${e}-${t}`).join(", ")})`, i)).forEach((e) => _.push(e));
256
- }
257
- return v();
258
- }
259
- if (r === "global") return (await C(n, "", i)).forEach((e) => _.push(e)), v();
260
- if (r.startsWith("@")) {
261
- p.test(r) && u(c, `At-rule "${r}" is missing its condition (e.g. "@media (min-width: 600px)").`);
262
- let e = m.test(r) ? "" : t, a = `${i?.mediaQueries?.[r] || r} { ${await w(n, e, i)} }`;
263
- return _.push(a), v();
264
- }
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)}"?).`);
267
- let e = D(t, r);
268
- return (await C(n, e, i)).forEach((e) => _.push(e)), v();
269
- }
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) => {
280
- let n = await e;
281
- if (!n) return n;
282
- let r = await t(n);
283
- if (!r) return n;
284
- let { transformed: i, additionalCss: a } = r, o = "";
285
- if (a) for (let e of a) o += await w(e, "");
286
- return `${o}${i}`;
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];
293
- }, w = async (e, t, n, r = !1) => (await C(e, t, n, r)).join("\n"), T = (e) => {
294
- let t = [], n = 0, r = "";
295
- for (let i of e) if (i === "(" || i === "[" ? n++ : (i === ")" || i === "]") && (n = Math.max(0, n - 1)), i === "," && n === 0) {
296
- let e = r.trim();
297
- e && t.push(e), r = "";
298
- } else r += i;
299
- let i = r.trim();
300
- return i && t.push(i), t;
301
- }, E = (e, t) => t.includes("&") ? t.replaceAll("&", e) : t.startsWith(":") ? `${e}${t}` : `${e} ${t}`, D = (e, t) => {
302
- if (!e) return t;
303
- let n = T(e), r = T(t);
304
- if (!r.length) return e;
305
- if (n.length <= 1 && r.length <= 1) return E(n[0] ?? e, r[0]);
306
- let i = [];
307
- for (let e of n) for (let t of r) i.push(E(e, t));
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
- }
332
- };
333
- //#endregion
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 };