@thi.ng/meta-css 0.12.0 → 0.12.2
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 +3 -3
- package/index.js +6 -6
- package/package.json +21 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-
|
|
3
|
+
- **Last updated**: 2024-06-21T19:34:38Z
|
|
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.12.2](https://github.com/thi-ng/umbrella/tree/@thi.ng/meta-css@0.12.2) (2024-06-21)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- enforce uniform naming convention of internal functions ([56992b2](https://github.com/thi-ng/umbrella/commit/56992b2))
|
|
17
|
+
|
|
12
18
|
## [0.12.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/meta-css@0.12.0) (2024-04-26)
|
|
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 193 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
|
>
|
|
@@ -1270,13 +1270,13 @@ Currently, there are 946 CSS utility classes (incl. 70 templates) defined in "Me
|
|
|
1270
1270
|
|
|
1271
1271
|
<details><summary>27 items:</summary>
|
|
1272
1272
|
|
|
1273
|
+
- `br-100` (100%)
|
|
1274
|
+
- `br-pill` (9999px)
|
|
1273
1275
|
- `br0` (0rem)
|
|
1274
1276
|
- `br1` (.125rem)
|
|
1275
1277
|
- `br2` (.25rem)
|
|
1276
1278
|
- `br3` (.5rem)
|
|
1277
1279
|
- `br4` (1rem)
|
|
1278
|
-
- `br-100` (100%)
|
|
1279
|
-
- `br-pill` (9999px)
|
|
1280
1280
|
- `brb0` (bottom 0rem)
|
|
1281
1281
|
- `brb1` (bottom .125rem)
|
|
1282
1282
|
- `brb2` (bottom .25rem)
|
package/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
`),this.parent&&this.parent.logEntry(
|
|
4
|
-
`]:[],...
|
|
5
|
-
`),s1(Z,W);const U=await Z.ctx({logger:new b0(process.stderr,Z.name,"INFO"),format:J?h0:d1,opts:Q.result,inputs:Q.rest},B);if(await B.fn(U),Z.post)await Z.post(U,B)}catch(Y){process.stderr.write(Y.message+"\n\n"),process.exit(1)}},s1=(Z,X)=>{process.stderr.write(N0(Z.opts,X)),process.exit(1)},u8=(Z)=>["\nAvailable commands:\n",...Object.keys(Z).map((X)=>`${v0(16)(X)}: ${Z[X].desc}`),"\n"].join("\n");import{existsSync as g8,mkdirSync as x8,statSync as q9} from"fs";import{dirname as d8} from"path";var n8=(Z)=>Z.length>0&&!g8(Z)?(x8(Z,{recursive:!0}),!0):!1,Z4=(Z)=>n8(d8(Z));var h=(Z)=>typeof Z==="function";var w=(Z)=>typeof Z==="string";import{readFileSync as p8} from"fs";import{writeFileSync as l8} from"fs";var X4=(Z,X,J,W,Y=!1)=>{if(W&&W.info(`${Y?"[dryrun] ":""}writing file: ${Z}`),Y)return;Z4(Z),l8(Z,X,!J&&w(X)?"utf-8":J)};var D=(Z,X,J="utf-8")=>{return X&&X.debug("reading file:",Z),p8(Z,J)},K1=(Z,X,J,W=!1)=>X4(Z,N(X)?X.join("\n"):X,"utf-8",J,W);var f=(Z,X)=>JSON.parse(D(Z,X));var u=Symbol(),H1=()=>{};var D0=Object.freeze({level:P.NONE,addChild(Z){return Z},childLogger:()=>D0,enabled:()=>!1,fine(){},debug(){},info(){},warn(){},severe(){},logEntry(){}});class $1 extends P0{set(Z){this.parent=Z}childLogger(Z,X){return new $1(Z,X??this.level,this)}logEntry(Z){this.parent.logEntry(Z)}}var J4=new $1("root",P.FINE,D0);import{join as _5} from"path";var M1=(Z,X)=>{if(Z===X)return 0;if(Z==null)return X==null?0:-1;if(X==null)return Z==null?0:1;if(typeof Z.compare==="function")return Z.compare(X);if(typeof X.compare==="function")return-X.compare(Z);return Z<X?-1:Z>X?1:0};var o8=S(()=>"Assertion failed"),u0=(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)?(Z,X)=>{if(typeof Z==="function"&&!Z()||!Z)throw new o8(typeof X==="function"?X():X)}:()=>{};var g0=(Z)=>Z!=null&&typeof Z!=="function"&&Z.length!==void 0;var W4=(Z)=>{return(Z==null||!Z[Symbol.iterator])&&$(`value is not iterable: ${Z}`),Z};var Y4=(Z)=>g0(Z)?Z:[...W4(Z)];var G0=(Z)=>Z[Z.length-1];var i8=S(()=>"illegal arity"),W0=(Z)=>{throw new i8(Z)};var a8=S(()=>"illegal state"),Y0=(Z)=>{throw new a8(Z)};var x0=(Z,X)=>Z!=null&&typeof Z[X]==="function";var O=(Z)=>Z!=null&&typeof Z[Symbol.iterator]==="function";var d0=(Z)=>Z!=null&&typeof Z!=="string"&&typeof Z[Symbol.iterator]==="function";var B4=["-moz-","-ms-","-o-","-webkit-"],B0={rules:"",ruleSep:",",valSep:"",decls:"",declStart:"{",declEnd:"}",indent:"",comments:!1},n0={rules:"\n",ruleSep:", ",valSep:" ",decls:"\n",declStart:" {\n",declEnd:"}\n",indent:" ",comments:!0};var C1=function(...Z){let[X,J,W,Y,B,V,Q,U,q,z]=Z;switch(Z.length){case 0:W0(0);case 1:return X;case 2:return(...K)=>X(J(...K));case 3:return(...K)=>X(J(W(...K)));case 4:return(...K)=>X(J(W(Y(...K))));case 5:return(...K)=>X(J(W(Y(B(...K)))));case 6:return(...K)=>X(J(W(Y(B(V(...K))))));case 7:return(...K)=>X(J(W(Y(B(V(Q(...K)))))));case 8:return(...K)=>X(J(W(Y(B(V(Q(U(...K))))))));case 9:return(...K)=>X(J(W(Y(B(V(Q(U(q(...K)))))))));case 10:default:const H=(...K)=>X(J(W(Y(B(V(Q(U(q(z(...K))))))))));return Z.length===10?H:C1(H,...Z.slice(10))}};var i=(Z)=>x0(Z,"xform")?Z.xform():Z;var v=function(...Z){return Z=Z.map(i),C1.apply(null,Z)};var g=(Z,X)=>[Z[0],Z[1],X];class j0{value;constructor(Z){this.value=Z}deref(){return this.value}}var G=(Z)=>Z instanceof j0,Q4=(Z)=>Z instanceof j0?Z:new j0(Z),y=(Z)=>Z instanceof j0?Z.deref():Z;var Q0=function(...Z){const X=Z[0],J=X[0],W=X[1],Y=X[2];Z=t8(Z);const B=Z[0]==null?J():Z[0],V=Z[1];return y(W(x0(V,"$reduce")?V.$reduce(Y,B):g0(V)?r8(Y,B,V):c8(Y,B,V)))};var t8=(Z)=>Z.length===2?[void 0,Z[1]]:Z.length===3?[Z[1],Z[2]]:W0(Z.length),r8=(Z,X,J)=>{for(let W=0,Y=J.length;W<Y;W++)if(X=Z(X,J[W]),G(X)){X=X.deref();break}return X},c8=(Z,X,J)=>{for(let W of J)if(X=Z(X,W),G(X)){X=X.deref();break}return X},V0=(Z,X)=>[Z,w0,X],V4=(Z,X)=>{const J=X.length-1;return O(X[J])?X.length>1?Q0(Z.apply(null,X.slice(0,J)),X[J]):Q0(Z(),X[0]):void 0};var U0=function(Z){return Z?[...Z]:V0(()=>[],(X,J)=>(X.push(J),X))};function*q0(Z,X){const J=i(Z)(U0()),W=J[1],Y=J[2];for(let B of X){const V=Y([],B);if(G(V)){yield*y(W(V.deref()));return}if(V.length)yield*V}yield*y(W([]))}function*a(Z,X){const J=i(Z)([H1,H1,(W,Y)=>Y])[2];for(let W of X){let Y=J(u,W);if(G(Y)){if(Y=y(Y.deref()),Y!==u)yield Y;return}if(Y!==u)yield Y}}var l0=(Z,X,J=a)=>{const W=X.length-1;return O(X[W])?X.length>1?J(Z.apply(null,X.slice(0,W)),X[W]):J(Z(),X[0]):void 0};var F1=function(Z,X){return O(X)?q0(F1(Z),w(X)?[X]:X):(J)=>{const W=J[2],Y=(B,V)=>{const Q=Z(V);if(Q){for(let U of Q)if(B=Y(B,U),G(B))break;return B}return W(B,V)};return g(J,Y)}};var U4=function(Z){return F1((X)=>d0(X)?X:void 0,Z)};var F=function(Z,X){return O(X)?a(F(Z),X):(J)=>{const W=J[2];return g(J,(Y,B)=>W(Y,Z(B)))}};function*p0(...Z){const X=Z.length-1;if(X<0)return;const J=new Array(X+1).fill(0),W=Z.map(Y4),Y=W.reduce((B,V)=>B*V.length,1);for(let B=0;B<Y;B++){const V=[];for(let Q=X;Q>=0;Q--){const U=W[Q];let q=J[Q];if(q===U.length)J[Q]=q=0,Q>0&&J[Q-1]++;V[Q]=U[q]}J[X]++,yield V}}function*q4(Z,X=Infinity){while(X-- >0)yield Z}var w1=function(Z,X){Z=Z||"";let J=!0;return X?[...X].join(Z):V0(()=>"",(W,Y)=>(W=J?W+Y:W+Z+Y,J=!1,W))};var o0=function(...Z){return s8(o0,Q0,Z)};var s8=(Z,X,J)=>{let W,Y;switch(J.length){case 4:Y=J[3],W=J[2];break;case 3:Y=J[2];break;case 2:return F((B)=>Z(J[0],J[1],B));default:W0(J.length)}return X(i(J[0])(J[1]),W,Y)};var e8=new Set,Z5=":[",z4=v(U4(),F((Z)=>Z[0]==="&"?Z.substring(1):Z5.includes(Z[0])?Z:" "+Z)),X5=(Z,X)=>v(Z,F((J)=>w(J)&&J.startsWith(" .")?J+X:J)),z0=(Z,X,J,W)=>{const Y=J.length,B=[];let V,Q;const U=(q,z)=>{let H=null;if(N(z))z0(Z,P1(X,B),z,W);else if(O(z)&&!w(z))z0(Z,P1(X,B),[...z],W);else if((Q=h(z))||(H=W.fns[z]))if(!X.length){if(H)return H.apply(null,J.slice(q+1))(Z,W),!0;z(Z,W)}else if(Q)U(q,z());else $(`quoted fn ('${z}') only allowed at head position`);else if(b(z))V=Object.assign(V||{},z);else if(z!=null)B.push(z)};for(let q=0;q<Y;q++)if(U(q,J[q]))return Z;return V&&Z.push(J5(X,B,V,W)),Z},P1=(Z,X)=>Z.length?[...p0(Z,X)]:X,J5=(Z,X,J,W)=>{const Y=W.format,B=_(W),V=W.scope?X5(z4,W.scope):z4;return[B,o0(F((Q)=>o0(V,w1(),N(Q)?Q:[Q]).trim()),w1(Y.ruleSep),P1(Z,X)),Y.declStart,k0(J,W),B,Y.declEnd].join("")},k0=(Z,X)=>{const J=X.format,W=X.autoprefix||e8,Y=_(X,X.depth+1),B=[];for(let V in Z)if(Z.hasOwnProperty(V)){let Q=Z[V];if(h(Q))Q=Q(Z);if(N(Q))Q=Q.map((U)=>N(U)?U.join(" "):U).join(J.ruleSep);if(W.has(V))for(let U of X.vendors)B.push(`${Y}${U}${V}:${J.valSep}${Q};`);B.push(`${Y}${V}:${J.valSep}${Q};`)}return B.join(J.decls)+J.decls},_=(Z,X=Z.depth)=>X>1?[...q4(Z.format.indent,X)].join(""):X>0?Z.format.indent:"";var K4=function(Z,...X){const J=X.length===1?X[0]:X.reduce((W,Y,B)=>{return W[B/(X.length-1)*100|0]=Y,W},{});return(W,Y)=>{const B=_(Y);Y.depth++;const V=_(Y);W.push(`${B}@keyframes ${Z}${Y.format.declStart}`);for(let Q in J)if(J.hasOwnProperty(Q))W.push([V,Q+"%",Y.format.declStart,k0(J[Q],Y),V,Y.format.declEnd].join(""));return Y.depth--,W.push(B+Y.format.declEnd),W}};var H4=(Z,X=!1)=>(J,W)=>{const Y=_(W),B=_(W,W.depth+1);if(W.format.comments||X)J.push(Y+"/*",Z.split("\n").map((V)=>B+V).join("\n"),Y+"*/");return J};var i0=(Z,X,J)=>(W,Y)=>{const B=_(Y);return W.push(`${B}${Z} ${W5(X)}${Y.format.declStart}`),Y.depth++,z0(W,[],J,Y),Y.depth--,W.push(B+Y.format.declEnd),W},W5=(Z)=>{if(w(Z))return Z;const X=[];for(let J in Z)if(Z.hasOwnProperty(J)){let W=Z[J];if(W===!0)W=$4.has(J)?J:`(${J})`;else if(W===!1)W=`(not ${$4.has(J)?J:`(${J})`})`;else if(W==="only")W+=" "+J;else W=`(${J}:${W})`;X.push(W)}return X.join(" and ")},$4=new Set(["all","print","screen"]);var t=(Z,X)=>{return X={format:B0,vendors:B4,fns:{},depth:0,...X},N(X.autoprefix)&&(X.autoprefix=new Set(X.autoprefix)),b(Z)?k0(Z,X):h(Z)?Z([],X).join(X.format.rules):z0([],[],N(Z)?Z:d0(Z)?[...Z]:$("invalid rules"),X).join(X.format.rules)};var M4=(Z,...X)=>(J,W)=>(J.push(X.length?`@import url(${Z}) ${X.join(W.format.ruleSep)};`:`@import url(${Z});`),J);var K0=(Z,X)=>i0("@media",Z,X);var C4=function(...Z){return(X,J)=>(X.push(Z.length>1?`@namespace ${Z[0]} url(${Z[1]});`:`@namespace url(${Z[0]});`),X)};var F4=(Z,X)=>i0("@supports",Z,X);var a0={"@comment":H4,"@import":M4,"@keyframes":K4,"@media":K0,"@namespace":C4,"@supports":F4};var w4=4,P4=(Z)=>w4=Z,I=(Z)=>Z===(Z|0)?String(Z):Z.toFixed(w4).replace(/^0./,".").replace(/^-0./,"-.").replace(/0+$/,"");var N4=(Z)=>`${I(Z)}em`,O4=(Z)=>`${I(Z)}ex`;var D4=(Z)=>`${I(Z)}rem`,N1=(Z)=>`${I(Z)}%`,G4=(Z)=>`${I(Z)}px`,j4=(Z)=>`${I(Z)}vh`,k4=(Z)=>`${I(Z)}vw`,T4=(Z)=>`${I(Z)}vmin`,I4=(Z)=>`${I(Z)}vmax`,E4=(Z)=>`${Z|0}ms`,R4=(Z)=>`${I(Z)}s`;var L4=(Z)=>`${I(Z)}deg`,S4=(Z)=>`${I(Z)}rad`,A4=(Z)=>`${I(Z)}turn`,b4=(Z)=>`url(${Z})`;var j=((Z)=>{return Z[Z.IDLE=0]="IDLE",Z[Z.ACTIVE=1]="ACTIVE",Z[Z.DONE=2]="DONE",Z[Z.UNSUBSCRIBED=3]="UNSUBSCRIBED",Z[Z.ERROR=4]="ERROR",Z})(j||{}),L=((Z)=>{return Z[Z.NEVER=0]="NEVER",Z[Z.FIRST=1]="FIRST",Z[Z.LAST=2]="LAST",Z})(L||{});var Y5=0,B5=()=>Y5++,r=(Z,X)=>!X||!X.id?{...X,id:Z+"-"+B5()}:X;var k=J4.childLogger("rstream");class x{constructor(Z,X){this.wrapped=Z,X=r("sub",{closeIn:L.LAST,closeOut:L.LAST,cache:!0,...X}),this.parent=X.parent,this.id=X.id,this.closeIn=X.closeIn,this.closeOut=X.closeOut,this.cacheLast=X.cache,X.xform&&(this.xform=X.xform(U0()))}id;closeIn;closeOut;parent;__owner;xform;cacheLast;last=u;state=j.IDLE;subs=[];deref(){return this.last!==u?this.last:void 0}getState(){return this.state}setState(Z){this.state=Z}subscribe(Z,X={}){this.ensureState();let J;if(Z instanceof x&&!X.xform)Z.ensureState(),u0(!Z.parent,`sub '${Z.id}' already has a parent`),Z.parent=this,J=Z;else J=new x(Z,{...X,parent:this});return this.subs.push(J),this.setState(j.ACTIVE),J.setState(j.ACTIVE),this.last!=u&&J.next(this.last),J}transform(...Z){let X,J;if(b(G0(Z)))J=Z.pop(),X={error:J.error};return this.subscribe(X,r("xform",Z.length>0?{...J,xform:v(...Z)}:J))}map(Z,X){return this.transform(F(Z),X||{})}unsubscribe(Z){return Z?this.unsubscribeChild(Z):this.unsubscribeSelf()}unsubscribeSelf(){return k.debug(this.id,"unsub self"),this.parent&&this.parent.unsubscribe(this),this.state<j.UNSUBSCRIBED&&(this.state=j.UNSUBSCRIBED),this.release(),!0}unsubscribeChild(Z){k.debug(this.id,"unsub child",Z.id);const X=this.subs.indexOf(Z);if(X>=0){if(this.subs.splice(X,1),this.closeOut===L.FIRST||!this.subs.length&&this.closeOut!==L.NEVER)this.unsubscribe();return!0}return!1}next(Z){if(this.state>=j.DONE)return;this.xform?this.dispatchXform(Z):this.dispatch(Z)}done(){if(k.debug(this.id,"entering done()"),this.state>=j.DONE)return;if(this.xform){if(!this.dispatchXformDone())return}if(this.state=j.DONE,this.dispatchTo("done"))this.state<j.UNSUBSCRIBED&&this.unsubscribe();k.debug(this.id,"exiting done()")}error(Z){const X=this.wrapped,J=X&&X.error;return J&&k.debug(this.id,"attempting wrapped error handler"),J&&X.error(Z)||this.unhandledError(Z)}unhandledError(Z){return(k.parent!==D0?k:console).warn(this.id,"unhandled error:",Z),this.unsubscribe(),this.state=j.ERROR,!1}dispatchTo(Z,X){let J=this.wrapped;if(J)try{J[Z]&&J[Z](X)}catch(Y){if(!this.error(Y))return!1}const W=Z==="next"?this.subs:[...this.subs];for(let Y=W.length;Y-- >0;){J=W[Y];try{J[Z]&&J[Z](X)}catch(B){if(Z==="error"||!J.error||!J.error(B))return this.unhandledError(B)}}return!0}dispatch(Z){k.debug(this.id,"dispatch",Z),this.cacheLast&&(this.last=Z),this.dispatchTo("next",Z)}dispatchXform(Z){let X;try{X=this.xform[2]([],Z)}catch(J){this.error(J);return}if(this.dispatchXformVals(X))G(X)&&this.done()}dispatchXformDone(){let Z;try{Z=this.xform[1]([])}catch(X){return this.error(X)}return this.dispatchXformVals(Z)}dispatchXformVals(Z){const X=y(Z);for(let J=0,W=X.length;J<W&&this.state<j.DONE;J++)this.dispatch(X[J]);return this.state<j.ERROR}ensureState(){if(this.state>=j.DONE)Y0(`operation not allowed in state ${this.state}`)}release(){this.subs.length=0,delete this.parent,delete this.xform,delete this.last}}var v4=(Z,X)=>{const J=new y4(X);return J.next(Z),J};class y4 extends x{src;_cancel;_inited;constructor(Z,X){const[J,W]=h(Z)?[Z,X||{}]:[void 0,Z||{}];super(W.error?{error:W.error}:void 0,r("stream",W));this.src=J,this._inited=!1}subscribe(Z,X={}){const J=super.subscribe(Z,X);if(!this._inited){if(this.src)try{this._cancel=this.src(this)||(()=>{return})}catch(W){let Y=this.wrapped;if(!Y||!Y.error||!Y.error(W))this.unhandledError(W)}this._inited=!0}return J}unsubscribe(Z){const X=super.unsubscribe(Z);if(X&&(!Z||(!this.subs||!this.subs.length)&&this.closeOut!==L.NEVER))this.cancel();return X}done(){this.cancel(),super.done(),delete this.src,delete this._cancel}error(Z){if(super.error(Z))return!0;return this.cancel(),!1}cancel(){if(this._cancel){k.debug(this.id,"cancel");const Z=this._cancel;delete this._cancel,Z()}}}var _4=(Z,X)=>Z===L.FIRST||Z===L.LAST&&!X;var O1=function(Z){return Z?Q0(O1(),Z):V0(()=>({}),(X,[J,W])=>(X[J]=W,X))};var h4=()=>(Z)=>{const X=Z[2];return g(Z,(J,W)=>{if(W){for(let Y of y(W))if(J=X(J,Y),G(J))break}return G(W)?Q4(J):J})};var D1=function(Z,X){return O(X)?q0(D1(Z),X):v(F(Z),h4())};var G1=function(Z,X){return O(X)?a(G1(Z),X):F(h(Z)?(J)=>[Z(J),J]:(J)=>[Z,J])};var j1=function(...Z){const X=l0(j1,Z);if(X)return X;const J=Z[0],W=Z[1]!==!1;return F((Y)=>{const B=W?{}:Y;for(let V in Y)B[V]=J(Y[V]);return B})};var f4=(Z)=>Z;var k1=function(...Z){const X=l0(k1,Z,q0);if(X)return X;const{key:J=f4,mergeOnly:W=!1,reset:Y=!0,all:B=!0,backPressure:V=0}=Z[1],Q=N(Z[0])?new Set(Z[0]):Z[0],U=new Set,q=new Map;let z={};const H=([K,M,E])=>{let p=!0;if(W||V<1)return[K,(C)=>{if(Y&&B&&U.size>0||!Y&&p)C=E(C,z),z={},U.clear(),p=!1;return M(C)},(C,o)=>{const T=J(o);if(Q.has(T)){if(z[T]=o,U.add(T),W||m4(Q,U))if(C=E(C,z),p=!1,Y)z={},U.clear();else z={...z}}return C}];else return[K,(C)=>{if(B&&U.size>0)C=E(C,u4(q,U)),q.clear(),U.clear();return M(C)},(C,o)=>{const T=J(o);if(Q.has(T)){let m=q.get(T);!m&&q.set(T,m=[]),m.length>=V&&Y0(`max back pressure (${V}) exceeded for input: ${String(T)}`),m.push(o),U.add(T);while(m4(Q,U))if(C=E(C,u4(q,U)),p=!1,G(C))break}return C}]};return H.keys=()=>Q,H.clear=()=>{q.clear(),Q.clear(),U.clear(),z={}},H.add=(K)=>{Q.add(K)},H.delete=(K,M=!0)=>{if(q.delete(K),Q.delete(K),M)U.delete(K),delete z[K]},H},m4=(Z,X)=>{if(X.size<Z.size)return!1;for(let J of Z)if(!X.has(J))return!1;return!0},u4=(Z,X)=>{const J={};for(let W of X){const Y=Z.get(W);J[W]=Y.shift(),!Y.length&&X.delete(W)}return J};var g4=(Z,X)=>{let J=!0;for(let W of X)J=Z.removeID(W)&&J;return J};var t0=(Z)=>new x4(Z);class x4 extends x{sources;idSources;realSourceIDs;invRealSourceIDs;psync;clean;constructor(Z){const X=k1(new Set,{key:(W)=>W[0],mergeOnly:Z.mergeOnly===!0,reset:Z.reset===!0,all:Z.all!==!1,backPressure:Z.backPressure||0}),J=j1((W)=>W[1]);super(void 0,r("streamsync",{...Z,xform:Z.xform?v(X,J,Z.xform):v(X,J)}));this.sources=new Map,this.realSourceIDs=new Map,this.invRealSourceIDs=new Map,this.idSources=new Map,this.psync=X,this.clean=!!Z.clean,Z.src&&this.addAll(Z.src)}add(Z,X){X||(X=Z.id),this.ensureState(),this.psync.add(X),this.realSourceIDs.set(X,Z.id),this.invRealSourceIDs.set(Z.id,X),this.idSources.set(Z.id,Z),this.sources.set(Z,Z.subscribe({next:(J)=>J[1]instanceof x?this.add(J[1]):this.next(J),done:()=>this.markDone(Z),__owner:this},{xform:G1(X),id:`in-${X}`}))}addAll(Z){for(let X in Z)this.psync.add(X);for(let X in Z)this.add(Z[X],X)}remove(Z){const X=this.sources.get(Z);if(X){const J=this.invRealSourceIDs.get(Z.id);return k.info(`removing src: ${Z.id} (${J})`),this.psync.delete(J,this.clean),this.realSourceIDs.delete(J),this.invRealSourceIDs.delete(Z.id),this.idSources.delete(Z.id),this.sources.delete(Z),X.unsubscribe(),!0}return!1}removeID(Z){const X=this.getSourceForID(Z);return X?this.remove(X):!1}removeAll(Z){for(let J of Z)this.psync.delete(this.invRealSourceIDs.get(J.id));let X=!0;for(let J of Z)X=this.remove(J)&&X;return X}removeAllIDs(Z){return g4(this,Z)}getSourceForID(Z){return this.idSources.get(this.realSourceIDs.get(Z))}getSources(){const Z={};for(let[X,J]of this.idSources)Z[this.invRealSourceIDs.get(X)]=J;return Z}unsubscribe(Z){if(!Z){k.debug(this.id,"unsub sources");for(let X of this.sources.values())X.unsubscribe();this.sources.clear(),this.psync.clear(),this.realSourceIDs.clear(),this.invRealSourceIDs.clear(),this.idSources.clear()}return super.unsubscribe(Z)}markDone(Z){this.remove(Z),_4(this.closeIn,this.sources.size)&&this.done()}}var T1=Z0((Z,X=" ")=>{const J=X0(String(X),Z);return(W,Y)=>{if(W==null)return J;return W=W.toString(),Y=Y!==void 0?Y:W.length,Y<Z?J.substring(Y)+W:W}}),nJ=T1(2,"0"),lJ=T1(3,"0"),d4=T1(4,"0");var Q5=/\{(\d+)\}/g;var I1=(Z,...X)=>X.length>0?Z.replace(Q5,(J,W)=>String(X[parseInt(W,10)])):Z;var n4=(Z)=>({key:(X)=>X,group:U0(),...Z});var E1=function(...Z){const X=V4(E1,Z);if(X)return X;const J=n4(Z[0]),[W,Y,B]=J.group;return[()=>({}),(V)=>{for(let Q in V)V[Q]=Y(V[Q]);return V},(V,Q)=>{const U=J.key(Q);return V[U]=V[U]?B(V[U],Q):B(W(),Q),V}]};var R1=function(Z,X){return O(X)?a(R1(Z),X):(J)=>{const W=J[2];return g(J,(Y,B)=>Z(B)?W(Y,B):Y)}};import{watch as a4} from"fs";import{resolve as c} from"path";var l4={specs:A({alias:"s",optional:!1,desc:"Path to generated JSON defs"})},r0={bundle:R({alias:"b",desc:"Bundle inputs (see `out` option)"})},H0={include:S0({alias:"I",desc:"Include CSS files (prepend)"})},c0={eval:A({alias:"e",desc:"eval meta stylesheet in given string (ignores other inputs & includes)"})},s0={force:S0({alias:"f",hint:"STR",desc:"CSS classes to force include (wildcards are supported, @-prefix will read from file)",delim:","})},p4={media:S0({alias:"m",hint:"ID",desc:"Media query IDs (use 'ALL' for all)",delim:","})},o4={onlyDecls:R({desc:"Only emit framework decls"})},d={out:A({alias:"o",desc:"Output file (or stdout)"})},e0={prec:A0({default:3,desc:"Number of fractional digits"})},n={pretty:R({alias:"p",desc:"Pretty print output"})},$0={noDecls:R({alias:"d",desc:"Don't emit framework decls"})},M0={noHeader:R({desc:"Don't emit generated header comment"})},C0={scope:A({desc:"Suffix for CSS class names"})},F0={watch:R({alias:"w",desc:"Watch input files for changes"})};import{watch as V5} from"fs";import{resolve as i4} from"path";var l=(Z,X,J)=>{X=w(X)?X:X.join("\n"),Z?K1(i4(Z),X,J):process.stdout.write(X+"\n")},Z1=({info:{name:Z,version:X}})=>`/*! ${Z} v${X} - generated by thi.ng/meta-css @ ${(new Date()).toISOString()} */`,T0=(Z,X)=>{const J=()=>{X.info("closing watchers..."),W.forEach((Y)=>Y.watcher.close())},W=Z.map((Y,B)=>{Y=i4(Y);const V=v4(D(Y,X),{id:`in${d4(B)}`});return{input:V,watcher:V5(Y,{},(Q)=>{if(Q==="change")try{V.next(D(Y,X))}catch(U){X.warn(U.message),J()}else X.warn("input removed:",Y),J()})}});return process.on("SIGINT",J),t0({src:O1(F(({input:Y})=>[Y.id,Y],W))})},X1=(Z)=>Object.keys(Z).reduce((X,J)=>{if(!J.startsWith("__"))X[J]=Z[J];return X},{});async function S1(Z){const X=f(c(Z.opts.specs),Z.logger),J=H5(X,Z.opts.force||[],Z.logger);if(Z.opts.bundle)if(Z.opts.watch)await q5(Z,J);else I0(Z,X,J,Z.opts.eval?[Z.opts.eval]:Z.inputs.map((W)=>D(c(W),Z.logger)),Z.opts.out);else if(Z.opts.watch)await U5(Z,X,J);else if(Z.opts.eval)try{I0(Z,X,J,[Z.opts.eval])}catch(W){Z.logger.warn(W.message)}else for(let W of Z.inputs)try{W=c(W);const Y=!Z.opts.noWrite?W.replace(/\.mcss$/,".css"):void 0;I0(Z,X,J,[D(W,Z.logger)],Y)}catch(Y){Z.logger.warn(Y.message)}}function*M5(Z){let X=-1,J=Z.length,W=0;for(let Y=0;Y<J;Y++){const B=Z[Y];if(B===" "||B==="\t"){if(!W&&X>=0)yield Z.substring(X,Y),X=-1}else if(B==="{"||B==="}"){if(X>=0)yield Z.substring(X,Y);yield B,X=-1}else if(B==="(")W++;else if(B===")"){if(--W<0)$(`invalid nesting in line: '${Z}'`)}else if(X<0)X=Y}if(W)$("template calls must be fully on a single line");if(X>=0)yield Z.substring(X,J)}var r4={desc:"Transpile (and optionally bundle) meta stylesheets to CSS",opts:{...r0,...c0,...s0,...H0,...$0,...M0,...d,...n,...C0,...l4,...F0,noWrite:R({desc:"Don't write files, use stdout only"})},fn:S1},U5=async(Z,X,J)=>{const W=c(Z.opts.specs);let Y,B={process:()=>{try{return X=f(W,Z.logger),Y.forEach((Q)=>Q.process()),!0}catch(Q){return Z.logger.warn(Q.message+": "+W),!1}},watcher:a4(W,{},(Q)=>{if(Q==="change")B.process();else Z.logger.warn("specs file removed:",W),V()})};const V=()=>{Z.logger.info("closing watchers..."),B.watcher.close(),Y.forEach((Q)=>Q.watcher.close())};Y=Z.inputs.map((Q)=>{Q=c(Q);const U=!Z.opts.noWrite?Q.replace(/\.mcss$/,".css"):void 0,q=()=>{try{return I0(Z,X,J,[D(Q,Z.logger)],U),!0}catch(z){if(Z.logger.warn(z.message+": "+Q),Y)V();return!1}};if(!q())process.exit(1);return{process:q,watcher:a4(Q,{},(z)=>{if(z==="change")q();else Z.logger.warn("input removed:",Q),V()})}}),Z.logger.info("waiting for changes, press ctrl+c to cancel..."),process.on("SIGINT",V)},q5=async(Z,X)=>{t0({src:{styles:T0(Z.inputs,Z.logger),specs:T0([Z.opts.specs],Z.logger).map((J)=>JSON.parse(Object.values(J)[0]))}}).subscribe({next({styles:J,specs:W}){try{I0(Z,W,X,Object.keys(J).sort().map((Y)=>J[Y]),Z.opts.out)}catch(Y){Z.logger.warn(Y.message)}}})},I0=({logger:Z,opts:{include:X,noDecls:J,noHeader:W,pretty:Y,scope:B}},V,Q,U,q)=>{const z={logger:Z,specs:V,css:{format:Y?n0:B0,fns:a0,scope:B},mediaQueryIDs:new Set(Object.keys(V.media)),mediaQueryRules:{...Q.mediaQueryRules},plainRules:{...Q.plainRules}},H=X?X.map((K)=>D(c(K),Z).trim()):[];if(!W)H.push(Z1(V));if(!J&&V.decls.length)H.push(t(V.decls,z.css));U.forEach((K)=>$5(K,z)),K5(H,z),z5(H,z),l(q,H,Z)},z5=(Z,{css:X,logger:J,mediaQueryRules:W,specs:Y})=>{for(let B in W){const V=s4(W[B],Y);J.debug("mediaquery rules",B,V),Z.push(t(K0(w5(Y.media,B),V),X))}},K5=(Z,{css:X,logger:J,plainRules:W,specs:Y})=>{const B=s4(W,Y);J.debug("plain rules",B),Z.push(t(B,X))},H5=(Z,X,J)=>{const W=new Set(Object.keys(Z.media)),Y=new Set(Object.keys(Z.classes)),B={},V={};if(X.length&&X[0][0]==="@")X=[...J0(D(c(X[0].substring(1)),J))];for(let Q of X){if(!Q||Q.startsWith("//"))continue;const{token:U,query:q}=e4(Q,W);let z;if(U.includes("*")){const H=new RegExp(`^${U.replace("*",".*")}\$`);z=[...R1((K)=>H.test(K),Y)]}else if(Y.has(U))z=[U];else{J.warn(`unknown include rule ID: ${Q}, skipping...`);continue}for(let H of z)J.debug("including class:",H),q?Z8(B,q,`.${H}`,H):X8(V,`.${H}`,H)}return{mediaQueryRules:B,plainRules:V}},$5=(Z,{specs:X,mediaQueryIDs:J,mediaQueryRules:W,plainRules:Y})=>{const B=E0(),V=E0(B),Q={root:B,curr:V,scopes:[V]};for(let U of J0(Z)){if(!U||/^\s*\/\//.test(U))continue;for(let q of M5(U)){if(!q)continue;let z=Q.curr;switch(z.state){case"sel":case"nest":if(q==="{"){if(z.state==="sel")z.sel=z.sel.map((H)=>H.replace(",","")),z.path=C5(Q.scopes);z.state="class"}else if(q==="}")t4(Q);else{const H=G0(z.sel);if(!H||H.endsWith(","))z.sel.push(q);else z.sel[z.sel.length-1]+=" "+q}break;case"class":if(q==="{")z.state="nest",Q.scopes.push(Q.curr=E0(z));else if(q==="}")t4(Q);else{let{token:H,query:K}=e4(q,J);if(!X.classes[H]&&!(J8(H)||W8(H)))$(`unknown class ID: ${H}`);if(K)Z8(W,K,z.path,H);else X8(Y,z.path,H)}break;default:Y0(z.state)}}}},L1=":",c4="///",E0=(Z)=>({state:"sel",sel:Z?[]:["<root>"],path:"",parent:Z}),t4=(Z)=>{const X=!Z.curr.sel.length;if(u0(!!Z.curr.parent,"stack underflow"),Z.scopes.pop(),Z.scopes.length>0){if(Z.curr=G0(Z.scopes),!X&&Z.curr.state==="nest")Z.scopes.push(Z.curr=E0(Z.curr))}else Z.scopes.push(Z.curr=E0(Z.root))},C5=(Z)=>Z.map((X)=>X.sel.join(",")).join(c4),s4=(Z,X)=>Object.entries(Z).map(([J,W])=>F5(J,W,X)),F5=(Z,X,J)=>{const W=[];let Y=W;const B=Z.split(c4);for(let V=0;V<B.length;V++){const Q=B[V].split(",");if(V==B.length-1){const U=Object.assign({},...F((q)=>W8(q)?N5(J,q):J8(q)?P5(q):X1(J.classes[q]),X));Q.push(U)}Y.push(Q),Y=Q}return W[0]},e4=(Z,X)=>{if(/^::?/.test(Z))return{token:Z};const J=Z.lastIndexOf(L1);if(J<0)return{token:Z};const W=Z.substring(0,J);if(!W.split(L1).every((B)=>X.has(B)))$(`invalid media query in token: ${Z}`);return{token:Z.substring(J+1),query:W}},w5=(Z,X)=>X.split(L1).reduce((J,W)=>Object.assign(J,Z[W]),{}),Z8=(Z,X,J,W)=>{if(!Z[X])Z[X]={};(Z[X][J]||(Z[X][J]=new Set)).add(W)},X8=(Z,X,J)=>(Z[X]||(Z[X]=new Set)).add(J),P5=(Z)=>{const X=Z.indexOf("=");return{[`--${Z.substring(0,X)}`]:Z.substring(X+1)}},N5=(Z,X)=>{const J=X.indexOf("("),W=X.substring(0,J),Y=X.substring(J+1,X.length-1).split(/(?<!\\),/g).map((V)=>V.trim().replace("\\,",",")),B=Z.templates[W];if(!B)$(`unknown template: ${W}`);if(Y.length!==B.__arity)$(`template "${W}" expected ${B.__arity} arguments`);return Object.entries(B).reduce((V,[Q,U])=>{if(!Q.startsWith("__")){if(Q=I1(Q,...Y),w(U))U=I1(U,...Y);V[Q]=U}return V},{})},J8=(Z)=>Z.includes("="),W8=(Z)=>Z.includes("(");async function A1(Z){if(Z.opts.watch)await G5(Z);else await V8(Z.inputs.map((X)=>D(X,Z.logger)),Z.opts,Z.logger)}var B8={deg:L4,em:N4,ex:O4,ms:E4,percent:N1,px:G4,rad:S4,rem:D4,second:R4,turn:A4,url:b4,vh:j4,vmax:I4,vmin:T4,vw:k4,"%":N1},O5={percent:"{0}%",second:"{0}s",url:"url({0})"},D5={"":[""],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:[""]},Q8={desc:"Generate framework rules from specs",opts:{...d,...e0,...n,...F0},fn:A1},G5=async(Z)=>{T0(Z.inputs,Z.logger).subscribe({next(X){try{V8(Object.keys(X).sort().map((J)=>X[J]),Z.opts,Z.logger)}catch(J){Z.logger.warn(J.message)}}})},V8=async(Z,X,J)=>{const W={info:{name:"TODO",version:"0.0.0"},media:{},classes:{},templates:{},decls:[]};P4(X.prec);for(let Y of Z){const B=JSON.parse(Y);if(Object.assign(W.info,B.info),Object.assign(W.media,B.media),B.decls)W.decls.push(...B.decls);if(B.specs)for(let V of B.specs)try{U8(B,V,W.classes,J)}catch(Q){J.warn(`error processing spec: ${V.name}`,Q,", skipping...")}if(B.templates)for(let V of B.templates)j5(B,V,W.templates,J)}return l(X.out,JSON.stringify(W,null,X.pretty?4:0),J),W},U8=(Z,X,J,W,Y=!1)=>{const B=N(X.vars)?X.vars:[""],V=w(X.props)?{[X.props]:"<v>"}:X.props,Q=k5(X,Z),U=new Set;for(let q of B){const z=Z.vars?.[q]||D5[q];if(!z)$(`unknown variation ID: ${q}`);for(let[H,K]of p0(z,Object.keys(Q))){const M=s(X.name,q,H,K,Q[K]),E=X.unit?s(X.unit,q,H,K,Q[K]):void 0,p=Y?I5(E):T5(Q[K],E);if(!J[M]){if(J[M]={},X.user!=null)J[M].__user=X.user;if(X.doc!=null)J[M].__doc=E5(X.doc,q,H,K,p)}else if(!U.has(M))$(`duplicate class ID: ${M}`);U.add(M);let C=-1;for(let[o,T]of Object.entries(V)){const m=s(o,q,H,K,Q[K]),J1=s(!E||w(T)?String(T):B8[E](T),q,H,K,p);if(J[M][m]=J1,W.debug(M,m,J1),Y)C=Y8(J1,Y8(m,C))}if(Y)J[M].__arity=C+1}}return J},j5=(Z,X,J,W)=>U8(Z,{...X,values:[""]},J,W,!0),Y8=(Z,X)=>{const J=/\{(\d+)\}/g;let W;while(W=J.exec(Z))X=Math.max(X,+W[1]);return X},k5=(Z,X)=>{const J=w(Z.values)?X.tables?.[Z.values]||$(`invalid table ID: ${Z.values}`):Z.values;if(b(J))return J;const W=Z.key==="v"?(Y)=>String(Y):Z.key==="i+1"?(Y,B)=>String(B+1):Z.key===void 0?(Y,B)=>String(B):$(`invalid key type: ${Z.key}`);return J.reduce((Y,B,V)=>{return Y[W(B,V)]=B,Y},{})},T5=(Z,X)=>{if(!X||w(Z))return Z;const J=B8[X];if(!J)$(`invalid unit: ${X}`);return J(Z)},I5=(Z)=>Z?O5[Z]||"{0}"+Z:"{0}",s=(Z,X,J,W,Y)=>Z.replace(/<vid>/g,X).replace(/<var>/g,J).replace(/<k>/g,W).replace(/<v>/g,String(Y)),E5=({group:Z,desc:X,args:J},W,Y,B,V)=>({group:Z?s(Z,W,Y,B,V):"TODO",desc:X?s(X,W,Y,B,V):void 0,args:J?J.map((Q)=>s(Q,W,Y,B,V)):void 0});var q8={desc:"Combination of the generate & convert commands",opts:{...r0,...c0,...s0,...H0,...$0,...M0,...e0,...n,...C0,...F0,outCss:A({desc:"Output file for CSS bundle",optional:!1}),outSpecs:A({desc:"Output file for framework",optional:!1})},fn:async(Z)=>{const{opts:X,inputs:J}=Z,[W,Y]=J.reduce((Q,U)=>(Q[U.endsWith(".json")?0:1].push(U),Q),[[],[]]),B={inputs:W,format:Z.format,logger:Z.logger,opts:{...X,out:X.outSpecs}},V={inputs:Y,format:Z.format,logger:Z.logger,opts:{...X,noWrite:!1,out:X.outCss,scope:X.scope,specs:X.outSpecs}};await A1(B),await S1(V)}};import{resolve as R5} from"path";var H8={desc:"Generate Markdown documentation for framework specs",opts:{...d,level:A0({alias:"l",desc:"Initial heading level",default:1}),title:A({alias:"t",desc:"Custom main title, set to NONE to disable"})},inputs:1,fn:async(Z)=>{const{logger:X,opts:J,inputs:W}=Z,Y=f(R5(W[0]),X),B=L5(Y,J);l(J.out,B,X)}},L5=(Z,{level:X,title:J})=>{const W=Object.keys(Z.classes).length,Y=Object.keys(Z.templates).length,B=[`Currently, there are ${W+Y} CSS utility classes (incl. ${Y} templates) defined in "${Z.info.name}" (v${Z.info.version}):`,"",`${e(X+1)} Classes by category`,"",...K8(Z.classes,A5,X+2),`${e(X+1)} Templates by category`,"",...K8(Z.templates,b5,X+2),`${e(X+1)} Media queries`,"",...Object.entries(Z.media).map(([V,Q])=>`- **${V}**: \`${JSON.stringify(Q)}\``),""];if(J!=="NONE")B.unshift(`${e(X)} ${J??Z.info.name}\n`);return B},z8=(Z)=>Z.split(/(\d+)/).map((X)=>{const J=parseInt(X);return isNaN(J)?X:J}),S5=(Z,X)=>{if(/\d+/.test(Z)&&/\d+/.test(X)){const J=z8(Z),W=z8(X),Y=J.length;if(Y===W.length){for(let B=0;B<Y;B++)if(J[B]!==W[B])return M1(J[B],W[B]);return 0}return J.length-W.length}return M1(Z,X)},K8=(Z,X,J)=>{const W=E1({key:([Y,{__doc:B}])=>B?.group||"TODO",group:[()=>[],(Y)=>Y.sort(),(Y,B)=>(Y.push(B[0]),Y)]},Object.entries(Z));return D1((Y)=>{const B=W[Y].sort(S5).map((Q)=>X(Q,Z[Q].__doc,J+1)),V=B.length;return[`${e(J)} ${f0(Y)}`,V>3?`\n<details><summary>${V} items:</summary>\n`:"",B.join("\n"),V>3?"</details>\n":""]},Object.keys(W).sort())},A5=(Z,X)=>{if(!(X&&X.desc))return`- \`${Z}\``;let J=X.desc;if(/^-[a-z]/.test(J))J=J.substring(1);return`- \`${Z}\` (${J})`},b5=(Z,X,J)=>{if(!(X&&X.args))return`${e(J)} ${Z}(...)\n\nTODO`;const W=X.args.map((Y)=>/^\w+/.exec(Y)[0]).join(", ");return[`${e(J)} \`${Z}(${W})\``,"",...X.args.map(v5),X.desc?`\n${X.desc}\n`:""].join("\n")},v5=(Z)=>`- ${Z.replace(/^(\w+)/,(X,J)=>`**${J}**`)}`,e=y0((Z)=>"#".repeat(Z));import{resolve as $8} from"path";var C8={desc:"Export entire generated framework as CSS",opts:{...H0,...$0,...o4,...d,...n,...M0,...p4,...C0},inputs:1,fn:async(Z)=>{const{logger:X,opts:{include:J,media:W,noDecls:Y,noHeader:B,onlyDecls:V,out:Q,pretty:U,scope:q},inputs:z}=Z,H={format:U?n0:B0,fns:a0,scope:q},K=f($8(z[0]),X),M=J?J.map((E)=>D($8(E),X).trim()):[];if(!B)M.push(Z1(K));if(!Y&&K.decls.length)M.push(t(K.decls,H));if(!V)M.push(y5(K,W,H,X));l(Q,M,X)}},y5=(Z,X,J,W)=>{const Y=M8("",Z);if(X){const B=X[0]==="ALL"?Object.keys(Z.media):X;for(let V of B)if(Z.media[V])Y.push(K0(Z.media[V],M8("-"+V,Z)));else W.warn(`invalid media query ID: ${V}, skipping...`)}return t(Y,J)},M8=(Z,X)=>Object.entries(X.classes).map(([J,W])=>[`.${J}${Z}`,X1(W)]);var b1=f(_5(import.meta.dir,"package.json"));e1({name:"metacss",opts:{verbose:R({alias:"v",desc:"Display extra process information"})},commands:{convert:r4,develop:q8,doc:H8,export:C8,generate:Q8},ctx:async(Z)=>{if(Z.opts.verbose)Z.logger.level=P.DEBUG;return{...Z,format:h0}},usage:{prefix:`
|
|
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
|
+
`),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
|
+
`]:[],...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=Infinity){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
|
-
\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${
|
|
9
|
-
\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${
|
|
8
|
+
\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${yo.name} ${yo.version}
|
|
9
|
+
\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${yo.description}
|
|
10
10
|
\u2588 \u2502
|
|
11
11
|
\u2588 \u2588 \u2502
|
|
12
12
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/meta-css",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
4
4
|
"description": "Data-driven CSS framework codegen, transpiler & bundler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": "https://github.com/thi-ng/umbrella.git"
|
|
15
15
|
},
|
|
16
|
-
"homepage": "https://
|
|
16
|
+
"homepage": "https://thi.ng/meta-css",
|
|
17
17
|
"funding": [
|
|
18
18
|
{
|
|
19
19
|
"type": "github",
|
|
@@ -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.
|
|
45
|
-
"@thi.ng/args": "^2.3.
|
|
46
|
-
"@thi.ng/arrays": "^2.9.
|
|
47
|
-
"@thi.ng/checks": "^3.6.
|
|
48
|
-
"@thi.ng/compare": "^2.3.
|
|
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.
|
|
55
|
-
"@thi.ng/strings": "^3.7.
|
|
56
|
-
"@thi.ng/text-format": "^2.2.
|
|
57
|
-
"@thi.ng/transducers": "^9.0.
|
|
44
|
+
"@thi.ng/api": "^8.11.3",
|
|
45
|
+
"@thi.ng/args": "^2.3.34",
|
|
46
|
+
"@thi.ng/arrays": "^2.9.7",
|
|
47
|
+
"@thi.ng/checks": "^3.6.5",
|
|
48
|
+
"@thi.ng/compare": "^2.3.6",
|
|
49
|
+
"@thi.ng/errors": "^2.5.8",
|
|
50
|
+
"@thi.ng/file-io": "^2.1.3",
|
|
51
|
+
"@thi.ng/hiccup-css": "^2.7.10",
|
|
52
|
+
"@thi.ng/logger": "^3.0.13",
|
|
53
|
+
"@thi.ng/memoize": "^3.3.5",
|
|
54
|
+
"@thi.ng/rstream": "^8.5.1",
|
|
55
|
+
"@thi.ng/strings": "^3.7.34",
|
|
56
|
+
"@thi.ng/text-format": "^2.2.6",
|
|
57
|
+
"@thi.ng/transducers": "^9.0.6"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@microsoft/api-extractor": "^7.
|
|
61
|
-
"esbuild": "^0.
|
|
62
|
-
"typedoc": "^0.25.
|
|
63
|
-
"typescript": "^5.
|
|
60
|
+
"@microsoft/api-extractor": "^7.47.0",
|
|
61
|
+
"esbuild": "^0.21.5",
|
|
62
|
+
"typedoc": "^0.25.13",
|
|
63
|
+
"typescript": "^5.5.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": "
|
|
113
|
+
"gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n"
|
|
114
114
|
}
|