import{parse as e,walk as t}from"../../../../css-tree/lib/index.mjs";import{isString as r,isRegExp as s}from"../../utils/validateTypes.mjs";import{atRuleParamIndex as i}from"../../utils/nodeFieldIndices.mjs";import{atRuleRegexes as o}from"../../utils/regexes.mjs";import n from"../../utils/getAtRuleParams.mjs";import l from"../../utils/getRuleSelector.mjs";import u from"../../utils/isStandardSyntaxAtRule.mjs";import m from"../../utils/isStandardSyntaxRule.mjs";import a from"../../utils/optionsMatches.mjs";import p from"../../utils/report.mjs";import c from"../../utils/ruleMessages.mjs";import f from"../../utils/validateOptions.mjs";const d="nesting-selector-no-missing-scoping-root",g=c(d,{rejected:"Unexpected missing scoping root"}),j=(a,c)=>(j,x)=>{function R(e,r,s=0){t(r,{enter(t){if("NestingSelector"!==t.type)return;if(!t.loc)return;const r=s+t.loc.start.offset,i=r+1;p({message:g.rejected,node:e,result:x,ruleName:d,index:r,endIndex:i})}})}f(x,d,{actual:a,possible:[!0]},{actual:c,possible:{ignoreAtRules:[r,s]},optional:!0})&&(j.walkRules(/&/,t=>{if(!m(t))return;if(y(t,c))return;let r;try{r=e(l(t),{context:"selectorList",positions:!0})}catch{return}R(t,r)}),j.walkAtRules(o.scopeName,t=>{if(!u(t))return;if(!t.params.includes("&"))return;if(y(t,c))return;let r;try{r=e(n(t),{atrule:"scope",context:"atrulePrelude",positions:!0})}catch{return}R(t,r,i(t))}))};function y(e,t){let r=e.parent;for(;r;){if("rule"===r.type)return!0;if("atrule"===r.type&&"scope"===r.name)return!0;if("atrule"===r.type&&a(t,"ignoreAtRules",r.name))return!0;if("root"===r.type)return!1;r=r.parent}return!1}j.ruleName=d,j.messages=g,j.meta={url:"https://stylelint.io/user-guide/rules/nesting-selector-no-missing-scoping-root"};export{j as default};