// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define(["exports"],function(p){function t(a){return!!a&&"object"==typeof a&&"type"in a&&a.type===e.BlockStatement}function x(a){return!!a&&"object"==typeof a&&"type"in a&&a.type===e.EmptyStatement}function u(a,b){return b.loc.end.line===a.loc.start.line&&b.loc.end.column<=a.loc.start.column}function v(a,b){a=y[a];return b?a.replace(H,(c,d)=>b[d]?.toString()??""):a}function z(a,b=0){let c=a.start-a.lineStart,d=a.lineNumber;return 0>c&&(c+=b,--d),{index:a.start,line:d,column:c}}function A(a){return[{index:a.range[0], ...a.loc.start},{index:a.range[1],...a.loc.end}]}function B(a){return a in C?C[a]:0}var k={Break:"break",Continue:"continue",Else:"else",For:"for",From:"from",Function:"function",If:"if",Import:"import",Export:"export",In:"in",Return:"return",Var:"var",While:"while"},e={AssignmentExpression:"AssignmentExpression",ArrayExpression:"ArrayExpression",BlockComment:"BlockComment",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression", ContinueStatement:"ContinueStatement",EmptyStatement:"EmptyStatement",ExpressionStatement:"ExpressionStatement",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ForStatement:"ForStatement",ForInStatement:"ForInStatement",FunctionDeclaration:"FunctionDeclaration",Identifier:"Identifier",IfStatement:"IfStatement",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",LineComment:"LineComment",Literal:"Literal",LogicalExpression:"LogicalExpression", MemberExpression:"MemberExpression",ObjectExpression:"ObjectExpression",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement"},w=["++","--"],D=["-","+","!","~"],E="\x3d /\x3d *\x3d %\x3d +\x3d -\x3d".split(" "),F=["||","\x26\x26"], C={"||":1,"\x26\x26":2,"|":3,"^":4,"\x26":5,"\x3d\x3d":6,"!\x3d":6,"\x3c":7,"\x3e":7,"\x3c\x3d":7,"\x3e\x3d":7,"\x3c\x3c":8,"\x3e\x3e":8,"\x3e\x3e\x3e":8,"+":9,"-":9,"*":10,"/":10,"%":10},I="Unknown Boolean \x3cend\x3e Identifier Keyword Null Numeric Punctuator String RegularExpression Template".split(" "),f={InvalidModuleUri:"InvalidModuleUri",ForInOfLoopInitializer:"ForInOfLoopInitializer",IdentiferExpected:"IdentiferExpected",InvalidEscapedReservedWord:"InvalidEscapedReservedWord",InvalidExpression:"InvalidExpression", InvalidFunctionIdentifier:"InvalidFunctionIdentifier",InvalidHexEscapeSequence:"InvalidHexEscapeSequence",InvalidLeftHandSideInAssignment:"InvalidLeftHandSideInAssignment",InvalidLeftHandSideInForIn:"InvalidLeftHandSideInForIn",InvalidTemplateHead:"InvalidTemplateHead",InvalidVariableAssignment:"InvalidVariableAssignment",KeyMustBeString:"KeyMustBeString",NoFunctionInsideBlock:"NoFunctionInsideBlock",NoFunctionInsideFunction:"NoFunctionInsideFunction",ModuleExportRootOnly:"ModuleExportRootOnly",ModuleImportRootOnly:"ModuleImportRootOnly", PunctuatorExpected:"PunctuatorExpected",TemplateOctalLiteral:"TemplateOctalLiteral",UnexpectedBoolean:"UnexpectedBoolean",UnexpectedEndOfScript:"UnexpectedEndOfScript",UnexpectedIdentifier:"UnexpectedIdentifier",UnexpectedKeyword:"UnexpectedKeyword",UnexpectedNull:"UnexpectedNull",UnexpectedNumber:"UnexpectedNumber",UnexpectedPunctuator:"UnexpectedPunctuator",UnexpectedString:"UnexpectedString",UnexpectedTemplate:"UnexpectedTemplate",UnexpectedToken:"UnexpectedToken"},y={[f.InvalidModuleUri]:"Module uri must be a text literal.", [f.ForInOfLoopInitializer]:"for-in loop variable declaration may not have an initializer.",[f.IdentiferExpected]:"'${value}' is an invalid identifier.",[f.InvalidEscapedReservedWord]:"Keyword cannot contain escaped characters.",[f.InvalidExpression]:"Invalid expression.",[f.InvalidFunctionIdentifier]:"'${value}' is an invalid function identifier.",[f.InvalidHexEscapeSequence]:"Invalid hexadecimal escape sequence.",[f.InvalidLeftHandSideInAssignment]:"Invalid left-hand side in assignment.",[f.InvalidLeftHandSideInForIn]:"Invalid left-hand side in for-in.", [f.InvalidTemplateHead]:"Invalid template structure.",[f.InvalidVariableAssignment]:"Invalid variable assignment.",[f.KeyMustBeString]:"Object property keys must be a word starting with a letter.",[f.NoFunctionInsideBlock]:"Functions cannot be declared inside of code blocks.",[f.NoFunctionInsideFunction]:"Functions cannot be declared inside another function.",[f.ModuleExportRootOnly]:"Module exports cannot be declared inside of code blocks.",[f.ModuleImportRootOnly]:"Module import cannot be declared inside of code blocks.", [f.PunctuatorExpected]:"'${value}' expected.",[f.TemplateOctalLiteral]:"Octal literals are not allowed in template literals.",[f.UnexpectedBoolean]:"Unexpected boolean literal.",[f.UnexpectedEndOfScript]:"Unexpected end of Arcade expression.",[f.UnexpectedIdentifier]:"Unexpected identifier.",[f.UnexpectedKeyword]:"Unexpected keyword.",[f.UnexpectedNull]:"Unexpected null literal.",[f.UnexpectedNumber]:"Unexpected number.",[f.UnexpectedPunctuator]:"Unexpected ponctuator.",[f.UnexpectedString]:"Unexpected text literal.", [f.UnexpectedTemplate]:"Unexpected quasi '${value}'.",[f.UnexpectedToken]:"Unexpected token '${value}'."},r=class a extends Error{constructor({code:b,index:c,line:d,column:g,len:m=0,description:l,data:n}){super(l??b);this.declaredRootClass="esri.arcade.lib.diagnostic";this.name="ParsingError";this.code=b;this.index=c;this.line=d;this.column=g;this.len=m;this.data=n;this.description=l;this.range={start:{line:d,column:g-1},end:{line:d,column:g+m}};Error.captureStackTrace?.(this,a)}},J=class{constructor(){this.comments= [];this._nodeStack=[];this._newComments=[]}insertInnerComments(a){if(t(a)&&0===a.body.length){var b=[];for(let c=this._newComments.length-1;0<=c;c--){let d=this._newComments[c];a.range[1]>=d.range[0]&&(b.unshift(d),this._newComments.splice(c,1))}b.length&&(a.innerComments=b)}}attachTrailingComments(a){let b=this._nodeStack.at(-1);if(b){if(t(a)&&b.range[0]>=a.range[0]&&b.range[1]<=a.range[1])for(var c=this._newComments.length-1;0<=c;c--){var d=this._newComments[c];d.range[0]>=a.range[0]&&d.range[1]<= a.range[1]&&(b.trailingComments=[...(b.trailingComments??[]),d],this._newComments.splice(c,1))}c=[];if(0=m.range[1]?(c.unshift(m),b.leadingComments.splice(g,1)):a&&"object"==typeof a&&"type"in a&&a.type===e.VariableDeclarator&&!(m&&"object"==typeof m&&"type"in m&&m.type===e.BlockComment)&&(d.unshift(m),b.leadingComments.splice(g,1))}0=== b.leadingComments.length&&delete b.leadingComments;c.length&&(a.leadingComments=c);d.length&&(a.trailingComments=[...d,...(a.trailingComments??[])])}}else{for(b=this._newComments.length-1;0<=b;b--)d=this._newComments[b],a.range[0]>=d.range[0]&&(c.unshift(d),this._newComments.splice(b,1));c.length&&(a.leadingComments=c)}}attachComments(a){if(a&&"object"==typeof a&&"type"in a&&a.type===e.Program&&0a?String.fromCharCode(a):String.fromCharCode(55296+(a-65536>>10))+String.fromCharCode(56320+(a-65536&1023))},isWhiteSpace(a){return 32===a||9===a||11===a||12===a||160===a||5760<=a&&[5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].includes(a)},isLineTerminator(a){return 10===a||13===a||8232===a||8233===a},isIdentifierStart(a){return 36===a||95===a||65<=a&&90>=a||97<=a&&122>=a||92===a||128<=a&&L.test(h.fromCodePoint(a))},isIdentifierPart(a){return 36=== a||95===a||65<=a&&90>=a||97<=a&&122>=a||48<=a&&57>=a||92===a||128<=a&&M.test(h.fromCodePoint(a))},isDecimalDigit(a){return 48<=a&&57>=a},isHexDigit(a){return 48<=a&&57>=a||65<=a&&70>=a||97<=a&&102>=a},isOctalDigit(a){return 48<=a&&55>=a}},q=[[],[],[]];w.forEach(a=>q[a.length-1]?.push(a));D.forEach(a=>q[a.length-1]?.push(a));F.forEach(a=>q[a.length-1]?.push(a));E.forEach(a=>q[a.length-1]?.push(a));"| \x26 \x3e\x3e \x3c\x3c \x3e\x3e\x3e ^ \x3d\x3d !\x3d \x3c \x3c\x3d \x3e \x3e\x3d + - * / %".split(" ").forEach(a=> q[a.length-1]?.push(a));var N=class{constructor(a,b){this.source=a;this.errorHandler=b;this._length=a.length;this.index=0;this.lineNumber=1;this.lineStart=0;this.curlyStack=[]}saveState(){return{index:this.index,lineNumber:this.lineNumber,lineStart:this.lineStart,curlyStack:this.curlyStack.slice()}}restoreState(a){this.index=a.index;this.lineNumber=a.lineNumber;this.lineStart=a.lineStart;this.curlyStack=a.curlyStack}eof(){return this.index>=this._length}throwUnexpectedToken(a=f.UnexpectedToken){this.errorHandler.throwError({code:a, index:this.index,line:this.lineNumber,column:this.index-this.lineStart+1,data:{value:this.source.charAt(this.index)}})}tolerateUnexpectedToken(a=f.UnexpectedToken){this.errorHandler.tolerateError({code:a,index:this.index,line:this.lineNumber,column:this.index-this.lineStart+1})}skipSingleLineComment(a){let b=[],c=this.index-a,d={start:{line:this.lineNumber,column:this.index-this.lineStart-a},end:{line:0,column:0}};for(;!this.eof();){let g=this.source.charCodeAt(this.index);if(this.index+=1,h.isLineTerminator(g))return d.end= {line:this.lineNumber,column:this.index-this.lineStart-1},b.push({multiLine:!1,start:c+a,end:this.index-1,range:[c,this.index-1],loc:d}),13===g&&10===this.source.charCodeAt(this.index)&&(this.index+=1),this.lineNumber+=1,this.lineStart=this.index,b}d.end={line:this.lineNumber,column:this.index-this.lineStart};return b.push({multiLine:!1,start:c+a,end:this.index,range:[c,this.index],loc:d}),b}skipMultiLineComment(){let a=[],b=this.index-2,c={start:{line:this.lineNumber,column:this.index-this.lineStart- 2},end:{line:0,column:0}};for(;!this.eof();){let d=this.source.charCodeAt(this.index);if(h.isLineTerminator(d))13===d&&10===this.source.charCodeAt(this.index+1)&&(this.index+=1),this.lineNumber+=1,this.lineStart=this.index+=1;else{if(42===d&&47===this.source.charCodeAt(this.index+1))return this.index+=2,c.end={line:this.lineNumber,column:this.index-this.lineStart},a.push({multiLine:!0,start:b+2,end:this.index-2,range:[b,this.index],loc:c}),a;this.index+=1}}c.end={line:this.lineNumber,column:this.index- this.lineStart};return a.push({multiLine:!0,start:b+2,end:this.index,range:[b,this.index],loc:c}),this.tolerateUnexpectedToken(),a}scanComments(){let a=[];for(;!this.eof();){var b=this.source.charCodeAt(this.index);if(h.isWhiteSpace(b))this.index+=1;else if(h.isLineTerminator(b))this.index+=1,13===b&&10===this.source.charCodeAt(this.index)&&(this.index+=1),this.lineNumber+=1,this.lineStart=this.index;else if(47===b)if(b=this.source.charCodeAt(this.index+1),47===b)this.index+=2,b=this.skipSingleLineComment(2), a=[...a,...b];else if(42===b)this.index+=2,b=this.skipMultiLineComment(),a=[...a,...b];else break;else break}return a}isKeyword(a){switch(a=a.toLowerCase(),a.length){case 2:return a===k.If||a===k.In;case 3:return a===k.Var||a===k.For;case 4:return a===k.Else;case 5:return a===k.Break||a===k.While;case 6:return a===k.Return||a===k.Import||a===k.Export;case 8:return a===k.Function||a===k.Continue;default:return!1}}codePointAt(a){let b=this.source.charCodeAt(a);55296<=b&&56319>=b&&(a=this.source.charCodeAt(a+ 1),56320<=a&&57343>=a&&(b=1024*(b-55296)+a-56320+65536));return b}scanHexEscape(a){a="u"===a?4:2;let b=0;for(let c=0;cb)return this.index=a,this.getComplexIdentifier();if(h.isIdentifierPart(b))this.index+=1;else break}return this.source.slice(a,this.index)}getComplexIdentifier(){let a=this.codePointAt(this.index),b=h.fromCodePoint(a);this.index+=b.length;let c; for(92===a&&(117!==this.source.charCodeAt(this.index)&&this.throwUnexpectedToken(),this.index+=1,"{"===this.source[this.index]?(this.index+=1,c=this.scanUnicodeCodePointEscape()):(c=this.scanHexEscape("u"),(null===c||"\\"===c||!h.isIdentifierStart(c.charCodeAt(0)))&&this.throwUnexpectedToken()),b=c);!this.eof()&&(a=this.codePointAt(this.index),h.isIdentifierPart(a));)c=h.fromCodePoint(a),b+=c,this.index+=c.length,92===a&&(b=b.substring(0,b.length-1),117!==this.source.charCodeAt(this.index)&&this.throwUnexpectedToken(), this.index+=1,"{"===this.source[this.index]?(this.index+=1,c=this.scanUnicodeCodePointEscape()):(c=this.scanHexEscape("u"),(null===c||"\\"===c||!h.isIdentifierPart(c.charCodeAt(0)))&&this.throwUnexpectedToken()),b+=c);return b}octalToDecimal(a){let b="0"!==a,c="01234567".indexOf(a);return!this.eof()&&h.isOctalDigit(this.source.charCodeAt(this.index))&&(b=!0,c=8*c+"01234567".indexOf(this.source[this.index]??""),this.index+=1,"0123".includes(a)&&!this.eof()&&h.isOctalDigit(this.source.charCodeAt(this.index))&& (c=8*c+"01234567".indexOf(this.source[this.index]??""),this.index+=1)),{code:c,octal:b}}scanIdentifier(){let a,b=this.index,c=92===this.source.charCodeAt(b)?this.getComplexIdentifier():this.getIdentifier();if(1===c.length?a=3:this.isKeyword(c)?a=4:"null"===c.toLowerCase()?a=5:"true"===c.toLowerCase()||"false"===c.toLowerCase()?a=1:a=3,3!==a&&b+c.length!==this.index){let d=this.index;this.index=b;this.tolerateUnexpectedToken(f.InvalidEscapedReservedWord);this.index=d}return{type:a,value:c,lineNumber:this.lineNumber, lineStart:this.lineStart,start:b,end:this.index}}scanPunctuator(){let a=this.index,b=this.source[this.index]??"";switch(b){case "(":case "{":"{"===b&&this.curlyStack.push("{");this.index+=1;break;case ".":this.index+=1;break;case "}":this.index+=1;this.curlyStack.pop();break;case ")":case ";":case ",":case "[":case "]":case ":":case "?":case "~":this.index+=1;break;default:for(let c=q.length;0a&&h.isIdentifierStart(this.codePointAt(this.index))? this.scanIdentifier():this.scanPunctuator()}},O=class{constructor(a,b={},c){this.delegate=c;this.hasLineTerminator=!1;this.options={tokens:"boolean"==typeof b.tokens&&b.tokens,comments:"boolean"==typeof b.comments&&b.comments,tolerant:"boolean"==typeof b.tolerant&&b.tolerant};this.options.comments&&(this.commentHandler=new J);this.errorHandler=new K(this.options.tolerant);this.scanner=new N(a,this.errorHandler);this.context={isAssignmentTarget:!1,blockContext:0,curlyParsingType:0};this.rawToken={type:2, value:"",lineNumber:this.scanner.lineNumber,lineStart:0,start:0,end:0};this.tokens=[];this.startMarker={index:0,line:this.scanner.lineNumber,column:0};this.endMarker={index:0,line:this.scanner.lineNumber,column:0};this.readNextRawToken();this.endMarker={index:this.scanner.index,line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}}throwIfInvalidType(a,b,{validTypes:c,invalidTypes:d}){c?.some(g=>a.type===g)||d?.some(g=>a.type===g)&&this.throwError(f.InvalidExpression,b)}throwError(a, b,c=this.endMarker){let {index:d,line:g,column:m}=b;this.errorHandler.throwError({code:a,index:d,line:g,column:m+1,len:c.index-d-1})}tolerateError(a,b){throw Error("######################################### !!!");}unexpectedTokenError(a={}){let {rawToken:b}=a,{code:c,data:d}=a;if(b){if(!c)switch(b.type){case 2:c=f.UnexpectedEndOfScript;break;case 3:c=f.UnexpectedIdentifier;break;case 6:c=f.UnexpectedNumber;break;case 8:c=f.UnexpectedString;break;case 10:c=f.UnexpectedTemplate}a=b.value.toString()}else a= "ILLEGAL";c??=f.UnexpectedToken;d||={value:a};a=v(c,d);if(b)return new r({code:c,index:b.start,line:b.lineNumber,column:b.start-b.lineStart+1,len:b.end-b.start-1,data:d,description:a});let {index:g,line:m}=this.endMarker;return new r({code:c,index:g,line:m,column:this.endMarker.column+1,data:d,description:a})}throwUnexpectedToken(a={}){throw a.rawToken??(a.rawToken=this.rawToken),this.unexpectedTokenError(a);}collectComments(a){let {commentHandler:b}=this;b&&a.length&&a.forEach(c=>{c={type:c.multiLine? e.BlockComment:e.LineComment,value:this.getSourceValue(c),range:c.range,loc:c.loc};b.collectComment(c)})}peekAhead(a){let b=this.scanner.saveState();a=a.call(this,()=>(this.scanner.scanComments(),this.scanner.lex()));return this.scanner.restoreState(b),a}getSourceValue(a){return this.scanner.source.slice(a.start,a.end)}convertToToken(a){return{type:I[a.type],value:this.getSourceValue(a),range:[a.start,a.end],loc:{start:{line:this.startMarker.line,column:this.startMarker.column},end:{line:this.scanner.lineNumber, column:this.scanner.index-this.scanner.lineStart}}}}readNextRawToken(){this.endMarker.index=this.scanner.index;this.endMarker.line=this.scanner.lineNumber;this.endMarker.column=this.scanner.index-this.scanner.lineStart;let a=this.rawToken;this.collectComments(this.scanner.scanComments());this.scanner.index!==this.startMarker.index&&(this.startMarker.index=this.scanner.index,this.startMarker.line=this.scanner.lineNumber,this.startMarker.column=this.scanner.index-this.scanner.lineStart);this.rawToken= this.scanner.lex();this.hasLineTerminator=a.lineNumber!==this.rawToken.lineNumber;this.options.tokens&&2!==this.rawToken.type&&this.tokens.push(this.convertToToken(this.rawToken))}captureStartMarker(){return{index:this.startMarker.index,line:this.startMarker.line,column:this.startMarker.column}}getItemLocation(a){return{range:[a.index,this.endMarker.index],loc:{start:{line:a.line,column:a.column},end:{line:this.endMarker.line,column:this.endMarker.column}}}}finalize(a){return(this.delegate??this.commentHandler)&& (this.commentHandler?.attachComments(a),this.delegate?.(a)),a}expectPunctuator(a){let b=this.rawToken;this.matchPunctuator(a)?this.readNextRawToken():this.throwUnexpectedToken({rawToken:b,code:f.PunctuatorExpected,data:{value:a}})}expectKeyword(a){4===this.rawToken.type&&this.rawToken.value.toLowerCase()===a.toString()?this.readNextRawToken():this.throwUnexpectedToken({rawToken:this.rawToken})}expectContextualKeyword(a){3===this.rawToken.type&&this.rawToken.value.toLowerCase()===a?this.readNextRawToken(): this.throwUnexpectedToken({rawToken:this.rawToken})}matchKeyword(a){return 4===this.rawToken.type&&this.rawToken.value.toLowerCase()===a}matchContextualKeyword(a){return 3===this.rawToken.type&&this.rawToken.value===a}matchPunctuator(a){return 7===this.rawToken.type&&this.rawToken.value===a}getMatchingPunctuator(a){if("string"==typeof a&&(a=a.split("")),7===this.rawToken.type&&a.length)return a.find(this.matchPunctuator.bind(this))}isolateCoverGrammar(a){let b=this.context.isAssignmentTarget;this.context.isAssignmentTarget= !0;a=a.call(this);return this.context.isAssignmentTarget=b,a}inheritCoverGrammar(a){var b;let c=this.context.isAssignmentTarget;this.context.isAssignmentTarget=!0;a=a.call(this);return(b=this.context).isAssignmentTarget&&(b.isAssignmentTarget=c),a}withBlockContext(a,b){let c=this.context.blockContext;this.context.blockContext|=a;a=this.context.curlyParsingType;this.context.curlyParsingType=1;b=b.call(this);return this.context.blockContext=c,this.context.curlyParsingType=a,b}consumeSemicolon(){this.matchPunctuator(";")? this.readNextRawToken():this.hasLineTerminator||(2===this.rawToken.type||this.matchPunctuator("}")?(this.endMarker.index=this.startMarker.index,this.endMarker.line=this.startMarker.line,this.endMarker.column=this.startMarker.column):this.throwUnexpectedToken({rawToken:this.rawToken}))}parsePrimaryExpression(){let a=this.captureStartMarker(),b=this.rawToken;switch(b.type){case 3:return this.readNextRawToken(),this.finalize({type:e.Identifier,name:b.value,...this.getItemLocation(a)});case 6:case 8:return this.context.isAssignmentTarget= !1,this.readNextRawToken(),this.finalize({type:e.Literal,value:b.value,raw:this.getSourceValue(b),isString:"string"==typeof b.value,...this.getItemLocation(a)});case 1:return this.context.isAssignmentTarget=!1,this.readNextRawToken(),this.finalize({type:e.Literal,value:"true"===b.value.toLowerCase(),raw:this.getSourceValue(b),isString:!1,...this.getItemLocation(a)});case 5:return this.context.isAssignmentTarget=!1,this.readNextRawToken(),this.finalize({type:e.Literal,value:null,raw:this.getSourceValue(b), isString:!1,...this.getItemLocation(a)});case 10:return this.parseTemplateLiteral();case 7:switch(b.value){case "(":return this.inheritCoverGrammar(this.parseGroupExpression.bind(this));case "[":return this.inheritCoverGrammar(this.parseArrayInitializer.bind(this));case "{":return this.inheritCoverGrammar(this.parseObjectExpression.bind(this));default:return this.throwUnexpectedToken({rawToken:this.rawToken})}case 4:return this.context.isAssignmentTarget=!1,this.throwUnexpectedToken({rawToken:this.rawToken}); default:return this.throwUnexpectedToken({rawToken:this.rawToken})}}parseArrayInitializer(){let a=this.captureStartMarker();this.expectPunctuator("[");let b=[];for(;!this.matchPunctuator("]");){let c=this.captureStartMarker();this.matchPunctuator(",")?(this.readNextRawToken(),this.throwError(f.InvalidExpression,c)):(b.push(this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this))),this.matchPunctuator("]")||this.expectPunctuator(","))}return this.expectPunctuator("]"),this.finalize({type:e.ArrayExpression, elements:b,...this.getItemLocation(a)})}parseObjectPropertyKey(){let a=this.captureStartMarker(),b=this.rawToken;switch(b.type){case 8:return this.readNextRawToken(),this.finalize({type:e.Literal,value:b.value,raw:this.getSourceValue(b),isString:!0,...this.getItemLocation(a)});case 3:case 1:case 5:case 4:return this.readNextRawToken(),this.finalize({type:e.Identifier,name:b.value,...this.getItemLocation(a)});default:this.throwError(f.KeyMustBeString,a)}}parseObjectProperty(){let a=this.rawToken,b= this.captureStartMarker(),c=this.parseObjectPropertyKey(),d=!1,g=null;return this.matchPunctuator(":")?(this.readNextRawToken(),g=this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this))):3===a.type?(d=!0,g=this.finalize({type:e.Identifier,name:a.value,...this.getItemLocation(b)})):this.throwUnexpectedToken({rawToken:this.rawToken}),this.finalize({type:e.Property,kind:"init",key:c,value:g,shorthand:d,...this.getItemLocation(b)})}parseObjectExpression(){let a=this.captureStartMarker();this.expectPunctuator("{"); let b=[];for(;!this.matchPunctuator("}");)b.push(this.parseObjectProperty()),this.matchPunctuator("}")||this.expectPunctuator(",");return this.expectPunctuator("}"),this.finalize({type:e.ObjectExpression,properties:b,...this.getItemLocation(a)})}parseTemplateElement(a=!1){var b=this.rawToken;10!==b.type&&this.throwUnexpectedToken({rawToken:b});a&&!b.head&&this.throwUnexpectedToken({code:f.InvalidTemplateHead,rawToken:b});a=this.captureStartMarker();this.readNextRawToken();let {value:c,cooked:d,tail:g}= b;b=this.finalize({type:e.TemplateElement,value:{raw:c,cooked:d},tail:g,...this.getItemLocation(a)});return b.loc.start.column+=1,b.loc.end.column-=g?1:2,b}parseTemplateLiteral(){let a=this.captureStartMarker(),b=[],c=[],d=this.parseTemplateElement(!0);for(c.push(d);!d.tail;)b.push(this.parseExpression()),d=this.parseTemplateElement(),c.push(d);return this.finalize({type:e.TemplateLiteral,quasis:c,expressions:b,...this.getItemLocation(a)})}parseGroupExpression(){this.expectPunctuator("(");let a=this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this)); return this.expectPunctuator(")"),a}parseArguments(){this.expectPunctuator("(");let a=[];if(!this.matchPunctuator(")"))for(;;){let b=this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this));if(a.push(b),this.matchPunctuator(")")||(this.expectPunctuator(","),this.matchPunctuator(")")))break}return this.expectPunctuator(")"),a}parseMemberName(){let a=this.rawToken,b=this.captureStartMarker();return this.readNextRawToken(),5!==a.type&&3!==a.type&&4!==a.type&&1!==a.type&&this.throwUnexpectedToken({rawToken:a}), this.finalize({type:e.Identifier,name:a.value,...this.getItemLocation(b)})}parseLeftHandSideExpression(){let a=this.captureStartMarker(),b=this.inheritCoverGrammar(this.parsePrimaryExpression.bind(this)),c=this.captureStartMarker();for(var d;d=this.getMatchingPunctuator("([.");)switch(d){case "(":this.context.isAssignmentTarget=!1;b.type!==e.Identifier&&b.type!==e.MemberExpression&&this.throwError(f.IdentiferExpected,a,c);d=this.parseArguments();b=this.finalize({type:e.CallExpression,callee:b,arguments:d, ...this.getItemLocation(a)});continue;case "[":this.context.isAssignmentTarget=!0;this.expectPunctuator("[");d=this.isolateCoverGrammar(()=>this.parseExpression());this.expectPunctuator("]");b=this.finalize({type:e.MemberExpression,computed:!0,object:b,property:d,...this.getItemLocation(a)});continue;case ".":this.context.isAssignmentTarget=!0,this.expectPunctuator("."),d=this.parseMemberName(),b=this.finalize({type:e.MemberExpression,computed:!1,object:b,property:d,...this.getItemLocation(a)})}return b}parseUpdateExpression(){let a= this.captureStartMarker(),b=this.getMatchingPunctuator(w);if(b){this.readNextRawToken();var c=this.captureStartMarker(),d=this.inheritCoverGrammar(this.parseUnaryExpression.bind(this));return d.type!==e.Identifier&&d.type!==e.MemberExpression&&d.type!==e.CallExpression&&this.throwError(f.InvalidExpression,c),this.context.isAssignmentTarget||this.tolerateError(f.InvalidLeftHandSideInAssignment,a),this.context.isAssignmentTarget=!1,this.finalize({type:e.UpdateExpression,operator:b,argument:d,prefix:!0, ...this.getItemLocation(a)})}c=this.captureStartMarker();d=this.inheritCoverGrammar(this.parseLeftHandSideExpression.bind(this));let g=this.captureStartMarker();return this.hasLineTerminator||(b=this.getMatchingPunctuator(w),!b)?d:(d.type!==e.Identifier&&d.type!==e.MemberExpression&&this.throwError(f.InvalidExpression,c,g),this.context.isAssignmentTarget||this.tolerateError(f.InvalidLeftHandSideInAssignment,a),this.readNextRawToken(),this.context.isAssignmentTarget=!1,this.finalize({type:e.UpdateExpression, operator:b,argument:d,prefix:!1,...this.getItemLocation(a)}))}parseUnaryExpression(){let a=this.getMatchingPunctuator(D);if(a){let b=this.captureStartMarker();this.readNextRawToken();let c=this.inheritCoverGrammar(this.parseUnaryExpression.bind(this));return this.context.isAssignmentTarget=!1,this.finalize({type:e.UnaryExpression,operator:a,argument:c,prefix:!0,...this.getItemLocation(b)})}return this.parseUpdateExpression()}parseBinaryExpression(){var a=this.rawToken,b=this.inheritCoverGrammar(this.parseUnaryExpression.bind(this)); if(7!==this.rawToken.type)return b;var c=this.rawToken.value,d=B(c);if(0===d)return b;this.readNextRawToken();this.context.isAssignmentTarget=!1;a=[a,this.rawToken];var g=this.inheritCoverGrammar(this.parseUnaryExpression.bind(this));c=[b,c,g];for(var m=[d];7===this.rawToken.type&&0<(d=B(this.rawToken.value));){for(;2{let b=a();return!(3!==b.type&&8!==b.type||(b=a(),7!==b.type||":"!==b.value))})?this.parseObjectStatement():this.parseBlock()}parseIdentifier(){let a= this.rawToken;if(3!==a.type)return null;let b=this.captureStartMarker();return this.readNextRawToken(),this.finalize({type:e.Identifier,name:a.value,...this.getItemLocation(b)})}parseVariableDeclarator(){let a=this.captureStartMarker(),b=this.parseIdentifier();b||this.throwUnexpectedToken({code:f.IdentiferExpected});let c=null;if(this.matchPunctuator("\x3d")){this.readNextRawToken();let d=this.rawToken;try{c=this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this))}catch{this.throwUnexpectedToken({rawToken:d, code:f.InvalidVariableAssignment})}}return this.finalize({type:e.VariableDeclarator,id:b,init:c,...this.getItemLocation(a)})}parseVariableDeclarationList(){let a=[this.parseVariableDeclarator()];for(;this.matchPunctuator(",");)this.readNextRawToken(),a.push(this.parseVariableDeclarator());return a}parseVariableDeclaration(){let a=this.captureStartMarker();this.expectKeyword(k.Var);let b=this.parseVariableDeclarationList();return this.consumeSemicolon(),this.finalize({type:e.VariableDeclaration,declarations:b, kind:"var",...this.getItemLocation(a)})}parseEmptyStatement(){let a=this.captureStartMarker();return this.expectPunctuator(";"),this.finalize({type:e.EmptyStatement,...this.getItemLocation(a)})}parseExpressionStatement(){let a=this.captureStartMarker(),b=this.parseExpression();return this.consumeSemicolon(),this.finalize({type:e.ExpressionStatement,expression:b,...this.getItemLocation(a)})}parseIfClause(){return this.withBlockContext(2,this.parseStatement.bind(this))}parseIfStatement(){let a=this.captureStartMarker(); this.expectKeyword(k.If);this.expectPunctuator("(");var b=this.captureStartMarker();let c=this.parseExpression();var d=this.captureStartMarker();this.expectPunctuator(")");c.type!==e.AssignmentExpression&&c.type!==e.UpdateExpression||this.throwError(f.InvalidExpression,b,d);b=this.parseIfClause();d=null;return this.matchKeyword(k.Else)&&(this.readNextRawToken(),d=this.parseIfClause()),this.finalize({type:e.IfStatement,test:c,consequent:b,alternate:d,...this.getItemLocation(a)})}parseWhileStatement(){let a= this.captureStartMarker();this.expectKeyword(k.While);this.expectPunctuator("(");var b=this.captureStartMarker();let c=this.parseExpression(),d=this.captureStartMarker();this.expectPunctuator(")");c.type!==e.AssignmentExpression&&c.type!==e.UpdateExpression||this.throwError(f.InvalidExpression,b,d);b=this.withBlockContext(8,this.parseStatement.bind(this));return this.finalize({type:e.WhileStatement,test:c,body:b,...this.getItemLocation(a)})}parseForStatement(){let a=null,b=null,c=null,d=null,g=null, m=this.captureStartMarker();if(this.expectKeyword(k.For),this.expectPunctuator("("),this.matchPunctuator(";"))this.readNextRawToken();else if(this.matchKeyword(k.Var)){var l=this.captureStartMarker();this.readNextRawToken();var n=this.parseVariableDeclarationList();1===n.length&&this.matchKeyword(k.In)?(n[0].init&&this.throwError(f.ForInOfLoopInitializer,l),d=this.finalize({type:e.VariableDeclaration,declarations:n,kind:"var",...this.getItemLocation(l)}),this.readNextRawToken(),g=this.parseExpression()): (this.matchKeyword(k.In)&&this.throwError(f.InvalidLeftHandSideInForIn,l),a=this.finalize({type:e.VariableDeclaration,declarations:n,kind:"var",...this.getItemLocation(l)}),this.expectPunctuator(";"))}else l=this.context.isAssignmentTarget,n=this.captureStartMarker(),a=this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this)),this.matchKeyword(k.In)?(this.context.isAssignmentTarget||this.tolerateError(f.InvalidLeftHandSideInForIn,n),a.type!==e.Identifier&&this.throwError(f.InvalidLeftHandSideInForIn, n),this.readNextRawToken(),d=a,g=this.parseExpression(),a=null):(this.context.isAssignmentTarget=l,this.expectPunctuator(";"));d||(this.matchPunctuator(";")||(b=this.isolateCoverGrammar(this.parseExpression.bind(this))),this.expectPunctuator(";"),this.matchPunctuator(")")||(c=this.isolateCoverGrammar(this.parseExpression.bind(this))));this.expectPunctuator(")");l=this.withBlockContext(4,()=>this.isolateCoverGrammar(this.parseStatement.bind(this)));return d&&g?this.finalize({type:e.ForInStatement, left:d,right:g,body:l,...this.getItemLocation(m)}):this.finalize({type:e.ForStatement,init:a,test:b,update:c,body:l,...this.getItemLocation(m)})}parseContinueStatement(){let a=this.captureStartMarker();return this.expectKeyword(k.Continue),this.consumeSemicolon(),this.finalize({type:e.ContinueStatement,...this.getItemLocation(a)})}parseBreakStatement(){let a=this.captureStartMarker();return this.expectKeyword(k.Break),this.consumeSemicolon(),this.finalize({type:e.BreakStatement,...this.getItemLocation(a)})}parseReturnStatement(){let a= this.captureStartMarker();this.expectKeyword(k.Return);let b=(this.matchPunctuator(";")||this.matchPunctuator("}")||this.hasLineTerminator||2===this.rawToken.type)&&8!==this.rawToken.type&&10!==this.rawToken.type?null:this.parseExpression();return this.consumeSemicolon(),this.finalize({type:e.ReturnStatement,argument:b,...this.getItemLocation(a)})}parseStatement(){switch(this.rawToken.type){case 1:case 5:case 6:case 8:case 10:case 3:return this.parseExpressionStatement();case 7:return"{"===this.rawToken.value? this.parseBlockOrObjectStatement():"("===this.rawToken.value?this.parseExpressionStatement():";"===this.rawToken.value?this.parseEmptyStatement():this.parseExpressionStatement();case 4:switch(this.rawToken.value.toLowerCase()){case k.Break:return this.parseBreakStatement();case k.Continue:return this.parseContinueStatement();case k.For:return this.parseForStatement();case k.Function:return this.parseFunctionDeclaration();case k.If:return this.parseIfStatement();case k.Return:return this.parseReturnStatement(); case k.Var:return this.parseVariableDeclaration();case k.While:return this.parseWhileStatement();default:return this.parseExpressionStatement()}default:return this.throwUnexpectedToken({rawToken:this.rawToken})}}parseFormalParameters(){let a=[];if(this.expectPunctuator("("),!this.matchPunctuator(")"))for(;2!==this.rawToken.type;){let b=this.parseIdentifier();if(b||this.throwUnexpectedToken({rawToken:this.rawToken,code:f.IdentiferExpected}),a.push(b),this.matchPunctuator(")")||(this.expectPunctuator(","), this.matchPunctuator(")")))break}return this.expectPunctuator(")"),a}parseFunctionDeclaration(){1===(this.context.blockContext&1)&&this.throwUnexpectedToken({code:f.NoFunctionInsideFunction});8!==(this.context.blockContext&8)&&2!==(this.context.blockContext&2)||this.throwUnexpectedToken({code:f.NoFunctionInsideBlock});let a=this.captureStartMarker();this.expectKeyword(k.Function);let b=this.parseIdentifier();b||this.throwUnexpectedToken({code:f.InvalidFunctionIdentifier});let c=this.parseFormalParameters(), d=this.context.blockContext;this.context.blockContext|=1;let g=this.parseBlock();return this.context.blockContext=d,this.finalize({type:e.FunctionDeclaration,id:b,params:c,body:g,...this.getItemLocation(a)})}parseScript(){var a=this.captureStartMarker();let b=this.parseStatements();a=this.finalize({type:e.Program,body:b,...this.getItemLocation(a)});return this.options.tokens&&(a.tokens=this.tokens),this.options.tolerant&&(a.errors=this.errorHandler.errors),a}parseExportDeclaration(){0!==this.context.blockContext&& this.throwUnexpectedToken({code:f.ModuleExportRootOnly});let a=null,b=this.captureStartMarker();return this.expectKeyword(k.Export),this.matchKeyword(k.Var)?a=this.parseVariableDeclaration():this.matchKeyword("function")?a=this.parseFunctionDeclaration():this.throwUnexpectedToken({code:f.InvalidExpression}),this.finalize({type:e.ExportNamedDeclaration,declaration:a,specifiers:[],source:null,...this.getItemLocation(b)})}parseModuleSpecifier(){let a=this.captureStartMarker(),b=this.rawToken;if(8=== b.type)return this.readNextRawToken(),this.finalize({type:e.Literal,value:b.value,raw:this.getSourceValue(b),isString:!0,...this.getItemLocation(a)});this.throwError(f.InvalidModuleUri,a)}parseDefaultSpecifier(){let a=this.captureStartMarker(),b=this.parseIdentifier();return b||this.throwUnexpectedToken({code:f.IdentiferExpected}),this.finalize({type:e.ImportDefaultSpecifier,local:b,...this.getItemLocation(a)})}parseImportDeclaration(){0!==this.context.blockContext&&this.throwUnexpectedToken({code:f.ModuleImportRootOnly}); let a=this.captureStartMarker();this.expectKeyword(k.Import);let b=this.parseDefaultSpecifier();this.expectContextualKeyword(k.From);let c=this.parseModuleSpecifier();return this.finalize({type:e.ImportDeclaration,specifiers:[b],source:c,...this.getItemLocation(a)})}};p.Ee=function(a){return!!a&&"object"==typeof a&&"type"in a&&a.type===e.VariableDeclaration};p.Q=x;p.T=r;p.i=e;p.j=t;p.ke=function(a){return!!a&&"object"==typeof a&&"type"in a&&a.type===e.Identifier};p.l=k;p.o=f;p.q=y;p.rt=function(a, b,c){return(new O(a,b,c)).parseScript()}});