@salty-css/core 0.0.1-alpha.216 → 0.0.1-alpha.218

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/main.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("commander"),G=require("fs"),s=require("fs/promises"),n=require("path"),ne=require("ejs"),t=require("../index-B6M9WK93.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),se=require("child_process"),oe=require("ora");var z=typeof document<"u"?document.currentScript:null;const X=y=>new Promise((C,P)=>{se.exec(y,F=>{if(F)return P(F);C()})}),I=async(...y)=>{const C=y.map(b=>b.replace("-D","").split("@").slice(0,-1).join("@").trim()).join(", "),P=oe(`Installing packages: ${C}`).start(),F=y.join(" ");await X(`npm install ${F}`),P.succeed(`Installed packages: ${C}`)},ae=()=>G.existsSync(n.join(process.cwd(),"node_modules",".bin","prettier"));async function S(y){try{if(!ae())return;await X(`./node_modules/.bin/prettier --write "${y}"`),t.logger.info(`Formatted ${y} with Prettier`)}catch(C){t.logger.error(`Error formatting ${y} with Prettier:`,C)}}async function re(){const y=new te.Command;y.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");const C={"salty.config.ts":Promise.resolve().then(()=>require("../salty.config-Dk6ZcCxI.cjs")),"saltygen/index.css":Promise.resolve().then(()=>require("../index-84Wroia-.cjs")),"react/react-styled-file.ts":Promise.resolve().then(()=>require("../react-styled-file-Dkubsz-U.cjs")),"react/react-vanilla-file.ts":Promise.resolve().then(()=>require("../react-vanilla-file-CG_WJLam.cjs"))},P=async(i,a)=>{const{default:l}=await C[i],u=ne.render(l,a);return{fileName:i,content:u}},F=async()=>{const i=n.join(process.cwd(),".saltyrc.json");return await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>({}))},b=n.join(process.cwd(),"package.json"),N=async(i=b)=>{const a=await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>{});if(!a)throw"Could not read package.json file!";return a},Y=async(i,a=b)=>{typeof i=="object"&&(i=JSON.stringify(i,null,2)),await s.writeFile(a,i)},B=async()=>{const i=new URL("../package.json",typeof document>"u"?require("url").pathToFileURL(__filename).href:z&&z.tagName.toUpperCase()==="SCRIPT"&&z.src||new URL("bin/main.cjs",document.baseURI).href);return N(i)},V=await(async()=>(await F()).defaultProject)(),$=await B(),D={core:`@salty-css/core@${$.version}`,react:`@salty-css/react@${$.version}`,eslintConfigCore:`@salty-css/eslint-config-core@${$.version}`,vite:`@salty-css/vite@${$.version}`,next:`@salty-css/next@${$.version}`},R=i=>{const a=i==="."?"":i,l=process.cwd();return n.join(l,a)};y.command("init [directory]").description("Initialize a new Salty-CSS project.").option("-d, --dir <dir>","Project directory to initialize the project in.").option("--css-file <css-file>","Existing CSS file where to import the generated CSS. Path must be relative to the given project directory.").option("--skip-install","Skip installing dependencies.").action(async function(i="."){if(!await N().catch(()=>{}))return t.logError("Salty CSS project must be initialized in a directory with a package.json file.");t.logger.info("Initializing a new Salty-CSS project!");const{dir:l=i,cssFile:u,skipInstall:p}=this.opts();if(!l)return t.logError("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");p||await I(D.core,D.react);const f=process.cwd(),r=R(l),T=await Promise.all([P("salty.config.ts"),P("saltygen/index.css")]);await s.mkdir(r,{recursive:!0});const m=T.map(async({fileName:e,content:g})=>{const c=n.join(r,e);if(await s.readFile(c,"utf-8").catch(()=>{})!==void 0){t.logger.debug("File already exists: "+c);return}const k=e.split("/").slice(0,-1).join("/");k&&await s.mkdir(n.join(r,k),{recursive:!0}),t.logger.info("Creating file: "+c),await s.writeFile(c,g),await S(c)});await Promise.all(m);const w=n.relative(f,r)||".",h=n.join(f,".saltyrc.json"),d=await s.readFile(h,"utf-8").catch(()=>{});if(d===void 0){t.logger.info("Creating file: "+h);const g=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:w,projects:[{dir:w,framework:"react"}]},null,2);await s.writeFile(h,g),await S(h)}else{const e=JSON.parse(d),g=(e==null?void 0:e.projects)||[];if(g.findIndex(o=>o.dir===w)===-1){g.push({dir:w,framework:"react"}),e.projects=[...g];const o=JSON.stringify(e,null,2);o!==d&&(t.logger.info("Edit file: "+h),await s.writeFile(h,o),await S(h))}}const j=n.join(f,".gitignore"),U=await s.readFile(j,"utf-8").catch(()=>{});U!==void 0&&(U.includes("saltygen")||(t.logger.info("Edit file: "+j),await s.writeFile(j,U+`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("commander"),G=require("fs"),s=require("fs/promises"),n=require("path"),ne=require("ejs"),t=require("../index-BPohv4BZ.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),se=require("child_process"),oe=require("ora");var z=typeof document<"u"?document.currentScript:null;const X=y=>new Promise((C,P)=>{se.exec(y,F=>{if(F)return P(F);C()})}),I=async(...y)=>{const C=y.map(b=>b.replace("-D","").split("@").slice(0,-1).join("@").trim()).join(", "),P=oe(`Installing packages: ${C}`).start(),F=y.join(" ");await X(`npm install ${F}`),P.succeed(`Installed packages: ${C}`)},ae=()=>G.existsSync(n.join(process.cwd(),"node_modules",".bin","prettier"));async function S(y){try{if(!ae())return;await X(`./node_modules/.bin/prettier --write "${y}"`),t.logger.info(`Formatted ${y} with Prettier`)}catch(C){t.logger.error(`Error formatting ${y} with Prettier:`,C)}}async function re(){const y=new te.Command;y.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");const C={"salty.config.ts":Promise.resolve().then(()=>require("../salty.config-Dk6ZcCxI.cjs")),"saltygen/index.css":Promise.resolve().then(()=>require("../index-84Wroia-.cjs")),"react/react-styled-file.ts":Promise.resolve().then(()=>require("../react-styled-file-Dkubsz-U.cjs")),"react/react-vanilla-file.ts":Promise.resolve().then(()=>require("../react-vanilla-file-CG_WJLam.cjs"))},P=async(i,a)=>{const{default:l}=await C[i],u=ne.render(l,a);return{fileName:i,content:u}},F=async()=>{const i=n.join(process.cwd(),".saltyrc.json");return await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>({}))},b=n.join(process.cwd(),"package.json"),N=async(i=b)=>{const a=await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>{});if(!a)throw"Could not read package.json file!";return a},Y=async(i,a=b)=>{typeof i=="object"&&(i=JSON.stringify(i,null,2)),await s.writeFile(a,i)},B=async()=>{const i=new URL("../package.json",typeof document>"u"?require("url").pathToFileURL(__filename).href:z&&z.tagName.toUpperCase()==="SCRIPT"&&z.src||new URL("bin/main.cjs",document.baseURI).href);return N(i)},V=await(async()=>(await F()).defaultProject)(),$=await B(),D={core:`@salty-css/core@${$.version}`,react:`@salty-css/react@${$.version}`,eslintConfigCore:`@salty-css/eslint-config-core@${$.version}`,vite:`@salty-css/vite@${$.version}`,next:`@salty-css/next@${$.version}`},R=i=>{const a=i==="."?"":i,l=process.cwd();return n.join(l,a)};y.command("init [directory]").description("Initialize a new Salty-CSS project.").option("-d, --dir <dir>","Project directory to initialize the project in.").option("--css-file <css-file>","Existing CSS file where to import the generated CSS. Path must be relative to the given project directory.").option("--skip-install","Skip installing dependencies.").action(async function(i="."){if(!await N().catch(()=>{}))return t.logError("Salty CSS project must be initialized in a directory with a package.json file.");t.logger.info("Initializing a new Salty-CSS project!");const{dir:l=i,cssFile:u,skipInstall:p}=this.opts();if(!l)return t.logError("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");p||await I(D.core,D.react);const f=process.cwd(),r=R(l),T=await Promise.all([P("salty.config.ts"),P("saltygen/index.css")]);await s.mkdir(r,{recursive:!0});const m=T.map(async({fileName:e,content:g})=>{const c=n.join(r,e);if(await s.readFile(c,"utf-8").catch(()=>{})!==void 0){t.logger.debug("File already exists: "+c);return}const k=e.split("/").slice(0,-1).join("/");k&&await s.mkdir(n.join(r,k),{recursive:!0}),t.logger.info("Creating file: "+c),await s.writeFile(c,g),await S(c)});await Promise.all(m);const w=n.relative(f,r)||".",h=n.join(f,".saltyrc.json"),d=await s.readFile(h,"utf-8").catch(()=>{});if(d===void 0){t.logger.info("Creating file: "+h);const g=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:w,projects:[{dir:w,framework:"react"}]},null,2);await s.writeFile(h,g),await S(h)}else{const e=JSON.parse(d),g=(e==null?void 0:e.projects)||[];if(g.findIndex(o=>o.dir===w)===-1){g.push({dir:w,framework:"react"}),e.projects=[...g];const o=JSON.stringify(e,null,2);o!==d&&(t.logger.info("Edit file: "+h),await s.writeFile(h,o),await S(h))}}const j=n.join(f,".gitignore"),U=await s.readFile(j,"utf-8").catch(()=>{});U!==void 0&&(U.includes("saltygen")||(t.logger.info("Edit file: "+j),await s.writeFile(j,U+`
2
2
 
3
3
  # Salty-CSS
4
4
  saltygen
package/bin/main.js CHANGED
@@ -3,7 +3,7 @@ import { existsSync as K } from "fs";
3
3
  import { mkdir as q, readFile as C, writeFile as w } from "fs/promises";
4
4
  import { join as i, relative as z, parse as re, format as ee } from "path";
5
5
  import { render as ce } from "ejs";
6
- import { l as t, a as h, g as te } from "../index-B_bv7TCc.js";
6
+ import { l as t, a as h, g as te } from "../index-DVSBEd3f.js";
7
7
  import { p as le } from "../pascal-case-BQpR5PdN.js";
8
8
  import { exec as de } from "child_process";
9
9
  import fe from "ora";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-BJEkFEGQ.cjs");require("path");require("fs");require("fs/promises");require("../parse-styles-C6OYNcYI.cjs");const e=require("../index-B6M9WK93.cjs");require("../css/merge.cjs");require("../define-templates-Cunsb_Tr.cjs");exports.compileSaltyFile=e.compileSaltyFile;exports.generateConfigStyles=e.generateConfigStyles;exports.generateCss=e.generateCss;exports.generateFile=e.generateFile;exports.isSaltyFile=e.isSaltyFile;exports.minimizeFile=e.minimizeFile;exports.saltyFileExtensions=e.saltyFileExtensions;exports.saltyFileRegExp=e.saltyFileRegExp;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-BJEkFEGQ.cjs");require("path");require("fs");require("fs/promises");require("../parse-styles-C6OYNcYI.cjs");const e=require("../index-BPohv4BZ.cjs");require("../css/merge.cjs");require("../define-templates-Cunsb_Tr.cjs");exports.compileSaltyFile=e.compileSaltyFile;exports.generateConfigStyles=e.generateConfigStyles;exports.generateCss=e.generateCss;exports.generateFile=e.generateFile;exports.isSaltyFile=e.isSaltyFile;exports.minimizeFile=e.minimizeFile;exports.saltyFileExtensions=e.saltyFileExtensions;exports.saltyFileRegExp=e.saltyFileRegExp;
package/compiler/index.js CHANGED
@@ -5,7 +5,7 @@ import "path";
5
5
  import "fs";
6
6
  import "fs/promises";
7
7
  import "../parse-styles-Cc_Ir3PV.js";
8
- import { d as g, c as F, g as y, e as x, i as S, m as c, s as f, b as C } from "../index-B_bv7TCc.js";
8
+ import { d as g, c as F, g as y, e as x, i as S, m as c, s as f, b as C } from "../index-DVSBEd3f.js";
9
9
  import "../css/merge.js";
10
10
  import "../define-templates-4A2yHcMF.js";
11
11
  export {
package/helpers/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var A=Object.defineProperty;var S=(e,t,n)=>t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _=(e,t,n)=>S(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},O=Object.create(null);for(const e in w)Object.hasOwn(w,e)&&(O[w[e]]=e);const d={to:{},get:{}};d.get=function(e){const t=e.slice(0,3).toLowerCase();let n,r;switch(t){case"hsl":{n=d.get.hsl(e),r="hsl";break}case"hwb":{n=d.get.hwb(e),r="hwb";break}default:{n=d.get.rgb(e),r="rgb";break}}return n?{model:r,value:n}:null};d.get.rgb=function(e){if(!e)return null;const t=/^#([a-f\d]{3,4})$/i,n=/^#([a-f\d]{6})([a-f\d]{2})?$/i,r=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/,o=/^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/,l=/^(\w+)$/;let s=[0,0,0,1],a,i,u;if(a=e.match(n)){for(u=a[2],a=a[1],i=0;i<3;i++){const m=i*2;s[i]=Number.parseInt(a.slice(m,m+2),16)}u&&(s[3]=Number.parseInt(u,16)/255)}else if(a=e.match(t)){for(a=a[1],u=a[3],i=0;i<3;i++)s[i]=Number.parseInt(a[i]+a[i],16);u&&(s[3]=Number.parseInt(u+u,16)/255)}else if(a=e.match(r)){for(i=0;i<3;i++)s[i]=Number.parseInt(a[i+1],10);a[4]&&(s[3]=a[5]?Number.parseFloat(a[4])*.01:Number.parseFloat(a[4]))}else if(a=e.match(o)){for(i=0;i<3;i++)s[i]=Math.round(Number.parseFloat(a[i+1])*2.55);a[4]&&(s[3]=a[5]?Number.parseFloat(a[4])*.01:Number.parseFloat(a[4]))}else return(a=e.match(l))?a[1]==="transparent"?[0,0,0,0]:Object.hasOwn(w,a[1])?(s=w[a[1]],s[3]=1,s):null:null;for(i=0;i<3;i++)s[i]=k(s[i],0,255);return s[3]=k(s[3],0,1),s};d.get.hsl=function(e){if(!e)return null;const t=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,n=e.match(t);if(n){const r=Number.parseFloat(n[4]),o=(Number.parseFloat(n[1])%360+360)%360,l=k(Number.parseFloat(n[2]),0,100),s=k(Number.parseFloat(n[3]),0,100),a=k(Number.isNaN(r)?1:r,0,1);return[o,l,s,a]}return null};d.get.hwb=function(e){if(!e)return null;const t=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,n=e.match(t);if(n){const r=Number.parseFloat(n[4]),o=(Number.parseFloat(n[1])%360+360)%360,l=k(Number.parseFloat(n[2]),0,100),s=k(Number.parseFloat(n[3]),0,100),a=k(Number.isNaN(r)?1:r,0,1);return[o,l,s,a]}return null};d.to.hex=function(...e){return"#"+x(e[0])+x(e[1])+x(e[2])+(e[3]<1?x(Math.round(e[3]*255)):"")};d.to.rgb=function(...e){return e.length<4||e[3]===1?"rgb("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+")":"rgba("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+", "+e[3]+")"};d.to.rgb.percent=function(...e){const t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),r=Math.round(e[2]/255*100);return e.length<4||e[3]===1?"rgb("+t+"%, "+n+"%, "+r+"%)":"rgba("+t+"%, "+n+"%, "+r+"%, "+e[3]+")"};d.to.hsl=function(...e){return e.length<4||e[3]===1?"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)":"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+e[3]+")"};d.to.hwb=function(...e){let t="";return e.length>=4&&e[3]!==1&&(t=", "+e[3]),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+t+")"};d.to.keyword=function(...e){return O[e.slice(0,3)]};function k(e,t,n){return Math.min(Math.max(t,e),n)}function x(e){const t=Math.round(e).toString(16).toUpperCase();return t.length<2?"0"+t:t}const M={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},q={};for(const e of Object.keys(M))q[M[e]]=e;const c={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}},y=(6/29)**3;for(const e of Object.keys(c)){if(!("channels"in c[e]))throw new Error("missing channels property: "+e);if(!("labels"in c[e]))throw new Error("missing channel labels property: "+e);if(c[e].labels.length!==c[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:n}=c[e];delete c[e].channels,delete c[e].labels,Object.defineProperty(c[e],"channels",{value:t}),Object.defineProperty(c[e],"labels",{value:n})}c.rgb.hsl=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,o=Math.min(t,n,r),l=Math.max(t,n,r),s=l-o;let a,i;switch(l){case o:{a=0;break}case t:{a=(n-r)/s;break}case n:{a=2+(r-t)/s;break}case r:{a=4+(t-n)/s;break}}a=Math.min(a*60,360),a<0&&(a+=360);const u=(o+l)/2;return l===o?i=0:u<=.5?i=s/(l+o):i=s/(2-l-o),[a,i*100,u*100]};c.rgb.hsv=function(e){let t,n,r,o,l;const s=e[0]/255,a=e[1]/255,i=e[2]/255,u=Math.max(s,a,i),m=u-Math.min(s,a,i),p=function(z){return(u-z)/6/m+1/2};if(m===0)o=0,l=0;else{switch(l=m/u,t=p(s),n=p(a),r=p(i),u){case s:{o=r-n;break}case a:{o=1/3+t-r;break}case i:{o=2/3+n-t;break}}o<0?o+=1:o>1&&(o-=1)}return[o*360,l*100,u*100]};c.rgb.hwb=function(e){const t=e[0],n=e[1];let r=e[2];const o=c.rgb.hsl(e)[0],l=1/255*Math.min(t,Math.min(n,r));return r=1-1/255*Math.max(t,Math.max(n,r)),[o,l*100,r*100]};c.rgb.cmyk=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,o=Math.min(1-t,1-n,1-r),l=(1-t-o)/(1-o)||0,s=(1-n-o)/(1-o)||0,a=(1-r-o)/(1-o)||0;return[l*100,s*100,a*100,o*100]};function P(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}c.rgb.keyword=function(e){const t=q[e];if(t)return t;let n=Number.POSITIVE_INFINITY,r;for(const o of Object.keys(M)){const l=M[o],s=P(e,l);s<n&&(n=s,r=o)}return r};c.keyword.rgb=function(e){return M[e]};c.rgb.xyz=function(e){let t=e[0]/255,n=e[1]/255,r=e[2]/255;t=t>.04045?((t+.055)/1.055)**2.4:t/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92;const o=t*.4124564+n*.3575761+r*.1804375,l=t*.2126729+n*.7151522+r*.072175,s=t*.0193339+n*.119192+r*.9503041;return[o*100,l*100,s*100]};c.rgb.lab=function(e){const t=c.rgb.xyz(e);let n=t[0],r=t[1],o=t[2];n/=95.047,r/=100,o/=108.883,n=n>y?n**(1/3):7.787*n+16/116,r=r>y?r**(1/3):7.787*r+16/116,o=o>y?o**(1/3):7.787*o+16/116;const l=116*r-16,s=500*(n-r),a=200*(r-o);return[l,s,a]};c.hsl.rgb=function(e){const t=e[0]/360,n=e[1]/100,r=e[2]/100;let o,l;if(n===0)return l=r*255,[l,l,l];const s=r<.5?r*(1+n):r+n-r*n,a=2*r-s,i=[0,0,0];for(let u=0;u<3;u++)o=t+1/3*-(u-1),o<0&&o++,o>1&&o--,6*o<1?l=a+(s-a)*6*o:2*o<1?l=s:3*o<2?l=a+(s-a)*(2/3-o)*6:l=a,i[u]=l*255;return i};c.hsl.hsv=function(e){const t=e[0];let n=e[1]/100,r=e[2]/100,o=n;const l=Math.max(r,.01);r*=2,n*=r<=1?r:2-r,o*=l<=1?l:2-l;const s=(r+n)/2,a=r===0?2*o/(l+o):2*n/(r+n);return[t,a*100,s*100]};c.hsv.rgb=function(e){const t=e[0]/60,n=e[1]/100;let r=e[2]/100;const o=Math.floor(t)%6,l=t-Math.floor(t),s=255*r*(1-n),a=255*r*(1-n*l),i=255*r*(1-n*(1-l));switch(r*=255,o){case 0:return[r,i,s];case 1:return[a,r,s];case 2:return[s,r,i];case 3:return[s,a,r];case 4:return[i,s,r];case 5:return[r,s,a]}};c.hsv.hsl=function(e){const t=e[0],n=e[1]/100,r=e[2]/100,o=Math.max(r,.01);let l,s;s=(2-n)*r;const a=(2-n)*o;return l=n*o,l/=a<=1?a:2-a,l=l||0,s/=2,[t,l*100,s*100]};c.hwb.rgb=function(e){const t=e[0]/360;let n=e[1]/100,r=e[2]/100;const o=n+r;let l;o>1&&(n/=o,r/=o);const s=Math.floor(6*t),a=1-r;l=6*t-s,(s&1)!==0&&(l=1-l);const i=n+l*(a-n);let u,m,p;switch(s){default:case 6:case 0:{u=a,m=i,p=n;break}case 1:{u=i,m=a,p=n;break}case 2:{u=n,m=a,p=i;break}case 3:{u=n,m=i,p=a;break}case 4:{u=i,m=n,p=a;break}case 5:{u=a,m=n,p=i;break}}return[u*255,m*255,p*255]};c.cmyk.rgb=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100,o=e[3]/100,l=1-Math.min(1,t*(1-o)+o),s=1-Math.min(1,n*(1-o)+o),a=1-Math.min(1,r*(1-o)+o);return[l*255,s*255,a*255]};c.xyz.rgb=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100;let o,l,s;return o=t*3.2404542+n*-1.5371385+r*-.4985314,l=t*-.969266+n*1.8760108+r*.041556,s=t*.0556434+n*-.2040259+r*1.0572252,o=o>.0031308?1.055*o**(1/2.4)-.055:o*12.92,l=l>.0031308?1.055*l**(1/2.4)-.055:l*12.92,s=s>.0031308?1.055*s**(1/2.4)-.055:s*12.92,o=Math.min(Math.max(0,o),1),l=Math.min(Math.max(0,l),1),s=Math.min(Math.max(0,s),1),[o*255,l*255,s*255]};c.xyz.lab=function(e){let t=e[0],n=e[1],r=e[2];t/=95.047,n/=100,r/=108.883,t=t>y?t**(1/3):7.787*t+16/116,n=n>y?n**(1/3):7.787*n+16/116,r=r>y?r**(1/3):7.787*r+16/116;const o=116*n-16,l=500*(t-n),s=200*(n-r);return[o,l,s]};c.lab.xyz=function(e){const t=e[0],n=e[1],r=e[2];let o,l,s;l=(t+16)/116,o=n/500+l,s=l-r/200;const a=l**3,i=o**3,u=s**3;return l=a>y?a:(l-16/116)/7.787,o=i>y?i:(o-16/116)/7.787,s=u>y?u:(s-16/116)/7.787,o*=95.047,l*=100,s*=108.883,[o,l,s]};c.lab.lch=function(e){const t=e[0],n=e[1],r=e[2];let o;o=Math.atan2(r,n)*360/2/Math.PI,o<0&&(o+=360);const s=Math.sqrt(n*n+r*r);return[t,s,o]};c.lch.lab=function(e){const t=e[0],n=e[1],o=e[2]/360*2*Math.PI,l=n*Math.cos(o),s=n*Math.sin(o);return[t,l,s]};c.rgb.ansi16=function(e,t=null){const[n,r,o]=e;let l=t===null?c.rgb.hsv(e)[2]:t;if(l=Math.round(l/50),l===0)return 30;let s=30+(Math.round(o/255)<<2|Math.round(r/255)<<1|Math.round(n/255));return l===2&&(s+=60),s};c.hsv.ansi16=function(e){return c.rgb.ansi16(c.hsv.rgb(e),e[2])};c.rgb.ansi256=function(e){const t=e[0],n=e[1],r=e[2];return t>>4===n>>4&&n>>4===r>>4?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)};c.ansi16.rgb=function(e){e=e[0];let t=e%10;if(t===0||t===7)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const n=(Math.trunc(e>50)+1)*.5,r=(t&1)*n*255,o=(t>>1&1)*n*255,l=(t>>2&1)*n*255;return[r,o,l]};c.ansi256.rgb=function(e){if(e=e[0],e>=232){const l=(e-232)*10+8;return[l,l,l]}e-=16;let t;const n=Math.floor(e/36)/5*255,r=Math.floor((t=e%36)/6)/5*255,o=t%6/5*255;return[n,r,o]};c.rgb.hex=function(e){const n=(((Math.round(e[0])&255)<<16)+((Math.round(e[1])&255)<<8)+(Math.round(e[2])&255)).toString(16).toUpperCase();return"000000".slice(n.length)+n};c.hex.rgb=function(e){const t=e.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!t)return[0,0,0];let n=t[0];t[0].length===3&&(n=[...n].map(a=>a+a).join(""));const r=Number.parseInt(n,16),o=r>>16&255,l=r>>8&255,s=r&255;return[o,l,s]};c.rgb.hcg=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,o=Math.max(Math.max(t,n),r),l=Math.min(Math.min(t,n),r),s=o-l;let a;const i=s<1?l/(1-s):0;return s<=0?a=0:o===t?a=(n-r)/s%6:o===n?a=2+(r-t)/s:a=4+(t-n)/s,a/=6,a%=1,[a*360,s*100,i*100]};c.hsl.hcg=function(e){const t=e[1]/100,n=e[2]/100,r=n<.5?2*t*n:2*t*(1-n);let o=0;return r<1&&(o=(n-.5*r)/(1-r)),[e[0],r*100,o*100]};c.hsv.hcg=function(e){const t=e[1]/100,n=e[2]/100,r=t*n;let o=0;return r<1&&(o=(n-r)/(1-r)),[e[0],r*100,o*100]};c.hcg.rgb=function(e){const t=e[0]/360,n=e[1]/100,r=e[2]/100;if(n===0)return[r*255,r*255,r*255];const o=[0,0,0],l=t%1*6,s=l%1,a=1-s;let i=0;switch(Math.floor(l)){case 0:{o[0]=1,o[1]=s,o[2]=0;break}case 1:{o[0]=a,o[1]=1,o[2]=0;break}case 2:{o[0]=0,o[1]=1,o[2]=s;break}case 3:{o[0]=0,o[1]=a,o[2]=1;break}case 4:{o[0]=s,o[1]=0,o[2]=1;break}default:o[0]=1,o[1]=0,o[2]=a}return i=(1-n)*r,[(n*o[0]+i)*255,(n*o[1]+i)*255,(n*o[2]+i)*255]};c.hcg.hsv=function(e){const t=e[1]/100,n=e[2]/100,r=t+n*(1-t);let o=0;return r>0&&(o=t/r),[e[0],o*100,r*100]};c.hcg.hsl=function(e){const t=e[1]/100,r=e[2]/100*(1-t)+.5*t;let o=0;return r>0&&r<.5?o=t/(2*r):r>=.5&&r<1&&(o=t/(2*(1-r))),[e[0],o*100,r*100]};c.hcg.hwb=function(e){const t=e[1]/100,n=e[2]/100,r=t+n*(1-t);return[e[0],(r-t)*100,(1-r)*100]};c.hwb.hcg=function(e){const t=e[1]/100,r=1-e[2]/100,o=r-t;let l=0;return o<1&&(l=(r-o)/(1-o)),[e[0],o*100,l*100]};c.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]};c.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]};c.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]};c.gray.hsl=function(e){return[0,0,e[0]]};c.gray.hsv=c.gray.hsl;c.gray.hwb=function(e){return[0,100,e[0]]};c.gray.cmyk=function(e){return[0,0,0,e[0]]};c.gray.lab=function(e){return[e[0],0,0]};c.gray.hex=function(e){const t=Math.round(e[0]/100*255)&255,r=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".slice(r.length)+r};c.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]};function I(){const e={},t=Object.keys(c);for(let{length:n}=t,r=0;r<n;r++)e[t[r]]={distance:-1,parent:null};return e}function j(e){const t=I(),n=[e];for(t[e].distance=0;n.length>0;){const r=n.pop(),o=Object.keys(c[r]);for(let{length:l}=o,s=0;s<l;s++){const a=o[s],i=t[a];i.distance===-1&&(i.distance=t[r].distance+1,i.parent=r,n.unshift(a))}}return t}function E(e,t){return function(n){return t(e(n))}}function $(e,t){const n=[t[e].parent,e];let r=c[t[e].parent][e],o=t[e].parent;for(;t[o].parent;)n.unshift(t[o].parent),r=E(c[t[o].parent][o],r),o=t[o].parent;return r.conversion=n,r}function T(e){const t=j(e),n={},r=Object.keys(t);for(let{length:o}=r,l=0;l<o;l++){const s=r[l];t[s].parent!==null&&(n[s]=$(s,t))}return n}const g={},U=Object.keys(c);function D(e){const t=function(...n){const r=n[0];return r==null?r:(r.length>1&&(n=r),e(n))};return"conversion"in e&&(t.conversion=e.conversion),t}function K(e){const t=function(...n){const r=n[0];if(r==null)return r;r.length>1&&(n=r);const o=e(n);if(typeof o=="object")for(let{length:l}=o,s=0;s<l;s++)o[s]=Math.round(o[s]);return o};return"conversion"in e&&(t.conversion=e.conversion),t}for(const e of U){g[e]={},Object.defineProperty(g[e],"channels",{value:c[e].channels}),Object.defineProperty(g[e],"labels",{value:c[e].labels});const t=T(e),n=Object.keys(t);for(const r of n){const o=t[r];g[e][r]=K(o),g[e][r].raw=D(o)}}const C=["keyword","gray","hex"],F={};for(const e of Object.keys(g))F[[...g[e].labels].sort().join("")]=e;const v={};function b(e,t){if(!(this instanceof b))return new b(e,t);if(t&&t in C&&(t=null),t&&!(t in g))throw new Error("Unknown model: "+t);let n,r;if(e==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(e instanceof b)this.model=e.model,this.color=[...e.color],this.valpha=e.valpha;else if(typeof e=="string"){const o=d.get(e);if(o===null)throw new Error("Unable to parse color from string: "+e);this.model=o.model,r=g[this.model].channels,this.color=o.value.slice(0,r),this.valpha=typeof o.value[r]=="number"?o.value[r]:1}else if(e.length>0){this.model=t||"rgb",r=g[this.model].channels;const o=Array.prototype.slice.call(e,0,r);this.color=N(o,r),this.valpha=typeof e[r]=="number"?e[r]:1}else if(typeof e=="number")this.model="rgb",this.color=[e>>16&255,e>>8&255,e&255],this.valpha=1;else{this.valpha=1;const o=Object.keys(e);"alpha"in e&&(o.splice(o.indexOf("alpha"),1),this.valpha=typeof e.alpha=="number"?e.alpha:0);const l=o.sort().join("");if(!(l in F))throw new Error("Unable to parse color from object: "+JSON.stringify(e));this.model=F[l];const{labels:s}=g[this.model],a=[];for(n=0;n<s.length;n++)a.push(e[s[n]]);this.color=N(a)}if(v[this.model])for(r=g[this.model].channels,n=0;n<r;n++){const o=v[this.model][n];o&&(this.color[n]=o(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}b.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(e){let t=this.model in d.to?this:this.rgb();t=t.round(typeof e=="number"?e:1);const n=t.valpha===1?t.color:[...t.color,this.valpha];return d.to[t.model](...n)},percentString(e){const t=this.rgb().round(typeof e=="number"?e:1),n=t.valpha===1?t.color:[...t.color,this.valpha];return d.to.rgb.percent(...n)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){const e={},{channels:t}=g[this.model],{labels:n}=g[this.model];for(let r=0;r<t;r++)e[n[r]]=this.color[r];return this.valpha!==1&&(e.alpha=this.valpha),e},unitArray(){const e=this.rgb().color;return e[0]/=255,e[1]/=255,e[2]/=255,this.valpha!==1&&e.push(this.valpha),e},unitObject(){const e=this.rgb().object();return e.r/=255,e.g/=255,e.b/=255,this.valpha!==1&&(e.alpha=this.valpha),e},round(e){return e=Math.max(e||0,0),new b([...this.color.map(L(e)),this.valpha],this.model)},alpha(e){return e!==void 0?new b([...this.color,Math.max(0,Math.min(1,e))],this.model):this.valpha},red:h("rgb",0,f(255)),green:h("rgb",1,f(255)),blue:h("rgb",2,f(255)),hue:h(["hsl","hsv","hsl","hwb","hcg"],0,e=>(e%360+360)%360),saturationl:h("hsl",1,f(100)),lightness:h("hsl",2,f(100)),saturationv:h("hsv",1,f(100)),value:h("hsv",2,f(100)),chroma:h("hcg",1,f(100)),gray:h("hcg",2,f(100)),white:h("hwb",1,f(100)),wblack:h("hwb",2,f(100)),cyan:h("cmyk",0,f(100)),magenta:h("cmyk",1,f(100)),yellow:h("cmyk",2,f(100)),black:h("cmyk",3,f(100)),x:h("xyz",0,f(95.047)),y:h("xyz",1,f(100)),z:h("xyz",2,f(108.833)),l:h("lab",0,f(100)),a:h("lab",1),b:h("lab",2),keyword(e){return e!==void 0?new b(e):g[this.model].keyword(this.color)},hex(e){return e!==void 0?new b(e):d.to.hex(...this.rgb().round().color)},hexa(e){if(e!==void 0)return new b(e);const t=this.rgb().round().color;let n=Math.round(this.valpha*255).toString(16).toUpperCase();return n.length===1&&(n="0"+n),d.to.hex(...t)+n},rgbNumber(){const e=this.rgb().color;return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255},luminosity(){const e=this.rgb().color,t=[];for(const[n,r]of e.entries()){const o=r/255;t[n]=o<=.04045?o/12.92:((o+.055)/1.055)**2.4}return .2126*t[0]+.7152*t[1]+.0722*t[2]},contrast(e){const t=this.luminosity(),n=e.luminosity();return t>n?(t+.05)/(n+.05):(n+.05)/(t+.05)},level(e){const t=this.contrast(e);return t>=7?"AAA":t>=4.5?"AA":""},isDark(){const e=this.rgb().color;return(e[0]*2126+e[1]*7152+e[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){const e=this.rgb();for(let t=0;t<3;t++)e.color[t]=255-e.color[t];return e},lighten(e){const t=this.hsl();return t.color[2]+=t.color[2]*e,t},darken(e){const t=this.hsl();return t.color[2]-=t.color[2]*e,t},saturate(e){const t=this.hsl();return t.color[1]+=t.color[1]*e,t},desaturate(e){const t=this.hsl();return t.color[1]-=t.color[1]*e,t},whiten(e){const t=this.hwb();return t.color[1]+=t.color[1]*e,t},blacken(e){const t=this.hwb();return t.color[2]+=t.color[2]*e,t},grayscale(){const e=this.rgb().color,t=e[0]*.3+e[1]*.59+e[2]*.11;return b.rgb(t,t,t)},fade(e){return this.alpha(this.valpha-this.valpha*e)},opaquer(e){return this.alpha(this.valpha+this.valpha*e)},rotate(e){const t=this.hsl();let n=t.color[0];return n=(n+e)%360,n=n<0?360+n:n,t.color[0]=n,t},mix(e,t){if(!e||!e.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e);const n=e.rgb(),r=this.rgb(),o=t===void 0?.5:t,l=2*o-1,s=n.alpha()-r.alpha(),a=((l*s===-1?l:(l+s)/(1+l*s))+1)/2,i=1-a;return b.rgb(a*n.red()+i*r.red(),a*n.green()+i*r.green(),a*n.blue()+i*r.blue(),n.alpha()*o+r.alpha()*(1-o))}};for(const e of Object.keys(g)){if(C.includes(e))continue;const{channels:t}=g[e];b.prototype[e]=function(...n){return this.model===e?new b(this):n.length>0?new b(n,e):new b([...R(g[this.model][e].raw(this.color)),this.valpha],e)},b[e]=function(...n){let r=n[0];return typeof r=="number"&&(r=N(n,t)),new b(r,e)}}function B(e,t){return Number(e.toFixed(t))}function L(e){return function(t){return B(t,e)}}function h(e,t,n){e=Array.isArray(e)?e:[e];for(const r of e)(v[r]||(v[r]=[]))[t]=n;return e=e[0],function(r){let o;return r!==void 0?(n&&(r=n(r)),o=this[e](),o.color[t]=r,o):(o=this[e]().color[t],n&&(o=n(o)),o)}}function f(e){return function(t){return Math.max(0,Math.min(e,t))}}function R(e){return Array.isArray(e)?e:[e]}function N(e,t){for(let n=0;n<t;n++)typeof e[n]!="number"&&(e[n]=0);return e}class V{constructor(t){_(this,"isColor",!0);_(this,"currentColor");this.base=t;const n=this._resolveBaseColor(t);return this.currentColor=b(n),this._createProxy()}_createProxy(){return new Proxy(this,{get(t,n){return n in t?t[n]:n in t.currentColor?t._handleColorMethod(n):t[n]}})}_resolveBaseColor(t){if(typeof t!="string"||!/\{[^{}]+\}/g.test(t))return t;if(typeof saltyConfig>"u")return"transparent";const{staticVariables:r}=saltyConfig;return r?t.replace(/^\{|\}$/g,"").split(".").reduce((s,a)=>s[a],r):"transparent"}_handleColorMethod(t){const n=this.currentColor;return typeof n[t]!="function"?n[t]:(...r)=>(this.currentColor=n[t](...r),this._createProxy())}toString(){return this.currentColor.toString()}}const J=e=>new V(e);exports.color=J;
1
+ "use strict";var A=Object.defineProperty;var S=(e,t,n)=>t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _=(e,t,n)=>S(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},O=Object.create(null);for(const e in k)Object.hasOwn(k,e)&&(O[k[e]]=e);const d={to:{},get:{}};d.get=function(e){const t=e.slice(0,3).toLowerCase();let n,r;switch(t){case"hsl":{n=d.get.hsl(e),r="hsl";break}case"hwb":{n=d.get.hwb(e),r="hwb";break}default:{n=d.get.rgb(e),r="rgb";break}}return n?{model:r,value:n}:null};d.get.rgb=function(e){if(!e)return null;const t=/^#([a-f\d]{3,4})$/i,n=/^#([a-f\d]{6})([a-f\d]{2})?$/i,r=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/,o=/^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/,l=/^(\w+)$/;let s=[0,0,0,1],a,i,u;if(a=e.match(n)){for(u=a[2],a=a[1],i=0;i<3;i++){const m=i*2;s[i]=Number.parseInt(a.slice(m,m+2),16)}u&&(s[3]=Number.parseInt(u,16)/255)}else if(a=e.match(t)){for(a=a[1],u=a[3],i=0;i<3;i++)s[i]=Number.parseInt(a[i]+a[i],16);u&&(s[3]=Number.parseInt(u+u,16)/255)}else if(a=e.match(r)){for(i=0;i<3;i++)s[i]=Number.parseInt(a[i+1],10);a[4]&&(s[3]=a[5]?Number.parseFloat(a[4])*.01:Number.parseFloat(a[4]))}else if(a=e.match(o)){for(i=0;i<3;i++)s[i]=Math.round(Number.parseFloat(a[i+1])*2.55);a[4]&&(s[3]=a[5]?Number.parseFloat(a[4])*.01:Number.parseFloat(a[4]))}else return(a=e.match(l))?a[1]==="transparent"?[0,0,0,0]:Object.hasOwn(k,a[1])?(s=k[a[1]],s[3]=1,s):null:null;for(i=0;i<3;i++)s[i]=w(s[i],0,255);return s[3]=w(s[3],0,1),s};d.get.hsl=function(e){if(!e)return null;const t=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,n=e.match(t);if(n){const r=Number.parseFloat(n[4]),o=(Number.parseFloat(n[1])%360+360)%360,l=w(Number.parseFloat(n[2]),0,100),s=w(Number.parseFloat(n[3]),0,100),a=w(Number.isNaN(r)?1:r,0,1);return[o,l,s,a]}return null};d.get.hwb=function(e){if(!e)return null;const t=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,n=e.match(t);if(n){const r=Number.parseFloat(n[4]),o=(Number.parseFloat(n[1])%360+360)%360,l=w(Number.parseFloat(n[2]),0,100),s=w(Number.parseFloat(n[3]),0,100),a=w(Number.isNaN(r)?1:r,0,1);return[o,l,s,a]}return null};d.to.hex=function(...e){return"#"+x(e[0])+x(e[1])+x(e[2])+(e[3]<1?x(Math.round(e[3]*255)):"")};d.to.rgb=function(...e){return e.length<4||e[3]===1?"rgb("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+")":"rgba("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+", "+e[3]+")"};d.to.rgb.percent=function(...e){const t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),r=Math.round(e[2]/255*100);return e.length<4||e[3]===1?"rgb("+t+"%, "+n+"%, "+r+"%)":"rgba("+t+"%, "+n+"%, "+r+"%, "+e[3]+")"};d.to.hsl=function(...e){return e.length<4||e[3]===1?"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)":"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+e[3]+")"};d.to.hwb=function(...e){let t="";return e.length>=4&&e[3]!==1&&(t=", "+e[3]),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+t+")"};d.to.keyword=function(...e){return O[e.slice(0,3)]};function w(e,t,n){return Math.min(Math.max(t,e),n)}function x(e){const t=Math.round(e).toString(16).toUpperCase();return t.length<2?"0"+t:t}const M={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},q={};for(const e of Object.keys(M))q[M[e]]=e;const c={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}},y=(6/29)**3;for(const e of Object.keys(c)){if(!("channels"in c[e]))throw new Error("missing channels property: "+e);if(!("labels"in c[e]))throw new Error("missing channel labels property: "+e);if(c[e].labels.length!==c[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:n}=c[e];delete c[e].channels,delete c[e].labels,Object.defineProperty(c[e],"channels",{value:t}),Object.defineProperty(c[e],"labels",{value:n})}c.rgb.hsl=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,o=Math.min(t,n,r),l=Math.max(t,n,r),s=l-o;let a,i;switch(l){case o:{a=0;break}case t:{a=(n-r)/s;break}case n:{a=2+(r-t)/s;break}case r:{a=4+(t-n)/s;break}}a=Math.min(a*60,360),a<0&&(a+=360);const u=(o+l)/2;return l===o?i=0:u<=.5?i=s/(l+o):i=s/(2-l-o),[a,i*100,u*100]};c.rgb.hsv=function(e){let t,n,r,o,l;const s=e[0]/255,a=e[1]/255,i=e[2]/255,u=Math.max(s,a,i),m=u-Math.min(s,a,i),p=function(z){return(u-z)/6/m+1/2};if(m===0)o=0,l=0;else{switch(l=m/u,t=p(s),n=p(a),r=p(i),u){case s:{o=r-n;break}case a:{o=1/3+t-r;break}case i:{o=2/3+n-t;break}}o<0?o+=1:o>1&&(o-=1)}return[o*360,l*100,u*100]};c.rgb.hwb=function(e){const t=e[0],n=e[1];let r=e[2];const o=c.rgb.hsl(e)[0],l=1/255*Math.min(t,Math.min(n,r));return r=1-1/255*Math.max(t,Math.max(n,r)),[o,l*100,r*100]};c.rgb.cmyk=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,o=Math.min(1-t,1-n,1-r),l=(1-t-o)/(1-o)||0,s=(1-n-o)/(1-o)||0,a=(1-r-o)/(1-o)||0;return[l*100,s*100,a*100,o*100]};function P(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}c.rgb.keyword=function(e){const t=q[e];if(t)return t;let n=Number.POSITIVE_INFINITY,r;for(const o of Object.keys(M)){const l=M[o],s=P(e,l);s<n&&(n=s,r=o)}return r};c.keyword.rgb=function(e){return M[e]};c.rgb.xyz=function(e){let t=e[0]/255,n=e[1]/255,r=e[2]/255;t=t>.04045?((t+.055)/1.055)**2.4:t/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92;const o=t*.4124564+n*.3575761+r*.1804375,l=t*.2126729+n*.7151522+r*.072175,s=t*.0193339+n*.119192+r*.9503041;return[o*100,l*100,s*100]};c.rgb.lab=function(e){const t=c.rgb.xyz(e);let n=t[0],r=t[1],o=t[2];n/=95.047,r/=100,o/=108.883,n=n>y?n**(1/3):7.787*n+16/116,r=r>y?r**(1/3):7.787*r+16/116,o=o>y?o**(1/3):7.787*o+16/116;const l=116*r-16,s=500*(n-r),a=200*(r-o);return[l,s,a]};c.hsl.rgb=function(e){const t=e[0]/360,n=e[1]/100,r=e[2]/100;let o,l;if(n===0)return l=r*255,[l,l,l];const s=r<.5?r*(1+n):r+n-r*n,a=2*r-s,i=[0,0,0];for(let u=0;u<3;u++)o=t+1/3*-(u-1),o<0&&o++,o>1&&o--,6*o<1?l=a+(s-a)*6*o:2*o<1?l=s:3*o<2?l=a+(s-a)*(2/3-o)*6:l=a,i[u]=l*255;return i};c.hsl.hsv=function(e){const t=e[0];let n=e[1]/100,r=e[2]/100,o=n;const l=Math.max(r,.01);r*=2,n*=r<=1?r:2-r,o*=l<=1?l:2-l;const s=(r+n)/2,a=r===0?2*o/(l+o):2*n/(r+n);return[t,a*100,s*100]};c.hsv.rgb=function(e){const t=e[0]/60,n=e[1]/100;let r=e[2]/100;const o=Math.floor(t)%6,l=t-Math.floor(t),s=255*r*(1-n),a=255*r*(1-n*l),i=255*r*(1-n*(1-l));switch(r*=255,o){case 0:return[r,i,s];case 1:return[a,r,s];case 2:return[s,r,i];case 3:return[s,a,r];case 4:return[i,s,r];case 5:return[r,s,a]}};c.hsv.hsl=function(e){const t=e[0],n=e[1]/100,r=e[2]/100,o=Math.max(r,.01);let l,s;s=(2-n)*r;const a=(2-n)*o;return l=n*o,l/=a<=1?a:2-a,l=l||0,s/=2,[t,l*100,s*100]};c.hwb.rgb=function(e){const t=e[0]/360;let n=e[1]/100,r=e[2]/100;const o=n+r;let l;o>1&&(n/=o,r/=o);const s=Math.floor(6*t),a=1-r;l=6*t-s,(s&1)!==0&&(l=1-l);const i=n+l*(a-n);let u,m,p;switch(s){default:case 6:case 0:{u=a,m=i,p=n;break}case 1:{u=i,m=a,p=n;break}case 2:{u=n,m=a,p=i;break}case 3:{u=n,m=i,p=a;break}case 4:{u=i,m=n,p=a;break}case 5:{u=a,m=n,p=i;break}}return[u*255,m*255,p*255]};c.cmyk.rgb=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100,o=e[3]/100,l=1-Math.min(1,t*(1-o)+o),s=1-Math.min(1,n*(1-o)+o),a=1-Math.min(1,r*(1-o)+o);return[l*255,s*255,a*255]};c.xyz.rgb=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100;let o,l,s;return o=t*3.2404542+n*-1.5371385+r*-.4985314,l=t*-.969266+n*1.8760108+r*.041556,s=t*.0556434+n*-.2040259+r*1.0572252,o=o>.0031308?1.055*o**(1/2.4)-.055:o*12.92,l=l>.0031308?1.055*l**(1/2.4)-.055:l*12.92,s=s>.0031308?1.055*s**(1/2.4)-.055:s*12.92,o=Math.min(Math.max(0,o),1),l=Math.min(Math.max(0,l),1),s=Math.min(Math.max(0,s),1),[o*255,l*255,s*255]};c.xyz.lab=function(e){let t=e[0],n=e[1],r=e[2];t/=95.047,n/=100,r/=108.883,t=t>y?t**(1/3):7.787*t+16/116,n=n>y?n**(1/3):7.787*n+16/116,r=r>y?r**(1/3):7.787*r+16/116;const o=116*n-16,l=500*(t-n),s=200*(n-r);return[o,l,s]};c.lab.xyz=function(e){const t=e[0],n=e[1],r=e[2];let o,l,s;l=(t+16)/116,o=n/500+l,s=l-r/200;const a=l**3,i=o**3,u=s**3;return l=a>y?a:(l-16/116)/7.787,o=i>y?i:(o-16/116)/7.787,s=u>y?u:(s-16/116)/7.787,o*=95.047,l*=100,s*=108.883,[o,l,s]};c.lab.lch=function(e){const t=e[0],n=e[1],r=e[2];let o;o=Math.atan2(r,n)*360/2/Math.PI,o<0&&(o+=360);const s=Math.sqrt(n*n+r*r);return[t,s,o]};c.lch.lab=function(e){const t=e[0],n=e[1],o=e[2]/360*2*Math.PI,l=n*Math.cos(o),s=n*Math.sin(o);return[t,l,s]};c.rgb.ansi16=function(e,t=null){const[n,r,o]=e;let l=t===null?c.rgb.hsv(e)[2]:t;if(l=Math.round(l/50),l===0)return 30;let s=30+(Math.round(o/255)<<2|Math.round(r/255)<<1|Math.round(n/255));return l===2&&(s+=60),s};c.hsv.ansi16=function(e){return c.rgb.ansi16(c.hsv.rgb(e),e[2])};c.rgb.ansi256=function(e){const t=e[0],n=e[1],r=e[2];return t>>4===n>>4&&n>>4===r>>4?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)};c.ansi16.rgb=function(e){e=e[0];let t=e%10;if(t===0||t===7)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const n=(Math.trunc(e>50)+1)*.5,r=(t&1)*n*255,o=(t>>1&1)*n*255,l=(t>>2&1)*n*255;return[r,o,l]};c.ansi256.rgb=function(e){if(e=e[0],e>=232){const l=(e-232)*10+8;return[l,l,l]}e-=16;let t;const n=Math.floor(e/36)/5*255,r=Math.floor((t=e%36)/6)/5*255,o=t%6/5*255;return[n,r,o]};c.rgb.hex=function(e){const n=(((Math.round(e[0])&255)<<16)+((Math.round(e[1])&255)<<8)+(Math.round(e[2])&255)).toString(16).toUpperCase();return"000000".slice(n.length)+n};c.hex.rgb=function(e){const t=e.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!t)return[0,0,0];let n=t[0];t[0].length===3&&(n=[...n].map(a=>a+a).join(""));const r=Number.parseInt(n,16),o=r>>16&255,l=r>>8&255,s=r&255;return[o,l,s]};c.rgb.hcg=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,o=Math.max(Math.max(t,n),r),l=Math.min(Math.min(t,n),r),s=o-l;let a;const i=s<1?l/(1-s):0;return s<=0?a=0:o===t?a=(n-r)/s%6:o===n?a=2+(r-t)/s:a=4+(t-n)/s,a/=6,a%=1,[a*360,s*100,i*100]};c.hsl.hcg=function(e){const t=e[1]/100,n=e[2]/100,r=n<.5?2*t*n:2*t*(1-n);let o=0;return r<1&&(o=(n-.5*r)/(1-r)),[e[0],r*100,o*100]};c.hsv.hcg=function(e){const t=e[1]/100,n=e[2]/100,r=t*n;let o=0;return r<1&&(o=(n-r)/(1-r)),[e[0],r*100,o*100]};c.hcg.rgb=function(e){const t=e[0]/360,n=e[1]/100,r=e[2]/100;if(n===0)return[r*255,r*255,r*255];const o=[0,0,0],l=t%1*6,s=l%1,a=1-s;let i=0;switch(Math.floor(l)){case 0:{o[0]=1,o[1]=s,o[2]=0;break}case 1:{o[0]=a,o[1]=1,o[2]=0;break}case 2:{o[0]=0,o[1]=1,o[2]=s;break}case 3:{o[0]=0,o[1]=a,o[2]=1;break}case 4:{o[0]=s,o[1]=0,o[2]=1;break}default:o[0]=1,o[1]=0,o[2]=a}return i=(1-n)*r,[(n*o[0]+i)*255,(n*o[1]+i)*255,(n*o[2]+i)*255]};c.hcg.hsv=function(e){const t=e[1]/100,n=e[2]/100,r=t+n*(1-t);let o=0;return r>0&&(o=t/r),[e[0],o*100,r*100]};c.hcg.hsl=function(e){const t=e[1]/100,r=e[2]/100*(1-t)+.5*t;let o=0;return r>0&&r<.5?o=t/(2*r):r>=.5&&r<1&&(o=t/(2*(1-r))),[e[0],o*100,r*100]};c.hcg.hwb=function(e){const t=e[1]/100,n=e[2]/100,r=t+n*(1-t);return[e[0],(r-t)*100,(1-r)*100]};c.hwb.hcg=function(e){const t=e[1]/100,r=1-e[2]/100,o=r-t;let l=0;return o<1&&(l=(r-o)/(1-o)),[e[0],o*100,l*100]};c.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]};c.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]};c.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]};c.gray.hsl=function(e){return[0,0,e[0]]};c.gray.hsv=c.gray.hsl;c.gray.hwb=function(e){return[0,100,e[0]]};c.gray.cmyk=function(e){return[0,0,0,e[0]]};c.gray.lab=function(e){return[e[0],0,0]};c.gray.hex=function(e){const t=Math.round(e[0]/100*255)&255,r=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".slice(r.length)+r};c.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]};function $(){const e={},t=Object.keys(c);for(let{length:n}=t,r=0;r<n;r++)e[t[r]]={distance:-1,parent:null};return e}function I(e){const t=$(),n=[e];for(t[e].distance=0;n.length>0;){const r=n.pop(),o=Object.keys(c[r]);for(let{length:l}=o,s=0;s<l;s++){const a=o[s],i=t[a];i.distance===-1&&(i.distance=t[r].distance+1,i.parent=r,n.unshift(a))}}return t}function j(e,t){return function(n){return t(e(n))}}function E(e,t){const n=[t[e].parent,e];let r=c[t[e].parent][e],o=t[e].parent;for(;t[o].parent;)n.unshift(t[o].parent),r=j(c[t[o].parent][o],r),o=t[o].parent;return r.conversion=n,r}function T(e){const t=I(e),n={},r=Object.keys(t);for(let{length:o}=r,l=0;l<o;l++){const s=r[l];t[s].parent!==null&&(n[s]=E(s,t))}return n}const g={},U=Object.keys(c);function V(e){const t=function(...n){const r=n[0];return r==null?r:(r.length>1&&(n=r),e(n))};return"conversion"in e&&(t.conversion=e.conversion),t}function D(e){const t=function(...n){const r=n[0];if(r==null)return r;r.length>1&&(n=r);const o=e(n);if(typeof o=="object")for(let{length:l}=o,s=0;s<l;s++)o[s]=Math.round(o[s]);return o};return"conversion"in e&&(t.conversion=e.conversion),t}for(const e of U){g[e]={},Object.defineProperty(g[e],"channels",{value:c[e].channels}),Object.defineProperty(g[e],"labels",{value:c[e].labels});const t=T(e),n=Object.keys(t);for(const r of n){const o=t[r];g[e][r]=D(o),g[e][r].raw=V(o)}}const C=["keyword","gray","hex"],F={};for(const e of Object.keys(g))F[[...g[e].labels].sort().join("")]=e;const v={};function b(e,t){if(!(this instanceof b))return new b(e,t);if(t&&t in C&&(t=null),t&&!(t in g))throw new Error("Unknown model: "+t);let n,r;if(e==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(e instanceof b)this.model=e.model,this.color=[...e.color],this.valpha=e.valpha;else if(typeof e=="string"){const o=d.get(e);if(o===null)throw new Error("Unable to parse color from string: "+e);this.model=o.model,r=g[this.model].channels,this.color=o.value.slice(0,r),this.valpha=typeof o.value[r]=="number"?o.value[r]:1}else if(e.length>0){this.model=t||"rgb",r=g[this.model].channels;const o=Array.prototype.slice.call(e,0,r);this.color=N(o,r),this.valpha=typeof e[r]=="number"?e[r]:1}else if(typeof e=="number")this.model="rgb",this.color=[e>>16&255,e>>8&255,e&255],this.valpha=1;else{this.valpha=1;const o=Object.keys(e);"alpha"in e&&(o.splice(o.indexOf("alpha"),1),this.valpha=typeof e.alpha=="number"?e.alpha:0);const l=o.sort().join("");if(!(l in F))throw new Error("Unable to parse color from object: "+JSON.stringify(e));this.model=F[l];const{labels:s}=g[this.model],a=[];for(n=0;n<s.length;n++)a.push(e[s[n]]);this.color=N(a)}if(v[this.model])for(r=g[this.model].channels,n=0;n<r;n++){const o=v[this.model][n];o&&(this.color[n]=o(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}b.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(e){let t=this.model in d.to?this:this.rgb();t=t.round(typeof e=="number"?e:1);const n=t.valpha===1?t.color:[...t.color,this.valpha];return d.to[t.model](...n)},percentString(e){const t=this.rgb().round(typeof e=="number"?e:1),n=t.valpha===1?t.color:[...t.color,this.valpha];return d.to.rgb.percent(...n)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){const e={},{channels:t}=g[this.model],{labels:n}=g[this.model];for(let r=0;r<t;r++)e[n[r]]=this.color[r];return this.valpha!==1&&(e.alpha=this.valpha),e},unitArray(){const e=this.rgb().color;return e[0]/=255,e[1]/=255,e[2]/=255,this.valpha!==1&&e.push(this.valpha),e},unitObject(){const e=this.rgb().object();return e.r/=255,e.g/=255,e.b/=255,this.valpha!==1&&(e.alpha=this.valpha),e},round(e){return e=Math.max(e||0,0),new b([...this.color.map(B(e)),this.valpha],this.model)},alpha(e){return e!==void 0?new b([...this.color,Math.max(0,Math.min(1,e))],this.model):this.valpha},red:h("rgb",0,f(255)),green:h("rgb",1,f(255)),blue:h("rgb",2,f(255)),hue:h(["hsl","hsv","hsl","hwb","hcg"],0,e=>(e%360+360)%360),saturationl:h("hsl",1,f(100)),lightness:h("hsl",2,f(100)),saturationv:h("hsv",1,f(100)),value:h("hsv",2,f(100)),chroma:h("hcg",1,f(100)),gray:h("hcg",2,f(100)),white:h("hwb",1,f(100)),wblack:h("hwb",2,f(100)),cyan:h("cmyk",0,f(100)),magenta:h("cmyk",1,f(100)),yellow:h("cmyk",2,f(100)),black:h("cmyk",3,f(100)),x:h("xyz",0,f(95.047)),y:h("xyz",1,f(100)),z:h("xyz",2,f(108.833)),l:h("lab",0,f(100)),a:h("lab",1),b:h("lab",2),keyword(e){return e!==void 0?new b(e):g[this.model].keyword(this.color)},hex(e){return e!==void 0?new b(e):d.to.hex(...this.rgb().round().color)},hexa(e){if(e!==void 0)return new b(e);const t=this.rgb().round().color;let n=Math.round(this.valpha*255).toString(16).toUpperCase();return n.length===1&&(n="0"+n),d.to.hex(...t)+n},rgbNumber(){const e=this.rgb().color;return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255},luminosity(){const e=this.rgb().color,t=[];for(const[n,r]of e.entries()){const o=r/255;t[n]=o<=.04045?o/12.92:((o+.055)/1.055)**2.4}return .2126*t[0]+.7152*t[1]+.0722*t[2]},contrast(e){const t=this.luminosity(),n=e.luminosity();return t>n?(t+.05)/(n+.05):(n+.05)/(t+.05)},level(e){const t=this.contrast(e);return t>=7?"AAA":t>=4.5?"AA":""},isDark(){const e=this.rgb().color;return(e[0]*2126+e[1]*7152+e[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){const e=this.rgb();for(let t=0;t<3;t++)e.color[t]=255-e.color[t];return e},lighten(e){const t=this.hsl();return t.color[2]+=t.color[2]*e,t},darken(e){const t=this.hsl();return t.color[2]-=t.color[2]*e,t},saturate(e){const t=this.hsl();return t.color[1]+=t.color[1]*e,t},desaturate(e){const t=this.hsl();return t.color[1]-=t.color[1]*e,t},whiten(e){const t=this.hwb();return t.color[1]+=t.color[1]*e,t},blacken(e){const t=this.hwb();return t.color[2]+=t.color[2]*e,t},grayscale(){const e=this.rgb().color,t=e[0]*.3+e[1]*.59+e[2]*.11;return b.rgb(t,t,t)},fade(e){return this.alpha(this.valpha-this.valpha*e)},opaquer(e){return this.alpha(this.valpha+this.valpha*e)},rotate(e){const t=this.hsl();let n=t.color[0];return n=(n+e)%360,n=n<0?360+n:n,t.color[0]=n,t},mix(e,t){if(!e||!e.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e);const n=e.rgb(),r=this.rgb(),o=t===void 0?.5:t,l=2*o-1,s=n.alpha()-r.alpha(),a=((l*s===-1?l:(l+s)/(1+l*s))+1)/2,i=1-a;return b.rgb(a*n.red()+i*r.red(),a*n.green()+i*r.green(),a*n.blue()+i*r.blue(),n.alpha()*o+r.alpha()*(1-o))}};for(const e of Object.keys(g)){if(C.includes(e))continue;const{channels:t}=g[e];b.prototype[e]=function(...n){return this.model===e?new b(this):n.length>0?new b(n,e):new b([...L(g[this.model][e].raw(this.color)),this.valpha],e)},b[e]=function(...n){let r=n[0];return typeof r=="number"&&(r=N(n,t)),new b(r,e)}}function K(e,t){return Number(e.toFixed(t))}function B(e){return function(t){return K(t,e)}}function h(e,t,n){e=Array.isArray(e)?e:[e];for(const r of e)(v[r]||(v[r]=[]))[t]=n;return e=e[0],function(r){let o;return r!==void 0?(n&&(r=n(r)),o=this[e](),o.color[t]=r,o):(o=this[e]().color[t],n&&(o=n(o)),o)}}function f(e){return function(t){return Math.max(0,Math.min(e,t))}}function L(e){return Array.isArray(e)?e:[e]}function N(e,t){for(let n=0;n<t;n++)typeof e[n]!="number"&&(e[n]=0);return e}class R{constructor(t){_(this,"isColor",!0);_(this,"currentColor");this.base=t;const n=this._resolveBaseColor(t);return this.currentColor=b(n),this._createProxy()}_createProxy(){return new Proxy(this,{get(t,n){return n in t?t[n]:n in t.currentColor?t._handleColorMethod(n):t[n]}})}_resolveBaseColor(t){if(typeof t!="string"||!/\{[^{}]+\}/g.test(t))return t;if(typeof saltyConfig>"u")return"transparent";const{staticVariables:r}=saltyConfig;return r?t.replace(/^\{|\}$/g,"").split(".").reduce((s,a)=>s[a],r):"transparent"}_handleColorMethod(t){const n=this.currentColor;return typeof n[t]!="function"?n[t]:(...r)=>(this.currentColor=n[t](...r),this._createProxy())}toString(){return this.currentColor.toString()}}const J=e=>new R(e),G=e=>t=>{const{screenSize:n,axis:r="horizontal",minMultiplier:o=.5,maxMultiplier:l=1.5}=e,s=Math.round(t/n*1e4)/100,a=r==="vertical"?"vh":"vw",i=Math.round(o*t),u=Math.round(l*t);return`clamp(${i}px, ${s}${a}, ${u}px)`};exports.color=J;exports.defineViewportClamp=G;
@@ -1 +1,2 @@
1
1
  export * from './color';
2
+ export * from './viewport-clamp';
package/helpers/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var A = Object.defineProperty;
2
- var P = (e, t, n) => t in e ? A(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var _ = (e, t, n) => P(e, typeof t != "symbol" ? t + "" : t, n);
4
- const w = {
2
+ var S = (e, t, n) => t in e ? A(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var _ = (e, t, n) => S(e, typeof t != "symbol" ? t + "" : t, n);
4
+ const k = {
5
5
  aliceblue: [240, 248, 255],
6
6
  antiquewhite: [250, 235, 215],
7
7
  aqua: [0, 255, 255],
@@ -151,8 +151,8 @@ const w = {
151
151
  yellow: [255, 255, 0],
152
152
  yellowgreen: [154, 205, 50]
153
153
  }, O = /* @__PURE__ */ Object.create(null);
154
- for (const e in w)
155
- Object.hasOwn(w, e) && (O[w[e]] = e);
154
+ for (const e in k)
155
+ Object.hasOwn(k, e) && (O[k[e]] = e);
156
156
  const d = {
157
157
  to: {},
158
158
  get: {}
@@ -199,17 +199,17 @@ d.get.rgb = function(e) {
199
199
  for (i = 0; i < 3; i++)
200
200
  s[i] = Math.round(Number.parseFloat(a[i + 1]) * 2.55);
201
201
  a[4] && (s[3] = a[5] ? Number.parseFloat(a[4]) * 0.01 : Number.parseFloat(a[4]));
202
- } else return (a = e.match(l)) ? a[1] === "transparent" ? [0, 0, 0, 0] : Object.hasOwn(w, a[1]) ? (s = w[a[1]], s[3] = 1, s) : null : null;
202
+ } else return (a = e.match(l)) ? a[1] === "transparent" ? [0, 0, 0, 0] : Object.hasOwn(k, a[1]) ? (s = k[a[1]], s[3] = 1, s) : null : null;
203
203
  for (i = 0; i < 3; i++)
204
- s[i] = k(s[i], 0, 255);
205
- return s[3] = k(s[3], 0, 1), s;
204
+ s[i] = w(s[i], 0, 255);
205
+ return s[3] = w(s[3], 0, 1), s;
206
206
  };
207
207
  d.get.hsl = function(e) {
208
208
  if (!e)
209
209
  return null;
210
210
  const t = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/, n = e.match(t);
211
211
  if (n) {
212
- const r = Number.parseFloat(n[4]), o = (Number.parseFloat(n[1]) % 360 + 360) % 360, l = k(Number.parseFloat(n[2]), 0, 100), s = k(Number.parseFloat(n[3]), 0, 100), a = k(Number.isNaN(r) ? 1 : r, 0, 1);
212
+ const r = Number.parseFloat(n[4]), o = (Number.parseFloat(n[1]) % 360 + 360) % 360, l = w(Number.parseFloat(n[2]), 0, 100), s = w(Number.parseFloat(n[3]), 0, 100), a = w(Number.isNaN(r) ? 1 : r, 0, 1);
213
213
  return [o, l, s, a];
214
214
  }
215
215
  return null;
@@ -219,7 +219,7 @@ d.get.hwb = function(e) {
219
219
  return null;
220
220
  const t = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/, n = e.match(t);
221
221
  if (n) {
222
- const r = Number.parseFloat(n[4]), o = (Number.parseFloat(n[1]) % 360 + 360) % 360, l = k(Number.parseFloat(n[2]), 0, 100), s = k(Number.parseFloat(n[3]), 0, 100), a = k(Number.isNaN(r) ? 1 : r, 0, 1);
222
+ const r = Number.parseFloat(n[4]), o = (Number.parseFloat(n[1]) % 360 + 360) % 360, l = w(Number.parseFloat(n[2]), 0, 100), s = w(Number.parseFloat(n[3]), 0, 100), a = w(Number.isNaN(r) ? 1 : r, 0, 1);
223
223
  return [o, l, s, a];
224
224
  }
225
225
  return null;
@@ -244,7 +244,7 @@ d.to.hwb = function(...e) {
244
244
  d.to.keyword = function(...e) {
245
245
  return O[e.slice(0, 3)];
246
246
  };
247
- function k(e, t, n) {
247
+ function w(e, t, n) {
248
248
  return Math.min(Math.max(t, e), n);
249
249
  }
250
250
  function x(e) {
@@ -495,7 +495,7 @@ c.rgb.cmyk = function(e) {
495
495
  const t = e[0] / 255, n = e[1] / 255, r = e[2] / 255, o = Math.min(1 - t, 1 - n, 1 - r), l = (1 - t - o) / (1 - o) || 0, s = (1 - n - o) / (1 - o) || 0, a = (1 - r - o) / (1 - o) || 0;
496
496
  return [l * 100, s * 100, a * 100, o * 100];
497
497
  };
498
- function S(e, t) {
498
+ function P(e, t) {
499
499
  return (e[0] - t[0]) ** 2 + (e[1] - t[1]) ** 2 + (e[2] - t[2]) ** 2;
500
500
  }
501
501
  c.rgb.keyword = function(e) {
@@ -504,7 +504,7 @@ c.rgb.keyword = function(e) {
504
504
  return t;
505
505
  let n = Number.POSITIVE_INFINITY, r;
506
506
  for (const o of Object.keys(M)) {
507
- const l = M[o], s = S(e, l);
507
+ const l = M[o], s = P(e, l);
508
508
  s < n && (n = s, r = o);
509
509
  }
510
510
  return r;
@@ -788,7 +788,7 @@ c.gray.hex = function(e) {
788
788
  c.rgb.gray = function(e) {
789
789
  return [(e[0] + e[1] + e[2]) / 3 / 255 * 100];
790
790
  };
791
- function I() {
791
+ function $() {
792
792
  const e = {}, t = Object.keys(c);
793
793
  for (let { length: n } = t, r = 0; r < n; r++)
794
794
  e[t[r]] = {
@@ -799,8 +799,8 @@ function I() {
799
799
  };
800
800
  return e;
801
801
  }
802
- function j(e) {
803
- const t = I(), n = [e];
802
+ function I(e) {
803
+ const t = $(), n = [e];
804
804
  for (t[e].distance = 0; n.length > 0; ) {
805
805
  const r = n.pop(), o = Object.keys(c[r]);
806
806
  for (let { length: l } = o, s = 0; s < l; s++) {
@@ -810,35 +810,35 @@ function j(e) {
810
810
  }
811
811
  return t;
812
812
  }
813
- function E(e, t) {
813
+ function j(e, t) {
814
814
  return function(n) {
815
815
  return t(e(n));
816
816
  };
817
817
  }
818
- function $(e, t) {
818
+ function E(e, t) {
819
819
  const n = [t[e].parent, e];
820
820
  let r = c[t[e].parent][e], o = t[e].parent;
821
821
  for (; t[o].parent; )
822
- n.unshift(t[o].parent), r = E(c[t[o].parent][o], r), o = t[o].parent;
822
+ n.unshift(t[o].parent), r = j(c[t[o].parent][o], r), o = t[o].parent;
823
823
  return r.conversion = n, r;
824
824
  }
825
- function T(e) {
826
- const t = j(e), n = {}, r = Object.keys(t);
825
+ function U(e) {
826
+ const t = I(e), n = {}, r = Object.keys(t);
827
827
  for (let { length: o } = r, l = 0; l < o; l++) {
828
828
  const s = r[l];
829
- t[s].parent !== null && (n[s] = $(s, t));
829
+ t[s].parent !== null && (n[s] = E(s, t));
830
830
  }
831
831
  return n;
832
832
  }
833
- const g = {}, U = Object.keys(c);
834
- function D(e) {
833
+ const g = {}, T = Object.keys(c);
834
+ function V(e) {
835
835
  const t = function(...n) {
836
836
  const r = n[0];
837
837
  return r == null ? r : (r.length > 1 && (n = r), e(n));
838
838
  };
839
839
  return "conversion" in e && (t.conversion = e.conversion), t;
840
840
  }
841
- function K(e) {
841
+ function D(e) {
842
842
  const t = function(...n) {
843
843
  const r = n[0];
844
844
  if (r == null)
@@ -852,12 +852,12 @@ function K(e) {
852
852
  };
853
853
  return "conversion" in e && (t.conversion = e.conversion), t;
854
854
  }
855
- for (const e of U) {
855
+ for (const e of T) {
856
856
  g[e] = {}, Object.defineProperty(g[e], "channels", { value: c[e].channels }), Object.defineProperty(g[e], "labels", { value: c[e].labels });
857
- const t = T(e), n = Object.keys(t);
857
+ const t = U(e), n = Object.keys(t);
858
858
  for (const r of n) {
859
859
  const o = t[r];
860
- g[e][r] = K(o), g[e][r].raw = D(o);
860
+ g[e][r] = D(o), g[e][r].raw = V(o);
861
861
  }
862
862
  }
863
863
  const C = [
@@ -951,7 +951,7 @@ b.prototype = {
951
951
  return e.r /= 255, e.g /= 255, e.b /= 255, this.valpha !== 1 && (e.alpha = this.valpha), e;
952
952
  },
953
953
  round(e) {
954
- return e = Math.max(e || 0, 0), new b([...this.color.map(L(e)), this.valpha], this.model);
954
+ return e = Math.max(e || 0, 0), new b([...this.color.map(B(e)), this.valpha], this.model);
955
955
  },
956
956
  alpha(e) {
957
957
  return e !== void 0 ? new b([...this.color, Math.max(0, Math.min(1, e))], this.model) : this.valpha;
@@ -1081,18 +1081,18 @@ for (const e of Object.keys(g)) {
1081
1081
  continue;
1082
1082
  const { channels: t } = g[e];
1083
1083
  b.prototype[e] = function(...n) {
1084
- return this.model === e ? new b(this) : n.length > 0 ? new b(n, e) : new b([...R(g[this.model][e].raw(this.color)), this.valpha], e);
1084
+ return this.model === e ? new b(this) : n.length > 0 ? new b(n, e) : new b([...L(g[this.model][e].raw(this.color)), this.valpha], e);
1085
1085
  }, b[e] = function(...n) {
1086
1086
  let r = n[0];
1087
1087
  return typeof r == "number" && (r = N(n, t)), new b(r, e);
1088
1088
  };
1089
1089
  }
1090
- function B(e, t) {
1090
+ function K(e, t) {
1091
1091
  return Number(e.toFixed(t));
1092
1092
  }
1093
- function L(e) {
1093
+ function B(e) {
1094
1094
  return function(t) {
1095
- return B(t, e);
1095
+ return K(t, e);
1096
1096
  };
1097
1097
  }
1098
1098
  function h(e, t, n) {
@@ -1109,7 +1109,7 @@ function f(e) {
1109
1109
  return Math.max(0, Math.min(e, t));
1110
1110
  };
1111
1111
  }
1112
- function R(e) {
1112
+ function L(e) {
1113
1113
  return Array.isArray(e) ? e : [e];
1114
1114
  }
1115
1115
  function N(e, t) {
@@ -1117,7 +1117,7 @@ function N(e, t) {
1117
1117
  typeof e[n] != "number" && (e[n] = 0);
1118
1118
  return e;
1119
1119
  }
1120
- class V {
1120
+ class R {
1121
1121
  constructor(t) {
1122
1122
  _(this, "isColor", !0);
1123
1123
  _(this, "currentColor");
@@ -1146,7 +1146,11 @@ class V {
1146
1146
  return this.currentColor.toString();
1147
1147
  }
1148
1148
  }
1149
- const G = (e) => new V(e);
1149
+ const G = (e) => new R(e), H = (e) => (t) => {
1150
+ const { screenSize: n, axis: r = "horizontal", minMultiplier: o = 0.5, maxMultiplier: l = 1.5 } = e, s = Math.round(t / n * 1e4) / 100, a = r === "vertical" ? "vh" : "vw", i = Math.round(o * t), u = Math.round(l * t);
1151
+ return `clamp(${i}px, ${s}${a}, ${u}px)`;
1152
+ };
1150
1153
  export {
1151
- G as color
1154
+ G as color,
1155
+ H as defineViewportClamp
1152
1156
  };
@@ -0,0 +1,8 @@
1
+ interface ViewportClampConfig {
2
+ screenSize: number;
3
+ axis?: 'vertical' | 'horizontal';
4
+ minMultiplier?: number;
5
+ maxMultiplier?: number;
6
+ }
7
+ export declare const defineViewportClamp: (config: ViewportClampConfig) => (value: number) => string;
8
+ export {};
@@ -0,0 +1,38 @@
1
+ "use strict";const xe=require("esbuild"),Pe=require("child_process"),_=require("./dash-case-BJEkFEGQ.cjs"),a=require("path"),c=require("fs"),oe=require("fs/promises"),Y=require("./parse-styles-C6OYNcYI.cjs"),G=require("winston"),M=require("./css/merge.cjs"),Ne=require("./define-templates-Cunsb_Tr.cjs");var ne=typeof document<"u"?document.currentScript:null;function ke(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const pe=ke(xe),ye=async(e,t=[])=>{if(!e)return"";const s=[],n={};for(const[i,o]of Object.entries(e))if(typeof o!="function")if(o&&typeof o=="object"){const r=i.trim(),S=await ye(o,[...t,r]);s.push(S)}else n[i]=o;if(Object.keys(n).length){const i=t.map(_.dashCase).join("-"),o="t_"+_.toHash(i,4),r=await Y.parseAndJoinStyles(n,`.${i}, .${o}`);s.push(r)}return s.join(`
2
+ `)},_e=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=me(n).map(i=>`"${i}"`).join(" | ")),t),{}):{},me=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,i])=>{const o=t?`${t}.${n}`:n;return typeof i=="object"?me(i,o,s):s.add(t)}),[...s]):[],ge=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=a.join(e,"package.json");return c.existsSync(t)?t:ge(a.join(e,".."))},De=async e=>{const t=ge(e);return await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Oe=async e=>{const t=await De(e);if(t)return t.type};let z;const he=async e=>{if(z)return z;const t=await Oe(e);return t==="module"?z="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:ne&&ne.tagName.toUpperCase()==="SCRIPT"&&ne.src||new URL("index-BPohv4BZ.cjs",document.baseURI).href).endsWith(".cjs"))&&(z="cjs"),z||"esm"},K=G.createLogger({level:"debug",format:G.format.combine(G.format.colorize(),G.format.cli()),transports:[new G.transports.Console({})]}),Te=e=>{K.error(e)};function Se(e){return e?typeof e!="string"?Se(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?".":"")+t.toLowerCase()):""}const Ee={"*, *::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"}},V={externalModules:[],rcFile:void 0,destDir:void 0},je=e=>{if(V.externalModules.length>0)return V.externalModules;const s=c.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(i=>i.replace(/['"`]/g,"").trim());return V.externalModules=n,n},v=async e=>{if(V.destDir)return V.destDir;const t=await re(e),s=a.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return V.destDir=s,s},ie=["salty","css","styles","styled"],we=(e=[])=>new RegExp(`\\.(${[...ie,...e].join("|")})\\.`),ee=(e,t=[])=>we(t).test(e),be=async e=>{if(V.rcFile)return V.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=a.join(e,".saltyrc.json"),s=await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(V.rcFile=s,s):be(a.join(e,".."))},re=async e=>{var n,i;const t=await be(e),s=(n=t.projects)==null?void 0:n.find(o=>e.endsWith(o.dir||""));return s||((i=t.projects)==null?void 0:i.find(o=>o.dir===t.defaultProject))},Re=async e=>{const t=await re(e),s=await v(e),n=a.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),i=a.join(s,"salty.config.js"),o=await he(e),r=je(n);await pe.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:i,format:o,external:r});const S=Date.now(),{config:j}=await import(`${i}?t=${S}`);return{config:j,path:i}},$e=async(e,t)=>{var le,fe;const s=await v(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async g=>{const{contents:b,outputFilePath:R}=await L(e,g,s);Object.entries(b).forEach(([P,O])=>{O.isMedia?n.mediaQueries.push([P,O]):O.isGlobalDefine?n.globalStyles.push(O):O.isDefineVariables?n.variables.push(O):O.isDefineTemplates&&n.templates.push(O._setPath(`${P};;${R}`))})}));const{config:i,path:o}=await Re(e),r={...i},S=new Set,j=(g,b=[])=>g?Object.entries(g).flatMap(([R,P])=>{if(!P)return;if(typeof P=="object")return j(P,[...b,R]);const O=Se(R),te=_.dashCase(R),se=[...b,O].join(".");S.add(`"${se}"`);const X=[...b.map(_.dashCase),te].join("-"),ue=Y.parseVariableTokens(P);return ue?`--${X}: ${ue.transformed};`:`--${X}: ${P};`}):[],l=g=>g?Object.entries(g).flatMap(([b,R])=>{const P=j(R);return b==="base"?P.join(""):`${b} { ${P.join("")} }`}):[],d=g=>g?Object.entries(g).flatMap(([b,R])=>Object.entries(R).flatMap(([P,O])=>{const te=j(O,[b]),se=`.${b}-${P}, [data-${b}="${P}"]`,X=te.join("");return`${se} { ${X} }`})):[],w=g=>({...g,responsive:void 0,conditional:void 0}),p=g=>n.variables.map(b=>g==="static"?w(b._current):b._current[g]),h=M.mergeObjects(w(i.variables),p("static")),y=j(h),C=M.mergeObjects((le=i.variables)==null?void 0:le.responsive,p("responsive")),N=l(C),k=M.mergeObjects((fe=i.variables)==null?void 0:fe.conditional,p("conditional")),J=d(k),T=a.join(s,"css/_variables.css"),H=`:root { ${y.join("")} ${N.join("")} } ${J.join("")}`;c.writeFileSync(T,H),r.staticVariables=h;const D=a.join(s,"css/_global.css"),q=M.mergeObjects(i.global,n.globalStyles),u=await Y.parseAndJoinStyles(q,"");c.writeFileSync(D,`@layer global { ${u} }`);const m=a.join(s,"css/_reset.css"),f=i.reset==="none"?{}:typeof i.reset=="object"?i.reset:Ee,F=await Y.parseAndJoinStyles(f,"");c.writeFileSync(m,`@layer reset { ${F} }`);const x=a.join(s,"css/_templates.css"),E=M.mergeObjects(i.templates,n.templates),I=await ye(E),W=_e(E);c.writeFileSync(x,`@layer templates { ${I} }`),r.templates=E;const A=i.templates?[Ne.defineTemplates(i.templates)._setPath(`config;;${o}`)]:[],Q=M.mergeFactories(n.templates,A);r.templatePaths=Object.fromEntries(Object.entries(Q).map(([g,b])=>[g,b._path]));const{mediaQueries:Z}=n;r.mediaQueries=Object.fromEntries(Z.map(([g,b])=>[`@${g}`,b]));const B=Z.map(([g])=>`'@${g}'`).join(" | "),U=a.join(s,"types/css-tokens.d.ts"),Fe=`
3
+ // Variable types
4
+ type VariableTokens = ${[...S].join("|")};
5
+ type PropertyValueToken = \`{\${VariableTokens}}\`;
6
+
7
+ // Template types
8
+ type TemplateTokens = {
9
+ ${Object.entries(W).map(([g,b])=>`${g}?: ${b}`).join(`
10
+ `)}
11
+ }
12
+
13
+ // Media query types
14
+ type MediaQueryKeys = ${B||"''"};
15
+ `;c.writeFileSync(U,Fe);const Ce=a.join(s,"cache/config-cache.json");c.writeFileSync(Ce,JSON.stringify(r,null,2))},de=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const i=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!i.test(e))return t;const r=i.exec(e);if(r){const S=r.at(1);if(ie.some(l=>S==null?void 0:S.includes(l)))return t}return"styled('div',"}),Ve=(e,t)=>{try{const s=c.readFileSync(a.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
16
+
17
+ ${e}`:`globalThis.saltyConfig = {};
18
+
19
+ ${e}`}catch{return e}},L=async(e,t,s)=>{const n=_.toHash(t),i=a.join(s,"./temp");c.existsSync(i)||c.mkdirSync(i);const o=a.parse(t);let r=c.readFileSync(t,"utf8");r=de(r),r=Ve(r,e);const S=a.join(s,"js",n+".js"),j=await re(e),l=a.join(e,(j==null?void 0:j.configDir)||"","salty.config.ts"),d=je(l),w=await he(e);await pe.build({stdin:{contents:r,sourcefile:o.base,resolveDir:o.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:S,format:w,target:["node20"],keepNames:!0,external:d,packages:"external",plugins:[{name:"test",setup:y=>{y.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},C=>{const N=c.readFileSync(C.path,"utf8");return{contents:de(N),loader:"ts"}})}}]});const p=Date.now();return{contents:await import(`${S}?t=${p}`),outputFilePath:S}},Me=async e=>{const t=await v(e),s=a.join(t,"cache/config-cache.json"),n=c.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ae=async e=>{const t=await Me(e),s=await v(e),n=a.join(s,"salty.config.js"),i=Date.now(),{config:o}=await import(`${n}?t=${i}`);return M.mergeObjects(o,t)},ce=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ve=async(e,t=ce(),s=!0)=>{try{const n=Date.now();t?K.info("Generating CSS in production mode! 🔥"):K.info("Generating CSS in development mode! 🚀");const i=[],o=[],r=await v(e),S=a.join(r,"index.css");s&&(()=>{c.existsSync(r)&&Pe.execSync("rm -rf "+r),c.mkdirSync(r,{recursive:!0}),c.mkdirSync(a.join(r,"css")),c.mkdirSync(a.join(r,"types")),c.mkdirSync(a.join(r,"js")),c.mkdirSync(a.join(r,"cache"))})();const l=new Set,d=new Set;async function w(u){const m=["node_modules","saltygen"],$=c.statSync(u);if($.isDirectory()){const f=c.readdirSync(u);if(m.some(x=>u.includes(x)))return;await Promise.all(f.map(x=>w(a.join(u,x))))}else if($.isFile()&&ee(u)){l.add(u);const F=c.readFileSync(u,"utf8");/define[\w\d]+\(/.test(F)&&d.add(u)}}await w(e),await $e(e,d);const p={keyframes:[],components:[],classNames:[]};await Promise.all([...l].map(async u=>{const{contents:m}=await L(e,u,r);Object.entries(m).forEach(([$,f])=>{f.isKeyframes?p.keyframes.push({value:f,src:u,name:$}):f.isClassName?p.classNames.push({...f,src:u,name:$}):f.generator&&p.components.push({...f,src:u,name:$})})}));const h=await ae(e);for(const u of p.keyframes){const{value:m}=u,$=`a_${m.animationName}.css`,f=`css/${$}`,F=a.join(r,f);i.push($),c.writeFileSync(F,m.css)}const y={};for(const u of p.components){const{src:m,name:$}=u;y[m]||(y[m]=[]);const f=u.generator._withBuildContext({callerName:$,isProduction:t,config:h});o[f.priority]||(o[f.priority]=[]);const F=await f.css;if(!F)continue;o[f.priority].push(f.cssFileName);const x=`css/${f.cssFileName}`,E=a.join(r,x);c.writeFileSync(E,F),h.importStrategy==="component"&&y[m].push(f.cssFileName)}for(const u of p.classNames){const{src:m,name:$}=u;y[m]||(y[m]=[]);const f=u.generator._withBuildContext({callerName:$,isProduction:t,config:h}),F=await f.css;if(!F)continue;o[f.priority]||(o[f.priority]=[]),o[f.priority].push(f.cssFileName);const x=`css/${f.cssFileName}`,E=a.join(r,x);c.writeFileSync(E,F),h.importStrategy==="component"&&y[m].push(f.cssFileName)}h.importStrategy==="component"&&Object.entries(y).forEach(([u,m])=>{const $=m.map(I=>`@import url('./${I}');`).join(`
20
+ `),f=_.toHash(u,6),F=a.parse(u),x=_.dashCase(F.name),E=a.join(r,`css/f_${x}-${f}.css`);c.writeFileSync(E,$||"/* Empty file */")});const C=i.map(u=>`@import url('./css/${u}');`).join(`
21
+ `);let T=`@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
22
+
23
+ ${["_variables.css","_reset.css","_global.css","_templates.css"].filter(u=>{try{return c.readFileSync(a.join(r,"css",u),"utf8").length>0}catch{return!1}}).map(u=>`@import url('./css/${u}');`).join(`
24
+ `)}
25
+ ${C}`;if(h.importStrategy!=="component"){const u=o.reduce((m,$,f)=>{const F=$.reduce((W,A)=>{var U;const Q=a.join(r,"css",A),Z=c.readFileSync(Q,"utf8"),B=((U=/.*-([^-]+)-\d+.css/.exec(A))==null?void 0:U.at(1))||_.toHash(Q,6);return W.includes(B)?W:`${W}
26
+ /*start:${B}-${A}*/
27
+ ${Z}
28
+ /*end:${B}*/
29
+ `},""),x=`l_${f}.css`,E=a.join(r,"css",x),I=`@layer l${f} { ${F}
30
+ }`;return c.writeFileSync(E,I),`${m}
31
+ @import url('./css/${x}');`},"");T+=u}c.writeFileSync(S,T);const D=Date.now()-n,q=D<200?"🔥":D<500?"🚀":D<1e3?"🎉":D<2e3?"🚗":D<5e3?"🤔":"🥴";K.info(`Generated CSS in ${D}ms! ${q}`)}catch(n){console.error(n)}},Je=async(e,t,s=ce())=>{try{const n=await v(e);if(ee(t)){const o=[],r=await ae(e),{contents:S}=await L(e,t,n);for(const[j,l]of Object.entries(S)){if(l.isKeyframes&&l.css){const C=`css/${`a_${l.animationName}.css`}`,N=a.join(n,C);c.writeFileSync(N,await l.css);return}if(l.isClassName){const y=l.generator._withBuildContext({callerName:j,isProduction:s,config:r}),C=await y.css;if(!C)continue;o[y.priority]||(o[y.priority]=[]),o[y.priority].push(y.cssFileName);const N=`css/${y.cssFileName}`,k=a.join(n,N);c.writeFileSync(k,C)}if(!l.generator)return;const d=l.generator._withBuildContext({callerName:j,isProduction:s,config:r}),w=await d.css;if(!w)continue;const p=`css/${d.cssFileName}`,h=a.join(n,p);c.writeFileSync(h,w),o[d.priority]||(o[d.priority]=[]),o[d.priority].push(d.cssFileName)}if(r.importStrategy!=="component")o.forEach((j,l)=>{const d=`l_${l}.css`,w=a.join(n,"css",d);let p=c.readFileSync(w,"utf8");j.forEach(h=>{var k;const y=a.join(n,"css",h),C=((k=/.*-([^-]+)-\d+.css/.exec(h))==null?void 0:k.at(1))||_.toHash(y,6);if(!p.includes(C)){const J=c.readFileSync(y,"utf8"),T=`/*start:${C}-${h}*/
32
+ ${J}
33
+ /*end:${C}*/
34
+ `;p=`${p.replace(/\}$/,"")}
35
+ ${T}
36
+ }`}}),c.writeFileSync(w,p)});else{const j=o.flat().map(h=>`@import url('./${h}');`).join(`
37
+ `),l=_.toHash(t,6),d=a.parse(t),w=_.dashCase(d.name),p=a.join(n,`css/f_${w}-${l}.css`);c.writeFileSync(p,j||"/* Empty file */")}}}catch(n){console.error(n)}},ze=async(e,t,s=ce())=>{try{const n=await v(e);if(ee(t)){const o=c.readFileSync(t,"utf8");o.replace(/^(?!export\s)const\s.*/gm,d=>`export ${d}`)!==o&&await oe.writeFile(t,o);const S=await ae(e),{contents:j}=await L(e,t,n);let l=o;if(Object.entries(j).forEach(([d,w])=>{var f;if(w.isKeyframes||!w.generator)return;const p=w.generator._withBuildContext({callerName:d,isProduction:s,config:S}),h=new RegExp(`\\s${d}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(o);if(!h)return console.error("Could not find the original declaration");const y=(f=h.at(1))==null?void 0:f.trim(),C=new RegExp(`\\s${d}[=\\s]+styled\\(`,"g").exec(l);if(!C)return console.error("Could not find the original declaration");const{index:N}=C;let k=!1;const J=setTimeout(()=>k=!0,5e3);let T=0,H=!1,D=0;for(;!H&&!k;){const F=l[N+T];F==="("&&D++,F===")"&&D--,D===0&&F===")"&&(H=!0),T>l.length&&(k=!0),T++}if(!k)clearTimeout(J);else throw new Error("Failed to find the end of the styled call and timed out");const q=N+T,u=l.slice(N,q),m=l,$=` ${d} = styled(${y}, "${p.classNames}", ${JSON.stringify(p.clientProps)});`;l=l.replace(u,$),m===l&&console.error("Minimize file failed to change content",{name:d,tagName:y})}),S.importStrategy==="component"){const d=_.toHash(t,6),w=a.parse(t);l=`import '../../saltygen/css/${`f_${_.dashCase(w.name)}-${d}.css`}';
38
+ ${l}`}return l=l.replace("{ styled }","{ styledClient as styled }"),l=l.replace("@salty-css/react/styled","@salty-css/react/styled-client"),l}}catch(n){console.error("Error in minimizeFile:",n)}};exports.compileSaltyFile=L;exports.generateConfigStyles=$e;exports.generateCss=ve;exports.generateFile=Je;exports.isSaltyFile=ee;exports.logError=Te;exports.logger=K;exports.minimizeFile=ze;exports.saltyFileExtensions=ie;exports.saltyFileRegExp=we;
@@ -11,21 +11,21 @@ import { d as Mt } from "./define-templates-4A2yHcMF.js";
11
11
  const ht = async (t, e = []) => {
12
12
  if (!t) return "";
13
13
  const s = [], n = {};
14
- for (const [o, a] of Object.entries(t))
15
- if (typeof a != "function") if (a && typeof a == "object") {
16
- const i = o.trim(), h = await ht(a, [...e, i]);
14
+ for (const [a, o] of Object.entries(t))
15
+ if (typeof o != "function") if (o && typeof o == "object") {
16
+ const i = a.trim(), h = await ht(o, [...e, i]);
17
17
  s.push(h);
18
18
  } else
19
- n[o] = a;
19
+ n[a] = o;
20
20
  if (Object.keys(n).length) {
21
- const o = e.map(B).join("-"), a = "t_" + v(o, 4), i = await at(n, `.${o}, .${a}`);
21
+ const a = e.map(B).join("-"), o = "t_" + v(a, 4), i = await at(n, `.${a}, .${o}`);
22
22
  s.push(i);
23
23
  }
24
24
  return s.join(`
25
25
  `);
26
- }, vt = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "function" ? e[s] = "any" : typeof n == "object" && (e[s] = $t(n).map((o) => `"${o}"`).join(" | ")), e), {}) : {}, $t = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, o]) => {
27
- const a = e ? `${e}.${n}` : n;
28
- return typeof o == "object" ? $t(o, a, s) : s.add(e);
26
+ }, vt = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "function" ? e[s] = "any" : typeof n == "object" && (e[s] = $t(n).map((a) => `"${a}"`).join(" | ")), e), {}) : {}, $t = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, a]) => {
27
+ const o = e ? `${e}.${n}` : n;
28
+ return typeof a == "object" ? $t(a, o, s) : s.add(e);
29
29
  }), [...s]) : [], bt = (t) => {
30
30
  if (!t || t === "/") throw new Error("Could not find package.json file");
31
31
  const e = r(t, "package.json");
@@ -108,7 +108,7 @@ const zt = {
108
108
  if (M.externalModules.length > 0) return M.externalModules;
109
109
  const s = O(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
110
110
  if (!s) return [];
111
- const n = s[1].split(",").map((o) => o.replace(/['"`]/g, "").trim());
111
+ const n = s[1].split(",").map((a) => a.replace(/['"`]/g, "").trim());
112
112
  return M.externalModules = n, n;
113
113
  }, R = async (t) => {
114
114
  if (M.destDir) return M.destDir;
@@ -121,22 +121,22 @@ const zt = {
121
121
  });
122
122
  return s ? (M.rcFile = s, s) : Ft(r(t, ".."));
123
123
  }, ct = async (t) => {
124
- var n, o;
125
- const e = await Ft(t), s = (n = e.projects) == null ? void 0 : n.find((a) => t.endsWith(a.dir || ""));
126
- return s || ((o = e.projects) == null ? void 0 : o.find((a) => a.dir === e.defaultProject));
124
+ var n, a;
125
+ const e = await Ft(t), s = (n = e.projects) == null ? void 0 : n.find((o) => t.endsWith(o.dir || ""));
126
+ return s || ((a = e.projects) == null ? void 0 : a.find((o) => o.dir === e.defaultProject));
127
127
  }, It = async (t) => {
128
- const e = await ct(t), s = await R(t), n = r(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), o = r(s, "salty.config.js"), a = await wt(t), i = Ct(n);
128
+ const e = await ct(t), s = await R(t), n = r(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), a = r(s, "salty.config.js"), o = await wt(t), i = Ct(n);
129
129
  await gt.build({
130
130
  entryPoints: [n],
131
131
  minify: !0,
132
132
  treeShaking: !0,
133
133
  bundle: !0,
134
- outfile: o,
135
- format: a,
134
+ outfile: a,
135
+ format: o,
136
136
  external: i
137
137
  });
138
- const h = Date.now(), { config: $ } = await import(`${o}?t=${h}`);
139
- return { config: $, path: o };
138
+ const h = Date.now(), { config: $ } = await import(`${a}?t=${h}`);
139
+ return { config: $, path: a };
140
140
  }, Bt = async (t, e) => {
141
141
  var pt, ut;
142
142
  const s = await R(t), n = {
@@ -146,46 +146,46 @@ const zt = {
146
146
  templates: []
147
147
  };
148
148
  await Promise.all(
149
- [...e].map(async (m) => {
150
- const { contents: w, outputFilePath: V } = await et(t, m, s);
149
+ [...e].map(async (g) => {
150
+ const { contents: w, outputFilePath: V } = await et(t, g, s);
151
151
  Object.entries(w).forEach(([N, _]) => {
152
152
  _.isMedia ? n.mediaQueries.push([N, _]) : _.isGlobalDefine ? n.globalStyles.push(_) : _.isDefineVariables ? n.variables.push(_) : _.isDefineTemplates && n.templates.push(_._setPath(`${N};;${V}`));
153
153
  });
154
154
  })
155
155
  );
156
- const { config: o, path: a } = await It(t), i = { ...o }, h = /* @__PURE__ */ new Set(), $ = (m, w = []) => m ? Object.entries(m).flatMap(([V, N]) => {
156
+ const { config: a, path: o } = await It(t), i = { ...a }, h = /* @__PURE__ */ new Set(), $ = (g, w = []) => g ? Object.entries(g).flatMap(([V, N]) => {
157
157
  if (!N) return;
158
158
  if (typeof N == "object") return $(N, [...w, V]);
159
159
  const _ = St(V), st = B(V), nt = [...w, _].join(".");
160
160
  h.add(`"${nt}"`);
161
161
  const X = [...w.map(B), st].join("-"), dt = Tt(N);
162
162
  return dt ? `--${X}: ${dt.transformed};` : `--${X}: ${N};`;
163
- }) : [], c = (m) => m ? Object.entries(m).flatMap(([w, V]) => {
163
+ }) : [], c = (g) => g ? Object.entries(g).flatMap(([w, V]) => {
164
164
  const N = $(V);
165
165
  return w === "base" ? N.join("") : `${w} { ${N.join("")} }`;
166
- }) : [], p = (m) => m ? Object.entries(m).flatMap(([w, V]) => Object.entries(V).flatMap(([N, _]) => {
166
+ }) : [], p = (g) => g ? Object.entries(g).flatMap(([w, V]) => Object.entries(V).flatMap(([N, _]) => {
167
167
  const st = $(_, [w]), nt = `.${w}-${N}, [data-${w}="${N}"]`, X = st.join("");
168
168
  return `${nt} { ${X} }`;
169
- })) : [], b = (m) => ({ ...m, responsive: void 0, conditional: void 0 }), u = (m) => n.variables.map((w) => m === "static" ? b(w._current) : w._current[m]), g = I(b(o.variables), u("static")), y = $(g), j = I((pt = o.variables) == null ? void 0 : pt.responsive, u("responsive")), P = c(j), k = I((ut = o.variables) == null ? void 0 : ut.conditional, u("conditional")), J = p(k), T = r(s, "css/_variables.css"), G = `:root { ${y.join("")} ${P.join("")} } ${J.join("")}`;
170
- F(T, G), i.staticVariables = g;
171
- const D = r(s, "css/_global.css"), H = I(o.global, n.globalStyles), l = await at(H, "");
172
- F(D, `@layer global { ${l} }`);
173
- const d = r(s, "css/_reset.css"), f = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset : zt, C = await at(f, "");
174
- F(d, `@layer reset { ${C} }`);
175
- const x = r(s, "css/_templates.css"), E = I(o.templates, n.templates), K = await ht(E), A = vt(E);
169
+ })) : [], b = (g) => ({ ...g, responsive: void 0, conditional: void 0 }), u = (g) => n.variables.map((w) => g === "static" ? b(w._current) : w._current[g]), y = I(b(a.variables), u("static")), d = $(y), j = I((pt = a.variables) == null ? void 0 : pt.responsive, u("responsive")), P = c(j), k = I((ut = a.variables) == null ? void 0 : ut.conditional, u("conditional")), J = p(k), T = r(s, "css/_variables.css"), G = `:root { ${d.join("")} ${P.join("")} } ${J.join("")}`;
170
+ F(T, G), i.staticVariables = y;
171
+ const D = r(s, "css/_global.css"), H = I(a.global, n.globalStyles), f = await at(H, "");
172
+ F(D, `@layer global { ${f} }`);
173
+ const m = r(s, "css/_reset.css"), l = a.reset === "none" ? {} : typeof a.reset == "object" ? a.reset : zt, C = await at(l, "");
174
+ F(m, `@layer reset { ${C} }`);
175
+ const x = r(s, "css/_templates.css"), E = I(a.templates, n.templates), K = await ht(E), A = vt(E);
176
176
  F(x, `@layer templates { ${K} }`), i.templates = E;
177
- const L = o.templates ? [Mt(o.templates)._setPath(`config;;${a}`)] : [], Z = Vt(n.templates, L);
178
- i.templatePaths = Object.fromEntries(Object.entries(Z).map(([m, w]) => [m, w._path]));
177
+ const L = a.templates ? [Mt(a.templates)._setPath(`config;;${o}`)] : [], Z = Vt(n.templates, L);
178
+ i.templatePaths = Object.fromEntries(Object.entries(Z).map(([g, w]) => [g, w._path]));
179
179
  const { mediaQueries: q } = n;
180
- i.mediaQueries = Object.fromEntries(q.map(([m, w]) => [`@${m}`, w]));
181
- const Q = q.map(([m]) => `'@${m}'`).join(" | "), U = r(s, "types/css-tokens.d.ts"), xt = `
180
+ i.mediaQueries = Object.fromEntries(q.map(([g, w]) => [`@${g}`, w]));
181
+ const Q = q.map(([g]) => `'@${g}'`).join(" | "), U = r(s, "types/css-tokens.d.ts"), xt = `
182
182
  // Variable types
183
183
  type VariableTokens = ${[...h].join("|")};
184
184
  type PropertyValueToken = \`{\${VariableTokens}}\`;
185
185
 
186
186
  // Template types
187
187
  type TemplateTokens = {
188
- ${Object.entries(A).map(([m, w]) => `${m}?: ${w}`).join(`
188
+ ${Object.entries(A).map(([g, w]) => `${g}?: ${w}`).join(`
189
189
  `)}
190
190
  }
191
191
 
@@ -197,9 +197,9 @@ const zt = {
197
197
  F(Nt, JSON.stringify(i, null, 2));
198
198
  }, mt = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
199
199
  if (/^['"`]/.test(s)) return e;
200
- const o = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
201
- if (!o.test(t)) return e;
202
- const i = o.exec(t);
200
+ const a = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
201
+ if (!a.test(t)) return e;
202
+ const i = a.exec(t);
203
203
  if (i) {
204
204
  const h = i.at(1);
205
205
  if (jt.some((c) => h == null ? void 0 : h.includes(c))) return e;
@@ -217,17 +217,17 @@ ${t}`;
217
217
  return t;
218
218
  }
219
219
  }, et = async (t, e, s) => {
220
- const n = v(e), o = r(s, "./temp");
221
- it(o) || W(o);
222
- const a = tt(e);
220
+ const n = v(e), a = r(s, "./temp");
221
+ it(a) || W(a);
222
+ const o = tt(e);
223
223
  let i = O(e, "utf8");
224
224
  i = mt(i), i = Gt(i, t);
225
225
  const h = r(s, "js", n + ".js"), $ = await ct(t), c = r(t, ($ == null ? void 0 : $.configDir) || "", "salty.config.ts"), p = Ct(c), b = await wt(t);
226
226
  await gt.build({
227
227
  stdin: {
228
228
  contents: i,
229
- sourcefile: a.base,
230
- resolveDir: a.dir,
229
+ sourcefile: o.base,
230
+ resolveDir: o.dir,
231
231
  loader: "tsx"
232
232
  },
233
233
  minify: !1,
@@ -242,8 +242,8 @@ ${t}`;
242
242
  plugins: [
243
243
  {
244
244
  name: "test",
245
- setup: (y) => {
246
- y.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (j) => {
245
+ setup: (d) => {
246
+ d.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (j) => {
247
247
  const P = O(j.path, "utf8");
248
248
  return { contents: mt(P), loader: "ts" };
249
249
  });
@@ -258,8 +258,8 @@ ${t}`;
258
258
  if (!n) throw new Error("Could not find config cache file");
259
259
  return JSON.parse(n);
260
260
  }, lt = async (t) => {
261
- const e = await Ht(t), s = await R(t), n = r(s, "salty.config.js"), o = Date.now(), { config: a } = await import(`${n}?t=${o}`);
262
- return I(a, e);
261
+ const e = await Ht(t), s = await R(t), n = r(s, "salty.config.js"), a = Date.now(), { config: o } = await import(`${n}?t=${a}`);
262
+ return I(o, e);
263
263
  }, ft = () => {
264
264
  try {
265
265
  return process.env.NODE_ENV === "production";
@@ -270,21 +270,21 @@ ${t}`;
270
270
  try {
271
271
  const n = Date.now();
272
272
  e ? Y.info("Generating CSS in production mode! 🔥") : Y.info("Generating CSS in development mode! 🚀");
273
- const o = [], a = [], i = await R(t), h = r(i, "index.css");
273
+ const a = [], o = [], i = await R(t), h = r(i, "index.css");
274
274
  s && (() => {
275
275
  it(i) && Pt("rm -rf " + i), W(i, { recursive: !0 }), W(r(i, "css")), W(r(i, "types")), W(r(i, "js")), W(r(i, "cache"));
276
276
  })();
277
277
  const c = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Set();
278
- async function b(l) {
279
- const d = ["node_modules", "saltygen"], S = kt(l);
278
+ async function b(f) {
279
+ const m = ["node_modules", "saltygen"], S = kt(f);
280
280
  if (S.isDirectory()) {
281
- const f = Dt(l);
282
- if (d.some((x) => l.includes(x))) return;
283
- await Promise.all(f.map((x) => b(r(l, x))));
284
- } else if (S.isFile() && rt(l)) {
285
- c.add(l);
286
- const C = O(l, "utf8");
287
- /define[\w\d]+\(/.test(C) && p.add(l);
281
+ const l = Dt(f);
282
+ if (m.some((x) => f.includes(x))) return;
283
+ await Promise.all(l.map((x) => b(r(f, x))));
284
+ } else if (S.isFile() && rt(f)) {
285
+ c.add(f);
286
+ const C = O(f, "utf8");
287
+ /define[\w\d]+\(/.test(C) && p.add(f);
288
288
  }
289
289
  }
290
290
  await b(t), await Bt(t, p);
@@ -294,79 +294,79 @@ ${t}`;
294
294
  classNames: []
295
295
  };
296
296
  await Promise.all(
297
- [...c].map(async (l) => {
298
- const { contents: d } = await et(t, l, i);
299
- Object.entries(d).forEach(([S, f]) => {
300
- f.isKeyframes ? u.keyframes.push({
301
- value: f,
302
- src: l,
297
+ [...c].map(async (f) => {
298
+ const { contents: m } = await et(t, f, i);
299
+ Object.entries(m).forEach(([S, l]) => {
300
+ l.isKeyframes ? u.keyframes.push({
301
+ value: l,
302
+ src: f,
303
303
  name: S
304
- }) : f.isClassName ? u.classNames.push({
305
- ...f,
306
- src: l,
304
+ }) : l.isClassName ? u.classNames.push({
305
+ ...l,
306
+ src: f,
307
307
  name: S
308
- }) : f.generator && u.components.push({
309
- ...f,
310
- src: l,
308
+ }) : l.generator && u.components.push({
309
+ ...l,
310
+ src: f,
311
311
  name: S
312
312
  });
313
313
  });
314
314
  })
315
315
  );
316
- const g = await lt(t);
317
- for (const l of u.keyframes) {
318
- const { value: d } = l, S = `a_${d.animationName}.css`, f = `css/${S}`, C = r(i, f);
319
- o.push(S), F(C, d.css);
316
+ const y = await lt(t);
317
+ for (const f of u.keyframes) {
318
+ const { value: m } = f, S = `a_${m.animationName}.css`, l = `css/${S}`, C = r(i, l);
319
+ a.push(S), F(C, m.css);
320
320
  }
321
- const y = {};
322
- for (const l of u.components) {
323
- const { src: d, name: S } = l;
324
- y[d] || (y[d] = []);
325
- const f = l.generator._withBuildContext({
321
+ const d = {};
322
+ for (const f of u.components) {
323
+ const { src: m, name: S } = f;
324
+ d[m] || (d[m] = []);
325
+ const l = f.generator._withBuildContext({
326
326
  callerName: S,
327
327
  isProduction: e,
328
- config: g
328
+ config: y
329
329
  });
330
- a[f.priority] || (a[f.priority] = []);
331
- const C = await f.css;
330
+ o[l.priority] || (o[l.priority] = []);
331
+ const C = await l.css;
332
332
  if (!C) continue;
333
- a[f.priority].push(f.cssFileName);
334
- const x = `css/${f.cssFileName}`, E = r(i, x);
335
- F(E, C), g.importStrategy === "component" && y[d].push(f.cssFileName);
333
+ o[l.priority].push(l.cssFileName);
334
+ const x = `css/${l.cssFileName}`, E = r(i, x);
335
+ F(E, C), y.importStrategy === "component" && d[m].push(l.cssFileName);
336
336
  }
337
- for (const l of u.classNames) {
338
- const { src: d, name: S } = l;
339
- y[d] || (y[d] = []);
340
- const f = l.generator._withBuildContext({
337
+ for (const f of u.classNames) {
338
+ const { src: m, name: S } = f;
339
+ d[m] || (d[m] = []);
340
+ const l = f.generator._withBuildContext({
341
341
  callerName: S,
342
342
  isProduction: e,
343
- config: g
344
- }), C = await f.css;
343
+ config: y
344
+ }), C = await l.css;
345
345
  if (!C) continue;
346
- a[0].push(f.cssFileName);
347
- const x = `css/${f.cssFileName}`, E = r(i, x);
348
- F(E, C), g.importStrategy === "component" && y[d].push(f.cssFileName);
346
+ o[l.priority] || (o[l.priority] = []), o[l.priority].push(l.cssFileName);
347
+ const x = `css/${l.cssFileName}`, E = r(i, x);
348
+ F(E, C), y.importStrategy === "component" && d[m].push(l.cssFileName);
349
349
  }
350
- g.importStrategy === "component" && Object.entries(y).forEach(([l, d]) => {
351
- const S = d.map((K) => `@import url('./${K}');`).join(`
352
- `), f = v(l, 6), C = tt(l), x = B(C.name), E = r(i, `css/f_${x}-${f}.css`);
350
+ y.importStrategy === "component" && Object.entries(d).forEach(([f, m]) => {
351
+ const S = m.map((K) => `@import url('./${K}');`).join(`
352
+ `), l = v(f, 6), C = tt(f), x = B(C.name), E = r(i, `css/f_${x}-${l}.css`);
353
353
  F(E, S || "/* Empty file */");
354
354
  });
355
- const j = o.map((l) => `@import url('./css/${l}');`).join(`
355
+ const j = a.map((f) => `@import url('./css/${f}');`).join(`
356
356
  `);
357
357
  let T = `@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
358
358
 
359
- ${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((l) => {
359
+ ${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((f) => {
360
360
  try {
361
- return O(r(i, "css", l), "utf8").length > 0;
361
+ return O(r(i, "css", f), "utf8").length > 0;
362
362
  } catch {
363
363
  return !1;
364
364
  }
365
- }).map((l) => `@import url('./css/${l}');`).join(`
365
+ }).map((f) => `@import url('./css/${f}');`).join(`
366
366
  `)}
367
367
  ${j}`;
368
- if (g.importStrategy !== "component") {
369
- const l = a.reduce((d, S, f) => {
368
+ if (y.importStrategy !== "component") {
369
+ const f = o.reduce((m, S, l) => {
370
370
  const C = S.reduce((A, L) => {
371
371
  var U;
372
372
  const Z = r(i, "css", L), q = O(Z, "utf8"), Q = ((U = /.*-([^-]+)-\d+.css/.exec(L)) == null ? void 0 : U.at(1)) || v(Z, 6);
@@ -375,12 +375,12 @@ ${j}`;
375
375
  ${q}
376
376
  /*end:${Q}*/
377
377
  `;
378
- }, ""), x = `l_${f}.css`, E = r(i, "css", x), K = `@layer l${f} { ${C}
378
+ }, ""), x = `l_${l}.css`, E = r(i, "css", x), K = `@layer l${l} { ${C}
379
379
  }`;
380
- return F(E, K), `${d}
380
+ return F(E, K), `${m}
381
381
  @import url('./css/${x}');`;
382
382
  }, "");
383
- T += l;
383
+ T += f;
384
384
  }
385
385
  F(h, T);
386
386
  const D = Date.now() - n, H = D < 200 ? "🔥" : D < 500 ? "🚀" : D < 1e3 ? "🎉" : D < 2e3 ? "🚗" : D < 5e3 ? "🤔" : "🥴";
@@ -392,7 +392,7 @@ ${q}
392
392
  try {
393
393
  const n = await R(t);
394
394
  if (rt(e)) {
395
- const a = [], i = await lt(t), { contents: h } = await et(t, e, n);
395
+ const o = [], i = await lt(t), { contents: h } = await et(t, e, n);
396
396
  for (const [$, c] of Object.entries(h)) {
397
397
  if (c.isKeyframes && c.css) {
398
398
  const j = `css/${`a_${c.animationName}.css`}`, P = r(n, j);
@@ -400,14 +400,14 @@ ${q}
400
400
  return;
401
401
  }
402
402
  if (c.isClassName) {
403
- const y = c.generator._withBuildContext({
403
+ const d = c.generator._withBuildContext({
404
404
  callerName: $,
405
405
  isProduction: s,
406
406
  config: i
407
- }), j = await y.css;
407
+ }), j = await d.css;
408
408
  if (!j) continue;
409
- a[0].push(y.cssFileName);
410
- const P = `css/${y.cssFileName}`, k = r(n, P);
409
+ o[d.priority] || (o[d.priority] = []), o[d.priority].push(d.cssFileName);
410
+ const P = `css/${d.cssFileName}`, k = r(n, P);
411
411
  F(k, j);
412
412
  }
413
413
  if (!c.generator) return;
@@ -417,18 +417,18 @@ ${q}
417
417
  config: i
418
418
  }), b = await p.css;
419
419
  if (!b) continue;
420
- const u = `css/${p.cssFileName}`, g = r(n, u);
421
- F(g, b), a[p.priority] || (a[p.priority] = []), a[p.priority].push(p.cssFileName);
420
+ const u = `css/${p.cssFileName}`, y = r(n, u);
421
+ F(y, b), o[p.priority] || (o[p.priority] = []), o[p.priority].push(p.cssFileName);
422
422
  }
423
423
  if (i.importStrategy !== "component")
424
- a.forEach(($, c) => {
424
+ o.forEach(($, c) => {
425
425
  const p = `l_${c}.css`, b = r(n, "css", p);
426
426
  let u = O(b, "utf8");
427
- $.forEach((g) => {
427
+ $.forEach((y) => {
428
428
  var k;
429
- const y = r(n, "css", g), j = ((k = /.*-([^-]+)-\d+.css/.exec(g)) == null ? void 0 : k.at(1)) || v(y, 6);
429
+ const d = r(n, "css", y), j = ((k = /.*-([^-]+)-\d+.css/.exec(y)) == null ? void 0 : k.at(1)) || v(d, 6);
430
430
  if (!u.includes(j)) {
431
- const J = O(y, "utf8"), T = `/*start:${j}-${g}*/
431
+ const J = O(d, "utf8"), T = `/*start:${j}-${y}*/
432
432
  ${J}
433
433
  /*end:${j}*/
434
434
  `;
@@ -439,7 +439,7 @@ ${T}
439
439
  }), F(b, u);
440
440
  });
441
441
  else {
442
- const $ = a.flat().map((g) => `@import url('./${g}');`).join(`
442
+ const $ = o.flat().map((y) => `@import url('./${y}');`).join(`
443
443
  `), c = v(e, 6), p = tt(e), b = B(p.name), u = r(n, `css/f_${b}-${c}.css`);
444
444
  F(u, $ || "/* Empty file */");
445
445
  }
@@ -451,20 +451,20 @@ ${T}
451
451
  try {
452
452
  const n = await R(t);
453
453
  if (rt(e)) {
454
- const a = O(e, "utf8");
455
- a.replace(/^(?!export\s)const\s.*/gm, (p) => `export ${p}`) !== a && await _t(e, a);
454
+ const o = O(e, "utf8");
455
+ o.replace(/^(?!export\s)const\s.*/gm, (p) => `export ${p}`) !== o && await _t(e, o);
456
456
  const h = await lt(t), { contents: $ } = await et(t, e, n);
457
- let c = a;
457
+ let c = o;
458
458
  if (Object.entries($).forEach(([p, b]) => {
459
- var f;
459
+ var l;
460
460
  if (b.isKeyframes || !b.generator) return;
461
461
  const u = b.generator._withBuildContext({
462
462
  callerName: p,
463
463
  isProduction: s,
464
464
  config: h
465
- }), g = new RegExp(`\\s${p}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(a);
466
- if (!g) return console.error("Could not find the original declaration");
467
- const y = (f = g.at(1)) == null ? void 0 : f.trim(), j = new RegExp(`\\s${p}[=\\s]+styled\\(`, "g").exec(c);
465
+ }), y = new RegExp(`\\s${p}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(o);
466
+ if (!y) return console.error("Could not find the original declaration");
467
+ const d = (l = y.at(1)) == null ? void 0 : l.trim(), j = new RegExp(`\\s${p}[=\\s]+styled\\(`, "g").exec(c);
468
468
  if (!j) return console.error("Could not find the original declaration");
469
469
  const { index: P } = j;
470
470
  let k = !1;
@@ -476,8 +476,8 @@ ${T}
476
476
  }
477
477
  if (!k) clearTimeout(J);
478
478
  else throw new Error("Failed to find the end of the styled call and timed out");
479
- const H = P + T, l = c.slice(P, H), d = c, S = ` ${p} = styled(${y}, "${u.classNames}", ${JSON.stringify(u.clientProps)});`;
480
- c = c.replace(l, S), d === c && console.error("Minimize file failed to change content", { name: p, tagName: y });
479
+ const H = P + T, f = c.slice(P, H), m = c, S = ` ${p} = styled(${d}, "${u.classNames}", ${JSON.stringify(u.clientProps)});`;
480
+ c = c.replace(f, S), m === c && console.error("Minimize file failed to change content", { name: p, tagName: d });
481
481
  }), h.importStrategy === "component") {
482
482
  const p = v(e, 6), b = tt(e);
483
483
  c = `import '../../saltygen/css/${`f_${B(b.name)}-${p}.css`}';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.216",
3
+ "version": "0.0.1-alpha.218",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
package/server/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("fs/promises"),r=require("../index-B6M9WK93.cjs"),i=async t=>{if(!t||t.includes("node_modules")||t.includes("saltygen"))return!1;if(t.includes("salty.config"))return!0;if(!r.isSaltyFile(t))return!1;const e=await s.readFile(t,"utf-8");return!!/.+define[A-Z]\w+/.test(e)};exports.checkShouldRestart=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("fs/promises"),r=require("../index-BPohv4BZ.cjs"),i=async t=>{if(!t||t.includes("node_modules")||t.includes("saltygen"))return!1;if(t.includes("salty.config"))return!0;if(!r.isSaltyFile(t))return!1;const e=await s.readFile(t,"utf-8");return!!/.+define[A-Z]\w+/.test(e)};exports.checkShouldRestart=i;
package/server/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { readFile as r } from "fs/promises";
2
- import { i as e } from "../index-B_bv7TCc.js";
2
+ import { i as e } from "../index-DVSBEd3f.js";
3
3
  const f = async (t) => {
4
4
  if (!t || t.includes("node_modules") || t.includes("saltygen")) return !1;
5
5
  if (t.includes("salty.config")) return !0;
@@ -1,38 +0,0 @@
1
- "use strict";const xe=require("esbuild"),Pe=require("child_process"),_=require("./dash-case-BJEkFEGQ.cjs"),r=require("path"),c=require("fs"),oe=require("fs/promises"),Y=require("./parse-styles-C6OYNcYI.cjs"),G=require("winston"),M=require("./css/merge.cjs"),Ne=require("./define-templates-Cunsb_Tr.cjs");var ne=typeof document<"u"?document.currentScript:null;function ke(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const pe=ke(xe),ye=async(e,t=[])=>{if(!e)return"";const s=[],n={};for(const[o,i]of Object.entries(e))if(typeof i!="function")if(i&&typeof i=="object"){const a=o.trim(),S=await ye(i,[...t,a]);s.push(S)}else n[o]=i;if(Object.keys(n).length){const o=t.map(_.dashCase).join("-"),i="t_"+_.toHash(o,4),a=await Y.parseAndJoinStyles(n,`.${o}, .${i}`);s.push(a)}return s.join(`
2
- `)},_e=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=me(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},me=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const i=t?`${t}.${n}`:n;return typeof o=="object"?me(o,i,s):s.add(t)}),[...s]):[],ge=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=r.join(e,"package.json");return c.existsSync(t)?t:ge(r.join(e,".."))},De=async e=>{const t=ge(e);return await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Oe=async e=>{const t=await De(e);if(t)return t.type};let z;const he=async e=>{if(z)return z;const t=await Oe(e);return t==="module"?z="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:ne&&ne.tagName.toUpperCase()==="SCRIPT"&&ne.src||new URL("index-B6M9WK93.cjs",document.baseURI).href).endsWith(".cjs"))&&(z="cjs"),z||"esm"},K=G.createLogger({level:"debug",format:G.format.combine(G.format.colorize(),G.format.cli()),transports:[new G.transports.Console({})]}),Te=e=>{K.error(e)};function Se(e){return e?typeof e!="string"?Se(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?".":"")+t.toLowerCase()):""}const Ee={"*, *::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"}},V={externalModules:[],rcFile:void 0,destDir:void 0},je=e=>{if(V.externalModules.length>0)return V.externalModules;const s=c.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return V.externalModules=n,n},v=async e=>{if(V.destDir)return V.destDir;const t=await ae(e),s=r.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return V.destDir=s,s},ie=["salty","css","styles","styled"],we=(e=[])=>new RegExp(`\\.(${[...ie,...e].join("|")})\\.`),ee=(e,t=[])=>we(t).test(e),be=async e=>{if(V.rcFile)return V.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=r.join(e,".saltyrc.json"),s=await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(V.rcFile=s,s):be(r.join(e,".."))},ae=async e=>{var n,o;const t=await be(e),s=(n=t.projects)==null?void 0:n.find(i=>e.endsWith(i.dir||""));return s||((o=t.projects)==null?void 0:o.find(i=>i.dir===t.defaultProject))},Re=async e=>{const t=await ae(e),s=await v(e),n=r.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=r.join(s,"salty.config.js"),i=await he(e),a=je(n);await pe.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:i,external:a});const S=Date.now(),{config:j}=await import(`${o}?t=${S}`);return{config:j,path:o}},$e=async(e,t)=>{var le,fe;const s=await v(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async m=>{const{contents:b,outputFilePath:R}=await L(e,m,s);Object.entries(b).forEach(([P,O])=>{O.isMedia?n.mediaQueries.push([P,O]):O.isGlobalDefine?n.globalStyles.push(O):O.isDefineVariables?n.variables.push(O):O.isDefineTemplates&&n.templates.push(O._setPath(`${P};;${R}`))})}));const{config:o,path:i}=await Re(e),a={...o},S=new Set,j=(m,b=[])=>m?Object.entries(m).flatMap(([R,P])=>{if(!P)return;if(typeof P=="object")return j(P,[...b,R]);const O=Se(R),te=_.dashCase(R),se=[...b,O].join(".");S.add(`"${se}"`);const X=[...b.map(_.dashCase),te].join("-"),ue=Y.parseVariableTokens(P);return ue?`--${X}: ${ue.transformed};`:`--${X}: ${P};`}):[],l=m=>m?Object.entries(m).flatMap(([b,R])=>{const P=j(R);return b==="base"?P.join(""):`${b} { ${P.join("")} }`}):[],d=m=>m?Object.entries(m).flatMap(([b,R])=>Object.entries(R).flatMap(([P,O])=>{const te=j(O,[b]),se=`.${b}-${P}, [data-${b}="${P}"]`,X=te.join("");return`${se} { ${X} }`})):[],w=m=>({...m,responsive:void 0,conditional:void 0}),p=m=>n.variables.map(b=>m==="static"?w(b._current):b._current[m]),g=M.mergeObjects(w(o.variables),p("static")),h=j(g),C=M.mergeObjects((le=o.variables)==null?void 0:le.responsive,p("responsive")),N=l(C),k=M.mergeObjects((fe=o.variables)==null?void 0:fe.conditional,p("conditional")),J=d(k),T=r.join(s,"css/_variables.css"),H=`:root { ${h.join("")} ${N.join("")} } ${J.join("")}`;c.writeFileSync(T,H),a.staticVariables=g;const D=r.join(s,"css/_global.css"),q=M.mergeObjects(o.global,n.globalStyles),f=await Y.parseAndJoinStyles(q,"");c.writeFileSync(D,`@layer global { ${f} }`);const y=r.join(s,"css/_reset.css"),u=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Ee,F=await Y.parseAndJoinStyles(u,"");c.writeFileSync(y,`@layer reset { ${F} }`);const x=r.join(s,"css/_templates.css"),E=M.mergeObjects(o.templates,n.templates),I=await ye(E),W=_e(E);c.writeFileSync(x,`@layer templates { ${I} }`),a.templates=E;const A=o.templates?[Ne.defineTemplates(o.templates)._setPath(`config;;${i}`)]:[],Q=M.mergeFactories(n.templates,A);a.templatePaths=Object.fromEntries(Object.entries(Q).map(([m,b])=>[m,b._path]));const{mediaQueries:Z}=n;a.mediaQueries=Object.fromEntries(Z.map(([m,b])=>[`@${m}`,b]));const B=Z.map(([m])=>`'@${m}'`).join(" | "),U=r.join(s,"types/css-tokens.d.ts"),Fe=`
3
- // Variable types
4
- type VariableTokens = ${[...S].join("|")};
5
- type PropertyValueToken = \`{\${VariableTokens}}\`;
6
-
7
- // Template types
8
- type TemplateTokens = {
9
- ${Object.entries(W).map(([m,b])=>`${m}?: ${b}`).join(`
10
- `)}
11
- }
12
-
13
- // Media query types
14
- type MediaQueryKeys = ${B||"''"};
15
- `;c.writeFileSync(U,Fe);const Ce=r.join(s,"cache/config-cache.json");c.writeFileSync(Ce,JSON.stringify(a,null,2))},de=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const o=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!o.test(e))return t;const a=o.exec(e);if(a){const S=a.at(1);if(ie.some(l=>S==null?void 0:S.includes(l)))return t}return"styled('div',"}),Ve=(e,t)=>{try{const s=c.readFileSync(r.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
16
-
17
- ${e}`:`globalThis.saltyConfig = {};
18
-
19
- ${e}`}catch{return e}},L=async(e,t,s)=>{const n=_.toHash(t),o=r.join(s,"./temp");c.existsSync(o)||c.mkdirSync(o);const i=r.parse(t);let a=c.readFileSync(t,"utf8");a=de(a),a=Ve(a,e);const S=r.join(s,"js",n+".js"),j=await ae(e),l=r.join(e,(j==null?void 0:j.configDir)||"","salty.config.ts"),d=je(l),w=await he(e);await pe.build({stdin:{contents:a,sourcefile:i.base,resolveDir:i.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:S,format:w,target:["node20"],keepNames:!0,external:d,packages:"external",plugins:[{name:"test",setup:h=>{h.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},C=>{const N=c.readFileSync(C.path,"utf8");return{contents:de(N),loader:"ts"}})}}]});const p=Date.now();return{contents:await import(`${S}?t=${p}`),outputFilePath:S}},Me=async e=>{const t=await v(e),s=r.join(t,"cache/config-cache.json"),n=c.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},re=async e=>{const t=await Me(e),s=await v(e),n=r.join(s,"salty.config.js"),o=Date.now(),{config:i}=await import(`${n}?t=${o}`);return M.mergeObjects(i,t)},ce=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ve=async(e,t=ce(),s=!0)=>{try{const n=Date.now();t?K.info("Generating CSS in production mode! 🔥"):K.info("Generating CSS in development mode! 🚀");const o=[],i=[],a=await v(e),S=r.join(a,"index.css");s&&(()=>{c.existsSync(a)&&Pe.execSync("rm -rf "+a),c.mkdirSync(a,{recursive:!0}),c.mkdirSync(r.join(a,"css")),c.mkdirSync(r.join(a,"types")),c.mkdirSync(r.join(a,"js")),c.mkdirSync(r.join(a,"cache"))})();const l=new Set,d=new Set;async function w(f){const y=["node_modules","saltygen"],$=c.statSync(f);if($.isDirectory()){const u=c.readdirSync(f);if(y.some(x=>f.includes(x)))return;await Promise.all(u.map(x=>w(r.join(f,x))))}else if($.isFile()&&ee(f)){l.add(f);const F=c.readFileSync(f,"utf8");/define[\w\d]+\(/.test(F)&&d.add(f)}}await w(e),await $e(e,d);const p={keyframes:[],components:[],classNames:[]};await Promise.all([...l].map(async f=>{const{contents:y}=await L(e,f,a);Object.entries(y).forEach(([$,u])=>{u.isKeyframes?p.keyframes.push({value:u,src:f,name:$}):u.isClassName?p.classNames.push({...u,src:f,name:$}):u.generator&&p.components.push({...u,src:f,name:$})})}));const g=await re(e);for(const f of p.keyframes){const{value:y}=f,$=`a_${y.animationName}.css`,u=`css/${$}`,F=r.join(a,u);o.push($),c.writeFileSync(F,y.css)}const h={};for(const f of p.components){const{src:y,name:$}=f;h[y]||(h[y]=[]);const u=f.generator._withBuildContext({callerName:$,isProduction:t,config:g});i[u.priority]||(i[u.priority]=[]);const F=await u.css;if(!F)continue;i[u.priority].push(u.cssFileName);const x=`css/${u.cssFileName}`,E=r.join(a,x);c.writeFileSync(E,F),g.importStrategy==="component"&&h[y].push(u.cssFileName)}for(const f of p.classNames){const{src:y,name:$}=f;h[y]||(h[y]=[]);const u=f.generator._withBuildContext({callerName:$,isProduction:t,config:g}),F=await u.css;if(!F)continue;i[0].push(u.cssFileName);const x=`css/${u.cssFileName}`,E=r.join(a,x);c.writeFileSync(E,F),g.importStrategy==="component"&&h[y].push(u.cssFileName)}g.importStrategy==="component"&&Object.entries(h).forEach(([f,y])=>{const $=y.map(I=>`@import url('./${I}');`).join(`
20
- `),u=_.toHash(f,6),F=r.parse(f),x=_.dashCase(F.name),E=r.join(a,`css/f_${x}-${u}.css`);c.writeFileSync(E,$||"/* Empty file */")});const C=o.map(f=>`@import url('./css/${f}');`).join(`
21
- `);let T=`@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
22
-
23
- ${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return c.readFileSync(r.join(a,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
24
- `)}
25
- ${C}`;if(g.importStrategy!=="component"){const f=i.reduce((y,$,u)=>{const F=$.reduce((W,A)=>{var U;const Q=r.join(a,"css",A),Z=c.readFileSync(Q,"utf8"),B=((U=/.*-([^-]+)-\d+.css/.exec(A))==null?void 0:U.at(1))||_.toHash(Q,6);return W.includes(B)?W:`${W}
26
- /*start:${B}-${A}*/
27
- ${Z}
28
- /*end:${B}*/
29
- `},""),x=`l_${u}.css`,E=r.join(a,"css",x),I=`@layer l${u} { ${F}
30
- }`;return c.writeFileSync(E,I),`${y}
31
- @import url('./css/${x}');`},"");T+=f}c.writeFileSync(S,T);const D=Date.now()-n,q=D<200?"🔥":D<500?"🚀":D<1e3?"🎉":D<2e3?"🚗":D<5e3?"🤔":"🥴";K.info(`Generated CSS in ${D}ms! ${q}`)}catch(n){console.error(n)}},Je=async(e,t,s=ce())=>{try{const n=await v(e);if(ee(t)){const i=[],a=await re(e),{contents:S}=await L(e,t,n);for(const[j,l]of Object.entries(S)){if(l.isKeyframes&&l.css){const C=`css/${`a_${l.animationName}.css`}`,N=r.join(n,C);c.writeFileSync(N,await l.css);return}if(l.isClassName){const h=l.generator._withBuildContext({callerName:j,isProduction:s,config:a}),C=await h.css;if(!C)continue;i[0].push(h.cssFileName);const N=`css/${h.cssFileName}`,k=r.join(n,N);c.writeFileSync(k,C)}if(!l.generator)return;const d=l.generator._withBuildContext({callerName:j,isProduction:s,config:a}),w=await d.css;if(!w)continue;const p=`css/${d.cssFileName}`,g=r.join(n,p);c.writeFileSync(g,w),i[d.priority]||(i[d.priority]=[]),i[d.priority].push(d.cssFileName)}if(a.importStrategy!=="component")i.forEach((j,l)=>{const d=`l_${l}.css`,w=r.join(n,"css",d);let p=c.readFileSync(w,"utf8");j.forEach(g=>{var k;const h=r.join(n,"css",g),C=((k=/.*-([^-]+)-\d+.css/.exec(g))==null?void 0:k.at(1))||_.toHash(h,6);if(!p.includes(C)){const J=c.readFileSync(h,"utf8"),T=`/*start:${C}-${g}*/
32
- ${J}
33
- /*end:${C}*/
34
- `;p=`${p.replace(/\}$/,"")}
35
- ${T}
36
- }`}}),c.writeFileSync(w,p)});else{const j=i.flat().map(g=>`@import url('./${g}');`).join(`
37
- `),l=_.toHash(t,6),d=r.parse(t),w=_.dashCase(d.name),p=r.join(n,`css/f_${w}-${l}.css`);c.writeFileSync(p,j||"/* Empty file */")}}}catch(n){console.error(n)}},ze=async(e,t,s=ce())=>{try{const n=await v(e);if(ee(t)){const i=c.readFileSync(t,"utf8");i.replace(/^(?!export\s)const\s.*/gm,d=>`export ${d}`)!==i&&await oe.writeFile(t,i);const S=await re(e),{contents:j}=await L(e,t,n);let l=i;if(Object.entries(j).forEach(([d,w])=>{var u;if(w.isKeyframes||!w.generator)return;const p=w.generator._withBuildContext({callerName:d,isProduction:s,config:S}),g=new RegExp(`\\s${d}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(i);if(!g)return console.error("Could not find the original declaration");const h=(u=g.at(1))==null?void 0:u.trim(),C=new RegExp(`\\s${d}[=\\s]+styled\\(`,"g").exec(l);if(!C)return console.error("Could not find the original declaration");const{index:N}=C;let k=!1;const J=setTimeout(()=>k=!0,5e3);let T=0,H=!1,D=0;for(;!H&&!k;){const F=l[N+T];F==="("&&D++,F===")"&&D--,D===0&&F===")"&&(H=!0),T>l.length&&(k=!0),T++}if(!k)clearTimeout(J);else throw new Error("Failed to find the end of the styled call and timed out");const q=N+T,f=l.slice(N,q),y=l,$=` ${d} = styled(${h}, "${p.classNames}", ${JSON.stringify(p.clientProps)});`;l=l.replace(f,$),y===l&&console.error("Minimize file failed to change content",{name:d,tagName:h})}),S.importStrategy==="component"){const d=_.toHash(t,6),w=r.parse(t);l=`import '../../saltygen/css/${`f_${_.dashCase(w.name)}-${d}.css`}';
38
- ${l}`}return l=l.replace("{ styled }","{ styledClient as styled }"),l=l.replace("@salty-css/react/styled","@salty-css/react/styled-client"),l}}catch(n){console.error("Error in minimizeFile:",n)}};exports.compileSaltyFile=L;exports.generateConfigStyles=$e;exports.generateCss=ve;exports.generateFile=Je;exports.isSaltyFile=ee;exports.logError=Te;exports.logger=K;exports.minimizeFile=ze;exports.saltyFileExtensions=ie;exports.saltyFileRegExp=we;