import e from"../../../../../_virtual/index20.mjs";import{isString as t,isRegExp as s}from"../../utils/validateTypes.mjs";import o from"../../utils/flattenNestedSelectorsForRule.mjs";import r from"../../utils/getStrippedSelectorSource.mjs";import i from"../../utils/isContextFunctionalPseudoClass.mjs";import l from"../../utils/isNonNegativeInteger.mjs";import m from"../../utils/isStandardSyntaxRule.mjs";import n from"../../utils/optionsMatches.mjs";import u from"../../utils/pluralize.mjs";import a from"../../utils/report.mjs";import c from"../../utils/ruleMessages.mjs";import p from"../../utils/validateOptions.mjs";const{isCombinator:d,isPseudo:f,isRoot:g,isSelector:x}=e,j="selector-max-compound-selectors",S=c(j,{expected:(e,t)=>`Expected "${e}" to have no more than ${t} compound ${u("selector",t)}`}),h=(e,u)=>(c,h)=>{function v(t,s,o){const i=[];if(t.each(e=>{(function(e){const t=f(e)?e.value:e.toString();return n(u,"ignoreSelectors",t)})(e)||i.push(e)}),g(s)||f(s))return;if(i.reduce((e,t,s,o)=>d(t)?0===s||s===o.length-1||d(o[s+1])?e:e+1:e,0)+1>e){const{index:t,endIndex:i,selector:l}=r(s);a({ruleName:j,result:h,node:o,message:S.expected,messageArgs:[l,e],index:t,endIndex:i})}}p(h,j,{actual:e,possible:l},{actual:u,possible:{ignoreSelectors:[t,s]},optional:!0})&&c.walkRules(e=>{m(e)&&o(e,h).forEach(({selector:t,resolvedSelectors:s})=>{s.walk(s=>{x(s)&&(g(s.parent)||i(s.parent))&&v(s,t,e)})})})};h.ruleName=j,h.messages=S,h.meta={url:"https://stylelint.io/user-guide/rules/selector-max-compound-selectors"};export{h as default};