@thi.ng/meta-css 0.16.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-11-15T16:47:21Z
3
+ - **Last updated**: 2024-11-24T18:15:48Z
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,30 @@ 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.17.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/meta-css@0.17.0) (2024-11-24)
13
+
14
+ #### 🚀 Features
15
+
16
+ - update width/height specs ([5e59d5e](https://github.com/thi-ng/umbrella/commit/5e59d5e))
17
+ - remove obsolete template defs, update readme ([2f607c0](https://github.com/thi-ng/umbrella/commit/2f607c0))
18
+ - commit which actually removed defs: [ecac29da87](https://github.com/thi-ng/umbrella/commit/ecac29da87)
19
+
20
+ #### 🩹 Bug fixes
21
+
22
+ - update `i` key/index handling in generator rules ([4150775](https://github.com/thi-ng/umbrella/commit/4150775))
23
+ - update verbatim prop parsing ([0876811](https://github.com/thi-ng/umbrella/commit/0876811))
24
+ - fixes nested selectors in the form `[sel] { ... }`
25
+ - update tests
26
+
27
+ #### ♻️ Refactoring
28
+
29
+ - remove obsolete default template specs ([ecac29d](https://github.com/thi-ng/umbrella/commit/ecac29d))
30
+ - remove template specs from base framework which can be easily replicated
31
+ via verbatim properties
32
+ - i.e. `prop-name(value)` => `prop-name-[value]`
33
+ - update framework version
34
+ - update readme
35
+
12
36
  ### [0.16.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/meta-css@0.16.1) (2024-11-15)
13
37
 
14
38
  #### 🩹 Bug fixes
package/README.md CHANGED
@@ -102,17 +102,12 @@
102
102
  - [Color adjustment](#color-adjustment)
103
103
  - [Color definitions](#color-definitions)
104
104
  - [Color scheme](#color-scheme)
105
- - [Dimensions](#dimensions)
106
- - [Font families](#font-families)
107
- - [Font size](#font-size)
108
105
  - [Fx](#fx)
109
106
  - [Grid layout](#grid-layout)
110
107
  - [Layout](#layout)
111
108
  - [Margin](#margin)
112
- - [Mask](#mask)
113
109
  - [Padding](#padding)
114
110
  - [Positions](#positions)
115
- - [Shadow](#shadow)
116
111
  - [Svg](#svg)
117
112
  - [Text color](#text-color)
118
113
  - [Media queries](#media-queries)
@@ -1150,7 +1145,15 @@ These are readily usable (and used by a growing number of example projects in
1150
1145
  this repo), but also are provided as starting point to define your own custom
1151
1146
  framework(s)...
1152
1147
 
1153
- Currently, there are 962 CSS utility classes (incl. 73 templates) defined in "MetaCSS base" (v0.16.0):
1148
+ > [!IMPORTANT]
1149
+ > Previous versions of the bundled framework included [template
1150
+ > definitions](#templated-class-definitions) which purely served as workaround
1151
+ > for the lack of [verbatim property syntax](#verbatim-property-definitions),
1152
+ > which has only been added in v0.16.0.
1153
+ >
1154
+ > Since v0.17.0 these templates have been removed, since obsolete now...
1155
+
1156
+ Currently, there are 950 CSS utility classes (incl. 59 templates) defined in "MetaCSS base" (v0.17.0):
1154
1157
 
1155
1158
  ### Classes by category
1156
1159
 
@@ -1599,8 +1602,9 @@ Currently, there are 962 CSS utility classes (incl. 73 templates) defined in "Me
1599
1602
 
1600
1603
  #### Height
1601
1604
 
1602
- <details><summary>29 items:</summary>
1605
+ <details><summary>30 items:</summary>
1603
1606
 
1607
+ - `h0` (0rem)
1604
1608
  - `h1` (1rem)
1605
1609
  - `h2` (2rem)
1606
1610
  - `h3` (4rem)
@@ -2263,12 +2267,13 @@ Currently, there are 962 CSS utility classes (incl. 73 templates) defined in "Me
2263
2267
 
2264
2268
  #### Width
2265
2269
 
2266
- <details><summary>29 items:</summary>
2270
+ <details><summary>30 items:</summary>
2267
2271
 
2268
2272
  - `vw-25`
2269
2273
  - `vw-50`
2270
2274
  - `vw-75`
2271
2275
  - `vw-100`
2276
+ - `w0` (0rem)
2272
2277
  - `w1` (1rem)
2273
2278
  - `w2` (2rem)
2274
2279
  - `w3` (4rem)
@@ -2314,11 +2319,7 @@ Currently, there are 962 CSS utility classes (incl. 73 templates) defined in "Me
2314
2319
 
2315
2320
  #### Animation / transition
2316
2321
 
2317
- <details><summary>15 items:</summary>
2318
-
2319
- ##### `anim(body)`
2320
-
2321
- - **body**: CSS value/definition
2322
+ <details><summary>12 items:</summary>
2322
2323
 
2323
2324
  ##### `anim-delay(delay)`
2324
2325
 
@@ -2369,10 +2370,6 @@ Animation which shrinks the height from given initial value to zero. Target elem
2369
2370
 
2370
2371
  Animation which rotates element a full turn, looping indefinitely
2371
2372
 
2372
- ##### `transition(body)`
2373
-
2374
- - **body**: CSS value/definition
2375
-
2376
2373
  ##### `transition-delay(delay)`
2377
2374
 
2378
2375
  - **delay**: time (in seconds)
@@ -2381,10 +2378,6 @@ Animation which rotates element a full turn, looping indefinitely
2381
2378
 
2382
2379
  - **duration**: time (in seconds)
2383
2380
 
2384
- ##### `transition-property(prop)`
2385
-
2386
- - **prop**: CSS value/definition
2387
-
2388
2381
  ##### `transition-steps(num)`
2389
2382
 
2390
2383
  - **num**: number of steps
@@ -2580,60 +2573,6 @@ Sets `stroke` color using CSS light-dark() function
2580
2573
 
2581
2574
  </details>
2582
2575
 
2583
- #### Dimensions
2584
-
2585
- <details><summary>6 items:</summary>
2586
-
2587
- ##### `height(height)`
2588
-
2589
- - **height**: incl. units
2590
-
2591
- Sets height to given value
2592
-
2593
- ##### `max-height(height)`
2594
-
2595
- - **height**: incl. units
2596
-
2597
- Sets max-height to given value
2598
-
2599
- ##### `max-width(width)`
2600
-
2601
- - **width**: incl. units
2602
-
2603
- Sets max-width to given value
2604
-
2605
- ##### `min-height(height)`
2606
-
2607
- - **height**: incl. units
2608
-
2609
- Sets min-height to given value
2610
-
2611
- ##### `min-width(width)`
2612
-
2613
- - **width**: incl. units
2614
-
2615
- Sets min-width to given value
2616
-
2617
- ##### `width(width)`
2618
-
2619
- - **width**: incl. units
2620
-
2621
- Sets width to given value
2622
-
2623
- </details>
2624
-
2625
- #### Font families
2626
-
2627
- ##### `font-family(body)`
2628
-
2629
- - **body**: CSS value/definition
2630
-
2631
- #### Font size
2632
-
2633
- ##### `font-size(body)`
2634
-
2635
- - **body**: CSS value/definition
2636
-
2637
2576
  #### Fx
2638
2577
 
2639
2578
  ##### `bg-blur(radius)`
@@ -2708,12 +2647,6 @@ Sets margin to custom size
2708
2647
 
2709
2648
  </details>
2710
2649
 
2711
- #### Mask
2712
-
2713
- ##### `mask-image(body)`
2714
-
2715
- - **body**: definition (e.g. url or gradient)
2716
-
2717
2650
  #### Padding
2718
2651
 
2719
2652
  <details><summary>7 items:</summary>
@@ -2784,16 +2717,6 @@ Sets padding to custom size
2784
2717
 
2785
2718
  </details>
2786
2719
 
2787
- #### Shadow
2788
-
2789
- ##### `box-shadow(body)`
2790
-
2791
- - **body**: CSS value/definition
2792
-
2793
- ##### `text-shadow(body)`
2794
-
2795
- - **body**: CSS value/definition
2796
-
2797
2720
  #### Svg
2798
2721
 
2799
2722
  ##### `fill(name)`
@@ -2844,7 +2767,7 @@ distributed as CLI bundle with **no runtime dependencies**. The following
2844
2767
  dependencies are only shown for informational purposes and are (partially)
2845
2768
  included in the bundle.
2846
2769
 
2847
- Package sizes (brotli'd, pre-treeshake): ESM: 13.77 KB
2770
+ Package sizes (brotli'd, pre-treeshake): ESM: 13.78 KB
2848
2771
 
2849
2772
  ## Dependencies
2850
2773
 
package/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  var nt={default:95,hint:90,multi:90,param:96,required:33};var To=(o)=>o;var z=function(o,t=Object.create(null)){return(...n)=>{const m=n.join("-");return m in t?t[m]:t[m]=o(...n)}};var oo=z((o,t)=>o.repeat(t));var yt=(o)=>/^[a-f0-9]+$/i.test(o);var Zt=(o)=>/^[-+]?\d+$/.test(o),Dt=(o)=>/^[-+]?\d*\.?\d+(e[-+]?\d+)?$/i.test(o);var X=(o,t=(n)=>n!==void 0?": "+n:"")=>class extends Error{origMessage;constructor(n){super(o(n)+t(n));this.origMessage=n!==void 0?String(n):""}};var $m=X(()=>"illegal argument(s)"),C=(o)=>{throw new $m(o)};var mt=(o)=>Dt(o)?parseFloat(o):C(`not a numeric value: ${o}`),jt=(o)=>o.map(mt),rt=(o)=>yt(o)?parseInt(o,16):C(`not a hex value: ${o}`),Kt=(o)=>o.map(rt),ft=(o)=>Zt(o)?parseInt(o):C(`not an integer: ${o}`),Vt=(o)=>o.map(ft);var Uo=(o,t)=>(n)=>({coerce:o,hint:t,group:"main",...n}),Jo=(o,t)=>(n)=>({hint:Hm(t,n.delim),multi:!0,coerce:o,group:"main",...n}),Hm=(o,t)=>o+(t?`[${t}..]`:""),J=(o)=>({flag:!0,default:!1,group:"flags",...o}),P=Uo(To,"STR"),zo=Jo(To,"STR"),ff=Uo(mt,"NUM"),Ef=Uo(rt,"HEX"),Xo=Uo(ft,"INT"),Gf=Jo(jt,"NUM"),Nf=Jo(Kt,"HEX"),Lf=Jo(Vt,"INT");var H=((o)=>{return o[o.FINE=0]="FINE",o[o.DEBUG=1]="DEBUG",o[o.INFO=2]="INFO",o[o.WARN=3]="WARN",o[o.SEVERE=4]="SEVERE",o[o.NONE=5]="NONE",o})(H||{});var _m=0;class $o{constructor(o,t=H.FINE,n){this.parent=n,this.id=o||`logger-${_m++}`,this.level=typeof t==="string"?H[t]:t}id;level;addChild(o){return o.parent=this,o}enabled(o){return this.level<=o}fine(...o){this.log(H.FINE,o)}debug(...o){this.log(H.DEBUG,o)}info(...o){this.log(H.INFO,o)}warn(...o){this.log(H.WARN,o)}severe(...o){this.log(H.SEVERE,o)}log(o,t){this.level<=o&&this.logEntry([o,this.id,Date.now(),...t])}}var qt=(o)=>o.map((t)=>{if(typeof t==="function")t=t();if(!(typeof t==="string"||typeof t==="number"))t=JSON.stringify(t);return t}).join(" ");class Po extends $o{constructor(o,t,n,m){super(t,n,m);this.target=o}childLogger(o,t){return new Po(this.target,o,t??this.level,this)}logEntry(o){if(o[0]<this.level)return;this.target.write(`[${H[o[0]]}] ${o[1]}: ${qt(o.slice(3))}
3
3
  `),this.parent&&this.parent.logEntry(o)}}var yo=z((o,t=" ")=>{const n=oo(String(t),o);return(m,r)=>{if(m==null)return n;return m=m.toString(),r=r!==void 0?r:m.length,r<o?m+n.substring(r):m}});var Et={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 Im=(o,t)=>(n)=>o.format(t,n),Gt=(o)=>Object.keys(Et).reduce((t,n)=>(t[n]=Im(o,Et[n]),t),{format:o});var Qt="\x1B[0m";var wm=["","1","2","1;2","4","1;4","2;4","1;2;4"],Zo={format:(o,t)=>Zo.start(o)+t+Zo.end,start:z((o)=>{let t=[],n=o&15;return n&&t.push(29+(o>>4&1)*60+n),n=o>>5&15,n&&t.push(39+(o>>9&1)*60+n),n=o>>10,n&&t.push(wm[n]),"\x1B["+t.join(";")+"m"}),end:Qt,prefix:Qt,suffix:"\n"};var ut={format:(o,t)=>String(t),prefix:"",suffix:"\n",start:()=>"",end:""};var Do=Gt(Zo),bt=Gt(ut);var _=Array.isArray;var Wm=(o)=>o.toUpperCase(),kt=(o)=>o.toLowerCase(),jo=(o)=>o.length?o[0].toUpperCase()+o.substring(1):o,it=(o,t="-")=>kt(o.replace(/([a-z0-9\u00e0-\u00fd])([A-Z\u00c0-\u00dd])/g,(n,m,r)=>m+t+r));var vt=(o,t="-")=>kt(o).replace(new RegExp(`\\${t}+(\\w)`,"g"),(n,m)=>Wm(m));var pt=Object.getPrototypeOf,y=(o)=>{let t;return o!=null&&typeof o==="object"&&((t=pt(o))===null||pt(t)===null)};var Mm=/\x1b\[[0-9;]+m/g,Ym=(o)=>o.replace(Mm,"");var Ko=(o)=>Ym(o).length;var lt=(o=!1,t)=>(n)=>o||typeof n!=="string"&&typeof n!=="number"?JSON.stringify(n,null,t):String(n);function*to(o,t=/\r?\n/g,n=!1){let m=0;const r=o.length,f=~~n;let G;if(typeof t==="string")G=new RegExp(t,"g");else if(!t.flags.includes("g"))G=new RegExp(t,t.flags+"g");else G=t;for(;m<r;){const E=G.exec(o);if(!E){yield o.substring(m);return}const N=E[0].length;yield o.substring(m,E.index+f*N),m=E.index+N}}class Nt{n=0;w=[];constructor(o,t){o!=null&&this.add(o,t)}add(o,t=o.length){return this.w.push(o),this.n+=t+~~(this.n>0),this}toString(){return this.w.join(" ")}}var Sm={length:(o)=>o.length,split:(o,t)=>t},et={length:Ko,split:(o,t)=>{const n=/\x1b\[[0-9;]+m/g;let m=t,r;while(r=n.exec(o)){if(r.index>=t)break;const f=r[0].length;m+=f,t+=f}return m}},dt=(o,t,n,m)=>{const r=o[o.length-1];r&&m-r.n>n?r.add(t,n):o.push(new Nt(t,n))},Rm=(o,{width:t,min:n,hard:m,splitter:r},f=0,G=[])=>{let E=r.length(o),N=t-f;if(N<n&&N<E)N=t;while(m&&E>N){const L=r.split(o,N),B=o.substring(0,L);dt(G,B,N,t),o=o.substring(L),N=t,E=r.length(o)}return dt(G,o,E,t),G},Um=(o,t,n=[])=>{if(!o.length)return n.push(new Nt),n;const m={width:80,min:4,hard:!1,splitter:Sm,...t};for(let r of to(o,t.delimWord||/\s/g)){const f=n[n.length-1];Rm(r,m,f&&f.n>0?f.n+1:0,n)}return n},gt=(o,t)=>{let n=[];for(let m of to(o,t.delimLine))n=n.concat(Um(m,t));return n};var Ho=(o,t={})=>{t={lineWidth:80,paramWidth:32,showDefaults:!0,prefix:"",suffix:"",groups:["flags","main"],...t};const n=y(t.color)?{...nt,...t.color}:t.color?nt:{},m=oo(" ",t.paramWidth),r=(E)=>E.map((N)=>Jm(N,o[N],t,n,m)),f=Object.keys(o).sort(),G=t.groups?t.groups.map((E)=>[E,f.filter((N)=>o[N].group===E)]).filter((E)=>!!E[1].length):[["options",f]];return[...Lt(t.prefix,t.lineWidth),...G.map(([E,N])=>[...t.showGroupNames?[`${jo(E)}:
4
4
  `]:[],...r(N),""].join("\n")),...Lt(t.suffix,t.lineWidth)].join("\n")},Jm=(o,t,n,m,r)=>{const f=zm(t,m),G=Xm(t,m,f),E=_o(`--${it(o)}`,m.param),N=`${G}${E}${f}`,L=t.optional===!1&&t.default===void 0,B=[];L&&B.push("required"),t.multi&&B.push("multiple");const h=Pm(B,m,L)+(t.desc||"")+ym(t,n,m);return yo(n.paramWidth)(N,Ko(N))+Lt(h,n.lineWidth-n.paramWidth).map((O,A)=>A>0?r+O:O).join("\n")},zm=(o,t)=>o.hint?_o(" "+o.hint,t.hint):"",Xm=(o,t,n)=>o.alias?`${_o("-"+o.alias,t.param)}${n}, `:"",Pm=(o,t,n)=>o.length?_o(`[${o.join(", ")}] `,n?t.required:t.multi):"",ym=(o,t,n)=>t.showDefaults&&o.default!=null&&o.default!==!1?_o(` (default: ${lt(!0)(o.defaultHint!=null?o.defaultHint:o.default)})`,n.default):"",_o=(o,t)=>t!=null?`\x1B[${t}m${o}\x1B[0m`:o,Lt=(o,t)=>o?gt(o,{width:t,splitter:et,hard:!1}):[];var Zm=X(()=>"parse error"),xt=(o,t,n)=>{n={start:2,showUsage:!0,help:["--help","-h"],...n};try{return Dm(o,t,n)}catch(m){if(n.showUsage)console.log(m.message+"\n\n"+Ho(o,n.usageOpts));throw new Zm(m.message)}},Dm=(o,t,n)=>{const m=jm(o),r={};let f,G,E=n.start;for(;E<t.length;){const N=t[E];if(!f){if(n.help.includes(N)){console.log(Ho(o,n.usageOpts));return}const L=Km(o,m,r,N);if(f=L.id,G=L.spec,E=E+~~(L.state<2),L.state)break}else{if(Vm(G,r,f,N))break;f=null,E++}}return f&&C(`missing value for: --${f}`),{result:qm(o,r),index:E,rest:t.slice(E),done:E>=t.length}},jm=(o)=>Object.entries(o).reduce((t,[n,m])=>m.alias?(t[m.alias]=n,t):t,{}),Km=(o,t,n,m)=>{if(m[0]==="-"){let r;if(m[1]==="-"){if(m==="--")return{state:1};r=vt(m.substring(2))}else r=t[m.substring(1)],!r&&C(`unknown option: ${m}`);const f=o[r];if(!f&&C(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}},Vm=(o,t,n,m)=>{if(/^-[a-z]/i.test(m)&&C(`missing value for: --${n}`),o.multi)_(t[n])?t[n].push(m):t[n]=[m];else t[n]=m;return o.fn&&!o.fn(m)},qm=(o,t)=>{let n;for(let m in o)if(n=o[m],t[m]===void 0){if(n.default!==void 0)t[m]=n.default;else if(n.optional===!1)C(`missing arg: --${m}`)}else if(n.coerce)Qm(n,t,m);return t},Qm=(o,t,n)=>{try{if(o.multi&&o.delim)t[n]=t[n].reduce((m,r)=>(m.push(...r.split(o.delim)),m),[]);t[n]=o.coerce(t[n])}catch(m){throw new Error(`arg --${n}: ${m.message}`)}};var st=async(o)=>{const t=o.argv||process.argv,n=!process.env.NO_COLOR,m={prefix:"",color:n,...o.usage};try{let r,f,G=o.start??2;if(o.single){if(r=Object.keys(o.commands)[0],!r)C("no command provided");f=o.commands[r]}else{if(r=t[G],f=o.commands[r],m.prefix+=um(o.commands),!f)at(o,m);G++}let E;try{E=xt({...o.opts,...f.opts},t,{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
- `),at(o,m);const N=await o.ctx({logger:new Po(process.stderr,o.name,"INFO"),format:n?Do:bt,opts:E.result,inputs:E.rest},f);if(await f.fn(N),o.post)await o.post(N,f)}catch(r){process.stderr.write(r.message+"\n\n"),process.exit(1)}},at=(o,t)=>{process.stderr.write(Ho(o.opts,t)),process.exit(1)},um=(o)=>["\nAvailable commands:\n",...Object.keys(o).map((t)=>`${yo(16)(t)}: ${o[t].desc}`),"\n"].join("\n");import{existsSync as bm,mkdirSync as km,statSync as OE} from"fs";import{dirname as im} from"path";var vm=(o)=>o.length>0&&!bm(o)?(km(o,{recursive:!0}),!0):!1,ct=(o)=>vm(im(o));var K=(o)=>typeof o==="function";var $=(o)=>typeof o==="string";import{readFileSync as lm} from"fs";import{writeFileSync as pm} from"fs";var on=(o,t,n,m,r=!1)=>{if(m&&m.info(`${r?"[dryrun] ":""}writing file: ${o}`),r)return;ct(o),pm(o,t,!n&&$(t)?"utf-8":n)};var W=(o,t,n="utf-8")=>{return t&&t.debug("reading file:",o),lm(o,n)},Bt=(o,t,n,m=!1)=>on(o,_(t)?t.join("\n"):t,"utf-8",n,m);var V=(o,t)=>JSON.parse(W(o,t));var Q=Symbol(),Ot=()=>{};var Io=Object.freeze({level:H.NONE,addChild(o){return o},childLogger:()=>Io,enabled:()=>!1,fine(){},debug(){},info(){},warn(){},severe(){},logEntry(){}});class ht extends $o{set(o){this.parent=o}childLogger(o,t){return new ht(o,t??this.level,this)}logEntry(o){this.parent.logEntry(o)}}var tn=new ht("root",H.FINE,Io);import{join as Vr} from"path";var Ct=(o,t)=>{if(o===t)return 0;if(o==null)return t==null?0:-1;if(t==null)return o==null?0:1;if(typeof o.compare==="function")return o.compare(t);if(typeof t.compare==="function")return-t.compare(o);return o<t?-1:o>t?1:0};var dm=X(()=>"Assertion failed"),Vo=(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)?(o,t)=>{if(typeof o==="function"&&!o()||!o)throw new dm(typeof t==="function"?t():t)}:()=>{};var qo=(o)=>o!=null&&typeof o!=="function"&&o.length!==void 0;var nn=(o)=>{return(o==null||!o[Symbol.iterator])&&C(`value is not iterable: ${o}`),o};var mn=(o)=>qo(o)?o:[...nn(o)];var wo=(o)=>o[o.length-1];var Qo=(o,t)=>o!=null&&typeof o[t]==="function";var I=(o)=>o!=null&&typeof o[Symbol.iterator]==="function";var uo=(o)=>o!=null&&typeof o!=="string"&&typeof o[Symbol.iterator]==="function";var em=X(()=>"illegal arity"),no=(o)=>{throw new em(o)};var gm=X(()=>"illegal state"),mo=(o)=>{throw new gm(o)};var rn=["-moz-","-ms-","-o-","-webkit-"],ro={rules:"",ruleSep:",",valSep:"",decls:"",declStart:"{",declEnd:"}",indent:"",comments:!1},bo={rules:"\n",ruleSep:", ",valSep:" ",decls:"\n",declStart:" {\n",declEnd:"}\n",indent:" ",comments:!0};var At=function(...o){let[t,n,m,r,f,G,E,N,L,B]=o;switch(o.length){case 0:no(0);case 1:return t;case 2:return(...O)=>t(n(...O));case 3:return(...O)=>t(n(m(...O)));case 4:return(...O)=>t(n(m(r(...O))));case 5:return(...O)=>t(n(m(r(f(...O)))));case 6:return(...O)=>t(n(m(r(f(G(...O))))));case 7:return(...O)=>t(n(m(r(f(G(E(...O)))))));case 8:return(...O)=>t(n(m(r(f(G(E(N(...O))))))));case 9:return(...O)=>t(n(m(r(f(G(E(N(L(...O)))))))));case 10:default:const h=(...O)=>t(n(m(r(f(G(E(N(L(B(...O))))))))));return o.length===10?h:At(h,...o.slice(10))}};var d=(o)=>Qo(o,"xform")?o.xform():o;var Z=function(...o){return o=o.map(d),At.apply(null,o)};var u=(o,t)=>[o[0],o[1],t];class Wo{value;constructor(o){this.value=o}deref(){return this.value}}var M=(o)=>o instanceof Wo,fn=(o)=>o instanceof Wo?o:new Wo(o),D=(o)=>o instanceof Wo?o.deref():o;var fo=function(...o){const t=o[0],n=t[0],m=t[1],r=t[2];o=xm(o);const f=o[0]==null?n():o[0],G=o[1];return D(m(Qo(G,"$reduce")?G.$reduce(r,f):qo(G)?am(r,f,G):sm(r,f,G)))};var xm=(o)=>o.length===2?[void 0,o[1]]:o.length===3?[o[1],o[2]]:no(o.length),am=(o,t,n)=>{for(let m=0,r=n.length;m<r;m++)if(t=o(t,n[m]),M(t)){t=t.deref();break}return t},sm=(o,t,n)=>{for(let m of n)if(t=o(t,m),M(t)){t=t.deref();break}return t},Eo=(o,t)=>[o,To,t],En=(o,t)=>{const n=t.length-1;return I(t[n])?t.length>1?fo(o.apply(null,t.slice(0,n)),t[n]):fo(o(),t[0]):void 0};var Go=function(o){return o?[...o]:Eo(()=>[],(t,n)=>(t.push(n),t))};function*No(o,t){const n=d(o)(Go()),m=n[1],r=n[2];for(let f of t){const G=r([],f);if(M(G)){yield*D(m(G.deref()));return}if(G.length)yield*G}yield*D(m([]))}function*e(o,t){const n=d(o)([Ot,Ot,(m,r)=>r])[2];for(let m of t){let r=n(Q,m);if(M(r)){if(r=D(r.deref()),r!==Q)yield r;return}if(r!==Q)yield r}}var ko=(o,t,n=e)=>{const m=t.length-1;return I(t[m])?t.length>1?n(o.apply(null,t.slice(0,m)),t[m]):n(o(),t[0]):void 0};var Ft=function(o,t){return I(t)?No(Ft(o),$(t)?[t]:t):(n)=>{const m=n[2],r=(f,G)=>{const E=o(G);if(E){for(let N of E)if(f=r(f,N),M(f))break;return f}return m(f,G)};return u(n,r)}};var Gn=function(o){return Ft((t)=>uo(t)?t:void 0,o)};var T=function(o,t){return I(t)?e(T(o),t):(n)=>{const m=n[2];return u(n,(r,f)=>m(r,o(f)))}};function*io(...o){const t=o.length-1;if(t<0)return;const n=new Array(t+1).fill(0),m=o.map(mn),r=m.reduce((f,G)=>f*G.length,1);for(let f=0;f<r;f++){const G=[];for(let E=t;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[t]++,yield G}}function*Nn(o,t=1/0){while(t-- >0)yield o}var Tt=function(o,t){o=o||"";let n=!0;return t?[...t].join(o):Eo(()=>"",(m,r)=>(m=n?m+r:m+o+r,n=!1,m))};var vo=function(...o){return cm(vo,fo,o)};var cm=(o,t,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)=>o(n[0],n[1],f));default:no(n.length)}return t(d(n[0])(n[1]),m,r)};var or=new Set,tr=":[",Ln=Z(Gn(),T((o)=>o[0]==="&"?o.substring(1):tr.includes(o[0])?o:" "+o)),nr=(o,t)=>Z(o,T((n)=>$(n)&&n.startsWith(" .")?n+t:n)),Lo=(o,t,n,m)=>{const r=n.length,f=[];let G,E;const N=(L,B)=>{let h=null;if(_(B))Lo(o,$t(t,f),B,m);else if(I(B)&&!$(B))Lo(o,$t(t,f),[...B],m);else if((E=K(B))||(h=m.fns[B]))if(!t.length){if(h)return h.apply(null,n.slice(L+1))(o,m),!0;B(o,m)}else if(E)N(L,B());else C(`quoted fn ('${B}') only allowed at head position`);else if(y(B))G=Object.assign(G||{},B);else if(B!=null)f.push(B)};for(let L=0;L<r;L++)if(N(L,n[L]))return o;return G&&o.push(mr(t,f,G,m)),o},$t=(o,t)=>o.length?[...io(o,t)]:t,mr=(o,t,n,m)=>{const r=m.format,f=j(m),G=m.scope?nr(Ln,m.scope):Ln;return[f,vo(T((E)=>vo(G,Tt(),_(E)?E:[E]).trim()),Tt(r.ruleSep),$t(o,t)),r.declStart,Mo(n,m),f,r.declEnd].join("")},Mo=(o,t)=>{const n=t.format,m=t.autoprefix||or,r=j(t,t.depth+1),f=[];for(let G in o)if(o.hasOwnProperty(G)){let E=o[G];if(K(E))E=E(o);if(_(E))E=E.map((N)=>_(N)?N.join(" "):N).join(n.ruleSep);if(m.has(G))for(let N of t.vendors)f.push(`${r}${N}${G}:${n.valSep}${E};`);f.push(`${r}${G}:${n.valSep}${E};`)}return f.join(n.decls)+n.decls},j=(o,t=o.depth)=>t>1?[...Nn(o.format.indent,t)].join(""):t>0?o.format.indent:"";var Bn=function(o,...t){const n=t.length===1?t[0]:t.reduce((m,r,f)=>{return m[f/(t.length-1)*100|0]=r,m},{});return(m,r)=>{const f=j(r);r.depth++;const G=j(r);m.push(`${f}@keyframes ${o}${r.format.declStart}`);for(let E in n)if(n.hasOwnProperty(E))m.push([G,E+"%",r.format.declStart,Mo(n[E],r),G,r.format.declEnd].join(""));return r.depth--,m.push(f+r.format.declEnd),m}};var On=(o,t=!1)=>(n,m)=>{const r=j(m),f=j(m,m.depth+1);if(m.format.comments||t)n.push(r+"/*",o.split("\n").map((G)=>f+G).join("\n"),r+"*/");return n};var po=(o,t,n)=>(m,r)=>{const f=j(r);return m.push(`${f}${o} ${rr(t)}${r.format.declStart}`),r.depth++,Lo(m,[],n,r),r.depth--,m.push(f+r.format.declEnd),m},rr=(o)=>{if($(o))return o;const t=[];for(let n in o)if(o.hasOwnProperty(n)){let m=o[n];if(m===!0)m=hn.has(n)?n:`(${n})`;else if(m===!1)m=`(not ${hn.has(n)?n:`(${n})`})`;else if(m==="only")m+=" "+n;else m=`(${n}:${m})`;t.push(m)}return t.join(" and ")},hn=new Set(["all","print","screen"]);var g=(o,t)=>{return t={format:ro,vendors:rn,fns:{},depth:0,...t},_(t.autoprefix)&&(t.autoprefix=new Set(t.autoprefix)),y(o)?Mo(o,t):K(o)?o([],t).join(t.format.rules):Lo([],[],_(o)?o:uo(o)?[...o]:C("invalid rules"),t).join(t.format.rules)};var Cn=(o,...t)=>(n,m)=>(n.push(t.length?`@import url(${o}) ${t.join(m.format.ruleSep)};`:`@import url(${o});`),n);var Bo=(o,t)=>po("@media",o,t);var An=function(...o){return(t,n)=>(t.push(o.length>1?`@namespace ${o[0]} url(${o[1]});`:`@namespace url(${o[0]});`),t)};var Fn=(o,t)=>po("@supports",o,t);var lo={"@comment":On,"@import":Cn,"@keyframes":Bn,"@media":Bo,"@namespace":An,"@supports":Fn};var Tn=4,$n=(o)=>Tn=o,R=(o)=>o===(o|0)?String(o):o.toFixed(Tn).replace(/^0./,".").replace(/^-0./,"-.").replace(/0+$/,"");var Hn=(o)=>`${R(o)}em`,_n=(o)=>`${R(o)}ex`;var In=(o)=>`${R(o)}rem`,Ht=(o)=>`${R(o)}%`,wn=(o)=>`${R(o)}px`,Wn=(o)=>`${R(o)}vh`,Mn=(o)=>`${R(o)}vw`,Yn=(o)=>`${R(o)}vmin`,Sn=(o)=>`${R(o)}vmax`,Rn=(o)=>`${o|0}ms`,Un=(o)=>`${R(o)}s`;var Jn=(o)=>`${R(o)}deg`,zn=(o)=>`${R(o)}rad`,Xn=(o)=>`${R(o)}turn`,Pn=(o)=>`url(${o})`;var w=((o)=>{return o[o.IDLE=0]="IDLE",o[o.ACTIVE=1]="ACTIVE",o[o.DONE=2]="DONE",o[o.UNSUBSCRIBED=3]="UNSUBSCRIBED",o[o.ERROR=4]="ERROR",o})(w||{});var fr=0,Er=()=>fr++,x=(o,t)=>!t||!t.id?{...t,id:o+"-"+Er()}:t;var Y=tn.childLogger("rstream");class b{constructor(o,t){this.wrapped=o,t=x("sub",{closeIn:"last",closeOut:"last",cache:!0,...t}),this.parent=t.parent,this.id=t.id,this.closeIn=t.closeIn,this.closeOut=t.closeOut,this.cacheLast=t.cache,t.xform&&(this.xform=t.xform(Go()))}id;closeIn;closeOut;parent;__owner;xform;cacheLast;last=Q;state=w.IDLE;subs=[];deref(){return this.last!==Q?this.last:void 0}getState(){return this.state}setState(o){this.state=o}subscribe(o,t={}){this.ensureState();let n;if(o instanceof b&&!t.xform)o.ensureState(),Vo(!o.parent,`sub '${o.id}' already has a parent`),o.parent=this,n=o;else n=new b(o,{...t,parent:this});return this.subs.push(n),this.setState(w.ACTIVE),n.setState(w.ACTIVE),this.last!=Q&&n.next(this.last),n}transform(...o){let t,n;if(y(wo(o)))n=o.pop(),t={error:n.error};return this.subscribe(t,x("xform",o.length>0?{...n,xform:Z(...o)}:n))}map(o,t){return this.transform(T(o),t||{})}unsubscribe(o){return o?this.unsubscribeChild(o):this.unsubscribeSelf()}unsubscribeSelf(){return Y.debug(this.id,"unsub self"),this.parent&&this.parent.unsubscribe(this),this.state<w.UNSUBSCRIBED&&(this.state=w.UNSUBSCRIBED),this.release(),!0}unsubscribeChild(o){Y.debug(this.id,"unsub child",o.id);const t=this.subs.indexOf(o);if(t>=0){if(this.subs.splice(t,1),this.closeOut==="first"||!this.subs.length&&this.closeOut!=="never")this.unsubscribe();return!0}return!1}next(o){if(this.state>=w.DONE)return;this.xform?this.dispatchXform(o):this.dispatch(o)}done(){if(Y.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();Y.debug(this.id,"exiting done()")}error(o){const t=this.wrapped,n=t&&t.error;return n&&Y.debug(this.id,"attempting wrapped error handler"),n&&t.error(o)||this.unhandledError(o)}unhandledError(o){return(Y.parent!==Io?Y:console).warn(this.id,"unhandled error:",o),this.unsubscribe(),this.state=w.ERROR,!1}dispatchTo(o,t){let n=this.wrapped;if(n)try{n[o]&&n[o](t)}catch(r){if(!this.error(r))return!1}const m=o==="next"?this.subs:[...this.subs];for(let r=m.length;r-- >0;){n=m[r];try{n[o]&&n[o](t)}catch(f){if(o==="error"||!n.error||!n.error(f))return this.unhandledError(f)}}return!0}dispatch(o){Y.debug(this.id,"dispatch",o),this.cacheLast&&(this.last=o),this.dispatchTo("next",o)}dispatchXform(o){let t;try{t=this.xform[2]([],o)}catch(n){this.error(n);return}if(this.dispatchXformVals(t))M(t)&&this.done()}dispatchXformDone(){let o;try{o=this.xform[1]([])}catch(t){return this.error(t)}return this.dispatchXformVals(o)}dispatchXformVals(o){const t=D(o);for(let n=0,m=t.length;n<m&&this.state<w.DONE;n++)this.dispatch(t[n]);return this.state<w.ERROR}ensureState(){if(this.state>=w.DONE)mo(`operation not allowed in state ${w[this.state]}`)}release(){this.subs.length=0,delete this.parent,delete this.xform,delete this.last}}var yn=(o,t)=>{const n=new Zn(t);return n.next(o),n};class Zn extends b{src;_cancel;_inited;constructor(o,t){const[n,m]=K(o)?[o,t||{}]:[void 0,o||{}];super(m.error?{error:m.error}:void 0,x("stream",m));this.src=n,this._inited=!1}subscribe(o,t={}){const n=super.subscribe(o,t);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(o){const t=super.unsubscribe(o);if(t&&(!o||(!this.subs||!this.subs.length)&&this.closeOut!=="never"))this.cancel();return t}done(){this.cancel(),super.done(),delete this.src,delete this._cancel}error(o){if(super.error(o))return!0;return this.cancel(),!1}cancel(){if(this._cancel){Y.debug(this.id,"cancel");const o=this._cancel;delete this._cancel,o()}}}var Dn=(o,t)=>o==="first"||o==="last"&&!t;var _t=function(o){return o?fo(_t(),o):Eo(()=>({}),(t,[n,m])=>(t[n]=m,t))};var jn=()=>(o)=>{const t=o[2];return u(o,(n,m)=>{if(m){for(let r of D(m)||[])if(n=t(n,r),M(n))break}return M(m)?fn(n):n})};var It=function(o,t){return I(t)?No(It(o),t):Z(T(o),jn())};var wt=function(o,t){return I(t)?e(wt(o),t):T(K(o)?(n)=>[o(n),n]:(n)=>[o,n])};var Wt=function(...o){const t=ko(Wt,o);if(t)return t;const n=o[0],m=o[1]!==!1;return T((r)=>{const f=m?{}:r;for(let G in r)f[G]=n(r[G]);return f})};var Kn=(o)=>o;var Mt=function(...o){const t=ko(Mt,o,No);if(t)return t;const{key:n=Kn,mergeOnly:m=!1,reset:r=!0,all:f=!0,backPressure:G=0}=o[1],E=_(o[0])?new Set(o[0]):o[0],N=new Set,L=new Map;let B={};const h=([O,A,U])=>{let p=!0;if(m||G<1)return[O,(F)=>{if(r&&f&&N.size>0||!r&&p)F=U(F,B),B={},N.clear(),p=!1;return A(F)},(F,l)=>{const S=n(l);if(E.has(S)){if(B[S]=l,N.add(S),m||Vn(E,N))if(F=U(F,B),p=!1,r)B={},N.clear();else B={...B}}return F}];else return[O,(F)=>{if(f&&N.size>0)F=U(F,qn(L,N)),L.clear(),N.clear();return A(F)},(F,l)=>{const S=n(l);if(E.has(S)){let q=L.get(S);!q&&L.set(S,q=[]),q.length>=G&&mo(`max back pressure (${G}) exceeded for input: ${String(S)}`),q.push(l),N.add(S);while(Vn(E,N))if(F=U(F,qn(L,N)),p=!1,M(F))break}return F}]};return h.keys=()=>E,h.clear=()=>{L.clear(),E.clear(),N.clear(),B={}},h.add=(O)=>{E.add(O)},h.delete=(O,A=!0)=>{if(L.delete(O),E.delete(O),A)N.delete(O),delete B[O]},h},Vn=(o,t)=>{if(t.size<o.size)return!1;for(let n of o)if(!t.has(n))return!1;return!0},qn=(o,t)=>{const n={};for(let m of t){const r=o.get(m);n[m]=r.shift(),!r.length&&t.delete(m)}return n};var Qn=(o,t)=>{let n=!0;for(let m of t)n=o.removeID(m)&&n;return n};var eo=(o)=>new un(o);class un extends b{sources;idSources;realSourceIDs;invRealSourceIDs;psync;clean;constructor(o){const t=Mt(new Set,{key:(m)=>m[0],mergeOnly:o.mergeOnly===!0,reset:o.reset===!0,all:o.all!==!1,backPressure:o.backPressure||0}),n=Wt((m)=>m[1]);super(void 0,x("streamsync",{...o,xform:o.xform?Z(t,n,o.xform):Z(t,n)}));this.sources=new Map,this.realSourceIDs=new Map,this.invRealSourceIDs=new Map,this.idSources=new Map,this.psync=t,this.clean=!!o.clean,o.src&&this.addAll(o.src)}add(o,t){t||(t=o.id),this.ensureState(),this.psync.add(t),this.realSourceIDs.set(t,o.id),this.invRealSourceIDs.set(o.id,t),this.idSources.set(o.id,o),this.sources.set(o,o.subscribe({next:(n)=>n[1]instanceof b?this.add(n[1]):this.next(n),done:()=>this.markDone(o),__owner:this},{xform:wt(t),id:`in-${t}`}))}addAll(o){for(let t in o)this.psync.add(t);for(let t in o)this.add(o[t],t)}remove(o){const t=this.sources.get(o);if(t){const n=this.invRealSourceIDs.get(o.id);return Y.info(`removing src: ${o.id} (${n})`),this.psync.delete(n,this.clean),this.realSourceIDs.delete(n),this.invRealSourceIDs.delete(o.id),this.idSources.delete(o.id),this.sources.delete(o),t.unsubscribe(),!0}return!1}removeID(o){const t=this.getSourceForID(o);return t?this.remove(t):!1}removeAll(o){for(let n of o)this.psync.delete(this.invRealSourceIDs.get(n.id));let t=!0;for(let n of o)t=this.remove(n)&&t;return t}removeAllIDs(o){return Qn(this,o)}getSourceForID(o){return this.idSources.get(this.realSourceIDs.get(o))}getSources(){const o={};for(let[t,n]of this.idSources)o[this.invRealSourceIDs.get(t)]=n;return o}unsubscribe(o){if(!o){Y.debug(this.id,"unsub sources");for(let t of this.sources.values())t.unsubscribe();this.sources.clear(),this.psync.clear(),this.realSourceIDs.clear(),this.invRealSourceIDs.clear(),this.idSources.clear()}return super.unsubscribe(o)}markDone(o){this.remove(o),Dn(this.closeIn,this.sources.size)&&this.done()}}var Yt=z((o,t=" ")=>{const n=oo(String(t),o);return(m,r)=>{if(m==null)return n;return m=m.toString(),r=r!==void 0?r:m.length,r<o?n.substring(r)+m:m}}),iN=Yt(2,"0"),vN=Yt(3,"0"),bn=Yt(4,"0");var Gr=/\{(\d+)\}/g;var St=(o,...t)=>t.length>0?o.replace(Gr,(n,m)=>String(t[parseInt(m,10)])):o;var kn=(o)=>({key:(t)=>t,group:Go(),...o});var Rt=function(...o){const t=En(Rt,o);if(t)return t;const n=kn(o[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 Ut=function(o,t){return I(t)?e(Ut(o),t):(n)=>{const m=n[2];return u(n,(r,f)=>o(f)?m(r,f):r)}};import{watch as en} from"fs";import{resolve as a} from"path";var vn={specs:P({alias:"s",optional:!1,desc:"Path to generated JSON defs"})},go={bundle:J({alias:"b",desc:"Bundle inputs (see `out` option)"})},Oo={include:zo({alias:"I",desc:"Include CSS files (prepend)"})},xo={eval:P({alias:"e",desc:"eval meta stylesheet in given string (ignores other inputs & includes)"})},ao={force:zo({alias:"f",hint:"STR",desc:"CSS classes to force include (wildcards are supported, @-prefix will read from file)",delim:","})},pn={media:zo({alias:"m",hint:"ID",desc:"Media query IDs (use 'ALL' for all)",delim:","})},ln={onlyDecls:J({desc:"Only emit framework decls"})},k={out:P({alias:"o",desc:"Output file (or stdout)"})},so={prec:Xo({default:3,desc:"Number of fractional digits"})},i={pretty:J({alias:"p",desc:"Pretty print output"})},ho={noDecls:J({alias:"d",desc:"Don't emit framework decls"})},Co={noHeader:J({desc:"Don't emit generated header comment"})},Ao={scope:P({desc:"Suffix for CSS class names"})},Fo={watch:J({alias:"w",desc:"Watch input files for changes"})};import{watch as Nr} from"fs";import{resolve as dn} from"path";var v=(o,t,n)=>{t=$(t)?t:t.join("\n"),o?Bt(dn(o),t,n):process.stdout.write(t+"\n")},co=({info:{name:o,version:t}})=>`/*! ${o} v${t} - generated by thi.ng/meta-css @ ${(new Date()).toISOString()} */`,Yo=(o,t)=>{const n=()=>{t.info("closing watchers..."),m.forEach((r)=>r.watcher.close())},m=o.map((r,f)=>{r=dn(r);const G=yn(W(r,t),{id:`in${bn(f)}`});return{input:G,watcher:Nr(r,{},(E)=>{if(E==="change")try{G.next(W(r,t))}catch(N){t.warn(N.message),n()}else t.warn("input removed:",r),n()})}});return process.on("SIGINT",n),eo({src:_t(T(({input:r})=>[r.id,r],m))})},ot=(o)=>Object.keys(o).reduce((t,n)=>{if(!n.startsWith("__"))t[n]=o[n];return t},{});async function zt(o){const t=V(a(o.opts.specs),o.logger),n=Cr(t,o.opts.force||[],o.logger);if(o.opts.bundle)if(o.opts.watch)await Br(o,n);else So(o,t,n,o.opts.eval?[o.opts.eval]:o.inputs.map((m)=>W(a(m),o.logger)),o.opts.out);else if(o.opts.watch)await Lr(o,t,n);else if(o.opts.eval)try{So(o,t,n,[o.opts.eval])}catch(m){o.logger.warn(m.message)}else for(let m of o.inputs)try{m=a(m);const r=!o.opts.noWrite?m.replace(/\.mcss$/,".css"):void 0;So(o,t,n,[W(m,o.logger)],r)}catch(r){o.logger.warn(r.message)}}function*Fr(o){let t=-1,n=o.length,m=0,r=0;for(let f=0;f<n;f++){const G=o[f];if(G===" "||G==="\t"){if(!(m||r)&&t>=0)yield o.substring(t,f),t=-1}else if(G==="{"||G==="}"){if(t>=0)yield o.substring(t,f);yield G,t=-1}else if(G==="(")m++;else if(G===")"){if(--m<0)C(`invalid nesting in line: '${o}'`)}else if(G==="[")r++;else if(G==="]"){if(--r<0)C(`invalid arg nesting in line: '${o}'`)}else if(t<0)t=f}if(m)C("template calls must be fully on a single line");if(r)C("verbatim properties must be fully on a single line");if(t>=0)yield o.substring(t,n)}var xn={desc:"Transpile (and optionally bundle) meta stylesheets to CSS",opts:{...go,...xo,...ao,...Oo,...ho,...Co,...k,...i,...Ao,...vn,...Fo,noWrite:J({desc:"Don't write files, use stdout only"})},fn:zt},Lr=async(o,t,n)=>{const m=a(o.opts.specs);let r,f={process:()=>{try{return t=V(m,o.logger),r.forEach((E)=>E.process()),!0}catch(E){return o.logger.warn(E.message+": "+m),!1}},watcher:en(m,{},(E)=>{if(E==="change")f.process();else o.logger.warn("specs file removed:",m),G()})};const G=()=>{o.logger.info("closing watchers..."),f.watcher.close(),r.forEach((E)=>E.watcher.close())};r=o.inputs.map((E)=>{E=a(E);const N=!o.opts.noWrite?E.replace(/\.mcss$/,".css"):void 0,L=()=>{try{return So(o,t,n,[W(E,o.logger)],N),!0}catch(B){if(o.logger.warn(B.message+": "+E),r)G();return!1}};if(!L())process.exit(1);return{process:L,watcher:en(E,{},(B)=>{if(B==="change")L();else o.logger.warn("input removed:",E),G()})}}),o.logger.info("waiting for changes, press ctrl+c to cancel..."),process.on("SIGINT",G)},Br=async(o,t)=>{eo({src:{styles:Yo(o.inputs,o.logger),specs:Yo([o.opts.specs],o.logger).map((n)=>JSON.parse(Object.values(n)[0]))}}).subscribe({next({styles:n,specs:m}){try{So(o,m,t,Object.keys(n).sort().map((r)=>n[r]),o.opts.out)}catch(r){o.logger.warn(r.message)}}})},So=({logger:o,opts:{include:t,noDecls:n,noHeader:m,pretty:r,scope:f}},G,E,N,L)=>{const B={logger:o,specs:G,css:{format:r?bo:ro,fns:lo,scope:f},mediaQueryIDs:new Set(Object.keys(G.media)),mediaQueryRules:{...E.mediaQueryRules},plainRules:{...E.plainRules}},h=t?t.map((O)=>W(a(O),o).trim()):[];if(!m)h.push(co(G));if(!n&&G.decls.length)h.push(g(G.decls,B.css));N.forEach((O)=>Ar(O,B)),hr(h,B),Or(h,B),v(L,h,o)},Or=(o,{css:t,logger:n,mediaQueryRules:m,specs:r})=>{for(let f in m){const G=sn(m[f],r);n.debug("mediaquery rules",f,G),o.push(g(Bo(Hr(r.media,f),G),t))}},hr=(o,{css:t,logger:n,plainRules:m,specs:r})=>{const f=sn(m,r);n.debug("plain rules",f),o.push(g(f,t))},Cr=(o,t,n)=>{const m=new Set(Object.keys(o.media)),r=new Set(Object.keys(o.classes)),f={},G={};if(t.length&&t[0][0]==="@")t=[...to(W(a(t[0].substring(1)),n))];for(let E of t){if(!E||E.startsWith("//"))continue;const{token:N,query:L}=cn(E,m);let B;if(N.includes("*")){const h=new RegExp(`^${N.replace("*",".*")}\$`);B=[...Ut((O)=>h.test(O),r)]}else if(r.has(N))B=[N];else{n.warn(`unknown include rule ID: ${E}, skipping...`);continue}for(let h of B)n.debug("including class:",h),L?om(f,L,`.${h}`,h):tm(G,`.${h}`,h)}return{mediaQueryRules:f,plainRules:G}},Ar=(o,{specs:t,mediaQueryIDs:n,mediaQueryRules:m,plainRules:r})=>{const f=Ro(),G=Ro(f),E={root:f,curr:G,scopes:[G]};for(let N of to(o)){if(!N||/^\s*\/\//.test(N))continue;for(let L of Fr(N)){if(!L)continue;let B=E.curr;switch(B.state){case"sel":case"nest":if(L==="{"){if(B.state==="sel")B.sel=B.sel.map((h)=>h.replace(",","")),B.path=Tr(E.scopes);B.state="class"}else if(L==="}")gn(E);else{const h=wo(B.sel);if(!h||h.endsWith(","))B.sel.push(L);else B.sel[B.sel.length-1]+=" "+L}break;case"class":if(L==="{")B.state="nest",E.scopes.push(E.curr=Ro(B));else if(L==="}")gn(E);else{let{token:h,query:O}=cn(L,n);if(!t.classes[h]&&!(nm(h)||rm(h)||mm(h)))C(`unknown class ID: ${h}`);if(O)om(m,O,B.path,h);else tm(r,B.path,h)}break;default:mo(B.state)}}}},Jt=":",an="///",Ro=(o)=>({state:"sel",sel:o?[]:["<root>"],path:"",parent:o}),gn=(o)=>{const t=!o.curr.sel.length;if(Vo(!!o.curr.parent,"stack underflow"),o.scopes.pop(),o.scopes.length>0){if(o.curr=wo(o.scopes),!t&&o.curr.state==="nest")o.scopes.push(o.curr=Ro(o.curr))}else o.scopes.push(o.curr=Ro(o.root))},Tr=(o)=>o.map((t)=>t.sel.join(",")).join(an),sn=(o,t)=>Object.entries(o).map(([n,m])=>$r(n,m,t)),$r=(o,t,n)=>{const m=[];let r=m;const f=o.split(an);for(let G=0;G<f.length;G++){const E=f[G].split(",");if(G==f.length-1){const N=Object.assign({},...T((L)=>rm(L)?wr(L):nm(L)?_r(L):mm(L)?Ir(n,L):ot(n.classes[L]),t));E.push(N)}r.push(E),r=E}return m[0]},cn=(o,t)=>{if(/^::?/.test(o))return{token:o};const n=o.lastIndexOf(Jt);if(n<0)return{token:o};const m=o.substring(0,n);if(!m.split(Jt).every((f)=>t.has(f)))C(`invalid media query in token: ${o}`);return{token:o.substring(n+1),query:m}},Hr=(o,t)=>t.split(Jt).reduce((n,m)=>Object.assign(n,o[m]),{}),om=(o,t,n,m)=>{if(!o[t])o[t]={};(o[t][n]||(o[t][n]=new Set)).add(m)},tm=(o,t,n)=>(o[t]||(o[t]=new Set)).add(n),_r=(o)=>{const t=o.indexOf("=");return{[`--${o.substring(0,t)}`]:o.substring(t+1)}},Ir=(o,t)=>{const n=t.indexOf("("),m=t.substring(0,n),r=t.substring(n+1,t.length-1).split(/(?<!\\),/g).map((G)=>G.trim().replace("\\,",",")),f=o.templates[m];if(!f)C(`unknown template: ${m}`);if(r.length!==f.__arity)C(`template "${m}" expected ${f.__arity} arguments`);return Object.entries(f).reduce((G,[E,N])=>{if(!E.startsWith("__")){if(E=St(E,...r),$(N))N=St(N,...r);G[E]=N}return G},{})},wr=(o)=>{const[t,n,m]=/^(.+)-\[(.+)\]/.exec(o);return{[n]:m}},nm=(o)=>o.includes("="),mm=(o)=>o.includes("("),rm=(o)=>o.includes("[");async function Xt(o){if(o.opts.watch)await Yr(o);else await Nm(o.inputs.map((t)=>W(t,o.logger)),o.opts,o.logger)}var Em={deg:Jn,em:Hn,ex:_n,ms:Rn,percent:Ht,px:wn,rad:zn,rem:In,second:Un,turn:Xn,url:Pn,vh:Wn,vmax:Sn,vmin:Yn,vw:Mn,"%":Ht},Wr={percent:"{0}%",second:"{0}s",url:"url({0})"},Mr={"":[""],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:[""]},Gm={desc:"Generate framework rules from specs",opts:{...k,...so,...i,...Fo},fn:Xt},Yr=async(o)=>{Yo(o.inputs,o.logger).subscribe({next(t){try{Nm(Object.keys(t).sort().map((n)=>t[n]),o.opts,o.logger)}catch(n){o.logger.warn(n.message)}}})},Nm=async(o,t,n)=>{const m={info:{name:"TODO",version:"0.0.0"},media:{},classes:{},templates:{},decls:[]};$n(t.prec);for(let r of o){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{Lm(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)Sr(f,G,m.templates,n)}return v(t.out,JSON.stringify(m,null,t.pretty?4:0),n),m},Lm=(o,t,n,m,r=!1)=>{const f=_(t.vars)?t.vars:[""],G=$(t.props)?{[t.props]:"<v>"}:t.props,E=Rr(t,o),N=new Set;for(let L of f){const B=o.vars?.[L]||Mr[L];if(!B)C(`unknown variation ID: ${L}`);for(let[h,O]of io(B,Object.keys(E))){const A=s(t.name,L,h,O,E[O]),U=t.unit?s(t.unit,L,h,O,E[O]):void 0,p=r?Jr(U):Ur(E[O],U);if(!n[A]){if(n[A]={},t.user!=null)n[A].__user=t.user;if(t.doc!=null)n[A].__doc=zr(t.doc,L,h,O,p)}else if(!N.has(A))C(`duplicate class ID: ${A}`);N.add(A);let F=-1;for(let[l,S]of Object.entries(G)){const q=s(l,L,h,O,E[O]),tt=s(!U||$(S)?String(S):Em[U](S),L,h,O,p);if(n[A][q]=tt,m.debug(A,q,tt),r)F=fm(tt,fm(q,F))}if(r)n[A].__arity=F+1}}return n},Sr=(o,t,n,m)=>Lm(o,{...t,values:[""]},n,m,!0),fm=(o,t)=>{const n=/\{(\d+)\}/g;let m;while(m=n.exec(o))t=Math.max(t,+m[1]);return t},Rr=(o,t)=>{const n=$(o.values)?t.tables?.[o.values]||C(`invalid table ID: ${o.values}`):o.values;if(y(n))return n;const m=o.key==="v"?(r)=>String(r):o.key==="i+1"?(r,f)=>String(f+1):o.key===void 0?(r,f)=>String(f):C(`invalid key type: ${o.key}`);return n.reduce((r,f,G)=>{return r[m(f,G)]=f,r},{})},Ur=(o,t)=>{if(!t||$(o))return o;const n=Em[t];if(!n)C(`invalid unit: ${t}`);return n(o)},Jr=(o)=>o?Wr[o]||"{0}"+o:"{0}",s=(o,t,n,m,r)=>o.replace(/<vid>/g,t).replace(/<var>/g,n).replace(/<k>/g,m).replace(/<v>/g,String(r)),zr=({group:o,desc:t,args:n},m,r,f,G)=>({group:o?s(o,m,r,f,G):"TODO",desc:t?s(t,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:{...go,...xo,...ao,...Oo,...ho,...Co,...so,...i,...Ao,...Fo,outCss:P({desc:"Output file for CSS bundle",optional:!1}),outSpecs:P({desc:"Output file for framework",optional:!1})},fn:async(o)=>{const{opts:t,inputs:n}=o,[m,r]=n.reduce((E,N)=>(E[N.endsWith(".json")?0:1].push(N),E),[[],[]]),f={inputs:m,format:o.format,logger:o.logger,opts:{...t,out:t.outSpecs}},G={inputs:r,format:o.format,logger:o.logger,opts:{...t,noWrite:!1,out:t.outCss,scope:t.scope,specs:t.outSpecs}};await Xt(f),await zt(G)}};import{resolve as Xr} from"path";var Cm={desc:"Generate Markdown documentation for framework specs",opts:{...k,level:Xo({alias:"l",desc:"Initial heading level",default:1}),title:P({alias:"t",desc:"Custom main title, set to NONE to disable"})},inputs:1,fn:async(o)=>{const{logger:t,opts:n,inputs:m}=o,r=V(Xr(m[0]),t),f=Pr(r,n);v(n.out,f,t)}},Pr=(o,{level:t,title:n})=>{const m=Object.keys(o.classes).length,r=Object.keys(o.templates).length,f=[`Currently, there are ${m+r} CSS utility classes (incl. ${r} templates) defined in "${o.info.name}" (v${o.info.version}):`,"",`${c(t+1)} Classes by category`,"",...hm(o.classes,Zr,t+2),`${c(t+1)} Templates by category`,"",...hm(o.templates,Dr,t+2),`${c(t+1)} Media queries`,"",...Object.entries(o.media).map(([G,E])=>`- **${G}**: \`${JSON.stringify(E)}\``),""];if(n!=="NONE")f.unshift(`${c(t)} ${n??o.info.name}\n`);return f},Om=(o)=>o.split(/(\d+)/).map((t)=>{const n=parseInt(t);return isNaN(n)?t:n}),yr=(o,t)=>{if(/\d+/.test(o)&&/\d+/.test(t)){const n=Om(o),m=Om(t),r=n.length;if(r===m.length){for(let f=0;f<r;f++)if(n[f]!==m[f])return Ct(n[f],m[f]);return 0}return n.length-m.length}return Ct(o,t)},hm=(o,t,n)=>{const m=Rt({key:([r,{__doc:f}])=>f?.group||"TODO",group:[()=>[],(r)=>r.sort(),(r,f)=>(r.push(f[0]),r)]},Object.entries(o));return It((r)=>{const f=m[r].sort(yr).map((E)=>t(E,o[E].__doc,n+1)),G=f.length;return[`${c(n)} ${jo(r)}`,G>3?`\n<details><summary>${G} items:</summary>\n`:"",f.join("\n"),G>3?"</details>\n":""]},Object.keys(m).sort())},Zr=(o,t)=>{if(!(t&&t.desc))return`- \`${o}\``;let n=t.desc;if(/^-[a-z]/.test(n))n=n.substring(1);return`- \`${o}\` (${n})`},Dr=(o,t,n)=>{if(!(t&&t.args))return`${c(n)} ${o}(...)\n\nTODO`;const m=t.args.map((r)=>/^\w+/.exec(r)[0]).join(", ");return[`${c(n)} \`${o}(${m})\``,"",...t.args.map(jr),t.desc?`\n${t.desc}\n`:""].join("\n")},jr=(o)=>`- ${o.replace(/^(\w+)/,(t,n)=>`**${n}**`)}`,c=z((o)=>"#".repeat(o));import{resolve as Am} from"path";var Tm={desc:"Export entire generated framework as CSS",opts:{...Oo,...ho,...ln,...k,...i,...Co,...pn,...Ao},inputs:1,fn:async(o)=>{const{logger:t,opts:{include:n,media:m,noDecls:r,noHeader:f,onlyDecls:G,out:E,pretty:N,scope:L},inputs:B}=o,h={format:N?bo:ro,fns:lo,scope:L},O=V(Am(B[0]),t),A=n?n.map((U)=>W(Am(U),t).trim()):[];if(!f)A.push(co(O));if(!r&&O.decls.length)A.push(g(O.decls,h));if(!G)A.push(Kr(O,m,h,t));v(E,A,t)}},Kr=(o,t,n,m)=>{const r=Fm("",o);if(t){const f=t[0]==="ALL"?Object.keys(o.media):t;for(let G of f)if(o.media[G])r.push(Bo(o.media[G],Fm("-"+G,o)));else m.warn(`invalid media query ID: ${G}, skipping...`)}return g(r,n)},Fm=(o,t)=>Object.entries(t.classes).map(([n,m])=>[`.${n}${o}`,ot(m)]);var Pt=V(Vr(import.meta.dir,"package.json"));st({name:"metacss",opts:{verbose:J({alias:"v",desc:"Display extra process information"})},commands:{convert:xn,develop:Bm,doc:Cm,export:Tm,generate:Gm},ctx:async(o)=>{if(o.opts.verbose)o.logger.level=H.DEBUG;return{...o,format:Do}},usage:{prefix:`
5
+ `),at(o,m);const N=await o.ctx({logger:new Po(process.stderr,o.name,"INFO"),format:n?Do:bt,opts:E.result,inputs:E.rest},f);if(await f.fn(N),o.post)await o.post(N,f)}catch(r){process.stderr.write(r.message+"\n\n"),process.exit(1)}},at=(o,t)=>{process.stderr.write(Ho(o.opts,t)),process.exit(1)},um=(o)=>["\nAvailable commands:\n",...Object.keys(o).map((t)=>`${yo(16)(t)}: ${o[t].desc}`),"\n"].join("\n");import{existsSync as bm,mkdirSync as km,statSync as OE} from"fs";import{dirname as im} from"path";var vm=(o)=>o.length>0&&!bm(o)?(km(o,{recursive:!0}),!0):!1,ct=(o)=>vm(im(o));var K=(o)=>typeof o==="function";var $=(o)=>typeof o==="string";import{readFileSync as lm} from"fs";import{writeFileSync as pm} from"fs";var on=(o,t,n,m,r=!1)=>{if(m&&m.info(`${r?"[dryrun] ":""}writing file: ${o}`),r)return;ct(o),pm(o,t,!n&&$(t)?"utf-8":n)};var W=(o,t,n="utf-8")=>{return t&&t.debug("reading file:",o),lm(o,n)},Bt=(o,t,n,m=!1)=>on(o,_(t)?t.join("\n"):t,"utf-8",n,m);var V=(o,t)=>JSON.parse(W(o,t));var Q=Symbol(),Ot=()=>{};var Io=Object.freeze({level:H.NONE,addChild(o){return o},childLogger:()=>Io,enabled:()=>!1,fine(){},debug(){},info(){},warn(){},severe(){},logEntry(){}});class ht extends $o{set(o){this.parent=o}childLogger(o,t){return new ht(o,t??this.level,this)}logEntry(o){this.parent.logEntry(o)}}var tn=new ht("root",H.FINE,Io);import{join as Vr} from"path";var Ct=(o,t)=>{if(o===t)return 0;if(o==null)return t==null?0:-1;if(t==null)return o==null?0:1;if(typeof o.compare==="function")return o.compare(t);if(typeof t.compare==="function")return-t.compare(o);return o<t?-1:o>t?1:0};var dm=X(()=>"Assertion failed"),Vo=(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)?(o,t)=>{if(typeof o==="function"&&!o()||!o)throw new dm(typeof t==="function"?t():t)}:()=>{};var qo=(o)=>o!=null&&typeof o!=="function"&&o.length!==void 0;var nn=(o)=>{return(o==null||!o[Symbol.iterator])&&C(`value is not iterable: ${o}`),o};var mn=(o)=>qo(o)?o:[...nn(o)];var wo=(o)=>o[o.length-1];var Qo=(o,t)=>o!=null&&typeof o[t]==="function";var I=(o)=>o!=null&&typeof o[Symbol.iterator]==="function";var uo=(o)=>o!=null&&typeof o!=="string"&&typeof o[Symbol.iterator]==="function";var em=X(()=>"illegal arity"),no=(o)=>{throw new em(o)};var gm=X(()=>"illegal state"),mo=(o)=>{throw new gm(o)};var rn=["-moz-","-ms-","-o-","-webkit-"],ro={rules:"",ruleSep:",",valSep:"",decls:"",declStart:"{",declEnd:"}",indent:"",comments:!1},bo={rules:"\n",ruleSep:", ",valSep:" ",decls:"\n",declStart:" {\n",declEnd:"}\n",indent:" ",comments:!0};var At=function(...o){let[t,n,m,r,f,G,E,N,L,B]=o;switch(o.length){case 0:no(0);case 1:return t;case 2:return(...O)=>t(n(...O));case 3:return(...O)=>t(n(m(...O)));case 4:return(...O)=>t(n(m(r(...O))));case 5:return(...O)=>t(n(m(r(f(...O)))));case 6:return(...O)=>t(n(m(r(f(G(...O))))));case 7:return(...O)=>t(n(m(r(f(G(E(...O)))))));case 8:return(...O)=>t(n(m(r(f(G(E(N(...O))))))));case 9:return(...O)=>t(n(m(r(f(G(E(N(L(...O)))))))));case 10:default:const h=(...O)=>t(n(m(r(f(G(E(N(L(B(...O))))))))));return o.length===10?h:At(h,...o.slice(10))}};var d=(o)=>Qo(o,"xform")?o.xform():o;var Z=function(...o){return o=o.map(d),At.apply(null,o)};var u=(o,t)=>[o[0],o[1],t];class Wo{value;constructor(o){this.value=o}deref(){return this.value}}var M=(o)=>o instanceof Wo,fn=(o)=>o instanceof Wo?o:new Wo(o),D=(o)=>o instanceof Wo?o.deref():o;var fo=function(...o){const t=o[0],n=t[0],m=t[1],r=t[2];o=xm(o);const f=o[0]==null?n():o[0],G=o[1];return D(m(Qo(G,"$reduce")?G.$reduce(r,f):qo(G)?am(r,f,G):sm(r,f,G)))};var xm=(o)=>o.length===2?[void 0,o[1]]:o.length===3?[o[1],o[2]]:no(o.length),am=(o,t,n)=>{for(let m=0,r=n.length;m<r;m++)if(t=o(t,n[m]),M(t)){t=t.deref();break}return t},sm=(o,t,n)=>{for(let m of n)if(t=o(t,m),M(t)){t=t.deref();break}return t},Eo=(o,t)=>[o,To,t],En=(o,t)=>{const n=t.length-1;return I(t[n])?t.length>1?fo(o.apply(null,t.slice(0,n)),t[n]):fo(o(),t[0]):void 0};var Go=function(o){return o?[...o]:Eo(()=>[],(t,n)=>(t.push(n),t))};function*No(o,t){const n=d(o)(Go()),m=n[1],r=n[2];for(let f of t){const G=r([],f);if(M(G)){yield*D(m(G.deref()));return}if(G.length)yield*G}yield*D(m([]))}function*e(o,t){const n=d(o)([Ot,Ot,(m,r)=>r])[2];for(let m of t){let r=n(Q,m);if(M(r)){if(r=D(r.deref()),r!==Q)yield r;return}if(r!==Q)yield r}}var ko=(o,t,n=e)=>{const m=t.length-1;return I(t[m])?t.length>1?n(o.apply(null,t.slice(0,m)),t[m]):n(o(),t[0]):void 0};var Ft=function(o,t){return I(t)?No(Ft(o),$(t)?[t]:t):(n)=>{const m=n[2],r=(f,G)=>{const E=o(G);if(E){for(let N of E)if(f=r(f,N),M(f))break;return f}return m(f,G)};return u(n,r)}};var Gn=function(o){return Ft((t)=>uo(t)?t:void 0,o)};var T=function(o,t){return I(t)?e(T(o),t):(n)=>{const m=n[2];return u(n,(r,f)=>m(r,o(f)))}};function*io(...o){const t=o.length-1;if(t<0)return;const n=new Array(t+1).fill(0),m=o.map(mn),r=m.reduce((f,G)=>f*G.length,1);for(let f=0;f<r;f++){const G=[];for(let E=t;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[t]++,yield G}}function*Nn(o,t=1/0){while(t-- >0)yield o}var Tt=function(o,t){o=o||"";let n=!0;return t?[...t].join(o):Eo(()=>"",(m,r)=>(m=n?m+r:m+o+r,n=!1,m))};var vo=function(...o){return cm(vo,fo,o)};var cm=(o,t,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)=>o(n[0],n[1],f));default:no(n.length)}return t(d(n[0])(n[1]),m,r)};var or=new Set,tr=":[",Ln=Z(Gn(),T((o)=>o[0]==="&"?o.substring(1):tr.includes(o[0])?o:" "+o)),nr=(o,t)=>Z(o,T((n)=>$(n)&&n.startsWith(" .")?n+t:n)),Lo=(o,t,n,m)=>{const r=n.length,f=[];let G,E;const N=(L,B)=>{let h=null;if(_(B))Lo(o,$t(t,f),B,m);else if(I(B)&&!$(B))Lo(o,$t(t,f),[...B],m);else if((E=K(B))||(h=m.fns[B]))if(!t.length){if(h)return h.apply(null,n.slice(L+1))(o,m),!0;B(o,m)}else if(E)N(L,B());else C(`quoted fn ('${B}') only allowed at head position`);else if(y(B))G=Object.assign(G||{},B);else if(B!=null)f.push(B)};for(let L=0;L<r;L++)if(N(L,n[L]))return o;return G&&o.push(mr(t,f,G,m)),o},$t=(o,t)=>o.length?[...io(o,t)]:t,mr=(o,t,n,m)=>{const r=m.format,f=j(m),G=m.scope?nr(Ln,m.scope):Ln;return[f,vo(T((E)=>vo(G,Tt(),_(E)?E:[E]).trim()),Tt(r.ruleSep),$t(o,t)),r.declStart,Mo(n,m),f,r.declEnd].join("")},Mo=(o,t)=>{const n=t.format,m=t.autoprefix||or,r=j(t,t.depth+1),f=[];for(let G in o)if(o.hasOwnProperty(G)){let E=o[G];if(K(E))E=E(o);if(_(E))E=E.map((N)=>_(N)?N.join(" "):N).join(n.ruleSep);if(m.has(G))for(let N of t.vendors)f.push(`${r}${N}${G}:${n.valSep}${E};`);f.push(`${r}${G}:${n.valSep}${E};`)}return f.join(n.decls)+n.decls},j=(o,t=o.depth)=>t>1?[...Nn(o.format.indent,t)].join(""):t>0?o.format.indent:"";var Bn=function(o,...t){const n=t.length===1?t[0]:t.reduce((m,r,f)=>{return m[f/(t.length-1)*100|0]=r,m},{});return(m,r)=>{const f=j(r);r.depth++;const G=j(r);m.push(`${f}@keyframes ${o}${r.format.declStart}`);for(let E in n)if(n.hasOwnProperty(E))m.push([G,E+"%",r.format.declStart,Mo(n[E],r),G,r.format.declEnd].join(""));return r.depth--,m.push(f+r.format.declEnd),m}};var On=(o,t=!1)=>(n,m)=>{const r=j(m),f=j(m,m.depth+1);if(m.format.comments||t)n.push(r+"/*",o.split("\n").map((G)=>f+G).join("\n"),r+"*/");return n};var po=(o,t,n)=>(m,r)=>{const f=j(r);return m.push(`${f}${o} ${rr(t)}${r.format.declStart}`),r.depth++,Lo(m,[],n,r),r.depth--,m.push(f+r.format.declEnd),m},rr=(o)=>{if($(o))return o;const t=[];for(let n in o)if(o.hasOwnProperty(n)){let m=o[n];if(m===!0)m=hn.has(n)?n:`(${n})`;else if(m===!1)m=`(not ${hn.has(n)?n:`(${n})`})`;else if(m==="only")m+=" "+n;else m=`(${n}:${m})`;t.push(m)}return t.join(" and ")},hn=new Set(["all","print","screen"]);var g=(o,t)=>{return t={format:ro,vendors:rn,fns:{},depth:0,...t},_(t.autoprefix)&&(t.autoprefix=new Set(t.autoprefix)),y(o)?Mo(o,t):K(o)?o([],t).join(t.format.rules):Lo([],[],_(o)?o:uo(o)?[...o]:C("invalid rules"),t).join(t.format.rules)};var Cn=(o,...t)=>(n,m)=>(n.push(t.length?`@import url(${o}) ${t.join(m.format.ruleSep)};`:`@import url(${o});`),n);var Bo=(o,t)=>po("@media",o,t);var An=function(...o){return(t,n)=>(t.push(o.length>1?`@namespace ${o[0]} url(${o[1]});`:`@namespace url(${o[0]});`),t)};var Fn=(o,t)=>po("@supports",o,t);var lo={"@comment":On,"@import":Cn,"@keyframes":Bn,"@media":Bo,"@namespace":An,"@supports":Fn};var Tn=4,$n=(o)=>Tn=o,R=(o)=>o===(o|0)?String(o):o.toFixed(Tn).replace(/^0./,".").replace(/^-0./,"-.").replace(/0+$/,"");var Hn=(o)=>`${R(o)}em`,_n=(o)=>`${R(o)}ex`;var In=(o)=>`${R(o)}rem`,Ht=(o)=>`${R(o)}%`,wn=(o)=>`${R(o)}px`,Wn=(o)=>`${R(o)}vh`,Mn=(o)=>`${R(o)}vw`,Yn=(o)=>`${R(o)}vmin`,Sn=(o)=>`${R(o)}vmax`,Rn=(o)=>`${o|0}ms`,Un=(o)=>`${R(o)}s`;var Jn=(o)=>`${R(o)}deg`,zn=(o)=>`${R(o)}rad`,Xn=(o)=>`${R(o)}turn`,Pn=(o)=>`url(${o})`;var w=((o)=>{return o[o.IDLE=0]="IDLE",o[o.ACTIVE=1]="ACTIVE",o[o.DONE=2]="DONE",o[o.UNSUBSCRIBED=3]="UNSUBSCRIBED",o[o.ERROR=4]="ERROR",o})(w||{});var fr=0,Er=()=>fr++,x=(o,t)=>!t||!t.id?{...t,id:o+"-"+Er()}:t;var Y=tn.childLogger("rstream");class b{constructor(o,t){this.wrapped=o,t=x("sub",{closeIn:"last",closeOut:"last",cache:!0,...t}),this.parent=t.parent,this.id=t.id,this.closeIn=t.closeIn,this.closeOut=t.closeOut,this.cacheLast=t.cache,t.xform&&(this.xform=t.xform(Go()))}id;closeIn;closeOut;parent;__owner;xform;cacheLast;last=Q;state=w.IDLE;subs=[];deref(){return this.last!==Q?this.last:void 0}getState(){return this.state}setState(o){this.state=o}subscribe(o,t={}){this.ensureState();let n;if(o instanceof b&&!t.xform)o.ensureState(),Vo(!o.parent,`sub '${o.id}' already has a parent`),o.parent=this,n=o;else n=new b(o,{...t,parent:this});return this.subs.push(n),this.setState(w.ACTIVE),n.setState(w.ACTIVE),this.last!=Q&&n.next(this.last),n}transform(...o){let t,n;if(y(wo(o)))n=o.pop(),t={error:n.error};return this.subscribe(t,x("xform",o.length>0?{...n,xform:Z(...o)}:n))}map(o,t){return this.transform(T(o),t||{})}unsubscribe(o){return o?this.unsubscribeChild(o):this.unsubscribeSelf()}unsubscribeSelf(){return Y.debug(this.id,"unsub self"),this.parent&&this.parent.unsubscribe(this),this.state<w.UNSUBSCRIBED&&(this.state=w.UNSUBSCRIBED),this.release(),!0}unsubscribeChild(o){Y.debug(this.id,"unsub child",o.id);const t=this.subs.indexOf(o);if(t>=0){if(this.subs.splice(t,1),this.closeOut==="first"||!this.subs.length&&this.closeOut!=="never")this.unsubscribe();return!0}return!1}next(o){if(this.state>=w.DONE)return;this.xform?this.dispatchXform(o):this.dispatch(o)}done(){if(Y.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();Y.debug(this.id,"exiting done()")}error(o){const t=this.wrapped,n=t&&t.error;return n&&Y.debug(this.id,"attempting wrapped error handler"),n&&t.error(o)||this.unhandledError(o)}unhandledError(o){return(Y.parent!==Io?Y:console).warn(this.id,"unhandled error:",o),this.unsubscribe(),this.state=w.ERROR,!1}dispatchTo(o,t){let n=this.wrapped;if(n)try{n[o]&&n[o](t)}catch(r){if(!this.error(r))return!1}const m=o==="next"?this.subs:[...this.subs];for(let r=m.length;r-- >0;){n=m[r];try{n[o]&&n[o](t)}catch(f){if(o==="error"||!n.error||!n.error(f))return this.unhandledError(f)}}return!0}dispatch(o){Y.debug(this.id,"dispatch",o),this.cacheLast&&(this.last=o),this.dispatchTo("next",o)}dispatchXform(o){let t;try{t=this.xform[2]([],o)}catch(n){this.error(n);return}if(this.dispatchXformVals(t))M(t)&&this.done()}dispatchXformDone(){let o;try{o=this.xform[1]([])}catch(t){return this.error(t)}return this.dispatchXformVals(o)}dispatchXformVals(o){const t=D(o);for(let n=0,m=t.length;n<m&&this.state<w.DONE;n++)this.dispatch(t[n]);return this.state<w.ERROR}ensureState(){if(this.state>=w.DONE)mo(`operation not allowed in state ${w[this.state]}`)}release(){this.subs.length=0,delete this.parent,delete this.xform,delete this.last}}var yn=(o,t)=>{const n=new Zn(t);return n.next(o),n};class Zn extends b{src;_cancel;_inited;constructor(o,t){const[n,m]=K(o)?[o,t||{}]:[void 0,o||{}];super(m.error?{error:m.error}:void 0,x("stream",m));this.src=n,this._inited=!1}subscribe(o,t={}){const n=super.subscribe(o,t);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(o){const t=super.unsubscribe(o);if(t&&(!o||(!this.subs||!this.subs.length)&&this.closeOut!=="never"))this.cancel();return t}done(){this.cancel(),super.done(),delete this.src,delete this._cancel}error(o){if(super.error(o))return!0;return this.cancel(),!1}cancel(){if(this._cancel){Y.debug(this.id,"cancel");const o=this._cancel;delete this._cancel,o()}}}var Dn=(o,t)=>o==="first"||o==="last"&&!t;var _t=function(o){return o?fo(_t(),o):Eo(()=>({}),(t,[n,m])=>(t[n]=m,t))};var jn=()=>(o)=>{const t=o[2];return u(o,(n,m)=>{if(m){for(let r of D(m)||[])if(n=t(n,r),M(n))break}return M(m)?fn(n):n})};var It=function(o,t){return I(t)?No(It(o),t):Z(T(o),jn())};var wt=function(o,t){return I(t)?e(wt(o),t):T(K(o)?(n)=>[o(n),n]:(n)=>[o,n])};var Wt=function(...o){const t=ko(Wt,o);if(t)return t;const n=o[0],m=o[1]!==!1;return T((r)=>{const f=m?{}:r;for(let G in r)f[G]=n(r[G]);return f})};var Kn=(o)=>o;var Mt=function(...o){const t=ko(Mt,o,No);if(t)return t;const{key:n=Kn,mergeOnly:m=!1,reset:r=!0,all:f=!0,backPressure:G=0}=o[1],E=_(o[0])?new Set(o[0]):o[0],N=new Set,L=new Map;let B={};const h=([O,A,U])=>{let p=!0;if(m||G<1)return[O,(F)=>{if(r&&f&&N.size>0||!r&&p)F=U(F,B),B={},N.clear(),p=!1;return A(F)},(F,l)=>{const S=n(l);if(E.has(S)){if(B[S]=l,N.add(S),m||Vn(E,N))if(F=U(F,B),p=!1,r)B={},N.clear();else B={...B}}return F}];else return[O,(F)=>{if(f&&N.size>0)F=U(F,qn(L,N)),L.clear(),N.clear();return A(F)},(F,l)=>{const S=n(l);if(E.has(S)){let q=L.get(S);!q&&L.set(S,q=[]),q.length>=G&&mo(`max back pressure (${G}) exceeded for input: ${String(S)}`),q.push(l),N.add(S);while(Vn(E,N))if(F=U(F,qn(L,N)),p=!1,M(F))break}return F}]};return h.keys=()=>E,h.clear=()=>{L.clear(),E.clear(),N.clear(),B={}},h.add=(O)=>{E.add(O)},h.delete=(O,A=!0)=>{if(L.delete(O),E.delete(O),A)N.delete(O),delete B[O]},h},Vn=(o,t)=>{if(t.size<o.size)return!1;for(let n of o)if(!t.has(n))return!1;return!0},qn=(o,t)=>{const n={};for(let m of t){const r=o.get(m);n[m]=r.shift(),!r.length&&t.delete(m)}return n};var Qn=(o,t)=>{let n=!0;for(let m of t)n=o.removeID(m)&&n;return n};var eo=(o)=>new un(o);class un extends b{sources;idSources;realSourceIDs;invRealSourceIDs;psync;clean;constructor(o){const t=Mt(new Set,{key:(m)=>m[0],mergeOnly:o.mergeOnly===!0,reset:o.reset===!0,all:o.all!==!1,backPressure:o.backPressure||0}),n=Wt((m)=>m[1]);super(void 0,x("streamsync",{...o,xform:o.xform?Z(t,n,o.xform):Z(t,n)}));this.sources=new Map,this.realSourceIDs=new Map,this.invRealSourceIDs=new Map,this.idSources=new Map,this.psync=t,this.clean=!!o.clean,o.src&&this.addAll(o.src)}add(o,t){t||(t=o.id),this.ensureState(),this.psync.add(t),this.realSourceIDs.set(t,o.id),this.invRealSourceIDs.set(o.id,t),this.idSources.set(o.id,o),this.sources.set(o,o.subscribe({next:(n)=>n[1]instanceof b?this.add(n[1]):this.next(n),done:()=>this.markDone(o),__owner:this},{xform:wt(t),id:`in-${t}`}))}addAll(o){for(let t in o)this.psync.add(t);for(let t in o)this.add(o[t],t)}remove(o){const t=this.sources.get(o);if(t){const n=this.invRealSourceIDs.get(o.id);return Y.info(`removing src: ${o.id} (${n})`),this.psync.delete(n,this.clean),this.realSourceIDs.delete(n),this.invRealSourceIDs.delete(o.id),this.idSources.delete(o.id),this.sources.delete(o),t.unsubscribe(),!0}return!1}removeID(o){const t=this.getSourceForID(o);return t?this.remove(t):!1}removeAll(o){for(let n of o)this.psync.delete(this.invRealSourceIDs.get(n.id));let t=!0;for(let n of o)t=this.remove(n)&&t;return t}removeAllIDs(o){return Qn(this,o)}getSourceForID(o){return this.idSources.get(this.realSourceIDs.get(o))}getSources(){const o={};for(let[t,n]of this.idSources)o[this.invRealSourceIDs.get(t)]=n;return o}unsubscribe(o){if(!o){Y.debug(this.id,"unsub sources");for(let t of this.sources.values())t.unsubscribe();this.sources.clear(),this.psync.clear(),this.realSourceIDs.clear(),this.invRealSourceIDs.clear(),this.idSources.clear()}return super.unsubscribe(o)}markDone(o){this.remove(o),Dn(this.closeIn,this.sources.size)&&this.done()}}var Yt=z((o,t=" ")=>{const n=oo(String(t),o);return(m,r)=>{if(m==null)return n;return m=m.toString(),r=r!==void 0?r:m.length,r<o?n.substring(r)+m:m}}),iN=Yt(2,"0"),vN=Yt(3,"0"),bn=Yt(4,"0");var Gr=/\{(\d+)\}/g;var St=(o,...t)=>t.length>0?o.replace(Gr,(n,m)=>String(t[parseInt(m,10)])):o;var kn=(o)=>({key:(t)=>t,group:Go(),...o});var Rt=function(...o){const t=En(Rt,o);if(t)return t;const n=kn(o[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 Ut=function(o,t){return I(t)?e(Ut(o),t):(n)=>{const m=n[2];return u(n,(r,f)=>o(f)?m(r,f):r)}};import{watch as en} from"fs";import{resolve as a} from"path";var vn={specs:P({alias:"s",optional:!1,desc:"Path to generated JSON defs"})},go={bundle:J({alias:"b",desc:"Bundle inputs (see `out` option)"})},Oo={include:zo({alias:"I",desc:"Include CSS files (prepend)"})},xo={eval:P({alias:"e",desc:"eval meta stylesheet in given string (ignores other inputs & includes)"})},ao={force:zo({alias:"f",hint:"STR",desc:"CSS classes to force include (wildcards are supported, @-prefix will read from file)",delim:","})},pn={media:zo({alias:"m",hint:"ID",desc:"Media query IDs (use 'ALL' for all)",delim:","})},ln={onlyDecls:J({desc:"Only emit framework decls"})},k={out:P({alias:"o",desc:"Output file (or stdout)"})},so={prec:Xo({default:3,desc:"Number of fractional digits"})},i={pretty:J({alias:"p",desc:"Pretty print output"})},ho={noDecls:J({alias:"d",desc:"Don't emit framework decls"})},Co={noHeader:J({desc:"Don't emit generated header comment"})},Ao={scope:P({desc:"Suffix for CSS class names"})},Fo={watch:J({alias:"w",desc:"Watch input files for changes"})};import{watch as Nr} from"fs";import{resolve as dn} from"path";var v=(o,t,n)=>{t=$(t)?t:t.join("\n"),o?Bt(dn(o),t,n):process.stdout.write(t+"\n")},co=({info:{name:o,version:t}})=>`/*! ${o} v${t} - generated by thi.ng/meta-css @ ${(new Date()).toISOString()} */`,Yo=(o,t)=>{const n=()=>{t.info("closing watchers..."),m.forEach((r)=>r.watcher.close())},m=o.map((r,f)=>{r=dn(r);const G=yn(W(r,t),{id:`in${bn(f)}`});return{input:G,watcher:Nr(r,{},(E)=>{if(E==="change")try{G.next(W(r,t))}catch(N){t.warn(N.message),n()}else t.warn("input removed:",r),n()})}});return process.on("SIGINT",n),eo({src:_t(T(({input:r})=>[r.id,r],m))})},ot=(o)=>Object.keys(o).reduce((t,n)=>{if(!n.startsWith("__"))t[n]=o[n];return t},{});async function zt(o){const t=V(a(o.opts.specs),o.logger),n=Cr(t,o.opts.force||[],o.logger);if(o.opts.bundle)if(o.opts.watch)await Br(o,n);else So(o,t,n,o.opts.eval?[o.opts.eval]:o.inputs.map((m)=>W(a(m),o.logger)),o.opts.out);else if(o.opts.watch)await Lr(o,t,n);else if(o.opts.eval)try{So(o,t,n,[o.opts.eval])}catch(m){o.logger.warn(m.message)}else for(let m of o.inputs)try{m=a(m);const r=!o.opts.noWrite?m.replace(/\.mcss$/,".css"):void 0;So(o,t,n,[W(m,o.logger)],r)}catch(r){o.logger.warn(r.message)}}function*Fr(o){let t=-1,n=o.length,m=0,r=0;for(let f=0;f<n;f++){const G=o[f];if(G===" "||G==="\t"){if(!(m||r)&&t>=0)yield o.substring(t,f),t=-1}else if(G==="{"||G==="}"){if(t>=0)yield o.substring(t,f);yield G,t=-1}else if(G==="(")m++;else if(G===")"){if(--m<0)C(`invalid nesting in line: '${o}'`)}else if(G==="["){if(t<0)t=f;r++}else if(G==="]"){if(--r<0)C(`invalid arg nesting in line: '${o}'`)}else if(t<0)t=f}if(m)C("template calls must be fully on a single line");if(r)C("verbatim properties must be fully on a single line");if(t>=0)yield o.substring(t,n)}var xn={desc:"Transpile (and optionally bundle) meta stylesheets to CSS",opts:{...go,...xo,...ao,...Oo,...ho,...Co,...k,...i,...Ao,...vn,...Fo,noWrite:J({desc:"Don't write files, use stdout only"})},fn:zt},Lr=async(o,t,n)=>{const m=a(o.opts.specs);let r,f={process:()=>{try{return t=V(m,o.logger),r.forEach((E)=>E.process()),!0}catch(E){return o.logger.warn(E.message+": "+m),!1}},watcher:en(m,{},(E)=>{if(E==="change")f.process();else o.logger.warn("specs file removed:",m),G()})};const G=()=>{o.logger.info("closing watchers..."),f.watcher.close(),r.forEach((E)=>E.watcher.close())};r=o.inputs.map((E)=>{E=a(E);const N=!o.opts.noWrite?E.replace(/\.mcss$/,".css"):void 0,L=()=>{try{return So(o,t,n,[W(E,o.logger)],N),!0}catch(B){if(o.logger.warn(B.message+": "+E),r)G();return!1}};if(!L())process.exit(1);return{process:L,watcher:en(E,{},(B)=>{if(B==="change")L();else o.logger.warn("input removed:",E),G()})}}),o.logger.info("waiting for changes, press ctrl+c to cancel..."),process.on("SIGINT",G)},Br=async(o,t)=>{eo({src:{styles:Yo(o.inputs,o.logger),specs:Yo([o.opts.specs],o.logger).map((n)=>JSON.parse(Object.values(n)[0]))}}).subscribe({next({styles:n,specs:m}){try{So(o,m,t,Object.keys(n).sort().map((r)=>n[r]),o.opts.out)}catch(r){o.logger.warn(r.message)}}})},So=({logger:o,opts:{include:t,noDecls:n,noHeader:m,pretty:r,scope:f}},G,E,N,L)=>{const B={logger:o,specs:G,css:{format:r?bo:ro,fns:lo,scope:f},mediaQueryIDs:new Set(Object.keys(G.media)),mediaQueryRules:{...E.mediaQueryRules},plainRules:{...E.plainRules}},h=t?t.map((O)=>W(a(O),o).trim()):[];if(!m)h.push(co(G));if(!n&&G.decls.length)h.push(g(G.decls,B.css));N.forEach((O)=>Ar(O,B)),hr(h,B),Or(h,B),v(L,h,o)},Or=(o,{css:t,logger:n,mediaQueryRules:m,specs:r})=>{for(let f in m){const G=sn(m[f],r);n.debug("mediaquery rules",f,G),o.push(g(Bo(Hr(r.media,f),G),t))}},hr=(o,{css:t,logger:n,plainRules:m,specs:r})=>{const f=sn(m,r);n.debug("plain rules",f),o.push(g(f,t))},Cr=(o,t,n)=>{const m=new Set(Object.keys(o.media)),r=new Set(Object.keys(o.classes)),f={},G={};if(t.length&&t[0][0]==="@")t=[...to(W(a(t[0].substring(1)),n))];for(let E of t){if(!E||E.startsWith("//"))continue;const{token:N,query:L}=cn(E,m);let B;if(N.includes("*")){const h=new RegExp(`^${N.replace("*",".*")}\$`);B=[...Ut((O)=>h.test(O),r)]}else if(r.has(N))B=[N];else{n.warn(`unknown include rule ID: ${E}, skipping...`);continue}for(let h of B)n.debug("including class:",h),L?om(f,L,`.${h}`,h):tm(G,`.${h}`,h)}return{mediaQueryRules:f,plainRules:G}},Ar=(o,{specs:t,mediaQueryIDs:n,mediaQueryRules:m,plainRules:r})=>{const f=Ro(),G=Ro(f),E={root:f,curr:G,scopes:[G]};for(let N of to(o)){if(!N||/^\s*\/\//.test(N))continue;for(let L of Fr(N)){if(!L)continue;let B=E.curr;switch(B.state){case"sel":case"nest":if(L==="{"){if(B.state==="sel")B.sel=B.sel.map((h)=>h.replace(",","")),B.path=Tr(E.scopes);B.state="class"}else if(L==="}")gn(E);else{const h=wo(B.sel);if(!h||h.endsWith(","))B.sel.push(L);else B.sel[B.sel.length-1]+=" "+L}break;case"class":if(L==="{")B.state="nest",E.scopes.push(E.curr=Ro(B));else if(L==="}")gn(E);else{let{token:h,query:O}=cn(L,n);if(!t.classes[h]&&!(nm(h)||rm(h)||mm(h)))C(`unknown class ID: ${h}`);if(O)om(m,O,B.path,h);else tm(r,B.path,h)}break;default:mo(B.state)}}}},Jt=":",an="///",Ro=(o)=>({state:"sel",sel:o?[]:["<root>"],path:"",parent:o}),gn=(o)=>{const t=!o.curr.sel.length;if(Vo(!!o.curr.parent,"stack underflow"),o.scopes.pop(),o.scopes.length>0){if(o.curr=wo(o.scopes),!t&&o.curr.state==="nest")o.scopes.push(o.curr=Ro(o.curr))}else o.scopes.push(o.curr=Ro(o.root))},Tr=(o)=>o.map((t)=>t.sel.join(",")).join(an),sn=(o,t)=>Object.entries(o).map(([n,m])=>$r(n,m,t)),$r=(o,t,n)=>{const m=[];let r=m;const f=o.split(an);for(let G=0;G<f.length;G++){const E=f[G].split(",");if(G==f.length-1){const N=Object.assign({},...T((L)=>rm(L)?wr(L):nm(L)?_r(L):mm(L)?Ir(n,L):ot(n.classes[L]),t));E.push(N)}r.push(E),r=E}return m[0]},cn=(o,t)=>{if(/^::?/.test(o))return{token:o};const n=o.lastIndexOf(Jt);if(n<0)return{token:o};const m=o.substring(0,n);if(!m.split(Jt).every((f)=>t.has(f)))C(`invalid media query in token: ${o}`);return{token:o.substring(n+1),query:m}},Hr=(o,t)=>t.split(Jt).reduce((n,m)=>Object.assign(n,o[m]),{}),om=(o,t,n,m)=>{if(!o[t])o[t]={};(o[t][n]||(o[t][n]=new Set)).add(m)},tm=(o,t,n)=>(o[t]||(o[t]=new Set)).add(n),_r=(o)=>{const t=o.indexOf("=");return{[`--${o.substring(0,t)}`]:o.substring(t+1)}},Ir=(o,t)=>{const n=t.indexOf("("),m=t.substring(0,n),r=t.substring(n+1,t.length-1).split(/(?<!\\),/g).map((G)=>G.trim().replace("\\,",",")),f=o.templates[m];if(!f)C(`unknown template: ${m}`);if(r.length!==f.__arity)C(`template "${m}" expected ${f.__arity} arguments`);return Object.entries(f).reduce((G,[E,N])=>{if(!E.startsWith("__")){if(E=St(E,...r),$(N))N=St(N,...r);G[E]=N}return G},{})},wr=(o)=>{const[t,n,m]=/^(.+)-\[(.+)\]/.exec(o);return{[n]:m}},nm=(o)=>o.includes("="),mm=(o)=>o.includes("("),rm=(o)=>o.indexOf("-[")>0&&o.endsWith("]");async function Xt(o){if(o.opts.watch)await Yr(o);else await Nm(o.inputs.map((t)=>W(t,o.logger)),o.opts,o.logger)}var Em={deg:Jn,em:Hn,ex:_n,ms:Rn,percent:Ht,px:wn,rad:zn,rem:In,second:Un,turn:Xn,url:Pn,vh:Wn,vmax:Sn,vmin:Yn,vw:Mn,"%":Ht},Wr={percent:"{0}%",second:"{0}s",url:"url({0})"},Mr={"":[""],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:[""]},Gm={desc:"Generate framework rules from specs",opts:{...k,...so,...i,...Fo},fn:Xt},Yr=async(o)=>{Yo(o.inputs,o.logger).subscribe({next(t){try{Nm(Object.keys(t).sort().map((n)=>t[n]),o.opts,o.logger)}catch(n){o.logger.warn(n.message)}}})},Nm=async(o,t,n)=>{const m={info:{name:"TODO",version:"0.0.0"},media:{},classes:{},templates:{},decls:[]};$n(t.prec);for(let r of o){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{Lm(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)Sr(f,G,m.templates,n)}return v(t.out,JSON.stringify(m,null,t.pretty?4:0),n),m},Lm=(o,t,n,m,r=!1)=>{const f=_(t.vars)?t.vars:[""],G=$(t.props)?{[t.props]:"<v>"}:t.props,E=Rr(t,o),N=new Set;for(let L of f){const B=o.vars?.[L]||Mr[L];if(!B)C(`unknown variation ID: ${L}`);for(let[h,O]of io(B,Object.keys(E))){const A=s(t.name,L,h,O,E[O]),U=t.unit?s(t.unit,L,h,O,E[O]):void 0,p=r?Jr(U):Ur(E[O],U);if(!n[A]){if(n[A]={},t.user!=null)n[A].__user=t.user;if(t.doc!=null)n[A].__doc=zr(t.doc,L,h,O,p)}else if(!N.has(A))C(`duplicate class ID: ${A}`);N.add(A);let F=-1;for(let[l,S]of Object.entries(G)){const q=s(l,L,h,O,E[O]),tt=s(!U||$(S)?String(S):Em[U](S),L,h,O,p);if(n[A][q]=tt,m.debug(A,q,tt),r)F=fm(tt,fm(q,F))}if(r)n[A].__arity=F+1}}return n},Sr=(o,t,n,m)=>Lm(o,{...t,values:[""]},n,m,!0),fm=(o,t)=>{const n=/\{(\d+)\}/g;let m;while(m=n.exec(o))t=Math.max(t,+m[1]);return t},Rr=(o,t)=>{const n=$(o.values)?t.tables?.[o.values]||C(`invalid table ID: ${o.values}`):o.values;if(y(n))return n;const m=o.key==="v"?(r)=>String(r):o.key==="i+1"?(r,f)=>String(f+1):o.key==="i"||o.key===void 0?(r,f)=>String(f):C(`invalid key type: ${o.key}`);return n.reduce((r,f,G)=>{return r[m(f,G)]=f,r},{})},Ur=(o,t)=>{if(!t||$(o))return o;const n=Em[t];if(!n)C(`invalid unit: ${t}`);return n(o)},Jr=(o)=>o?Wr[o]||"{0}"+o:"{0}",s=(o,t,n,m,r)=>o.replace(/<vid>/g,t).replace(/<var>/g,n).replace(/<k>/g,m).replace(/<v>/g,String(r)),zr=({group:o,desc:t,args:n},m,r,f,G)=>({group:o?s(o,m,r,f,G):"TODO",desc:t?s(t,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:{...go,...xo,...ao,...Oo,...ho,...Co,...so,...i,...Ao,...Fo,outCss:P({desc:"Output file for CSS bundle",optional:!1}),outSpecs:P({desc:"Output file for framework",optional:!1})},fn:async(o)=>{const{opts:t,inputs:n}=o,[m,r]=n.reduce((E,N)=>(E[N.endsWith(".json")?0:1].push(N),E),[[],[]]),f={inputs:m,format:o.format,logger:o.logger,opts:{...t,out:t.outSpecs}},G={inputs:r,format:o.format,logger:o.logger,opts:{...t,noWrite:!1,out:t.outCss,scope:t.scope,specs:t.outSpecs}};await Xt(f),await zt(G)}};import{resolve as Xr} from"path";var Cm={desc:"Generate Markdown documentation for framework specs",opts:{...k,level:Xo({alias:"l",desc:"Initial heading level",default:1}),title:P({alias:"t",desc:"Custom main title, set to NONE to disable"})},inputs:1,fn:async(o)=>{const{logger:t,opts:n,inputs:m}=o,r=V(Xr(m[0]),t),f=Pr(r,n);v(n.out,f,t)}},Pr=(o,{level:t,title:n})=>{const m=Object.keys(o.classes).length,r=Object.keys(o.templates).length,f=[`Currently, there are ${m+r} CSS utility classes (incl. ${r} templates) defined in "${o.info.name}" (v${o.info.version}):`,"",`${c(t+1)} Classes by category`,"",...hm(o.classes,Zr,t+2),`${c(t+1)} Templates by category`,"",...hm(o.templates,Dr,t+2),`${c(t+1)} Media queries`,"",...Object.entries(o.media).map(([G,E])=>`- **${G}**: \`${JSON.stringify(E)}\``),""];if(n!=="NONE")f.unshift(`${c(t)} ${n??o.info.name}\n`);return f},Om=(o)=>o.split(/(\d+)/).map((t)=>{const n=parseInt(t);return isNaN(n)?t:n}),yr=(o,t)=>{if(/\d+/.test(o)&&/\d+/.test(t)){const n=Om(o),m=Om(t),r=n.length;if(r===m.length){for(let f=0;f<r;f++)if(n[f]!==m[f])return Ct(n[f],m[f]);return 0}return n.length-m.length}return Ct(o,t)},hm=(o,t,n)=>{const m=Rt({key:([r,{__doc:f}])=>f?.group||"TODO",group:[()=>[],(r)=>r.sort(),(r,f)=>(r.push(f[0]),r)]},Object.entries(o));return It((r)=>{const f=m[r].sort(yr).map((E)=>t(E,o[E].__doc,n+1)),G=f.length;return[`${c(n)} ${jo(r)}`,G>3?`\n<details><summary>${G} items:</summary>\n`:"",f.join("\n"),G>3?"</details>\n":""]},Object.keys(m).sort())},Zr=(o,t)=>{if(!(t&&t.desc))return`- \`${o}\``;let n=t.desc;if(/^-[a-z]/.test(n))n=n.substring(1);return`- \`${o}\` (${n})`},Dr=(o,t,n)=>{if(!(t&&t.args))return`${c(n)} ${o}(...)\n\nTODO`;const m=t.args.map((r)=>/^\w+/.exec(r)[0]).join(", ");return[`${c(n)} \`${o}(${m})\``,"",...t.args.map(jr),t.desc?`\n${t.desc}\n`:""].join("\n")},jr=(o)=>`- ${o.replace(/^(\w+)/,(t,n)=>`**${n}**`)}`,c=z((o)=>"#".repeat(o));import{resolve as Am} from"path";var Tm={desc:"Export entire generated framework as CSS",opts:{...Oo,...ho,...ln,...k,...i,...Co,...pn,...Ao},inputs:1,fn:async(o)=>{const{logger:t,opts:{include:n,media:m,noDecls:r,noHeader:f,onlyDecls:G,out:E,pretty:N,scope:L},inputs:B}=o,h={format:N?bo:ro,fns:lo,scope:L},O=V(Am(B[0]),t),A=n?n.map((U)=>W(Am(U),t).trim()):[];if(!f)A.push(co(O));if(!r&&O.decls.length)A.push(g(O.decls,h));if(!G)A.push(Kr(O,m,h,t));v(E,A,t)}},Kr=(o,t,n,m)=>{const r=Fm("",o);if(t){const f=t[0]==="ALL"?Object.keys(o.media):t;for(let G of f)if(o.media[G])r.push(Bo(o.media[G],Fm("-"+G,o)));else m.warn(`invalid media query ID: ${G}, skipping...`)}return g(r,n)},Fm=(o,t)=>Object.entries(t.classes).map(([n,m])=>[`.${n}${o}`,ot(m)]);var Pt=V(Vr(import.meta.dir,"package.json"));st({name:"metacss",opts:{verbose:J({alias:"v",desc:"Display extra process information"})},commands:{convert:xn,develop:Bm,doc:Cm,export:Tm,generate:Gm},ctx:async(o)=>{if(o.opts.verbose)o.logger.level=H.DEBUG;return{...o,format:Do}},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 ${Pt.name} ${Pt.version}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/meta-css",
3
- "version": "0.16.1",
3
+ "version": "0.17.0",
4
4
  "description": "Data-driven CSS framework codegen, transpiler & bundler",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -41,26 +41,26 @@
41
41
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
42
42
  },
43
43
  "dependencies": {
44
- "@thi.ng/api": "^8.11.12",
45
- "@thi.ng/args": "^2.3.48",
46
- "@thi.ng/arrays": "^2.10.5",
47
- "@thi.ng/checks": "^3.6.14",
48
- "@thi.ng/compare": "^2.4.4",
49
- "@thi.ng/errors": "^2.5.18",
50
- "@thi.ng/file-io": "^2.1.16",
51
- "@thi.ng/hiccup-css": "^2.7.28",
52
- "@thi.ng/logger": "^3.0.22",
53
- "@thi.ng/memoize": "^4.0.2",
54
- "@thi.ng/rstream": "^9.0.8",
55
- "@thi.ng/strings": "^3.8.10",
56
- "@thi.ng/text-format": "^2.2.17",
57
- "@thi.ng/transducers": "^9.2.8"
44
+ "@thi.ng/api": "^8.11.13",
45
+ "@thi.ng/args": "^2.3.49",
46
+ "@thi.ng/arrays": "^2.10.6",
47
+ "@thi.ng/checks": "^3.6.15",
48
+ "@thi.ng/compare": "^2.4.5",
49
+ "@thi.ng/errors": "^2.5.19",
50
+ "@thi.ng/file-io": "^2.1.17",
51
+ "@thi.ng/hiccup-css": "^2.7.29",
52
+ "@thi.ng/logger": "^3.0.23",
53
+ "@thi.ng/memoize": "^4.0.3",
54
+ "@thi.ng/rstream": "^9.0.9",
55
+ "@thi.ng/strings": "^3.8.11",
56
+ "@thi.ng/text-format": "^2.2.18",
57
+ "@thi.ng/transducers": "^9.2.9"
58
58
  },
59
59
  "devDependencies": {
60
- "@microsoft/api-extractor": "^7.47.9",
60
+ "@microsoft/api-extractor": "^7.48.0",
61
61
  "esbuild": "^0.24.0",
62
- "typedoc": "^0.26.7",
63
- "typescript": "^5.6.2"
62
+ "typedoc": "^0.26.11",
63
+ "typescript": "^5.7.2"
64
64
  },
65
65
  "keywords": [
66
66
  "browser",
@@ -110,5 +110,5 @@
110
110
  "status": "alpha",
111
111
  "year": 2023
112
112
  },
113
- "gitHead": "da057e9ed42ca9f043d272e27987e1d33e50114f\n"
113
+ "gitHead": "85e2f0935b58bde5d165fbe754fafec5da0b731e\n"
114
114
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "info": {
3
3
  "name": "MetaCSS base",
4
- "version": "0.16.0"
4
+ "version": "0.17.0"
5
5
  },
6
6
  "media": {
7
7
  "ns": { "min-width": "640px" },
@@ -138,23 +138,6 @@
138
138
  },
139
139
  "name": "anim-iter",
140
140
  "props": "animation-iteration-count"
141
- },
142
- {
143
- "doc": {
144
- "group": "animation / transition",
145
- "args": ["body: CSS value/definition"]
146
- },
147
- "name": "<vid>",
148
- "props": "<var>",
149
- "vars": ["anim", "transition"]
150
- },
151
- {
152
- "doc": {
153
- "group": "animation / transition",
154
- "args": ["prop: CSS value/definition"]
155
- },
156
- "name": "transition-property",
157
- "props": "transition-property"
158
141
  }
159
142
  ]
160
143
  }
@@ -140,7 +140,9 @@
140
140
  ]
141
141
  },
142
142
  "name": "border-light-dark",
143
- "props": { "border-color": "light-dark(var(--{0}), var(--{1}))" }
143
+ "props": {
144
+ "border-color": "light-dark(var(--{0}), var(--{1}))"
145
+ }
144
146
  },
145
147
  {
146
148
  "doc": {
@@ -167,7 +169,7 @@
167
169
  },
168
170
  "name": "light-dark",
169
171
  "props": {
170
- "background-color": "light-dark(var(--{0}), var(--{1}))"
172
+ "color": "light-dark(var(--{0}), var(--{1}))"
171
173
  }
172
174
  },
173
175
  {
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "tables": {
3
+ "sizes-abs0": [0, 1, 2, 4, 8, 16],
3
4
  "sizes-abs": [1, 2, 4, 8, 16],
4
5
  "sizes-rel": [
5
6
  10, 16, 17, 20, 25, 30, 33, 34, 40, 50, 60, 66, 67, 70, 75, 80, 83,
@@ -14,9 +15,8 @@
14
15
  {
15
16
  "doc": { "group": "<var>", "desc": "<v>" },
16
17
  "name": "<vid><k>",
17
- "key": "i+1",
18
18
  "props": "<var>",
19
- "values": "sizes-abs",
19
+ "values": "sizes-abs0",
20
20
  "unit": "rem",
21
21
  "vars": ["w", "h"]
22
22
  },
@@ -70,37 +70,5 @@
70
70
  "unit": "v<vid>",
71
71
  "vars": ["w", "h"]
72
72
  }
73
- ],
74
- "templates": [
75
- {
76
- "doc": {
77
- "group": "dimensions",
78
- "desc": "Sets <var> to given value",
79
- "args": ["<var>: incl. units"]
80
- },
81
- "name": "<var>",
82
- "props": "<var>",
83
- "vars": ["w", "h"]
84
- },
85
- {
86
- "doc": {
87
- "group": "dimensions",
88
- "desc": "Sets min-<var> to given value",
89
- "args": ["<var>: incl. units"]
90
- },
91
- "name": "min-<var>",
92
- "props": "min-<var>",
93
- "vars": ["w", "h"]
94
- },
95
- {
96
- "doc": {
97
- "group": "dimensions",
98
- "desc": "Sets max-<var> to given value",
99
- "args": ["<var>: incl. units"]
100
- },
101
- "name": "max-<var>",
102
- "props": "max-<var>",
103
- "vars": ["w", "h"]
104
- }
105
73
  ]
106
74
  }
@@ -25,15 +25,5 @@
25
25
  "values": ["alpha", "luminance", "match-source"],
26
26
  "vars": ["mode", "type"]
27
27
  }
28
- ],
29
- "templates": [
30
- {
31
- "doc": {
32
- "group": "mask",
33
- "args": ["body: definition (e.g. url or gradient)"]
34
- },
35
- "name": "mask-image",
36
- "props": "mask-image"
37
- }
38
28
  ]
39
29
  }
@@ -39,23 +39,5 @@
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
- }
60
42
  ]
61
43
  }
@@ -140,23 +140,5 @@
140
140
  },
141
141
  "unit": "em"
142
142
  }
143
- ],
144
- "templates": [
145
- {
146
- "doc": {
147
- "group": "font families",
148
- "args": ["body: CSS value/definition"]
149
- },
150
- "name": "font-family",
151
- "props": "font-family"
152
- },
153
- {
154
- "doc": {
155
- "group": "font size",
156
- "args": ["body: CSS value/definition"]
157
- },
158
- "name": "font-size",
159
- "props": "font-size"
160
- }
161
143
  ]
162
144
  }