@thi.ng/meta-css 0.13.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/README.md +14 -3
- package/index.js +1 -1
- package/package.json +16 -16
- package/specs/shadows.mcss.json +18 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-08-
|
|
3
|
+
- **Last updated**: 2024-08-18T14:11:34Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [0.14.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/meta-css@0.14.0) (2024-08-18)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add shadow templates ([5a1b3f9](https://github.com/thi-ng/umbrella/commit/5a1b3f9))
|
|
17
|
+
|
|
12
18
|
## [0.13.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/meta-css@0.13.0) (2024-08-13)
|
|
13
19
|
|
|
14
20
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 199 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
|
@@ -109,6 +109,7 @@
|
|
|
109
109
|
- [Mask](#mask)
|
|
110
110
|
- [Padding](#padding)
|
|
111
111
|
- [Positions](#positions)
|
|
112
|
+
- [Shadow](#shadow)
|
|
112
113
|
- [Svg](#svg)
|
|
113
114
|
- [Text color](#text-color)
|
|
114
115
|
- [Media queries](#media-queries)
|
|
@@ -1114,7 +1115,7 @@ These are readily usable (and used by a growing number of example projects in
|
|
|
1114
1115
|
this repo), but also are provided as starting point to define your own custom
|
|
1115
1116
|
framework(s)...
|
|
1116
1117
|
|
|
1117
|
-
Currently, there are
|
|
1118
|
+
Currently, there are 952 CSS utility classes (incl. 72 templates) defined in "MetaCSS base" (v0.13.0):
|
|
1118
1119
|
|
|
1119
1120
|
### Classes by category
|
|
1120
1121
|
|
|
@@ -2727,6 +2728,16 @@ Sets padding to custom size
|
|
|
2727
2728
|
|
|
2728
2729
|
</details>
|
|
2729
2730
|
|
|
2731
|
+
#### Shadow
|
|
2732
|
+
|
|
2733
|
+
##### `box-shadow(body)`
|
|
2734
|
+
|
|
2735
|
+
- **body**: CSS value/definition
|
|
2736
|
+
|
|
2737
|
+
##### `text-shadow(body)`
|
|
2738
|
+
|
|
2739
|
+
- **body**: CSS value/definition
|
|
2740
|
+
|
|
2730
2741
|
#### Svg
|
|
2731
2742
|
|
|
2732
2743
|
##### `fill(name)`
|
|
@@ -2777,7 +2788,7 @@ distributed as CLI bundle with **no runtime dependencies**. The following
|
|
|
2777
2788
|
dependencies are only shown for informational purposes and are (partially)
|
|
2778
2789
|
included in the bundle.
|
|
2779
2790
|
|
|
2780
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 13.
|
|
2791
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 13.74 KB
|
|
2781
2792
|
|
|
2782
2793
|
## Dependencies
|
|
2783
2794
|
|
package/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var mo={default:95,hint:90,multi:90,param:96,required:33};var $t=(t)=>t;var tt=function(t,o=Object.create(null)){return(...n)=>{const m=JSON.stringify(n);if(m!==void 0)return m in o?o[m]:o[m]=t.apply(null,n);return t.apply(null,n)}};var ot=tt((t,o)=>t.repeat(o));var Do=(t)=>/^[a-f0-9]+$/i.test(t);var Zo=(t)=>/^[-+]?\d+$/.test(t),jo=(t)=>/^[-+]?\d*\.?\d+(e[-+]?\d+)?$/i.test(t);var P=(t,o=(n)=>n!==void 0?": "+n:"")=>class extends Error{origMessage;constructor(n){super(t(n)+o(n));this.origMessage=n!==void 0?String(n):""}};var _m=P(()=>"illegal argument(s)"),h=(t)=>{throw new _m(t)};var ro=(t)=>jo(t)?parseFloat(t):h(`not a numeric value: ${t}`),Ko=(t)=>t.map(ro),fo=(t)=>Do(t)?parseInt(t,16):h(`not a hex value: ${t}`),Vo=(t)=>t.map(fo),Eo=(t)=>Zo(t)?parseInt(t):h(`not an integer: ${t}`),qo=(t)=>t.map(Eo);var Jt=(t,o)=>(n)=>({coerce:t,hint:o,group:"main",...n}),zt=(t,o)=>(n)=>({hint:Hm(o,n.delim),multi:!0,coerce:t,group:"main",...n}),Hm=(t,o)=>t+(o?`[${o}..]`:""),J=(t)=>({flag:!0,default:!1,group:"flags",...t}),X=Jt($t,"STR"),Pt=zt($t,"STR"),ff=Jt(ro,"NUM"),Ef=Jt(fo,"HEX"),Xt=Jt(Eo,"INT"),Gf=zt(Ko,"NUM"),Nf=zt(Vo,"HEX"),Lf=zt(qo,"INT");var _=((t)=>{return t[t.FINE=0]="FINE",t[t.DEBUG=1]="DEBUG",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.SEVERE=4]="SEVERE",t[t.NONE=5]="NONE",t})(_||{});var Im=0;class _t{constructor(t,o=_.FINE,n){this.parent=n,this.id=t||`logger-${Im++}`,this.level=typeof o==="string"?_[o]:o}id;level;addChild(t){return t.parent=this,t}enabled(t){return this.level<=t}fine(...t){this.log(_.FINE,t)}debug(...t){this.log(_.DEBUG,t)}info(...t){this.log(_.INFO,t)}warn(...t){this.log(_.WARN,t)}severe(...t){this.log(_.SEVERE,t)}log(t,o){this.level<=t&&this.logEntry([t,this.id,Date.now(),...o])}}var uo=(t)=>t.map((o)=>{if(typeof o==="function")o=o();if(!(typeof o==="string"||typeof o==="number"))o=JSON.stringify(o);return o}).join(" ");class yt extends _t{constructor(t,o,n,m){super(o,n,m);this.target=t}childLogger(t,o){return new yt(this.target,t,o??this.level,this)}logEntry(t){if(t[0]<this.level)return;this.target.write(`[${_[t[0]]}] ${t[1]}: ${uo(t.slice(3))}
|
|
3
3
|
`),this.parent&&this.parent.logEntry(t)}}var Dt=tt((t,o=" ")=>{const n=ot(String(o),t);return(m,r)=>{if(m==null)return n;return m=m.toString(),r=r!==void 0?r:m.length,r<t?m+n.substring(r):m}});var Zt=(t,o=Object.create(null))=>(n)=>(n in o)?o[n]:o[n]=t(n);var Go={black:1,blue:5,cyan:7,gray:17,green:3,magenta:6,red:2,white:24,yellow:4,lightBlue:21,lightCyan:23,lightGray:8,lightGreen:19,lightMagenta:22,lightRed:18,lightYellow:20,bgBlack:32,bgBlue:160,bgCyan:224,bgGray:544,bgGreen:96,bgMagenta:192,bgRed:64,bgWhite:768,bgYellow:128,bgLightBlue:672,bgLightCyan:736,bgLightGray:256,bgLightGreen:608,bgLightMagenta:704,bgLightRed:576,bgLightYellow:640};var Sm=(t,o)=>(n)=>t.format(o,n),No=(t)=>Object.keys(Go).reduce((o,n)=>(o[n]=Sm(t,Go[n]),o),{format:t});var Qo="\x1B[0m";var wm=["","1","2","1;2","4","1;4","2;4","1;2;4"],jt={format:(t,o)=>jt.start(t)+o+jt.end,start:Zt((t)=>{let o=[],n=t&15;return n&&o.push(29+(t>>4&1)*60+n),n=t>>5&15,n&&o.push(39+(t>>9&1)*60+n),n=t>>10,n&&o.push(wm[n]),"\x1B["+o.join(";")+"m"}),end:Qo,prefix:Qo,suffix:"\n"};var bo={format:(t,o)=>String(o),prefix:"",suffix:"\n",start:()=>"",end:""};var Kt=No(jt),ko=No(bo);var H=Array.isArray;var Wm=(t)=>t.toUpperCase(),io=(t)=>t.toLowerCase(),Vt=(t)=>t.length?t[0].toUpperCase()+t.substring(1):t,vo=(t,o="-")=>io(t.replace(/([a-z0-9\u00e0-\u00fd])([A-Z\u00c0-\u00dd])/g,(n,m,r)=>m+o+r));var po=(t,o="-")=>io(t).replace(new RegExp(`\\${o}+(\\w)`,"g"),(n,m)=>Wm(m));var lo=Object.getPrototypeOf,y=(t)=>{let o;return t!=null&&typeof t==="object"&&((o=lo(t))===null||lo(o)===null)};var Rm=/\x1b\[[0-9;]+m/g,Ym=(t)=>t.replace(Rm,"");var qt=(t)=>Ym(t).length;var eo=(t=!1,o)=>(n)=>t||typeof n!=="string"&&typeof n!=="number"?JSON.stringify(n,null,o):String(n);function*nt(t,o=/\r?\n/g,n=!1){let m=0;const r=t.length,f=~~n;let G;if(typeof o==="string")G=new RegExp(o,"g");else if(!o.flags.includes("g"))G=new RegExp(o,o.flags+"g");else G=o;for(;m<r;){const E=G.exec(t);if(!E){yield t.substring(m);return}const N=E[0].length;yield t.substring(m,E.index+f*N),m=E.index+N}}class Lo{n=0;w=[];constructor(t,o){t!=null&&this.add(t,o)}add(t,o=t.length){return this.w.push(t),this.n+=o+~~(this.n>0),this}toString(){return this.w.join(" ")}}var Um={length:(t)=>t.length,split:(t,o)=>o},xo={length:qt,split:(t,o)=>{const n=/\x1b\[[0-9;]+m/g;let m=o,r;while(r=n.exec(t)){if(r.index>=o)break;const f=r[0].length;m+=f,o+=f}return m}},go=(t,o,n,m)=>{const r=t[t.length-1];r&&m-r.n>n?r.add(o,n):t.push(new Lo(o,n))},Mm=(t,{width:o,min:n,hard:m,splitter:r},f=0,G=[])=>{let E=r.length(t),N=o-f;if(N<n&&N<E)N=o;while(m&&E>N){const L=r.split(t,N),O=t.substring(0,L);go(G,O,N,o),t=t.substring(L),N=o,E=r.length(t)}return go(G,t,E,o),G},Jm=(t,o,n=[])=>{if(!t.length)return n.push(new Lo),n;const m={width:80,min:4,hard:!1,splitter:Um,...o};for(let r of nt(t,o.delimWord||/\s/g)){const f=n[n.length-1];Mm(r,m,f&&f.n>0?f.n+1:0,n)}return n},ao=(t,o)=>{let n=[];for(let m of nt(t,o.delimLine))n=n.concat(Jm(m,o));return n};var Ht=(t,o={})=>{o={lineWidth:80,paramWidth:32,showDefaults:!0,prefix:"",suffix:"",groups:["flags","main"],...o};const n=y(o.color)?{...mo,...o.color}:o.color?mo:{},m=ot(" ",o.paramWidth),r=(E)=>E.map((N)=>zm(N,t[N],o,n,m)),f=Object.keys(t).sort(),G=o.groups?o.groups.map((E)=>[E,f.filter((N)=>t[N].group===E)]).filter((E)=>!!E[1].length):[["options",f]];return[...Oo(o.prefix,o.lineWidth),...G.map(([E,N])=>[...o.showGroupNames?[`${Vt(E)}:
|
|
4
4
|
`]:[],...r(N),""].join("\n")),...Oo(o.suffix,o.lineWidth)].join("\n")},zm=(t,o,n,m,r)=>{const f=Pm(o,m),G=Xm(o,m,f),E=It(`--${vo(t)}`,m.param),N=`${G}${E}${f}`,L=o.optional===!1&&o.default===void 0,O=[];L&&O.push("required"),o.multi&&O.push("multiple");const A=ym(O,m,L)+(o.desc||"")+Dm(o,n,m);return Dt(n.paramWidth)(N,qt(N))+Oo(A,n.lineWidth-n.paramWidth).map((B,C)=>C>0?r+B:B).join("\n")},Pm=(t,o)=>t.hint?It(" "+t.hint,o.hint):"",Xm=(t,o,n)=>t.alias?`${It("-"+t.alias,o.param)}${n}, `:"",ym=(t,o,n)=>t.length?It(`[${t.join(", ")}] `,n?o.required:o.multi):"",Dm=(t,o,n)=>o.showDefaults&&t.default!=null&&t.default!==!1?It(` (default: ${eo(!0)(t.defaultHint!=null?t.defaultHint:t.default)})`,n.default):"",It=(t,o)=>o!=null?`\x1B[${o}m${t}\x1B[0m`:t,Oo=(t,o)=>t?ao(t,{width:o,splitter:xo,hard:!1}):[];var Zm=P(()=>"parse error"),so=(t,o,n)=>{n={start:2,showUsage:!0,help:["--help","-h"],...n};try{return jm(t,o,n)}catch(m){if(n.showUsage)console.log(m.message+"\n\n"+Ht(t,n.usageOpts));throw new Zm(m.message)}},jm=(t,o,n)=>{const m=Km(t),r={};let f,G,E=n.start;for(;E<o.length;){const N=o[E];if(!f){if(n.help.includes(N)){console.log(Ht(t,n.usageOpts));return}const L=Vm(t,m,r,N);if(f=L.id,G=L.spec,E=E+~~(L.state<2),L.state)break}else{if(qm(G,r,f,N))break;f=null,E++}}return f&&h(`missing value for: --${f}`),{result:um(t,r),index:E,rest:o.slice(E),done:E>=o.length}},Km=(t)=>Object.entries(t).reduce((o,[n,m])=>m.alias?(o[m.alias]=n,o):o,{}),Vm=(t,o,n,m)=>{if(m[0]==="-"){let r;if(m[1]==="-"){if(m==="--")return{state:1};r=po(m.substring(2))}else r=o[m.substring(1)],!r&&h(`unknown option: ${m}`);const f=t[r];if(!f&&h(r),f.flag){if(n[r]=!0,r=void 0,f.fn&&!f.fn("true"))return{state:1,spec:f}}return{state:0,id:r,spec:f}}return{state:2}},qm=(t,o,n,m)=>{if(/^-[a-z]/i.test(m)&&h(`missing value for: --${n}`),t.multi)H(o[n])?o[n].push(m):o[n]=[m];else o[n]=m;return t.fn&&!t.fn(m)},um=(t,o)=>{let n;for(let m in t)if(n=t[m],o[m]===void 0){if(n.default!==void 0)o[m]=n.default;else if(n.optional===!1)h(`missing arg: --${m}`)}else if(n.coerce)Qm(n,o,m);return o},Qm=(t,o,n)=>{try{if(t.multi&&t.delim)o[n]=o[n].reduce((m,r)=>(m.push(...r.split(t.delim)),m),[]);o[n]=t.coerce(o[n])}catch(m){throw new Error(`arg --${n}: ${m.message}`)}};var tn=async(t)=>{const o=t.argv||process.argv,n=!process.env.NO_COLOR,m={prefix:"",color:n,...t.usage};try{let r,f,G=t.start??2;if(t.single){if(r=Object.keys(t.commands)[0],!r)h("no command provided");f=t.commands[r]}else{if(r=o[G],f=t.commands[r],m.prefix+=bm(t.commands),!f)co(t,m);G++}let E;try{E=so({...t.opts,...f.opts},o,{showUsage:!0,usageOpts:m,start:G})}catch(L){}if(!E)process.exit(1);if(f.inputs!==void 0&&f.inputs!==E.rest.length)process.stderr.write(`expected ${f.inputs||0} input(s)
|
|
5
|
-
`),co(t,m);const N=await t.ctx({logger:new yt(process.stderr,t.name,"INFO"),format:n?Kt:ko,opts:E.result,inputs:E.rest},f);if(await f.fn(N),t.post)await t.post(N,f)}catch(r){process.stderr.write(r.message+"\n\n"),process.exit(1)}},co=(t,o)=>{process.stderr.write(Ht(t.opts,o)),process.exit(1)},bm=(t)=>["\nAvailable commands:\n",...Object.keys(t).map((o)=>`${Dt(16)(o)}: ${t[o].desc}`),"\n"].join("\n");import{existsSync as km,mkdirSync as im,statSync as AE} from"fs";import{dirname as vm} from"path";var pm=(t)=>t.length>0&&!km(t)?(im(t,{recursive:!0}),!0):!1,on=(t)=>pm(vm(t));var K=(t)=>typeof t==="function";var $=(t)=>typeof t==="string";import{readFileSync as dm} from"fs";import{writeFileSync as lm} from"fs";var nn=(t,o,n,m,r=!1)=>{if(m&&m.info(`${r?"[dryrun] ":""}writing file: ${t}`),r)return;on(t),lm(t,o,!n&&$(o)?"utf-8":n)};var S=(t,o,n="utf-8")=>{return o&&o.debug("reading file:",t),dm(t,n)},Bo=(t,o,n,m=!1)=>nn(t,H(o)?o.join("\n"):o,"utf-8",n,m);var V=(t,o)=>JSON.parse(S(t,o));var u=Symbol(),Ao=()=>{};var St=Object.freeze({level:_.NONE,addChild(t){return t},childLogger:()=>St,enabled:()=>!1,fine(){},debug(){},info(){},warn(){},severe(){},logEntry(){}});class ho extends _t{set(t){this.parent=t}childLogger(t,o){return new ho(t,o??this.level,this)}logEntry(t){this.parent.logEntry(t)}}var mn=new ho("root",_.FINE,St);import{join as Vr} from"path";var Co=(t,o)=>{if(t===o)return 0;if(t==null)return o==null?0:-1;if(o==null)return t==null?0:1;if(typeof t.compare==="function")return t.compare(o);if(typeof o.compare==="function")return-o.compare(t);return t<o?-1:t>o?1:0};var em=P(()=>"Assertion failed"),ut=(typeof process!=="undefined"&&process.env!==void 0?!0:import.meta.env?import.meta.env.MODE!=="production"||!!import.meta.env.UMBRELLA_ASSERTS||!!import.meta.env.VITE_UMBRELLA_ASSERTS:!0)?(t,o)=>{if(typeof t==="function"&&!t()||!t)throw new em(typeof o==="function"?o():o)}:()=>{};var Qt=(t)=>t!=null&&typeof t!=="function"&&t.length!==void 0;var rn=(t)=>{return(t==null||!t[Symbol.iterator])&&h(`value is not iterable: ${t}`),t};var fn=(t)=>Qt(t)?t:[...rn(t)];var wt=(t)=>t[t.length-1];var gm=P(()=>"illegal arity"),mt=(t)=>{throw new gm(t)};var xm=P(()=>"illegal state"),rt=(t)=>{throw new xm(t)};var bt=(t,o)=>t!=null&&typeof t[o]==="function";var I=(t)=>t!=null&&typeof t[Symbol.iterator]==="function";var kt=(t)=>t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function";var En=["-moz-","-ms-","-o-","-webkit-"],ft={rules:"",ruleSep:",",valSep:"",decls:"",declStart:"{",declEnd:"}",indent:"",comments:!1},it={rules:"\n",ruleSep:", ",valSep:" ",decls:"\n",declStart:" {\n",declEnd:"}\n",indent:" ",comments:!0};var Fo=function(...t){let[o,n,m,r,f,G,E,N,L,O]=t;switch(t.length){case 0:mt(0);case 1:return o;case 2:return(...B)=>o(n(...B));case 3:return(...B)=>o(n(m(...B)));case 4:return(...B)=>o(n(m(r(...B))));case 5:return(...B)=>o(n(m(r(f(...B)))));case 6:return(...B)=>o(n(m(r(f(G(...B))))));case 7:return(...B)=>o(n(m(r(f(G(E(...B)))))));case 8:return(...B)=>o(n(m(r(f(G(E(N(...B))))))));case 9:return(...B)=>o(n(m(r(f(G(E(N(L(...B)))))))));case 10:default:const A=(...B)=>o(n(m(r(f(G(E(N(L(O(...B))))))))));return t.length===10?A:Fo(A,...t.slice(10))}};var d=(t)=>bt(t,"xform")?t.xform():t;var D=function(...t){return t=t.map(d),Fo.apply(null,t)};var Q=(t,o)=>[t[0],t[1],o];class Wt{value;constructor(t){this.value=t}deref(){return this.value}}var w=(t)=>t instanceof Wt,Gn=(t)=>t instanceof Wt?t:new Wt(t),Z=(t)=>t instanceof Wt?t.deref():t;var Et=function(...t){const o=t[0],n=o[0],m=o[1],r=o[2];t=am(t);const f=t[0]==null?n():t[0],G=t[1];return Z(m(bt(G,"$reduce")?G.$reduce(r,f):Qt(G)?sm(r,f,G):cm(r,f,G)))};var am=(t)=>t.length===2?[void 0,t[1]]:t.length===3?[t[1],t[2]]:mt(t.length),sm=(t,o,n)=>{for(let m=0,r=n.length;m<r;m++)if(o=t(o,n[m]),w(o)){o=o.deref();break}return o},cm=(t,o,n)=>{for(let m of n)if(o=t(o,m),w(o)){o=o.deref();break}return o},Gt=(t,o)=>[t,$t,o],Nn=(t,o)=>{const n=o.length-1;return I(o[n])?o.length>1?Et(t.apply(null,o.slice(0,n)),o[n]):Et(t(),o[0]):void 0};var Nt=function(t){return t?[...t]:Gt(()=>[],(o,n)=>(o.push(n),o))};function*Lt(t,o){const n=d(t)(Nt()),m=n[1],r=n[2];for(let f of o){const G=r([],f);if(w(G)){yield*Z(m(G.deref()));return}if(G.length)yield*G}yield*Z(m([]))}function*e(t,o){const n=d(t)([Ao,Ao,(m,r)=>r])[2];for(let m of o){let r=n(u,m);if(w(r)){if(r=Z(r.deref()),r!==u)yield r;return}if(r!==u)yield r}}var vt=(t,o,n=e)=>{const m=o.length-1;return I(o[m])?o.length>1?n(t.apply(null,o.slice(0,m)),o[m]):n(t(),o[0]):void 0};var To=function(t,o){return I(o)?Lt(To(t),$(o)?[o]:o):(n)=>{const m=n[2],r=(f,G)=>{const E=t(G);if(E){for(let N of E)if(f=r(f,N),w(f))break;return f}return m(f,G)};return Q(n,r)}};var Ln=function(t){return To((o)=>kt(o)?o:void 0,t)};var T=function(t,o){return I(o)?e(T(t),o):(n)=>{const m=n[2];return Q(n,(r,f)=>m(r,t(f)))}};function*pt(...t){const o=t.length-1;if(o<0)return;const n=new Array(o+1).fill(0),m=t.map(fn),r=m.reduce((f,G)=>f*G.length,1);for(let f=0;f<r;f++){const G=[];for(let E=o;E>=0;E--){const N=m[E];let L=n[E];if(L===N.length)n[E]=L=0,E>0&&n[E-1]++;G[E]=N[L]}n[o]++,yield G}}function*On(t,o=1/0){while(o-- >0)yield t}var $o=function(t,o){t=t||"";let n=!0;return o?[...o].join(t):Gt(()=>"",(m,r)=>(m=n?m+r:m+t+r,n=!1,m))};var lt=function(...t){return tr(lt,Et,t)};var tr=(t,o,n)=>{let m,r;switch(n.length){case 4:r=n[3],m=n[2];break;case 3:r=n[2];break;case 2:return T((f)=>t(n[0],n[1],f));default:mt(n.length)}return o(d(n[0])(n[1]),m,r)};var or=new Set,nr=":[",Bn=D(Ln(),T((t)=>t[0]==="&"?t.substring(1):nr.includes(t[0])?t:" "+t)),mr=(t,o)=>D(t,T((n)=>$(n)&&n.startsWith(" .")?n+o:n)),Ot=(t,o,n,m)=>{const r=n.length,f=[];let G,E;const N=(L,O)=>{let A=null;if(H(O))Ot(t,_o(o,f),O,m);else if(I(O)&&!$(O))Ot(t,_o(o,f),[...O],m);else if((E=K(O))||(A=m.fns[O]))if(!o.length){if(A)return A.apply(null,n.slice(L+1))(t,m),!0;O(t,m)}else if(E)N(L,O());else h(`quoted fn ('${O}') only allowed at head position`);else if(y(O))G=Object.assign(G||{},O);else if(O!=null)f.push(O)};for(let L=0;L<r;L++)if(N(L,n[L]))return t;return G&&t.push(rr(o,f,G,m)),t},_o=(t,o)=>t.length?[...pt(t,o)]:o,rr=(t,o,n,m)=>{const r=m.format,f=j(m),G=m.scope?mr(Bn,m.scope):Bn;return[f,lt(T((E)=>lt(G,$o(),H(E)?E:[E]).trim()),$o(r.ruleSep),_o(t,o)),r.declStart,Rt(n,m),f,r.declEnd].join("")},Rt=(t,o)=>{const n=o.format,m=o.autoprefix||or,r=j(o,o.depth+1),f=[];for(let G in t)if(t.hasOwnProperty(G)){let E=t[G];if(K(E))E=E(t);if(H(E))E=E.map((N)=>H(N)?N.join(" "):N).join(n.ruleSep);if(m.has(G))for(let N of o.vendors)f.push(`${r}${N}${G}:${n.valSep}${E};`);f.push(`${r}${G}:${n.valSep}${E};`)}return f.join(n.decls)+n.decls},j=(t,o=t.depth)=>o>1?[...On(t.format.indent,o)].join(""):o>0?t.format.indent:"";var An=function(t,...o){const n=o.length===1?o[0]:o.reduce((m,r,f)=>{return m[f/(o.length-1)*100|0]=r,m},{});return(m,r)=>{const f=j(r);r.depth++;const G=j(r);m.push(`${f}@keyframes ${t}${r.format.declStart}`);for(let E in n)if(n.hasOwnProperty(E))m.push([G,E+"%",r.format.declStart,Rt(n[E],r),G,r.format.declEnd].join(""));return r.depth--,m.push(f+r.format.declEnd),m}};var hn=(t,o=!1)=>(n,m)=>{const r=j(m),f=j(m,m.depth+1);if(m.format.comments||o)n.push(r+"/*",t.split("\n").map((G)=>f+G).join("\n"),r+"*/");return n};var dt=(t,o,n)=>(m,r)=>{const f=j(r);return m.push(`${f}${t} ${fr(o)}${r.format.declStart}`),r.depth++,Ot(m,[],n,r),r.depth--,m.push(f+r.format.declEnd),m},fr=(t)=>{if($(t))return t;const o=[];for(let n in t)if(t.hasOwnProperty(n)){let m=t[n];if(m===!0)m=Cn.has(n)?n:`(${n})`;else if(m===!1)m=`(not ${Cn.has(n)?n:`(${n})`})`;else if(m==="only")m+=" "+n;else m=`(${n}:${m})`;o.push(m)}return o.join(" and ")},Cn=new Set(["all","print","screen"]);var g=(t,o)=>{return o={format:ft,vendors:En,fns:{},depth:0,...o},H(o.autoprefix)&&(o.autoprefix=new Set(o.autoprefix)),y(t)?Rt(t,o):K(t)?t([],o).join(o.format.rules):Ot([],[],H(t)?t:kt(t)?[...t]:h("invalid rules"),o).join(o.format.rules)};var Fn=(t,...o)=>(n,m)=>(n.push(o.length?`@import url(${t}) ${o.join(m.format.ruleSep)};`:`@import url(${t});`),n);var Bt=(t,o)=>dt("@media",t,o);var Tn=function(...t){return(o,n)=>(o.push(t.length>1?`@namespace ${t[0]} url(${t[1]});`:`@namespace url(${t[0]});`),o)};var $n=(t,o)=>dt("@supports",t,o);var et={"@comment":hn,"@import":Fn,"@keyframes":An,"@media":Bt,"@namespace":Tn,"@supports":$n};var _n=4,Hn=(t)=>_n=t,U=(t)=>t===(t|0)?String(t):t.toFixed(_n).replace(/^0./,".").replace(/^-0./,"-.").replace(/0+$/,"");var In=(t)=>`${U(t)}em`,Sn=(t)=>`${U(t)}ex`;var wn=(t)=>`${U(t)}rem`,Ho=(t)=>`${U(t)}%`,Wn=(t)=>`${U(t)}px`,Rn=(t)=>`${U(t)}vh`,Yn=(t)=>`${U(t)}vw`,Un=(t)=>`${U(t)}vmin`,Mn=(t)=>`${U(t)}vmax`,Jn=(t)=>`${t|0}ms`,zn=(t)=>`${U(t)}s`;var Pn=(t)=>`${U(t)}deg`,Xn=(t)=>`${U(t)}rad`,yn=(t)=>`${U(t)}turn`,Dn=(t)=>`url(${t})`;var W=((t)=>{return t[t.IDLE=0]="IDLE",t[t.ACTIVE=1]="ACTIVE",t[t.DONE=2]="DONE",t[t.UNSUBSCRIBED=3]="UNSUBSCRIBED",t[t.ERROR=4]="ERROR",t})(W||{}),z=((t)=>{return t[t.NEVER=0]="NEVER",t[t.FIRST=1]="FIRST",t[t.LAST=2]="LAST",t})(z||{});var Er=0,Gr=()=>Er++,x=(t,o)=>!o||!o.id?{...o,id:t+"-"+Gr()}:o;var R=mn.childLogger("rstream");class b{constructor(t,o){this.wrapped=t,o=x("sub",{closeIn:z.LAST,closeOut:z.LAST,cache:!0,...o}),this.parent=o.parent,this.id=o.id,this.closeIn=o.closeIn,this.closeOut=o.closeOut,this.cacheLast=o.cache,o.xform&&(this.xform=o.xform(Nt()))}id;closeIn;closeOut;parent;__owner;xform;cacheLast;last=u;state=W.IDLE;subs=[];deref(){return this.last!==u?this.last:void 0}getState(){return this.state}setState(t){this.state=t}subscribe(t,o={}){this.ensureState();let n;if(t instanceof b&&!o.xform)t.ensureState(),ut(!t.parent,`sub '${t.id}' already has a parent`),t.parent=this,n=t;else n=new b(t,{...o,parent:this});return this.subs.push(n),this.setState(W.ACTIVE),n.setState(W.ACTIVE),this.last!=u&&n.next(this.last),n}transform(...t){let o,n;if(y(wt(t)))n=t.pop(),o={error:n.error};return this.subscribe(o,x("xform",t.length>0?{...n,xform:D(...t)}:n))}map(t,o){return this.transform(T(t),o||{})}unsubscribe(t){return t?this.unsubscribeChild(t):this.unsubscribeSelf()}unsubscribeSelf(){return R.debug(this.id,"unsub self"),this.parent&&this.parent.unsubscribe(this),this.state<W.UNSUBSCRIBED&&(this.state=W.UNSUBSCRIBED),this.release(),!0}unsubscribeChild(t){R.debug(this.id,"unsub child",t.id);const o=this.subs.indexOf(t);if(o>=0){if(this.subs.splice(o,1),this.closeOut===z.FIRST||!this.subs.length&&this.closeOut!==z.NEVER)this.unsubscribe();return!0}return!1}next(t){if(this.state>=W.DONE)return;this.xform?this.dispatchXform(t):this.dispatch(t)}done(){if(R.debug(this.id,"entering done()"),this.state>=W.DONE)return;if(this.xform){if(!this.dispatchXformDone())return}if(this.state=W.DONE,this.dispatchTo("done"))this.state<W.UNSUBSCRIBED&&this.unsubscribe();R.debug(this.id,"exiting done()")}error(t){const o=this.wrapped,n=o&&o.error;return n&&R.debug(this.id,"attempting wrapped error handler"),n&&o.error(t)||this.unhandledError(t)}unhandledError(t){return(R.parent!==St?R:console).warn(this.id,"unhandled error:",t),this.unsubscribe(),this.state=W.ERROR,!1}dispatchTo(t,o){let n=this.wrapped;if(n)try{n[t]&&n[t](o)}catch(r){if(!this.error(r))return!1}const m=t==="next"?this.subs:[...this.subs];for(let r=m.length;r-- >0;){n=m[r];try{n[t]&&n[t](o)}catch(f){if(t==="error"||!n.error||!n.error(f))return this.unhandledError(f)}}return!0}dispatch(t){R.debug(this.id,"dispatch",t),this.cacheLast&&(this.last=t),this.dispatchTo("next",t)}dispatchXform(t){let o;try{o=this.xform[2]([],t)}catch(n){this.error(n);return}if(this.dispatchXformVals(o))w(o)&&this.done()}dispatchXformDone(){let t;try{t=this.xform[1]([])}catch(o){return this.error(o)}return this.dispatchXformVals(t)}dispatchXformVals(t){const o=Z(t);for(let n=0,m=o.length;n<m&&this.state<W.DONE;n++)this.dispatch(o[n]);return this.state<W.ERROR}ensureState(){if(this.state>=W.DONE)rt(`operation not allowed in state ${this.state}`)}release(){this.subs.length=0,delete this.parent,delete this.xform,delete this.last}}var Zn=(t,o)=>{const n=new jn(o);return n.next(t),n};class jn extends b{src;_cancel;_inited;constructor(t,o){const[n,m]=K(t)?[t,o||{}]:[void 0,t||{}];super(m.error?{error:m.error}:void 0,x("stream",m));this.src=n,this._inited=!1}subscribe(t,o={}){const n=super.subscribe(t,o);if(!this._inited){if(this.src)try{this._cancel=this.src(this)||(()=>{return})}catch(m){let r=this.wrapped;if(!r||!r.error||!r.error(m))this.unhandledError(m)}this._inited=!0}return n}unsubscribe(t){const o=super.unsubscribe(t);if(o&&(!t||(!this.subs||!this.subs.length)&&this.closeOut!==z.NEVER))this.cancel();return o}done(){this.cancel(),super.done(),delete this.src,delete this._cancel}error(t){if(super.error(t))return!0;return this.cancel(),!1}cancel(){if(this._cancel){R.debug(this.id,"cancel");const t=this._cancel;delete this._cancel,t()}}}var Kn=(t,o)=>t===z.FIRST||t===z.LAST&&!o;var Io=function(t){return t?Et(Io(),t):Gt(()=>({}),(o,[n,m])=>(o[n]=m,o))};var Vn=()=>(t)=>{const o=t[2];return Q(t,(n,m)=>{if(m){for(let r of Z(m)||[])if(n=o(n,r),w(n))break}return w(m)?Gn(n):n})};var So=function(t,o){return I(o)?Lt(So(t),o):D(T(t),Vn())};var wo=function(t,o){return I(o)?e(wo(t),o):T(K(t)?(n)=>[t(n),n]:(n)=>[t,n])};var Wo=function(...t){const o=vt(Wo,t);if(o)return o;const n=t[0],m=t[1]!==!1;return T((r)=>{const f=m?{}:r;for(let G in r)f[G]=n(r[G]);return f})};var qn=(t)=>t;var Ro=function(...t){const o=vt(Ro,t,Lt);if(o)return o;const{key:n=qn,mergeOnly:m=!1,reset:r=!0,all:f=!0,backPressure:G=0}=t[1],E=H(t[0])?new Set(t[0]):t[0],N=new Set,L=new Map;let O={};const A=([B,C,M])=>{let p=!0;if(m||G<1)return[B,(F)=>{if(r&&f&&N.size>0||!r&&p)F=M(F,O),O={},N.clear(),p=!1;return C(F)},(F,l)=>{const Y=n(l);if(E.has(Y)){if(O[Y]=l,N.add(Y),m||un(E,N))if(F=M(F,O),p=!1,r)O={},N.clear();else O={...O}}return F}];else return[B,(F)=>{if(f&&N.size>0)F=M(F,Qn(L,N)),L.clear(),N.clear();return C(F)},(F,l)=>{const Y=n(l);if(E.has(Y)){let q=L.get(Y);!q&&L.set(Y,q=[]),q.length>=G&&rt(`max back pressure (${G}) exceeded for input: ${String(Y)}`),q.push(l),N.add(Y);while(un(E,N))if(F=M(F,Qn(L,N)),p=!1,w(F))break}return F}]};return A.keys=()=>E,A.clear=()=>{L.clear(),E.clear(),N.clear(),O={}},A.add=(B)=>{E.add(B)},A.delete=(B,C=!0)=>{if(L.delete(B),E.delete(B),C)N.delete(B),delete O[B]},A},un=(t,o)=>{if(o.size<t.size)return!1;for(let n of t)if(!o.has(n))return!1;return!0},Qn=(t,o)=>{const n={};for(let m of o){const r=t.get(m);n[m]=r.shift(),!r.length&&o.delete(m)}return n};var bn=(t,o)=>{let n=!0;for(let m of o)n=t.removeID(m)&&n;return n};var gt=(t)=>new kn(t);class kn extends b{sources;idSources;realSourceIDs;invRealSourceIDs;psync;clean;constructor(t){const o=Ro(new Set,{key:(m)=>m[0],mergeOnly:t.mergeOnly===!0,reset:t.reset===!0,all:t.all!==!1,backPressure:t.backPressure||0}),n=Wo((m)=>m[1]);super(void 0,x("streamsync",{...t,xform:t.xform?D(o,n,t.xform):D(o,n)}));this.sources=new Map,this.realSourceIDs=new Map,this.invRealSourceIDs=new Map,this.idSources=new Map,this.psync=o,this.clean=!!t.clean,t.src&&this.addAll(t.src)}add(t,o){o||(o=t.id),this.ensureState(),this.psync.add(o),this.realSourceIDs.set(o,t.id),this.invRealSourceIDs.set(t.id,o),this.idSources.set(t.id,t),this.sources.set(t,t.subscribe({next:(n)=>n[1]instanceof b?this.add(n[1]):this.next(n),done:()=>this.markDone(t),__owner:this},{xform:wo(o),id:`in-${o}`}))}addAll(t){for(let o in t)this.psync.add(o);for(let o in t)this.add(t[o],o)}remove(t){const o=this.sources.get(t);if(o){const n=this.invRealSourceIDs.get(t.id);return R.info(`removing src: ${t.id} (${n})`),this.psync.delete(n,this.clean),this.realSourceIDs.delete(n),this.invRealSourceIDs.delete(t.id),this.idSources.delete(t.id),this.sources.delete(t),o.unsubscribe(),!0}return!1}removeID(t){const o=this.getSourceForID(t);return o?this.remove(o):!1}removeAll(t){for(let n of t)this.psync.delete(this.invRealSourceIDs.get(n.id));let o=!0;for(let n of t)o=this.remove(n)&&o;return o}removeAllIDs(t){return bn(this,t)}getSourceForID(t){return this.idSources.get(this.realSourceIDs.get(t))}getSources(){const t={};for(let[o,n]of this.idSources)t[this.invRealSourceIDs.get(o)]=n;return t}unsubscribe(t){if(!t){R.debug(this.id,"unsub sources");for(let o of this.sources.values())o.unsubscribe();this.sources.clear(),this.psync.clear(),this.realSourceIDs.clear(),this.invRealSourceIDs.clear(),this.idSources.clear()}return super.unsubscribe(t)}markDone(t){this.remove(t),Kn(this.closeIn,this.sources.size)&&this.done()}}var Yo=tt((t,o=" ")=>{const n=ot(String(o),t);return(m,r)=>{if(m==null)return n;return m=m.toString(),r=r!==void 0?r:m.length,r<t?n.substring(r)+m:m}}),lN=Yo(2,"0"),dN=Yo(3,"0"),vn=Yo(4,"0");var Nr=/\{(\d+)\}/g;var Uo=(t,...o)=>o.length>0?t.replace(Nr,(n,m)=>String(o[parseInt(m,10)])):t;var pn=(t)=>({key:(o)=>o,group:Nt(),...t});var Mo=function(...t){const o=Nn(Mo,t);if(o)return o;const n=pn(t[0]),[m,r,f]=n.group;return[()=>({}),(G)=>{for(let E in G)G[E]=r(G[E]);return G},(G,E)=>{const N=n.key(E);return G[N]=G[N]?f(G[N],E):f(m(),E),G}]};var Jo=function(t,o){return I(o)?e(Jo(t),o):(n)=>{const m=n[2];return Q(n,(r,f)=>t(f)?m(r,f):r)}};import{watch as xn} from"fs";import{resolve as a} from"path";var ln={specs:X({alias:"s",optional:!1,desc:"Path to generated JSON defs"})},xt={bundle:J({alias:"b",desc:"Bundle inputs (see `out` option)"})},At={include:Pt({alias:"I",desc:"Include CSS files (prepend)"})},at={eval:X({alias:"e",desc:"eval meta stylesheet in given string (ignores other inputs & includes)"})},st={force:Pt({alias:"f",hint:"STR",desc:"CSS classes to force include (wildcards are supported, @-prefix will read from file)",delim:","})},dn={media:Pt({alias:"m",hint:"ID",desc:"Media query IDs (use 'ALL' for all)",delim:","})},en={onlyDecls:J({desc:"Only emit framework decls"})},k={out:X({alias:"o",desc:"Output file (or stdout)"})},ct={prec:Xt({default:3,desc:"Number of fractional digits"})},i={pretty:J({alias:"p",desc:"Pretty print output"})},ht={noDecls:J({alias:"d",desc:"Don't emit framework decls"})},Ct={noHeader:J({desc:"Don't emit generated header comment"})},Ft={scope:X({desc:"Suffix for CSS class names"})},Tt={watch:J({alias:"w",desc:"Watch input files for changes"})};import{watch as Lr} from"fs";import{resolve as gn} from"path";var v=(t,o,n)=>{o=$(o)?o:o.join("\n"),t?Bo(gn(t),o,n):process.stdout.write(o+"\n")},to=({info:{name:t,version:o}})=>`/*! ${t} v${o} - generated by thi.ng/meta-css @ ${(new Date()).toISOString()} */`,Yt=(t,o)=>{const n=()=>{o.info("closing watchers..."),m.forEach((r)=>r.watcher.close())},m=t.map((r,f)=>{r=gn(r);const G=Zn(S(r,o),{id:`in${vn(f)}`});return{input:G,watcher:Lr(r,{},(E)=>{if(E==="change")try{G.next(S(r,o))}catch(N){o.warn(N.message),n()}else o.warn("input removed:",r),n()})}});return process.on("SIGINT",n),gt({src:Io(T(({input:r})=>[r.id,r],m))})},oo=(t)=>Object.keys(t).reduce((o,n)=>{if(!n.startsWith("__"))o[n]=t[n];return o},{});async function Po(t){const o=V(a(t.opts.specs),t.logger),n=Cr(o,t.opts.force||[],t.logger);if(t.opts.bundle)if(t.opts.watch)await Br(t,n);else Ut(t,o,n,t.opts.eval?[t.opts.eval]:t.inputs.map((m)=>S(a(m),t.logger)),t.opts.out);else if(t.opts.watch)await Or(t,o,n);else if(t.opts.eval)try{Ut(t,o,n,[t.opts.eval])}catch(m){t.logger.warn(m.message)}else for(let m of t.inputs)try{m=a(m);const r=!t.opts.noWrite?m.replace(/\.mcss$/,".css"):void 0;Ut(t,o,n,[S(m,t.logger)],r)}catch(r){t.logger.warn(r.message)}}function*Tr(t){let o=-1,n=t.length,m=0;for(let r=0;r<n;r++){const f=t[r];if(f===" "||f==="\t"){if(!m&&o>=0)yield t.substring(o,r),o=-1}else if(f==="{"||f==="}"){if(o>=0)yield t.substring(o,r);yield f,o=-1}else if(f==="(")m++;else if(f===")"){if(--m<0)h(`invalid nesting in line: '${t}'`)}else if(o<0)o=r}if(m)h("template calls must be fully on a single line");if(o>=0)yield t.substring(o,n)}var sn={desc:"Transpile (and optionally bundle) meta stylesheets to CSS",opts:{...xt,...at,...st,...At,...ht,...Ct,...k,...i,...Ft,...ln,...Tt,noWrite:J({desc:"Don't write files, use stdout only"})},fn:Po},Or=async(t,o,n)=>{const m=a(t.opts.specs);let r,f={process:()=>{try{return o=V(m,t.logger),r.forEach((E)=>E.process()),!0}catch(E){return t.logger.warn(E.message+": "+m),!1}},watcher:xn(m,{},(E)=>{if(E==="change")f.process();else t.logger.warn("specs file removed:",m),G()})};const G=()=>{t.logger.info("closing watchers..."),f.watcher.close(),r.forEach((E)=>E.watcher.close())};r=t.inputs.map((E)=>{E=a(E);const N=!t.opts.noWrite?E.replace(/\.mcss$/,".css"):void 0,L=()=>{try{return Ut(t,o,n,[S(E,t.logger)],N),!0}catch(O){if(t.logger.warn(O.message+": "+E),r)G();return!1}};if(!L())process.exit(1);return{process:L,watcher:xn(E,{},(O)=>{if(O==="change")L();else t.logger.warn("input removed:",E),G()})}}),t.logger.info("waiting for changes, press ctrl+c to cancel..."),process.on("SIGINT",G)},Br=async(t,o)=>{gt({src:{styles:Yt(t.inputs,t.logger),specs:Yt([t.opts.specs],t.logger).map((n)=>JSON.parse(Object.values(n)[0]))}}).subscribe({next({styles:n,specs:m}){try{Ut(t,m,o,Object.keys(n).sort().map((r)=>n[r]),t.opts.out)}catch(r){t.logger.warn(r.message)}}})},Ut=({logger:t,opts:{include:o,noDecls:n,noHeader:m,pretty:r,scope:f}},G,E,N,L)=>{const O={logger:t,specs:G,css:{format:r?it:ft,fns:et,scope:f},mediaQueryIDs:new Set(Object.keys(G.media)),mediaQueryRules:{...E.mediaQueryRules},plainRules:{...E.plainRules}},A=o?o.map((B)=>S(a(B),t).trim()):[];if(!m)A.push(to(G));if(!n&&G.decls.length)A.push(g(G.decls,O.css));N.forEach((B)=>Fr(B,O)),hr(A,O),Ar(A,O),v(L,A,t)},Ar=(t,{css:o,logger:n,mediaQueryRules:m,specs:r})=>{for(let f in m){const G=tm(m[f],r);n.debug("mediaquery rules",f,G),t.push(g(Bt(Hr(r.media,f),G),o))}},hr=(t,{css:o,logger:n,plainRules:m,specs:r})=>{const f=tm(m,r);n.debug("plain rules",f),t.push(g(f,o))},Cr=(t,o,n)=>{const m=new Set(Object.keys(t.media)),r=new Set(Object.keys(t.classes)),f={},G={};if(o.length&&o[0][0]==="@")o=[...nt(S(a(o[0].substring(1)),n))];for(let E of o){if(!E||E.startsWith("//"))continue;const{token:N,query:L}=om(E,m);let O;if(N.includes("*")){const A=new RegExp(`^${N.replace("*",".*")}\$`);O=[...Jo((B)=>A.test(B),r)]}else if(r.has(N))O=[N];else{n.warn(`unknown include rule ID: ${E}, skipping...`);continue}for(let A of O)n.debug("including class:",A),L?nm(f,L,`.${A}`,A):mm(G,`.${A}`,A)}return{mediaQueryRules:f,plainRules:G}},Fr=(t,{specs:o,mediaQueryIDs:n,mediaQueryRules:m,plainRules:r})=>{const f=Mt(),G=Mt(f),E={root:f,curr:G,scopes:[G]};for(let N of nt(t)){if(!N||/^\s*\/\//.test(N))continue;for(let L of Tr(N)){if(!L)continue;let O=E.curr;switch(O.state){case"sel":case"nest":if(L==="{"){if(O.state==="sel")O.sel=O.sel.map((A)=>A.replace(",","")),O.path=$r(E.scopes);O.state="class"}else if(L==="}")an(E);else{const A=wt(O.sel);if(!A||A.endsWith(","))O.sel.push(L);else O.sel[O.sel.length-1]+=" "+L}break;case"class":if(L==="{")O.state="nest",E.scopes.push(E.curr=Mt(O));else if(L==="}")an(E);else{let{token:A,query:B}=om(L,n);if(!o.classes[A]&&!(rm(A)||fm(A)))h(`unknown class ID: ${A}`);if(B)nm(m,B,O.path,A);else mm(r,O.path,A)}break;default:rt(O.state)}}}},zo=":",cn="///",Mt=(t)=>({state:"sel",sel:t?[]:["<root>"],path:"",parent:t}),an=(t)=>{const o=!t.curr.sel.length;if(ut(!!t.curr.parent,"stack underflow"),t.scopes.pop(),t.scopes.length>0){if(t.curr=wt(t.scopes),!o&&t.curr.state==="nest")t.scopes.push(t.curr=Mt(t.curr))}else t.scopes.push(t.curr=Mt(t.root))},$r=(t)=>t.map((o)=>o.sel.join(",")).join(cn),tm=(t,o)=>Object.entries(t).map(([n,m])=>_r(n,m,o)),_r=(t,o,n)=>{const m=[];let r=m;const f=t.split(cn);for(let G=0;G<f.length;G++){const E=f[G].split(",");if(G==f.length-1){const N=Object.assign({},...T((L)=>fm(L)?Sr(n,L):rm(L)?Ir(L):oo(n.classes[L]),o));E.push(N)}r.push(E),r=E}return m[0]},om=(t,o)=>{if(/^::?/.test(t))return{token:t};const n=t.lastIndexOf(zo);if(n<0)return{token:t};const m=t.substring(0,n);if(!m.split(zo).every((f)=>o.has(f)))h(`invalid media query in token: ${t}`);return{token:t.substring(n+1),query:m}},Hr=(t,o)=>o.split(zo).reduce((n,m)=>Object.assign(n,t[m]),{}),nm=(t,o,n,m)=>{if(!t[o])t[o]={};(t[o][n]||(t[o][n]=new Set)).add(m)},mm=(t,o,n)=>(t[o]||(t[o]=new Set)).add(n),Ir=(t)=>{const o=t.indexOf("=");return{[`--${t.substring(0,o)}`]:t.substring(o+1)}},Sr=(t,o)=>{const n=o.indexOf("("),m=o.substring(0,n),r=o.substring(n+1,o.length-1).split(/(?<!\\),/g).map((G)=>G.trim().replace("\\,",",")),f=t.templates[m];if(!f)h(`unknown template: ${m}`);if(r.length!==f.__arity)h(`template "${m}" expected ${f.__arity} arguments`);return Object.entries(f).reduce((G,[E,N])=>{if(!E.startsWith("__")){if(E=Uo(E,...r),$(N))N=Uo(N,...r);G[E]=N}return G},{})},rm=(t)=>t.includes("="),fm=(t)=>t.includes("(");async function Xo(t){if(t.opts.watch)await Rr(t);else await Lm(t.inputs.map((o)=>S(o,t.logger)),t.opts,t.logger)}var Gm={deg:Pn,em:In,ex:Sn,ms:Jn,percent:Ho,px:Wn,rad:Xn,rem:wn,second:zn,turn:yn,url:Dn,vh:Rn,vmax:Mn,vmin:Un,vw:Yn,"%":Ho},wr={percent:"{0}%",second:"{0}s",url:"url({0})"},Wr={"":[""],a:[""],h:["-left","-right"],v:["-top","-bottom"],t:["-top"],top:["top"],b:["-bottom"],bottom:["bottom"],r:["-right"],right:["right"],l:["-left"],left:["left"],x:["-x"],y:["-y"],in:[""],out:[""]},Nm={desc:"Generate framework rules from specs",opts:{...k,...ct,...i,...Tt},fn:Xo},Rr=async(t)=>{Yt(t.inputs,t.logger).subscribe({next(o){try{Lm(Object.keys(o).sort().map((n)=>o[n]),t.opts,t.logger)}catch(n){t.logger.warn(n.message)}}})},Lm=async(t,o,n)=>{const m={info:{name:"TODO",version:"0.0.0"},media:{},classes:{},templates:{},decls:[]};Hn(o.prec);for(let r of t){const f=JSON.parse(r);if(Object.assign(m.info,f.info),Object.assign(m.media,f.media),f.decls)m.decls.push(...f.decls);if(f.specs)for(let G of f.specs)try{Om(f,G,m.classes,n)}catch(E){n.warn(`error processing spec: ${G.name}`,E,", skipping...")}if(f.templates)for(let G of f.templates)Yr(f,G,m.templates,n)}return v(o.out,JSON.stringify(m,null,o.pretty?4:0),n),m},Om=(t,o,n,m,r=!1)=>{const f=H(o.vars)?o.vars:[""],G=$(o.props)?{[o.props]:"<v>"}:o.props,E=Ur(o,t),N=new Set;for(let L of f){const O=t.vars?.[L]||Wr[L];if(!O)h(`unknown variation ID: ${L}`);for(let[A,B]of pt(O,Object.keys(E))){const C=s(o.name,L,A,B,E[B]),M=o.unit?s(o.unit,L,A,B,E[B]):void 0,p=r?Jr(M):Mr(E[B],M);if(!n[C]){if(n[C]={},o.user!=null)n[C].__user=o.user;if(o.doc!=null)n[C].__doc=zr(o.doc,L,A,B,p)}else if(!N.has(C))h(`duplicate class ID: ${C}`);N.add(C);let F=-1;for(let[l,Y]of Object.entries(G)){const q=s(l,L,A,B,E[B]),no=s(!M||$(Y)?String(Y):Gm[M](Y),L,A,B,p);if(n[C][q]=no,m.debug(C,q,no),r)F=Em(no,Em(q,F))}if(r)n[C].__arity=F+1}}return n},Yr=(t,o,n,m)=>Om(t,{...o,values:[""]},n,m,!0),Em=(t,o)=>{const n=/\{(\d+)\}/g;let m;while(m=n.exec(t))o=Math.max(o,+m[1]);return o},Ur=(t,o)=>{const n=$(t.values)?o.tables?.[t.values]||h(`invalid table ID: ${t.values}`):t.values;if(y(n))return n;const m=t.key==="v"?(r)=>String(r):t.key==="i+1"?(r,f)=>String(f+1):t.key===void 0?(r,f)=>String(f):h(`invalid key type: ${t.key}`);return n.reduce((r,f,G)=>{return r[m(f,G)]=f,r},{})},Mr=(t,o)=>{if(!o||$(t))return t;const n=Gm[o];if(!n)h(`invalid unit: ${o}`);return n(t)},Jr=(t)=>t?wr[t]||"{0}"+t:"{0}",s=(t,o,n,m,r)=>t.replace(/<vid>/g,o).replace(/<var>/g,n).replace(/<k>/g,m).replace(/<v>/g,String(r)),zr=({group:t,desc:o,args:n},m,r,f,G)=>({group:t?s(t,m,r,f,G):"TODO",desc:o?s(o,m,r,f,G):void 0,args:n?n.map((E)=>s(E,m,r,f,G)):void 0});var Bm={desc:"Combination of the generate & convert commands",opts:{...xt,...at,...st,...At,...ht,...Ct,...ct,...i,...Ft,...Tt,outCss:X({desc:"Output file for CSS bundle",optional:!1}),outSpecs:X({desc:"Output file for framework",optional:!1})},fn:async(t)=>{const{opts:o,inputs:n}=t,[m,r]=n.reduce((E,N)=>(E[N.endsWith(".json")?0:1].push(N),E),[[],[]]),f={inputs:m,format:t.format,logger:t.logger,opts:{...o,out:o.outSpecs}},G={inputs:r,format:t.format,logger:t.logger,opts:{...o,noWrite:!1,out:o.outCss,scope:o.scope,specs:o.outSpecs}};await Xo(f),await Po(G)}};import{resolve as Pr} from"path";var Cm={desc:"Generate Markdown documentation for framework specs",opts:{...k,level:Xt({alias:"l",desc:"Initial heading level",default:1}),title:X({alias:"t",desc:"Custom main title, set to NONE to disable"})},inputs:1,fn:async(t)=>{const{logger:o,opts:n,inputs:m}=t,r=V(Pr(m[0]),o),f=Xr(r,n);v(n.out,f,o)}},Xr=(t,{level:o,title:n})=>{const m=Object.keys(t.classes).length,r=Object.keys(t.templates).length,f=[`Currently, there are ${m+r} CSS utility classes (incl. ${r} templates) defined in "${t.info.name}" (v${t.info.version}):`,"",`${c(o+1)} Classes by category`,"",...hm(t.classes,Dr,o+2),`${c(o+1)} Templates by category`,"",...hm(t.templates,Zr,o+2),`${c(o+1)} Media queries`,"",...Object.entries(t.media).map(([G,E])=>`- **${G}**: \`${JSON.stringify(E)}\``),""];if(n!=="NONE")f.unshift(`${c(o)} ${n??t.info.name}\n`);return f},Am=(t)=>t.split(/(\d+)/).map((o)=>{const n=parseInt(o);return isNaN(n)?o:n}),yr=(t,o)=>{if(/\d+/.test(t)&&/\d+/.test(o)){const n=Am(t),m=Am(o),r=n.length;if(r===m.length){for(let f=0;f<r;f++)if(n[f]!==m[f])return Co(n[f],m[f]);return 0}return n.length-m.length}return Co(t,o)},hm=(t,o,n)=>{const m=Mo({key:([r,{__doc:f}])=>f?.group||"TODO",group:[()=>[],(r)=>r.sort(),(r,f)=>(r.push(f[0]),r)]},Object.entries(t));return So((r)=>{const f=m[r].sort(yr).map((E)=>o(E,t[E].__doc,n+1)),G=f.length;return[`${c(n)} ${Vt(r)}`,G>3?`\n<details><summary>${G} items:</summary>\n`:"",f.join("\n"),G>3?"</details>\n":""]},Object.keys(m).sort())},Dr=(t,o)=>{if(!(o&&o.desc))return`- \`${t}\``;let n=o.desc;if(/^-[a-z]/.test(n))n=n.substring(1);return`- \`${t}\` (${n})`},Zr=(t,o,n)=>{if(!(o&&o.args))return`${c(n)} ${t}(...)\n\nTODO`;const m=o.args.map((r)=>/^\w+/.exec(r)[0]).join(", ");return[`${c(n)} \`${t}(${m})\``,"",...o.args.map(jr),o.desc?`\n${o.desc}\n`:""].join("\n")},jr=(t)=>`- ${t.replace(/^(\w+)/,(o,n)=>`**${n}**`)}`,c=Zt((t)=>"#".repeat(t));import{resolve as Fm} from"path";var $m={desc:"Export entire generated framework as CSS",opts:{...At,...ht,...en,...k,...i,...Ct,...dn,...Ft},inputs:1,fn:async(t)=>{const{logger:o,opts:{include:n,media:m,noDecls:r,noHeader:f,onlyDecls:G,out:E,pretty:N,scope:L},inputs:O}=t,A={format:N?it:ft,fns:et,scope:L},B=V(Fm(O[0]),o),C=n?n.map((M)=>S(Fm(M),o).trim()):[];if(!f)C.push(to(B));if(!r&&B.decls.length)C.push(g(B.decls,A));if(!G)C.push(Kr(B,m,A,o));v(E,C,o)}},Kr=(t,o,n,m)=>{const r=Tm("",t);if(o){const f=o[0]==="ALL"?Object.keys(t.media):o;for(let G of f)if(t.media[G])r.push(Bt(t.media[G],Tm("-"+G,t)));else m.warn(`invalid media query ID: ${G}, skipping...`)}return g(r,n)},Tm=(t,o)=>Object.entries(o.classes).map(([n,m])=>[`.${n}${t}`,oo(m)]);var yo=V(Vr(import.meta.dir,"package.json"));tn({name:"metacss",opts:{verbose:J({alias:"v",desc:"Display extra process information"})},commands:{convert:sn,develop:Bm,doc:Cm,export:$m,generate:Nm},ctx:async(t)=>{if(t.opts.verbose)t.logger.level=_.DEBUG;return{...t,format:Kt}},usage:{prefix:`
|
|
5
|
+
`),co(t,m);const N=await t.ctx({logger:new yt(process.stderr,t.name,"INFO"),format:n?Kt:ko,opts:E.result,inputs:E.rest},f);if(await f.fn(N),t.post)await t.post(N,f)}catch(r){process.stderr.write(r.message+"\n\n"),process.exit(1)}},co=(t,o)=>{process.stderr.write(Ht(t.opts,o)),process.exit(1)},bm=(t)=>["\nAvailable commands:\n",...Object.keys(t).map((o)=>`${Dt(16)(o)}: ${t[o].desc}`),"\n"].join("\n");import{existsSync as km,mkdirSync as im,statSync as AE} from"fs";import{dirname as vm} from"path";var pm=(t)=>t.length>0&&!km(t)?(im(t,{recursive:!0}),!0):!1,on=(t)=>pm(vm(t));var K=(t)=>typeof t==="function";var $=(t)=>typeof t==="string";import{readFileSync as dm} from"fs";import{writeFileSync as lm} from"fs";var nn=(t,o,n,m,r=!1)=>{if(m&&m.info(`${r?"[dryrun] ":""}writing file: ${t}`),r)return;on(t),lm(t,o,!n&&$(o)?"utf-8":n)};var S=(t,o,n="utf-8")=>{return o&&o.debug("reading file:",t),dm(t,n)},Bo=(t,o,n,m=!1)=>nn(t,H(o)?o.join("\n"):o,"utf-8",n,m);var V=(t,o)=>JSON.parse(S(t,o));var u=Symbol(),Ao=()=>{};var St=Object.freeze({level:_.NONE,addChild(t){return t},childLogger:()=>St,enabled:()=>!1,fine(){},debug(){},info(){},warn(){},severe(){},logEntry(){}});class ho extends _t{set(t){this.parent=t}childLogger(t,o){return new ho(t,o??this.level,this)}logEntry(t){this.parent.logEntry(t)}}var mn=new ho("root",_.FINE,St);import{join as Vr} from"path";var Co=(t,o)=>{if(t===o)return 0;if(t==null)return o==null?0:-1;if(o==null)return t==null?0:1;if(typeof t.compare==="function")return t.compare(o);if(typeof o.compare==="function")return-o.compare(t);return t<o?-1:t>o?1:0};var em=P(()=>"Assertion failed"),ut=(typeof process!=="undefined"&&process.env!==void 0?!0:import.meta.env?import.meta.env.MODE!=="production"||!!import.meta.env.UMBRELLA_ASSERTS||!!import.meta.env.VITE_UMBRELLA_ASSERTS:!0)?(t,o)=>{if(typeof t==="function"&&!t()||!t)throw new em(typeof o==="function"?o():o)}:()=>{};var Qt=(t)=>t!=null&&typeof t!=="function"&&t.length!==void 0;var rn=(t)=>{return(t==null||!t[Symbol.iterator])&&h(`value is not iterable: ${t}`),t};var fn=(t)=>Qt(t)?t:[...rn(t)];var wt=(t)=>t[t.length-1];var bt=(t,o)=>t!=null&&typeof t[o]==="function";var I=(t)=>t!=null&&typeof t[Symbol.iterator]==="function";var kt=(t)=>t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function";var gm=P(()=>"illegal arity"),mt=(t)=>{throw new gm(t)};var xm=P(()=>"illegal state"),rt=(t)=>{throw new xm(t)};var En=["-moz-","-ms-","-o-","-webkit-"],ft={rules:"",ruleSep:",",valSep:"",decls:"",declStart:"{",declEnd:"}",indent:"",comments:!1},it={rules:"\n",ruleSep:", ",valSep:" ",decls:"\n",declStart:" {\n",declEnd:"}\n",indent:" ",comments:!0};var Fo=function(...t){let[o,n,m,r,f,G,E,N,L,O]=t;switch(t.length){case 0:mt(0);case 1:return o;case 2:return(...B)=>o(n(...B));case 3:return(...B)=>o(n(m(...B)));case 4:return(...B)=>o(n(m(r(...B))));case 5:return(...B)=>o(n(m(r(f(...B)))));case 6:return(...B)=>o(n(m(r(f(G(...B))))));case 7:return(...B)=>o(n(m(r(f(G(E(...B)))))));case 8:return(...B)=>o(n(m(r(f(G(E(N(...B))))))));case 9:return(...B)=>o(n(m(r(f(G(E(N(L(...B)))))))));case 10:default:const A=(...B)=>o(n(m(r(f(G(E(N(L(O(...B))))))))));return t.length===10?A:Fo(A,...t.slice(10))}};var d=(t)=>bt(t,"xform")?t.xform():t;var D=function(...t){return t=t.map(d),Fo.apply(null,t)};var Q=(t,o)=>[t[0],t[1],o];class Wt{value;constructor(t){this.value=t}deref(){return this.value}}var w=(t)=>t instanceof Wt,Gn=(t)=>t instanceof Wt?t:new Wt(t),Z=(t)=>t instanceof Wt?t.deref():t;var Et=function(...t){const o=t[0],n=o[0],m=o[1],r=o[2];t=am(t);const f=t[0]==null?n():t[0],G=t[1];return Z(m(bt(G,"$reduce")?G.$reduce(r,f):Qt(G)?sm(r,f,G):cm(r,f,G)))};var am=(t)=>t.length===2?[void 0,t[1]]:t.length===3?[t[1],t[2]]:mt(t.length),sm=(t,o,n)=>{for(let m=0,r=n.length;m<r;m++)if(o=t(o,n[m]),w(o)){o=o.deref();break}return o},cm=(t,o,n)=>{for(let m of n)if(o=t(o,m),w(o)){o=o.deref();break}return o},Gt=(t,o)=>[t,$t,o],Nn=(t,o)=>{const n=o.length-1;return I(o[n])?o.length>1?Et(t.apply(null,o.slice(0,n)),o[n]):Et(t(),o[0]):void 0};var Nt=function(t){return t?[...t]:Gt(()=>[],(o,n)=>(o.push(n),o))};function*Lt(t,o){const n=d(t)(Nt()),m=n[1],r=n[2];for(let f of o){const G=r([],f);if(w(G)){yield*Z(m(G.deref()));return}if(G.length)yield*G}yield*Z(m([]))}function*e(t,o){const n=d(t)([Ao,Ao,(m,r)=>r])[2];for(let m of o){let r=n(u,m);if(w(r)){if(r=Z(r.deref()),r!==u)yield r;return}if(r!==u)yield r}}var vt=(t,o,n=e)=>{const m=o.length-1;return I(o[m])?o.length>1?n(t.apply(null,o.slice(0,m)),o[m]):n(t(),o[0]):void 0};var To=function(t,o){return I(o)?Lt(To(t),$(o)?[o]:o):(n)=>{const m=n[2],r=(f,G)=>{const E=t(G);if(E){for(let N of E)if(f=r(f,N),w(f))break;return f}return m(f,G)};return Q(n,r)}};var Ln=function(t){return To((o)=>kt(o)?o:void 0,t)};var T=function(t,o){return I(o)?e(T(t),o):(n)=>{const m=n[2];return Q(n,(r,f)=>m(r,t(f)))}};function*pt(...t){const o=t.length-1;if(o<0)return;const n=new Array(o+1).fill(0),m=t.map(fn),r=m.reduce((f,G)=>f*G.length,1);for(let f=0;f<r;f++){const G=[];for(let E=o;E>=0;E--){const N=m[E];let L=n[E];if(L===N.length)n[E]=L=0,E>0&&n[E-1]++;G[E]=N[L]}n[o]++,yield G}}function*On(t,o=1/0){while(o-- >0)yield t}var $o=function(t,o){t=t||"";let n=!0;return o?[...o].join(t):Gt(()=>"",(m,r)=>(m=n?m+r:m+t+r,n=!1,m))};var lt=function(...t){return tr(lt,Et,t)};var tr=(t,o,n)=>{let m,r;switch(n.length){case 4:r=n[3],m=n[2];break;case 3:r=n[2];break;case 2:return T((f)=>t(n[0],n[1],f));default:mt(n.length)}return o(d(n[0])(n[1]),m,r)};var or=new Set,nr=":[",Bn=D(Ln(),T((t)=>t[0]==="&"?t.substring(1):nr.includes(t[0])?t:" "+t)),mr=(t,o)=>D(t,T((n)=>$(n)&&n.startsWith(" .")?n+o:n)),Ot=(t,o,n,m)=>{const r=n.length,f=[];let G,E;const N=(L,O)=>{let A=null;if(H(O))Ot(t,_o(o,f),O,m);else if(I(O)&&!$(O))Ot(t,_o(o,f),[...O],m);else if((E=K(O))||(A=m.fns[O]))if(!o.length){if(A)return A.apply(null,n.slice(L+1))(t,m),!0;O(t,m)}else if(E)N(L,O());else h(`quoted fn ('${O}') only allowed at head position`);else if(y(O))G=Object.assign(G||{},O);else if(O!=null)f.push(O)};for(let L=0;L<r;L++)if(N(L,n[L]))return t;return G&&t.push(rr(o,f,G,m)),t},_o=(t,o)=>t.length?[...pt(t,o)]:o,rr=(t,o,n,m)=>{const r=m.format,f=j(m),G=m.scope?mr(Bn,m.scope):Bn;return[f,lt(T((E)=>lt(G,$o(),H(E)?E:[E]).trim()),$o(r.ruleSep),_o(t,o)),r.declStart,Rt(n,m),f,r.declEnd].join("")},Rt=(t,o)=>{const n=o.format,m=o.autoprefix||or,r=j(o,o.depth+1),f=[];for(let G in t)if(t.hasOwnProperty(G)){let E=t[G];if(K(E))E=E(t);if(H(E))E=E.map((N)=>H(N)?N.join(" "):N).join(n.ruleSep);if(m.has(G))for(let N of o.vendors)f.push(`${r}${N}${G}:${n.valSep}${E};`);f.push(`${r}${G}:${n.valSep}${E};`)}return f.join(n.decls)+n.decls},j=(t,o=t.depth)=>o>1?[...On(t.format.indent,o)].join(""):o>0?t.format.indent:"";var An=function(t,...o){const n=o.length===1?o[0]:o.reduce((m,r,f)=>{return m[f/(o.length-1)*100|0]=r,m},{});return(m,r)=>{const f=j(r);r.depth++;const G=j(r);m.push(`${f}@keyframes ${t}${r.format.declStart}`);for(let E in n)if(n.hasOwnProperty(E))m.push([G,E+"%",r.format.declStart,Rt(n[E],r),G,r.format.declEnd].join(""));return r.depth--,m.push(f+r.format.declEnd),m}};var hn=(t,o=!1)=>(n,m)=>{const r=j(m),f=j(m,m.depth+1);if(m.format.comments||o)n.push(r+"/*",t.split("\n").map((G)=>f+G).join("\n"),r+"*/");return n};var dt=(t,o,n)=>(m,r)=>{const f=j(r);return m.push(`${f}${t} ${fr(o)}${r.format.declStart}`),r.depth++,Ot(m,[],n,r),r.depth--,m.push(f+r.format.declEnd),m},fr=(t)=>{if($(t))return t;const o=[];for(let n in t)if(t.hasOwnProperty(n)){let m=t[n];if(m===!0)m=Cn.has(n)?n:`(${n})`;else if(m===!1)m=`(not ${Cn.has(n)?n:`(${n})`})`;else if(m==="only")m+=" "+n;else m=`(${n}:${m})`;o.push(m)}return o.join(" and ")},Cn=new Set(["all","print","screen"]);var g=(t,o)=>{return o={format:ft,vendors:En,fns:{},depth:0,...o},H(o.autoprefix)&&(o.autoprefix=new Set(o.autoprefix)),y(t)?Rt(t,o):K(t)?t([],o).join(o.format.rules):Ot([],[],H(t)?t:kt(t)?[...t]:h("invalid rules"),o).join(o.format.rules)};var Fn=(t,...o)=>(n,m)=>(n.push(o.length?`@import url(${t}) ${o.join(m.format.ruleSep)};`:`@import url(${t});`),n);var Bt=(t,o)=>dt("@media",t,o);var Tn=function(...t){return(o,n)=>(o.push(t.length>1?`@namespace ${t[0]} url(${t[1]});`:`@namespace url(${t[0]});`),o)};var $n=(t,o)=>dt("@supports",t,o);var et={"@comment":hn,"@import":Fn,"@keyframes":An,"@media":Bt,"@namespace":Tn,"@supports":$n};var _n=4,Hn=(t)=>_n=t,U=(t)=>t===(t|0)?String(t):t.toFixed(_n).replace(/^0./,".").replace(/^-0./,"-.").replace(/0+$/,"");var In=(t)=>`${U(t)}em`,Sn=(t)=>`${U(t)}ex`;var wn=(t)=>`${U(t)}rem`,Ho=(t)=>`${U(t)}%`,Wn=(t)=>`${U(t)}px`,Rn=(t)=>`${U(t)}vh`,Yn=(t)=>`${U(t)}vw`,Un=(t)=>`${U(t)}vmin`,Mn=(t)=>`${U(t)}vmax`,Jn=(t)=>`${t|0}ms`,zn=(t)=>`${U(t)}s`;var Pn=(t)=>`${U(t)}deg`,Xn=(t)=>`${U(t)}rad`,yn=(t)=>`${U(t)}turn`,Dn=(t)=>`url(${t})`;var W=((t)=>{return t[t.IDLE=0]="IDLE",t[t.ACTIVE=1]="ACTIVE",t[t.DONE=2]="DONE",t[t.UNSUBSCRIBED=3]="UNSUBSCRIBED",t[t.ERROR=4]="ERROR",t})(W||{}),z=((t)=>{return t[t.NEVER=0]="NEVER",t[t.FIRST=1]="FIRST",t[t.LAST=2]="LAST",t})(z||{});var Er=0,Gr=()=>Er++,x=(t,o)=>!o||!o.id?{...o,id:t+"-"+Gr()}:o;var R=mn.childLogger("rstream");class b{constructor(t,o){this.wrapped=t,o=x("sub",{closeIn:z.LAST,closeOut:z.LAST,cache:!0,...o}),this.parent=o.parent,this.id=o.id,this.closeIn=o.closeIn,this.closeOut=o.closeOut,this.cacheLast=o.cache,o.xform&&(this.xform=o.xform(Nt()))}id;closeIn;closeOut;parent;__owner;xform;cacheLast;last=u;state=W.IDLE;subs=[];deref(){return this.last!==u?this.last:void 0}getState(){return this.state}setState(t){this.state=t}subscribe(t,o={}){this.ensureState();let n;if(t instanceof b&&!o.xform)t.ensureState(),ut(!t.parent,`sub '${t.id}' already has a parent`),t.parent=this,n=t;else n=new b(t,{...o,parent:this});return this.subs.push(n),this.setState(W.ACTIVE),n.setState(W.ACTIVE),this.last!=u&&n.next(this.last),n}transform(...t){let o,n;if(y(wt(t)))n=t.pop(),o={error:n.error};return this.subscribe(o,x("xform",t.length>0?{...n,xform:D(...t)}:n))}map(t,o){return this.transform(T(t),o||{})}unsubscribe(t){return t?this.unsubscribeChild(t):this.unsubscribeSelf()}unsubscribeSelf(){return R.debug(this.id,"unsub self"),this.parent&&this.parent.unsubscribe(this),this.state<W.UNSUBSCRIBED&&(this.state=W.UNSUBSCRIBED),this.release(),!0}unsubscribeChild(t){R.debug(this.id,"unsub child",t.id);const o=this.subs.indexOf(t);if(o>=0){if(this.subs.splice(o,1),this.closeOut===z.FIRST||!this.subs.length&&this.closeOut!==z.NEVER)this.unsubscribe();return!0}return!1}next(t){if(this.state>=W.DONE)return;this.xform?this.dispatchXform(t):this.dispatch(t)}done(){if(R.debug(this.id,"entering done()"),this.state>=W.DONE)return;if(this.xform){if(!this.dispatchXformDone())return}if(this.state=W.DONE,this.dispatchTo("done"))this.state<W.UNSUBSCRIBED&&this.unsubscribe();R.debug(this.id,"exiting done()")}error(t){const o=this.wrapped,n=o&&o.error;return n&&R.debug(this.id,"attempting wrapped error handler"),n&&o.error(t)||this.unhandledError(t)}unhandledError(t){return(R.parent!==St?R:console).warn(this.id,"unhandled error:",t),this.unsubscribe(),this.state=W.ERROR,!1}dispatchTo(t,o){let n=this.wrapped;if(n)try{n[t]&&n[t](o)}catch(r){if(!this.error(r))return!1}const m=t==="next"?this.subs:[...this.subs];for(let r=m.length;r-- >0;){n=m[r];try{n[t]&&n[t](o)}catch(f){if(t==="error"||!n.error||!n.error(f))return this.unhandledError(f)}}return!0}dispatch(t){R.debug(this.id,"dispatch",t),this.cacheLast&&(this.last=t),this.dispatchTo("next",t)}dispatchXform(t){let o;try{o=this.xform[2]([],t)}catch(n){this.error(n);return}if(this.dispatchXformVals(o))w(o)&&this.done()}dispatchXformDone(){let t;try{t=this.xform[1]([])}catch(o){return this.error(o)}return this.dispatchXformVals(t)}dispatchXformVals(t){const o=Z(t);for(let n=0,m=o.length;n<m&&this.state<W.DONE;n++)this.dispatch(o[n]);return this.state<W.ERROR}ensureState(){if(this.state>=W.DONE)rt(`operation not allowed in state ${this.state}`)}release(){this.subs.length=0,delete this.parent,delete this.xform,delete this.last}}var Zn=(t,o)=>{const n=new jn(o);return n.next(t),n};class jn extends b{src;_cancel;_inited;constructor(t,o){const[n,m]=K(t)?[t,o||{}]:[void 0,t||{}];super(m.error?{error:m.error}:void 0,x("stream",m));this.src=n,this._inited=!1}subscribe(t,o={}){const n=super.subscribe(t,o);if(!this._inited){if(this.src)try{this._cancel=this.src(this)||(()=>{return})}catch(m){let r=this.wrapped;if(!r||!r.error||!r.error(m))this.unhandledError(m)}this._inited=!0}return n}unsubscribe(t){const o=super.unsubscribe(t);if(o&&(!t||(!this.subs||!this.subs.length)&&this.closeOut!==z.NEVER))this.cancel();return o}done(){this.cancel(),super.done(),delete this.src,delete this._cancel}error(t){if(super.error(t))return!0;return this.cancel(),!1}cancel(){if(this._cancel){R.debug(this.id,"cancel");const t=this._cancel;delete this._cancel,t()}}}var Kn=(t,o)=>t===z.FIRST||t===z.LAST&&!o;var Io=function(t){return t?Et(Io(),t):Gt(()=>({}),(o,[n,m])=>(o[n]=m,o))};var Vn=()=>(t)=>{const o=t[2];return Q(t,(n,m)=>{if(m){for(let r of Z(m)||[])if(n=o(n,r),w(n))break}return w(m)?Gn(n):n})};var So=function(t,o){return I(o)?Lt(So(t),o):D(T(t),Vn())};var wo=function(t,o){return I(o)?e(wo(t),o):T(K(t)?(n)=>[t(n),n]:(n)=>[t,n])};var Wo=function(...t){const o=vt(Wo,t);if(o)return o;const n=t[0],m=t[1]!==!1;return T((r)=>{const f=m?{}:r;for(let G in r)f[G]=n(r[G]);return f})};var qn=(t)=>t;var Ro=function(...t){const o=vt(Ro,t,Lt);if(o)return o;const{key:n=qn,mergeOnly:m=!1,reset:r=!0,all:f=!0,backPressure:G=0}=t[1],E=H(t[0])?new Set(t[0]):t[0],N=new Set,L=new Map;let O={};const A=([B,C,M])=>{let p=!0;if(m||G<1)return[B,(F)=>{if(r&&f&&N.size>0||!r&&p)F=M(F,O),O={},N.clear(),p=!1;return C(F)},(F,l)=>{const Y=n(l);if(E.has(Y)){if(O[Y]=l,N.add(Y),m||un(E,N))if(F=M(F,O),p=!1,r)O={},N.clear();else O={...O}}return F}];else return[B,(F)=>{if(f&&N.size>0)F=M(F,Qn(L,N)),L.clear(),N.clear();return C(F)},(F,l)=>{const Y=n(l);if(E.has(Y)){let q=L.get(Y);!q&&L.set(Y,q=[]),q.length>=G&&rt(`max back pressure (${G}) exceeded for input: ${String(Y)}`),q.push(l),N.add(Y);while(un(E,N))if(F=M(F,Qn(L,N)),p=!1,w(F))break}return F}]};return A.keys=()=>E,A.clear=()=>{L.clear(),E.clear(),N.clear(),O={}},A.add=(B)=>{E.add(B)},A.delete=(B,C=!0)=>{if(L.delete(B),E.delete(B),C)N.delete(B),delete O[B]},A},un=(t,o)=>{if(o.size<t.size)return!1;for(let n of t)if(!o.has(n))return!1;return!0},Qn=(t,o)=>{const n={};for(let m of o){const r=t.get(m);n[m]=r.shift(),!r.length&&o.delete(m)}return n};var bn=(t,o)=>{let n=!0;for(let m of o)n=t.removeID(m)&&n;return n};var gt=(t)=>new kn(t);class kn extends b{sources;idSources;realSourceIDs;invRealSourceIDs;psync;clean;constructor(t){const o=Ro(new Set,{key:(m)=>m[0],mergeOnly:t.mergeOnly===!0,reset:t.reset===!0,all:t.all!==!1,backPressure:t.backPressure||0}),n=Wo((m)=>m[1]);super(void 0,x("streamsync",{...t,xform:t.xform?D(o,n,t.xform):D(o,n)}));this.sources=new Map,this.realSourceIDs=new Map,this.invRealSourceIDs=new Map,this.idSources=new Map,this.psync=o,this.clean=!!t.clean,t.src&&this.addAll(t.src)}add(t,o){o||(o=t.id),this.ensureState(),this.psync.add(o),this.realSourceIDs.set(o,t.id),this.invRealSourceIDs.set(t.id,o),this.idSources.set(t.id,t),this.sources.set(t,t.subscribe({next:(n)=>n[1]instanceof b?this.add(n[1]):this.next(n),done:()=>this.markDone(t),__owner:this},{xform:wo(o),id:`in-${o}`}))}addAll(t){for(let o in t)this.psync.add(o);for(let o in t)this.add(t[o],o)}remove(t){const o=this.sources.get(t);if(o){const n=this.invRealSourceIDs.get(t.id);return R.info(`removing src: ${t.id} (${n})`),this.psync.delete(n,this.clean),this.realSourceIDs.delete(n),this.invRealSourceIDs.delete(t.id),this.idSources.delete(t.id),this.sources.delete(t),o.unsubscribe(),!0}return!1}removeID(t){const o=this.getSourceForID(t);return o?this.remove(o):!1}removeAll(t){for(let n of t)this.psync.delete(this.invRealSourceIDs.get(n.id));let o=!0;for(let n of t)o=this.remove(n)&&o;return o}removeAllIDs(t){return bn(this,t)}getSourceForID(t){return this.idSources.get(this.realSourceIDs.get(t))}getSources(){const t={};for(let[o,n]of this.idSources)t[this.invRealSourceIDs.get(o)]=n;return t}unsubscribe(t){if(!t){R.debug(this.id,"unsub sources");for(let o of this.sources.values())o.unsubscribe();this.sources.clear(),this.psync.clear(),this.realSourceIDs.clear(),this.invRealSourceIDs.clear(),this.idSources.clear()}return super.unsubscribe(t)}markDone(t){this.remove(t),Kn(this.closeIn,this.sources.size)&&this.done()}}var Yo=tt((t,o=" ")=>{const n=ot(String(o),t);return(m,r)=>{if(m==null)return n;return m=m.toString(),r=r!==void 0?r:m.length,r<t?n.substring(r)+m:m}}),lN=Yo(2,"0"),dN=Yo(3,"0"),vn=Yo(4,"0");var Nr=/\{(\d+)\}/g;var Uo=(t,...o)=>o.length>0?t.replace(Nr,(n,m)=>String(o[parseInt(m,10)])):t;var pn=(t)=>({key:(o)=>o,group:Nt(),...t});var Mo=function(...t){const o=Nn(Mo,t);if(o)return o;const n=pn(t[0]),[m,r,f]=n.group;return[()=>({}),(G)=>{for(let E in G)G[E]=r(G[E]);return G},(G,E)=>{const N=n.key(E);return G[N]=G[N]?f(G[N],E):f(m(),E),G}]};var Jo=function(t,o){return I(o)?e(Jo(t),o):(n)=>{const m=n[2];return Q(n,(r,f)=>t(f)?m(r,f):r)}};import{watch as xn} from"fs";import{resolve as a} from"path";var ln={specs:X({alias:"s",optional:!1,desc:"Path to generated JSON defs"})},xt={bundle:J({alias:"b",desc:"Bundle inputs (see `out` option)"})},At={include:Pt({alias:"I",desc:"Include CSS files (prepend)"})},at={eval:X({alias:"e",desc:"eval meta stylesheet in given string (ignores other inputs & includes)"})},st={force:Pt({alias:"f",hint:"STR",desc:"CSS classes to force include (wildcards are supported, @-prefix will read from file)",delim:","})},dn={media:Pt({alias:"m",hint:"ID",desc:"Media query IDs (use 'ALL' for all)",delim:","})},en={onlyDecls:J({desc:"Only emit framework decls"})},k={out:X({alias:"o",desc:"Output file (or stdout)"})},ct={prec:Xt({default:3,desc:"Number of fractional digits"})},i={pretty:J({alias:"p",desc:"Pretty print output"})},ht={noDecls:J({alias:"d",desc:"Don't emit framework decls"})},Ct={noHeader:J({desc:"Don't emit generated header comment"})},Ft={scope:X({desc:"Suffix for CSS class names"})},Tt={watch:J({alias:"w",desc:"Watch input files for changes"})};import{watch as Lr} from"fs";import{resolve as gn} from"path";var v=(t,o,n)=>{o=$(o)?o:o.join("\n"),t?Bo(gn(t),o,n):process.stdout.write(o+"\n")},to=({info:{name:t,version:o}})=>`/*! ${t} v${o} - generated by thi.ng/meta-css @ ${(new Date()).toISOString()} */`,Yt=(t,o)=>{const n=()=>{o.info("closing watchers..."),m.forEach((r)=>r.watcher.close())},m=t.map((r,f)=>{r=gn(r);const G=Zn(S(r,o),{id:`in${vn(f)}`});return{input:G,watcher:Lr(r,{},(E)=>{if(E==="change")try{G.next(S(r,o))}catch(N){o.warn(N.message),n()}else o.warn("input removed:",r),n()})}});return process.on("SIGINT",n),gt({src:Io(T(({input:r})=>[r.id,r],m))})},oo=(t)=>Object.keys(t).reduce((o,n)=>{if(!n.startsWith("__"))o[n]=t[n];return o},{});async function Po(t){const o=V(a(t.opts.specs),t.logger),n=Cr(o,t.opts.force||[],t.logger);if(t.opts.bundle)if(t.opts.watch)await Br(t,n);else Ut(t,o,n,t.opts.eval?[t.opts.eval]:t.inputs.map((m)=>S(a(m),t.logger)),t.opts.out);else if(t.opts.watch)await Or(t,o,n);else if(t.opts.eval)try{Ut(t,o,n,[t.opts.eval])}catch(m){t.logger.warn(m.message)}else for(let m of t.inputs)try{m=a(m);const r=!t.opts.noWrite?m.replace(/\.mcss$/,".css"):void 0;Ut(t,o,n,[S(m,t.logger)],r)}catch(r){t.logger.warn(r.message)}}function*Tr(t){let o=-1,n=t.length,m=0;for(let r=0;r<n;r++){const f=t[r];if(f===" "||f==="\t"){if(!m&&o>=0)yield t.substring(o,r),o=-1}else if(f==="{"||f==="}"){if(o>=0)yield t.substring(o,r);yield f,o=-1}else if(f==="(")m++;else if(f===")"){if(--m<0)h(`invalid nesting in line: '${t}'`)}else if(o<0)o=r}if(m)h("template calls must be fully on a single line");if(o>=0)yield t.substring(o,n)}var sn={desc:"Transpile (and optionally bundle) meta stylesheets to CSS",opts:{...xt,...at,...st,...At,...ht,...Ct,...k,...i,...Ft,...ln,...Tt,noWrite:J({desc:"Don't write files, use stdout only"})},fn:Po},Or=async(t,o,n)=>{const m=a(t.opts.specs);let r,f={process:()=>{try{return o=V(m,t.logger),r.forEach((E)=>E.process()),!0}catch(E){return t.logger.warn(E.message+": "+m),!1}},watcher:xn(m,{},(E)=>{if(E==="change")f.process();else t.logger.warn("specs file removed:",m),G()})};const G=()=>{t.logger.info("closing watchers..."),f.watcher.close(),r.forEach((E)=>E.watcher.close())};r=t.inputs.map((E)=>{E=a(E);const N=!t.opts.noWrite?E.replace(/\.mcss$/,".css"):void 0,L=()=>{try{return Ut(t,o,n,[S(E,t.logger)],N),!0}catch(O){if(t.logger.warn(O.message+": "+E),r)G();return!1}};if(!L())process.exit(1);return{process:L,watcher:xn(E,{},(O)=>{if(O==="change")L();else t.logger.warn("input removed:",E),G()})}}),t.logger.info("waiting for changes, press ctrl+c to cancel..."),process.on("SIGINT",G)},Br=async(t,o)=>{gt({src:{styles:Yt(t.inputs,t.logger),specs:Yt([t.opts.specs],t.logger).map((n)=>JSON.parse(Object.values(n)[0]))}}).subscribe({next({styles:n,specs:m}){try{Ut(t,m,o,Object.keys(n).sort().map((r)=>n[r]),t.opts.out)}catch(r){t.logger.warn(r.message)}}})},Ut=({logger:t,opts:{include:o,noDecls:n,noHeader:m,pretty:r,scope:f}},G,E,N,L)=>{const O={logger:t,specs:G,css:{format:r?it:ft,fns:et,scope:f},mediaQueryIDs:new Set(Object.keys(G.media)),mediaQueryRules:{...E.mediaQueryRules},plainRules:{...E.plainRules}},A=o?o.map((B)=>S(a(B),t).trim()):[];if(!m)A.push(to(G));if(!n&&G.decls.length)A.push(g(G.decls,O.css));N.forEach((B)=>Fr(B,O)),hr(A,O),Ar(A,O),v(L,A,t)},Ar=(t,{css:o,logger:n,mediaQueryRules:m,specs:r})=>{for(let f in m){const G=tm(m[f],r);n.debug("mediaquery rules",f,G),t.push(g(Bt(Hr(r.media,f),G),o))}},hr=(t,{css:o,logger:n,plainRules:m,specs:r})=>{const f=tm(m,r);n.debug("plain rules",f),t.push(g(f,o))},Cr=(t,o,n)=>{const m=new Set(Object.keys(t.media)),r=new Set(Object.keys(t.classes)),f={},G={};if(o.length&&o[0][0]==="@")o=[...nt(S(a(o[0].substring(1)),n))];for(let E of o){if(!E||E.startsWith("//"))continue;const{token:N,query:L}=om(E,m);let O;if(N.includes("*")){const A=new RegExp(`^${N.replace("*",".*")}\$`);O=[...Jo((B)=>A.test(B),r)]}else if(r.has(N))O=[N];else{n.warn(`unknown include rule ID: ${E}, skipping...`);continue}for(let A of O)n.debug("including class:",A),L?nm(f,L,`.${A}`,A):mm(G,`.${A}`,A)}return{mediaQueryRules:f,plainRules:G}},Fr=(t,{specs:o,mediaQueryIDs:n,mediaQueryRules:m,plainRules:r})=>{const f=Mt(),G=Mt(f),E={root:f,curr:G,scopes:[G]};for(let N of nt(t)){if(!N||/^\s*\/\//.test(N))continue;for(let L of Tr(N)){if(!L)continue;let O=E.curr;switch(O.state){case"sel":case"nest":if(L==="{"){if(O.state==="sel")O.sel=O.sel.map((A)=>A.replace(",","")),O.path=$r(E.scopes);O.state="class"}else if(L==="}")an(E);else{const A=wt(O.sel);if(!A||A.endsWith(","))O.sel.push(L);else O.sel[O.sel.length-1]+=" "+L}break;case"class":if(L==="{")O.state="nest",E.scopes.push(E.curr=Mt(O));else if(L==="}")an(E);else{let{token:A,query:B}=om(L,n);if(!o.classes[A]&&!(rm(A)||fm(A)))h(`unknown class ID: ${A}`);if(B)nm(m,B,O.path,A);else mm(r,O.path,A)}break;default:rt(O.state)}}}},zo=":",cn="///",Mt=(t)=>({state:"sel",sel:t?[]:["<root>"],path:"",parent:t}),an=(t)=>{const o=!t.curr.sel.length;if(ut(!!t.curr.parent,"stack underflow"),t.scopes.pop(),t.scopes.length>0){if(t.curr=wt(t.scopes),!o&&t.curr.state==="nest")t.scopes.push(t.curr=Mt(t.curr))}else t.scopes.push(t.curr=Mt(t.root))},$r=(t)=>t.map((o)=>o.sel.join(",")).join(cn),tm=(t,o)=>Object.entries(t).map(([n,m])=>_r(n,m,o)),_r=(t,o,n)=>{const m=[];let r=m;const f=t.split(cn);for(let G=0;G<f.length;G++){const E=f[G].split(",");if(G==f.length-1){const N=Object.assign({},...T((L)=>fm(L)?Sr(n,L):rm(L)?Ir(L):oo(n.classes[L]),o));E.push(N)}r.push(E),r=E}return m[0]},om=(t,o)=>{if(/^::?/.test(t))return{token:t};const n=t.lastIndexOf(zo);if(n<0)return{token:t};const m=t.substring(0,n);if(!m.split(zo).every((f)=>o.has(f)))h(`invalid media query in token: ${t}`);return{token:t.substring(n+1),query:m}},Hr=(t,o)=>o.split(zo).reduce((n,m)=>Object.assign(n,t[m]),{}),nm=(t,o,n,m)=>{if(!t[o])t[o]={};(t[o][n]||(t[o][n]=new Set)).add(m)},mm=(t,o,n)=>(t[o]||(t[o]=new Set)).add(n),Ir=(t)=>{const o=t.indexOf("=");return{[`--${t.substring(0,o)}`]:t.substring(o+1)}},Sr=(t,o)=>{const n=o.indexOf("("),m=o.substring(0,n),r=o.substring(n+1,o.length-1).split(/(?<!\\),/g).map((G)=>G.trim().replace("\\,",",")),f=t.templates[m];if(!f)h(`unknown template: ${m}`);if(r.length!==f.__arity)h(`template "${m}" expected ${f.__arity} arguments`);return Object.entries(f).reduce((G,[E,N])=>{if(!E.startsWith("__")){if(E=Uo(E,...r),$(N))N=Uo(N,...r);G[E]=N}return G},{})},rm=(t)=>t.includes("="),fm=(t)=>t.includes("(");async function Xo(t){if(t.opts.watch)await Rr(t);else await Lm(t.inputs.map((o)=>S(o,t.logger)),t.opts,t.logger)}var Gm={deg:Pn,em:In,ex:Sn,ms:Jn,percent:Ho,px:Wn,rad:Xn,rem:wn,second:zn,turn:yn,url:Dn,vh:Rn,vmax:Mn,vmin:Un,vw:Yn,"%":Ho},wr={percent:"{0}%",second:"{0}s",url:"url({0})"},Wr={"":[""],a:[""],h:["-left","-right"],v:["-top","-bottom"],t:["-top"],top:["top"],b:["-bottom"],bottom:["bottom"],r:["-right"],right:["right"],l:["-left"],left:["left"],x:["-x"],y:["-y"],in:[""],out:[""]},Nm={desc:"Generate framework rules from specs",opts:{...k,...ct,...i,...Tt},fn:Xo},Rr=async(t)=>{Yt(t.inputs,t.logger).subscribe({next(o){try{Lm(Object.keys(o).sort().map((n)=>o[n]),t.opts,t.logger)}catch(n){t.logger.warn(n.message)}}})},Lm=async(t,o,n)=>{const m={info:{name:"TODO",version:"0.0.0"},media:{},classes:{},templates:{},decls:[]};Hn(o.prec);for(let r of t){const f=JSON.parse(r);if(Object.assign(m.info,f.info),Object.assign(m.media,f.media),f.decls)m.decls.push(...f.decls);if(f.specs)for(let G of f.specs)try{Om(f,G,m.classes,n)}catch(E){n.warn(`error processing spec: ${G.name}`,E,", skipping...")}if(f.templates)for(let G of f.templates)Yr(f,G,m.templates,n)}return v(o.out,JSON.stringify(m,null,o.pretty?4:0),n),m},Om=(t,o,n,m,r=!1)=>{const f=H(o.vars)?o.vars:[""],G=$(o.props)?{[o.props]:"<v>"}:o.props,E=Ur(o,t),N=new Set;for(let L of f){const O=t.vars?.[L]||Wr[L];if(!O)h(`unknown variation ID: ${L}`);for(let[A,B]of pt(O,Object.keys(E))){const C=s(o.name,L,A,B,E[B]),M=o.unit?s(o.unit,L,A,B,E[B]):void 0,p=r?Jr(M):Mr(E[B],M);if(!n[C]){if(n[C]={},o.user!=null)n[C].__user=o.user;if(o.doc!=null)n[C].__doc=zr(o.doc,L,A,B,p)}else if(!N.has(C))h(`duplicate class ID: ${C}`);N.add(C);let F=-1;for(let[l,Y]of Object.entries(G)){const q=s(l,L,A,B,E[B]),no=s(!M||$(Y)?String(Y):Gm[M](Y),L,A,B,p);if(n[C][q]=no,m.debug(C,q,no),r)F=Em(no,Em(q,F))}if(r)n[C].__arity=F+1}}return n},Yr=(t,o,n,m)=>Om(t,{...o,values:[""]},n,m,!0),Em=(t,o)=>{const n=/\{(\d+)\}/g;let m;while(m=n.exec(t))o=Math.max(o,+m[1]);return o},Ur=(t,o)=>{const n=$(t.values)?o.tables?.[t.values]||h(`invalid table ID: ${t.values}`):t.values;if(y(n))return n;const m=t.key==="v"?(r)=>String(r):t.key==="i+1"?(r,f)=>String(f+1):t.key===void 0?(r,f)=>String(f):h(`invalid key type: ${t.key}`);return n.reduce((r,f,G)=>{return r[m(f,G)]=f,r},{})},Mr=(t,o)=>{if(!o||$(t))return t;const n=Gm[o];if(!n)h(`invalid unit: ${o}`);return n(t)},Jr=(t)=>t?wr[t]||"{0}"+t:"{0}",s=(t,o,n,m,r)=>t.replace(/<vid>/g,o).replace(/<var>/g,n).replace(/<k>/g,m).replace(/<v>/g,String(r)),zr=({group:t,desc:o,args:n},m,r,f,G)=>({group:t?s(t,m,r,f,G):"TODO",desc:o?s(o,m,r,f,G):void 0,args:n?n.map((E)=>s(E,m,r,f,G)):void 0});var Bm={desc:"Combination of the generate & convert commands",opts:{...xt,...at,...st,...At,...ht,...Ct,...ct,...i,...Ft,...Tt,outCss:X({desc:"Output file for CSS bundle",optional:!1}),outSpecs:X({desc:"Output file for framework",optional:!1})},fn:async(t)=>{const{opts:o,inputs:n}=t,[m,r]=n.reduce((E,N)=>(E[N.endsWith(".json")?0:1].push(N),E),[[],[]]),f={inputs:m,format:t.format,logger:t.logger,opts:{...o,out:o.outSpecs}},G={inputs:r,format:t.format,logger:t.logger,opts:{...o,noWrite:!1,out:o.outCss,scope:o.scope,specs:o.outSpecs}};await Xo(f),await Po(G)}};import{resolve as Pr} from"path";var Cm={desc:"Generate Markdown documentation for framework specs",opts:{...k,level:Xt({alias:"l",desc:"Initial heading level",default:1}),title:X({alias:"t",desc:"Custom main title, set to NONE to disable"})},inputs:1,fn:async(t)=>{const{logger:o,opts:n,inputs:m}=t,r=V(Pr(m[0]),o),f=Xr(r,n);v(n.out,f,o)}},Xr=(t,{level:o,title:n})=>{const m=Object.keys(t.classes).length,r=Object.keys(t.templates).length,f=[`Currently, there are ${m+r} CSS utility classes (incl. ${r} templates) defined in "${t.info.name}" (v${t.info.version}):`,"",`${c(o+1)} Classes by category`,"",...hm(t.classes,Dr,o+2),`${c(o+1)} Templates by category`,"",...hm(t.templates,Zr,o+2),`${c(o+1)} Media queries`,"",...Object.entries(t.media).map(([G,E])=>`- **${G}**: \`${JSON.stringify(E)}\``),""];if(n!=="NONE")f.unshift(`${c(o)} ${n??t.info.name}\n`);return f},Am=(t)=>t.split(/(\d+)/).map((o)=>{const n=parseInt(o);return isNaN(n)?o:n}),yr=(t,o)=>{if(/\d+/.test(t)&&/\d+/.test(o)){const n=Am(t),m=Am(o),r=n.length;if(r===m.length){for(let f=0;f<r;f++)if(n[f]!==m[f])return Co(n[f],m[f]);return 0}return n.length-m.length}return Co(t,o)},hm=(t,o,n)=>{const m=Mo({key:([r,{__doc:f}])=>f?.group||"TODO",group:[()=>[],(r)=>r.sort(),(r,f)=>(r.push(f[0]),r)]},Object.entries(t));return So((r)=>{const f=m[r].sort(yr).map((E)=>o(E,t[E].__doc,n+1)),G=f.length;return[`${c(n)} ${Vt(r)}`,G>3?`\n<details><summary>${G} items:</summary>\n`:"",f.join("\n"),G>3?"</details>\n":""]},Object.keys(m).sort())},Dr=(t,o)=>{if(!(o&&o.desc))return`- \`${t}\``;let n=o.desc;if(/^-[a-z]/.test(n))n=n.substring(1);return`- \`${t}\` (${n})`},Zr=(t,o,n)=>{if(!(o&&o.args))return`${c(n)} ${t}(...)\n\nTODO`;const m=o.args.map((r)=>/^\w+/.exec(r)[0]).join(", ");return[`${c(n)} \`${t}(${m})\``,"",...o.args.map(jr),o.desc?`\n${o.desc}\n`:""].join("\n")},jr=(t)=>`- ${t.replace(/^(\w+)/,(o,n)=>`**${n}**`)}`,c=Zt((t)=>"#".repeat(t));import{resolve as Fm} from"path";var $m={desc:"Export entire generated framework as CSS",opts:{...At,...ht,...en,...k,...i,...Ct,...dn,...Ft},inputs:1,fn:async(t)=>{const{logger:o,opts:{include:n,media:m,noDecls:r,noHeader:f,onlyDecls:G,out:E,pretty:N,scope:L},inputs:O}=t,A={format:N?it:ft,fns:et,scope:L},B=V(Fm(O[0]),o),C=n?n.map((M)=>S(Fm(M),o).trim()):[];if(!f)C.push(to(B));if(!r&&B.decls.length)C.push(g(B.decls,A));if(!G)C.push(Kr(B,m,A,o));v(E,C,o)}},Kr=(t,o,n,m)=>{const r=Tm("",t);if(o){const f=o[0]==="ALL"?Object.keys(t.media):o;for(let G of f)if(t.media[G])r.push(Bt(t.media[G],Tm("-"+G,t)));else m.warn(`invalid media query ID: ${G}, skipping...`)}return g(r,n)},Tm=(t,o)=>Object.entries(o.classes).map(([n,m])=>[`.${n}${t}`,oo(m)]);var yo=V(Vr(import.meta.dir,"package.json"));tn({name:"metacss",opts:{verbose:J({alias:"v",desc:"Display extra process information"})},commands:{convert:sn,develop:Bm,doc:Cm,export:$m,generate:Nm},ctx:async(t)=>{if(t.opts.verbose)t.logger.level=_.DEBUG;return{...t,format:Kt}},usage:{prefix:`
|
|
6
6
|
\u2588 \u2588 \u2588 \u2502
|
|
7
7
|
\u2588\u2588 \u2588 \u2502
|
|
8
8
|
\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${yo.name} ${yo.version}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/meta-css",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "Data-driven CSS framework codegen, transpiler & bundler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -41,20 +41,20 @@
|
|
|
41
41
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@thi.ng/api": "^8.11.
|
|
45
|
-
"@thi.ng/args": "^2.3.
|
|
46
|
-
"@thi.ng/arrays": "^2.
|
|
47
|
-
"@thi.ng/checks": "^3.6.
|
|
48
|
-
"@thi.ng/compare": "^2.4.
|
|
49
|
-
"@thi.ng/errors": "^2.5.
|
|
50
|
-
"@thi.ng/file-io": "^2.1.
|
|
51
|
-
"@thi.ng/hiccup-css": "^2.7.
|
|
52
|
-
"@thi.ng/logger": "^3.0.
|
|
53
|
-
"@thi.ng/memoize": "^3.3.
|
|
54
|
-
"@thi.ng/rstream": "^8.5.
|
|
55
|
-
"@thi.ng/strings": "^3.8.
|
|
56
|
-
"@thi.ng/text-format": "^2.2.
|
|
57
|
-
"@thi.ng/transducers": "^9.
|
|
44
|
+
"@thi.ng/api": "^8.11.9",
|
|
45
|
+
"@thi.ng/args": "^2.3.42",
|
|
46
|
+
"@thi.ng/arrays": "^2.10.0",
|
|
47
|
+
"@thi.ng/checks": "^3.6.11",
|
|
48
|
+
"@thi.ng/compare": "^2.4.1",
|
|
49
|
+
"@thi.ng/errors": "^2.5.15",
|
|
50
|
+
"@thi.ng/file-io": "^2.1.11",
|
|
51
|
+
"@thi.ng/hiccup-css": "^2.7.20",
|
|
52
|
+
"@thi.ng/logger": "^3.0.19",
|
|
53
|
+
"@thi.ng/memoize": "^3.3.11",
|
|
54
|
+
"@thi.ng/rstream": "^8.5.13",
|
|
55
|
+
"@thi.ng/strings": "^3.8.4",
|
|
56
|
+
"@thi.ng/text-format": "^2.2.12",
|
|
57
|
+
"@thi.ng/transducers": "^9.2.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@microsoft/api-extractor": "^7.47.5",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"status": "alpha",
|
|
111
111
|
"year": 2023
|
|
112
112
|
},
|
|
113
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "bfbc227cf5ca2d3c2984b3d4713eebd6225cbd54\n"
|
|
114
114
|
}
|
package/specs/shadows.mcss.json
CHANGED
|
@@ -39,5 +39,23 @@
|
|
|
39
39
|
"3px 3px 8px #0003"
|
|
40
40
|
]
|
|
41
41
|
}
|
|
42
|
+
],
|
|
43
|
+
"templates": [
|
|
44
|
+
{
|
|
45
|
+
"doc": {
|
|
46
|
+
"group": "shadow",
|
|
47
|
+
"args": ["body: CSS value/definition"]
|
|
48
|
+
},
|
|
49
|
+
"name": "box-shadow",
|
|
50
|
+
"props": "box-shadow"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"doc": {
|
|
54
|
+
"group": "shadow",
|
|
55
|
+
"args": ["body: CSS value/definition"]
|
|
56
|
+
},
|
|
57
|
+
"name": "text-shadow",
|
|
58
|
+
"props": "text-shadow"
|
|
59
|
+
}
|
|
42
60
|
]
|
|
43
61
|
}
|