import e from"../../../../../_virtual/index19.mjs";import{isString as r,isRegExp as t}from"../../utils/validateTypes.mjs";import{acceptCustomIdentsProperties as s}from"../../reference/properties.mjs";import{colord as o}from"./colordUtils.mjs";import{declarationValueIndex as i}from"../../utils/nodeFieldIndices.mjs";import n from"../../utils/hasColorFunction.mjs";import l from"../../utils/hasNamedColor.mjs";import a from"../../utils/hasValidHex.mjs";import m from"../../utils/isStandardSyntaxFunction.mjs";import u from"../../utils/isStandardSyntaxValue.mjs";import{namedColorsKeywords as p}from"../../reference/keywords.mjs";import d from"../../utils/optionsMatches.mjs";import f from"../../utils/report.mjs";import c from"../../utils/ruleMessages.mjs";import j from"../../utils/validateOptions.mjs";const g="color-named",w=c(g,{expected:(e,r)=>`Expected "${e}" to be "${r}"`,rejected:e=>`Unexpected named color "${e}"`}),h=new Set(["word","function"]),x=/\bgray\(/i,y=(c,y)=>(v,b)=>{function S(e,r,t,s,o){f({result:b,ruleName:g,message:e,messageArgs:r,node:t,index:s,endIndex:s+o})}j(b,g,{actual:c,possible:["never","always-where-possible"]},{actual:y,possible:{ignoreProperties:[r,t],ignore:["inside-function"]},optional:!0})&&v.walkDecls(r=>{if(s.has(r.prop))return;if(d(y,"ignoreProperties",r.prop))return;const{value:t}=r;("never"!==c||l(t))&&("always-where-possible"!==c||a(t)||n(t)||x.test(t))&&e(t).walk(t=>{const s=t.value,n=t.type,l=t.sourceIndex;if(d(y,"ignore","inside-function")&&"function"===n)return!1;if(!m(t))return!1;if(!u(s))return;if(!h.has(n))return;if("never"===c&&"word"===n&&p.has(s.toLowerCase()))return void S(w.rejected,[s],r,i(r)+l,s.length);if("always-where-possible"!==c)return;let a=null,f=null;if("function"===n)a=e.stringify(t),f=a.replace(/\s*([,/()])\s*/g,"$1").replace(/\s{2,}/g," ");else{if("word"!==n||!s.startsWith("#"))return;a=f=s}const j=o(f);if(!j.isValid())return;const g=j.toName();g&&"transparent"!==g.toLowerCase()&&S(w.expected,[f,g],r,i(r)+l,a.length)})})};y.ruleName=g,y.messages=w,y.meta={url:"https://stylelint.io/user-guide/rules/color-named"};export{y as default};