import s from"autoprefixer";import e from"cssdb";import o from"@csstools/postcss-progressive-custom-properties";import t from"fs";import i from"path";import r from"browserslist";import n from"postcss-initial";import a from"postcss-pseudo-class-any-link";import c from"css-blank-pseudo";import p from"postcss-page-break";import u from"@csstools/postcss-cascade-layers";import m from"postcss-attribute-case-insensitive";import l from"postcss-clamp";import d from"@csstools/postcss-color-function";import f from"postcss-color-functional-notation";import g from"postcss-custom-media";import b from"postcss-custom-properties";import h from"postcss-custom-selectors";import y from"postcss-dir-pseudo-class";import k from"@csstools/postcss-normalize-display-values";import N from"postcss-double-position-gradients";import v from"postcss-env-function";import w from"postcss-focus-visible";import $ from"postcss-focus-within";import O from"@csstools/postcss-font-format-keywords";import S from"postcss-font-variant";import x from"postcss-gap-properties";import P from"css-has-pseudo";import j from"postcss-color-hex-alpha";import F from"@csstools/postcss-hwb-function";import E from"@csstools/postcss-ic-unit";import M from"postcss-image-set-function";import C from"@csstools/postcss-is-pseudo-class";import _ from"postcss-lab-function";import q from"postcss-logical";import A from"postcss-media-minmax";import R from"postcss-nesting";import U from"postcss-selector-not";import B from"@csstools/postcss-oklab-function";import T from"postcss-opacity-percentage";import I from"postcss-overflow-shorthand";import V from"postcss-replace-overflow-wrap";import W from"postcss-place";import L from"css-prefers-color-scheme";import D from"postcss-color-rebeccapurple";import H from"@csstools/postcss-stepped-value-functions";import J from"@csstools/postcss-trigonometric-functions";import z from"@csstools/postcss-unset-value";const G={"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"},K=["blank-pseudo-class","focus-visible-pseudo-class","focus-within-pseudo-class","has-pseudo-class","prefers-color-scheme-query"];async function Q(s,e,o,t){const i=function(s){return`:root {\n${Object.keys(s).reduce(((e,o)=>(e.push(`\t${o}: ${s[o]};`),e)),[]).join("\n")}\n}\n`}(o),r=function(s){return`${Object.keys(s).reduce(((e,o)=>(e.push(`@custom-media ${o} ${s[o]};`),e)),[]).join("\n")}\n`}(e),n=function(s){return`${Object.keys(s).reduce(((e,o)=>(e.push(`@custom-selector ${o} ${s[o]};`),e)),[]).join("\n")}\n`}(t),a=`${r}\n${n}\n${i}`;await es(s,a)}function X(s,e){return`\n\t${s}: {\n${Object.keys(e).reduce(((s,o)=>(s.push(`\t\t'${os(o)}': '${os(e[o])}'`),s)),[]).join(",\n")}\n\t}`}function Y(s,e){return`export const ${s} = {\n${Object.keys(e).reduce(((s,o)=>(s.push(`\t'${os(o)}': '${os(e[o])}'`),s)),[]).join(",\n")}\n};\n`}function Z(s,e){return Promise.all([].concat(e).map((async e=>{if(e instanceof Function)await e({customMedia:ss(s.customMedia),customProperties:ss(s.customProperties),customSelectors:ss(s.customSelectors)});else{const o=e===Object(e)?e:{to:String(e)},t=o.toJSON||ss;if("customMedia"in o||"customProperties"in o||"customSelectors"in o)o.customMedia=t(s.customMedia),o.customProperties=t(s.customProperties),o.customSelectors=t(s.customSelectors);else if("custom-media"in o||"custom-properties"in o||"custom-selectors"in o)o["custom-media"]=t(s.customMedia),o["custom-properties"]=t(s.customProperties),o["custom-selectors"]=t(s.customSelectors);else{const e=String(o.to||""),r=(o.type||i.extname(o.to).slice(1)).toLowerCase(),n=t(s.customMedia),a=t(s.customProperties),c=t(s.customSelectors);"css"===r&&await Q(e,n,a,c),"js"===r&&await async function(s,e,o,t){const i=`module.exports = {${X("customMedia",e)},${X("customProperties",o)},${X("customSelectors",t)}\n};\n`;await es(s,i)}(e,n,a,c),"json"===r&&await async function(s,e,o,t){const i=`${JSON.stringify({"custom-media":e,"custom-properties":o,"custom-selectors":t},null," ")}\n`;await es(s,i)}(e,n,a,c),"mjs"===r&&await async function(s,e,o,t){const i=`${Y("customMedia",e)}\n${Y("customProperties",o)}\n${Y("customSelectors",t)}`;await es(s,i)}(e,n,a,c)}}})))}function ss(s){return Object.keys(s).reduce(((e,o)=>(e[o]=String(s[o]),e)),{})}function es(s,e){return new Promise(((o,i)=>{t.writeFile(s,e,(s=>{s?i(s):o()}))}))}function os(s){return s.replace(/\\([\s\S])|(')/g,"\\$1$2").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}function ts(s,e){if(!s)return!1;if("string"==typeof s)return!0;if(Array.isArray(s)){for(let o=0;os.id===o)))continue;let r=e[o];Array.isArray(r)||(r=[r]);for(let s=0;sfunction(s){return!!s[rs]||!!s[ns]||!!hs.has(s.id)}(s))).sort(((s,e)=>function(s,e){return s.id===e.id?s[rs]&&e[rs]||s[ns]&&e[ns]?is(-1,s[as]-e[as],1):s[rs]||e[ns]?-1:s[ns]||e[rs]?1:0:is(-1,us.indexOf(s.id)-us.indexOf(e.id),1)}(s,e)))}const ks=["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 Ns(s){if(!s)return[];if(!("browser_support"in s))return["> 0%"];const e=[];return ks.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 vs(s,e,o,t){const i=r(s,{ignoreUnknownVersions:!0});switch(e.id){case"is-pseudo-class":return{onComplexSelector:"warning"};case"nesting-rules":if(function(s,e){const o=Ns(s);if(e.some((s=>r(o,{ignoreUnknownVersions:!0}).some((e=>e===s)))))return!0;return!1}(o.find((s=>"is-pseudo-class"===s.id)),i))return t.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 t.log('Adding area[href] fallbacks for ":any-link" support in Edge and IE.'),{subFeatures:{areaHrefNeedsFixing:!0}};return{};default:return{}}}function ws(s,e,o,t){const i=Object(e.features),n=!("enableClientSidePolyfills"in e)||e.enableClientSidePolyfills,a=Object(e.insertBefore),c=Object(e.insertAfter),p=e.browsers,u=is(0,function(s){const e=parseInt(s,10);return Number.isNaN(e)?0:e}(e.minimumVendorImplementations),3);u>0&&t.log(`Using features with ${u} or more vendor implementations`);const m=function(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=is(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}(e,t);2===m&&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 l=ys(s,a,c).map((s=>function(s){const e=Ns(s);if(s[rs]||s[ns]){let o=s.id;return o=s.insertBefore?`before-${o}`:`after-${o}`,{browsers:e,vendors_implementations:s.vendors_implementations,plugin:s[cs],id:o,stage:6}}return{browsers:e,vendors_implementations:s.vendors_implementations,plugin:hs.get(s.id),id:s.id,stage:s.stage}}(s))).filter((s=>0===u||(!(!s[rs]&&!s[ns])||(u<=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>=m,o=n||!K.includes(s.id),r=!1===i[s.id],a=i[s.id]?i[s.id]:e&&o;return r?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=>function(s,e,o,t,i,r){let n,a;return n=vs(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,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}}(s,p,i,e,o,t))),d=r(p,{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(ts(s.pluginOptions.importFrom,"customMedia"))return!0;break;case"custom-properties":if(ts(s.pluginOptions.importFrom,"customProperties"))return!0;break;case"environment-variables":if(ts(s.pluginOptions.importFrom,"environmentVariables"))return!0;break;case"custom-selectors":if(ts(s.pluginOptions.importFrom,"customSelectors"))return!0}if("exportTo"in Object(s.pluginOptions))switch(s.id){case"custom-media-queries":if(ts(s.pluginOptions.exportTo,"customMedia"))return!0;break;case"custom-properties":if(ts(s.pluginOptions.exportTo,"customProperties"))return!0;break;case"environment-variables":if(ts(s.pluginOptions.exportTo,"environmentVariables"))return!0;break;case"custom-selectors":if(ts(s.pluginOptions.exportTo,"customSelectors"))return!0}return!1}(s))return!0;const e=r(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 $s{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 Os=[{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 Ss(s,e,o){const t=Os.map((s=>s.id)),i=Os.map((s=>s.packageName)),r=function(){const s={};return Os.forEach((e=>{s[e.packageName]=e.id})),s}();s.forEach((s=>{if(t.includes(s))return;const n=xs(s,t),a=xs(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{const i=new $s,r=Object(t),n=Object.keys(Object(r.features)),a=r.browsers,c=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}(r),p=ws(e,r,c,i),u=p.map((s=>s.plugin));!1!==r.autoprefixer&&u.push(s(Object.assign({overrideBrowserslist:a},r.autoprefixer))),u.push(o()),function(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!==G[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}: ${G[s]}`))))}}(p,r,i);const m=()=>({postcssPlugin:"postcss-preset-env",OnceExit:function(s,{result:e}){Ss(n,s,e),r.debug&&i.dumpLogs(e),i.resetLogger(),r.exportTo&&Z(c.exportTo,t.exportTo)}});return m.postcss=!0,{postcssPlugin:"postcss-preset-env",plugins:[...u,m()]}};js.postcss=!0;export{js as default};