import{LeftParenthesis as i,RightParenthesis as t,Function as e,Ident as s,Dimension as n,Number as o}from"../../tokenizer/types.mjs";import"../../tokenizer/char-code-definitions.mjs";import"../../tokenizer/TokenStream.mjs";const r="FeatureRange",h={kind:String,left:["Identifier","Number","Dimension","Ratio","Function"],leftComparison:String,middle:["Identifier","Number","Dimension","Ratio","Function"],rightComparison:[String,null],right:["Identifier","Number","Dimension","Ratio","Function",null]};function l(){switch(this.skipSC(),this.tokenType){case o:return this.isDelim(47,this.lookupOffsetNonSC(1))?this.Ratio():this.Number();case n:return this.Dimension();case s:return this.Identifier();case e:return this.parseWithFallback(()=>{const i=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(47)&&this.error(),i},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function a(i){if(this.skipSC(),this.isDelim(60)||this.isDelim(62)){const i=this.source[this.tokenStart];return this.next(),this.isDelim(61)?(this.next(),i+"="):i}if(this.isDelim(61))return"=";this.error(`Expected ${i?'":", ':""}"<", ">", "=" or ")"`)}function u(e="unknown"){const s=this.tokenStart;this.skipSC(),this.eat(i);const n=l.call(this),o=a.call(this,"Identifier"===n.type),r=l.call(this);let h=null,u=null;return this.lookupNonWSType(0)!==t&&(h=a.call(this),u=l.call(this)),this.skipSC(),this.eat(t),{type:"FeatureRange",loc:this.getLocation(s,this.tokenStart),kind:e,left:n,leftComparison:o,middle:r,rightComparison:h,right:u}}function c(e){this.token(i,"("),this.node(e.left),this.tokenize(e.leftComparison),this.node(e.middle),e.right&&(this.tokenize(e.rightComparison),this.node(e.right)),this.token(t,")")}export{c as generate,r as name,u as parse,h as structure};