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 l from"../../utils/isContextFunctionalPseudoClass.mjs";import i from"../../utils/isNonNegativeInteger.mjs";import a from"../../utils/isStandardSyntaxRule.mjs";import n from"../../utils/optionsMatches.mjs";import u from"../../utils/report.mjs";import m from"../../utils/ruleMessages.mjs";import c from"../../utils/validateOptions.mjs";const{isRoot:p,isSelector:d}=e,f="selector-max-id",x=m(f,{expected:(e,t)=>`Expected "${e}" to have no more than ${t} ID ${1===t?"selector":"selectors"}`}),g=(e,m)=>(g,j)=>{c(j,f,{actual:e,possible:i},{actual:m,possible:{ignoreContextFunctionalPseudoClasses:[t,s],checkContextFunctionalPseudoClasses:[t,s]},optional:!0})&&g.walkRules(t=>{a(t)&&o(t,j).forEach(({selector:s,resolvedSelectors:o})=>{o.walk(o=>{var i;d(o)&&(o.parent&&(p(o.parent)||(i=o.parent,"pseudo"===i?.type&&n(m,"checkContextFunctionalPseudoClasses",i.value))||function(e){return l(e)&&!n(m,"ignoreContextFunctionalPseudoClasses",e.value)}(o.parent))&&function(t,s,o){if(t.reduce((e,t)=>("id"===t.type&&(e+=1),e),0)>e){const{index:t,endIndex:l,selector:i}=r(s);u({ruleName:f,result:j,node:o,message:x.expected,messageArgs:[i,e],index:t,endIndex:l})}}(o,s,t))})})})};g.ruleName=f,g.messages=x,g.meta={url:"https://stylelint.io/user-guide/rules/selector-max-id"};export{g as default};