import e from"../../../../../_virtual/index20.mjs";import{isString as t,isRegExp as r}from"../../utils/validateTypes.mjs";import s from"../../utils/flattenNestedSelectorsForRule.mjs";import o from"../../utils/getStrippedSelectorSource.mjs";import n from"../../utils/isContextFunctionalPseudoClass.mjs";import i from"../../utils/isCustomElement.mjs";import l from"../../utils/isKeyframeSelector.mjs";import m from"../../utils/isNonNegativeInteger.mjs";import u from"../../utils/isOnlyWhitespace.mjs";import a from"../../utils/isStandardSyntaxRule.mjs";import p from"../../utils/isStandardSyntaxTypeSelector.mjs";import c from"../../utils/optionsMatches.mjs";import d from"../../utils/report.mjs";import f from"../../utils/ruleMessages.mjs";import g from"../../utils/validateOptions.mjs";const{isRoot:x,isSelector:v}=e,j="selector-max-type",y=f(j,{expected:(e,t)=>`Expected "${e}" to have no more than ${t} type ${1===t?"selector":"selectors"}`}),S=(e,f)=>(S,b)=>{if(!g(b,j,{actual:e,possible:m},{actual:f,possible:{ignore:["descendant","child","compounded","next-sibling","custom-elements"],ignoreTypes:[t,r]},optional:!0}))return;const N=c(f,"ignore","descendant"),O=c(f,"ignore","child"),R=c(f,"ignore","compounded"),T=c(f,"ignore","next-sibling"),C=c(f,"ignore","custom-elements");function E(r,s,n){if(r.reduce((e,r)=>c(f,"ignoreTypes",r.value)||N&&function(e){if(!e.parent)return!1;const r=e.parent.nodes.indexOf(e);return e.parent.nodes.slice(0,r).some(e=>function(e){return!!e&&(h(e)&&t(e.value)&&u(e.value))}(e))}(r)||O&&function(e){if(!e.parent)return!1;const t=e.parent.nodes.indexOf(e);return e.parent.nodes.slice(0,t).some(e=>function(e){return!!e&&(h(e)&&">"===e.value)}(e))}(r)||R&&function(e){if(e.prev()&&!h(e.prev()))return!0;if(e.next()&&!h(e.next()))return!0;return!1}(r)||T&&function(e){return h(e)&&"+"===e.value}(r.prev())||C&&r.value&&i(r.value)?e:("tag"!==r.type||p(r))&&"tag"===r.type?e+1:e,0)>e){const{selector:t,index:r,endIndex:i}=o(s);d({ruleName:j,result:b,node:n,message:y.expected,messageArgs:[t,e],index:r,endIndex:i})}}S.walkRules(e=>{a(e)&&(e.selectors.some(l)||s(e,b).forEach(({selector:t,resolvedSelectors:r})=>{r.walk(r=>{v(r)&&(x(r.parent)||n(r.parent))&&E(r,t,e)})}))})};function h(e){return!!e&&"combinator"===e.type}S.ruleName=j,S.messages=y,S.meta={url:"https://stylelint.io/user-guide/rules/selector-max-type"};export{S as default};