-
-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathcli.cjs
executable file
·3 lines (2 loc) · 35 KB
/
cli.cjs
1
2
3
#!/usr/bin/env node
"use strict";var s,e=require("css-blank-pseudo"),o=require("postcss"),t=require("fs"),i=require("path"),r=require("css-has-pseudo"),n=require("css-prefers-color-scheme"),a=require("postcss-attribute-case-insensitive"),c=require("@csstools/postcss-cascade-layers"),p=require("@csstools/postcss-color-function"),l=require("postcss-color-functional-notation"),u=require("postcss-color-hex-alpha"),d=require("postcss-color-rebeccapurple"),m=require("postcss-custom-media"),g=require("postcss-custom-properties"),f=require("postcss-custom-selectors"),h=require("postcss-dir-pseudo-class"),v=require("postcss-double-position-gradients"),b=require("postcss-focus-visible"),S=require("postcss-focus-within"),y=require("@csstools/postcss-font-format-keywords"),w=require("postcss-gap-properties"),C=require("@csstools/postcss-hwb-function"),N=require("@csstools/postcss-ic-unit"),k=require("postcss-image-set-function"),P=require("@csstools/postcss-is-pseudo-class"),x=require("postcss-lab-function"),L=require("postcss-logical"),q=require("postcss-nesting"),F=require("@csstools/postcss-normalize-display-values"),O=require("@csstools/postcss-oklab-function"),T=require("postcss-overflow-shorthand"),$=require("postcss-place"),I=require("autoprefixer"),M=require("cssdb"),A=require("@csstools/postcss-progressive-custom-properties"),E=require("browserslist"),V=require("postcss-initial"),B=require("postcss-pseudo-class-any-link"),D=require("postcss-page-break"),U=require("postcss-value-parser"),j=require("postcss-font-variant"),W=require("@csstools/postcss-media-queries-aspect-ratio-number-values"),_=require("postcss-media-minmax"),R=require("@csstools/postcss-nested-calc"),H=require("postcss-selector-not"),z=require("postcss-replace-overflow-wrap"),G=require("@csstools/postcss-scope-pseudo-class"),J=require("@csstools/postcss-stepped-value-functions"),K=require("@csstools/postcss-text-decoration-shorthand"),Q=require("@csstools/postcss-trigonometric-functions"),Z=require("@csstools/postcss-unset-value");function parseArguments(e,o,t){const i=e.map((s=>s.trim())).filter((s=>!!s)),r={stdin:!1,stdout:!1,output:null,outputDir:null,inputs:[],inlineMap:!0,externalMap:!1,replace:!1,pluginOptions:{},debug:!1};let n=null,a=!1;for(let e=0;e<i.length;e++){const o=i[e];switch(o){case"-o":case"--output":r.output=i[e+1],e++,a=!0;break;case"-m":case"--map":r.externalMap=!0,r.inlineMap=!1,a=!0;break;case"--no-map":r.externalMap=!1,r.inlineMap=!1,a=!0;break;case"-r":case"--replace":r.replace=!0,a=!0;break;case"--debug":r.debug=!0,a=!0;break;case"-d":case"--dir":r.outputDir=i[e+1],e++,a=!0;break;case"-p":case"--plugin-options":n=i[e+1],e++,a=!0;break;default:if(0===o.indexOf("-"))return console.warn(`[error] unknown argument : ${o}\n`),t(),s.InvalidArguments;if(!a){r.inputs.push(o);break}return t(),s.InvalidArguments}}if(r.replace&&(r.output=null,r.outputDir=null),r.outputDir&&(r.output=null),r.inputs.length>1&&r.output)return console.warn('[error] omit "--output" when processing multiple inputs\n'),t(),s.InvalidArguments;0===r.inputs.length&&(r.stdin=!0),r.output||r.outputDir||r.replace||(r.stdout=!0),r.stdout&&(r.externalMap=!1);let c={};if(n)try{c=JSON.parse(n)}catch(e){return console.warn("[error] plugin options must be valid JSON\n"),t(),s.InvalidArguments}for(const e in c){const i=c[e];if(!o.includes(e))return console.warn(`[error] unknown plugin option: ${e}\n`),t(),s.InvalidArguments;r.pluginOptions[e]=i}return r}async function getStdin(){return new Promise((s=>{let e="",o=!1;if(setTimeout((()=>{o=!0,s("")}),1e4),process.stdin.isTTY){if(o)return;s(e)}else process.stdin.setEncoding("utf8"),process.stdin.on("readable",(()=>{let s;for(;s=process.stdin.read();)e+=s})),process.stdin.on("end",(()=>{o||s(e)}))}))}async function stdinToStdout(s,e,t){let i="";try{const r=await getStdin();r||(t(),process.exit(1));const n=await o([s]).process(r,{from:"stdin",to:"stdout",map:!!e.inlineMap&&{inline:!0}});n.warnings().forEach((s=>{console.warn(s.toString())})),i=n.css}catch(s){console.error(e.debug?s:s.message),process.exit(1)}process.stdout.write(i+(e.inlineMap?"\n":"")),process.exit(0)}async function stdinToFs(s,e,r){let n=e.output;!n&&e.outputDir&&(n=i.join(e.outputDir,"output.css"));try{const i=await getStdin();i||(r(),process.exit(1));const a=await o([s]).process(i,{from:"stdin",to:n,map:!(!e.inlineMap&&!e.externalMap)&&{inline:e.inlineMap}});a.warnings().forEach((s=>{console.warn(s.toString())})),e.externalMap&&a.map?await Promise.all([await t.promises.writeFile(n,a.css+(e.inlineMap?"\n":"")),await t.promises.writeFile(`${n}.map`,a.map.toString())]):await t.promises.writeFile(n,a.css+(e.inlineMap?"\n":""))}catch(s){console.error(e.debug?s:s.message),process.exit(1)}console.log(`CSS was written to "${i.normalize(n)}"`),process.exit(0)}async function fsToStdout(s,e){let i=[];try{i=await Promise.all(e.inputs.map((async e=>{const i=await t.promises.readFile(e),r=await o([s]).process(i,{from:e,to:"stdout",map:!1});return r.warnings().forEach((s=>{console.warn(s.toString())})),r.css})))}catch(s){console.error(e.debug?s:s.message),process.exit(1)}for(const s of i)process.stdout.write(s);process.exit(0)}async function fsToFs(s,e){try{await Promise.all(e.inputs.map((async r=>{let n=e.output;e.outputDir&&(n=i.join(e.outputDir,i.basename(r))),e.replace&&(n=r);const a=await t.promises.readFile(r),c=await o([s]).process(a,{from:r,to:n,map:!(!e.inlineMap&&!e.externalMap)&&{inline:e.inlineMap}});c.warnings().forEach((s=>{console.warn(s.toString())})),e.externalMap&&c.map?await Promise.all([await t.promises.writeFile(n,c.css+(e.inlineMap?"\n":"")),await t.promises.writeFile(`${n}.map`,c.map.toString())]):await t.promises.writeFile(n,c.css+(e.inlineMap?"\n":"")),console.log(`CSS was written to "${i.normalize(n)}"`)})))}catch(s){console.error(e.debug?s:s.message),process.exit(1)}process.exit(0)}function helpTextLogger(s,e,o,t=null){let i=[];if(t){const s=Math.max(...Object.keys(t).map((s=>s.length))),e=new Array(s).fill(" ").join("");e.length&&(i=["\nPlugin Options:",...Object.keys(t).map((s=>` ${(s+e).slice(0,e.length)} ${typeof t[s]}`))],i.push(`\n ${JSON.stringify(t,null,2).split("\n").join("\n ")}`))}const r=[`${e}\n`,` ${o}\n`,"Usage:",` ${s} [input.css] [OPTIONS] [-o|--output output.css]`,` ${s} <input.css>... [OPTIONS] --dir <output-directory>`,` ${s} <input.css>... [OPTIONS] --replace`,"\nOptions:"," -o, --output Output file"," -d, --dir Output directory"," -r, --replace Replace (overwrite) the input file"," -m, --map Create an external sourcemap"," --no-map Disable the default inline sourcemaps"," -p, --plugin-options Stringified JSON object with plugin options"];return i.length>0&&r.push(...i),()=>{console.warn(r.join("\n"))}}async function cli(e,o,t,i=!0){const r=parseArguments(process.argv.slice(i?2:3),o,t);r===s.InvalidArguments&&process.exit(1);const n=e(r.pluginOptions);r.stdin&&r.stdout?await stdinToStdout(n,r,t):r.stdin?await stdinToFs(n,r,t):r.stdout?await fsToStdout(n,r):await fsToFs(n,r)}!function(s){s.InvalidArguments="INVALID_ARGUMENTS"}(s||(s={}));var Y={exports:{}};let X=U;function parseValue(s){let e=s.match(/([\d.-]+)(.*)/);if(e&&e[1]&&e[2]&&!isNaN(e[1]))return[parseFloat(e[1]),e[2]]}function compose(s,e,o){return s&&e&&o?`max(${s}, min(${e}, ${o}))`:s&&e?`max(${s}, ${e})`:s}function updateValue(s,e,o){let t=e,i=X(e),r=X(s.value),n=!1;r.walk(((s,e,o)=>{"function"===s.type&&"clamp"===s.value&&!n&&(n=!0,o[e]=i)})),n&&(t=r.toString()),o?s.cloneBefore({value:t}):s.value=t}Y.exports=s=>{let e=!!(s=s||{}).precalculate&&Boolean(s.precalculate),o=!!s.preserve&&Boolean(s.preserve);return{postcssPlugin:"postcss-clamp",Declaration(s){s&&s.value.includes("clamp")&&X(s.value).walk((t=>{let i=t.nodes;if("function"!==t.type||"clamp"!==t.value||5!==i.length)return;let r=i[0],n=i[2],a=i[4],c=compose(X.stringify(r),X.stringify(n),X.stringify(a));if(!e||"word"!==n.type||"word"!==a.type)return void updateValue(s,c,o);let p=parseValue(n.value),l=parseValue(a.value);if(void 0===p||void 0===l)return void updateValue(s,c,o);let[u,d]=p,[m,g]=l;if(d!==g)return void updateValue(s,c,o);let f=parseValue(r.value);if(void 0===f){let e=`${u+m}${d}`;return void updateValue(s,compose(X.stringify(r),e),o)}let[h,v]=f;if(v===d)updateValue(s,compose(`${h+u+m}${d}`),o);else{let e=`${u+m}${d}`;updateValue(s,compose(X.stringify(r),e),o)}}))}}},Y.exports.postcss=!0;var ss={exports:{}};const es=new Set(["inherit","initial","revert","unset"]);ss.exports=({preserve:s=!1}={})=>({postcssPlugin:"postcss-opacity-percentage",Declaration:{opacity:e=>{e.value&&!e.value.startsWith("var(")&&e.value.endsWith("%")&&!es.has(e.value)&&(e.cloneBefore({value:String(Number.parseFloat(e.value)/100)}),s||e.remove())}}}),ss.exports.postcss=!0;const os={"blank-pseudo-class":"https://github.com/csstools/postcss-plugins/blob/main/plugins/css-blank-pseudo/README-BROWSER.md","focus-visible-pseudo-class":"https://github.com/WICG/focus-visible","focus-within-pseudo-class":"https://github.com/jsxtools/focus-within/blob/master/README-BROWSER.md","has-pseudo-class":"https://github.com/csstools/postcss-plugins/blob/main/plugins/css-has-pseudo/README-BROWSER.md","prefers-color-scheme-query":"https://github.com/csstools/postcss-plugins/blob/main/plugins/css-prefers-color-scheme/README-BROWSER.md"},ts=["blank-pseudo-class","focus-visible-pseudo-class","focus-within-pseudo-class","has-pseudo-class","prefers-color-scheme-query"];function logFeaturesList(s,e,o){if(e.debug){o.log("Enabling the following feature(s):");const e=[];s.forEach((s=>{s.id.startsWith("before")||s.id.startsWith("after")?o.log(` ${s.id} (injected via options)`):o.log(` ${s.id}`),void 0!==os[s.id]&&e.push(s.id)})),e.length&&(o.log("These feature(s) need a browser library to work:"),e.forEach((s=>o.log(` ${s}: ${os[s]}`))))}}function initializeSharedOptions(s){if("preserve"in s){const e={};return"preserve"in s&&(e.preserve=s.preserve),e}return!1}function clamp(s,e,o){return Math.max(s,Math.min(e,o))}function stageFromOptions(s,e){let o=2;if(void 0===s.stage)return e.log(`Using features from Stage ${o} (default)`),o;if(!1===s.stage)o=5;else{let e=parseInt(s.stage,10);Number.isNaN(e)&&(e=0),o=clamp(0,e,5)}return 5===o?e.log('Stage has been disabled, features will be handled via the "features" option.'):e.log(`Using features from Stage ${o}`),o}const is=Symbol("insertBefore"),rs=Symbol("insertAfter"),ns=Symbol("insertOrder"),as=Symbol("plugin");function getTransformedInsertions(s,e,o){if("insertBefore"!==o&&"insertAfter"!==o)return[];const t="insertBefore"===o?is:rs,i=[];for(const o in e){if(!Object.hasOwnProperty.call(e,o))continue;if(!s.find((s=>s.id===o)))continue;let r=e[o];Array.isArray(r)||(r=[r]);for(let s=0;s<r.length;s++)i.push({id:o,[as]:r[s],[ns]:s,[t]:!0})}return i}var cs=["custom-media-queries","custom-properties","environment-variables","image-set-function","media-query-ranges","media-queries-aspect-ratio-number-values","prefers-color-scheme-query","nesting-rules","custom-selectors","any-link-pseudo-class","case-insensitive-attributes","focus-visible-pseudo-class","focus-within-pseudo-class","not-pseudo-class","logical-properties-and-values","dir-pseudo-class","all-property","color-functional-notation","double-position-gradients","hexadecimal-alpha-notation","hwb-function","lab-function","rebeccapurple-color","blank-pseudo-class","break-properties","font-variant-property","is-pseudo-class","scope-pseudo-class","has-pseudo-class","gap-properties","overflow-property","overflow-wrap-property","place-properties","system-ui-font-family","stepped-value-functions","trigonometric-functions","cascade-layers"];function featureIsLess(s,e){return s.id===e.id?s[is]&&e[is]||s[rs]&&e[rs]?clamp(-1,s[ns]-e[ns],1):s[is]||e[rs]?-1:s[rs]||e[is]?1:0:clamp(-1,cs.indexOf(s.id)-cs.indexOf(e.id),1)}function postcssSystemUiFont(){return{postcssPlugin:"postcss-system-ui-font",Declaration(s){ps.test(s.prop)&&(s.value.includes(us.join(", "))||(s.value=s.value.replace(ds,ms)))}}}postcssSystemUiFont.postcss=!0;const ps=/(?:^(?:-|\\002d){2})|(?:^font(?:-family)?$)/i,ls="[\\f\\n\\r\\x09\\x20]",us=["system-ui","-apple-system","Segoe UI","Roboto","Ubuntu","Cantarell","Noto Sans","sans-serif"],ds=new RegExp(`(^|,|${ls}+)(?:system-ui${ls}*)(?:,${ls}*(?:${us.join("|")})${ls}*)?(,|$)`,"i"),ms=`$1${us.join(", ")}$2`,gs=new Map([["all-property",V],["any-link-pseudo-class",B],["blank-pseudo-class",e],["break-properties",D],["cascade-layers",c],["case-insensitive-attributes",a],["clamp",Y.exports],["color-function",p],["color-functional-notation",l],["custom-media-queries",m],["custom-properties",g],["custom-selectors",f],["dir-pseudo-class",h],["display-two-values",F],["double-position-gradients",v],["focus-visible-pseudo-class",b],["focus-within-pseudo-class",S],["font-format-keywords",y],["font-variant-property",j],["gap-properties",w],["has-pseudo-class",r],["hexadecimal-alpha-notation",u],["hwb-function",C],["ic-unit",N],["image-set-function",k],["is-pseudo-class",P],["lab-function",x],["logical-properties-and-values",L],["media-queries-aspect-ratio-number-values",W],["media-query-ranges",_],["nested-calc",R],["nesting-rules",q],["not-pseudo-class",H],["oklab-function",O],["opacity-percentage",ss.exports],["overflow-property",T],["overflow-wrap-property",z],["place-properties",$],["prefers-color-scheme-query",n],["rebeccapurple-color",d],["scope-pseudo-class",G],["stepped-value-functions",J],["system-ui-font-family",postcssSystemUiFont],["text-decoration-shorthand",K],["trigonometric-functions",Q],["unset-value",Z]]);function featureIsInsertedOrHasAPlugin(s){return!!s[is]||!!s[rs]||!!gs.has(s.id)}function prepareFeaturesList(s,e,o){return s.concat(getTransformedInsertions(s,e,"insertBefore"),getTransformedInsertions(s,o,"insertAfter")).filter((s=>featureIsInsertedOrHasAPlugin(s))).sort(((s,e)=>featureIsLess(s,e)))}const fs=["and_chr","and_ff","and_qq","and_uc","android","baidu","chrome","edge","firefox","ie","ie_mob","ios_saf","kaios","op_mini","op_mob","opera","safari","samsung"];function getUnsupportedBrowsersByFeature(s){if(!s)return[];if(!("browser_support"in s))return["> 0%"];const e=[];return fs.forEach((o=>{if("op_mini"===o&&void 0===s.browser_support[o])return void e.push("op_mini all");const t=s.browser_support[o];"string"==typeof t&&/^[0-9|.]+$/.test(t)?e.push(`${o} < ${s.browser_support[o]}`):e.push(`${o} >= 1`)})),e}function getOptionsForBrowsersByFeature(s,e,o,t){const i=E(s,{ignoreUnknownVersions:!0});switch(e.id){case"is-pseudo-class":return{onComplexSelector:"warning"};case"nesting-rules":return needsOptionFor(o.find((s=>"is-pseudo-class"===s.id)),i)?(t.log('Disabling :is on "nesting-rules" due to lack of browser support.'),{noIsPseudoSelector:!0}):{};case"any-link-pseudo-class":return i.find((s=>s.startsWith("ie ")||s.startsWith("edge ")))?(t.log('Adding area[href] fallbacks for ":any-link" support in Edge and IE.'),{subFeatures:{areaHrefNeedsFixing:!0}}):{};default:return{}}}function needsOptionFor(s,e){const o=getUnsupportedBrowsersByFeature(s);return!!e.some((s=>E(o,{ignoreUnknownVersions:!0}).some((e=>e===s))))}function formatPolyfillableFeature(s){const e=getUnsupportedBrowsersByFeature(s);if(s[is]||s[rs]){let o=s.id;return o=s.insertBefore?`before-${o}`:`after-${o}`,{browsers:e,vendors_implementations:s.vendors_implementations,plugin:s[as],id:o,stage:6}}return{browsers:e,vendors_implementations:s.vendors_implementations,plugin:gs.get(s.id),id:s.id,stage:s.stage}}function formatStagedFeature(s,e,o,t,i,r){let n,a;return n=getOptionsForBrowsersByFeature(e,t,s,r),!0===o[t.id]?i&&(n=Object.assign({},n,i)):n=i?Object.assign({},n,i,o[t.id]):Object.assign({},n,o[t.id]),n.enableProgressiveCustomProperties=!1,"all-property"===t.id&&"preserve"in n&&(n.replace=n.preserve),"overflow-wrap-property"===t.id&&"preserve"in n&&(n.method=n.preserve?"copy":"replace"),a=t.plugin.postcss&&"function"==typeof t.plugin?t.plugin(n):t.plugin&&t.plugin.default&&"function"==typeof t.plugin.default&&t.plugin.default.postcss?t.plugin.default(n):t.plugin,{browsers:t.browsers,vendors_implementations:t.vendors_implementations,plugin:a,pluginOptions:n,id:t.id}}function intOrZero(s){const e=parseInt(s,10);return Number.isNaN(e)?0:e}function listFeatures(s,e,o,t){const i=Object(e.features),r="enableClientSidePolyfills"in e&&e.enableClientSidePolyfills,n=Object(e.insertBefore),a=Object(e.insertAfter),c=e.browsers,p=clamp(0,intOrZero(e.minimumVendorImplementations),3);p>0&&t.log(`Using features with ${p} or more vendor implementations`);const l=stageFromOptions(e,t);2===l&&o&&!1===o.preserve&&(s=JSON.parse(JSON.stringify(s))).forEach((s=>{("blank-pseudo-class"===s.id||"prefers-color-scheme-query"===s.id)&&(s.stage=1)}));const u=prepareFeaturesList(s,n,a).map((s=>formatPolyfillableFeature(s))).filter((s=>0===p||!(!s[is]&&!s[rs])||p<=s.vendors_implementations||(i[s.id]?(t.log(` ${s.id} does not meet the required vendor implementations but has been enabled by options`),!0):(t.log(` ${s.id} with ${s.vendors_implementations} vendor implementations has been disabled`),!1)))).filter((s=>{const e=s.stage>=l,o=r||!ts.includes(s.id),n=!1===i[s.id],a=i[s.id]?i[s.id]:e&&o;return n?t.log(` ${s.id} has been disabled by options`):e?o||t.log(` ${s.id} has been disabled by "enableClientSidePolyfills: false".`):a?t.log(` ${s.id} does not meet the required stage but has been enabled by options`):t.log(` ${s.id} with stage ${s.stage} has been disabled`),a})).map((e=>formatStagedFeature(s,c,i,e,o,t))),d=E(c,{ignoreUnknownVersions:!0});return u.filter((s=>{if(s.id in i)return i[s.id];const e=E(s.browsers,{ignoreUnknownVersions:!0}),o=d.some((s=>e.some((e=>e===s))));return o||t.log(`${s.id} disabled due to browser support`),o}))}class Logger{constructor(){this.logs=[]}log(s){this.logs.push(s)}resetLogger(){this.logs.length=0}dumpLogs(s){s&&this.logs.forEach((e=>s.warn(e))),this.resetLogger()}}var hs=[{packageName:"css-blank-pseudo",id:"blank-pseudo-class",importName:"postcssBlankPseudo"},{packageName:"css-has-pseudo",id:"has-pseudo-class",importName:"postcssHasPseudo"},{packageName:"css-prefers-color-scheme",id:"prefers-color-scheme-query",importName:"postcssPrefersColorScheme"},{packageName:"postcss-attribute-case-insensitive",id:"case-insensitive-attributes",importName:"postcssAttributeCaseInsensitive"},{packageName:"postcss-clamp",id:"clamp",importName:"postcssClamp"},{packageName:"@csstools/postcss-color-function",id:"color-function",importName:"postcssColorFunction"},{packageName:"postcss-color-functional-notation",id:"color-functional-notation",importName:"postcssColorFunctionalNotation"},{packageName:"postcss-color-hex-alpha",id:"hexadecimal-alpha-notation",importName:"postcssColorHexAlpha"},{packageName:"postcss-color-rebeccapurple",id:"rebeccapurple-color",importName:"postcssColorRebeccapurple"},{packageName:"postcss-custom-media",id:"custom-media-queries",importName:"postcssCustomMedia"},{packageName:"postcss-custom-properties",id:"custom-properties",importName:"postcssCustomProperties"},{packageName:"postcss-custom-selectors",id:"custom-selectors",importName:"postcssCustomSelectors"},{packageName:"postcss-dir-pseudo-class",id:"dir-pseudo-class",importName:"postcssDirPseudoClass"},{packageName:"postcss-double-position-gradients",id:"double-position-gradients",importName:"postcssDoublePositionGradients"},{packageName:"postcss-focus-visible",id:"focus-visible-pseudo-class",importName:"postcssFocusVisible"},{packageName:"postcss-focus-within",id:"focus-within-pseudo-class",importName:"postcssFocusWithin"},{packageName:"@csstools/postcss-font-format-keywords",id:"font-format-keywords",importName:"postcssFontFormatKeywords"},{packageName:"postcss-font-variant",id:"font-variant-property",importName:"postcssFontVariant"},{packageName:"postcss-gap-properties",id:"gap-properties",importName:"postcssGapProperties"},{packageName:"@csstools/postcss-hwb-function",id:"hwb-function",importName:"postcssHWBFunction"},{packageName:"@csstools/postcss-ic-unit",id:"ic-unit",importName:"postcssICUnit"},{packageName:"postcss-image-set-function",id:"image-set-function",importName:"postcssImageSetFunction"},{packageName:"postcss-initial",id:"all-property",importName:"postcssInitial"},{packageName:"@csstools/postcss-is-pseudo-class",id:"is-pseudo-class",importName:"postcssIsPseudoClass"},{packageName:"@csstools/postcss-scope-pseudo-class",id:"scope-pseudo-class",importName:"postcssScopePseudoClass"},{packageName:"postcss-lab-function",id:"lab-function",importName:"postcssLabFunction"},{packageName:"postcss-logical",id:"logical-properties-and-values",importName:"postcssLogical"},{packageName:"postcss-media-minmax",id:"media-query-ranges",importName:"postcssMediaMinmax"},{packageName:"@csstools/postcss-media-queries-aspect-ratio-number-values",id:"media-queries-aspect-ratio-number-values",importName:"postcssMediaQueriesAspectRatioNumberValues"},{packageName:"postcss-nesting",id:"nesting-rules",importName:"postcssNesting"},{packageName:"@csstools/postcss-normalize-display-values",id:"display-two-values",importName:"postcssNormalizeDisplayValues"},{packageName:"@csstools/postcss-oklab-function",id:"oklab-function",importName:"postcssOKLabFunction"},{packageName:"postcss-opacity-percentage",id:"opacity-percentage",importName:"postcssOpacityPercentage"},{packageName:"postcss-overflow-shorthand",id:"overflow-property",importName:"postcssOverflowShorthand"},{packageName:"postcss-page-break",id:"break-properties",importName:"postcssPageBreak"},{packageName:"postcss-place",id:"place-properties",importName:"postcssPlace"},{packageName:"postcss-pseudo-class-any-link",id:"any-link-pseudo-class",importName:"postcssPseudoClassAnyLink"},{packageName:"postcss-replace-overflow-wrap",id:"overflow-wrap-property",importName:"postcssReplaceOverflowWrap"},{packageName:"postcss-selector-not",id:"not-pseudo-class",importName:"postcssSelectorNot"},{packageName:"@csstools/postcss-stepped-value-functions",id:"stepped-value-functions",importName:"postcssSteppedValueFunctions"},{packageName:"postcss-system-ui-font-family",importedPackage:"../patch/postcss-system-ui-font-family.mjs",id:"system-ui-font-family",importName:"postcssFontFamilySystemUI"},{packageName:"@csstools/postcss-unset-value",id:"unset-value",importName:"postcssUnsetValue"},{packageName:"@csstools/postcss-cascade-layers",id:"cascade-layers",importName:"postcssCascadeLayers"},{packageName:"@csstools/postcss-trigonometric-functions",id:"trigonometric-functions",importName:"postcssTrigonometricFunctions"},{packageName:"@csstools/postcss-nested-calc",id:"nested-calc",importName:"postcssNestedCalc"},{packageName:"@csstools/postcss-text-decoration-shorthand",id:"text-decoration-shorthand",importName:"postcssTextDecorationShorthand"}];function getPackageNamesToIds(){const s={};return hs.forEach((e=>{s[e.packageName]=e.id})),s}function pluginIdHelp(s,e,o){const t=hs.map((s=>s.id)),i=hs.map((s=>s.packageName)),r=getPackageNamesToIds();s.forEach((s=>{if(t.includes(s))return;const n=mostSimilar(s,t),a=mostSimilar(s,i);Math.min(n.distance,a.distance)>10?e.warn(o`Unknown feature: "${s}", see the list of features https://github.com/csstools/postcss-plugins/blob/main/plugin-packs/postcss-preset-env/FEATURES.md`):n.distance<a.distance?e.warn(o,`Unknown feature: "${s}", did you mean: "${n.mostSimilar}"`):e.warn(o,`Unknown feature: "${s}", did you mean: "${r[a.mostSimilar]}"`)}))}function mostSimilar(s,e){let o="unknown",t=1/0;for(let i=0;i<e.length;i++){const r=levenshteinDistance(s,e[i]);r<t&&(t=r,o=e[i])}return{mostSimilar:o,distance:t}}function levenshteinDistance(s,e){if(!s.length)return e.length;if(!e.length)return s.length;const o=[];for(let t=0;t<=e.length;t++){o[t]=[t];for(let i=1;i<=s.length;i++)o[t][i]=0===t?i:Math.min(o[t-1][i]+1,o[t][i-1]+1,o[t-1][i-1]+(s[i-1]===e[t-1]?0:1))}return o[e.length][s.length]}const creator=s=>{const e=new Logger,o=Object(s),t=Object.keys(Object(o.features)),i=o.browsers,r=initializeSharedOptions(o),n=listFeatures(M,o,r,e),a=n.map((s=>s.plugin));!1!==o.autoprefixer&&a.push(I(Object.assign({overrideBrowserslist:i},o.autoprefixer))),a.push(A()),logFeaturesList(n,o,e);const internalPlugin=()=>({postcssPlugin:"postcss-preset-env",OnceExit:function(s,{result:i}){pluginIdHelp(t,s,i),o.debug&&e.dumpLogs(i),e.resetLogger()}});return internalPlugin.postcss=!0,{postcssPlugin:"postcss-preset-env",plugins:[...a,internalPlugin()]}};creator.postcss=!0,function main(){switch(process.argv[2]??!1){case"css-blank-pseudo":return void cli(e,["preserve","replaceWith"],helpTextLogger("@csstools/cli css-blank-pseudo","PostCSS Blank Pseudo","Lets you style form elements when they are empty, following the Selectors Level 4 specification.",{preserve:!0,replaceWith:".css-blank"}),!1);case"css-has-pseudo":return void cli(r,["preserve"],helpTextLogger("@csstools/cli css-has-pseudo","PostCSS Has Pseudo","Transforms CSS with :has {}",{preserve:!0}),!1);case"css-prefers-color-scheme":return void cli(n,["preserve","mediaQuery"],helpTextLogger("@csstools/cli css-prefers-color-scheme","Prefers Color Scheme","Lets you use light and dark color schemes in all browsers, following the Media Queries specification.",{preserve:!0,mediaQuery:"color|color-index"}),!1);case"postcss-attribute-case-insensitive":return void cli(a,[],helpTextLogger("@csstools/cli postcss-attribute-case-insensitive","PostCSS Attribute Case Insensitive","Enables support for Case Insensitive Attribute matching in selectors"),!1);case"postcss-cascade-layers":return void cli(c,[],helpTextLogger("@csstools/cli postcss-cascade-layers","PostCSS Cascade Layers","Lets you use `@layer` following the Cascade Layers Specification."),!1);case"postcss-color-function":return void cli(p,["preserve","enableProgressiveCustomProperties"],helpTextLogger("@csstools/cli postcss-color-function","PostCSS Color Function","Lets you use the color() function in CSS.",{preserve:!0,enableProgressiveCustomProperties:!1}),!1);case"postcss-color-functional-notation":return void cli(l,["preserve"],helpTextLogger("@csstools/cli postcss-color-functional-notation","PostCSS Color Functional Notation","Lets you use space and slash separated color notation in CSS, following the CSS Color specification.",{preserve:!0}),!1);case"postcss-color-hex-alpha":return void cli(u,["preserve"],helpTextLogger("@csstools/cli postcss-color-hex-alpha","PostCSS Color Hex Alpha","Lets you use 4 & 8 character hex color notation in CSS, following the CSS Color Module specification.",{preserve:!0}),!1);case"postcss-color-rebeccapurple":return void cli(d,["preserve"],helpTextLogger("@csstools/cli postcss-color-rebeccapurple","PostCSS RebeccaPurple","Lets you use the rebeccapurple color keyword in CSS.",{preserve:!0}),!1);case"postcss-custom-media":return void cli(m,["preserve"],helpTextLogger("@csstools/cli postcss-custom-media","PostCSS Custom Media","Lets you define @custom-media in CSS following the Custom Media Specification",{preserve:!0}),!1);case"postcss-custom-properties":return void cli(g,["preserve"],helpTextLogger("@csstools/cli postcss-custom-properties","PostCSS Custom Properties","Lets you use Custom Properties in CSS, following the CSS Custom Properties specification.",{preserve:!0}),!1);case"postcss-custom-selectors":return void cli(f,["preserve"],helpTextLogger("@csstools/cli postcss-custom-selectors","PostCSS Custom Selectors","Lets you define @custom-selector in CSS following the Custom Selectors Specification",{preserve:!0}),!1);case"postcss-dir-pseudo-class":return void cli(h,["dir","preserve","shadow"],helpTextLogger("@csstools/cli postcss-dir-pseudo-class","PostCSS Dir Pseudo Class","Lets you style by directionality using the `:dir()` pseudo-class in CSS",{dir:"ltr",preserve:!0,shadow:!0}),!1);case"postcss-double-position-gradients":return void cli(v,["preserve","enableProgressiveCustomProperties"],helpTextLogger("@csstools/cli postcss-double-position-gradients","PostCSS Double Position Gradients","Lets you use double-position gradients in CSS, following the CSS Image Values and Replaced Content specification",{preserve:!0,enableProgressiveCustomProperties:!1}),!1);case"postcss-focus-visible":return void cli(b,["preserve","replaceWith"],helpTextLogger("@csstools/cli postcss-focus-visible","PostCSS Focus Visible","Lets you use the `:focus-visible` pseudo-class in CSS, following the Selectors Level 4 specification.",{preserve:!0,replaceWith:".focus-visible"}),!1);case"postcss-focus-within":return void cli(S,["preserve","replaceWith"],helpTextLogger("@csstools/cli postcss-focus-within","PostCSS Focus Within","Lets you use the `:focus-within` pseudo-class in CSS, following the Selectors Level 4 specification.",{preserve:!0,replaceWith:".focus-within"}),!1);case"postcss-font-format-keywords":return void cli(y,["preserve"],helpTextLogger("@csstools/cli postcss-font-format-keywords","PostCSS Font Format Keyword","Lets you use unquoted format on @font-face CSS definitions.",{preserve:!0}),!1);case"postcss-gap-properties":return void cli(w,["preserve"],helpTextLogger("@csstools/cli postcss-gap-properties","PostCSS Gap Properties","Lets you use the gap, column-gap, and row-gap shorthand properties in CSS, following the CSS Grid Layout specification.",{preserve:!0}),!1);case"postcss-hwb-function":return void cli(C,["preserve"],helpTextLogger("@csstools/cli postcss-hwb-function","PostCSS HWB function","Convert hwb() to rgb()",{preserve:!0}),!1);case"postcss-ic-unit":return void cli(N,["preserve","enableProgressiveCustomProperties"],helpTextLogger("@csstools/cli postcss-ic-unit","PostCSS IC Unit","Lets you use the ic length unit.",{preserve:!0,enableProgressiveCustomProperties:!1}),!1);case"postcss-image-set-function":return void cli(k,["oninvalid","preserve"],helpTextLogger("@csstools/cli postcss-image-set-function","PostCSS Image Set Function","Lets you display resolution-dependent images using the image-set() function in CSS, following the CSS Images specification.",{preserve:!0,oninvalid:"ignore|warn|throw"}),!1);case"postcss-is-pseudo-class":return void cli(P,["onComplexSelector","preserve","specificityMatchingName"],helpTextLogger("@csstools/cli postcss-is-pseudo-class","PostCSS Is Pseudo Class","Lets you use the :is pseudo class function, following the CSS Selector specification.",{onComplexSelector:"warning",preserve:!0,specificityMatchingName:"does-not-exist"}),!1);case"postcss-lab-function":return void cli(x,["preserve","enableProgressiveCustomProperties","subFeatures"],helpTextLogger("@csstools/cli postcss-lab-function","PostCSS Lab function","Convert lab() to rgb()",{preserve:!0,enableProgressiveCustomProperties:!1,subFeatures:{displayP3:!1}}),!1);case"postcss-logical":return void cli(L,["dir","preserve"],helpTextLogger("@csstools/cli postcss-logical","PostCSS Logical","Lets you use logical, rather than physical, direction and dimension mappings in CSS, following the CSS Logical Properties and Values specification.",{dir:"ltr|rtl",preserve:!0}),!1);case"postcss-nesting":return void cli(q,["noIsPseudoSelector"],helpTextLogger("@csstools/cli postcss-nesting","PostCSS Nesting","Lets you nest style rules inside each other, following the CSS Nesting specification.",{noIsPseudoSelector:!0}),!1);case"postcss-normalize-display-values":return void cli(F,["preserve"],helpTextLogger("@csstools/cli postcss-normalize-display-values","PostCSS Normalize Display Values","Lets you use two values display syntax for inner and outer display types.",{preserve:!0}),!1);case"postcss-oklab-function":return void cli(O,["preserve","enableProgressiveCustomProperties","subFeatures"],helpTextLogger("@csstools/cli postcss-oklab-function","PostCSS OKLab Function","Lets you use oklab() and oklch() color functions in CSS.",{preserve:!0,enableProgressiveCustomProperties:!1,subFeatures:{displayP3:!1}}),!1);case"postcss-overflow-shorthand":return void cli(T,["preserve"],helpTextLogger("@csstools/cli postcss-overflow-shorthand","PostCSS Overflow Shorthand","Lets you use the `overflow` shorthand in CSS, following the CSS Overflow specification.",{preserve:!0}),!1);case"postcss-place":return void cli($,["preserve"],helpTextLogger("@csstools/cli postcss-place","PostCSS Place","Lets you use place-* properties as shorthands for align-* and justify-*, following the CSS Box Alignment specification.",{preserve:!0}),!1);case"postcss-preset-env":return void cli(creator,["stage","minimumVendorImplementations","features","browsers","autoprefixer","preserve","enableClientSidePolyfills"],helpTextLogger("@csstools/cli postcss-preset-env","PostCSS Preset Env","Lets you convert modern CSS into something most browsers can understand, determining the polyfills you need based on your targeted browsers or runtime environments.",{stage:0,minimumVendorImplementations:2,features:{"blank-pseudo-class":{preserve:!1},"color-functional-notation":{preserve:!0}},browsers:"last 2 versions",autoprefixer:{grid:!0},preserve:!1,enableClientSidePolyfills:!1}),!1);case"postcss-pseudo-class-any-link":return void cli(B,["preserve"],helpTextLogger("@csstools/cli postcss-pseudo-class-any-link","PostCSS Pseudo Class Any Link","Lets you :any-link pseudo-class in CSS, following the Selectors specification.",{preserve:!0}),!1);case"postcss-selector-not":return void cli(H,[],helpTextLogger("@csstools/cli postcss-selector-not","PostCSS Selector Not","Transforms :not() W3C CSS level 4 pseudo classes to :not() CSS level 3 selectors following the Selectors 4 Specification"),!1);case"postcss-stepped-value-functions":return void cli(J,["preserve","onInvalid"],helpTextLogger("@csstools/cli postcss-stepped-value-functions","PostCSS Stepped Value Functions","Lets you use round(), mod() and rem() functions.",{preserve:!1,onInvalid:"warn"}),!1);case"postcss-trigonometric-functions":return void cli(Q,["preserve"],helpTextLogger("@csstools/cli postcss-trigonometric-functions","PostCSS Trigonometric Functions","Lets you use `sin`, `cos`, `tan`, `asin`, `acos`, `atan` and `atan2` to be able to compute trigonometric relationships following the CSS Values 4 specification.",{preserve:!0}),!1);case"postcss-unset-value":return void cli(Z,["preserve"],helpTextLogger("@csstools/cli postcss-unset-value","PostCSS Stepped Unset Value","Use the unset keyword in CSS.",{preserve:!1}),!1);default:{const s=["CSSTools CLI\n"," Transform CSS with any plugin from https://github.com/csstools/postcss-plugins\n","Usage:"," @csstools/csstools-cli postcss-preset-env [input.css] [OPTIONS] [-o|--output output.css]"," @csstools/csstools-cli postcss-preset-env <input.css>... [OPTIONS] --dir <output-directory>"," @csstools/csstools-cli postcss-preset-env <input.css>... [OPTIONS] --replace","\nAvailable Plugins:"," css-blank-pseudo"," css-has-pseudo"," css-prefers-color-scheme"," postcss-attribute-case-insensitive"," postcss-cascade-layers"," postcss-color-function"," postcss-color-functional-notation"," postcss-color-hex-alpha"," postcss-color-rebeccapurple"," postcss-custom-media"," postcss-custom-properties"," postcss-custom-selectors"," postcss-dir-pseudo-class"," postcss-double-position-gradients"," postcss-env-function"," postcss-focus-visible"," postcss-focus-within"," postcss-font-format-keywords"," postcss-gap-properties"," postcss-hwb-function"," postcss-ic-unit"," postcss-image-set-function"," postcss-is-pseudo-class"," postcss-lab-function"," postcss-logical"," postcss-nesting"," postcss-normalize-display-values"," postcss-oklab-function"," postcss-overflow-shorthand"," postcss-place"," postcss-pseudo-class-any-link"," postcss-selector-not"," postcss-stepped-value-functions"," postcss-trigonometric-functions"," postcss-unset-value","\nPlugin Help:"," @csstools/csstools-cli <plugin-name>"," @csstools/csstools-cli postcss-preset-env"];console.warn(s.join("\n"))}}}();