import e from"postcss";import t,{mergeExtractorSelectors as o,defaultOptions as s}from"purgecss";const r=e.plugin("postcss-plugin-purgecss",(function(e){return async function(r,n){const c=new t,i={...s,...e};e&&"function"==typeof e.contentFunction&&(i.content=e.contentFunction(r.source&&r.source.input.file||"")),c.options=i;const{content:p,extractors:u}=i,a=p.filter(e=>"string"==typeof e),l=p.filter(e=>"object"==typeof e),m=await c.extractSelectorsFromFiles(a,u),f=await c.extractSelectorsFromString(l,u),g=o(m,f);c.walkThroughCSS(r,g),c.options.fontFace&&c.removeUnusedFontFaces(),c.options.keyframes&&c.removeUnusedKeyframes(),c.options.variables&&c.removeUnusedCSSVariables(),c.options.rejected&&c.selectorsRemoved.size>0&&(n.messages.push({type:"purgecss",plugin:"postcss-purgecss",text:`purging ${c.selectorsRemoved.size} selectors:\n        ${Array.from(c.selectorsRemoved).map(e=>e.trim()).join("\n  ")}`}),c.selectorsRemoved.clear())}}));export default r;
