import{LeftCurlyBracket as t,Semicolon as e,RightCurlyBracket as i,AtKeyword as s,Comment as n,WhiteSpace as o}from"../../tokenizer/types.mjs";import"../../tokenizer/char-code-definitions.mjs";import"../../tokenizer/TokenStream.mjs";function h(){return this.Raw(null,!0)}function r(){return this.parseWithFallback(this.Rule,h)}function c(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function a(){if(this.tokenType===e)return c.call(this,this.tokenIndex);const t=this.parseWithFallback(this.Declaration,c);return this.tokenType===e&&this.next(),t}const l="Block",u="block",k={children:[["Atrule","Rule","Declaration"]]};function p(e){const c=e?a:r,l=this.tokenStart;let u=this.createList();this.eat(t);t:for(;!this.eof;)switch(this.tokenType){case i:break t;case o:case n:this.next();break;case s:u.push(this.parseWithFallback(this.Atrule.bind(this,e),h));break;default:e&&this.isDelim(38)?u.push(r.call(this)):u.push(c.call(this))}return this.eof||this.eat(i),{type:"Block",loc:this.getLocation(l,this.tokenStart),children:u}}function f(s){this.token(t,"{"),this.children(s,t=>{"Declaration"===t.type&&this.token(e,";")}),this.token(i,"}")}export{f as generate,l as name,p as parse,k as structure,u as walkContext};