"use strict";var s=require("autoprefixer"),e=require("cssdb"),t=require("@csstools/postcss-progressive-custom-properties"),o=require("fs"),i=require("path"),r=require("browserslist"),a=require("postcss-initial"),n=require("postcss-pseudo-class-any-link"),c=require("css-blank-pseudo"),p=require("postcss-page-break"),u=require("@csstools/postcss-cascade-layers"),l=require("postcss-attribute-case-insensitive"),m=require("postcss-clamp"),d=require("@csstools/postcss-color-function"),f=require("postcss-color-functional-notation"),g=require("postcss-custom-media"),b=require("postcss-custom-properties"),h=require("postcss-custom-selectors"),y=require("postcss-dir-pseudo-class"),k=require("@csstools/postcss-normalize-display-values"),N=require("postcss-double-position-gradients"),v=require("postcss-env-function"),w=require("postcss-focus-visible"),q=require("postcss-focus-within"),$=require("@csstools/postcss-font-format-keywords"),O=require("postcss-font-variant"),S=require("postcss-gap-properties"),x=require("css-has-pseudo"),j=require("postcss-color-hex-alpha"),P=require("@csstools/postcss-hwb-function"),F=require("@csstools/postcss-ic-unit"),E=require("postcss-image-set-function"),M=require("@csstools/postcss-is-pseudo-class"),C=require("postcss-lab-function"),_=require("postcss-logical"),A=require("postcss-media-minmax"),R=require("postcss-nesting"),U=require("postcss-selector-not"),B=require("@csstools/postcss-oklab-function"),T=require("postcss-opacity-percentage"),I=require("postcss-overflow-shorthand"),V=require("postcss-replace-overflow-wrap"),W=require("postcss-place"),L=require("css-prefers-color-scheme"),D=require("postcss-color-rebeccapurple"),H=require("@csstools/postcss-stepped-value-functions"),J=require("@csstools/postcss-trigonometric-functions"),z=require("@csstools/postcss-unset-value");function G(s){return s&&"object"==typeof s&&"default"in s?s:{default:s}}var K=G(s),Q=G(e),X=G(t),Y=G(o),Z=G(i),ss=G(r),es=G(a),ts=G(n),os=G(c),is=G(p),rs=G(u),as=G(l),ns=G(m),cs=G(d),ps=G(f),us=G(g),ls=G(b),ms=G(h),ds=G(y),fs=G(k),gs=G(N),bs=G(v),hs=G(w),ys=G(q),ks=G($),Ns=G(O),vs=G(S),ws=G(x),qs=G(j),$s=G(P),Os=G(F),Ss=G(E),xs=G(M),js=G(C),Ps=G(_),Fs=G(A),Es=G(R),Ms=G(U),Cs=G(B),_s=G(T),As=G(I),Rs=G(V),Us=G(W),Bs=G(L),Ts=G(D),Is=G(H),Vs=G(J),Ws=G(z);const Ls={"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"},Ds=["blank-pseudo-class","focus-visible-pseudo-class","focus-within-pseudo-class","has-pseudo-class","prefers-color-scheme-query"];async function Hs(s,e,t,o){const i=function(s){return`:root {\n${Object.keys(s).reduce(((e,t)=>(e.push(`\t${t}: ${s[t]};`),e)),[]).join("\n")}\n}\n`}(t),r=function(s){return`${Object.keys(s).reduce(((e,t)=>(e.push(`@custom-media ${t} ${s[t]};`),e)),[]).join("\n")}\n`}(e),a=function(s){return`${Object.keys(s).reduce(((e,t)=>(e.push(`@custom-selector ${t} ${s[t]};`),e)),[]).join("\n")}\n`}(o),n=`${r}\n${a}\n${i}`;await Qs(s,n)}function Js(s,e){return`\n\t${s}: {\n${Object.keys(e).reduce(((s,t)=>(s.push(`\t\t'${Xs(t)}': '${Xs(e[t])}'`),s)),[]).join(",\n")}\n\t}`}function zs(s,e){return`export const ${s} = {\n${Object.keys(e).reduce(((s,t)=>(s.push(`\t'${Xs(t)}': '${Xs(e[t])}'`),s)),[]).join(",\n")}\n};\n`}function Gs(s,e){return Promise.all([].concat(e).map((async e=>{if(e instanceof Function)await e({customMedia:Ks(s.customMedia),customProperties:Ks(s.customProperties),customSelectors:Ks(s.customSelectors)});else{const t=e===Object(e)?e:{to:String(e)},o=t.toJSON||Ks;if("customMedia"in t||"customProperties"in t||"customSelectors"in t)t.customMedia=o(s.customMedia),t.customProperties=o(s.customProperties),t.customSelectors=o(s.customSelectors);else if("custom-media"in t||"custom-properties"in t||"custom-selectors"in t)t["custom-media"]=o(s.customMedia),t["custom-properties"]=o(s.customProperties),t["custom-selectors"]=o(s.customSelectors);else{const e=String(t.to||""),i=(t.type||Z.default.extname(t.to).slice(1)).toLowerCase(),r=o(s.customMedia),a=o(s.customProperties),n=o(s.customSelectors);"css"===i&&await Hs(e,r,a,n),"js"===i&&await async function(s,e,t,o){const i=`module.exports = {${Js("customMedia",e)},${Js("customProperties",t)},${Js("customSelectors",o)}\n};\n`;await Qs(s,i)}(e,r,a,n),"json"===i&&await async function(s,e,t,o){const i=`${JSON.stringify({"custom-media":e,"custom-properties":t,"custom-selectors":o},null," ")}\n`;await Qs(s,i)}(e,r,a,n),"mjs"===i&&await async function(s,e,t,o){const i=`${zs("customMedia",e)}\n${zs("customProperties",t)}\n${zs("customSelectors",o)}`;await Qs(s,i)}(e,r,a,n)}}})))}function Ks(s){return Object.keys(s).reduce(((e,t)=>(e[t]=String(s[t]),e)),{})}function Qs(s,e){return new Promise(((t,o)=>{Y.default.writeFile(s,e,(s=>{s?o(s):t()}))}))}function Xs(s){return s.replace(/\\([\s\S])|(')/g,"\\$1$2").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}function Ys(s,e){if(!s)return!1;if("string"==typeof s)return!0;if(Array.isArray(s)){for(let t=0;ts.id===t)))continue;let r=e[t];Array.isArray(r)||(r=[r]);for(let s=0;sfunction(s){return!!s[se]||!!s[ee]||!!me.has(s.id)}(s))).sort(((s,e)=>function(s,e){return s.id===e.id?s[se]&&e[se]||s[ee]&&e[ee]?Zs(-1,s[te]-e[te],1):s[se]||e[ee]?-1:s[ee]||e[se]?1:0:Zs(-1,re.indexOf(s.id)-re.indexOf(e.id),1)}(s,e)))}const fe=["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 ge(s){if(!s)return[];if(!("browser_support"in s))return["> 0%"];const e=[];return fe.forEach((t=>{if("op_mini"===t&&void 0===s.browser_support[t])return void e.push("op_mini all");const o=s.browser_support[t];"string"==typeof o&&/^[0-9|.]+$/.test(o)?e.push(`${t} < ${s.browser_support[t]}`):e.push(`${t} >= 1`)})),e}function be(s,e,t,o){const i=ss.default(s,{ignoreUnknownVersions:!0});switch(e.id){case"is-pseudo-class":return{onComplexSelector:"warning"};case"nesting-rules":if(function(s,e){const t=ge(s);if(e.some((s=>ss.default(t,{ignoreUnknownVersions:!0}).some((e=>e===s)))))return!0;return!1}(t.find((s=>"is-pseudo-class"===s.id)),i))return o.log('Disabling :is on "nesting-rules" due to lack of browser support.'),{noIsPseudoSelector:!0};return{};case"any-link-pseudo-class":if(i.find((s=>s.startsWith("ie ")||s.startsWith("edge "))))return o.log('Adding area[href] fallbacks for ":any-link" support in Edge and IE.'),{subFeatures:{areaHrefNeedsFixing:!0}};return{};default:return{}}}function he(s,e,t,o){const i=Object(e.features),r=!("enableClientSidePolyfills"in e)||e.enableClientSidePolyfills,a=Object(e.insertBefore),n=Object(e.insertAfter),c=e.browsers,p=Zs(0,function(s){const e=parseInt(s,10);return Number.isNaN(e)?0:e}(e.minimumVendorImplementations),3);p>0&&o.log(`Using features with ${p} or more vendor implementations`);const u=function(s,e){let t=2;if(void 0===s.stage)return e.log(`Using features from Stage ${t} (default)`),t;if(!1===s.stage)t=5;else{let e=parseInt(s.stage,10);Number.isNaN(e)&&(e=0),t=Zs(0,e,5)}return 5===t?e.log('Stage has been disabled, features will be handled via the "features" option.'):e.log(`Using features from Stage ${t}`),t}(e,o);2===u&&t&&!1===t.preserve&&(s=JSON.parse(JSON.stringify(s))).forEach((s=>{("blank-pseudo-class"===s.id||"prefers-color-scheme-query"===s.id)&&(s.stage=1)}));const l=de(s,a,n).map((s=>function(s){const e=ge(s);if(s[se]||s[ee]){let t=s.id;return t=s.insertBefore?`before-${t}`:`after-${t}`,{browsers:e,vendors_implementations:s.vendors_implementations,plugin:s[oe],id:t,stage:6}}return{browsers:e,vendors_implementations:s.vendors_implementations,plugin:me.get(s.id),id:s.id,stage:s.stage}}(s))).filter((s=>0===p||(!(!s[se]&&!s[ee])||(p<=s.vendors_implementations||(i[s.id]?(o.log(` ${s.id} does not meet the required vendor implementations but has been enabled by options`),!0):(o.log(` ${s.id} with ${s.vendors_implementations} vendor implementations has been disabled`),!1)))))).filter((s=>{const e=s.stage>=u,t=r||!Ds.includes(s.id),a=!1===i[s.id],n=i[s.id]?i[s.id]:e&&t;return a?o.log(` ${s.id} has been disabled by options`):e?t||o.log(` ${s.id} has been disabled by "enableClientSidePolyfills: false".`):n?o.log(` ${s.id} does not meet the required stage but has been enabled by options`):o.log(` ${s.id} with stage ${s.stage} has been disabled`),n})).map((e=>function(s,e,t,o,i,r){let a,n;return a=be(e,o,s,r),!0===t[o.id]?i&&(a=Object.assign({},a,i)):a=i?Object.assign({},a,i,t[o.id]):Object.assign({},a,t[o.id]),a.enableProgressiveCustomProperties=!1,n=o.plugin.postcss&&"function"==typeof o.plugin?o.plugin(a):o.plugin&&o.plugin.default&&"function"==typeof o.plugin.default&&o.plugin.default.postcss?o.plugin.default(a):o.plugin,{browsers:o.browsers,vendors_implementations:o.vendors_implementations,plugin:n,pluginOptions:a,id:o.id}}(s,c,i,e,t,o))),m=ss.default(c,{ignoreUnknownVersions:!0});return l.filter((s=>{if(s.id in i)return i[s.id];if(function(s){if("importFrom"in Object(s.pluginOptions))switch(s.id){case"custom-media-queries":if(Ys(s.pluginOptions.importFrom,"customMedia"))return!0;break;case"custom-properties":if(Ys(s.pluginOptions.importFrom,"customProperties"))return!0;break;case"environment-variables":if(Ys(s.pluginOptions.importFrom,"environmentVariables"))return!0;break;case"custom-selectors":if(Ys(s.pluginOptions.importFrom,"customSelectors"))return!0}if("exportTo"in Object(s.pluginOptions))switch(s.id){case"custom-media-queries":if(Ys(s.pluginOptions.exportTo,"customMedia"))return!0;break;case"custom-properties":if(Ys(s.pluginOptions.exportTo,"customProperties"))return!0;break;case"environment-variables":if(Ys(s.pluginOptions.exportTo,"environmentVariables"))return!0;break;case"custom-selectors":if(Ys(s.pluginOptions.exportTo,"customSelectors"))return!0}return!1}(s))return!0;const e=ss.default(s.browsers,{ignoreUnknownVersions:!0}),t=m.some((s=>e.some((e=>e===s))));return t||o.log(`${s.id} disabled due to browser support`),t}))}class ye{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 ke=[{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-env-function",id:"environment-variables",importName:"postcssEnvFunction"},{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:"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:"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"}];function Ne(s,e,t){const o=ke.map((s=>s.id)),i=ke.map((s=>s.packageName)),r=function(){const s={};return ke.forEach((e=>{s[e.packageName]=e.id})),s}();s.forEach((s=>{if(o.includes(s))return;const a=ve(s,o),n=ve(s,i);Math.min(a.distance,n.distance)>10?e.warn(t`Unknown feature: "${s}", see the list of features https://github.com/csstools/postcss-plugins/blob/main/plugin-packs/postcss-preset-env/FEATURES.md`):a.distance{const e=new ye,t=Object(s),o=Object.keys(Object(t.features)),i=t.browsers,r=function(s){if("importFrom"in s||"exportTo"in s||"preserve"in s){const e={};return"importFrom"in s&&(e.importFrom=s.importFrom),"exportTo"in s&&(e.exportTo={customMedia:{},customProperties:{},customSelectors:{}}),"preserve"in s&&(e.preserve=s.preserve),e}return!1}(t),a=he(Q.default,t,r,e),n=a.map((s=>s.plugin));!1!==t.autoprefixer&&n.push(K.default(Object.assign({overrideBrowserslist:i},t.autoprefixer))),n.push(X.default()),function(s,e,t){if(e.debug){t.log("Enabling the following feature(s):");const e=[];s.forEach((s=>{s.id.startsWith("before")||s.id.startsWith("after")?t.log(` ${s.id} (injected via options)`):t.log(` ${s.id}`),void 0!==Ls[s.id]&&e.push(s.id)})),e.length&&(t.log("These feature(s) need a browser library to work:"),e.forEach((s=>t.log(` ${s}: ${Ls[s]}`))))}}(a,t,e);const c=()=>({postcssPlugin:"postcss-preset-env",OnceExit:function(i,{result:a}){Ne(o,i,a),t.debug&&e.dumpLogs(a),e.resetLogger(),t.exportTo&&Gs(r.exportTo,s.exportTo)}});return c.postcss=!0,{postcssPlugin:"postcss-preset-env",plugins:[...n,c()]}};qe.postcss=!0,module.exports=qe;