sveast 0.9.6 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/a11y.d.ts +1636 -0
- package/a11y.js +36 -0
- package/core.js +1 -1
- package/is-valid-type.js +1 -1
- package/module.js +1 -1
- package/package.json +6 -1
- package/parse-imports-exports.js +1 -1
- package/parse-module.js +1 -1
- package/parse-sections.js +1 -1
- package/parse.js +1 -1
- package/runes.js +1 -1
- package/shared-dscc5xg8.js +2 -0
- package/{shared-cs1ezg1f.js → shared-f45stvzk.js} +1 -1
- package/{shared-tapcgcpr.js → shared-k0xcpcmz.js} +1 -1
- package/{shared-qkp49nav.js → shared-nb0h4j83.js} +1 -1
- package/{shared-xwzsb4m8.js → shared-qqrqzz29.js} +1 -1
- package/shared-s46wfvhw.js +10 -0
- package/{shared-nan648gn.js → shared-w3mxqtgj.js} +1 -1
- package/{shared-z9y4mrek.js → shared-x2vs5571.js} +1 -1
- package/{shared-as9z0pac.js → shared-xmc2pnaf.js} +1 -1
- package/typescript.js +1 -1
- package/shared-2pngd0mg.js +0 -10
- package/shared-ke0fgd3r.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{definePlugin,hasLineBreak,hasName}from"./shared-2pngd0mg.js";var SKIP_WHITESPACE=/(?:\s|\/\/.*|\/\*[\s\S]*?\*\/)*/g,KEYWORD_TYPES=new Map([["any","TSAnyKeyword"],["bigint","TSBigIntKeyword"],["boolean","TSBooleanKeyword"],["never","TSNeverKeyword"],["null","TSNullKeyword"],["number","TSNumberKeyword"],["object","TSObjectKeyword"],["string","TSStringKeyword"],["symbol","TSSymbolKeyword"],["undefined","TSUndefinedKeyword"],["unknown","TSUnknownKeyword"],["void","TSVoidKeyword"]]),CLASS_MODIFIERS=new Set("public private protected readonly declare abstract override static accessor".split(" ")),PARAMETER_MODIFIERS=new Set("public private protected readonly override".split(" ")),DECLARE_TARGETS=new Set("var let const function class abstract enum interface type namespace module global".split(" ")),DECLARE_FIRST=new Set("var let const function class interface enum".split(" ")),TS_EXPRESSION_WRAPPERS=new Set(["TSAsExpression","TSSatisfiesExpression","TSNonNullExpression","TSTypeAssertion"]),SCOPE_TOP=1,SCOPE_SIMPLE_CATCH=32,SCOPE_CLASS_STATIC_BLOCK=256,BIND_NONE=0,BIND_VAR=1,BIND_LEXICAL=2,BIND_FUNCTION=3,BIND_SIMPLE_CATCH=4,BIND_TS_TYPE=6,BIND_TS_INTERFACE=7,BIND_FLAGS_TS_ENUM=256,BIND_FLAGS_TS_EXPORT_ONLY=1024,BIND_TS_NAMESPACE=8|BIND_FLAGS_TS_EXPORT_ONLY,BIND_TS_ENUM=BIND_LEXICAL|BIND_FLAGS_TS_ENUM,FUNC_STATEMENT=1,FUNC_HANGING_STATEMENT=2,CHAR_PAREN_L=40,CHAR_PAREN_R=41,CHAR_COMMA=44,CHAR_DOT=46,CHAR_COLON=58,CHAR_EQ=61,CHAR_LT=60,CHAR_BRACE_L=123,CHAR_BRACKET_L=91,CHAR_STAR=42,CHAR_HASH=35,CHAR_DQUOTE=34,CHAR_SQUOTE=39,SPECULATION_FAILED=SyntaxError("speculative parse failed"),tsPlugin=definePlugin((Base)=>{let{tokTypes:tt,keywordTypes,isIdentifierChar,isIdentifierStart}=Base.acorn,atType=new Base.acorn.TokenType("@");class TSParser extends Base{inType=!1;$4=!1;$5=!1;$7=null;$k=null;$l=!1;$m=!1;$f=null;$9=[[]];$n=0;$t=0;$o=-1;constructor(options,input,startPos){super(options,input,startPos);let onComment=this.options.onComment;if(typeof onComment==="function")this.options.onComment=(block,text,start,end,startLoc,endLoc)=>{if(start<this.$t)return;this.$t=end,onComment.call(this,block,text,start,end,startLoc,endLoc)}}reset(){this.inType=!1,this.$4=!1,this.$5=!1,this.$7=null,this.$k=null,this.$l=!1,this.$m=!1,this.$f=null,this.$9=[[]],this.$n=0,this.$t=0,this.$o=-1}getTokenFromCode(code){if(code===64)return++this.pos,this.finishToken(atType);return super.getTokenFromCode(code)}readToken_lt_gt(code){if(this.inType)return this.finishOp(tt.relational,1);return super.readToken_lt_gt(code)}$a(fn){let old=this.inType;this.inType=!0;let result=fn();if(this.inType=old,!old&&this.type===tt.relational)this.pos=this.start,this.nextToken();return result}$1(){return this.type===tt.relational&&this.value==="<"}$p(){if(this.type===tt.bitShift&&this.value==="<<")this.pos=this.start+1,this.finishToken(tt.relational,"<");return this.$1()}$c(){return this.type===tt.relational&&this.value===">"}$u(){return this.type===tt.prefix&&this.value==="!"}hasPrecedingLineBreak(){return hasLineBreak(this.input,this.lastTokEnd,this.start)}$d(from=this.pos){return SKIP_WHITESPACE.lastIndex=from,SKIP_WHITESPACE.exec(this.input),SKIP_WHITESPACE.lastIndex}$2(){return this.input.charCodeAt(this.$d())}$3(){let start=this.$d(),end=start;while(end<this.input.length&&isIdentifierChar(this.input.charCodeAt(end)))end++;return this.input.slice(start,end)}$b(){return!hasLineBreak(this.input,this.pos,this.$d())}$14(){return this.$b()&&isIdentifierStart(this.$2())&&!Object.hasOwn(keywordTypes,this.$3())}$15(){return{pos:this.pos,type:this.type,value:this.value,start:this.start,end:this.end,startLoc:this.startLoc,endLoc:this.endLoc,lastTokStart:this.lastTokStart,lastTokEnd:this.lastTokEnd,lastTokStartLoc:this.lastTokStartLoc,lastTokEndLoc:this.lastTokEndLoc,curLine:this.curLine,lineStart:this.lineStart,context:this.context.slice(),exprAllowed:this.exprAllowed,containsEsc:this.containsEsc,inType:this.inType,$4:this.$4,$5:this.$5,$7:this.$7,scopes:this.scopeStack.length,privateNames:this.privateNameStack.length,labels:this.labels,labelCount:this.labels.length,strict:this.strict,yieldPos:this.yieldPos,awaitPos:this.awaitPos,awaitIdentPos:this.awaitIdentPos,potentialArrowAt:this.potentialArrowAt,potentialArrowInForAwait:this.potentialArrowInForAwait}}$16(state){this.pos=state.pos,this.type=state.type,this.value=state.value,this.start=state.start,this.end=state.end,this.startLoc=state.startLoc,this.endLoc=state.endLoc,this.lastTokStart=state.lastTokStart,this.lastTokEnd=state.lastTokEnd,this.lastTokStartLoc=state.lastTokStartLoc,this.lastTokEndLoc=state.lastTokEndLoc,this.curLine=state.curLine,this.lineStart=state.lineStart,this.context=state.context,this.exprAllowed=state.exprAllowed,this.containsEsc=state.containsEsc,this.inType=state.inType,this.$4=state.$4,this.$5=state.$5,this.$7=state.$7,this.scopeStack.length=state.scopes,this.privateNameStack.length=state.privateNames,this.labels=state.labels,this.labels.length=state.labelCount,this.strict=state.strict,this.yieldPos=state.yieldPos,this.awaitPos=state.awaitPos,this.awaitIdentPos=state.awaitIdentPos,this.potentialArrowAt=state.potentialArrowAt,this.potentialArrowInForAwait=state.potentialArrowInForAwait}raise(pos,message){if(this.$n>0)throw SPECULATION_FAILED;return super.raise(pos,message)}$1y(pos,message){try{super.raise(pos,message)}catch(error){if(error instanceof SyntaxError)error.$1z=!0;throw error}throw Error("unreachable")}$g(fn,lookahead=!1){let state=this.$15();this.$n++;try{let result=fn();if(lookahead||result===void 0)this.$16(state);return result}catch(error){if(!(error instanceof SyntaxError)||!lookahead&&error.$1z)throw error;this.$16(state);return}finally{this.$n--}}$v(fn){return this.$g(fn,!0)===!0}$17(node){if(node.end=this.lastTokEnd,this.options.locations)node.loc.end=this.lastTokEndLoc}$q(node,from){if(node.start=from.start,this.options.locations)node.loc.start=from.loc.start}$6(returnType=!1){let node=this.startNode();return node.typeAnnotation=this.$a(()=>(this.next(),returnType?this.$20():this.$0())),this.finishNode(node,"TSTypeAnnotation")}$h(node,optional){if(optional&&this.eat(tt.question))node.optional=!0,this.$17(node);if(this.type===tt.colon)node.typeAnnotation=this.$6(),this.$17(node);return node}$20(){if(this.type!==tt.name&&this.type!==tt._this)return this.$0();if(this.isContextual("asserts")&&this.$b()&&isIdentifierStart(this.$2())){let node=this.startNode();if(this.next(),node.parameterName=this.type===tt._this?this.$w():this.parseIdent(),this.isContextual("is")&&!this.hasPrecedingLineBreak())return this.$x(node,!0);return node.asserts=!0,node.typeAnnotation=null,this.finishNode(node,"TSTypePredicate")}if(this.$3()==="is"&&this.$b()){let node=this.startNode();return node.parameterName=this.type===tt._this?this.$w():this.parseIdent(!0),this.$x(node,!1)}return this.$0()}$x(node,asserts){this.next();let annotation=this.startNode();return annotation.typeAnnotation=this.$0(),node.typeAnnotation=this.finishNode(annotation,"TSTypeAnnotation"),node.asserts=asserts,this.finishNode(node,"TSTypePredicate")}$w(){let node=this.startNode();return this.next(),this.finishNode(node,"TSThisType")}parseWholeType(){this.inType=!0,this.nextToken();let type=this.$0();if(this.type!==tt.eof)this.unexpected();return type}$0(){let type=this.$18();if(this.$4||this.type!==tt._extends||this.hasPrecedingLineBreak())return type;let node=this.startNodeAt(type.start,type.loc?.start);return this.next(),node.checkType=type,node.extendsType=this.$i(!0,()=>this.$18()),this.expect(tt.question),node.trueType=this.$i(!1,()=>this.$0()),this.expect(tt.colon),node.falseType=this.$i(!1,()=>this.$0()),this.finishNode(node,"TSConditionalType")}$i(disallow,fn){let old=this.$4;this.$4=disallow;let result=fn();return this.$4=old,result}$18(){if(this.$21())return this.$19("TSFunctionType");if(this.type===tt._new||this.isContextual("abstract")&&this.$3()==="new")return this.$19("TSConstructorType");return this.$1a("TSUnionType",tt.bitwiseOR,()=>this.$1a("TSIntersectionType",tt.bitwiseAND,()=>this.$1b()))}$19(type){let node=this.startNode();if(type==="TSConstructorType"){if(node.abstract=this.isContextual("abstract"),node.abstract)this.next();this.next()}return this.$i(!1,()=>this.$r(node,tt.arrow)),this.finishNode(node,type)}$r(node,returnToken){if(this.$1())node.typeParameters=this.$8();if(this.expect(tt.parenL),node.parameters=this.parseBindingList(tt.parenR,!1,!0),this.type===returnToken)node.typeAnnotation=this.$6(!0);else if(returnToken===tt.arrow)this.unexpected()}$21(){if(this.$1())return!0;if(this.type!==tt.parenL)return!1;return this.$v(()=>{if(this.next(),this.type===tt.parenR||this.type===tt.ellipsis)return!0;if(this.type===tt.name||this.type===tt._this)this.next();else if(this.type===tt.braceL||this.type===tt.bracketL)this.parseBindingAtom();else return!1;let type=this.type;if(type===tt.colon||type===tt.comma||type===tt.question||type===tt.eq)return!0;if(type!==tt.parenR)return!1;return this.next(),this.type===tt.arrow})}$1a(type,operator,parseConstituent){let node=this.startNode(),hasLeadingOperator=this.eat(operator),types=[];do types.push(parseConstituent());while(this.eat(operator));if(types.length===1&&!hasLeadingOperator)return types[0];return node.types=types,this.finishNode(node,type)}$1b(){if(this.type===tt.name&&!this.containsEsc){let value=this.value;if(value==="keyof"||value==="unique"||value==="readonly"){let node=this.startNode();return this.next(),node.operator=value,node.typeAnnotation=this.$1b(),this.finishNode(node,"TSTypeOperator")}if(value==="infer"){let node=this.startNode();this.next();let parameter=this.startNode();parameter.name=this.$y();let constraint=this.$g(()=>this.$22());if(constraint)parameter.constraint=constraint;return node.typeParameter=this.finishNode(parameter,"TSTypeParameter"),this.finishNode(node,"TSInferType")}}return this.$i(!1,()=>this.$23())}$22(){if(!this.eat(tt._extends))return;let constraint=this.$i(!0,()=>this.$0());return this.$4||this.type!==tt.question?constraint:void 0}$y(){if(this.type!==tt.name&&!this.type.keyword)this.unexpected();let name=this.type===tt.name?this.value:this.type.keyword;return this.next(),name}$23(){let type=this.$24();while(!this.hasPrecedingLineBreak()&&this.eat(tt.bracketL)){let node=this.startNodeAt(type.start,type.loc?.start);if(this.eat(tt.bracketR))node.elementType=type,type=this.finishNode(node,"TSArrayType");else node.objectType=type,node.indexType=this.$0(),this.expect(tt.bracketR),type=this.finishNode(node,"TSIndexedAccessType")}return type}$24(){switch(this.type){case tt.name:case tt._void:case tt._null:{let keyword=KEYWORD_TYPES.get(this.value);if(keyword&&(this.type!==tt.name||!this.containsEsc&&this.$2()!==CHAR_DOT)){let node=this.startNode();return this.next(),this.finishNode(node,keyword)}return this.$1c()}case tt.string:case tt.num:case tt._true:case tt._false:{let node=this.startNode();return node.literal=this.parseExprAtom(),this.finishNode(node,"TSLiteralType")}case tt.plusMin:{if(this.value!=="-")break;let node=this.startNode(),unary=this.startNode();if(this.next(),this.type!==tt.num)this.unexpected();return unary.operator="-",unary.prefix=!0,unary.argument=this.parseExprAtom(),node.literal=this.finishNode(unary,"UnaryExpression"),this.finishNode(node,"TSLiteralType")}case tt.backQuote:return this.$25();case tt._this:{let thisType=this.$w();if(this.isContextual("is")&&!this.hasPrecedingLineBreak()){let node=this.startNodeAt(thisType.start,thisType.loc?.start);return node.parameterName=thisType,this.$x(node,!1)}return thisType}case tt._typeof:return this.$26();case tt._import:return this.$1d();case tt.braceL:return this.$27()?this.$28():this.$29();case tt.bracketL:return this.$2a();case tt.parenL:{let node=this.startNode();return this.next(),node.typeAnnotation=this.$0(),this.expect(tt.parenR),this.finishNode(node,"TSParenthesizedType")}default:if(this.type.keyword)return this.$1c()}return this.unexpected()}$1c(){let node=this.startNode();if(node.typeName=this.$j(),!this.hasPrecedingLineBreak()&&this.$1())node.typeArguments=this.$e();return this.finishNode(node,"TSTypeReference")}$j(){let entity=this.parseIdent(!0);while(this.eat(tt.dot)){let node=this.startNodeAt(entity.start,entity.loc?.start);node.left=entity,node.right=this.parseIdent(!0),entity=this.finishNode(node,"TSQualifiedName")}return entity}$26(){let node=this.startNode();if(this.next(),node.exprName=this.type===tt._import?this.$1d():this.$j(),!this.hasPrecedingLineBreak()&&this.$1())node.typeArguments=this.$e();return this.finishNode(node,"TSTypeQuery")}$1d(){let node=this.startNode();if(this.next(),node.argument=this.$1e(),this.eat(tt.dot))node.qualifier=this.$j();if(this.$1())node.typeArguments=this.$e();return this.finishNode(node,"TSImportType")}$z(){if(this.type!==tt.string)this.unexpected();return this.parseExprAtom()}$1e(){this.expect(tt.parenL);let string=this.$z();return this.expect(tt.parenR),string}$25(){let node=this.startNode(),literal=this.startNode();this.next(),literal.expressions=[];let element=this.parseTemplateElement({isTagged:!1});literal.quasis=[element];while(!element.tail){if(this.type===tt.eof)this.raise(this.pos,"Unterminated template literal");this.expect(tt.dollarBraceL),literal.expressions.push(this.$0()),this.expect(tt.braceR),element=this.parseTemplateElement({isTagged:!1}),literal.quasis.push(element)}return this.next(),node.literal=this.finishNode(literal,"TemplateLiteral"),this.finishNode(node,"TSLiteralType")}$27(){return this.$v(()=>{if(this.next(),this.type===tt.plusMin)return this.next(),this.isContextual("readonly");if(this.isContextual("readonly"))this.next();if(this.type!==tt.bracketL)return!1;if(this.next(),this.type!==tt.name)return!1;return this.next(),this.type===tt._in})}$28(){let node=this.startNode();if(this.expect(tt.braceL),this.type===tt.plusMin)node.readonly=this.value,this.next(),this.expectContextual("readonly");else if(this.eatContextual("readonly"))node.readonly=!0;this.expect(tt.bracketL);let parameter=this.startNode();if(parameter.name=this.$y(),this.expect(tt._in),parameter.constraint=this.$0(),node.typeParameter=this.finishNode(parameter,"TSTypeParameter"),node.nameType=this.eatContextual("as")?this.$0():null,this.expect(tt.bracketR),this.type===tt.plusMin)node.optional=this.value,this.next(),this.expect(tt.question);else if(this.eat(tt.question))node.optional=!0;if(this.eat(tt.colon))node.typeAnnotation=this.$0();return this.semicolon(),this.expect(tt.braceR),this.finishNode(node,"TSMappedType")}$29(){let node=this.startNode();return node.members=this.$1f(),this.finishNode(node,"TSTypeLiteral")}$1f(){this.expect(tt.braceL);let members=[];while(!this.eat(tt.braceR))members.push(this.$2b());return members}$2b(){let node=this.startNode(),type="TSPropertySignature",next=this.type===tt._new?this.$2():-1;if(this.type===tt.parenL||this.$1())type="TSCallSignatureDeclaration",this.$r(node,tt.colon);else if(next===CHAR_PAREN_L||next===CHAR_LT)type="TSConstructSignatureDeclaration",this.next(),this.$r(node,tt.colon);else{let newKey=this.type===tt._new?this.parseIdent(!0):null;if(this.isContextual("readonly")&&this.$s(!0))this.next(),node.readonly=!0;if(this.type===tt.bracketL&&this.$1g())return this.$1h(node);let kind="method";if(newKey)node.key=newKey;else{if((this.isContextual("get")||this.isContextual("set"))&&this.$s(!1))kind=this.value,this.next();this.parsePropertyName(node)}if(this.eat(tt.question))node.optional=!0;if(this.type===tt.parenL||this.$1()){if(type="TSMethodSignature",kind!=="method")node.kind=kind;this.$r(node,tt.colon),node.kind=kind}else if(this.type===tt.colon)node.typeAnnotation=this.$6()}return this.$1i(),this.finishNode(node,type)}$1i(){if(!this.eat(tt.comma))this.semicolon()}$1g(){return this.$v(()=>{if(this.next(),this.type!==tt.name)return!1;return this.next(),this.type===tt.colon})}$1h(node){if(this.expect(tt.bracketL),node.parameters=[this.$h(this.parseIdent(),!1)],this.expect(tt.bracketR),this.type===tt.colon)node.typeAnnotation=this.$6();return this.$1i(),this.finishNode(node,"TSIndexSignature")}$2a(){let node=this.startNode();this.expect(tt.bracketL),node.elementTypes=[];while(!this.eat(tt.bracketR))if(node.elementTypes.push(this.$2c()),this.type!==tt.bracketR)this.expect(tt.comma);return this.finishNode(node,"TSTupleType")}$2c(){let start=this.start,startLoc=this.startLoc,rest=this.eat(tt.ellipsis),element;if((this.type===tt.name||this.type.keyword)&&this.$2d()){let node=this.startNode();node.label=this.parseIdent(!0),node.optional=this.eat(tt.question),this.expect(tt.colon),node.elementType=this.$0(),element=this.finishNode(node,"TSNamedTupleMember")}else if(element=this.$0(),this.eat(tt.question)){let node=this.startNodeAt(element.start,element.loc?.start);node.typeAnnotation=element,element=this.finishNode(node,"TSOptionalType")}if(rest){let node=this.startNodeAt(start,startLoc);node.typeAnnotation=element,element=this.finishNode(node,"TSRestType")}return element}$2d(){let at=this.$d();if(this.input.charCodeAt(at)===63)at=this.$d(at+1);return this.input.charCodeAt(at)===CHAR_COLON}$8(){return this.$a(()=>{let node=this.startNode();this.next(),node.params=[];while(!this.$c()){let parameter=this.startNode();while((this.type===tt._const||this.type===tt._in||this.isContextual("out"))&&isIdentifierStart(this.$2()))parameter[this.value]=!0,this.next();if(parameter.name=this.$y(),this.eat(tt._extends))parameter.constraint=this.$0();if(this.eat(tt.eq))parameter.default=this.$0();if(node.params.push(this.finishNode(parameter,"TSTypeParameter")),!this.$c()){if(this.expect(tt.comma),this.$c())node.extra={trailingComma:this.lastTokStart}}}if(this.next(),node.params.length===0)this.$1y(this.start,"Type parameter list cannot be empty.");return this.finishNode(node,"TSTypeParameterDeclaration")})}$e(){return this.$a(()=>{let node=this.startNode();this.next(),node.params=[];while(!this.$c())if(node.params.push(this.$0()),!this.$c())this.expect(tt.comma);if(node.params.length===0)this.unexpected();return this.next(),this.finishNode(node,"TSTypeParameterInstantiation")})}$1j(){let list=[];do{let node=this.startNode();if(node.expression=this.$j(),this.$1())node.typeParameters=this.$e();list.push(this.finishNode(node,"TSExpressionWithTypeArguments"))}while(this.eat(tt.comma));return list}$1k(exported=!1){if(this.type!==tt.name||this.containsEsc){if(this.type===tt._const&&this.$3()==="enum")return this.$10(this.startNode());return}if(!this.$2e(this.value))return;if(this.value==="declare")return this.$2f(exported);return this.$1l(this.startNode(),this.value)}$2e(word){switch(word){case"interface":case"type":case"namespace":return this.$14();case"enum":return isIdentifierStart(this.$2());case"abstract":return this.$b()&&this.$3()==="class";case"module":{let next=this.$2();return this.$b()&&(next===CHAR_DQUOTE||next===CHAR_SQUOTE||isIdentifierStart(next))}case"declare":return this.$b()&&DECLARE_TARGETS.has(this.$3());case"global":return this.$b()&&this.$2()===CHAR_BRACE_L}return!1}$1l(node,word){switch(word){case"interface":return this.$1m(node);case"type":return this.$2g(node);case"enum":return this.$10(node);case"abstract":return this.$1n(node,!0);case"global":return node.global=!0,node.id=this.parseIdent(),node.body=this.$11(),this.finishNode(node,"TSModuleDeclaration")}return this.$2h(node)}$2f(exported){let old=this.$5;this.$5=!0;let node=this.startNode();this.next();let word=this.value;if(word==="const"&&this.$3()==="enum")node.const=!0;if(!exported&&DECLARE_FIRST.has(word))node.declare=!0;let declaration;if(node.const)declaration=this.$10(node);else if(word==="var"||word==="let"||word==="const")declaration=this.parseVarStatement(node,word,!0);else if(word==="function")this.next(),declaration=this.parseFunction(node,FUNC_STATEMENT,!1,!1);else if(word==="class")declaration=this.parseClass(node,!0);else declaration=this.$1l(node,word);return declaration.declare=!0,this.$5=old,declaration}$1n(node,isStatement){return this.next(),node.abstract=!0,this.parseClass(node,isStatement)}$1m(node){if(this.next(),node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_INTERFACE),this.$1())node.typeParameters=this.$8();return this.$a(()=>{if(this.eat(tt._extends))node.extends=this.$1j();let body=this.startNode();body.body=this.$1f(),node.body=this.finishNode(body,"TSInterfaceBody")}),this.finishNode(node,"TSInterfaceDeclaration")}$2g(node){if(this.next(),node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_TYPE),this.$1())node.typeParameters=this.$8();return node.typeAnnotation=this.$a(()=>(this.expect(tt.eq),this.$0())),this.semicolon(),this.finishNode(node,"TSTypeAliasDeclaration")}$10(node){if(this.type===tt._const)node.const=!0,this.next();this.next(),node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_ENUM),this.expect(tt.braceL),node.members=[];while(!this.eat(tt.braceR)){let member=this.startNode();if(member.id=this.type===tt.string?this.parseExprAtom():this.parseIdent(!0),this.eat(tt.eq))member.initializer=this.parseMaybeAssign();if(node.members.push(this.finishNode(member,"TSEnumMember")),this.type!==tt.braceR)this.expect(tt.comma)}return this.finishNode(node,"TSEnumDeclaration")}$2h(node){if(this.next(),this.type===tt.string){if(node.id=this.parseExprAtom(),this.type===tt.braceL)node.body=this.$11();else this.semicolon();return this.finishNode(node,"TSModuleDeclaration")}return node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_NAMESPACE),this.$1o(node)}$1o(node){if(this.eat(tt.dot)){let inner=this.startNode();inner.id=this.parseIdent(),node.body=this.$1o(inner)}else node.body=this.$11();return this.finishNode(node,"TSModuleDeclaration")}$11(){this.enterScope(SCOPE_CLASS_STATIC_BLOCK);let node=this.startNode();this.enterScope(0),this.expect(tt.braceL),node.body=[];while(!this.eat(tt.braceR))node.body.push(this.parseStatement(null,!0));return this.exitScope(),this.exitScope(),this.finishNode(node,"TSModuleBlock")}$1p(node,isExport){if(node.isExport=isExport,node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_LEXICAL),this.expect(tt.eq),this.isContextual("require")&&this.$2()===CHAR_PAREN_L){let reference=this.startNode();this.next(),reference.expression=this.$1e(),node.moduleReference=this.finishNode(reference,"TSExternalModuleReference")}else node.moduleReference=this.$j();return this.semicolon(),this.finishNode(node,"TSImportEqualsDeclaration")}$2i(){let at=this.$d();if(this.input.charCodeAt(at)!==CHAR_EQ)return!1;let after=this.input.charCodeAt(at+1);return after!==CHAR_EQ&&after!==62}parseStatement(context,topLevel,exports){if(this.type===atType)this.$1q(!0);let declaration=this.$1k();if(declaration)return declaration;return super.parseStatement(context,topLevel,exports)}parseVarStatement(node,kind,allowMissingInitializer){return super.parseVarStatement(node,kind,allowMissingInitializer||this.$5)}parseVarId(decl,kind){if(super.parseVarId(decl,kind),decl.id.type==="Identifier"&&this.$u()&&!this.hasPrecedingLineBreak())this.next(),decl.definite=!0;this.$h(decl.id,!1)}parseCatchClauseParam(){let param=this.$h(this.parseBindingAtom(),!1),simple=param.type==="Identifier";return this.enterScope(simple?SCOPE_SIMPLE_CATCH:0),this.checkLValPattern(param,simple?BIND_SIMPLE_CATCH:BIND_LEXICAL),this.expect(tt.parenR),param}parseImport(node){if(this.next(),node.importKind="value",this.type===tt.string)node.specifiers=[],node.source=this.parseExprAtom();else{if(this.isContextual("type")){let next=this.$2();if(next===CHAR_BRACE_L||next===CHAR_STAR||isIdentifierStart(next)&&this.$3()!=="from")node.importKind="type",this.next()}if(this.type===tt.name&&this.$2i())return this.$1p(node,!1);node.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),node.source=this.$z()}return this.$1r(node),this.semicolon(),this.finishNode(node,"ImportDeclaration")}parseWithClause(){if(this.isContextual("assert")&&!this.hasPrecedingLineBreak())this.type=tt._with;return this.type===tt._with?super.parseWithClause():void 0}$1r(node){let attributes=this.parseWithClause();if(attributes)node.attributes=attributes}parseImportSpecifier(){return this.$1s("importKind",()=>super.parseImportSpecifier())}parseExportSpecifier(exports){return this.$1s("exportKind",()=>super.parseExportSpecifier(exports))}$1s(kindKey,parse){let next=this.isContextual("type")?this.$2():-1;if(next===CHAR_DQUOTE||next===CHAR_SQUOTE||isIdentifierStart(next)&&this.$3()!=="as"){let modifier=this.startNode();this.next();let node=parse();return this.$q(node,modifier),node[kindKey]="type",node}let node=parse();return node[kindKey]="value",node}parseExport(node,exports){if(this.next(),this.eat(tt._import)){if(node.importKind="value",this.isContextual("type")&&isIdentifierStart(this.$2())&&this.$3()!=="from")node.importKind="type",this.next();return this.$1p(node,!0)}if(this.eat(tt.eq))return node.expression=this.parseExpression(),this.semicolon(),this.finishNode(node,"TSExportAssignment");if(this.eatContextual("as"))return this.expectContextual("namespace"),node.id=this.parseIdent(),this.semicolon(),this.finishNode(node,"TSNamespaceExportDeclaration");if(node.exportKind="value",this.isContextual("type")){let next=this.$2();if(next===CHAR_BRACE_L||next===CHAR_STAR)node.exportKind="type",this.next()}if(this.eat(tt.star))return this.parseExportAllDeclaration(node,exports);if(this.eat(tt._default)){if(this.isContextual("interface")&&this.$14())node.declaration=this.$1m(this.startNode());else if(this.isContextual("abstract")&&this.$3()==="class")node.declaration=this.$1n(this.startNode(),"nullableID");else node.declaration=this.parseExportDefaultDeclaration();return this.finishNode(node,"ExportDefaultDeclaration")}let isDeclare=this.isContextual("declare"),declaration=this.$1k(!0);if(declaration||this.shouldParseExportStatement()){if(node.declaration=declaration??this.parseStatement(null),isDeclare||node.declaration.type==="TSInterfaceDeclaration"||node.declaration.type==="TSTypeAliasDeclaration")node.exportKind="type";return node.specifiers=[],node.source=null,this.finishNode(node,"ExportNamedDeclaration")}if(node.declaration=null,node.specifiers=this.parseExportSpecifiers(exports),this.eatContextual("from"))node.source=this.$z(),this.$1r(node);else{for(let spec of node.specifiers)if(this.checkUnreserved(spec.local),this.checkLocalExport(spec.local),spec.local.type==="Literal")this.raise(spec.local.start,"A string literal cannot be used as an exported binding without `from`.");node.source=null}return this.semicolon(),this.finishNode(node,"ExportNamedDeclaration")}parseFunction(node,statement,allowExpressionBody,isAsync,forInit){let isDeclaration=statement&FUNC_STATEMENT;if(isDeclaration)this.$f=node,this.$o=node.start;super.parseFunction(node,statement,allowExpressionBody,isAsync,forInit),this.$f=null;let bodiless=!node.body;if(bodiless)node.type="TSDeclareFunction";if(isDeclaration&&node.id){if(bodiless){if(this.$5&&this.currentScope().flags&SCOPE_TOP)this.declareName(node.id.name,BIND_FLAGS_TS_EXPORT_ONLY,node.id.start);this.checkLValSimple(node.id,BIND_NONE)}else if(!(statement&FUNC_HANGING_STATEMENT)){let bindingType=BIND_FUNCTION;if(this.strict||node.generator||node.async)bindingType=this.treatFunctionsAsVar?BIND_VAR:BIND_LEXICAL;this.checkLValSimple(node.id,bindingType)}}return node}parseFunctionParams(node){if(this.$1())node.typeParameters=this.$8();if(super.parseFunctionParams(node),this.type===tt.colon)node.returnType=this.$6(!0)}parseFunctionBody(node,isArrowFunction,isMethod,forInit){if(isMethod&&this.type===tt.colon)node.returnType=this.$6(!0);if(isArrowFunction||this.type===tt.braceL||node.start!==this.$o){super.parseFunctionBody(node,isArrowFunction,isMethod,forInit);return}this.semicolon(),this.exitScope()}parseMethod(isGenerator,isAsync,allowDirectSuper){let typeParameters=this.$k;this.$k=null;let node=super.parseMethod(isGenerator,isAsync,allowDirectSuper);if(!node.body)node.type="TSDeclareMethod";if(typeParameters)node.typeParameters=typeParameters;return node}parseBindingList(close,allowEmpty,allowTrailingComma,allowModifiers){let modifiers=allowModifiers===!0||this.$l;return this.$l=!1,super.parseBindingList(close,allowEmpty,allowTrailingComma,modifiers)}$s(allowLineBreak){if(!allowLineBreak&&!this.$b())return!1;let next=this.$2();return next===CHAR_BRACKET_L||next===CHAR_BRACE_L||next===CHAR_STAR||next===CHAR_DOT||next===CHAR_HASH||next===CHAR_DQUOTE||next===CHAR_SQUOTE||next>=48&&next<=57||isIdentifierStart(next)}parseAssignableListItem(allowModifiers){let decorators=this.$12(),start=this.start,startLoc=this.startLoc,accessibility,readonly=!1,override=!1;if(allowModifiers)while(this.type===tt.name&&PARAMETER_MODIFIERS.has(this.value)&&!this.containsEsc&&this.$s(!1)){if(this.value==="readonly")readonly=!0;else if(this.value==="override")override=!0;else accessibility=this.value;this.next()}let left;if(this.type===tt._this)left=this.startNode(),left.name="this",this.next(),this.finishNode(left,"Identifier");else left=this.parseBindingAtom();let element=this.type===tt.eq?this.parseMaybeDefault(start,startLoc,left):this.parseMaybeDefault(left.start,left.loc?.start,this.$h(left,!0));if(decorators.length>0)element.decorators=decorators;if(!accessibility&&!readonly&&!override)return element;let node=this.startNodeAt(start,startLoc);if(accessibility)node.accessibility=accessibility;if(readonly)node.readonly=!0;if(override)node.override=!0;return node.parameter=element,this.finishNode(node,"TSParameterProperty")}parseBindingListItem(param){if(param.type==="RestElement")this.$h(param,!0);return param}checkLValSimple(expr,bindingType,checkClashes){if(this.$f&&expr===this.$f.id){this.$f=null;return}if(!bindingType&&TS_EXPRESSION_WRAPPERS.has(expr.type)){this.checkLValSimple(expr.expression,bindingType,checkClashes);return}switch(expr.type){case"TSParameterProperty":this.checkLValInnerPattern(expr.parameter,bindingType,checkClashes);return;case"Identifier":if(expr.name==="this")return}super.checkLValSimple(expr,bindingType,checkClashes)}toAssignable(node,isBinding,refDestructuringErrors){if(node&&!isBinding&&TS_EXPRESSION_WRAPPERS.has(node.type))return node;return super.toAssignable(node,isBinding,refDestructuringErrors)}declareName(name,bindingType,pos){let scope=this.currentScope();if(bindingType&BIND_FLAGS_TS_EXPORT_ONLY){this.$1t(scope,name),scope.$1u??=[],scope.$1u.push(name);return}if(bindingType===BIND_TS_TYPE||bindingType===BIND_TS_INTERFACE){if(scope.$13??=[],bindingType===BIND_TS_TYPE&&hasName(scope.$13,name))this.raise(pos,`type '${name}' has already been declared.`);scope.$13.push(name),this.$1t(scope,name);return}if(bindingType&BIND_FLAGS_TS_ENUM){if(scope.$1v??=[],hasName(scope.$1v,name))return;super.declareName(name,BIND_LEXICAL,pos),scope.$1v.push(name);return}super.declareName(name,bindingType,pos)}$1t(scope,name){if(this.inModule&&scope.flags&SCOPE_TOP)delete this.undefinedExports[name]}checkLocalExport(id){for(let i=this.scopeStack.length-1;i>=0;i--){let scope=this.scopeStack[i];if(hasName(scope.$13,id.name)||hasName(scope.$1u,id.name))return}super.checkLocalExport(id)}checkExport(){}raiseRecoverable(pos,message){if(message==="Duplicate constructor in the same class")return;super.raiseRecoverable(pos,message)}$12(){let decorators=[];while(this.type===atType)decorators.push(this.$1w());return decorators}$1q(allowExport){let pending=this.$9[this.$9.length-1];while(this.type===atType)pending.push(this.$1w());if(this.type===tt._export){if(!allowExport)this.unexpected()}else if(this.type!==tt._class&&!((this.isContextual("abstract")||this.isContextual("declare"))&&this.$3()==="class"))this.raise(this.start,"Leading decorators must be attached to a class declaration.")}$1w(){let node=this.startNode();this.next(),this.$9.push([]);let startPos=this.start,startLoc=this.startLoc,expression;if(this.type===tt.parenL){if(this.next(),expression=this.parseExpression(),this.expect(tt.parenR),this.options.preserveParens){let paren=this.startNodeAt(startPos,startLoc);paren.expression=expression,expression=this.finishNode(paren,"ParenthesizedExpression")}}else{expression=this.parseIdent(!1);while(this.eat(tt.dot)){let member=this.startNodeAt(startPos,startLoc);member.object=expression,member.property=this.parseIdent(!0),member.computed=!1,expression=this.finishNode(member,"MemberExpression")}}let typeArguments=this.$p()?this.$e():void 0;if(this.eat(tt.parenL)){let call=this.startNodeAt(expression.start,expression.loc?.start);if(call.callee=expression,call.arguments=this.parseExprList(tt.parenR,!1,!1),typeArguments)call.typeArguments=typeArguments;expression=this.finishNode(call,"CallExpression")}else if(typeArguments){let instantiation=this.startNodeAt(expression.start,expression.loc?.start);instantiation.expression=expression,instantiation.typeArguments=typeArguments,expression=this.finishNode(instantiation,"TSInstantiationExpression")}return node.expression=expression,this.$9.pop(),this.finishNode(node,"Decorator")}shouldParseExportStatement(){return this.type===atType||super.shouldParseExportStatement()}parseExprAtom(refDestructuringErrors,forInit,forNew){if(this.type===atType)this.$1q(!1);return super.parseExprAtom(refDestructuringErrors,forInit,forNew)}parseProperty(isPattern,refDestructuringErrors){if(isPattern||this.type!==atType)return super.parseProperty(isPattern,refDestructuringErrors);let decorators=this.$12(),property=super.parseProperty(isPattern,refDestructuringErrors);if(property.type==="SpreadElement")this.raise(property.start,"Decorators can't be used with SpreadElement");return property.decorators=decorators,property}parseClassId(node,isStatement){let index=this.$9.length-1,decorators=this.$9[index];if(decorators.length>0)node.decorators=decorators,this.$q(node,decorators[0]),this.$9[index]=[];if(!this.isContextual("implements")||isStatement===!0)super.parseClassId(node,isStatement);if(this.$1())node.typeParameters=this.$8()}parseClassSuper(node){if(super.parseClassSuper(node),node.superClass&&this.$1())node.superTypeParameters=this.$e();if(this.eatContextual("implements"))node.implements=this.$a(()=>this.$1j())}parseClassElement(constructorAllowsSuper){if(this.type===atType){let decorators=this.$12();if(this.type===tt.braceR)this.raise(this.start,"Decorators must be attached to a class element.");let element=this.parseClassElement(constructorAllowsSuper);return element.decorators=decorators,this.$q(element,decorators[0]),element}if(this.eat(tt.semi))return null;let node=this.startNode();while(this.type===tt.name&&CLASS_MODIFIERS.has(this.value)&&!this.containsEsc&&this.$s(this.value==="static")){let modifier=this.value;if(this.next(),modifier==="static"&&this.type===tt.braceL)return this.next(),this.parseClassStaticBlock(node),node;if(modifier==="public"||modifier==="private"||modifier==="protected")node.accessibility=modifier;else node[modifier]=!0}if(this.type===tt.bracketL&&this.$1g())return this.$1h(node);node.static??=!1;let keyName="",isGenerator=!1,isAsync=!1,kind="method";if(this.eatContextual("async"))if((this.isClassElementNameStart()||this.type===tt.star)&&!this.canInsertSemicolon())isAsync=!0;else keyName="async";if(!keyName&&this.eat(tt.star))isGenerator=!0;if(!keyName&&!isAsync&&!isGenerator){let lastValue=this.value;if(this.eatContextual("get")||this.eatContextual("set"))if(this.isClassElementNameStart())kind=lastValue;else keyName=lastValue}if(keyName)node.computed=!1,node.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),node.key.name=keyName,this.finishNode(node.key,"Identifier");else this.parseClassElementName(node);if(this.eat(tt.question))node.optional=!0;if(this.type===tt.parenL||this.$1()||kind!=="method"||isGenerator||isAsync){let key=node.key,isConstructor=!node.static&&!node.computed&&(key.type==="Identifier"&&key.name==="constructor"||key.type==="Literal"&&key.value==="constructor");if(node.kind=isConstructor?"constructor":kind,this.$1())node.typeParameters=this.$8();this.$l=isConstructor,this.$o=this.start,this.parseClassMethod(node,isGenerator,isAsync,isConstructor&&constructorAllowsSuper)}else{if(!node.optional&&this.$u())this.next(),node.definite=!0;if(this.type===tt.colon)node.typeAnnotation=this.$6();this.parseClassField(node)}return node}parseMaybeAssign(forInit,refDestructuringErrors,afterLeftParse){if(this.$p()){let arrow=this.$g(()=>{let typeParameters=this.$8(),expr=super.parseMaybeAssign(forInit,refDestructuringErrors,afterLeftParse);if(expr.type!=="ArrowFunctionExpression")return;return expr.typeParameters=typeParameters,this.$q(expr,typeParameters),expr});if(arrow)return arrow}return super.parseMaybeAssign(forInit,refDestructuringErrors,afterLeftParse)}parseMaybeUnary(refDestructuringErrors,sawUnary,incDec,forInit){if(this.$p()){let node=this.startNode();return node.typeAnnotation=this.$a(()=>{this.next();let type=this.$0();if(!this.$c())this.unexpected();return this.next(),type}),node.expression=this.parseMaybeUnary(null,!1,!1,forInit),this.finishNode(node,"TSTypeAssertion")}return super.parseMaybeUnary(refDestructuringErrors,sawUnary,incDec,forInit)}parseMaybeConditional(forInit,refDestructuringErrors){let startPos=this.start,startLoc=this.startLoc,expr=this.parseExprOps(forInit,refDestructuringErrors);if(this.checkExpressionErrors(refDestructuringErrors))return expr;if(this.type===tt.question&&!(expr.type==="ArrowFunctionExpression"&&expr.start===startPos)&&!this.$2j()){this.next();let node=this.startNodeAt(startPos,startLoc);return node.test=expr,node.consequent=this.parseMaybeAssign(),this.expect(tt.colon),node.alternate=this.parseMaybeAssign(forInit),this.finishNode(node,"ConditionalExpression")}return expr}$2j(){let at=this.$d(),next=this.input.charCodeAt(at);if(next===CHAR_COLON||next===CHAR_COMMA||next===CHAR_PAREN_R)return!0;return next===CHAR_EQ&&this.input.charCodeAt(at+1)!==CHAR_EQ}parseParenItem(item){return this.$h(item,!0)}$1x(){if(this.type!==tt.colon)return!0;let returnType=this.$g(()=>{let type=this.$6(!0);return this.type===tt.arrow&&!this.canInsertSemicolon()?type:void 0});if(!returnType)return!1;return this.$7=returnType,!0}shouldParseArrow(exprList){return this.$1x()&&super.shouldParseArrow(exprList)}shouldParseAsyncArrow(){return this.$1x()&&super.shouldParseAsyncArrow()}parseArrowExpression(node,params,isAsync,forInit){if(this.$7)node.returnType=this.$7,this.$7=null;return super.parseArrowExpression(node,params,isAsync,forInit)}parseExprList(close,allowTrailingComma,allowEmpty,refDestructuringErrors){if(!this.$m)return super.parseExprList(close,allowTrailingComma,allowEmpty,refDestructuringErrors);this.$m=!1;let elements=[],first=!0;while(!this.eat(close)){if(first)first=!1;else if(this.expect(tt.comma),allowTrailingComma&&this.afterTrailingComma(close))break;if(this.type===tt.ellipsis){let spread=this.parseSpread(refDestructuringErrors);if(this.eat(tt.question))spread.optional=!0;if(this.type===tt.colon)spread.typeAnnotation=this.$6();elements.push(spread)}else elements.push(this.parseMaybeAssign(!1,refDestructuringErrors,this.parseParenItem))}return elements}parseSubscript(base,startPos,startLoc,noCalls,maybeAsyncArrow,optionalChained,forInit){if(this.$u()&&!this.hasPrecedingLineBreak()){let node=this.startNodeAt(startPos,startLoc);return this.exprAllowed=!1,this.next(),node.expression=base,this.finishNode(node,"TSNonNullExpression")}if(maybeAsyncArrow&&this.$1()){let arrow=this.$g(()=>this.$2k(startPos,startLoc,forInit));if(arrow)return arrow}let optional=this.type===tt.questionDot&&this.$2()===CHAR_LT;if(this.$1()||optional||this.type===tt.bitShift&&this.value==="<<"){let typeArguments=this.$g(()=>{if(optional)this.next();this.$p();let args=this.$e();if(this.type===tt.parenL&&!noCalls)return args;if(this.type===tt.backQuote)return optional?void 0:args;if(optional)return;if(this.$c()||this.type===tt.bitShift||this.type.startsExpr&&this.type!==tt.parenL&&!this.hasPrecedingLineBreak())return;return args});if(typeArguments){let node=this.startNodeAt(startPos,startLoc);if(this.type===tt.parenL&&!noCalls){if(this.next(),node.callee=base,node.arguments=this.parseExprList(tt.parenR,!0,!1),node.typeArguments=typeArguments,optional)base.optional=!0;if(optional||optionalChained)node.optional=optional;return this.finishNode(node,"CallExpression")}if(this.type===tt.backQuote)return node.tag=base,node.quasi=this.parseTemplate({isTagged:!0}),node.typeArguments=typeArguments,this.finishNode(node,"TaggedTemplateExpression");return node.expression=base,node.typeArguments=typeArguments,this.finishNode(node,"TSInstantiationExpression")}}if(maybeAsyncArrow&&this.type===tt.parenL)this.$m=!0;return super.parseSubscript(base,startPos,startLoc,noCalls,maybeAsyncArrow,optionalChained,forInit)}$2k(startPos,startLoc,forInit){let node=this.startNodeAt(startPos,startLoc);if(node.typeParameters=this.$8(),this.expect(tt.parenL),node.params=this.parseBindingList(tt.parenR,!1,!0),this.type===tt.colon)node.returnType=this.$6(!0);if(this.type!==tt.arrow||this.canInsertSemicolon())return;return this.next(),this.parseArrowExpression(node,node.params,!0,forInit)}parseDynamicImport(node){if(this.next(),node.source=this.parseMaybeAssign(),this.eat(tt.comma)&&this.type!==tt.parenR)node.arguments=[this.parseExpression()];return this.expect(tt.parenR),this.finishNode(node,"ImportExpression")}parseNew(){let node=super.parseNew();if(node.callee?.type!=="TSInstantiationExpression")return node;let result=this.startNodeAt(node.start,node.loc?.start);return result.callee=node.callee.expression,result.typeArguments=node.callee.typeArguments,result.arguments=node.arguments,this.finishNodeAt(result,"NewExpression",node.end,node.loc?.end)}parseExprOp(left,leftStartPos,leftStartLoc,minPrec,forInit){if(tt._in.binop>minPrec&&this.type===tt.name&&(this.value==="as"||this.value==="satisfies")&&!this.containsEsc&&!this.hasPrecedingLineBreak()){let isSatisfies=this.value==="satisfies",node=this.startNodeAt(leftStartPos,leftStartLoc);return node.expression=left,node.typeAnnotation=this.$a(()=>{if(this.next(),!isSatisfies&&this.type===tt._const){let reference=this.startNode();return reference.typeName=this.parseIdent(!0),this.finishNode(reference,"TSTypeReference")}return this.$0()}),this.finishNode(node,isSatisfies?"TSSatisfiesExpression":"TSAsExpression"),this.parseExprOp(node,leftStartPos,leftStartLoc,minPrec,forInit)}return super.parseExprOp(left,leftStartPos,leftStartLoc,minPrec,forInit)}parseGetterSetter(prop){prop.kind=prop.key.name,super.parseGetterSetter(prop)}parsePropertyValue(prop,isPattern,isGenerator,isAsync,startPos,startLoc,refDestructuringErrors,containsEsc){if(!isPattern&&this.$1()){if(this.$k=this.$8(),this.type!==tt.parenL)this.unexpected();prop.kind="init"}return super.parsePropertyValue(prop,isPattern,isGenerator,isAsync,startPos,startLoc,refDestructuringErrors,containsEsc)}}return TSParser});
|
|
1
|
+
import{definePlugin,hasLineBreak,hasName}from"./shared-s46wfvhw.js";var SKIP_WHITESPACE=/(?:\s|\/\/.*|\/\*[\s\S]*?\*\/)*/g,KEYWORD_TYPES=new Map([["any","TSAnyKeyword"],["bigint","TSBigIntKeyword"],["boolean","TSBooleanKeyword"],["never","TSNeverKeyword"],["null","TSNullKeyword"],["number","TSNumberKeyword"],["object","TSObjectKeyword"],["string","TSStringKeyword"],["symbol","TSSymbolKeyword"],["undefined","TSUndefinedKeyword"],["unknown","TSUnknownKeyword"],["void","TSVoidKeyword"]]),CLASS_MODIFIERS=new Set("public private protected readonly declare abstract override static accessor".split(" ")),PARAMETER_MODIFIERS=new Set("public private protected readonly override".split(" ")),DECLARE_TARGETS=new Set("var let const function class abstract enum interface type namespace module global".split(" ")),DECLARE_FIRST=new Set("var let const function class interface enum".split(" ")),TS_EXPRESSION_WRAPPERS=new Set(["TSAsExpression","TSSatisfiesExpression","TSNonNullExpression","TSTypeAssertion"]),SCOPE_TOP=1,SCOPE_SIMPLE_CATCH=32,SCOPE_CLASS_STATIC_BLOCK=256,BIND_NONE=0,BIND_VAR=1,BIND_LEXICAL=2,BIND_FUNCTION=3,BIND_SIMPLE_CATCH=4,BIND_TS_TYPE=6,BIND_TS_INTERFACE=7,BIND_FLAGS_TS_ENUM=256,BIND_FLAGS_TS_EXPORT_ONLY=1024,BIND_TS_NAMESPACE=8|BIND_FLAGS_TS_EXPORT_ONLY,BIND_TS_ENUM=BIND_LEXICAL|BIND_FLAGS_TS_ENUM,FUNC_STATEMENT=1,FUNC_HANGING_STATEMENT=2,CHAR_PAREN_L=40,CHAR_PAREN_R=41,CHAR_COMMA=44,CHAR_DOT=46,CHAR_COLON=58,CHAR_EQ=61,CHAR_LT=60,CHAR_BRACE_L=123,CHAR_BRACKET_L=91,CHAR_STAR=42,CHAR_HASH=35,CHAR_DQUOTE=34,CHAR_SQUOTE=39,SPECULATION_FAILED=SyntaxError("speculative parse failed"),tsPlugin=definePlugin((Base)=>{let{tokTypes:tt,keywordTypes,isIdentifierChar,isIdentifierStart}=Base.acorn,atType=new Base.acorn.TokenType("@");class TSParser extends Base{inType=!1;$4=!1;$5=!1;$7=null;$k=null;$l=!1;$m=!1;$f=null;$9=[[]];$n=0;$t=0;$o=-1;constructor(options,input,startPos){super(options,input,startPos);let onComment=this.options.onComment;if(typeof onComment==="function")this.options.onComment=(block,text,start,end,startLoc,endLoc)=>{if(start<this.$t)return;this.$t=end,onComment.call(this,block,text,start,end,startLoc,endLoc)}}reset(){this.inType=!1,this.$4=!1,this.$5=!1,this.$7=null,this.$k=null,this.$l=!1,this.$m=!1,this.$f=null,this.$9=[[]],this.$n=0,this.$t=0,this.$o=-1}getTokenFromCode(code){if(code===64)return++this.pos,this.finishToken(atType);return super.getTokenFromCode(code)}readToken_lt_gt(code){if(this.inType)return this.finishOp(tt.relational,1);return super.readToken_lt_gt(code)}$a(fn){let old=this.inType;this.inType=!0;let result=fn();if(this.inType=old,!old&&this.type===tt.relational)this.pos=this.start,this.nextToken();return result}$1(){return this.type===tt.relational&&this.value==="<"}$p(){if(this.type===tt.bitShift&&this.value==="<<")this.pos=this.start+1,this.finishToken(tt.relational,"<");return this.$1()}$c(){return this.type===tt.relational&&this.value===">"}$u(){return this.type===tt.prefix&&this.value==="!"}hasPrecedingLineBreak(){return hasLineBreak(this.input,this.lastTokEnd,this.start)}$d(from=this.pos){return SKIP_WHITESPACE.lastIndex=from,SKIP_WHITESPACE.exec(this.input),SKIP_WHITESPACE.lastIndex}$2(){return this.input.charCodeAt(this.$d())}$3(){let start=this.$d(),end=start;while(end<this.input.length&&isIdentifierChar(this.input.charCodeAt(end)))end++;return this.input.slice(start,end)}$b(){return!hasLineBreak(this.input,this.pos,this.$d())}$14(){return this.$b()&&isIdentifierStart(this.$2())&&!Object.hasOwn(keywordTypes,this.$3())}$15(){return{pos:this.pos,type:this.type,value:this.value,start:this.start,end:this.end,startLoc:this.startLoc,endLoc:this.endLoc,lastTokStart:this.lastTokStart,lastTokEnd:this.lastTokEnd,lastTokStartLoc:this.lastTokStartLoc,lastTokEndLoc:this.lastTokEndLoc,curLine:this.curLine,lineStart:this.lineStart,context:this.context.slice(),exprAllowed:this.exprAllowed,containsEsc:this.containsEsc,inType:this.inType,$4:this.$4,$5:this.$5,$7:this.$7,scopes:this.scopeStack.length,privateNames:this.privateNameStack.length,labels:this.labels,labelCount:this.labels.length,strict:this.strict,yieldPos:this.yieldPos,awaitPos:this.awaitPos,awaitIdentPos:this.awaitIdentPos,potentialArrowAt:this.potentialArrowAt,potentialArrowInForAwait:this.potentialArrowInForAwait}}$16(state){this.pos=state.pos,this.type=state.type,this.value=state.value,this.start=state.start,this.end=state.end,this.startLoc=state.startLoc,this.endLoc=state.endLoc,this.lastTokStart=state.lastTokStart,this.lastTokEnd=state.lastTokEnd,this.lastTokStartLoc=state.lastTokStartLoc,this.lastTokEndLoc=state.lastTokEndLoc,this.curLine=state.curLine,this.lineStart=state.lineStart,this.context=state.context,this.exprAllowed=state.exprAllowed,this.containsEsc=state.containsEsc,this.inType=state.inType,this.$4=state.$4,this.$5=state.$5,this.$7=state.$7,this.scopeStack.length=state.scopes,this.privateNameStack.length=state.privateNames,this.labels=state.labels,this.labels.length=state.labelCount,this.strict=state.strict,this.yieldPos=state.yieldPos,this.awaitPos=state.awaitPos,this.awaitIdentPos=state.awaitIdentPos,this.potentialArrowAt=state.potentialArrowAt,this.potentialArrowInForAwait=state.potentialArrowInForAwait}raise(pos,message){if(this.$n>0)throw SPECULATION_FAILED;return super.raise(pos,message)}$1y(pos,message){try{super.raise(pos,message)}catch(error){if(error instanceof SyntaxError)error.$1z=!0;throw error}throw Error("unreachable")}$g(fn,lookahead=!1){let state=this.$15();this.$n++;try{let result=fn();if(lookahead||result===void 0)this.$16(state);return result}catch(error){if(!(error instanceof SyntaxError)||!lookahead&&error.$1z)throw error;this.$16(state);return}finally{this.$n--}}$v(fn){return this.$g(fn,!0)===!0}$17(node){if(node.end=this.lastTokEnd,this.options.locations)node.loc.end=this.lastTokEndLoc}$q(node,from){if(node.start=from.start,this.options.locations)node.loc.start=from.loc.start}$6(returnType=!1){let node=this.startNode();return node.typeAnnotation=this.$a(()=>(this.next(),returnType?this.$20():this.$0())),this.finishNode(node,"TSTypeAnnotation")}$h(node,optional){if(optional&&this.eat(tt.question))node.optional=!0,this.$17(node);if(this.type===tt.colon)node.typeAnnotation=this.$6(),this.$17(node);return node}$20(){if(this.type!==tt.name&&this.type!==tt._this)return this.$0();if(this.isContextual("asserts")&&this.$b()&&isIdentifierStart(this.$2())){let node=this.startNode();if(this.next(),node.parameterName=this.type===tt._this?this.$w():this.parseIdent(),this.isContextual("is")&&!this.hasPrecedingLineBreak())return this.$x(node,!0);return node.asserts=!0,node.typeAnnotation=null,this.finishNode(node,"TSTypePredicate")}if(this.$3()==="is"&&this.$b()){let node=this.startNode();return node.parameterName=this.type===tt._this?this.$w():this.parseIdent(!0),this.$x(node,!1)}return this.$0()}$x(node,asserts){this.next();let annotation=this.startNode();return annotation.typeAnnotation=this.$0(),node.typeAnnotation=this.finishNode(annotation,"TSTypeAnnotation"),node.asserts=asserts,this.finishNode(node,"TSTypePredicate")}$w(){let node=this.startNode();return this.next(),this.finishNode(node,"TSThisType")}parseWholeType(){this.inType=!0,this.nextToken();let type=this.$0();if(this.type!==tt.eof)this.unexpected();return type}$0(){let type=this.$18();if(this.$4||this.type!==tt._extends||this.hasPrecedingLineBreak())return type;let node=this.startNodeAt(type.start,type.loc?.start);return this.next(),node.checkType=type,node.extendsType=this.$i(!0,()=>this.$18()),this.expect(tt.question),node.trueType=this.$i(!1,()=>this.$0()),this.expect(tt.colon),node.falseType=this.$i(!1,()=>this.$0()),this.finishNode(node,"TSConditionalType")}$i(disallow,fn){let old=this.$4;this.$4=disallow;let result=fn();return this.$4=old,result}$18(){if(this.$21())return this.$19("TSFunctionType");if(this.type===tt._new||this.isContextual("abstract")&&this.$3()==="new")return this.$19("TSConstructorType");return this.$1a("TSUnionType",tt.bitwiseOR,()=>this.$1a("TSIntersectionType",tt.bitwiseAND,()=>this.$1b()))}$19(type){let node=this.startNode();if(type==="TSConstructorType"){if(node.abstract=this.isContextual("abstract"),node.abstract)this.next();this.next()}return this.$i(!1,()=>this.$r(node,tt.arrow)),this.finishNode(node,type)}$r(node,returnToken){if(this.$1())node.typeParameters=this.$8();if(this.expect(tt.parenL),node.parameters=this.parseBindingList(tt.parenR,!1,!0),this.type===returnToken)node.typeAnnotation=this.$6(!0);else if(returnToken===tt.arrow)this.unexpected()}$21(){if(this.$1())return!0;if(this.type!==tt.parenL)return!1;return this.$v(()=>{if(this.next(),this.type===tt.parenR||this.type===tt.ellipsis)return!0;if(this.type===tt.name||this.type===tt._this)this.next();else if(this.type===tt.braceL||this.type===tt.bracketL)this.parseBindingAtom();else return!1;let type=this.type;if(type===tt.colon||type===tt.comma||type===tt.question||type===tt.eq)return!0;if(type!==tt.parenR)return!1;return this.next(),this.type===tt.arrow})}$1a(type,operator,parseConstituent){let node=this.startNode(),hasLeadingOperator=this.eat(operator),types=[];do types.push(parseConstituent());while(this.eat(operator));if(types.length===1&&!hasLeadingOperator)return types[0];return node.types=types,this.finishNode(node,type)}$1b(){if(this.type===tt.name&&!this.containsEsc){let value=this.value;if(value==="keyof"||value==="unique"||value==="readonly"){let node=this.startNode();return this.next(),node.operator=value,node.typeAnnotation=this.$1b(),this.finishNode(node,"TSTypeOperator")}if(value==="infer"){let node=this.startNode();this.next();let parameter=this.startNode();parameter.name=this.$y();let constraint=this.$g(()=>this.$22());if(constraint)parameter.constraint=constraint;return node.typeParameter=this.finishNode(parameter,"TSTypeParameter"),this.finishNode(node,"TSInferType")}}return this.$i(!1,()=>this.$23())}$22(){if(!this.eat(tt._extends))return;let constraint=this.$i(!0,()=>this.$0());return this.$4||this.type!==tt.question?constraint:void 0}$y(){if(this.type!==tt.name&&!this.type.keyword)this.unexpected();let name=this.type===tt.name?this.value:this.type.keyword;return this.next(),name}$23(){let type=this.$24();while(!this.hasPrecedingLineBreak()&&this.eat(tt.bracketL)){let node=this.startNodeAt(type.start,type.loc?.start);if(this.eat(tt.bracketR))node.elementType=type,type=this.finishNode(node,"TSArrayType");else node.objectType=type,node.indexType=this.$0(),this.expect(tt.bracketR),type=this.finishNode(node,"TSIndexedAccessType")}return type}$24(){switch(this.type){case tt.name:case tt._void:case tt._null:{let keyword=KEYWORD_TYPES.get(this.value);if(keyword&&(this.type!==tt.name||!this.containsEsc&&this.$2()!==CHAR_DOT)){let node=this.startNode();return this.next(),this.finishNode(node,keyword)}return this.$1c()}case tt.string:case tt.num:case tt._true:case tt._false:{let node=this.startNode();return node.literal=this.parseExprAtom(),this.finishNode(node,"TSLiteralType")}case tt.plusMin:{if(this.value!=="-")break;let node=this.startNode(),unary=this.startNode();if(this.next(),this.type!==tt.num)this.unexpected();return unary.operator="-",unary.prefix=!0,unary.argument=this.parseExprAtom(),node.literal=this.finishNode(unary,"UnaryExpression"),this.finishNode(node,"TSLiteralType")}case tt.backQuote:return this.$25();case tt._this:{let thisType=this.$w();if(this.isContextual("is")&&!this.hasPrecedingLineBreak()){let node=this.startNodeAt(thisType.start,thisType.loc?.start);return node.parameterName=thisType,this.$x(node,!1)}return thisType}case tt._typeof:return this.$26();case tt._import:return this.$1d();case tt.braceL:return this.$27()?this.$28():this.$29();case tt.bracketL:return this.$2a();case tt.parenL:{let node=this.startNode();return this.next(),node.typeAnnotation=this.$0(),this.expect(tt.parenR),this.finishNode(node,"TSParenthesizedType")}default:if(this.type.keyword)return this.$1c()}return this.unexpected()}$1c(){let node=this.startNode();if(node.typeName=this.$j(),!this.hasPrecedingLineBreak()&&this.$1())node.typeArguments=this.$e();return this.finishNode(node,"TSTypeReference")}$j(){let entity=this.parseIdent(!0);while(this.eat(tt.dot)){let node=this.startNodeAt(entity.start,entity.loc?.start);node.left=entity,node.right=this.parseIdent(!0),entity=this.finishNode(node,"TSQualifiedName")}return entity}$26(){let node=this.startNode();if(this.next(),node.exprName=this.type===tt._import?this.$1d():this.$j(),!this.hasPrecedingLineBreak()&&this.$1())node.typeArguments=this.$e();return this.finishNode(node,"TSTypeQuery")}$1d(){let node=this.startNode();if(this.next(),node.argument=this.$1e(),this.eat(tt.dot))node.qualifier=this.$j();if(this.$1())node.typeArguments=this.$e();return this.finishNode(node,"TSImportType")}$z(){if(this.type!==tt.string)this.unexpected();return this.parseExprAtom()}$1e(){this.expect(tt.parenL);let string=this.$z();return this.expect(tt.parenR),string}$25(){let node=this.startNode(),literal=this.startNode();this.next(),literal.expressions=[];let element=this.parseTemplateElement({isTagged:!1});literal.quasis=[element];while(!element.tail){if(this.type===tt.eof)this.raise(this.pos,"Unterminated template literal");this.expect(tt.dollarBraceL),literal.expressions.push(this.$0()),this.expect(tt.braceR),element=this.parseTemplateElement({isTagged:!1}),literal.quasis.push(element)}return this.next(),node.literal=this.finishNode(literal,"TemplateLiteral"),this.finishNode(node,"TSLiteralType")}$27(){return this.$v(()=>{if(this.next(),this.type===tt.plusMin)return this.next(),this.isContextual("readonly");if(this.isContextual("readonly"))this.next();if(this.type!==tt.bracketL)return!1;if(this.next(),this.type!==tt.name)return!1;return this.next(),this.type===tt._in})}$28(){let node=this.startNode();if(this.expect(tt.braceL),this.type===tt.plusMin)node.readonly=this.value,this.next(),this.expectContextual("readonly");else if(this.eatContextual("readonly"))node.readonly=!0;this.expect(tt.bracketL);let parameter=this.startNode();if(parameter.name=this.$y(),this.expect(tt._in),parameter.constraint=this.$0(),node.typeParameter=this.finishNode(parameter,"TSTypeParameter"),node.nameType=this.eatContextual("as")?this.$0():null,this.expect(tt.bracketR),this.type===tt.plusMin)node.optional=this.value,this.next(),this.expect(tt.question);else if(this.eat(tt.question))node.optional=!0;if(this.eat(tt.colon))node.typeAnnotation=this.$0();return this.semicolon(),this.expect(tt.braceR),this.finishNode(node,"TSMappedType")}$29(){let node=this.startNode();return node.members=this.$1f(),this.finishNode(node,"TSTypeLiteral")}$1f(){this.expect(tt.braceL);let members=[];while(!this.eat(tt.braceR))members.push(this.$2b());return members}$2b(){let node=this.startNode(),type="TSPropertySignature",next=this.type===tt._new?this.$2():-1;if(this.type===tt.parenL||this.$1())type="TSCallSignatureDeclaration",this.$r(node,tt.colon);else if(next===CHAR_PAREN_L||next===CHAR_LT)type="TSConstructSignatureDeclaration",this.next(),this.$r(node,tt.colon);else{let newKey=this.type===tt._new?this.parseIdent(!0):null;if(this.isContextual("readonly")&&this.$s(!0))this.next(),node.readonly=!0;if(this.type===tt.bracketL&&this.$1g())return this.$1h(node);let kind="method";if(newKey)node.key=newKey;else{if((this.isContextual("get")||this.isContextual("set"))&&this.$s(!1))kind=this.value,this.next();this.parsePropertyName(node)}if(this.eat(tt.question))node.optional=!0;if(this.type===tt.parenL||this.$1()){if(type="TSMethodSignature",kind!=="method")node.kind=kind;this.$r(node,tt.colon),node.kind=kind}else if(this.type===tt.colon)node.typeAnnotation=this.$6()}return this.$1i(),this.finishNode(node,type)}$1i(){if(!this.eat(tt.comma))this.semicolon()}$1g(){return this.$v(()=>{if(this.next(),this.type!==tt.name)return!1;return this.next(),this.type===tt.colon})}$1h(node){if(this.expect(tt.bracketL),node.parameters=[this.$h(this.parseIdent(),!1)],this.expect(tt.bracketR),this.type===tt.colon)node.typeAnnotation=this.$6();return this.$1i(),this.finishNode(node,"TSIndexSignature")}$2a(){let node=this.startNode();this.expect(tt.bracketL),node.elementTypes=[];while(!this.eat(tt.bracketR))if(node.elementTypes.push(this.$2c()),this.type!==tt.bracketR)this.expect(tt.comma);return this.finishNode(node,"TSTupleType")}$2c(){let start=this.start,startLoc=this.startLoc,rest=this.eat(tt.ellipsis),element;if((this.type===tt.name||this.type.keyword)&&this.$2d()){let node=this.startNode();node.label=this.parseIdent(!0),node.optional=this.eat(tt.question),this.expect(tt.colon),node.elementType=this.$0(),element=this.finishNode(node,"TSNamedTupleMember")}else if(element=this.$0(),this.eat(tt.question)){let node=this.startNodeAt(element.start,element.loc?.start);node.typeAnnotation=element,element=this.finishNode(node,"TSOptionalType")}if(rest){let node=this.startNodeAt(start,startLoc);node.typeAnnotation=element,element=this.finishNode(node,"TSRestType")}return element}$2d(){let at=this.$d();if(this.input.charCodeAt(at)===63)at=this.$d(at+1);return this.input.charCodeAt(at)===CHAR_COLON}$8(){return this.$a(()=>{let node=this.startNode();this.next(),node.params=[];while(!this.$c()){let parameter=this.startNode();while((this.type===tt._const||this.type===tt._in||this.isContextual("out"))&&isIdentifierStart(this.$2()))parameter[this.value]=!0,this.next();if(parameter.name=this.$y(),this.eat(tt._extends))parameter.constraint=this.$0();if(this.eat(tt.eq))parameter.default=this.$0();if(node.params.push(this.finishNode(parameter,"TSTypeParameter")),!this.$c()){if(this.expect(tt.comma),this.$c())node.extra={trailingComma:this.lastTokStart}}}if(this.next(),node.params.length===0)this.$1y(this.start,"Type parameter list cannot be empty.");return this.finishNode(node,"TSTypeParameterDeclaration")})}$e(){return this.$a(()=>{let node=this.startNode();this.next(),node.params=[];while(!this.$c())if(node.params.push(this.$0()),!this.$c())this.expect(tt.comma);if(node.params.length===0)this.unexpected();return this.next(),this.finishNode(node,"TSTypeParameterInstantiation")})}$1j(){let list=[];do{let node=this.startNode();if(node.expression=this.$j(),this.$1())node.typeParameters=this.$e();list.push(this.finishNode(node,"TSExpressionWithTypeArguments"))}while(this.eat(tt.comma));return list}$1k(exported=!1){if(this.type!==tt.name||this.containsEsc){if(this.type===tt._const&&this.$3()==="enum")return this.$10(this.startNode());return}if(!this.$2e(this.value))return;if(this.value==="declare")return this.$2f(exported);return this.$1l(this.startNode(),this.value)}$2e(word){switch(word){case"interface":case"type":case"namespace":return this.$14();case"enum":return isIdentifierStart(this.$2());case"abstract":return this.$b()&&this.$3()==="class";case"module":{let next=this.$2();return this.$b()&&(next===CHAR_DQUOTE||next===CHAR_SQUOTE||isIdentifierStart(next))}case"declare":return this.$b()&&DECLARE_TARGETS.has(this.$3());case"global":return this.$b()&&this.$2()===CHAR_BRACE_L}return!1}$1l(node,word){switch(word){case"interface":return this.$1m(node);case"type":return this.$2g(node);case"enum":return this.$10(node);case"abstract":return this.$1n(node,!0);case"global":return node.global=!0,node.id=this.parseIdent(),node.body=this.$11(),this.finishNode(node,"TSModuleDeclaration")}return this.$2h(node)}$2f(exported){let old=this.$5;this.$5=!0;let node=this.startNode();this.next();let word=this.value;if(word==="const"&&this.$3()==="enum")node.const=!0;if(!exported&&DECLARE_FIRST.has(word))node.declare=!0;let declaration;if(node.const)declaration=this.$10(node);else if(word==="var"||word==="let"||word==="const")declaration=this.parseVarStatement(node,word,!0);else if(word==="function")this.next(),declaration=this.parseFunction(node,FUNC_STATEMENT,!1,!1);else if(word==="class")declaration=this.parseClass(node,!0);else declaration=this.$1l(node,word);return declaration.declare=!0,this.$5=old,declaration}$1n(node,isStatement){return this.next(),node.abstract=!0,this.parseClass(node,isStatement)}$1m(node){if(this.next(),node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_INTERFACE),this.$1())node.typeParameters=this.$8();return this.$a(()=>{if(this.eat(tt._extends))node.extends=this.$1j();let body=this.startNode();body.body=this.$1f(),node.body=this.finishNode(body,"TSInterfaceBody")}),this.finishNode(node,"TSInterfaceDeclaration")}$2g(node){if(this.next(),node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_TYPE),this.$1())node.typeParameters=this.$8();return node.typeAnnotation=this.$a(()=>(this.expect(tt.eq),this.$0())),this.semicolon(),this.finishNode(node,"TSTypeAliasDeclaration")}$10(node){if(this.type===tt._const)node.const=!0,this.next();this.next(),node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_ENUM),this.expect(tt.braceL),node.members=[];while(!this.eat(tt.braceR)){let member=this.startNode();if(member.id=this.type===tt.string?this.parseExprAtom():this.parseIdent(!0),this.eat(tt.eq))member.initializer=this.parseMaybeAssign();if(node.members.push(this.finishNode(member,"TSEnumMember")),this.type!==tt.braceR)this.expect(tt.comma)}return this.finishNode(node,"TSEnumDeclaration")}$2h(node){if(this.next(),this.type===tt.string){if(node.id=this.parseExprAtom(),this.type===tt.braceL)node.body=this.$11();else this.semicolon();return this.finishNode(node,"TSModuleDeclaration")}return node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_NAMESPACE),this.$1o(node)}$1o(node){if(this.eat(tt.dot)){let inner=this.startNode();inner.id=this.parseIdent(),node.body=this.$1o(inner)}else node.body=this.$11();return this.finishNode(node,"TSModuleDeclaration")}$11(){this.enterScope(SCOPE_CLASS_STATIC_BLOCK);let node=this.startNode();this.enterScope(0),this.expect(tt.braceL),node.body=[];while(!this.eat(tt.braceR))node.body.push(this.parseStatement(null,!0));return this.exitScope(),this.exitScope(),this.finishNode(node,"TSModuleBlock")}$1p(node,isExport){if(node.isExport=isExport,node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_LEXICAL),this.expect(tt.eq),this.isContextual("require")&&this.$2()===CHAR_PAREN_L){let reference=this.startNode();this.next(),reference.expression=this.$1e(),node.moduleReference=this.finishNode(reference,"TSExternalModuleReference")}else node.moduleReference=this.$j();return this.semicolon(),this.finishNode(node,"TSImportEqualsDeclaration")}$2i(){let at=this.$d();if(this.input.charCodeAt(at)!==CHAR_EQ)return!1;let after=this.input.charCodeAt(at+1);return after!==CHAR_EQ&&after!==62}parseStatement(context,topLevel,exports){if(this.type===atType)this.$1q(!0);let declaration=this.$1k();if(declaration)return declaration;return super.parseStatement(context,topLevel,exports)}parseVarStatement(node,kind,allowMissingInitializer){return super.parseVarStatement(node,kind,allowMissingInitializer||this.$5)}parseVarId(decl,kind){if(super.parseVarId(decl,kind),decl.id.type==="Identifier"&&this.$u()&&!this.hasPrecedingLineBreak())this.next(),decl.definite=!0;this.$h(decl.id,!1)}parseCatchClauseParam(){let param=this.$h(this.parseBindingAtom(),!1),simple=param.type==="Identifier";return this.enterScope(simple?SCOPE_SIMPLE_CATCH:0),this.checkLValPattern(param,simple?BIND_SIMPLE_CATCH:BIND_LEXICAL),this.expect(tt.parenR),param}parseImport(node){if(this.next(),node.importKind="value",this.type===tt.string)node.specifiers=[],node.source=this.parseExprAtom();else{if(this.isContextual("type")){let next=this.$2();if(next===CHAR_BRACE_L||next===CHAR_STAR||isIdentifierStart(next)&&this.$3()!=="from")node.importKind="type",this.next()}if(this.type===tt.name&&this.$2i())return this.$1p(node,!1);node.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),node.source=this.$z()}return this.$1r(node),this.semicolon(),this.finishNode(node,"ImportDeclaration")}parseWithClause(){if(this.isContextual("assert")&&!this.hasPrecedingLineBreak())this.type=tt._with;return this.type===tt._with?super.parseWithClause():void 0}$1r(node){let attributes=this.parseWithClause();if(attributes)node.attributes=attributes}parseImportSpecifier(){return this.$1s("importKind",()=>super.parseImportSpecifier())}parseExportSpecifier(exports){return this.$1s("exportKind",()=>super.parseExportSpecifier(exports))}$1s(kindKey,parse){let next=this.isContextual("type")?this.$2():-1;if(next===CHAR_DQUOTE||next===CHAR_SQUOTE||isIdentifierStart(next)&&this.$3()!=="as"){let modifier=this.startNode();this.next();let node=parse();return this.$q(node,modifier),node[kindKey]="type",node}let node=parse();return node[kindKey]="value",node}parseExport(node,exports){if(this.next(),this.eat(tt._import)){if(node.importKind="value",this.isContextual("type")&&isIdentifierStart(this.$2())&&this.$3()!=="from")node.importKind="type",this.next();return this.$1p(node,!0)}if(this.eat(tt.eq))return node.expression=this.parseExpression(),this.semicolon(),this.finishNode(node,"TSExportAssignment");if(this.eatContextual("as"))return this.expectContextual("namespace"),node.id=this.parseIdent(),this.semicolon(),this.finishNode(node,"TSNamespaceExportDeclaration");if(node.exportKind="value",this.isContextual("type")){let next=this.$2();if(next===CHAR_BRACE_L||next===CHAR_STAR)node.exportKind="type",this.next()}if(this.eat(tt.star))return this.parseExportAllDeclaration(node,exports);if(this.eat(tt._default)){if(this.isContextual("interface")&&this.$14())node.declaration=this.$1m(this.startNode());else if(this.isContextual("abstract")&&this.$3()==="class")node.declaration=this.$1n(this.startNode(),"nullableID");else node.declaration=this.parseExportDefaultDeclaration();return this.finishNode(node,"ExportDefaultDeclaration")}let isDeclare=this.isContextual("declare"),declaration=this.$1k(!0);if(declaration||this.shouldParseExportStatement()){if(node.declaration=declaration??this.parseStatement(null),isDeclare||node.declaration.type==="TSInterfaceDeclaration"||node.declaration.type==="TSTypeAliasDeclaration")node.exportKind="type";return node.specifiers=[],node.source=null,this.finishNode(node,"ExportNamedDeclaration")}if(node.declaration=null,node.specifiers=this.parseExportSpecifiers(exports),this.eatContextual("from"))node.source=this.$z(),this.$1r(node);else{for(let spec of node.specifiers)if(this.checkUnreserved(spec.local),this.checkLocalExport(spec.local),spec.local.type==="Literal")this.raise(spec.local.start,"A string literal cannot be used as an exported binding without `from`.");node.source=null}return this.semicolon(),this.finishNode(node,"ExportNamedDeclaration")}parseFunction(node,statement,allowExpressionBody,isAsync,forInit){let isDeclaration=statement&FUNC_STATEMENT;if(isDeclaration)this.$f=node,this.$o=node.start;super.parseFunction(node,statement,allowExpressionBody,isAsync,forInit),this.$f=null;let bodiless=!node.body;if(bodiless)node.type="TSDeclareFunction";if(isDeclaration&&node.id){if(bodiless){if(this.$5&&this.currentScope().flags&SCOPE_TOP)this.declareName(node.id.name,BIND_FLAGS_TS_EXPORT_ONLY,node.id.start);this.checkLValSimple(node.id,BIND_NONE)}else if(!(statement&FUNC_HANGING_STATEMENT)){let bindingType=BIND_FUNCTION;if(this.strict||node.generator||node.async)bindingType=this.treatFunctionsAsVar?BIND_VAR:BIND_LEXICAL;this.checkLValSimple(node.id,bindingType)}}return node}parseFunctionParams(node){if(this.$1())node.typeParameters=this.$8();if(super.parseFunctionParams(node),this.type===tt.colon)node.returnType=this.$6(!0)}parseFunctionBody(node,isArrowFunction,isMethod,forInit){if(isMethod&&this.type===tt.colon)node.returnType=this.$6(!0);if(isArrowFunction||this.type===tt.braceL||node.start!==this.$o){super.parseFunctionBody(node,isArrowFunction,isMethod,forInit);return}this.semicolon(),this.exitScope()}parseMethod(isGenerator,isAsync,allowDirectSuper){let typeParameters=this.$k;this.$k=null;let node=super.parseMethod(isGenerator,isAsync,allowDirectSuper);if(!node.body)node.type="TSDeclareMethod";if(typeParameters)node.typeParameters=typeParameters;return node}parseBindingList(close,allowEmpty,allowTrailingComma,allowModifiers){let modifiers=allowModifiers===!0||this.$l;return this.$l=!1,super.parseBindingList(close,allowEmpty,allowTrailingComma,modifiers)}$s(allowLineBreak){if(!allowLineBreak&&!this.$b())return!1;let next=this.$2();return next===CHAR_BRACKET_L||next===CHAR_BRACE_L||next===CHAR_STAR||next===CHAR_DOT||next===CHAR_HASH||next===CHAR_DQUOTE||next===CHAR_SQUOTE||next>=48&&next<=57||isIdentifierStart(next)}parseAssignableListItem(allowModifiers){let decorators=this.$12(),start=this.start,startLoc=this.startLoc,accessibility,readonly=!1,override=!1;if(allowModifiers)while(this.type===tt.name&&PARAMETER_MODIFIERS.has(this.value)&&!this.containsEsc&&this.$s(!1)){if(this.value==="readonly")readonly=!0;else if(this.value==="override")override=!0;else accessibility=this.value;this.next()}let left;if(this.type===tt._this)left=this.startNode(),left.name="this",this.next(),this.finishNode(left,"Identifier");else left=this.parseBindingAtom();let element=this.type===tt.eq?this.parseMaybeDefault(start,startLoc,left):this.parseMaybeDefault(left.start,left.loc?.start,this.$h(left,!0));if(decorators.length>0)element.decorators=decorators;if(!accessibility&&!readonly&&!override)return element;let node=this.startNodeAt(start,startLoc);if(accessibility)node.accessibility=accessibility;if(readonly)node.readonly=!0;if(override)node.override=!0;return node.parameter=element,this.finishNode(node,"TSParameterProperty")}parseBindingListItem(param){if(param.type==="RestElement")this.$h(param,!0);return param}checkLValSimple(expr,bindingType,checkClashes){if(this.$f&&expr===this.$f.id){this.$f=null;return}if(!bindingType&&TS_EXPRESSION_WRAPPERS.has(expr.type)){this.checkLValSimple(expr.expression,bindingType,checkClashes);return}switch(expr.type){case"TSParameterProperty":this.checkLValInnerPattern(expr.parameter,bindingType,checkClashes);return;case"Identifier":if(expr.name==="this")return}super.checkLValSimple(expr,bindingType,checkClashes)}toAssignable(node,isBinding,refDestructuringErrors){if(node&&!isBinding&&TS_EXPRESSION_WRAPPERS.has(node.type))return node;return super.toAssignable(node,isBinding,refDestructuringErrors)}declareName(name,bindingType,pos){let scope=this.currentScope();if(bindingType&BIND_FLAGS_TS_EXPORT_ONLY){this.$1t(scope,name),scope.$1u??=[],scope.$1u.push(name);return}if(bindingType===BIND_TS_TYPE||bindingType===BIND_TS_INTERFACE){if(scope.$13??=[],bindingType===BIND_TS_TYPE&&hasName(scope.$13,name))this.raise(pos,`type '${name}' has already been declared.`);scope.$13.push(name),this.$1t(scope,name);return}if(bindingType&BIND_FLAGS_TS_ENUM){if(scope.$1v??=[],hasName(scope.$1v,name))return;super.declareName(name,BIND_LEXICAL,pos),scope.$1v.push(name);return}super.declareName(name,bindingType,pos)}$1t(scope,name){if(this.inModule&&scope.flags&SCOPE_TOP)delete this.undefinedExports[name]}checkLocalExport(id){for(let i=this.scopeStack.length-1;i>=0;i--){let scope=this.scopeStack[i];if(hasName(scope.$13,id.name)||hasName(scope.$1u,id.name))return}super.checkLocalExport(id)}checkExport(){}raiseRecoverable(pos,message){if(message==="Duplicate constructor in the same class")return;super.raiseRecoverable(pos,message)}$12(){let decorators=[];while(this.type===atType)decorators.push(this.$1w());return decorators}$1q(allowExport){let pending=this.$9[this.$9.length-1];while(this.type===atType)pending.push(this.$1w());if(this.type===tt._export){if(!allowExport)this.unexpected()}else if(this.type!==tt._class&&!((this.isContextual("abstract")||this.isContextual("declare"))&&this.$3()==="class"))this.raise(this.start,"Leading decorators must be attached to a class declaration.")}$1w(){let node=this.startNode();this.next(),this.$9.push([]);let startPos=this.start,startLoc=this.startLoc,expression;if(this.type===tt.parenL){if(this.next(),expression=this.parseExpression(),this.expect(tt.parenR),this.options.preserveParens){let paren=this.startNodeAt(startPos,startLoc);paren.expression=expression,expression=this.finishNode(paren,"ParenthesizedExpression")}}else{expression=this.parseIdent(!1);while(this.eat(tt.dot)){let member=this.startNodeAt(startPos,startLoc);member.object=expression,member.property=this.parseIdent(!0),member.computed=!1,expression=this.finishNode(member,"MemberExpression")}}let typeArguments=this.$p()?this.$e():void 0;if(this.eat(tt.parenL)){let call=this.startNodeAt(expression.start,expression.loc?.start);if(call.callee=expression,call.arguments=this.parseExprList(tt.parenR,!1,!1),typeArguments)call.typeArguments=typeArguments;expression=this.finishNode(call,"CallExpression")}else if(typeArguments){let instantiation=this.startNodeAt(expression.start,expression.loc?.start);instantiation.expression=expression,instantiation.typeArguments=typeArguments,expression=this.finishNode(instantiation,"TSInstantiationExpression")}return node.expression=expression,this.$9.pop(),this.finishNode(node,"Decorator")}shouldParseExportStatement(){return this.type===atType||super.shouldParseExportStatement()}parseExprAtom(refDestructuringErrors,forInit,forNew){if(this.type===atType)this.$1q(!1);return super.parseExprAtom(refDestructuringErrors,forInit,forNew)}parseProperty(isPattern,refDestructuringErrors){if(isPattern||this.type!==atType)return super.parseProperty(isPattern,refDestructuringErrors);let decorators=this.$12(),property=super.parseProperty(isPattern,refDestructuringErrors);if(property.type==="SpreadElement")this.raise(property.start,"Decorators can't be used with SpreadElement");return property.decorators=decorators,property}parseClassId(node,isStatement){let index=this.$9.length-1,decorators=this.$9[index];if(decorators.length>0)node.decorators=decorators,this.$q(node,decorators[0]),this.$9[index]=[];if(!this.isContextual("implements")||isStatement===!0)super.parseClassId(node,isStatement);if(this.$1())node.typeParameters=this.$8()}parseClassSuper(node){if(super.parseClassSuper(node),node.superClass&&this.$1())node.superTypeParameters=this.$e();if(this.eatContextual("implements"))node.implements=this.$a(()=>this.$1j())}parseClassElement(constructorAllowsSuper){if(this.type===atType){let decorators=this.$12();if(this.type===tt.braceR)this.raise(this.start,"Decorators must be attached to a class element.");let element=this.parseClassElement(constructorAllowsSuper);return element.decorators=decorators,this.$q(element,decorators[0]),element}if(this.eat(tt.semi))return null;let node=this.startNode();while(this.type===tt.name&&CLASS_MODIFIERS.has(this.value)&&!this.containsEsc&&this.$s(this.value==="static")){let modifier=this.value;if(this.next(),modifier==="static"&&this.type===tt.braceL)return this.next(),this.parseClassStaticBlock(node),node;if(modifier==="public"||modifier==="private"||modifier==="protected")node.accessibility=modifier;else node[modifier]=!0}if(this.type===tt.bracketL&&this.$1g())return this.$1h(node);node.static??=!1;let keyName="",isGenerator=!1,isAsync=!1,kind="method";if(this.eatContextual("async"))if((this.isClassElementNameStart()||this.type===tt.star)&&!this.canInsertSemicolon())isAsync=!0;else keyName="async";if(!keyName&&this.eat(tt.star))isGenerator=!0;if(!keyName&&!isAsync&&!isGenerator){let lastValue=this.value;if(this.eatContextual("get")||this.eatContextual("set"))if(this.isClassElementNameStart())kind=lastValue;else keyName=lastValue}if(keyName)node.computed=!1,node.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),node.key.name=keyName,this.finishNode(node.key,"Identifier");else this.parseClassElementName(node);if(this.eat(tt.question))node.optional=!0;if(this.type===tt.parenL||this.$1()||kind!=="method"||isGenerator||isAsync){let key=node.key,isConstructor=!node.static&&!node.computed&&(key.type==="Identifier"&&key.name==="constructor"||key.type==="Literal"&&key.value==="constructor");if(node.kind=isConstructor?"constructor":kind,this.$1())node.typeParameters=this.$8();this.$l=isConstructor,this.$o=this.start,this.parseClassMethod(node,isGenerator,isAsync,isConstructor&&constructorAllowsSuper)}else{if(!node.optional&&this.$u())this.next(),node.definite=!0;if(this.type===tt.colon)node.typeAnnotation=this.$6();this.parseClassField(node)}return node}parseMaybeAssign(forInit,refDestructuringErrors,afterLeftParse){if(this.$p()){let arrow=this.$g(()=>{let typeParameters=this.$8(),expr=super.parseMaybeAssign(forInit,refDestructuringErrors,afterLeftParse);if(expr.type!=="ArrowFunctionExpression")return;return expr.typeParameters=typeParameters,this.$q(expr,typeParameters),expr});if(arrow)return arrow}return super.parseMaybeAssign(forInit,refDestructuringErrors,afterLeftParse)}parseMaybeUnary(refDestructuringErrors,sawUnary,incDec,forInit){if(this.$p()){let node=this.startNode();return node.typeAnnotation=this.$a(()=>{this.next();let type=this.$0();if(!this.$c())this.unexpected();return this.next(),type}),node.expression=this.parseMaybeUnary(null,!1,!1,forInit),this.finishNode(node,"TSTypeAssertion")}return super.parseMaybeUnary(refDestructuringErrors,sawUnary,incDec,forInit)}parseMaybeConditional(forInit,refDestructuringErrors){let startPos=this.start,startLoc=this.startLoc,expr=this.parseExprOps(forInit,refDestructuringErrors);if(this.checkExpressionErrors(refDestructuringErrors))return expr;if(this.type===tt.question&&!(expr.type==="ArrowFunctionExpression"&&expr.start===startPos)&&!this.$2j()){this.next();let node=this.startNodeAt(startPos,startLoc);return node.test=expr,node.consequent=this.parseMaybeAssign(),this.expect(tt.colon),node.alternate=this.parseMaybeAssign(forInit),this.finishNode(node,"ConditionalExpression")}return expr}$2j(){let at=this.$d(),next=this.input.charCodeAt(at);if(next===CHAR_COLON||next===CHAR_COMMA||next===CHAR_PAREN_R)return!0;return next===CHAR_EQ&&this.input.charCodeAt(at+1)!==CHAR_EQ}parseParenItem(item){return this.$h(item,!0)}$1x(){if(this.type!==tt.colon)return!0;let returnType=this.$g(()=>{let type=this.$6(!0);return this.type===tt.arrow&&!this.canInsertSemicolon()?type:void 0});if(!returnType)return!1;return this.$7=returnType,!0}shouldParseArrow(exprList){return this.$1x()&&super.shouldParseArrow(exprList)}shouldParseAsyncArrow(){return this.$1x()&&super.shouldParseAsyncArrow()}parseArrowExpression(node,params,isAsync,forInit){if(this.$7)node.returnType=this.$7,this.$7=null;return super.parseArrowExpression(node,params,isAsync,forInit)}parseExprList(close,allowTrailingComma,allowEmpty,refDestructuringErrors){if(!this.$m)return super.parseExprList(close,allowTrailingComma,allowEmpty,refDestructuringErrors);this.$m=!1;let elements=[],first=!0;while(!this.eat(close)){if(first)first=!1;else if(this.expect(tt.comma),allowTrailingComma&&this.afterTrailingComma(close))break;if(this.type===tt.ellipsis){let spread=this.parseSpread(refDestructuringErrors);if(this.eat(tt.question))spread.optional=!0;if(this.type===tt.colon)spread.typeAnnotation=this.$6();elements.push(spread)}else elements.push(this.parseMaybeAssign(!1,refDestructuringErrors,this.parseParenItem))}return elements}parseSubscript(base,startPos,startLoc,noCalls,maybeAsyncArrow,optionalChained,forInit){if(this.$u()&&!this.hasPrecedingLineBreak()){let node=this.startNodeAt(startPos,startLoc);return this.exprAllowed=!1,this.next(),node.expression=base,this.finishNode(node,"TSNonNullExpression")}if(maybeAsyncArrow&&this.$1()){let arrow=this.$g(()=>this.$2k(startPos,startLoc,forInit));if(arrow)return arrow}let optional=this.type===tt.questionDot&&this.$2()===CHAR_LT;if(this.$1()||optional||this.type===tt.bitShift&&this.value==="<<"){let typeArguments=this.$g(()=>{if(optional)this.next();this.$p();let args=this.$e();if(this.type===tt.parenL&&!noCalls)return args;if(this.type===tt.backQuote)return optional?void 0:args;if(optional)return;if(this.$c()||this.type===tt.bitShift||this.type.startsExpr&&this.type!==tt.parenL&&!this.hasPrecedingLineBreak())return;return args});if(typeArguments){let node=this.startNodeAt(startPos,startLoc);if(this.type===tt.parenL&&!noCalls){if(this.next(),node.callee=base,node.arguments=this.parseExprList(tt.parenR,!0,!1),node.typeArguments=typeArguments,optional)base.optional=!0;if(optional||optionalChained)node.optional=optional;return this.finishNode(node,"CallExpression")}if(this.type===tt.backQuote)return node.tag=base,node.quasi=this.parseTemplate({isTagged:!0}),node.typeArguments=typeArguments,this.finishNode(node,"TaggedTemplateExpression");return node.expression=base,node.typeArguments=typeArguments,this.finishNode(node,"TSInstantiationExpression")}}if(maybeAsyncArrow&&this.type===tt.parenL)this.$m=!0;return super.parseSubscript(base,startPos,startLoc,noCalls,maybeAsyncArrow,optionalChained,forInit)}$2k(startPos,startLoc,forInit){let node=this.startNodeAt(startPos,startLoc);if(node.typeParameters=this.$8(),this.expect(tt.parenL),node.params=this.parseBindingList(tt.parenR,!1,!0),this.type===tt.colon)node.returnType=this.$6(!0);if(this.type!==tt.arrow||this.canInsertSemicolon())return;return this.next(),this.parseArrowExpression(node,node.params,!0,forInit)}parseDynamicImport(node){if(this.next(),node.source=this.parseMaybeAssign(),this.eat(tt.comma)&&this.type!==tt.parenR)node.arguments=[this.parseExpression()];return this.expect(tt.parenR),this.finishNode(node,"ImportExpression")}parseNew(){let node=super.parseNew();if(node.callee?.type!=="TSInstantiationExpression")return node;let result=this.startNodeAt(node.start,node.loc?.start);return result.callee=node.callee.expression,result.typeArguments=node.callee.typeArguments,result.arguments=node.arguments,this.finishNodeAt(result,"NewExpression",node.end,node.loc?.end)}parseExprOp(left,leftStartPos,leftStartLoc,minPrec,forInit){if(tt._in.binop>minPrec&&this.type===tt.name&&(this.value==="as"||this.value==="satisfies")&&!this.containsEsc&&!this.hasPrecedingLineBreak()){let isSatisfies=this.value==="satisfies",node=this.startNodeAt(leftStartPos,leftStartLoc);return node.expression=left,node.typeAnnotation=this.$a(()=>{if(this.next(),!isSatisfies&&this.type===tt._const){let reference=this.startNode();return reference.typeName=this.parseIdent(!0),this.finishNode(reference,"TSTypeReference")}return this.$0()}),this.finishNode(node,isSatisfies?"TSSatisfiesExpression":"TSAsExpression"),this.parseExprOp(node,leftStartPos,leftStartLoc,minPrec,forInit)}return super.parseExprOp(left,leftStartPos,leftStartLoc,minPrec,forInit)}parseGetterSetter(prop){prop.kind=prop.key.name,super.parseGetterSetter(prop)}parsePropertyValue(prop,isPattern,isGenerator,isAsync,startPos,startLoc,refDestructuringErrors,containsEsc){if(!isPattern&&this.$1()){if(this.$k=this.$8(),this.type!==tt.parenL)this.unexpected();prop.kind="init"}return super.parsePropertyValue(prop,isPattern,isGenerator,isAsync,startPos,startLoc,refDestructuringErrors,containsEsc)}}return TSParser});
|
|
2
2
|
export{tsPlugin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{setSource}from"./shared-m0dcdh24.js";import{parseStatementsAt}from"./shared-
|
|
1
|
+
import{setSource}from"./shared-m0dcdh24.js";import{parseStatementsAt}from"./shared-w3mxqtgj.js";import{scan}from"./shared-e4gbs4rb.js";function parseImportsExportsWith(source,options,typescript){setSource(source);let context={isTypeScript:options.typescript??!1,typescript,loc:!1,comments:!1,root:{comments:[]}};return parseStatementsAt(context,source,(parseAt)=>scan(source,options.localExports??!0,parseAt))}
|
|
2
2
|
export{parseImportsExportsWith};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{parseComponent}from"./shared-
|
|
1
|
+
import{parseComponent}from"./shared-qqrqzz29.js";import{htmlEntityNames}from"./shared-drb44hb9.js";import{TypeScriptParser}from"./shared-dscc5xg8.js";var support={typescript:TypeScriptParser,entityNames:htmlEntityNames};function parse2(source,options){return parseComponent(source,options,support)}
|
|
2
2
|
export{parse2};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{closingTagOmitted}from"./shared-dgdrqgdn.js";import{setSource,locate3,position,mapChildren,assertType}from"./shared-m0dcdh24.js";import{isIdentifierStart,isIdentifierChar}from"./shared-2pngd0mg.js";import{ParseError2,attribute_duplicate,attribute_empty_shorthand,block_duplicate_clause,block_invalid_continuation_placement,block_invalid_elseif,block_invalid_placement,block_unclosed,block_unexpected_close,const_tag_invalid_expression,css_empty_declaration,css_expected_identifier,css_selector_invalid,debug_tag_invalid_arguments,declaration_tag_invalid_type,directive_invalid_value,directive_missing_name,element_invalid_closing_tag,element_invalid_closing_tag_autoclosed,element_unclosed,expected_attribute_value,expected_block_type,expected_identifier,expected_pattern,expected_tag,expected_token,expected_whitespace,render_tag_invalid_expression,script_duplicate,script_invalid_attribute_value,script_invalid_context,script_reserved_attribute,style_duplicate,svelte_component_invalid_this,svelte_component_missing_this,svelte_element_missing_this,svelte_meta_duplicate,svelte_meta_invalid_content,svelte_meta_invalid_placement,svelte_meta_invalid_tag,svelte_options_deprecated_tag,svelte_options_invalid_attribute,svelte_options_invalid_attribute_value,svelte_options_invalid_customelement,svelte_options_invalid_customelement_props,svelte_options_invalid_customelement_shadow,svelte_options_invalid_tagname,svelte_options_reserved_tagname,svelte_options_unknown_attribute,tag_invalid_name,tag_invalid_placement,unexpected_eof,unexpected_reserved_word,unterminated_string_constant,void_element_invalid_content,RESERVED_WORDS,parseProgram,parseExpressionAt,parsePatternAt,parseStatementAt}from"./shared-nan648gn.js";import{withoutByteOrderMark,isDigit,isWhitespace,skipWhitespace,isTypeScript,closingScriptTag,closingScriptTagEnd,isVoid,styleContentEnd,isQuote,nameEnd,endsUnquotedValue}from"./shared-5tpb3h6x.js";import{decodeCharacterReferences}from"./shared-bzqbnvee.js";import{missingTypeScript}from"./shared-h6z1kjbb.js";var REGEX_NON_LF_LINE_BREAK=/\r(?!\n)|[\u2028\u2029]/,REGEX_WHITESPACE_THEN_CLOSING_BRACE=/\s*}/y;function scanIdentifier(source,from){let code=source.codePointAt(from);if(code===void 0||!isIdentifierStart(code,!0))return from;let end=from+(code<=65535?1:2),next=source.codePointAt(end);while(next!==void 0&&isIdentifierChar(next,!0))end+=next<=65535?1:2,next=source.codePointAt(end);return end}class TemplateParserState{source;index=0;loc;lfOnly;isTypeScript;typescript;entityNames;css;script;comments;root;stack;fragments;metaTags=new Set;lastAutoClosedTag;nextAngle=-1;nextBrace=-1;constructor(source,originalLength,support,options={}){if(this.source=source,this.loc=options.loc??!1,this.lfOnly=this.loc&&!REGEX_NON_LF_LINE_BREAK.test(source),this.isTypeScript=isTypeScript(source),this.typescript=support.typescript,this.isTypeScript&&!this.typescript)missingTypeScript();this.entityNames=support.entityNames,this.css=options.css??!0,this.script=options.script??!0,this.comments=options.comments??!0,this.root={type:"Root",start:0,end:originalLength,css:null,js:[],options:null,fragment:{type:"Fragment",nodes:[]},comments:[]},this.stack=[this.root],this.fragments=[this.root.fragment]}match(str){if(str.length===1)return this.source.charCodeAt(this.index)===str.charCodeAt(0);return this.source.startsWith(str,this.index)}matchRegex(pattern){return pattern.lastIndex=this.index,pattern.exec(this.source)?.[0]??null}eat(str,required=!1){if(this.match(str))return this.index+=str.length,!0;if(required)expected_token(this.index,str);return!1}read(pattern){let result=this.matchRegex(pattern);if(result)this.index+=result.length;return result}readUntil(needle){if(this.index>=this.source.length)unexpected_eof(this.source.length);let found=this.source.indexOf(needle,this.index),end=found===-1?this.source.length:found,result=this.source.slice(this.index,end);return this.index=end,result}allowWhitespace(){this.index=skipWhitespace(this.source,this.index)}requireWhitespace(){if(!isWhitespace(this.source.charCodeAt(this.index)))expected_whitespace(this.index);this.allowWhitespace()}eatClosingBrace(){this.allowWhitespace(),this.eat("}",!0)}sourceLocation(start,end){return this.loc?{start:locate3(start),end:locate3(end)}:void 0}readIdentifierName(){let start=this.index,end=scanIdentifier(this.source,start),name=this.source.slice(start,end);if(this.index=end,RESERVED_WORDS.has(name))unexpected_reserved_word(start,name);let identifier={type:"Identifier",name,start,end};if(this.loc)identifier.loc=this.sourceLocation(start,end);return identifier}current(){return this.stack[this.stack.length-1]}append(node){this.fragments[this.fragments.length-1].nodes.push(node)}open(node,fragment){this.append(node),this.stack.push(node),this.fragments.push(fragment)}setFragment(fragment){this.fragments[this.fragments.length-1]=fragment}close(){this.stack.pop(),this.fragments.pop()}}var PRECEDENCE={"||":1,"??":1,"&&":2,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"+":9,"-":9,"*":10,"/":10,"%":10};function literal(source,start,end,value){return{type:"Literal",start,end,value,raw:source.slice(start,end)}}function scanLiteral(source,from){let first=source.charCodeAt(from);if(first===34||first===39){for(let end=from+1;end<source.length;end++){let code=source.charCodeAt(end);if(code===first)return literal(source,from,end+1,source.slice(from+1,end));if(code===92||code===10||code===13)return null}return null}let end=from;for(;end<source.length;end++){let code=source.charCodeAt(end);if(code<48||code>57)break}if(end===from||first===48&&end-from>1)return null;return literal(source,from,end,Number(source.slice(from,end)))}function scanAtom(source,from,typescript){let identifierEnd=scanIdentifier(source,from);if(identifierEnd===from)return scanLiteral(source,from);let name=source.slice(from,identifierEnd);if(name==="true"||name==="false"||name==="null")return literal(source,from,identifierEnd,name==="null"?null:name==="true");if(RESERVED_WORDS.has(name))return null;let node={type:"Identifier",start:from,end:identifierEnd,name};for(let index=identifierEnd;;){let next=source.charCodeAt(index);if(next===40){let call=scanArguments(source,index+1,typescript);if(!call)return null;node={type:"CallExpression",start:from,end:call.end,callee:node,arguments:call.arguments,optional:!1},index=call.end;continue}let property,end;if(next===46){if(end=scanIdentifier(source,index+1),end===index+1)return null;property={type:"Identifier",start:index+1,end,name:source.slice(index+1,end)}}else if(next===91){if(property=scanLiteral(source,index+1),!property||source.charCodeAt(property.end)!==93)return null;end=property.end+1}else return node;node={type:"MemberExpression",start:from,end,object:node,property,computed:next===91,optional:!1},index=end}}function scanArguments(source,from,typescript){let args=[],index=skipWhitespace(source,from);if(source.charCodeAt(index)===41)return{arguments:args,end:index+1};for(;;){let argument=scanConditional(source,index,typescript);if(!argument)return null;args.push(argument),index=skipWhitespace(source,argument.end);let code=source.charCodeAt(index);if(code===41)return{arguments:args,end:index+1};if(code!==44)return null;if(index=skipWhitespace(source,index+1),source.charCodeAt(index)===41)return null}}function scanUnary(source,from,typescript){let code=source.charCodeAt(from),next=source.charCodeAt(from+1);if(!(code===33&&next!==61)&&!(code===45&&next!==45&&next!==61))return scanAtom(source,from,typescript);let argument=scanUnary(source,skipWhitespace(source,from+1),typescript);if(!argument)return null;return{type:"UnaryExpression",start:from,end:argument.end,operator:code===33?"!":"-",prefix:!0,argument}}function operatorAt(source,index,typescript){let code=source.charCodeAt(index),next=source.charCodeAt(index+1);switch(code){case 124:return next===124&&source.charCodeAt(index+2)!==61?"||":null;case 38:return next===38&&source.charCodeAt(index+2)!==61?"&&":null;case 63:return next===63&&source.charCodeAt(index+2)!==61?"??":null;case 61:if(next!==61)return null;return source.charCodeAt(index+2)===61?"===":"==";case 33:if(next!==61)return null;return source.charCodeAt(index+2)===61?"!==":"!=";case 60:case 62:if(typescript||next===code)return null;if(next===61)return code===60?"<=":">=";return code===60?"<":">";case 43:return next===43||next===61?null:"+";case 45:return next===45||next===61?null:"-";case 42:return next===42||next===61?null:"*";case 47:return next===47||next===42||next===61?null:"/";case 37:return next===61?null:"%";default:return null}}function scanBinary(source,left,minPrecedence,typescript){if(isClosing(source.charCodeAt(left.end)))return left;let index=skipWhitespace(source,left.end),operator=operatorAt(source,index,typescript);if(operator===null)return left;let precedence=PRECEDENCE[operator];if(precedence<=minPrecedence)return left;let operand=scanUnary(source,skipWhitespace(source,index+operator.length),typescript);if(!operand)return null;let right=scanBinary(source,operand,operator==="??"?2:precedence,typescript);if(!right)return null;let node;if(operator==="||"||operator==="&&"||operator==="??"){let after=operatorAt(source,skipWhitespace(source,right.end),typescript);if(operator==="??"?after==="||"||after==="&&":after==="??")return null;node={type:"LogicalExpression",start:left.start,end:right.end,left,operator,right}}else node={type:"BinaryExpression",start:left.start,end:right.end,left,operator,right};return scanBinary(source,node,minPrecedence,typescript)}function scanConditional(source,from,typescript){let operand=scanUnary(source,from,typescript);if(!operand)return null;let test=scanBinary(source,operand,-1,typescript);if(!test||isClosing(source.charCodeAt(test.end)))return test;let question=skipWhitespace(source,test.end);if(source.charCodeAt(question)!==63)return test;let next=source.charCodeAt(question+1);if(next===46||next===63)return null;let consequent=scanConditional(source,skipWhitespace(source,question+1),typescript);if(!consequent)return null;let colon=skipWhitespace(source,consequent.end);if(source.charCodeAt(colon)!==58)return null;let alternate=scanConditional(source,skipWhitespace(source,colon+1),typescript);if(!alternate)return null;return{type:"ConditionalExpression",start:test.start,end:alternate.end,test,consequent,alternate}}function isClosing(code){return code===125||code===41||code===44||code===58}function atTerminator(source,from){let code=source.charCodeAt(skipWhitespace(source,from));return code===125||code===41}function scanTrivialExpression(source,from,typescript){let node=scanConditional(source,from,typescript);return node&&atTerminator(source,node.end)?node:null}function addLocations(node){switch(node.loc={start:position(node.start),end:position(node.end)},node.type){case"MemberExpression":addLocations(node.object),addLocations(node.property);break;case"CallExpression":addLocations(node.callee);for(let argument of node.arguments)addLocations(argument);break;case"UnaryExpression":addLocations(node.argument);break;case"BinaryExpression":case"LogicalExpression":addLocations(node.left),addLocations(node.right);break;case"ConditionalExpression":addLocations(node.test),addLocations(node.consequent),addLocations(node.alternate);break}}function readExpression(state){let trivial=!state.loc||state.lfOnly?scanTrivialExpression(state.source,state.index,state.isTypeScript):null;if(trivial){if(state.index=trivial.end,state.loc)addLocations(trivial);return trivial}let{node,end}=parseExpressionAt(state,state.source,state.index);return state.index=end,node}var RESERVED_ATTRIBUTES=new Set(["server","client","worker","test","default"]);function readScript(state,start,attributes){let{source,index:scriptStart}=state;if(scriptStart>=source.length)unexpected_eof(source.length);let close=closingScriptTag(source,scriptStart);if(close===-1)element_unclosed(source.length,"script");state.index=closingScriptTagEnd(source,close);let program=state.script?parseProgram(state,source.slice(0,close),scriptStart):{type:"Program",start:scriptStart,end:close,body:[],sourceType:"module"};if(program.start=scriptStart,program.loc)Object.assign(program.loc.start,position(start)),Object.assign(program.loc.end,position(state.index));else if(state.loc)program.loc={start:position(start),end:position(state.index)};let context="default";for(let attribute of attributes){if(RESERVED_ATTRIBUTES.has(attribute.name))script_reserved_attribute(attribute,attribute.name);if(attribute.name==="module"){if(attribute.value!==!0)script_invalid_attribute_value(attribute,attribute.name);context="module"}if(attribute.name==="context"){let value=attribute.value;if(!Array.isArray(value)||value.length!==1||value[0].type!=="Text"||value[0].data!=="module")script_invalid_context(attribute);context="module"}}return{type:"Script",start,end:state.index,context,content:program,attributes}}var REGEX_NTH_OF=/(even|odd|\+?(\d+|\d*n(\s*[+-]\s*\d+)?)|-\d*n(\s*\+\s*\d+))((?=\s*[,)])|\s+of(\s+|(?=[.#[*:&])))/y,REGEX_PERCENTAGE=/\d+(\.\d+)?%/y,REGEX_UNICODE_SEQUENCE=/\\[0-9a-fA-F]{1,6}(\r\n|\s)?/y,REGEX_CLOSING_STYLE_TAG_END=/\s*>/y,NONE=-1,DOUBLE_QUOTE=34,HASH=35,DOLLAR=36,AMPERSAND=38,SINGLE_QUOTE=39,OPEN_PAREN=40,CLOSE_PAREN=41,ASTERISK=42,PLUS=43,HYPHEN=45,DOT=46,SLASH=47,COLON=58,SEMICOLON=59,LESS_THAN=60,EQUALS=61,GREATER_THAN=62,OPEN_BRACKET=91,BACKSLASH=92,CLOSE_BRACKET=93,CARET=94,OPEN_BRACE=123,PIPE=124,CLOSE_BRACE=125,TILDE=126,comments=[];function readStyle(state,start,attributes){let contentStart=state.index;comments=[];let children=state.css?readBody(state):skipBody(state),contentEnd=state.index;return state.eat("</style",!0),state.read(REGEX_CLOSING_STYLE_TAG_END),{type:"StyleSheet",start,end:state.index,attributes,children,comments,content:{start:contentStart,end:contentEnd,styles:state.source.slice(contentStart,contentEnd),comment:null}}}function skipBody(state){return state.index=styleContentEnd(state.source,state.index),[]}function readBody(state){let children=[];for(;;){if(allowCommentOrWhitespace(state,!0),state.match("</style")||state.index>=state.source.length)break;children.push(state.match("@")?readAtRule(state):readRule(state))}return children}function readAtRule(state){let start=state.index;state.eat("@",!0);let name=readIdentifier(state),prelude=readValue(state,!0),block=null;if(state.match("{"))block=readBlock(state);else state.eat(";",!0);return{type:"Atrule",start,end:state.index,name,prelude,block}}function readRule(state){let start=state.index;return{type:"Rule",prelude:readSelectorList(state,!1),block:readBlock(state),start,end:state.index}}function readSelectorList(state,insidePseudoClass){let children=[];allowCommentOrWhitespace(state,!0);let start=state.index;while(state.index<state.source.length){children.push(readSelector(state,insidePseudoClass));let end=state.index;if(allowCommentOrWhitespace(state,!0),state.match(insidePseudoClass?")":"{"))return{type:"SelectorList",start,end,children};state.eat(",",!0),allowCommentOrWhitespace(state,!0)}return unexpected_eof(state.source.length)}function createRelativeSelector(combinator,start){return{type:"RelativeSelector",combinator,selectors:[],start,end:-1}}function readSelector(state,insidePseudoClass){let{source,index:listStart}=state,children=[],relativeSelector=createRelativeSelector(null,state.index);while(state.index<source.length){let start=state.index,code=source.charCodeAt(start),selectors=relativeSelector.selectors;if(code===AMPERSAND)state.index++,selectors.push({type:"NestingSelector",name:"&",start,end:state.index});else if(code===ASTERISK)state.index++,selectors.push(readTypeSelectorRest(state,start,"*"));else if(code===HASH)state.index++,selectors.push({type:"IdSelector",name:readIdentifier(state),start,end:state.index});else if(code===DOT)state.index++,selectors.push({type:"ClassSelector",name:readIdentifier(state),start,end:state.index});else if(code===COLON){let isElement=source.charCodeAt(start+1)===COLON;state.index+=isElement?2:1;let name=readIdentifier(state),args=null;if(state.eat("("))args=readSelectorList(state,!0),state.eat(")",!0);if(isElement)selectors.push({type:"PseudoElementSelector",name,start,end:state.index,...args&&{args}});else selectors.push({type:"PseudoClassSelector",name,args,start,end:state.index})}else if(code===OPEN_BRACKET)state.index++,selectors.push(readAttributeSelector(state,start));else{let nth=insidePseudoClass?state.read(REGEX_NTH_OF):null,percentage=!nth&&isDigit(code)?state.read(REGEX_PERCENTAGE):null;if(nth)selectors.push({type:"Nth",value:nth,start,end:state.index});else if(percentage)selectors.push({type:"Percentage",value:percentage,start,end:state.index});else if(combinatorLength(source,start)===0){let name=readIdentifier(state);selectors.push(readTypeSelectorRest(state,start,name))}}let index=state.index;allowCommentOrWhitespace(state,!1);let end=state.match(",")||state.match(insidePseudoClass?")":"{");if(state.index=index,end)return relativeSelector.end=index,children.push(relativeSelector),{type:"ComplexSelector",start:listStart,end:index,children};let combinator=readCombinator(state);if(combinator){if(relativeSelector.selectors.length>0)relativeSelector.end=index,children.push(relativeSelector);if(relativeSelector=createRelativeSelector(combinator,combinator.start),state.allowWhitespace(),state.match(",")||state.match(insidePseudoClass?")":"{"))css_selector_invalid(state.index)}}return unexpected_eof(source.length)}function readTypeSelectorRest(state,start,first){let name=first,namespace;if(state.eat("|"))namespace=name,name=state.eat("*")?"*":readIdentifier(state);return{type:"TypeSelector",name,...namespace!==void 0&&{namespace},start,end:state.index}}function readAttributeSelector(state,start){let source=state.source;state.allowWhitespace();let name=readIdentifier(state);state.allowWhitespace();let value=null,matcher=null,code=source.charCodeAt(state.index);if(code===EQUALS)matcher="=";else if((code===TILDE||code===CARET||code===DOLLAR||code===ASTERISK||code===PIPE)&&source.charCodeAt(state.index+1)===EQUALS)matcher=source.slice(state.index,state.index+2);if(matcher)state.index+=matcher.length,state.allowWhitespace(),value=readAttributeValue(state);state.allowWhitespace();let flagsStart=state.index;while(isAsciiLetter(source.charCodeAt(state.index)))state.index++;let flags=state.index>flagsStart?source.slice(flagsStart,state.index):null;return state.allowWhitespace(),state.eat("]",!0),{type:"AttributeSelector",start,end:state.index,name,matcher,value,flags}}function combinatorLength(source,index){let code=source.charCodeAt(index);if(code===PLUS||code===TILDE||code===GREATER_THAN)return 1;if(code===PIPE&&source.charCodeAt(index+1)===PIPE)return 2;return 0}function readCombinator(state){let start=state.index;state.allowWhitespace();let index=state.index,length=combinatorLength(state.source,index);if(length>0){state.index+=length;let end=state.index;return state.allowWhitespace(),{type:"Combinator",name:state.source.slice(index,end),start:index,end}}if(state.index!==start)return{type:"Combinator",name:" ",start,end:state.index};return null}function readBlock(state){let start=state.index;state.eat("{",!0);let children=[];while(state.index<state.source.length){if(allowCommentOrWhitespace(state,!0),state.match("}"))break;children.push(readBlockItem(state))}return state.eat("}",!0),{type:"Block",start,end:state.index,children}}function readBlockItem(state){if(state.match("@"))return readAtRule(state);let start=state.index;readValue(state,!1);let code=state.source.charCodeAt(state.index);return state.index=start,code===OPEN_BRACE?readRule(state):readDeclaration(state)}function readDeclaration(state){let{source,index:start}=state;if(start>=source.length)unexpected_eof(source.length);let propertyEnd=start;while(propertyEnd<source.length){let code=source.charCodeAt(propertyEnd);if(code===COLON||isWhitespace(code))break;propertyEnd++}let property=source.slice(start,propertyEnd);state.index=propertyEnd,state.allowWhitespace(),state.eat(":");let index=state.index;state.allowWhitespace();let value=readValue(state,!0);if(!value&&!property.startsWith("--"))css_empty_declaration({start,end:index});let end=state.index;if(!state.match("}"))state.eat(";",!0);return{type:"Declaration",start,end,property,value}}function readValue(state,capture){let source=state.source,length=source.length,value="",segmentStart=state.index,valueComments=null,escaped=!1,inUrl=!1,quoteMark=NONE,i=state.index;while(i<length){let code=source.charCodeAt(i);if(escaped){escaped=!1,i++;continue}if(code===BACKSLASH){escaped=!0,i++;continue}if(code===quoteMark)quoteMark=NONE;else if(code===CLOSE_PAREN)inUrl=!1;else if(quoteMark===NONE&&(code===DOUBLE_QUOTE||code===SINGLE_QUOTE))quoteMark=code;else if(code===OPEN_PAREN){if(endsWithUrl(source,value,segmentStart,i))inUrl=!0}else if((code===SEMICOLON||code===OPEN_BRACE||code===CLOSE_BRACE)&&!inUrl&"eMark===NONE){if(state.index=i,!capture)return"";if(value+=source.slice(segmentStart,i),valueComments){let leadingWhitespace=value.length-value.trimStart().length;for(let comment of valueComments)comment.position=Math.max(0,(comment.position??0)-leadingWhitespace)}return value.trim()}else if(code===SLASH&&!inUrl&"eMark===NONE&&source.charCodeAt(i+1)===ASTERISK){value+=source.slice(segmentStart,i),state.index=i;let comment=readComment(state);if(capture)comment.position=value.length,comments.push(comment),valueComments??=[],valueComments.push(comment);i=state.index,segmentStart=i;continue}i++}return state.index=length,unexpected_eof(length)}function endsWithUrl(source,value,segmentStart,end){if(end-segmentStart>=3)return source.charCodeAt(end-3)===117&&source.charCodeAt(end-2)===114&&source.charCodeAt(end-1)===108;return(value+source.slice(segmentStart,end)).endsWith("url")}function readAttributeValue(state){let source=state.source,quoteMark=NONE;if(state.eat('"'))quoteMark=DOUBLE_QUOTE;else if(state.eat("'"))quoteMark=SINGLE_QUOTE;let start=state.index,escaped=!1,i=start;while(i<source.length){let code=source.charCodeAt(i);if(escaped)escaped=!1;else if(code===BACKSLASH)escaped=!0;else if(quoteMark===NONE?code===CLOSE_BRACKET||isWhitespace(code):code===quoteMark)return state.index=quoteMark===NONE?i:i+1,source.slice(start,i).trim();i++}return state.index=i,unexpected_eof(source.length)}function readIdentifier(state){let{source,index:start}=state,first=source.charCodeAt(start);if(isDigit(first)||first===HYPHEN&&isDigit(source.charCodeAt(start+1)))css_expected_identifier(start);let identifier="",runStart=start,i=start;while(i<source.length){let code=source.charCodeAt(i);if(code===BACKSLASH){identifier+=source.slice(runStart,i),state.index=i;let sequence=state.matchRegex(REGEX_UNICODE_SEQUENCE);if(sequence){let character=String.fromCodePoint(Number.parseInt(sequence.slice(1),16));identifier+=character==="\\"?"\\\\":character,i+=sequence.length}else identifier+=`\\${source[i+1]}`,i+=2;runStart=i}else if(code>=160||isIdentifierChar2(code))i++;else break}if(identifier+=source.slice(runStart,i),state.index=i,identifier==="")css_expected_identifier(start);return identifier}function allowCommentOrWhitespace(state,capture){let source=state.source;state.allowWhitespace();for(;;){let code=source.charCodeAt(state.index);if(code===SLASH&&source.charCodeAt(state.index+1)===ASTERISK){let comment=readComment(state);if(capture)comments.push(comment)}else if(code===LESS_THAN&&state.eat("<!--"))state.readUntil("-->"),state.eat("-->",!0);else break;state.allowWhitespace()}}function readComment(state){let start=state.index;state.eat("/*",!0);let value=state.readUntil("*/");return state.eat("*/",!0),{type:"CSSComment",value,start,end:state.index}}function isAsciiLetter(code){return code>=65&&code<=90||code>=97&&code<=122}function isIdentifierChar2(code){return isAsciiLetter(code)||isDigit(code)||code===95||code===45}var REGEX_CLOSING_TEXTAREA=/<\/textarea(\s[^>]*)?>/iy,REGEX_DOCTYPE_NAME=/^![a-zA-Z]+$/,REGEX_NAMESPACED_NAME=/^[a-zA-Z][a-zA-Z0-9]*:[a-zA-Z][a-zA-Z0-9-]*[a-zA-Z0-9]$/,REGEX_CUSTOM_ELEMENT_NAME=/^[a-zA-Z][a-zA-Z0-9]*(-[a-zA-Z0-9.\-_\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}]*)?$/u,ID_JOINERS="\\u200C\\u200D",REGEX_COMPONENT_NAME=new RegExp(`^(?:\\p{Lu}[$${ID_JOINERS}\\p{ID_Continue}.]*|\\p{ID_Start}[$${ID_JOINERS}\\p{ID_Continue}]*(?:\\.[$${ID_JOINERS}\\p{ID_Continue}]+)+)$`,"u"),DIRECTIVES=new Map([["use","UseDirective"],["animate","AnimateDirective"],["bind","BindDirective"],["class","ClassDirective"],["style","StyleDirective"],["on","OnDirective"],["let","LetDirective"],["in","TransitionDirective"],["out","TransitionDirective"],["transition","TransitionDirective"]]),META_TAGS=new Map([["svelte:head",["SvelteHead",!0]],["svelte:options",["SvelteOptions",!0]],["svelte:window",["SvelteWindow",!0]],["svelte:document",["SvelteDocument",!0]],["svelte:body",["SvelteBody",!0]],["svelte:element",["SvelteElement",!1]],["svelte:component",["SvelteComponent",!1]],["svelte:self",["SvelteSelf",!1]],["svelte:fragment",["SvelteFragment",!1]],["svelte:boundary",["SvelteBoundary",!1]]]),META_TAG_NAMES=[...META_TAGS.keys()],META_TAG_LIST=`${META_TAG_NAMES.slice(0,-1).join(", ")} or ${META_TAG_NAMES.at(-1)}`,GT=62,BRACE=123;function readName(state,isAttribute){let start=state.index;if(start>=state.source.length)unexpected_eof(state.source.length);let end=nameEnd(state.source,start,isAttribute);return state.index=end,{name:state.source.slice(start,end),start,end,loc:state.sourceLocation(start,end)}}var text=(start,end,raw,data=raw)=>({start,end,type:"Text",raw,data});function isComponentName(name){let first=name.charCodeAt(0);if(first>=97&&first<=122&&!name.includes("."))return!1;return REGEX_COMPONENT_NAME.test(name)}function isElementName(name){let simple=!0;for(let i=0;i<name.length&&simple;i++){let code=name.charCodeAt(i);simple=code>=97&&code<=122||i>0&&code>=48&&code<=57}return simple&&name.length>0||REGEX_DOCTYPE_NAME.test(name)||REGEX_NAMESPACED_NAME.test(name)||REGEX_CUSTOM_ELEMENT_NAME.test(name)}function hasAncestor(stack,matches){for(let i=stack.length-1;i>=0;i--){let found=matches(stack[i]);if(found!==void 0)return found}return!1}function elementType(state,name,isComponent){let meta=META_TAGS.get(name);if(meta)return meta[0];if(isComponent)return"Component";if(name==="title"){if(hasAncestor(state.stack,({type})=>{if(type==="SvelteHead")return!0;return type==="RegularElement"||type==="Component"?!1:void 0}))return"TitleElement"}if(name==="slot"){if(!hasAncestor(state.stack,(node)=>node.type==="RegularElement"&&node.attributes.some((a)=>a.type==="Attribute"&&a.name==="shadowrootmode")?!0:void 0))return"SlotElement"}return"RegularElement"}function readElement(state){let start=state.index++;if(state.eat("!--")){let data=state.readUntil("-->");state.eat("-->",!0),state.append({type:"Comment",start,end:state.index,data})}else if(state.eat("/"))closeElement(state,start);else openElement(state,start)}function closeElement(state,start){let{name}=readName(state,!1);if(state.allowWhitespace(),state.eat(">",!0),isVoid(name))void_element_invalid_content(start);let open=state.current();while(!("name"in open)||open.name!==name){if(open.type!=="RegularElement"){let autoClosed=state.lastAutoClosedTag;if(autoClosed?.tag===name)element_invalid_closing_tag_autoclosed(start,name,autoClosed.reason);element_invalid_closing_tag(start,name)}open.end=start,state.close(),open=state.current()}if(open.end=state.index,state.close(),state.stack.length<(state.lastAutoClosedTag?.depth??0))state.lastAutoClosedTag=void 0}function createElement(type,start,name){return{type,start,end:-1,name}}function openElement(state,start){let tag=readName(state,!1),{name}=tag,meta=META_TAGS.get(name);if(!meta&&name.startsWith("svelte:"))svelte_meta_invalid_tag(tag,META_TAG_LIST);let isComponent=isComponentName(name);if(!isComponent&&!isElementName(name))tag_invalid_name(tag);if(meta?.[1]){if(state.metaTags.has(name))svelte_meta_duplicate(start,name);if(state.current().type!=="Root")svelte_meta_invalid_placement(start,name);state.metaTags.add(name)}let element=createElement(elementType(state,name,isComponent),start,name);if(state.loc)element.name_loc=tag.loc;element.attributes=[],element.fragment={type:"Fragment",nodes:[]},state.allowWhitespace();let parent=state.current();if(parent.type==="RegularElement"&&closingTagOmitted(parent.name,name))parent.end=start,state.close(),state.lastAutoClosedTag={tag:parent.name,reason:name,depth:state.stack.length};if((name==="script"||name==="style")&&state.current().type==="Root"){let attributes=[];element.attributes=attributes,readAttributes(state,attributes,readStaticAttribute),readTopLevelBlock(state,element,start,attributes);return}if(readAttributes(state,element.attributes,readAttribute),element.type==="SvelteComponent"){let definition=takeThis(element);if(!definition)svelte_component_missing_this(start);if(!isExpressionValue(definition.value))svelte_component_invalid_this(definition.start);element.expression=expressionOf(definition.value)}else if(element.type==="SvelteElement"){let definition=takeThis(element);if(!definition)svelte_element_missing_this(start);if(definition.value===!0)svelte_element_missing_this(definition);element.tag=isExpressionValue(definition.value)?expressionOf(definition.value):literalTag(definition.value[0])}if(!state.eat("/")&&!isVoid(name))if(state.eat(">",!0),name==="textarea")element.fragment.nodes=readSequence(state,(source,i)=>(REGEX_CLOSING_TEXTAREA.lastIndex=i,REGEX_CLOSING_TEXTAREA.test(source)),"inside <textarea>"),state.read(REGEX_CLOSING_TEXTAREA);else if(name==="script"||name==="style")element.fragment.nodes.push(readRawText(state,`</${name}>`));else{state.open(element,element.fragment);return}else state.eat(">",!0);element.end=state.index,state.append(element)}function readRawText(state,closer){let start=state.index,found=state.source.indexOf(closer,start);state.index=found===-1?state.source.length:found;let node=text(start,state.index,state.source.slice(start,state.index));return state.eat(closer,!0),node}function readTopLevelBlock(state,element,start,attributes){state.eat(">",!0);let comment=commentBefore(state.root.fragment.nodes,start);if(element.name==="style"){let css=readStyle(state,start,attributes);if(css.content.comment=comment,state.root.css)style_duplicate(start);state.root.css=css;return}let script=readScript(state,start,attributes);if(comment&&state.comments)script.content.leadingComments=[{type:"Line",value:comment.data}];let slot=script.context==="module"?"module":"instance";if(state.root[slot])script_duplicate(start);state.root[slot]=script}function commentBefore(nodes,start){let last=nodes.length-1;if(last<0||nodes[last].end!==start)return null;for(let i=last;i>=0;i--){let node=nodes[i];if(node.type==="Comment")return node;if(node.type!=="Text"||node.data.trim())return null}return null}var isThisAttribute=(node)=>node.type==="Attribute"&&node.name==="this";function takeThis(element){let found=element.attributes.find(isThisAttribute);if(found)element.attributes.splice(element.attributes.indexOf(found),1);return found}function isExpressionValue(value){if(value===!0)return!1;if(!Array.isArray(value))return!0;return value.length===1&&value[0].type==="ExpressionTag"}function expressionOf(value){return(Array.isArray(value)?value[0]:value).expression}function literalTag(chunk){if(chunk.type!=="Text")return chunk.expression;return{type:"Literal",value:chunk.data,raw:`'${chunk.raw}'`,start:chunk.start,end:chunk.end}}function readAttributes(state,into,read){let seen=new Set;for(;;){let parsed=read(state);if(!parsed)return;let{type}=parsed;if(type==="Attribute"||type==="BindDirective"||type==="StyleDirective"||type==="ClassDirective"){let key=`${type==="BindDirective"?"Attribute":type}${parsed.name}`;if(seen.has(key))attribute_duplicate(parsed);if(parsed.name!=="this")seen.add(key)}into.push(parsed),state.allowWhitespace()}}function createAttribute(state,name,start,end,value){return state.loc?{type:"Attribute",start,end,name:name.name,name_loc:name.loc,value}:{type:"Attribute",start,end,name:name.name,value}}function rejectQuote(state){if(isQuote(state.source.charCodeAt(state.index)))expected_token(state.index,"=")}function readStaticAttribute(state){let start=state.index,name=readName(state,!0);if(!name.name)return null;let value=!0;if(state.eat("=")){state.allowWhitespace();let{source}=state,at=state.index,quoted=isQuote(source.charCodeAt(at)),end=-1;if(quoted){let close=source.indexOf(source[at],at+1);if(close!==-1)end=close+1}if(end===-1){end=at;while(end<source.length&&source.charCodeAt(end)!==GT&&!isWhitespace(source.charCodeAt(end)))end++;if(end===at)expected_attribute_value(at)}state.index=end;let quotes=quoted?1:0,raw=source.slice(at+quotes,end-quotes);value=[text(end-raw.length-quotes,end-quotes,raw,decodeCharacterReferences(raw,!0,state.entityNames))]}return rejectQuote(state),createAttribute(state,name,start,state.index,value)}function readJsComment(state){let start=state.index,block=state.match("/*");if(!block&&!state.match("//"))return!1;state.index+=2;let value=state.readUntil(block?"*/":`
|
|
1
|
+
import{closingTagOmitted}from"./shared-dgdrqgdn.js";import{setSource,locate3,position,mapChildren,assertType}from"./shared-m0dcdh24.js";import{isIdentifierStart,isIdentifierChar}from"./shared-s46wfvhw.js";import{ParseError2,attribute_duplicate,attribute_empty_shorthand,block_duplicate_clause,block_invalid_continuation_placement,block_invalid_elseif,block_invalid_placement,block_unclosed,block_unexpected_close,const_tag_invalid_expression,css_empty_declaration,css_expected_identifier,css_selector_invalid,debug_tag_invalid_arguments,declaration_tag_invalid_type,directive_invalid_value,directive_missing_name,element_invalid_closing_tag,element_invalid_closing_tag_autoclosed,element_unclosed,expected_attribute_value,expected_block_type,expected_identifier,expected_pattern,expected_tag,expected_token,expected_whitespace,render_tag_invalid_expression,script_duplicate,script_invalid_attribute_value,script_invalid_context,script_reserved_attribute,style_duplicate,svelte_component_invalid_this,svelte_component_missing_this,svelte_element_missing_this,svelte_meta_duplicate,svelte_meta_invalid_content,svelte_meta_invalid_placement,svelte_meta_invalid_tag,svelte_options_deprecated_tag,svelte_options_invalid_attribute,svelte_options_invalid_attribute_value,svelte_options_invalid_customelement,svelte_options_invalid_customelement_props,svelte_options_invalid_customelement_shadow,svelte_options_invalid_tagname,svelte_options_reserved_tagname,svelte_options_unknown_attribute,tag_invalid_name,tag_invalid_placement,unexpected_eof,unexpected_reserved_word,unterminated_string_constant,void_element_invalid_content,RESERVED_WORDS,parseProgram,parseExpressionAt,parsePatternAt,parseStatementAt}from"./shared-w3mxqtgj.js";import{withoutByteOrderMark,isDigit,isWhitespace,skipWhitespace,isTypeScript,closingScriptTag,closingScriptTagEnd,isVoid,styleContentEnd,isQuote,nameEnd,endsUnquotedValue}from"./shared-5tpb3h6x.js";import{decodeCharacterReferences}from"./shared-bzqbnvee.js";import{missingTypeScript}from"./shared-h6z1kjbb.js";var REGEX_NON_LF_LINE_BREAK=/\r(?!\n)|[\u2028\u2029]/,REGEX_WHITESPACE_THEN_CLOSING_BRACE=/\s*}/y;function scanIdentifier(source,from){let code=source.codePointAt(from);if(code===void 0||!isIdentifierStart(code,!0))return from;let end=from+(code<=65535?1:2),next=source.codePointAt(end);while(next!==void 0&&isIdentifierChar(next,!0))end+=next<=65535?1:2,next=source.codePointAt(end);return end}class TemplateParserState{source;index=0;loc;lfOnly;isTypeScript;typescript;entityNames;css;script;comments;root;stack;fragments;metaTags=new Set;lastAutoClosedTag;nextAngle=-1;nextBrace=-1;constructor(source,originalLength,support,options={}){if(this.source=source,this.loc=options.loc??!1,this.lfOnly=this.loc&&!REGEX_NON_LF_LINE_BREAK.test(source),this.isTypeScript=isTypeScript(source),this.typescript=support.typescript,this.isTypeScript&&!this.typescript)missingTypeScript();this.entityNames=support.entityNames,this.css=options.css??!0,this.script=options.script??!0,this.comments=options.comments??!0,this.root={type:"Root",start:0,end:originalLength,css:null,js:[],options:null,fragment:{type:"Fragment",nodes:[]},comments:[]},this.stack=[this.root],this.fragments=[this.root.fragment]}match(str){if(str.length===1)return this.source.charCodeAt(this.index)===str.charCodeAt(0);return this.source.startsWith(str,this.index)}matchRegex(pattern){return pattern.lastIndex=this.index,pattern.exec(this.source)?.[0]??null}eat(str,required=!1){if(this.match(str))return this.index+=str.length,!0;if(required)expected_token(this.index,str);return!1}read(pattern){let result=this.matchRegex(pattern);if(result)this.index+=result.length;return result}readUntil(needle){if(this.index>=this.source.length)unexpected_eof(this.source.length);let found=this.source.indexOf(needle,this.index),end=found===-1?this.source.length:found,result=this.source.slice(this.index,end);return this.index=end,result}allowWhitespace(){this.index=skipWhitespace(this.source,this.index)}requireWhitespace(){if(!isWhitespace(this.source.charCodeAt(this.index)))expected_whitespace(this.index);this.allowWhitespace()}eatClosingBrace(){this.allowWhitespace(),this.eat("}",!0)}sourceLocation(start,end){return this.loc?{start:locate3(start),end:locate3(end)}:void 0}readIdentifierName(){let start=this.index,end=scanIdentifier(this.source,start),name=this.source.slice(start,end);if(this.index=end,RESERVED_WORDS.has(name))unexpected_reserved_word(start,name);let identifier={type:"Identifier",name,start,end};if(this.loc)identifier.loc=this.sourceLocation(start,end);return identifier}current(){return this.stack[this.stack.length-1]}append(node){this.fragments[this.fragments.length-1].nodes.push(node)}open(node,fragment){this.append(node),this.stack.push(node),this.fragments.push(fragment)}setFragment(fragment){this.fragments[this.fragments.length-1]=fragment}close(){this.stack.pop(),this.fragments.pop()}}var PRECEDENCE={"||":1,"??":1,"&&":2,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"+":9,"-":9,"*":10,"/":10,"%":10};function literal(source,start,end,value){return{type:"Literal",start,end,value,raw:source.slice(start,end)}}function scanLiteral(source,from){let first=source.charCodeAt(from);if(first===34||first===39){for(let end=from+1;end<source.length;end++){let code=source.charCodeAt(end);if(code===first)return literal(source,from,end+1,source.slice(from+1,end));if(code===92||code===10||code===13)return null}return null}let end=from;for(;end<source.length;end++){let code=source.charCodeAt(end);if(code<48||code>57)break}if(end===from||first===48&&end-from>1)return null;return literal(source,from,end,Number(source.slice(from,end)))}function scanAtom(source,from,typescript){let identifierEnd=scanIdentifier(source,from);if(identifierEnd===from)return scanLiteral(source,from);let name=source.slice(from,identifierEnd);if(name==="true"||name==="false"||name==="null")return literal(source,from,identifierEnd,name==="null"?null:name==="true");if(RESERVED_WORDS.has(name))return null;let node={type:"Identifier",start:from,end:identifierEnd,name};for(let index=identifierEnd;;){let next=source.charCodeAt(index);if(next===40){let call=scanArguments(source,index+1,typescript);if(!call)return null;node={type:"CallExpression",start:from,end:call.end,callee:node,arguments:call.arguments,optional:!1},index=call.end;continue}let property,end;if(next===46){if(end=scanIdentifier(source,index+1),end===index+1)return null;property={type:"Identifier",start:index+1,end,name:source.slice(index+1,end)}}else if(next===91){if(property=scanLiteral(source,index+1),!property||source.charCodeAt(property.end)!==93)return null;end=property.end+1}else return node;node={type:"MemberExpression",start:from,end,object:node,property,computed:next===91,optional:!1},index=end}}function scanArguments(source,from,typescript){let args=[],index=skipWhitespace(source,from);if(source.charCodeAt(index)===41)return{arguments:args,end:index+1};for(;;){let argument=scanConditional(source,index,typescript);if(!argument)return null;args.push(argument),index=skipWhitespace(source,argument.end);let code=source.charCodeAt(index);if(code===41)return{arguments:args,end:index+1};if(code!==44)return null;if(index=skipWhitespace(source,index+1),source.charCodeAt(index)===41)return null}}function scanUnary(source,from,typescript){let code=source.charCodeAt(from),next=source.charCodeAt(from+1);if(!(code===33&&next!==61)&&!(code===45&&next!==45&&next!==61))return scanAtom(source,from,typescript);let argument=scanUnary(source,skipWhitespace(source,from+1),typescript);if(!argument)return null;return{type:"UnaryExpression",start:from,end:argument.end,operator:code===33?"!":"-",prefix:!0,argument}}function operatorAt(source,index,typescript){let code=source.charCodeAt(index),next=source.charCodeAt(index+1);switch(code){case 124:return next===124&&source.charCodeAt(index+2)!==61?"||":null;case 38:return next===38&&source.charCodeAt(index+2)!==61?"&&":null;case 63:return next===63&&source.charCodeAt(index+2)!==61?"??":null;case 61:if(next!==61)return null;return source.charCodeAt(index+2)===61?"===":"==";case 33:if(next!==61)return null;return source.charCodeAt(index+2)===61?"!==":"!=";case 60:case 62:if(typescript||next===code)return null;if(next===61)return code===60?"<=":">=";return code===60?"<":">";case 43:return next===43||next===61?null:"+";case 45:return next===45||next===61?null:"-";case 42:return next===42||next===61?null:"*";case 47:return next===47||next===42||next===61?null:"/";case 37:return next===61?null:"%";default:return null}}function scanBinary(source,left,minPrecedence,typescript){if(isClosing(source.charCodeAt(left.end)))return left;let index=skipWhitespace(source,left.end),operator=operatorAt(source,index,typescript);if(operator===null)return left;let precedence=PRECEDENCE[operator];if(precedence<=minPrecedence)return left;let operand=scanUnary(source,skipWhitespace(source,index+operator.length),typescript);if(!operand)return null;let right=scanBinary(source,operand,operator==="??"?2:precedence,typescript);if(!right)return null;let node;if(operator==="||"||operator==="&&"||operator==="??"){let after=operatorAt(source,skipWhitespace(source,right.end),typescript);if(operator==="??"?after==="||"||after==="&&":after==="??")return null;node={type:"LogicalExpression",start:left.start,end:right.end,left,operator,right}}else node={type:"BinaryExpression",start:left.start,end:right.end,left,operator,right};return scanBinary(source,node,minPrecedence,typescript)}function scanConditional(source,from,typescript){let operand=scanUnary(source,from,typescript);if(!operand)return null;let test=scanBinary(source,operand,-1,typescript);if(!test||isClosing(source.charCodeAt(test.end)))return test;let question=skipWhitespace(source,test.end);if(source.charCodeAt(question)!==63)return test;let next=source.charCodeAt(question+1);if(next===46||next===63)return null;let consequent=scanConditional(source,skipWhitespace(source,question+1),typescript);if(!consequent)return null;let colon=skipWhitespace(source,consequent.end);if(source.charCodeAt(colon)!==58)return null;let alternate=scanConditional(source,skipWhitespace(source,colon+1),typescript);if(!alternate)return null;return{type:"ConditionalExpression",start:test.start,end:alternate.end,test,consequent,alternate}}function isClosing(code){return code===125||code===41||code===44||code===58}function atTerminator(source,from){let code=source.charCodeAt(skipWhitespace(source,from));return code===125||code===41}function scanTrivialExpression(source,from,typescript){let node=scanConditional(source,from,typescript);return node&&atTerminator(source,node.end)?node:null}function addLocations(node){switch(node.loc={start:position(node.start),end:position(node.end)},node.type){case"MemberExpression":addLocations(node.object),addLocations(node.property);break;case"CallExpression":addLocations(node.callee);for(let argument of node.arguments)addLocations(argument);break;case"UnaryExpression":addLocations(node.argument);break;case"BinaryExpression":case"LogicalExpression":addLocations(node.left),addLocations(node.right);break;case"ConditionalExpression":addLocations(node.test),addLocations(node.consequent),addLocations(node.alternate);break}}function readExpression(state){let trivial=!state.loc||state.lfOnly?scanTrivialExpression(state.source,state.index,state.isTypeScript):null;if(trivial){if(state.index=trivial.end,state.loc)addLocations(trivial);return trivial}let{node,end}=parseExpressionAt(state,state.source,state.index);return state.index=end,node}var RESERVED_ATTRIBUTES=new Set(["server","client","worker","test","default"]);function readScript(state,start,attributes){let{source,index:scriptStart}=state;if(scriptStart>=source.length)unexpected_eof(source.length);let close=closingScriptTag(source,scriptStart);if(close===-1)element_unclosed(source.length,"script");state.index=closingScriptTagEnd(source,close);let program=state.script?parseProgram(state,source.slice(0,close),scriptStart):{type:"Program",start:scriptStart,end:close,body:[],sourceType:"module"};if(program.start=scriptStart,program.loc)Object.assign(program.loc.start,position(start)),Object.assign(program.loc.end,position(state.index));else if(state.loc)program.loc={start:position(start),end:position(state.index)};let context="default";for(let attribute of attributes){if(RESERVED_ATTRIBUTES.has(attribute.name))script_reserved_attribute(attribute,attribute.name);if(attribute.name==="module"){if(attribute.value!==!0)script_invalid_attribute_value(attribute,attribute.name);context="module"}if(attribute.name==="context"){let value=attribute.value;if(!Array.isArray(value)||value.length!==1||value[0].type!=="Text"||value[0].data!=="module")script_invalid_context(attribute);context="module"}}return{type:"Script",start,end:state.index,context,content:program,attributes}}var REGEX_NTH_OF=/(even|odd|\+?(\d+|\d*n(\s*[+-]\s*\d+)?)|-\d*n(\s*\+\s*\d+))((?=\s*[,)])|\s+of(\s+|(?=[.#[*:&])))/y,REGEX_PERCENTAGE=/\d+(\.\d+)?%/y,REGEX_UNICODE_SEQUENCE=/\\[0-9a-fA-F]{1,6}(\r\n|\s)?/y,REGEX_CLOSING_STYLE_TAG_END=/\s*>/y,NONE=-1,DOUBLE_QUOTE=34,HASH=35,DOLLAR=36,AMPERSAND=38,SINGLE_QUOTE=39,OPEN_PAREN=40,CLOSE_PAREN=41,ASTERISK=42,PLUS=43,HYPHEN=45,DOT=46,SLASH=47,COLON=58,SEMICOLON=59,LESS_THAN=60,EQUALS=61,GREATER_THAN=62,OPEN_BRACKET=91,BACKSLASH=92,CLOSE_BRACKET=93,CARET=94,OPEN_BRACE=123,PIPE=124,CLOSE_BRACE=125,TILDE=126,comments=[];function readStyle(state,start,attributes){let contentStart=state.index;comments=[];let children=state.css?readBody(state):skipBody(state),contentEnd=state.index;return state.eat("</style",!0),state.read(REGEX_CLOSING_STYLE_TAG_END),{type:"StyleSheet",start,end:state.index,attributes,children,comments,content:{start:contentStart,end:contentEnd,styles:state.source.slice(contentStart,contentEnd),comment:null}}}function skipBody(state){return state.index=styleContentEnd(state.source,state.index),[]}function readBody(state){let children=[];for(;;){if(allowCommentOrWhitespace(state,!0),state.match("</style")||state.index>=state.source.length)break;children.push(state.match("@")?readAtRule(state):readRule(state))}return children}function readAtRule(state){let start=state.index;state.eat("@",!0);let name=readIdentifier(state),prelude=readValue(state,!0),block=null;if(state.match("{"))block=readBlock(state);else state.eat(";",!0);return{type:"Atrule",start,end:state.index,name,prelude,block}}function readRule(state){let start=state.index;return{type:"Rule",prelude:readSelectorList(state,!1),block:readBlock(state),start,end:state.index}}function readSelectorList(state,insidePseudoClass){let children=[];allowCommentOrWhitespace(state,!0);let start=state.index;while(state.index<state.source.length){children.push(readSelector(state,insidePseudoClass));let end=state.index;if(allowCommentOrWhitespace(state,!0),state.match(insidePseudoClass?")":"{"))return{type:"SelectorList",start,end,children};state.eat(",",!0),allowCommentOrWhitespace(state,!0)}return unexpected_eof(state.source.length)}function createRelativeSelector(combinator,start){return{type:"RelativeSelector",combinator,selectors:[],start,end:-1}}function readSelector(state,insidePseudoClass){let{source,index:listStart}=state,children=[],relativeSelector=createRelativeSelector(null,state.index);while(state.index<source.length){let start=state.index,code=source.charCodeAt(start),selectors=relativeSelector.selectors;if(code===AMPERSAND)state.index++,selectors.push({type:"NestingSelector",name:"&",start,end:state.index});else if(code===ASTERISK)state.index++,selectors.push(readTypeSelectorRest(state,start,"*"));else if(code===HASH)state.index++,selectors.push({type:"IdSelector",name:readIdentifier(state),start,end:state.index});else if(code===DOT)state.index++,selectors.push({type:"ClassSelector",name:readIdentifier(state),start,end:state.index});else if(code===COLON){let isElement=source.charCodeAt(start+1)===COLON;state.index+=isElement?2:1;let name=readIdentifier(state),args=null;if(state.eat("("))args=readSelectorList(state,!0),state.eat(")",!0);if(isElement)selectors.push({type:"PseudoElementSelector",name,start,end:state.index,...args&&{args}});else selectors.push({type:"PseudoClassSelector",name,args,start,end:state.index})}else if(code===OPEN_BRACKET)state.index++,selectors.push(readAttributeSelector(state,start));else{let nth=insidePseudoClass?state.read(REGEX_NTH_OF):null,percentage=!nth&&isDigit(code)?state.read(REGEX_PERCENTAGE):null;if(nth)selectors.push({type:"Nth",value:nth,start,end:state.index});else if(percentage)selectors.push({type:"Percentage",value:percentage,start,end:state.index});else if(combinatorLength(source,start)===0){let name=readIdentifier(state);selectors.push(readTypeSelectorRest(state,start,name))}}let index=state.index;allowCommentOrWhitespace(state,!1);let end=state.match(",")||state.match(insidePseudoClass?")":"{");if(state.index=index,end)return relativeSelector.end=index,children.push(relativeSelector),{type:"ComplexSelector",start:listStart,end:index,children};let combinator=readCombinator(state);if(combinator){if(relativeSelector.selectors.length>0)relativeSelector.end=index,children.push(relativeSelector);if(relativeSelector=createRelativeSelector(combinator,combinator.start),state.allowWhitespace(),state.match(",")||state.match(insidePseudoClass?")":"{"))css_selector_invalid(state.index)}}return unexpected_eof(source.length)}function readTypeSelectorRest(state,start,first){let name=first,namespace;if(state.eat("|"))namespace=name,name=state.eat("*")?"*":readIdentifier(state);return{type:"TypeSelector",name,...namespace!==void 0&&{namespace},start,end:state.index}}function readAttributeSelector(state,start){let source=state.source;state.allowWhitespace();let name=readIdentifier(state);state.allowWhitespace();let value=null,matcher=null,code=source.charCodeAt(state.index);if(code===EQUALS)matcher="=";else if((code===TILDE||code===CARET||code===DOLLAR||code===ASTERISK||code===PIPE)&&source.charCodeAt(state.index+1)===EQUALS)matcher=source.slice(state.index,state.index+2);if(matcher)state.index+=matcher.length,state.allowWhitespace(),value=readAttributeValue(state);state.allowWhitespace();let flagsStart=state.index;while(isAsciiLetter(source.charCodeAt(state.index)))state.index++;let flags=state.index>flagsStart?source.slice(flagsStart,state.index):null;return state.allowWhitespace(),state.eat("]",!0),{type:"AttributeSelector",start,end:state.index,name,matcher,value,flags}}function combinatorLength(source,index){let code=source.charCodeAt(index);if(code===PLUS||code===TILDE||code===GREATER_THAN)return 1;if(code===PIPE&&source.charCodeAt(index+1)===PIPE)return 2;return 0}function readCombinator(state){let start=state.index;state.allowWhitespace();let index=state.index,length=combinatorLength(state.source,index);if(length>0){state.index+=length;let end=state.index;return state.allowWhitespace(),{type:"Combinator",name:state.source.slice(index,end),start:index,end}}if(state.index!==start)return{type:"Combinator",name:" ",start,end:state.index};return null}function readBlock(state){let start=state.index;state.eat("{",!0);let children=[];while(state.index<state.source.length){if(allowCommentOrWhitespace(state,!0),state.match("}"))break;children.push(readBlockItem(state))}return state.eat("}",!0),{type:"Block",start,end:state.index,children}}function readBlockItem(state){if(state.match("@"))return readAtRule(state);let start=state.index;readValue(state,!1);let code=state.source.charCodeAt(state.index);return state.index=start,code===OPEN_BRACE?readRule(state):readDeclaration(state)}function readDeclaration(state){let{source,index:start}=state;if(start>=source.length)unexpected_eof(source.length);let propertyEnd=start;while(propertyEnd<source.length){let code=source.charCodeAt(propertyEnd);if(code===COLON||isWhitespace(code))break;propertyEnd++}let property=source.slice(start,propertyEnd);state.index=propertyEnd,state.allowWhitespace(),state.eat(":");let index=state.index;state.allowWhitespace();let value=readValue(state,!0);if(!value&&!property.startsWith("--"))css_empty_declaration({start,end:index});let end=state.index;if(!state.match("}"))state.eat(";",!0);return{type:"Declaration",start,end,property,value}}function readValue(state,capture){let source=state.source,length=source.length,value="",segmentStart=state.index,valueComments=null,escaped=!1,inUrl=!1,quoteMark=NONE,i=state.index;while(i<length){let code=source.charCodeAt(i);if(escaped){escaped=!1,i++;continue}if(code===BACKSLASH){escaped=!0,i++;continue}if(code===quoteMark)quoteMark=NONE;else if(code===CLOSE_PAREN)inUrl=!1;else if(quoteMark===NONE&&(code===DOUBLE_QUOTE||code===SINGLE_QUOTE))quoteMark=code;else if(code===OPEN_PAREN){if(endsWithUrl(source,value,segmentStart,i))inUrl=!0}else if((code===SEMICOLON||code===OPEN_BRACE||code===CLOSE_BRACE)&&!inUrl&"eMark===NONE){if(state.index=i,!capture)return"";if(value+=source.slice(segmentStart,i),valueComments){let leadingWhitespace=value.length-value.trimStart().length;for(let comment of valueComments)comment.position=Math.max(0,(comment.position??0)-leadingWhitespace)}return value.trim()}else if(code===SLASH&&!inUrl&"eMark===NONE&&source.charCodeAt(i+1)===ASTERISK){value+=source.slice(segmentStart,i),state.index=i;let comment=readComment(state);if(capture)comment.position=value.length,comments.push(comment),valueComments??=[],valueComments.push(comment);i=state.index,segmentStart=i;continue}i++}return state.index=length,unexpected_eof(length)}function endsWithUrl(source,value,segmentStart,end){if(end-segmentStart>=3)return source.charCodeAt(end-3)===117&&source.charCodeAt(end-2)===114&&source.charCodeAt(end-1)===108;return(value+source.slice(segmentStart,end)).endsWith("url")}function readAttributeValue(state){let source=state.source,quoteMark=NONE;if(state.eat('"'))quoteMark=DOUBLE_QUOTE;else if(state.eat("'"))quoteMark=SINGLE_QUOTE;let start=state.index,escaped=!1,i=start;while(i<source.length){let code=source.charCodeAt(i);if(escaped)escaped=!1;else if(code===BACKSLASH)escaped=!0;else if(quoteMark===NONE?code===CLOSE_BRACKET||isWhitespace(code):code===quoteMark)return state.index=quoteMark===NONE?i:i+1,source.slice(start,i).trim();i++}return state.index=i,unexpected_eof(source.length)}function readIdentifier(state){let{source,index:start}=state,first=source.charCodeAt(start);if(isDigit(first)||first===HYPHEN&&isDigit(source.charCodeAt(start+1)))css_expected_identifier(start);let identifier="",runStart=start,i=start;while(i<source.length){let code=source.charCodeAt(i);if(code===BACKSLASH){identifier+=source.slice(runStart,i),state.index=i;let sequence=state.matchRegex(REGEX_UNICODE_SEQUENCE);if(sequence){let character=String.fromCodePoint(Number.parseInt(sequence.slice(1),16));identifier+=character==="\\"?"\\\\":character,i+=sequence.length}else identifier+=`\\${source[i+1]}`,i+=2;runStart=i}else if(code>=160||isIdentifierChar2(code))i++;else break}if(identifier+=source.slice(runStart,i),state.index=i,identifier==="")css_expected_identifier(start);return identifier}function allowCommentOrWhitespace(state,capture){let source=state.source;state.allowWhitespace();for(;;){let code=source.charCodeAt(state.index);if(code===SLASH&&source.charCodeAt(state.index+1)===ASTERISK){let comment=readComment(state);if(capture)comments.push(comment)}else if(code===LESS_THAN&&state.eat("<!--"))state.readUntil("-->"),state.eat("-->",!0);else break;state.allowWhitespace()}}function readComment(state){let start=state.index;state.eat("/*",!0);let value=state.readUntil("*/");return state.eat("*/",!0),{type:"CSSComment",value,start,end:state.index}}function isAsciiLetter(code){return code>=65&&code<=90||code>=97&&code<=122}function isIdentifierChar2(code){return isAsciiLetter(code)||isDigit(code)||code===95||code===45}var REGEX_CLOSING_TEXTAREA=/<\/textarea(\s[^>]*)?>/iy,REGEX_DOCTYPE_NAME=/^![a-zA-Z]+$/,REGEX_NAMESPACED_NAME=/^[a-zA-Z][a-zA-Z0-9]*:[a-zA-Z][a-zA-Z0-9-]*[a-zA-Z0-9]$/,REGEX_CUSTOM_ELEMENT_NAME=/^[a-zA-Z][a-zA-Z0-9]*(-[a-zA-Z0-9.\-_\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}]*)?$/u,ID_JOINERS="\\u200C\\u200D",REGEX_COMPONENT_NAME=new RegExp(`^(?:\\p{Lu}[$${ID_JOINERS}\\p{ID_Continue}.]*|\\p{ID_Start}[$${ID_JOINERS}\\p{ID_Continue}]*(?:\\.[$${ID_JOINERS}\\p{ID_Continue}]+)+)$`,"u"),DIRECTIVES=new Map([["use","UseDirective"],["animate","AnimateDirective"],["bind","BindDirective"],["class","ClassDirective"],["style","StyleDirective"],["on","OnDirective"],["let","LetDirective"],["in","TransitionDirective"],["out","TransitionDirective"],["transition","TransitionDirective"]]),META_TAGS=new Map([["svelte:head",["SvelteHead",!0]],["svelte:options",["SvelteOptions",!0]],["svelte:window",["SvelteWindow",!0]],["svelte:document",["SvelteDocument",!0]],["svelte:body",["SvelteBody",!0]],["svelte:element",["SvelteElement",!1]],["svelte:component",["SvelteComponent",!1]],["svelte:self",["SvelteSelf",!1]],["svelte:fragment",["SvelteFragment",!1]],["svelte:boundary",["SvelteBoundary",!1]]]),META_TAG_NAMES=[...META_TAGS.keys()],META_TAG_LIST=`${META_TAG_NAMES.slice(0,-1).join(", ")} or ${META_TAG_NAMES.at(-1)}`,GT=62,BRACE=123;function readName(state,isAttribute){let start=state.index;if(start>=state.source.length)unexpected_eof(state.source.length);let end=nameEnd(state.source,start,isAttribute);return state.index=end,{name:state.source.slice(start,end),start,end,loc:state.sourceLocation(start,end)}}var text=(start,end,raw,data=raw)=>({start,end,type:"Text",raw,data});function isComponentName(name){let first=name.charCodeAt(0);if(first>=97&&first<=122&&!name.includes("."))return!1;return REGEX_COMPONENT_NAME.test(name)}function isElementName(name){let simple=!0;for(let i=0;i<name.length&&simple;i++){let code=name.charCodeAt(i);simple=code>=97&&code<=122||i>0&&code>=48&&code<=57}return simple&&name.length>0||REGEX_DOCTYPE_NAME.test(name)||REGEX_NAMESPACED_NAME.test(name)||REGEX_CUSTOM_ELEMENT_NAME.test(name)}function hasAncestor(stack,matches){for(let i=stack.length-1;i>=0;i--){let found=matches(stack[i]);if(found!==void 0)return found}return!1}function elementType(state,name,isComponent){let meta=META_TAGS.get(name);if(meta)return meta[0];if(isComponent)return"Component";if(name==="title"){if(hasAncestor(state.stack,({type})=>{if(type==="SvelteHead")return!0;return type==="RegularElement"||type==="Component"?!1:void 0}))return"TitleElement"}if(name==="slot"){if(!hasAncestor(state.stack,(node)=>node.type==="RegularElement"&&node.attributes.some((a)=>a.type==="Attribute"&&a.name==="shadowrootmode")?!0:void 0))return"SlotElement"}return"RegularElement"}function readElement(state){let start=state.index++;if(state.eat("!--")){let data=state.readUntil("-->");state.eat("-->",!0),state.append({type:"Comment",start,end:state.index,data})}else if(state.eat("/"))closeElement(state,start);else openElement(state,start)}function closeElement(state,start){let{name}=readName(state,!1);if(state.allowWhitespace(),state.eat(">",!0),isVoid(name))void_element_invalid_content(start);let open=state.current();while(!("name"in open)||open.name!==name){if(open.type!=="RegularElement"){let autoClosed=state.lastAutoClosedTag;if(autoClosed?.tag===name)element_invalid_closing_tag_autoclosed(start,name,autoClosed.reason);element_invalid_closing_tag(start,name)}open.end=start,state.close(),open=state.current()}if(open.end=state.index,state.close(),state.stack.length<(state.lastAutoClosedTag?.depth??0))state.lastAutoClosedTag=void 0}function createElement(type,start,name){return{type,start,end:-1,name}}function openElement(state,start){let tag=readName(state,!1),{name}=tag,meta=META_TAGS.get(name);if(!meta&&name.startsWith("svelte:"))svelte_meta_invalid_tag(tag,META_TAG_LIST);let isComponent=isComponentName(name);if(!isComponent&&!isElementName(name))tag_invalid_name(tag);if(meta?.[1]){if(state.metaTags.has(name))svelte_meta_duplicate(start,name);if(state.current().type!=="Root")svelte_meta_invalid_placement(start,name);state.metaTags.add(name)}let element=createElement(elementType(state,name,isComponent),start,name);if(state.loc)element.name_loc=tag.loc;element.attributes=[],element.fragment={type:"Fragment",nodes:[]},state.allowWhitespace();let parent=state.current();if(parent.type==="RegularElement"&&closingTagOmitted(parent.name,name))parent.end=start,state.close(),state.lastAutoClosedTag={tag:parent.name,reason:name,depth:state.stack.length};if((name==="script"||name==="style")&&state.current().type==="Root"){let attributes=[];element.attributes=attributes,readAttributes(state,attributes,readStaticAttribute),readTopLevelBlock(state,element,start,attributes);return}if(readAttributes(state,element.attributes,readAttribute),element.type==="SvelteComponent"){let definition=takeThis(element);if(!definition)svelte_component_missing_this(start);if(!isExpressionValue(definition.value))svelte_component_invalid_this(definition.start);element.expression=expressionOf(definition.value)}else if(element.type==="SvelteElement"){let definition=takeThis(element);if(!definition)svelte_element_missing_this(start);if(definition.value===!0)svelte_element_missing_this(definition);element.tag=isExpressionValue(definition.value)?expressionOf(definition.value):literalTag(definition.value[0])}if(!state.eat("/")&&!isVoid(name))if(state.eat(">",!0),name==="textarea")element.fragment.nodes=readSequence(state,(source,i)=>(REGEX_CLOSING_TEXTAREA.lastIndex=i,REGEX_CLOSING_TEXTAREA.test(source)),"inside <textarea>"),state.read(REGEX_CLOSING_TEXTAREA);else if(name==="script"||name==="style")element.fragment.nodes.push(readRawText(state,`</${name}>`));else{state.open(element,element.fragment);return}else state.eat(">",!0);element.end=state.index,state.append(element)}function readRawText(state,closer){let start=state.index,found=state.source.indexOf(closer,start);state.index=found===-1?state.source.length:found;let node=text(start,state.index,state.source.slice(start,state.index));return state.eat(closer,!0),node}function readTopLevelBlock(state,element,start,attributes){state.eat(">",!0);let comment=commentBefore(state.root.fragment.nodes,start);if(element.name==="style"){let css=readStyle(state,start,attributes);if(css.content.comment=comment,state.root.css)style_duplicate(start);state.root.css=css;return}let script=readScript(state,start,attributes);if(comment&&state.comments)script.content.leadingComments=[{type:"Line",value:comment.data}];let slot=script.context==="module"?"module":"instance";if(state.root[slot])script_duplicate(start);state.root[slot]=script}function commentBefore(nodes,start){let last=nodes.length-1;if(last<0||nodes[last].end!==start)return null;for(let i=last;i>=0;i--){let node=nodes[i];if(node.type==="Comment")return node;if(node.type!=="Text"||node.data.trim())return null}return null}var isThisAttribute=(node)=>node.type==="Attribute"&&node.name==="this";function takeThis(element){let found=element.attributes.find(isThisAttribute);if(found)element.attributes.splice(element.attributes.indexOf(found),1);return found}function isExpressionValue(value){if(value===!0)return!1;if(!Array.isArray(value))return!0;return value.length===1&&value[0].type==="ExpressionTag"}function expressionOf(value){return(Array.isArray(value)?value[0]:value).expression}function literalTag(chunk){if(chunk.type!=="Text")return chunk.expression;return{type:"Literal",value:chunk.data,raw:`'${chunk.raw}'`,start:chunk.start,end:chunk.end}}function readAttributes(state,into,read){let seen=new Set;for(;;){let parsed=read(state);if(!parsed)return;let{type}=parsed;if(type==="Attribute"||type==="BindDirective"||type==="StyleDirective"||type==="ClassDirective"){let key=`${type==="BindDirective"?"Attribute":type}${parsed.name}`;if(seen.has(key))attribute_duplicate(parsed);if(parsed.name!=="this")seen.add(key)}into.push(parsed),state.allowWhitespace()}}function createAttribute(state,name,start,end,value){return state.loc?{type:"Attribute",start,end,name:name.name,name_loc:name.loc,value}:{type:"Attribute",start,end,name:name.name,value}}function rejectQuote(state){if(isQuote(state.source.charCodeAt(state.index)))expected_token(state.index,"=")}function readStaticAttribute(state){let start=state.index,name=readName(state,!0);if(!name.name)return null;let value=!0;if(state.eat("=")){state.allowWhitespace();let{source}=state,at=state.index,quoted=isQuote(source.charCodeAt(at)),end=-1;if(quoted){let close=source.indexOf(source[at],at+1);if(close!==-1)end=close+1}if(end===-1){end=at;while(end<source.length&&source.charCodeAt(end)!==GT&&!isWhitespace(source.charCodeAt(end)))end++;if(end===at)expected_attribute_value(at)}state.index=end;let quotes=quoted?1:0,raw=source.slice(at+quotes,end-quotes);value=[text(end-raw.length-quotes,end-quotes,raw,decodeCharacterReferences(raw,!0,state.entityNames))]}return rejectQuote(state),createAttribute(state,name,start,state.index,value)}function readJsComment(state){let start=state.index,block=state.match("/*");if(!block&&!state.match("//"))return!1;state.index+=2;let value=state.readUntil(block?"*/":`
|
|
2
2
|
`);if(block)state.eat("*/");let comment={type:block?"Block":"Line",start,end:state.index,value},loc=state.sourceLocation(start,state.index);if(loc)comment.loc=loc;if(state.comments)state.root.comments.push(comment);return!0}function readAttribute(state){while(readJsComment(state))state.allowWhitespace();let start=state.index;if(state.eat("{"))return readBraceAttribute(state,start);let name=readName(state,!0);if(!name.name)return null;let end=state.index;state.allowWhitespace();let value=!0;if(state.eat("=")){if(state.allowWhitespace(),state.match("/>"))value=[text(state.index,state.index+1,"/")],state.index++;else value=readAttributeValue2(state);end=state.index}else rejectQuote(state);let colon=name.name.indexOf(":"),type=colon>0?DIRECTIVES.get(name.name.slice(0,colon)):void 0;return type?directive(state,type,name,colon,start,end,value):createAttribute(state,name,start,end,value)}function readBraceAttribute(state,start){if(state.allowWhitespace(),state.eat("@attach")){state.requireWhitespace();let expression=readExpression(state);return state.eatClosingBrace(),{type:"AttachTag",start,end:state.index,expression}}if(state.eat("...")){let expression=readExpression(state);return state.eatClosingBrace(),{type:"SpreadAttribute",start,end:state.index,expression}}let id=state.readIdentifierName();if(id.name==="")attribute_empty_shorthand(start);state.eatClosingBrace();let value={type:"ExpressionTag",start:id.start,end:id.end,expression:id};return createAttribute(state,id,start,state.index,value)}function firstChunk(value){if(value===!0)return;return Array.isArray(value)?value[0]:value}function directive(state,type,tag,colon,start,end,value){let[name,...modifiers]=tag.name.slice(colon+1).split("|");if(name==="")directive_missing_name({start,end:start+colon+1},tag.name);let node={start,end,type,name};if(state.loc)node.name_loc=tag.loc;if(type==="StyleDirective")return node.modifiers=modifiers,node.value=value,node;let first=firstChunk(value);if(first&&(Array.isArray(value)&&value.length>1||first.type==="Text"))directive_invalid_value(first.start);if(node.expression=first?.expression??null,node.modifiers=modifiers,type==="TransitionDirective"){let direction=tag.name.slice(0,colon);node.intro=direction!=="out",node.outro=direction!=="in"}if((type==="BindDirective"||type==="ClassDirective")&&!node.expression)node.expression={start:start+colon+1,end,type:"Identifier",name};return node}function readAttributeValue2(state){let quote=state.source.charCodeAt(state.index),quoted=isQuote(quote);if(quoted){if(state.index++,state.source.charCodeAt(state.index)===quote)return state.index++,[text(state.index-1,state.index-1,"")]}let value;try{value=readSequence(state,quoted?(source,i)=>source.charCodeAt(i)===quote:endsUnquotedValue,"in attribute value",quoted?quote:void 0)}catch(error){let jsErrorAt=error instanceof ParseError2&&error.code==="js_parse_error"?error.position?.[0]:void 0;if(jsErrorAt!==void 0&&state.source.startsWith("/>",jsErrorAt-1))state.index=jsErrorAt,expected_token(jsErrorAt,quoted?String.fromCharCode(quote):"}");throw error}if(quoted)state.index++;else if(value.length===0)expected_attribute_value(state.index);return quoted||value.length>1||value[0].type==="Text"?value:value[0]}function readSequence(state,ends,location,quote){let{source}=state,chunks=[],textStart=state.index,flushText=(end)=>{if(end<=textStart)return;let raw=source.slice(textStart,end);chunks.push(text(textStart,end,raw,decodeCharacterReferences(raw,!0,state.entityNames)))};while(state.index<source.length){let at=state.index;if(ends(source,at))return flushText(at),chunks;if(source.charCodeAt(at)!==BRACE){if(state.index++,quote!==void 0)while(state.index<source.length&&source.charCodeAt(state.index)!==BRACE&&source.charCodeAt(state.index)!==quote)state.index++;continue}state.index++;let marker=source.charCodeAt(state.index);if(marker===35||marker===64){state.index++;let nameStart=state.index;while(state.index<source.length&&source.charCodeAt(state.index)>=97&&source.charCodeAt(state.index)<=122)state.index++;let name=source.slice(nameStart,state.index);(marker===35?block_invalid_placement:tag_invalid_placement)(at,name,location)}flushText(at),state.allowWhitespace();let expression=readExpression(state);state.eatClosingBrace(),chunks.push({type:"ExpressionTag",start:at,end:state.index,expression}),textStart=state.index}unexpected_eof(source.length)}var NAMESPACES=new Map([["html","html"],["svg","svg"],["mathml","mathml"],["http://www.w3.org/2000/svg","svg"],["http://www.w3.org/1998/Math/MathML","mathml"]]),PROP_READERS=new Map([["type",(prop,value)=>{if(value!=="String"&&value!=="Number"&&value!=="Boolean"&&value!=="Array"&&value!=="Object")return!1;return prop.type=value,!0}],["reflect",(prop,value)=>{if(typeof value!=="boolean")return!1;return prop.reflect=value,!0}],["attribute",(prop,value)=>{if(typeof value!=="string")return!1;return prop.attribute=value,!0}]]),NAME_CHAR="[a-z0-9_.\\xB7\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u203F-\\u2040\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\u{10000}-\\u{EFFFF}-]",REGEX_CUSTOM_ELEMENT_NAME2=new RegExp(`^[a-z]${NAME_CHAR}*-${NAME_CHAR}*$`,"u"),RESERVED_NAMES=new Set("annotation-xml color-profile font-face font-face-src font-face-uri font-face-format font-face-name missing-glyph".split(" ")),flag=(key)=>(options,attribute)=>{let value=staticValue(attribute);if(typeof value!=="boolean")svelte_options_invalid_attribute_value(attribute,"true or false");options[key]=value},READERS=new Map([["runes",flag("runes")],["immutable",flag("immutable")],["preserveWhitespace",flag("preserveWhitespace")],["accessors",flag("accessors")],["namespace",(options,attribute)=>{let namespace=NAMESPACES.get(staticValue(attribute));if(!namespace)svelte_options_invalid_attribute_value(attribute,'"html", "mathml" or "svg"');options.namespace=namespace}],["css",(options,attribute)=>{if(staticValue(attribute)!=="injected")svelte_options_invalid_attribute_value(attribute,'"injected"');options.css="injected"}],["tag",(_,attribute)=>svelte_options_deprecated_tag(attribute)],["customElement",(options,attribute)=>{let customElement=readCustomElement(attribute);if(customElement)options.customElement=customElement}]]);function readOptions(node){let attributes=[],options={start:node.start,end:node.end,attributes};for(let attribute of node.attributes){if(attribute.type!=="Attribute")svelte_options_invalid_attribute(attribute);attributes.push(attribute);let read=READERS.get(attribute.name);if(!read)svelte_options_unknown_attribute(attribute,attribute.name);read(options,attribute)}return options}function staticValue({value}){if(value===!0)return!0;let chunks=Array.isArray(value)?value:[value];if(chunks.length===0)return!0;if(chunks.length>1)return null;let[chunk]=chunks;if(chunk.type==="Text")return chunk.data;return chunk.expression.type==="Literal"?chunk.expression.value:null}function checkName(node,name){if(typeof name!=="string")svelte_options_invalid_tagname(node);if(!name)return;if(!REGEX_CUSTOM_ELEMENT_NAME2.test(name))svelte_options_invalid_tagname(node);if(RESERVED_NAMES.has(name))svelte_options_reserved_tagname(node)}function isNamedProperty(property){return property.type==="Property"&&!property.computed&&property.key.type==="Identifier"}function propertiesOf(object,fail){let properties=new Map;for(let property of object.properties){if(!isNamedProperty(property))fail();if(!properties.has(property.key.name))properties.set(property.key.name,property.value)}return properties}function readCustomElement(attribute){let fail=()=>svelte_options_invalid_customelement(attribute);if(attribute.value===!0)fail();let chunk=Array.isArray(attribute.value)?attribute.value[0]:attribute.value;if(chunk.type==="Text"){let tag=staticValue(attribute);return checkName(attribute,tag),{tag}}let{expression}=chunk;if(expression.type!=="ObjectExpression"){if(expression.type==="Literal"&&expression.value===null)return;fail()}let properties=propertiesOf(expression,fail),customElement={},tagValue=properties.get("tag");if(tagValue){let tag=tagValue.type==="Literal"?tagValue.value:void 0;checkName(null,tag),customElement.tag=tag}let props=properties.get("props");if(props){let failProps=()=>svelte_options_invalid_customelement_props(attribute);if(props.type!=="ObjectExpression")failProps();customElement.props={};for(let property of props.properties){if(!isNamedProperty(property)||property.value.type!=="ObjectExpression")failProps();let prop={};customElement.props[property.key.name]=prop;for(let field of property.value.properties){if(!isNamedProperty(field)||field.value.type!=="Literal")failProps();if(!PROP_READERS.get(field.key.name)?.(prop,field.value.value))failProps()}}}let shadow=properties.get("shadow");if(shadow)if(shadow.type==="ObjectExpression")customElement.shadow=shadow;else if(shadow.type==="Literal"&&(shadow.value==="open"||shadow.value==="none"))customElement.shadow=shadow.value;else svelte_options_invalid_customelement_shadow(attribute);let extend=properties.get("extend");if(extend)customElement.extend=extend;return customElement}var DEFAULT_BRACKETS={"{":"}","(":")","[":"]"};function matchBracket(source,start,brackets=DEFAULT_BRACKETS){let close=Object.values(brackets),stack=[],i=start;while(i<source.length){let char=source[i++];if(char==="'"||char==='"'||char==="`")i=matchQuote(source,i,char);else if(Object.hasOwn(brackets,char))stack.push(char);else if(close.includes(char)){let expected=brackets[stack.pop()??""];if(char!==expected)expected_token(i-1,expected);if(stack.length===0)return i}}unexpected_eof(source.length)}function matchQuote(source,start,quote){let i=start;while(i<source.length){let char=source[i++];if(char===quote)return i;if(char==="\\")i++;else if(quote==="`"&&char==="$"&&source[i]==="{")i=matchBracket(source,i)}unterminated_string_constant(start)}var REGEX_OPTIONAL_PARAM_COLON=/\?\s*:/g;function readPattern(state){let start=state.index,id=state.readIdentifierName();if(id.name!=="")return{...id,typeAnnotation:readTypeAnnotation(state)};let char=state.source[state.index];if(char!=="{"&&char!=="[")expected_pattern(state.index);state.index=matchBracket(state.source,start);let pattern=parsePatternAt(state,state.source.slice(0,state.index),start)??assignedPattern(state,start);assertType(pattern,"ObjectPattern","ArrayPattern");let typeAnnotation=readTypeAnnotation(state);if(pattern.typeAnnotation=typeAnnotation,typeAnnotation)pattern.end=typeAnnotation.end;return pattern}function assignedPattern(state,start){let{node}=parseExpressionAt(state,`${state.source.slice(0,state.index)} = 1`,start);return assertType(node,"AssignmentExpression"),node.left}function readTypeAnnotation(state){let start=state.index;if(state.allowWhitespace(),!state.eat(":")){state.index=start;return}let insert="_ as ",a=state.index-insert.length,synthetic=state.source.slice(0,a)+insert+state.source.slice(state.index).replace(REGEX_OPTIONAL_PARAM_COLON,":"),expression=parseExpressionAt(state,synthetic,a).node;if(expression.type==="AssignmentExpression"){let b=expression.right.start;while(synthetic[b]!=="=")b-=1;expression=parseExpressionAt(state,synthetic.slice(0,b),a).node}if(expression.type==="SequenceExpression")expression=expression.expressions[0];return assertType(expression,"TSAsExpression"),state.index=expression.end,{type:"TSTypeAnnotation",start,end:state.index,typeAnnotation:expression.typeAnnotation}}var CLOSING_WORDS={IfBlock:"if",EachBlock:"each",KeyBlock:"key",AwaitBlock:"await",SnippetBlock:"snippet"},fragment=()=>({type:"Fragment",nodes:[]});function openBlock(state,start){if(state.eat("if")){state.requireWhitespace();let test=readExpression(state);state.eatClosingBrace();let consequent=fragment();state.open({type:"IfBlock",elseif:!1,start,end:-1,test,consequent,alternate:null},consequent)}else if(state.eat("each"))openEach(state,start);else if(state.eat("await")){state.requireWhitespace();let expression=readExpression(state);state.allowWhitespace();let block={type:"AwaitBlock",start,end:-1,expression,value:null,error:null,pending:null,then:null,catch:null},body=fragment();if(state.eat("then"))block.value=readAwaitBinding(state),block.then=body;else if(state.eat("catch"))block.error=readAwaitBinding(state),block.catch=body;else block.pending=body;state.eat("}",!0),state.open(block,body)}else if(state.eat("key")){state.requireWhitespace();let expression=readExpression(state);state.eatClosingBrace();let body=fragment();state.open({type:"KeyBlock",start,end:-1,expression,fragment:body},body)}else if(state.eat("snippet"))openSnippet(state,start);else expected_block_type(state.index)}function readAwaitBinding(state){if(state.matchRegex(REGEX_WHITESPACE_THEN_CLOSING_BRACE))return state.allowWhitespace(),null;state.requireWhitespace();let pattern=readPattern(state);return state.allowWhitespace(),pattern}function stripTrailingAssertion(root){let found={assertion:null},end=root.end,unwrap=(node)=>{if(node.type==="TSAsExpression"&&node.end===root.end)return found.assertion=node,end=node.expression.end,node.expression;return mapChildren(node,unwrap),node},expression=root;if(root.type==="TSAsExpression")found.assertion=root,expression=root.expression,end=expression.end;else mapChildren(root,unwrap);return expression.end=end,{expression,assertion:found.assertion}}function openEach(state,start){state.requireWhitespace();let source=state.source,expression;while(!expression)try{expression=readExpression(state)}catch(error){let end=((error instanceof ParseError2?error.position:void 0)?.[0]??start)-2;while(end>start&&state.source.slice(end,end+2)!=="as")end-=1;if(end<=start)throw state.source=source,error;state.source=source.slice(0,end)}if(state.source=source,state.allowWhitespace(),!state.match("as")){if(expression.type==="SequenceExpression")expression=expression.expressions[0];let stripped=stripTrailingAssertion(expression);if(expression=stripped.expression,stripped.assertion){let rewind=stripped.assertion.typeAnnotation.start-2;while(state.source.slice(rewind,rewind+2)!=="as")rewind-=1;state.index=rewind}}let context=null,index,key;if(state.eat("as"))state.requireWhitespace(),context=readPattern(state);else state.index=expression.end;if(state.allowWhitespace(),state.eat(",")){if(state.allowWhitespace(),index=state.readIdentifierName().name,!index)expected_identifier(state.index);state.allowWhitespace()}if(state.eat("("))state.allowWhitespace(),key=readExpression(state),state.allowWhitespace(),state.eat(")",!0),state.allowWhitespace();state.eat("}",!0);let body=fragment();state.open({type:"EachBlock",start,end:-1,expression,body,context,index,key},body)}function openSnippet(state,start){state.requireWhitespace();let id=state.readIdentifierName();if(id.name==="")expected_identifier(state.index);state.allowWhitespace();let paramsStart=state.index,typeParams;if(state.isTypeScript&&state.match("<")){let end=matchBracket(state.source,paramsStart,{"<":">"});typeParams=state.source.slice(paramsStart+1,end-1),state.index=end}state.allowWhitespace(),state.eat("(",!0);let parentheses=1;while(state.index<state.source.length&&(!state.match(")")||parentheses!==1)){if(state.match("("))parentheses++;if(state.match(")"))parentheses--;state.index+=1}state.eat(")",!0);let{node}=parseExpressionAt(state,`${state.source.slice(0,state.index)} => {}`,paramsStart,!0);state.eatClosingBrace();let body=fragment();state.open({type:"SnippetBlock",start,end:-1,expression:id,typeParams,parameters:node.type==="ArrowFunctionExpression"?node.params:void 0,body},body)}function nextBlockClause(state,tagStart){let start=state.index-1,block=state.current();if(block.type==="IfBlock"){if(!state.eat("else"))expected_token(start,"{:else} or {:else if}");if(state.eat("if"))block_invalid_elseif(start);if(state.allowWhitespace(),block.alternate=fragment(),state.setFragment(block.alternate),state.eat("if")){state.requireWhitespace();let test=readExpression(state);state.eatClosingBrace();let consequent=fragment();state.open({start:tagStart,end:-1,type:"IfBlock",elseif:!0,test,consequent,alternate:null},consequent)}else state.eatClosingBrace()}else if(block.type==="EachBlock"){if(!state.eat("else"))expected_token(start,"{:else}");state.eatClosingBrace(),block.fallback=fragment(),state.setFragment(block.fallback)}else if(block.type==="AwaitBlock"){let clause;if(state.eat("then"))clause="then";else if(state.eat("catch"))clause="catch";else expected_token(start,"{:then ...} or {:catch ...}");if(block[clause])block_duplicate_clause(start,`{:${clause}}`);if(!state.eat("}")){state.requireWhitespace();let pattern=readPattern(state);if(clause==="then")block.value=pattern;else block.error=pattern;state.eatClosingBrace()}let body=fragment();block[clause]=body,state.setFragment(body)}else block_invalid_continuation_placement(start)}function closeBlock(state){let block=state.current(),word=CLOSING_WORDS[block.type];if(!word)block_unexpected_close(state.index-1);state.eat(word,!0),state.eatClosingBrace();while(block.type==="IfBlock"&&block.elseif)block.end=state.index,state.close(),block=state.current();block.end=state.index,state.close()}function isCall(expression){return expression.type==="CallExpression"||expression.type==="ChainExpression"&&expression.expression.type==="CallExpression"}function readSpecialTag(state,start){if(state.eat("html")){state.requireWhitespace();let expression=readExpression(state);state.eatClosingBrace(),state.append({type:"HtmlTag",start,end:state.index,expression})}else if(state.eat("debug")){let identifiers=[];if(!state.read(REGEX_WHITESPACE_THEN_CLOSING_BRACE)){let expression=readExpression(state),nodes=expression.type==="SequenceExpression"?expression.expressions:[expression];for(let node of nodes){if(node.type!=="Identifier")debug_tag_invalid_arguments(node.start);identifiers.push(node)}state.eatClosingBrace()}state.append({type:"DebugTag",start,end:state.index,identifiers})}else if(state.eat("const")){state.requireWhitespace();let id=readPattern(state);state.allowWhitespace(),state.eat("=",!0),state.allowWhitespace();let expressionStart=state.index,init=readExpression(state),declaratorEnd=state.index;if(init.type==="SequenceExpression"&&!state.source.slice(expressionStart,init.start).includes("("))const_tag_invalid_expression(init);state.eatClosingBrace();let declarator={type:"VariableDeclarator",id,init,start:id.start,end:declaratorEnd};state.append({type:"ConstTag",start,end:state.index,declaration:{type:"VariableDeclaration",kind:"const",declarations:[declarator],start:start+2,end:state.index-1}})}else if(state.eat("render")){state.requireWhitespace();let expression=readExpression(state);if(!isCall(expression))render_tag_invalid_expression(expression);state.eatClosingBrace(),state.append({type:"RenderTag",start,end:state.index,expression})}else expected_tag(state.index)}var REGEX_UNSUPPORTED_DECLARATION=/(?:var|interface|enum)\b/y,REGEX_MAYBE_DECLARATION=/(?:let|const|type)\b/y;function readTag(state){let start=state.index;if(state.index+=1,state.allowWhitespace(),state.eat("#"))openBlock(state,start);else if(state.eat(":"))nextBlockClause(state,start);else if(state.eat("@"))readSpecialTag(state,start);else if(state.match("/")&&!state.match("/*")&&!state.match("//"))state.index+=1,closeBlock(state);else if(!readDeclarationTag(state,start)){let expression=readExpression(state);state.eatClosingBrace(),state.append({type:"ExpressionTag",start,end:state.index,expression})}}function readDeclarationTag(state,tagStart){let start=state.index,unsupported=state.matchRegex(REGEX_UNSUPPORTED_DECLARATION);if(unsupported)declaration_tag_invalid_type({start,end:start+unsupported.length});if(!state.matchRegex(REGEX_MAYBE_DECLARATION))return!1;let commentsBefore=state.root.comments.length,statement=parseStatementAt(state,state.source,start);if(statement.type==="ExpressionStatement")return state.root.comments.length=commentsBefore,!1;if(statement.type!=="VariableDeclaration"||statement.kind!=="let"&&statement.kind!=="const")declaration_tag_invalid_type(statement);return state.index=statement.end,state.eatClosingBrace(),state.append({type:"DeclarationTag",start:tagStart,end:state.index,declaration:statement}),!0}function readText(state){let{source,index:start}=state;if(state.nextAngle<start)state.nextAngle=find(source,"<",start);if(state.nextBrace<start)state.nextBrace=find(source,"{",start);let end=Math.min(state.nextAngle,state.nextBrace);state.index=end;let raw=source.slice(start,end);state.append({type:"Text",start,end,raw,data:decodeCharacterReferences(raw,!1,state.entityNames)})}function find(source,char,from){let index=source.indexOf(char,from);return index===-1?source.length:index}function parseComponent(source,options,support){let state=componentState(source,options,support);while(state.index<state.source.length)readNode(state);return finishComponent(state)}function componentState(source,options,support){let template=withoutByteOrderMark(source);return setSource(template),new TemplateParserState(template.trimEnd(),template.length,support,options)}function finishComponent(state){if(state.stack.length>1){let current=state.current();if(current.end=current.start+1,current.type==="RegularElement")element_unclosed(current,current.name);block_unclosed(current)}let{nodes:rootNodes}=state.root.fragment,optionsIndex=rootNodes.findIndex((node)=>node.type==="SvelteOptions"),raw=rootNodes[optionsIndex];if(raw?.type==="SvelteOptions"){rootNodes.splice(optionsIndex,1),state.root.options=readOptions(raw);let{nodes}=raw.fragment;if(nodes.length>0)svelte_meta_invalid_content({start:nodes[0].start,end:nodes[nodes.length-1].end},raw.name)}return state.root}function readNode(state){if(state.match("<"))readElement(state);else if(state.match("{"))readTag(state);else readText(state)}
|
|
3
3
|
export{readElement,parseComponent,componentState,finishComponent,readNode};
|