import e from"postcss";import o,{defaultOptions as t,standardizeSafelist as s,mergeExtractorSelectors as r}from"purgecss";async function n(e,n,{result:c}){const i=new o,u={...t,...e,safelist:s(null==e?void 0:e.safelist)};e&&"function"==typeof e.contentFunction&&(u.content=e.contentFunction(n.source&&n.source.input.file||"")),i.options=u;const{content:p,extractors:a}=u,l=p.filter((e=>"string"==typeof e)),f=p.filter((e=>"object"==typeof e)),m=await i.extractSelectorsFromFiles(l,a),g=await i.extractSelectorsFromString(f,a),d=r(m,g);i.walkThroughCSS(n,d),i.options.fontFace&&i.removeUnusedFontFaces(),i.options.keyframes&&i.removeUnusedKeyframes(),i.options.variables&&i.removeUnusedCSSVariables(),i.options.rejected&&i.selectorsRemoved.size>0&&(c.messages.push({type:"purgecss",plugin:"postcss-purgecss",text:`purging ${i.selectorsRemoved.size} selectors:\n          ${Array.from(i.selectorsRemoved).map((e=>e.trim())).join("\n  ")}`}),i.selectorsRemoved.clear())}const c=function(e){if(void 0===e)throw new Error("PurgeCSS plugin does not have the correct options");return{postcssPlugin:"postcss-purgecss",Once:(o,t)=>n(e,o,t)}};c.postcss=!0;var i,u=function(e){return void 0!==e.Root}(i=e)?c:i.plugin("postcss-purgecss",(e=>{if(void 0===e)throw new Error("PurgeCSS plugin does not have the correct options");return async function(o,t){return n(e,o,t)}}));export default u;
