import{TokenType as e,NumberType as a}from"../../../../@csstools/css-tokenizer/dist/index.mjs";import{isTokenNode as t,isFunctionNode as r,sourceIndices as s}from"../../../../@csstools/css-parser-algorithms/dist/index.mjs";import{isMediaQueryInvalid as i,isMediaFeature as o,isMediaFeatureValue as n,matchesRatioExactly as m}from"../../../../@csstools/media-query-list-parser/dist/index.mjs";import{resolutionUnits as u,lengthUnits as l}from"../../reference/units.mjs";import{mediaFeatureNames as d,mediaFeatureNameAllowedValueKeywords as f,mediaFeatureNameAllowedValueTypes as c}from"../../reference/mediaFeatures.mjs";import{mathFunctions as h}from"../../reference/functions.mjs";import{atRuleParamIndex as p}from"../../utils/nodeFieldIndices.mjs";import{atRuleRegexes as g}from"../../utils/regexes.mjs";import v from"../../utils/parseMediaQuery.mjs";import N from"../../utils/report.mjs";import j from"../../utils/ruleMessages.mjs";import w from"../../utils/validateOptions.mjs";import F from"../../utils/vendor.mjs";const x="media-feature-name-value-no-unknown",y=j(x,{rejected:(e,a)=>`Unexpected unknown media feature value "${a}" for name "${e}"`}),k=/^(?:min|max)-/i,R=j=>(R,b)=>{function A(i,o,n){t(o.value)?function(t,r,s){const[i,o,n,m,d]=r;if(i===e.Ident){const e=f.get(t.mediaFeatureName);if(e){const a=F.unprefixed(d.value.toLowerCase());if(e.has(a))return}return void s(t,o,n,m)}const h=c.get(t.mediaFeatureName);if(h)if(i!==e.Number){if(i===e.Dimension){const e=d.unit.toLowerCase();if(h.has("resolution")&&u.has(e))return;if(h.has("length")&&l.has(e))return;s(t,o,n,m)}}else{if(d.type===a.Integer){if(h.has("integer")||h.has("ratio")||0===d.value&&(h.has("length")||h.has("resolution")||h.has("mq-boolean"))||1===d.value&&h.has("mq-boolean"))return;return void s(t,o,n,m)}if(h.has("ratio")||0===d.value&&(h.has("length")||h.has("resolution")))return;s(t,o,n,m)}else s(t,o,n,m)}(i,o.value.value,n):r(o.value)?function(e,a,t){const r=a.getName().toLowerCase();if("env"===r)return;const i=c.get(e.mediaFeatureName);i&&h.has(r)&&(i.has("integer")||i.has("length")||i.has("ratio")||i.has("resolution"))||t(e,a.toString(),...s(a))}(i,o.value,n):Array.isArray(o.value)&&function(e,a,t){const r=c.get(e.mediaFeatureName);r&&r.has("ratio")&&-1!==m(a)||t(e,a.map(e=>e.toString()).join(""),...s(a))}(i,o.value,n)}w(b,x,{actual:j})&&R.walkAtRules(g.mediaName,e=>{const a=(a,t,r,s)=>{const i=p(e);N({message:y.rejected,messageArgs:[a.mediaFeatureNameRaw,t],index:i+r,endIndex:i+s+1,node:e,ruleName:x,result:b})},t={mediaFeatureName:"",mediaFeatureNameRaw:""};v(e).forEach(e=>{i(e)||e.walk(({node:e,state:t})=>{if(t){if(o(e)){const a=e.getName();let r=F.unprefixed(a.toLowerCase());if(!d.has(r))return;return r=r.replace(k,""),t.mediaFeatureName=r,void(t.mediaFeatureNameRaw=a)}t.mediaFeatureName&&t.mediaFeatureNameRaw&&n(e)&&A(t,e,a)}},t)})})};R.ruleName=x,R.messages=y,R.meta={url:"https://stylelint.io/user-guide/rules/media-feature-name-value-no-unknown"};export{R as default};