(function(a,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@projectwallace/css-analyzer")):typeof define=="function"&&define.amd?define(["exports","@projectwallace/css-analyzer"],r):(a=typeof globalThis<"u"?globalThis:a||self,r(a.cssCodeQuality={},a.cssAnalyzer))})(this,function(a,r){"use strict";const l=[e=>({id:"Imports",score:e.atrules.import.total*10,value:e.atrules.import.total,actuals:Object.keys(e.atrules.import.unique)}),e=>({id:"EmptyRules",score:e.rules.empty.total,value:e.rules.empty.total}),e=>{const s={id:"SelectorDuplications",score:0,value:1-e.selectors.uniquenessRatio};return e.selectors.uniquenessRatio<.66&&(s.score=Math.floor((1-e.selectors.uniquenessRatio)*10)),s},e=>{const s={id:"DeclarationDuplications",score:0,value:1-e.declarations.unique.ratio};return e.declarations.unique.ratio<.66&&(s.score=Math.floor((1-e.declarations.unique.ratio)*10)),s},e=>({id:"CssSize",score:e.stylesheet.size>2e5?5:0,value:e.stylesheet.size}),e=>{const{comments:s}=e.stylesheet;return{id:"TooMuchComments",score:Math.min(10,Math.floor(s.size/250)),value:s.size}},e=>{const{size:s}=e.stylesheet.embeddedContent;return{id:"TooMuchEmbeddedContent",score:Math.min(20,Math.floor(s.total/250)),value:s.total,actuals:Object.keys(e.stylesheet.embeddedContent.unique)}}],u=[e=>{const s={id:"SourceLinesOfCode",score:0,value:e.stylesheet.sourceLinesOfCode};if(e.stylesheet.sourceLinesOfCode>1e4){const o=Math.floor((e.stylesheet.sourceLinesOfCode-1e4)/1e3);s.score=Math.min(15,o)}return s},e=>{const o=e.rules.selectors.mean,t={id:"AverageSelectorsPerRule",score:0,value:o,actuals:e.rules.selectors.items};if(o>2){const c=Math.floor((o-2)*5);t.score=Math.min(15,c)}return t},e=>{const o={id:"AverageDeclarationsPerRule",score:0,value:e.rules.declarations.mean,actuals:e.rules.declarations.items};if(e.rules.declarations.mean>5){const t=Math.floor((e.rules.declarations.mean-5)*5);o.score=Math.min(15,t)}return o},e=>{const o={id:"MaxSelectorsPerRule",score:0,value:e.rules.selectors.max,actuals:e.rules.selectors.items};if(e.rules.selectors.max>10){const t=Math.ceil((e.rules.selectors.max-10)*.5);o.score=Math.min(t,15)}return o},e=>{const o={id:"MaxDeclarationsPerRule",score:0,value:e.rules.declarations.max,actuals:e.rules.declarations.items};if(e.rules.declarations.max>10){const t=Math.ceil((e.rules.declarations.max-10)*.5);o.score=Math.min(15,t)}return o},e=>{const s=e.rules.selectors.mode,o=e.rules.selectors.items.filter(c=>c>s).length,t={id:"MoreThanMostCommonSelectorsPerRule",score:0,value:e.rules.selectors.mode,actuals:e.rules.selectors.items};if(o>e.rules.total*.1){const c=Math.floor(o*.01);t.score=Math.min(15,c)}return t},e=>{const s=e.rules.selectors.mode,o=e.rules.declarations.items.filter(c=>c>s).length,t={id:"MoreThanMostCommonDeclarationsPerRule",score:0,value:e.rules.declarations.mode,actuals:e.rules.declarations.items};if(o>e.rules.total*.1){const c=Math.floor(o*.01);t.score=Math.min(15,c)}return t}],m=[e=>{const s=e.selectors.complexity.mode,o=e.selectors.complexity.items.filter(c=>c>s).length,t={id:"MoreThanMostCommonSelectorComplexity",score:0,value:e.selectors.total===0?0:o/e.selectors.total,actuals:e.selectors.complexity.items};if(o>e.selectors.total*.1){const c=Math.floor(o*.01);t.score=Math.min(10,c)}return t},e=>{const s=e.selectors.specificity.mode,o=e.selectors.specificity.items.filter(c=>r.compareSpecificity(c,s)<0).length,t={id:"MoreThanMostCommonSelectorSpecificity",score:0,value:e.selectors.total===0?0:o/e.selectors.total,actuals:e.selectors.specificity.items};if(o>e.selectors.total*.1){const c=Math.floor(o*.01);t.score=Math.min(10,c)}return t},e=>{const o=e.selectors.complexity.max,t={id:"MaxSelectorComplexity",score:0,value:e.selectors.complexity.max,actuals:e.selectors.complexity.items};if(o>5){const c=Math.ceil((o-5)*.5);t.score=Math.min(5,c)}return t},e=>{const o=e.selectors.complexity.mean,t={id:"AverageSelectorComplexity",score:0,value:o,actuals:e.selectors.complexity.items};if(o>2){const c=Math.ceil((o-2)*2);t.score=Math.min(10,c)}return t},e=>{const o=e.selectors.id.ratio,t={id:"IdSelectorRatio",score:0,value:o,actuals:Object.keys(e.selectors.id.unique)};if(o>.01){const c=Math.floor((o-.01)*10);t.score=Math.min(c,5)}return t},e=>{const o=e.declarations.importants.ratio,t={id:"ImportantRatio",score:0,value:o,actuals:e.declarations.importants.total};if(o>.01){const c=Math.floor((o-.01)*10);t.score=Math.min(c,5)}return t}];function i(e,s){let o=100,t=[],c=[];for(const M of s){const n=M(e);n.score>0?(o-=n.score,t.push(n)):c.push(n)}return{score:Math.max(o,0),violations:t,passes:c}}function E(e){const s=i(e,l),o=i(e,u),t=i(e,m);return{score:0,violations:s.violations.concat(o.violations).concat(t.violations),passes:s.passes.concat(o.passes).concat(t.passes),performance:s,maintainability:o,complexity:t}}function d(e){const s=r.analyze(e);return E(s)}a.calculate=d,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});