import{AtKeyword as t,Semicolon as e,LeftCurlyBracket as i,RightCurlyBracket as o}from"../../tokenizer/types.mjs";import"../../tokenizer/char-code-definitions.mjs";import"../../tokenizer/TokenStream.mjs";function r(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function l(){for(let e,r=1;e=this.lookupType(r);r++){if(e===o)return!0;if(e===i||e===t)return!1}return!1}const s="Atrule",n="atrule",u={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]};function h(o=!1){const s=this.tokenStart;let n,u,h=null,c=null;switch(this.eat(t),n=this.substrToCursor(s+1),u=n.toLowerCase(),this.skipSC(),!1===this.eof&&this.tokenType!==i&&this.tokenType!==e&&(h=this.parseAtrulePrelude?this.parseWithFallback(this.AtrulePrelude.bind(this,n,o),r):r.call(this,this.tokenIndex),this.skipSC()),this.tokenType){case e:this.next();break;case i:c=hasOwnProperty.call(this.atrule,u)&&"function"==typeof this.atrule[u].block?this.atrule[u].block.call(this,o):this.Block(l.call(this))}return{type:"Atrule",loc:this.getLocation(s,this.tokenStart),name:n,prelude:h,block:c}}function c(i){this.token(t,"@"+i.name),null!==i.prelude&&this.node(i.prelude),i.block?this.node(i.block):this.token(e,";")}export{c as generate,s as name,h as parse,u as structure,n as walkContext};