@lostcityrs/runescript 0.9.3 → 0.9.5

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.
@@ -1,14 +1,13 @@
1
- import{existsSync as D5,readFileSync as B5}from"fs";import{join as w5,resolve as Y2}from"path";import{exit as l6}from"process";class N{representation;static ACTIVE_PLAYER=new N("active_player");static ACTIVE_PLAYER2=new N(".active_player");static P_ACTIVE_PLAYER=new N("p_active_player");static P_ACTIVE_PLAYER2=new N(".p_active_player");static ACTIVE_NPC=new N("active_npc");static ACTIVE_NPC2=new N(".active_npc");static ACTIVE_LOC=new N("active_loc");static ACTIVE_LOC2=new N(".active_loc");static ACTIVE_OBJ=new N("active_obj");static ACTIVE_OBJ2=new N(".active_obj");static FIND_PLAYER=new N("find_player");static FIND_NPC=new N("find_npc");static FIND_LOC=new N("find_loc");static FIND_OBJ=new N("find_obj");static FIND_DB=new N("find_db");static LAST_COM=new N("last_com");static LAST_INT=new N("last_int");static LAST_ITEM=new N("last_item");static LAST_SLOT=new N("last_slot");static LAST_TARGETSLOT=new N("last_targetslot");static LAST_USEITEM=new N("last_useitem");static LAST_USESLOT=new N("last_useslot");static ALL=Object.values(N).filter((_)=>_ instanceof N);static NAME_TO_TYPE=N.ALL.reduce((_,A)=>{return _[A.getName().toLowerCase()]=A,_},{});constructor(_){this.representation=_}getName(){for(let _ of Object.keys(N))if(N[_]===this)return _;return""}static forName(_){return this.NAME_TO_TYPE[_.toLowerCase()]}}class v0{trigger;name;parameters;returns;constructor(_,A,R,U){this.trigger=_;this.name=A;this.parameters=R;this.returns=U}pointers(_){return _.getPointers(this)}}class x1 extends v0{}class K{constructor(){}static None=new class extends K{};static Name=new class extends K{};static Type(_,A=!0,R=!0){return new class extends K{type=_;category=A;global=R}}}var N0={id:-1,identifier:"command",subjectMode:K.Name,allowParameters:!0,parameters:null,allowReturns:!0,returns:null,pointers:null};class g2{commands=new Map;scripts=new Map;symbols=new Map;putSymbol(_,A){if(this.symbols.has(A)){if(A.context?.diagnostics)A.context.diagnostics.report(`Duplicate symbol: ${A}.`);return}this.symbols.set(A,_)}putCommand(_,A){if(this.commands.has(A))return;this.commands.set(A,_)}putScript(_,A){if(this.scripts.has(A))return;this.scripts.set(A,_)}get(_){if(_ instanceof v0)if(_.trigger===N0){let R=_.name.substring(_.name.indexOf(".")+1),U=this.commands.get(R);if(U===void 0){if(_.context?.diagnostics)_.context.diagnostics.report(`Unable to find id for '${_}'.`);return-1}return U}else{let R=`[${_.trigger.identifier},${_.name}]`,U=this.scripts.get(R);if(U===void 0){if(_.context?.diagnostics)_.context.diagnostics.report(`Unable to find id for '${_}'.`);return-1}return U}let A=this.symbols.get(_);if(A===void 0)throw Error(`Unable to find id for '${_}'.`);return A}}import*as i from"fs";import*as l1 from"path";class H{constructor(){}static PushConstantInt=new H;static PushConstantString=new H;static PushConstantLong=new H;static PushConstantSymbol=new H;static PushLocalVar=new H;static PopLocalVar=new H;static PushVar=new H;static PushVar2=new H;static PopVar=new H;static PopVar2=new H;static DefineArray=new H;static Switch=new H;static Branch=new H;static BranchNot=new H;static BranchEquals=new H;static BranchLessThan=new H;static BranchGreaterThan=new H;static BranchLessThanOrEquals=new H;static BranchGreaterThanOrEquals=new H;static LongBranchNot=new H;static LongBranchEquals=new H;static LongBranchLessThan=new H;static LongBranchGreaterThan=new H;static LongBranchLessThanOrEquals=new H;static LongBranchGreaterThanOrEquals=new H;static ObjBranchNot=new H;static ObjBranchEquals=new H;static JoinString=new H;static Discard=new H;static Gosub=new H;static Jump=new H;static Command=new H;static Return=new H;static Add=new H;static Sub=new H;static Multiply=new H;static Divide=new H;static Modulo=new H;static Or=new H;static And=new H;static LongAdd=new H;static LongSub=new H;static LongMultiply=new H;static LongDivide=new H;static LongModulo=new H;static LongOr=new H;static LongAnd=new H;static LineNumber=new H}class I0{name;type;constructor(_,A){this.name=_;this.type=A}}class _0{name;type;isProtected;constructor(_,A,R=!1){this.name=_;this.type=A;this.isProtected=R}}class W1{name;value;constructor(_,A){this.name=_;this.value=A}}class l{allowSwitch=!0;allowArray=!0;allowDeclaration=!0;constructor(_){if(_)Object.assign(this,_)}}class q{name;representation;baseType=0;defaultValue=-1;options=new l({allowSwitch:!1,allowArray:!1,allowDeclaration:!1});constructor(_){this.name=_;this.representation=_.toLowerCase()}get code(){throw Error("MetaType has no character representation.")}static Any=new q("any");static Nothing=new q("nothing");static Error=new q("error");static Unit=new q("unit");static Type=class extends q{inner;constructor(_){super("type");this.inner=_,this.representation=`type<${_.representation}>`}};static Script=class extends q{trigger;parameterType;returnType;constructor(_,A,R){super("script");this.trigger=_,this.parameterType=A,this.returnType=R,this.representation=_.identifier}};static Hook=class extends q{transmitListType;constructor(_){super("hook");this.transmitListType=_,this.representation=`hook<${_.representation}>`}}}class m1{representation;code;baseType;defaultValue;options}class w extends m1{code;baseType;defaultValue;constructor(_,A,R,U,Y){super();this.code=A;this.baseType=R;this.defaultValue=U;this.representation=_.toLowerCase();let X=new l;Y?.(X),this.options=X}static INT=new w("INT","i",0,0);static BOOLEAN=new w("BOOLEAN","1",0,0);static COORD=new w("COORD","c",0,-1);static STRING=new w("STRING","s",1,"",(_)=>{_.allowArray=!1,_.allowSwitch=!1});static CHAR=new w("CHAR","z",0,-1);static LONG=new w("LONG","Ï",2,-1,(_)=>{_.allowArray=!1,_.allowSwitch=!1});static MAPZONE=new w("MAPZONE","0",0,-1);static ALL=[w.INT,w.BOOLEAN,w.COORD,w.STRING,w.CHAR,w.LONG,w.MAPZONE];static byRepresentation(_){return w.ALL.find((A)=>A.representation===_)}}class a{inner;options=new l({allowArray:!1,allowDeclaration:!0,allowSwitch:!0});constructor(_){if(_ instanceof a)throw Error("ArrayType cannot wrap another ArrayType.");this.inner=_}get representation(){return`${this.inner.representation}array`}get code(){throw Error("ArrayType has no character representation.")}get baseType(){return 0}get defaultValue(){throw Error("ArrayType hass no default value.")}toString(){return`ArrayType{inner=${this.inner}}`}}class y0{code=void 0;baseType=0;defaultValue=-1;options=new l({allowArray:!1,allowDeclaration:!1,allowSwitch:!1})}class J0 extends y0{inner;representation;constructor(_){super();this.inner=_;this.representation=`varp<${_.representation}>`}}class H0 extends y0{inner;representation;constructor(_){super();this.inner=_;this.representation=`varbit<${_.representation}>`}}class W0 extends y0{inner;representation;constructor(_){super();this.inner=_;this.representation=`varn<${_.representation}>`}}class q1 extends y0{inner;representation;constructor(_){super();this.inner=_;this.representation=`vars<${_.representation}>`}}class R0{idProvider;constructor(_){this.idProvider=_}write(_){let A=this.createContext(_);for(let R of _.blocks){this.enterBlock(A,R);for(let U of R.instructions)this.writeInstruction(A,U),A.curIndex++}this.finishWrite(_,A)}close(){}writeInstruction(_,A){let{opcode:R,operand:U}=A;switch(R){case H.PushConstantInt:this.writePushConstantInt(_,U);break;case H.PushConstantString:this.writePushConstantString(_,U);break;case H.PushConstantLong:this.writePushConstantLong(_,U);break;case H.PushConstantSymbol:this.writePushConstantSymbol(_,U);break;case H.PushLocalVar:this.writePushLocalVar(_,U);break;case H.PopLocalVar:this.writePopLocalVar(_,U);break;case H.PushVar:this.writePushVar(_,U,!1);break;case H.PushVar2:this.writePushVar(_,U,!0);break;case H.PopVar:this.writePopVar(_,U,!1);break;case H.PopVar2:this.writePopVar(_,U,!0);break;case H.DefineArray:this.writeDefineArray(_,U);break;case H.Switch:this.writeSwitch(_,U);break;case H.Branch:case H.BranchNot:case H.BranchEquals:case H.BranchLessThan:case H.BranchGreaterThan:case H.BranchLessThanOrEquals:case H.BranchGreaterThanOrEquals:case H.LongBranchNot:case H.LongBranchEquals:case H.LongBranchLessThan:case H.LongBranchGreaterThan:case H.LongBranchLessThanOrEquals:case H.LongBranchGreaterThanOrEquals:case H.ObjBranchNot:case H.ObjBranchEquals:this.writeBranch(_,R,U);break;case H.JoinString:this.writeJoinString(_,U);break;case H.Discard:this.writeDiscard(_,U);break;case H.Gosub:this.writeGosub(_,U);break;case H.Jump:this.writeJump(_,U);break;case H.Command:this.writeCommand(_,U);break;case H.Return:this.writeReturn(_);break;case H.Add:case H.Sub:case H.Multiply:case H.Divide:case H.Modulo:case H.Or:case H.And:case H.LongAdd:case H.LongSub:case H.LongMultiply:case H.LongDivide:case H.LongModulo:case H.LongOr:case H.LongAnd:this.writeMath(_,R);break;case H.LineNumber:throw Error("LineNumber opcode should not exist.")}}enterBlock(_,A){throw Error("Not implemented")}writePushConstantInt(_,A){throw Error("Not implemented")}writePushConstantString(_,A){throw Error("Not implemented")}writePushConstantLong(_,A){throw Error("Not implemented")}writePushConstantSymbol(_,A){throw Error("Not implemented")}writePushLocalVar(_,A){throw Error("Not implemented")}writePopLocalVar(_,A){throw Error("Not implemented")}writePushVar(_,A,R){throw Error("Not implemented")}writePopVar(_,A,R){throw Error("Not implemented")}writeDefineArray(_,A){throw Error("Not implemented")}writeSwitch(_,A){throw Error("Not implemented")}writeBranch(_,A,R){throw Error("Not implemented")}writeJoinString(_,A){throw Error("Not implemented")}writeDiscard(_,A){throw Error("Not implemented")}writeJump(_,A){throw Error("Not implemented")}writeGosub(_,A){throw Error("Not implemented")}writeCommand(_,A){throw Error("Not implemented")}writeReturn(_){throw Error("Not implemented")}writeMath(_,A){throw Error("Not implemented")}static generateLineNumberTable(_){let A=new Map,R=0,U=-1;for(let Y of _.blocks)for(let X of Y.instructions){let G=X.source?.line;if(G!==void 0&&G!==U)A.set(R,G),U=G;R++}return A}static generateJumpTable(_){let A=new Map,R=0;for(let U of _.blocks)A.set(U.label,R),R+=U.instructions.length;return A}static getParameterCount(_,A){return _.parameters.filter((R)=>R.type.baseType===A).length}static getLocalCount(_,A){return _.all.filter((R)=>R.type.baseType===A&&(!(R.type instanceof a)||_.parameters.includes(R))).length}static getVariableId(_,A){if(A.type instanceof a)return _.all.filter((R)=>R.type instanceof a).indexOf(A);return _.all.filter((R)=>R.type.baseType===A.type.baseType&&(!(R.type instanceof a)||_.parameters.includes(R))).indexOf(A)}}class d2{script;curIndex=0;lineNumberTable;jumpTable;constructor(_){this.script=_;this.lineNumberTable=R0.generateLineNumberTable(_),this.jumpTable=R0.generateJumpTable(_)}close(){}}class L{id;largeOperand;constructor(_,A=!1){this.id=_;this.largeOperand=A}static PUSH_CONSTANT_INT=new L(0,!0);static PUSH_VARP=new L(1,!0);static POP_VARP=new L(2,!0);static PUSH_CONSTANT_STRING=new L(3,!0);static PUSH_VARN=new L(4,!0);static POP_VARN=new L(5,!0);static BRANCH=new L(6,!0);static BRANCH_NOT=new L(7,!0);static BRANCH_EQUALS=new L(8,!0);static BRANCH_LESS_THAN=new L(9,!0);static BRANCH_GREATER_THAN=new L(10,!0);static PUSH_VARS=new L(11,!0);static POP_VARS=new L(12,!0);static RETURN=new L(21);static GOSUB=new L(22);static JUMP=new L(23);static SWITCH=new L(24,!0);static PUSH_VARBIT=new L(25,!0);static POP_VARBIT=new L(27,!0);static BRANCH_LESS_THAN_OR_EQUALS=new L(31,!0);static BRANCH_GREATER_THAN_OR_EQUALS=new L(32,!0);static PUSH_INT_LOCAL=new L(33,!0);static POP_INT_LOCAL=new L(34,!0);static PUSH_STRING_LOCAL=new L(35,!0);static POP_STRING_LOCAL=new L(36,!0);static JOIN_STRING=new L(37,!0);static POP_INT_DISCARD=new L(38);static POP_STRING_DISCARD=new L(39);static GOSUB_WITH_PARAMS=new L(40,!0);static JUMP_WITH_PARAMS=new L(41,!0);static DEFINE_ARRAY=new L(44,!0);static PUSH_ARRAY_INT=new L(45,!0);static POP_ARRAY_INT=new L(46,!0);static ADD=new L(4600);static SUB=new L(4601);static MULTIPLY=new L(4602);static DIVIDE=new L(4603);static MODULO=new L(4611);static AND=new L(4614);static OR=new L(4615);static ALL=[L.PUSH_CONSTANT_INT,L.PUSH_VARP,L.POP_VARP,L.PUSH_CONSTANT_STRING,L.PUSH_VARN,L.POP_VARN,L.BRANCH,L.BRANCH_NOT,L.BRANCH_EQUALS,L.BRANCH_LESS_THAN,L.BRANCH_GREATER_THAN,L.PUSH_VARS,L.POP_VARS,L.RETURN,L.GOSUB,L.JUMP,L.SWITCH,L.PUSH_VARBIT,L.POP_VARBIT,L.BRANCH_LESS_THAN_OR_EQUALS,L.BRANCH_GREATER_THAN_OR_EQUALS,L.PUSH_INT_LOCAL,L.POP_INT_LOCAL,L.PUSH_STRING_LOCAL,L.POP_STRING_LOCAL,L.JOIN_STRING,L.POP_INT_DISCARD,L.POP_STRING_DISCARD,L.GOSUB_WITH_PARAMS,L.JUMP_WITH_PARAMS,L.DEFINE_ARRAY,L.PUSH_ARRAY_INT,L.POP_ARRAY_INT,L.ADD,L.SUB,L.MULTIPLY,L.DIVIDE,L.MODULO,L.AND,L.OR]}class $ extends m1{static ALL=[];constructor(_,A=0,R=-1,U){super();this.code=_,this.baseType=A,this.defaultValue=R,this.representation=U,this.options=new l,$.ALL.push(this)}static SEQ=new $("A",0,-1,"seq");static LOC_SHAPE=new $("H",0,-1,"locshape");static COMPONENT=new $("I",0,-1,"component");static IDKIT=new $("K",0,-1,"idkit");static MIDI=new $("M",0,-1,"midi");static NPC_MODE=new $("N",0,-1,"npc_mode");static NAMEDOBJ=new $("O",0,-1,"namedobj");static SYNTH=new $("P",0,-1,"synth");static AREA=new $("R",0,-1,"area");static STAT=new $("S",0,-1,"stat");static NPC_STAT=new $("T",0,-1,"npc_stat");static WRITEINV=new $("V",0,-1,"writeinv");static MAPAREA=new $("`",0,-1,"wma");static GRAPHIC=new $("d",0,-1,"graphic");static FONTMETRICS=new $("f",0,-1,"fontmetrics");static ENUM=new $("g",0,-1,"enum");static HUNT=new $("h",0,-1,"hunt");static JINGLE=new $("j",0,-1,"jingle");static LOC=new $("l",0,-1,"loc");static MODEL=new $("m",0,-1,"model");static NPC=new $("n",0,-1,"npc");static OBJ=new $("o",0,-1,"obj");static PLAYER_UID=new $("p",0,-1,"player_uid");static SPOTANIM=new $("t",0,-1,"spotanim");static NPC_UID=new $("u",0,-1,"npc_uid");static INV=new $("v",0,-1,"inv");static TEXTURE=new $("x",0,-1,"texture");static CATEGORY=new $("y",0,-1,"category");static MAPELEMENT=new $("µ",0,-1,"mapelement");static HITMARK=new $("×",0,-1,"hitmark");static STRUCT=new $("J",0,-1,"struct");static DBROW=new $("Ð",0,-1,"dbrow");static INTERFACE=new $("a",0,-1,"interface");static TOPLEVELINTERFACE=new $("F",0,-1,"toplevelinterface");static OVERLAYINTERFACE=new $("L",0,-1,"overlayinterface");static MOVESPEED=new $("Ý",0,-1,"movespeed");static ENTITYOVERLAY=new $("-",0,-1,"entityoverlay");static DBTABLE=new $("Ø",0,-1,"dbtable");static STRINGVECTOR=new $("¸",0,-1,"stringvector");static MESANIM=new $("Á",0,-1,"mesanim");static VERIFY_OBJECT=new $("®",0,-1,"verifyobj")}class O{children;representation;code=null;baseType=null;defaultValue=null;options=new l({allowArray:!1,allowSwitch:!1,allowDeclaration:!1});constructor(..._){let A=O.flatten(_);if(A.length<2)throw Error("TupleType should not be used when type count is < 2");this.children=A,this.representation=this.children.map((R)=>R.representation).join(",")}static fromList(_){if(!_||_.length===0)return q.Unit;if(_.length===1)return _[0];return new O(..._)}static toList(_){if(!_||_===q.Unit||_===q.Nothing)return[];if(_ instanceof O)return _.children;return[_]}static flatten(_){let A=[];for(let R of _)if(R instanceof O)A.push(...R.children);else A.push(R);return A}}class z{static ALL=[];id;subjectMode;allowParameters;parameters;allowReturns;returns;pointers;identifier;constructor({id:_,name:A,subjectMode:R,allowParameters:U=!1,parameters:Y=null,allowReturns:X=!1,returns:G=null,pointers:Q=null}){if(this.id=_,R==null)this.subjectMode=K.Name;else this.subjectMode=R;this.allowParameters=U,this.parameters=Y,this.allowReturns=X,this.returns=G,this.pointers=Q??null,this.identifier=A.toLowerCase(),z.ALL.push(this)}static PROC=new z({id:0,name:"PROC",subjectMode:K.Name,allowParameters:!0,allowReturns:!0,pointers:new Set(Object.values(N))});static LABEL=new z({id:1,name:"LABEL",subjectMode:K.Name,allowParameters:!0,pointers:new Set(Object.values(N))});static DEBUGPROC=new z({id:2,name:"DEBUGPROC",subjectMode:K.Name,allowParameters:!0,pointers:new Set([N.ACTIVE_PLAYER])});static APNPC1=new z({id:3,name:"APNPC1",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_NPC])});static APNPC2=new z({id:4,name:"APNPC2",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_NPC])});static APNPC3=new z({id:5,name:"APNPC3",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_NPC])});static APNPC4=new z({id:6,name:"APNPC4",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_NPC])});static APNPC5=new z({id:7,name:"APNPC5",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_NPC])});static APNPCU=new z({id:8,name:"APNPCU",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_USEITEM,N.LAST_USESLOT,N.ACTIVE_NPC])});static APNPCT=new z({id:9,name:"APNPCT",subjectMode:K.Type($.COMPONENT,!1,!1),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_NPC])});static OPNPC1=new z({id:10,name:"OPNPC1",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_NPC])});static OPNPC2=new z({id:11,name:"OPNPC2",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_NPC])});static OPNPC3=new z({id:12,name:"OPNPC3",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_NPC])});static OPNPC4=new z({id:13,name:"OPNPC4",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_NPC])});static OPNPC5=new z({id:14,name:"OPNPC5",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_NPC])});static OPNPCU=new z({id:15,name:"OPNPCU",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_USEITEM,N.LAST_USESLOT,N.ACTIVE_NPC])});static OPNPCT=new z({id:16,name:"OPNPCT",subjectMode:K.Type($.COMPONENT,!1,!1),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_NPC])});static AI_APNPC1=new z({id:17,name:"AI_APNPC1",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_NPC2])});static AI_APNPC2=new z({id:18,name:"AI_APNPC2",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_NPC2])});static AI_APNPC3=new z({id:19,name:"AI_APNPC3",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_NPC2])});static AI_APNPC4=new z({id:20,name:"AI_APNPC4",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_NPC2])});static AI_APNPC5=new z({id:21,name:"AI_APNPC5",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_NPC2])});static AI_OPNPC1=new z({id:24,name:"AI_OPNPC1",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_NPC2])});static AI_OPNPC2=new z({id:25,name:"AI_OPNPC2",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_NPC2])});static AI_OPNPC3=new z({id:26,name:"AI_OPNPC3",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_NPC2])});static AI_OPNPC4=new z({id:27,name:"AI_OPNPC4",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_NPC2])});static AI_OPNPC5=new z({id:28,name:"AI_OPNPC5",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_NPC2])});static APOBJ1=new z({id:31,name:"APOBJ1",subjectMode:K.Type($.NAMEDOBJ),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_OBJ])});static APOBJ2=new z({id:32,name:"APOBJ2",subjectMode:K.Type($.NAMEDOBJ),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_OBJ])});static APOBJ3=new z({id:33,name:"APOBJ3",subjectMode:K.Type($.NAMEDOBJ),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_OBJ])});static APOBJ4=new z({id:34,name:"APOBJ4",subjectMode:K.Type($.NAMEDOBJ),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_OBJ])});static APOBJ5=new z({id:35,name:"APOBJ5",subjectMode:K.Type($.NAMEDOBJ),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_OBJ])});static APOBJU=new z({id:36,name:"APOBJU",subjectMode:K.Type($.NAMEDOBJ),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_USEITEM,N.LAST_USESLOT,N.ACTIVE_OBJ])});static APOBJT=new z({id:37,name:"APOBJT",subjectMode:K.Type($.COMPONENT,!1,!1),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_OBJ])});static OPOBJ1=new z({id:38,name:"OPOBJ1",subjectMode:K.Type($.NAMEDOBJ),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_OBJ])});static OPOBJ2=new z({id:39,name:"OPOBJ2",subjectMode:K.Type($.NAMEDOBJ),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_OBJ])});static OPOBJ3=new z({id:40,name:"OPOBJ3",subjectMode:K.Type($.NAMEDOBJ),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_OBJ])});static OPOBJ4=new z({id:41,name:"OPOBJ4",subjectMode:K.Type($.NAMEDOBJ),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_OBJ])});static OPOBJ5=new z({id:42,name:"OPOBJ5",subjectMode:K.Type($.NAMEDOBJ),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_OBJ])});static OPOBJU=new z({id:43,name:"OPOBJU",subjectMode:K.Type($.NAMEDOBJ),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_USEITEM,N.LAST_USESLOT,N.ACTIVE_OBJ])});static OPOBJT=new z({id:44,name:"OPOBJT",subjectMode:K.Type($.COMPONENT,!1,!1),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_OBJ])});static AI_APOBJ1=new z({id:45,name:"AI_APOBJ1",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_OBJ])});static AI_APOBJ2=new z({id:46,name:"AI_APOBJ2",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_OBJ])});static AI_APOBJ3=new z({id:47,name:"AI_APOBJ3",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_OBJ])});static AI_APOBJ4=new z({id:48,name:"AI_APOBJ4",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_OBJ])});static AI_APOBJ5=new z({id:49,name:"AI_APOBJ5",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_OBJ])});static AI_OPOBJ1=new z({id:52,name:"AI_OPOBJ1",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_OBJ])});static AI_OPOBJ2=new z({id:53,name:"AI_OPOBJ2",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_OBJ])});static AI_OPOBJ3=new z({id:54,name:"AI_OPOBJ3",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_OBJ])});static AI_OPOBJ4=new z({id:55,name:"AI_OPOBJ4",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_OBJ])});static AI_OPOBJ5=new z({id:56,name:"AI_OPOBJ5",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_OBJ])});static APLOC1=new z({id:59,name:"APLOC1",subjectMode:K.Type($.LOC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_LOC])});static APLOC2=new z({id:60,name:"APLOC2",subjectMode:K.Type($.LOC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_LOC])});static APLOC3=new z({id:61,name:"APLOC3",subjectMode:K.Type($.LOC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_LOC])});static APLOC4=new z({id:62,name:"APLOC4",subjectMode:K.Type($.LOC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_LOC])});static APLOC5=new z({id:63,name:"APLOC5",subjectMode:K.Type($.LOC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_LOC])});static APLOCU=new z({id:64,name:"APLOCU",subjectMode:K.Type($.LOC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_USEITEM,N.LAST_USESLOT,N.ACTIVE_LOC])});static APLOCT=new z({id:65,name:"APLOCT",subjectMode:K.Type($.COMPONENT,!1,!1),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_LOC])});static OPLOC1=new z({id:66,name:"OPLOC1",subjectMode:K.Type($.LOC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_LOC])});static OPLOC2=new z({id:67,name:"OPLOC2",subjectMode:K.Type($.LOC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_LOC])});static OPLOC3=new z({id:68,name:"OPLOC3",subjectMode:K.Type($.LOC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_LOC])});static OPLOC4=new z({id:69,name:"OPLOC4",subjectMode:K.Type($.LOC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_LOC])});static OPLOC5=new z({id:70,name:"OPLOC5",subjectMode:K.Type($.LOC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_LOC])});static OPLOCU=new z({id:71,name:"OPLOCU",subjectMode:K.Type($.LOC),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_USEITEM,N.LAST_USESLOT,N.ACTIVE_LOC])});static OPLOCT=new z({id:72,name:"OPLOCT",subjectMode:K.Type($.COMPONENT,!1,!1),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_LOC])});static AI_APLOC1=new z({id:73,name:"AI_APLOC1",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_LOC])});static AI_APLOC2=new z({id:74,name:"AI_APLOC2",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_LOC])});static AI_APLOC3=new z({id:75,name:"AI_APLOC3",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_LOC])});static AI_APLOC4=new z({id:76,name:"AI_APLOC4",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_LOC])});static AI_APLOC5=new z({id:77,name:"AI_APLOC5",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_LOC])});static AI_OPLOC1=new z({id:80,name:"AI_OPLOC1",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_LOC])});static AI_OPLOC2=new z({id:81,name:"AI_OPLOC2",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_LOC])});static AI_OPLOC3=new z({id:82,name:"AI_OPLOC3",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_LOC])});static AI_OPLOC4=new z({id:83,name:"AI_OPLOC4",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_LOC])});static AI_OPLOC5=new z({id:84,name:"AI_OPLOC5",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_LOC])});static APPLAYER1=new z({id:87,name:"APPLAYER1",subjectMode:K.None,pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_PLAYER2])});static APPLAYER2=new z({id:88,name:"APPLAYER2",subjectMode:K.None,pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_PLAYER2])});static APPLAYER3=new z({id:89,name:"APPLAYER3",subjectMode:K.None,pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_PLAYER2])});static APPLAYER4=new z({id:90,name:"APPLAYER4",subjectMode:K.None,pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_PLAYER2])});static APPLAYER5=new z({id:91,name:"APPLAYER5",subjectMode:K.None,pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_PLAYER2])});static APPLAYERU=new z({id:92,name:"APPLAYERU",subjectMode:K.Type($.NAMEDOBJ,!0,!1),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_USEITEM,N.LAST_USESLOT,N.ACTIVE_PLAYER2])});static APPLAYERT=new z({id:93,name:"APPLAYERT",subjectMode:K.Type($.COMPONENT,!1,!1),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_PLAYER2])});static OPPLAYER1=new z({id:94,name:"OPPLAYER1",subjectMode:K.None,pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_PLAYER2])});static OPPLAYER2=new z({id:95,name:"OPPLAYER2",subjectMode:K.None,pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_PLAYER2])});static OPPLAYER3=new z({id:96,name:"OPPLAYER3",subjectMode:K.None,pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_PLAYER2])});static OPPLAYER4=new z({id:97,name:"OPPLAYER4",subjectMode:K.None,pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_PLAYER2])});static OPPLAYER5=new z({id:98,name:"OPPLAYER5",subjectMode:K.None,pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_PLAYER2])});static OPPLAYERU=new z({id:99,name:"OPPLAYERU",subjectMode:K.Type($.NAMEDOBJ,!0,!1),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_USEITEM,N.LAST_USESLOT,N.ACTIVE_PLAYER2])});static OPPLAYERT=new z({id:100,name:"OPPLAYERT",subjectMode:K.Type($.COMPONENT,!1,!1),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.ACTIVE_PLAYER2])});static AI_APPLAYER1=new z({id:101,name:"AI_APPLAYER1",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_PLAYER])});static AI_APPLAYER2=new z({id:102,name:"AI_APPLAYER2",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_PLAYER])});static AI_APPLAYER3=new z({id:103,name:"AI_APPLAYER3",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_PLAYER])});static AI_APPLAYER4=new z({id:104,name:"AI_APPLAYER4",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_PLAYER])});static AI_APPLAYER5=new z({id:105,name:"AI_APPLAYER5",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_PLAYER])});static AI_OPPLAYER1=new z({id:108,name:"AI_OPPLAYER1",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_PLAYER])});static AI_OPPLAYER2=new z({id:109,name:"AI_OPPLAYER2",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_PLAYER])});static AI_OPPLAYER3=new z({id:110,name:"AI_OPPLAYER3",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_PLAYER])});static AI_OPPLAYER4=new z({id:111,name:"AI_OPPLAYER4",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_PLAYER])});static AI_OPPLAYER5=new z({id:112,name:"AI_OPPLAYER5",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.ACTIVE_PLAYER])});static QUEUE=new z({id:116,name:"QUEUE",allowParameters:!0,pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER])});static AI_QUEUE1=new z({id:117,name:"AI_QUEUE1",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static AI_QUEUE2=new z({id:118,name:"AI_QUEUE2",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static AI_QUEUE3=new z({id:119,name:"AI_QUEUE3",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static AI_QUEUE4=new z({id:120,name:"AI_QUEUE4",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static AI_QUEUE5=new z({id:121,name:"AI_QUEUE5",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static AI_QUEUE6=new z({id:122,name:"AI_QUEUE6",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static AI_QUEUE7=new z({id:123,name:"AI_QUEUE7",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static AI_QUEUE8=new z({id:124,name:"AI_QUEUE8",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static AI_QUEUE9=new z({id:125,name:"AI_QUEUE9",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static AI_QUEUE10=new z({id:126,name:"AI_QUEUE10",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static AI_QUEUE11=new z({id:127,name:"AI_QUEUE11",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static AI_QUEUE12=new z({id:128,name:"AI_QUEUE12",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static AI_QUEUE13=new z({id:129,name:"AI_QUEUE13",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static AI_QUEUE14=new z({id:130,name:"AI_QUEUE14",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static AI_QUEUE15=new z({id:131,name:"AI_QUEUE15",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static AI_QUEUE16=new z({id:132,name:"AI_QUEUE16",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static AI_QUEUE17=new z({id:133,name:"AI_QUEUE17",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static AI_QUEUE18=new z({id:134,name:"AI_QUEUE18",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static AI_QUEUE19=new z({id:135,name:"AI_QUEUE19",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static AI_QUEUE20=new z({id:136,name:"AI_QUEUE20",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC,N.LAST_INT])});static SOFTTIMER=new z({id:137,name:"SOFTTIMER",allowParameters:!0,pointers:new Set([N.ACTIVE_PLAYER])});static TIMER=new z({id:138,name:"TIMER",allowParameters:!0,pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER])});static AI_TIMER=new z({id:139,name:"AI_TIMER",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC])});static OPHELD1=new z({id:140,name:"OPHELD1",subjectMode:K.Type($.NAMEDOBJ),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_ITEM,N.LAST_SLOT])});static OPHELD2=new z({id:141,name:"OPHELD2",subjectMode:K.Type($.NAMEDOBJ),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_ITEM,N.LAST_SLOT])});static OPHELD3=new z({id:142,name:"OPHELD3",subjectMode:K.Type($.NAMEDOBJ),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_ITEM,N.LAST_SLOT])});static OPHELD4=new z({id:143,name:"OPHELD4",subjectMode:K.Type($.NAMEDOBJ),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_ITEM,N.LAST_SLOT])});static OPHELD5=new z({id:144,name:"OPHELD5",subjectMode:K.Type($.NAMEDOBJ),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_ITEM,N.LAST_SLOT])});static OPHELDU=new z({id:145,name:"OPHELDU",subjectMode:K.Type($.NAMEDOBJ),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_ITEM,N.LAST_SLOT,N.LAST_USEITEM,N.LAST_USESLOT])});static OPHELDT=new z({id:146,name:"OPHELDT",subjectMode:K.Type($.COMPONENT,!1,!1),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_ITEM,N.LAST_SLOT])});static IF_BUTTON=new z({id:147,name:"IF_BUTTON",subjectMode:K.Type($.COMPONENT),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_COM])});static IF_CLOSE=new z({id:148,name:"IF_CLOSE",subjectMode:K.Type($.INTERFACE),pointers:new Set([N.ACTIVE_PLAYER])});static INV_BUTTON1=new z({id:149,name:"INV_BUTTON1",subjectMode:K.Type($.COMPONENT),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_ITEM,N.LAST_SLOT])});static INV_BUTTON2=new z({id:150,name:"INV_BUTTON2",subjectMode:K.Type($.COMPONENT),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_ITEM,N.LAST_SLOT])});static INV_BUTTON3=new z({id:151,name:"INV_BUTTON3",subjectMode:K.Type($.COMPONENT),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_ITEM,N.LAST_SLOT])});static INV_BUTTON4=new z({id:152,name:"INV_BUTTON4",subjectMode:K.Type($.COMPONENT),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_ITEM,N.LAST_SLOT])});static INV_BUTTON5=new z({id:153,name:"INV_BUTTON5",subjectMode:K.Type($.COMPONENT),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_ITEM,N.LAST_SLOT])});static INV_BUTTOND=new z({id:154,name:"INV_BUTTOND",subjectMode:K.Type($.COMPONENT),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER,N.LAST_SLOT,N.LAST_TARGETSLOT])});static WALKTRIGGER=new z({id:155,name:"WALKTRIGGER",subjectMode:K.Name,pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER])});static AI_WALKTRIGGER=new z({id:156,name:"AI_WALKTRIGGER",subjectMode:K.Name,pointers:new Set([N.ACTIVE_NPC])});static LOGIN=new z({id:157,name:"LOGIN",subjectMode:K.None,pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER])});static LOGOUT=new z({id:158,name:"LOGOUT",subjectMode:K.None,allowReturns:!0,returns:w.BOOLEAN,pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER])});static TUTORIAL=new z({id:159,name:"TUTORIAL",subjectMode:K.None,pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER])});static ADVANCESTAT=new z({id:160,name:"ADVANCESTAT",subjectMode:K.Type($.STAT),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER])});static MAPZONE=new z({id:161,name:"MAPZONE",subjectMode:K.Type(w.MAPZONE),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER])});static MAPZONEEXIT=new z({id:162,name:"MAPZONEEXIT",subjectMode:K.Type(w.MAPZONE),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER])});static ZONE=new z({id:163,name:"ZONE",subjectMode:K.Type(w.COORD),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER])});static ZONEEXIT=new z({id:164,name:"ZONEEXIT",subjectMode:K.Type(w.COORD),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER])});static CHANGESTAT=new z({id:165,name:"CHANGESTAT",subjectMode:K.Type($.STAT),pointers:new Set([N.ACTIVE_PLAYER,N.P_ACTIVE_PLAYER])});static AI_SPAWN=new z({id:166,name:"AI_SPAWN",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC])});static AI_DESPAWN=new z({id:167,name:"AI_DESPAWN",subjectMode:K.Type($.NPC),pointers:new Set([N.ACTIVE_NPC])})}class g1 extends d2{lookupKey;static INITIAL_CAPACITY=512;instructionBuffer;switchBuffer;instructionCount=0;instructionOffset=0;switchOffset=0;constructor(_,A){super(_);this.lookupKey=A;this.instructionBuffer=Buffer.alloc(g1.INITIAL_CAPACITY),this.switchBuffer=Buffer.alloc(g1.INITIAL_CAPACITY)}ensureInstructionCapacity(_){if(this.instructionOffset+_>this.instructionBuffer.length){let A=Buffer.alloc(this.instructionBuffer.length*2);this.instructionBuffer.copy(A),this.instructionBuffer=A}}ensureSwitchCapacity(_){if(this.switchOffset+_>this.switchBuffer.length){let A=Buffer.alloc(this.switchBuffer.length*2);this.switchBuffer.copy(A),this.switchBuffer=A}}instruction(_,A){if(this.instructionCount++,this.ensureInstructionCapacity(_.largeOperand?6:4),this.instructionBuffer.writeUInt16BE(_.id,this.instructionOffset),this.instructionOffset+=2,_.largeOperand)this.instructionBuffer.writeInt32BE(A|0,this.instructionOffset),this.instructionOffset+=4;else this.instructionBuffer.writeUInt8(A,this.instructionOffset),this.instructionOffset+=1}instructionRaw(_,A){this.instructionCount++,this.ensureInstructionCapacity(3),this.instructionBuffer.writeUInt16BE(_,this.instructionOffset),this.instructionOffset+=2,this.instructionBuffer.writeUInt8(A,this.instructionOffset),this.instructionOffset+=1}instructionString(_,A){this.instructionCount++;let R=A.length+1;this.ensureInstructionCapacity(2+R),this.instructionBuffer.writeUInt16BE(_.id,this.instructionOffset),this.instructionOffset+=2,this.instructionOffset=this.writeString(this.instructionBuffer,A,this.instructionOffset)}switch(_,A){this.instruction(L.SWITCH,_);let R=this.switchOffset;this.ensureSwitchCapacity(2),this.switchOffset+=2;let U=A();this.switchBuffer.writeUInt16BE(U,R)}switchCase(_,A){this.ensureSwitchCapacity(8),this.switchBuffer.writeInt32BE(_,this.switchOffset),this.switchOffset+=4,this.switchBuffer.writeInt32BE(A,this.switchOffset),this.switchOffset+=4}finish(){let _=this.calculateBufferSize(),A=Buffer.alloc(_),R=0;if(R=this.writeString(A,this.script.fullName,R),R=this.writeString(A,this.script.sourceName,R),A.writeInt32BE(this.lookupKey,R),R+=4,this.script.trigger===z.DEBUGPROC){let Y=O.toList(this.script.symbol.parameters);A.writeUInt8(Y.length,R++);for(let X of Y){let G=X.code?.charCodeAt(0)??-1;A.writeInt8(G,R++)}}else A.writeUInt8(0,R++);A.writeUInt16BE(this.lineNumberTable.size,R),R+=2;for(let[Y,X]of this.lineNumberTable)A.writeInt32BE(Y,R),R+=4,A.writeInt32BE(X,R),R+=4;this.instructionBuffer.copy(A,R,0,this.instructionOffset),R+=this.instructionOffset,A.writeInt32BE(this.instructionCount,R),R+=4;let U=this.script.locals;return A.writeUInt16BE(R0.getLocalCount(U,0),R),R+=2,A.writeUInt16BE(R0.getLocalCount(U,1),R),R+=2,A.writeUInt16BE(R0.getParameterCount(U,0),R),R+=2,A.writeUInt16BE(R0.getParameterCount(U,1),R),R+=2,A.writeUInt8(this.script.switchTables.length,R++),this.switchBuffer.copy(A,R,0,this.switchOffset),R+=this.switchOffset,A.writeUInt16BE(this.switchOffset+1,R),A}calculateBufferSize(){let _=0;if(_+=this.script.fullName.length+1,_+=this.script.sourceName.length+1,_+=4,this.script.trigger===z.DEBUGPROC){let A=O.toList(this.script.symbol.parameters);_+=1+A.length}else _+=1;return _+=this.lineNumberTable.size*8+2,_+=this.instructionOffset,_+=4,_+=8,_+=1,_+=this.switchOffset,_+=2,_}close(){}writeString(_,A,R){for(let U=0;U<A.length;U++)_.writeUInt8(A.charCodeAt(U)&255,R++);return _.writeUInt8(0,R++),R}}class d1 extends R0{constructor(_){super(_)}finishWrite(_,A){let R=A.finish();try{this.outputScript(_,R)}finally{}}createContext(_){let A=this.generateLookupKey(_);return new g1(_,A)}generateLookupKey(_){let A=_.trigger,R=_.trigger.subjectMode,U=_.subjectReference;if(R===K.Name)return-1;let Y=A.id;if("type"in R&&U!=null){let X=U.type,G;if(U.type===w.MAPZONE||U.type===w.COORD)G=parseInt(U.name,10);else G=this.idProvider.get(U);let Q=X===$.CATEGORY?1:2;Y+=Q<<8|G<<10}return Y}enterBlock(_,A){}writePushConstantInt(_,A){_.instruction(L.PUSH_CONSTANT_INT,A)}writePushConstantString(_,A){_.instructionString(L.PUSH_CONSTANT_STRING,A)}writePushConstantLong(_,A){throw Error("Not supported.")}writePushConstantSymbol(_,A){let R;if(A instanceof I0)R=R0.getVariableId(_.script.locals,A);else if(A instanceof _0&&A.type instanceof q.Type){let U=A.type;if(typeof U.inner.code==="string"&&U.inner.code.length>0)R=U.inner.code.charCodeAt(0);else throw Error(`Type has chno code: ${U.inner}.`)}else R=this.idProvider.get(A);_.instruction(L.PUSH_CONSTANT_INT,R)}writePushLocalVar(_,A){let R=R0.getVariableId(_.script.locals,A),U;if(A.type instanceof a)U=L.PUSH_ARRAY_INT;else if(A.type.baseType===1)U=L.PUSH_STRING_LOCAL;else if(A.type.baseType===0)U=L.PUSH_INT_LOCAL;else throw Error(`Unsupported local variable type: ${A.type}.`);_.instruction(U,R)}writePopLocalVar(_,A){let R=R0.getVariableId(_.script.locals,A),U;if(A.type instanceof a)U=L.POP_ARRAY_INT;else if(A.type.baseType===1)U=L.POP_STRING_LOCAL;else if(A.type.baseType===0)U=L.POP_INT_LOCAL;else throw Error(`Unsupported local variable type: ${A.type}.`);_.instruction(U,R)}writePushVar(_,A,R){let U=this.idProvider.get(A),Y;if(A.type instanceof J0)Y=L.PUSH_VARP;else if(A.type instanceof H0)Y=L.PUSH_VARBIT;else if(A.type instanceof W0)Y=L.PUSH_VARN;else if(A.type instanceof q1)Y=L.PUSH_VARS;else throw Error(`Unsupported variable type: ${A.type}.`);let X=U;if(R)X+=65536;_.instruction(Y,X)}writePopVar(_,A,R){let U=this.idProvider.get(A),Y;if(A.type instanceof J0)Y=L.POP_VARP;else if(A.type instanceof H0)Y=L.POP_VARBIT;else if(A.type instanceof W0)Y=L.POP_VARN;else if(A.type instanceof q1)Y=L.POP_VARS;else throw Error(`Unsupported variable typ: ${A.type}.`);let X=U;if(R)X+=65536;_.instruction(Y,X)}writeDefineArray(_,A){let R=R0.getVariableId(_.script.locals,A),U=A.type;if(typeof U.inner.code!=="string"||U.inner.code.length===0)throw Error(`Type has no char code: ${U.inner}.`);let Y=U.inner.code.charCodeAt(0);_.instruction(L.DEFINE_ARRAY,R<<16|Y)}writeSwitch(_,A){_.switch(A.id,()=>{let R=0;for(let U of A.cases.entries()){let Y=_.jumpTable.get(U[1].label);if(Y===void 0)throw Error(`Label not found: ${U[1].label}.`);let X=Y-_.curIndex-1;for(let G of U[1].keys)_.switchCase(this.findCaseKeyValue(G),X);R+=U[1].keys.length}return R})}findCaseKeyValue(_){if(typeof _==="number")return _;return this.idProvider.get(_)}writeBranch(_,A,R){let U;switch(A){case H.Branch:U=L.BRANCH;break;case H.BranchNot:U=L.BRANCH_NOT;break;case H.BranchEquals:U=L.BRANCH_EQUALS;break;case H.BranchLessThan:U=L.BRANCH_LESS_THAN;break;case H.BranchGreaterThan:U=L.BRANCH_GREATER_THAN;break;case H.BranchLessThanOrEquals:U=L.BRANCH_LESS_THAN_OR_EQUALS;break;case H.BranchGreaterThanOrEquals:U=L.BRANCH_GREATER_THAN_OR_EQUALS;break;default:throw Error(`Unsupported opcode: ${A}.`)}let Y=_.jumpTable.get(R);if(Y===void 0)throw Error(`Label not found: ${R}.`);_.instruction(U,Y-_.curIndex-1)}writeJoinString(_,A){_.instruction(L.JOIN_STRING,A)}writeDiscard(_,A){let R;switch(A){case 0:R=L.POP_INT_DISCARD;break;case 1:R=L.POP_STRING_DISCARD;break;default:throw Error(`Unsupported base type: ${A}.`)}_.instruction(R,0)}writeGosub(_,A){let R=this.idProvider.get(A);_.instruction(L.GOSUB_WITH_PARAMS,R)}writeJump(_,A){let R=this.idProvider.get(A);_.instruction(L.JUMP_WITH_PARAMS,R)}writeCommand(_,A){let R=this.idProvider.get(A),U=A.name.startsWith(".");_.instructionRaw(R,U?1:0)}writeReturn(_){_.instruction(L.RETURN,0)}writeMath(_,A){let R;switch(A){case H.Add:R=L.ADD;break;case H.Sub:R=L.SUB;break;case H.Multiply:R=L.MULTIPLY;break;case H.Divide:R=L.DIVIDE;break;case H.Modulo:R=L.MODULO;break;case H.Or:R=L.OR;break;case H.And:R=L.AND;break;default:throw Error(`Unsupported math opcode: ${A}`)}_.instruction(R,0)}}var H7=q.Type;class N2 extends d1{output;buffers=new Map;static VERSION=26;constructor(_,A){super(A);if(this.output=_,!i.existsSync(_))i.mkdirSync(_,{recursive:!0});if(!i.statSync(_).isDirectory())throw Error(`${l1.resolve(_)} is not a directory.`)}outputScript(_,A){let R=this.idProvider.get(_.symbol);this.buffers.set(R,Buffer.from(A))}close(){let _=l1.join(this.output,"script.dat"),A=l1.join(this.output,"script.idx"),R=i.openSync(_,"w"),U=i.openSync(A,"w");try{let Y=[...this.buffers.keys()].sort((G,Q)=>G-Q),X=Y.length>0?Y[Y.length-1]:0;this.p4(R,X+1),this.p4(U,X+1),this.p4(R,N2.VERSION);for(let G=0;G<=X;G++){let Q=this.buffers.get(G);if(!Q){this.p4(U,0);continue}this.p4(U,Q.length),i.writeSync(R,Q)}}finally{i.closeSync(R),i.closeSync(U)}}p2(_,A){let R=Buffer.allocUnsafe(2);R.writeUInt16BE(A&65535,0),i.writeSync(_,R)}p4(_,A){let R=Buffer.allocUnsafe(4);R.writeInt32BE(A,0),i.writeSync(_,R)}}class Q2{parent;symbols=new Map;constructor(_=null){this.parent=_}insert(_,A){let R=this;while(R){if(R.symbols.get(_)?.has(A.name))return!1;R=R.parent}let U=this.symbols.get(_);if(!U)U=new Map,this.symbols.set(_,U);return U.set(A.name,A),!0}find(_,A){let U=this.symbols.get(_)?.get(A);if(U)return U;return this.parent?.find(_,A)??null}findAll(_,A){let R=[];for(let U of this.symbols.values()){let Y=U.get(_);if(Y&&(!A||Y instanceof A))R.push(Y)}if(this.parent)R.push(...this.parent.findAll(_,A));return R}createSubTable(){return new Q2(this)}}class l2{nameToTrigger=new Map;register(_,A){if(this.nameToTrigger.has(_))throw Error(`Trigger '${_}' is already registered.`);this.nameToTrigger.set(_,A)}registerTrigger(_){this.register(_.identifier,_)}registerAll(_){for(let A of _.ALL)this.registerTrigger(A)}find(_){let A=this.nameToTrigger.get(_);if(!A)throw Error(`Unable to find trigger '${_}'.`);return A}findOrNull(_){return this.nameToTrigger.get(_)??null}}class T2{nameToType=new Map;checkers=[];register(_,A){if(typeof _==="string"){if(this.nameToType.get(_))throw Error(`Type '${_} is already registered.`);if(!A)throw Error("Type must be provided.");this.nameToType.set(_,A)}else{let R=_.representation;if(this.nameToType.get(R))throw Error(`Type '${R}' is already registered.`);this.nameToType.set(R,_)}}registerNew(_,A,R=0,U=-1,Y){let X=new l;if(Y)Y(X);let G={representation:_,code:A,baseType:R,defaultValue:U,options:X};return this.register(G),G}registerAll(_){for(let A of _.ALL)this.register(A)}changeOptions(_,A){let R=this.nameToType.get(_);if(!R)throw Error(`'${_}' was not found.`);let U=R.options;A(U)}find(_,A=!1){let R=this.findOrNull(_,A);if(!R)throw Error(`Unable to find type: '${_}'.`);return R}findOrNull(_,A=!1){if(A&&_.endsWith("array")){let R=_.substring(0,_.length-5),U=this.findOrNull(R);if(!U||!U.options.allowArray)return null;return new a(U)}return this.nameToType.get(_)??null}addTypeChecker(_){this.checkers.push(_)}check(_,A){return this.checkers.some((R)=>R(_,A))}}import*as $4 from"fs";import*as F4 from"path";import*as I4 from"util";class y2{handleParse(_){this.handleShared(_)}handleTypeChecking(_){this.handleShared(_)}handleCodeGeneration(_){this.handleShared(_)}handlePointerChecking(_){this.handleShared(_)}handleShared(_){let A=new Map;for(let R of _.diagnostics){let U=F4.resolve(R.sourceLocation.name);if(!A.has(U))A.set(U,$4.readFileSync(U,"utf-8").split(/\r?\n/));let Y=A.get(U),X=`${R.sourceLocation.name}:${R.sourceLocation.line}:${R.sourceLocation.column}`;console.log(`${X}: ${R.type}: ${I4.format(R.message,...R.messageArgs)}`);let G=R.sourceLocation.line-1;if(G>=0&&G<Y.length){let Q=Y[G],J=Q.replace(/\t/g," "),F=(Q.match(/\t/g)??[]).length,I=R.sourceLocation.column??1,B=Math.max(1,I),C=Math.max(0,F*3+(B-1));console.log(` > ${J}`),console.log(` > ${" ".repeat(C)}^`)}}if(_.hasErrors())process.exit(1)}}import*as z5 from"fs";import*as E0 from"path";class _1{_diagnostics=[];get diagnostics(){return this._diagnostics}report(_){this._diagnostics.push(_)}hasErrors(){return this._diagnostics.some((_)=>_1.ERROR_TYPES.has(_.type))}static ERROR_TYPES=new Set(["ERROR","SYNTAX_ERROR"])}class s{source;parent=null;_children=[];get children(){return this._children}attributes=new Map;constructor(_){this.source=_;this.source=_}addChild(_){if(!_)return;if(_.parent)throw Error("Parent already set.");_.parent=this,this._children.push(_)}addChildren(_){for(let A of _){if(!A)continue;if(A.parent)throw Error("Parent already set.");A.parent=this,this._children.push(A)}}findParentByType(_){let A=this.parent;while(A!==null){if(A instanceof _)return A;A=A.parent}return null}reportInfo(_,A,...R){_.report(new U0("INFO",this,A,...R))}reportWarning(_,A,...R){_.report(new U0("WARNING",this,A,...R))}reportError(_,A,...R){_.report(new U0("ERROR",this,A,...R))}}class U0{type;sourceLocation;message;messageArgs;constructor(_,A,R,...U){if(this.type=_,"source"in A)this.sourceLocation=A.source;else this.sourceLocation=A;this.messageArgs=U,this.message=R}isError(){return this.type==="ERROR"||this.type==="SYNTAX_ERROR"}}class y1{sourceFile;diagnostics;lineOffset;columnOffset;constructor(_,A,R=0,U=0){this.sourceFile=_;this.diagnostics=A;this.lineOffset=R;this.columnOffset=U}syntaxError(_,A,R,U,Y,X){let G=R===1?this.columnOffset:0,Q=R+this.lineOffset,J=U+G+1,F={name:this.sourceFile,line:Q,column:J,endLine:Q,endColumn:J};this.diagnostics.report(new U0("SYNTAX_ERROR",F,Y.replace(/%/g,"%%"),[]))}reportAmbiguity(_,A,R,U,Y,X,G){}reportAttemptingFullContext(_,A,R,U,Y,X){}reportContextSensitivity(_,A,R,U,Y,X){}}import{readFileSync as V6}from"fs";import{readFile as P6}from"fs/promises";var M5=Object.defineProperty,W=(_,A)=>M5(_,"name",{value:A,configurable:!0}),H2;((_)=>{_.EOF=-1,_.UNKNOWN_SOURCE_NAME="<unknown>"})(H2||(H2={}));var D;((_)=>{_.INVALID_TYPE=0,_.EPSILON=-2,_.MIN_USER_TOKEN_TYPE=1,_.EOF=H2.EOF,_.DEFAULT_CHANNEL=0,_.HIDDEN_CHANNEL=1,_.MIN_USER_CHANNEL_VALUE=2})(D||(D={}));var f5=W((_)=>{let A=_;return A.tokenSource!==void 0&&A.channel!==void 0},"isToken"),j0=class{static{W(this,"BitSet")}data;constructor(_){if(_)this.data=new Uint32Array(_.map((A)=>{return A>>>0}));else this.data=new Uint32Array(1)}[Symbol.iterator](){let _=this.data.length,A=0,R=this.data[A],U=this.data;return{[Symbol.iterator](){return this},next:W(()=>{while(A<_)if(R!==0){let Y=R&-R,X=(A<<5)+this.bitCount(Y-1);return R^=Y,{done:!1,value:X}}else if(A++,A<_)R=U[A];return{done:!0,value:void 0}},"next")}}clear(_){if(_===void 0)this.data=new Uint32Array;else this.resize(_),this.data[_>>>5]&=~(1<<_)}or(_){let A=Math.min(this.data.length,_.data.length);for(let R=0;R<A;++R)this.data[R]|=_.data[R];if(this.data.length<_.data.length){this.resize((_.data.length<<5)-1);let R=_.data.length;for(let U=A;U<R;++U)this.data[U]=_.data[U]}}get(_){if(_<0)throw RangeError("index cannot be negative");let A=_>>>5;if(A>=this.data.length)return!1;return(this.data[A]&1<<_%32)!==0}get length(){let _=0,A=this.data.length,R=this.data;for(let U=0;U<A;U++)_+=this.bitCount(R[U]);return _}values(){let _=Array(this.length),A=0,R=this.data.length;for(let U=0;U<R;++U){let Y=this.data[U];while(Y!==0){let X=Y&-Y;_[A++]=(U<<5)+this.bitCount(X-1),Y^=X}}return _}nextSetBit(_){if(_<0)throw RangeError("index cannot be negative");for(let A of this)if(A>=_)return A;return}set(_){if(_<0)throw RangeError("index cannot be negative");this.resize(_),this.data[_>>>5]|=1<<_%32}toString(){return"{"+this.values().join(", ")+"}"}resize(_){let A=_+32>>>5;if(A<=this.data.length)return;let R=new Uint32Array(A);R.set(this.data),R.fill(0,this.data.length),this.data=R}bitCount(_){return _=_-(_>>1&1431655765),_=(_&858993459)+(_>>2&858993459),_=_+(_>>4)&252645135,_=_+(_>>8),_=_+(_>>16),_&63}},h5=3432918353,V5=461845907,W4=15,q4=13,P5=5,v5=3864292196,k=class _{static{W(this,"MurmurHash")}static defaultSeed=701;constructor(){}static initialize(A=_.defaultSeed){return A}static updateFromComparable(A,R){return this.update(A,R?.hashCode()??0)}static update(A,R){return R=Math.imul(R,h5),R=R<<W4|R>>>32-W4,R=Math.imul(R,V5),A=A^R,A=A<<q4|A>>>32-q4,A=Math.imul(A,P5)+v5,A}static finish(A,R){return A^=R*4,A^=A>>>16,A=Math.imul(A,2246822507),A^=A>>>13,A=Math.imul(A,3266489909),A^=A>>>16,A}static hashCode(A,R){return _.finish(_.update(R??_.defaultSeed,A),1)}},R1=class _{static{W(this,"ObjectEqualityComparator")}static instance=new _;hashCode(A){if(A==null)return 0;return A.hashCode()}equals(A,R){if(A==null)return R==null;return A.equals(R)}},f4=class _{static{W(this,"DefaultEqualityComparator")}static instance=new _;hashCode(A){if(A==null)return 0;return R1.instance.hashCode(A)}equals(A,R){if(A==null)return R==null;if(typeof A==="string"||typeof A==="number")return A===R;return R1.instance.equals(A,R)}},$0=class _{static{W(this,"HashSet")}static defaultLoadFactor=0.75;static initialCapacity=16;comparator;buckets;threshold;itemCount=0;constructor(A,R=_.initialCapacity){if(A instanceof _){this.comparator=A.comparator,this.buckets=A.buckets.slice(0);for(let U=0;U<this.buckets.length;U++){let Y=this.buckets[U];if(Y)this.buckets[U]=Y.slice(0)}this.itemCount=A.itemCount,this.threshold=A.threshold}else this.comparator=A??f4.instance,this.buckets=this.createBuckets(R),this.threshold=Math.floor(_.initialCapacity*_.defaultLoadFactor)}getOrAdd(A){if(this.itemCount>this.threshold)this.expand();let R=this.getBucket(A),U=this.buckets[R];if(!U)return U=[A],this.buckets[R]=U,++this.itemCount,A;for(let Y of U)if(this.comparator.equals(Y,A))return Y;return U.push(A),++this.itemCount,A}get(A){if(A==null)return A;let R=this.getBucket(A),U=this.buckets[R];if(!U)return;for(let Y of U)if(this.comparator.equals(Y,A))return Y;return}remove(A){if(A==null)return!1;let R=this.getBucket(A),U=this.buckets[R];if(!U)return!1;for(let Y=0;Y<U.length;Y++){let X=U[Y];if(this.comparator.equals(X,A))return U.splice(Y,1),--this.itemCount,!0}return!1}hashCode(){let A=k.initialize();for(let R of this.buckets){if(R==null)continue;for(let U of R){if(U==null)break;A=k.update(A,this.comparator.hashCode(U))}}return A=k.finish(A,this.size),A}equals(A){if(A===this)return!0;if(!(A instanceof _))return!1;if(A.size!==this.size)return!1;return this.containsAll(A)}add(A){return this.getOrAdd(A)===A}contains(A){return this.containsFast(A)}containsFast(A){if(A==null)return!1;return this.get(A)!==void 0}*[Symbol.iterator](){yield*this.toArray()}toArray(){let A=Array(this.size),R=0;for(let U of this.buckets){if(U==null)continue;for(let Y of U){if(Y==null)break;A[R++]=Y}}return A}containsAll(A){if(A instanceof _)for(let R of A.buckets){if(R==null)continue;for(let U of R){if(U==null)break;if(!this.containsFast(U))return!1}}else for(let R of A)if(!this.containsFast(R))return!1;return!0}addAll(A){let R=!1;for(let U of A)if(this.getOrAdd(U)!==U)R=!0;return R}clear(){this.buckets=this.createBuckets(_.initialCapacity),this.itemCount=0,this.threshold=Math.floor(_.initialCapacity*_.defaultLoadFactor)}toString(){if(this.size===0)return"{}";let A="{",R=!0;for(let U of this.buckets){if(U==null)continue;for(let Y of U){if(Y==null)break;if(R)R=!1;else A+=", ";A+=Y.toString()}}return A+="}",A}toTableString(){let A="";for(let R of this.buckets){if(R==null){A+=`null
2
- `;continue}A+="[";let U=!0;for(let Y of R){if(U)U=!1;else A+=" ";if(Y==null)A+="_";else A+=Y.toString()}A+=`]
3
- `}return A}getBucket(A){return this.comparator.hashCode(A)&this.buckets.length-1}expand(){let A=this.buckets,R=this.buckets.length*2,U=this.createBuckets(R);this.buckets=U,this.threshold=Math.floor(R*_.defaultLoadFactor);for(let Y of A){if(!Y)continue;for(let X of Y){let G=this.getBucket(X),Q=this.buckets[G];if(!Q)Q=[],this.buckets[G]=Q;Q.push(X)}}}get size(){return this.itemCount}get isEmpty(){return this.itemCount===0}createBuckets(A){return Array(A)}},b=class _{static{W(this,"Interval")}static INVALID_INTERVAL=new _(-1,-2);static INTERVAL_POOL_MAX_VALUE=1000;static cache=[];start;stop;cachedHashCode;constructor(A,R){this.start=A,this.stop=R,this.cachedHashCode=Math.imul(651+A,31)+R}static of(A,R){if(A!==R||A<0||A>_.INTERVAL_POOL_MAX_VALUE)return new _(A,R);if(!_.cache[A])_.cache[A]=new _(A,A);return _.cache[A]}equals(A){return this.start===A.start&&this.stop===A.stop}hashCode(){return this.cachedHashCode}startsBeforeDisjoint(A){return this.start<A.start&&this.stop<A.start}startsBeforeNonDisjoint(A){return this.start<=A.start&&this.stop>=A.start}startsAfter(A){return this.start>A.start}startsAfterDisjoint(A){return this.start>A.stop}startsAfterNonDisjoint(A){return this.start>A.start&&this.start<=A.stop}disjoint(A){return this.startsBeforeDisjoint(A)||this.startsAfterDisjoint(A)}adjacent(A){return this.start===A.stop+1||this.stop===A.start-1}properlyContains(A){return A.start>=this.start&&A.stop<=this.stop}union(A){return _.of(Math.min(this.start,A.start),Math.max(this.stop,A.stop))}intersection(A){return _.of(Math.max(this.start,A.start),Math.min(this.stop,A.stop))}differenceNotProperlyContained(A){let R=null;if(A.startsBeforeNonDisjoint(this))R=_.of(Math.max(this.start,A.stop+1),this.stop);else if(A.startsAfterNonDisjoint(this))R=_.of(this.start,A.start-1);return R}toString(){return`${this.start}..${this.stop}`}get length(){if(this.stop<this.start)return 0;return this.stop-this.start+1}},D0=class _{static{W(this,"Vocabulary")}static EMPTY_NAMES=[];static EMPTY_VOCABULARY=new _(_.EMPTY_NAMES,_.EMPTY_NAMES,_.EMPTY_NAMES);maxTokenType;literalNames;symbolicNames;displayNames;constructor(A,R,U){this.literalNames=A??_.EMPTY_NAMES,this.symbolicNames=R??_.EMPTY_NAMES,this.displayNames=U??_.EMPTY_NAMES,this.maxTokenType=Math.max(this.displayNames.length,Math.max(this.literalNames.length,this.symbolicNames.length))-1}static fromTokenNames(A){if(A==null||A.length===0)return _.EMPTY_VOCABULARY;let R=[...A],U=[...A];for(let Y=0;Y<A.length;Y++){let X=A[Y];if(X==null)continue;if(X.length>0){let G=X.codePointAt(0);if(G===39){U[Y]=null;continue}else if(G>=65&&G<=90){R[Y]=null;continue}}R[Y]=null,U[Y]=null}return new _(R,U,A)}getMaxTokenType(){return this.maxTokenType}getLiteralName(A){if(A>=0&&A<this.literalNames.length)return this.literalNames[A];return null}getSymbolicName(A){if(A>=0&&A<this.symbolicNames.length)return this.symbolicNames[A];if(A===D.EOF)return"EOF";return null}getDisplayName(A){if(A>=0&&A<this.displayNames.length){let Y=this.displayNames[A];if(Y!=null)return Y}let R=this.getLiteralName(A);if(R!=null)return R;let U=this.getSymbolicName(A);if(U!=null)return U;return`${A}`}getLiteralNames(){return this.literalNames}getSymbolicNames(){return this.symbolicNames}getDisplayNames(){return this.displayNames}},K0=class _{static{W(this,"IntervalSet")}intervals=[];cachedHashCode;constructor(A){if(A)if(Array.isArray(A))for(let R of A)this.addOne(R);else this.addSet(A)}static of(A,R){let U=new _;return U.addRange(A,R),U}static or(A){let R=new _;for(let U of A)R.addSet(U);return R}[Symbol.iterator](){return this.intervals[Symbol.iterator]()}get(A){return this.intervals[A]}get minElement(){if(this.intervals.length===0)return D.INVALID_TYPE;return this.intervals[0].start}get maxElement(){if(this.intervals.length===0)return D.INVALID_TYPE;return this.intervals[this.intervals.length-1].stop}clear(){this.cachedHashCode=void 0,this.intervals=[]}addOne(A){this.addInterval(new b(A,A))}addRange(A,R){this.addInterval(new b(A,R))}addInterval(A){if(this.cachedHashCode=void 0,this.intervals.length===0)this.intervals.push(A);else{for(let R=0;R<this.intervals.length;R++){let U=this.intervals[R];if(A.equals(U))return;if(A.adjacent(U)||!A.disjoint(U)){let Y=A.union(U);this.intervals[R]=Y;for(let X=R+1;X<this.intervals.length;){let G=this.intervals[X];if(!Y.adjacent(G)&&Y.disjoint(G))break;this.intervals.splice(X,1),this.intervals[R]=Y.union(G)}return}if(A.startsBeforeDisjoint(U)){this.intervals.splice(R,0,A);return}}this.intervals.push(A)}}addSet(A){return A.intervals.forEach((R)=>{return this.addInterval(R)},this),this}complementWithVocabulary(A){let R=new _;if(!A)return R;if(A.length===0)return R;return R.addSet(A),R.subtract(this)}complement(A,R){let U=new _;return U.addInterval(new b(A,R)),U.subtract(this)}or(A){let R=new _;return R.addSet(this),A.forEach((U)=>{return R.addSet(U)}),R}and(A){if(A.length===0)return new _;let R=this.intervals,U=A.intervals,Y,X=R.length,G=U.length,Q=0,J=0;while(Q<X&&J<G){let F=R[Q],I=U[J];if(F.startsBeforeDisjoint(I))Q++;else if(I.startsBeforeDisjoint(F))J++;else if(F.properlyContains(I)){if(!Y)Y=new _;Y.addInterval(F.intersection(I)),J++}else if(I.properlyContains(F)){if(!Y)Y=new _;Y.addInterval(F.intersection(I)),Q++}else if(!F.disjoint(I)){if(!Y)Y=new _;if(Y.addInterval(F.intersection(I)),F.startsAfterNonDisjoint(I))J++;else if(I.startsAfterNonDisjoint(F))Q++}}if(!Y)return new _;return Y}subtract(A){if(this.length===0)return new _;let R=new _(this);if(A.length===0)return R;let U=0,Y=0;while(U<R.intervals.length&&Y<A.intervals.length){let X=R.intervals[U],G=A.intervals[Y];if(G.stop<X.start){Y++;continue}if(G.start>X.stop){U++;continue}let Q,J;if(G.start>X.start)Q=new b(X.start,G.start-1);if(G.stop<X.stop)J=new b(G.stop+1,X.stop);if(Q)if(J)R.intervals[U]=Q,R.intervals.splice(U+1,0,J),U++,Y++;else R.intervals[U]=Q,U++;else if(J)R.intervals[U]=J,Y++;else R.intervals.splice(U,1)}return R}contains(A){let R=this.intervals.length,U=0,Y=R-1;while(U<=Y){let X=Math.floor((U+Y)/2),G=this.intervals[X];if(G.stop<A)U=X+1;else if(G.start>A)Y=X-1;else return!0}return!1}removeRange(A){if(this.cachedHashCode=void 0,A.start===A.stop)this.removeOne(A.start);else if(this.intervals!==null){let R=0;for(let U of this.intervals){if(A.stop<=U.start)return;else if(A.start>U.start&&A.stop<U.stop){this.intervals[R]=new b(U.start,A.start);let Y=new b(A.stop,U.stop);this.intervals.splice(R,0,Y);return}else if(A.start<=U.start&&A.stop>=U.stop)this.intervals.splice(R,1),R=R-1;else if(A.start<U.stop)this.intervals[R]=new b(U.start,A.start);else if(A.stop<U.stop)this.intervals[R]=new b(A.stop,U.stop);R+=1}}}removeOne(A){this.cachedHashCode=void 0;for(let R=0;R<this.intervals.length;R++){let U=this.intervals[R];if(A<U.start)return;else if(A===U.start&&A===U.stop){this.intervals.splice(R,1);return}else if(A===U.start){this.intervals[R]=new b(U.start+1,U.stop);return}else if(A===U.stop){this.intervals[R]=new b(U.start,U.stop-1);return}else if(A<U.stop){let Y=new b(U.start,A-1);this.intervals[R]=new b(A+1,U.stop),this.intervals.splice(R,0,Y);return}}}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize();for(let R of this.intervals)A=k.update(A,R.start),A=k.update(A,R.stop);this.cachedHashCode=k.finish(A,this.intervals.length*2)}return this.cachedHashCode}equals(A){if(this===A)return!0;if(this.intervals.length!==A.intervals.length)return!1;for(let R=0;R<this.intervals.length;R++)if(!this.intervals[R].equals(A.intervals[R]))return!1;return!0}toString(A){if(this.intervals.length===0)return"{}";let R="";if(this.length>1)R+="{";for(let U=0;U<this.intervals.length;++U){let Y=this.intervals[U],X=Y.start,G=Y.stop;if(X===G)if(X===D.EOF)R+="<EOF>";else if(A)R+="'"+String.fromCodePoint(X)+"'";else R+=X;else if(A)R+="'"+String.fromCodePoint(X)+"'..'"+String.fromCodePoint(G)+"'";else R+=X+".."+G;if(U<this.intervals.length-1)R+=", "}if(this.length>1)R+="}";return R}toStringWithVocabulary(A){if(this.intervals.length===0)return"{}";let R="";if(this.length>1)R+="{";for(let U=0;U<this.intervals.length;++U){let Y=this.intervals[U],X=Y.start,G=Y.stop;if(X===G)if(X===D.EOF)R+="<EOF>";else R+=this.elementName(A,X);else for(let Q=X;Q<=G;++Q){if(Q>X)R+=", ";R+=this.elementName(A,Q)}if(U<this.intervals.length-1)R+=", "}if(this.length>1)R+="}";return R}toStringWithRuleNames(A){if(this.intervals.length===0)return"{}";let R="";if(this.length>1)R+="{";let U=D0.fromTokenNames(A);for(let Y=0;Y<this.intervals.length;++Y){let X=this.intervals[Y],G=X.start,Q=X.stop;if(G===Q)if(G===D.EOF)R+="<EOF>";else R+=this.elementName(U,G);else for(let J=G;J<=Q;++J){if(J>G)R+=", ";R+=this.elementName(U,J)}if(Y<this.intervals.length-1)R+=", "}if(this.length>1)R+="}";return R}toArray(){let A=[];for(let R of this.intervals)for(let U=R.start;U<=R.stop;U++)A.push(U);return A}get length(){let A=0;for(let R of this.intervals)A+=R.length;return A}elementName(A,R){if(R===D.EOF)return"<EOF>";if(R===D.EPSILON)return"<EPSILON>";return A.getDisplayName(R)}};var b5=W((_)=>{return _===null?"null":_},"valueToString"),D1=W((_)=>{return Array.isArray(_)?"["+_.map(b5).join(", ")+"]":"null"},"arrayToString"),I2=W((_,A)=>{if(_===A)return!0;if(_.length!==A.length)return!1;for(let R=0;R<_.length;R++){let U=_[R],Y=A[R];if(U===Y)continue;if(!U||!U.equals(Y))return!1}return!0},"equalArrays"),u5=W((_,A)=>{if(_===A)return!0;if(_.length!==A.length)return!1;for(let R=0;R<_.length;R++)if(_[R]!==A[R])return!1;return!0},"equalNumberArrays"),S5=W((_,A=!1)=>{if(_=_.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r"),A)_=_.replace(/ /g,"·");return _},"escapeWhitespace"),u=class _{static{W(this,"SemanticContext")}cachedHashCode;static andContext(A,R){if(A===null||A===_.NONE)return R;if(R===null||R===_.NONE)return A;let U=new x5(A,R);if(U.operands.length===1)return U.operands[0];return U}static orContext(A,R){if(A===null)return R;if(R===null)return A;if(A===_.NONE||R===_.NONE)return _.NONE;let U=new m5(A,R);if(U.operands.length===1)return U.operands[0];else return U}static filterPrecedencePredicates(A){let R=[];for(let U of A)if(U instanceof _.PrecedencePredicate)R.push(U);return R}evalPrecedence(A,R){return this}},x5=class _ extends u{static{W(this,"AND")}operands;constructor(A,R){super();let U=new $0;if(A instanceof _)A.operands.forEach((X)=>{U.add(X)});else U.add(A);if(R instanceof _)R.operands.forEach((X)=>{U.add(X)});else U.add(R);let Y=u.filterPrecedencePredicates(U);if(Y.length>0){let X=null;if(Y.forEach((G)=>{if(X===null||G.precedence<X.precedence)X=G}),X)U.add(X)}this.operands=U.toArray()}equals(A){if(this===A)return!0;if(!(A instanceof _))return!1;return I2(this.operands,A.operands)}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize();for(let R of this.operands)A=k.updateFromComparable(A,R);A=k.update(A,3813686060),this.cachedHashCode=k.finish(A,this.operands.length+1)}return this.cachedHashCode}evaluate(A,R){for(let U of this.operands)if(!U.evaluate(A,R))return!1;return!0}evalPrecedence(A,R){let U=!1,Y=[];for(let G of this.operands){let Q=G.evalPrecedence(A,R);if(U||=Q!==G,Q===null)return null;else if(Q!==u.NONE)Y.push(Q)}if(!U)return this;if(Y.length===0)return u.NONE;let X=null;return Y.forEach((G)=>{X=X===null?G:u.andContext(X,G)}),X}toString(){let A=this.operands.map((R)=>{return R.toString()});return(A.length>3?A.slice(3):A).join("&&")}},m5=class _ extends u{static{W(this,"OR")}operands;constructor(A,R){super();let U=new $0;if(A instanceof _)A.operands.forEach((X)=>{U.add(X)});else U.add(A);if(R instanceof _)R.operands.forEach((X)=>{U.add(X)});else U.add(R);let Y=u.filterPrecedencePredicates(U);if(Y.length>0){let X=Y.sort((Q,J)=>{return Q.compareTo(J)}),G=X[X.length-1];U.add(G)}this.operands=U.toArray()}equals(A){if(this===A)return!0;else if(!(A instanceof _))return!1;else return I2(this.operands,A.operands)}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize();for(let R of this.operands)A=k.updateFromComparable(A,R);A=k.update(A,3383313031),this.cachedHashCode=k.finish(A,this.operands.length+1)}return this.cachedHashCode}evaluate(A,R){for(let U of this.operands)if(U.evaluate(A,R))return!0;return!1}evalPrecedence(A,R){let U=!1,Y=[];for(let G of this.operands){let Q=G.evalPrecedence(A,R);if(U||=Q!==G,Q===u.NONE)return u.NONE;else if(Q!==null)Y.push(Q)}if(!U)return this;if(Y.length===0)return null;let X=null;return Y.forEach((G)=>{X=X===null?G:u.orContext(X,G)}),X}toString(){let A=this.operands.map((R)=>{return R.toString()});return(A.length>3?A.slice(3):A).join("||")}};((_)=>{class A extends _{static{W(this,"Predicate")}ruleIndex;predIndex;isCtxDependent;constructor(U,Y,X){super();this.ruleIndex=U??-1,this.predIndex=Y??-1,this.isCtxDependent=X??!1}evaluate(U,Y){let X=this.isCtxDependent?Y:null;return U.sempred(X,this.ruleIndex,this.predIndex)}hashCode(){if(this.cachedHashCode===void 0){let U=k.initialize();U=k.update(U,this.ruleIndex),U=k.update(U,this.predIndex),U=k.update(U,this.isCtxDependent?1:0),U=k.finish(U,3),this.cachedHashCode=U}return this.cachedHashCode}equals(U){if(this===U)return!0;return this.ruleIndex===U.ruleIndex&&this.predIndex===U.predIndex&&this.isCtxDependent===U.isCtxDependent}toString(){return"{"+this.ruleIndex+":"+this.predIndex+"}?"}}_.Predicate=A;class R extends _{static{W(this,"PrecedencePredicate")}precedence;constructor(U){super();this.precedence=U??0}evaluate(U,Y){return U.precpred(Y,this.precedence)}evalPrecedence(U,Y){if(U.precpred(Y??null,this.precedence))return _.NONE;return null}compareTo(U){return this.precedence-U.precedence}hashCode(){return 31+this.precedence}equals(U){if(this===U)return!0;return this.precedence===U.precedence}toString(){return"{"+this.precedence+">=prec}?"}}_.PrecedencePredicate=R,_.NONE=new A})(u||(u={}));var y=class _{static{W(this,"ATNConfig")}state;alt;reachesIntoOuterContext=!1;precedenceFilterSuppressed=!1;get semanticContext(){return this.#A}cachedHashCode;#_=null;#A;constructor(A,R,U,Y){if(this.state=R,this.alt=A.alt,this.context=U,this.#A=Y??u.NONE,this.reachesIntoOuterContext=A.reachesIntoOuterContext,A.precedenceFilterSuppressed!==void 0)this.precedenceFilterSuppressed=A.precedenceFilterSuppressed}static duplicate(A,R){return new _(A,A.state,A.context,R??A.semanticContext)}static createWithContext(A,R,U,Y){return new _({alt:R},A,U,Y)}static createWithConfig(A,R,U){return new _(R,A,U??R.context,R.semanticContext)}static createWithSemanticContext(A,R,U){return new _(R,A??R.state,R.context,U)}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize(7);A=k.update(A,this.state.stateNumber),A=k.update(A,this.alt),A=k.updateFromComparable(A,this.#_),A=k.updateFromComparable(A,this.semanticContext),A=k.finish(A,4),this.cachedHashCode=A}return this.cachedHashCode}get context(){return this.#_}set context(A){this.#_=A,this.cachedHashCode=void 0}equals(A){if(this===A)return!0;return this.state.stateNumber===A.state.stateNumber&&this.alt===A.alt&&(this.context===null?A.context===null:this.context.equals(A.context))&&this.semanticContext.equals(A.semanticContext)&&this.precedenceFilterSuppressed===A.precedenceFilterSuppressed}toString(A,R=!0){let U="";if(R)U=","+this.alt;return"("+this.state+U+(this.context!==null?",["+this.context.toString()+"]":"")+(this.semanticContext!==u.NONE?","+this.semanticContext.toString():"")+(this.reachesIntoOuterContext?",up="+this.reachesIntoOuterContext:"")+")"}},f=class _{static{W(this,"ATNState")}static INVALID_STATE_NUMBER=-1;static INVALID_TYPE=0;static BASIC=1;static RULE_START=2;static BLOCK_START=3;static PLUS_BLOCK_START=4;static STAR_BLOCK_START=5;static TOKEN_START=6;static RULE_STOP=7;static BLOCK_END=8;static STAR_LOOP_BACK=9;static STAR_LOOP_ENTRY=10;static PLUS_LOOP_BACK=11;static LOOP_END=12;static stateType=_.INVALID_STATE_NUMBER;stateNumber=0;ruleIndex=0;epsilonOnlyTransitions=!1;nextTokenWithinRule;transitions=[];hashCode(){return this.stateNumber}equals(A){return this.stateNumber===A.stateNumber}toString(){return`${this.stateNumber}`}addTransitionAtIndex(A,R){if(this.transitions.length===0)this.epsilonOnlyTransitions=R.isEpsilon;else if(this.epsilonOnlyTransitions!==R.isEpsilon)this.epsilonOnlyTransitions=!1;this.transitions.splice(A,0,R)}addTransition(A){if(this.transitions.length===0)this.epsilonOnlyTransitions=A.isEpsilon;else if(this.epsilonOnlyTransitions!==A.isEpsilon)this.epsilonOnlyTransitions=!1;this.transitions.push(A)}setTransition(A,R){this.transitions.splice(A,1,R)}removeTransition(A){return this.transitions.splice(A,1)[0]}},n=class _{static{W(this,"PredictionContext")}static EMPTY_RETURN_STATE=2147483647;static traceATNSimulator=!1;cachedHashCode;constructor(A){this.cachedHashCode=A}static calculateEmptyHashCode(){let A=k.initialize(31);return A=k.finish(A,0),A}static calculateHashCodeSingle(A,R){let U=k.initialize(31);return U=k.updateFromComparable(U,A),U=k.update(U,R),U=k.finish(U,2),U}static calculateHashCodeList(A,R){let U=k.initialize(31);for(let Y of A)U=k.updateFromComparable(U,Y);for(let Y of R)U=k.update(U,Y);return U=k.finish(U,2*A.length),U}isEmpty(){return!1}hasEmptyPath(){return this.getReturnState(this.length-1)===_.EMPTY_RETURN_STATE}hashCode(){return this.cachedHashCode}toString(A){return""}},B1=class _ extends n{static{W(this,"SingletonPredictionContext")}parent;returnState;constructor(A,R){super(A?n.calculateHashCodeSingle(A,R):n.calculateEmptyHashCode());this.parent=A??null,this.returnState=R}getParent(A){return this.parent}getReturnState(A){return this.returnState}equals(A){if(this===A)return!0;if(!(A instanceof _))return!1;if(this.hashCode()!==A.hashCode())return!1;if(this.returnState!==A.returnState)return!1;if(this.parent==null)return A.parent==null;return this.parent.equals(A.parent)}toString(){let A=this.parent===null?"":this.parent.toString();if(A.length===0){if(this.returnState===n.EMPTY_RETURN_STATE)return"$";return""+this.returnState}else return""+this.returnState+" "+A}get length(){return 1}},c=class _ extends B1{static{W(this,"EmptyPredictionContext")}static instance=new _;constructor(){super(void 0,n.EMPTY_RETURN_STATE)}isEmpty(){return!0}getParent(){return null}getReturnState(){return this.returnState}equals(A){return this===A}toString(){return"$"}},j=class{static{W(this,"Transition")}static INVALID=0;static EPSILON=1;static RANGE=2;static RULE=3;static PREDICATE=4;static ATOM=5;static ACTION=6;static SET=7;static NOT_SET=8;static WILDCARD=9;static PRECEDENCE=10;target;constructor(_){this.target=_}get isEpsilon(){return!1}get label(){return null}toString(){return""}},e2=class extends j{static{W(this,"SetTransition")}set;constructor(_,A){super(_);if(A)this.set=A;else this.set=K0.of(D.INVALID_TYPE,D.INVALID_TYPE)}get transitionType(){return j.SET}get label(){return this.set}matches(_,A,R){return this.set.contains(_)}toString(){return this.set.toString()}},_3=class extends e2{static{W(this,"NotSetTransition")}get transitionType(){return j.NOT_SET}matches(_,A,R){return _>=A&&_<=R&&!super.matches(_,A,R)}toString(){return"~"+super.toString()}},g5=class{static{W(this,"MapKeyEqualityComparator")}keyComparator;constructor(_){this.keyComparator=_}hashCode(_){return this.keyComparator.hashCode(_.key)}equals(_,A){return this.keyComparator.equals(_.key,A.key)}},u0=class _{static{W(this,"HashMap")}backingStore;constructor(A){if(A instanceof _)this.backingStore=new $0(A.backingStore);else A=A??f4.instance,this.backingStore=new $0(new g5(A))}clear(){this.backingStore.clear()}containsKey(A){return this.backingStore.contains({key:A})}get(A){let R=this.backingStore.get({key:A});if(!R)return;return R.value}get isEmpty(){return this.backingStore.isEmpty}set(A,R){let U=this.backingStore.get({key:A,value:R}),Y;if(!U)this.backingStore.add({key:A,value:R});else Y=U.value,U.value=R;return Y}setIfAbsent(A,R){let U=this.backingStore.get({key:A,value:R}),Y;if(!U)this.backingStore.add({key:A,value:R});else Y=U.value;return Y}keys(){return this.backingStore.toArray().map((A)=>{return A.key})}values(){return this.backingStore.toArray().map((A)=>{return A.value})}get size(){return this.backingStore.size}hashCode(){return this.backingStore.hashCode()}equals(A){return this.backingStore.equals(A.backingStore)}},L0=class{static{W(this,"TerminalNode")}parent=null;symbol;constructor(_){this.symbol=_}getChild(_){return null}getSymbol(){return this.symbol}getPayload(){return this.symbol}getSourceInterval(){if(this.symbol===null)return b.INVALID_INTERVAL;let _=this.symbol.tokenIndex;return new b(_,_)}getChildCount(){return 0}accept(_){return _.visitTerminal(this)}getText(){return this.symbol?.text??""}toString(){if(this.symbol?.type===D.EOF)return"<EOF>";else return this.symbol?.text??""}toStringTree(){return this.toString()}},n1=class extends L0{static{W(this,"ErrorNode")}accept(_){return _.visitErrorNode(this)}},$2=class _{static{W(this,"CommonToken")}static EMPTY_SOURCE=[null,null];source;tokenIndex;start;stop;type;line;column;channel;#_;constructor(A){if(this.type=A.type,this.source=A.source,this.tokenIndex=A.tokenIndex??-1,this.line=A.line??0,this.column=A.column??-1,this.channel=A.channel??D.DEFAULT_CHANNEL,this.start=A.start??0,this.stop=A.stop??0,this.#_=A.text,A.line===void 0&&A.source[0]!==null)this.line=A.source[0].line;if(A.column===void 0&&A.source[0]!==null)this.column=A.source[0].column}static fromToken(A){let R=[A.tokenSource,A.inputStream];return new _({type:A.type,line:A.line,tokenIndex:A.tokenIndex,column:A.column,channel:A.channel,start:A.start,stop:A.stop,text:A.text,source:R})}static fromType(A,R){return new _({type:A,text:R,source:_.EMPTY_SOURCE})}static fromSource(A,R,U,Y,X){return new _({type:R,channel:U,start:Y,stop:X,source:A})}get tokenSource(){return this.source[0]}get inputStream(){return this.source[1]}set inputStream(A){this.source[1]=A}clone(){return new _({source:this.source,type:this.type,channel:this.channel,start:this.start,stop:this.stop,tokenIndex:this.tokenIndex,line:this.line,column:this.column,text:this.#_})}toString(A){let R="";if(this.channel>0)R=",channel="+this.channel;let U=this.text;if(U)U=U.replace(/\n/g,"\\n"),U=U.replace(/\r/g,"\\r"),U=U.replace(/\t/g,"\\t");else U="<no text>";let Y=String(this.type);if(A)Y=A.vocabulary.getDisplayName(this.type)??"<unknown>";return"[@"+this.tokenIndex+","+this.start+":"+this.stop+"='"+U+"',<"+Y+">"+R+","+this.line+":"+this.column+"]"}get text(){if(this.#_!==void 0)return this.#_;let A=this.inputStream;if(!A)return;let R=A.size;if(this.start<R&&this.stop<R)return A.getTextFromRange(this.start,this.stop);return"<EOF>"}set text(A){this.#_=A}setText(A){this.#_=A}setType(A){this.type=A}setLine(A){this.line=A}setCharPositionInLine(A){this.column=A}setChannel(A){this.channel=A}setTokenIndex(A){this.tokenIndex=A}},a0=class _{static{W(this,"Trees")}static toStringTree(A,R,U){if(R=R??null,U)R=U.ruleNames;let Y=_.getNodeText(A,R);Y=S5(Y,!1);let X=A.getChildCount();if(X===0)return Y;let G="("+Y+" ";if(X>0)Y=_.toStringTree(A.getChild(0),R),G=G.concat(Y);for(let Q=1;Q<X;Q++)Y=_.toStringTree(A.getChild(Q),R),G=G.concat(" "+Y);return G=G.concat(")"),G}static getNodeText(A,R,U){if(R=R??null,U)R=U.ruleNames;if(R!==null){if(A instanceof M){let G=A.ruleContext.getAltNumber();if(G!==0)return R[A.ruleIndex]+":"+G;return R[A.ruleIndex]}else if(A instanceof n1)return A.toString();else if(A instanceof L0)return A.symbol.text}let Y=A.getPayload();if(f5(Y))return Y.text;return String(A.getPayload())}static getChildren(A){let R=[];for(let U=0;U<A.getChildCount();U++)R.push(A.getChild(U));return R}static getAncestors(A){if(A.parent===null)return[];let R=[],U=A.parent;while(U!==null)R=[U].concat(R),U=U.parent;return R}static isAncestorOf(A,R){if(A===null||R===null||A.parent===null)return!1;let U=R.parent;while(U!==null){if(A===U)return!0;U=U.parent}return!1}static findAllTokenNodes(A,R){return _.findAllNodes(A,R,!0)}static findAllRuleNodes(A,R){return _.findAllNodes(A,R,!1)}static findAllNodes(A,R,U){let Y=[];return _.doFindAllNodes(A,R,U,Y),Y}static descendants(A){let R=[A];for(let U=0;U<A.getChildCount();U++)R=R.concat(_.descendants(A.getChild(U)));return R}static getRootOfSubtreeEnclosingRegion(A,R,U){let Y=A.getChildCount();for(let X=0;X<Y;X++){let G=A.getChild(X),Q=this.getRootOfSubtreeEnclosingRegion(G,R,U);if(Q!==null)return Q}if(A instanceof M){if(R>=A.start.tokenIndex&&(A.stop===null||U<=A.stop.tokenIndex))return A}return null}static stripChildrenOutOfRange(A,R,U,Y){if(A===null)return;for(let X=0;X<A.getChildCount();X++){let G=A.getChild(X),Q=G.getSourceInterval();if(A instanceof M&&(Q.stop<U||Q.start>Y)){if(this.isAncestorOf(G,R)){let J=$2.fromType(D.INVALID_TYPE,"...");A.children[X]=new L0(J)}}}}static doFindAllNodes(A,R,U,Y){if(U&&A instanceof L0){if(A.symbol?.type===R)Y.push(A)}else if(!U&&A instanceof M){if(A.ruleIndex===R)Y.push(A)}for(let X=0;X<A.getChildCount();X++)_.doFindAllNodes(A.getChild(X),R,U,Y)}},M=class _{static{W(this,"ParserRuleContext")}static empty=new _(null);start=null;stop=null;children=[];invokingState;parent;constructor(A,R=-1){this.parent=A,this.invokingState=R}copyFrom(A){if(this.parent=A.parent,this.invokingState=A.invokingState,this.children.slice(0,this.children.length),this.start=A.start,this.stop=A.stop,A.children)A.children.forEach((R)=>{if(R instanceof n1)this.children.push(R),R.parent=this})}enterRule(A){}exitRule(A){}addChild(A){return this.children.push(A),A}removeLastChild(){this.children.pop()}addTokenNode(A){let R=new L0(A);return this.children.push(R),R.parent=this,R}addErrorNode(A){return A.parent=this,this.children.push(A),A}getChild(A,R){if(A<0||A>=this.children.length)return null;if(!R)return this.children[A];for(let U of this.children)if(U instanceof R)if(A===0)return U;else A-=1;return null}getToken(A,R){if(R<0||R>=this.children.length)return null;for(let U of this.children)if("symbol"in U){if(U.symbol?.type===A)if(R===0)return U;else R-=1}return null}getTokens(A){let R=[];for(let U of this.children)if("symbol"in U){if(U.symbol?.type===A)R.push(U)}return R}getRuleContext(A,R){return this.getChild(A,R)}getRuleContexts(A){let R=[];for(let U of this.children)if(U instanceof A)R.push(U);return R}getChildCount(){return this.children.length}getSourceInterval(){if(this.start===null)return b.INVALID_INTERVAL;if(this.stop===null||this.stop.tokenIndex<this.start.tokenIndex)return new b(this.start.tokenIndex,this.start.tokenIndex-1);return new b(this.start.tokenIndex,this.stop.tokenIndex)}depth(){let A=0,R=this;while(R!==null)R=R.parent,A+=1;return A}isEmpty(){return this.invokingState===-1}get ruleContext(){return this}get ruleIndex(){return-1}getPayload(){return this}getText(){if(this.children.length===0)return"";return this.children.map((A)=>{return A.getText()}).join("")}getAltNumber(){return P.INVALID_ALT_NUMBER}setAltNumber(A){}accept(A){return A.visitChildren(this)}toStringTree(...A){if(A.length<2)return a0.toStringTree(this,null,A[0]);return a0.toStringTree(this,A[0],A[1])}toString(A,R){A=A??null,R=R??null;let U=this,Y="[";while(U!==null&&U!==R){if(A===null){if(!U.isEmpty())Y+=U.invokingState}else{let X=U.ruleIndex,G=X>=0&&X<A.length?A[X]:""+X;Y+=G}if(U.parent!==null&&(A!==null||!U.parent.isEmpty()))Y+=" ";U=U.parent}return Y+="]",Y}},s0=class _ extends n{static{W(this,"ArrayPredictionContext")}parents=[];returnStates=[];constructor(A,R){super(n.calculateHashCodeList(A,R));return this.parents=A,this.returnStates=R,this}isEmpty(){return this.returnStates[0]===n.EMPTY_RETURN_STATE}get length(){return this.returnStates.length}getParent(A){return this.parents[A]}getReturnState(A){return this.returnStates[A]}equals(A){if(this===A)return!0;if(!(A instanceof _)||this.hashCode()!==A.hashCode())return!1;return u5(this.returnStates,A.returnStates)&&I2(this.parents,A.parents)}toString(){if(this.isEmpty())return"[]";let A=[];for(let R=0;R<this.returnStates.length;R++){if(this.returnStates[R]===n.EMPTY_RETURN_STATE){A.push("$");continue}if(A.push(this.returnStates[R].toString()),this.parents[R])A.push(this.parents[R].toString());else A.push("null")}return`[${A.join(", ")}]`}},U1=W((_,A)=>{if(A===n.EMPTY_RETURN_STATE&&_===null)return c.instance;else return new B1(_,A)},"createSingletonPredictionContext"),A3=W((_,A)=>{if(!A)A=M.empty;if(!A.parent||A===M.empty)return c.instance;let R=A3(_,A.parent),Y=_.states[A.invokingState].transitions[0];return U1(R,Y.followState.stateNumber)},"predictionContextFromRuleContext"),h4=W((_,A,R)=>{if(_.isEmpty())return _;let U=R.get(_);if(U)return U;if(U=A.get(_),U)return R.set(_,U),U;let Y=!1,X=[];for(let Q=0;Q<X.length;Q++){let J=h4(_.getParent(Q),A,R);if(Y||J!==_.getParent(Q)){if(!Y){X=[];for(let F=0;F<_.length;F++)X[F]=_.getParent(F);Y=!0}X[Q]=J}}if(!Y)return A.add(_),R.set(_,_),_;let G;if(X.length===0)G=c.instance;else if(X.length===1)G=U1(X[0]??void 0,_.getReturnState(0));else G=new s0(X,_.returnStates);return A.add(G),R.set(G,G),R.set(_,G),G},"getCachedPredictionContext"),R3=W((_,A,R,U)=>{if(_===A||_.equals(A))return _;if(_ instanceof B1&&A instanceof B1)return T5(_,A,R,U);if(R){if(_ instanceof c)return _;if(A instanceof c)return A}if(_ instanceof B1)_=new s0([_.parent],[_.returnState]);if(A instanceof B1)A=new s0([A.parent],[A.returnState]);return d5(_,A,R,U)},"merge"),d5=W((_,A,R,U)=>{if(U){let I=U.get(_,A);if(I)return I;if(I=U.get(A,_),I)return I}let Y=0,X=0,G=0,Q=Array(_.returnStates.length+A.returnStates.length).fill(0),J=Array(_.returnStates.length+A.returnStates.length).fill(null);while(Y<_.returnStates.length&&X<A.returnStates.length){let I=_.parents[Y],B=A.parents[X];if(_.returnStates[Y]===A.returnStates[X]){let C=_.returnStates[Y];if(C===n.EMPTY_RETURN_STATE&&I===null&&B===null||I!==null&&B!==null&&I===B)J[G]=I,Q[G]=C;else J[G]=R3(I,B,R,U),Q[G]=C;Y+=1,X+=1}else if(_.returnStates[Y]<A.returnStates[X])J[G]=I,Q[G]=_.returnStates[Y],Y+=1;else J[G]=B,Q[G]=A.returnStates[X],X+=1;G+=1}if(Y<_.returnStates.length)for(let I=Y;I<_.returnStates.length;I++)J[G]=_.parents[I],Q[G]=_.returnStates[I],G+=1;else for(let I=X;I<A.returnStates.length;I++)J[G]=A.parents[I],Q[G]=A.returnStates[I],G+=1;if(G<J.length){if(G===1){let I=U1(J[0]??void 0,Q[0]);if(U!==null)U.set(_,A,I);return I}J=J.slice(0,G),Q=Q.slice(0,G)}let F=new s0(J,Q);if(F.equals(_)){if(U!==null)U.set(_,A,_);if(n.traceATNSimulator)console.log("mergeArrays a="+_+",b="+A+" -> a");return _}if(F.equals(A)){if(U!==null)U.set(_,A,A);return A}if(l5(J),U!==null)U.set(_,A,F);if(n.traceATNSimulator)console.log("mergeArrays a="+_+",b="+A+" -> "+F);return F},"mergeArrays"),l5=W((_)=>{let A=new u0(R1.instance);for(let R of _)if(R){if(!A.containsKey(R))A.set(R,R)}for(let R=0;R<_.length;R++)if(_[R])_[R]=A.get(_[R])??null},"combineCommonParents"),T5=W((_,A,R,U)=>{if(U!==null){let X=U.get(_,A);if(X!==null)return X;if(X=U.get(A,_),X!==null)return X}let Y=y5(_,A,R);if(Y!==null){if(U!==null)U.set(_,A,Y);return Y}if(_.returnState===A.returnState){let X=R3(_.parent,A.parent,R,U);if(X===_.parent)return _;if(X===A.parent)return A;let G=U1(X,_.returnState);if(U!==null)U.set(_,A,G);return G}else{let X=null;if(_===A||_.parent!==null&&_.parent.equals(A.parent))X=_.parent;if(X!==null){let F=[_.returnState,A.returnState];if(_.returnState>A.returnState)F[0]=A.returnState,F[1]=_.returnState;let B=new s0([X,X],F);if(U!==null)U.set(_,A,B);return B}let G=[_.returnState,A.returnState],Q=[_.parent,A.parent];if(_.returnState>A.returnState)G[0]=A.returnState,G[1]=_.returnState,Q=[A.parent,_.parent];let J=new s0(Q,G);if(U!==null)U.set(_,A,J);return J}},"mergeSingletons"),y5=W((_,A,R)=>{if(R){if(_===c.instance||A===c.instance)return c.instance}else{if(_===c.instance&&A===c.instance)return c.instance;if(_===c.instance){let U=[A.returnState,n.EMPTY_RETURN_STATE],Y=[A.parent,null];return new s0(Y,U)}if(A===c.instance){let U=[_.returnState,n.EMPTY_RETURN_STATE],Y=[_.parent,null];return new s0(Y,U)}}return null},"mergeRoot"),c5=class _{constructor(A){this.atn=A}static{W(this,"LL1Analyzer")}static hitPredicate=D.INVALID_TYPE;getDecisionLookahead(A){let R=A.transitions.length,U=Array(R);for(let Y=0;Y<R;Y++){let X=new K0,G=new $0;if(this.doLook(A.transitions[Y].target,void 0,c.instance,X,G,new j0,!1,!1),X.length>0&&!X.contains(_.hitPredicate))U[Y]=X}return U}look(A,R,U){let Y=new K0,X=U?A3(this.atn,U):null;return this.doLook(A,R,X,Y,new $0,new j0,!0,!0),Y}doLook(A,R,U,Y,X,G,Q,J){let F=y.createWithContext(A,0,U);if(X.get(F))return;if(X.add(F),A===R){if(!U){Y.addOne(D.EPSILON);return}else if(U.isEmpty()&&J){Y.addOne(D.EOF);return}}if(A.constructor.stateType===f.RULE_STOP){if(!U){Y.addOne(D.EPSILON);return}else if(U.isEmpty()&&J){Y.addOne(D.EOF);return}if(U!==c.instance){let I=G.get(A.ruleIndex);try{G.clear(A.ruleIndex);for(let B=0;B<U.length;B++){let C=this.atn.states[U.getReturnState(B)];this.doLook(C,R,U.getParent(B),Y,X,G,Q,J)}}finally{if(I)G.set(A.ruleIndex)}return}}for(let I of A.transitions)switch(I.transitionType){case j.RULE:{if(G.get(I.target.ruleIndex))continue;let B=U1(U??void 0,I.followState.stateNumber);try{G.set(I.target.ruleIndex),this.doLook(I.target,R,B,Y,X,G,Q,J)}finally{G.clear(I.target.ruleIndex)}break}case j.PREDICATE:case j.PRECEDENCE:{if(Q)this.doLook(I.target,R,U,Y,X,G,Q,J);else Y.addOne(_.hitPredicate);break}case j.WILDCARD:{Y.addRange(D.MIN_USER_TOKEN_TYPE,this.atn.maxTokenType);break}default:{if(I.isEpsilon)this.doLook(I.target,R,U,Y,X,G,Q,J);else{let B=I.label;if(B){if(I instanceof _3)B=B.complement(D.MIN_USER_TOKEN_TYPE,this.atn.maxTokenType);Y.addSet(B)}}break}}}},P=class{static{W(this,"ATN")}static INVALID_ALT_NUMBER=0;static LEXER=0;static PARSER=1;grammarType;maxTokenType;states=[];decisionToState=[];ruleToStartState=[];ruleToStopState=[];modeNameToStartState=new Map;ruleToTokenType=[];lexerActions=[];modeToStartState=[];analyzer;constructor(_,A){this.grammarType=_,this.maxTokenType=A,this.analyzer=new c5(this)}nextTokens(_,A){if(!A&&_.nextTokenWithinRule)return _.nextTokenWithinRule;let R=this.analyzer.look(_,void 0,A);if(!A)_.nextTokenWithinRule=R;return R}addState(_){if(_)_.stateNumber=this.states.length;this.states.push(_)}removeState(_){this.states[_.stateNumber]=null}defineDecisionState(_){return this.decisionToState.push(_),_.decision=this.decisionToState.length-1,_.decision}getDecisionState(_){if(this.decisionToState.length===0)return null;else return this.decisionToState[_]}getNumberOfDecisions(){return this.decisionToState.length}getExpectedTokens(_,A){if(_<0||_>=this.states.length)throw Error("Invalid state number.");let R=this.states[_],U=this.nextTokens(R);if(!U.contains(D.EPSILON))return U;let Y=A,X=new K0;X.addSet(U),X.removeOne(D.EPSILON);while(Y!==null&&Y.invokingState>=0&&U.contains(D.EPSILON)){let Q=this.states[Y.invokingState].transitions[0];U=this.nextTokens(Q.followState),X.addSet(U),X.removeOne(D.EPSILON),Y=Y.parent}if(U.contains(D.EPSILON))X.addOne(D.EOF);return X}},z4=class _{static{W(this,"KeyTypeEqualityComparer")}static instance=new _;hashCode(A){let R=7;return R=31*R+A.state.stateNumber,R=31*R+A.alt,R=31*R+A.semanticContext.hashCode(),R}equals(A,R){if(A===R)return!0;return A.state.stateNumber===R.state.stateNumber&&A.alt===R.alt&&A.semanticContext.equals(R.semanticContext)}},b0=class{static{W(this,"ATNConfigSet")}configLookup=new $0(z4.instance);configs=[];uniqueAlt=0;hasSemanticContext=!1;dipsIntoOuterContext=!1;fullCtx=!1;readOnly=!1;conflictingAlts=null;firstStopState;#_=-1;constructor(_){if(_!==void 0)if(typeof _==="boolean")this.fullCtx=_??!0;else{let A=_;this.addAll(A.configs),this.uniqueAlt=A.uniqueAlt,this.conflictingAlts=A.conflictingAlts,this.hasSemanticContext=A.hasSemanticContext,this.dipsIntoOuterContext=A.dipsIntoOuterContext}}[Symbol.iterator](){return this.configs[Symbol.iterator]()}add(_,A=null){if(this.readOnly)throw Error("This set is readonly");if(!this.firstStopState&&_.state.constructor.stateType===f.RULE_STOP)this.firstStopState=_;this.hasSemanticContext||=_.semanticContext!==u.NONE,this.dipsIntoOuterContext||=_.reachesIntoOuterContext;let R=this.configLookup.getOrAdd(_);if(R===_){this.#_=-1,this.configs.push(_);return}let U=!this.fullCtx,Y=R3(R.context,_.context,U,A);R.reachesIntoOuterContext||=_.reachesIntoOuterContext,R.precedenceFilterSuppressed||=_.precedenceFilterSuppressed,R.context=Y}get elements(){return this.configs}getAlts(){let _=new j0;for(let A of this.configs)_.set(A.alt);return _}getPredicates(){let _=[];for(let A of this.configs)if(A.semanticContext!==u.NONE)_.push(A.semanticContext);return _}getStates(){let _=new $0;for(let A of this.configs)_.add(A.state);return _}optimizeConfigs(_){if(this.readOnly)throw Error("This set is readonly");if(this.configLookup.size===0)return;for(let A of this.configs)A.context=_.getCachedContext(A.context)}addAll(_){for(let A of _)this.add(A);return!1}equals(_){if(this===_)return!0;if(this.fullCtx===_.fullCtx&&this.uniqueAlt===_.uniqueAlt&&this.conflictingAlts===_.conflictingAlts&&this.hasSemanticContext===_.hasSemanticContext&&this.dipsIntoOuterContext===_.dipsIntoOuterContext&&I2(this.configs,_.configs))return!0;return!1}hashCode(){if(this.#_===-1)this.#_=this.computeHashCode();return this.#_}get length(){return this.configs.length}isEmpty(){return this.configs.length===0}contains(_){if(this.configLookup===null)throw Error("This method is not implemented for readonly sets.");return this.configLookup.contains(_)}containsFast(_){if(this.configLookup===null)throw Error("This method is not implemented for readonly sets.");return this.configLookup.contains(_)}clear(){if(this.readOnly)throw Error("This set is readonly");this.configs=[],this.#_=-1,this.configLookup=new $0(z4.instance)}setReadonly(_){if(this.readOnly=_,_)this.configLookup=null}toString(){return D1(this.configs)+(this.hasSemanticContext?",hasSemanticContext="+this.hasSemanticContext:"")+(this.uniqueAlt!==P.INVALID_ALT_NUMBER?",uniqueAlt="+this.uniqueAlt:"")+(this.conflictingAlts!==null?",conflictingAlts="+this.conflictingAlts:"")+(this.dipsIntoOuterContext?",dipsIntoOuterContext":"")}computeHashCode(){let _=k.initialize();return this.configs.forEach((A)=>{_=k.update(_,A.hashCode())}),_=k.finish(_,this.configs.length),_}},K4=class extends f{static{W(this,"BasicState")}static stateType=f.BASIC},Y1=class extends f{static{W(this,"DecisionState")}decision=-1;nonGreedy=!1},A1=class extends Y1{static{W(this,"BlockStartState")}endState},c2=class extends f{static{W(this,"BlockEndState")}static stateType=f.BLOCK_END;startState},z1=class extends f{static{W(this,"LoopEndState")}static stateType=f.LOOP_END;loopBackState},o2=class extends f{static{W(this,"RuleStartState")}static stateType=f.RULE_START;stopState;isLeftRecursiveRule=!1},z0=class extends f{static{W(this,"RuleStopState")}static stateType=f.RULE_STOP},a5=class extends Y1{static{W(this,"TokensStartState")}static stateType=f.TOKEN_START},L4=class extends Y1{static{W(this,"PlusLoopbackState")}static stateType=f.PLUS_LOOP_BACK},a2=class extends f{static{W(this,"StarLoopbackState")}static stateType=f.STAR_LOOP_BACK},c0=class extends Y1{static{W(this,"StarLoopEntryState")}static stateType=f.STAR_LOOP_ENTRY;loopBackState;precedenceRuleDecision=!1},s2=class extends A1{static{W(this,"PlusBlockStartState")}static stateType=f.PLUS_BLOCK_START;loopBackState},n2=class extends A1{static{W(this,"StarBlockStartState")}static stateType=f.STAR_BLOCK_START},D4=class extends A1{static{W(this,"BasicBlockStartState")}static stateType=f.BLOCK_START},a1=class extends j{static{W(this,"AtomTransition")}labelValue;#_;constructor(_,A){super(_);this.labelValue=A,this.#_=K0.of(A,A)}get label(){return this.#_}get transitionType(){return j.ATOM}matches(_){return this.labelValue===_}toString(){return this.labelValue.toString()}},i2=class extends j{static{W(this,"RuleTransition")}ruleIndex;precedence;followState;constructor(_,A,R,U){super(_);this.ruleIndex=A,this.precedence=R,this.followState=U}get isEpsilon(){return!0}get transitionType(){return j.RULE}matches(_,A,R){return!1}},t2=class extends j{static{W(this,"RangeTransition")}start;stop;#_=new K0;constructor(_,A,R){super(_);this.start=A,this.stop=R,this.#_.addRange(A,R)}get label(){return this.#_}get transitionType(){return j.RANGE}matches(_,A,R){return _>=this.start&&_<=this.stop}toString(){return"'"+String.fromCharCode(this.start)+"'..'"+String.fromCharCode(this.stop)+"'"}},V4=class extends j{static{W(this,"ActionTransition")}ruleIndex;actionIndex;isCtxDependent;constructor(_,A,R,U){super(_);this.ruleIndex=A,this.actionIndex=R??-1,this.isCtxDependent=U??!1}get isEpsilon(){return!0}get transitionType(){return j.ACTION}matches(_,A,R){return!1}toString(){return"action_"+this.ruleIndex+":"+this.actionIndex}},c1=class extends j{static{W(this,"EpsilonTransition")}#_;constructor(_,A=-1){super(_);this.#_=A}get outermostPrecedenceReturn(){return this.#_}get isEpsilon(){return!0}get transitionType(){return j.EPSILON}matches(){return!1}toString(){return"epsilon"}},s5=class extends j{static{W(this,"WildcardTransition")}get transitionType(){return j.WILDCARD}matches(_,A,R){return _>=A&&_<=R}toString(){return"."}},P4=class extends j{static{W(this,"AbstractPredicateTransition")}constructor(_){super(_)}},v4=class extends P4{static{W(this,"PredicateTransition")}ruleIndex;predIndex;isCtxDependent;constructor(_,A,R,U){super(_);this.ruleIndex=A,this.predIndex=R,this.isCtxDependent=U}get isEpsilon(){return!0}matches(_,A,R){return!1}get transitionType(){return j.PREDICATE}getPredicate(){return new u.Predicate(this.ruleIndex,this.predIndex,this.isCtxDependent)}toString(){return"pred_"+this.ruleIndex+":"+this.predIndex}},n5=class extends P4{static{W(this,"PrecedencePredicateTransition")}precedence;constructor(_,A){super(_);this.precedence=A}get isEpsilon(){return!0}matches(_,A,R){return!1}getPredicate(){return new u.PrecedencePredicate(this.precedence)}get transitionType(){return j.PRECEDENCE}toString(){return this.precedence+" >= _p"}},S={CHANNEL:0,CUSTOM:1,MODE:2,MORE:3,POP_MODE:4,PUSH_MODE:5,SKIP:6,TYPE:7},p5=class _{static{W(this,"LexerSkipAction")}static instance=new _;actionType;isPositionDependent=!1;constructor(){this.actionType=S.SKIP}equals(A){return A===this}hashCode(){return S.SKIP}execute(A){A.skip()}toString(){return"skip"}},o5=class _{static{W(this,"LexerChannelAction")}channel;actionType;isPositionDependent=!1;cachedHashCode;constructor(A){this.actionType=S.CHANNEL,this.channel=A}execute(A){A.channel=this.channel}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize();A=k.update(A,this.actionType),A=k.update(A,this.channel),this.cachedHashCode=k.finish(A,2)}return this.cachedHashCode}equals(A){if(this===A)return!0;if(!(A instanceof _))return!1;return this.channel===A.channel}toString(){return"channel("+this.channel+")"}},i5=class _{static{W(this,"LexerCustomAction")}ruleIndex;actionIndex;actionType;isPositionDependent=!0;cachedHashCode;constructor(A,R){this.actionType=S.CUSTOM,this.ruleIndex=A,this.actionIndex=R}execute(A){A.action(null,this.ruleIndex,this.actionIndex)}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize();A=k.update(A,this.actionType),A=k.update(A,this.ruleIndex),A=k.update(A,this.actionIndex),this.cachedHashCode=k.finish(A,3)}return this.cachedHashCode}equals(A){if(this===A)return!0;if(!(A instanceof _))return!1;return this.ruleIndex===A.ruleIndex&&this.actionIndex===A.actionIndex}},t5=class _{static{W(this,"LexerMoreAction")}static instance=new _;actionType;isPositionDependent=!1;constructor(){this.actionType=S.MORE}equals(A){return A===this}hashCode(){return S.MORE}execute(A){A.more()}toString(){return"more"}},r5=class _{static{W(this,"LexerTypeAction")}type;actionType;isPositionDependent=!1;cachedHashCode;constructor(A){this.actionType=S.TYPE,this.type=A}execute(A){A.type=this.type}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize();A=k.update(A,this.actionType),A=k.update(A,this.type),this.cachedHashCode=k.finish(A,2)}return this.cachedHashCode}equals(A){if(this===A)return!0;if(!(A instanceof _))return!1;return this.type===A.type}toString(){return"type("+this.type+")"}},e5=class _{static{W(this,"LexerPushModeAction")}mode;actionType;isPositionDependent=!1;cachedHashCode;constructor(A){this.actionType=S.PUSH_MODE,this.mode=A}execute(A){A.pushMode(this.mode)}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize();A=k.update(A,this.actionType),A=k.update(A,this.mode),this.cachedHashCode=k.finish(A,2)}return this.cachedHashCode}equals(A){if(this===A)return!0;if(!(A instanceof _))return!1;return this.mode===A.mode}toString(){return"pushMode("+this.mode+")"}},_6=class _{static{W(this,"LexerPopModeAction")}static instance=new _;actionType;isPositionDependent=!1;constructor(){this.actionType=S.POP_MODE}equals(A){return A===this}hashCode(){return S.POP_MODE}execute(A){A.popMode()}toString(){return"popMode"}},A6=class _{static{W(this,"LexerModeAction")}mode;actionType;isPositionDependent=!1;cachedHashCode;constructor(A){this.actionType=S.MODE,this.mode=A}execute(A){A.mode=this.mode}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize();A=k.update(A,this.actionType),A=k.update(A,this.mode),this.cachedHashCode=k.finish(A,2)}return this.cachedHashCode}equals(A){if(this===A)return!0;if(!(A instanceof _))return!1;return this.mode===A.mode}toString(){return"mode("+this.mode+")"}},n0=class _{static{W(this,"ATNDeserializer")}static SERIALIZED_VERSION=4;static stateTypeMapper=new Map([[f.INVALID_TYPE,void 0],[f.BASIC,K4],[f.RULE_START,o2],[f.BLOCK_START,D4],[f.PLUS_BLOCK_START,s2],[f.STAR_BLOCK_START,n2],[f.TOKEN_START,a5],[f.RULE_STOP,z0],[f.BLOCK_END,c2],[f.STAR_LOOP_BACK,a2],[f.STAR_LOOP_ENTRY,c0],[f.PLUS_LOOP_BACK,L4],[f.LOOP_END,z1]]);static lexerActionFactoryMapper=new Map([[S.CHANNEL,(A)=>{return new o5(A)}],[S.CUSTOM,(A,R)=>{return new i5(A,R)}],[S.MODE,(A)=>{return new A6(A)}],[S.MORE,()=>{return t5.instance}],[S.POP_MODE,()=>{return _6.instance}],[S.PUSH_MODE,(A)=>{return new e5(A)}],[S.SKIP,()=>{return p5.instance}],[S.TYPE,(A)=>{return new r5(A)}]]);data=[];pos=0;deserializationOptions;actionFactories;constructor(A){if(!A)A={readOnly:!1,verifyATN:!0,generateRuleBypassTransitions:!1};this.deserializationOptions=A}deserialize(A){this.data=A,this.checkVersion();let R=this.readATN();this.readStates(R),this.readRules(R),this.readModes(R);let U=[];if(this.readSets(R,U),this.readEdges(R,U),this.readDecisions(R),this.readLexerActions(R),this.markPrecedenceDecisions(R),this.verifyATN(R),this.deserializationOptions.generateRuleBypassTransitions&&R.grammarType===P.PARSER)this.generateRuleBypassTransitions(R),this.verifyATN(R);return R}checkVersion(){let A=this.data[this.pos++];if(A!==_.SERIALIZED_VERSION)throw Error("Could not deserialize ATN with version "+A+" (expected "+_.SERIALIZED_VERSION+").")}readATN(){let A=this.data[this.pos++],R=this.data[this.pos++];return new P(A,R)}readStates(A){let R,U,Y=[],X=[],G=this.data[this.pos++];for(let F=0;F<G;F++){let I=this.data[this.pos++];if(I===f.INVALID_TYPE){A.addState(null);continue}let B=this.data[this.pos++],C=this.stateFactory(I,B);if(I===f.LOOP_END){let V=this.data[this.pos++];Y.push([C,V])}else if(C instanceof A1){let V=this.data[this.pos++];X.push([C,V])}A.addState(C)}for(R=0;R<Y.length;R++){let F=Y[R];F[0].loopBackState=A.states[F[1]]??void 0}for(R=0;R<X.length;R++){let F=X[R];F[0].endState=A.states[F[1]]}let Q=this.data[this.pos++];for(R=0;R<Q;R++)U=this.data[this.pos++],A.states[U].nonGreedy=!0;let J=this.data[this.pos++];for(R=0;R<J;R++)U=this.data[this.pos++],A.states[U].isLeftRecursiveRule=!0}readRules(A){let R,U=this.data[this.pos++];if(A.grammarType===P.LEXER)A.ruleToTokenType=Array(U),A.ruleToTokenType.fill(0);A.ruleToStartState=Array(U),A.ruleToStartState.fill(null);for(R=0;R<U;R++){let Y=this.data[this.pos++];if(A.ruleToStartState[R]=A.states[Y],A.grammarType===P.LEXER){let X=this.data[this.pos++];A.ruleToTokenType[R]=X}}A.ruleToStopState=Array(U),A.ruleToStopState.fill(null);for(R=0;R<A.states.length;R++){let Y=A.states[R];if(!(Y instanceof z0))continue;A.ruleToStopState[Y.ruleIndex]=Y,A.ruleToStartState[Y.ruleIndex].stopState=Y}}readModes(A){let R=this.data[this.pos++];for(let U=0;U<R;U++){let Y=this.data[this.pos++];A.modeToStartState.push(A.states[Y])}}readSets(A,R){let U=this.data[this.pos++];for(let Y=0;Y<U;Y++){let X=new K0;R.push(X);let G=this.data[this.pos++];if(this.data[this.pos++]!==0)X.addOne(-1);for(let J=0;J<G;J++){let F=this.data[this.pos++],I=this.data[this.pos++];X.addRange(F,I)}}}readEdges(A,R){let U,Y,X,G,Q,J=this.data[this.pos++];for(U=0;U<J;U++){let F=this.data[this.pos++],I=this.data[this.pos++],B=this.data[this.pos++],C=this.data[this.pos++],V=this.data[this.pos++],x=this.data[this.pos++];G=this.edgeFactory(A,B,I,C,V,x,R),A.states[F].addTransition(G)}for(U=0;U<A.states.length;U++){X=A.states[U];for(Y=0;Y<X.transitions.length;Y++){let F=X.transitions[Y];if(!(F instanceof i2))continue;let I=-1;if(A.ruleToStartState[F.target.ruleIndex].isLeftRecursiveRule){if(F.precedence===0)I=F.target.ruleIndex}G=new c1(F.followState,I),A.ruleToStopState[F.target.ruleIndex].addTransition(G)}}for(U=0;U<A.states.length;U++){if(X=A.states[U],X instanceof A1){if(!X.endState)throw Error("IllegalState");if(X.endState.startState)throw Error("IllegalState");X.endState.startState=X}if(X instanceof L4){for(Y=0;Y<X.transitions.length;Y++)if(Q=X.transitions[Y].target,Q instanceof s2)Q.loopBackState=X}else if(X instanceof a2){for(Y=0;Y<X.transitions.length;Y++)if(Q=X.transitions[Y].target,Q instanceof c0)Q.loopBackState=X}}}readDecisions(A){let R=this.data[this.pos++];for(let U=0;U<R;U++){let Y=this.data[this.pos++],X=A.states[Y];A.decisionToState.push(X),X.decision=U}}readLexerActions(A){if(A.grammarType===P.LEXER){let R=this.data[this.pos++];A.lexerActions=[];for(let U=0;U<R;U++){let Y=this.data[this.pos++],X=this.data[this.pos++],G=this.data[this.pos++];A.lexerActions.push(this.lexerActionFactory(Y,X,G))}}}generateRuleBypassTransitions(A){let R,U=A.ruleToStartState.length;for(R=0;R<U;R++)A.ruleToTokenType[R]=A.maxTokenType+R+1;for(R=0;R<U;R++)this.generateRuleBypassTransition(A,R)}generateRuleBypassTransition(A,R){let U,Y,X=new D4;X.ruleIndex=R,A.addState(X);let G=new c2;G.ruleIndex=R,A.addState(G),X.endState=G,A.defineDecisionState(X),G.startState=X;let Q=null,J=null;if(A.ruleToStartState[R].isLeftRecursiveRule){J=null;for(U=0;U<A.states.length;U++)if(Y=A.states[U],this.stateIsEndStateFor(Y,R)){J=Y,Q=Y.loopBackState.transitions[0];break}if(Q===null)throw Error("Couldn't identify final state of the precedence rule prefix section.")}else J=A.ruleToStopState[R];for(U=0;U<A.states.length;U++){Y=A.states[U];for(let B of Y.transitions){if(B===Q)continue;if(B.target===J)B.target=G}}let F=A.ruleToStartState[R];while(F.transitions.length>0){let B=F.removeTransition(F.transitions.length-1);X.addTransition(B)}if(A.ruleToStartState[R].addTransition(new c1(X)),J)G.addTransition(new c1(J));let I=new K4;A.addState(I),I.addTransition(new a1(G,A.ruleToTokenType[R])),X.addTransition(new c1(I))}stateIsEndStateFor(A,R){if(A.ruleIndex!==R)return null;if(!(A instanceof c0))return null;let U=A.transitions[A.transitions.length-1].target;if(!(U instanceof z1))return null;if(U.epsilonOnlyTransitions&&U.transitions[0].target instanceof z0)return A;else return null}markPrecedenceDecisions(A){for(let R of A.states){if(!(R instanceof c0))continue;if(A.ruleToStartState[R.ruleIndex].isLeftRecursiveRule){let U=R.transitions[R.transitions.length-1].target;if(U instanceof z1){if(U.epsilonOnlyTransitions&&U.transitions[0].target instanceof z0)R.precedenceRuleDecision=!0}}}}verifyATN(A){if(!this.deserializationOptions.verifyATN)return;for(let R of A.states){if(R===null)continue;if(this.checkCondition(R.epsilonOnlyTransitions||R.transitions.length<=1),R instanceof s2)this.checkCondition(R.loopBackState!==null);else if(R instanceof c0)if(this.checkCondition(R.loopBackState!==null),this.checkCondition(R.transitions.length===2),R.transitions[0].target instanceof n2)this.checkCondition(R.transitions[1].target instanceof z1),this.checkCondition(!R.nonGreedy);else if(R.transitions[0].target instanceof z1)this.checkCondition(R.transitions[1].target instanceof n2),this.checkCondition(R.nonGreedy);else throw Error("IllegalState");else if(R instanceof a2)this.checkCondition(R.transitions.length===1),this.checkCondition(R.transitions[0].target instanceof c0);else if(R instanceof z1)this.checkCondition(R.loopBackState!==null);else if(R instanceof o2)this.checkCondition(R.stopState!==null);else if(R instanceof A1)this.checkCondition(R.endState!==null);else if(R instanceof c2)this.checkCondition(R.startState!==null);else if(R instanceof Y1)this.checkCondition(R.transitions.length<=1||R.decision>=0);else this.checkCondition(R.transitions.length<=1||R instanceof z0)}}checkCondition(A,R){if(!A){if(R===void 0||R===null)R="IllegalState";throw R}}edgeFactory(A,R,U,Y,X,G,Q){let J=A.states[U];switch(R){case j.EPSILON:return new c1(J);case j.RANGE:return G!==0?new t2(J,D.EOF,X):new t2(J,Y,X);case j.RULE:return new i2(A.states[Y],X,G,J);case j.PREDICATE:return new v4(J,Y,X,G!==0);case j.PRECEDENCE:return new n5(J,Y);case j.ATOM:return G!==0?new a1(J,D.EOF):new a1(J,Y);case j.ACTION:return new V4(J,Y,X,G!==0);case j.SET:return new e2(J,Q[Y]);case j.NOT_SET:return new _3(J,Q[Y]);case j.WILDCARD:return new s5(J);default:throw Error("The specified transition type: "+R+" is not valid.")}}stateFactory(A,R){let U=_.stateTypeMapper.get(A);if(!U)throw Error("The specified state type "+A+" is not valid.");let Y=new U;return Y.ruleIndex=R,Y}lexerActionFactory(A,R,U){let Y=_.lexerActionFactoryMapper.get(A);if(!Y)throw Error("The specified lexer action type "+A+" is not valid.");return Y(R,U)}},R6=class _ extends u0{static{W(this,"OrderedHashMap")}#_=[];clear(){super.clear(),this.#_=[]}get(A){return super.get(A)}set(A,R){let U=super.set(A,R);if(U===void 0)this.#_.push(A);return U}setIfAbsent(A,R){let U=super.setIfAbsent(A,R);if(U===void 0)this.#_.push(A);return U}values(){return{[Symbol.iterator]:()=>{let A=0;return{next:W(()=>{if(A<this.#_.length)return{done:!1,value:super.get(this.#_[A++])};return{done:!0,value:void 0}},"next")}}}}keys(){return this.#_[Symbol.iterator]()}equals(A){if(!(A instanceof _))return!1;return super.equals(A)}},b7=class _{static{W(this,"ATNSerializer")}atn;data=[];sets=new R6(R1.instance);nonGreedyStates=[];precedenceStates=[];constructor(A){this.atn=A}static getSerialized(A){return new _(A).serialize()}static serializeSets(A,R){A.push(R.length);for(let U of R){let Y=U.contains(D.EOF),X=[...U];if(Y&&X[0].stop===D.EOF)A.push(X.length-1);else A.push(X.length);A.push(Y?1:0);for(let G of X){if(G.start===D.EOF)if(G.stop===D.EOF)continue;else A.push(0);else A.push(G.start);A.push(G.stop)}}}serialize(){this.addPreamble();let A=this.addEdges();this.addNonGreedyStates(),this.addPrecedenceStates(),this.addRuleStatesAndLexerTokenTypes(),this.addModeStartStates();let R=this.addSets();return this.addEdges(A,R),this.addDecisionStartStates(),this.addLexerActions(),this.data}addPreamble(){this.data.push(n0.SERIALIZED_VERSION),this.data.push(this.atn.grammarType),this.data.push(this.atn.maxTokenType)}addLexerActions(){if(this.atn.grammarType===P.LEXER){this.data.push(this.atn.lexerActions.length);for(let A of this.atn.lexerActions)switch(this.data.push(A.actionType),A.actionType){case S.CHANNEL:{let R=A.channel;this.data.push(R),this.data.push(0);break}case S.CUSTOM:{let{ruleIndex:R,actionIndex:U}=A;this.data.push(R),this.data.push(U);break}case S.MODE:{let R=A.mode;this.data.push(R),this.data.push(0);break}case S.MORE:{this.data.push(0),this.data.push(0);break}case S.POP_MODE:{this.data.push(0),this.data.push(0);break}case S.PUSH_MODE:{let R=A.mode;this.data.push(R),this.data.push(0);break}case S.SKIP:{this.data.push(0),this.data.push(0);break}case S.TYPE:{let R=A.type;this.data.push(R),this.data.push(0);break}default:throw Error(`The specified lexer action type ${A.actionType} is not valid.`)}}}addDecisionStartStates(){this.data.push(this.atn.decisionToState.length);for(let A of this.atn.decisionToState)this.data.push(A.stateNumber)}addEdges(...A){switch(A.length){case 0:{let R=0;this.data.push(this.atn.states.length);for(let U of this.atn.states){if(U===null){this.data.push(f.INVALID_TYPE);continue}let Y=U.constructor.stateType;if(U instanceof Y1&&U.nonGreedy)this.nonGreedyStates.push(U.stateNumber);if(U instanceof o2&&U.isLeftRecursiveRule)this.precedenceStates.push(U.stateNumber);if(this.data.push(Y),this.data.push(U.ruleIndex),U.constructor.stateType===f.LOOP_END)this.data.push(U.loopBackState.stateNumber);else if(U instanceof A1)this.data.push(U.endState.stateNumber);if(U.constructor.stateType!==f.RULE_STOP)R+=U.transitions.length;for(let X of U.transitions){let G=X.transitionType;if(G===j.SET||G===j.NOT_SET){let Q=X;this.sets.set(Q.set,!0)}}}return R}case 2:{let[R,U]=A;this.data.push(R);for(let Y of this.atn.states){if(Y===null)continue;if(Y.constructor.stateType===f.RULE_STOP)continue;for(let X of Y.transitions){if(this.atn.states[X.target.stateNumber]===null)throw Error("Cannot serialize a transition to a removed state.");let G=Y.stateNumber,Q=X.target.stateNumber,J=X.transitionType,F=0,I=0,B=0;switch(J){case j.RULE:{Q=X.followState.stateNumber,F=X.target.stateNumber,I=X.ruleIndex,B=X.precedence;break}case j.PRECEDENCE:{F=X.precedence;break}case j.PREDICATE:{let C=X;F=C.ruleIndex,I=C.predIndex,B=C.isCtxDependent?1:0;break}case j.RANGE:{if(F=X.start,I=X.stop,F===D.EOF)F=0,B=1;break}case j.ATOM:{if(F=X.labelValue,F===D.EOF)F=0,B=1;break}case j.ACTION:{let C=X;F=C.ruleIndex,I=C.actionIndex,B=C.isCtxDependent?1:0;break}case j.SET:{F=U.get(X.set);break}case j.NOT_SET:{F=U.get(X.set);break}case j.WILDCARD:break;default:}this.data.push(G),this.data.push(Q),this.data.push(J),this.data.push(F),this.data.push(I),this.data.push(B)}}break}default:throw Error("Invalid number of arguments")}}addSets(){_.serializeSets(this.data,[...this.sets.keys()]);let A=new u0,R=0;for(let U of this.sets.keys())A.set(U,R++);return A}addModeStartStates(){let A=this.atn.modeToStartState.length;if(this.data.push(A),A>0)for(let R of this.atn.modeToStartState)this.data.push(R.stateNumber)}addRuleStatesAndLexerTokenTypes(){let A=this.atn.ruleToStartState.length;this.data.push(A);for(let R=0;R<A;R++){let U=this.atn.ruleToStartState[R];if(this.data.push(U.stateNumber),this.atn.grammarType===P.LEXER)this.data.push(this.atn.ruleToTokenType[R])}}addPrecedenceStates(){this.data.push(this.precedenceStates.length);for(let A of this.precedenceStates)this.data.push(A)}addNonGreedyStates(){this.data.push(this.nonGreedyStates.length);for(let A of this.nonGreedyStates)this.data.push(A)}},w1=class _{static{W(this,"DFAState")}stateNumber=-1;configs;edges=[];isAcceptState=!1;prediction=-1;lexerActionExecutor=null;requiresFullContext=!1;predicates=null;constructor(A){if(A)this.configs=A}static fromState(A){let R=new _;return R.stateNumber=A,R}static fromConfigs(A){return new _(A)}static hashCode(A){return A.configs.hashCode()}static equals(A,R){return A.configs.equals(R.configs)}getAltSet(){let A=new Set;for(let R of this.configs)A.add(R.alt);if(A.size===0)return null;return A}toString(){let A="";if(A+=this.stateNumber,A+=":",A+=this.configs?this.configs.toString():"",this.isAcceptState)if(A+="=>",this.predicates)A+=D1(this.predicates);else A+=this.prediction;return A.toString()}},C0=class{static{W(this,"ATNSimulator")}static ERROR=w1.fromState(2147483647);atn;sharedContextCache;constructor(_,A){return this.atn=_,this.sharedContextCache=A,this}getCachedContext(_){if(!this.sharedContextCache)return _;let A=new u0(R1.instance);return h4(_,this.sharedContextCache,A)}},u7=class _{static{W(this,"CodePointTransitions")}static createWithCodePoint(A,R){return _.createWithCodePointRange(A,R,R)}static createWithCodePointRange(A,R,U){return R===U?new a1(A,R):new t2(A,R,U)}},U6=class{static{W(this,"DecisionInfo")}decision=0;invocations=0;timeInPrediction=0;sllTotalLook=0;sllMinLook=0;sllMaxLook=0;sllMaxLookEvent;llTotalLook=0;llMinLook=0;llMaxLook=0;llMaxLookEvent;contextSensitivities;errors;ambiguities;predicateEvals;sllATNTransitions=0;sllDFATransitions=0;llFallback=0;llATNTransitions=0;llDFATransitions=0;constructor(_){this.decision=_,this.contextSensitivities=[],this.errors=[],this.ambiguities=[],this.predicateEvals=[]}toString(){return"{decision="+this.decision+", contextSensitivities="+this.contextSensitivities.length+", errors="+this.errors.length+", ambiguities="+this.ambiguities.length+", sllLookahead="+this.sllTotalLook+", sllATNTransitions="+this.sllATNTransitions+", sllDFATransitions="+this.sllDFATransitions+", llFallback="+this.llFallback+", llLookahead="+this.llTotalLook+", llATNTransitions="+this.llATNTransitions+"}"}},k0=class _ extends y{static{W(this,"LexerATNConfig")}lexerActionExecutor;passedThroughNonGreedyDecision;constructor(A,R,U,Y){super(A,R,U??A.context,U?u.NONE:A.semanticContext);return this.lexerActionExecutor=U?Y:A.lexerActionExecutor??null,this.passedThroughNonGreedyDecision=_.checkNonGreedyDecision(A,this.state),this}static createWithExecutor(A,R,U){return new _(A,R,A.context,U)}static createWithConfig(A,R,U){return new _(R,A,U??null,R.lexerActionExecutor)}static createWithContext(A,R,U){return new _({alt:R},A,U,null)}static checkNonGreedyDecision(A,R){return A.passedThroughNonGreedyDecision||"nonGreedy"in R&&R.nonGreedy}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize(7);A=k.update(A,this.state.stateNumber),A=k.update(A,this.alt),A=k.updateFromComparable(A,this.context),A=k.updateFromComparable(A,this.semanticContext),A=k.update(A,this.passedThroughNonGreedyDecision?1:0),A=k.updateFromComparable(A,this.lexerActionExecutor),A=k.finish(A,6),this.cachedHashCode=A}return this.cachedHashCode}equals(A){if(this===A)return!0;return this.passedThroughNonGreedyDecision===A.passedThroughNonGreedyDecision&&(this.lexerActionExecutor&&A.lexerActionExecutor?this.lexerActionExecutor.equals(A.lexerActionExecutor):!A.lexerActionExecutor)&&super.equals(A)}},W2=class{static{W(this,"BaseErrorListener")}syntaxError(_,A,R,U,Y,X){}reportAmbiguity(_,A,R,U,Y,X,G){}reportAttemptingFullContext(_,A,R,U,Y,X){}reportContextSensitivity(_,A,R,U,Y,X){}},Y6=class _ extends W2{static{W(this,"ConsoleErrorListener")}static instance=new _;syntaxError(A,R,U,Y,X,G){console.error("line "+U+":"+Y+" "+X)}},X6=class extends W2{constructor(_){super();return this.delegates=_,this}static{W(this,"ProxyErrorListener")}syntaxError(_,A,R,U,Y,X){this.delegates.forEach((G)=>{G.syntaxError(_,A,R,U,Y,X)})}reportAmbiguity(_,A,R,U,Y,X,G){this.delegates.forEach((Q)=>{Q.reportAmbiguity(_,A,R,U,Y,X,G)})}reportAttemptingFullContext(_,A,R,U,Y,X){this.delegates.forEach((G)=>{G.reportAttemptingFullContext(_,A,R,U,Y,X)})}reportContextSensitivity(_,A,R,U,Y,X){this.delegates.forEach((G)=>{G.reportContextSensitivity(_,A,R,U,Y,X)})}},b4=class _{static{W(this,"Recognizer")}static EOF=-1;static tokenTypeMapCache=new Map;static ruleIndexMapCache=new Map;interpreter;listeners=[Y6.instance];stateNumber=-1;checkVersion(A){if(A!=="4.13.1")console.error("ANTLR runtime and generated code versions disagree: 4.13.1!="+A)}addErrorListener(A){this.listeners.push(A)}removeErrorListeners(){this.listeners=[]}removeErrorListener(A){for(let R=0;R<this.listeners.length;R++)if(this.listeners[R]===A){this.listeners.splice(R,1);return}}getErrorListeners(){return this.listeners}getTokenTypeMap(){let A=this.vocabulary,R=_.tokenTypeMapCache.get(A);if(!R){R=new Map;for(let U=0;U<=this.atn.maxTokenType;U++){let Y=A.getLiteralName(U);if(Y)R.set(Y,U);let X=A.getSymbolicName(U);if(X)R.set(X,U)}R.set("EOF",D.EOF),_.tokenTypeMapCache.set(A,R)}return R}getRuleIndexMap(){let A=this.ruleNames,R=_.ruleIndexMapCache.get(A);if(!R)R=new Map,A.forEach((U,Y)=>{return R.set(U,Y)}),_.ruleIndexMapCache.set(A,R);return R}getTokenType(A){let R=this.getTokenTypeMap().get(A);if(R)return R;return D.INVALID_TYPE}getErrorHeader(A){let R=A.offendingToken?.line,U=A.offendingToken?.column;return"line "+R+":"+U}get errorListenerDispatch(){return new X6(this.listeners)}sempred(A,R,U){return!0}precpred(A,R){return!0}action(A,R,U){}get atn(){return this.interpreter.atn}get state(){return this.stateNumber}set state(A){this.stateNumber=A}getParseInfo(){return}},u4=class _{static{W(this,"CommonTokenFactory")}static DEFAULT=new _;copyText=!1;constructor(A){this.copyText=A??!1}create(A,R,U,Y,X,G,Q,J){let F=$2.fromSource(A,R,Y,X,G);if(F.line=Q,F.column=J,U)F.text=U;else if(this.copyText&&A[1]!==null)F.text=A[1].getTextFromRange(X,G);return F}},h=class _ extends Error{static{W(this,"RecognitionException")}ctx;offendingToken=null;offendingState=-1;recognizer;input;constructor(A){super(A.message);if(Error.captureStackTrace)Error.captureStackTrace(this,_);if(this.message=A.message,this.recognizer=A.recognizer,this.input=A.input,this.ctx=A.ctx,this.recognizer!==null)this.offendingState=this.recognizer.state}getExpectedTokens(){if(this.recognizer!==null&&this.ctx!==null)return this.recognizer.atn.getExpectedTokens(this.offendingState,this.ctx);else return null}toString(){return this.message}},F2=class extends h{static{W(this,"LexerNoViableAltException")}startIndex;deadEndConfigs;constructor(_,A,R,U){super({message:"",recognizer:_,input:A,ctx:null});this.startIndex=R,this.deadEndConfigs=U}toString(){let _="";if(this.input&&this.startIndex>=0&&this.startIndex<this.input.size)_=this.input.getTextFromRange(this.startIndex,this.startIndex);return`LexerNoViableAltException(${_})`}},O0=class _ extends b4{static{W(this,"Lexer")}static DEFAULT_MODE=0;static MORE=-2;static SKIP=-3;static DEFAULT_TOKEN_CHANNEL=D.DEFAULT_CHANNEL;static HIDDEN=D.HIDDEN_CHANNEL;options={minDFAEdge:0,maxDFAEdge:256,minCodePoint:0,maxCodePoint:1114111};tokenStartCharIndex=-1;channel=0;type=0;mode=_.DEFAULT_MODE;currentTokenColumn=0;currentTokenStartLine=0;input;token=null;hitEOF=!1;factory;#_=[];#A;constructor(A,R){super();this.options={...this.options,...R},this.input=A,this.factory=u4.DEFAULT}reset(A=!0){if(A)this.input.seek(0);this.token=null,this.type=D.INVALID_TYPE,this.channel=D.DEFAULT_CHANNEL,this.tokenStartCharIndex=-1,this.currentTokenColumn=-1,this.currentTokenStartLine=-1,this.#A=void 0,this.hitEOF=!1,this.mode=_.DEFAULT_MODE,this.#_=[],this.interpreter.reset()}nextToken(){if(this.input===null)throw Error("nextToken requires a non-null input stream.");let A=this.input.mark();try{while(!0){if(this.hitEOF)return this.emitEOF(),this.token;this.token=null,this.channel=D.DEFAULT_CHANNEL,this.tokenStartCharIndex=this.input.index,this.currentTokenColumn=this.interpreter.column,this.currentTokenStartLine=this.interpreter.line,this.#A=void 0;let R=!1;while(!0){this.type=D.INVALID_TYPE;let U=_.SKIP;try{U=this.interpreter.match(this.input,this.mode)}catch(Y){if(Y instanceof F2)this.notifyListeners(Y),this.recover(Y);else throw Y}if(this.input.LA(1)===D.EOF)this.hitEOF=!0;if(this.type===D.INVALID_TYPE)this.type=U;if(this.type===_.SKIP){R=!0;break}if(this.type!==_.MORE)break}if(R)continue;if(this.token===null)this.emit();return this.token}}finally{this.input.release(A)}}skip(){this.type=_.SKIP}more(){this.type=_.MORE}pushMode(A){if(E1.debug)console.log("pushMode "+A);this.#_.push(this.mode),this.mode=A}popMode(){if(this.#_.length===0)throw Error("Empty Stack");if(E1.debug)console.log("popMode back to "+this.#_.slice(0,-1));return this.mode=this.#_.pop(),this.mode}get modeStack(){return this.#_}emitToken(A){this.token=A}emit(){let A=this.factory.create([this,this.input],this.type,this.#A,this.channel,this.tokenStartCharIndex,this.getCharIndex()-1,this.currentTokenStartLine,this.currentTokenColumn);return this.emitToken(A),A}emitEOF(){let A=this.factory.create([this,this.input],D.EOF,void 0,D.DEFAULT_CHANNEL,this.input.index,this.input.index-1,this.line,this.column);return this.emitToken(A),A}getCharIndex(){return this.input.index}getAllTokens(){let A=[],R=this.nextToken();while(R.type!==D.EOF)A.push(R),R=this.nextToken();return A}notifyListeners(A){let R=this.tokenStartCharIndex,U=this.input.index,Y=this.input.getTextFromRange(R,U),X="token recognition error at: '"+this.getErrorDisplay(Y)+"'";this.errorListenerDispatch.syntaxError(this,null,this.currentTokenStartLine,this.currentTokenColumn,X,A)}getErrorDisplay(A){return A}getErrorDisplayForChar(A){if(A.charCodeAt(0)===D.EOF)return"<EOF>";if(A===`
4
- `)return"\\n";if(A==="\t")return"\\t";if(A==="\r")return"\\r";return A}getCharErrorDisplay(A){return"'"+this.getErrorDisplayForChar(A)+"'"}recover(A){if(this.input.LA(1)!==D.EOF)if(A instanceof F2)this.interpreter.consume(this.input);else this.input.consume()}get inputStream(){return this.input}set inputStream(A){this.reset(!1),this.input=A}set tokenFactory(A){this.factory=A}get tokenFactory(){return this.factory}get sourceName(){return this.input.getSourceName()}get line(){return this.interpreter.line}set line(A){this.interpreter.line=A}get column(){return this.interpreter.column}set column(A){this.interpreter.column=A}get text(){if(this.#A)return this.#A;else return this.interpreter.getText(this.input)}set text(A){this.#A=A}},S4=class{static{W(this,"DFASerializer")}dfa;vocabulary;constructor(_,A){this.dfa=_,this.vocabulary=A}toString(){if(!this.dfa.s0)return"";let _="",A=this.dfa.getStates();for(let R of A){let U=0;U=R.edges.length;for(let Y=0;Y<U;Y++){let X=R.edges[Y];if(X&&X.stateNumber!==2147483647){_+=this.getStateString(R);let G=this.getEdgeLabel(Y);_+="-",_+=G,_+="->",_+=this.getStateString(X),_+=`
5
- `}}}return _}getEdgeLabel(_){return`${this.vocabulary.getDisplayName(_-1)}`}getStateString(_){let A=_.stateNumber,R=(_.isAcceptState?":":"")+"s"+A+(_.requiresFullContext?"^":"");if(_.isAcceptState){if(_.predicates!==null)return`${R}=>${_.predicates.toString()}`;return`${R}=>${_.prediction}`}else return`${R}`}},G6=class extends S4{static{W(this,"LexerDFASerializer")}constructor(_){super(_,D0.EMPTY_VOCABULARY)}getEdgeLabel=W((_)=>{return"'"+String.fromCharCode(_)+"'"},"getEdgeLabel")},S0=class{static{W(this,"DFA")}s0;decision;atnStartState;isPrecedenceDfa;states=new Map;constructor(_,A){this.atnStartState=_,this.decision=A??0;let R=!1;if(_ instanceof c0){if(_.precedenceRuleDecision)R=!0,this.s0=w1.fromState(-1)}this.isPrecedenceDfa=R}[Symbol.iterator]=()=>{return this.states.values()[Symbol.iterator]()};getPrecedenceStartState=W((_)=>{if(!this.isPrecedenceDfa)throw Error("Only precedence DFAs may contain a precedence start state.");if(!this.s0||!this.s0.edges||_<0||_>=this.s0.edges.length)return;return this.s0.edges[_]},"getPrecedenceStartState");setPrecedenceStartState=W((_,A)=>{if(!this.isPrecedenceDfa)throw Error("Only precedence DFAs may contain a precedence start state.");if(_<0||!this.s0)return;this.s0.edges[_]=A},"setPrecedenceStartState");getStates(){let _=[...this.states.values()];return _.sort((A,R)=>{return A.stateNumber-R.stateNumber}),_}getState(_){return this.states.get(_.configs.hashCode())??null}getStateForConfigs(_){return this.states.get(_.hashCode())??null}addState(_){let A=_.configs.hashCode();if(this.states.has(A))return;this.states.set(A,_),_.stateNumber=this.states.size-1}toString(_){if(!_)return this.toString(D0.EMPTY_VOCABULARY);if(!this.s0)return"";return new S4(this,_).toString()??""}toLexerString(){if(!this.s0)return"";return new G6(this).toString()??""}get length(){return this.states.size}},p2=class _{static{W(this,"LexerIndexedCustomAction")}offset;action;actionType;isPositionDependent=!0;cachedHashCode;constructor(A,R){this.actionType=R.actionType,this.offset=A,this.action=R}execute(A){this.action.execute(A)}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize();A=k.update(A,this.offset),A=k.updateFromComparable(A,this.action),this.cachedHashCode=k.finish(A,2)}return this.cachedHashCode}equals(A){if(this===A)return!0;if(!(A instanceof _))return!1;return this.offset===A.offset&&this.action===A.action}},N6=class _{static{W(this,"LexerActionExecutor")}lexerActions;actionType;isPositionDependent=!1;cachedHashCode;constructor(A){return this.actionType=-1,this.lexerActions=A??[],this}static append(A,R){if(A===null)return new _([R]);let U=A.lexerActions.concat([R]);return new _(U)}fixOffsetBeforeMatch(A){let R=null;for(let U=0;U<this.lexerActions.length;U++)if(this.lexerActions[U].isPositionDependent&&!(this.lexerActions[U]instanceof p2)){if(R===null)R=this.lexerActions.concat([]);R[U]=new p2(A,this.lexerActions[U])}if(R===null)return this;else return new _(R)}execute(A,R,U){if(R===void 0||U===void 0)return;let Y=!1,X=R.index;try{for(let G of this.lexerActions){let Q=G;if(G instanceof p2){let J=G.offset;R.seek(U+J),Q=G.action,Y=U+J!==X}else if(G.isPositionDependent)R.seek(X),Y=!1;Q.execute(A)}}finally{if(Y)R.seek(X)}}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize(7);for(let R of this.lexerActions)A=k.update(A,R.hashCode());this.cachedHashCode=k.finish(A,this.lexerActions.length)}return this.cachedHashCode}equals(A){if(this===A)return!0;if(this.cachedHashCode!==A.cachedHashCode)return!1;if(this.lexerActions.length!==A.lexerActions.length)return!1;return this.lexerActions.every((R,U)=>{return R.equals(A.lexerActions[U])})}},Q6=class _ extends $0{static{W(this,"OrderedHashSet")}elements=[];getOrAdd(A){let R=this.size,U=super.getOrAdd(A);if(this.size>R)this.elements.push(A);return U}equals(A){if(!(A instanceof _))return!1;return super.equals(A)}clear(){super.clear(),this.elements=[]}*[Symbol.iterator](){yield*this.elements}toArray(){return this.elements.slice(0)}},B4=class extends b0{static{W(this,"OrderedATNConfigSet")}constructor(){super();this.configLookup=new Q6}},E1=class _ extends C0{static{W(this,"LexerATNSimulator")}static debug=!1;decisionToDFA;recognizer=null;startIndex=-1;line=1;column=0;mode=O0.DEFAULT_MODE;prevAccept;options;lexerATNConfigFactory;constructor(A,R,U,Y){super(R,Y);if(this.decisionToDFA=U,this.recognizer=A,A)this.options=A.options;else this.options={minDFAEdge:0,maxDFAEdge:256,minCodePoint:0,maxCodePoint:1114111}}match(A,R){this.mode=R;let U=A.mark();try{this.startIndex=A.index,this.prevAccept=void 0;let Y=this.decisionToDFA[R];if(!Y.s0)return this.matchATN(A);return this.execATN(A,Y.s0)}finally{A.release(U)}}reset(){this.prevAccept=void 0,this.startIndex=-1,this.line=1,this.column=0,this.mode=O0.DEFAULT_MODE}clearDFA(){for(let A=0;A<this.decisionToDFA.length;A++)this.decisionToDFA[A]=new S0(this.atn.getDecisionState(A),A)}getDFA(A){return this.decisionToDFA[A]}getText(A){return A.getTextFromRange(this.startIndex,A.index-1)}consume(A){if(A.LA(1)===10)this.line+=1,this.column=0;else this.column+=1;A.consume()}getTokenName(A){if(A===D.EOF)return"EOF";else return"'"+String.fromCharCode(A)+"'"}matchATN(A){let R=this.atn.modeToStartState[this.mode];if(_.debug)console.log("matchATN mode "+this.mode+" start: "+R);let U=this.mode,Y=this.computeStartState(A,R),X=Y.hasSemanticContext;Y.hasSemanticContext=!1;let G=this.addDFAState(Y);if(!X)this.decisionToDFA[this.mode].s0=G;let Q=this.execATN(A,G);if(_.debug)console.log("DFA after matchATN: "+this.decisionToDFA[U].toLexerString());return Q}execATN(A,R){if(_.debug)console.log("start state closure="+R.configs);if(R.isAcceptState)this.captureSimState(A,R);let U=A.LA(1);while(!0){if(_.debug)console.log("execATN loop starting closure: "+R.configs);let Y=this.getExistingTargetState(R,U);if(!Y)Y=this.computeTargetState(A,R,U);if(Y===C0.ERROR)break;if(U!==D.EOF)this.consume(A);if(Y.isAcceptState){if(this.captureSimState(A,Y),U===D.EOF)break}U=A.LA(1),R=Y}return this.failOrAccept(A,R.configs,U)}getExistingTargetState(A,R){if(R>=this.options.minDFAEdge&&R<=this.options.maxDFAEdge){let U=A.edges[R-this.options.minDFAEdge];if(_.debug&&U)console.log("reuse state "+A.stateNumber+" edge to "+U.stateNumber);return U}return}computeTargetState(A,R,U){let Y=new B4;if(this.getReachableConfigSet(A,R.configs,Y,U),Y.length===0){if(!Y.hasSemanticContext)this.addDFAEdge(R,U,C0.ERROR);return C0.ERROR}return this.addDFAEdge(R,U,null,Y)}failOrAccept(A,R,U){if(this.prevAccept?.dfaState){let{dfaState:Y,index:X,line:G,column:Q}=this.prevAccept;return this.accept(A,Y.lexerActionExecutor,this.startIndex,X,G,Q),Y.prediction}if(U===D.EOF&&A.index===this.startIndex)return D.EOF;throw new F2(this.recognizer,A,this.startIndex,R)}getReachableConfigSet(A,R,U,Y){let X=P.INVALID_ALT_NUMBER;for(let G of R){let Q=G.alt===X;if(Q&&G.passedThroughNonGreedyDecision)continue;if(_.debug)console.log(`testing %s at %s
6
- `,this.getTokenName(Y),G.toString(this.recognizer,!0));for(let J of G.state.transitions){let F=this.getReachableTarget(J,Y);if(F){let I=G.lexerActionExecutor;if(I)I=I.fixOffsetBeforeMatch(A.index-this.startIndex);let B=Y===D.EOF,C=k0.createWithExecutor(G,F,I);if(this.closure(A,C,U,Q,!0,B))X=G.alt}}}}accept(A,R,U,Y,X,G){if(_.debug)console.log(`ACTION %s
7
- `,R);if(A.seek(Y),this.line=X,this.column=G,R&&this.recognizer)R.execute(this.recognizer,A,U)}getReachableTarget(A,R){if(A.matches(R,this.options.minCodePoint,this.options.maxCodePoint))return A.target;else return}computeStartState(A,R){let U=c.instance,Y=new B4;for(let X=0;X<R.transitions.length;X++){let G=R.transitions[X].target,Q=k0.createWithContext(G,X+1,U);this.closure(A,Q,Y,!1,!1,!1)}return Y}closure(A,R,U,Y,X,G){let Q=null;if(_.debug)console.log("closure("+R.toString(this.recognizer,!0)+")");if(R.state.constructor.stateType===f.RULE_STOP){if(_.debug)if(this.recognizer!==null)console.log(`closure at %s rule stop %s
1
+ import{resolve as h2}from"path";class G{representation;static ACTIVE_PLAYER=new G("active_player");static ACTIVE_PLAYER2=new G(".active_player");static P_ACTIVE_PLAYER=new G("p_active_player");static P_ACTIVE_PLAYER2=new G(".p_active_player");static ACTIVE_NPC=new G("active_npc");static ACTIVE_NPC2=new G(".active_npc");static ACTIVE_LOC=new G("active_loc");static ACTIVE_LOC2=new G(".active_loc");static ACTIVE_OBJ=new G("active_obj");static ACTIVE_OBJ2=new G(".active_obj");static FIND_PLAYER=new G("find_player");static FIND_NPC=new G("find_npc");static FIND_LOC=new G("find_loc");static FIND_OBJ=new G("find_obj");static FIND_DB=new G("find_db");static LAST_COM=new G("last_com");static LAST_INT=new G("last_int");static LAST_ITEM=new G("last_item");static LAST_SLOT=new G("last_slot");static LAST_TARGETSLOT=new G("last_targetslot");static LAST_USEITEM=new G("last_useitem");static LAST_USESLOT=new G("last_useslot");static ALL=Object.values(G).filter((_)=>_ instanceof G);static NAME_TO_TYPE=G.ALL.reduce((_,A)=>{return _[A.getName().toLowerCase()]=A,_},{});constructor(_){this.representation=_}getName(){for(let _ of Object.keys(G))if(G[_]===this)return _;return""}static forName(_){return this.NAME_TO_TYPE[_.toLowerCase()]}}import D6 from"fs";import $1 from"path";class a{source;parent=null;_children=[];get children(){return this._children}attributes=new Map;constructor(_){this.source=_;this.source=_}addChild(_){if(!_)return;if(_.parent)throw Error("Parent already set.");_.parent=this,this._children.push(_)}addChildren(_){for(let A of _){if(!A)continue;if(A.parent)throw Error("Parent already set.");A.parent=this,this._children.push(A)}}findParentByType(_){let A=this.parent;while(A!==null){if(A instanceof _)return A;A=A.parent}return null}reportInfo(_,A,...R){_.report(new _0("INFO",this,A,...R))}reportWarning(_,A,...R){_.report(new _0("WARNING",this,A,...R))}reportError(_,A,...R){_.report(new _0("ERROR",this,A,...R))}}class _0{type;sourceLocation;message;messageArgs;constructor(_,A,R,...U){if(this.type=_,"source"in A)this.sourceLocation=A.source;else this.sourceLocation=A;this.messageArgs=U,this.message=R}isError(){return this.type==="ERROR"||this.type==="SYNTAX_ERROR"}}class m1{sourceFile;diagnostics;lineOffset;columnOffset;constructor(_,A,R=0,U=0){this.sourceFile=_;this.diagnostics=A;this.lineOffset=R;this.columnOffset=U}syntaxError(_,A,R,U,N,Y){let X=R===1?this.columnOffset:0,Q=R+this.lineOffset,$=U+X+1,J={name:this.sourceFile,line:Q,column:$,endLine:Q,endColumn:$};this.diagnostics.report(new _0("SYNTAX_ERROR",J,N.replace(/%/g,"%%"),[]))}reportAmbiguity(_,A,R,U,N,Y,X){}reportAttemptingFullContext(_,A,R,U,N,Y){}reportContextSensitivity(_,A,R,U,N,Y){}}class U2{opcode;operand;source;constructor(_,A,R){this.opcode=_;this.operand=A;this.source=R}deconstruct(){return[this.opcode,this.operand]}toString(){return`Instruction(opcode=${this.opcode}, operand=${this.operand})`}}class H{constructor(){}static PushConstantInt=new H;static PushConstantString=new H;static PushConstantLong=new H;static PushConstantSymbol=new H;static PushLocalVar=new H;static PopLocalVar=new H;static PushVar=new H;static PushVar2=new H;static PopVar=new H;static PopVar2=new H;static DefineArray=new H;static Switch=new H;static Branch=new H;static BranchNot=new H;static BranchEquals=new H;static BranchLessThan=new H;static BranchGreaterThan=new H;static BranchLessThanOrEquals=new H;static BranchGreaterThanOrEquals=new H;static LongBranchNot=new H;static LongBranchEquals=new H;static LongBranchLessThan=new H;static LongBranchGreaterThan=new H;static LongBranchLessThanOrEquals=new H;static LongBranchGreaterThanOrEquals=new H;static ObjBranchNot=new H;static ObjBranchEquals=new H;static JoinString=new H;static Discard=new H;static Gosub=new H;static Jump=new H;static Command=new H;static Return=new H;static Add=new H;static Sub=new H;static Multiply=new H;static Divide=new H;static Modulo=new H;static Or=new H;static And=new H;static LongAdd=new H;static LongSub=new H;static LongMultiply=new H;static LongDivide=new H;static LongModulo=new H;static LongOr=new H;static LongAnd=new H;static LineNumber=new H}class N2{label;instructions=[];constructor(_){this.label=_}add(_){this.instructions.push(_)}plusAssign(_){this.add(_)}}class x1{name;constructor(_){this.name=_}}class j2{names=new Map;generate(_){let A=this.names.get(_)??0;return this.names.set(_,A+1),new x1(`${_}_${A}`)}reset(){this.names.clear()}}class f2{label;keys;constructor(_,A){this.label=_;this.keys=A}}class V2{id;_cases=[];constructor(_){this.id=_}get cases(){return this._cases}addCase(_){this._cases.push(_)}}class P2{sourceName;symbol;subjectReference;trigger;name;fullName;locals;blocks=[];switchTables=[];constructor(_,A,R){this.sourceName=_;this.symbol=A;this.subjectReference=R;this.trigger=A.trigger,this.name=A.name,this.fullName=`[${this.trigger.identifier},${this.name}]`,this.locals=new U4}generateSwitchTable(){let _=new V2(this.switchTables.length);return this.switchTables.push(_),_}}class U4{parameters=[];all=[]}class n extends a{constructor(_){super(_)}type=null;typeHint=null;getNullableType(){return this.type}getType(){if(this.type==null)throw Error("Attribute: 'type' should be initialized before get.");else return this.type}}class A0 extends n{kind="Identifier";text;reference=null;constructor(_,A){super(_);this.text=A}accept(_){return _.visitIdentifier(this)}}class i extends n{name;arguments;symbol;constructor(_,A,R){super(_);this.name=A,this.arguments=R,this.addChild(this.name),this.addChildren(this.arguments)}}class D0 extends i{kind="CommandCallExpression";arguments2;constructor(_,A,R,U){super(_,A,R);if(this.arguments2=U,this.arguments2)this.addChildren(this.arguments2)}get isStar(){return this.arguments2!=null}get nameString(){return this.isStar?`${this.name.text}*`:this.name.text}accept(_){return _.visitCommandCallExpression(this)}}class b2{codeGenerator;rootTable;expression;diagnostics;constructor(_,A,R,U){this.codeGenerator=_;this.rootTable=A;this.expression=R;this.diagnostics=U}get arguments(){if(this.expression instanceof i)return this.expression.arguments;return[]}get arguments2(){if(this.expression instanceof D0&&this.expression.isStar&&this.expression.arguments2)return this.expression.arguments2;return[]}instruction(_,A,R){this.codeGenerator.instruction(_,A,R)}command(){let _=(()=>{if(this.expression instanceof D0)return this.expression.symbol;if(this.expression instanceof A0)return this.expression.reference;return null})();if(this.lineInstruction(this.expression),!_)throw Error("Symbol cannot be null for command generation.");this.instruction(H.Command,_,this.expression.source)}lineInstruction(_){this.codeGenerator.lineInstruction(_)}visitNode(_){if(!_)return;this.codeGenerator.visitNodeOrNull(_)}visitExpression(_){if(!_)return;this.codeGenerator.visitNodeOrNull(_)}visitNodes(_){if(!_)return;this.codeGenerator.visitNodes(_)}}var E={UNSUPPORTED_SYMBOLTYPE_TO_TYPE:"Internal compiler error: Unsupported SymbolType -> Type conversion: %s",CASE_WITHOUT_SWITCH:"Internal compiler error: Case without switch statement as parent.",RETURN_ORPHAN:"Internal compiler error: Orphaned `return` statement, no parent `script` node found.",TRIGGER_TYPE_NOT_FOUND:"Internal compiler error: The trigger '%s' has no declaration.",CUSTOM_HANDLER_NOTYPE:"Internal compiler error: Custom command handler did not assign return type.",CUSTOM_HANDLER_NOSYMBOL:"Internal compiler error: Custom command handler did not assign symbol.",SYMBOL_IS_NULL:"Internal compiler error: Symbol has not been defined for the node.",TYPE_HAS_NO_BASETYPE:"Internal compiler error: Type has no defined base type: %s.",TYPE_HAS_NO_DEFAULT:"Internal compiler error: Return type '%s' has no defined default value.",INVALID_CONDITION:"Internal compiler error: %s is not a supported expression type for conditions.",NULL_CONSTANT:"Internal compiler error: %s evaluated to 'null' constant value.",EXPRESSION_NO_SUBEXPR:"Internal compiler error: No sub expression node.",GENERIC_INVALID_TYPE:"'%s' is not a valid type.",GENERIC_TYPE_MISMATCH:"Type mismatch: '%s' was given but '%s' was expected.",GENERIC_UNRESOLVED_SYMBOL:"'%s' could not be resolved to a symbol.",ARITHMETIC_INVALID_TYPE:"Type mismatch: '%s' was given but 'int' or 'long' was expected.",SCRIPT_REDECLARATION:"[%s,%s] is already defined.",SCRIPT_LOCAL_REDECLARATION:"'$%s' is already defined.",SCRIPT_TRIGGER_INVALID:"'%s' is not a valid trigger type.",SCRIPT_COMMAND_ONLY:"Using a '*' is only allowed for commands.",SCRIPT_TRIGGER_NO_PARAMETERS:"The trigger type '%s' is not allowed to have parameters defined.",SCRIPT_TRIGGER_EXPECTED_PARAMETERS:"The trigger type '%s' is expected to accept (%s).",SCRIPT_TRIGGER_NO_RETURNS:"The trigger type '%s' is not allowed to return values.",SCRIPT_TRIGGER_EXPECTED_RETURNS:"The trigger type '%s' is expected to return (%s).",SCRIPT_SUBJECT_ONLY_GLOBAL:"Trigger '%s' only allows global subjects.",SCRIPT_SUBJECT_NO_GLOBAL:"Trigger '%s' does not allow global subjects.",SCRIPT_SUBJECT_NO_CATEGORY:"Trigger '%s' does not allow category subjects.",SWITCH_INVALID_TYPE:"'%s' is not allowed within a switch statement.",SWITCH_DUPLICATE_DEFAULT:"Duplicate default label.",SWITCH_CASE_NOT_CONSTANT:"Switch case value is not a constant expression.",ASSIGN_MULTI_ARRAY:"Arrays are not allowed in multi-assignment statements.",CONDITION_INVALID_NODE_TYPE:"Conditions are only allowed to be binary expressions.",BINOP_INVALID_TYPES:"Operator '%s' cannot be applied to '%s', '%s'.",BINOP_TUPLE_TYPE:"%s side of binary expressions can only have one type but has '%s'.",COMMAND_REFERENCE_UNRESOLVED:"'%s' cannot be resolved to a command.",COMMAND_NOARGS_EXPECTED:"'%s' is expected to have no arguments but has '%s'.",PROC_REFERENCE_UNRESOLVED:"'~%s' cannot be resolved to a proc.",PROC_NOARGS_EXPECTED:"'~%s' is expected to have no arguments but has '%s'.",JUMP_REFERENCE_UNRESOLVED:"'@%s' cannot be resolved to a label.",JUMP_NOARGS_EXPECTED:"'@%s' is expected to have no arguments but has '%s'.",CLIENTSCRIPT_REFERENCE_UNRESOLVED:"'%s' cannot be resolved to a clientscript.",CLIENTSCRIPT_NOARGS_EXPECTED:"'%s' is expected to have no arguments but has '%s'.",HOOK_TRANSMIT_LIST_UNEXPECTED:"Unexpected hook transmit list.",LOCAL_DECLARATION_INVALID_TYPE:"'%s' is not allowed to be declared as a type.",LOCAL_REFERENCE_UNRESOLVED:"'$%s' cannot be resolved to a local variable.",LOCAL_REFERENCE_NOT_ARRAY:"Access of indexed value of non-array type variable '$%s'.",LOCAL_ARRAY_INVALID_TYPE:"'%s' is not allowed to be used as an array.",LOCAL_ARRAY_REFERENCE_NOINDEX:"'$%s' is a reference to an array variable without specifying the index.",GAME_REFERENCE_UNRESOLVED:"'%%%s' cannot be resolved to a game variable.",CONSTANT_REFERENCE_UNRESOLVED:"'^%s' cannot be resolved to a constant.",CONSTANT_CYCLIC_REF:"Cyclic constant references are not permitted: %s.",CONSTANT_UNKNOWN_TYPE:"Unable to infer type for '^%s'.",CONSTANT_PARSE_ERROR:"Unable to parse constant value of '%s' into type '%s'.",CONSTANT_NONCONSTANT:"Constant value of '%s' evaluated to a non-constant expression.",POINTER_UNINITIALIZED:"Attempt to access uninitialized pointer %s.",POINTER_CORRUPTED:"Attempt to access corrupted pointer %s.",POINTER_CORRUPTED_LOC:"%s corrupted here.",POINTER_REQUIRED_LOC:"%s required here."};class V0{trigger;name;parameters;returns;constructor(_,A,R,U){this.trigger=_;this.name=A;this.parameters=R;this.returns=U}pointers(_){return _.getPointers(this)}}class g1 extends V0{}class F0{name;type;constructor(_,A){this.name=_;this.type=A}}class r{name;type;isProtected;constructor(_,A,R=!1){this.name=_;this.type=A;this.isProtected=R}}class I1{name;value;constructor(_,A){this.name=_;this.value=A}}class K{constructor(){}static None=new class extends K{};static Name=new class extends K{};static Type(_,A=!0,R=!0){return new class extends K{type=_;category=A;global=R}}}var Y0={id:-1,identifier:"command",subjectMode:K.Name,allowParameters:!0,parameters:null,allowReturns:!0,returns:null,pointers:null};class d{allowSwitch=!0;allowArray=!0;allowDeclaration=!0;constructor(_){if(_)Object.assign(this,_)}}class W{name;representation;baseType=0;defaultValue=-1;options=new d({allowSwitch:!1,allowArray:!1,allowDeclaration:!1});constructor(_){this.name=_;this.representation=_.toLowerCase()}get code(){throw Error("MetaType has no character representation.")}static Any=new W("any");static Nothing=new W("nothing");static Error=new W("error");static Unit=new W("unit");static Type=class extends W{inner;constructor(_){super("type");this.inner=_,this.representation=`type<${_.representation}>`}};static Script=class extends W{trigger;parameterType;returnType;constructor(_,A,R){super("script");this.trigger=_,this.parameterType=A,this.returnType=R,this.representation=_.identifier}};static Hook=class extends W{transmitListType;constructor(_){super("hook");this.transmitListType=_,this.representation=`hook<${_.representation}>`}}}class l1{representation;code;baseType;defaultValue;options}class D extends l1{code;baseType;defaultValue;constructor(_,A,R,U,N){super();this.code=A;this.baseType=R;this.defaultValue=U;this.representation=_.toLowerCase();let Y=new d;N?.(Y),this.options=Y}static INT=new D("INT","i",0,0);static BOOLEAN=new D("BOOLEAN","1",0,0);static COORD=new D("COORD","c",0,-1);static STRING=new D("STRING","s",1,"",(_)=>{_.allowArray=!1,_.allowSwitch=!1});static CHAR=new D("CHAR","z",0,-1);static LONG=new D("LONG","Ï",2,-1,(_)=>{_.allowArray=!1,_.allowSwitch=!1});static MAPZONE=new D("MAPZONE","0",0,-1);static ALL=[D.INT,D.BOOLEAN,D.COORD,D.STRING,D.CHAR,D.LONG,D.MAPZONE];static byRepresentation(_){return D.ALL.find((A)=>A.representation===_)}}class M{children;representation;code=null;baseType=null;defaultValue=null;options=new d({allowArray:!1,allowSwitch:!1,allowDeclaration:!1});constructor(..._){let A=M.flatten(_);if(A.length<2)throw Error("TupleType should not be used when type count is < 2");this.children=A,this.representation=this.children.map((R)=>R.representation).join(",")}static fromList(_){if(!_||_.length===0)return W.Unit;if(_.length===1)return _[0];return new M(..._)}static toList(_){if(!_||_===W.Unit||_===W.Nothing)return[];if(_ instanceof M)return _.children;return[_]}static flatten(_){let A=[];for(let R of _)if(R instanceof M)A.push(...R.children);else A.push(R);return A}}class P0{visitScriptFile(_){return this.visitNode(_)}visitScript(_){return this.visitNode(_)}visitParameter(_){return this.visitNode(_)}visitBlockStatement(_){return this.visitStatement(_)}visitReturnStatement(_){return this.visitStatement(_)}visitIfStatement(_){return this.visitStatement(_)}visitWhileStatement(_){return this.visitStatement(_)}visitSwitchStatement(_){return this.visitStatement(_)}visitSwitchCase(_){return this.visitNode(_)}visitDeclarationStatement(_){return this.visitStatement(_)}visitArrayDeclarationStatement(_){return this.visitStatement(_)}visitAssignmentStatement(_){return this.visitStatement(_)}visitExpressionStatement(_){return this.visitStatement(_)}visitEmptyStatement(_){return this.visitStatement(_)}visitStatement(_){return this.visitNode(_)}visitParenthesizedExpression(_){return this.visitExpression(_)}visitConditionExpression(_){return this.visitBinaryExpression(_)}visitArithmeticExpression(_){return this.visitBinaryExpression(_)}visitBinaryExpression(_){return this.visitExpression(_)}visitCalcExpression(_){return this.visitExpression(_)}visitProcCallExpression(_){return this.visitCallExpression(_)}visitCommandCallExpression(_){return this.visitCallExpression(_)}visitJumpCallExpression(_){return this.visitCallExpression(_)}visitCallExpression(_){return this.visitExpression(_)}visitClientScriptExpression(_){return this.visitExpression(_)}visitLocalVariableExpression(_){return this.visitVariableExpression(_)}visitGameVariableExpression(_){return this.visitVariableExpression(_)}visitConstantVariableExpression(_){return this.visitVariableExpression(_)}visitVariableExpression(_){return this.visitExpression(_)}visitExpression(_){return this.visitNode(_)}visitIntegerLiteral(_){return this.visitLiteral(_)}visitCoordLiteral(_){return this.visitLiteral(_)}visitBooleanLiteral(_){return this.visitLiteral(_)}visitCharacterLiteral(_){return this.visitLiteral(_)}visitNullLiteral(_){return this.visitLiteral(_)}visitStringLiteral(_){return this.visitLiteral(_)}visitLiteral(_){return this.visitExpression(_)}visitJoinedStringExpression(_){return this.visitExpression(_)}visitJoinedStringPart(_){return this.visitNode(_)}visitIdentifier(_){return this.visitExpression(_)}visitToken(_){return this.visitNode(_)}visitNode(_){throw Error(`Not implemented: ${_.constructor.name}`)}}class e0 extends n{left;operator;right;constructor(_,A,R,U){super(_);this.left=A,this.operator=R,this.right=U,this.addChild(this.left),this.addChild(this.operator),this.addChild(this.right)}accept(_){return _.visitBinaryExpression(this)}}class _1 extends e0{kind="ConditionExpression";constructor(_,A,R,U){super(_,A,R,U)}accept(_){return _.visitConditionExpression(this)}}class b0 extends n{kind="ParenthesizedExpression";expression;constructor(_,A){super(_);this.expression=A,this.addChild(this.expression)}accept(_){return _.visitParenthesizedExpression(this)}}class v2 extends a{constructor(_){super(_)}accept(_){return _.visitJoinedStringPart(this)}}class v0 extends v2{kind="BasicStringPart";value;constructor(_,A){super(_);this.value=A}}class u2 extends v0{kind="PTagStringPart"}class u0 extends v2{kind="ExpressionStringPart";expression;constructor(_,A){super(_);this.expression=A,this.addChild(this.expression)}}class A1 extends n{name;reference=null;constructor(_,A){super(_);this.name=A,this.addChild(this.name)}}class R1 extends A1{kind="ConstantVariableExpression";subExpression=null;constructor(_,A){super(_,A)}accept(_){return _.visitConstantVariableExpression(this)}}class d1 extends A1{kind="GameVariableExpression";dot;constructor(_,A,R){super(_,R);this.dot=A}accept(_){return _.visitGameVariableExpression(this)}}class d0 extends A1{kind="LocalVariableExpression";index;constructor(_,A,R){super(_,A);this.index=R,this.addChild(this.index)}get isArray(){return this.index!=null}accept(_){return _.visitLocalVariableExpression(this)}}class o extends n{value;constructor(_,A){super(_);this.value=A}}class T0 extends o{kind="StringLiteral";symbol=null;subExpression=null;constructor(_,A){super(_,A)}accept(_){return _.visitStringLiteral(this)}}class e extends P0{rootTable;dynamicCommands;diagnostics;labelGenerator=new j2;_scripts=[];block;lastLineNumber=-1;constructor(_,A,R){super();this.rootTable=_;this.dynamicCommands=A;this.diagnostics=R}get scripts(){return this._scripts}get script(){return this._scripts[this._scripts.length-1]}bind(_){return this.block=_,_}generateBlock(_,A=!0){let R=A?this.labelGenerator.generate(_):new x1(_),U=new N2(R);return this.script.blocks.push(U),U}generateBlockLabel(_){let A=new N2(_);return this.script.blocks.push(A),A}instruction(_,A,R,U=this.block){U.instructions.push(new U2(_,A,R))}instructionUnit(_,A,R=this.block){R.instructions.push(new U2(_,void 0,A))}lineInstruction(_){if(_.source.line!==this.lastLineNumber)this.lastLineNumber=_.source.line}visitScriptFile(_){this.visitNodes(_.scripts)}visitScript(_){if(_.triggerType==Y0)return;this._scripts.push(new P2(_.source.name,_.symbol,_.subjectReference)),this.visitNodes(_.parameters),this.bind(this.generateBlock("entry",!1)),this.lineInstruction(_),this.visitNodes(_.statements),this.generateDefaultReturns(_),this.labelGenerator.reset(),this.lastLineNumber=-1}visitParameter(_){let A=_.symbol;this.script.locals.parameters.push(A),this.script.locals.all.push(A)}generateDefaultReturns(_){this.lineInstruction(_);let A=M.toList(_.returnType);for(let R of A)if(R==D.INT)this.instruction(H.PushConstantInt,0);else if(R.baseType==0)this.instruction(H.PushConstantInt,-1);else if(R.baseType==1)this.instruction(H.PushConstantString,"");else if(R.baseType==2)this.instruction(H.PushConstantLong,BigInt(-1));else throw Error(`Unsupported type in returns: ${R}`);this.instructionUnit(H.Return)}visitBlockStatement(_){this.visitNodes(_.statements)}visitReturnStatement(_){this.visitNodes(_.expressions),this.lineInstruction(_),this.instructionUnit(H.Return,_.source)}visitIfStatement(_){let A=this.labelGenerator.generate("if_true"),R=_.elseStatement?this.labelGenerator.generate("if_else"):null,U=this.labelGenerator.generate("if_end");if(this.generateCondition(_.condition,this.block,A,R??U),this.bind(this.generateBlockLabel(A)),this.visitNodeOrNull(_.thenStatement),this.instruction(H.Branch,U),R!=null)this.bind(this.generateBlockLabel(R)),this.visitNodeOrNull(_.elseStatement),this.instruction(H.Branch,U);this.bind(this.generateBlockLabel(U))}visitWhileStatement(_){let A=this.labelGenerator.generate("while_start"),R=this.labelGenerator.generate("while_body"),U=this.labelGenerator.generate("while_end"),N=this.bind(this.generateBlockLabel(A));this.generateCondition(_.condition,N,R,U),this.bind(this.generateBlockLabel(R)),this.visitNodeOrNull(_.thenStatement),this.instruction(H.Branch,A),this.bind(this.generateBlockLabel(U))}generateCondition(_,A,R,U){if(_ instanceof e0||_ instanceof _1)if(!e.LOGICAL_OPERATORS.includes(_.operator.text)){let Y=_.left.type.baseType;if(Y==null){_.left.reportError(this.diagnostics,E.TYPE_HAS_NO_BASETYPE,_.left.type);return}let X=e.BRANCH_MAPPINGS.get(Y);if(!X)throw Error(`No mappings for BaseType: ${Y}`);let Q=X.get(_.operator.text);if(!Q)throw Error(`No mappings for operator: ${_.operator.text}`);this.visitNodeOrNull(_.left),this.visitNodeOrNull(_.right),this.instruction(Q,R,void 0,A),this.instruction(H.Branch,U,void 0,A)}else{let Y=_.operator.text===e.LOGICAL_OR?this.labelGenerator.generate("condition_or"):this.labelGenerator.generate("condition_and"),X=_.operator.text===e.LOGICAL_OR?R:Y,Q=_.operator.text===e.LOGICAL_OR?Y:U;this.generateCondition(_.left,A,X,Q);let $=this.bind(this.generateBlockLabel(Y));this.generateCondition(_.right,$,R,U)}else if(_ instanceof b0)this.generateCondition(_.expression,A,R,U);else _.reportError(this.diagnostics,E.INVALID_CONDITION,_.constructor.name)}visitSwitchStatement(_){let A=this.script.generateSwitchTable(),U=_.defaultCase!=null?this.labelGenerator.generate("switch_default_case"):null,N=this.labelGenerator.generate("switch_end");this.visitNodeOrNull(_.condition),this.instruction(H.Switch,A,_.source);let Y=_.cases[0]??null;if(Y==null||!Y.isDefault)this.instruction(H.Branch,U??N);for(let X of _.cases){let Q=!X.isDefault?this.labelGenerator.generate(`switch_${A.id}_case`):U??(()=>{throw Error("switchDefault null while having a default case")}),$=[];for(let J of X.keys){let I=this.resolveConstantValue(J);if(I==null){J.reportError(this.diagnostics,E.NULL_CONSTANT,J.constructor.name);continue}$.push(I)}A.addCase(new f2(Q,$)),this.bind(this.generateBlockLabel(Q)),this.visitNodes(X.statements),this.instruction(H.Branch,N)}this.bind(this.generateBlockLabel(N))}resolveConstantValue(_){if(_ instanceof R1)return _.subExpression?this.resolveConstantValue(_.subExpression):null;if(_ instanceof A0)return _.reference;if(_ instanceof T0)return _.symbol??_.value;if(_ instanceof o)return _.value;return null}visitDeclarationStatement(_){let A=_.symbol;if(this.script.locals.all.push(A),_.initializer!=null)this.visitNodeOrNull(_.initializer);else{let U=A.type.defaultValue;if(typeof U==="number")this.instruction(H.PushConstantInt,U);else if(typeof U==="string")this.instruction(H.PushConstantString,U);else if(typeof U==="bigint")this.instruction(H.PushConstantLong,U);else throw Error(`Unsupported default type: ${U?.constructor?.name}`)}this.instruction(H.PopLocalVar,A,_.source)}visitArrayDeclarationStatement(_){let A=_.symbol;this.script.locals.all.push(A),this.visitNodeOrNull(_.initializer),this.instruction(H.DefineArray,A,_.source)}visitAssignmentStatement(_){let A=_.vars,R=A[0];if(R instanceof d0&&R.index!=null)this.visitNodeOrNull(R.index);this.visitNodes(_.expressions);for(let U=A.length-1;U>=0;U--){let N=A[U],Y=N.reference;if(Y==null){N.reportError(this.diagnostics,E.SYMBOL_IS_NULL);return}if(Y instanceof F0)this.instruction(H.PopLocalVar,Y,N.source);else if(Y instanceof r){if(!(N instanceof d1))throw Error("Expected 'GameVariableExpression'.");this.instruction(!N.dot?H.PopVar:H.PopVar2,Y,N.source)}else throw Error(`Unsupported reference type: ${Y}`)}}visitExpressionStatement(_){let A=_.expression;this.visitNodeOrNull(A);let R=M.toList(A.type);for(let U of R){let N=U.baseType;if(N==null){_.reportError(this.diagnostics,E.TYPE_HAS_NO_BASETYPE,U);return}this.instruction(H.Discard,N)}}visitEmptyStatement(_){}visitLocalVariableExpression(_){let A=_.reference;if(A==null){_.reportError(this.diagnostics,E.SYMBOL_IS_NULL);return}this.lineInstruction(_),this.visitNodeOrNull(_.index),this.instruction(H.PushLocalVar,A,_.source)}visitGameVariableExpression(_){let A=_.reference;if(A==null){_.reportError(this.diagnostics,E.SYMBOL_IS_NULL);return}this.lineInstruction(_),this.instruction(!_.dot?H.PushVar:H.PushVar2,A,_.source)}visitConstantVariableExpression(_){let A=_.subExpression;if(A==null){_.reportError(this.diagnostics,E.EXPRESSION_NO_SUBEXPR);return}this.visitNodeOrNull(A)}visitParenthesizedExpression(_){this.lineInstruction(_),this.visitNodeOrNull(_.expression)}visitArithmeticExpression(_){let A=_.operator.text,R=_.left.type.baseType,N=(()=>{switch(R){case 0:return e.INT_OPERATIONS;case 2:return e.LONG_OPERATIONS;default:throw Error(`No mapping for BaseType: ${R}.`)}})().get(A);if(!N)throw Error(`No mapping for operator: ${A}.`);this.visitNodeOrNull(_.left),this.visitNodeOrNull(_.right),this.instructionUnit(N)}visitCalcExpression(_){this.lineInstruction(_),this.visitNodeOrNull(_.expression)}visitCommandCallExpression(_){let A=_.symbol;if(A==null){_.reportError(this.diagnostics,E.SYMBOL_IS_NULL);return}if(this.emitDynamicCommand(_.nameString,_))return;this.visitNodes(_.arguments),this.lineInstruction(_),this.instruction(H.Command,A,_.source)}emitDynamicCommand(_,A){let R=this.dynamicCommands.get(_);if(!R)return!1;let U=new b2(this,this.rootTable,A,this.diagnostics);if(R.generateCode)R.generateCode(U);else U.visitNodes(U.arguments),U.command();return!0}visitProcCallExpression(_){let A=_.symbol;if(A==null){_.reportError(this.diagnostics,E.SYMBOL_IS_NULL);return}this.visitNodes(_.arguments),this.lineInstruction(_),this.instruction(H.Gosub,A,_.source)}visitJumpCallExpression(_){let A=_.symbol;if(A==null){_.reportError(this.diagnostics,E.SYMBOL_IS_NULL);return}this.visitNodes(_.arguments),this.lineInstruction(_),this.instruction(H.Jump,A,_.source)}visitClientScriptExpression(_){let A=_.symbol;if(A==null){_.reportError(this.diagnostics,E.SYMBOL_IS_NULL);return}let R=M.toList(A.parameters),U=R.map((N)=>N.code).filter(Boolean).join("");if(R.length!==U.length)throw Error("Mismatch between argument types and their codes.");if(this.instruction(H.PushConstantSymbol,A,_.source),this.visitNodes(_.arguments),_.transmitList.length>0)this.visitNodes(_.transmitList),U+="Y",this.instruction(H.PushConstantInt,_.transmitList.length);this.instruction(H.PushConstantString,U)}visitIntegerLiteral(_){this.lineInstruction(_),this.instruction(H.PushConstantInt,_.value,_.source)}visitCoordLiteral(_){this.lineInstruction(_),this.instruction(H.PushConstantInt,_.value,_.source)}visitBooleanLiteral(_){this.lineInstruction(_),this.instruction(H.PushConstantInt,_.value?1:0,_.source)}visitCharacterLiteral(_){this.lineInstruction(_),this.instruction(H.PushConstantInt,_.value.charCodeAt(0),_.source)}visitNullLiteral(_){this.lineInstruction(_);let A=_.type.baseType;if(A==1){this.instruction(H.PushConstantString,"null");return}else if(A==2){this.instruction(H.PushConstantLong,BigInt(-1));return}if(this.instruction(H.PushConstantInt,-1,_.source),_.getType()instanceof W.Hook)this.instruction(H.PushConstantString,"")}visitStringLiteral(_){this.lineInstruction(_);let A=_.subExpression;if(A!=null){this.visitNodeOrNull(A);return}let R=_.symbol;if(R!=null){this.instruction(H.PushConstantSymbol,R,_.source);return}this.instruction(H.PushConstantString,_.value,_.source)}visitJoinedStringExpression(_){if(this.visitNodes(_.parts),_.parts.length>1)this.lineInstruction(_),this.instruction(H.JoinString,_.parts.length,_.source)}visitJoinedStringPart(_){if(this.lineInstruction(_),_ instanceof v0)this.instruction(H.PushConstantString,_.value,_.source);else if(_ instanceof u0)this.visitNodeOrNull(_.expression);else throw Error(`Unsupported StringPart: ${_.constructor.name}`)}visitIdentifier(_){let A=_.reference;if(A==null){_.reportError(this.diagnostics,E.SYMBOL_IS_NULL);return}if(this.lineInstruction(_),A instanceof g1&&A.trigger==Y0){if(this.emitDynamicCommand(_.text,_))return;this.instruction(H.Command,A,_.source)}else this.instruction(H.PushConstantSymbol,A,_.source)}visitNodeOrNull(_){if(!_)return;_.accept(this)}visitNodes(_){if(!_)return;for(let A of _)this.visitNodeOrNull(A)}static LOGICAL_AND="&";static LOGICAL_OR="|";static LOGICAL_OPERATORS=[e.LOGICAL_AND,e.LOGICAL_OR];static INT_BRANCHES=new Map([["=",H.BranchEquals],["!",H.BranchNot],["<",H.BranchLessThan],[">",H.BranchGreaterThan],["<=",H.BranchLessThanOrEquals],[">=",H.BranchGreaterThanOrEquals]]);static OBJ_BRANCHES=new Map([["=",H.ObjBranchEquals],["!",H.ObjBranchNot]]);static LONG_BRANCHES=new Map([["=",H.LongBranchEquals],["!",H.LongBranchNot],["<",H.LongBranchLessThan],[">",H.LongBranchGreaterThan],["<=",H.LongBranchLessThanOrEquals],[">=",H.LongBranchGreaterThanOrEquals]]);static BRANCH_MAPPINGS=new Map([[0,e.INT_BRANCHES],[1,e.OBJ_BRANCHES],[2,e.LONG_BRANCHES]]);static INT_OPERATIONS=new Map([["+",H.Add],["-",H.Sub],["*",H.Multiply],["/",H.Divide],["%",H.Modulo],["&",H.And],["|",H.Or]]);static LONG_OPERATIONS=new Map([["+",H.LongAdd],["-",H.LongSub],["*",H.LongMultiply],["/",H.LongDivide],["%",H.LongModulo],["&",H.LongAnd],["|",H.LongOr]])}class q1{instruction;next=[];previous=[];constructor(_){this.instruction=_}addNext(_){this.next.push(_),_.previous.push(this)}toString(){return`InstructionNode(instruction=${this.instruction})`}}class W1 extends q1{set;constructor(_){super(null);this.set=_}}class S2{commandPointers;constructor(_){this.commandPointers=_}generate(_){let A=new Map,R=[],U=new q1(null);U.addNext(this.firstInstruction(_[0],A,_)),R.push(U);let N=!1;for(let Y=0;Y<_.length;Y++){let X=_[Y];for(let Q=0;Q<X.instructions.length;Q++){let $=X.instructions[Q];if($.opcode===H.LineNumber)continue;let J=this.getOrCreate(A,$);if(R.push(J),N&&$.opcode===H.BranchEquals&&this.checkInvertedConditional(X.instructions,Q)){if(Q+1>=X.instructions.length)throw Error("Invalid inverted conditional layout");let I=X.instructions[Q+1],w=this.getOrCreate(A,I);if(I.opcode!==H.Branch)throw Error("Expected Branch opcode");let C=X.instructions[Q-2];if(C.opcode!==H.Command)throw Error("Expected command before conditional");let V=C.operand.name,m=this.commandPointers.get(V).set,N0=new W1(m);R.push(N0),J.addNext(N0),N0.addNext(w),N=!1}else if(!Z5.has($.opcode)){let I;if(Q+1<X.instructions.length)I=X.instructions[Q+1];else if(Y+1<_.length)I=_[Y+1].instructions[0];else throw Error("No next instruction");J.addNext(this.getOrCreate(A,I))}if(N&&$.opcode===H.BranchEquals&&this.checkConditional(X.instructions,Q)){let I=$.operand,w=_.find((R2)=>R2.label===I);if(!w)throw Error("Unable to find block.");let C=X.instructions[Q-2];if(C.opcode!==H.Command)throw Error("Expected command before conditional.");let V=C.operand.name,m=this.commandPointers.get(V).set,N0=new W1(m);R.push(N0),J.addNext(N0),N0.addNext(this.firstInstruction(w,A,_)),N=!1}else if($5.has($.opcode)){let I=$.operand,w=_.find((C)=>C.label===I);if(!w)throw Error("Unable to find block.");J.addNext(this.firstInstruction(w,A,_))}else if($.opcode===H.Switch){let I=$.operand;for(let w of I.cases){if(w.keys.length===0)continue;let C=_.find((V)=>V.label===w.label);if(!C)throw Error("Unable to find block.");J.addNext(this.firstInstruction(C,A,_))}}if(this.isConditionalPointerSetter($))N=!0}}return R}checkConditional(_,A){if(A<2)return!1;let R=_[A-2];if(!this.isConditionalPointerSetter(R))return!1;let U=_[A-1];return U.opcode===H.PushConstantInt&&U.operand===1}checkInvertedConditional(_,A){if(A<2)return!1;let R=_[A-2];if(!this.isConditionalPointerSetter(R))return!1;let U=_[A-1];return U.opcode===H.PushConstantInt&&U.operand===0}isConditionalPointerSetter(_){if(_.opcode==H.Command&&_.operand instanceof V0){let A=this.commandPointers.get(_.operand.name);return A!==void 0&&A.conditionalSet}return!1}firstInstruction(_,A,R){let U=this.firstValid(_.instructions);if(U)return this.getOrCreate(A,U);let N=R.indexOf(_);for(let Y=N;Y<R.length;Y++){let X=this.firstValid(R[Y].instructions);if(X)return this.getOrCreate(A,X)}throw Error("No instructions remaining.")}firstValid(_){for(let A of _)if(A.opcode!==H.LineNumber)return A;return null}getOrCreate(_,A){let R=_.get(A);if(!R)R=new q1(A),_.set(A,R);return R}}var Z5=new Set([H.Branch,H.Jump,H.Return]),$5=new Set([H.Branch,H.BranchNot,H.BranchEquals,H.BranchLessThan,H.BranchGreaterThan,H.BranchLessThanOrEquals,H.BranchGreaterThanOrEquals,H.LongBranchNot,H.LongBranchEquals,H.LongBranchLessThan,H.LongBranchGreaterThan,H.LongBranchLessThanOrEquals,H.LongBranchGreaterThanOrEquals,H.ObjBranchNot,H.ObjBranchEquals]);class y0{code=void 0;baseType=0;defaultValue=-1;options=new d({allowArray:!1,allowDeclaration:!1,allowSwitch:!1})}class Q0 extends y0{inner;representation;constructor(_){super();this.inner=_;this.representation=`varp<${_.representation}>`}}class Z0 extends y0{inner;representation;constructor(_){super();this.inner=_;this.representation=`varbit<${_.representation}>`}}class J0 extends y0{inner;representation;constructor(_){super();this.inner=_;this.representation=`varn<${_.representation}>`}}class z1 extends y0{inner;representation;constructor(_){super();this.inner=_;this.representation=`vars<${_.representation}>`}}class m2{diagnostics;scripts;commandPointers;scriptsBySymbol;graphGenerator;scriptGraphs=new Map;scriptPointers=new Map;pendingScripts=new Set;constructor(_,A,R){this.diagnostics=_;this.scripts=A;this.commandPointers=R;this.scriptsBySymbol=new Map(A.map((U)=>[U.symbol,U])),this.graphGenerator=new S2(R)}getGraph(_){let A=this.scriptGraphs.get(_.symbol);if(A)return A;let R=this.graphGenerator.generate(_.blocks);return this.scriptGraphs.set(_.symbol,R),R}getPointers(_){let A=this.scriptPointers.get(_);if(A)return A;let R=this.calculatePointers(_);return this.scriptPointers.set(_,R),R}run(){for(let _ of this.scripts){let A=performance.now();this.validatePointers(_);let R=performance.now()-A}}calculatePointers(_){if(this.pendingScripts.has(_))return{required:new Set,set:new Set,conditionalSet:!1,corrupted:new Set};let A=this.scriptsBySymbol.get(_);if(!A)throw Error(`Unable to find script from symbol: ${_.name}`);let R=new Set,U=new Set,N=new Set;this.pendingScripts.add(_);for(let Y of G.ALL){if(this.requiresPointerScript(A,Y))R.add(Y);if(this.setsPointerScript(A,Y))U.add(Y);if(this.corruptsPointerScript(A,Y))N.add(Y)}return this.pendingScripts.delete(_),{required:R,set:U,conditionalSet:!1,corrupted:N}}validatePointers(_){for(let A of G.ALL)this.validatePointer(_,A)}validatePointer(_,A){let R=this.getGraph(_),U=R.filter((Q)=>this.requiresPointerNode(Q,A)),N=R.filter((Q)=>this.setsPointerNode(Q,A)),Y=R.filter((Q)=>this.corruptsPointerNode(Q,A));if(!this.setsPointerTrigger(_.trigger,A)){if(R.length>0)Y.push(R[0])}let X=this.findEdgePath(U,(Q)=>Y.includes(Q),(Q)=>Q.previous.filter(($)=>!N.includes($)));if(X!==null){let Q=X[0],$=Q.instruction?.source??(()=>{throw Error("Unknown instruction source.")})(),J=X[X.length-1],I=J!==R[0]&&J!==Q,w=I?E.POINTER_CORRUPTED:E.POINTER_UNINITIALIZED;if(this.diagnostics.report(new _0("ERROR",$,w,[A.representation])),I){let V=J.instruction?.source??(()=>{throw Error("Unknown instruction source.")})();this.diagnostics.report(new _0("HINT",V,E.POINTER_CORRUPTED_LOC,[A.representation]))}let C=(V)=>{let m=V.instruction?.opcode;if(m!==H.Gosub&&m!==H.Jump)return;let N0=V.instruction.operand,R2=this.scripts.find((Q5)=>Q5.symbol===N0);if(!R2)throw Error("Unable to find script.");let A4=this.requiresPointerPathScript(R2,A);if(!A4)throw Error("Unable to find requirement path?");let R4=A4[0],G5=R4.instruction?.source??(()=>{throw Error("Invalid instruction/source.")})();this.diagnostics.report(new _0("HINT",G5,E.POINTER_REQUIRED_LOC,[A.representation])),C(R4)};C(Q)}}setsPointerTrigger(_,A){let R=_.pointers;return R!=null&&R.has(A)}requiresPointerScript(_,A){return this.requiresPointerPathScript(_,A)!==null}requiresPointerPathScript(_,A){let R=this.getGraph(_),U=R.filter((N)=>this.requiresPointerNode(N,A));return this.findEdgePath(U,(N)=>N===R[0],(N)=>N.previous.filter((Y)=>!this.setsPointerNode(Y,A)))}setsPointerScript(_,A){let R=this.getGraph(_),U=R.filter((N)=>N.instruction?.opcode===H.Return);return this.findEdgePath(U,(N)=>N===R[0]||this.corruptsPointerNode(N,A),(N)=>N.previous.filter((Y)=>!this.setsPointerNode(Y,A)))===null}corruptsPointerScript(_,A){let U=this.getGraph(_).filter((N)=>N.instruction?.opcode===H.Return);return this.findEdgePath(U,(N)=>this.corruptsPointerNode(N,A),(N)=>N.previous.filter((Y)=>!this.setsPointerNode(Y,A)))!==null}requiresPointerNode(_,A){let R=_.instruction;if(!R)return!1;switch(R.opcode){case H.Command:{let U=R.operand,N=this.commandPointers.get(U.name);return N?N.required.has(A):!1}case H.Gosub:case H.Jump:{let U=R.operand;return this.getPointers(U).required.has(A)}case H.PushVar:{let N=R.operand.type;if(N instanceof Q0)return A===G.ACTIVE_PLAYER;if(N instanceof Z0)return A===G.ACTIVE_PLAYER;if(N instanceof J0)return A===G.ACTIVE_NPC;return!1}case H.PopVar:{let U=R.operand,N=U.type;if(N instanceof Q0||N instanceof Z0)return U.isProtected?A===G.P_ACTIVE_PLAYER:A===G.ACTIVE_PLAYER;if(N instanceof J0)return A===G.ACTIVE_NPC;return!1}case H.PushVar2:{let N=R.operand.type;if(N instanceof Q0)return A===G.ACTIVE_PLAYER2;if(N instanceof Z0)return A===G.ACTIVE_PLAYER2;if(N instanceof J0)return A===G.ACTIVE_NPC2;return!1}case H.PopVar2:{let U=R.operand,N=U.type;if(N instanceof Q0||N instanceof Z0)return U.isProtected?A===G.P_ACTIVE_PLAYER2:A===G.ACTIVE_PLAYER2;if(N instanceof J0)return A===G.ACTIVE_NPC2;return!1}default:return!1}}setsPointerNode(_,A){if(_ instanceof W1)return _.set.has(A);let R=_.instruction;if(!R)return!1;switch(R.opcode){case H.Command:{let U=R.operand,N=this.commandPointers.get(U.name);return N?N.set.has(A)&&!N.conditionalSet:!1}case H.Gosub:{let U=R.operand;return this.getPointers(U).set.has(A)}default:return!1}}corruptsPointerNode(_,A){let R=_.instruction;if(!R)return!1;switch(R.opcode){case H.Command:{let U=R.operand,N=this.commandPointers.get(U.name);return N?N.corrupted.has(A):!1}case H.Gosub:{let U=R.operand;return this.getPointers(U).corrupted.has(A)}default:return!1}}findEdgePath(_,A,R){if(!_.length)return null;let U=new Map,N=new Map,Y=[];for(let X of _)for(let Q of R(X))if(!U.has(Q))N.set(Q,X),U.set(Q,null),Y.push(Q);while(Y.length){let X=Y.shift();if(A(X)){let Q=[],$=X;while($)Q.unshift($),$=U.get($)??void 0;return Q.unshift(N.get(Q[0])),Q}for(let Q of R(X))if(!U.has(Q))U.set(Q,X),Y.push(Q)}return null}}class U1{_diagnostics=[];get diagnostics(){return this._diagnostics}report(_){this._diagnostics.push(_)}hasErrors(){return this._diagnostics.some((_)=>U1.ERROR_TYPES.has(_.type))}static ERROR_TYPES=new Set(["ERROR","SYNTAX_ERROR"])}import H5 from"fs";import F5 from"path";import J5 from"util";class x2{handleParse(_){this.handleShared(_)}handleTypeChecking(_){this.handleShared(_)}handleCodeGeneration(_){this.handleShared(_)}handlePointerChecking(_){this.handleShared(_)}handleShared(_){let A=new Map;for(let R of _.diagnostics){let U=F5.resolve(R.sourceLocation.name);if(!A.has(U))A.set(U,H5.readFileSync(U,"utf-8").split(/\r?\n/));let N=A.get(U),Y=`${R.sourceLocation.name}:${R.sourceLocation.line}:${R.sourceLocation.column}`;console.log(`${Y}: ${R.type}: ${J5.format(R.message,...R.messageArgs)}`);let X=R.sourceLocation.line-1;if(X>=0&&X<N.length){let Q=N[X],$=Q.replace(/\t/g," "),J=(Q.match(/\t/g)??[]).length,I=R.sourceLocation.column??1,w=Math.max(1,I),C=Math.max(0,J*3+(w-1));console.log(` > ${$}`),console.log(` > ${" ".repeat(C)}^`)}}if(_.hasErrors())process.exit(1)}}var N4=new WeakMap,Y4=new WeakMap,X4=new Map,I5={kind:"LocalVariable"},q5={kind:"Constant"},x={serverScript:(_)=>{let A=N4.get(_);if(!A)A={kind:"ServerScript",type:_},N4.set(_,A);return A},clientScript:(_)=>{let A=Y4.get(_);if(!A)A={kind:"ClientScript",type:_},Y4.set(_,A);return A},localVariable:()=>I5,basic:(_)=>{let A=X4.get(_);if(!A)A={kind:"Basic",type:_},X4.set(_,A);return A},constant:()=>q5};class g2 extends P0{typeManager;triggerManager;rootTable;diagnostics;tables=[];get table(){return this.tables[0]}categoryType;constructor(_,A,R,U){super();this.typeManager=_;this.triggerManager=A;this.rootTable=R;this.diagnostics=U;this.categoryType=this.typeManager.findOrNull("category"),this.tables.unshift(this.rootTable.createSubTable())}isTypeMode(_){return"type"in _}createScopedTable(_){this.tables.unshift(this.table.createSubTable());try{_()}finally{this.tables.shift()}}visitScriptFile(_){for(let A of _.scripts)this.createScopedTable(()=>{A.accept(this)})}visitScript(_){let A=this.triggerManager.findOrNull(_.trigger.text);if(!A)_.trigger.reportError(this.diagnostics,E.SCRIPT_TRIGGER_INVALID,_.trigger.text);else _.triggerType=A;if(_.isStar&&A!==Y0)_.name.reportError(this.diagnostics,E.SCRIPT_COMMAND_ONLY);this.checkScriptSubject(A,_);let R=_.parameters;R?.forEach((N)=>N.accept(this)),_.parameterType=M.fromList(R?.map((N)=>N.symbol.type??W.Error)??[]),this.checkScriptParameters(A,_,R);let U=_.returnTokens;if(U&&U.length>0){let N=[];for(let Y of U){let X=this.typeManager.findOrNull(Y.text);if(!X)Y.reportError(this.diagnostics,E.GENERIC_INVALID_TYPE,Y.text);N.push(X??W.Error)}_.returnType=M.fromList(N.map((Y)=>Y??W.Error))}else _.returnType=!A?W.Error:A.allowReturns?W.Unit:W.Nothing;if(this.checkScriptReturns(A,_),A){let N=new g1(A,_.nameString,_.parameterType,_.returnType);if(!this.rootTable.insert(x.serverScript(A),N))_.reportError(this.diagnostics,E.SCRIPT_REDECLARATION,A.identifier,_.nameString);else _.symbol=N}_.statements.forEach((N)=>N.accept(this)),_.block=this.table}checkScriptSubject(_,A){let R=_?.subjectMode;if(!R)return;let U=A.name.text;if(R===K.Name)return;if(U==="_"){this.checkGlobalScriptSubject(_,A);return}if(U.startsWith("_")){this.checkCategoryScriptSubject(_,A,U.substring(1));return}this.checkTypeScriptSubject(_,A,U)}checkGlobalScriptSubject(_,A){let R=_.subjectMode;if(R===K.None)return;if(this.isTypeMode(R)){if(!R.global)A.name.reportError(this.diagnostics,E.SCRIPT_SUBJECT_NO_GLOBAL,_.identifier);return}throw Error(`Unexpected subject mode: ${R}.`)}checkCategoryScriptSubject(_,A,R){let U=_.subjectMode,N=this.categoryType;if(!N)throw Error("'category' type not defined.");if(U===K.None){A.name.reportError(this.diagnostics,E.SCRIPT_SUBJECT_ONLY_GLOBAL,_.identifier);return}if(this.isTypeMode(U)){if(!U.category){A.name.reportError(this.diagnostics,E.SCRIPT_SUBJECT_NO_CATEGORY,_.identifier);return}this.resolveSubjectSymbol(A,R,N);return}throw Error(`Unexpected subject mode: ${U}.`)}checkTypeScriptSubject(_,A,R){let U=_.subjectMode;if(U===K.None){A.name.reportError(this.diagnostics,E.SCRIPT_SUBJECT_ONLY_GLOBAL,_.identifier);return}if(this.isTypeMode(U)){this.resolveSubjectSymbol(A,R,U.type);return}throw Error(`Unexpected subject mode: ${U}.`)}tryParseMapZone(_,A){let R=A.split("_");if(R.length!==3)return _.name.reportError(this.diagnostics,"Mapzone subject must be of the form: 'level_mx_mz'."),-1;let[U,N,Y]=R,X=parseInt(U,10),Q=parseInt(N,10),$=parseInt(Y,10);if(Q<0||Q>255||$<0||$>255)_.name.reportError(this.diagnostics,"Invalid mapzone coord.");if(X!==0)return _.name.reportError(this.diagnostics,"Mapzone affect all level, just specify '0'."),-1;let J=Q<<6;return $<<6&16383|(J&16383)<<14}tryParseZone(_,A){let R=A.split("_");if(R.length!==5)return _.name.reportError(this.diagnostics,"Zone subject must be of the form: 'level_mx_mz_lx_lz'."),-1;let[U,N,Y,X,Q]=R,$=parseInt(U,10),J=parseInt(N,10),I=parseInt(Y,10),w=parseInt(X,10),C=parseInt(Q,10);if($<0||$>3||J<0||J>255||I<0||I>255||w<0||w>63||C<0||C>63)_.name.reportError(this.diagnostics,"Invalid zone coord.");if(w%8!==0||C%8!==0)return _.name.reportError(this.diagnostics,"Local zone coord must be a multiple of 8"),-1;let V=(J<<6|w)>>3<<3;return(I<<6|C)>>3<<3&16383|(V&16383)<<14|($&3)<<28}resolveSubjectSymbol(_,A,R){if(R===D.MAPZONE){let N=this.tryParseMapZone(_,A);_.subjectReference=new r(N.toString(),R,!1);return}if(R===D.COORD){let N=this.tryParseZone(_,A);_.subjectReference=new r(N.toString(),R,!1);return}let U=this.rootTable.find(x.basic(R),A);if(!U){_.name.reportError(this.diagnostics,E.GENERIC_UNRESOLVED_SYMBOL,A);return}if(!(("type"in U)&&("isProtected"in U))){_.name.reportError(this.diagnostics,E.GENERIC_UNRESOLVED_SYMBOL,A);return}_.subjectReference=U}checkScriptParameters(_,A,R){let U=_?.parameters,N=A.parameterType;if(_&&!_.allowParameters&&R&&R.length>0)R[0].reportError(this.diagnostics,E.SCRIPT_TRIGGER_NO_PARAMETERS,_.identifier);else if(U&&N!==U){let Y=U.representation;A.reportError(this.diagnostics,E.SCRIPT_TRIGGER_EXPECTED_PARAMETERS,A.trigger.text,Y)}}checkScriptReturns(_,A){let R=_?.returns,U=A.returnType;if(_&&!_.allowReturns&&U!==W.Nothing)A.reportError(this.diagnostics,E.SCRIPT_TRIGGER_NO_RETURNS,_.identifier);else if(R&&U!==R){let N=R.representation;A.reportError(this.diagnostics,E.SCRIPT_TRIGGER_EXPECTED_RETURNS,A.trigger.text,N)}}visitParameter(_){let A=_.name.text,R=_.typeToken.text,U=this.typeManager.findOrNull(R,!0);if(!U)_.reportError(this.diagnostics,E.GENERIC_INVALID_TYPE,R);let N=new F0(A,U??W.Error);if(!this.table.insert(x.localVariable(),N))_.reportError(this.diagnostics,E.SCRIPT_LOCAL_REDECLARATION,A);_.symbol=N}visitBlockStatement(_){this.createScopedTable(()=>{this.visit(_.statements),_.scope=this.table})}visitSwitchStatement(_){let A=_.typeToken.text.replace(/^switch_/,""),R=this.typeManager.findOrNull(A);if(!R)_.typeToken.reportError(this.diagnostics,E.GENERIC_INVALID_TYPE,A);else if(!R?.options?.allowSwitch)_.typeToken.reportError(this.diagnostics,E.SWITCH_INVALID_TYPE,R.representation);_.condition.accept(this),this.visit(_.cases),_.type=R??W.Error}visitSwitchCase(_){this.visit(_.keys),this.createScopedTable(()=>{this.visit(_.statements),_.scope=this.table})}visitNode(_){this.visit(_.children)}visit(_){for(let A of _)A.accept(this)}}var W5=Object.defineProperty,q=(_,A)=>W5(_,"name",{value:A,configurable:!0}),G2;((_)=>{_.EOF=-1,_.UNKNOWN_SOURCE_NAME="<unknown>"})(G2||(G2={}));var B;((_)=>{_.INVALID_TYPE=0,_.EPSILON=-2,_.MIN_USER_TOKEN_TYPE=1,_.EOF=G2.EOF,_.DEFAULT_CHANNEL=0,_.HIDDEN_CHANNEL=1,_.MIN_USER_CHANNEL_VALUE=2})(B||(B={}));var z5=q((_)=>{let A=_;return A.tokenSource!==void 0&&A.channel!==void 0},"isToken"),k0=class{static{q(this,"BitSet")}data;constructor(_){if(_)this.data=new Uint32Array(_.map((A)=>{return A>>>0}));else this.data=new Uint32Array(1)}[Symbol.iterator](){let _=this.data.length,A=0,R=this.data[A],U=this.data;return{[Symbol.iterator](){return this},next:q(()=>{while(A<_)if(R!==0){let N=R&-R,Y=(A<<5)+this.bitCount(N-1);return R^=N,{done:!1,value:Y}}else if(A++,A<_)R=U[A];return{done:!0,value:void 0}},"next")}}clear(_){if(_===void 0)this.data=new Uint32Array;else this.resize(_),this.data[_>>>5]&=~(1<<_)}or(_){let A=Math.min(this.data.length,_.data.length);for(let R=0;R<A;++R)this.data[R]|=_.data[R];if(this.data.length<_.data.length){this.resize((_.data.length<<5)-1);let R=_.data.length;for(let U=A;U<R;++U)this.data[U]=_.data[U]}}get(_){if(_<0)throw RangeError("index cannot be negative");let A=_>>>5;if(A>=this.data.length)return!1;return(this.data[A]&1<<_%32)!==0}get length(){let _=0,A=this.data.length,R=this.data;for(let U=0;U<A;U++)_+=this.bitCount(R[U]);return _}values(){let _=Array(this.length),A=0,R=this.data.length;for(let U=0;U<R;++U){let N=this.data[U];while(N!==0){let Y=N&-N;_[A++]=(U<<5)+this.bitCount(Y-1),N^=Y}}return _}nextSetBit(_){if(_<0)throw RangeError("index cannot be negative");for(let A of this)if(A>=_)return A;return}set(_){if(_<0)throw RangeError("index cannot be negative");this.resize(_),this.data[_>>>5]|=1<<_%32}toString(){return"{"+this.values().join(", ")+"}"}resize(_){let A=_+32>>>5;if(A<=this.data.length)return;let R=new Uint32Array(A);R.set(this.data),R.fill(0,this.data.length),this.data=R}bitCount(_){return _=_-(_>>1&1431655765),_=(_&858993459)+(_>>2&858993459),_=_+(_>>4)&252645135,_=_+(_>>8),_=_+(_>>16),_&63}},K5=3432918353,L5=461845907,G4=15,Q4=13,B5=5,D5=3864292196,k=class _{static{q(this,"MurmurHash")}static defaultSeed=701;constructor(){}static initialize(A=_.defaultSeed){return A}static updateFromComparable(A,R){return this.update(A,R?.hashCode()??0)}static update(A,R){return R=Math.imul(R,K5),R=R<<G4|R>>>32-G4,R=Math.imul(R,L5),A=A^R,A=A<<Q4|A>>>32-Q4,A=Math.imul(A,B5)+D5,A}static finish(A,R){return A^=R*4,A^=A>>>16,A=Math.imul(A,2246822507),A^=A>>>13,A=Math.imul(A,3266489909),A^=A>>>16,A}static hashCode(A,R){return _.finish(_.update(R??_.defaultSeed,A),1)}},Y1=class _{static{q(this,"ObjectEqualityComparator")}static instance=new _;hashCode(A){if(A==null)return 0;return A.hashCode()}equals(A,R){if(A==null)return R==null;return A.equals(R)}},D4=class _{static{q(this,"DefaultEqualityComparator")}static instance=new _;hashCode(A){if(A==null)return 0;return Y1.instance.hashCode(A)}equals(A,R){if(A==null)return R==null;if(typeof A==="string"||typeof A==="number")return A===R;return Y1.instance.equals(A,R)}},$0=class _{static{q(this,"HashSet")}static defaultLoadFactor=0.75;static initialCapacity=16;comparator;buckets;threshold;itemCount=0;constructor(A,R=_.initialCapacity){if(A instanceof _){this.comparator=A.comparator,this.buckets=A.buckets.slice(0);for(let U=0;U<this.buckets.length;U++){let N=this.buckets[U];if(N)this.buckets[U]=N.slice(0)}this.itemCount=A.itemCount,this.threshold=A.threshold}else this.comparator=A??D4.instance,this.buckets=this.createBuckets(R),this.threshold=Math.floor(_.initialCapacity*_.defaultLoadFactor)}getOrAdd(A){if(this.itemCount>this.threshold)this.expand();let R=this.getBucket(A),U=this.buckets[R];if(!U)return U=[A],this.buckets[R]=U,++this.itemCount,A;for(let N of U)if(this.comparator.equals(N,A))return N;return U.push(A),++this.itemCount,A}get(A){if(A==null)return A;let R=this.getBucket(A),U=this.buckets[R];if(!U)return;for(let N of U)if(this.comparator.equals(N,A))return N;return}remove(A){if(A==null)return!1;let R=this.getBucket(A),U=this.buckets[R];if(!U)return!1;for(let N=0;N<U.length;N++){let Y=U[N];if(this.comparator.equals(Y,A))return U.splice(N,1),--this.itemCount,!0}return!1}hashCode(){let A=k.initialize();for(let R of this.buckets){if(R==null)continue;for(let U of R){if(U==null)break;A=k.update(A,this.comparator.hashCode(U))}}return A=k.finish(A,this.size),A}equals(A){if(A===this)return!0;if(!(A instanceof _))return!1;if(A.size!==this.size)return!1;return this.containsAll(A)}add(A){return this.getOrAdd(A)===A}contains(A){return this.containsFast(A)}containsFast(A){if(A==null)return!1;return this.get(A)!==void 0}*[Symbol.iterator](){yield*this.toArray()}toArray(){let A=Array(this.size),R=0;for(let U of this.buckets){if(U==null)continue;for(let N of U){if(N==null)break;A[R++]=N}}return A}containsAll(A){if(A instanceof _)for(let R of A.buckets){if(R==null)continue;for(let U of R){if(U==null)break;if(!this.containsFast(U))return!1}}else for(let R of A)if(!this.containsFast(R))return!1;return!0}addAll(A){let R=!1;for(let U of A)if(this.getOrAdd(U)!==U)R=!0;return R}clear(){this.buckets=this.createBuckets(_.initialCapacity),this.itemCount=0,this.threshold=Math.floor(_.initialCapacity*_.defaultLoadFactor)}toString(){if(this.size===0)return"{}";let A="{",R=!0;for(let U of this.buckets){if(U==null)continue;for(let N of U){if(N==null)break;if(R)R=!1;else A+=", ";A+=N.toString()}}return A+="}",A}toTableString(){let A="";for(let R of this.buckets){if(R==null){A+=`null
2
+ `;continue}A+="[";let U=!0;for(let N of R){if(U)U=!1;else A+=" ";if(N==null)A+="_";else A+=N.toString()}A+=`]
3
+ `}return A}getBucket(A){return this.comparator.hashCode(A)&this.buckets.length-1}expand(){let A=this.buckets,R=this.buckets.length*2,U=this.createBuckets(R);this.buckets=U,this.threshold=Math.floor(R*_.defaultLoadFactor);for(let N of A){if(!N)continue;for(let Y of N){let X=this.getBucket(Y),Q=this.buckets[X];if(!Q)Q=[],this.buckets[X]=Q;Q.push(Y)}}}get size(){return this.itemCount}get isEmpty(){return this.itemCount===0}createBuckets(A){return Array(A)}},v=class _{static{q(this,"Interval")}static INVALID_INTERVAL=new _(-1,-2);static INTERVAL_POOL_MAX_VALUE=1000;static cache=[];start;stop;cachedHashCode;constructor(A,R){this.start=A,this.stop=R,this.cachedHashCode=Math.imul(651+A,31)+R}static of(A,R){if(A!==R||A<0||A>_.INTERVAL_POOL_MAX_VALUE)return new _(A,R);if(!_.cache[A])_.cache[A]=new _(A,A);return _.cache[A]}equals(A){return this.start===A.start&&this.stop===A.stop}hashCode(){return this.cachedHashCode}startsBeforeDisjoint(A){return this.start<A.start&&this.stop<A.start}startsBeforeNonDisjoint(A){return this.start<=A.start&&this.stop>=A.start}startsAfter(A){return this.start>A.start}startsAfterDisjoint(A){return this.start>A.stop}startsAfterNonDisjoint(A){return this.start>A.start&&this.start<=A.stop}disjoint(A){return this.startsBeforeDisjoint(A)||this.startsAfterDisjoint(A)}adjacent(A){return this.start===A.stop+1||this.stop===A.start-1}properlyContains(A){return A.start>=this.start&&A.stop<=this.stop}union(A){return _.of(Math.min(this.start,A.start),Math.max(this.stop,A.stop))}intersection(A){return _.of(Math.max(this.start,A.start),Math.min(this.stop,A.stop))}differenceNotProperlyContained(A){let R=null;if(A.startsBeforeNonDisjoint(this))R=_.of(Math.max(this.start,A.stop+1),this.stop);else if(A.startsAfterNonDisjoint(this))R=_.of(this.start,A.start-1);return R}toString(){return`${this.start}..${this.stop}`}get length(){if(this.stop<this.start)return 0;return this.stop-this.start+1}},K0=class _{static{q(this,"Vocabulary")}static EMPTY_NAMES=[];static EMPTY_VOCABULARY=new _(_.EMPTY_NAMES,_.EMPTY_NAMES,_.EMPTY_NAMES);maxTokenType;literalNames;symbolicNames;displayNames;constructor(A,R,U){this.literalNames=A??_.EMPTY_NAMES,this.symbolicNames=R??_.EMPTY_NAMES,this.displayNames=U??_.EMPTY_NAMES,this.maxTokenType=Math.max(this.displayNames.length,Math.max(this.literalNames.length,this.symbolicNames.length))-1}static fromTokenNames(A){if(A==null||A.length===0)return _.EMPTY_VOCABULARY;let R=[...A],U=[...A];for(let N=0;N<A.length;N++){let Y=A[N];if(Y==null)continue;if(Y.length>0){let X=Y.codePointAt(0);if(X===39){U[N]=null;continue}else if(X>=65&&X<=90){R[N]=null;continue}}R[N]=null,U[N]=null}return new _(R,U,A)}getMaxTokenType(){return this.maxTokenType}getLiteralName(A){if(A>=0&&A<this.literalNames.length)return this.literalNames[A];return null}getSymbolicName(A){if(A>=0&&A<this.symbolicNames.length)return this.symbolicNames[A];if(A===B.EOF)return"EOF";return null}getDisplayName(A){if(A>=0&&A<this.displayNames.length){let N=this.displayNames[A];if(N!=null)return N}let R=this.getLiteralName(A);if(R!=null)return R;let U=this.getSymbolicName(A);if(U!=null)return U;return`${A}`}getLiteralNames(){return this.literalNames}getSymbolicNames(){return this.symbolicNames}getDisplayNames(){return this.displayNames}},W0=class _{static{q(this,"IntervalSet")}intervals=[];cachedHashCode;constructor(A){if(A)if(Array.isArray(A))for(let R of A)this.addOne(R);else this.addSet(A)}static of(A,R){let U=new _;return U.addRange(A,R),U}static or(A){let R=new _;for(let U of A)R.addSet(U);return R}[Symbol.iterator](){return this.intervals[Symbol.iterator]()}get(A){return this.intervals[A]}get minElement(){if(this.intervals.length===0)return B.INVALID_TYPE;return this.intervals[0].start}get maxElement(){if(this.intervals.length===0)return B.INVALID_TYPE;return this.intervals[this.intervals.length-1].stop}clear(){this.cachedHashCode=void 0,this.intervals=[]}addOne(A){this.addInterval(new v(A,A))}addRange(A,R){this.addInterval(new v(A,R))}addInterval(A){if(this.cachedHashCode=void 0,this.intervals.length===0)this.intervals.push(A);else{for(let R=0;R<this.intervals.length;R++){let U=this.intervals[R];if(A.equals(U))return;if(A.adjacent(U)||!A.disjoint(U)){let N=A.union(U);this.intervals[R]=N;for(let Y=R+1;Y<this.intervals.length;){let X=this.intervals[Y];if(!N.adjacent(X)&&N.disjoint(X))break;this.intervals.splice(Y,1),this.intervals[R]=N.union(X)}return}if(A.startsBeforeDisjoint(U)){this.intervals.splice(R,0,A);return}}this.intervals.push(A)}}addSet(A){return A.intervals.forEach((R)=>{return this.addInterval(R)},this),this}complementWithVocabulary(A){let R=new _;if(!A)return R;if(A.length===0)return R;return R.addSet(A),R.subtract(this)}complement(A,R){let U=new _;return U.addInterval(new v(A,R)),U.subtract(this)}or(A){let R=new _;return R.addSet(this),A.forEach((U)=>{return R.addSet(U)}),R}and(A){if(A.length===0)return new _;let R=this.intervals,U=A.intervals,N,Y=R.length,X=U.length,Q=0,$=0;while(Q<Y&&$<X){let J=R[Q],I=U[$];if(J.startsBeforeDisjoint(I))Q++;else if(I.startsBeforeDisjoint(J))$++;else if(J.properlyContains(I)){if(!N)N=new _;N.addInterval(J.intersection(I)),$++}else if(I.properlyContains(J)){if(!N)N=new _;N.addInterval(J.intersection(I)),Q++}else if(!J.disjoint(I)){if(!N)N=new _;if(N.addInterval(J.intersection(I)),J.startsAfterNonDisjoint(I))$++;else if(I.startsAfterNonDisjoint(J))Q++}}if(!N)return new _;return N}subtract(A){if(this.length===0)return new _;let R=new _(this);if(A.length===0)return R;let U=0,N=0;while(U<R.intervals.length&&N<A.intervals.length){let Y=R.intervals[U],X=A.intervals[N];if(X.stop<Y.start){N++;continue}if(X.start>Y.stop){U++;continue}let Q,$;if(X.start>Y.start)Q=new v(Y.start,X.start-1);if(X.stop<Y.stop)$=new v(X.stop+1,Y.stop);if(Q)if($)R.intervals[U]=Q,R.intervals.splice(U+1,0,$),U++,N++;else R.intervals[U]=Q,U++;else if($)R.intervals[U]=$,N++;else R.intervals.splice(U,1)}return R}contains(A){let R=this.intervals.length,U=0,N=R-1;while(U<=N){let Y=Math.floor((U+N)/2),X=this.intervals[Y];if(X.stop<A)U=Y+1;else if(X.start>A)N=Y-1;else return!0}return!1}removeRange(A){if(this.cachedHashCode=void 0,A.start===A.stop)this.removeOne(A.start);else if(this.intervals!==null){let R=0;for(let U of this.intervals){if(A.stop<=U.start)return;else if(A.start>U.start&&A.stop<U.stop){this.intervals[R]=new v(U.start,A.start);let N=new v(A.stop,U.stop);this.intervals.splice(R,0,N);return}else if(A.start<=U.start&&A.stop>=U.stop)this.intervals.splice(R,1),R=R-1;else if(A.start<U.stop)this.intervals[R]=new v(U.start,A.start);else if(A.stop<U.stop)this.intervals[R]=new v(A.stop,U.stop);R+=1}}}removeOne(A){this.cachedHashCode=void 0;for(let R=0;R<this.intervals.length;R++){let U=this.intervals[R];if(A<U.start)return;else if(A===U.start&&A===U.stop){this.intervals.splice(R,1);return}else if(A===U.start){this.intervals[R]=new v(U.start+1,U.stop);return}else if(A===U.stop){this.intervals[R]=new v(U.start,U.stop-1);return}else if(A<U.stop){let N=new v(U.start,A-1);this.intervals[R]=new v(A+1,U.stop),this.intervals.splice(R,0,N);return}}}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize();for(let R of this.intervals)A=k.update(A,R.start),A=k.update(A,R.stop);this.cachedHashCode=k.finish(A,this.intervals.length*2)}return this.cachedHashCode}equals(A){if(this===A)return!0;if(this.intervals.length!==A.intervals.length)return!1;for(let R=0;R<this.intervals.length;R++)if(!this.intervals[R].equals(A.intervals[R]))return!1;return!0}toString(A){if(this.intervals.length===0)return"{}";let R="";if(this.length>1)R+="{";for(let U=0;U<this.intervals.length;++U){let N=this.intervals[U],Y=N.start,X=N.stop;if(Y===X)if(Y===B.EOF)R+="<EOF>";else if(A)R+="'"+String.fromCodePoint(Y)+"'";else R+=Y;else if(A)R+="'"+String.fromCodePoint(Y)+"'..'"+String.fromCodePoint(X)+"'";else R+=Y+".."+X;if(U<this.intervals.length-1)R+=", "}if(this.length>1)R+="}";return R}toStringWithVocabulary(A){if(this.intervals.length===0)return"{}";let R="";if(this.length>1)R+="{";for(let U=0;U<this.intervals.length;++U){let N=this.intervals[U],Y=N.start,X=N.stop;if(Y===X)if(Y===B.EOF)R+="<EOF>";else R+=this.elementName(A,Y);else for(let Q=Y;Q<=X;++Q){if(Q>Y)R+=", ";R+=this.elementName(A,Q)}if(U<this.intervals.length-1)R+=", "}if(this.length>1)R+="}";return R}toStringWithRuleNames(A){if(this.intervals.length===0)return"{}";let R="";if(this.length>1)R+="{";let U=K0.fromTokenNames(A);for(let N=0;N<this.intervals.length;++N){let Y=this.intervals[N],X=Y.start,Q=Y.stop;if(X===Q)if(X===B.EOF)R+="<EOF>";else R+=this.elementName(U,X);else for(let $=X;$<=Q;++$){if($>X)R+=", ";R+=this.elementName(U,$)}if(N<this.intervals.length-1)R+=", "}if(this.length>1)R+="}";return R}toArray(){let A=[];for(let R of this.intervals)for(let U=R.start;U<=R.stop;U++)A.push(U);return A}get length(){let A=0;for(let R of this.intervals)A+=R.length;return A}elementName(A,R){if(R===B.EOF)return"<EOF>";if(R===B.EPSILON)return"<EPSILON>";return A.getDisplayName(R)}};var w5=q((_)=>{return _===null?"null":_},"valueToString"),D1=q((_)=>{return Array.isArray(_)?"["+_.map(w5).join(", ")+"]":"null"},"arrayToString"),$2=q((_,A)=>{if(_===A)return!0;if(_.length!==A.length)return!1;for(let R=0;R<_.length;R++){let U=_[R],N=A[R];if(U===N)continue;if(!U||!U.equals(N))return!1}return!0},"equalArrays"),E5=q((_,A)=>{if(_===A)return!0;if(_.length!==A.length)return!1;for(let R=0;R<_.length;R++)if(_[R]!==A[R])return!1;return!0},"equalNumberArrays"),k5=q((_,A=!1)=>{if(_=_.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r"),A)_=_.replace(/ /g,"·");return _},"escapeWhitespace"),u=class _{static{q(this,"SemanticContext")}cachedHashCode;static andContext(A,R){if(A===null||A===_.NONE)return R;if(R===null||R===_.NONE)return A;let U=new C5(A,R);if(U.operands.length===1)return U.operands[0];return U}static orContext(A,R){if(A===null)return R;if(R===null)return A;if(A===_.NONE||R===_.NONE)return _.NONE;let U=new O5(A,R);if(U.operands.length===1)return U.operands[0];else return U}static filterPrecedencePredicates(A){let R=[];for(let U of A)if(U instanceof _.PrecedencePredicate)R.push(U);return R}evalPrecedence(A,R){return this}},C5=class _ extends u{static{q(this,"AND")}operands;constructor(A,R){super();let U=new $0;if(A instanceof _)A.operands.forEach((Y)=>{U.add(Y)});else U.add(A);if(R instanceof _)R.operands.forEach((Y)=>{U.add(Y)});else U.add(R);let N=u.filterPrecedencePredicates(U);if(N.length>0){let Y=null;if(N.forEach((X)=>{if(Y===null||X.precedence<Y.precedence)Y=X}),Y)U.add(Y)}this.operands=U.toArray()}equals(A){if(this===A)return!0;if(!(A instanceof _))return!1;return $2(this.operands,A.operands)}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize();for(let R of this.operands)A=k.updateFromComparable(A,R);A=k.update(A,3813686060),this.cachedHashCode=k.finish(A,this.operands.length+1)}return this.cachedHashCode}evaluate(A,R){for(let U of this.operands)if(!U.evaluate(A,R))return!1;return!0}evalPrecedence(A,R){let U=!1,N=[];for(let X of this.operands){let Q=X.evalPrecedence(A,R);if(U||=Q!==X,Q===null)return null;else if(Q!==u.NONE)N.push(Q)}if(!U)return this;if(N.length===0)return u.NONE;let Y=null;return N.forEach((X)=>{Y=Y===null?X:u.andContext(Y,X)}),Y}toString(){let A=this.operands.map((R)=>{return R.toString()});return(A.length>3?A.slice(3):A).join("&&")}},O5=class _ extends u{static{q(this,"OR")}operands;constructor(A,R){super();let U=new $0;if(A instanceof _)A.operands.forEach((Y)=>{U.add(Y)});else U.add(A);if(R instanceof _)R.operands.forEach((Y)=>{U.add(Y)});else U.add(R);let N=u.filterPrecedencePredicates(U);if(N.length>0){let Y=N.sort((Q,$)=>{return Q.compareTo($)}),X=Y[Y.length-1];U.add(X)}this.operands=U.toArray()}equals(A){if(this===A)return!0;else if(!(A instanceof _))return!1;else return $2(this.operands,A.operands)}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize();for(let R of this.operands)A=k.updateFromComparable(A,R);A=k.update(A,3383313031),this.cachedHashCode=k.finish(A,this.operands.length+1)}return this.cachedHashCode}evaluate(A,R){for(let U of this.operands)if(U.evaluate(A,R))return!0;return!1}evalPrecedence(A,R){let U=!1,N=[];for(let X of this.operands){let Q=X.evalPrecedence(A,R);if(U||=Q!==X,Q===u.NONE)return u.NONE;else if(Q!==null)N.push(Q)}if(!U)return this;if(N.length===0)return null;let Y=null;return N.forEach((X)=>{Y=Y===null?X:u.orContext(Y,X)}),Y}toString(){let A=this.operands.map((R)=>{return R.toString()});return(A.length>3?A.slice(3):A).join("||")}};((_)=>{class A extends _{static{q(this,"Predicate")}ruleIndex;predIndex;isCtxDependent;constructor(U,N,Y){super();this.ruleIndex=U??-1,this.predIndex=N??-1,this.isCtxDependent=Y??!1}evaluate(U,N){let Y=this.isCtxDependent?N:null;return U.sempred(Y,this.ruleIndex,this.predIndex)}hashCode(){if(this.cachedHashCode===void 0){let U=k.initialize();U=k.update(U,this.ruleIndex),U=k.update(U,this.predIndex),U=k.update(U,this.isCtxDependent?1:0),U=k.finish(U,3),this.cachedHashCode=U}return this.cachedHashCode}equals(U){if(this===U)return!0;return this.ruleIndex===U.ruleIndex&&this.predIndex===U.predIndex&&this.isCtxDependent===U.isCtxDependent}toString(){return"{"+this.ruleIndex+":"+this.predIndex+"}?"}}_.Predicate=A;class R extends _{static{q(this,"PrecedencePredicate")}precedence;constructor(U){super();this.precedence=U??0}evaluate(U,N){return U.precpred(N,this.precedence)}evalPrecedence(U,N){if(U.precpred(N??null,this.precedence))return _.NONE;return null}compareTo(U){return this.precedence-U.precedence}hashCode(){return 31+this.precedence}equals(U){if(this===U)return!0;return this.precedence===U.precedence}toString(){return"{"+this.precedence+">=prec}?"}}_.PrecedencePredicate=R,_.NONE=new A})(u||(u={}));var y=class _{static{q(this,"ATNConfig")}state;alt;reachesIntoOuterContext=!1;precedenceFilterSuppressed=!1;get semanticContext(){return this.#A}cachedHashCode;#_=null;#A;constructor(A,R,U,N){if(this.state=R,this.alt=A.alt,this.context=U,this.#A=N??u.NONE,this.reachesIntoOuterContext=A.reachesIntoOuterContext,A.precedenceFilterSuppressed!==void 0)this.precedenceFilterSuppressed=A.precedenceFilterSuppressed}static duplicate(A,R){return new _(A,A.state,A.context,R??A.semanticContext)}static createWithContext(A,R,U,N){return new _({alt:R},A,U,N)}static createWithConfig(A,R,U){return new _(R,A,U??R.context,R.semanticContext)}static createWithSemanticContext(A,R,U){return new _(R,A??R.state,R.context,U)}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize(7);A=k.update(A,this.state.stateNumber),A=k.update(A,this.alt),A=k.updateFromComparable(A,this.#_),A=k.updateFromComparable(A,this.semanticContext),A=k.finish(A,4),this.cachedHashCode=A}return this.cachedHashCode}get context(){return this.#_}set context(A){this.#_=A,this.cachedHashCode=void 0}equals(A){if(this===A)return!0;return this.state.stateNumber===A.state.stateNumber&&this.alt===A.alt&&(this.context===null?A.context===null:this.context.equals(A.context))&&this.semanticContext.equals(A.semanticContext)&&this.precedenceFilterSuppressed===A.precedenceFilterSuppressed}toString(A,R=!0){let U="";if(R)U=","+this.alt;return"("+this.state+U+(this.context!==null?",["+this.context.toString()+"]":"")+(this.semanticContext!==u.NONE?","+this.semanticContext.toString():"")+(this.reachesIntoOuterContext?",up="+this.reachesIntoOuterContext:"")+")"}},j=class _{static{q(this,"ATNState")}static INVALID_STATE_NUMBER=-1;static INVALID_TYPE=0;static BASIC=1;static RULE_START=2;static BLOCK_START=3;static PLUS_BLOCK_START=4;static STAR_BLOCK_START=5;static TOKEN_START=6;static RULE_STOP=7;static BLOCK_END=8;static STAR_LOOP_BACK=9;static STAR_LOOP_ENTRY=10;static PLUS_LOOP_BACK=11;static LOOP_END=12;static stateType=_.INVALID_STATE_NUMBER;stateNumber=0;ruleIndex=0;epsilonOnlyTransitions=!1;nextTokenWithinRule;transitions=[];hashCode(){return this.stateNumber}equals(A){return this.stateNumber===A.stateNumber}toString(){return`${this.stateNumber}`}addTransitionAtIndex(A,R){if(this.transitions.length===0)this.epsilonOnlyTransitions=R.isEpsilon;else if(this.epsilonOnlyTransitions!==R.isEpsilon)this.epsilonOnlyTransitions=!1;this.transitions.splice(A,0,R)}addTransition(A){if(this.transitions.length===0)this.epsilonOnlyTransitions=A.isEpsilon;else if(this.epsilonOnlyTransitions!==A.isEpsilon)this.epsilonOnlyTransitions=!1;this.transitions.push(A)}setTransition(A,R){this.transitions.splice(A,1,R)}removeTransition(A){return this.transitions.splice(A,1)[0]}},p=class _{static{q(this,"PredictionContext")}static EMPTY_RETURN_STATE=2147483647;static traceATNSimulator=!1;cachedHashCode;constructor(A){this.cachedHashCode=A}static calculateEmptyHashCode(){let A=k.initialize(31);return A=k.finish(A,0),A}static calculateHashCodeSingle(A,R){let U=k.initialize(31);return U=k.updateFromComparable(U,A),U=k.update(U,R),U=k.finish(U,2),U}static calculateHashCodeList(A,R){let U=k.initialize(31);for(let N of A)U=k.updateFromComparable(U,N);for(let N of R)U=k.update(U,N);return U=k.finish(U,2*A.length),U}isEmpty(){return!1}hasEmptyPath(){return this.getReturnState(this.length-1)===_.EMPTY_RETURN_STATE}hashCode(){return this.cachedHashCode}toString(A){return""}},w1=class _ extends p{static{q(this,"SingletonPredictionContext")}parent;returnState;constructor(A,R){super(A?p.calculateHashCodeSingle(A,R):p.calculateEmptyHashCode());this.parent=A??null,this.returnState=R}getParent(A){return this.parent}getReturnState(A){return this.returnState}equals(A){if(this===A)return!0;if(!(A instanceof _))return!1;if(this.hashCode()!==A.hashCode())return!1;if(this.returnState!==A.returnState)return!1;if(this.parent==null)return A.parent==null;return this.parent.equals(A.parent)}toString(){let A=this.parent===null?"":this.parent.toString();if(A.length===0){if(this.returnState===p.EMPTY_RETURN_STATE)return"$";return""+this.returnState}else return""+this.returnState+" "+A}get length(){return 1}},c=class _ extends w1{static{q(this,"EmptyPredictionContext")}static instance=new _;constructor(){super(void 0,p.EMPTY_RETURN_STATE)}isEmpty(){return!0}getParent(){return null}getReturnState(){return this.returnState}equals(A){return this===A}toString(){return"$"}},O=class{static{q(this,"Transition")}static INVALID=0;static EPSILON=1;static RANGE=2;static RULE=3;static PREDICATE=4;static ATOM=5;static ACTION=6;static SET=7;static NOT_SET=8;static WILDCARD=9;static PRECEDENCE=10;target;constructor(_){this.target=_}get isEpsilon(){return!1}get label(){return null}toString(){return""}},p2=class extends O{static{q(this,"SetTransition")}set;constructor(_,A){super(_);if(A)this.set=A;else this.set=W0.of(B.INVALID_TYPE,B.INVALID_TYPE)}get transitionType(){return O.SET}get label(){return this.set}matches(_,A,R){return this.set.contains(_)}toString(){return this.set.toString()}},i2=class extends p2{static{q(this,"NotSetTransition")}get transitionType(){return O.NOT_SET}matches(_,A,R){return _>=A&&_<=R&&!super.matches(_,A,R)}toString(){return"~"+super.toString()}},M5=class{static{q(this,"MapKeyEqualityComparator")}keyComparator;constructor(_){this.keyComparator=_}hashCode(_){return this.keyComparator.hashCode(_.key)}equals(_,A){return this.keyComparator.equals(_.key,A.key)}},m0=class _{static{q(this,"HashMap")}backingStore;constructor(A){if(A instanceof _)this.backingStore=new $0(A.backingStore);else A=A??D4.instance,this.backingStore=new $0(new M5(A))}clear(){this.backingStore.clear()}containsKey(A){return this.backingStore.contains({key:A})}get(A){let R=this.backingStore.get({key:A});if(!R)return;return R.value}get isEmpty(){return this.backingStore.isEmpty}set(A,R){let U=this.backingStore.get({key:A,value:R}),N;if(!U)this.backingStore.add({key:A,value:R});else N=U.value,U.value=R;return N}setIfAbsent(A,R){let U=this.backingStore.get({key:A,value:R}),N;if(!U)this.backingStore.add({key:A,value:R});else N=U.value;return N}keys(){return this.backingStore.toArray().map((A)=>{return A.key})}values(){return this.backingStore.toArray().map((A)=>{return A.value})}get size(){return this.backingStore.size}hashCode(){return this.backingStore.hashCode()}equals(A){return this.backingStore.equals(A.backingStore)}},z0=class{static{q(this,"TerminalNode")}parent=null;symbol;constructor(_){this.symbol=_}getChild(_){return null}getSymbol(){return this.symbol}getPayload(){return this.symbol}getSourceInterval(){if(this.symbol===null)return v.INVALID_INTERVAL;let _=this.symbol.tokenIndex;return new v(_,_)}getChildCount(){return 0}accept(_){return _.visitTerminal(this)}getText(){return this.symbol?.text??""}toString(){if(this.symbol?.type===B.EOF)return"<EOF>";else return this.symbol?.text??""}toStringTree(){return this.toString()}},a1=class extends z0{static{q(this,"ErrorNode")}accept(_){return _.visitErrorNode(this)}},Q2=class _{static{q(this,"CommonToken")}static EMPTY_SOURCE=[null,null];source;tokenIndex;start;stop;type;line;column;channel;#_;constructor(A){if(this.type=A.type,this.source=A.source,this.tokenIndex=A.tokenIndex??-1,this.line=A.line??0,this.column=A.column??-1,this.channel=A.channel??B.DEFAULT_CHANNEL,this.start=A.start??0,this.stop=A.stop??0,this.#_=A.text,A.line===void 0&&A.source[0]!==null)this.line=A.source[0].line;if(A.column===void 0&&A.source[0]!==null)this.column=A.source[0].column}static fromToken(A){let R=[A.tokenSource,A.inputStream];return new _({type:A.type,line:A.line,tokenIndex:A.tokenIndex,column:A.column,channel:A.channel,start:A.start,stop:A.stop,text:A.text,source:R})}static fromType(A,R){return new _({type:A,text:R,source:_.EMPTY_SOURCE})}static fromSource(A,R,U,N,Y){return new _({type:R,channel:U,start:N,stop:Y,source:A})}get tokenSource(){return this.source[0]}get inputStream(){return this.source[1]}set inputStream(A){this.source[1]=A}clone(){return new _({source:this.source,type:this.type,channel:this.channel,start:this.start,stop:this.stop,tokenIndex:this.tokenIndex,line:this.line,column:this.column,text:this.#_})}toString(A){let R="";if(this.channel>0)R=",channel="+this.channel;let U=this.text;if(U)U=U.replace(/\n/g,"\\n"),U=U.replace(/\r/g,"\\r"),U=U.replace(/\t/g,"\\t");else U="<no text>";let N=String(this.type);if(A)N=A.vocabulary.getDisplayName(this.type)??"<unknown>";return"[@"+this.tokenIndex+","+this.start+":"+this.stop+"='"+U+"',<"+N+">"+R+","+this.line+":"+this.column+"]"}get text(){if(this.#_!==void 0)return this.#_;let A=this.inputStream;if(!A)return;let R=A.size;if(this.start<R&&this.stop<R)return A.getTextFromRange(this.start,this.stop);return"<EOF>"}set text(A){this.#_=A}setText(A){this.#_=A}setType(A){this.type=A}setLine(A){this.line=A}setCharPositionInLine(A){this.column=A}setChannel(A){this.channel=A}setTokenIndex(A){this.tokenIndex=A}},a0=class _{static{q(this,"Trees")}static toStringTree(A,R,U){if(R=R??null,U)R=U.ruleNames;let N=_.getNodeText(A,R);N=k5(N,!1);let Y=A.getChildCount();if(Y===0)return N;let X="("+N+" ";if(Y>0)N=_.toStringTree(A.getChild(0),R),X=X.concat(N);for(let Q=1;Q<Y;Q++)N=_.toStringTree(A.getChild(Q),R),X=X.concat(" "+N);return X=X.concat(")"),X}static getNodeText(A,R,U){if(R=R??null,U)R=U.ruleNames;if(R!==null){if(A instanceof h){let X=A.ruleContext.getAltNumber();if(X!==0)return R[A.ruleIndex]+":"+X;return R[A.ruleIndex]}else if(A instanceof a1)return A.toString();else if(A instanceof z0)return A.symbol.text}let N=A.getPayload();if(z5(N))return N.text;return String(A.getPayload())}static getChildren(A){let R=[];for(let U=0;U<A.getChildCount();U++)R.push(A.getChild(U));return R}static getAncestors(A){if(A.parent===null)return[];let R=[],U=A.parent;while(U!==null)R=[U].concat(R),U=U.parent;return R}static isAncestorOf(A,R){if(A===null||R===null||A.parent===null)return!1;let U=R.parent;while(U!==null){if(A===U)return!0;U=U.parent}return!1}static findAllTokenNodes(A,R){return _.findAllNodes(A,R,!0)}static findAllRuleNodes(A,R){return _.findAllNodes(A,R,!1)}static findAllNodes(A,R,U){let N=[];return _.doFindAllNodes(A,R,U,N),N}static descendants(A){let R=[A];for(let U=0;U<A.getChildCount();U++)R=R.concat(_.descendants(A.getChild(U)));return R}static getRootOfSubtreeEnclosingRegion(A,R,U){let N=A.getChildCount();for(let Y=0;Y<N;Y++){let X=A.getChild(Y),Q=this.getRootOfSubtreeEnclosingRegion(X,R,U);if(Q!==null)return Q}if(A instanceof h){if(R>=A.start.tokenIndex&&(A.stop===null||U<=A.stop.tokenIndex))return A}return null}static stripChildrenOutOfRange(A,R,U,N){if(A===null)return;for(let Y=0;Y<A.getChildCount();Y++){let X=A.getChild(Y),Q=X.getSourceInterval();if(A instanceof h&&(Q.stop<U||Q.start>N)){if(this.isAncestorOf(X,R)){let $=Q2.fromType(B.INVALID_TYPE,"...");A.children[Y]=new z0($)}}}}static doFindAllNodes(A,R,U,N){if(U&&A instanceof z0){if(A.symbol?.type===R)N.push(A)}else if(!U&&A instanceof h){if(A.ruleIndex===R)N.push(A)}for(let Y=0;Y<A.getChildCount();Y++)_.doFindAllNodes(A.getChild(Y),R,U,N)}},h=class _{static{q(this,"ParserRuleContext")}static empty=new _(null);start=null;stop=null;children=[];invokingState;parent;constructor(A,R=-1){this.parent=A,this.invokingState=R}copyFrom(A){if(this.parent=A.parent,this.invokingState=A.invokingState,this.children.slice(0,this.children.length),this.start=A.start,this.stop=A.stop,A.children)A.children.forEach((R)=>{if(R instanceof a1)this.children.push(R),R.parent=this})}enterRule(A){}exitRule(A){}addChild(A){return this.children.push(A),A}removeLastChild(){this.children.pop()}addTokenNode(A){let R=new z0(A);return this.children.push(R),R.parent=this,R}addErrorNode(A){return A.parent=this,this.children.push(A),A}getChild(A,R){if(A<0||A>=this.children.length)return null;if(!R)return this.children[A];for(let U of this.children)if(U instanceof R)if(A===0)return U;else A-=1;return null}getToken(A,R){if(R<0||R>=this.children.length)return null;for(let U of this.children)if("symbol"in U){if(U.symbol?.type===A)if(R===0)return U;else R-=1}return null}getTokens(A){let R=[];for(let U of this.children)if("symbol"in U){if(U.symbol?.type===A)R.push(U)}return R}getRuleContext(A,R){return this.getChild(A,R)}getRuleContexts(A){let R=[];for(let U of this.children)if(U instanceof A)R.push(U);return R}getChildCount(){return this.children.length}getSourceInterval(){if(this.start===null)return v.INVALID_INTERVAL;if(this.stop===null||this.stop.tokenIndex<this.start.tokenIndex)return new v(this.start.tokenIndex,this.start.tokenIndex-1);return new v(this.start.tokenIndex,this.stop.tokenIndex)}depth(){let A=0,R=this;while(R!==null)R=R.parent,A+=1;return A}isEmpty(){return this.invokingState===-1}get ruleContext(){return this}get ruleIndex(){return-1}getPayload(){return this}getText(){if(this.children.length===0)return"";return this.children.map((A)=>{return A.getText()}).join("")}getAltNumber(){return P.INVALID_ALT_NUMBER}setAltNumber(A){}accept(A){return A.visitChildren(this)}toStringTree(...A){if(A.length<2)return a0.toStringTree(this,null,A[0]);return a0.toStringTree(this,A[0],A[1])}toString(A,R){A=A??null,R=R??null;let U=this,N="[";while(U!==null&&U!==R){if(A===null){if(!U.isEmpty())N+=U.invokingState}else{let Y=U.ruleIndex,X=Y>=0&&Y<A.length?A[Y]:""+Y;N+=X}if(U.parent!==null&&(A!==null||!U.parent.isEmpty()))N+=" ";U=U.parent}return N+="]",N}},s0=class _ extends p{static{q(this,"ArrayPredictionContext")}parents=[];returnStates=[];constructor(A,R){super(p.calculateHashCodeList(A,R));return this.parents=A,this.returnStates=R,this}isEmpty(){return this.returnStates[0]===p.EMPTY_RETURN_STATE}get length(){return this.returnStates.length}getParent(A){return this.parents[A]}getReturnState(A){return this.returnStates[A]}equals(A){if(this===A)return!0;if(!(A instanceof _)||this.hashCode()!==A.hashCode())return!1;return E5(this.returnStates,A.returnStates)&&$2(this.parents,A.parents)}toString(){if(this.isEmpty())return"[]";let A=[];for(let R=0;R<this.returnStates.length;R++){if(this.returnStates[R]===p.EMPTY_RETURN_STATE){A.push("$");continue}if(A.push(this.returnStates[R].toString()),this.parents[R])A.push(this.parents[R].toString());else A.push("null")}return`[${A.join(", ")}]`}},X1=q((_,A)=>{if(A===p.EMPTY_RETURN_STATE&&_===null)return c.instance;else return new w1(_,A)},"createSingletonPredictionContext"),t2=q((_,A)=>{if(!A)A=h.empty;if(!A.parent||A===h.empty)return c.instance;let R=t2(_,A.parent),N=_.states[A.invokingState].transitions[0];return X1(R,N.followState.stateNumber)},"predictionContextFromRuleContext"),w4=q((_,A,R)=>{if(_.isEmpty())return _;let U=R.get(_);if(U)return U;if(U=A.get(_),U)return R.set(_,U),U;let N=!1,Y=[];for(let Q=0;Q<Y.length;Q++){let $=w4(_.getParent(Q),A,R);if(N||$!==_.getParent(Q)){if(!N){Y=[];for(let J=0;J<_.length;J++)Y[J]=_.getParent(J);N=!0}Y[Q]=$}}if(!N)return A.add(_),R.set(_,_),_;let X;if(Y.length===0)X=c.instance;else if(Y.length===1)X=X1(Y[0]??void 0,_.getReturnState(0));else X=new s0(Y,_.returnStates);return A.add(X),R.set(X,X),R.set(_,X),X},"getCachedPredictionContext"),r2=q((_,A,R,U)=>{if(_===A||_.equals(A))return _;if(_ instanceof w1&&A instanceof w1)return f5(_,A,R,U);if(R){if(_ instanceof c)return _;if(A instanceof c)return A}if(_ instanceof w1)_=new s0([_.parent],[_.returnState]);if(A instanceof w1)A=new s0([A.parent],[A.returnState]);return h5(_,A,R,U)},"merge"),h5=q((_,A,R,U)=>{if(U){let I=U.get(_,A);if(I)return I;if(I=U.get(A,_),I)return I}let N=0,Y=0,X=0,Q=Array(_.returnStates.length+A.returnStates.length).fill(0),$=Array(_.returnStates.length+A.returnStates.length).fill(null);while(N<_.returnStates.length&&Y<A.returnStates.length){let I=_.parents[N],w=A.parents[Y];if(_.returnStates[N]===A.returnStates[Y]){let C=_.returnStates[N];if(C===p.EMPTY_RETURN_STATE&&I===null&&w===null||I!==null&&w!==null&&I===w)$[X]=I,Q[X]=C;else $[X]=r2(I,w,R,U),Q[X]=C;N+=1,Y+=1}else if(_.returnStates[N]<A.returnStates[Y])$[X]=I,Q[X]=_.returnStates[N],N+=1;else $[X]=w,Q[X]=A.returnStates[Y],Y+=1;X+=1}if(N<_.returnStates.length)for(let I=N;I<_.returnStates.length;I++)$[X]=_.parents[I],Q[X]=_.returnStates[I],X+=1;else for(let I=Y;I<A.returnStates.length;I++)$[X]=A.parents[I],Q[X]=A.returnStates[I],X+=1;if(X<$.length){if(X===1){let I=X1($[0]??void 0,Q[0]);if(U!==null)U.set(_,A,I);return I}$=$.slice(0,X),Q=Q.slice(0,X)}let J=new s0($,Q);if(J.equals(_)){if(U!==null)U.set(_,A,_);if(p.traceATNSimulator)console.log("mergeArrays a="+_+",b="+A+" -> a");return _}if(J.equals(A)){if(U!==null)U.set(_,A,A);return A}if(j5($),U!==null)U.set(_,A,J);if(p.traceATNSimulator)console.log("mergeArrays a="+_+",b="+A+" -> "+J);return J},"mergeArrays"),j5=q((_)=>{let A=new m0(Y1.instance);for(let R of _)if(R){if(!A.containsKey(R))A.set(R,R)}for(let R=0;R<_.length;R++)if(_[R])_[R]=A.get(_[R])??null},"combineCommonParents"),f5=q((_,A,R,U)=>{if(U!==null){let Y=U.get(_,A);if(Y!==null)return Y;if(Y=U.get(A,_),Y!==null)return Y}let N=V5(_,A,R);if(N!==null){if(U!==null)U.set(_,A,N);return N}if(_.returnState===A.returnState){let Y=r2(_.parent,A.parent,R,U);if(Y===_.parent)return _;if(Y===A.parent)return A;let X=X1(Y,_.returnState);if(U!==null)U.set(_,A,X);return X}else{let Y=null;if(_===A||_.parent!==null&&_.parent.equals(A.parent))Y=_.parent;if(Y!==null){let J=[_.returnState,A.returnState];if(_.returnState>A.returnState)J[0]=A.returnState,J[1]=_.returnState;let w=new s0([Y,Y],J);if(U!==null)U.set(_,A,w);return w}let X=[_.returnState,A.returnState],Q=[_.parent,A.parent];if(_.returnState>A.returnState)X[0]=A.returnState,X[1]=_.returnState,Q=[A.parent,_.parent];let $=new s0(Q,X);if(U!==null)U.set(_,A,$);return $}},"mergeSingletons"),V5=q((_,A,R)=>{if(R){if(_===c.instance||A===c.instance)return c.instance}else{if(_===c.instance&&A===c.instance)return c.instance;if(_===c.instance){let U=[A.returnState,p.EMPTY_RETURN_STATE],N=[A.parent,null];return new s0(N,U)}if(A===c.instance){let U=[_.returnState,p.EMPTY_RETURN_STATE],N=[_.parent,null];return new s0(N,U)}}return null},"mergeRoot"),P5=class _{constructor(A){this.atn=A}static{q(this,"LL1Analyzer")}static hitPredicate=B.INVALID_TYPE;getDecisionLookahead(A){let R=A.transitions.length,U=Array(R);for(let N=0;N<R;N++){let Y=new W0,X=new $0;if(this.doLook(A.transitions[N].target,void 0,c.instance,Y,X,new k0,!1,!1),Y.length>0&&!Y.contains(_.hitPredicate))U[N]=Y}return U}look(A,R,U){let N=new W0,Y=U?t2(this.atn,U):null;return this.doLook(A,R,Y,N,new $0,new k0,!0,!0),N}doLook(A,R,U,N,Y,X,Q,$){let J=y.createWithContext(A,0,U);if(Y.get(J))return;if(Y.add(J),A===R){if(!U){N.addOne(B.EPSILON);return}else if(U.isEmpty()&&$){N.addOne(B.EOF);return}}if(A.constructor.stateType===j.RULE_STOP){if(!U){N.addOne(B.EPSILON);return}else if(U.isEmpty()&&$){N.addOne(B.EOF);return}if(U!==c.instance){let I=X.get(A.ruleIndex);try{X.clear(A.ruleIndex);for(let w=0;w<U.length;w++){let C=this.atn.states[U.getReturnState(w)];this.doLook(C,R,U.getParent(w),N,Y,X,Q,$)}}finally{if(I)X.set(A.ruleIndex)}return}}for(let I of A.transitions)switch(I.transitionType){case O.RULE:{if(X.get(I.target.ruleIndex))continue;let w=X1(U??void 0,I.followState.stateNumber);try{X.set(I.target.ruleIndex),this.doLook(I.target,R,w,N,Y,X,Q,$)}finally{X.clear(I.target.ruleIndex)}break}case O.PREDICATE:case O.PRECEDENCE:{if(Q)this.doLook(I.target,R,U,N,Y,X,Q,$);else N.addOne(_.hitPredicate);break}case O.WILDCARD:{N.addRange(B.MIN_USER_TOKEN_TYPE,this.atn.maxTokenType);break}default:{if(I.isEpsilon)this.doLook(I.target,R,U,N,Y,X,Q,$);else{let w=I.label;if(w){if(I instanceof i2)w=w.complement(B.MIN_USER_TOKEN_TYPE,this.atn.maxTokenType);N.addSet(w)}}break}}}},P=class{static{q(this,"ATN")}static INVALID_ALT_NUMBER=0;static LEXER=0;static PARSER=1;grammarType;maxTokenType;states=[];decisionToState=[];ruleToStartState=[];ruleToStopState=[];modeNameToStartState=new Map;ruleToTokenType=[];lexerActions=[];modeToStartState=[];analyzer;constructor(_,A){this.grammarType=_,this.maxTokenType=A,this.analyzer=new P5(this)}nextTokens(_,A){if(!A&&_.nextTokenWithinRule)return _.nextTokenWithinRule;let R=this.analyzer.look(_,void 0,A);if(!A)_.nextTokenWithinRule=R;return R}addState(_){if(_)_.stateNumber=this.states.length;this.states.push(_)}removeState(_){this.states[_.stateNumber]=null}defineDecisionState(_){return this.decisionToState.push(_),_.decision=this.decisionToState.length-1,_.decision}getDecisionState(_){if(this.decisionToState.length===0)return null;else return this.decisionToState[_]}getNumberOfDecisions(){return this.decisionToState.length}getExpectedTokens(_,A){if(_<0||_>=this.states.length)throw Error("Invalid state number.");let R=this.states[_],U=this.nextTokens(R);if(!U.contains(B.EPSILON))return U;let N=A,Y=new W0;Y.addSet(U),Y.removeOne(B.EPSILON);while(N!==null&&N.invokingState>=0&&U.contains(B.EPSILON)){let Q=this.states[N.invokingState].transitions[0];U=this.nextTokens(Q.followState),Y.addSet(U),Y.removeOne(B.EPSILON),N=N.parent}if(U.contains(B.EPSILON))Y.addOne(B.EOF);return Y}},Z4=class _{static{q(this,"KeyTypeEqualityComparer")}static instance=new _;hashCode(A){let R=7;return R=31*R+A.state.stateNumber,R=31*R+A.alt,R=31*R+A.semanticContext.hashCode(),R}equals(A,R){if(A===R)return!0;return A.state.stateNumber===R.state.stateNumber&&A.alt===R.alt&&A.semanticContext.equals(R.semanticContext)}},S0=class{static{q(this,"ATNConfigSet")}configLookup=new $0(Z4.instance);configs=[];uniqueAlt=0;hasSemanticContext=!1;dipsIntoOuterContext=!1;fullCtx=!1;readOnly=!1;conflictingAlts=null;firstStopState;#_=-1;constructor(_){if(_!==void 0)if(typeof _==="boolean")this.fullCtx=_??!0;else{let A=_;this.addAll(A.configs),this.uniqueAlt=A.uniqueAlt,this.conflictingAlts=A.conflictingAlts,this.hasSemanticContext=A.hasSemanticContext,this.dipsIntoOuterContext=A.dipsIntoOuterContext}}[Symbol.iterator](){return this.configs[Symbol.iterator]()}add(_,A=null){if(this.readOnly)throw Error("This set is readonly");if(!this.firstStopState&&_.state.constructor.stateType===j.RULE_STOP)this.firstStopState=_;this.hasSemanticContext||=_.semanticContext!==u.NONE,this.dipsIntoOuterContext||=_.reachesIntoOuterContext;let R=this.configLookup.getOrAdd(_);if(R===_){this.#_=-1,this.configs.push(_);return}let U=!this.fullCtx,N=r2(R.context,_.context,U,A);R.reachesIntoOuterContext||=_.reachesIntoOuterContext,R.precedenceFilterSuppressed||=_.precedenceFilterSuppressed,R.context=N}get elements(){return this.configs}getAlts(){let _=new k0;for(let A of this.configs)_.set(A.alt);return _}getPredicates(){let _=[];for(let A of this.configs)if(A.semanticContext!==u.NONE)_.push(A.semanticContext);return _}getStates(){let _=new $0;for(let A of this.configs)_.add(A.state);return _}optimizeConfigs(_){if(this.readOnly)throw Error("This set is readonly");if(this.configLookup.size===0)return;for(let A of this.configs)A.context=_.getCachedContext(A.context)}addAll(_){for(let A of _)this.add(A);return!1}equals(_){if(this===_)return!0;if(this.fullCtx===_.fullCtx&&this.uniqueAlt===_.uniqueAlt&&this.conflictingAlts===_.conflictingAlts&&this.hasSemanticContext===_.hasSemanticContext&&this.dipsIntoOuterContext===_.dipsIntoOuterContext&&$2(this.configs,_.configs))return!0;return!1}hashCode(){if(this.#_===-1)this.#_=this.computeHashCode();return this.#_}get length(){return this.configs.length}isEmpty(){return this.configs.length===0}contains(_){if(this.configLookup===null)throw Error("This method is not implemented for readonly sets.");return this.configLookup.contains(_)}containsFast(_){if(this.configLookup===null)throw Error("This method is not implemented for readonly sets.");return this.configLookup.contains(_)}clear(){if(this.readOnly)throw Error("This set is readonly");this.configs=[],this.#_=-1,this.configLookup=new $0(Z4.instance)}setReadonly(_){if(this.readOnly=_,_)this.configLookup=null}toString(){return D1(this.configs)+(this.hasSemanticContext?",hasSemanticContext="+this.hasSemanticContext:"")+(this.uniqueAlt!==P.INVALID_ALT_NUMBER?",uniqueAlt="+this.uniqueAlt:"")+(this.conflictingAlts!==null?",conflictingAlts="+this.conflictingAlts:"")+(this.dipsIntoOuterContext?",dipsIntoOuterContext":"")}computeHashCode(){let _=k.initialize();return this.configs.forEach((A)=>{_=k.update(_,A.hashCode())}),_=k.finish(_,this.configs.length),_}},$4=class extends j{static{q(this,"BasicState")}static stateType=j.BASIC},G1=class extends j{static{q(this,"DecisionState")}decision=-1;nonGreedy=!1},N1=class extends G1{static{q(this,"BlockStartState")}endState},l2=class extends j{static{q(this,"BlockEndState")}static stateType=j.BLOCK_END;startState},K1=class extends j{static{q(this,"LoopEndState")}static stateType=j.LOOP_END;loopBackState},a2=class extends j{static{q(this,"RuleStartState")}static stateType=j.RULE_START;stopState;isLeftRecursiveRule=!1},q0=class extends j{static{q(this,"RuleStopState")}static stateType=j.RULE_STOP},b5=class extends G1{static{q(this,"TokensStartState")}static stateType=j.TOKEN_START},H4=class extends G1{static{q(this,"PlusLoopbackState")}static stateType=j.PLUS_LOOP_BACK},d2=class extends j{static{q(this,"StarLoopbackState")}static stateType=j.STAR_LOOP_BACK},c0=class extends G1{static{q(this,"StarLoopEntryState")}static stateType=j.STAR_LOOP_ENTRY;loopBackState;precedenceRuleDecision=!1},T2=class extends N1{static{q(this,"PlusBlockStartState")}static stateType=j.PLUS_BLOCK_START;loopBackState},y2=class extends N1{static{q(this,"StarBlockStartState")}static stateType=j.STAR_BLOCK_START},F4=class extends N1{static{q(this,"BasicBlockStartState")}static stateType=j.BLOCK_START},y1=class extends O{static{q(this,"AtomTransition")}labelValue;#_;constructor(_,A){super(_);this.labelValue=A,this.#_=W0.of(A,A)}get label(){return this.#_}get transitionType(){return O.ATOM}matches(_){return this.labelValue===_}toString(){return this.labelValue.toString()}},s2=class extends O{static{q(this,"RuleTransition")}ruleIndex;precedence;followState;constructor(_,A,R,U){super(_);this.ruleIndex=A,this.precedence=R,this.followState=U}get isEpsilon(){return!0}get transitionType(){return O.RULE}matches(_,A,R){return!1}},n2=class extends O{static{q(this,"RangeTransition")}start;stop;#_=new W0;constructor(_,A,R){super(_);this.start=A,this.stop=R,this.#_.addRange(A,R)}get label(){return this.#_}get transitionType(){return O.RANGE}matches(_,A,R){return _>=this.start&&_<=this.stop}toString(){return"'"+String.fromCharCode(this.start)+"'..'"+String.fromCharCode(this.stop)+"'"}},E4=class extends O{static{q(this,"ActionTransition")}ruleIndex;actionIndex;isCtxDependent;constructor(_,A,R,U){super(_);this.ruleIndex=A,this.actionIndex=R??-1,this.isCtxDependent=U??!1}get isEpsilon(){return!0}get transitionType(){return O.ACTION}matches(_,A,R){return!1}toString(){return"action_"+this.ruleIndex+":"+this.actionIndex}},T1=class extends O{static{q(this,"EpsilonTransition")}#_;constructor(_,A=-1){super(_);this.#_=A}get outermostPrecedenceReturn(){return this.#_}get isEpsilon(){return!0}get transitionType(){return O.EPSILON}matches(){return!1}toString(){return"epsilon"}},v5=class extends O{static{q(this,"WildcardTransition")}get transitionType(){return O.WILDCARD}matches(_,A,R){return _>=A&&_<=R}toString(){return"."}},k4=class extends O{static{q(this,"AbstractPredicateTransition")}constructor(_){super(_)}},C4=class extends k4{static{q(this,"PredicateTransition")}ruleIndex;predIndex;isCtxDependent;constructor(_,A,R,U){super(_);this.ruleIndex=A,this.predIndex=R,this.isCtxDependent=U}get isEpsilon(){return!0}matches(_,A,R){return!1}get transitionType(){return O.PREDICATE}getPredicate(){return new u.Predicate(this.ruleIndex,this.predIndex,this.isCtxDependent)}toString(){return"pred_"+this.ruleIndex+":"+this.predIndex}},u5=class extends k4{static{q(this,"PrecedencePredicateTransition")}precedence;constructor(_,A){super(_);this.precedence=A}get isEpsilon(){return!0}matches(_,A,R){return!1}getPredicate(){return new u.PrecedencePredicate(this.precedence)}get transitionType(){return O.PRECEDENCE}toString(){return this.precedence+" >= _p"}},S={CHANNEL:0,CUSTOM:1,MODE:2,MORE:3,POP_MODE:4,PUSH_MODE:5,SKIP:6,TYPE:7},S5=class _{static{q(this,"LexerSkipAction")}static instance=new _;actionType;isPositionDependent=!1;constructor(){this.actionType=S.SKIP}equals(A){return A===this}hashCode(){return S.SKIP}execute(A){A.skip()}toString(){return"skip"}},m5=class _{static{q(this,"LexerChannelAction")}channel;actionType;isPositionDependent=!1;cachedHashCode;constructor(A){this.actionType=S.CHANNEL,this.channel=A}execute(A){A.channel=this.channel}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize();A=k.update(A,this.actionType),A=k.update(A,this.channel),this.cachedHashCode=k.finish(A,2)}return this.cachedHashCode}equals(A){if(this===A)return!0;if(!(A instanceof _))return!1;return this.channel===A.channel}toString(){return"channel("+this.channel+")"}},x5=class _{static{q(this,"LexerCustomAction")}ruleIndex;actionIndex;actionType;isPositionDependent=!0;cachedHashCode;constructor(A,R){this.actionType=S.CUSTOM,this.ruleIndex=A,this.actionIndex=R}execute(A){A.action(null,this.ruleIndex,this.actionIndex)}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize();A=k.update(A,this.actionType),A=k.update(A,this.ruleIndex),A=k.update(A,this.actionIndex),this.cachedHashCode=k.finish(A,3)}return this.cachedHashCode}equals(A){if(this===A)return!0;if(!(A instanceof _))return!1;return this.ruleIndex===A.ruleIndex&&this.actionIndex===A.actionIndex}},g5=class _{static{q(this,"LexerMoreAction")}static instance=new _;actionType;isPositionDependent=!1;constructor(){this.actionType=S.MORE}equals(A){return A===this}hashCode(){return S.MORE}execute(A){A.more()}toString(){return"more"}},l5=class _{static{q(this,"LexerTypeAction")}type;actionType;isPositionDependent=!1;cachedHashCode;constructor(A){this.actionType=S.TYPE,this.type=A}execute(A){A.type=this.type}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize();A=k.update(A,this.actionType),A=k.update(A,this.type),this.cachedHashCode=k.finish(A,2)}return this.cachedHashCode}equals(A){if(this===A)return!0;if(!(A instanceof _))return!1;return this.type===A.type}toString(){return"type("+this.type+")"}},d5=class _{static{q(this,"LexerPushModeAction")}mode;actionType;isPositionDependent=!1;cachedHashCode;constructor(A){this.actionType=S.PUSH_MODE,this.mode=A}execute(A){A.pushMode(this.mode)}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize();A=k.update(A,this.actionType),A=k.update(A,this.mode),this.cachedHashCode=k.finish(A,2)}return this.cachedHashCode}equals(A){if(this===A)return!0;if(!(A instanceof _))return!1;return this.mode===A.mode}toString(){return"pushMode("+this.mode+")"}},T5=class _{static{q(this,"LexerPopModeAction")}static instance=new _;actionType;isPositionDependent=!1;constructor(){this.actionType=S.POP_MODE}equals(A){return A===this}hashCode(){return S.POP_MODE}execute(A){A.popMode()}toString(){return"popMode"}},y5=class _{static{q(this,"LexerModeAction")}mode;actionType;isPositionDependent=!1;cachedHashCode;constructor(A){this.actionType=S.MODE,this.mode=A}execute(A){A.mode=this.mode}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize();A=k.update(A,this.actionType),A=k.update(A,this.mode),this.cachedHashCode=k.finish(A,2)}return this.cachedHashCode}equals(A){if(this===A)return!0;if(!(A instanceof _))return!1;return this.mode===A.mode}toString(){return"mode("+this.mode+")"}},n0=class _{static{q(this,"ATNDeserializer")}static SERIALIZED_VERSION=4;static stateTypeMapper=new Map([[j.INVALID_TYPE,void 0],[j.BASIC,$4],[j.RULE_START,a2],[j.BLOCK_START,F4],[j.PLUS_BLOCK_START,T2],[j.STAR_BLOCK_START,y2],[j.TOKEN_START,b5],[j.RULE_STOP,q0],[j.BLOCK_END,l2],[j.STAR_LOOP_BACK,d2],[j.STAR_LOOP_ENTRY,c0],[j.PLUS_LOOP_BACK,H4],[j.LOOP_END,K1]]);static lexerActionFactoryMapper=new Map([[S.CHANNEL,(A)=>{return new m5(A)}],[S.CUSTOM,(A,R)=>{return new x5(A,R)}],[S.MODE,(A)=>{return new y5(A)}],[S.MORE,()=>{return g5.instance}],[S.POP_MODE,()=>{return T5.instance}],[S.PUSH_MODE,(A)=>{return new d5(A)}],[S.SKIP,()=>{return S5.instance}],[S.TYPE,(A)=>{return new l5(A)}]]);data=[];pos=0;deserializationOptions;actionFactories;constructor(A){if(!A)A={readOnly:!1,verifyATN:!0,generateRuleBypassTransitions:!1};this.deserializationOptions=A}deserialize(A){this.data=A,this.checkVersion();let R=this.readATN();this.readStates(R),this.readRules(R),this.readModes(R);let U=[];if(this.readSets(R,U),this.readEdges(R,U),this.readDecisions(R),this.readLexerActions(R),this.markPrecedenceDecisions(R),this.verifyATN(R),this.deserializationOptions.generateRuleBypassTransitions&&R.grammarType===P.PARSER)this.generateRuleBypassTransitions(R),this.verifyATN(R);return R}checkVersion(){let A=this.data[this.pos++];if(A!==_.SERIALIZED_VERSION)throw Error("Could not deserialize ATN with version "+A+" (expected "+_.SERIALIZED_VERSION+").")}readATN(){let A=this.data[this.pos++],R=this.data[this.pos++];return new P(A,R)}readStates(A){let R,U,N=[],Y=[],X=this.data[this.pos++];for(let J=0;J<X;J++){let I=this.data[this.pos++];if(I===j.INVALID_TYPE){A.addState(null);continue}let w=this.data[this.pos++],C=this.stateFactory(I,w);if(I===j.LOOP_END){let V=this.data[this.pos++];N.push([C,V])}else if(C instanceof N1){let V=this.data[this.pos++];Y.push([C,V])}A.addState(C)}for(R=0;R<N.length;R++){let J=N[R];J[0].loopBackState=A.states[J[1]]??void 0}for(R=0;R<Y.length;R++){let J=Y[R];J[0].endState=A.states[J[1]]}let Q=this.data[this.pos++];for(R=0;R<Q;R++)U=this.data[this.pos++],A.states[U].nonGreedy=!0;let $=this.data[this.pos++];for(R=0;R<$;R++)U=this.data[this.pos++],A.states[U].isLeftRecursiveRule=!0}readRules(A){let R,U=this.data[this.pos++];if(A.grammarType===P.LEXER)A.ruleToTokenType=Array(U),A.ruleToTokenType.fill(0);A.ruleToStartState=Array(U),A.ruleToStartState.fill(null);for(R=0;R<U;R++){let N=this.data[this.pos++];if(A.ruleToStartState[R]=A.states[N],A.grammarType===P.LEXER){let Y=this.data[this.pos++];A.ruleToTokenType[R]=Y}}A.ruleToStopState=Array(U),A.ruleToStopState.fill(null);for(R=0;R<A.states.length;R++){let N=A.states[R];if(!(N instanceof q0))continue;A.ruleToStopState[N.ruleIndex]=N,A.ruleToStartState[N.ruleIndex].stopState=N}}readModes(A){let R=this.data[this.pos++];for(let U=0;U<R;U++){let N=this.data[this.pos++];A.modeToStartState.push(A.states[N])}}readSets(A,R){let U=this.data[this.pos++];for(let N=0;N<U;N++){let Y=new W0;R.push(Y);let X=this.data[this.pos++];if(this.data[this.pos++]!==0)Y.addOne(-1);for(let $=0;$<X;$++){let J=this.data[this.pos++],I=this.data[this.pos++];Y.addRange(J,I)}}}readEdges(A,R){let U,N,Y,X,Q,$=this.data[this.pos++];for(U=0;U<$;U++){let J=this.data[this.pos++],I=this.data[this.pos++],w=this.data[this.pos++],C=this.data[this.pos++],V=this.data[this.pos++],m=this.data[this.pos++];X=this.edgeFactory(A,w,I,C,V,m,R),A.states[J].addTransition(X)}for(U=0;U<A.states.length;U++){Y=A.states[U];for(N=0;N<Y.transitions.length;N++){let J=Y.transitions[N];if(!(J instanceof s2))continue;let I=-1;if(A.ruleToStartState[J.target.ruleIndex].isLeftRecursiveRule){if(J.precedence===0)I=J.target.ruleIndex}X=new T1(J.followState,I),A.ruleToStopState[J.target.ruleIndex].addTransition(X)}}for(U=0;U<A.states.length;U++){if(Y=A.states[U],Y instanceof N1){if(!Y.endState)throw Error("IllegalState");if(Y.endState.startState)throw Error("IllegalState");Y.endState.startState=Y}if(Y instanceof H4){for(N=0;N<Y.transitions.length;N++)if(Q=Y.transitions[N].target,Q instanceof T2)Q.loopBackState=Y}else if(Y instanceof d2){for(N=0;N<Y.transitions.length;N++)if(Q=Y.transitions[N].target,Q instanceof c0)Q.loopBackState=Y}}}readDecisions(A){let R=this.data[this.pos++];for(let U=0;U<R;U++){let N=this.data[this.pos++],Y=A.states[N];A.decisionToState.push(Y),Y.decision=U}}readLexerActions(A){if(A.grammarType===P.LEXER){let R=this.data[this.pos++];A.lexerActions=[];for(let U=0;U<R;U++){let N=this.data[this.pos++],Y=this.data[this.pos++],X=this.data[this.pos++];A.lexerActions.push(this.lexerActionFactory(N,Y,X))}}}generateRuleBypassTransitions(A){let R,U=A.ruleToStartState.length;for(R=0;R<U;R++)A.ruleToTokenType[R]=A.maxTokenType+R+1;for(R=0;R<U;R++)this.generateRuleBypassTransition(A,R)}generateRuleBypassTransition(A,R){let U,N,Y=new F4;Y.ruleIndex=R,A.addState(Y);let X=new l2;X.ruleIndex=R,A.addState(X),Y.endState=X,A.defineDecisionState(Y),X.startState=Y;let Q=null,$=null;if(A.ruleToStartState[R].isLeftRecursiveRule){$=null;for(U=0;U<A.states.length;U++)if(N=A.states[U],this.stateIsEndStateFor(N,R)){$=N,Q=N.loopBackState.transitions[0];break}if(Q===null)throw Error("Couldn't identify final state of the precedence rule prefix section.")}else $=A.ruleToStopState[R];for(U=0;U<A.states.length;U++){N=A.states[U];for(let w of N.transitions){if(w===Q)continue;if(w.target===$)w.target=X}}let J=A.ruleToStartState[R];while(J.transitions.length>0){let w=J.removeTransition(J.transitions.length-1);Y.addTransition(w)}if(A.ruleToStartState[R].addTransition(new T1(Y)),$)X.addTransition(new T1($));let I=new $4;A.addState(I),I.addTransition(new y1(X,A.ruleToTokenType[R])),Y.addTransition(new T1(I))}stateIsEndStateFor(A,R){if(A.ruleIndex!==R)return null;if(!(A instanceof c0))return null;let U=A.transitions[A.transitions.length-1].target;if(!(U instanceof K1))return null;if(U.epsilonOnlyTransitions&&U.transitions[0].target instanceof q0)return A;else return null}markPrecedenceDecisions(A){for(let R of A.states){if(!(R instanceof c0))continue;if(A.ruleToStartState[R.ruleIndex].isLeftRecursiveRule){let U=R.transitions[R.transitions.length-1].target;if(U instanceof K1){if(U.epsilonOnlyTransitions&&U.transitions[0].target instanceof q0)R.precedenceRuleDecision=!0}}}}verifyATN(A){if(!this.deserializationOptions.verifyATN)return;for(let R of A.states){if(R===null)continue;if(this.checkCondition(R.epsilonOnlyTransitions||R.transitions.length<=1),R instanceof T2)this.checkCondition(R.loopBackState!==null);else if(R instanceof c0)if(this.checkCondition(R.loopBackState!==null),this.checkCondition(R.transitions.length===2),R.transitions[0].target instanceof y2)this.checkCondition(R.transitions[1].target instanceof K1),this.checkCondition(!R.nonGreedy);else if(R.transitions[0].target instanceof K1)this.checkCondition(R.transitions[1].target instanceof y2),this.checkCondition(R.nonGreedy);else throw Error("IllegalState");else if(R instanceof d2)this.checkCondition(R.transitions.length===1),this.checkCondition(R.transitions[0].target instanceof c0);else if(R instanceof K1)this.checkCondition(R.loopBackState!==null);else if(R instanceof a2)this.checkCondition(R.stopState!==null);else if(R instanceof N1)this.checkCondition(R.endState!==null);else if(R instanceof l2)this.checkCondition(R.startState!==null);else if(R instanceof G1)this.checkCondition(R.transitions.length<=1||R.decision>=0);else this.checkCondition(R.transitions.length<=1||R instanceof q0)}}checkCondition(A,R){if(!A){if(R===void 0||R===null)R="IllegalState";throw R}}edgeFactory(A,R,U,N,Y,X,Q){let $=A.states[U];switch(R){case O.EPSILON:return new T1($);case O.RANGE:return X!==0?new n2($,B.EOF,Y):new n2($,N,Y);case O.RULE:return new s2(A.states[N],Y,X,$);case O.PREDICATE:return new C4($,N,Y,X!==0);case O.PRECEDENCE:return new u5($,N);case O.ATOM:return X!==0?new y1($,B.EOF):new y1($,N);case O.ACTION:return new E4($,N,Y,X!==0);case O.SET:return new p2($,Q[N]);case O.NOT_SET:return new i2($,Q[N]);case O.WILDCARD:return new v5($);default:throw Error("The specified transition type: "+R+" is not valid.")}}stateFactory(A,R){let U=_.stateTypeMapper.get(A);if(!U)throw Error("The specified state type "+A+" is not valid.");let N=new U;return N.ruleIndex=R,N}lexerActionFactory(A,R,U){let N=_.lexerActionFactoryMapper.get(A);if(!N)throw Error("The specified lexer action type "+A+" is not valid.");return N(R,U)}},c5=class _ extends m0{static{q(this,"OrderedHashMap")}#_=[];clear(){super.clear(),this.#_=[]}get(A){return super.get(A)}set(A,R){let U=super.set(A,R);if(U===void 0)this.#_.push(A);return U}setIfAbsent(A,R){let U=super.setIfAbsent(A,R);if(U===void 0)this.#_.push(A);return U}values(){return{[Symbol.iterator]:()=>{let A=0;return{next:q(()=>{if(A<this.#_.length)return{done:!1,value:super.get(this.#_[A++])};return{done:!0,value:void 0}},"next")}}}}keys(){return this.#_[Symbol.iterator]()}equals(A){if(!(A instanceof _))return!1;return super.equals(A)}},O8=class _{static{q(this,"ATNSerializer")}atn;data=[];sets=new c5(Y1.instance);nonGreedyStates=[];precedenceStates=[];constructor(A){this.atn=A}static getSerialized(A){return new _(A).serialize()}static serializeSets(A,R){A.push(R.length);for(let U of R){let N=U.contains(B.EOF),Y=[...U];if(N&&Y[0].stop===B.EOF)A.push(Y.length-1);else A.push(Y.length);A.push(N?1:0);for(let X of Y){if(X.start===B.EOF)if(X.stop===B.EOF)continue;else A.push(0);else A.push(X.start);A.push(X.stop)}}}serialize(){this.addPreamble();let A=this.addEdges();this.addNonGreedyStates(),this.addPrecedenceStates(),this.addRuleStatesAndLexerTokenTypes(),this.addModeStartStates();let R=this.addSets();return this.addEdges(A,R),this.addDecisionStartStates(),this.addLexerActions(),this.data}addPreamble(){this.data.push(n0.SERIALIZED_VERSION),this.data.push(this.atn.grammarType),this.data.push(this.atn.maxTokenType)}addLexerActions(){if(this.atn.grammarType===P.LEXER){this.data.push(this.atn.lexerActions.length);for(let A of this.atn.lexerActions)switch(this.data.push(A.actionType),A.actionType){case S.CHANNEL:{let R=A.channel;this.data.push(R),this.data.push(0);break}case S.CUSTOM:{let{ruleIndex:R,actionIndex:U}=A;this.data.push(R),this.data.push(U);break}case S.MODE:{let R=A.mode;this.data.push(R),this.data.push(0);break}case S.MORE:{this.data.push(0),this.data.push(0);break}case S.POP_MODE:{this.data.push(0),this.data.push(0);break}case S.PUSH_MODE:{let R=A.mode;this.data.push(R),this.data.push(0);break}case S.SKIP:{this.data.push(0),this.data.push(0);break}case S.TYPE:{let R=A.type;this.data.push(R),this.data.push(0);break}default:throw Error(`The specified lexer action type ${A.actionType} is not valid.`)}}}addDecisionStartStates(){this.data.push(this.atn.decisionToState.length);for(let A of this.atn.decisionToState)this.data.push(A.stateNumber)}addEdges(...A){switch(A.length){case 0:{let R=0;this.data.push(this.atn.states.length);for(let U of this.atn.states){if(U===null){this.data.push(j.INVALID_TYPE);continue}let N=U.constructor.stateType;if(U instanceof G1&&U.nonGreedy)this.nonGreedyStates.push(U.stateNumber);if(U instanceof a2&&U.isLeftRecursiveRule)this.precedenceStates.push(U.stateNumber);if(this.data.push(N),this.data.push(U.ruleIndex),U.constructor.stateType===j.LOOP_END)this.data.push(U.loopBackState.stateNumber);else if(U instanceof N1)this.data.push(U.endState.stateNumber);if(U.constructor.stateType!==j.RULE_STOP)R+=U.transitions.length;for(let Y of U.transitions){let X=Y.transitionType;if(X===O.SET||X===O.NOT_SET){let Q=Y;this.sets.set(Q.set,!0)}}}return R}case 2:{let[R,U]=A;this.data.push(R);for(let N of this.atn.states){if(N===null)continue;if(N.constructor.stateType===j.RULE_STOP)continue;for(let Y of N.transitions){if(this.atn.states[Y.target.stateNumber]===null)throw Error("Cannot serialize a transition to a removed state.");let X=N.stateNumber,Q=Y.target.stateNumber,$=Y.transitionType,J=0,I=0,w=0;switch($){case O.RULE:{Q=Y.followState.stateNumber,J=Y.target.stateNumber,I=Y.ruleIndex,w=Y.precedence;break}case O.PRECEDENCE:{J=Y.precedence;break}case O.PREDICATE:{let C=Y;J=C.ruleIndex,I=C.predIndex,w=C.isCtxDependent?1:0;break}case O.RANGE:{if(J=Y.start,I=Y.stop,J===B.EOF)J=0,w=1;break}case O.ATOM:{if(J=Y.labelValue,J===B.EOF)J=0,w=1;break}case O.ACTION:{let C=Y;J=C.ruleIndex,I=C.actionIndex,w=C.isCtxDependent?1:0;break}case O.SET:{J=U.get(Y.set);break}case O.NOT_SET:{J=U.get(Y.set);break}case O.WILDCARD:break;default:}this.data.push(X),this.data.push(Q),this.data.push($),this.data.push(J),this.data.push(I),this.data.push(w)}}break}default:throw Error("Invalid number of arguments")}}addSets(){_.serializeSets(this.data,[...this.sets.keys()]);let A=new m0,R=0;for(let U of this.sets.keys())A.set(U,R++);return A}addModeStartStates(){let A=this.atn.modeToStartState.length;if(this.data.push(A),A>0)for(let R of this.atn.modeToStartState)this.data.push(R.stateNumber)}addRuleStatesAndLexerTokenTypes(){let A=this.atn.ruleToStartState.length;this.data.push(A);for(let R=0;R<A;R++){let U=this.atn.ruleToStartState[R];if(this.data.push(U.stateNumber),this.atn.grammarType===P.LEXER)this.data.push(this.atn.ruleToTokenType[R])}}addPrecedenceStates(){this.data.push(this.precedenceStates.length);for(let A of this.precedenceStates)this.data.push(A)}addNonGreedyStates(){this.data.push(this.nonGreedyStates.length);for(let A of this.nonGreedyStates)this.data.push(A)}},E1=class _{static{q(this,"DFAState")}stateNumber=-1;configs;edges=[];isAcceptState=!1;prediction=-1;lexerActionExecutor=null;requiresFullContext=!1;predicates=null;constructor(A){if(A)this.configs=A}static fromState(A){let R=new _;return R.stateNumber=A,R}static fromConfigs(A){return new _(A)}static hashCode(A){return A.configs.hashCode()}static equals(A,R){return A.configs.equals(R.configs)}getAltSet(){let A=new Set;for(let R of this.configs)A.add(R.alt);if(A.size===0)return null;return A}toString(){let A="";if(A+=this.stateNumber,A+=":",A+=this.configs?this.configs.toString():"",this.isAcceptState)if(A+="=>",this.predicates)A+=D1(this.predicates);else A+=this.prediction;return A.toString()}},E0=class{static{q(this,"ATNSimulator")}static ERROR=E1.fromState(2147483647);atn;sharedContextCache;constructor(_,A){return this.atn=_,this.sharedContextCache=A,this}getCachedContext(_){if(!this.sharedContextCache)return _;let A=new m0(Y1.instance);return w4(_,this.sharedContextCache,A)}},M8=class _{static{q(this,"CodePointTransitions")}static createWithCodePoint(A,R){return _.createWithCodePointRange(A,R,R)}static createWithCodePointRange(A,R,U){return R===U?new y1(A,R):new n2(A,R,U)}},a5=class{static{q(this,"DecisionInfo")}decision=0;invocations=0;timeInPrediction=0;sllTotalLook=0;sllMinLook=0;sllMaxLook=0;sllMaxLookEvent;llTotalLook=0;llMinLook=0;llMaxLook=0;llMaxLookEvent;contextSensitivities;errors;ambiguities;predicateEvals;sllATNTransitions=0;sllDFATransitions=0;llFallback=0;llATNTransitions=0;llDFATransitions=0;constructor(_){this.decision=_,this.contextSensitivities=[],this.errors=[],this.ambiguities=[],this.predicateEvals=[]}toString(){return"{decision="+this.decision+", contextSensitivities="+this.contextSensitivities.length+", errors="+this.errors.length+", ambiguities="+this.ambiguities.length+", sllLookahead="+this.sllTotalLook+", sllATNTransitions="+this.sllATNTransitions+", sllDFATransitions="+this.sllDFATransitions+", llFallback="+this.llFallback+", llLookahead="+this.llTotalLook+", llATNTransitions="+this.llATNTransitions+"}"}},w0=class _ extends y{static{q(this,"LexerATNConfig")}lexerActionExecutor;passedThroughNonGreedyDecision;constructor(A,R,U,N){super(A,R,U??A.context,U?u.NONE:A.semanticContext);return this.lexerActionExecutor=U?N:A.lexerActionExecutor??null,this.passedThroughNonGreedyDecision=_.checkNonGreedyDecision(A,this.state),this}static createWithExecutor(A,R,U){return new _(A,R,A.context,U)}static createWithConfig(A,R,U){return new _(R,A,U??null,R.lexerActionExecutor)}static createWithContext(A,R,U){return new _({alt:R},A,U,null)}static checkNonGreedyDecision(A,R){return A.passedThroughNonGreedyDecision||"nonGreedy"in R&&R.nonGreedy}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize(7);A=k.update(A,this.state.stateNumber),A=k.update(A,this.alt),A=k.updateFromComparable(A,this.context),A=k.updateFromComparable(A,this.semanticContext),A=k.update(A,this.passedThroughNonGreedyDecision?1:0),A=k.updateFromComparable(A,this.lexerActionExecutor),A=k.finish(A,6),this.cachedHashCode=A}return this.cachedHashCode}equals(A){if(this===A)return!0;return this.passedThroughNonGreedyDecision===A.passedThroughNonGreedyDecision&&(this.lexerActionExecutor&&A.lexerActionExecutor?this.lexerActionExecutor.equals(A.lexerActionExecutor):!A.lexerActionExecutor)&&super.equals(A)}},H2=class{static{q(this,"BaseErrorListener")}syntaxError(_,A,R,U,N,Y){}reportAmbiguity(_,A,R,U,N,Y,X){}reportAttemptingFullContext(_,A,R,U,N,Y){}reportContextSensitivity(_,A,R,U,N,Y){}},s5=class _ extends H2{static{q(this,"ConsoleErrorListener")}static instance=new _;syntaxError(A,R,U,N,Y,X){console.error("line "+U+":"+N+" "+Y)}},n5=class extends H2{constructor(_){super();return this.delegates=_,this}static{q(this,"ProxyErrorListener")}syntaxError(_,A,R,U,N,Y){this.delegates.forEach((X)=>{X.syntaxError(_,A,R,U,N,Y)})}reportAmbiguity(_,A,R,U,N,Y,X){this.delegates.forEach((Q)=>{Q.reportAmbiguity(_,A,R,U,N,Y,X)})}reportAttemptingFullContext(_,A,R,U,N,Y){this.delegates.forEach((X)=>{X.reportAttemptingFullContext(_,A,R,U,N,Y)})}reportContextSensitivity(_,A,R,U,N,Y){this.delegates.forEach((X)=>{X.reportContextSensitivity(_,A,R,U,N,Y)})}},O4=class _{static{q(this,"Recognizer")}static EOF=-1;static tokenTypeMapCache=new Map;static ruleIndexMapCache=new Map;interpreter;listeners=[s5.instance];stateNumber=-1;checkVersion(A){if(A!=="4.13.1")console.error("ANTLR runtime and generated code versions disagree: 4.13.1!="+A)}addErrorListener(A){this.listeners.push(A)}removeErrorListeners(){this.listeners=[]}removeErrorListener(A){for(let R=0;R<this.listeners.length;R++)if(this.listeners[R]===A){this.listeners.splice(R,1);return}}getErrorListeners(){return this.listeners}getTokenTypeMap(){let A=this.vocabulary,R=_.tokenTypeMapCache.get(A);if(!R){R=new Map;for(let U=0;U<=this.atn.maxTokenType;U++){let N=A.getLiteralName(U);if(N)R.set(N,U);let Y=A.getSymbolicName(U);if(Y)R.set(Y,U)}R.set("EOF",B.EOF),_.tokenTypeMapCache.set(A,R)}return R}getRuleIndexMap(){let A=this.ruleNames,R=_.ruleIndexMapCache.get(A);if(!R)R=new Map,A.forEach((U,N)=>{return R.set(U,N)}),_.ruleIndexMapCache.set(A,R);return R}getTokenType(A){let R=this.getTokenTypeMap().get(A);if(R)return R;return B.INVALID_TYPE}getErrorHeader(A){let R=A.offendingToken?.line,U=A.offendingToken?.column;return"line "+R+":"+U}get errorListenerDispatch(){return new n5(this.listeners)}sempred(A,R,U){return!0}precpred(A,R){return!0}action(A,R,U){}get atn(){return this.interpreter.atn}get state(){return this.stateNumber}set state(A){this.stateNumber=A}getParseInfo(){return}},M4=class _{static{q(this,"CommonTokenFactory")}static DEFAULT=new _;copyText=!1;constructor(A){this.copyText=A??!1}create(A,R,U,N,Y,X,Q,$){let J=Q2.fromSource(A,R,N,Y,X);if(J.line=Q,J.column=$,U)J.text=U;else if(this.copyText&&A[1]!==null)J.text=A[1].getTextFromRange(Y,X);return J}},f=class _ extends Error{static{q(this,"RecognitionException")}ctx;offendingToken=null;offendingState=-1;recognizer;input;constructor(A){super(A.message);if(Error.captureStackTrace)Error.captureStackTrace(this,_);if(this.message=A.message,this.recognizer=A.recognizer,this.input=A.input,this.ctx=A.ctx,this.recognizer!==null)this.offendingState=this.recognizer.state}getExpectedTokens(){if(this.recognizer!==null&&this.ctx!==null)return this.recognizer.atn.getExpectedTokens(this.offendingState,this.ctx);else return null}toString(){return this.message}},Z2=class extends f{static{q(this,"LexerNoViableAltException")}startIndex;deadEndConfigs;constructor(_,A,R,U){super({message:"",recognizer:_,input:A,ctx:null});this.startIndex=R,this.deadEndConfigs=U}toString(){let _="";if(this.input&&this.startIndex>=0&&this.startIndex<this.input.size)_=this.input.getTextFromRange(this.startIndex,this.startIndex);return`LexerNoViableAltException(${_})`}},C0=class _ extends O4{static{q(this,"Lexer")}static DEFAULT_MODE=0;static MORE=-2;static SKIP=-3;static DEFAULT_TOKEN_CHANNEL=B.DEFAULT_CHANNEL;static HIDDEN=B.HIDDEN_CHANNEL;options={minDFAEdge:0,maxDFAEdge:256,minCodePoint:0,maxCodePoint:1114111};tokenStartCharIndex=-1;channel=0;type=0;mode=_.DEFAULT_MODE;currentTokenColumn=0;currentTokenStartLine=0;input;token=null;hitEOF=!1;factory;#_=[];#A;constructor(A,R){super();this.options={...this.options,...R},this.input=A,this.factory=M4.DEFAULT}reset(A=!0){if(A)this.input.seek(0);this.token=null,this.type=B.INVALID_TYPE,this.channel=B.DEFAULT_CHANNEL,this.tokenStartCharIndex=-1,this.currentTokenColumn=-1,this.currentTokenStartLine=-1,this.#A=void 0,this.hitEOF=!1,this.mode=_.DEFAULT_MODE,this.#_=[],this.interpreter.reset()}nextToken(){if(this.input===null)throw Error("nextToken requires a non-null input stream.");let A=this.input.mark();try{while(!0){if(this.hitEOF)return this.emitEOF(),this.token;this.token=null,this.channel=B.DEFAULT_CHANNEL,this.tokenStartCharIndex=this.input.index,this.currentTokenColumn=this.interpreter.column,this.currentTokenStartLine=this.interpreter.line,this.#A=void 0;let R=!1;while(!0){this.type=B.INVALID_TYPE;let U=_.SKIP;try{U=this.interpreter.match(this.input,this.mode)}catch(N){if(N instanceof Z2)this.notifyListeners(N),this.recover(N);else throw N}if(this.input.LA(1)===B.EOF)this.hitEOF=!0;if(this.type===B.INVALID_TYPE)this.type=U;if(this.type===_.SKIP){R=!0;break}if(this.type!==_.MORE)break}if(R)continue;if(this.token===null)this.emit();return this.token}}finally{this.input.release(A)}}skip(){this.type=_.SKIP}more(){this.type=_.MORE}pushMode(A){if(k1.debug)console.log("pushMode "+A);this.#_.push(this.mode),this.mode=A}popMode(){if(this.#_.length===0)throw Error("Empty Stack");if(k1.debug)console.log("popMode back to "+this.#_.slice(0,-1));return this.mode=this.#_.pop(),this.mode}get modeStack(){return this.#_}emitToken(A){this.token=A}emit(){let A=this.factory.create([this,this.input],this.type,this.#A,this.channel,this.tokenStartCharIndex,this.getCharIndex()-1,this.currentTokenStartLine,this.currentTokenColumn);return this.emitToken(A),A}emitEOF(){let A=this.factory.create([this,this.input],B.EOF,void 0,B.DEFAULT_CHANNEL,this.input.index,this.input.index-1,this.line,this.column);return this.emitToken(A),A}getCharIndex(){return this.input.index}getAllTokens(){let A=[],R=this.nextToken();while(R.type!==B.EOF)A.push(R),R=this.nextToken();return A}notifyListeners(A){let R=this.tokenStartCharIndex,U=this.input.index,N=this.input.getTextFromRange(R,U),Y="token recognition error at: '"+this.getErrorDisplay(N)+"'";this.errorListenerDispatch.syntaxError(this,null,this.currentTokenStartLine,this.currentTokenColumn,Y,A)}getErrorDisplay(A){return A}getErrorDisplayForChar(A){if(A.charCodeAt(0)===B.EOF)return"<EOF>";if(A===`
4
+ `)return"\\n";if(A==="\t")return"\\t";if(A==="\r")return"\\r";return A}getCharErrorDisplay(A){return"'"+this.getErrorDisplayForChar(A)+"'"}recover(A){if(this.input.LA(1)!==B.EOF)if(A instanceof Z2)this.interpreter.consume(this.input);else this.input.consume()}get inputStream(){return this.input}set inputStream(A){this.reset(!1),this.input=A}set tokenFactory(A){this.factory=A}get tokenFactory(){return this.factory}get sourceName(){return this.input.getSourceName()}get line(){return this.interpreter.line}set line(A){this.interpreter.line=A}get column(){return this.interpreter.column}set column(A){this.interpreter.column=A}get text(){if(this.#A)return this.#A;else return this.interpreter.getText(this.input)}set text(A){this.#A=A}},h4=class{static{q(this,"DFASerializer")}dfa;vocabulary;constructor(_,A){this.dfa=_,this.vocabulary=A}toString(){if(!this.dfa.s0)return"";let _="",A=this.dfa.getStates();for(let R of A){let U=0;U=R.edges.length;for(let N=0;N<U;N++){let Y=R.edges[N];if(Y&&Y.stateNumber!==2147483647){_+=this.getStateString(R);let X=this.getEdgeLabel(N);_+="-",_+=X,_+="->",_+=this.getStateString(Y),_+=`
5
+ `}}}return _}getEdgeLabel(_){return`${this.vocabulary.getDisplayName(_-1)}`}getStateString(_){let A=_.stateNumber,R=(_.isAcceptState?":":"")+"s"+A+(_.requiresFullContext?"^":"");if(_.isAcceptState){if(_.predicates!==null)return`${R}=>${_.predicates.toString()}`;return`${R}=>${_.prediction}`}else return`${R}`}},o5=class extends h4{static{q(this,"LexerDFASerializer")}constructor(_){super(_,K0.EMPTY_VOCABULARY)}getEdgeLabel=q((_)=>{return"'"+String.fromCharCode(_)+"'"},"getEdgeLabel")},x0=class{static{q(this,"DFA")}s0;decision;atnStartState;isPrecedenceDfa;states=new Map;constructor(_,A){this.atnStartState=_,this.decision=A??0;let R=!1;if(_ instanceof c0){if(_.precedenceRuleDecision)R=!0,this.s0=E1.fromState(-1)}this.isPrecedenceDfa=R}[Symbol.iterator]=()=>{return this.states.values()[Symbol.iterator]()};getPrecedenceStartState=q((_)=>{if(!this.isPrecedenceDfa)throw Error("Only precedence DFAs may contain a precedence start state.");if(!this.s0||!this.s0.edges||_<0||_>=this.s0.edges.length)return;return this.s0.edges[_]},"getPrecedenceStartState");setPrecedenceStartState=q((_,A)=>{if(!this.isPrecedenceDfa)throw Error("Only precedence DFAs may contain a precedence start state.");if(_<0||!this.s0)return;this.s0.edges[_]=A},"setPrecedenceStartState");getStates(){let _=[...this.states.values()];return _.sort((A,R)=>{return A.stateNumber-R.stateNumber}),_}getState(_){return this.states.get(_.configs.hashCode())??null}getStateForConfigs(_){return this.states.get(_.hashCode())??null}addState(_){let A=_.configs.hashCode();if(this.states.has(A))return;this.states.set(A,_),_.stateNumber=this.states.size-1}toString(_){if(!_)return this.toString(K0.EMPTY_VOCABULARY);if(!this.s0)return"";return new h4(this,_).toString()??""}toLexerString(){if(!this.s0)return"";return new o5(this).toString()??""}get length(){return this.states.size}},c2=class _{static{q(this,"LexerIndexedCustomAction")}offset;action;actionType;isPositionDependent=!0;cachedHashCode;constructor(A,R){this.actionType=R.actionType,this.offset=A,this.action=R}execute(A){this.action.execute(A)}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize();A=k.update(A,this.offset),A=k.updateFromComparable(A,this.action),this.cachedHashCode=k.finish(A,2)}return this.cachedHashCode}equals(A){if(this===A)return!0;if(!(A instanceof _))return!1;return this.offset===A.offset&&this.action===A.action}},p5=class _{static{q(this,"LexerActionExecutor")}lexerActions;actionType;isPositionDependent=!1;cachedHashCode;constructor(A){return this.actionType=-1,this.lexerActions=A??[],this}static append(A,R){if(A===null)return new _([R]);let U=A.lexerActions.concat([R]);return new _(U)}fixOffsetBeforeMatch(A){let R=null;for(let U=0;U<this.lexerActions.length;U++)if(this.lexerActions[U].isPositionDependent&&!(this.lexerActions[U]instanceof c2)){if(R===null)R=this.lexerActions.concat([]);R[U]=new c2(A,this.lexerActions[U])}if(R===null)return this;else return new _(R)}execute(A,R,U){if(R===void 0||U===void 0)return;let N=!1,Y=R.index;try{for(let X of this.lexerActions){let Q=X;if(X instanceof c2){let $=X.offset;R.seek(U+$),Q=X.action,N=U+$!==Y}else if(X.isPositionDependent)R.seek(Y),N=!1;Q.execute(A)}}finally{if(N)R.seek(Y)}}hashCode(){if(this.cachedHashCode===void 0){let A=k.initialize(7);for(let R of this.lexerActions)A=k.update(A,R.hashCode());this.cachedHashCode=k.finish(A,this.lexerActions.length)}return this.cachedHashCode}equals(A){if(this===A)return!0;if(this.cachedHashCode!==A.cachedHashCode)return!1;if(this.lexerActions.length!==A.lexerActions.length)return!1;return this.lexerActions.every((R,U)=>{return R.equals(A.lexerActions[U])})}},i5=class _ extends $0{static{q(this,"OrderedHashSet")}elements=[];getOrAdd(A){let R=this.size,U=super.getOrAdd(A);if(this.size>R)this.elements.push(A);return U}equals(A){if(!(A instanceof _))return!1;return super.equals(A)}clear(){super.clear(),this.elements=[]}*[Symbol.iterator](){yield*this.elements}toArray(){return this.elements.slice(0)}},J4=class extends S0{static{q(this,"OrderedATNConfigSet")}constructor(){super();this.configLookup=new i5}},k1=class _ extends E0{static{q(this,"LexerATNSimulator")}static debug=!1;decisionToDFA;recognizer=null;startIndex=-1;line=1;column=0;mode=C0.DEFAULT_MODE;prevAccept;options;lexerATNConfigFactory;constructor(A,R,U,N){super(R,N);if(this.decisionToDFA=U,this.recognizer=A,A)this.options=A.options;else this.options={minDFAEdge:0,maxDFAEdge:256,minCodePoint:0,maxCodePoint:1114111}}match(A,R){this.mode=R;let U=A.mark();try{this.startIndex=A.index,this.prevAccept=void 0;let N=this.decisionToDFA[R];if(!N.s0)return this.matchATN(A);return this.execATN(A,N.s0)}finally{A.release(U)}}reset(){this.prevAccept=void 0,this.startIndex=-1,this.line=1,this.column=0,this.mode=C0.DEFAULT_MODE}clearDFA(){for(let A=0;A<this.decisionToDFA.length;A++)this.decisionToDFA[A]=new x0(this.atn.getDecisionState(A),A)}getDFA(A){return this.decisionToDFA[A]}getText(A){return A.getTextFromRange(this.startIndex,A.index-1)}consume(A){if(A.LA(1)===10)this.line+=1,this.column=0;else this.column+=1;A.consume()}getTokenName(A){if(A===B.EOF)return"EOF";else return"'"+String.fromCharCode(A)+"'"}matchATN(A){let R=this.atn.modeToStartState[this.mode];if(_.debug)console.log("matchATN mode "+this.mode+" start: "+R);let U=this.mode,N=this.computeStartState(A,R),Y=N.hasSemanticContext;N.hasSemanticContext=!1;let X=this.addDFAState(N);if(!Y)this.decisionToDFA[this.mode].s0=X;let Q=this.execATN(A,X);if(_.debug)console.log("DFA after matchATN: "+this.decisionToDFA[U].toLexerString());return Q}execATN(A,R){if(_.debug)console.log("start state closure="+R.configs);if(R.isAcceptState)this.captureSimState(A,R);let U=A.LA(1);while(!0){if(_.debug)console.log("execATN loop starting closure: "+R.configs);let N=this.getExistingTargetState(R,U);if(!N)N=this.computeTargetState(A,R,U);if(N===E0.ERROR)break;if(U!==B.EOF)this.consume(A);if(N.isAcceptState){if(this.captureSimState(A,N),U===B.EOF)break}U=A.LA(1),R=N}return this.failOrAccept(A,R.configs,U)}getExistingTargetState(A,R){if(R>=this.options.minDFAEdge&&R<=this.options.maxDFAEdge){let U=A.edges[R-this.options.minDFAEdge];if(_.debug&&U)console.log("reuse state "+A.stateNumber+" edge to "+U.stateNumber);return U}return}computeTargetState(A,R,U){let N=new J4;if(this.getReachableConfigSet(A,R.configs,N,U),N.length===0){if(!N.hasSemanticContext)this.addDFAEdge(R,U,E0.ERROR);return E0.ERROR}return this.addDFAEdge(R,U,null,N)}failOrAccept(A,R,U){if(this.prevAccept?.dfaState){let{dfaState:N,index:Y,line:X,column:Q}=this.prevAccept;return this.accept(A,N.lexerActionExecutor,this.startIndex,Y,X,Q),N.prediction}if(U===B.EOF&&A.index===this.startIndex)return B.EOF;throw new Z2(this.recognizer,A,this.startIndex,R)}getReachableConfigSet(A,R,U,N){let Y=P.INVALID_ALT_NUMBER;for(let X of R){let Q=X.alt===Y;if(Q&&X.passedThroughNonGreedyDecision)continue;if(_.debug)console.log(`testing %s at %s
6
+ `,this.getTokenName(N),X.toString(this.recognizer,!0));for(let $ of X.state.transitions){let J=this.getReachableTarget($,N);if(J){let I=X.lexerActionExecutor;if(I)I=I.fixOffsetBeforeMatch(A.index-this.startIndex);let w=N===B.EOF,C=w0.createWithExecutor(X,J,I);if(this.closure(A,C,U,Q,!0,w))Y=X.alt}}}}accept(A,R,U,N,Y,X){if(_.debug)console.log(`ACTION %s
7
+ `,R);if(A.seek(N),this.line=Y,this.column=X,R&&this.recognizer)R.execute(this.recognizer,A,U)}getReachableTarget(A,R){if(A.matches(R,this.options.minCodePoint,this.options.maxCodePoint))return A.target;else return}computeStartState(A,R){let U=c.instance,N=new J4;for(let Y=0;Y<R.transitions.length;Y++){let X=R.transitions[Y].target,Q=w0.createWithContext(X,Y+1,U);this.closure(A,Q,N,!1,!1,!1)}return N}closure(A,R,U,N,Y,X){let Q=null;if(_.debug)console.log("closure("+R.toString(this.recognizer,!0)+")");if(R.state.constructor.stateType===j.RULE_STOP){if(_.debug)if(this.recognizer!==null)console.log(`closure at %s rule stop %s
8
8
  `,this.recognizer.ruleNames[R.state.ruleIndex],R);else console.log(`closure at rule stop %s
9
- `,R);if(!R.context||R.context.hasEmptyPath())if(!R.context||R.context.isEmpty())return U.add(R),!0;else U.add(k0.createWithConfig(R.state,R,c.instance)),Y=!0;if(R.context&&!R.context.isEmpty()){for(let J=0;J<R.context.length;J++)if(R.context.getReturnState(J)!==n.EMPTY_RETURN_STATE){let F=R.context.getParent(J),I=this.atn.states[R.context.getReturnState(J)];Q=k0.createWithConfig(I,R,F),Y=this.closure(A,Q,U,Y,X,G)}}return Y}if(!R.state.epsilonOnlyTransitions){if(!Y||!R.passedThroughNonGreedyDecision)U.add(R)}for(let J of R.state.transitions)if(Q=this.getEpsilonTarget(A,R,J,U,X,G),Q)Y=this.closure(A,Q,U,Y,X,G);return Y}getEpsilonTarget(A,R,U,Y,X,G){if(!this.lexerATNConfigFactory)this.setupATNFactoryLookup();let Q=this.lexerATNConfigFactory[U.transitionType];if(!Q)return null;return Q(A,R,U,Y,X,G)}setupATNFactoryLookup(){this.lexerATNConfigFactory=[],this.lexerATNConfigFactory[j.RULE]=(R,U,Y)=>{let X=U1(U.context??void 0,Y.followState.stateNumber);return k0.createWithConfig(Y.target,U,X)},this.lexerATNConfigFactory[j.PRECEDENCE]=()=>{throw Error("Precedence predicates are not supported in lexers.")},this.lexerATNConfigFactory[j.PREDICATE]=(R,U,Y,X,G)=>{let Q=Y;if(_.debug)console.log("EVAL rule "+Q.ruleIndex+":"+Q.predIndex);if(X.hasSemanticContext=!0,this.evaluatePredicate(R,Q.ruleIndex,Q.predIndex,G))return k0.createWithConfig(Y.target,U);return null},this.lexerATNConfigFactory[j.ACTION]=(R,U,Y)=>{if(U.context===null||U.context.hasEmptyPath()){let X=N6.append(U.lexerActionExecutor,this.atn.lexerActions[Y.actionIndex]);return k0.createWithExecutor(U,Y.target,X)}else return k0.createWithConfig(Y.target,U)},this.lexerATNConfigFactory[j.EPSILON]=(R,U,Y)=>{return k0.createWithConfig(Y.target,U)};let A=W((R,U,Y,X,G,Q)=>{if(Q){if(Y.matches(D.EOF,this.options.minCodePoint,this.options.maxCodePoint))return k0.createWithConfig(Y.target,U)}return null},"simple");this.lexerATNConfigFactory[j.ATOM]=A,this.lexerATNConfigFactory[j.RANGE]=A,this.lexerATNConfigFactory[j.SET]=A}evaluatePredicate(A,R,U,Y){if(!this.recognizer)return!0;if(!Y)return this.recognizer.sempred(null,R,U);let X=this.column,G=this.line,Q=A.index,J=A.mark();try{return this.consume(A),this.recognizer.sempred(null,R,U)}finally{this.column=X,this.line=G,A.seek(Q),A.release(J)}}captureSimState(A,R){this.prevAccept={index:A.index,line:this.line,column:this.column,dfaState:R}}addDFAEdge(A,R,U,Y){if(!U&&Y){let X=Y.hasSemanticContext;if(Y.hasSemanticContext=!1,U=this.addDFAState(Y),X)return U}if(R<this.options.minDFAEdge||R>this.options.maxDFAEdge)return U;if(_.debug)console.log("EDGE "+A+" -> "+U+" upon "+R);return A.edges[R-this.options.minDFAEdge]=U,U}addDFAState(A){let R=this.decisionToDFA[this.mode],U=R.getStateForConfigs(A);if(U)return U;let Y=w1.fromConfigs(A),X=A.firstStopState;if(X)Y.isAcceptState=!0,Y.lexerActionExecutor=X.lexerActionExecutor,Y.prediction=this.atn.ruleToTokenType[X.state.ruleIndex];return A.setReadonly(!0),R.addState(Y),Y}},Z6=class{static{W(this,"ParseInfo")}atnSimulator;constructor(_){this.atnSimulator=_}getDecisionInfo(){return this.atnSimulator.getDecisionInfo()}getLLDecisions(){let _=this.atnSimulator.getDecisionInfo(),A=[];for(let R=0;R<_.length;R++)if(_[R].llFallback>0)A.push(R);return A}getTotalTimeInPrediction(){let _=this.atnSimulator.getDecisionInfo(),A=0;for(let R of _)A+=R.timeInPrediction;return A}getTotalSLLLookaheadOps(){let _=this.atnSimulator.getDecisionInfo(),A=0;for(let R of _)A+=R.sllTotalLook;return A}getTotalLLLookaheadOps(){let _=this.atnSimulator.getDecisionInfo(),A=0;for(let R of _)A+=R.llTotalLook;return A}getTotalSLLATNLookaheadOps(){let _=this.atnSimulator.getDecisionInfo(),A=0;for(let R of _)A+=R.sllATNTransitions;return A}getTotalLLATNLookaheadOps(){let _=this.atnSimulator.getDecisionInfo(),A=0;for(let R of _)A+=R.llATNTransitions;return A}getTotalATNLookaheadOps(){let _=this.atnSimulator.getDecisionInfo(),A=0;for(let R of _)A+=R.sllATNTransitions,A+=R.llATNTransitions;return A}getDFASize(_){if(_===void 0){let A=0,R=this.atnSimulator.decisionToDFA;for(let U=0;U<R.length;U++)A+=this.getDFASize(U);return A}else return this.atnSimulator.decisionToDFA[_].length}},X1=class extends h{static{W(this,"NoViableAltException")}deadEndConfigs=null;startToken;constructor(_,A=null,R=null,U=null,Y=null,X=null){X=X??_.context,U=U??_.getCurrentToken(),R=R??_.getCurrentToken(),A=A??_.inputStream;super({message:"",recognizer:_,input:A,ctx:X});this.deadEndConfigs=Y,this.startToken=R,this.offendingToken=U}},w4=class{static{W(this,"DoubleDict")}cacheMap;constructor(){this.cacheMap=new u0}get(_,A){let R=this.cacheMap.get(_)??null;return R===null?null:R.get(A)??null}set(_,A,R){let U=this.cacheMap.get(_);if(!U)U=new u0,this.cacheMap.set(_,U);U.set(A,R)}},J6=class _{static{W(this,"SubsetEqualityComparer")}static instance=new _;hashCode(A){let R=k.initialize(7);return R=k.update(R,A.state.stateNumber),R=k.updateFromComparable(R,A.context),R=k.finish(R,2),R}equals(A,R){return A.state.stateNumber===R.state.stateNumber&&(A.context?.equals(R.context)??!0)}},t=class _{static{W(this,"PredictionMode")}static SLL=0;static LL=1;static LL_EXACT_AMBIG_DETECTION=2;static hasSLLConflictTerminatingPrediction(A,R){if(_.allConfigsInRuleStopStates(R))return!0;if(A===_.SLL){if(R.hasSemanticContext){let Y=new b0;for(let X of R)X=y.duplicate(X,u.NONE),Y.add(X);R=Y}}let U=_.getConflictingAltSubsets(R);return _.hasConflictingAltSet(U)&&!_.hasStateAssociatedWithOneAlt(R)}static hasConfigInRuleStopState(A){for(let R of A)if(R.state instanceof z0)return!0;return!1}static allConfigsInRuleStopStates(A){for(let R of A)if(!(R.state instanceof z0))return!1;return!0}static resolvesToJustOneViableAlt(A){return _.getSingleViableAlt(A)}static allSubsetsConflict(A){return!_.hasNonConflictingAltSet(A)}static hasNonConflictingAltSet(A){for(let R of A)if(R.length===1)return!0;return!1}static hasConflictingAltSet(A){for(let R of A)if(R.length>1)return!0;return!1}static allSubsetsEqual(A){let R=null;for(let U of A)if(R===null)R=U;else if(U!==R)return!1;return!0}static getUniqueAlt(A){let R=_.getAlts(A);if(R.length===1)return R.nextSetBit(0);else return P.INVALID_ALT_NUMBER}static getAlts(A){let R=new j0;return A.forEach((U)=>{R.or(U)}),R}static getConflictingAltSubsets(A){let R=new u0(J6.instance);for(let U of A){let Y=R.get(U);if(!Y)Y=new j0,R.set(U,Y);Y.set(U.alt)}return Array.from(R.values())}static getStateToAltMap(A){let R=new u0(R1.instance);for(let U of A){let Y=R.get(U.state);if(!Y)Y=new j0,R.set(U.state,Y);Y.set(U.alt)}return R}static hasStateAssociatedWithOneAlt(A){let R={};for(let U of A){let Y=U.state.stateNumber;if(!R[Y])R[Y]=0;R[Y]++}return Object.values(R).some((U)=>{return U===1})}static getSingleViableAlt(A){let R=null;for(let U of A){let Y=U.nextSetBit(0);if(R===null)R=Y;else if(R!==Y)return P.INVALID_ALT_NUMBER}return R??0}},o1=class _ extends C0{static{W(this,"ParserATNSimulator")}static traceATNSimulator=!1;static debug;static debugAdd=!1;static debugClosure=!1;static dfaDebug=!1;static retryDebug=!1;predictionMode;decisionToDFA;parser;mergeCache=new w4;predictionState;constructor(A,R,U,Y){super(R,Y);this.parser=A,this.decisionToDFA=U}static getUniqueAlt(A){let R=P.INVALID_ALT_NUMBER;for(let U of A)if(R===P.INVALID_ALT_NUMBER)R=U.alt;else if(U.alt!==R)return P.INVALID_ALT_NUMBER;return R}reset(){}clearDFA(){for(let A=0;A<this.decisionToDFA.length;A++)this.decisionToDFA[A]=new S0(this.atn.getDecisionState(A),A)}adaptivePredict(A,R,U){if(_.debug||_.traceATNSimulator)console.log("adaptivePredict decision "+R+" exec LA(1)=="+this.getLookaheadName(A)+" line "+A.LT(1).line+":"+A.LT(1).column);let Y=this.decisionToDFA[R];this.predictionState={input:A,startIndex:A.index,outerContext:U??void 0,dfa:Y};let X=A.mark(),G=A.index;try{let Q;if(Y.isPrecedenceDfa)Q=Y.getPrecedenceStartState(this.parser.getPrecedence());else Q=Y.s0;if(!Q){if(!U)U=M.empty;if(_.debug)console.log("predictATN decision "+Y.decision+" exec LA(1)=="+this.getLookaheadName(A)+", outerContext="+U.toString(this.parser.ruleNames));let F=!1,I=this.computeStartState(Y.atnStartState,M.empty,F);if(Y.isPrecedenceDfa)I=this.applyPrecedenceFilter(I),Q=this.addDFAState(Y,w1.fromConfigs(I)),Y.setPrecedenceStartState(this.parser.getPrecedence(),Q);else Q=this.addDFAState(Y,w1.fromConfigs(I)),Y.s0=Q}let J=this.execATN(Y,Q,A,G,U);if(_.debug)console.log("DFA after predictATN: "+Y.toString(this.parser.vocabulary));return J}finally{this.predictionState.dfa=void 0,this.mergeCache=new w4,A.seek(G),A.release(X)}}execATN(A,R,U,Y,X){if(_.debug||_.traceATNSimulator)console.log("execATN decision "+A.decision+", DFA state "+R+", LA(1)=="+this.getLookaheadName(U)+" line "+U.LT(1).line+":"+U.LT(1).column);let G,Q=R,J=U.LA(1);while(!0){let F=this.getExistingTargetState(Q,J);if(!F)F=this.computeTargetState(A,Q,J);if(F===C0.ERROR){let I=this.noViableAlt(U,X,Q.configs,Y);if(U.seek(Y),G=this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(Q.configs,X),G!==P.INVALID_ALT_NUMBER)return G;else throw I}if(F.requiresFullContext&&this.predictionMode!==t.SLL){let I=null;if(F.predicates!==null){if(_.debug)console.log("DFA state has preds in DFA sim LL failover");let V=U.index;if(V!==Y)U.seek(Y);if(I=this.evalSemanticContext(F.predicates,X,!0),I.length===1){if(_.debug)console.log("Full LL avoided");return I.nextSetBit(0)}if(V!==Y)U.seek(V)}if(_.dfaDebug)console.log("ctx sensitive state "+X+" in "+F);let B=!0,C=this.computeStartState(A.atnStartState,X,B);return this.reportAttemptingFullContext(A,I,F.configs,Y,U.index),G=this.execATNWithFullContext(A,F,C,U,Y,X),G}if(F.isAcceptState){if(F.predicates===null)return F.prediction;let I=U.index;U.seek(Y);let B=this.evalSemanticContext(F.predicates,X,!0);if(B.length===0)throw this.noViableAlt(U,X,F.configs,Y);if(B.length===1)return B.nextSetBit(0);return this.reportAmbiguity(A,F,Y,I,!1,B,F.configs),B.nextSetBit(0)}if(Q=F,J!==D.EOF)U.consume(),J=U.LA(1)}}getExistingTargetState(A,R){return A.edges[R+1]}computeTargetState(A,R,U){let Y=this.computeReachSet(R.configs,U,!1);if(Y===null)return this.addDFAEdge(A,R,U,C0.ERROR),C0.ERROR;let X=w1.fromConfigs(Y),G=_.getUniqueAlt(Y);if(_.debug){let Q=t.getConflictingAltSubsets(Y);console.log("SLL altSubSets="+D1(Q)+", configs="+Y+", predict="+G+", allSubsetsConflict="+t.allSubsetsConflict(Q)+", conflictingAlts="+this.getConflictingAlts(Y))}if(G!==P.INVALID_ALT_NUMBER)X.isAcceptState=!0,X.configs.uniqueAlt=G,X.prediction=G;else if(t.hasSLLConflictTerminatingPrediction(this.predictionMode,Y))X.configs.conflictingAlts=this.getConflictingAlts(Y),X.requiresFullContext=!0,X.isAcceptState=!0,X.prediction=X.configs.conflictingAlts.nextSetBit(0);if(X.isAcceptState&&X.configs.hasSemanticContext){if(this.predicateDFAState(X,this.atn.getDecisionState(A.decision)),X.predicates!==null)X.prediction=P.INVALID_ALT_NUMBER}return X=this.addDFAEdge(A,R,U,X),X}getRuleName(A){if(this.parser!==null&&A>=0)return this.parser.ruleNames[A];else return"<rule "+A+">"}getTokenName(A){if(A===D.EOF)return"EOF";let U=(this.parser?.vocabulary??D0.EMPTY_VOCABULARY).getDisplayName(A);if(U===A.toString())return U;return U+"<"+A+">"}getLookaheadName(A){return this.getTokenName(A.LA(1))}dumpDeadEndConfigs(A){console.log("dead end configs: ");let R=A.deadEndConfigs;for(let U of R){let Y="no edges";if(U.state.transitions.length>0){let X=U.state.transitions[0];if(X instanceof a1)Y="Atom "+this.getTokenName(X.labelValue);else if(X instanceof e2)Y=(X instanceof _3?"~":"")+"Set "+X.label}console.error(U.toString(this.parser,!0)+":"+Y)}}predicateDFAState(A,R){let U=R.transitions.length,Y=this.getConflictingAltsOrUniqueAlt(A.configs),X=this.getPredsForAmbigAlts(Y,A.configs,U);if(X!==null)A.predicates=this.getPredicatePredictions(Y,X),A.prediction=P.INVALID_ALT_NUMBER;else A.prediction=Y.nextSetBit(0)}execATNWithFullContext(A,R,U,Y,X,G){if(_.debug||_.traceATNSimulator)console.log("execATNWithFullContext "+U);let Q=!0,J=!1,F,I=U;Y.seek(X);let B=Y.LA(1),C=-1;for(;;){if(F=this.computeReachSet(I,B,Q),F===null){let x=this.noViableAlt(Y,G,I,X);Y.seek(X);let e=this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(I,G);if(e!==P.INVALID_ALT_NUMBER)return e;else throw x}let V=t.getConflictingAltSubsets(F);if(_.debug)console.log("LL altSubSets="+V+", predict="+t.getUniqueAlt(V)+", resolvesToJustOneViableAlt="+t.resolvesToJustOneViableAlt(V));if(F.uniqueAlt=_.getUniqueAlt(F),F.uniqueAlt!==P.INVALID_ALT_NUMBER){C=F.uniqueAlt;break}else if(this.predictionMode!==t.LL_EXACT_AMBIG_DETECTION){if(C=t.resolvesToJustOneViableAlt(V),C!==P.INVALID_ALT_NUMBER)break}else if(t.allSubsetsConflict(V)&&t.allSubsetsEqual(V)){J=!0,C=t.getSingleViableAlt(V);break}if(I=F,B!==D.EOF)Y.consume(),B=Y.LA(1)}if(F.uniqueAlt!==P.INVALID_ALT_NUMBER)return this.reportContextSensitivity(A,C,F,X,Y.index),C;return this.reportAmbiguity(A,R,X,Y.index,J,F.getAlts(),F),C}computeReachSet(A,R,U){if(_.debug)console.log("in computeReachSet, starting closure: "+A);let Y=new b0(U),X=null;for(let Q of A){if(_.debug)console.log("testing "+this.getTokenName(R)+" at "+Q);if(Q.state instanceof z0){if(U||R===D.EOF){if(X===null)X=[];X.push(Q)}continue}for(let J of Q.state.transitions){let F=this.getReachableTarget(J,R);if(F!==null){let I=y.createWithConfig(F,Q);if(Y.add(I,this.mergeCache),_.debugAdd)console.log("added "+I+" to intermediate")}}}let G=null;if(X===null&&R!==D.EOF){if(Y.length===1)G=Y;else if(_.getUniqueAlt(Y)!==P.INVALID_ALT_NUMBER)G=Y}if(G===null){G=new b0(U);let Q=new $0,J=R===D.EOF;for(let F of Y)this.closure(F,G,Q,!1,U,J)}if(R===D.EOF)G=this.removeAllConfigsNotInRuleStopState(G,G===Y);if(X!==null&&(!U||!t.hasConfigInRuleStopState(G)))for(let Q of X)G.add(Q,this.mergeCache);if(_.traceATNSimulator)console.log("computeReachSet "+A+" -> "+G);if(G.length===0)return null;else return G}removeAllConfigsNotInRuleStopState(A,R){if(t.allConfigsInRuleStopStates(A))return A;let U=new b0(A.fullCtx);for(let Y of A){if(Y.state instanceof z0){U.add(Y,this.mergeCache);continue}if(R&&Y.state.epsilonOnlyTransitions){if(this.atn.nextTokens(Y.state).contains(D.EPSILON)){let G=this.atn.ruleToStopState[Y.state.ruleIndex];U.add(y.createWithConfig(G,Y),this.mergeCache)}}}return U}computeStartState(A,R,U){let Y=A3(this.atn,R),X=new b0(U);if(_.traceATNSimulator)console.log("computeStartState from ATN state "+A+" initialContext="+Y.toString(this.parser));for(let G=0;G<A.transitions.length;G++){let Q=A.transitions[G].target,J=y.createWithContext(Q,G+1,Y),F=new $0;this.closure(J,X,F,!0,U,!1)}return X}applyPrecedenceFilter(A){let R=[],U=new b0(A.fullCtx);for(let Y of A){if(Y.alt!==1)continue;let X=Y.semanticContext.evalPrecedence(this.parser,this.predictionState.outerContext);if(X===null)continue;if(R[Y.state.stateNumber]=Y.context,X!==Y.semanticContext)U.add(y.duplicate(Y,X),this.mergeCache);else U.add(Y,this.mergeCache)}for(let Y of A){if(Y.alt===1)continue;if(!Y.precedenceFilterSuppressed){let X=R[Y.state.stateNumber]||null;if(X!==null&&X.equals(Y.context))continue}U.add(Y,this.mergeCache)}return U}getReachableTarget(A,R){if(A.matches(R,0,this.atn.maxTokenType))return A.target;else return null}getPredsForAmbigAlts(A,R,U){let Y=[];for(let G of R)if(A.get(G.alt))Y[G.alt]=u.orContext(Y[G.alt]??null,G.semanticContext);let X=0;for(let G=1;G<U+1;G++){let Q=Y[G]??null;if(Q===null)Y[G]=u.NONE;else if(Q!==u.NONE)X+=1}if(X===0)Y=null;if(_.debug)console.log("getPredsForAmbigAlts result "+D1(Y));return Y}getPredicatePredictions(A,R){let U=[],Y=!1;for(let X=1;X<R.length;X++){let G=R[X];if(A.get(X))U.push({pred:G,alt:X});if(G!==u.NONE)Y=!0}if(!Y)return null;return U}getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(A,R){let U=this.splitAccordingToSemanticValidity(A,R),Y=U[0],X=U[1],G=this.getAltThatFinishedDecisionEntryRule(Y);if(G!==P.INVALID_ALT_NUMBER)return G;if(X.length>0){if(G=this.getAltThatFinishedDecisionEntryRule(X),G!==P.INVALID_ALT_NUMBER)return G}return P.INVALID_ALT_NUMBER}getAltThatFinishedDecisionEntryRule(A){let R=[];for(let U of A)if(U.reachesIntoOuterContext||U.state instanceof z0&&U.context.hasEmptyPath()){if(R.indexOf(U.alt)<0)R.push(U.alt)}if(R.length===0)return P.INVALID_ALT_NUMBER;else return Math.min(...R)}splitAccordingToSemanticValidity(A,R){let U=new b0(A.fullCtx),Y=new b0(A.fullCtx);for(let X of A)if(X.semanticContext!==u.NONE)if(X.semanticContext.evaluate(this.parser,R))U.add(X);else Y.add(X);else U.add(X);return[U,Y]}evalSemanticContext(A,R,U){let Y=new j0;for(let X of A){if(X.pred===u.NONE){if(Y.set(X.alt),!U)break;continue}let G=X.pred.evaluate(this.parser,R);if(_.debug||_.dfaDebug)console.log("eval pred "+X+"="+G);if(G){if(Y.set(X.alt),!U)break}}return Y}closure(A,R,U,Y,X,G){this.closureCheckingStopState(A,R,U,Y,X,0,G)}closureCheckingStopState(A,R,U,Y,X,G,Q){if(_.traceATNSimulator||_.debugClosure)console.log("closure("+A.toString(this.parser,!0)+")");if(A.state instanceof z0){if(A.context&&!A.context.isEmpty()){for(let J=0;J<A.context.length;J++){if(A.context.getReturnState(J)===n.EMPTY_RETURN_STATE){if(X){R.add(y.createWithConfig(A.state,A,c.instance),this.mergeCache);continue}else{if(_.debug)console.log("FALLING off rule "+this.getRuleName(A.state.ruleIndex));this.closure_(A,R,U,Y,X,G,Q)}continue}let F=this.atn.states[A.context.getReturnState(J)],I=A.context.getParent(J),B=y.createWithContext(F,A.alt,I,A.semanticContext);B.reachesIntoOuterContext=A.reachesIntoOuterContext,this.closureCheckingStopState(B,R,U,Y,X,G-1,Q)}return}else if(X){R.add(A,this.mergeCache);return}else if(_.debug)console.log("FALLING off rule "+this.getRuleName(A.state.ruleIndex))}this.closure_(A,R,U,Y,X,G,Q)}closure_(A,R,U,Y,X,G,Q){let J=A.state;if(!J.epsilonOnlyTransitions)R.add(A,this.mergeCache);for(let F=0;F<J.transitions.length;F++){if(F===0&&this.canDropLoopEntryEdgeInLeftRecursiveRule(A))continue;let I=J.transitions[F],B=Y&&!(I instanceof V4),C=this.getEpsilonTarget(A,I,B,G===0,X,Q);if(C){let V=G;if(A.state.constructor.stateType===f.RULE_STOP){if(this.predictionState.dfa&&this.predictionState?.dfa.isPrecedenceDfa){if(I.outermostPrecedenceReturn===this.predictionState?.dfa.atnStartState?.ruleIndex)C.precedenceFilterSuppressed=!0}if(C.reachesIntoOuterContext=!0,U.getOrAdd(C)!==C)continue;if(R.dipsIntoOuterContext=!0,V-=1,_.debug)console.log("dips into outer ctx: "+C)}else{if(!I.isEpsilon&&U.getOrAdd(C)!==C)continue;if(I instanceof i2){if(V>=0)V+=1}}this.closureCheckingStopState(C,R,U,B,X,V,Q)}}}canDropLoopEntryEdgeInLeftRecursiveRule(A){let R=A.state;if(R.constructor.stateType!==f.STAR_LOOP_ENTRY||!A.context)return!1;if(!R.precedenceRuleDecision||A.context.isEmpty()||A.context.hasEmptyPath())return!1;let U=A.context.length;for(let Q=0;Q<U;Q++)if(this.atn.states[A.context.getReturnState(Q)].ruleIndex!==R.ruleIndex)return!1;let X=R.transitions[0].target.endState.stateNumber,G=this.atn.states[X];for(let Q=0;Q<U;Q++){let J=A.context.getReturnState(Q),F=this.atn.states[J];if(F.transitions.length!==1||!F.transitions[0].isEpsilon)return!1;let I=F.transitions[0].target;if(F.constructor.stateType===f.BLOCK_END&&I===R)continue;if(F===G)continue;if(I===G)continue;if(I.constructor.stateType===f.BLOCK_END&&I.transitions.length===1&&I.transitions[0].isEpsilon&&I.transitions[0].target===R)continue;return!1}return!0}getEpsilonTarget(A,R,U,Y,X,G){switch(R.transitionType){case j.RULE:return this.ruleTransition(A,R);case j.PRECEDENCE:return this.precedenceTransition(A,R,U,Y,X);case j.PREDICATE:return this.predTransition(A,R,U,Y,X);case j.ACTION:{if(_.debug){let Q=R,J=Q.actionIndex===-1?65535:Q.actionIndex;console.log("ACTION edge "+Q.ruleIndex+":"+J)}return y.createWithConfig(R.target,A)}case j.EPSILON:return y.createWithConfig(R.target,A);case j.ATOM:case j.RANGE:case j.SET:{if(G){if(R.matches(D.EOF,0,1))return y.createWithConfig(R.target,A)}return null}default:return null}}precedenceTransition(A,R,U,Y,X){if(_.debug){if(console.log("PRED (collectPredicates="+U+") "+R.precedence+">=_p, ctx dependent=true"),this.parser!==null)console.log("context surrounding pred is "+D1(this.parser.getRuleInvocationStack()))}let G=null;if(U&&Y)if(X&&this.predictionState?.input){let Q=this.predictionState.input.index;this.predictionState.input.seek(this.predictionState.startIndex);let J=R.getPredicate().evaluate(this.parser,this.predictionState.outerContext);if(this.predictionState.input.seek(Q),J)G=y.createWithConfig(R.target,A)}else{let Q=u.andContext(A.semanticContext,R.getPredicate());G=y.createWithSemanticContext(R.target,A,Q)}else G=y.createWithConfig(R.target,A);if(_.debug)console.log("config from pred transition="+G);return G}predTransition(A,R,U,Y,X){if(_.debug){if(console.log("PRED (collectPredicates="+U+") "+R.ruleIndex+":"+R.predIndex+", ctx dependent="+R.isCtxDependent),this.parser!==null)console.log("context surrounding pred is "+D1(this.parser.getRuleInvocationStack()))}let G=null;if(U&&(R.isCtxDependent&&Y||!R.isCtxDependent))if(X&&this.predictionState?.input){let Q=this.predictionState.input.index;this.predictionState.input.seek(this.predictionState.startIndex);let J=R.getPredicate().evaluate(this.parser,this.predictionState.outerContext);if(this.predictionState.input.seek(Q),J)G=y.createWithConfig(R.target,A)}else{let Q=u.andContext(A.semanticContext,R.getPredicate());G=y.createWithSemanticContext(R.target,A,Q)}else G=y.createWithConfig(R.target,A);if(_.debug)console.log("config from pred transition="+G);return G}ruleTransition(A,R){if(_.debug)console.log("CALL rule "+this.getRuleName(R.target.ruleIndex)+", ctx="+A.context);let U=R.followState,Y=U1(A.context??void 0,U.stateNumber);return y.createWithConfig(R.target,A,Y)}getConflictingAlts(A){let R=t.getConflictingAltSubsets(A);return t.getAlts(R)}getConflictingAltsOrUniqueAlt(A){let R;if(A.uniqueAlt!==P.INVALID_ALT_NUMBER)R=new j0,R.set(A.uniqueAlt);else R=A.conflictingAlts;return R}noViableAlt(A,R,U,Y){return new X1(this.parser,A,A.get(Y),A.LT(1),U,R)}addDFAEdge(A,R,U,Y){if(_.debug)console.log("EDGE "+R+" -> "+Y+" upon "+this.getTokenName(U));if(Y=this.addDFAState(A,Y),U<-1||U>this.atn.maxTokenType)return Y;if(_.debug)console.log(`DFA=
10
- `+A.toString(this.parser!=null?this.parser.vocabulary:D0.EMPTY_VOCABULARY));return R.edges[U+1]=Y,Y}addDFAState(A,R){if(R===C0.ERROR)return R;let U=A.getState(R);if(U!==null)return U;if(!R.configs.readOnly)R.configs.optimizeConfigs(this),R.configs.setReadonly(!0);if(_.traceATNSimulator)console.log("addDFAState new "+R);return A.addState(R),R}reportAttemptingFullContext(A,R,U,Y,X){if(_.debug||_.retryDebug){let G=new b(Y,X+1);console.log("reportAttemptingFullContext decision="+A.decision+":"+U+", input="+this.parser.tokenStream.getTextFromInterval(G))}this.parser.errorListenerDispatch.reportAttemptingFullContext(this.parser,A,Y,X,R,U)}reportContextSensitivity(A,R,U,Y,X){if(_.debug||_.retryDebug){let G=new b(Y,X+1);console.log("reportContextSensitivity decision="+A.decision+":"+U+", input="+this.parser.tokenStream.getTextFromInterval(G))}this.parser.errorListenerDispatch.reportContextSensitivity(this.parser,A,Y,X,R,U)}reportAmbiguity(A,R,U,Y,X,G,Q){if(_.debug||_.retryDebug){let J=new b(U,Y+1);console.log("reportAmbiguity "+G+":"+Q+", input="+this.parser.tokenStream.getTextFromInterval(J))}this.parser.errorListenerDispatch.reportAmbiguity(this.parser,A,U,Y,X,G,Q)}},G1=class{static{W(this,"PredictionContextCache")}cache=new u0(R1.instance);add(_){if(_===c.instance)return _;let A=this.cache.get(_);if(A)return A;return this.cache.set(_,_),_}get(_){return this.cache.get(_)}get length(){return this.cache.size}},Z2=class extends o1{static{W(this,"ProfilingATNSimulator")}decisions;numDecisions=0;currentDecision=0;currentState;conflictingAltResolvedBySLL;sllStopIndex=0;llStopIndex=0;constructor(_){let A=_.interpreter.sharedContextCache;super(_,_.interpreter.atn,_.interpreter.decisionToDFA,A);if(A){this.numDecisions=this.atn.decisionToState.length,this.decisions=Array(this.numDecisions);for(let R=0;R<this.numDecisions;R++)this.decisions[R]=new U6(R)}}adaptivePredict(_,A,R){try{this.sllStopIndex=-1,this.llStopIndex=-1,this.currentDecision=A;let U=performance.now(),Y=super.adaptivePredict(_,A,R),X=performance.now();this.decisions[A].timeInPrediction+=X-U,this.decisions[A].invocations++;let G=this.sllStopIndex-this.predictionState.startIndex+1;if(this.decisions[A].sllTotalLook+=G,this.decisions[A].sllMinLook=this.decisions[A].sllMinLook===0?G:Math.min(this.decisions[A].sllMinLook,G),G>this.decisions[A].sllMaxLook)this.decisions[A].sllMaxLook=G,this.decisions[A].sllMaxLookEvent={decision:A,configs:null,predictedAlt:Y,input:_,startIndex:this.predictionState.startIndex,stopIndex:this.sllStopIndex,fullCtx:!1};if(this.llStopIndex>=0){let Q=this.llStopIndex-this.predictionState.startIndex+1;if(this.decisions[A].llTotalLook+=Q,this.decisions[A].llMinLook=this.decisions[A].llMinLook===0?Q:Math.min(this.decisions[A].llMinLook,Q),Q>this.decisions[A].llMaxLook)this.decisions[A].llMaxLook=Q,this.decisions[A].llMaxLookEvent={decision:A,configs:null,predictedAlt:Y,input:_,startIndex:this.predictionState.startIndex,stopIndex:this.llStopIndex,fullCtx:!0}}return Y}finally{this.currentDecision=-1}}getExistingTargetState(_,A){this.sllStopIndex=this.predictionState.input.index;let R=super.getExistingTargetState(_,A);if(R!==void 0){if(this.decisions[this.currentDecision].sllDFATransitions++,R===C0.ERROR)this.decisions[this.currentDecision].errors.push({decision:this.currentDecision,configs:_.configs,input:this.predictionState.input,startIndex:this.predictionState.startIndex,stopIndex:this.sllStopIndex,fullCtx:!1})}return this.currentState=R,R}computeTargetState(_,A,R){let U=super.computeTargetState(_,A,R);return this.currentState=U,U}computeReachSet(_,A,R){if(R&&this.predictionState?.input)this.llStopIndex=this.predictionState.input.index;let U=super.computeReachSet(_,A,R);if(this.predictionState?.input){if(R){if(this.decisions[this.currentDecision].llATNTransitions++,U===null)this.decisions[this.currentDecision].errors.push({decision:this.currentDecision,configs:_,input:this.predictionState.input,startIndex:this.predictionState.startIndex,stopIndex:this.sllStopIndex,fullCtx:!0})}else if(this.decisions[this.currentDecision].sllATNTransitions++,U===null)this.decisions[this.currentDecision].errors.push({decision:this.currentDecision,configs:_,input:this.predictionState.input,startIndex:this.predictionState.startIndex,stopIndex:this.sllStopIndex,fullCtx:!1})}return U}reportAttemptingFullContext(_,A,R,U,Y){if(A!==null)this.conflictingAltResolvedBySLL=A.nextSetBit(0);else this.conflictingAltResolvedBySLL=R.getAlts().nextSetBit(0);if(this.decisions[this.currentDecision].llFallback++,A)super.reportAttemptingFullContext(_,A,R,U,Y)}reportContextSensitivity(_,A,R,U,Y){if(A!==this.conflictingAltResolvedBySLL&&this.predictionState.input)this.decisions[this.currentDecision].contextSensitivities.push({decision:this.currentDecision,configs:R,input:this.predictionState.input,startIndex:U,stopIndex:Y,fullCtx:!0});super.reportContextSensitivity(_,A,R,U,Y)}reportAmbiguity(_,A,R,U,Y,X,G){let Q;if(X)Q=X.nextSetBit(0);else Q=G.getAlts().nextSetBit(0);if(this.predictionState?.input){if(G.fullCtx&&Q!==this.conflictingAltResolvedBySLL)this.decisions[this.currentDecision].contextSensitivities.push({decision:this.currentDecision,configs:G,input:this.predictionState.input,startIndex:R,stopIndex:U,fullCtx:!0});this.decisions[this.currentDecision].ambiguities.push({ambigAlts:X,decision:this.currentDecision,configs:G,input:this.predictionState.input,startIndex:R,stopIndex:U,fullCtx:G.fullCtx})}super.reportAmbiguity(_,A,R,U,Y,X,G)}getDecisionInfo(){return this.decisions}getCurrentState(){return this.currentState}},E4;((_)=>{_.toString=W((A)=>{return`(${A.pred}, ${A.alt})`},"toString")})(E4||(E4={}));var r2=class extends Error{static{W(this,"ParseCancellationException")}constructor(_){super();this.cause=_}},S7=class{static{W(this,"InterpreterDataReader")}static parseInterpreterData(_){let A=[],R=[],U=[],Y=[],X=[],G=_.split(`
11
- `),Q=0,J=G[Q++];if(J!=="token literal names:")throw Error("Unexpected data entry");do{if(J=G[Q++],J.length===0)break;Y.push(J==="null"?null:J)}while(!0);if(J=G[Q++],J!=="token symbolic names:")throw Error("Unexpected data entry");do{if(J=G[Q++],J.length===0)break;X.push(J==="null"?null:J)}while(!0);if(J=G[Q++],J!=="rule names:")throw Error("Unexpected data entry");do{if(J=G[Q++],J.length===0)break;A.push(J)}while(!0);if(J=G[Q++],J==="channel names:"){do{if(J=G[Q++],J.length===0)break;R.push(J)}while(!0);if(J=G[Q++],J!=="mode names:")throw Error("Unexpected data entry");do{if(J=G[Q++],J.length===0)break;U.push(J)}while(!0)}if(J=G[Q++],J!=="atn:")throw Error("Unexpected data entry");J=G[Q++];let F=J.split(","),I,B=[];for(let V=0;V<F.length;++V){let x=F[V];if(x.startsWith("["))I=Number(x.substring(1).trim());else if(x.endsWith("]"))I=Number(x.substring(0,x.length-1).trim());else I=Number(x.trim());B[V]=I}return{atn:new n0().deserialize(B),vocabulary:new D0(Y,X,[]),ruleNames:A,channels:R.length>0?R:void 0,modes:U.length>0?U:void 0}}},x4=class{static{W(this,"AbstractParseTreeVisitor")}visit(_){return _.accept(this)}visitChildren(_){let A=this.defaultResult(),R=_.getChildCount();for(let U=0;U<R;U++){if(!this.shouldVisitNextChild(_,A))break;let Y=_.getChild(U);if(Y){let X=Y.accept(this);A=this.aggregateResult(A,X)}}return A}visitTerminal(_){return this.defaultResult()}visitErrorNode(_){return this.defaultResult()}defaultResult(){return null}shouldVisitNextChild(_,A){return!0}aggregateResult(_,A){return A}},x7=class _{static{W(this,"ParseTreeWalker")}static DEFAULT=new _;walk(A,R){if(R instanceof n1)A.visitErrorNode(R);else if(R instanceof L0)A.visitTerminal(R);else{let Y=R;this.enterRule(A,Y);for(let X=0;X<R.getChildCount();X++)this.walk(A,R.getChild(X));this.exitRule(A,Y)}}enterRule(A,R){let U=R.ruleContext;A.enterEveryRule(U),U.enterRule(A)}exitRule(A,R){let U=R.ruleContext;U.exitRule(A),A.exitEveryRule(U)}},F0;((_)=>{_.fromString=W((A)=>{return new H6(A)},"fromString")})(F0||(F0={}));var H6=class{static{W(this,"CharStreamImpl")}name="";index=0;data;constructor(_){let A=[];for(let R of _)A.push(R.codePointAt(0));this.data=new Uint32Array(A)}reset(){this.index=0}consume(){if(this.index>=this.data.length)throw Error("cannot consume EOF");this.index+=1}LA(_){if(_===0)return 0;if(_<0)_+=1;let A=this.index+_-1;if(A<0||A>=this.data.length)return D.EOF;return this.data[A]}mark(){return-1}release(_){}seek(_){if(_<=this.index){this.index=_;return}this.index=Math.min(_,this.data.length)}getTextFromRange(_,A){if(A=A??this.data.length-1,A>=this.data.length)A=this.data.length-1;if(_>=this.data.length)return"";return this.stringFromRange(_,A+1)}getTextFromInterval(_){let{start:A,stop:R}=_;if(R>=this.data.length)R=this.data.length-1;if(A>=this.data.length)return"";return this.stringFromRange(A,R+1)}toString(){return this.stringFromRange(0)}get size(){return this.data.length}getSourceName(){if(this.name)return this.name;return H2.UNKNOWN_SOURCE_NAME}stringFromRange(_,A){let R=this.data.slice(_,A),U="";return R.forEach((Y)=>{U+=String.fromCodePoint(Y)}),U}},m4=W((_)=>{return _.setText!==void 0},"isWritableToken"),$6=class{static{W(this,"BufferedTokenStream")}tokenSource;tokens=[];p=-1;fetchedEOF=!1;constructor(_){this.tokenSource=_}mark(){return 0}release(_){}reset(){this.seek(0)}seek(_){this.lazyInit(),this.p=this.adjustSeekIndex(_)}get size(){return this.tokens.length}get index(){return this.p}get(_){return this.lazyInit(),this.tokens[_]}consume(){let _=!1;if(this.p>=0)if(this.fetchedEOF)_=this.p<this.tokens.length-1;else _=this.p<this.tokens.length;else _=!1;if(!_&&this.LA(1)===D.EOF)throw Error("cannot consume EOF");if(this.sync(this.p+1))this.p=this.adjustSeekIndex(this.p+1)}sync(_){let A=_-this.tokens.length+1;if(A>0)return this.fetch(A)>=A;return!0}fetch(_){if(this.fetchedEOF)return 0;for(let A=0;A<_;A++){let R=this.tokenSource.nextToken();if(m4(R))R.tokenIndex=this.tokens.length;if(this.tokens.push(R),R.type===D.EOF)return this.fetchedEOF=!0,A+1}return _}getTokens(_,A,R){if(this.lazyInit(),_===void 0&&A===void 0)return this.tokens;if(_??=0,A===void 0)A=this.tokens.length-1;if(_<0||A>=this.tokens.length||A<0||_>=this.tokens.length)throw RangeError("start "+_+" or stop "+A+" not in 0.."+(this.tokens.length-1));if(_>A)return[];if(R===void 0)return this.tokens.slice(_,A+1);let U=[];if(A>=this.tokens.length)A=this.tokens.length-1;for(let Y=_;Y<A;Y++){let X=this.tokens[Y];if(X.type===D.EOF){U.push(X);break}if(R.has(X.type))U.push(X)}return U}LA(_){return this.LT(_)?.type??D.INVALID_TYPE}LB(_){if(this.p-_<0)return null;return this.tokens[this.p-_]}LT(_){if(this.lazyInit(),_===0)return null;if(_<0)return this.LB(-_);let A=this.p+_-1;if(this.sync(A),A>=this.tokens.length)return this.tokens[this.tokens.length-1];return this.tokens[A]}adjustSeekIndex(_){return _}lazyInit(){if(this.p===-1)this.setup()}setup(){this.sync(0),this.p=this.adjustSeekIndex(0)}setTokenSource(_){this.tokenSource=_,this.tokens=[],this.p=-1,this.fetchedEOF=!1}nextTokenOnChannel(_,A){if(this.sync(_),_>=this.tokens.length)return-1;let R=this.tokens[_];while(R.channel!==A){if(R.type===D.EOF)return-1;_+=1,this.sync(_),R=this.tokens[_]}return _}previousTokenOnChannel(_,A){if(_>=this.tokens.length)return this.tokens.length-1;while(_>=0){let R=this.tokens[_];if(R.type===D.EOF||R.channel===A)return _;--_}return _}getHiddenTokensToRight(_,A){if(A===void 0)A=-1;if(this.lazyInit(),_<0||_>=this.tokens.length)throw Error(`${_} not in 0..${this.tokens.length-1}`);let R=this.nextTokenOnChannel(_+1,O0.DEFAULT_TOKEN_CHANNEL),U=_+1,Y=R===-1?this.tokens.length-1:R;return this.filterForChannel(U,Y,A)}getHiddenTokensToLeft(_,A){if(A===void 0)A=-1;if(this.lazyInit(),_<0||_>=this.tokens.length)throw Error(`${_} not in 0..${this.tokens.length-1}`);let R=this.previousTokenOnChannel(_-1,O0.DEFAULT_TOKEN_CHANNEL);if(R===_-1)return;let U=R+1,Y=_-1;return this.filterForChannel(U,Y,A)}filterForChannel(_,A,R){let U=[];for(let Y=_;Y<A+1;Y++){let X=this.tokens[Y];if(R===-1){if(X.channel!==O0.DEFAULT_TOKEN_CHANNEL)U.push(X)}else if(X.channel===R)U.push(X)}if(U.length===0)return;return U}getSourceName(){return this.tokenSource.sourceName}getText(){return this.getTextFromInterval(b.of(0,this.size-1))}getTextFromInterval(_){let{start:A,stop:R}=_;if(A<0||R<0)return"";if(this.sync(R),R>=this.tokens.length)R=this.tokens.length-1;let U="";for(let Y=A;Y<=R;++Y){let X=this.tokens[Y];if(X.type===D.EOF)break;U+=X.text}return U}getTextFromContext(_){return this.getTextFromInterval(_.getSourceInterval())}getTextFromRange(_,A){if(_!==null&&A!==null)return this.getTextFromInterval(b.of(_.tokenIndex,A.tokenIndex));return""}fill(){this.lazyInit();while(this.fetch(1000)===1000);}setLine(_){this.tokenSource.line=_}setColumn(_){this.tokenSource.column=_}},q2=class extends $6{static{W(this,"CommonTokenStream")}channel=D.DEFAULT_CHANNEL;constructor(_,A){super(_);this.channel=A??D.DEFAULT_CHANNEL}adjustSeekIndex(_){return this.nextTokenOnChannel(_,this.channel)}LB(_){if(_===0||this.index-_<0)return null;let A=this.index,R=1;while(R<=_)A=this.previousTokenOnChannel(A-1,this.channel),R+=1;if(A<0)return null;return this.tokens[A]}LT(_){if(this.lazyInit(),_===0)return null;if(_<0)return this.LB(-_);let A=this.index,R=1;while(R<_){if(this.sync(A+1))A=this.nextTokenOnChannel(A+1,this.channel);R+=1}return this.tokens[A]}getNumberOfOnChannelTokens(){let _=0;this.fill();for(let A of this.tokens){if(A.channel===this.channel)_+=1;if(A.type===D.EOF)break}return _}},q0=class _ extends O0{static{W(this,"XPathLexer")}static TOKEN_REF=1;static RULE_REF=2;static ANYWHERE=3;static ROOT=4;static WILDCARD=5;static BANG=6;static ID=7;static STRING=8;static channelNames=["DEFAULT_TOKEN_CHANNEL","HIDDEN"];static literalNames=[null,null,null,"'//'","'/'","'*'","'!'"];static symbolicNames=[null,"TOKEN_REF","RULE_REF","ANYWHERE","ROOT","WILDCARD","BANG","ID","STRING"];static modeNames=["DEFAULT_MODE"];static ruleNames=["ANYWHERE","ROOT","WILDCARD","BANG","ID","NameChar","NameStartChar","STRING"];constructor(A){super(A);this.interpreter=new E1(this,_._ATN,_.decisionsToDFA,new G1)}get grammarFileName(){return"XPathLexer.g4"}get literalNames(){return _.literalNames}get symbolicNames(){return _.symbolicNames}get ruleNames(){return _.ruleNames}get serializedATN(){return _._serializedATN}get channelNames(){return _.channelNames}get modeNames(){return _.modeNames}action(A,R,U){switch(R){case 4:this.ID_action(A,U);break}}ID_action(A,R){switch(R){case 0:let U=this.text;if(U.charAt(0)===U.charAt(0).toUpperCase())this.type=_.TOKEN_REF;else this.type=_.RULE_REF;break}}static _serializedATN=[4,0,8,48,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,1,0,1,0,1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,4,1,4,5,4,29,8,4,10,4,12,4,32,9,4,1,4,1,4,1,5,1,5,1,6,1,6,1,7,1,7,5,7,42,8,7,10,7,12,7,45,9,7,1,7,1,7,1,43,0,8,1,3,3,4,5,5,7,6,9,7,11,0,13,0,15,8,1,0,2,784,0,0,8,14,27,48,57,65,90,95,95,97,122,127,159,170,170,173,173,181,181,186,186,192,214,216,246,248,705,710,721,736,740,748,748,750,750,768,884,886,887,890,893,895,895,902,902,904,906,908,908,910,929,931,1013,1015,1153,1155,1159,1162,1327,1329,1366,1369,1369,1376,1416,1425,1469,1471,1471,1473,1474,1476,1477,1479,1479,1488,1514,1519,1522,1536,1541,1552,1562,1564,1564,1568,1641,1646,1747,1749,1757,1759,1768,1770,1788,1791,1791,1807,1866,1869,1969,1984,2037,2042,2042,2045,2045,2048,2093,2112,2139,2144,2154,2160,2183,2185,2190,2192,2193,2200,2403,2406,2415,2417,2435,2437,2444,2447,2448,2451,2472,2474,2480,2482,2482,2486,2489,2492,2500,2503,2504,2507,2510,2519,2519,2524,2525,2527,2531,2534,2545,2556,2556,2558,2558,2561,2563,2565,2570,2575,2576,2579,2600,2602,2608,2610,2611,2613,2614,2616,2617,2620,2620,2622,2626,2631,2632,2635,2637,2641,2641,2649,2652,2654,2654,2662,2677,2689,2691,2693,2701,2703,2705,2707,2728,2730,2736,2738,2739,2741,2745,2748,2757,2759,2761,2763,2765,2768,2768,2784,2787,2790,2799,2809,2815,2817,2819,2821,2828,2831,2832,2835,2856,2858,2864,2866,2867,2869,2873,2876,2884,2887,2888,2891,2893,2901,2903,2908,2909,2911,2915,2918,2927,2929,2929,2946,2947,2949,2954,2958,2960,2962,2965,2969,2970,2972,2972,2974,2975,2979,2980,2984,2986,2990,3001,3006,3010,3014,3016,3018,3021,3024,3024,3031,3031,3046,3055,3072,3084,3086,3088,3090,3112,3114,3129,3132,3140,3142,3144,3146,3149,3157,3158,3160,3162,3165,3165,3168,3171,3174,3183,3200,3203,3205,3212,3214,3216,3218,3240,3242,3251,3253,3257,3260,3268,3270,3272,3274,3277,3285,3286,3293,3294,3296,3299,3302,3311,3313,3315,3328,3340,3342,3344,3346,3396,3398,3400,3402,3406,3412,3415,3423,3427,3430,3439,3450,3455,3457,3459,3461,3478,3482,3505,3507,3515,3517,3517,3520,3526,3530,3530,3535,3540,3542,3542,3544,3551,3558,3567,3570,3571,3585,3642,3648,3662,3664,3673,3713,3714,3716,3716,3718,3722,3724,3747,3749,3749,3751,3773,3776,3780,3782,3782,3784,3790,3792,3801,3804,3807,3840,3840,3864,3865,3872,3881,3893,3893,3895,3895,3897,3897,3902,3911,3913,3948,3953,3972,3974,3991,3993,4028,4038,4038,4096,4169,4176,4253,4256,4293,4295,4295,4301,4301,4304,4346,4348,4680,4682,4685,4688,4694,4696,4696,4698,4701,4704,4744,4746,4749,4752,4784,4786,4789,4792,4798,4800,4800,4802,4805,4808,4822,4824,4880,4882,4885,4888,4954,4957,4959,4992,5007,5024,5109,5112,5117,5121,5740,5743,5759,5761,5786,5792,5866,5870,5880,5888,5909,5919,5940,5952,5971,5984,5996,5998,6000,6002,6003,6016,6099,6103,6103,6108,6109,6112,6121,6155,6169,6176,6264,6272,6314,6320,6389,6400,6430,6432,6443,6448,6459,6470,6509,6512,6516,6528,6571,6576,6601,6608,6617,6656,6683,6688,6750,6752,6780,6783,6793,6800,6809,6823,6823,6832,6845,6847,6862,6912,6988,6992,7001,7019,7027,7040,7155,7168,7223,7232,7241,7245,7293,7296,7304,7312,7354,7357,7359,7376,7378,7380,7418,7424,7957,7960,7965,7968,8005,8008,8013,8016,8023,8025,8025,8027,8027,8029,8029,8031,8061,8064,8116,8118,8124,8126,8126,8130,8132,8134,8140,8144,8147,8150,8155,8160,8172,8178,8180,8182,8188,8203,8207,8234,8238,8255,8256,8276,8276,8288,8292,8294,8303,8305,8305,8319,8319,8336,8348,8400,8412,8417,8417,8421,8432,8450,8450,8455,8455,8458,8467,8469,8469,8473,8477,8484,8484,8486,8486,8488,8488,8490,8493,8495,8505,8508,8511,8517,8521,8526,8526,8544,8584,11264,11492,11499,11507,11520,11557,11559,11559,11565,11565,11568,11623,11631,11631,11647,11670,11680,11686,11688,11694,11696,11702,11704,11710,11712,11718,11720,11726,11728,11734,11736,11742,11744,11775,11823,11823,12293,12295,12321,12335,12337,12341,12344,12348,12353,12438,12441,12442,12445,12447,12449,12538,12540,12543,12549,12591,12593,12686,12704,12735,12784,12799,13312,19903,19968,42124,42192,42237,42240,42508,42512,42539,42560,42607,42612,42621,42623,42737,42775,42783,42786,42888,42891,42954,42960,42961,42963,42963,42965,42969,42994,43047,43052,43052,43072,43123,43136,43205,43216,43225,43232,43255,43259,43259,43261,43309,43312,43347,43360,43388,43392,43456,43471,43481,43488,43518,43520,43574,43584,43597,43600,43609,43616,43638,43642,43714,43739,43741,43744,43759,43762,43766,43777,43782,43785,43790,43793,43798,43808,43814,43816,43822,43824,43866,43868,43881,43888,44010,44012,44013,44016,44025,44032,55203,55216,55238,55243,55291,63744,64109,64112,64217,64256,64262,64275,64279,64285,64296,64298,64310,64312,64316,64318,64318,64320,64321,64323,64324,64326,64433,64467,64829,64848,64911,64914,64967,65008,65019,65024,65039,65056,65071,65075,65076,65101,65103,65136,65140,65142,65276,65279,65279,65296,65305,65313,65338,65343,65343,65345,65370,65382,65470,65474,65479,65482,65487,65490,65495,65498,65500,65529,65531,65536,65547,65549,65574,65576,65594,65596,65597,65599,65613,65616,65629,65664,65786,65856,65908,66045,66045,66176,66204,66208,66256,66272,66272,66304,66335,66349,66378,66384,66426,66432,66461,66464,66499,66504,66511,66513,66517,66560,66717,66720,66729,66736,66771,66776,66811,66816,66855,66864,66915,66928,66938,66940,66954,66956,66962,66964,66965,66967,66977,66979,66993,66995,67001,67003,67004,67072,67382,67392,67413,67424,67431,67456,67461,67463,67504,67506,67514,67584,67589,67592,67592,67594,67637,67639,67640,67644,67644,67647,67669,67680,67702,67712,67742,67808,67826,67828,67829,67840,67861,67872,67897,67968,68023,68030,68031,68096,68099,68101,68102,68108,68115,68117,68119,68121,68149,68152,68154,68159,68159,68192,68220,68224,68252,68288,68295,68297,68326,68352,68405,68416,68437,68448,68466,68480,68497,68608,68680,68736,68786,68800,68850,68864,68903,68912,68921,69248,69289,69291,69292,69296,69297,69373,69404,69415,69415,69424,69456,69488,69509,69552,69572,69600,69622,69632,69702,69734,69749,69759,69818,69821,69821,69826,69826,69837,69837,69840,69864,69872,69881,69888,69940,69942,69951,69956,69959,69968,70003,70006,70006,70016,70084,70089,70092,70094,70106,70108,70108,70144,70161,70163,70199,70206,70209,70272,70278,70280,70280,70282,70285,70287,70301,70303,70312,70320,70378,70384,70393,70400,70403,70405,70412,70415,70416,70419,70440,70442,70448,70450,70451,70453,70457,70459,70468,70471,70472,70475,70477,70480,70480,70487,70487,70493,70499,70502,70508,70512,70516,70656,70730,70736,70745,70750,70753,70784,70853,70855,70855,70864,70873,71040,71093,71096,71104,71128,71133,71168,71232,71236,71236,71248,71257,71296,71352,71360,71369,71424,71450,71453,71467,71472,71481,71488,71494,71680,71738,71840,71913,71935,71942,71945,71945,71948,71955,71957,71958,71960,71989,71991,71992,71995,72003,72016,72025,72096,72103,72106,72151,72154,72161,72163,72164,72192,72254,72263,72263,72272,72345,72349,72349,72368,72440,72704,72712,72714,72758,72760,72768,72784,72793,72818,72847,72850,72871,72873,72886,72960,72966,72968,72969,72971,73014,73018,73018,73020,73021,73023,73031,73040,73049,73056,73061,73063,73064,73066,73102,73104,73105,73107,73112,73120,73129,73440,73462,73472,73488,73490,73530,73534,73538,73552,73561,73648,73648,73728,74649,74752,74862,74880,75075,77712,77808,77824,78933,82944,83526,92160,92728,92736,92766,92768,92777,92784,92862,92864,92873,92880,92909,92912,92916,92928,92982,92992,92995,93008,93017,93027,93047,93053,93071,93760,93823,93952,94026,94031,94087,94095,94111,94176,94177,94179,94180,94192,94193,94208,100343,100352,101589,101632,101640,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,113664,113770,113776,113788,113792,113800,113808,113817,113821,113822,113824,113827,118528,118573,118576,118598,119141,119145,119149,119170,119173,119179,119210,119213,119362,119364,119808,119892,119894,119964,119966,119967,119970,119970,119973,119974,119977,119980,119982,119993,119995,119995,119997,120003,120005,120069,120071,120074,120077,120084,120086,120092,120094,120121,120123,120126,120128,120132,120134,120134,120138,120144,120146,120485,120488,120512,120514,120538,120540,120570,120572,120596,120598,120628,120630,120654,120656,120686,120688,120712,120714,120744,120746,120770,120772,120779,120782,120831,121344,121398,121403,121452,121461,121461,121476,121476,121499,121503,121505,121519,122624,122654,122661,122666,122880,122886,122888,122904,122907,122913,122915,122916,122918,122922,122928,122989,123023,123023,123136,123180,123184,123197,123200,123209,123214,123214,123536,123566,123584,123641,124112,124153,124896,124902,124904,124907,124909,124910,124912,124926,124928,125124,125136,125142,125184,125259,125264,125273,126464,126467,126469,126495,126497,126498,126500,126500,126503,126503,126505,126514,126516,126519,126521,126521,126523,126523,126530,126530,126535,126535,126537,126537,126539,126539,126541,126543,126545,126546,126548,126548,126551,126551,126553,126553,126555,126555,126557,126557,126559,126559,126561,126562,126564,126564,126567,126570,126572,126578,126580,126583,126585,126588,126590,126590,126592,126601,126603,126619,126625,126627,126629,126633,126635,126651,130032,130041,131072,173791,173824,177977,177984,178205,178208,183969,183984,191456,194560,195101,196608,201546,201552,205743,917505,917505,917536,917631,917760,917999,662,0,65,90,97,122,170,170,181,181,186,186,192,214,216,246,248,705,710,721,736,740,748,748,750,750,880,884,886,887,890,893,895,895,902,902,904,906,908,908,910,929,931,1013,1015,1153,1162,1327,1329,1366,1369,1369,1376,1416,1488,1514,1519,1522,1568,1610,1646,1647,1649,1747,1749,1749,1765,1766,1774,1775,1786,1788,1791,1791,1808,1808,1810,1839,1869,1957,1969,1969,1994,2026,2036,2037,2042,2042,2048,2069,2074,2074,2084,2084,2088,2088,2112,2136,2144,2154,2160,2183,2185,2190,2208,2249,2308,2361,2365,2365,2384,2384,2392,2401,2417,2432,2437,2444,2447,2448,2451,2472,2474,2480,2482,2482,2486,2489,2493,2493,2510,2510,2524,2525,2527,2529,2544,2545,2556,2556,2565,2570,2575,2576,2579,2600,2602,2608,2610,2611,2613,2614,2616,2617,2649,2652,2654,2654,2674,2676,2693,2701,2703,2705,2707,2728,2730,2736,2738,2739,2741,2745,2749,2749,2768,2768,2784,2785,2809,2809,2821,2828,2831,2832,2835,2856,2858,2864,2866,2867,2869,2873,2877,2877,2908,2909,2911,2913,2929,2929,2947,2947,2949,2954,2958,2960,2962,2965,2969,2970,2972,2972,2974,2975,2979,2980,2984,2986,2990,3001,3024,3024,3077,3084,3086,3088,3090,3112,3114,3129,3133,3133,3160,3162,3165,3165,3168,3169,3200,3200,3205,3212,3214,3216,3218,3240,3242,3251,3253,3257,3261,3261,3293,3294,3296,3297,3313,3314,3332,3340,3342,3344,3346,3386,3389,3389,3406,3406,3412,3414,3423,3425,3450,3455,3461,3478,3482,3505,3507,3515,3517,3517,3520,3526,3585,3632,3634,3635,3648,3654,3713,3714,3716,3716,3718,3722,3724,3747,3749,3749,3751,3760,3762,3763,3773,3773,3776,3780,3782,3782,3804,3807,3840,3840,3904,3911,3913,3948,3976,3980,4096,4138,4159,4159,4176,4181,4186,4189,4193,4193,4197,4198,4206,4208,4213,4225,4238,4238,4256,4293,4295,4295,4301,4301,4304,4346,4348,4680,4682,4685,4688,4694,4696,4696,4698,4701,4704,4744,4746,4749,4752,4784,4786,4789,4792,4798,4800,4800,4802,4805,4808,4822,4824,4880,4882,4885,4888,4954,4992,5007,5024,5109,5112,5117,5121,5740,5743,5759,5761,5786,5792,5866,5870,5880,5888,5905,5919,5937,5952,5969,5984,5996,5998,6000,6016,6067,6103,6103,6108,6108,6176,6264,6272,6276,6279,6312,6314,6314,6320,6389,6400,6430,6480,6509,6512,6516,6528,6571,6576,6601,6656,6678,6688,6740,6823,6823,6917,6963,6981,6988,7043,7072,7086,7087,7098,7141,7168,7203,7245,7247,7258,7293,7296,7304,7312,7354,7357,7359,7401,7404,7406,7411,7413,7414,7418,7418,7424,7615,7680,7957,7960,7965,7968,8005,8008,8013,8016,8023,8025,8025,8027,8027,8029,8029,8031,8061,8064,8116,8118,8124,8126,8126,8130,8132,8134,8140,8144,8147,8150,8155,8160,8172,8178,8180,8182,8188,8305,8305,8319,8319,8336,8348,8450,8450,8455,8455,8458,8467,8469,8469,8473,8477,8484,8484,8486,8486,8488,8488,8490,8493,8495,8505,8508,8511,8517,8521,8526,8526,8544,8584,11264,11492,11499,11502,11506,11507,11520,11557,11559,11559,11565,11565,11568,11623,11631,11631,11648,11670,11680,11686,11688,11694,11696,11702,11704,11710,11712,11718,11720,11726,11728,11734,11736,11742,11823,11823,12293,12295,12321,12329,12337,12341,12344,12348,12353,12438,12445,12447,12449,12538,12540,12543,12549,12591,12593,12686,12704,12735,12784,12799,13312,19903,19968,42124,42192,42237,42240,42508,42512,42527,42538,42539,42560,42606,42623,42653,42656,42735,42775,42783,42786,42888,42891,42954,42960,42961,42963,42963,42965,42969,42994,43009,43011,43013,43015,43018,43020,43042,43072,43123,43138,43187,43250,43255,43259,43259,43261,43262,43274,43301,43312,43334,43360,43388,43396,43442,43471,43471,43488,43492,43494,43503,43514,43518,43520,43560,43584,43586,43588,43595,43616,43638,43642,43642,43646,43695,43697,43697,43701,43702,43705,43709,43712,43712,43714,43714,43739,43741,43744,43754,43762,43764,43777,43782,43785,43790,43793,43798,43808,43814,43816,43822,43824,43866,43868,43881,43888,44002,44032,55203,55216,55238,55243,55291,63744,64109,64112,64217,64256,64262,64275,64279,64285,64285,64287,64296,64298,64310,64312,64316,64318,64318,64320,64321,64323,64324,64326,64433,64467,64829,64848,64911,64914,64967,65008,65019,65136,65140,65142,65276,65313,65338,65345,65370,65382,65470,65474,65479,65482,65487,65490,65495,65498,65500,65536,65547,65549,65574,65576,65594,65596,65597,65599,65613,65616,65629,65664,65786,65856,65908,66176,66204,66208,66256,66304,66335,66349,66378,66384,66421,66432,66461,66464,66499,66504,66511,66513,66517,66560,66717,66736,66771,66776,66811,66816,66855,66864,66915,66928,66938,66940,66954,66956,66962,66964,66965,66967,66977,66979,66993,66995,67001,67003,67004,67072,67382,67392,67413,67424,67431,67456,67461,67463,67504,67506,67514,67584,67589,67592,67592,67594,67637,67639,67640,67644,67644,67647,67669,67680,67702,67712,67742,67808,67826,67828,67829,67840,67861,67872,67897,67968,68023,68030,68031,68096,68096,68112,68115,68117,68119,68121,68149,68192,68220,68224,68252,68288,68295,68297,68324,68352,68405,68416,68437,68448,68466,68480,68497,68608,68680,68736,68786,68800,68850,68864,68899,69248,69289,69296,69297,69376,69404,69415,69415,69424,69445,69488,69505,69552,69572,69600,69622,69635,69687,69745,69746,69749,69749,69763,69807,69840,69864,69891,69926,69956,69956,69959,69959,69968,70002,70006,70006,70019,70066,70081,70084,70106,70106,70108,70108,70144,70161,70163,70187,70207,70208,70272,70278,70280,70280,70282,70285,70287,70301,70303,70312,70320,70366,70405,70412,70415,70416,70419,70440,70442,70448,70450,70451,70453,70457,70461,70461,70480,70480,70493,70497,70656,70708,70727,70730,70751,70753,70784,70831,70852,70853,70855,70855,71040,71086,71128,71131,71168,71215,71236,71236,71296,71338,71352,71352,71424,71450,71488,71494,71680,71723,71840,71903,71935,71942,71945,71945,71948,71955,71957,71958,71960,71983,71999,71999,72001,72001,72096,72103,72106,72144,72161,72161,72163,72163,72192,72192,72203,72242,72250,72250,72272,72272,72284,72329,72349,72349,72368,72440,72704,72712,72714,72750,72768,72768,72818,72847,72960,72966,72968,72969,72971,73008,73030,73030,73056,73061,73063,73064,73066,73097,73112,73112,73440,73458,73474,73474,73476,73488,73490,73523,73648,73648,73728,74649,74752,74862,74880,75075,77712,77808,77824,78895,78913,78918,82944,83526,92160,92728,92736,92766,92784,92862,92880,92909,92928,92975,92992,92995,93027,93047,93053,93071,93760,93823,93952,94026,94032,94032,94099,94111,94176,94177,94179,94179,94208,100343,100352,101589,101632,101640,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,113664,113770,113776,113788,113792,113800,113808,113817,119808,119892,119894,119964,119966,119967,119970,119970,119973,119974,119977,119980,119982,119993,119995,119995,119997,120003,120005,120069,120071,120074,120077,120084,120086,120092,120094,120121,120123,120126,120128,120132,120134,120134,120138,120144,120146,120485,120488,120512,120514,120538,120540,120570,120572,120596,120598,120628,120630,120654,120656,120686,120688,120712,120714,120744,120746,120770,120772,120779,122624,122654,122661,122666,122928,122989,123136,123180,123191,123197,123214,123214,123536,123565,123584,123627,124112,124139,124896,124902,124904,124907,124909,124910,124912,124926,124928,125124,125184,125251,125259,125259,126464,126467,126469,126495,126497,126498,126500,126500,126503,126503,126505,126514,126516,126519,126521,126521,126523,126523,126530,126530,126535,126535,126537,126537,126539,126539,126541,126543,126545,126546,126548,126548,126551,126551,126553,126553,126555,126555,126557,126557,126559,126559,126561,126562,126564,126564,126567,126570,126572,126578,126580,126583,126585,126588,126590,126590,126592,126601,126603,126619,126625,126627,126629,126633,126635,126651,131072,173791,173824,177977,177984,178205,178208,183969,183984,191456,194560,195101,196608,201546,201552,205743,47,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,15,1,0,0,0,1,17,1,0,0,0,3,20,1,0,0,0,5,22,1,0,0,0,7,24,1,0,0,0,9,26,1,0,0,0,11,35,1,0,0,0,13,37,1,0,0,0,15,39,1,0,0,0,17,18,5,47,0,0,18,19,5,47,0,0,19,2,1,0,0,0,20,21,5,47,0,0,21,4,1,0,0,0,22,23,5,42,0,0,23,6,1,0,0,0,24,25,5,33,0,0,25,8,1,0,0,0,26,30,3,13,6,0,27,29,3,11,5,0,28,27,1,0,0,0,29,32,1,0,0,0,30,28,1,0,0,0,30,31,1,0,0,0,31,33,1,0,0,0,32,30,1,0,0,0,33,34,6,4,0,0,34,10,1,0,0,0,35,36,7,0,0,0,36,12,1,0,0,0,37,38,7,1,0,0,38,14,1,0,0,0,39,43,5,39,0,0,40,42,9,0,0,0,41,40,1,0,0,0,42,45,1,0,0,0,43,44,1,0,0,0,43,41,1,0,0,0,44,46,1,0,0,0,45,43,1,0,0,0,46,47,5,39,0,0,47,16,1,0,0,0,3,0,30,43,1,1,4,0];static __ATN;static get _ATN(){if(!_.__ATN)_.__ATN=new n0().deserialize(_._serializedATN);return _.__ATN}static vocabulary=new D0(_.literalNames,_.symbolicNames,[]);get vocabulary(){return _.vocabulary}static decisionsToDFA=_._ATN.decisionToState.map((A,R)=>{return new S0(A,R)})},F6=class extends W2{static{W(this,"XPathLexerErrorListener")}syntaxError(_,A,R,U,Y,X){}},k1=class{static{W(this,"XPathElement")}invert;nodeName;constructor(_){this.nodeName=_,this.invert=!1}toString(){return"XPathElement["+(this.invert?"!":"")+this.nodeName+"]"}},I6=class extends k1{static{W(this,"XPathRuleAnywhereElement")}ruleIndex;constructor(_,A){super(_);this.ruleIndex=A}evaluate(_){return a0.findAllRuleNodes(_,this.ruleIndex)}toString(){return"XPathRuleAnywhereElement["+(this.invert?"!":"")+this.nodeName+"]"}},W6=class extends k1{static{W(this,"XPathRuleElement")}ruleIndex;constructor(_,A){super(_);this.ruleIndex=A}evaluate(_){let A=[];for(let R of a0.getChildren(_))if(R instanceof M){if(R.ruleIndex===this.ruleIndex&&!this.invert||R.ruleIndex!==this.ruleIndex&&this.invert)A.push(R)}return A}toString(){return"XPathRuleElement["+(this.invert?"!":"")+this.nodeName+"]"}},q6=class extends k1{static{W(this,"XPathTokenAnywhereElement")}tokenType;constructor(_,A){super(_);this.tokenType=A}evaluate(_){return a0.findAllTokenNodes(_,this.tokenType)}toString(){return"XPathTokenAnywhereElement["+(this.invert?"!":"")+this.nodeName+"]"}},z6=class extends k1{static{W(this,"XPathTokenElement")}tokenType;constructor(_,A){super(_);this.tokenType=A}evaluate(_){let A=[];for(let R of a0.getChildren(_))if(R instanceof L0&&R.symbol){if(R.symbol.type===this.tokenType&&!this.invert||R.symbol.type!==this.tokenType&&this.invert)A.push(R)}return A}toString(){return"XPathTokenElement["+(this.invert?"!":"")+this.nodeName+"]"}},K6=class extends k1{static{W(this,"XPathWildcardAnywhereElement")}constructor(){super(U3.WILDCARD)}evaluate(_){if(this.invert)return[];return a0.descendants(_)}toString(){return"XPathWildcardAnywhereElement["+(this.invert?"!":"")+this.nodeName+"]"}},L6=class extends k1{static{W(this,"XPathWildcardElement")}constructor(){super(U3.WILDCARD)}evaluate(_){let A=[];if(this.invert)return A;for(let R of a0.getChildren(_))A.push(R);return A}toString(){return"XPathWildcardElement["+(this.invert?"!":"")+this.nodeName+"]"}},U3=class _{static{W(this,"XPath")}static WILDCARD="*";static NOT="!";path;elements;parser;constructor(A,R){this.parser=A,this.path=R,this.elements=this.split(R)}static findAll(A,R,U){return new _(U,R).evaluate(A)}split(A){let R=new q0(F0.fromString(A));R.recover=(J)=>{throw J},R.removeErrorListeners(),R.addErrorListener(new F6);let U=new q2(R);try{U.fill()}catch(J){if(J instanceof F2){let I="Invalid tokens or characters at index "+R.column+" in path '"+A+"' -- "+J.message;throw RangeError(I)}throw J}let Y=U.getTokens(),X=[],G=Y.length,Q=0;_:while(Q<G){let J=Y[Q],F;switch(J.type){case q0.ROOT:case q0.ANYWHERE:let I=J.type===q0.ANYWHERE;Q++,F=Y[Q];let B=F.type===q0.BANG;if(B)Q++,F=Y[Q];let C=this.getXPathElement(F,I);C.invert=B,X.push(C),Q++;break;case q0.TOKEN_REF:case q0.RULE_REF:case q0.WILDCARD:X.push(this.getXPathElement(J,!1)),++Q;break;case D.EOF:break _;default:throw Error("Unknown path element "+J)}}return X}evaluate(A){let R=new M(null);R.addChild(A);let U=new Set([R]),Y=0;while(Y<this.elements.length){let X=new Set;for(let G of U)if(G.getChildCount()>0)this.elements[Y].evaluate(G).forEach((J)=>{X.add(J)},X);Y++,U=X}return U}getXPathElement(A,R){if(A.type===D.EOF)throw Error("Missing path element at end of path");let U=A.text;if(U==null)throw Error("Expected wordToken to have text content.");let Y=this.parser.getTokenType(U),X=this.parser.getRuleIndex(U);switch(A.type){case q0.WILDCARD:return R?new K6:new L6;case q0.TOKEN_REF:case q0.STRING:if(Y===D.INVALID_TYPE)throw Error(U+" at index "+A.start+" isn't a valid token name");return R?new q6(U,Y):new z6(U,Y);default:if(X===-1)throw Error(U+" at index "+A.start+" isn't a valid rule name");return R?new I6(U,X):new W6(U,X)}}},g4=class{static{W(this,"Chunk")}},D6=class{static{W(this,"ParseTreeMatch")}tree;pattern;labels;mismatchedNode;constructor(_,A,R,U){this.tree=_,this.pattern=A,this.labels=R,this.mismatchedNode=U}get(_){let A=this.labels.get(_);if(!A||A.length===0)return null;return A[A.length-1]}getAll(_){return this.labels.get(_)??[]}getLabels(){return this.labels}getMismatchedNode(){return this.mismatchedNode}succeeded(){return!this.mismatchedNode}getPattern(){return this.pattern}getTree(){return this.tree}toString(){return`Match ${this.succeeded()?"succeeded":"failed"}; found ${this.getLabels().size} labels`}},B6=class{static{W(this,"ParseTreePattern")}patternRuleIndex;pattern;patternTree;matcher;constructor(_,A,R,U){this.matcher=_,this.patternRuleIndex=R,this.pattern=A,this.patternTree=U}match(_){return this.matcher.match(_,this)}matches(_){return this.matcher.match(_,this).succeeded()}findAll(_,A){let R=U3.findAll(_,A,this.matcher.getParser()),U=[];for(let Y of R){let X=this.match(Y);if(X.succeeded())U.push(X)}return U}getMatcher(){return this.matcher}getPattern(){return this.pattern}getPatternRuleIndex(){return this.patternRuleIndex}getPatternTree(){return this.patternTree}},s1=class extends h{static{W(this,"InputMismatchException")}constructor(_){super({message:"",recognizer:_,input:_.inputStream,ctx:_.context});this.offendingToken=_.getCurrentToken()}},p1=class extends h{static{W(this,"FailedPredicateException")}ruleIndex=0;predicateIndex=0;predicate;constructor(_,A,R=null){super({message:w6(A??"no predicate",R??null),recognizer:_,input:_.inputStream,ctx:_.context});let Y=_.atn.states[_.state].transitions[0];if(Y instanceof v4)this.ruleIndex=Y.ruleIndex,this.predicateIndex=Y.predIndex;else this.ruleIndex=0,this.predicateIndex=0;this.predicate=A,this.offendingToken=_.getCurrentToken()}},w6=W((_,A)=>{if(A!==null)return A;return"failed predicate: {"+_+"}?"},"formatMessage"),d4=class{static{W(this,"DefaultErrorStrategy")}errorRecoveryMode=!1;lastErrorIndex=-1;lastErrorStates=new K0;nextTokensContext=null;nextTokenState=0;reset(_){this.endErrorCondition(_)}beginErrorCondition(_){this.errorRecoveryMode=!0}inErrorRecoveryMode(_){return this.errorRecoveryMode}endErrorCondition(_){this.errorRecoveryMode=!1,this.lastErrorStates=new K0,this.lastErrorIndex=-1}reportMatch(_){this.endErrorCondition(_)}reportError(_,A){if(this.inErrorRecoveryMode(_))return;if(this.beginErrorCondition(_),A instanceof X1)this.reportNoViableAlternative(_,A);else if(A instanceof s1)this.reportInputMismatch(_,A);else if(A instanceof p1)this.reportFailedPredicate(_,A);else _.notifyErrorListeners(A.message,A.offendingToken,A)}recover(_,A){if(this.lastErrorIndex===_.inputStream?.index&&this.lastErrorStates.contains(_.state))_.consume();this.lastErrorIndex=_.inputStream?.index??0,this.lastErrorStates.addOne(_.state);let R=this.getErrorRecoverySet(_);this.consumeUntil(_,R)}sync(_){if(this.inErrorRecoveryMode(_))return;let A=_.atn.states[_.state],R=_.tokenStream.LA(1),U=_.atn.nextTokens(A);if(U.contains(R)){this.nextTokensContext=null,this.nextTokenState=f.INVALID_STATE_NUMBER;return}if(U.contains(D.EPSILON)){if(this.nextTokensContext===null)this.nextTokensContext=_.context,this.nextTokenState=_.state;return}switch(A.constructor.stateType){case f.BLOCK_START:case f.STAR_BLOCK_START:case f.PLUS_BLOCK_START:case f.STAR_LOOP_ENTRY:{if(this.singleTokenDeletion(_)!==null)return;throw new s1(_)}case f.PLUS_LOOP_BACK:case f.STAR_LOOP_BACK:{this.reportUnwantedToken(_);let Y=new K0;Y.addSet(_.getExpectedTokens());let X=Y.addSet(this.getErrorRecoverySet(_));this.consumeUntil(_,X);break}default:}}reportNoViableAlternative(_,A){if(A.message.length>0){_.notifyErrorListeners(A.message,A.offendingToken,A);return}let R=_.tokenStream,U;if(R!==null&&A.startToken)if(A.startToken.type===D.EOF)U="<EOF>";else U=R.getTextFromRange(A.startToken,A.offendingToken);else U="<unknown input>";let Y="no viable alternative at input "+this.escapeWSAndQuote(U);_.notifyErrorListeners(Y,A.offendingToken,A)}reportInputMismatch(_,A){if(A.message.length>0){_.notifyErrorListeners(A.message,A.offendingToken,A);return}let R="mismatched input "+this.getTokenErrorDisplay(A.offendingToken)+" expecting "+A.getExpectedTokens().toStringWithVocabulary(_.vocabulary);_.notifyErrorListeners(R,A.offendingToken,A)}reportFailedPredicate(_,A){let U="rule "+_.ruleNames[_.context.ruleIndex]+" "+A.message;_.notifyErrorListeners(U,A.offendingToken,A)}reportUnwantedToken(_){if(this.inErrorRecoveryMode(_))return;this.beginErrorCondition(_);let A=_.getCurrentToken(),R=this.getTokenErrorDisplay(A),U=this.getExpectedTokens(_),Y="extraneous input "+R+" expecting "+U.toStringWithVocabulary(_.vocabulary);_.notifyErrorListeners(Y,A,null)}reportMissingToken(_){if(this.inErrorRecoveryMode(_))return;this.beginErrorCondition(_);let A=_.getCurrentToken(),U="missing "+this.getExpectedTokens(_).toStringWithVocabulary(_.vocabulary)+" at "+this.getTokenErrorDisplay(A);_.notifyErrorListeners(U,A,null)}recoverInline(_){let A=this.singleTokenDeletion(_);if(A)return _.consume(),A;if(this.singleTokenInsertion(_))return this.getMissingSymbol(_);throw new s1(_)}singleTokenInsertion(_){let A=_.tokenStream?.LA(1)??-1,R=_.atn,Y=R.states[_.state].transitions[0].target;if(R.nextTokens(Y,_.context??void 0).contains(A))return this.reportMissingToken(_),!0;return!1}singleTokenDeletion(_){let A=_.tokenStream?.LA(2)??-1;if(this.getExpectedTokens(_).contains(A)){this.reportUnwantedToken(_),_.consume();let U=_.getCurrentToken();return this.reportMatch(_),U}return null}getMissingSymbol(_){let A=_.getCurrentToken(),R=this.getExpectedTokens(_),U=D.INVALID_TYPE;if(R.length!==0)U=R.minElement;let Y;if(U===D.EOF)Y="<missing EOF>";else Y="<missing "+_.vocabulary.getDisplayName(U)+">";let X=A,G=_.tokenStream?.LT(-1);if(X.type===D.EOF&&G!==null)X=G;return _.getTokenFactory().create(X.source,U,Y,D.DEFAULT_CHANNEL,-1,-1,X.line,X.column)}getExpectedTokens(_){return _.getExpectedTokens()}getTokenErrorDisplay(_){if(_===null)return"<no token>";let A=_.text;if(!A)if(_.type===D.EOF)A="<EOF>";else A="<"+_.type+">";return this.escapeWSAndQuote(A)}escapeWSAndQuote(_){return _=_.replace(/\n/g,"\\n"),_=_.replace(/\r/g,"\\r"),_=_.replace(/\t/g,"\\t"),"'"+_+"'"}getErrorRecoverySet(_){let{atn:A,context:R}=_,U=new K0;while(R!==null&&R.invokingState>=0){let X=A.states[R.invokingState].transitions[0],G=A.nextTokens(X.followState);U.addSet(G),R=R.parent}return U.removeOne(D.EPSILON),U}consumeUntil(_,A){let R=_.tokenStream?.LA(1)??-1;while(R!==D.EOF&&!A.contains(R))_.consume(),R=_.tokenStream?.LA(1)??-1}},E6=class extends d4{static{W(this,"BailErrorStrategy")}recover(_,A){throw new r2(A)}recoverInline(_){let A=new s1(_);throw new r2(A)}sync(_){}},k6=class{static{W(this,"ListTokenSource")}sourceName;tokenFactory=u4.DEFAULT;tokens=[];i=0;eofToken=null;constructor(_,A){this.tokens=_,this.sourceName=A??""}get column(){if(this.i<this.tokens.length)return this.tokens[this.i].column;if(this.eofToken!==null)return this.eofToken.column;if(this.tokens.length>0){let _=this.tokens[this.tokens.length-1],A=_.text;if(A){let R=A.lastIndexOf(`
12
- `);if(R>=0)return A.length-R-1}return _.column+_.stop-_.start+1}return 0}nextToken(){if(this.i>=this.tokens.length){if(this.eofToken===null){let A=-1;if(this.tokens.length>0){let U=this.tokens[this.tokens.length-1].stop;if(U!==-1)A=U+1}let R=Math.max(-1,A-1);this.eofToken=this.tokenFactory.create([this,this.inputStream],D.EOF,"EOF",D.DEFAULT_CHANNEL,A,R,this.line,this.column)}return this.eofToken}let _=this.tokens[this.i];if(this.i===this.tokens.length-1&&_.type===D.EOF)this.eofToken=_;return this.i++,_}get line(){if(this.i<this.tokens.length)return this.tokens[this.i].line;if(this.eofToken!==null)return this.eofToken.line;if(this.tokens.length>0){let _=this.tokens[this.tokens.length-1],A=_.line,R=_.text;if(R){for(let U of R)if(U===`
13
- `)A++}return A}return 1}get inputStream(){if(this.i<this.tokens.length)return this.tokens[this.i].inputStream;if(this.eofToken!==null)return this.eofToken.inputStream;if(this.tokens.length>0)return this.tokens[this.tokens.length-1].inputStream;return null}getSourceName(){if(this.sourceName!==null)return this.sourceName;let _=this.inputStream;if(_!==null)return _.getSourceName();return"List"}},C6=class extends M{static{W(this,"InterpreterRuleContext")}#_;constructor(_,A,R){super(A,R);this.#_=_}get ruleIndex(){return this.#_}},j6=class{static{W(this,"TraceListener")}parser;constructor(_){this.parser=_}enterEveryRule(_){console.log("enter "+this.parser.ruleNames[_.ruleIndex]+", LT(1)="+this.parser.inputStream?.LT(1)?.text)}visitTerminal(_){console.log("consume "+_.getSymbol()+" rule "+this.parser.ruleNames[this.parser.context.ruleIndex])}exitEveryRule(_){console.log("exit "+this.parser.ruleNames[_.ruleIndex]+", LT(1)="+this.parser.inputStream?.LT(1)?.text)}visitErrorNode(_){}},Y3=class extends b4{static{W(this,"Parser")}printer=null;buildParseTrees=!0;errorHandler=new d4;context=null;precedenceStack=[];parseListeners=null;syntaxErrors=0;matchedEOF=!1;tracer=null;bypassAltsAtnCache=null;#_;constructor(_){super();this.precedenceStack.push(0),this.syntaxErrors=0,this.#_=_}reset(_=!0){if(_)this.inputStream.seek(0);if(this.errorHandler.reset(this),this.context=null,this.syntaxErrors=0,this.matchedEOF=!1,this.setTrace(!1),this.precedenceStack=[],this.precedenceStack.push(0),this.interpreter)this.interpreter.reset()}match(_){let A=this.getCurrentToken();if(A.type===_){if(_===D.EOF)this.matchedEOF=!0;this.errorHandler.reportMatch(this),this.consume()}else if(A=this.errorHandler.recoverInline(this),this.buildParseTrees&&A.tokenIndex===-1)this.context.addErrorNode(this.createErrorNode(this.context,A));return A}matchWildcard(){let _=this.getCurrentToken();if(_.type>0)this.errorHandler.reportMatch(this),this.consume();else if(_=this.errorHandler.recoverInline(this),this.buildParseTrees&&_.tokenIndex===-1)this.context.addErrorNode(this.createErrorNode(this.context,_));return _}getParseListeners(){return this.parseListeners??[]}addParseListener(_){if(_===null)throw Error("listener");if(this.parseListeners===null)this.parseListeners=[];this.parseListeners.push(_)}removeParseListener(_){if(this.parseListeners!==null&&_!==null){let A=this.parseListeners.indexOf(_);if(A>=0)this.parseListeners.splice(A,1);if(this.parseListeners.length===0)this.parseListeners=null}}removeParseListeners(){this.parseListeners=null}triggerEnterRuleEvent(){if(this.parseListeners!==null){let _=this.context;this.parseListeners.forEach((A)=>{A.enterEveryRule(_),_.enterRule(A)})}}triggerExitRuleEvent(){if(this.parseListeners!==null){let _=this.context;this.parseListeners.slice(0).reverse().forEach((A)=>{_.exitRule(A),A.exitEveryRule(_)})}}getTokenFactory(){return this.inputStream.tokenSource.tokenFactory}setTokenFactory(_){this.inputStream.tokenSource.tokenFactory=_}compileParseTreePattern(_,A,R){if(!R){if(this.tokenStream!==null){let Y=this.tokenStream.tokenSource;if(Y instanceof O0)R=Y}}if(!R)throw Error("Parser can't discover a lexer to use");return new h6(R,this).compile(_,A)}getATNWithBypassAlts(){let _=this.serializedATN;if(_===null)throw Error("The current parser does not support an ATN with bypass alternatives.");if(this.bypassAltsAtnCache!==null)return this.bypassAltsAtnCache;let A={readOnly:!1,verifyATN:!0,generateRuleBypassTransitions:!0};return this.bypassAltsAtnCache=new n0(A).deserialize(_),this.bypassAltsAtnCache}get numberOfSyntaxErrors(){return this.syntaxErrors}get inputStream(){return this.#_}set inputStream(_){this.tokenStream=_}get tokenStream(){return this.#_}set tokenStream(_){this.reset(!1),this.#_=_}getCurrentToken(){return this.inputStream.LT(1)}notifyErrorListeners(_,A,R){if(A=A??null,R=R??null,A===null)A=this.getCurrentToken();this.syntaxErrors+=1;let{line:U,column:Y}=A;this.errorListenerDispatch.syntaxError(this,A,U,Y,_,R)}consume(){let _=this.getCurrentToken();if(_.type!==D.EOF)this.tokenStream.consume();let A=this.parseListeners!==null&&this.parseListeners.length>0;if(this.buildParseTrees||A){let R;if(this.errorHandler.inErrorRecoveryMode(this))R=this.context.addErrorNode(this.createErrorNode(this.context,_));else R=this.context.addTokenNode(_);if(A)this.parseListeners.forEach((U)=>{if(R instanceof n1)U.visitErrorNode(R);else U.visitTerminal(R)})}return _}addContextToParseTree(){if(this.context?.parent)this.context.parent.addChild(this.context)}enterRule(_,A,R){if(this.state=A,this.context=_,this.context.start=this.inputStream.LT(1),this.buildParseTrees)this.addContextToParseTree();this.triggerEnterRuleEvent()}exitRule(){if(this.matchedEOF)this.context.stop=this.inputStream.LT(1);else this.context.stop=this.inputStream.LT(-1);this.triggerExitRuleEvent(),this.state=this.context.invokingState,this.context=this.context.parent}enterOuterAlt(_,A){if(_.setAltNumber(A),this.buildParseTrees&&this.context!==_){if(this.context?.parent)this.context.parent.removeLastChild(),this.context.parent.addChild(_)}this.context=_}getPrecedence(){if(this.precedenceStack.length===0)return-1;return this.precedenceStack[this.precedenceStack.length-1]}enterRecursionRule(_,A,R,U){this.state=A,this.precedenceStack.push(U),this.context=_,this.context.start=this.inputStream.LT(1),this.triggerEnterRuleEvent()}pushNewRecursionContext(_,A,R){let U=this.context;if(U.parent=_,U.invokingState=A,U.stop=this.inputStream.LT(-1),this.context=_,this.context.start=U.start,this.buildParseTrees)this.context.addChild(U);this.triggerEnterRuleEvent()}unrollRecursionContexts(_){this.precedenceStack.pop(),this.context.stop=this.inputStream.LT(-1);let A=this.context,R=this.getParseListeners();if(R!==null&&R.length>0)while(this.context!==_)this.triggerExitRuleEvent(),this.context=this.context.parent;else this.context=_;if(A.parent=_,this.buildParseTrees&&_!==null)_.addChild(A)}getInvokingContext(_){let A=this.context;while(A!==null){if(A.ruleIndex===_)return A;A=A.parent}return null}precpred(_,A){return A>=this.precedenceStack[this.precedenceStack.length-1]}isExpectedToken(_){let A=this.interpreter.atn,R=this.context,U=A.states[this.state],Y=A.nextTokens(U);if(Y.contains(_))return!0;if(!Y.contains(D.EPSILON))return!1;while(R!==null&&R.invokingState>=0&&Y.contains(D.EPSILON)){let G=A.states[R.invokingState].transitions[0];if(Y=A.nextTokens(G.followState),Y.contains(_))return!0;R=R.parent}if(Y.contains(D.EPSILON)&&_===D.EOF)return!0;else return!1}getExpectedTokens(){return this.interpreter.atn.getExpectedTokens(this.state,this.context)}getExpectedTokensWithinCurrentRule(){let _=this.interpreter.atn,A=_.states[this.state];return _.nextTokens(A)}getRuleIndex(_){return this.getRuleIndexMap().get(_)??-1}getRuleInvocationStack(_){if(_=_??null,_===null)_=this.context;let A=[];while(_!==null){let R=_.ruleIndex;if(R<0)A.push("n/a");else A.push(this.ruleNames[R]);_=_.parent}return A}getDFAStrings(){return this.interpreter.decisionToDFA.toString()}dumpDFA(){let _=!1;for(let A of this.interpreter.decisionToDFA)if(A.length>0){if(_)console.log();if(this.printer)this.printer.println("Decision "+A.decision+":"),this.printer.print(A.toString(this.vocabulary));_=!0}}getSourceName(){return this.inputStream.getSourceName()}getParseInfo(){let _=this.interpreter;if(_ instanceof Z2)return new Z6(_);return}setProfile(_){let A=this.interpreter,R=A.predictionMode;if(_){if(!(A instanceof Z2))this.interpreter=new Z2(this)}else if(A instanceof Z2){let U=A.sharedContextCache;if(U){let Y=new o1(this,this.atn,A.decisionToDFA,U);this.interpreter=Y}}this.interpreter.predictionMode=R}setTrace(_){if(!_)this.removeParseListener(this.tracer),this.tracer=null;else{if(this.tracer!==null)this.removeParseListener(this.tracer);this.tracer=new j6(this),this.addParseListener(this.tracer)}}createTerminalNode(_,A){return new L0(A)}createErrorNode(_,A){return new n1(A)}},O6=class extends Y3{static{W(this,"ParserInterpreter")}rootContext;overrideDecisionRoot=null;parentContextStack=[];overrideDecisionAlt=-1;overrideDecisionReached=!1;decisionToDFA;sharedContextCache=new G1;pushRecursionContextStates;#_=-1;#A=-1;#U;#R;#Y;#X;constructor(_,A,R,U,Y){super(Y);this.#U=_,this.#R=U,this.#Y=R.slice(0),this.#X=A,this.pushRecursionContextStates=new j0;for(let X of U.states)if(X instanceof c0&&X.precedenceRuleDecision)this.pushRecursionContextStates.set(X.stateNumber);this.decisionToDFA=U.decisionToState.map((X,G)=>{return new S0(X,G)}),this.interpreter=new o1(this,U,this.decisionToDFA,this.sharedContextCache)}reset(){super.reset(),this.overrideDecisionReached=!1,this.overrideDecisionRoot=null}get atn(){return this.#R}get vocabulary(){return this.#X}get ruleNames(){return this.#Y}get grammarFileName(){return this.#U}get atnState(){return this.#R.states[this.state]}parse(_){let A=this.#R.ruleToStartState[_];if(this.rootContext=this.createInterpreterRuleContext(null,f.INVALID_STATE_NUMBER,_),A.isLeftRecursiveRule)this.enterRecursionRule(this.rootContext,A.stateNumber,_,0);else this.enterRule(this.rootContext,A.stateNumber,_);while(!0){let R=this.atnState;switch(R.constructor.stateType){case f.RULE_STOP:{if(this.context?.isEmpty())if(A.isLeftRecursiveRule){let U=this.context,Y=this.parentContextStack.pop();return this.unrollRecursionContexts(Y[0]),U}else return this.exitRule(),this.rootContext;this.visitRuleStopState(R);break}default:{try{this.visitState(R)}catch(U){if(U instanceof h)this.state=this.#R.ruleToStopState[R.ruleIndex].stateNumber,this.errorHandler.reportError(this,U),this.recover(U);else throw U}break}}}}addDecisionOverride(_,A,R){this.#_=_,this.#A=A,this.overrideDecisionAlt=R}get overrideDecision(){return this.#_}get overrideDecisionInputIndex(){return this.#A}enterRecursionRule(_,A,R,U){this.parentContextStack.push([this.context,_.invokingState]),super.enterRecursionRule(_,A,R,U)}get serializedATN(){throw Error("The ParserInterpreter does not support the serializedATN property.")}visitState(_){let A=1;if(_ instanceof Y1)A=this.visitDecisionState(_);let R=_.transitions[A-1];switch(R.transitionType){case j.EPSILON:if(this.pushRecursionContextStates.get(_.stateNumber)&&R.target.constructor.stateType!==f.LOOP_END){let J=this.parentContextStack[this.parentContextStack.length-1],F=this.createInterpreterRuleContext(J[0],J[1],this.context.ruleIndex);this.pushNewRecursionContext(F,this.#R.ruleToStartState[_.ruleIndex].stateNumber,this.context.ruleIndex)}break;case j.ATOM:this.match(R.label.minElement);break;case j.RANGE:case j.SET:case j.NOT_SET:if(!R.matches(this.inputStream.LA(1),D.MIN_USER_TOKEN_TYPE,65535))this.recoverInline();this.matchWildcard();break;case j.WILDCARD:this.matchWildcard();break;case j.RULE:let U=R.target,Y=U.ruleIndex,X=this.createInterpreterRuleContext(this.context,_.stateNumber,Y);if(U.isLeftRecursiveRule)this.enterRecursionRule(X,U.stateNumber,Y,R.precedence);else this.enterRule(X,R.target.stateNumber,Y);break;case j.PREDICATE:let G=R;if(!this.sempred(this.context,G.ruleIndex,G.predIndex))throw new p1(this);break;case j.ACTION:let Q=R;this.action(this.context,Q.ruleIndex,Q.actionIndex);break;case j.PRECEDENCE:if(!this.precpred(this.context,R.precedence)){let J=R.precedence;throw new p1(this,`precpred(_ctx, ${J})`)}break;default:throw Error("UnsupportedOperationException: Unrecognized ATN transition type.")}this.state=R.target.stateNumber}visitDecisionState(_){let A=1;if(_.transitions.length>1){this.errorHandler.sync(this);let R=_.decision;if(R===this.#_&&this.inputStream.index===this.#A&&!this.overrideDecisionReached)A=this.overrideDecisionAlt,this.overrideDecisionReached=!0;else A=this.interpreter.adaptivePredict(this.inputStream,R,this.context)}return A}createInterpreterRuleContext(_,A,R){return new C6(R,_,A)}visitRuleStopState(_){if(this.#R.ruleToStartState[_.ruleIndex].isLeftRecursiveRule){let[U,Y]=this.parentContextStack.pop();this.unrollRecursionContexts(U),this.state=Y}else this.exitRule();let R=this.#R.states[this.state].transitions[0];this.state=R.followState.stateNumber}recover(_){let A=this.inputStream.index;if(this.errorHandler.recover(this,_),this.inputStream.index===A){let R=_.offendingToken;if(!R)throw Error("Expected exception to have an offending token");let U=R.tokenSource,Y=U?.inputStream??null,X=[U,Y];if(_ instanceof s1){let G=_.getExpectedTokens();if(!G)throw Error("Expected the exception to provide expected tokens");let Q=D.INVALID_TYPE;if(G.length!==0)Q=G.minElement;let J=this.getTokenFactory().create(X,Q,R.text,D.DEFAULT_CHANNEL,-1,-1,R.line,R.column);this.context.addErrorNode(this.createErrorNode(this.context,J))}else{let G=this.getTokenFactory().create(X,D.INVALID_TYPE,R.text,D.DEFAULT_CHANNEL,-1,-1,R.line,R.column);this.context.addErrorNode(this.createErrorNode(this.context,G))}}}recoverInline(){return this.errorHandler.recoverInline(this)}},k4=class extends Map{static{W(this,"MultiMap")}map(_,A){let R=this.get(_);if(!R)R=[],this.set(_,R);R.push(A)}getPairs(){let _=[];for(let A of this.keys()){let R=this.get(A)??[];for(let U of R)_.push([A,U])}return _}toString(){let _=[];return this.forEach((A,R)=>{_.push(`${R}=[${A.join(", ")}]`)}),`{${_.join(", ")}}`}},M6=class extends Error{static{W(this,"CannotInvokeStartRuleError")}constructor(_){super();this.cause=_}},C4=class{static{W(this,"RuleTagToken")}label;ruleName;bypassTokenType;constructor(_,A,R){this.ruleName=_,this.bypassTokenType=A,this.label=R}get channel(){return D.DEFAULT_CHANNEL}get text(){if(this.label!==void 0)return"<"+this.label+":"+this.ruleName+">";return"<"+this.ruleName+">"}get type(){return this.bypassTokenType}get line(){return 0}get column(){return-1}get tokenIndex(){return-1}get start(){return-1}get stop(){return-1}get tokenSource(){return null}get inputStream(){return null}toString(){return this.ruleName+":"+this.bypassTokenType}},f6=class extends Error{static{W(this,"StartRuleDoesNotConsumeFullPatternError")}},j4=class extends g4{static{W(this,"TagChunk")}tag;label;constructor(..._){let A,R;if(_.length===1)R=_[0];else A=_[0],R=_[1];super();if(!R)throw Error("tag cannot be null or empty");this.label=A,this.tag=R}toString(){if(this.label!==void 0)return this.label+":"+this.tag;return this.tag}},K1=class extends g4{static{W(this,"TextChunk")}text;constructor(_){super();this.text=_}toString(){return"'"+this.text+"'"}},O4=class extends $2{static{W(this,"TokenTagToken")}tokenName;label;constructor(_,A,R){super({type:A,source:$2.EMPTY_SOURCE});this.tokenName=_,this.label=R}get text(){if(this.label!==void 0)return"<"+this.label+":"+this.tokenName+">";return"<"+this.tokenName+">"}toString(){return this.tokenName+":"+this.type}},h6=class{static{W(this,"ParseTreePatternMatcher")}start="<";stop=">";escape="\\";lexer;parser;constructor(_,A){this.lexer=_,this.parser=A}setDelimiters(_,A,R){if(_===null||_.length===0)throw Error("start cannot be null or empty");if(A===null||A.length===0)throw Error("stop cannot be null or empty");this.start=_,this.stop=A,this.escape=R}matches(..._){switch(_.length){case 2:{let[A,R]=_,U=new k4;return this.matchImpl(A,R.getPatternTree(),U)===null}case 3:{let[A,R,U]=_,Y=this.compile(R,U);return this.matches(A,Y)}default:throw Error("Invalid number of arguments")}}match(..._){switch(_.length){case 2:{let[A,R]=_,U=new k4,Y=this.matchImpl(A,R.getPatternTree(),U);return new D6(A,R,U,Y)}case 3:{let[A,R,U]=_,Y=this.compile(R,U);return this.match(A,Y)}default:throw Error("Invalid number of arguments")}}compile(_,A){let R=this.tokenize(_),U=new k6(R),Y=new q2(U),X=new O6(this.parser.grammarFileName,this.parser.vocabulary,this.parser.ruleNames,this.parser.getATNWithBypassAlts(),Y);X.removeErrorListeners();let G=null;try{X.errorHandler=new E6,G=X.parse(A)}catch(Q){if(Q instanceof r2)throw Q.cause;else if(Q instanceof h)throw Q;else if(Q instanceof Error)throw new M6(Q);else throw Q}if(Y.LA(1)!==D.EOF)throw new f6;return new B6(this,_,A,G)}getLexer(){return this.lexer}getParser(){return this.parser}tokenize(_){let A=this.split(_),R=[];for(let U of A)if(U instanceof j4){let Y=U,X=Y.tag[0];if(X===X.toUpperCase()){let G=this.parser.getTokenType(Y.tag);if(G===D.INVALID_TYPE)throw Error("Unknown token "+Y.tag+" in pattern: "+_);let Q=new O4(Y.tag,G,Y.label);R.push(Q)}else if(X===X.toLowerCase()){let G=this.parser.getRuleIndex(Y.tag);if(G===-1)throw Error("Unknown rule "+Y.tag+" in pattern: "+_);let Q=this.parser.getATNWithBypassAlts().ruleToTokenType[G];R.push(new C4(Y.tag,Q,Y.label))}else throw Error("invalid tag: "+Y.tag+" in pattern: "+_)}else{let Y=U,X=F0.fromString(Y.text);this.lexer.inputStream=X;let G=this.lexer.nextToken();while(G.type!==D.EOF)R.push(G),G=this.lexer.nextToken()}return R}split(_){let A=0,R=_.length,U=[],Y=[],X=[];while(A<R)if(A===_.indexOf(this.escape+this.start,A))A+=this.escape.length+this.start.length;else if(A===_.indexOf(this.escape+this.stop,A))A+=this.escape.length+this.stop.length;else if(A===_.indexOf(this.start,A))Y.push(A),A+=this.start.length;else if(A===_.indexOf(this.stop,A))X.push(A),A+=this.stop.length;else A++;if(Y.length>X.length)throw Error("unterminated tag in pattern: "+_);if(Y.length<X.length)throw Error("missing start tag in pattern: "+_);let G=Y.length;for(let Q=0;Q<G;Q++)if(Y[Q]>=X[Q])throw Error("tag delimiters out of order in pattern: "+_);if(G===0){let Q=_.substring(0,R);U.push(new K1(Q))}if(G>0&&Y[0]>0){let Q=_.substring(0,Y[0]);U.push(new K1(Q))}for(let Q=0;Q<G;Q++){let J=_.substring(Y[Q]+this.start.length,X[Q]),F=J,I,B=J.indexOf(":");if(B>=0)I=J.substring(0,B),F=J.substring(B+1,J.length);if(U.push(new j4(I,F)),Q+1<G){let C=_.substring(X[Q]+this.stop.length,Y[Q+1]);U.push(new K1(C))}}if(G>0){let Q=X[G-1]+this.stop.length;if(Q<R){let J=_.substring(Q,R);U.push(new K1(J))}}for(let Q=0;Q<U.length;Q++){let J=U[Q];if(J instanceof K1){let F=J,I=F.text.replaceAll(this.escape,"");if(I.length<F.text.length)U[Q]=new K1(I)}}return U}matchImpl(_,A,R){if(_ instanceof L0&&A instanceof L0){let U=_,Y=A,X;if(U.getSymbol().type===Y.getSymbol().type){if(Y.getSymbol()instanceof O4){let G=Y.getSymbol();if(R.map(G.tokenName,_),G.label!==void 0)R.map(G.label,_)}else if(U.getText()===Y.getText());else if(!X)X=U}else if(!X)X=U;return X}if(_ instanceof M&&A instanceof M){let U,Y=this.getRuleTagToken(A);if(Y){if(_.ruleIndex===A.ruleIndex){if(R.map(Y.ruleName,_),Y.label)R.map(Y.label,_)}else if(!U)U=_;return U}if(_.getChildCount()!==A.getChildCount()){if(!U)U=_;return U}let X=_.getChildCount();for(let G=0;G<X;G++){let Q=this.matchImpl(_.getChild(G),A.getChild(G),R);if(Q)return Q}return U}return _}getRuleTagToken(_){if(_ instanceof M){if(_.getChildCount()===1&&_.getChild(0)instanceof L0){let A=_.getChild(0);if(A.getSymbol()instanceof C4)return A.getSymbol()}}return}},m7=class extends W2{static{W(this,"DiagnosticErrorListener")}exactOnly;constructor(_){super();this.exactOnly=_??!0}reportAmbiguity=W((_,A,R,U,Y,X,G)=>{if(this.exactOnly&&!Y)return;let Q=this.getDecisionDescription(_,A),J=this.getConflictingAlts(X,G),F=_.tokenStream?.getTextFromInterval(b.of(R,U)),I=`reportAmbiguity d=${Q}: ambigAlts=${J}, input='${F}'`;_.notifyErrorListeners(I,null,null)},"reportAmbiguity");reportAttemptingFullContext=W((_,A,R,U,Y,X)=>{let G=this.getDecisionDescription(_,A),Q=_.tokenStream?.getTextFromInterval(b.of(R,U)),J=`reportAttemptingFullContext d=${G}, input='${Q}'`;_.notifyErrorListeners(J,null,null)},"reportAttemptingFullContext");reportContextSensitivity=W((_,A,R,U,Y,X)=>{let G=this.getDecisionDescription(_,A),Q=_.tokenStream?.getTextFromInterval(b.of(R,U)),J=`reportContextSensitivity d=${G}, input='${Q}'`;_.notifyErrorListeners(J,null,null)},"reportContextSensitivity");getDecisionDescription=W((_,A)=>{let R=A.decision,U=A.atnStartState.ruleIndex,Y=_.ruleNames;if(U<0||U>=Y.length)return R.toString();let X=Y[U];if(X.length===0)return R.toString();return`${R} (${X})`},"getDecisionDescription");getConflictingAlts=W((_,A)=>{if(_)return _;let R=new j0;for(let U=0;U<A.configs.length;U++)R.set(A.configs[U].alt);return R},"getConflictingAlts")},g7=class extends O0{static{W(this,"LexerInterpreter")}decisionToDFA;sharedContextCache=new G1;#_;#A;#U;#R;#Y;#X;constructor(_,A,R,U,Y,X,G){super(G);if(X.grammarType!==P.LEXER)throw Error("IllegalArgumentException: The ATN must be a lexer ATN.");this.#_=_,this.#A=X,this.#U=R.slice(0),this.#R=U.slice(0),this.#Y=Y.slice(0),this.#X=A,this.decisionToDFA=X.decisionToState.map((Q,J)=>{return new S0(Q,J)}),this.interpreter=new E1(this,X,this.decisionToDFA,this.sharedContextCache)}get atn(){return this.#A}get grammarFileName(){return this.#_}get ruleNames(){return this.#U}get channelNames(){return this.#R}get modeNames(){return this.#Y}get vocabulary(){return this.#X}get serializedATN(){throw Error("The LexerInterpreter does not support the serializedATN property.")}},d7=class _{static{W(this,"RuntimeMetaData")}static VERSION="4.13.1";static getRuntimeVersion(){return _.VERSION}static checkVersion(A,R){let U=_.VERSION,Y=!1,X=!1;if(Y=U!==A&&_.getMajorMinorVersion(U)!==_.getMajorMinorVersion(A),X=U!==R&&_.getMajorMinorVersion(U)!==_.getMajorMinorVersion(R),Y)console.error(`ANTLR Tool version ${A} used for code generation does not match the current runtime version ${U}`);if(X)console.error(`ANTLR Runtime version ${R} used for parser compilation does not match the current runtime version ${U}`)}static getMajorMinorVersion(A){let R=A.indexOf("."),U=R>=0?A.indexOf(".",R+1):-1,Y=A.indexOf("-"),X=A.length;if(U>=0)X=Math.min(X,U);if(Y>=0)X=Math.min(X,Y);return A.substring(0,X)}},l7=class _{static{W(this,"TokenStreamRewriter")}static DEFAULT_PROGRAM_NAME="default";static PROGRAM_INIT_SIZE=100;static MIN_TOKEN_INDEX=0;tokens;programs=new Map;lastRewriteTokenIndexes;constructor(A){this.tokens=A}getTokenStream(){return this.tokens}insertAfter(A,R,U=_.DEFAULT_PROGRAM_NAME){let Y;if(typeof A==="number")Y=A;else Y=A.tokenIndex;let X=this.getProgram(U),G=new M4(this.tokens,Y,X.length,R);X.push(G)}insertBefore(A,R,U=_.DEFAULT_PROGRAM_NAME){let Y;if(typeof A==="number")Y=A;else Y=A.tokenIndex;let X=this.getProgram(U),G=new L1(this.tokens,Y,X.length,R);X.push(G)}replaceSingle(A,R,U=_.DEFAULT_PROGRAM_NAME){this.replace(A,A,R,U)}replace(A,R,U,Y=_.DEFAULT_PROGRAM_NAME){if(typeof A!=="number")A=A.tokenIndex;if(typeof R!=="number")R=R.tokenIndex;if(A>R||A<0||R<0||R>=this.tokens.size)throw RangeError(`replace: range invalid: ${A}..${R}(size=${this.tokens.size})`);let X=this.getProgram(Y),G=new J2(this.tokens,A,R,X.length,U);X.push(G)}delete(A,R,U=_.DEFAULT_PROGRAM_NAME){if(R==null)R=A;this.replace(A,R,null,U)}getProgram(A){let R=this.programs.get(A);if(R==null)R=this.initializeProgram(A);return R}initializeProgram(A){let R=[];return this.programs.set(A,R),R}getText(A,R=_.DEFAULT_PROGRAM_NAME){let U;if(A instanceof b)U=A;else U=new b(0,this.tokens.size-1);if(typeof A==="string")R=A;let Y=this.programs.get(R),X=U.start,G=U.stop;if(G>this.tokens.size-1)G=this.tokens.size-1;if(X<0)X=0;if(Y==null||Y.length===0)return this.tokens.getTextFromInterval(new b(X,G));let Q=[],J=this.reduceToSingleOperationPerIndex(Y),F=X;while(F<=G&&F<this.tokens.size){let I=J.get(F);J.delete(F);let B=this.tokens.get(F);if(I==null){if(B.type!==D.EOF)Q.push(String(B.text));F++}else F=I.execute(Q)}if(G===this.tokens.size-1){for(let I of J.values())if(I&&I.index>=this.tokens.size-1)Q.push(String(I.text))}return Q.join("")}reduceToSingleOperationPerIndex(A){for(let U=0;U<A.length;U++){let Y=A[U];if(Y==null)continue;if(!(Y instanceof J2))continue;let X=Y,G=this.getKindOfOps(A,L1,U);for(let J of G)if(J.index===X.index)A[J.instructionIndex]=null,X.text=String(J.text)+(X.text!=null?X.text.toString():"");else if(J.index>X.index&&J.index<=X.lastIndex)A[J.instructionIndex]=null;let Q=this.getKindOfOps(A,J2,U);for(let J of Q){if(J.index>=X.index&&J.lastIndex<=X.lastIndex){A[J.instructionIndex]=null;continue}let F=J.lastIndex<X.index||J.index>X.lastIndex;if(J.text==null&&X.text==null&&!F)A[J.instructionIndex]=null,X.index=Math.min(J.index,X.index),X.lastIndex=Math.max(J.lastIndex,X.lastIndex);else if(!F)throw Error(`replace op boundaries of ${X} overlap with previous ${J}`)}}for(let U=0;U<A.length;U++){let Y=A[U];if(Y==null)continue;if(!(Y instanceof L1))continue;let X=Y,G=this.getKindOfOps(A,L1,U);for(let J of G)if(J.index===X.index){if(J instanceof M4)X.text=this.catOpText(J.text,X.text),A[J.instructionIndex]=null;else if(J instanceof L1)X.text=this.catOpText(X.text,J.text),A[J.instructionIndex]=null}let Q=this.getKindOfOps(A,J2,U);for(let J of Q){if(X.index===J.index){J.text=this.catOpText(X.text,J.text),A[U]=null;continue}if(X.index>=J.index&&X.index<=J.lastIndex)throw Error(`insert op ${X} within boundaries of previous ${J}`)}}let R=new Map;for(let U of A){if(U==null)continue;if(R.get(U.index)!=null)throw Error("should only be one op per index");R.set(U.index,U)}return R}catOpText(A,R){let U="",Y="";if(A!=null)U=A.toString();if(R!=null)Y=R.toString();return U+Y}getKindOfOps(A,R,U){return A.slice(0,U).filter((Y)=>{return Y&&Y instanceof R})}},l4=class{static{W(this,"RewriteOperation")}instructionIndex;index;text;tokens;constructor(_,A,R,U){this.tokens=_,this.instructionIndex=R,this.index=A,this.text=U===void 0?"":U}execute(_){return this.index}toString(){return"<RewriteOperation@"+this.tokens.get(this.index)+':"'+this.text+'">'}},L1=class extends l4{static{W(this,"InsertBeforeOp")}constructor(_,A,R,U){super(_,A,R,U)}execute(_){if(this.text)_.push(this.text.toString());if(this.tokens.get(this.index).type!==D.EOF)_.push(String(this.tokens.get(this.index).text));return this.index+1}toString(){return"<InsertBeforeOp@"+this.tokens.get(this.index)+':"'+this.text+'">'}},M4=class extends L1{static{W(this,"InsertAfterOp")}constructor(_,A,R,U){super(_,A+1,R,U)}toString(){return"<InsertAfterOp@"+this.tokens.get(this.index)+':"'+this.text+'">'}},J2=class extends l4{static{W(this,"ReplaceOp")}lastIndex;constructor(_,A,R,U,Y){super(_,A,U,Y);this.lastIndex=R}execute(_){if(this.text)_.push(this.text.toString());return this.lastIndex+1}toString(){if(this.text==null)return"<DeleteOp@"+this.tokens.get(this.index)+".."+this.tokens.get(this.lastIndex)+">";return"<ReplaceOp@"+this.tokens.get(this.index)+".."+this.tokens.get(this.lastIndex)+':"'+this.text+'">'}},T7=class{static{W(this,"UnbufferedTokenStream")}tokenSource;tokens;n;p=0;numMarkers=0;lastToken;lastTokenBufferStart;currentTokenIndex=0;constructor(_,A){this.tokenSource=_,A=A??256,this.tokens=Array(A),this.n=0,this.fill(1)}get(_){let A=this.getBufferStartIndex();if(_<A||_>=A+this.n)throw Error("get("+_+") outside buffer: "+A+".."+(A+this.n));return this.tokens[_-A]}LT(_){if(_===-1)return this.lastToken;this.sync(_);let A=this.p+_-1;if(A<0)throw Error("LT("+_+") gives negative index");if(A>=this.n)return this.tokens[this.n-1];return this.tokens[A]}LA(_){return this.LT(_).type}getText(){return""}getTextFromContext(_){return this.getTextFromInterval(_.getSourceInterval())}getTextFromInterval(_){let A=this.getBufferStartIndex(),R=A+this.tokens.length-1,U=_.start,Y=_.stop;if(U<A||Y>R)throw Error("interval "+_+" not in token buffer window: "+A+".."+R);let X=U-A,G=Y-A,Q="";for(let J=X;J<=G;J++){let F=this.tokens[J];Q+=F.text}return Q}getTextFromRange(_,A){return this.getTextFromInterval(b.of(_.tokenIndex,A.tokenIndex))}consume(){if(this.LA(1)===D.EOF)throw Error("cannot consume EOF");if(this.lastToken=this.tokens[this.p],this.p===this.n-1&&this.numMarkers===0)this.n=0,this.p=-1,this.lastTokenBufferStart=this.lastToken;this.p++,this.currentTokenIndex++,this.sync(1)}mark(){if(this.numMarkers===0)this.lastTokenBufferStart=this.lastToken;let _=-this.numMarkers-1;return this.numMarkers++,_}release(_){let A=-this.numMarkers;if(_!==A)throw Error("release() called with an invalid marker.");if(this.numMarkers--,this.numMarkers===0){if(this.p>0)this.tokens.copyWithin(0,this.p,this.n),this.n=this.n-this.p,this.p=0;this.lastTokenBufferStart=this.lastToken}}get index(){return this.currentTokenIndex}seek(_){if(_===this.currentTokenIndex)return;if(_>this.currentTokenIndex)this.sync(_-this.currentTokenIndex),_=Math.min(_,this.getBufferStartIndex()+this.n-1);let A=this.getBufferStartIndex(),R=_-A;if(R<0)throw Error("cannot seek to negative index "+_);else if(R>=this.n)throw Error("seek to index outside buffer: "+_+" not in "+A+".."+(A+this.n));if(this.p=R,this.currentTokenIndex=_,this.p===0)this.lastToken=this.lastTokenBufferStart;else this.lastToken=this.tokens[this.p-1]}get size(){throw Error("Unbuffered stream cannot know its size")}getSourceName(){return this.tokenSource.sourceName}setLine(_){this.tokenSource.line=_}setColumn(_){this.tokenSource.column=_}sync(_){let A=this.p+_-1-this.n+1;if(A>0)this.fill(A)}fill(_){for(let A=0;A<_;A++){if(this.n>0&&this.tokens[this.n-1].type===D.EOF)return A;let R=this.tokenSource.nextToken();this.add(R)}return _}add(_){if(this.n>=this.tokens.length)this.tokens.length=this.tokens.length*2;if(m4(_))_.setTokenIndex(this.getBufferStartIndex()+this.n);this.tokens[this.n++]=_}getBufferStartIndex(){return this.currentTokenIndex-this.p}};class T extends O0{static LPAREN=1;static RPAREN=2;static COLON=3;static SEMICOLON=4;static COMMA=5;static LBRACK=6;static RBRACK=7;static LBRACE=8;static RBRACE=9;static PLUS=10;static MINUS=11;static MUL=12;static DIV=13;static DOTMOD=14;static MOD=15;static AND=16;static OR=17;static EQ=18;static EXCL=19;static DOLLAR=20;static CARET=21;static TILDE=22;static AT=23;static GT=24;static GTE=25;static LT=26;static LTE=27;static IF=28;static ELSE=29;static WHILE=30;static CASE=31;static DEFAULT=32;static RETURN=33;static CALC=34;static TYPE_ARRAY=35;static DEF_TYPE=36;static SWITCH_TYPE=37;static INTEGER_LITERAL=38;static HEX_LITERAL=39;static COORD_LITERAL=40;static MAPZONE_LITERAL=41;static BOOLEAN_LITERAL=42;static CHAR_LITERAL=43;static NULL_LITERAL=44;static LINE_COMMENT=45;static BLOCK_COMMENT=46;static QUOTE_OPEN=47;static IDENTIFIER=48;static WHITESPACE=49;static QUOTE_CLOSE=50;static STRING_TEXT=51;static STRING_TAG=52;static STRING_CLOSE_TAG=53;static STRING_PARTIAL_TAG=54;static STRING_P_TAG=55;static STRING_EXPR_START=56;static STRING_EXPR_END=57;static String=1;static channelNames=["DEFAULT_TOKEN_CHANNEL","HIDDEN"];static literalNames=[null,"'('","')'","':'","';'","','","'['","']'","'{'","'}'","'+'","'-'","'*'","'/'","'.%'","'%'","'&'","'|'","'='","'!'","'$'","'^'","'~'","'@'",null,"'>='",null,"'<='","'if'","'else'","'while'","'case'","'default'","'return'","'calc'",null,null,null,null,null,null,null,null,null,"'null'"];static symbolicNames=[null,"LPAREN","RPAREN","COLON","SEMICOLON","COMMA","LBRACK","RBRACK","LBRACE","RBRACE","PLUS","MINUS","MUL","DIV","DOTMOD","MOD","AND","OR","EQ","EXCL","DOLLAR","CARET","TILDE","AT","GT","GTE","LT","LTE","IF","ELSE","WHILE","CASE","DEFAULT","RETURN","CALC","TYPE_ARRAY","DEF_TYPE","SWITCH_TYPE","INTEGER_LITERAL","HEX_LITERAL","COORD_LITERAL","MAPZONE_LITERAL","BOOLEAN_LITERAL","CHAR_LITERAL","NULL_LITERAL","LINE_COMMENT","BLOCK_COMMENT","QUOTE_OPEN","IDENTIFIER","WHITESPACE","QUOTE_CLOSE","STRING_TEXT","STRING_TAG","STRING_CLOSE_TAG","STRING_PARTIAL_TAG","STRING_P_TAG","STRING_EXPR_START","STRING_EXPR_END"];static modeNames=["DEFAULT_MODE","String"];static ruleNames=["LPAREN","RPAREN","COLON","SEMICOLON","COMMA","LBRACK","RBRACK","LBRACE","RBRACE","PLUS","MINUS","MUL","DIV","DOTMOD","MOD","AND","OR","EQ","EXCL","DOLLAR","CARET","TILDE","AT","GT","GTE","LT","LTE","IF","ELSE","WHILE","CASE","DEFAULT","RETURN","CALC","TYPE_ARRAY","DEF_TYPE","SWITCH_TYPE","INTEGER_LITERAL","HEX_LITERAL","COORD_LITERAL","MAPZONE_LITERAL","BOOLEAN_LITERAL","CHAR_LITERAL","NULL_LITERAL","LINE_COMMENT","BLOCK_COMMENT","Digit","CharEscapeSequence","QUOTE_OPEN","IDENTIFIER","WHITESPACE","QUOTE_CLOSE","STRING_TEXT","STRING_TAG","STRING_CLOSE_TAG","STRING_PARTIAL_TAG","STRING_P_TAG","STRING_EXPR_START","STRING_EXPR_END","StringEscapeSequence","Tag"];depth=0;constructor(_){super(_);this.interpreter=new E1(this,T._ATN,T.decisionsToDFA,new G1)}get grammarFileName(){return"RuneScriptLexer.g4"}get literalNames(){return T.literalNames}get symbolicNames(){return T.symbolicNames}get ruleNames(){return T.ruleNames}get serializedATN(){return T._serializedATN}get channelNames(){return T.channelNames}get modeNames(){return T.modeNames}action(_,A,R){switch(A){case 23:this.GT_action(_,R);break;case 48:this.QUOTE_OPEN_action(_,R);break;case 51:this.QUOTE_CLOSE_action(_,R);break}}GT_action(_,A){switch(A){case 0:if(this.depth>0)this.type=T.STRING_EXPR_END,this.popMode();break}}QUOTE_OPEN_action(_,A){switch(A){case 1:this.depth++;break}}QUOTE_CLOSE_action(_,A){switch(A){case 2:this.depth--;break}}static _serializedATN=[4,0,57,456,6,-1,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,45,2,46,7,46,2,47,7,47,2,48,7,48,2,49,7,49,2,50,7,50,2,51,7,51,2,52,7,52,2,53,7,53,2,54,7,54,2,55,7,55,2,56,7,56,2,57,7,57,2,58,7,58,2,59,7,59,2,60,7,60,1,0,1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,4,1,4,1,5,1,5,1,6,1,6,1,7,1,7,1,8,1,8,1,9,1,9,1,10,1,10,1,11,1,11,1,12,1,12,1,13,1,13,1,13,1,14,1,14,1,15,1,15,1,16,1,16,1,17,1,17,1,18,1,18,1,19,1,19,1,20,1,20,1,21,1,21,1,22,1,22,1,23,1,23,1,23,1,24,1,24,1,24,1,25,1,25,1,26,1,26,1,26,1,27,1,27,1,27,1,28,1,28,1,28,1,28,1,28,1,29,1,29,1,29,1,29,1,29,1,29,1,30,1,30,1,30,1,30,1,30,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,33,1,33,1,33,1,33,1,33,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,35,1,35,1,35,1,35,1,35,1,35,1,35,1,36,1,36,1,36,1,36,1,36,1,36,1,36,1,36,1,36,1,36,1,37,3,37,247,8,37,1,37,4,37,250,8,37,11,37,12,37,251,1,38,1,38,1,38,4,38,257,8,38,11,38,12,38,258,1,39,4,39,262,8,39,11,39,12,39,263,1,39,1,39,4,39,268,8,39,11,39,12,39,269,1,39,1,39,4,39,274,8,39,11,39,12,39,275,1,39,1,39,4,39,280,8,39,11,39,12,39,281,1,39,1,39,4,39,286,8,39,11,39,12,39,287,1,40,4,40,291,8,40,11,40,12,40,292,1,40,1,40,4,40,297,8,40,11,40,12,40,298,1,40,1,40,4,40,303,8,40,11,40,12,40,304,1,41,1,41,1,41,1,41,1,41,1,41,1,41,1,41,1,41,3,41,316,8,41,1,42,1,42,1,42,3,42,321,8,42,1,42,1,42,1,43,1,43,1,43,1,43,1,43,1,44,1,44,1,44,1,44,5,44,334,8,44,10,44,12,44,337,9,44,1,44,3,44,340,8,44,1,44,1,44,1,45,1,45,1,45,1,45,5,45,348,8,45,10,45,12,45,351,9,45,1,45,1,45,1,45,1,45,1,45,1,46,1,46,1,47,1,47,1,47,1,48,1,48,1,48,1,48,1,48,1,49,4,49,369,8,49,11,49,12,49,370,1,50,4,50,374,8,50,11,50,12,50,375,1,50,1,50,1,51,1,51,1,51,1,51,1,51,1,52,1,52,4,52,387,8,52,11,52,12,52,388,3,52,391,8,52,1,53,1,53,1,53,1,53,4,53,397,8,53,11,53,12,53,398,3,53,401,8,53,1,53,1,53,1,54,1,54,1,54,1,54,1,54,1,54,1,55,1,55,1,55,1,55,1,56,1,56,1,56,1,56,1,56,4,56,420,8,56,11,56,12,56,421,1,56,1,56,1,57,1,57,1,57,1,57,1,58,1,58,1,59,1,59,1,59,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,3,60,455,8,60,2,335,349,0,61,2,1,4,2,6,3,8,4,10,5,12,6,14,7,16,8,18,9,20,10,22,11,24,12,26,13,28,14,30,15,32,16,34,17,36,18,38,19,40,20,42,21,44,22,46,23,48,24,50,25,52,26,54,27,56,28,58,29,60,30,62,31,64,32,66,33,68,34,70,35,72,36,74,37,76,38,78,39,80,40,82,41,84,42,86,43,88,44,90,45,92,46,94,0,96,0,98,47,100,48,102,49,104,50,106,51,108,52,110,53,112,54,114,55,116,56,118,57,120,0,122,0,2,0,1,11,2,0,88,88,120,120,3,0,48,57,65,70,97,102,4,0,10,10,13,13,39,39,92,92,1,1,10,10,1,0,48,57,2,0,39,39,92,92,6,0,43,43,46,46,48,58,65,90,95,95,97,122,3,0,9,10,13,13,32,32,5,0,10,10,13,13,34,34,60,60,92,92,2,0,60,60,62,62,3,0,34,34,60,60,92,92,479,0,2,1,0,0,0,0,4,1,0,0,0,0,6,1,0,0,0,0,8,1,0,0,0,0,10,1,0,0,0,0,12,1,0,0,0,0,14,1,0,0,0,0,16,1,0,0,0,0,18,1,0,0,0,0,20,1,0,0,0,0,22,1,0,0,0,0,24,1,0,0,0,0,26,1,0,0,0,0,28,1,0,0,0,0,30,1,0,0,0,0,32,1,0,0,0,0,34,1,0,0,0,0,36,1,0,0,0,0,38,1,0,0,0,0,40,1,0,0,0,0,42,1,0,0,0,0,44,1,0,0,0,0,46,1,0,0,0,0,48,1,0,0,0,0,50,1,0,0,0,0,52,1,0,0,0,0,54,1,0,0,0,0,56,1,0,0,0,0,58,1,0,0,0,0,60,1,0,0,0,0,62,1,0,0,0,0,64,1,0,0,0,0,66,1,0,0,0,0,68,1,0,0,0,0,70,1,0,0,0,0,72,1,0,0,0,0,74,1,0,0,0,0,76,1,0,0,0,0,78,1,0,0,0,0,80,1,0,0,0,0,82,1,0,0,0,0,84,1,0,0,0,0,86,1,0,0,0,0,88,1,0,0,0,0,90,1,0,0,0,0,92,1,0,0,0,0,98,1,0,0,0,0,100,1,0,0,0,0,102,1,0,0,0,1,104,1,0,0,0,1,106,1,0,0,0,1,108,1,0,0,0,1,110,1,0,0,0,1,112,1,0,0,0,1,114,1,0,0,0,1,116,1,0,0,0,1,118,1,0,0,0,2,124,1,0,0,0,4,126,1,0,0,0,6,128,1,0,0,0,8,130,1,0,0,0,10,132,1,0,0,0,12,134,1,0,0,0,14,136,1,0,0,0,16,138,1,0,0,0,18,140,1,0,0,0,20,142,1,0,0,0,22,144,1,0,0,0,24,146,1,0,0,0,26,148,1,0,0,0,28,150,1,0,0,0,30,153,1,0,0,0,32,155,1,0,0,0,34,157,1,0,0,0,36,159,1,0,0,0,38,161,1,0,0,0,40,163,1,0,0,0,42,165,1,0,0,0,44,167,1,0,0,0,46,169,1,0,0,0,48,171,1,0,0,0,50,174,1,0,0,0,52,177,1,0,0,0,54,179,1,0,0,0,56,182,1,0,0,0,58,185,1,0,0,0,60,190,1,0,0,0,62,196,1,0,0,0,64,201,1,0,0,0,66,209,1,0,0,0,68,216,1,0,0,0,70,221,1,0,0,0,72,228,1,0,0,0,74,235,1,0,0,0,76,246,1,0,0,0,78,253,1,0,0,0,80,261,1,0,0,0,82,290,1,0,0,0,84,315,1,0,0,0,86,317,1,0,0,0,88,324,1,0,0,0,90,329,1,0,0,0,92,343,1,0,0,0,94,357,1,0,0,0,96,359,1,0,0,0,98,362,1,0,0,0,100,368,1,0,0,0,102,373,1,0,0,0,104,379,1,0,0,0,106,390,1,0,0,0,108,392,1,0,0,0,110,404,1,0,0,0,112,410,1,0,0,0,114,414,1,0,0,0,116,425,1,0,0,0,118,429,1,0,0,0,120,431,1,0,0,0,122,454,1,0,0,0,124,125,5,40,0,0,125,3,1,0,0,0,126,127,5,41,0,0,127,5,1,0,0,0,128,129,5,58,0,0,129,7,1,0,0,0,130,131,5,59,0,0,131,9,1,0,0,0,132,133,5,44,0,0,133,11,1,0,0,0,134,135,5,91,0,0,135,13,1,0,0,0,136,137,5,93,0,0,137,15,1,0,0,0,138,139,5,123,0,0,139,17,1,0,0,0,140,141,5,125,0,0,141,19,1,0,0,0,142,143,5,43,0,0,143,21,1,0,0,0,144,145,5,45,0,0,145,23,1,0,0,0,146,147,5,42,0,0,147,25,1,0,0,0,148,149,5,47,0,0,149,27,1,0,0,0,150,151,5,46,0,0,151,152,5,37,0,0,152,29,1,0,0,0,153,154,5,37,0,0,154,31,1,0,0,0,155,156,5,38,0,0,156,33,1,0,0,0,157,158,5,124,0,0,158,35,1,0,0,0,159,160,5,61,0,0,160,37,1,0,0,0,161,162,5,33,0,0,162,39,1,0,0,0,163,164,5,36,0,0,164,41,1,0,0,0,165,166,5,94,0,0,166,43,1,0,0,0,167,168,5,126,0,0,168,45,1,0,0,0,169,170,5,64,0,0,170,47,1,0,0,0,171,172,5,62,0,0,172,173,6,23,0,0,173,49,1,0,0,0,174,175,5,62,0,0,175,176,5,61,0,0,176,51,1,0,0,0,177,178,5,60,0,0,178,53,1,0,0,0,179,180,5,60,0,0,180,181,5,61,0,0,181,55,1,0,0,0,182,183,5,105,0,0,183,184,5,102,0,0,184,57,1,0,0,0,185,186,5,101,0,0,186,187,5,108,0,0,187,188,5,115,0,0,188,189,5,101,0,0,189,59,1,0,0,0,190,191,5,119,0,0,191,192,5,104,0,0,192,193,5,105,0,0,193,194,5,108,0,0,194,195,5,101,0,0,195,61,1,0,0,0,196,197,5,99,0,0,197,198,5,97,0,0,198,199,5,115,0,0,199,200,5,101,0,0,200,63,1,0,0,0,201,202,5,100,0,0,202,203,5,101,0,0,203,204,5,102,0,0,204,205,5,97,0,0,205,206,5,117,0,0,206,207,5,108,0,0,207,208,5,116,0,0,208,65,1,0,0,0,209,210,5,114,0,0,210,211,5,101,0,0,211,212,5,116,0,0,212,213,5,117,0,0,213,214,5,114,0,0,214,215,5,110,0,0,215,67,1,0,0,0,216,217,5,99,0,0,217,218,5,97,0,0,218,219,5,108,0,0,219,220,5,99,0,0,220,69,1,0,0,0,221,222,3,100,49,0,222,223,5,97,0,0,223,224,5,114,0,0,224,225,5,114,0,0,225,226,5,97,0,0,226,227,5,121,0,0,227,71,1,0,0,0,228,229,5,100,0,0,229,230,5,101,0,0,230,231,5,102,0,0,231,232,5,95,0,0,232,233,1,0,0,0,233,234,3,100,49,0,234,73,1,0,0,0,235,236,5,115,0,0,236,237,5,119,0,0,237,238,5,105,0,0,238,239,5,116,0,0,239,240,5,99,0,0,240,241,5,104,0,0,241,242,5,95,0,0,242,243,1,0,0,0,243,244,3,100,49,0,244,75,1,0,0,0,245,247,5,45,0,0,246,245,1,0,0,0,246,247,1,0,0,0,247,249,1,0,0,0,248,250,3,94,46,0,249,248,1,0,0,0,250,251,1,0,0,0,251,249,1,0,0,0,251,252,1,0,0,0,252,77,1,0,0,0,253,254,5,48,0,0,254,256,7,0,0,0,255,257,7,1,0,0,256,255,1,0,0,0,257,258,1,0,0,0,258,256,1,0,0,0,258,259,1,0,0,0,259,79,1,0,0,0,260,262,3,94,46,0,261,260,1,0,0,0,262,263,1,0,0,0,263,261,1,0,0,0,263,264,1,0,0,0,264,265,1,0,0,0,265,267,5,95,0,0,266,268,3,94,46,0,267,266,1,0,0,0,268,269,1,0,0,0,269,267,1,0,0,0,269,270,1,0,0,0,270,271,1,0,0,0,271,273,5,95,0,0,272,274,3,94,46,0,273,272,1,0,0,0,274,275,1,0,0,0,275,273,1,0,0,0,275,276,1,0,0,0,276,277,1,0,0,0,277,279,5,95,0,0,278,280,3,94,46,0,279,278,1,0,0,0,280,281,1,0,0,0,281,279,1,0,0,0,281,282,1,0,0,0,282,283,1,0,0,0,283,285,5,95,0,0,284,286,3,94,46,0,285,284,1,0,0,0,286,287,1,0,0,0,287,285,1,0,0,0,287,288,1,0,0,0,288,81,1,0,0,0,289,291,3,94,46,0,290,289,1,0,0,0,291,292,1,0,0,0,292,290,1,0,0,0,292,293,1,0,0,0,293,294,1,0,0,0,294,296,5,95,0,0,295,297,3,94,46,0,296,295,1,0,0,0,297,298,1,0,0,0,298,296,1,0,0,0,298,299,1,0,0,0,299,300,1,0,0,0,300,302,5,95,0,0,301,303,3,94,46,0,302,301,1,0,0,0,303,304,1,0,0,0,304,302,1,0,0,0,304,305,1,0,0,0,305,83,1,0,0,0,306,307,5,116,0,0,307,308,5,114,0,0,308,309,5,117,0,0,309,316,5,101,0,0,310,311,5,102,0,0,311,312,5,97,0,0,312,313,5,108,0,0,313,314,5,115,0,0,314,316,5,101,0,0,315,306,1,0,0,0,315,310,1,0,0,0,316,85,1,0,0,0,317,320,5,39,0,0,318,321,3,96,47,0,319,321,8,2,0,0,320,318,1,0,0,0,320,319,1,0,0,0,321,322,1,0,0,0,322,323,5,39,0,0,323,87,1,0,0,0,324,325,5,110,0,0,325,326,5,117,0,0,326,327,5,108,0,0,327,328,5,108,0,0,328,89,1,0,0,0,329,330,5,47,0,0,330,331,5,47,0,0,331,335,1,0,0,0,332,334,9,0,0,0,333,332,1,0,0,0,334,337,1,0,0,0,335,336,1,0,0,0,335,333,1,0,0,0,336,339,1,0,0,0,337,335,1,0,0,0,338,340,7,3,0,0,339,338,1,0,0,0,340,341,1,0,0,0,341,342,6,44,1,0,342,91,1,0,0,0,343,344,5,47,0,0,344,345,5,42,0,0,345,349,1,0,0,0,346,348,9,0,0,0,347,346,1,0,0,0,348,351,1,0,0,0,349,350,1,0,0,0,349,347,1,0,0,0,350,352,1,0,0,0,351,349,1,0,0,0,352,353,5,42,0,0,353,354,5,47,0,0,354,355,1,0,0,0,355,356,6,45,1,0,356,93,1,0,0,0,357,358,7,4,0,0,358,95,1,0,0,0,359,360,5,92,0,0,360,361,7,5,0,0,361,97,1,0,0,0,362,363,5,34,0,0,363,364,6,48,2,0,364,365,1,0,0,0,365,366,6,48,3,0,366,99,1,0,0,0,367,369,7,6,0,0,368,367,1,0,0,0,369,370,1,0,0,0,370,368,1,0,0,0,370,371,1,0,0,0,371,101,1,0,0,0,372,374,7,7,0,0,373,372,1,0,0,0,374,375,1,0,0,0,375,373,1,0,0,0,375,376,1,0,0,0,376,377,1,0,0,0,377,378,6,50,1,0,378,103,1,0,0,0,379,380,5,34,0,0,380,381,6,51,4,0,381,382,1,0,0,0,382,383,6,51,5,0,383,105,1,0,0,0,384,391,3,120,59,0,385,387,8,8,0,0,386,385,1,0,0,0,387,388,1,0,0,0,388,386,1,0,0,0,388,389,1,0,0,0,389,391,1,0,0,0,390,384,1,0,0,0,390,386,1,0,0,0,391,107,1,0,0,0,392,393,5,60,0,0,393,400,3,122,60,0,394,396,5,61,0,0,395,397,8,9,0,0,396,395,1,0,0,0,397,398,1,0,0,0,398,396,1,0,0,0,398,399,1,0,0,0,399,401,1,0,0,0,400,394,1,0,0,0,400,401,1,0,0,0,401,402,1,0,0,0,402,403,5,62,0,0,403,109,1,0,0,0,404,405,5,60,0,0,405,406,5,47,0,0,406,407,1,0,0,0,407,408,3,122,60,0,408,409,5,62,0,0,409,111,1,0,0,0,410,411,5,60,0,0,411,412,3,122,60,0,412,413,5,61,0,0,413,113,1,0,0,0,414,415,5,60,0,0,415,416,5,112,0,0,416,417,5,44,0,0,417,419,1,0,0,0,418,420,8,9,0,0,419,418,1,0,0,0,420,421,1,0,0,0,421,419,1,0,0,0,421,422,1,0,0,0,422,423,1,0,0,0,423,424,5,62,0,0,424,115,1,0,0,0,425,426,5,60,0,0,426,427,1,0,0,0,427,428,6,57,6,0,428,117,1,0,0,0,429,430,5,62,0,0,430,119,1,0,0,0,431,432,5,92,0,0,432,433,7,10,0,0,433,121,1,0,0,0,434,435,5,98,0,0,435,455,5,114,0,0,436,437,5,99,0,0,437,438,5,111,0,0,438,455,5,108,0,0,439,440,5,115,0,0,440,441,5,116,0,0,441,455,5,114,0,0,442,443,5,115,0,0,443,444,5,104,0,0,444,445,5,97,0,0,445,455,5,100,0,0,446,455,5,117,0,0,447,448,5,105,0,0,448,449,5,109,0,0,449,455,5,103,0,0,450,451,5,103,0,0,451,455,5,116,0,0,452,453,5,108,0,0,453,455,5,116,0,0,454,434,1,0,0,0,454,436,1,0,0,0,454,439,1,0,0,0,454,442,1,0,0,0,454,446,1,0,0,0,454,447,1,0,0,0,454,450,1,0,0,0,454,452,1,0,0,0,455,123,1,0,0,0,26,0,1,246,251,258,263,269,275,281,287,292,298,304,315,320,335,339,349,370,375,388,390,398,400,421,454,7,1,23,0,0,1,0,1,48,1,5,1,0,1,51,2,4,0,0,5,0,0];static __ATN;static get _ATN(){if(!T.__ATN)T.__ATN=new n0().deserialize(T._serializedATN);return T.__ATN}static vocabulary=new D0(T.literalNames,T.symbolicNames,[]);get vocabulary(){return T.vocabulary}static decisionsToDFA=T._ATN.decisionToState.map((_,A)=>new S0(_,A))}class X3 extends s{text;constructor(_,A){super(_);this.text=A}accept(_){return _.visitToken(this)}}class G3 extends s{scripts;constructor(_,A){super(_);this.scripts=A,this.addChildren(this.scripts)}accept(_){return _.visitScriptFile(this)}}class p0 extends s{kind="Script";trigger;name;isStar;parameters;returnTokens;statements;block;symbol;returnType;triggerType;subjectReference=null;parameterType;constructor(_){super(_.source);if(this.trigger=_.trigger,this.name=_.name,this.isStar=_.isStar,this.parameters=_.parameters,this.returnTokens=_.returnTokens,this.statements=_.statements,this.addChild(this.trigger),this.addChild(this.name),this.parameters)this.addChildren(this.parameters);if(this.returnTokens)this.addChildren(this.returnTokens);this.addChildren(this.statements)}get nameString(){return this.isStar?`${this.name.text}*`:this.name.text}accept(_){return _.visitScript(this)}}class N3 extends s{typeToken;name;symbol;constructor(_,A,R){super(_);this.typeToken=A,this.name=R,this.addChild(this.typeToken),this.addChild(this.name)}accept(_){return _.visitParameter(this)}}class m extends s{constructor(_){super(_)}}class Q3 extends m{kind="BlockStatement";statements;scope;constructor(_,A){super(_);this.statements=A,this.addChildren(this.statements)}accept(_){return _.visitBlockStatement(this)}}class p extends s{constructor(_){super(_)}type=null;typeHint=null;getNullableType(){return this.type}getType(){if(this.type==null)throw Error("Attribute: 'type' should be initialized before get.");else return this.type}}class o extends p{value;constructor(_,A){super(_);this.value=A}}class Z3 extends o{kind="NullLiteral";constructor(_){super(_,-1)}accept(_){return _.visitNullLiteral(this)}}class J3 extends m{kind="ReturnStatement";expressions;constructor(_,A){super(_);this.expressions=A,this.addChildren(this.expressions)}accept(_){return _.visitReturnStatement(this)}}class H3 extends m{kind="IfStatement";condition;thenStatement;elseStatement;constructor(_,A,R,U){super(_);this.condition=A,this.thenStatement=R,this.elseStatement=U,this.addChild(this.condition),this.addChild(this.thenStatement),this.addChild(this.elseStatement)}accept(_){return _.visitIfStatement(this)}}class $3 extends m{kind="WhileStatement";condition;thenStatement;constructor(_,A,R){super(_);this.condition=A,this.thenStatement=R,this.addChild(this.condition),this.addChild(this.thenStatement)}accept(_){return _.visitWhileStatement(this)}}class i1 extends m{kind="SwitchStatement";typeToken;condition;cases;defaultCase=null;type;constructor(_,A,R,U){super(_);this.typeToken=A,this.condition=R,this.cases=U,this.addChild(this.typeToken),this.addChild(this.condition),this.addChildren(this.cases)}accept(_){return _.visitSwitchStatement(this)}}class F3 extends s{kind="SwitchCase";keys;statements;scope;constructor(_,A,R){super(_);this.keys=A,this.statements=R,this.addChildren(this.keys),this.addChildren(this.statements)}get isDefault(){return this.keys.length===0}accept(_){return _.visitSwitchCase(this)}}class I3 extends m{kind="DeclarationStatement";typeToken;name;initializer;symbol;constructor(_,A,R,U){super(_);this.typeToken=A,this.name=R,this.initializer=U,this.addChild(this.typeToken),this.addChild(this.name),this.addChild(this.initializer)}accept(_){return _.visitDeclarationStatement(this)}}class W3 extends m{kind="ArrayDeclarationStatement";typeToken;name;initializer;symbol;constructor(_,A,R,U){super(_);this.typeToken=A,this.name=R,this.initializer=U,this.addChild(this.typeToken),this.addChild(this.name),this.addChild(this.initializer)}accept(_){return _.visitArrayDeclarationStatement(this)}}class q3 extends m{kind="AssignmentStatement";vars;expressions;constructor(_,A,R){super(_);this.vars=A,this.expressions=R,this.addChildren(this.vars),this.addChildren(this.expressions)}accept(_){return _.visitAssignmentStatement(this)}}class z3 extends m{kind="ExpressionStatement";expression;constructor(_,A){super(_);this.expression=A,this.addChild(this.expression)}accept(_){return _.visitExpressionStatement(this)}}class K3 extends m{readonly="EmptyStatement";constructor(_){super(_)}accept(_){return _.visitEmptyStatement(this)}}class x0 extends p{kind="ParenthesizedExpression";expression;constructor(_,A){super(_);this.expression=A,this.addChild(this.expression)}accept(_){return _.visitParenthesizedExpression(this)}}class N1 extends p{left;operator;right;constructor(_,A,R,U){super(_);this.left=A,this.operator=R,this.right=U,this.addChild(this.left),this.addChild(this.operator),this.addChild(this.right)}accept(_){return _.visitBinaryExpression(this)}}class L3 extends N1{kind="ArithmeticExpression";constructor(_,A,R,U){super(_,A,R,U)}accept(_){return _.visitArithmeticExpression(this)}}class Q1 extends p{name;reference=null;constructor(_,A){super(_);this.name=A,this.addChild(this.name)}}class o0 extends Q1{kind="LocalVariableExpression";index;constructor(_,A,R){super(_,A);this.index=R,this.addChild(this.index)}get isArray(){return this.index!=null}accept(_){return _.visitLocalVariableExpression(this)}}class D3 extends p{kind="CalcExpression";expression;constructor(_,A){super(_);this.expression=A,this.addChild(this.expression)}accept(_){return _.visitCalcExpression(this)}}class r extends p{name;arguments;symbol;constructor(_,A,R){super(_);this.name=A,this.arguments=R,this.addChild(this.name),this.addChildren(this.arguments)}}class M0 extends r{kind="CommandCallExpression";arguments2;constructor(_,A,R,U){super(_,A,R);if(this.arguments2=U,this.arguments2)this.addChildren(this.arguments2)}get isStar(){return this.arguments2!=null}get nameString(){return this.isStar?`${this.name.text}*`:this.name.text}accept(_){return _.visitCommandCallExpression(this)}}class t1 extends r{kind="ProcCallExpression";constructor(_,A,R){super(_,A,R)}accept(_){return _.visitProcCallExpression(this)}}class r1 extends r{kind="JumpCallExpression";constructor(_,A,R){super(_,A,R)}accept(_){return _.visitJumpCallExpression(this)}}class e1 extends r{kind="ClientScriptExpression";transmitList;constructor(_,A,R,U){super(_,A,R);this.transmitList=U,this.addChildren(this.transmitList)}accept(_){return _.visitClientScriptExpression(this)}}class _2 extends Q1{kind="GameVariableExpression";dot;constructor(_,A,R){super(_,R);this.dot=A}accept(_){return _.visitGameVariableExpression(this)}}class Z1 extends Q1{kind="ConstantVariableExpression";subExpression=null;constructor(_,A){super(_,A)}accept(_){return _.visitConstantVariableExpression(this)}}class z2 extends o{kind="IntegerLiteral";constructor(_,A){super(_,A)}accept(_){return _.visitIntegerLiteral(this)}}class B3 extends o{kind="CoordLiteral";constructor(_,A){super(_,A)}accept(_){return _.visitCoordLiteral(this)}}class w3 extends o{kind="BooleanLiteral";constructor(_,A){super(_,A)}accept(_){return _.visitBooleanLiteral(this)}}class J1 extends N1{kind="ConditionExpression";constructor(_,A,R,U){super(_,A,R,U)}accept(_){return _.visitConditionExpression(this)}}class E3 extends o{kind="CharacterLiteral";constructor(_,A){super(_,A)}accept(_){return _.visitCharacterLiteral(this)}}class i0 extends o{kind="StringLiteral";symbol=null;subExpression=null;constructor(_,A){super(_,A)}accept(_){return _.visitStringLiteral(this)}}class k3 extends p{kind="JoinedStringExpression";parts;constructor(_,A){super(_);this.parts=A,this.addChildren(this.parts)}accept(_){return _.visitJoinedStringExpression(this)}}class C3 extends s{constructor(_){super(_)}accept(_){return _.visitJoinedStringPart(this)}}class m0 extends C3{kind="BasicStringPart";value;constructor(_,A){super(_);this.value=A}}class j3 extends m0{kind="PTagStringPart"}class g0 extends C3{kind="ExpressionStringPart";expression;constructor(_,A){super(_);this.expression=A,this.addChild(this.expression)}}class Y0 extends p{kind="Identifier";text;reference=null;constructor(_,A){super(_);this.text=A}accept(_){return _.visitIdentifier(this)}}class Z extends Y3{static LPAREN=1;static RPAREN=2;static COLON=3;static SEMICOLON=4;static COMMA=5;static LBRACK=6;static RBRACK=7;static LBRACE=8;static RBRACE=9;static PLUS=10;static MINUS=11;static MUL=12;static DIV=13;static DOTMOD=14;static MOD=15;static AND=16;static OR=17;static EQ=18;static EXCL=19;static DOLLAR=20;static CARET=21;static TILDE=22;static AT=23;static GT=24;static GTE=25;static LT=26;static LTE=27;static IF=28;static ELSE=29;static WHILE=30;static CASE=31;static DEFAULT=32;static RETURN=33;static CALC=34;static TYPE_ARRAY=35;static DEF_TYPE=36;static SWITCH_TYPE=37;static INTEGER_LITERAL=38;static HEX_LITERAL=39;static COORD_LITERAL=40;static MAPZONE_LITERAL=41;static BOOLEAN_LITERAL=42;static CHAR_LITERAL=43;static NULL_LITERAL=44;static LINE_COMMENT=45;static BLOCK_COMMENT=46;static QUOTE_OPEN=47;static IDENTIFIER=48;static WHITESPACE=49;static QUOTE_CLOSE=50;static STRING_TEXT=51;static STRING_TAG=52;static STRING_CLOSE_TAG=53;static STRING_PARTIAL_TAG=54;static STRING_P_TAG=55;static STRING_EXPR_START=56;static STRING_EXPR_END=57;static RULE_scriptFile=0;static RULE_script=1;static RULE_parameterList=2;static RULE_parameter=3;static RULE_typeList=4;static RULE_statement=5;static RULE_blockStatement=6;static RULE_returnStatement=7;static RULE_ifStatement=8;static RULE_whileStatement=9;static RULE_switchStatement=10;static RULE_switchCase=11;static RULE_declarationStatement=12;static RULE_arrayDeclarationStatement=13;static RULE_assignmentStatement=14;static RULE_expressionStatement=15;static RULE_emptyStatement=16;static RULE_expressionList=17;static RULE_parenthesis=18;static RULE_singleExpression=19;static RULE_expression=20;static RULE_condition=21;static RULE_calc=22;static RULE_arithmetic=23;static RULE_call=24;static RULE_clientScript=25;static RULE_assignableVariableList=26;static RULE_assignableVariable=27;static RULE_localVariable=28;static RULE_localArrayVariable=29;static RULE_gameVariable=30;static RULE_constantVariable=31;static RULE_literal=32;static RULE_stringLiteral=33;static RULE_stringLiteralContent=34;static RULE_joinedString=35;static RULE_stringTag=36;static RULE_stringPTag=37;static RULE_stringExpression=38;static RULE_identifier=39;static RULE_advancedIdentifier=40;static literalNames=[null,"'('","')'","':'","';'","','","'['","']'","'{'","'}'","'+'","'-'","'*'","'/'","'.%'","'%'","'&'","'|'","'='","'!'","'$'","'^'","'~'","'@'",null,"'>='",null,"'<='","'if'","'else'","'while'","'case'","'default'","'return'","'calc'",null,null,null,null,null,null,null,null,null,"'null'"];static symbolicNames=[null,"LPAREN","RPAREN","COLON","SEMICOLON","COMMA","LBRACK","RBRACK","LBRACE","RBRACE","PLUS","MINUS","MUL","DIV","DOTMOD","MOD","AND","OR","EQ","EXCL","DOLLAR","CARET","TILDE","AT","GT","GTE","LT","LTE","IF","ELSE","WHILE","CASE","DEFAULT","RETURN","CALC","TYPE_ARRAY","DEF_TYPE","SWITCH_TYPE","INTEGER_LITERAL","HEX_LITERAL","COORD_LITERAL","MAPZONE_LITERAL","BOOLEAN_LITERAL","CHAR_LITERAL","NULL_LITERAL","LINE_COMMENT","BLOCK_COMMENT","QUOTE_OPEN","IDENTIFIER","WHITESPACE","QUOTE_CLOSE","STRING_TEXT","STRING_TAG","STRING_CLOSE_TAG","STRING_PARTIAL_TAG","STRING_P_TAG","STRING_EXPR_START","STRING_EXPR_END"];static ruleNames=["scriptFile","script","parameterList","parameter","typeList","statement","blockStatement","returnStatement","ifStatement","whileStatement","switchStatement","switchCase","declarationStatement","arrayDeclarationStatement","assignmentStatement","expressionStatement","emptyStatement","expressionList","parenthesis","singleExpression","expression","condition","calc","arithmetic","call","clientScript","assignableVariableList","assignableVariable","localVariable","localArrayVariable","gameVariable","constantVariable","literal","stringLiteral","stringLiteralContent","joinedString","stringTag","stringPTag","stringExpression","identifier","advancedIdentifier"];get grammarFileName(){return"RuneScriptParser.g4"}get literalNames(){return Z.literalNames}get symbolicNames(){return Z.symbolicNames}get ruleNames(){return Z.ruleNames}get serializedATN(){return Z._serializedATN}createFailedPredicateException(_,A){return new p1(this,_,A)}constructor(_){super(_);this.interpreter=new o1(this,Z._ATN,Z.decisionsToDFA,new G1)}scriptFile(){let _=new y4(this.context,this.state);this.enterRule(_,0,Z.RULE_scriptFile);let A;try{this.enterOuterAlt(_,1);{this.state=85,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while(A===6)this.state=82,this.script(),this.state=87,this.errorHandler.sync(this),A=this.tokenStream.LA(1);this.state=88,this.match(Z.EOF)}}catch(R){if(R instanceof h)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}script(){let _=new K2(this.context,this.state);this.enterRule(_,2,Z.RULE_script);let A;try{this.enterOuterAlt(_,1);{if(this.state=90,this.match(Z.LBRACK),this.state=91,_._trigger=this.identifier(),this.state=92,this.match(Z.COMMA),this.state=93,_._name=this.identifier(),this.state=95,this.errorHandler.sync(this),A=this.tokenStream.LA(1),A===12)this.state=94,this.match(Z.MUL);switch(this.state=97,this.match(Z.RBRACK),this.state=111,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,5,this.context)){case 1:{{if(this.state=98,this.match(Z.LPAREN),this.state=100,this.errorHandler.sync(this),A=this.tokenStream.LA(1),A===35||A===48)this.state=99,this.parameterList();this.state=102,this.match(Z.RPAREN)}switch(this.state=109,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,4,this.context)){case 1:{if(this.state=104,this.match(Z.LPAREN),this.state=106,this.errorHandler.sync(this),A=this.tokenStream.LA(1),A===48)this.state=105,this.typeList();this.state=108,this.match(Z.RPAREN)}break}}break}this.state=116,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while((A&-32)===0&&(1<<A&1357955346)!==0||(A-32&-32)===0&&(1<<A-32&106495)!==0)this.state=113,this.statement(),this.state=118,this.errorHandler.sync(this),A=this.tokenStream.LA(1)}}catch(R){if(R instanceof h)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}parameterList(){let _=new f3(this.context,this.state);this.enterRule(_,4,Z.RULE_parameterList);let A;try{this.enterOuterAlt(_,1);{this.state=119,this.parameter(),this.state=124,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while(A===5)this.state=120,this.match(Z.COMMA),this.state=121,this.parameter(),this.state=126,this.errorHandler.sync(this),A=this.tokenStream.LA(1)}}catch(R){if(R instanceof h)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}parameter(){let _=new L2(this.context,this.state);this.enterRule(_,6,Z.RULE_parameter);let A;try{this.enterOuterAlt(_,1);{if(this.state=127,_._type_=this.tokenStream.LT(1),A=this.tokenStream.LA(1),!(A===35||A===48))_._type_=this.errorHandler.recoverInline(this);else this.errorHandler.reportMatch(this),this.consume();this.state=128,this.match(Z.DOLLAR),this.state=129,this.advancedIdentifier()}}catch(R){if(R instanceof h)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}typeList(){let _=new h3(this.context,this.state);this.enterRule(_,8,Z.RULE_typeList);let A;try{this.enterOuterAlt(_,1);{this.state=131,this.match(Z.IDENTIFIER),this.state=136,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while(A===5)this.state=132,this.match(Z.COMMA),this.state=133,this.match(Z.IDENTIFIER),this.state=138,this.errorHandler.sync(this),A=this.tokenStream.LA(1)}}catch(R){if(R instanceof h)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}statement(){let _=new B0(this.context,this.state);this.enterRule(_,10,Z.RULE_statement);try{switch(this.state=149,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,9,this.context)){case 1:this.enterOuterAlt(_,1),this.state=139,this.blockStatement();break;case 2:this.enterOuterAlt(_,2),this.state=140,this.returnStatement();break;case 3:this.enterOuterAlt(_,3),this.state=141,this.ifStatement();break;case 4:this.enterOuterAlt(_,4),this.state=142,this.whileStatement();break;case 5:this.enterOuterAlt(_,5),this.state=143,this.switchStatement();break;case 6:this.enterOuterAlt(_,6),this.state=144,this.declarationStatement();break;case 7:this.enterOuterAlt(_,7),this.state=145,this.arrayDeclarationStatement();break;case 8:this.enterOuterAlt(_,8),this.state=146,this.assignmentStatement();break;case 9:this.enterOuterAlt(_,9),this.state=147,this.expressionStatement();break;case 10:this.enterOuterAlt(_,10),this.state=148,this.emptyStatement();break}}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}blockStatement(){let _=new V3(this.context,this.state);this.enterRule(_,12,Z.RULE_blockStatement);let A;try{this.enterOuterAlt(_,1);{this.state=151,this.match(Z.LBRACE),this.state=155,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while((A&-32)===0&&(1<<A&1357955346)!==0||(A-32&-32)===0&&(1<<A-32&106495)!==0)this.state=152,this.statement(),this.state=157,this.errorHandler.sync(this),A=this.tokenStream.LA(1);this.state=158,this.match(Z.RBRACE)}}catch(R){if(R instanceof h)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}returnStatement(){let _=new P3(this.context,this.state);this.enterRule(_,14,Z.RULE_returnStatement);let A;try{this.enterOuterAlt(_,1);{if(this.state=160,this.match(Z.RETURN),this.state=166,this.errorHandler.sync(this),A=this.tokenStream.LA(1),A===1){if(this.state=161,this.match(Z.LPAREN),this.state=163,this.errorHandler.sync(this),A=this.tokenStream.LA(1),(A&-32)===0&&(1<<A&15777794)!==0||(A-32&-32)===0&&(1<<A-32&106493)!==0)this.state=162,this.expressionList();this.state=165,this.match(Z.RPAREN)}this.state=168,this.match(Z.SEMICOLON)}}catch(R){if(R instanceof h)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}ifStatement(){let _=new v3(this.context,this.state);this.enterRule(_,16,Z.RULE_ifStatement);try{switch(this.enterOuterAlt(_,1),this.state=170,this.match(Z.IF),this.state=171,this.match(Z.LPAREN),this.state=172,this.condition(0),this.state=173,this.match(Z.RPAREN),this.state=174,this.statement(),this.state=177,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,13,this.context)){case 1:this.state=175,this.match(Z.ELSE),this.state=176,this.statement();break}}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}whileStatement(){let _=new b3(this.context,this.state);this.enterRule(_,18,Z.RULE_whileStatement);try{this.enterOuterAlt(_,1),this.state=179,this.match(Z.WHILE),this.state=180,this.match(Z.LPAREN),this.state=181,this.condition(0),this.state=182,this.match(Z.RPAREN),this.state=183,this.statement()}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}switchStatement(){let _=new u3(this.context,this.state);this.enterRule(_,20,Z.RULE_switchStatement);let A;try{this.enterOuterAlt(_,1);{this.state=185,this.match(Z.SWITCH_TYPE),this.state=186,this.parenthesis(),this.state=187,this.match(Z.LBRACE),this.state=191,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while(A===31)this.state=188,this.switchCase(),this.state=193,this.errorHandler.sync(this),A=this.tokenStream.LA(1);this.state=194,this.match(Z.RBRACE)}}catch(R){if(R instanceof h)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}switchCase(){let _=new D2(this.context,this.state);this.enterRule(_,22,Z.RULE_switchCase);let A;try{this.enterOuterAlt(_,1);{switch(this.state=196,this.match(Z.CASE),this.state=199,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,15,this.context)){case 1:this.state=197,this.match(Z.DEFAULT);break;case 2:this.state=198,this.expressionList();break}this.state=201,this.match(Z.COLON),this.state=205,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while((A&-32)===0&&(1<<A&1357955346)!==0||(A-32&-32)===0&&(1<<A-32&106495)!==0)this.state=202,this.statement(),this.state=207,this.errorHandler.sync(this),A=this.tokenStream.LA(1)}}catch(R){if(R instanceof h)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}declarationStatement(){let _=new S3(this.context,this.state);this.enterRule(_,24,Z.RULE_declarationStatement);let A;try{this.enterOuterAlt(_,1);{if(this.state=208,this.match(Z.DEF_TYPE),this.state=209,this.match(Z.DOLLAR),this.state=210,this.advancedIdentifier(),this.state=213,this.errorHandler.sync(this),A=this.tokenStream.LA(1),A===18)this.state=211,this.match(Z.EQ),this.state=212,this.expression();this.state=215,this.match(Z.SEMICOLON)}}catch(R){if(R instanceof h)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}arrayDeclarationStatement(){let _=new x3(this.context,this.state);this.enterRule(_,26,Z.RULE_arrayDeclarationStatement);try{this.enterOuterAlt(_,1),this.state=217,this.match(Z.DEF_TYPE),this.state=218,this.match(Z.DOLLAR),this.state=219,this.advancedIdentifier(),this.state=220,this.parenthesis(),this.state=221,this.match(Z.SEMICOLON)}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}assignmentStatement(){let _=new m3(this.context,this.state);this.enterRule(_,28,Z.RULE_assignmentStatement);try{this.enterOuterAlt(_,1),this.state=223,this.assignableVariableList(),this.state=224,this.match(Z.EQ),this.state=225,this.expressionList(),this.state=226,this.match(Z.SEMICOLON)}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}expressionStatement(){let _=new g3(this.context,this.state);this.enterRule(_,30,Z.RULE_expressionStatement);try{this.enterOuterAlt(_,1),this.state=228,this.expression(),this.state=229,this.match(Z.SEMICOLON)}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}emptyStatement(){let _=new d3(this.context,this.state);this.enterRule(_,32,Z.RULE_emptyStatement);try{this.enterOuterAlt(_,1),this.state=231,this.match(Z.SEMICOLON)}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}expressionList(){let _=new w0(this.context,this.state);this.enterRule(_,34,Z.RULE_expressionList);let A;try{this.enterOuterAlt(_,1);{this.state=233,this.expression(),this.state=238,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while(A===5)this.state=234,this.match(Z.COMMA),this.state=235,this.expression(),this.state=240,this.errorHandler.sync(this),A=this.tokenStream.LA(1)}}catch(R){if(R instanceof h)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}parenthesis(){let _=new M1(this.context,this.state);this.enterRule(_,36,Z.RULE_parenthesis);try{this.enterOuterAlt(_,1),this.state=241,this.match(Z.LPAREN),this.state=242,this.expression(),this.state=243,this.match(Z.RPAREN)}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}singleExpression(){let _=new c4(this.context,this.state);this.enterRule(_,38,Z.RULE_singleExpression);try{this.enterOuterAlt(_,1),this.state=245,this.expression(),this.state=246,this.match(Z.EOF)}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}expression(){let _=new g(this.context,this.state);this.enterRule(_,40,Z.RULE_expression);try{switch(this.state=258,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,19,this.context)){case 1:_=new a4(_),this.enterOuterAlt(_,1),this.state=248,this.parenthesis();break;case 2:_=new s4(_),this.enterOuterAlt(_,2),this.state=249,this.calc();break;case 3:_=new n4(_),this.enterOuterAlt(_,3),this.state=250,this.call();break;case 4:_=new p4(_),this.enterOuterAlt(_,4),this.state=251,this.localVariable();break;case 5:_=new o4(_),this.enterOuterAlt(_,5),this.state=252,this.localArrayVariable();break;case 6:_=new i4(_),this.enterOuterAlt(_,6),this.state=253,this.gameVariable();break;case 7:_=new t4(_),this.enterOuterAlt(_,7),this.state=254,this.constantVariable();break;case 8:_=new r4(_),this.enterOuterAlt(_,8),this.state=255,this.literal();break;case 9:_=new e4(_),this.enterOuterAlt(_,9),this.state=256,this.joinedString();break;case 10:_=new _5(_),this.enterOuterAlt(_,10),this.state=257,this.identifier();break}}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}condition(_){if(_===void 0)_=0;let A=this.context,R=this.state,U=new X0(this.context,R),Y=U,X=42;this.enterRecursionRule(U,42,Z.RULE_condition,_);let G;try{let Q;this.enterOuterAlt(U,1);{switch(this.state=266,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,20,this.context)){case 1:U=new A5(U),this.context=U,Y=U,this.state=261,this.match(Z.LPAREN),this.state=262,this.condition(0),this.state=263,this.match(Z.RPAREN);break;case 2:U=new R5(U),this.context=U,Y=U,this.state=265,this.expression();break}this.context.stop=this.tokenStream.LT(-1),this.state=282,this.errorHandler.sync(this),Q=this.interpreter.adaptivePredict(this.tokenStream,22,this.context);while(Q!==2&&Q!==P.INVALID_ALT_NUMBER){if(Q===1){if(this.parseListeners!=null)this.triggerExitRuleEvent();switch(Y=U,this.state=280,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,21,this.context)){case 1:{if(U=new A2(new X0(A,R)),this.pushNewRecursionContext(U,X,Z.RULE_condition),this.state=268,!this.precpred(this.context,5))throw this.createFailedPredicateException("this.precpred(this.context, 5)");if(this.state=269,U._op=this.tokenStream.LT(1),G=this.tokenStream.LA(1),!((G&-32)===0&&(1<<G&251658240)!==0))U._op=this.errorHandler.recoverInline(this);else this.errorHandler.reportMatch(this),this.consume();this.state=270,this.condition(6)}break;case 2:{if(U=new A2(new X0(A,R)),this.pushNewRecursionContext(U,X,Z.RULE_condition),this.state=271,!this.precpred(this.context,4))throw this.createFailedPredicateException("this.precpred(this.context, 4)");if(this.state=272,U._op=this.tokenStream.LT(1),G=this.tokenStream.LA(1),!(G===18||G===19))U._op=this.errorHandler.recoverInline(this);else this.errorHandler.reportMatch(this),this.consume();this.state=273,this.condition(5)}break;case 3:{if(U=new A2(new X0(A,R)),this.pushNewRecursionContext(U,X,Z.RULE_condition),this.state=274,!this.precpred(this.context,3))throw this.createFailedPredicateException("this.precpred(this.context, 3)");this.state=275,U._op=this.match(Z.AND),this.state=276,this.condition(4)}break;case 4:{if(U=new A2(new X0(A,R)),this.pushNewRecursionContext(U,X,Z.RULE_condition),this.state=277,!this.precpred(this.context,2))throw this.createFailedPredicateException("this.precpred(this.context, 2)");this.state=278,U._op=this.match(Z.OR),this.state=279,this.condition(3)}break}}this.state=284,this.errorHandler.sync(this),Q=this.interpreter.adaptivePredict(this.tokenStream,22,this.context)}}}catch(Q){if(Q instanceof h)this.errorHandler.reportError(this,Q),this.errorHandler.recover(this,Q);else throw Q}finally{this.unrollRecursionContexts(A)}return U}calc(){let _=new l3(this.context,this.state);this.enterRule(_,44,Z.RULE_calc);try{this.enterOuterAlt(_,1),this.state=285,this.match(Z.CALC),this.state=286,this.match(Z.LPAREN),this.state=287,this.arithmetic(0),this.state=288,this.match(Z.RPAREN)}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}arithmetic(_){if(_===void 0)_=0;let A=this.context,R=this.state,U=new Q0(this.context,R),Y=U,X=46;this.enterRecursionRule(U,46,Z.RULE_arithmetic,_);let G;try{let Q;this.enterOuterAlt(U,1);{switch(this.state=296,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,23,this.context)){case 1:U=new U5(U),this.context=U,Y=U,this.state=291,this.match(Z.LPAREN),this.state=292,this.arithmetic(0),this.state=293,this.match(Z.RPAREN);break;case 2:U=new Y5(U),this.context=U,Y=U,this.state=295,this.expression();break}this.context.stop=this.tokenStream.LT(-1),this.state=312,this.errorHandler.sync(this),Q=this.interpreter.adaptivePredict(this.tokenStream,25,this.context);while(Q!==2&&Q!==P.INVALID_ALT_NUMBER){if(Q===1){if(this.parseListeners!=null)this.triggerExitRuleEvent();switch(Y=U,this.state=310,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,24,this.context)){case 1:{if(U=new R2(new Q0(A,R)),this.pushNewRecursionContext(U,X,Z.RULE_arithmetic),this.state=298,!this.precpred(this.context,5))throw this.createFailedPredicateException("this.precpred(this.context, 5)");if(this.state=299,U._op=this.tokenStream.LT(1),G=this.tokenStream.LA(1),!((G&-32)===0&&(1<<G&45056)!==0))U._op=this.errorHandler.recoverInline(this);else this.errorHandler.reportMatch(this),this.consume();this.state=300,this.arithmetic(6)}break;case 2:{if(U=new R2(new Q0(A,R)),this.pushNewRecursionContext(U,X,Z.RULE_arithmetic),this.state=301,!this.precpred(this.context,4))throw this.createFailedPredicateException("this.precpred(this.context, 4)");if(this.state=302,U._op=this.tokenStream.LT(1),G=this.tokenStream.LA(1),!(G===10||G===11))U._op=this.errorHandler.recoverInline(this);else this.errorHandler.reportMatch(this),this.consume();this.state=303,this.arithmetic(5)}break;case 3:{if(U=new R2(new Q0(A,R)),this.pushNewRecursionContext(U,X,Z.RULE_arithmetic),this.state=304,!this.precpred(this.context,3))throw this.createFailedPredicateException("this.precpred(this.context, 3)");this.state=305,U._op=this.match(Z.AND),this.state=306,this.arithmetic(4)}break;case 4:{if(U=new R2(new Q0(A,R)),this.pushNewRecursionContext(U,X,Z.RULE_arithmetic),this.state=307,!this.precpred(this.context,2))throw this.createFailedPredicateException("this.precpred(this.context, 2)");this.state=308,U._op=this.match(Z.OR),this.state=309,this.arithmetic(3)}break}}this.state=314,this.errorHandler.sync(this),Q=this.interpreter.adaptivePredict(this.tokenStream,25,this.context)}}}catch(Q){if(Q instanceof h)this.errorHandler.reportError(this,Q),this.errorHandler.recover(this,Q);else throw Q}finally{this.unrollRecursionContexts(A)}return U}call(){let _=new f1(this.context,this.state);this.enterRule(_,48,Z.RULE_call);let A;try{switch(this.state=353,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,33,this.context)){case 1:_=new O3(_),this.enterOuterAlt(_,1);{if(this.state=315,this.identifier(),this.state=316,this.match(Z.MUL),this.state=317,this.match(Z.LPAREN),this.state=319,this.errorHandler.sync(this),A=this.tokenStream.LA(1),(A&-32)===0&&(1<<A&15777794)!==0||(A-32&-32)===0&&(1<<A-32&106493)!==0)this.state=318,this.expressionList();if(this.state=321,this.match(Z.RPAREN),this.state=322,this.match(Z.LPAREN),this.state=324,this.errorHandler.sync(this),A=this.tokenStream.LA(1),(A&-32)===0&&(1<<A&15777794)!==0||(A-32&-32)===0&&(1<<A-32&106493)!==0)this.state=323,this.expressionList();this.state=326,this.match(Z.RPAREN)}break;case 2:_=new O3(_),this.enterOuterAlt(_,2);{if(this.state=328,this.identifier(),this.state=329,this.match(Z.LPAREN),this.state=331,this.errorHandler.sync(this),A=this.tokenStream.LA(1),(A&-32)===0&&(1<<A&15777794)!==0||(A-32&-32)===0&&(1<<A-32&106493)!==0)this.state=330,this.expressionList();this.state=333,this.match(Z.RPAREN)}break;case 3:switch(_=new X5(_),this.enterOuterAlt(_,3),this.state=335,this.match(Z.TILDE),this.state=336,this.identifier(),this.state=342,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,30,this.context)){case 1:{if(this.state=337,this.match(Z.LPAREN),this.state=339,this.errorHandler.sync(this),A=this.tokenStream.LA(1),(A&-32)===0&&(1<<A&15777794)!==0||(A-32&-32)===0&&(1<<A-32&106493)!==0)this.state=338,this.expressionList();this.state=341,this.match(Z.RPAREN)}break}break;case 4:switch(_=new G5(_),this.enterOuterAlt(_,4),this.state=344,this.match(Z.AT),this.state=345,this.identifier(),this.state=351,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,32,this.context)){case 1:{if(this.state=346,this.match(Z.LPAREN),this.state=348,this.errorHandler.sync(this),A=this.tokenStream.LA(1),(A&-32)===0&&(1<<A&15777794)!==0||(A-32&-32)===0&&(1<<A-32&106493)!==0)this.state=347,this.expressionList();this.state=350,this.match(Z.RPAREN)}break}break}}catch(R){if(R instanceof h)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}clientScript(){let _=new N5(this.context,this.state);this.enterRule(_,50,Z.RULE_clientScript);let A;try{this.enterOuterAlt(_,1);{if(this.state=355,this.identifier(),this.state=361,this.errorHandler.sync(this),A=this.tokenStream.LA(1),A===1){if(this.state=356,this.match(Z.LPAREN),this.state=358,this.errorHandler.sync(this),A=this.tokenStream.LA(1),(A&-32)===0&&(1<<A&15777794)!==0||(A-32&-32)===0&&(1<<A-32&106493)!==0)this.state=357,_._args=this.expressionList();this.state=360,this.match(Z.RPAREN)}if(this.state=368,this.errorHandler.sync(this),A=this.tokenStream.LA(1),A===8){if(this.state=363,this.match(Z.LBRACE),this.state=365,this.errorHandler.sync(this),A=this.tokenStream.LA(1),(A&-32)===0&&(1<<A&15777794)!==0||(A-32&-32)===0&&(1<<A-32&106493)!==0)this.state=364,_._triggers=this.expressionList();this.state=367,this.match(Z.RBRACE)}this.state=370,this.match(Z.EOF)}}catch(R){if(R instanceof h)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}assignableVariableList(){let _=new T3(this.context,this.state);this.enterRule(_,52,Z.RULE_assignableVariableList);let A;try{this.enterOuterAlt(_,1);{this.state=372,this.assignableVariable(),this.state=377,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while(A===5)this.state=373,this.match(Z.COMMA),this.state=374,this.assignableVariable(),this.state=379,this.errorHandler.sync(this),A=this.tokenStream.LA(1)}}catch(R){if(R instanceof h)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}assignableVariable(){let _=new B2(this.context,this.state);this.enterRule(_,54,Z.RULE_assignableVariable);try{switch(this.state=383,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,39,this.context)){case 1:this.enterOuterAlt(_,1),this.state=380,this.localVariable();break;case 2:this.enterOuterAlt(_,2),this.state=381,this.localArrayVariable();break;case 3:this.enterOuterAlt(_,3),this.state=382,this.gameVariable();break}}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}localVariable(){let _=new w2(this.context,this.state);this.enterRule(_,56,Z.RULE_localVariable);try{this.enterOuterAlt(_,1),this.state=385,this.match(Z.DOLLAR),this.state=386,this.advancedIdentifier()}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}localArrayVariable(){let _=new E2(this.context,this.state);this.enterRule(_,58,Z.RULE_localArrayVariable);try{this.enterOuterAlt(_,1),this.state=388,this.match(Z.DOLLAR),this.state=389,this.advancedIdentifier(),this.state=390,this.parenthesis()}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}gameVariable(){let _=new k2(this.context,this.state);this.enterRule(_,60,Z.RULE_gameVariable);try{switch(this.state=396,this.errorHandler.sync(this),this.tokenStream.LA(1)){case Z.MOD:this.enterOuterAlt(_,1),this.state=392,this.match(Z.MOD),this.state=393,this.advancedIdentifier();break;case Z.DOTMOD:this.enterOuterAlt(_,2),this.state=394,this.match(Z.DOTMOD),this.state=395,this.advancedIdentifier();break;default:throw new X1(this)}}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}constantVariable(){let _=new y3(this.context,this.state);this.enterRule(_,62,Z.RULE_constantVariable);try{this.enterOuterAlt(_,1),this.state=398,this.match(Z.CARET),this.state=399,this.advancedIdentifier()}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}literal(){let _=new d0(this.context,this.state);this.enterRule(_,64,Z.RULE_literal);try{switch(this.state=408,this.errorHandler.sync(this),this.tokenStream.LA(1)){case Z.INTEGER_LITERAL:_=new M3(_),this.enterOuterAlt(_,1),this.state=401,this.match(Z.INTEGER_LITERAL);break;case Z.HEX_LITERAL:_=new M3(_),this.enterOuterAlt(_,2),this.state=402,this.match(Z.HEX_LITERAL);break;case Z.COORD_LITERAL:_=new Q5(_),this.enterOuterAlt(_,3),this.state=403,this.match(Z.COORD_LITERAL);break;case Z.BOOLEAN_LITERAL:_=new Z5(_),this.enterOuterAlt(_,4),this.state=404,this.match(Z.BOOLEAN_LITERAL);break;case Z.CHAR_LITERAL:_=new J5(_),this.enterOuterAlt(_,5),this.state=405,this.match(Z.CHAR_LITERAL);break;case Z.NULL_LITERAL:_=new H5(_),this.enterOuterAlt(_,6),this.state=406,this.match(Z.NULL_LITERAL);break;case Z.QUOTE_OPEN:_=new $5(_),this.enterOuterAlt(_,7),this.state=407,this.stringLiteral();break;default:throw new X1(this)}}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}stringLiteral(){let _=new c3(this.context,this.state);this.enterRule(_,66,Z.RULE_stringLiteral);let A;try{this.enterOuterAlt(_,1);{this.state=410,this.match(Z.QUOTE_OPEN),this.state=414,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while(A===51)this.state=411,this.stringLiteralContent(),this.state=416,this.errorHandler.sync(this),A=this.tokenStream.LA(1);this.state=417,this.match(Z.QUOTE_CLOSE)}}catch(R){if(R instanceof h)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}stringLiteralContent(){let _=new t0(this.context,this.state);this.enterRule(_,68,Z.RULE_stringLiteralContent);try{this.enterOuterAlt(_,1),this.state=419,this.match(Z.STRING_TEXT)}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}joinedString(){let _=new a3(this.context,this.state);this.enterRule(_,70,Z.RULE_joinedString);let A;try{this.enterOuterAlt(_,1);{this.state=421,this.match(Z.QUOTE_OPEN),this.state=428,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while((A-51&-32)===0&&(1<<A-51&63)!==0){switch(this.state=426,this.errorHandler.sync(this),this.tokenStream.LA(1)){case Z.STRING_TEXT:this.state=422,this.stringLiteralContent();break;case Z.STRING_TAG:case Z.STRING_CLOSE_TAG:case Z.STRING_PARTIAL_TAG:this.state=423,this.stringTag();break;case Z.STRING_P_TAG:this.state=424,this.stringPTag();break;case Z.STRING_EXPR_START:this.state=425,this.stringExpression();break;default:throw new X1(this)}this.state=430,this.errorHandler.sync(this),A=this.tokenStream.LA(1)}this.state=431,this.match(Z.QUOTE_CLOSE)}}catch(R){if(R instanceof h)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}stringTag(){let _=new C1(this.context,this.state);this.enterRule(_,72,Z.RULE_stringTag);let A;try{if(this.enterOuterAlt(_,1),this.state=433,A=this.tokenStream.LA(1),!((A-52&-32)===0&&(1<<A-52&7)!==0))this.errorHandler.recoverInline(this);else this.errorHandler.reportMatch(this),this.consume()}catch(R){if(R instanceof h)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}stringPTag(){let _=new j1(this.context,this.state);this.enterRule(_,74,Z.RULE_stringPTag);try{this.enterOuterAlt(_,1),this.state=435,this.match(Z.STRING_P_TAG)}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}stringExpression(){let _=new O1(this.context,this.state);this.enterRule(_,76,Z.RULE_stringExpression);try{this.enterOuterAlt(_,1),this.state=437,this.match(Z.STRING_EXPR_START),this.state=438,this.expression(),this.state=439,this.match(Z.STRING_EXPR_END)}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}identifier(){let _=new f0(this.context,this.state);this.enterRule(_,78,Z.RULE_identifier);let A;try{if(this.enterOuterAlt(_,1),this.state=441,A=this.tokenStream.LA(1),!((A-32&-32)===0&&(1<<A-32&71609)!==0))this.errorHandler.recoverInline(this);else this.errorHandler.reportMatch(this),this.consume()}catch(R){if(R instanceof h)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}advancedIdentifier(){let _=new l0(this.context,this.state);this.enterRule(_,80,Z.RULE_advancedIdentifier);try{switch(this.state=449,this.errorHandler.sync(this),this.tokenStream.LA(1)){case Z.DEFAULT:case Z.TYPE_ARRAY:case Z.DEF_TYPE:case Z.SWITCH_TYPE:case Z.HEX_LITERAL:case Z.COORD_LITERAL:case Z.MAPZONE_LITERAL:case Z.BOOLEAN_LITERAL:case Z.NULL_LITERAL:case Z.IDENTIFIER:this.enterOuterAlt(_,1),this.state=443,this.identifier();break;case Z.IF:this.enterOuterAlt(_,2),this.state=444,this.match(Z.IF);break;case Z.ELSE:this.enterOuterAlt(_,3),this.state=445,this.match(Z.ELSE);break;case Z.WHILE:this.enterOuterAlt(_,4),this.state=446,this.match(Z.WHILE);break;case Z.RETURN:this.enterOuterAlt(_,5),this.state=447,this.match(Z.RETURN);break;case Z.CALC:this.enterOuterAlt(_,6),this.state=448,this.match(Z.CALC);break;default:throw new X1(this)}}catch(A){if(A instanceof h)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}sempred(_,A,R){switch(A){case 21:return this.condition_sempred(_,R);case 23:return this.arithmetic_sempred(_,R)}return!0}condition_sempred(_,A){switch(A){case 0:return this.precpred(this.context,5);case 1:return this.precpred(this.context,4);case 2:return this.precpred(this.context,3);case 3:return this.precpred(this.context,2)}return!0}arithmetic_sempred(_,A){switch(A){case 4:return this.precpred(this.context,5);case 5:return this.precpred(this.context,4);case 6:return this.precpred(this.context,3);case 7:return this.precpred(this.context,2)}return!0}static _serializedATN=[4,1,57,452,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,39,2,40,7,40,1,0,5,0,84,8,0,10,0,12,0,87,9,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,3,1,96,8,1,1,1,1,1,1,1,3,1,101,8,1,1,1,1,1,1,1,1,1,3,1,107,8,1,1,1,3,1,110,8,1,3,1,112,8,1,1,1,5,1,115,8,1,10,1,12,1,118,9,1,1,2,1,2,1,2,5,2,123,8,2,10,2,12,2,126,9,2,1,3,1,3,1,3,1,3,1,4,1,4,1,4,5,4,135,8,4,10,4,12,4,138,9,4,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,3,5,150,8,5,1,6,1,6,5,6,154,8,6,10,6,12,6,157,9,6,1,6,1,6,1,7,1,7,1,7,3,7,164,8,7,1,7,3,7,167,8,7,1,7,1,7,1,8,1,8,1,8,1,8,1,8,1,8,1,8,3,8,178,8,8,1,9,1,9,1,9,1,9,1,9,1,9,1,10,1,10,1,10,1,10,5,10,190,8,10,10,10,12,10,193,9,10,1,10,1,10,1,11,1,11,1,11,3,11,200,8,11,1,11,1,11,5,11,204,8,11,10,11,12,11,207,9,11,1,12,1,12,1,12,1,12,1,12,3,12,214,8,12,1,12,1,12,1,13,1,13,1,13,1,13,1,13,1,13,1,14,1,14,1,14,1,14,1,14,1,15,1,15,1,15,1,16,1,16,1,17,1,17,1,17,5,17,237,8,17,10,17,12,17,240,9,17,1,18,1,18,1,18,1,18,1,19,1,19,1,19,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,3,20,259,8,20,1,21,1,21,1,21,1,21,1,21,1,21,3,21,267,8,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,5,21,281,8,21,10,21,12,21,284,9,21,1,22,1,22,1,22,1,22,1,22,1,23,1,23,1,23,1,23,1,23,1,23,3,23,297,8,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,5,23,311,8,23,10,23,12,23,314,9,23,1,24,1,24,1,24,1,24,3,24,320,8,24,1,24,1,24,1,24,3,24,325,8,24,1,24,1,24,1,24,1,24,1,24,3,24,332,8,24,1,24,1,24,1,24,1,24,1,24,1,24,3,24,340,8,24,1,24,3,24,343,8,24,1,24,1,24,1,24,1,24,3,24,349,8,24,1,24,3,24,352,8,24,3,24,354,8,24,1,25,1,25,1,25,3,25,359,8,25,1,25,3,25,362,8,25,1,25,1,25,3,25,366,8,25,1,25,3,25,369,8,25,1,25,1,25,1,26,1,26,1,26,5,26,376,8,26,10,26,12,26,379,9,26,1,27,1,27,1,27,3,27,384,8,27,1,28,1,28,1,28,1,29,1,29,1,29,1,29,1,30,1,30,1,30,1,30,3,30,397,8,30,1,31,1,31,1,31,1,32,1,32,1,32,1,32,1,32,1,32,1,32,3,32,409,8,32,1,33,1,33,5,33,413,8,33,10,33,12,33,416,9,33,1,33,1,33,1,34,1,34,1,35,1,35,1,35,1,35,1,35,5,35,427,8,35,10,35,12,35,430,9,35,1,35,1,35,1,36,1,36,1,37,1,37,1,38,1,38,1,38,1,38,1,39,1,39,1,40,1,40,1,40,1,40,1,40,1,40,3,40,450,8,40,1,40,0,2,42,46,41,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,0,7,2,0,35,35,48,48,1,0,24,27,1,0,18,19,2,0,12,13,15,15,1,0,10,11,1,0,52,54,5,0,32,32,35,37,39,42,44,44,48,48,490,0,85,1,0,0,0,2,90,1,0,0,0,4,119,1,0,0,0,6,127,1,0,0,0,8,131,1,0,0,0,10,149,1,0,0,0,12,151,1,0,0,0,14,160,1,0,0,0,16,170,1,0,0,0,18,179,1,0,0,0,20,185,1,0,0,0,22,196,1,0,0,0,24,208,1,0,0,0,26,217,1,0,0,0,28,223,1,0,0,0,30,228,1,0,0,0,32,231,1,0,0,0,34,233,1,0,0,0,36,241,1,0,0,0,38,245,1,0,0,0,40,258,1,0,0,0,42,266,1,0,0,0,44,285,1,0,0,0,46,296,1,0,0,0,48,353,1,0,0,0,50,355,1,0,0,0,52,372,1,0,0,0,54,383,1,0,0,0,56,385,1,0,0,0,58,388,1,0,0,0,60,396,1,0,0,0,62,398,1,0,0,0,64,408,1,0,0,0,66,410,1,0,0,0,68,419,1,0,0,0,70,421,1,0,0,0,72,433,1,0,0,0,74,435,1,0,0,0,76,437,1,0,0,0,78,441,1,0,0,0,80,449,1,0,0,0,82,84,3,2,1,0,83,82,1,0,0,0,84,87,1,0,0,0,85,83,1,0,0,0,85,86,1,0,0,0,86,88,1,0,0,0,87,85,1,0,0,0,88,89,5,0,0,1,89,1,1,0,0,0,90,91,5,6,0,0,91,92,3,78,39,0,92,93,5,5,0,0,93,95,3,78,39,0,94,96,5,12,0,0,95,94,1,0,0,0,95,96,1,0,0,0,96,97,1,0,0,0,97,111,5,7,0,0,98,100,5,1,0,0,99,101,3,4,2,0,100,99,1,0,0,0,100,101,1,0,0,0,101,102,1,0,0,0,102,103,5,2,0,0,103,109,1,0,0,0,104,106,5,1,0,0,105,107,3,8,4,0,106,105,1,0,0,0,106,107,1,0,0,0,107,108,1,0,0,0,108,110,5,2,0,0,109,104,1,0,0,0,109,110,1,0,0,0,110,112,1,0,0,0,111,98,1,0,0,0,111,112,1,0,0,0,112,116,1,0,0,0,113,115,3,10,5,0,114,113,1,0,0,0,115,118,1,0,0,0,116,114,1,0,0,0,116,117,1,0,0,0,117,3,1,0,0,0,118,116,1,0,0,0,119,124,3,6,3,0,120,121,5,5,0,0,121,123,3,6,3,0,122,120,1,0,0,0,123,126,1,0,0,0,124,122,1,0,0,0,124,125,1,0,0,0,125,5,1,0,0,0,126,124,1,0,0,0,127,128,7,0,0,0,128,129,5,20,0,0,129,130,3,80,40,0,130,7,1,0,0,0,131,136,5,48,0,0,132,133,5,5,0,0,133,135,5,48,0,0,134,132,1,0,0,0,135,138,1,0,0,0,136,134,1,0,0,0,136,137,1,0,0,0,137,9,1,0,0,0,138,136,1,0,0,0,139,150,3,12,6,0,140,150,3,14,7,0,141,150,3,16,8,0,142,150,3,18,9,0,143,150,3,20,10,0,144,150,3,24,12,0,145,150,3,26,13,0,146,150,3,28,14,0,147,150,3,30,15,0,148,150,3,32,16,0,149,139,1,0,0,0,149,140,1,0,0,0,149,141,1,0,0,0,149,142,1,0,0,0,149,143,1,0,0,0,149,144,1,0,0,0,149,145,1,0,0,0,149,146,1,0,0,0,149,147,1,0,0,0,149,148,1,0,0,0,150,11,1,0,0,0,151,155,5,8,0,0,152,154,3,10,5,0,153,152,1,0,0,0,154,157,1,0,0,0,155,153,1,0,0,0,155,156,1,0,0,0,156,158,1,0,0,0,157,155,1,0,0,0,158,159,5,9,0,0,159,13,1,0,0,0,160,166,5,33,0,0,161,163,5,1,0,0,162,164,3,34,17,0,163,162,1,0,0,0,163,164,1,0,0,0,164,165,1,0,0,0,165,167,5,2,0,0,166,161,1,0,0,0,166,167,1,0,0,0,167,168,1,0,0,0,168,169,5,4,0,0,169,15,1,0,0,0,170,171,5,28,0,0,171,172,5,1,0,0,172,173,3,42,21,0,173,174,5,2,0,0,174,177,3,10,5,0,175,176,5,29,0,0,176,178,3,10,5,0,177,175,1,0,0,0,177,178,1,0,0,0,178,17,1,0,0,0,179,180,5,30,0,0,180,181,5,1,0,0,181,182,3,42,21,0,182,183,5,2,0,0,183,184,3,10,5,0,184,19,1,0,0,0,185,186,5,37,0,0,186,187,3,36,18,0,187,191,5,8,0,0,188,190,3,22,11,0,189,188,1,0,0,0,190,193,1,0,0,0,191,189,1,0,0,0,191,192,1,0,0,0,192,194,1,0,0,0,193,191,1,0,0,0,194,195,5,9,0,0,195,21,1,0,0,0,196,199,5,31,0,0,197,200,5,32,0,0,198,200,3,34,17,0,199,197,1,0,0,0,199,198,1,0,0,0,200,201,1,0,0,0,201,205,5,3,0,0,202,204,3,10,5,0,203,202,1,0,0,0,204,207,1,0,0,0,205,203,1,0,0,0,205,206,1,0,0,0,206,23,1,0,0,0,207,205,1,0,0,0,208,209,5,36,0,0,209,210,5,20,0,0,210,213,3,80,40,0,211,212,5,18,0,0,212,214,3,40,20,0,213,211,1,0,0,0,213,214,1,0,0,0,214,215,1,0,0,0,215,216,5,4,0,0,216,25,1,0,0,0,217,218,5,36,0,0,218,219,5,20,0,0,219,220,3,80,40,0,220,221,3,36,18,0,221,222,5,4,0,0,222,27,1,0,0,0,223,224,3,52,26,0,224,225,5,18,0,0,225,226,3,34,17,0,226,227,5,4,0,0,227,29,1,0,0,0,228,229,3,40,20,0,229,230,5,4,0,0,230,31,1,0,0,0,231,232,5,4,0,0,232,33,1,0,0,0,233,238,3,40,20,0,234,235,5,5,0,0,235,237,3,40,20,0,236,234,1,0,0,0,237,240,1,0,0,0,238,236,1,0,0,0,238,239,1,0,0,0,239,35,1,0,0,0,240,238,1,0,0,0,241,242,5,1,0,0,242,243,3,40,20,0,243,244,5,2,0,0,244,37,1,0,0,0,245,246,3,40,20,0,246,247,5,0,0,1,247,39,1,0,0,0,248,259,3,36,18,0,249,259,3,44,22,0,250,259,3,48,24,0,251,259,3,56,28,0,252,259,3,58,29,0,253,259,3,60,30,0,254,259,3,62,31,0,255,259,3,64,32,0,256,259,3,70,35,0,257,259,3,78,39,0,258,248,1,0,0,0,258,249,1,0,0,0,258,250,1,0,0,0,258,251,1,0,0,0,258,252,1,0,0,0,258,253,1,0,0,0,258,254,1,0,0,0,258,255,1,0,0,0,258,256,1,0,0,0,258,257,1,0,0,0,259,41,1,0,0,0,260,261,6,21,-1,0,261,262,5,1,0,0,262,263,3,42,21,0,263,264,5,2,0,0,264,267,1,0,0,0,265,267,3,40,20,0,266,260,1,0,0,0,266,265,1,0,0,0,267,282,1,0,0,0,268,269,10,5,0,0,269,270,7,1,0,0,270,281,3,42,21,6,271,272,10,4,0,0,272,273,7,2,0,0,273,281,3,42,21,5,274,275,10,3,0,0,275,276,5,16,0,0,276,281,3,42,21,4,277,278,10,2,0,0,278,279,5,17,0,0,279,281,3,42,21,3,280,268,1,0,0,0,280,271,1,0,0,0,280,274,1,0,0,0,280,277,1,0,0,0,281,284,1,0,0,0,282,280,1,0,0,0,282,283,1,0,0,0,283,43,1,0,0,0,284,282,1,0,0,0,285,286,5,34,0,0,286,287,5,1,0,0,287,288,3,46,23,0,288,289,5,2,0,0,289,45,1,0,0,0,290,291,6,23,-1,0,291,292,5,1,0,0,292,293,3,46,23,0,293,294,5,2,0,0,294,297,1,0,0,0,295,297,3,40,20,0,296,290,1,0,0,0,296,295,1,0,0,0,297,312,1,0,0,0,298,299,10,5,0,0,299,300,7,3,0,0,300,311,3,46,23,6,301,302,10,4,0,0,302,303,7,4,0,0,303,311,3,46,23,5,304,305,10,3,0,0,305,306,5,16,0,0,306,311,3,46,23,4,307,308,10,2,0,0,308,309,5,17,0,0,309,311,3,46,23,3,310,298,1,0,0,0,310,301,1,0,0,0,310,304,1,0,0,0,310,307,1,0,0,0,311,314,1,0,0,0,312,310,1,0,0,0,312,313,1,0,0,0,313,47,1,0,0,0,314,312,1,0,0,0,315,316,3,78,39,0,316,317,5,12,0,0,317,319,5,1,0,0,318,320,3,34,17,0,319,318,1,0,0,0,319,320,1,0,0,0,320,321,1,0,0,0,321,322,5,2,0,0,322,324,5,1,0,0,323,325,3,34,17,0,324,323,1,0,0,0,324,325,1,0,0,0,325,326,1,0,0,0,326,327,5,2,0,0,327,354,1,0,0,0,328,329,3,78,39,0,329,331,5,1,0,0,330,332,3,34,17,0,331,330,1,0,0,0,331,332,1,0,0,0,332,333,1,0,0,0,333,334,5,2,0,0,334,354,1,0,0,0,335,336,5,22,0,0,336,342,3,78,39,0,337,339,5,1,0,0,338,340,3,34,17,0,339,338,1,0,0,0,339,340,1,0,0,0,340,341,1,0,0,0,341,343,5,2,0,0,342,337,1,0,0,0,342,343,1,0,0,0,343,354,1,0,0,0,344,345,5,23,0,0,345,351,3,78,39,0,346,348,5,1,0,0,347,349,3,34,17,0,348,347,1,0,0,0,348,349,1,0,0,0,349,350,1,0,0,0,350,352,5,2,0,0,351,346,1,0,0,0,351,352,1,0,0,0,352,354,1,0,0,0,353,315,1,0,0,0,353,328,1,0,0,0,353,335,1,0,0,0,353,344,1,0,0,0,354,49,1,0,0,0,355,361,3,78,39,0,356,358,5,1,0,0,357,359,3,34,17,0,358,357,1,0,0,0,358,359,1,0,0,0,359,360,1,0,0,0,360,362,5,2,0,0,361,356,1,0,0,0,361,362,1,0,0,0,362,368,1,0,0,0,363,365,5,8,0,0,364,366,3,34,17,0,365,364,1,0,0,0,365,366,1,0,0,0,366,367,1,0,0,0,367,369,5,9,0,0,368,363,1,0,0,0,368,369,1,0,0,0,369,370,1,0,0,0,370,371,5,0,0,1,371,51,1,0,0,0,372,377,3,54,27,0,373,374,5,5,0,0,374,376,3,54,27,0,375,373,1,0,0,0,376,379,1,0,0,0,377,375,1,0,0,0,377,378,1,0,0,0,378,53,1,0,0,0,379,377,1,0,0,0,380,384,3,56,28,0,381,384,3,58,29,0,382,384,3,60,30,0,383,380,1,0,0,0,383,381,1,0,0,0,383,382,1,0,0,0,384,55,1,0,0,0,385,386,5,20,0,0,386,387,3,80,40,0,387,57,1,0,0,0,388,389,5,20,0,0,389,390,3,80,40,0,390,391,3,36,18,0,391,59,1,0,0,0,392,393,5,15,0,0,393,397,3,80,40,0,394,395,5,14,0,0,395,397,3,80,40,0,396,392,1,0,0,0,396,394,1,0,0,0,397,61,1,0,0,0,398,399,5,21,0,0,399,400,3,80,40,0,400,63,1,0,0,0,401,409,5,38,0,0,402,409,5,39,0,0,403,409,5,40,0,0,404,409,5,42,0,0,405,409,5,43,0,0,406,409,5,44,0,0,407,409,3,66,33,0,408,401,1,0,0,0,408,402,1,0,0,0,408,403,1,0,0,0,408,404,1,0,0,0,408,405,1,0,0,0,408,406,1,0,0,0,408,407,1,0,0,0,409,65,1,0,0,0,410,414,5,47,0,0,411,413,3,68,34,0,412,411,1,0,0,0,413,416,1,0,0,0,414,412,1,0,0,0,414,415,1,0,0,0,415,417,1,0,0,0,416,414,1,0,0,0,417,418,5,50,0,0,418,67,1,0,0,0,419,420,5,51,0,0,420,69,1,0,0,0,421,428,5,47,0,0,422,427,3,68,34,0,423,427,3,72,36,0,424,427,3,74,37,0,425,427,3,76,38,0,426,422,1,0,0,0,426,423,1,0,0,0,426,424,1,0,0,0,426,425,1,0,0,0,427,430,1,0,0,0,428,426,1,0,0,0,428,429,1,0,0,0,429,431,1,0,0,0,430,428,1,0,0,0,431,432,5,50,0,0,432,71,1,0,0,0,433,434,7,5,0,0,434,73,1,0,0,0,435,436,5,55,0,0,436,75,1,0,0,0,437,438,5,56,0,0,438,439,3,40,20,0,439,440,5,57,0,0,440,77,1,0,0,0,441,442,7,6,0,0,442,79,1,0,0,0,443,450,3,78,39,0,444,450,5,28,0,0,445,450,5,29,0,0,446,450,5,30,0,0,447,450,5,33,0,0,448,450,5,34,0,0,449,443,1,0,0,0,449,444,1,0,0,0,449,445,1,0,0,0,449,446,1,0,0,0,449,447,1,0,0,0,449,448,1,0,0,0,450,81,1,0,0,0,46,85,95,100,106,109,111,116,124,136,149,155,163,166,177,191,199,205,213,238,258,266,280,282,296,310,312,319,324,331,339,342,348,351,353,358,361,365,368,377,383,396,408,414,426,428,449];static __ATN;static get _ATN(){if(!Z.__ATN)Z.__ATN=new n0().deserialize(Z._serializedATN);return Z.__ATN}static vocabulary=new D0(Z.literalNames,Z.symbolicNames,[]);get vocabulary(){return Z.vocabulary}static decisionsToDFA=Z._ATN.decisionToState.map((_,A)=>new S0(_,A))}class y4 extends M{constructor(_,A){super(_,A)}EOF(){return this.getToken(Z.EOF,0)}script(_){if(_===void 0)return this.getRuleContexts(K2);return this.getRuleContext(_,K2)}get ruleIndex(){return Z.RULE_scriptFile}accept(_){if(_.visitScriptFile)return _.visitScriptFile(this);else return _.visitChildren(this)}}class K2 extends M{_trigger;_name;constructor(_,A){super(_,A)}LBRACK(){return this.getToken(Z.LBRACK,0)}COMMA(){return this.getToken(Z.COMMA,0)}RBRACK(){return this.getToken(Z.RBRACK,0)}identifier(_){if(_===void 0)return this.getRuleContexts(f0);return this.getRuleContext(_,f0)}MUL(){return this.getToken(Z.MUL,0)}statement(_){if(_===void 0)return this.getRuleContexts(B0);return this.getRuleContext(_,B0)}LPAREN(_){if(_===void 0)return this.getTokens(Z.LPAREN);else return this.getToken(Z.LPAREN,_)}RPAREN(_){if(_===void 0)return this.getTokens(Z.RPAREN);else return this.getToken(Z.RPAREN,_)}parameterList(){return this.getRuleContext(0,f3)}typeList(){return this.getRuleContext(0,h3)}get ruleIndex(){return Z.RULE_script}accept(_){if(_.visitScript)return _.visitScript(this);else return _.visitChildren(this)}}class f3 extends M{constructor(_,A){super(_,A)}parameter(_){if(_===void 0)return this.getRuleContexts(L2);return this.getRuleContext(_,L2)}COMMA(_){if(_===void 0)return this.getTokens(Z.COMMA);else return this.getToken(Z.COMMA,_)}get ruleIndex(){return Z.RULE_parameterList}accept(_){if(_.visitParameterList)return _.visitParameterList(this);else return _.visitChildren(this)}}class L2 extends M{_type_;constructor(_,A){super(_,A)}DOLLAR(){return this.getToken(Z.DOLLAR,0)}advancedIdentifier(){return this.getRuleContext(0,l0)}IDENTIFIER(){return this.getToken(Z.IDENTIFIER,0)}TYPE_ARRAY(){return this.getToken(Z.TYPE_ARRAY,0)}get ruleIndex(){return Z.RULE_parameter}accept(_){if(_.visitParameter)return _.visitParameter(this);else return _.visitChildren(this)}}class h3 extends M{constructor(_,A){super(_,A)}IDENTIFIER(_){if(_===void 0)return this.getTokens(Z.IDENTIFIER);else return this.getToken(Z.IDENTIFIER,_)}COMMA(_){if(_===void 0)return this.getTokens(Z.COMMA);else return this.getToken(Z.COMMA,_)}get ruleIndex(){return Z.RULE_typeList}accept(_){if(_.visitTypeList)return _.visitTypeList(this);else return _.visitChildren(this)}}class B0 extends M{constructor(_,A){super(_,A)}blockStatement(){return this.getRuleContext(0,V3)}returnStatement(){return this.getRuleContext(0,P3)}ifStatement(){return this.getRuleContext(0,v3)}whileStatement(){return this.getRuleContext(0,b3)}switchStatement(){return this.getRuleContext(0,u3)}declarationStatement(){return this.getRuleContext(0,S3)}arrayDeclarationStatement(){return this.getRuleContext(0,x3)}assignmentStatement(){return this.getRuleContext(0,m3)}expressionStatement(){return this.getRuleContext(0,g3)}emptyStatement(){return this.getRuleContext(0,d3)}get ruleIndex(){return Z.RULE_statement}accept(_){if(_.visitStatement)return _.visitStatement(this);else return _.visitChildren(this)}}class V3 extends M{constructor(_,A){super(_,A)}LBRACE(){return this.getToken(Z.LBRACE,0)}RBRACE(){return this.getToken(Z.RBRACE,0)}statement(_){if(_===void 0)return this.getRuleContexts(B0);return this.getRuleContext(_,B0)}get ruleIndex(){return Z.RULE_blockStatement}accept(_){if(_.visitBlockStatement)return _.visitBlockStatement(this);else return _.visitChildren(this)}}class P3 extends M{constructor(_,A){super(_,A)}RETURN(){return this.getToken(Z.RETURN,0)}SEMICOLON(){return this.getToken(Z.SEMICOLON,0)}LPAREN(){return this.getToken(Z.LPAREN,0)}RPAREN(){return this.getToken(Z.RPAREN,0)}expressionList(){return this.getRuleContext(0,w0)}get ruleIndex(){return Z.RULE_returnStatement}accept(_){if(_.visitReturnStatement)return _.visitReturnStatement(this);else return _.visitChildren(this)}}class v3 extends M{constructor(_,A){super(_,A)}IF(){return this.getToken(Z.IF,0)}LPAREN(){return this.getToken(Z.LPAREN,0)}condition(){return this.getRuleContext(0,X0)}RPAREN(){return this.getToken(Z.RPAREN,0)}statement(_){if(_===void 0)return this.getRuleContexts(B0);return this.getRuleContext(_,B0)}ELSE(){return this.getToken(Z.ELSE,0)}get ruleIndex(){return Z.RULE_ifStatement}accept(_){if(_.visitIfStatement)return _.visitIfStatement(this);else return _.visitChildren(this)}}class b3 extends M{constructor(_,A){super(_,A)}WHILE(){return this.getToken(Z.WHILE,0)}LPAREN(){return this.getToken(Z.LPAREN,0)}condition(){return this.getRuleContext(0,X0)}RPAREN(){return this.getToken(Z.RPAREN,0)}statement(){return this.getRuleContext(0,B0)}get ruleIndex(){return Z.RULE_whileStatement}accept(_){if(_.visitWhileStatement)return _.visitWhileStatement(this);else return _.visitChildren(this)}}class u3 extends M{constructor(_,A){super(_,A)}SWITCH_TYPE(){return this.getToken(Z.SWITCH_TYPE,0)}parenthesis(){return this.getRuleContext(0,M1)}LBRACE(){return this.getToken(Z.LBRACE,0)}RBRACE(){return this.getToken(Z.RBRACE,0)}switchCase(_){if(_===void 0)return this.getRuleContexts(D2);return this.getRuleContext(_,D2)}get ruleIndex(){return Z.RULE_switchStatement}accept(_){if(_.visitSwitchStatement)return _.visitSwitchStatement(this);else return _.visitChildren(this)}}class D2 extends M{constructor(_,A){super(_,A)}CASE(){return this.getToken(Z.CASE,0)}COLON(){return this.getToken(Z.COLON,0)}DEFAULT(){return this.getToken(Z.DEFAULT,0)}expressionList(){return this.getRuleContext(0,w0)}statement(_){if(_===void 0)return this.getRuleContexts(B0);return this.getRuleContext(_,B0)}get ruleIndex(){return Z.RULE_switchCase}accept(_){if(_.visitSwitchCase)return _.visitSwitchCase(this);else return _.visitChildren(this)}}class S3 extends M{constructor(_,A){super(_,A)}DEF_TYPE(){return this.getToken(Z.DEF_TYPE,0)}DOLLAR(){return this.getToken(Z.DOLLAR,0)}advancedIdentifier(){return this.getRuleContext(0,l0)}SEMICOLON(){return this.getToken(Z.SEMICOLON,0)}EQ(){return this.getToken(Z.EQ,0)}expression(){return this.getRuleContext(0,g)}get ruleIndex(){return Z.RULE_declarationStatement}accept(_){if(_.visitDeclarationStatement)return _.visitDeclarationStatement(this);else return _.visitChildren(this)}}class x3 extends M{constructor(_,A){super(_,A)}DEF_TYPE(){return this.getToken(Z.DEF_TYPE,0)}DOLLAR(){return this.getToken(Z.DOLLAR,0)}advancedIdentifier(){return this.getRuleContext(0,l0)}parenthesis(){return this.getRuleContext(0,M1)}SEMICOLON(){return this.getToken(Z.SEMICOLON,0)}get ruleIndex(){return Z.RULE_arrayDeclarationStatement}accept(_){if(_.visitArrayDeclarationStatement)return _.visitArrayDeclarationStatement(this);else return _.visitChildren(this)}}class m3 extends M{constructor(_,A){super(_,A)}assignableVariableList(){return this.getRuleContext(0,T3)}EQ(){return this.getToken(Z.EQ,0)}expressionList(){return this.getRuleContext(0,w0)}SEMICOLON(){return this.getToken(Z.SEMICOLON,0)}get ruleIndex(){return Z.RULE_assignmentStatement}accept(_){if(_.visitAssignmentStatement)return _.visitAssignmentStatement(this);else return _.visitChildren(this)}}class g3 extends M{constructor(_,A){super(_,A)}expression(){return this.getRuleContext(0,g)}SEMICOLON(){return this.getToken(Z.SEMICOLON,0)}get ruleIndex(){return Z.RULE_expressionStatement}accept(_){if(_.visitExpressionStatement)return _.visitExpressionStatement(this);else return _.visitChildren(this)}}class d3 extends M{constructor(_,A){super(_,A)}SEMICOLON(){return this.getToken(Z.SEMICOLON,0)}get ruleIndex(){return Z.RULE_emptyStatement}accept(_){if(_.visitEmptyStatement)return _.visitEmptyStatement(this);else return _.visitChildren(this)}}class w0 extends M{constructor(_,A){super(_,A)}expression(_){if(_===void 0)return this.getRuleContexts(g);return this.getRuleContext(_,g)}COMMA(_){if(_===void 0)return this.getTokens(Z.COMMA);else return this.getToken(Z.COMMA,_)}get ruleIndex(){return Z.RULE_expressionList}accept(_){if(_.visitExpressionList)return _.visitExpressionList(this);else return _.visitChildren(this)}}class M1 extends M{constructor(_,A){super(_,A)}LPAREN(){return this.getToken(Z.LPAREN,0)}expression(){return this.getRuleContext(0,g)}RPAREN(){return this.getToken(Z.RPAREN,0)}get ruleIndex(){return Z.RULE_parenthesis}accept(_){if(_.visitParenthesis)return _.visitParenthesis(this);else return _.visitChildren(this)}}class c4 extends M{constructor(_,A){super(_,A)}expression(){return this.getRuleContext(0,g)}EOF(){return this.getToken(Z.EOF,0)}get ruleIndex(){return Z.RULE_singleExpression}accept(_){if(_.visitSingleExpression)return _.visitSingleExpression(this);else return _.visitChildren(this)}}class g extends M{constructor(_,A){super(_,A)}get ruleIndex(){return Z.RULE_expression}copyFrom(_){super.copyFrom(_)}}class a4 extends g{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}parenthesis(){return this.getRuleContext(0,M1)}accept(_){if(_.visitParenthesizedExpression)return _.visitParenthesizedExpression(this);else return _.visitChildren(this)}}class s4 extends g{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}calc(){return this.getRuleContext(0,l3)}accept(_){if(_.visitCalcExpression)return _.visitCalcExpression(this);else return _.visitChildren(this)}}class n4 extends g{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}call(){return this.getRuleContext(0,f1)}accept(_){if(_.visitCallExpression)return _.visitCallExpression(this);else return _.visitChildren(this)}}class p4 extends g{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}localVariable(){return this.getRuleContext(0,w2)}accept(_){if(_.visitLocalVariableExpression)return _.visitLocalVariableExpression(this);else return _.visitChildren(this)}}class o4 extends g{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}localArrayVariable(){return this.getRuleContext(0,E2)}accept(_){if(_.visitLocalArrayVariableExpression)return _.visitLocalArrayVariableExpression(this);else return _.visitChildren(this)}}class i4 extends g{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}gameVariable(){return this.getRuleContext(0,k2)}accept(_){if(_.visitGameVariableExpression)return _.visitGameVariableExpression(this);else return _.visitChildren(this)}}class t4 extends g{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}constantVariable(){return this.getRuleContext(0,y3)}accept(_){if(_.visitConstantVariableExpression)return _.visitConstantVariableExpression(this);else return _.visitChildren(this)}}class r4 extends g{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}literal(){return this.getRuleContext(0,d0)}accept(_){if(_.visitLiteralExpression)return _.visitLiteralExpression(this);else return _.visitChildren(this)}}class e4 extends g{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}joinedString(){return this.getRuleContext(0,a3)}accept(_){if(_.visitJoinedStringExpression)return _.visitJoinedStringExpression(this);else return _.visitChildren(this)}}class _5 extends g{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}identifier(){return this.getRuleContext(0,f0)}accept(_){if(_.visitIdentifierExpression)return _.visitIdentifierExpression(this);else return _.visitChildren(this)}}class X0 extends M{constructor(_,A){super(_,A)}get ruleIndex(){return Z.RULE_condition}copyFrom(_){super.copyFrom(_)}}class A5 extends X0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}LPAREN(){return this.getToken(Z.LPAREN,0)}condition(){return this.getRuleContext(0,X0)}RPAREN(){return this.getToken(Z.RPAREN,0)}accept(_){if(_.visitConditionParenthesizedExpression)return _.visitConditionParenthesizedExpression(this);else return _.visitChildren(this)}}class R5 extends X0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}expression(){return this.getRuleContext(0,g)}accept(_){if(_.visitConditionNormalExpression)return _.visitConditionNormalExpression(this);else return _.visitChildren(this)}}class A2 extends X0{_op;constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}condition(_){if(_===void 0)return this.getRuleContexts(X0);return this.getRuleContext(_,X0)}LT(){return this.getToken(Z.LT,0)}GT(){return this.getToken(Z.GT,0)}LTE(){return this.getToken(Z.LTE,0)}GTE(){return this.getToken(Z.GTE,0)}EQ(){return this.getToken(Z.EQ,0)}EXCL(){return this.getToken(Z.EXCL,0)}AND(){return this.getToken(Z.AND,0)}OR(){return this.getToken(Z.OR,0)}accept(_){if(_.visitConditionBinaryExpression)return _.visitConditionBinaryExpression(this);else return _.visitChildren(this)}}class l3 extends M{constructor(_,A){super(_,A)}CALC(){return this.getToken(Z.CALC,0)}LPAREN(){return this.getToken(Z.LPAREN,0)}arithmetic(){return this.getRuleContext(0,Q0)}RPAREN(){return this.getToken(Z.RPAREN,0)}get ruleIndex(){return Z.RULE_calc}accept(_){if(_.visitCalc)return _.visitCalc(this);else return _.visitChildren(this)}}class Q0 extends M{constructor(_,A){super(_,A)}get ruleIndex(){return Z.RULE_arithmetic}copyFrom(_){super.copyFrom(_)}}class U5 extends Q0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}LPAREN(){return this.getToken(Z.LPAREN,0)}arithmetic(){return this.getRuleContext(0,Q0)}RPAREN(){return this.getToken(Z.RPAREN,0)}accept(_){if(_.visitArithmeticParenthesizedExpression)return _.visitArithmeticParenthesizedExpression(this);else return _.visitChildren(this)}}class Y5 extends Q0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}expression(){return this.getRuleContext(0,g)}accept(_){if(_.visitArithmeticNormalExpression)return _.visitArithmeticNormalExpression(this);else return _.visitChildren(this)}}class R2 extends Q0{_op;constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}arithmetic(_){if(_===void 0)return this.getRuleContexts(Q0);return this.getRuleContext(_,Q0)}MUL(){return this.getToken(Z.MUL,0)}DIV(){return this.getToken(Z.DIV,0)}MOD(){return this.getToken(Z.MOD,0)}PLUS(){return this.getToken(Z.PLUS,0)}MINUS(){return this.getToken(Z.MINUS,0)}AND(){return this.getToken(Z.AND,0)}OR(){return this.getToken(Z.OR,0)}accept(_){if(_.visitArithmeticBinaryExpression)return _.visitArithmeticBinaryExpression(this);else return _.visitChildren(this)}}class f1 extends M{constructor(_,A){super(_,A)}get ruleIndex(){return Z.RULE_call}copyFrom(_){super.copyFrom(_)}}class O3 extends f1{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}identifier(){return this.getRuleContext(0,f0)}MUL(){return this.getToken(Z.MUL,0)}LPAREN(_){if(_===void 0)return this.getTokens(Z.LPAREN);else return this.getToken(Z.LPAREN,_)}RPAREN(_){if(_===void 0)return this.getTokens(Z.RPAREN);else return this.getToken(Z.RPAREN,_)}expressionList(_){if(_===void 0)return this.getRuleContexts(w0);return this.getRuleContext(_,w0)}accept(_){if(_.visitCommandCallExpression)return _.visitCommandCallExpression(this);else return _.visitChildren(this)}}class X5 extends f1{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}TILDE(){return this.getToken(Z.TILDE,0)}identifier(){return this.getRuleContext(0,f0)}LPAREN(){return this.getToken(Z.LPAREN,0)}RPAREN(){return this.getToken(Z.RPAREN,0)}expressionList(){return this.getRuleContext(0,w0)}accept(_){if(_.visitProcCallExpression)return _.visitProcCallExpression(this);else return _.visitChildren(this)}}class G5 extends f1{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}AT(){return this.getToken(Z.AT,0)}identifier(){return this.getRuleContext(0,f0)}LPAREN(){return this.getToken(Z.LPAREN,0)}RPAREN(){return this.getToken(Z.RPAREN,0)}expressionList(){return this.getRuleContext(0,w0)}accept(_){if(_.visitJumpCallExpression)return _.visitJumpCallExpression(this);else return _.visitChildren(this)}}class N5 extends M{_args;_triggers;constructor(_,A){super(_,A)}identifier(){return this.getRuleContext(0,f0)}EOF(){return this.getToken(Z.EOF,0)}LPAREN(){return this.getToken(Z.LPAREN,0)}RPAREN(){return this.getToken(Z.RPAREN,0)}LBRACE(){return this.getToken(Z.LBRACE,0)}RBRACE(){return this.getToken(Z.RBRACE,0)}expressionList(_){if(_===void 0)return this.getRuleContexts(w0);return this.getRuleContext(_,w0)}get ruleIndex(){return Z.RULE_clientScript}accept(_){if(_.visitClientScript)return _.visitClientScript(this);else return _.visitChildren(this)}}class T3 extends M{constructor(_,A){super(_,A)}assignableVariable(_){if(_===void 0)return this.getRuleContexts(B2);return this.getRuleContext(_,B2)}COMMA(_){if(_===void 0)return this.getTokens(Z.COMMA);else return this.getToken(Z.COMMA,_)}get ruleIndex(){return Z.RULE_assignableVariableList}accept(_){if(_.visitAssignableVariableList)return _.visitAssignableVariableList(this);else return _.visitChildren(this)}}class B2 extends M{constructor(_,A){super(_,A)}localVariable(){return this.getRuleContext(0,w2)}localArrayVariable(){return this.getRuleContext(0,E2)}gameVariable(){return this.getRuleContext(0,k2)}get ruleIndex(){return Z.RULE_assignableVariable}accept(_){if(_.visitAssignableVariable)return _.visitAssignableVariable(this);else return _.visitChildren(this)}}class w2 extends M{constructor(_,A){super(_,A)}DOLLAR(){return this.getToken(Z.DOLLAR,0)}advancedIdentifier(){return this.getRuleContext(0,l0)}get ruleIndex(){return Z.RULE_localVariable}accept(_){if(_.visitLocalVariable)return _.visitLocalVariable(this);else return _.visitChildren(this)}}class E2 extends M{constructor(_,A){super(_,A)}DOLLAR(){return this.getToken(Z.DOLLAR,0)}advancedIdentifier(){return this.getRuleContext(0,l0)}parenthesis(){return this.getRuleContext(0,M1)}get ruleIndex(){return Z.RULE_localArrayVariable}accept(_){if(_.visitLocalArrayVariable)return _.visitLocalArrayVariable(this);else return _.visitChildren(this)}}class k2 extends M{constructor(_,A){super(_,A)}MOD(){return this.getToken(Z.MOD,0)}advancedIdentifier(){return this.getRuleContext(0,l0)}DOTMOD(){return this.getToken(Z.DOTMOD,0)}get ruleIndex(){return Z.RULE_gameVariable}accept(_){if(_.visitGameVariable)return _.visitGameVariable(this);else return _.visitChildren(this)}}class y3 extends M{constructor(_,A){super(_,A)}CARET(){return this.getToken(Z.CARET,0)}advancedIdentifier(){return this.getRuleContext(0,l0)}get ruleIndex(){return Z.RULE_constantVariable}accept(_){if(_.visitConstantVariable)return _.visitConstantVariable(this);else return _.visitChildren(this)}}class d0 extends M{constructor(_,A){super(_,A)}get ruleIndex(){return Z.RULE_literal}copyFrom(_){super.copyFrom(_)}}class M3 extends d0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}INTEGER_LITERAL(){return this.getToken(Z.INTEGER_LITERAL,0)}HEX_LITERAL(){return this.getToken(Z.HEX_LITERAL,0)}accept(_){if(_.visitIntegerLiteral)return _.visitIntegerLiteral(this);else return _.visitChildren(this)}}class Q5 extends d0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}COORD_LITERAL(){return this.getToken(Z.COORD_LITERAL,0)}accept(_){if(_.visitCoordLiteral)return _.visitCoordLiteral(this);else return _.visitChildren(this)}}class Z5 extends d0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}BOOLEAN_LITERAL(){return this.getToken(Z.BOOLEAN_LITERAL,0)}accept(_){if(_.visitBooleanLiteral)return _.visitBooleanLiteral(this);else return _.visitChildren(this)}}class J5 extends d0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}CHAR_LITERAL(){return this.getToken(Z.CHAR_LITERAL,0)}accept(_){if(_.visitCharacterLiteral)return _.visitCharacterLiteral(this);else return _.visitChildren(this)}}class H5 extends d0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}NULL_LITERAL(){return this.getToken(Z.NULL_LITERAL,0)}accept(_){if(_.visitNullLiteral)return _.visitNullLiteral(this);else return _.visitChildren(this)}}class $5 extends d0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}stringLiteral(){return this.getRuleContext(0,c3)}accept(_){if(_.visitStringLiteralExpression)return _.visitStringLiteralExpression(this);else return _.visitChildren(this)}}class c3 extends M{constructor(_,A){super(_,A)}QUOTE_OPEN(){return this.getToken(Z.QUOTE_OPEN,0)}QUOTE_CLOSE(){return this.getToken(Z.QUOTE_CLOSE,0)}stringLiteralContent(_){if(_===void 0)return this.getRuleContexts(t0);return this.getRuleContext(_,t0)}get ruleIndex(){return Z.RULE_stringLiteral}accept(_){if(_.visitStringLiteral)return _.visitStringLiteral(this);else return _.visitChildren(this)}}class t0 extends M{constructor(_,A){super(_,A)}STRING_TEXT(){return this.getToken(Z.STRING_TEXT,0)}get ruleIndex(){return Z.RULE_stringLiteralContent}accept(_){if(_.visitStringLiteralContent)return _.visitStringLiteralContent(this);else return _.visitChildren(this)}}class a3 extends M{constructor(_,A){super(_,A)}QUOTE_OPEN(){return this.getToken(Z.QUOTE_OPEN,0)}QUOTE_CLOSE(){return this.getToken(Z.QUOTE_CLOSE,0)}stringLiteralContent(_){if(_===void 0)return this.getRuleContexts(t0);return this.getRuleContext(_,t0)}stringTag(_){if(_===void 0)return this.getRuleContexts(C1);return this.getRuleContext(_,C1)}stringPTag(_){if(_===void 0)return this.getRuleContexts(j1);return this.getRuleContext(_,j1)}stringExpression(_){if(_===void 0)return this.getRuleContexts(O1);return this.getRuleContext(_,O1)}get ruleIndex(){return Z.RULE_joinedString}accept(_){if(_.visitJoinedString)return _.visitJoinedString(this);else return _.visitChildren(this)}}class C1 extends M{constructor(_,A){super(_,A)}STRING_TAG(){return this.getToken(Z.STRING_TAG,0)}STRING_CLOSE_TAG(){return this.getToken(Z.STRING_CLOSE_TAG,0)}STRING_PARTIAL_TAG(){return this.getToken(Z.STRING_PARTIAL_TAG,0)}get ruleIndex(){return Z.RULE_stringTag}accept(_){if(_.visitStringTag)return _.visitStringTag(this);else return _.visitChildren(this)}}class j1 extends M{constructor(_,A){super(_,A)}STRING_P_TAG(){return this.getToken(Z.STRING_P_TAG,0)}get ruleIndex(){return Z.RULE_stringPTag}accept(_){if(_.visitStringPTag)return _.visitStringPTag(this);else return _.visitChildren(this)}}class O1 extends M{constructor(_,A){super(_,A)}STRING_EXPR_START(){return this.getToken(Z.STRING_EXPR_START,0)}expression(){return this.getRuleContext(0,g)}STRING_EXPR_END(){return this.getToken(Z.STRING_EXPR_END,0)}get ruleIndex(){return Z.RULE_stringExpression}accept(_){if(_.visitStringExpression)return _.visitStringExpression(this);else return _.visitChildren(this)}}class f0 extends M{constructor(_,A){super(_,A)}IDENTIFIER(){return this.getToken(Z.IDENTIFIER,0)}HEX_LITERAL(){return this.getToken(Z.HEX_LITERAL,0)}BOOLEAN_LITERAL(){return this.getToken(Z.BOOLEAN_LITERAL,0)}NULL_LITERAL(){return this.getToken(Z.NULL_LITERAL,0)}COORD_LITERAL(){return this.getToken(Z.COORD_LITERAL,0)}MAPZONE_LITERAL(){return this.getToken(Z.MAPZONE_LITERAL,0)}TYPE_ARRAY(){return this.getToken(Z.TYPE_ARRAY,0)}SWITCH_TYPE(){return this.getToken(Z.SWITCH_TYPE,0)}DEF_TYPE(){return this.getToken(Z.DEF_TYPE,0)}DEFAULT(){return this.getToken(Z.DEFAULT,0)}get ruleIndex(){return Z.RULE_identifier}accept(_){if(_.visitIdentifier)return _.visitIdentifier(this);else return _.visitChildren(this)}}class l0 extends M{constructor(_,A){super(_,A)}identifier(){return this.getRuleContext(0,f0)}IF(){return this.getToken(Z.IF,0)}ELSE(){return this.getToken(Z.ELSE,0)}WHILE(){return this.getToken(Z.WHILE,0)}RETURN(){return this.getToken(Z.RETURN,0)}CALC(){return this.getToken(Z.CALC,0)}get ruleIndex(){return Z.RULE_advancedIdentifier}accept(_){if(_.visitAdvancedIdentifier)return _.visitAdvancedIdentifier(this);else return _.visitChildren(this)}}class s3 extends x4{visitScriptFile;visitScript;visitParameterList;visitParameter;visitTypeList;visitStatement;visitBlockStatement;visitReturnStatement;visitIfStatement;visitWhileStatement;visitSwitchStatement;visitSwitchCase;visitDeclarationStatement;visitArrayDeclarationStatement;visitAssignmentStatement;visitExpressionStatement;visitEmptyStatement;visitExpressionList;visitParenthesis;visitSingleExpression;visitParenthesizedExpression;visitCalcExpression;visitCallExpression;visitLocalVariableExpression;visitLocalArrayVariableExpression;visitGameVariableExpression;visitConstantVariableExpression;visitLiteralExpression;visitJoinedStringExpression;visitIdentifierExpression;visitConditionParenthesizedExpression;visitConditionNormalExpression;visitConditionBinaryExpression;visitCalc;visitArithmeticParenthesizedExpression;visitArithmeticNormalExpression;visitArithmeticBinaryExpression;visitCommandCallExpression;visitProcCallExpression;visitJumpCallExpression;visitClientScript;visitAssignableVariableList;visitAssignableVariable;visitLocalVariable;visitLocalArrayVariable;visitGameVariable;visitConstantVariable;visitIntegerLiteral;visitCoordLiteral;visitBooleanLiteral;visitCharacterLiteral;visitNullLiteral;visitStringLiteralExpression;visitStringLiteral;visitStringLiteralContent;visitJoinedString;visitStringTag;visitStringPTag;visitStringExpression;visitIdentifier;visitAdvancedIdentifier}class n3 extends s3{source;lineOffset;columnOffset;constructor(_,A,R){super();this.source=_,this.lineOffset=A,this.columnOffset=R}visitScriptFile=(_)=>{return new G3(this.location(_),_.script().map((A)=>this.visitNode(A)))};visitScript=(_)=>{let A=_.typeList()?.IDENTIFIER()?.map((R)=>this.toAstToken(R.symbol));return new p0({source:this.location(_),trigger:this.visitNode(_._trigger),name:this.visitNode(_._name),isStar:_.MUL()!==null,parameters:_.parameterList()?.parameter().map((R)=>this.visitNode(R))??null,returnTokens:A??null,statements:_.statement().map((R)=>this.visitNode(R))})};visitParameter=(_)=>{return new N3(this.location(_),this.toAstToken(_._type_),this.visitNode(_.advancedIdentifier()))};visitBlockStatement=(_)=>{return new Q3(this.location(_),_.statement().map((A)=>this.visitNode(A)))};visitReturnStatement=(_)=>{return new J3(this.location(_),this.collectExpressionList(_.expressionList()))};visitIfStatement=(_)=>{let A=_.statement();if(!A[0])throw Error("IfStatement missing then statement.");return new H3(this.location(_),this.visitNode(_.condition()),this.visitNode(A[0]),A.length>1?this.visitNode(A[1]):null)};visitWhileStatement=(_)=>{return new $3(this.location(_),this.visitNode(_.condition()),this.visitNode(_.statement()))};visitSwitchStatement=(_)=>{return new i1(this.location(_),this.toAstToken(_.SWITCH_TYPE().symbol),this.extractParenthesisExpression(_.parenthesis()),_.switchCase().map((A)=>this.visitNode(A)))};visitSwitchCase=(_)=>{return new F3(this.location(_),this.collectExpressionList(_.expressionList()),_.statement()?.map((A)=>this.visitNode(A))??[])};visitDeclarationStatement=(_)=>{return new I3(this.location(_),this.toAstToken(_.DEF_TYPE().symbol),this.visitNode(_.advancedIdentifier()),_.expression()?this.visitNode(_.expression()):null)};visitArrayDeclarationStatement=(_)=>{return new W3(this.location(_),this.toAstToken(_.DEF_TYPE().symbol),this.visitNode(_.advancedIdentifier()),this.extractParenthesisExpression(_.parenthesis()))};visitAssignmentStatement=(_)=>{return new q3(this.location(_),_.assignableVariableList().assignableVariable().map((A)=>this.visitNode(A)),this.collectExpressionList(_.expressionList()))};visitExpressionStatement=(_)=>{return new z3(this.location(_),this.visitNode(_.expression()))};visitEmptyStatement=(_)=>{return new K3(this.location(_))};visitSingleExpression=(_)=>{return this.visitNode(_.expression())};visitParenthesizedExpression=(_)=>{return new x0(this.location(_),this.extractParenthesisExpression(_.parenthesis()))};visitConditionParenthesizedExpression=(_)=>{return new x0(this.location(_),this.visitNode(_.condition()))};visitArithmeticParenthesizedExpression=(_)=>{return new x0(this.location(_),this.visitNode(_.arithmetic()))};visitConditionBinaryExpression=(_)=>{return new J1(this.location(_),this.visitNode(_.condition(0)),this.toAstToken(_._op),this.visitNode(_.condition(1)))};visitArithmeticBinaryExpression=(_)=>{return new L3(this.location(_),this.visitNode(_.arithmetic(0)),this.toAstToken(_._op),this.visitNode(_.arithmetic(1)))};visitCalcExpression=(_)=>{return new D3(this.location(_),this.visitNode(_.calc().arithmetic()))};visitCommandCallExpression=(_)=>{let A=_.expressionList(),R=Array.isArray(A)?A:A?[A]:[],U=_.MUL()!==null?this.collectExpressionList(R[1]):null;return new M0(this.location(_),this.visitNode(_.identifier()),this.collectExpressionList(R[0]),U)};visitProcCallExpression=(_)=>{let A=_.expressionList(),R=Array.isArray(A)?A:A?[A]:[];return new t1(this.location(_),this.visitNode(_.identifier()),this.collectExpressionList(R[0]))};visitJumpCallExpression=(_)=>{let A=_.expressionList(),R=Array.isArray(A)?A:A?[A]:[];return new r1(this.location(_),this.visitNode(_.identifier()),this.collectExpressionList(R[0]))};visitClientScript=(_)=>{return new e1(this.location(_),this.visitNode(_.identifier()),this.collectExpressionList(_._args),this.collectExpressionList(_._triggers))};visitLocalVariable=(_)=>{return new o0(this.location(_),this.visitNode(_.advancedIdentifier()),null)};visitLocalArrayVariable=(_)=>{return new o0(this.location(_),this.visitNode(_.advancedIdentifier()),this.extractParenthesisExpression(_.parenthesis()))};visitGameVariable=(_)=>{let A=_.DOTMOD()!==null;return new _2(this.location(_),A,this.visitNode(_.advancedIdentifier()))};visitConstantVariable=(_)=>{return new Z1(this.location(_),this.visitNode(_.advancedIdentifier()))};visitIntegerLiteral=(_)=>{let A=_.getText();if(A.length>1&&A[0]==="0"&&(A[1]==="x"||A[1]==="X"))return new z2(this.location(_),parseInt(A.slice(2),16));return new z2(this.location(_),parseInt(A,10))};visitCoordLiteral=(_)=>{let R=_.getText().split("_").map((Q)=>parseInt(Q,10)),U=R[1]<<6|R[3]&16383,Y=R[2]<<6|R[4]&16383,X=R[0]&3,G=Y|U<<14|X<<28|0;return new B3(this.location(_),G)};visitBooleanLiteral=(_)=>{return new w3(this.location(_),_.getText()==="true")};visitCharacterLiteral=(_)=>{let A=this.unescape(_.getText().slice(1,-1));if(A.length!==1)throw Error(`invalid character literal: text=${_.getText()}, cleaned=${A}`);return new E3(this.location(_),A)};visitStringLiteral=(_)=>{return new i0(this.location(_),this.unescape(_.getText().slice(1,-1)))};visitNullLiteral=(_)=>{return new Z3(this.location(_))};visitJoinedString=(_)=>{let A=[];for(let R of _.children??[])if(R instanceof t0)A.push(new m0(this.location(R),this.unescape(R.getText())));else if(R instanceof C1)A.push(new m0(this.location(R),R.getText()));else if(R instanceof j1)A.push(new j3(this.location(R),R.getText()));else if(R instanceof O1){let U=this.visitNode(R.expression());A.push(new g0(this.location(R),U))}return new k3(this.location(_),A)};visitIdentifier=(_)=>{return new Y0(this.location(_),_.getText())};visitAdvancedIdentifier=(_)=>{return new Y0(this.location(_),_.getText())};visitConditionNormalExpression=(_)=>{return this.visitNode(_.expression())};visitArithmeticNormalExpression=(_)=>{return this.visitNode(_.expression())};visitCallExpression=(_)=>{return this.visitNode(_.call())};visitIdentifierExpression=(_)=>{return this.visitNode(_.identifier())};visitLiteralExpression=(_)=>{return this.visitNode(_.literal())};visitJoinedStringExpression=(_)=>{return this.visitNode(_.joinedString())};visitLocalVariableExpression=(_)=>{return this.visitNode(_.localVariable())};visitLocalArrayVariableExpression=(_)=>{return this.visitNode(_.localArrayVariable())};visitGameVariableExpression=(_)=>{return this.visitNode(_.gameVariable())};visitConstantVariableExpression=(_)=>{return this.visitNode(_.constantVariable())};location(_){let A=_.stop??_.start;return this.locationFromRange(_.start,A)}locationFromToken(_){return this.locationFromRange(_,_)}locationFromRange(_,A){let R=_.line===1?this.columnOffset:0,U=A.line===1?this.columnOffset:0,Y=Math.max(A.text?.length??0,1);return{name:this.source,line:_.line+this.lineOffset,column:_.column+1+R,endLine:A.line+this.lineOffset,endColumn:A.column+1+U+Y}}toAstToken(_){return new X3(this.locationFromToken(_),_.text??"")}visitNode(_){if(!_)throw Error("Expected parser context but recieved null/undefined.");return this.visit(_)}collectExpressionList(_){if(!_)return[];let A=_.expression();return(Array.isArray(A)?A:[A]).map((U)=>this.visitNode(U))}extractParenthesisExpression(_){return this.visitNode(_.expression())}unescape(_){let A="";for(let R=0;R<_.length;R+=1){let U=_[R];if(U==="\\"){let Y=R===_.length-1?"\\":_[R+1];if(Y==="\\"||Y==="'"||Y==='"'||Y==="<")A+=Y;else throw Error(`Unsupported escape sequence: \\${Y}`);R+=1}else A+=U}return A}}class h1{static createScriptFile(_,A){let R=V6(_,"utf8"),U=F0.fromString(R);return U.name=_,this.invokeParser(U,(Y)=>Y.scriptFile(),A)}static async createScriptFileAsync(_,A){let R=await P6(_,"utf8"),U=F0.fromString(R);return U.name=_,this.invokeParser(U,(Y)=>Y.scriptFile(),A)}static createScriptFileFromString(_,A){let R=F0.fromString(_);return R.name="<source>",this.invokeParser(R,(U)=>U.scriptFile(),A)}static createScript(_,A){let R=F0.fromString(_);return R.name="<source>",this.invokeParser(R,(U)=>U.script(),A)}static invokeParser(_,A,R,U=0,Y=0){let X=new T(_),G=new q2(X),Q=new Z(G);if(R)X.removeErrorListeners(),X.addErrorListener(R),Q.removeErrorListeners(),Q.addErrorListener(R);let J=A(Q);if(Q.numberOfSyntaxErrors>0)return null;return new n3(_.getSourceName(),U,Y).visit(J)}}class T0{visitScriptFile(_){return this.visitNode(_)}visitScript(_){return this.visitNode(_)}visitParameter(_){return this.visitNode(_)}visitBlockStatement(_){return this.visitStatement(_)}visitReturnStatement(_){return this.visitStatement(_)}visitIfStatement(_){return this.visitStatement(_)}visitWhileStatement(_){return this.visitStatement(_)}visitSwitchStatement(_){return this.visitStatement(_)}visitSwitchCase(_){return this.visitNode(_)}visitDeclarationStatement(_){return this.visitStatement(_)}visitArrayDeclarationStatement(_){return this.visitStatement(_)}visitAssignmentStatement(_){return this.visitStatement(_)}visitExpressionStatement(_){return this.visitStatement(_)}visitEmptyStatement(_){return this.visitStatement(_)}visitStatement(_){return this.visitNode(_)}visitParenthesizedExpression(_){return this.visitExpression(_)}visitConditionExpression(_){return this.visitBinaryExpression(_)}visitArithmeticExpression(_){return this.visitBinaryExpression(_)}visitBinaryExpression(_){return this.visitExpression(_)}visitCalcExpression(_){return this.visitExpression(_)}visitProcCallExpression(_){return this.visitCallExpression(_)}visitCommandCallExpression(_){return this.visitCallExpression(_)}visitJumpCallExpression(_){return this.visitCallExpression(_)}visitCallExpression(_){return this.visitExpression(_)}visitClientScriptExpression(_){return this.visitExpression(_)}visitLocalVariableExpression(_){return this.visitVariableExpression(_)}visitGameVariableExpression(_){return this.visitVariableExpression(_)}visitConstantVariableExpression(_){return this.visitVariableExpression(_)}visitVariableExpression(_){return this.visitExpression(_)}visitExpression(_){return this.visitNode(_)}visitIntegerLiteral(_){return this.visitLiteral(_)}visitCoordLiteral(_){return this.visitLiteral(_)}visitBooleanLiteral(_){return this.visitLiteral(_)}visitCharacterLiteral(_){return this.visitLiteral(_)}visitNullLiteral(_){return this.visitLiteral(_)}visitStringLiteral(_){return this.visitLiteral(_)}visitLiteral(_){return this.visitExpression(_)}visitJoinedStringExpression(_){return this.visitExpression(_)}visitJoinedStringPart(_){return this.visitNode(_)}visitIdentifier(_){return this.visitExpression(_)}visitToken(_){return this.visitNode(_)}visitNode(_){throw Error(`Not implemented: ${_.constructor.name}`)}}var E={UNSUPPORTED_SYMBOLTYPE_TO_TYPE:"Internal compiler error: Unsupported SymbolType -> Type conversion: %s",CASE_WITHOUT_SWITCH:"Internal compiler error: Case without switch statement as parent.",RETURN_ORPHAN:"Internal compiler error: Orphaned `return` statement, no parent `script` node found.",TRIGGER_TYPE_NOT_FOUND:"Internal compiler error: The trigger '%s' has no declaration.",CUSTOM_HANDLER_NOTYPE:"Internal compiler error: Custom command handler did not assign return type.",CUSTOM_HANDLER_NOSYMBOL:"Internal compiler error: Custom command handler did not assign symbol.",SYMBOL_IS_NULL:"Internal compiler error: Symbol has not been defined for the node.",TYPE_HAS_NO_BASETYPE:"Internal compiler error: Type has no defined base type: %s.",TYPE_HAS_NO_DEFAULT:"Internal compiler error: Return type '%s' has no defined default value.",INVALID_CONDITION:"Internal compiler error: %s is not a supported expression type for conditions.",NULL_CONSTANT:"Internal compiler error: %s evaluated to 'null' constant value.",EXPRESSION_NO_SUBEXPR:"Internal compiler error: No sub expression node.",GENERIC_INVALID_TYPE:"'%s' is not a valid type.",GENERIC_TYPE_MISMATCH:"Type mismatch: '%s' was given but '%s' was expected.",GENERIC_UNRESOLVED_SYMBOL:"'%s' could not be resolved to a symbol.",ARITHMETIC_INVALID_TYPE:"Type mismatch: '%s' was given but 'int' or 'long' was expected.",SCRIPT_REDECLARATION:"[%s,%s] is already defined.",SCRIPT_LOCAL_REDECLARATION:"'$%s' is already defined.",SCRIPT_TRIGGER_INVALID:"'%s' is not a valid trigger type.",SCRIPT_COMMAND_ONLY:"Using a '*' is only allowed for commands.",SCRIPT_TRIGGER_NO_PARAMETERS:"The trigger type '%s' is not allowed to have parameters defined.",SCRIPT_TRIGGER_EXPECTED_PARAMETERS:"The trigger type '%s' is expected to accept (%s).",SCRIPT_TRIGGER_NO_RETURNS:"The trigger type '%s' is not allowed to return values.",SCRIPT_TRIGGER_EXPECTED_RETURNS:"The trigger type '%s' is expected to return (%s).",SCRIPT_SUBJECT_ONLY_GLOBAL:"Trigger '%s' only allows global subjects.",SCRIPT_SUBJECT_NO_GLOBAL:"Trigger '%s' does not allow global subjects.",SCRIPT_SUBJECT_NO_CATEGORY:"Trigger '%s' does not allow category subjects.",SWITCH_INVALID_TYPE:"'%s' is not allowed within a switch statement.",SWITCH_DUPLICATE_DEFAULT:"Duplicate default label.",SWITCH_CASE_NOT_CONSTANT:"Switch case value is not a constant expression.",ASSIGN_MULTI_ARRAY:"Arrays are not allowed in multi-assignment statements.",CONDITION_INVALID_NODE_TYPE:"Conditions are only allowed to be binary expressions.",BINOP_INVALID_TYPES:"Operator '%s' cannot be applied to '%s', '%s'.",BINOP_TUPLE_TYPE:"%s side of binary expressions can only have one type but has '%s'.",COMMAND_REFERENCE_UNRESOLVED:"'%s' cannot be resolved to a command.",COMMAND_NOARGS_EXPECTED:"'%s' is expected to have no arguments but has '%s'.",PROC_REFERENCE_UNRESOLVED:"'~%s' cannot be resolved to a proc.",PROC_NOARGS_EXPECTED:"'~%s' is expected to have no arguments but has '%s'.",JUMP_REFERENCE_UNRESOLVED:"'@%s' cannot be resolved to a label.",JUMP_NOARGS_EXPECTED:"'@%s' is expected to have no arguments but has '%s'.",CLIENTSCRIPT_REFERENCE_UNRESOLVED:"'%s' cannot be resolved to a clientscript.",CLIENTSCRIPT_NOARGS_EXPECTED:"'%s' is expected to have no arguments but has '%s'.",HOOK_TRANSMIT_LIST_UNEXPECTED:"Unexpected hook transmit list.",LOCAL_DECLARATION_INVALID_TYPE:"'%s' is not allowed to be declared as a type.",LOCAL_REFERENCE_UNRESOLVED:"'$%s' cannot be resolved to a local variable.",LOCAL_REFERENCE_NOT_ARRAY:"Access of indexed value of non-array type variable '$%s'.",LOCAL_ARRAY_INVALID_TYPE:"'%s' is not allowed to be used as an array.",LOCAL_ARRAY_REFERENCE_NOINDEX:"'$%s' is a reference to an array variable without specifying the index.",GAME_REFERENCE_UNRESOLVED:"'%%%s' cannot be resolved to a game variable.",CONSTANT_REFERENCE_UNRESOLVED:"'^%s' cannot be resolved to a constant.",CONSTANT_CYCLIC_REF:"Cyclic constant references are not permitted: %s.",CONSTANT_UNKNOWN_TYPE:"Unable to infer type for '^%s'.",CONSTANT_PARSE_ERROR:"Unable to parse constant value of '%s' into type '%s'.",CONSTANT_NONCONSTANT:"Constant value of '%s' evaluated to a non-constant expression.",POINTER_UNINITIALIZED:"Attempt to access uninitialized pointer %s.",POINTER_CORRUPTED:"Attempt to access corrupted pointer %s.",POINTER_CORRUPTED_LOC:"%s corrupted here.",POINTER_REQUIRED_LOC:"%s required here."};var F5=new WeakMap,I5=new WeakMap,W5=new Map,v6={kind:"LocalVariable"},b6={kind:"Constant"},d={serverScript:(_)=>{let A=F5.get(_);if(!A)A={kind:"ServerScript",type:_},F5.set(_,A);return A},clientScript:(_)=>{let A=I5.get(_);if(!A)A={kind:"ClientScript",type:_},I5.set(_,A);return A},localVariable:()=>v6,basic:(_)=>{let A=W5.get(_);if(!A)A={kind:"Basic",type:_},W5.set(_,A);return A},constant:()=>b6};class p3 extends T0{typeManager;triggerManager;rootTable;diagnostics;tables=[];get table(){return this.tables[0]}categoryType;constructor(_,A,R,U){super();this.typeManager=_;this.triggerManager=A;this.rootTable=R;this.diagnostics=U;this.categoryType=this.typeManager.findOrNull("category"),this.tables.unshift(this.rootTable.createSubTable())}isTypeMode(_){return"type"in _}createScopedTable(_){this.tables.unshift(this.table.createSubTable());try{_()}finally{this.tables.shift()}}visitScriptFile(_){for(let A of _.scripts)this.createScopedTable(()=>{A.accept(this)})}visitScript(_){let A=this.triggerManager.findOrNull(_.trigger.text);if(!A)_.trigger.reportError(this.diagnostics,E.SCRIPT_TRIGGER_INVALID,_.trigger.text);else _.triggerType=A;if(_.isStar&&A!==N0)_.name.reportError(this.diagnostics,E.SCRIPT_COMMAND_ONLY);this.checkScriptSubject(A,_);let R=_.parameters;R?.forEach((Y)=>Y.accept(this)),_.parameterType=O.fromList(R?.map((Y)=>Y.symbol.type??q.Error)??[]),this.checkScriptParameters(A,_,R);let U=_.returnTokens;if(U&&U.length>0){let Y=[];for(let X of U){let G=this.typeManager.findOrNull(X.text);if(!G)X.reportError(this.diagnostics,E.GENERIC_INVALID_TYPE,X.text);Y.push(G??q.Error)}_.returnType=O.fromList(Y.map((X)=>X??q.Error))}else _.returnType=!A?q.Error:A.allowReturns?q.Unit:q.Nothing;if(this.checkScriptReturns(A,_),A){let Y=new x1(A,_.nameString,_.parameterType,_.returnType);if(!this.rootTable.insert(d.serverScript(A),Y))_.reportError(this.diagnostics,E.SCRIPT_REDECLARATION,A.identifier,_.nameString);else _.symbol=Y}_.statements.forEach((Y)=>Y.accept(this)),_.block=this.table}checkScriptSubject(_,A){let R=_?.subjectMode;if(!R)return;let U=A.name.text;if(R===K.Name)return;if(U==="_"){this.checkGlobalScriptSubject(_,A);return}if(U.startsWith("_")){this.checkCategoryScriptSubject(_,A,U.substring(1));return}this.checkTypeScriptSubject(_,A,U)}checkGlobalScriptSubject(_,A){let R=_.subjectMode;if(R===K.None)return;if(this.isTypeMode(R)){if(!R.global)A.name.reportError(this.diagnostics,E.SCRIPT_SUBJECT_NO_GLOBAL,_.identifier);return}throw Error(`Unexpected subject mode: ${R}.`)}checkCategoryScriptSubject(_,A,R){let U=_.subjectMode,Y=this.categoryType;if(!Y)throw Error("'category' type not defined.");if(U===K.None){A.name.reportError(this.diagnostics,E.SCRIPT_SUBJECT_ONLY_GLOBAL,_.identifier);return}if(this.isTypeMode(U)){if(!U.category){A.name.reportError(this.diagnostics,E.SCRIPT_SUBJECT_NO_CATEGORY,_.identifier);return}this.resolveSubjectSymbol(A,R,Y);return}throw Error(`Unexpected subject mode: ${U}.`)}checkTypeScriptSubject(_,A,R){let U=_.subjectMode;if(U===K.None){A.name.reportError(this.diagnostics,E.SCRIPT_SUBJECT_ONLY_GLOBAL,_.identifier);return}if(this.isTypeMode(U)){this.resolveSubjectSymbol(A,R,U.type);return}throw Error(`Unexpected subject mode: ${U}.`)}tryParseMapZone(_,A){let R=A.split("_");if(R.length!==3)return _.name.reportError(this.diagnostics,"Mapzone subject must be of the form: 'level_mx_mz'."),-1;let[U,Y,X]=R,G=parseInt(U,10),Q=parseInt(Y,10),J=parseInt(X,10);if(Q<0||Q>255||J<0||J>255)_.name.reportError(this.diagnostics,"Invalid mapzone coord.");if(G!==0)return _.name.reportError(this.diagnostics,"Mapzone affect all level, just specify '0'."),-1;let F=Q<<6;return J<<6&16383|(F&16383)<<14}tryParseZone(_,A){let R=A.split("_");if(R.length!==5)return _.name.reportError(this.diagnostics,"Zone subject must be of the form: 'level_mx_mz_lx_lz'."),-1;let[U,Y,X,G,Q]=R,J=parseInt(U,10),F=parseInt(Y,10),I=parseInt(X,10),B=parseInt(G,10),C=parseInt(Q,10);if(J<0||J>3||F<0||F>255||I<0||I>255||B<0||B>63||C<0||C>63)_.name.reportError(this.diagnostics,"Invalid zone coord.");if(B%8!==0||C%8!==0)return _.name.reportError(this.diagnostics,"Local zone coord must be a multiple of 8"),-1;let V=(F<<6|B)>>3<<3;return(I<<6|C)>>3<<3&16383|(V&16383)<<14|(J&3)<<28}resolveSubjectSymbol(_,A,R){if(R===w.MAPZONE){let Y=this.tryParseMapZone(_,A);_.subjectReference=new _0(Y.toString(),R,!1);return}if(R===w.COORD){let Y=this.tryParseZone(_,A);_.subjectReference=new _0(Y.toString(),R,!1);return}let U=this.rootTable.find(d.basic(R),A);if(!U){_.name.reportError(this.diagnostics,E.GENERIC_UNRESOLVED_SYMBOL,A);return}if(!(("type"in U)&&("isProtected"in U))){_.name.reportError(this.diagnostics,E.GENERIC_UNRESOLVED_SYMBOL,A);return}_.subjectReference=U}checkScriptParameters(_,A,R){let U=_?.parameters,Y=A.parameterType;if(_&&!_.allowParameters&&R&&R.length>0)R[0].reportError(this.diagnostics,E.SCRIPT_TRIGGER_NO_PARAMETERS,_.identifier);else if(U&&Y!==U){let X=U.representation;A.reportError(this.diagnostics,E.SCRIPT_TRIGGER_EXPECTED_PARAMETERS,A.trigger.text,X)}}checkScriptReturns(_,A){let R=_?.returns,U=A.returnType;if(_&&!_.allowReturns&&U!==q.Nothing)A.reportError(this.diagnostics,E.SCRIPT_TRIGGER_NO_RETURNS,_.identifier);else if(R&&U!==R){let Y=R.representation;A.reportError(this.diagnostics,E.SCRIPT_TRIGGER_EXPECTED_RETURNS,A.trigger.text,Y)}}visitParameter(_){let A=_.name.text,R=_.typeToken.text,U=this.typeManager.findOrNull(R,!0);if(!U)_.reportError(this.diagnostics,E.GENERIC_INVALID_TYPE,R);let Y=new I0(A,U??q.Error);if(!this.table.insert(d.localVariable(),Y))_.reportError(this.diagnostics,E.SCRIPT_LOCAL_REDECLARATION,A);_.symbol=Y}visitBlockStatement(_){this.createScopedTable(()=>{this.visit(_.statements),_.scope=this.table})}visitSwitchStatement(_){let A=_.typeToken.text.replace(/^switch_/,""),R=this.typeManager.findOrNull(A);if(!R)_.typeToken.reportError(this.diagnostics,E.GENERIC_INVALID_TYPE,A);else if(!R?.options?.allowSwitch)_.typeToken.reportError(this.diagnostics,E.SWITCH_INVALID_TYPE,R.representation);_.condition.accept(this),this.visit(_.cases),_.type=R??q.Error}visitSwitchCase(_){this.visit(_.keys),this.createScopedTable(()=>{this.visit(_.statements),_.scope=this.table})}visitNode(_){this.visit(_.children)}visit(_){for(let A of _)A.accept(this)}}class C2{typeChecker;typeManager;expression;diagnostics;get arguments(){if(this.expression instanceof r)return this.expression.arguments;return[]}get isConstant(){if(!this.expression)return!1;return this.typeChecker.isConstantExpression(this.expression)}constructor(_,A,R,U){this.typeChecker=_;this.typeManager=A;this.expression=R;this.diagnostics=U}getArgumentsList(_=!1){if(_&&this.expression instanceof M0)return this.expression.arguments2??[];return this.arguments}checkArgument(_,A,R=!1){let U=this.getArgumentsList(R);if(_<0||_>=U.length)return null;let Y=U[_];return this.visitExpression(Y,A),Y}checkTypeArgument(_){let A=this.arguments;if(_<0||_>=A.length)return null;let R=A[_];if(!(R instanceof Y0))return this.diagnostics.report(new U0("ERROR",R,C2.DIAGNOSTIC_TYPEREF_EXPECTED)),R.type=q.Error,R;let U=this.typeManager.findOrNull(R.text);if(!U)return this.diagnostics.report(new U0("ERROR",R,E.GENERIC_INVALID_TYPE,R.text)),R.type=q.Error,R;return R.type=new q.Type(U),R.reference=new _0(R.text,R.type),R}checkArgumentTypes(_,A=!0,R=!1){let U=this.getArgumentsList(R),Y=[];for(let G of U){if(!G.getNullableType())this.visitExpression(G);Y.push(G.type??q.Error)}let X=O.fromList(Y.map((G)=>G??q.Error));return this.typeChecker.checkTypeMatch(this.expression,_,X,A)}collectTypes(..._){return O.fromList(_.filter((A)=>!!A).map((A)=>A.getNullableType()??q.Error))}visitNode(_){if(_)this.typeChecker.visitNodeOrNull(_)}visitExpression(_,A){if(!_)return;if(A)_.typeHint=A;this.typeChecker.visitNodeOrNull(_)}visitNodeList(_){if(!_)return;for(let A of _)this.typeChecker.visitNodeOrNull(A)}static DIAGNOSTIC_TYPEREF_EXPECTED="Type reference expected."}class h0 extends T0{typeManager;triggerManager;rootTable;dynamicCommands;diagnostics;commandTrigger;procTrigger;clientscriptTrigger;labelTrigger;table;constantsBeingEvaluated;constructor(_,A,R,U,Y){super();this.typeManager=_;this.triggerManager=A;this.rootTable=R;this.dynamicCommands=U;this.diagnostics=Y;this.commandTrigger=this.triggerManager.find("command"),this.procTrigger=this.triggerManager.find("proc"),this.clientscriptTrigger=this.triggerManager.findOrNull("clientscript"),this.labelTrigger=this.triggerManager.findOrNull("label"),this.table=this.rootTable,this.constantsBeingEvaluated=new Set}scoped(_,A){let R=this.table;this.table=_,A(),this.table=R}visitScriptFile(_){this.visitNodes(_.scripts)}visitScript(_){this.scoped(_.block,()=>{this.visitNodes(_.statements)})}visitBlockStatement(_){this.scoped(_.scope,()=>{this.visitNodes(_.statements)})}visitReturnStatement(_){let A=_.findParentByType(p0);if(A==null){_.reportError(this.diagnostics,E.RETURN_ORPHAN);return}let R=O.toList(A.returnType),U=this.typeHintExpressionList(R,_.expressions),Y=O.fromList(R),X=O.fromList(U);this.checkTypeMatch(_,Y,X)}visitIfStatement(_){this.checkCondition(_.condition),this.visitNodeOrNull(_.thenStatement),this.visitNodeOrNull(_.elseStatement)}visitWhileStatement(_){this.checkCondition(_.condition),this.visitNodeOrNull(_.thenStatement)}checkCondition(_){_.typeHint=w.BOOLEAN;let A=this.findInvalidConditionExpression(_);if(A==null)this.visitNodeOrNull(_),this.checkTypeMatch(_,w.BOOLEAN,_.type??q.Error);else A.reportError(this.diagnostics,E.CONDITION_INVALID_NODE_TYPE)}findInvalidConditionExpression(_){if(_ instanceof J1){let A=_.operator.text;if(A==="|"||A==="&")return this.findInvalidConditionExpression(_.left)??this.findInvalidConditionExpression(_.right);else return null}else if(_ instanceof x0)return this.findInvalidConditionExpression(_.expression);else return _}visitSwitchStatement(_){let{type:A,condition:R}=_;R.typeHint=A,this.visitNodeOrNull(R),this.checkTypeMatch(R,A,R.type??q.Error);let U=null;for(let Y of _.cases){if(Y.isDefault)if(U==null)U=Y;else Y.reportError(this.diagnostics,E.SWITCH_DUPLICATE_DEFAULT);this.visitNodeOrNull(Y)}_.defaultCase=U}visitSwitchCase(_){let A=_.findParentByType(i1);if(!A){_.reportError(this.diagnostics,E.CASE_WITHOUT_SWITCH);return}let R=A.type;for(let U of _.keys){if(U.typeHint=R,this.visitNodeOrNull(U),!this.isConstantExpression(U)){U.reportError(this.diagnostics,E.SWITCH_CASE_NOT_CONSTANT);continue}this.checkTypeMatch(U,R,U.type)}this.scoped(_.scope,()=>{this.visitNodes(_.statements)})}isConstantExpression(_){if(_ instanceof Z1)return!0;if(_ instanceof i0){let A=_.subExpression;return A==null||this.isConstantExpression(A)}if(_ instanceof o)return!0;if(_ instanceof Y0){let A=_.reference;return A==null||this.isConstantSymobl(A)}return!1}isConstantSymobl(_){return _ instanceof _0||_ instanceof W1}visitDeclarationStatement(_){let A=_.typeToken.text.replace(/^def_/,""),R=_.name.text,U=this.typeManager.findOrNull(A);if(!U)_.typeToken.reportError(this.diagnostics,E.GENERIC_INVALID_TYPE,A);else if(U.options&&!U.options.allowDeclaration)_.typeToken.reportError(this.diagnostics,E.LOCAL_DECLARATION_INVALID_TYPE,U.representation);let Y=new I0(R,U??q.Error);if(!this.table.insert(d.localVariable(),Y))_.name.reportError(this.diagnostics,E.SCRIPT_LOCAL_REDECLARATION,R);let G=_.initializer;if(G!=null)G.typeHint=Y.type,this.visitNodeOrNull(G),this.checkTypeMatch(G,Y.type,G.type??q.Error);_.symbol=Y}visitArrayDeclarationStatement(_){let A=_.typeToken.text.replace(/^def_/,""),R=_.name.text,U=this.typeManager.findOrNull(A);if(!U)_.typeToken.reportError(this.diagnostics,E.GENERIC_INVALID_TYPE,A);else if(U.options&&!U.options.allowDeclaration)_.typeToken.reportError(this.diagnostics,E.LOCAL_DECLARATION_INVALID_TYPE,U.representation);else if(U.options&&!U.options.allowArray)_.typeToken.reportError(this.diagnostics,E.LOCAL_ARRAY_INVALID_TYPE,U.representation);if(U)U=new a(U);else U=q.Error;let Y=_.initializer;Y.typeHint=w.INT,this.visitNodeOrNull(Y),this.checkTypeMatch(Y,w.INT,Y.type??q.Error);let X=new I0(R,U);if(!this.table.insert(d.localVariable(),X))_.name.reportError(this.diagnostics,E.SCRIPT_LOCAL_REDECLARATION,R);_.symbol=X}visitAssignmentStatement(_){let A=_.vars;this.visitNodes(A);let R=A.map((Q)=>this.getSafeType(Q)),U=this.typeHintExpressionList(R,_.expressions).map((Q)=>Q??q.Error),Y=O.fromList(R),X=O.fromList(U);this.checkTypeMatch(_,Y,X);let G=A.find((Q)=>Q instanceof o0&&Q.isArray);if(A.length>1&&G)G.reportError(this.diagnostics,E.ASSIGN_MULTI_ARRAY)}visitExpressionStatement(_){this.visitNodeOrNull(_.expression)}visitEmptyStatement(_){}visitParenthesizedExpression(_){let A=_.expression;A.typeHint=_.typeHint,this.visitNodeOrNull(A),_.type=A.type}visitConditionExpression(_){let{left:A,right:R,operator:U}=_;if(!this.checkBinaryConditionOperation(A,U,R)){_.type=q.Error;return}_.type=w.BOOLEAN}checkBinaryConditionOperation(_,A,R){let U;switch(A.text){case"&":case"|":U=h0.ALLOWED_LOGICAL_TYPES;break;case"<":case">":case"<=":case">=":U=h0.ALLOWED_RELATIONAL_TYPES;break;default:U=null}if(U!=null)_.typeHint=U[0],R.typeHint=U[0];else _.typeHint=_.typeHint??(R.type??null),R.typeHint=R.typeHint??(_.type??null);if(this.visitNodeOrNull(_),R.typeHint=R.typeHint??_.type,this.visitNodeOrNull(R),_.type==null||R.type==null)return A.reportError(this.diagnostics,E.BINOP_INVALID_TYPES,A.text,_.type?_.type.representation:"<null>",R.type?R.type.representation:"<null>"),!1;if(_.type instanceof O||R.type instanceof O){if(_.type instanceof O)_.reportError(this.diagnostics,E.BINOP_TUPLE_TYPE,"Left",_.type.representation);if(R.type instanceof O)R.reportError(this.diagnostics,E.BINOP_TUPLE_TYPE,"Right",R.type.representation);return!1}else if(_.type==q.Unit||R.type==q.Unit)return A.reportError(this.diagnostics,E.BINOP_INVALID_TYPES,A.text,_.type.representation,R.type.representation),!1;if(U!=null){if(!this.checkTypeMatchAny(_,U,_.type)||!this.checkTypeMatchAny(R,U,R.type))return A.reportError(this.diagnostics,E.BINOP_INVALID_TYPES,A.text,_.type.representation,R.type.representation),!1}if(!this.checkTypeMatch(_,_.type,R.type,!1))return A.reportError(this.diagnostics,E.BINOP_INVALID_TYPES,A.text,_.type.representation,R.type.representation),!1;else if(_.type==w.STRING&&R.type==w.STRING)return A.reportError(this.diagnostics,E.BINOP_INVALID_TYPES,A.text,_.type.representation,R.type.representation),!1;return!0}visitArithmeticExpression(_){let{left:A,right:R,operator:U}=_,Y=_.typeHint??w.INT;if(A.typeHint=Y,this.visitNodeOrNull(A),R.typeHint=Y,this.visitNodeOrNull(R),A.type==null||R.type==null||!this.checkTypeMatchAny(A,h0.ALLOWED_ARITHMETIC_TYPES,A.type??q.Error)||!this.checkTypeMatchAny(A,h0.ALLOWED_ARITHMETIC_TYPES,R.type??q.Error)||!this.checkTypeMatch(A,Y,A.type??q.Error,!1)||!this.checkTypeMatch(R,Y,R.type??q.Error,!1)){U.reportError(this.diagnostics,E.BINOP_INVALID_TYPES,U.text,A.type?A.type.representation:"<null>",R.type?R.type.representation:"<null>"),_.type=q.Error;return}_.type=Y}visitCalcExpression(_){let A=_.typeHint??w.INT,R=_.expression;if(R.typeHint=A,this.visitNodeOrNull(R),R.type==null||!this.checkTypeMatchAny(R,h0.ALLOWED_ARITHMETIC_TYPES,R.type??q.Error))R.reportError(this.diagnostics,E.ARITHMETIC_INVALID_TYPE,R.type?R.type.representation:"<null>"),_.type=q.Error;else _.type=R.type}visitCommandCallExpression(_){let A=_.nameString;if(this.checkDynamicCommand(A,_))return;this.checkCallExpression(_,this.commandTrigger,E.COMMAND_REFERENCE_UNRESOLVED)}visitProcCallExpression(_){this.checkCallExpression(_,this.procTrigger,E.PROC_REFERENCE_UNRESOLVED)}visitJumpCallExpression(_){if(!this.labelTrigger){_.reportError(this.diagnostics,"Jump expression not allowed.");return}let A=_.findParentByType(p0);if(!A)throw Error("Parent script not found.");if(A.triggerType===this.procTrigger){_.reportError(this.diagnostics,"Unable to jump to labels from within a proc.");return}this.checkCallExpression(_,this.labelTrigger,E.JUMP_REFERENCE_UNRESOLVED)}checkDynamicCommand(_,A){let R=this.dynamicCommands.get(_);if(!R)return!1;return(()=>{let U=new C2(this,this.typeManager,A,this.diagnostics);if(R.typeCheck(U),!A.getNullableType())A.reportError(this.diagnostics,E.CUSTOM_HANDLER_NOTYPE);if(A instanceof Y0&&!A.reference||A instanceof r&&!A.symbol){let X=this.rootTable.find(d.serverScript(this.commandTrigger),_);if(!X)A.reportError(this.diagnostics,E.CUSTOM_HANDLER_NOSYMBOL);if(A instanceof Y0)A.reference=X;else if(A instanceof r)A.symbol=X}})(),!0}checkCallExpression(_,A,R){let U=_.name.text,Y=d.serverScript(A),X=this.rootTable.find(Y,U);if(!X)_.type=q.Error,_.reportError(this.diagnostics,R,U);else _.symbol=X,_.type=X.returns;this.typeCheckArguments(X,_,U)}visitClientScriptExpression(_){if(!this.clientscriptTrigger){_.reportError(this.diagnostics,E.TRIGGER_TYPE_NOT_FOUND,"clientscript");return}let A=_.typeHint;if(!(A instanceof q.Hook))throw Error("Expected MetaType Hook");let R=_.name.text,U=d.clientScript(this.clientscriptTrigger),Y=this.rootTable.find(U,R);if(!Y)_.reportError(this.diagnostics,E.CLIENTSCRIPT_REFERENCE_UNRESOLVED,R),_.type=q.Error;else _.symbol=Y,_.type=A;this.typeCheckArguments(Y,_,R);let X=A.transmitListType;if(X==q.Unit&&_.transmitList.length>0){_.transmitList[0].reportError(this.diagnostics,E.HOOK_TRANSMIT_LIST_UNEXPECTED),_.type=q.Error;return}for(let G of _.transmitList)G.typeHint=X,this.visitNodeOrNull(G),this.checkTypeMatch(G,X,G.type??q.Error)}typeCheckArguments(_,A,R){let U=_?.parameters??q.Error,Y=U instanceof O?[...U.children]:[U],X=this.typeHintExpressionList(Y,A.arguments),G=O.fromList(Y),Q=O.fromList(X);if(G==q.Unit&&Q!=q.Unit){let J;if(A instanceof M0)J=E.COMMAND_NOARGS_EXPECTED;else if(A instanceof t1)J=E.PROC_NOARGS_EXPECTED;else if(A instanceof r1)J=E.JUMP_NOARGS_EXPECTED;else if(A instanceof e1)J=E.CLIENTSCRIPT_NOARGS_EXPECTED;else throw Error(`Unexpected callExpression type: ${A}`);A.reportError(this.diagnostics,J,R,Q.representation);return}this.checkTypeMatch(A,G,Q)}visitLocalVariableExpression(_){let A=_.name.text,R=this.table.find(d.localVariable(),A);if(!R){_.reportError(this.diagnostics,E.LOCAL_REFERENCE_UNRESOLVED,A),_.type=q.Error;return}let U=R.type instanceof a;if(!U&&_.isArray){_.reportError(this.diagnostics,E.LOCAL_REFERENCE_NOT_ARRAY,A),_.type=q.Error;return}if(U&&!_.isArray){_.reportError(this.diagnostics,E.LOCAL_ARRAY_REFERENCE_NOINDEX,A),_.type=q.Error;return}let Y=_.index;if(R.type instanceof a&&Y!=null)this.visitNodeOrNull(Y),this.checkTypeMatch(Y,w.INT,Y.type??q.Error);_.reference=R,_.type=R.type instanceof a?R.type.inner:R.type}visitGameVariableExpression(_){let A=_.name.text,R=this.rootTable.findAll(A).find((U)=>U.type instanceof y0);if(!R||!(R.type instanceof y0)){_.type=q.Error,_.reportError(this.diagnostics,E.GAME_REFERENCE_UNRESOLVED,A);return}_.reference=R,_.type=R.type.inner}visitConstantVariableExpression(_){let A=_.name.text,R=_.typeHint;if(!R){_.reportError(this.diagnostics,E.CONSTANT_UNKNOWN_TYPE,A),_.type=q.Error;return}else if(R==q.Error){_.type=q.Error;return}let U=this.rootTable.find(d.constant(),A);if(!U){_.reportError(this.diagnostics,E.CONSTANT_REFERENCE_UNRESOLVED,A),_.type=q.Error;return}if(this.constantsBeingEvaluated.has(U)){let Y=Array.from(this.constantsBeingEvaluated).map((X)=>`^${X.name}`).join(" -> ");Y+=` -> ^${U.name}`,_.reportError(this.diagnostics,E.CONSTANT_CYCLIC_REF,Y),_.type=q.Error;return}this.constantsBeingEvaluated.add(U);try{let{name:Y,line:X,column:G}=_.source,Q=this.typeManager.findOrNull("graphic"),J=R==w.STRING||Q!=null&&R==Q,F=F0.fromString(U.value);F.name=Y;let I=J?new i0({name:Y,line:X-1,column:G-1,endLine:X-1,endColumn:G},U.value):h1.invokeParser(F,(B)=>B.singleExpression(),h0.DISCARD_ERROR_LISTENER,X-1,G-1);if(!I){_.reportError(this.diagnostics,E.CONSTANT_PARSE_ERROR,U.value,R.representation),_.type=q.Error;return}if(I.typeHint=R,this.visitNodeOrNull(I),!this.isConstantExpression(I)){_.reportError(this.diagnostics,E.CONSTANT_NONCONSTANT,U.value),_.type=q.Error;return}_.subExpression=I,_.type=I.type}finally{this.constantsBeingEvaluated.delete(U)}}visitIntegerLiteral(_){_.type=w.INT}visitCoordLiteral(_){_.type=w.COORD}visitBooleanLiteral(_){_.type=w.BOOLEAN}visitCharacterLiteral(_){_.type=w.CHAR}visitNullLiteral(_){let A=_.typeHint;if(A!=null){_.type=A;return}_.type=w.INT}visitStringLiteral(_){let A=_.typeHint;if(!A||this.typeManager.check(A,w.STRING))_.type=w.STRING;else if(A instanceof q.Hook)this.handleClientScriptExpression(_,A);else if(!h0.LITERAL_TYPES.has(A))_.symbol=this.resolveSymbol(_,_.value,A);else _.type=w.STRING}handleClientScriptExpression(_,A){let{name:R,line:U,column:Y}=_.source,X=new y1(R,this.diagnostics,U-1,Y),G=F0.fromString(_.value);G.name=R;let Q=h1.invokeParser(G,(J)=>J.clientScript(),X,U-1,Y);if(!Q){_.type=q.Error;return}Q.typeHint=A,this.visitNodeOrNull(Q),_.subExpression=Q,_.type=Q.type}visitJoinedStringExpression(_){_.parts.forEach((A)=>A.accept(this)),_.type=w.STRING}visitJoinedStringPart(_){if(_ instanceof g0){let A=_.expression;A.typeHint=w.STRING,A.accept(this),this.checkTypeMatch(A,w.STRING,A.type??q.Error)}}visitIdentifier(_){let{text:A,typeHint:R}=_;if(this.checkDynamicCommand(A,_))return;let U=this.resolveSymbol(_,A,R??void 0);if(!U)return;if(U instanceof v0&&U.trigger===this.commandTrigger&&U.parameters!==q.Unit)_.reportError(this.diagnostics,E.GENERIC_TYPE_MISMATCH,"<unit>",U.parameters.representation);_.reference=U}resolveSymbol(_,A,R){let U=null,Y=null;for(let X of this.table.findAll(A)){let G=this.symbolToType(X);if(!G)continue;if(!R&&G instanceof q.Script)continue;else if(!R||this.typeManager.check(R,G)){U=X,Y=G;break}else if(!U)U=X,Y=G}if(!U)return _.type=q.Error,_.reportError(this.diagnostics,E.GENERIC_UNRESOLVED_SYMBOL,A),null;if(!Y)return _.type=q.Error,_.reportError(this.diagnostics,E.UNSUPPORTED_SYMBOLTYPE_TO_TYPE,U.constructor.name),null;return _.type=Y,U}symbolToType(_){if(_ instanceof v0)if(_.trigger===N0)return _.returns;else return new q.Script(_.trigger,_.parameters,_.returns);else if(_ instanceof I0)if(_.type instanceof a)return _.type;else return null;else if(_ instanceof _0)return _.type;else if(_ instanceof W1)return null;return null}visitToken(_){}visitNode(_){let A=_.parent;if(!A)_.reportInfo(this.diagnostics,`Unhandled node: ${_.constructor.name}.`);else _.reportInfo(this.diagnostics,`Unhandled node: ${_.constructor.name}. Parent: ${A.constructor.name}.`)}typeHintExpressionList(_,A){let R=[],U=0;for(let Y of A)if(Y.typeHint=U<_.length?_[U]:null,Y.accept(this),R.push(this.getSafeType(Y)),Y.type instanceof O)U+=Y.type.children.length;else U+=1;return R}checkTypeMatch(_,A,R,U=!0){let Y=A instanceof O?A.children:[A],X=R instanceof O?R.children:[R],G=!0;if(A===q.Error)G=!0;else if(Y.length!==X.length)G=!1;else for(let Q=0;Q<Y.length;Q++)G=G&&this.typeManager.check(Y[Q],X[Q]);if(!G&&U){let Q=R===q.Unit?"<unit>":R.representation;_.reportError(this.diagnostics,E.GENERIC_TYPE_MISMATCH,Q,A.representation)}return G}checkTypeMatchAny(_,A,R){for(let U of A)if(this.checkTypeMatch(_,U,R,!1))return!0;return!1}visitNodeOrNull(_){if(!_)return;_.accept(this)}visitNodes(_){if(!_)return;for(let A of _)this.visitNodeOrNull(A)}getSafeType(_){return _&&_.type?_.type:q.Error}static ALLOWED_LOGICAL_TYPES=[w.BOOLEAN];static ALLOWED_RELATIONAL_TYPES=[w.INT,w.LONG];static ALLOWED_ARITHMETIC_TYPES=[w.INT,w.LONG];static LITERAL_TYPES=new Set([w.INT,w.BOOLEAN,w.COORD,w.STRING,w.CHAR,w.LONG]);static DISCARD_ERROR_LISTENER={syntaxError(_,A,R,U,Y,X){},reportAmbiguity:function(_,A,R,U,Y,X,G){},reportAttemptingFullContext:function(_,A,R,U,Y,X){},reportContextSensitivity:function(_,A,R,U,Y,X){}}}class o3{codeGenerator;rootTable;expression;diagnostics;constructor(_,A,R,U){this.codeGenerator=_;this.rootTable=A;this.expression=R;this.diagnostics=U}get arguments(){if(this.expression instanceof r)return this.expression.arguments;return[]}get arguments2(){if(this.expression instanceof M0&&this.expression.isStar&&this.expression.arguments2)return this.expression.arguments2;return[]}instruction(_,A,R){this.codeGenerator.instruction(_,A,R)}command(){let _=(()=>{if(this.expression instanceof M0)return this.expression.symbol;if(this.expression instanceof Y0)return this.expression.reference;return null})();if(this.lineInstruction(this.expression),!_)throw Error("Symbol cannot be null for command generation.");this.instruction(H.Command,_,this.expression.source)}lineInstruction(_){this.codeGenerator.lineInstruction(_)}visitNode(_){if(!_)return;this.codeGenerator.visitNodeOrNull(_)}visitExpression(_){if(!_)return;this.codeGenerator.visitNodeOrNull(_)}visitNodes(_){if(!_)return;this.codeGenerator.visitNodes(_)}}class j2{opcode;operand;source;constructor(_,A,R){this.opcode=_;this.operand=A;this.source=R}deconstruct(){return[this.opcode,this.operand]}toString(){return`Instruction(opcode=${this.opcode}, operand=${this.operand})`}}class O2{label;instructions=[];constructor(_){this.label=_}add(_){this.instructions.push(_)}plusAssign(_){this.add(_)}}class U2{name;constructor(_){this.name=_}}class i3{names=new Map;generate(_){let A=this.names.get(_)??0;return this.names.set(_,A+1),new U2(`${_}_${A}`)}reset(){this.names.clear()}}class t3{label;keys;constructor(_,A){this.label=_;this.keys=A}}class r3{id;_cases=[];constructor(_){this.id=_}get cases(){return this._cases}addCase(_){this._cases.push(_)}}class e3{sourceName;symbol;subjectReference;trigger;name;fullName;locals;blocks=[];switchTables=[];constructor(_,A,R){this.sourceName=_;this.symbol=A;this.subjectReference=R;this.trigger=A.trigger,this.name=A.name,this.fullName=`[${this.trigger.identifier},${this.name}]`,this.locals=new q5}generateSwitchTable(){let _=new r3(this.switchTables.length);return this.switchTables.push(_),_}}class q5{parameters=[];all=[]}class A0 extends T0{rootTable;dynamicCommands;diagnostics;labelGenerator=new i3;_scripts=[];block;lastLineNumber=-1;constructor(_,A,R){super();this.rootTable=_;this.dynamicCommands=A;this.diagnostics=R}get scripts(){return this._scripts}get script(){return this._scripts[this._scripts.length-1]}bind(_){return this.block=_,_}generateBlock(_,A=!0){let R=A?this.labelGenerator.generate(_):new U2(_),U=new O2(R);return this.script.blocks.push(U),U}generateBlockLabel(_){let A=new O2(_);return this.script.blocks.push(A),A}instruction(_,A,R,U=this.block){U.instructions.push(new j2(_,A,R))}instructionUnit(_,A,R=this.block){R.instructions.push(new j2(_,void 0,A))}lineInstruction(_){if(_.source.line!==this.lastLineNumber)this.lastLineNumber=_.source.line}visitScriptFile(_){this.visitNodes(_.scripts)}visitScript(_){if(_.triggerType==N0)return;this._scripts.push(new e3(_.source.name,_.symbol,_.subjectReference)),this.visitNodes(_.parameters),this.bind(this.generateBlock("entry",!1)),this.lineInstruction(_),this.visitNodes(_.statements),this.generateDefaultReturns(_),this.labelGenerator.reset(),this.lastLineNumber=-1}visitParameter(_){let A=_.symbol;this.script.locals.parameters.push(A),this.script.locals.all.push(A)}generateDefaultReturns(_){this.lineInstruction(_);let A=O.toList(_.returnType);for(let R of A)if(R==w.INT)this.instruction(H.PushConstantInt,0);else if(R.baseType==0)this.instruction(H.PushConstantInt,-1);else if(R.baseType==1)this.instruction(H.PushConstantString,"");else if(R.baseType==2)this.instruction(H.PushConstantLong,BigInt(-1));else throw Error(`Unsupported type in returns: ${R}`);this.instructionUnit(H.Return)}visitBlockStatement(_){this.visitNodes(_.statements)}visitReturnStatement(_){this.visitNodes(_.expressions),this.lineInstruction(_),this.instructionUnit(H.Return,_.source)}visitIfStatement(_){let A=this.labelGenerator.generate("if_true"),R=_.elseStatement?this.labelGenerator.generate("if_else"):null,U=this.labelGenerator.generate("if_end");if(this.generateCondition(_.condition,this.block,A,R??U),this.bind(this.generateBlockLabel(A)),this.visitNodeOrNull(_.thenStatement),this.instruction(H.Branch,U),R!=null)this.bind(this.generateBlockLabel(R)),this.visitNodeOrNull(_.elseStatement),this.instruction(H.Branch,U);this.bind(this.generateBlockLabel(U))}visitWhileStatement(_){let A=this.labelGenerator.generate("while_start"),R=this.labelGenerator.generate("while_body"),U=this.labelGenerator.generate("while_end"),Y=this.bind(this.generateBlockLabel(A));this.generateCondition(_.condition,Y,R,U),this.bind(this.generateBlockLabel(R)),this.visitNodeOrNull(_.thenStatement),this.instruction(H.Branch,A),this.bind(this.generateBlockLabel(U))}generateCondition(_,A,R,U){if(_ instanceof N1||_ instanceof J1)if(!A0.LOGICAL_OPERATORS.includes(_.operator.text)){let X=_.left.type.baseType;if(X==null){_.left.reportError(this.diagnostics,E.TYPE_HAS_NO_BASETYPE,_.left.type);return}let G=A0.BRANCH_MAPPINGS.get(X);if(!G)throw Error(`No mappings for BaseType: ${X}`);let Q=G.get(_.operator.text);if(!Q)throw Error(`No mappings for operator: ${_.operator.text}`);this.visitNodeOrNull(_.left),this.visitNodeOrNull(_.right),this.instruction(Q,R,void 0,A),this.instruction(H.Branch,U,void 0,A)}else{let X=_.operator.text===A0.LOGICAL_OR?this.labelGenerator.generate("condition_or"):this.labelGenerator.generate("condition_and"),G=_.operator.text===A0.LOGICAL_OR?R:X,Q=_.operator.text===A0.LOGICAL_OR?X:U;this.generateCondition(_.left,A,G,Q);let J=this.bind(this.generateBlockLabel(X));this.generateCondition(_.right,J,R,U)}else if(_ instanceof x0)this.generateCondition(_.expression,A,R,U);else _.reportError(this.diagnostics,E.INVALID_CONDITION,_.constructor.name)}visitSwitchStatement(_){let A=this.script.generateSwitchTable(),U=_.defaultCase!=null?this.labelGenerator.generate("switch_default_case"):null,Y=this.labelGenerator.generate("switch_end");this.visitNodeOrNull(_.condition),this.instruction(H.Switch,A,_.source);let X=_.cases[0]??null;if(X==null||!X.isDefault)this.instruction(H.Branch,U??Y);for(let G of _.cases){let Q=!G.isDefault?this.labelGenerator.generate(`switch_${A.id}_case`):U??(()=>{throw Error("switchDefault null while having a default case")}),J=[];for(let F of G.keys){let I=this.resolveConstantValue(F);if(I==null){F.reportError(this.diagnostics,E.NULL_CONSTANT,F.constructor.name);continue}J.push(I)}A.addCase(new t3(Q,J)),this.bind(this.generateBlockLabel(Q)),this.visitNodes(G.statements),this.instruction(H.Branch,Y)}this.bind(this.generateBlockLabel(Y))}resolveConstantValue(_){if(_ instanceof Z1)return _.subExpression?this.resolveConstantValue(_.subExpression):null;if(_ instanceof Y0)return _.reference;if(_ instanceof i0)return _.symbol??_.value;if(_ instanceof o)return _.value;return null}visitDeclarationStatement(_){let A=_.symbol;if(this.script.locals.all.push(A),_.initializer!=null)this.visitNodeOrNull(_.initializer);else{let U=A.type.defaultValue;if(typeof U==="number")this.instruction(H.PushConstantInt,U);else if(typeof U==="string")this.instruction(H.PushConstantString,U);else if(typeof U==="bigint")this.instruction(H.PushConstantLong,U);else throw Error(`Unsupported default type: ${U?.constructor?.name}`)}this.instruction(H.PopLocalVar,A,_.source)}visitArrayDeclarationStatement(_){let A=_.symbol;this.script.locals.all.push(A),this.visitNodeOrNull(_.initializer),this.instruction(H.DefineArray,A,_.source)}visitAssignmentStatement(_){let A=_.vars,R=A[0];if(R instanceof o0&&R.index!=null)this.visitNodeOrNull(R.index);this.visitNodes(_.expressions);for(let U=A.length-1;U>=0;U--){let Y=A[U],X=Y.reference;if(X==null){Y.reportError(this.diagnostics,E.SYMBOL_IS_NULL);return}if(X instanceof I0)this.instruction(H.PopLocalVar,X,Y.source);else if(X instanceof _0){if(!(Y instanceof _2))throw Error("Expected 'GameVariableExpression'.");this.instruction(!Y.dot?H.PopVar:H.PopVar2,X,Y.source)}else throw Error(`Unsupported reference type: ${X}`)}}visitExpressionStatement(_){let A=_.expression;this.visitNodeOrNull(A);let R=O.toList(A.type);for(let U of R){let Y=U.baseType;if(Y==null){_.reportError(this.diagnostics,E.TYPE_HAS_NO_BASETYPE,U);return}this.instruction(H.Discard,Y)}}visitEmptyStatement(_){}visitLocalVariableExpression(_){let A=_.reference;if(A==null){_.reportError(this.diagnostics,E.SYMBOL_IS_NULL);return}this.lineInstruction(_),this.visitNodeOrNull(_.index),this.instruction(H.PushLocalVar,A,_.source)}visitGameVariableExpression(_){let A=_.reference;if(A==null){_.reportError(this.diagnostics,E.SYMBOL_IS_NULL);return}this.lineInstruction(_),this.instruction(!_.dot?H.PushVar:H.PushVar2,A,_.source)}visitConstantVariableExpression(_){let A=_.subExpression;if(A==null){_.reportError(this.diagnostics,E.EXPRESSION_NO_SUBEXPR);return}this.visitNodeOrNull(A)}visitParenthesizedExpression(_){this.lineInstruction(_),this.visitNodeOrNull(_.expression)}visitArithmeticExpression(_){let A=_.operator.text,R=_.left.type.baseType,Y=(()=>{switch(R){case 0:return A0.INT_OPERATIONS;case 2:return A0.LONG_OPERATIONS;default:throw Error(`No mapping for BaseType: ${R}.`)}})().get(A);if(!Y)throw Error(`No mapping for operator: ${A}.`);this.visitNodeOrNull(_.left),this.visitNodeOrNull(_.right),this.instructionUnit(Y)}visitCalcExpression(_){this.lineInstruction(_),this.visitNodeOrNull(_.expression)}visitCommandCallExpression(_){let A=_.symbol;if(A==null){_.reportError(this.diagnostics,E.SYMBOL_IS_NULL);return}if(this.emitDynamicCommand(_.nameString,_))return;this.visitNodes(_.arguments),this.lineInstruction(_),this.instruction(H.Command,A,_.source)}emitDynamicCommand(_,A){let R=this.dynamicCommands.get(_);if(!R)return!1;let U=new o3(this,this.rootTable,A,this.diagnostics);if(R.generateCode)R.generateCode(U);else U.visitNodes(U.arguments),U.command();return!0}visitProcCallExpression(_){let A=_.symbol;if(A==null){_.reportError(this.diagnostics,E.SYMBOL_IS_NULL);return}this.visitNodes(_.arguments),this.lineInstruction(_),this.instruction(H.Gosub,A,_.source)}visitJumpCallExpression(_){let A=_.symbol;if(A==null){_.reportError(this.diagnostics,E.SYMBOL_IS_NULL);return}this.visitNodes(_.arguments),this.lineInstruction(_),this.instruction(H.Jump,A,_.source)}visitClientScriptExpression(_){let A=_.symbol;if(A==null){_.reportError(this.diagnostics,E.SYMBOL_IS_NULL);return}let R=O.toList(A.parameters),U=R.map((Y)=>Y.code).filter(Boolean).join("");if(R.length!==U.length)throw Error("Mismatch between argument types and their codes.");if(this.instruction(H.PushConstantSymbol,A,_.source),this.visitNodes(_.arguments),_.transmitList.length>0)this.visitNodes(_.transmitList),U+="Y",this.instruction(H.PushConstantInt,_.transmitList.length);this.instruction(H.PushConstantString,U)}visitIntegerLiteral(_){this.lineInstruction(_),this.instruction(H.PushConstantInt,_.value,_.source)}visitCoordLiteral(_){this.lineInstruction(_),this.instruction(H.PushConstantInt,_.value,_.source)}visitBooleanLiteral(_){this.lineInstruction(_),this.instruction(H.PushConstantInt,_.value?1:0,_.source)}visitCharacterLiteral(_){this.lineInstruction(_),this.instruction(H.PushConstantInt,_.value.charCodeAt(0),_.source)}visitNullLiteral(_){this.lineInstruction(_);let A=_.type.baseType;if(A==1){this.instruction(H.PushConstantString,"null");return}else if(A==2){this.instruction(H.PushConstantLong,BigInt(-1));return}if(this.instruction(H.PushConstantInt,-1,_.source),_.getType()instanceof q.Hook)this.instruction(H.PushConstantString,"")}visitStringLiteral(_){this.lineInstruction(_);let A=_.subExpression;if(A!=null){this.visitNodeOrNull(A);return}let R=_.symbol;if(R!=null){this.instruction(H.PushConstantSymbol,R,_.source);return}this.instruction(H.PushConstantString,_.value,_.source)}visitJoinedStringExpression(_){if(this.visitNodes(_.parts),_.parts.length>1)this.lineInstruction(_),this.instruction(H.JoinString,_.parts.length,_.source)}visitJoinedStringPart(_){if(this.lineInstruction(_),_ instanceof m0)this.instruction(H.PushConstantString,_.value,_.source);else if(_ instanceof g0)this.visitNodeOrNull(_.expression);else throw Error(`Unsupported StringPart: ${_.constructor.name}`)}visitIdentifier(_){let A=_.reference;if(A==null){_.reportError(this.diagnostics,E.SYMBOL_IS_NULL);return}if(this.lineInstruction(_),A instanceof x1&&A.trigger==N0){if(this.emitDynamicCommand(_.text,_))return;this.instruction(H.Command,A,_.source)}else this.instruction(H.PushConstantSymbol,A,_.source)}visitNodeOrNull(_){if(!_)return;_.accept(this)}visitNodes(_){if(!_)return;for(let A of _)this.visitNodeOrNull(A)}static LOGICAL_AND="&";static LOGICAL_OR="|";static LOGICAL_OPERATORS=[A0.LOGICAL_AND,A0.LOGICAL_OR];static INT_BRANCHES=new Map([["=",H.BranchEquals],["!",H.BranchNot],["<",H.BranchLessThan],[">",H.BranchGreaterThan],["<=",H.BranchLessThanOrEquals],[">=",H.BranchGreaterThanOrEquals]]);static OBJ_BRANCHES=new Map([["=",H.ObjBranchEquals],["!",H.ObjBranchNot]]);static LONG_BRANCHES=new Map([["=",H.LongBranchEquals],["!",H.LongBranchNot],["<",H.LongBranchLessThan],[">",H.LongBranchGreaterThan],["<=",H.LongBranchLessThanOrEquals],[">=",H.LongBranchGreaterThanOrEquals]]);static BRANCH_MAPPINGS=new Map([[0,A0.INT_BRANCHES],[1,A0.OBJ_BRANCHES],[2,A0.LONG_BRANCHES]]);static INT_OPERATIONS=new Map([["+",H.Add],["-",H.Sub],["*",H.Multiply],["/",H.Divide],["%",H.Modulo],["&",H.And],["|",H.Or]]);static LONG_OPERATIONS=new Map([["+",H.LongAdd],["-",H.LongSub],["*",H.LongMultiply],["/",H.LongDivide],["%",H.LongModulo],["&",H.LongAnd],["|",H.LongOr]])}class V1{instruction;next=[];previous=[];constructor(_){this.instruction=_}addNext(_){this.next.push(_),_.previous.push(this)}toString(){return`InstructionNode(instruction=${this.instruction})`}}class P1 extends V1{set;constructor(_){super(null);this.set=_}}class _4{commandPointers;constructor(_){this.commandPointers=_}generate(_){let A=new Map,R=[],U=new V1(null);U.addNext(this.firstInstruction(_[0],A,_)),R.push(U);let Y=!1;for(let X=0;X<_.length;X++){let G=_[X];for(let Q=0;Q<G.instructions.length;Q++){let J=G.instructions[Q];if(J.opcode===H.LineNumber)continue;let F=this.getOrCreate(A,J);if(R.push(F),Y&&J.opcode===H.BranchEquals&&this.checkInvertedConditional(G.instructions,Q)){if(Q+1>=G.instructions.length)throw Error("Invalid inverted conditional layout");let I=G.instructions[Q+1],B=this.getOrCreate(A,I);if(I.opcode!==H.Branch)throw Error("Expected Branch opcode");let C=G.instructions[Q-2];if(C.opcode!==H.Command)throw Error("Expected command before conditional");let V=C.operand.name,x=this.commandPointers.get(V).set,e=new P1(x);R.push(e),F.addNext(e),e.addNext(B),Y=!1}else if(!u6.has(J.opcode)){let I;if(Q+1<G.instructions.length)I=G.instructions[Q+1];else if(X+1<_.length)I=_[X+1].instructions[0];else throw Error("No next instruction");F.addNext(this.getOrCreate(A,I))}if(Y&&J.opcode===H.BranchEquals&&this.checkConditional(G.instructions,Q)){let I=J.operand,B=_.find((I1)=>I1.label===I);if(!B)throw Error("Unable to find block.");let C=G.instructions[Q-2];if(C.opcode!==H.Command)throw Error("Expected command before conditional.");let V=C.operand.name,x=this.commandPointers.get(V).set,e=new P1(x);R.push(e),F.addNext(e),e.addNext(this.firstInstruction(B,A,_)),Y=!1}else if(S6.has(J.opcode)){let I=J.operand,B=_.find((C)=>C.label===I);if(!B)throw Error("Unable to find block.");F.addNext(this.firstInstruction(B,A,_))}else if(J.opcode===H.Switch){let I=J.operand;for(let B of I.cases){if(B.keys.length===0)continue;let C=_.find((V)=>V.label===B.label);if(!C)throw Error("Unable to find block.");F.addNext(this.firstInstruction(C,A,_))}}if(this.isConditionalPointerSetter(J))Y=!0}}return R}checkConditional(_,A){if(A<2)return!1;let R=_[A-2];if(!this.isConditionalPointerSetter(R))return!1;let U=_[A-1];return U.opcode===H.PushConstantInt&&U.operand===1}checkInvertedConditional(_,A){if(A<2)return!1;let R=_[A-2];if(!this.isConditionalPointerSetter(R))return!1;let U=_[A-1];return U.opcode===H.PushConstantInt&&U.operand===0}isConditionalPointerSetter(_){if(_.opcode==H.Command&&_.operand instanceof v0){let A=this.commandPointers.get(_.operand.name);return A!==void 0&&A.conditionalSet}return!1}firstInstruction(_,A,R){let U=this.firstValid(_.instructions);if(U)return this.getOrCreate(A,U);let Y=R.indexOf(_);for(let X=Y;X<R.length;X++){let G=this.firstValid(R[X].instructions);if(G)return this.getOrCreate(A,G)}throw Error("No instructions remaining.")}firstValid(_){for(let A of _)if(A.opcode!==H.LineNumber)return A;return null}getOrCreate(_,A){let R=_.get(A);if(!R)R=new V1(A),_.set(A,R);return R}}var u6=new Set([H.Branch,H.Jump,H.Return]),S6=new Set([H.Branch,H.BranchNot,H.BranchEquals,H.BranchLessThan,H.BranchGreaterThan,H.BranchLessThanOrEquals,H.BranchGreaterThanOrEquals,H.LongBranchNot,H.LongBranchEquals,H.LongBranchLessThan,H.LongBranchGreaterThan,H.LongBranchLessThanOrEquals,H.LongBranchGreaterThanOrEquals,H.ObjBranchNot,H.ObjBranchEquals]);class A4{diagnostics;scripts;commandPointers;scriptsBySymbol;graphGenerator;scriptGraphs=new Map;scriptPointers=new Map;pendingScripts=new Set;constructor(_,A,R){this.diagnostics=_;this.scripts=A;this.commandPointers=R;this.scriptsBySymbol=new Map(A.map((U)=>[U.symbol,U])),this.graphGenerator=new _4(R)}getGraph(_){let A=this.scriptGraphs.get(_.symbol);if(A)return A;let R=this.graphGenerator.generate(_.blocks);return this.scriptGraphs.set(_.symbol,R),R}getPointers(_){let A=this.scriptPointers.get(_);if(A)return A;let R=this.calculatePointers(_);return this.scriptPointers.set(_,R),R}run(){for(let _ of this.scripts){let A=performance.now();this.validatePointers(_);let R=performance.now()-A}}calculatePointers(_){if(this.pendingScripts.has(_))return{required:new Set,set:new Set,conditionalSet:!1,corrupted:new Set};let A=this.scriptsBySymbol.get(_);if(!A)throw Error(`Unable to find script from symbol: ${_.name}`);let R=new Set,U=new Set,Y=new Set;this.pendingScripts.add(_);for(let X of N.ALL){if(this.requiresPointerScript(A,X))R.add(X);if(this.setsPointerScript(A,X))U.add(X);if(this.corruptsPointerScript(A,X))Y.add(X)}return this.pendingScripts.delete(_),{required:R,set:U,conditionalSet:!1,corrupted:Y}}validatePointers(_){for(let A of N.ALL)this.validatePointer(_,A)}validatePointer(_,A){let R=this.getGraph(_),U=R.filter((Q)=>this.requiresPointerNode(Q,A)),Y=R.filter((Q)=>this.setsPointerNode(Q,A)),X=R.filter((Q)=>this.corruptsPointerNode(Q,A));if(!this.setsPointerTrigger(_.trigger,A)){if(R.length>0)X.push(R[0])}let G=this.findEdgePath(U,(Q)=>X.includes(Q),(Q)=>Q.previous.filter((J)=>!Y.includes(J)));if(G!==null){let Q=G[0],J=Q.instruction?.source??(()=>{throw Error("Unknown instruction source.")})(),F=G[G.length-1],I=F!==R[0]&&F!==Q,B=I?E.POINTER_CORRUPTED:E.POINTER_UNINITIALIZED;if(this.diagnostics.report(new U0("ERROR",J,B,[A.representation])),I){let V=F.instruction?.source??(()=>{throw Error("Unknown instruction source.")})();this.diagnostics.report(new U0("HINT",V,E.POINTER_CORRUPTED_LOC,[A.representation]))}let C=(V)=>{let x=V.instruction?.opcode;if(x!==H.Gosub&&x!==H.Jump)return;let e=V.instruction.operand,I1=this.scripts.find((m2)=>m2.symbol===e);if(!I1)throw Error("Unable to find script.");let X2=this.requiresPointerPathScript(I1,A);if(!X2)throw Error("Unable to find requirement path?");let G2=X2[0],x2=G2.instruction?.source??(()=>{throw Error("Invalid instruction/source.")})();this.diagnostics.report(new U0("HINT",x2,E.POINTER_REQUIRED_LOC,[A.representation])),C(G2)};C(Q)}}setsPointerTrigger(_,A){let R=_.pointers;return R!=null&&R.has(A)}requiresPointerScript(_,A){return this.requiresPointerPathScript(_,A)!==null}requiresPointerPathScript(_,A){let R=this.getGraph(_),U=R.filter((Y)=>this.requiresPointerNode(Y,A));return this.findEdgePath(U,(Y)=>Y===R[0],(Y)=>Y.previous.filter((X)=>!this.setsPointerNode(X,A)))}setsPointerScript(_,A){let R=this.getGraph(_),U=R.filter((Y)=>Y.instruction?.opcode===H.Return);return this.findEdgePath(U,(Y)=>Y===R[0]||this.corruptsPointerNode(Y,A),(Y)=>Y.previous.filter((X)=>!this.setsPointerNode(X,A)))===null}corruptsPointerScript(_,A){let U=this.getGraph(_).filter((Y)=>Y.instruction?.opcode===H.Return);return this.findEdgePath(U,(Y)=>this.corruptsPointerNode(Y,A),(Y)=>Y.previous.filter((X)=>!this.setsPointerNode(X,A)))!==null}requiresPointerNode(_,A){let R=_.instruction;if(!R)return!1;switch(R.opcode){case H.Command:{let U=R.operand,Y=this.commandPointers.get(U.name);return Y?Y.required.has(A):!1}case H.Gosub:case H.Jump:{let U=R.operand;return this.getPointers(U).required.has(A)}case H.PushVar:{let Y=R.operand.type;if(Y instanceof J0)return A===N.ACTIVE_PLAYER;if(Y instanceof H0)return A===N.ACTIVE_PLAYER;if(Y instanceof W0)return A===N.ACTIVE_NPC;return!1}case H.PopVar:{let U=R.operand,Y=U.type;if(Y instanceof J0||Y instanceof H0)return U.isProtected?A===N.P_ACTIVE_PLAYER:A===N.ACTIVE_PLAYER;if(Y instanceof W0)return A===N.ACTIVE_NPC;return!1}case H.PushVar2:{let Y=R.operand.type;if(Y instanceof J0)return A===N.ACTIVE_PLAYER2;if(Y instanceof H0)return A===N.ACTIVE_PLAYER2;if(Y instanceof W0)return A===N.ACTIVE_NPC2;return!1}case H.PopVar2:{let U=R.operand,Y=U.type;if(Y instanceof J0||Y instanceof H0)return U.isProtected?A===N.P_ACTIVE_PLAYER2:A===N.ACTIVE_PLAYER2;if(Y instanceof W0)return A===N.ACTIVE_NPC2;return!1}default:return!1}}setsPointerNode(_,A){if(_ instanceof P1)return _.set.has(A);let R=_.instruction;if(!R)return!1;switch(R.opcode){case H.Command:{let U=R.operand,Y=this.commandPointers.get(U.name);return Y?Y.set.has(A)&&!Y.conditionalSet:!1}case H.Gosub:{let U=R.operand;return this.getPointers(U).set.has(A)}default:return!1}}corruptsPointerNode(_,A){let R=_.instruction;if(!R)return!1;switch(R.opcode){case H.Command:{let U=R.operand,Y=this.commandPointers.get(U.name);return Y?Y.corrupted.has(A):!1}case H.Gosub:{let U=R.operand;return this.getPointers(U).corrupted.has(A)}default:return!1}}findEdgePath(_,A,R){if(!_.length)return null;let U=new Map,Y=new Map,X=[];for(let G of _)for(let Q of R(G))if(!U.has(Q))Y.set(Q,G),U.set(Q,null),X.push(Q);while(X.length){let G=X.shift();if(A(G)){let Q=[],J=G;while(J)Q.unshift(J),J=U.get(J)??void 0;return Q.unshift(Y.get(Q[0])),Q}for(let Q of R(G))if(!U.has(Q))U.set(Q,G),X.push(Q)}return null}}class M2{scriptWriter;commandPointers;logger=console;sourcePaths;excludePaths;rootTable=new Q2;symbolLoaders=[];dynamicCommandHandlers=new Map;types=new T2;triggers=new l2;static DEFAULT_DIAGNOSTICS_HANDLER=new y2;diagnosticsHandler=M2.DEFAULT_DIAGNOSTICS_HANDLER;constructor(_,A,R,U){this.scriptWriter=R;this.commandPointers=U;this.sourcePaths=_.map((Y)=>this.normalizePath(Y)),this.excludePaths=A.map((Y)=>this.normalizePath(Y)),this.types.registerAll(w),this.setupDefaultTypeCheckers(),this.triggers.registerTrigger(N0)}setupDefaultTypeCheckers(){this.types.addTypeChecker((_,A)=>_===q.Any),this.types.addTypeChecker((_,A)=>A===q.Nothing),this.types.addTypeChecker((_,A)=>_===q.Error||A===q.Error),this.types.addTypeChecker((_,A)=>_===A),this.types.addTypeChecker((_,A)=>_ instanceof q.Script&&A instanceof q.Script&&_.trigger===A.trigger&&this.types.check(_.parameterType,A.parameterType)&&this.types.check(_.returnType,A.returnType)),this.types.addTypeChecker((_,A)=>_ instanceof q.Hook&&A instanceof q.Hook&&this.types.check(_.transmitListType,A.transmitListType)),this.types.addTypeChecker((_,A)=>{let R="inner"in _&&_.inner!=null,U="inner"in A&&A.inner!=null;if(!R||!U)return!1;if(_.constructor.name!==A.constructor.name)return!1;return this.types.check(_.inner,A.inner)}),this.types.addTypeChecker((_,A)=>{if(!(_ instanceof O)||!(A instanceof O))return!1;if(_.children.length!==A.children.length)return!1;for(let R=0;R<_.children.length;R++)if(!this.types.check(_.children[R],A.children[R]))return!1;return!0}),this.types.addTypeChecker((_,A)=>{return _.representation===A.representation})}addSymbolLoader(_){this.symbolLoaders.push(_)}addDynamicCommandHandler(_,A){if(this.dynamicCommandHandlers.has(_))throw Error(`A dynamic command handler with the name of '${_}' already exists.`);this.dynamicCommandHandlers.set(_,A)}run(_){if(this.loadSymbols(),this.compile(_),"close"in this.scriptWriter)this.scriptWriter.close()}loadSymbols(){for(let _ of this.symbolLoaders)_.load(this.rootTable,this)}compile(_){let[A,R]=this.parse(_);if(!A)return;if(!this.analyze(R))return;let[Y,X]=this.codegen(R);if(!Y)return;if(!this.checkPointers(X))return;this.write(X)}parse(_){let A=new _1,R=[],U=0;for(let Y of this.sourcePaths){let X=this.walkTopDown(Y);for(let G of X){if(!G.endsWith(`.${_}`))continue;let Q=new y1(G,A),J=h1.createScriptFile(G,Q);if(J)R.push(J);U++}}return this.diagnosticsHandler.handleParse?.(A),[A.hasErrors()===!1,R]}analyze(_){let A=new _1,R=new p3(this.types,this.triggers,this.rootTable,A);for(let Y of _)Y.accept(R);let U=new h0(this.types,this.triggers,this.rootTable,this.dynamicCommandHandlers,A);for(let Y of _)Y.accept(U);return this.diagnosticsHandler.handleTypeChecking?.(A),!A.hasErrors()}codegen(_){let A=new _1,R=[];for(let U of _){let Y=new A0(this.rootTable,this.dynamicCommandHandlers,A);U.accept(Y),R.push(...Y.scripts)}return this.diagnosticsHandler.handleCodeGeneration?.(A),[A.hasErrors()===!1,R]}checkPointers(_){if(this.commandPointers.size<1)return!1;let A=new _1;return new A4(A,_,this.commandPointers).run(),this.diagnosticsHandler.handlePointerChecking?.(A),!A.hasErrors()}write(_){for(let A of _){if(this.isExcluded(A.sourceName))continue;this.scriptWriter.write(A)}}isExcluded(_){let A;try{A=E0.normalize(E0.resolve(_))}catch{return!1}return this.excludePaths.some((R)=>{let U=E0.normalize(R);return A===U||A.startsWith(U+E0.sep)})}normalizePath(_){return E0.normalize(E0.resolve(_))}walkTopDown(_){let A=[];for(let R of z5.readdirSync(_,{withFileTypes:!0})){let U=E0.join(_,R.name);if(R.isDirectory())A=A.concat(this.walkTopDown(U));else A.push(U)}return A}}import*as v2 from"fs";import*as b2 from"path";import{readFileSync as x6}from"fs";class H1{addConstant(_,A,R){let U=new W1(A,R);if(!_.insert(d.constant(),U))throw Error(`Unable to add constant: name=${A}, value=${R}.`);return U}addBasic(_,A,R,U=!1){let Y=new _0(R,A,U);if(!_.insert(d.basic(A),Y))throw Error(`Unable to add basic: type=${A}, name=${R}`);return Y}}class R4 extends H1{path;constructor(_){super();this.path=_}load(_,A){let R=x6(this.path,"utf8");for(let U of R.split(/\r?\n/)){let Y=U.split("\t",2);if(Y.length!==2)continue;this.addConstant(_,Y[0],Y[1])}}}import{readFileSync as m6}from"fs";class f2 extends H1{mapper;path;typeSupplier;constructor(_,A,R){super();this.mapper=_,this.path=A,this.typeSupplier=R}static withType(_,A,R){return new f2(_,A,()=>R)}load(_,A){let R=m6(this.path,"utf8").split(`
14
- `);for(let U of R){if(!U)continue;let Y=U.split("\t");if(Y.length<2)continue;let X=Number(Y[0]),G=Y[1],Q=Y.length>=3&&Y[2]!=="none"?O.fromList(Y[2].split(",").map((B)=>A.types.find(B)??q.Error)):q.Unit,J=Y.length>=4?Y[3]==="true":!1,F=this.typeSupplier(Q),I=this.addBasic(_,F,G,J);this.mapper.putSymbol(X,I)}}}import{readFileSync as g6}from"fs";class h2 extends H1{mapper;path;typeSupplier;constructor(_,A,R){super();this.mapper=_,this.path=A,this.typeSupplier=R}static withType(_,A,R){return new h2(_,A,()=>R)}load(_,A){let U=g6(this.path,"utf-8").split(/\r?\n/);for(let Y of U){if(!Y)continue;let X=Y.split("\t");if(X.length<2)continue;let G=Number(X[0]),Q=X[1],J=X.length>=3?O.fromList(X[2].split(",").map((B)=>A.types.find(B)??q.Error)):q.Unit,F=this.typeSupplier(J),I=this.addBasic(_,F,Q);this.mapper.putSymbol(G,I)}}}class r0{queueType;constructor(_){this.queueType=_}typeCheck(_){_.checkArgument(0,this.queueType),_.checkArgument(1,w.INT),_.checkArgument(2,w.INT);let A=[this.queueType,w.INT,w.INT];_.checkArgumentTypes(O.fromList(A)),_.expression.type=q.Unit}}class e0{queueType;constructor(_){this.queueType=_}typeCheck(_){let A=_.checkArgument(0,this.queueType);_.checkArgument(1,w.INT);let R=[this.queueType,w.INT],U=[],Y=A?.type;if(Y instanceof q.Script&&Y.trigger==this.queueType.trigger&&Y.parameterType!=q.Unit)U.push(...O.toList(Y.parameterType));_.checkArgumentTypes(O.fromList(R),!0,!1),_.checkArgumentTypes(O.fromList(U),!0,!0),_.expression.type=q.Unit}generateCode(_){let A=_.arguments;_.visitNodes(A);let R=_.arguments2;if(_.visitNodes(R),R.length>0){let U=R.map((Y)=>Y.type.code).filter((Y)=>Y!=null).join("");_.instruction(H.PushConstantString,U)}else _.instruction(H.PushConstantString,"");_.command()}}class V2{queueType;constructor(_){this.queueType=_}typeCheck(_){_.checkArgument(0,this.queueType),_.checkArgument(1,w.INT),_.checkArgument(2,w.INT),_.checkArgument(3,w.INT);let A=[this.queueType,w.INT,w.INT,w.INT];_.checkArgumentTypes(O.fromList(A)),_.expression.type=q.Unit}}class P2{queueType;constructor(_){this.queueType=_}typeCheck(_){let A=_.checkArgument(0,this.queueType);_.checkArgument(1,w.INT),_.checkArgument(2,w.INT);let R=[this.queueType,w.INT,w.INT],U=[],Y=A?.type;if(Y instanceof q.Script&&Y.trigger==this.queueType.trigger&&Y.parameterType!=q.Unit)U.push(...O.toList(Y.parameterType));_.checkArgumentTypes(O.fromList(R),!0,!1),_.checkArgumentTypes(O.fromList(U),!0,!0),_.expression.type=q.Unit}generateCode(_){let A=_.arguments;_.visitNodes(A);let R=_.arguments2;if(_.visitNodes(R),R.length>0){let U=R.map((Y)=>Y.type.code).filter((Y)=>Y!=null).join("");_.instruction(H.PushConstantString,U)}else _.instruction(H.PushConstantString,"");_.command()}}class v1{timerType;constructor(_){this.timerType=_}typeCheck(_){let A=_.checkArgument(0,this.timerType);_.checkArgument(1,w.INT);let R=A?.type,U=[this.timerType,w.INT];if(R instanceof q.Script&&R.trigger==this.timerType.trigger&&R.parameterType!=q.Unit)U.push(...O.toList(R.parameterType));_.checkArgumentTypes(O.fromList(U)),_.expression.type=q.Unit}generateCode(_){let A=_.arguments;if(_.visitNodes(A),A.length>2){let R=A.slice(2).map((U)=>U.type.code).filter((U)=>U!=null).join("");_.instruction(H.PushConstantString,R)}else _.instruction(H.PushConstantString,"");_.command()}}class $1{inner;representation;code;baseType=0;defaultValue=-1;options;constructor(_){this.inner=_;this.representation=`param<${_.representation}>`,this.options=new l({allowSwitch:!1,allowArray:!1,allowDeclaration:!1})}}class V0{type;constructor(_){this.type=_}typeCheck(_){let A=[];if(this.type!==null)A.push(this.type),_.checkArgument(0,this.type);let R=this.type===null?0:1,U=_.checkArgument(R,V0.PARAM_ANY),Y=U?.type instanceof $1?U.type.inner:void 0;if(A.push(new $1(Y??q.Any)),!_.checkArgumentTypes(O.fromList(A))){_.expression.type=q.Error;return}if(Y==null){_.expression.reportError(_.diagnostics,"Param return type was not able to be found."),_.expression.type=q.Error;return}_.expression.type=Y}static PARAM_ANY=new $1(q.Any)}class U4 extends T0{visitBinaryExpression(_){return`${this.visit(_.left)} ${_.operator.text} ${this.visit(_.right)}`}visitCalcExpression(_){return`calc${this.visit(_.expression)}`}visitCommandCallExpression(_){let A="~"+this.visit(_.name);if(_.arguments.length>0)A+="(",A+=_.arguments.map((R)=>this.visit(R)).join(""),A+=")";return A}visitLocalVariableExpression(_){return`$${this.visit(_.name)}`}visitGameVariableExpression(_){return`%${this.visit(_.name)}`}visitConstantVariableExpression(_){return`^${this.visit(_.name)}`}visitCharacterLiteral(_){return`'${_.value}'`}visitNullLiteral(_){return"null"}visitStringLiteral(_){return`"${_.value}"`}visitLiteral(_){return String(_.value)}visitJoinedStringExpression(_){let A='"';for(let R of _.parts)A+=this.visit(R);return A+='"',A}visitJoinedStringPart(_){if(_ instanceof m0)return _.value;if(_ instanceof g0)return`<${this.visit(_.expression)}>`;throw Error(`Unsupported StringPart: ${_}`)}visitIdentifier(_){return _.text}visit(_){_.accept(this)}}class F1{typeCheck(_){if(_.arguments.length===0)_.expression.reportError(_.diagnostics,F1.DIAGNOSTIC_INVALID_SIGNATURE);else _.arguments.forEach((A,R)=>{_.checkArgument(R,q.Any);let U=A.type;if(U instanceof O)A.reportError(_.diagnostics,F1.DIAGNOSTIC_TUPLE_TYPE,U.representation);else if(U.baseType!==0&&U.baseType!==1)A.reportError(_.diagnostics,F1.DIAGNOSTIC_UNIT_TYPE,U.representation)});_.expression.type=w.STRING}generateCode(_){_.lineInstruction(_.expression);let A=0;_.arguments.forEach((R,U)=>{let Y=R.accept(F1.EXPRESSION_GENERATOR);if(_.instruction(H.PushConstantString,`${Y}=`),A++,_.visitNode(R),this.typeToString(_,R.type),U!==_.arguments.length-1)_.instruction(H.PushConstantString,", "),A++}),_.instruction(H.JoinString,A)}typeToString(_,A){let R;if(A===w.STRING)R="escape";else if(A.baseType===0)R="toString";else throw Error(`Unsupported type conversion to string: ${A}`);let U=_.rootTable.find(d.serverScript(N0),R);if(U)_.instruction(H.Command,U)}static DIAGNOSTIC_INVALID_SIGNATURE="Type mismatch: '<unit>' was given but 'any...' was expected.";static DIAGNOSTIC_TUPLE_TYPE="Unable to dump multi-value types: %s";static DIAGNOSTIC_INVALID_BASE_TYPE="Unable to debug '%s' expressions.";static DIAGNOSTIC_UNIT_TYPE="Unable to debug expression with no return value.";static EXPRESSION_GENERATOR=new U4}class Y4{typeCheck(_){_.checkArgumentTypes(q.Unit),_.expression.type=w.STRING}generateCode(_){let A=_.expression.findParentByType(p0);if(!A)throw Error("Script not found.");let R=`[${A.trigger.text}, ${A.name.text}]`;_.lineInstruction(_.expression),_.instruction(H.PushConstantString,R)}}class P0{inner;representation;code;baseType=0;defaultValue=-1;options;constructor(_){this.inner=_;this.representation=`dbcolumn<${_.representation}>`,this.options=new l({allowSwitch:!1,allowArray:!1,allowDeclaration:!1})}}class b1{withCount;constructor(_){this.withCount=_}typeCheck(_){let A=_.checkArgument(0,new P0(q.Any)),R=A?.type?.inner;_.checkArgument(1,R);let U=new O(new P0(R??q.Any),R??q.Any);if(R instanceof O)A.reportError(_.diagnostics,"Tuple columns are not supported.");else _.checkArgumentTypes(U);_.expression.type=this.withCount?w.INT:q.Unit}generateCode(_){let R=_.arguments[0].type.inner.baseType,U=(()=>{switch(R){case 0:return 0;case 2:return 1;case 1:return 2;default:throw Error(`Unsupported base type: ${R}.`)}})();_.visitNodes(_.arguments),_.instruction(H.PushConstantInt,U),_.command()}}class X4{typeCheck(_){_.checkArgument(0,$.DBROW);let A=_.checkArgument(1,new P0(q.Any));_.checkArgument(2,w.INT);let R=A?.type?.inner,U=new O($.DBROW,new P0(R??q.Any),w.INT);if(!_.checkArgumentTypes(U)){_.expression.type=q.Error;return}if(A==null){(A??_.expression).reportError(_.diagnostics,"Unable to extract type from argument."),_.expression.type=q.Error;return}_.expression.type=R}}class G4{typeCheck(_){let A=_.checkTypeArgument(0),R=_.checkTypeArgument(1);_.checkArgument(2,$.ENUM);let U=A?.type instanceof q.Type?A.type.inner:void 0,Y=R?.type instanceof q.Type?R.type.inner:void 0;_.checkArgument(3,U);let X=new O(new q.Type(U??q.Any),new q.Type(Y??q.Any),$.ENUM,U??q.Any);_.checkArgumentTypes(X),_.expression.type=Y??q.Error}}class N4 extends M2{symbolPaths;mapper;constructor(_,A,R,U,Y,X){super(_,A,R,U);this.symbolPaths=Y,this.mapper=X}setup(){this.triggers.registerAll(z),this.types.registerAll($),this.types.changeOptions("long",(_)=>{_.allowDeclaration=!1}),this.types.register("proc",new q.Script(z.PROC,q.Unit,q.Unit)),this.types.register("label",new q.Script(z.LABEL,q.Unit,q.Nothing)),this.types.addTypeChecker((_,A)=>_===$.OBJ&&A===$.NAMEDOBJ),this.addSymConstantLoaders(),this.types.register("walktrigger",new q.Script(z.WALKTRIGGER,q.Any,q.Nothing)),this.types.register("ai_walktrigger",new q.Script(z.AI_WALKTRIGGER,q.Any,q.Nothing)),this.types.register("queue",new q.Script(z.QUEUE,q.Any,q.Nothing)),this.addDynamicCommandHandler("queue",new r0(this.types.find("queue"))),this.addDynamicCommandHandler(".queue",new r0(this.types.find("queue"))),this.addDynamicCommandHandler("queue*",new e0(this.types.find("queue"))),this.addDynamicCommandHandler(".queue*",new e0(this.types.find("queue"))),this.addDynamicCommandHandler("longqueue",new V2(this.types.find("queue"))),this.addDynamicCommandHandler(".longqueue",new V2(this.types.find("queue"))),this.addDynamicCommandHandler("longqueue*",new P2(this.types.find("queue"))),this.addDynamicCommandHandler(".longqueue*",new P2(this.types.find("queue"))),this.types.register("timer",new q.Script(z.TIMER,q.Any,q.Nothing)),this.addDynamicCommandHandler("settimer",new v1(this.types.find("timer"))),this.addDynamicCommandHandler(".settimer",new v1(this.types.find("timer"))),this.addDynamicCommandHandler("lc_param",new V0($.LOC)),this.addDynamicCommandHandler("loc_param",new V0(null)),this.addSymLoader("loc",$.LOC),this.addDynamicCommandHandler("nc_param",new V0($.NPC)),this.addDynamicCommandHandler("npc_param",new V0(null)),this.addSymLoader("npc",$.NPC),this.addDynamicCommandHandler("oc_param",new V0($.OBJ)),this.addDynamicCommandHandler("obj_param",new V0(null)),this.addSymLoader("obj",$.NAMEDOBJ),this.addSymLoader("component",$.COMPONENT),this.addSymLoader("interface",$.INTERFACE),this.addSymLoader("overlayinterface",$.OVERLAYINTERFACE),this.addSymLoader("fontmetrics",$.FONTMETRICS),this.addSymLoader("category",$.CATEGORY),this.addSymLoader("hunt",$.HUNT),this.addSymLoader("inv",$.INV),this.addSymLoader("idk",$.IDKIT),this.addSymLoader("mesanim",$.MESANIM),this.addSymLoaderWithSupplier("param",(_)=>new $1(_)),this.addSymLoader("seq",$.SEQ),this.addSymLoader("spotanim",$.SPOTANIM),this.types.register("varp",new J0(q.Any)),this.addProtectedSymLoaderWithSupplier("varp",(_)=>new J0(_)),this.addSymLoaderWithSupplier("varn",(_)=>new W0(_)),this.addSymLoaderWithSupplier("vars",(_)=>new q1(_)),this.addSymLoader("stat",$.STAT),this.addSymLoader("locshape",$.LOC_SHAPE),this.addSymLoader("movespeed",$.MOVESPEED),this.addSymLoader("npc_mode",$.NPC_MODE),this.addSymLoader("npc_stat",$.NPC_STAT),this.addSymLoader("model",$.MODEL),this.addSymLoader("synth",$.SYNTH),this.types.register("varbit",new H0(q.Any)),this.addProtectedSymLoaderWithSupplier("varbit",(_)=>new H0(_)),this.addDynamicCommandHandler("weakqueue",new r0(this.types.find("queue"))),this.addDynamicCommandHandler(".weakqueue",new r0(this.types.find("queue"))),this.addDynamicCommandHandler("weakqueue*",new e0(this.types.find("queue"))),this.addDynamicCommandHandler(".weakqueue*",new e0(this.types.find("queue"))),this.addDynamicCommandHandler("strongqueue",new r0(this.types.find("queue"))),this.addDynamicCommandHandler(".strongqueue",new r0(this.types.find("queue"))),this.addDynamicCommandHandler("strongqueue*",new e0(this.types.find("queue"))),this.addDynamicCommandHandler(".strongqueue*",new e0(this.types.find("queue"))),this.addDynamicCommandHandler("enum",new G4),this.addSymLoader("enum",$.ENUM),this.addDynamicCommandHandler("struct_param",new V0($.STRUCT)),this.addSymLoader("struct",$.STRUCT),this.types.register("softtimer",new q.Script(z.SOFTTIMER,q.Any,q.Nothing)),this.addDynamicCommandHandler("softtimer",new v1(this.types.find("softtimer"))),this.addDynamicCommandHandler(".softtimer",new v1(this.types.find("softtimer"))),this.types.register("dbcolumn",new P0(q.Any)),this.addDynamicCommandHandler("db_find",new b1(!1)),this.addDynamicCommandHandler("db_find_refine",new b1(!1)),this.addDynamicCommandHandler("db_find_with_count",new b1(!0)),this.addDynamicCommandHandler("db_find_refine_with_count",new b1(!0)),this.addDynamicCommandHandler("db_getfield",new X4),this.addSymLoaderWithSupplier("dbcolumn",(_)=>new P0(_)),this.addSymLoader("dbrow",$.DBROW),this.addSymLoader("dbtable",$.DBTABLE),this.addDynamicCommandHandler("dump",new F1),this.addDynamicCommandHandler("script",new Y4)}addSymConstantLoaders(){for(let _ of this.symbolPaths){let A=b2.join(_,"constant.sym");if(v2.existsSync(A))this.addSymbolLoader(new R4(A))}}addSymLoader(_,A){this.addSymLoaderWithSupplier(_,()=>A)}addSymLoaderWithSupplier(_,A){for(let R of this.symbolPaths){let U=b2.join(R,`${_}.sym`);if(v2.existsSync(U))this.addSymbolLoader(new h2(this.mapper,U,A))}}addProtectedSymLoader(_,A){this.addProtectedSymLoaderWithSupplier(_,()=>A)}addProtectedSymLoaderWithSupplier(_,A){for(let R of this.symbolPaths){let U=b2.join(R,`${_}.sym`);if(v2.existsSync(U))this.addSymbolLoader(new f2(this.mapper,U,A))}}}import*as E5 from"console";import*as G0 from"fs";import*as S2 from"path";import*as L5 from"zlib";var d6=(()=>{let _=new Int32Array(256);for(let A=0;A<256;A++){let R=A;for(let U=0;U<8;U++)if((R&1)===1)R=R>>>1^3988292384;else R>>>=1;_[A]=R}return _})();function K5(_){let A=4294967295;for(let R=0;R<_.length;R++)A=A>>>8^d6[(A^_[R])&255];return~A|0}class u2{buffer;offset=0;constructor(_){this.buffer=Buffer.alloc(Math.max(64,_))}p1(_){this.ensure(1),this.buffer.writeUInt8(_&255,this.offset),this.offset+=1}p2(_){this.ensure(2),this.buffer.writeUInt16BE(_&65535,this.offset),this.offset+=2}p4(_){this.ensure(4),this.buffer.writeInt32BE(_|0,this.offset),this.offset+=4}pSmart2or4(_){if(_<32768)this.p2(_);else this.p4(_|2147483648)}pdata(_){this.ensure(_.length),_.copy(this.buffer,this.offset),this.offset+=_.length}toBuffer(){return this.buffer.subarray(0,this.offset)}ensure(_){if(this.offset+_<=this.buffer.length)return;let A=this.buffer.length*2;while(this.offset+_>A)A*=2;let R=Buffer.alloc(A);this.buffer.copy(R,0,0,this.offset),this.buffer=R}}class u1 extends d1{output;buffers=new Map;static INDEX_FORMAT=7;static INDEX_VERSION=1;static GROUP_VERSION=1;constructor(_,A){super(A);this.output=_;let R=S2.dirname(_);if(!G0.existsSync(R))G0.mkdirSync(R,{recursive:!0});if(!G0.statSync(R).isDirectory())throw Error(`${S2.resolve(R)} is not a directory.`)}outputScript(_,A){let R=this.idProvider.get(_.symbol);this.buffers.set(R,Buffer.from(A))}close(){let _=[...this.buffers.entries()].sort((Y,X)=>Y[0]-X[0]).map(([Y,X])=>{let G=this.packGroup(X,0);return{groupId:Y,packedGroup:G,checksum:K5(G),version:u1.GROUP_VERSION}}),A=this.encodeIndex(_),R=this.packGroup(A,2),U=G0.openSync(this.output,"w");try{G0.writeSync(U,R);for(let Y of _)G0.writeSync(U,Y.packedGroup);for(let Y of _)this.p4(U,Y.packedGroup.length)}finally{G0.closeSync(U)}}encodeIndex(_){let A=new u2(128);A.p1(u1.INDEX_FORMAT),A.p4(u1.INDEX_VERSION),A.p1(0),A.pSmart2or4(_.length);let R=0;for(let U of _)A.pSmart2or4(U.groupId-R),R=U.groupId;for(let U of _)A.p4(U.checksum);for(let U of _)A.p4(U.version);for(let U of _)A.pSmart2or4(1);for(let U of _)A.pSmart2or4(0);return A.toBuffer()}packGroup(_,A){let R=new u2(_.length+16);if(R.p1(A),A===0)R.p4(_.length),R.pdata(_);else if(A===2){let U=L5.gzipSync(_);U[9]=0,R.p4(U.length),R.p4(_.length),R.pdata(U)}else throw Error(`Unsupported compression type ${A}`);return R.toBuffer()}p4(_,A){let R=Buffer.allocUnsafe(4);R.writeInt32BE(A,0),G0.writeSync(_,R)}}function T6(_){let A=["../content/scripts"],R=["./data/symbols"],U=[],Y=!0,X={output:"./data/pack/server"},G=null;if(typeof _<"u"){if(typeof _.sourcePaths<"u")A=_.sourcePaths;if(typeof _.symbolPaths<"u")R=_.symbolPaths;if(typeof _.excludePaths<"u")U=_.excludePaths;if(typeof _.checkPointers<"u")Y=_.checkPointers;if(typeof _.writer<"u"){if(typeof _.writer.jag<"u")X=_.writer.jag,G=null;else if(typeof _.writer.js5<"u")G=_.writer.js5,X=null}}A.map((B)=>Y2(B)),R.map((B)=>Y2(B)),U.map((B)=>Y2(B));let Q=new g2,J;if(X)J=new N2(Y2(X.output),Q);else if(G)J=new u1(Y2(G.output),Q);else E5.error("No writer configured."),l6(1);let F=new Map;y6(R,Q,F,Y);let I=new N4(A,U,J,F,R,Q);I.setup(),I.run("rs2")}function y6(_,A,R,U){for(let Y of _){let X=w5(Y,"commands.sym");if(D5(X)){let Q=B5(X,"utf-8").split(/\r?\n/);for(let J of Q){if(!J.trim())continue;let F=J.split("\t"),I=parseInt(F[0],10),B=F[1];if(U&&F.length>2){let C=F[2]??"",V=F[3]??"",x=V.includes("CONDITIONAL:")?V.split("CONDITIONAL:")[1]:V,e=F[4]??"",[I1,X2]=C.split(":"),[G2,x2]=x.split(":"),[m2,k5]=e.split(":"),C5=S1(I1),Q4=S1(X2),j5=S1(G2),Z4=S1(x2),J4=V!==x,O5=S1(m2),H4=S1(k5);if(R.set(B,{required:C5,set:j5,conditionalSet:J4,corrupted:O5}),Q4.size||Z4.size||H4.size)R.set(`.${B}`,{required:Q4,set:Z4,conditionalSet:J4,corrupted:H4})}A.putCommand(I,B)}}let G=w5(Y,"runescript.sym");if(D5(G)){let Q=B5(G,"utf-8").split(/\r?\n/);for(let J of Q){if(!J.trim())continue;let F=J.split("\t"),I=parseInt(F[0],10),B=F[1];A.putScript(I,B)}}}}function S1(_){if(!_||_==="none")return new Set;let A=new Set,R=_.split(",");for(let U of R){let Y=N.forName(U);if(Y)A.add(Y);else throw Error(`Invalid pointer name: ${U}.`)}return A}export{T6 as CompileServerScript};
9
+ `,R);if(!R.context||R.context.hasEmptyPath())if(!R.context||R.context.isEmpty())return U.add(R),!0;else U.add(w0.createWithConfig(R.state,R,c.instance)),N=!0;if(R.context&&!R.context.isEmpty()){for(let $=0;$<R.context.length;$++)if(R.context.getReturnState($)!==p.EMPTY_RETURN_STATE){let J=R.context.getParent($),I=this.atn.states[R.context.getReturnState($)];Q=w0.createWithConfig(I,R,J),N=this.closure(A,Q,U,N,Y,X)}}return N}if(!R.state.epsilonOnlyTransitions){if(!N||!R.passedThroughNonGreedyDecision)U.add(R)}for(let $ of R.state.transitions)if(Q=this.getEpsilonTarget(A,R,$,U,Y,X),Q)N=this.closure(A,Q,U,N,Y,X);return N}getEpsilonTarget(A,R,U,N,Y,X){if(!this.lexerATNConfigFactory)this.setupATNFactoryLookup();let Q=this.lexerATNConfigFactory[U.transitionType];if(!Q)return null;return Q(A,R,U,N,Y,X)}setupATNFactoryLookup(){this.lexerATNConfigFactory=[],this.lexerATNConfigFactory[O.RULE]=(R,U,N)=>{let Y=X1(U.context??void 0,N.followState.stateNumber);return w0.createWithConfig(N.target,U,Y)},this.lexerATNConfigFactory[O.PRECEDENCE]=()=>{throw Error("Precedence predicates are not supported in lexers.")},this.lexerATNConfigFactory[O.PREDICATE]=(R,U,N,Y,X)=>{let Q=N;if(_.debug)console.log("EVAL rule "+Q.ruleIndex+":"+Q.predIndex);if(Y.hasSemanticContext=!0,this.evaluatePredicate(R,Q.ruleIndex,Q.predIndex,X))return w0.createWithConfig(N.target,U);return null},this.lexerATNConfigFactory[O.ACTION]=(R,U,N)=>{if(U.context===null||U.context.hasEmptyPath()){let Y=p5.append(U.lexerActionExecutor,this.atn.lexerActions[N.actionIndex]);return w0.createWithExecutor(U,N.target,Y)}else return w0.createWithConfig(N.target,U)},this.lexerATNConfigFactory[O.EPSILON]=(R,U,N)=>{return w0.createWithConfig(N.target,U)};let A=q((R,U,N,Y,X,Q)=>{if(Q){if(N.matches(B.EOF,this.options.minCodePoint,this.options.maxCodePoint))return w0.createWithConfig(N.target,U)}return null},"simple");this.lexerATNConfigFactory[O.ATOM]=A,this.lexerATNConfigFactory[O.RANGE]=A,this.lexerATNConfigFactory[O.SET]=A}evaluatePredicate(A,R,U,N){if(!this.recognizer)return!0;if(!N)return this.recognizer.sempred(null,R,U);let Y=this.column,X=this.line,Q=A.index,$=A.mark();try{return this.consume(A),this.recognizer.sempred(null,R,U)}finally{this.column=Y,this.line=X,A.seek(Q),A.release($)}}captureSimState(A,R){this.prevAccept={index:A.index,line:this.line,column:this.column,dfaState:R}}addDFAEdge(A,R,U,N){if(!U&&N){let Y=N.hasSemanticContext;if(N.hasSemanticContext=!1,U=this.addDFAState(N),Y)return U}if(R<this.options.minDFAEdge||R>this.options.maxDFAEdge)return U;if(_.debug)console.log("EDGE "+A+" -> "+U+" upon "+R);return A.edges[R-this.options.minDFAEdge]=U,U}addDFAState(A){let R=this.decisionToDFA[this.mode],U=R.getStateForConfigs(A);if(U)return U;let N=E1.fromConfigs(A),Y=A.firstStopState;if(Y)N.isAcceptState=!0,N.lexerActionExecutor=Y.lexerActionExecutor,N.prediction=this.atn.ruleToTokenType[Y.state.ruleIndex];return A.setReadonly(!0),R.addState(N),N}},t5=class{static{q(this,"ParseInfo")}atnSimulator;constructor(_){this.atnSimulator=_}getDecisionInfo(){return this.atnSimulator.getDecisionInfo()}getLLDecisions(){let _=this.atnSimulator.getDecisionInfo(),A=[];for(let R=0;R<_.length;R++)if(_[R].llFallback>0)A.push(R);return A}getTotalTimeInPrediction(){let _=this.atnSimulator.getDecisionInfo(),A=0;for(let R of _)A+=R.timeInPrediction;return A}getTotalSLLLookaheadOps(){let _=this.atnSimulator.getDecisionInfo(),A=0;for(let R of _)A+=R.sllTotalLook;return A}getTotalLLLookaheadOps(){let _=this.atnSimulator.getDecisionInfo(),A=0;for(let R of _)A+=R.llTotalLook;return A}getTotalSLLATNLookaheadOps(){let _=this.atnSimulator.getDecisionInfo(),A=0;for(let R of _)A+=R.sllATNTransitions;return A}getTotalLLATNLookaheadOps(){let _=this.atnSimulator.getDecisionInfo(),A=0;for(let R of _)A+=R.llATNTransitions;return A}getTotalATNLookaheadOps(){let _=this.atnSimulator.getDecisionInfo(),A=0;for(let R of _)A+=R.sllATNTransitions,A+=R.llATNTransitions;return A}getDFASize(_){if(_===void 0){let A=0,R=this.atnSimulator.decisionToDFA;for(let U=0;U<R.length;U++)A+=this.getDFASize(U);return A}else return this.atnSimulator.decisionToDFA[_].length}},Q1=class extends f{static{q(this,"NoViableAltException")}deadEndConfigs=null;startToken;constructor(_,A=null,R=null,U=null,N=null,Y=null){Y=Y??_.context,U=U??_.getCurrentToken(),R=R??_.getCurrentToken(),A=A??_.inputStream;super({message:"",recognizer:_,input:A,ctx:Y});this.deadEndConfigs=N,this.startToken=R,this.offendingToken=U}},I4=class{static{q(this,"DoubleDict")}cacheMap;constructor(){this.cacheMap=new m0}get(_,A){let R=this.cacheMap.get(_)??null;return R===null?null:R.get(A)??null}set(_,A,R){let U=this.cacheMap.get(_);if(!U)U=new m0,this.cacheMap.set(_,U);U.set(A,R)}},r5=class _{static{q(this,"SubsetEqualityComparer")}static instance=new _;hashCode(A){let R=k.initialize(7);return R=k.update(R,A.state.stateNumber),R=k.updateFromComparable(R,A.context),R=k.finish(R,2),R}equals(A,R){return A.state.stateNumber===R.state.stateNumber&&(A.context?.equals(R.context)??!0)}},t=class _{static{q(this,"PredictionMode")}static SLL=0;static LL=1;static LL_EXACT_AMBIG_DETECTION=2;static hasSLLConflictTerminatingPrediction(A,R){if(_.allConfigsInRuleStopStates(R))return!0;if(A===_.SLL){if(R.hasSemanticContext){let N=new S0;for(let Y of R)Y=y.duplicate(Y,u.NONE),N.add(Y);R=N}}let U=_.getConflictingAltSubsets(R);return _.hasConflictingAltSet(U)&&!_.hasStateAssociatedWithOneAlt(R)}static hasConfigInRuleStopState(A){for(let R of A)if(R.state instanceof q0)return!0;return!1}static allConfigsInRuleStopStates(A){for(let R of A)if(!(R.state instanceof q0))return!1;return!0}static resolvesToJustOneViableAlt(A){return _.getSingleViableAlt(A)}static allSubsetsConflict(A){return!_.hasNonConflictingAltSet(A)}static hasNonConflictingAltSet(A){for(let R of A)if(R.length===1)return!0;return!1}static hasConflictingAltSet(A){for(let R of A)if(R.length>1)return!0;return!1}static allSubsetsEqual(A){let R=null;for(let U of A)if(R===null)R=U;else if(U!==R)return!1;return!0}static getUniqueAlt(A){let R=_.getAlts(A);if(R.length===1)return R.nextSetBit(0);else return P.INVALID_ALT_NUMBER}static getAlts(A){let R=new k0;return A.forEach((U)=>{R.or(U)}),R}static getConflictingAltSubsets(A){let R=new m0(r5.instance);for(let U of A){let N=R.get(U);if(!N)N=new k0,R.set(U,N);N.set(U.alt)}return Array.from(R.values())}static getStateToAltMap(A){let R=new m0(Y1.instance);for(let U of A){let N=R.get(U.state);if(!N)N=new k0,R.set(U.state,N);N.set(U.alt)}return R}static hasStateAssociatedWithOneAlt(A){let R={};for(let U of A){let N=U.state.stateNumber;if(!R[N])R[N]=0;R[N]++}return Object.values(R).some((U)=>{return U===1})}static getSingleViableAlt(A){let R=null;for(let U of A){let N=U.nextSetBit(0);if(R===null)R=N;else if(R!==N)return P.INVALID_ALT_NUMBER}return R??0}},n1=class _ extends E0{static{q(this,"ParserATNSimulator")}static traceATNSimulator=!1;static debug;static debugAdd=!1;static debugClosure=!1;static dfaDebug=!1;static retryDebug=!1;predictionMode;decisionToDFA;parser;mergeCache=new I4;predictionState;constructor(A,R,U,N){super(R,N);this.parser=A,this.decisionToDFA=U}static getUniqueAlt(A){let R=P.INVALID_ALT_NUMBER;for(let U of A)if(R===P.INVALID_ALT_NUMBER)R=U.alt;else if(U.alt!==R)return P.INVALID_ALT_NUMBER;return R}reset(){}clearDFA(){for(let A=0;A<this.decisionToDFA.length;A++)this.decisionToDFA[A]=new x0(this.atn.getDecisionState(A),A)}adaptivePredict(A,R,U){if(_.debug||_.traceATNSimulator)console.log("adaptivePredict decision "+R+" exec LA(1)=="+this.getLookaheadName(A)+" line "+A.LT(1).line+":"+A.LT(1).column);let N=this.decisionToDFA[R];this.predictionState={input:A,startIndex:A.index,outerContext:U??void 0,dfa:N};let Y=A.mark(),X=A.index;try{let Q;if(N.isPrecedenceDfa)Q=N.getPrecedenceStartState(this.parser.getPrecedence());else Q=N.s0;if(!Q){if(!U)U=h.empty;if(_.debug)console.log("predictATN decision "+N.decision+" exec LA(1)=="+this.getLookaheadName(A)+", outerContext="+U.toString(this.parser.ruleNames));let J=!1,I=this.computeStartState(N.atnStartState,h.empty,J);if(N.isPrecedenceDfa)I=this.applyPrecedenceFilter(I),Q=this.addDFAState(N,E1.fromConfigs(I)),N.setPrecedenceStartState(this.parser.getPrecedence(),Q);else Q=this.addDFAState(N,E1.fromConfigs(I)),N.s0=Q}let $=this.execATN(N,Q,A,X,U);if(_.debug)console.log("DFA after predictATN: "+N.toString(this.parser.vocabulary));return $}finally{this.predictionState.dfa=void 0,this.mergeCache=new I4,A.seek(X),A.release(Y)}}execATN(A,R,U,N,Y){if(_.debug||_.traceATNSimulator)console.log("execATN decision "+A.decision+", DFA state "+R+", LA(1)=="+this.getLookaheadName(U)+" line "+U.LT(1).line+":"+U.LT(1).column);let X,Q=R,$=U.LA(1);while(!0){let J=this.getExistingTargetState(Q,$);if(!J)J=this.computeTargetState(A,Q,$);if(J===E0.ERROR){let I=this.noViableAlt(U,Y,Q.configs,N);if(U.seek(N),X=this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(Q.configs,Y),X!==P.INVALID_ALT_NUMBER)return X;else throw I}if(J.requiresFullContext&&this.predictionMode!==t.SLL){let I=null;if(J.predicates!==null){if(_.debug)console.log("DFA state has preds in DFA sim LL failover");let V=U.index;if(V!==N)U.seek(N);if(I=this.evalSemanticContext(J.predicates,Y,!0),I.length===1){if(_.debug)console.log("Full LL avoided");return I.nextSetBit(0)}if(V!==N)U.seek(V)}if(_.dfaDebug)console.log("ctx sensitive state "+Y+" in "+J);let w=!0,C=this.computeStartState(A.atnStartState,Y,w);return this.reportAttemptingFullContext(A,I,J.configs,N,U.index),X=this.execATNWithFullContext(A,J,C,U,N,Y),X}if(J.isAcceptState){if(J.predicates===null)return J.prediction;let I=U.index;U.seek(N);let w=this.evalSemanticContext(J.predicates,Y,!0);if(w.length===0)throw this.noViableAlt(U,Y,J.configs,N);if(w.length===1)return w.nextSetBit(0);return this.reportAmbiguity(A,J,N,I,!1,w,J.configs),w.nextSetBit(0)}if(Q=J,$!==B.EOF)U.consume(),$=U.LA(1)}}getExistingTargetState(A,R){return A.edges[R+1]}computeTargetState(A,R,U){let N=this.computeReachSet(R.configs,U,!1);if(N===null)return this.addDFAEdge(A,R,U,E0.ERROR),E0.ERROR;let Y=E1.fromConfigs(N),X=_.getUniqueAlt(N);if(_.debug){let Q=t.getConflictingAltSubsets(N);console.log("SLL altSubSets="+D1(Q)+", configs="+N+", predict="+X+", allSubsetsConflict="+t.allSubsetsConflict(Q)+", conflictingAlts="+this.getConflictingAlts(N))}if(X!==P.INVALID_ALT_NUMBER)Y.isAcceptState=!0,Y.configs.uniqueAlt=X,Y.prediction=X;else if(t.hasSLLConflictTerminatingPrediction(this.predictionMode,N))Y.configs.conflictingAlts=this.getConflictingAlts(N),Y.requiresFullContext=!0,Y.isAcceptState=!0,Y.prediction=Y.configs.conflictingAlts.nextSetBit(0);if(Y.isAcceptState&&Y.configs.hasSemanticContext){if(this.predicateDFAState(Y,this.atn.getDecisionState(A.decision)),Y.predicates!==null)Y.prediction=P.INVALID_ALT_NUMBER}return Y=this.addDFAEdge(A,R,U,Y),Y}getRuleName(A){if(this.parser!==null&&A>=0)return this.parser.ruleNames[A];else return"<rule "+A+">"}getTokenName(A){if(A===B.EOF)return"EOF";let U=(this.parser?.vocabulary??K0.EMPTY_VOCABULARY).getDisplayName(A);if(U===A.toString())return U;return U+"<"+A+">"}getLookaheadName(A){return this.getTokenName(A.LA(1))}dumpDeadEndConfigs(A){console.log("dead end configs: ");let R=A.deadEndConfigs;for(let U of R){let N="no edges";if(U.state.transitions.length>0){let Y=U.state.transitions[0];if(Y instanceof y1)N="Atom "+this.getTokenName(Y.labelValue);else if(Y instanceof p2)N=(Y instanceof i2?"~":"")+"Set "+Y.label}console.error(U.toString(this.parser,!0)+":"+N)}}predicateDFAState(A,R){let U=R.transitions.length,N=this.getConflictingAltsOrUniqueAlt(A.configs),Y=this.getPredsForAmbigAlts(N,A.configs,U);if(Y!==null)A.predicates=this.getPredicatePredictions(N,Y),A.prediction=P.INVALID_ALT_NUMBER;else A.prediction=N.nextSetBit(0)}execATNWithFullContext(A,R,U,N,Y,X){if(_.debug||_.traceATNSimulator)console.log("execATNWithFullContext "+U);let Q=!0,$=!1,J,I=U;N.seek(Y);let w=N.LA(1),C=-1;for(;;){if(J=this.computeReachSet(I,w,Q),J===null){let m=this.noViableAlt(N,X,I,Y);N.seek(Y);let N0=this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(I,X);if(N0!==P.INVALID_ALT_NUMBER)return N0;else throw m}let V=t.getConflictingAltSubsets(J);if(_.debug)console.log("LL altSubSets="+V+", predict="+t.getUniqueAlt(V)+", resolvesToJustOneViableAlt="+t.resolvesToJustOneViableAlt(V));if(J.uniqueAlt=_.getUniqueAlt(J),J.uniqueAlt!==P.INVALID_ALT_NUMBER){C=J.uniqueAlt;break}else if(this.predictionMode!==t.LL_EXACT_AMBIG_DETECTION){if(C=t.resolvesToJustOneViableAlt(V),C!==P.INVALID_ALT_NUMBER)break}else if(t.allSubsetsConflict(V)&&t.allSubsetsEqual(V)){$=!0,C=t.getSingleViableAlt(V);break}if(I=J,w!==B.EOF)N.consume(),w=N.LA(1)}if(J.uniqueAlt!==P.INVALID_ALT_NUMBER)return this.reportContextSensitivity(A,C,J,Y,N.index),C;return this.reportAmbiguity(A,R,Y,N.index,$,J.getAlts(),J),C}computeReachSet(A,R,U){if(_.debug)console.log("in computeReachSet, starting closure: "+A);let N=new S0(U),Y=null;for(let Q of A){if(_.debug)console.log("testing "+this.getTokenName(R)+" at "+Q);if(Q.state instanceof q0){if(U||R===B.EOF){if(Y===null)Y=[];Y.push(Q)}continue}for(let $ of Q.state.transitions){let J=this.getReachableTarget($,R);if(J!==null){let I=y.createWithConfig(J,Q);if(N.add(I,this.mergeCache),_.debugAdd)console.log("added "+I+" to intermediate")}}}let X=null;if(Y===null&&R!==B.EOF){if(N.length===1)X=N;else if(_.getUniqueAlt(N)!==P.INVALID_ALT_NUMBER)X=N}if(X===null){X=new S0(U);let Q=new $0,$=R===B.EOF;for(let J of N)this.closure(J,X,Q,!1,U,$)}if(R===B.EOF)X=this.removeAllConfigsNotInRuleStopState(X,X===N);if(Y!==null&&(!U||!t.hasConfigInRuleStopState(X)))for(let Q of Y)X.add(Q,this.mergeCache);if(_.traceATNSimulator)console.log("computeReachSet "+A+" -> "+X);if(X.length===0)return null;else return X}removeAllConfigsNotInRuleStopState(A,R){if(t.allConfigsInRuleStopStates(A))return A;let U=new S0(A.fullCtx);for(let N of A){if(N.state instanceof q0){U.add(N,this.mergeCache);continue}if(R&&N.state.epsilonOnlyTransitions){if(this.atn.nextTokens(N.state).contains(B.EPSILON)){let X=this.atn.ruleToStopState[N.state.ruleIndex];U.add(y.createWithConfig(X,N),this.mergeCache)}}}return U}computeStartState(A,R,U){let N=t2(this.atn,R),Y=new S0(U);if(_.traceATNSimulator)console.log("computeStartState from ATN state "+A+" initialContext="+N.toString(this.parser));for(let X=0;X<A.transitions.length;X++){let Q=A.transitions[X].target,$=y.createWithContext(Q,X+1,N),J=new $0;this.closure($,Y,J,!0,U,!1)}return Y}applyPrecedenceFilter(A){let R=[],U=new S0(A.fullCtx);for(let N of A){if(N.alt!==1)continue;let Y=N.semanticContext.evalPrecedence(this.parser,this.predictionState.outerContext);if(Y===null)continue;if(R[N.state.stateNumber]=N.context,Y!==N.semanticContext)U.add(y.duplicate(N,Y),this.mergeCache);else U.add(N,this.mergeCache)}for(let N of A){if(N.alt===1)continue;if(!N.precedenceFilterSuppressed){let Y=R[N.state.stateNumber]||null;if(Y!==null&&Y.equals(N.context))continue}U.add(N,this.mergeCache)}return U}getReachableTarget(A,R){if(A.matches(R,0,this.atn.maxTokenType))return A.target;else return null}getPredsForAmbigAlts(A,R,U){let N=[];for(let X of R)if(A.get(X.alt))N[X.alt]=u.orContext(N[X.alt]??null,X.semanticContext);let Y=0;for(let X=1;X<U+1;X++){let Q=N[X]??null;if(Q===null)N[X]=u.NONE;else if(Q!==u.NONE)Y+=1}if(Y===0)N=null;if(_.debug)console.log("getPredsForAmbigAlts result "+D1(N));return N}getPredicatePredictions(A,R){let U=[],N=!1;for(let Y=1;Y<R.length;Y++){let X=R[Y];if(A.get(Y))U.push({pred:X,alt:Y});if(X!==u.NONE)N=!0}if(!N)return null;return U}getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(A,R){let U=this.splitAccordingToSemanticValidity(A,R),N=U[0],Y=U[1],X=this.getAltThatFinishedDecisionEntryRule(N);if(X!==P.INVALID_ALT_NUMBER)return X;if(Y.length>0){if(X=this.getAltThatFinishedDecisionEntryRule(Y),X!==P.INVALID_ALT_NUMBER)return X}return P.INVALID_ALT_NUMBER}getAltThatFinishedDecisionEntryRule(A){let R=[];for(let U of A)if(U.reachesIntoOuterContext||U.state instanceof q0&&U.context.hasEmptyPath()){if(R.indexOf(U.alt)<0)R.push(U.alt)}if(R.length===0)return P.INVALID_ALT_NUMBER;else return Math.min(...R)}splitAccordingToSemanticValidity(A,R){let U=new S0(A.fullCtx),N=new S0(A.fullCtx);for(let Y of A)if(Y.semanticContext!==u.NONE)if(Y.semanticContext.evaluate(this.parser,R))U.add(Y);else N.add(Y);else U.add(Y);return[U,N]}evalSemanticContext(A,R,U){let N=new k0;for(let Y of A){if(Y.pred===u.NONE){if(N.set(Y.alt),!U)break;continue}let X=Y.pred.evaluate(this.parser,R);if(_.debug||_.dfaDebug)console.log("eval pred "+Y+"="+X);if(X){if(N.set(Y.alt),!U)break}}return N}closure(A,R,U,N,Y,X){this.closureCheckingStopState(A,R,U,N,Y,0,X)}closureCheckingStopState(A,R,U,N,Y,X,Q){if(_.traceATNSimulator||_.debugClosure)console.log("closure("+A.toString(this.parser,!0)+")");if(A.state instanceof q0){if(A.context&&!A.context.isEmpty()){for(let $=0;$<A.context.length;$++){if(A.context.getReturnState($)===p.EMPTY_RETURN_STATE){if(Y){R.add(y.createWithConfig(A.state,A,c.instance),this.mergeCache);continue}else{if(_.debug)console.log("FALLING off rule "+this.getRuleName(A.state.ruleIndex));this.closure_(A,R,U,N,Y,X,Q)}continue}let J=this.atn.states[A.context.getReturnState($)],I=A.context.getParent($),w=y.createWithContext(J,A.alt,I,A.semanticContext);w.reachesIntoOuterContext=A.reachesIntoOuterContext,this.closureCheckingStopState(w,R,U,N,Y,X-1,Q)}return}else if(Y){R.add(A,this.mergeCache);return}else if(_.debug)console.log("FALLING off rule "+this.getRuleName(A.state.ruleIndex))}this.closure_(A,R,U,N,Y,X,Q)}closure_(A,R,U,N,Y,X,Q){let $=A.state;if(!$.epsilonOnlyTransitions)R.add(A,this.mergeCache);for(let J=0;J<$.transitions.length;J++){if(J===0&&this.canDropLoopEntryEdgeInLeftRecursiveRule(A))continue;let I=$.transitions[J],w=N&&!(I instanceof E4),C=this.getEpsilonTarget(A,I,w,X===0,Y,Q);if(C){let V=X;if(A.state.constructor.stateType===j.RULE_STOP){if(this.predictionState.dfa&&this.predictionState?.dfa.isPrecedenceDfa){if(I.outermostPrecedenceReturn===this.predictionState?.dfa.atnStartState?.ruleIndex)C.precedenceFilterSuppressed=!0}if(C.reachesIntoOuterContext=!0,U.getOrAdd(C)!==C)continue;if(R.dipsIntoOuterContext=!0,V-=1,_.debug)console.log("dips into outer ctx: "+C)}else{if(!I.isEpsilon&&U.getOrAdd(C)!==C)continue;if(I instanceof s2){if(V>=0)V+=1}}this.closureCheckingStopState(C,R,U,w,Y,V,Q)}}}canDropLoopEntryEdgeInLeftRecursiveRule(A){let R=A.state;if(R.constructor.stateType!==j.STAR_LOOP_ENTRY||!A.context)return!1;if(!R.precedenceRuleDecision||A.context.isEmpty()||A.context.hasEmptyPath())return!1;let U=A.context.length;for(let Q=0;Q<U;Q++)if(this.atn.states[A.context.getReturnState(Q)].ruleIndex!==R.ruleIndex)return!1;let Y=R.transitions[0].target.endState.stateNumber,X=this.atn.states[Y];for(let Q=0;Q<U;Q++){let $=A.context.getReturnState(Q),J=this.atn.states[$];if(J.transitions.length!==1||!J.transitions[0].isEpsilon)return!1;let I=J.transitions[0].target;if(J.constructor.stateType===j.BLOCK_END&&I===R)continue;if(J===X)continue;if(I===X)continue;if(I.constructor.stateType===j.BLOCK_END&&I.transitions.length===1&&I.transitions[0].isEpsilon&&I.transitions[0].target===R)continue;return!1}return!0}getEpsilonTarget(A,R,U,N,Y,X){switch(R.transitionType){case O.RULE:return this.ruleTransition(A,R);case O.PRECEDENCE:return this.precedenceTransition(A,R,U,N,Y);case O.PREDICATE:return this.predTransition(A,R,U,N,Y);case O.ACTION:{if(_.debug){let Q=R,$=Q.actionIndex===-1?65535:Q.actionIndex;console.log("ACTION edge "+Q.ruleIndex+":"+$)}return y.createWithConfig(R.target,A)}case O.EPSILON:return y.createWithConfig(R.target,A);case O.ATOM:case O.RANGE:case O.SET:{if(X){if(R.matches(B.EOF,0,1))return y.createWithConfig(R.target,A)}return null}default:return null}}precedenceTransition(A,R,U,N,Y){if(_.debug){if(console.log("PRED (collectPredicates="+U+") "+R.precedence+">=_p, ctx dependent=true"),this.parser!==null)console.log("context surrounding pred is "+D1(this.parser.getRuleInvocationStack()))}let X=null;if(U&&N)if(Y&&this.predictionState?.input){let Q=this.predictionState.input.index;this.predictionState.input.seek(this.predictionState.startIndex);let $=R.getPredicate().evaluate(this.parser,this.predictionState.outerContext);if(this.predictionState.input.seek(Q),$)X=y.createWithConfig(R.target,A)}else{let Q=u.andContext(A.semanticContext,R.getPredicate());X=y.createWithSemanticContext(R.target,A,Q)}else X=y.createWithConfig(R.target,A);if(_.debug)console.log("config from pred transition="+X);return X}predTransition(A,R,U,N,Y){if(_.debug){if(console.log("PRED (collectPredicates="+U+") "+R.ruleIndex+":"+R.predIndex+", ctx dependent="+R.isCtxDependent),this.parser!==null)console.log("context surrounding pred is "+D1(this.parser.getRuleInvocationStack()))}let X=null;if(U&&(R.isCtxDependent&&N||!R.isCtxDependent))if(Y&&this.predictionState?.input){let Q=this.predictionState.input.index;this.predictionState.input.seek(this.predictionState.startIndex);let $=R.getPredicate().evaluate(this.parser,this.predictionState.outerContext);if(this.predictionState.input.seek(Q),$)X=y.createWithConfig(R.target,A)}else{let Q=u.andContext(A.semanticContext,R.getPredicate());X=y.createWithSemanticContext(R.target,A,Q)}else X=y.createWithConfig(R.target,A);if(_.debug)console.log("config from pred transition="+X);return X}ruleTransition(A,R){if(_.debug)console.log("CALL rule "+this.getRuleName(R.target.ruleIndex)+", ctx="+A.context);let U=R.followState,N=X1(A.context??void 0,U.stateNumber);return y.createWithConfig(R.target,A,N)}getConflictingAlts(A){let R=t.getConflictingAltSubsets(A);return t.getAlts(R)}getConflictingAltsOrUniqueAlt(A){let R;if(A.uniqueAlt!==P.INVALID_ALT_NUMBER)R=new k0,R.set(A.uniqueAlt);else R=A.conflictingAlts;return R}noViableAlt(A,R,U,N){return new Q1(this.parser,A,A.get(N),A.LT(1),U,R)}addDFAEdge(A,R,U,N){if(_.debug)console.log("EDGE "+R+" -> "+N+" upon "+this.getTokenName(U));if(N=this.addDFAState(A,N),U<-1||U>this.atn.maxTokenType)return N;if(_.debug)console.log(`DFA=
10
+ `+A.toString(this.parser!=null?this.parser.vocabulary:K0.EMPTY_VOCABULARY));return R.edges[U+1]=N,N}addDFAState(A,R){if(R===E0.ERROR)return R;let U=A.getState(R);if(U!==null)return U;if(!R.configs.readOnly)R.configs.optimizeConfigs(this),R.configs.setReadonly(!0);if(_.traceATNSimulator)console.log("addDFAState new "+R);return A.addState(R),R}reportAttemptingFullContext(A,R,U,N,Y){if(_.debug||_.retryDebug){let X=new v(N,Y+1);console.log("reportAttemptingFullContext decision="+A.decision+":"+U+", input="+this.parser.tokenStream.getTextFromInterval(X))}this.parser.errorListenerDispatch.reportAttemptingFullContext(this.parser,A,N,Y,R,U)}reportContextSensitivity(A,R,U,N,Y){if(_.debug||_.retryDebug){let X=new v(N,Y+1);console.log("reportContextSensitivity decision="+A.decision+":"+U+", input="+this.parser.tokenStream.getTextFromInterval(X))}this.parser.errorListenerDispatch.reportContextSensitivity(this.parser,A,N,Y,R,U)}reportAmbiguity(A,R,U,N,Y,X,Q){if(_.debug||_.retryDebug){let $=new v(U,N+1);console.log("reportAmbiguity "+X+":"+Q+", input="+this.parser.tokenStream.getTextFromInterval($))}this.parser.errorListenerDispatch.reportAmbiguity(this.parser,A,U,N,Y,X,Q)}},Z1=class{static{q(this,"PredictionContextCache")}cache=new m0(Y1.instance);add(_){if(_===c.instance)return _;let A=this.cache.get(_);if(A)return A;return this.cache.set(_,_),_}get(_){return this.cache.get(_)}get length(){return this.cache.size}},Y2=class extends n1{static{q(this,"ProfilingATNSimulator")}decisions;numDecisions=0;currentDecision=0;currentState;conflictingAltResolvedBySLL;sllStopIndex=0;llStopIndex=0;constructor(_){let A=_.interpreter.sharedContextCache;super(_,_.interpreter.atn,_.interpreter.decisionToDFA,A);if(A){this.numDecisions=this.atn.decisionToState.length,this.decisions=Array(this.numDecisions);for(let R=0;R<this.numDecisions;R++)this.decisions[R]=new a5(R)}}adaptivePredict(_,A,R){try{this.sllStopIndex=-1,this.llStopIndex=-1,this.currentDecision=A;let U=performance.now(),N=super.adaptivePredict(_,A,R),Y=performance.now();this.decisions[A].timeInPrediction+=Y-U,this.decisions[A].invocations++;let X=this.sllStopIndex-this.predictionState.startIndex+1;if(this.decisions[A].sllTotalLook+=X,this.decisions[A].sllMinLook=this.decisions[A].sllMinLook===0?X:Math.min(this.decisions[A].sllMinLook,X),X>this.decisions[A].sllMaxLook)this.decisions[A].sllMaxLook=X,this.decisions[A].sllMaxLookEvent={decision:A,configs:null,predictedAlt:N,input:_,startIndex:this.predictionState.startIndex,stopIndex:this.sllStopIndex,fullCtx:!1};if(this.llStopIndex>=0){let Q=this.llStopIndex-this.predictionState.startIndex+1;if(this.decisions[A].llTotalLook+=Q,this.decisions[A].llMinLook=this.decisions[A].llMinLook===0?Q:Math.min(this.decisions[A].llMinLook,Q),Q>this.decisions[A].llMaxLook)this.decisions[A].llMaxLook=Q,this.decisions[A].llMaxLookEvent={decision:A,configs:null,predictedAlt:N,input:_,startIndex:this.predictionState.startIndex,stopIndex:this.llStopIndex,fullCtx:!0}}return N}finally{this.currentDecision=-1}}getExistingTargetState(_,A){this.sllStopIndex=this.predictionState.input.index;let R=super.getExistingTargetState(_,A);if(R!==void 0){if(this.decisions[this.currentDecision].sllDFATransitions++,R===E0.ERROR)this.decisions[this.currentDecision].errors.push({decision:this.currentDecision,configs:_.configs,input:this.predictionState.input,startIndex:this.predictionState.startIndex,stopIndex:this.sllStopIndex,fullCtx:!1})}return this.currentState=R,R}computeTargetState(_,A,R){let U=super.computeTargetState(_,A,R);return this.currentState=U,U}computeReachSet(_,A,R){if(R&&this.predictionState?.input)this.llStopIndex=this.predictionState.input.index;let U=super.computeReachSet(_,A,R);if(this.predictionState?.input){if(R){if(this.decisions[this.currentDecision].llATNTransitions++,U===null)this.decisions[this.currentDecision].errors.push({decision:this.currentDecision,configs:_,input:this.predictionState.input,startIndex:this.predictionState.startIndex,stopIndex:this.sllStopIndex,fullCtx:!0})}else if(this.decisions[this.currentDecision].sllATNTransitions++,U===null)this.decisions[this.currentDecision].errors.push({decision:this.currentDecision,configs:_,input:this.predictionState.input,startIndex:this.predictionState.startIndex,stopIndex:this.sllStopIndex,fullCtx:!1})}return U}reportAttemptingFullContext(_,A,R,U,N){if(A!==null)this.conflictingAltResolvedBySLL=A.nextSetBit(0);else this.conflictingAltResolvedBySLL=R.getAlts().nextSetBit(0);if(this.decisions[this.currentDecision].llFallback++,A)super.reportAttemptingFullContext(_,A,R,U,N)}reportContextSensitivity(_,A,R,U,N){if(A!==this.conflictingAltResolvedBySLL&&this.predictionState.input)this.decisions[this.currentDecision].contextSensitivities.push({decision:this.currentDecision,configs:R,input:this.predictionState.input,startIndex:U,stopIndex:N,fullCtx:!0});super.reportContextSensitivity(_,A,R,U,N)}reportAmbiguity(_,A,R,U,N,Y,X){let Q;if(Y)Q=Y.nextSetBit(0);else Q=X.getAlts().nextSetBit(0);if(this.predictionState?.input){if(X.fullCtx&&Q!==this.conflictingAltResolvedBySLL)this.decisions[this.currentDecision].contextSensitivities.push({decision:this.currentDecision,configs:X,input:this.predictionState.input,startIndex:R,stopIndex:U,fullCtx:!0});this.decisions[this.currentDecision].ambiguities.push({ambigAlts:Y,decision:this.currentDecision,configs:X,input:this.predictionState.input,startIndex:R,stopIndex:U,fullCtx:X.fullCtx})}super.reportAmbiguity(_,A,R,U,N,Y,X)}getDecisionInfo(){return this.decisions}getCurrentState(){return this.currentState}},q4;((_)=>{_.toString=q((A)=>{return`(${A.pred}, ${A.alt})`},"toString")})(q4||(q4={}));var o2=class extends Error{static{q(this,"ParseCancellationException")}constructor(_){super();this.cause=_}},h8=class{static{q(this,"InterpreterDataReader")}static parseInterpreterData(_){let A=[],R=[],U=[],N=[],Y=[],X=_.split(`
11
+ `),Q=0,$=X[Q++];if($!=="token literal names:")throw Error("Unexpected data entry");do{if($=X[Q++],$.length===0)break;N.push($==="null"?null:$)}while(!0);if($=X[Q++],$!=="token symbolic names:")throw Error("Unexpected data entry");do{if($=X[Q++],$.length===0)break;Y.push($==="null"?null:$)}while(!0);if($=X[Q++],$!=="rule names:")throw Error("Unexpected data entry");do{if($=X[Q++],$.length===0)break;A.push($)}while(!0);if($=X[Q++],$==="channel names:"){do{if($=X[Q++],$.length===0)break;R.push($)}while(!0);if($=X[Q++],$!=="mode names:")throw Error("Unexpected data entry");do{if($=X[Q++],$.length===0)break;U.push($)}while(!0)}if($=X[Q++],$!=="atn:")throw Error("Unexpected data entry");$=X[Q++];let J=$.split(","),I,w=[];for(let V=0;V<J.length;++V){let m=J[V];if(m.startsWith("["))I=Number(m.substring(1).trim());else if(m.endsWith("]"))I=Number(m.substring(0,m.length-1).trim());else I=Number(m.trim());w[V]=I}return{atn:new n0().deserialize(w),vocabulary:new K0(N,Y,[]),ruleNames:A,channels:R.length>0?R:void 0,modes:U.length>0?U:void 0}}},j4=class{static{q(this,"AbstractParseTreeVisitor")}visit(_){return _.accept(this)}visitChildren(_){let A=this.defaultResult(),R=_.getChildCount();for(let U=0;U<R;U++){if(!this.shouldVisitNextChild(_,A))break;let N=_.getChild(U);if(N){let Y=N.accept(this);A=this.aggregateResult(A,Y)}}return A}visitTerminal(_){return this.defaultResult()}visitErrorNode(_){return this.defaultResult()}defaultResult(){return null}shouldVisitNextChild(_,A){return!0}aggregateResult(_,A){return A}},j8=class _{static{q(this,"ParseTreeWalker")}static DEFAULT=new _;walk(A,R){if(R instanceof a1)A.visitErrorNode(R);else if(R instanceof z0)A.visitTerminal(R);else{let N=R;this.enterRule(A,N);for(let Y=0;Y<R.getChildCount();Y++)this.walk(A,R.getChild(Y));this.exitRule(A,N)}}enterRule(A,R){let U=R.ruleContext;A.enterEveryRule(U),U.enterRule(A)}exitRule(A,R){let U=R.ruleContext;U.exitRule(A),A.exitEveryRule(U)}},H0;((_)=>{_.fromString=q((A)=>{return new e5(A)},"fromString")})(H0||(H0={}));var e5=class{static{q(this,"CharStreamImpl")}name="";index=0;data;constructor(_){let A=[];for(let R of _)A.push(R.codePointAt(0));this.data=new Uint32Array(A)}reset(){this.index=0}consume(){if(this.index>=this.data.length)throw Error("cannot consume EOF");this.index+=1}LA(_){if(_===0)return 0;if(_<0)_+=1;let A=this.index+_-1;if(A<0||A>=this.data.length)return B.EOF;return this.data[A]}mark(){return-1}release(_){}seek(_){if(_<=this.index){this.index=_;return}this.index=Math.min(_,this.data.length)}getTextFromRange(_,A){if(A=A??this.data.length-1,A>=this.data.length)A=this.data.length-1;if(_>=this.data.length)return"";return this.stringFromRange(_,A+1)}getTextFromInterval(_){let{start:A,stop:R}=_;if(R>=this.data.length)R=this.data.length-1;if(A>=this.data.length)return"";return this.stringFromRange(A,R+1)}toString(){return this.stringFromRange(0)}get size(){return this.data.length}getSourceName(){if(this.name)return this.name;return G2.UNKNOWN_SOURCE_NAME}stringFromRange(_,A){let R=this.data.slice(_,A),U="";return R.forEach((N)=>{U+=String.fromCodePoint(N)}),U}},f4=q((_)=>{return _.setText!==void 0},"isWritableToken"),_6=class{static{q(this,"BufferedTokenStream")}tokenSource;tokens=[];p=-1;fetchedEOF=!1;constructor(_){this.tokenSource=_}mark(){return 0}release(_){}reset(){this.seek(0)}seek(_){this.lazyInit(),this.p=this.adjustSeekIndex(_)}get size(){return this.tokens.length}get index(){return this.p}get(_){return this.lazyInit(),this.tokens[_]}consume(){let _=!1;if(this.p>=0)if(this.fetchedEOF)_=this.p<this.tokens.length-1;else _=this.p<this.tokens.length;else _=!1;if(!_&&this.LA(1)===B.EOF)throw Error("cannot consume EOF");if(this.sync(this.p+1))this.p=this.adjustSeekIndex(this.p+1)}sync(_){let A=_-this.tokens.length+1;if(A>0)return this.fetch(A)>=A;return!0}fetch(_){if(this.fetchedEOF)return 0;for(let A=0;A<_;A++){let R=this.tokenSource.nextToken();if(f4(R))R.tokenIndex=this.tokens.length;if(this.tokens.push(R),R.type===B.EOF)return this.fetchedEOF=!0,A+1}return _}getTokens(_,A,R){if(this.lazyInit(),_===void 0&&A===void 0)return this.tokens;if(_??=0,A===void 0)A=this.tokens.length-1;if(_<0||A>=this.tokens.length||A<0||_>=this.tokens.length)throw RangeError("start "+_+" or stop "+A+" not in 0.."+(this.tokens.length-1));if(_>A)return[];if(R===void 0)return this.tokens.slice(_,A+1);let U=[];if(A>=this.tokens.length)A=this.tokens.length-1;for(let N=_;N<A;N++){let Y=this.tokens[N];if(Y.type===B.EOF){U.push(Y);break}if(R.has(Y.type))U.push(Y)}return U}LA(_){return this.LT(_)?.type??B.INVALID_TYPE}LB(_){if(this.p-_<0)return null;return this.tokens[this.p-_]}LT(_){if(this.lazyInit(),_===0)return null;if(_<0)return this.LB(-_);let A=this.p+_-1;if(this.sync(A),A>=this.tokens.length)return this.tokens[this.tokens.length-1];return this.tokens[A]}adjustSeekIndex(_){return _}lazyInit(){if(this.p===-1)this.setup()}setup(){this.sync(0),this.p=this.adjustSeekIndex(0)}setTokenSource(_){this.tokenSource=_,this.tokens=[],this.p=-1,this.fetchedEOF=!1}nextTokenOnChannel(_,A){if(this.sync(_),_>=this.tokens.length)return-1;let R=this.tokens[_];while(R.channel!==A){if(R.type===B.EOF)return-1;_+=1,this.sync(_),R=this.tokens[_]}return _}previousTokenOnChannel(_,A){if(_>=this.tokens.length)return this.tokens.length-1;while(_>=0){let R=this.tokens[_];if(R.type===B.EOF||R.channel===A)return _;--_}return _}getHiddenTokensToRight(_,A){if(A===void 0)A=-1;if(this.lazyInit(),_<0||_>=this.tokens.length)throw Error(`${_} not in 0..${this.tokens.length-1}`);let R=this.nextTokenOnChannel(_+1,C0.DEFAULT_TOKEN_CHANNEL),U=_+1,N=R===-1?this.tokens.length-1:R;return this.filterForChannel(U,N,A)}getHiddenTokensToLeft(_,A){if(A===void 0)A=-1;if(this.lazyInit(),_<0||_>=this.tokens.length)throw Error(`${_} not in 0..${this.tokens.length-1}`);let R=this.previousTokenOnChannel(_-1,C0.DEFAULT_TOKEN_CHANNEL);if(R===_-1)return;let U=R+1,N=_-1;return this.filterForChannel(U,N,A)}filterForChannel(_,A,R){let U=[];for(let N=_;N<A+1;N++){let Y=this.tokens[N];if(R===-1){if(Y.channel!==C0.DEFAULT_TOKEN_CHANNEL)U.push(Y)}else if(Y.channel===R)U.push(Y)}if(U.length===0)return;return U}getSourceName(){return this.tokenSource.sourceName}getText(){return this.getTextFromInterval(v.of(0,this.size-1))}getTextFromInterval(_){let{start:A,stop:R}=_;if(A<0||R<0)return"";if(this.sync(R),R>=this.tokens.length)R=this.tokens.length-1;let U="";for(let N=A;N<=R;++N){let Y=this.tokens[N];if(Y.type===B.EOF)break;U+=Y.text}return U}getTextFromContext(_){return this.getTextFromInterval(_.getSourceInterval())}getTextFromRange(_,A){if(_!==null&&A!==null)return this.getTextFromInterval(v.of(_.tokenIndex,A.tokenIndex));return""}fill(){this.lazyInit();while(this.fetch(1000)===1000);}setLine(_){this.tokenSource.line=_}setColumn(_){this.tokenSource.column=_}},F2=class extends _6{static{q(this,"CommonTokenStream")}channel=B.DEFAULT_CHANNEL;constructor(_,A){super(_);this.channel=A??B.DEFAULT_CHANNEL}adjustSeekIndex(_){return this.nextTokenOnChannel(_,this.channel)}LB(_){if(_===0||this.index-_<0)return null;let A=this.index,R=1;while(R<=_)A=this.previousTokenOnChannel(A-1,this.channel),R+=1;if(A<0)return null;return this.tokens[A]}LT(_){if(this.lazyInit(),_===0)return null;if(_<0)return this.LB(-_);let A=this.index,R=1;while(R<_){if(this.sync(A+1))A=this.nextTokenOnChannel(A+1,this.channel);R+=1}return this.tokens[A]}getNumberOfOnChannelTokens(){let _=0;this.fill();for(let A of this.tokens){if(A.channel===this.channel)_+=1;if(A.type===B.EOF)break}return _}},I0=class _ extends C0{static{q(this,"XPathLexer")}static TOKEN_REF=1;static RULE_REF=2;static ANYWHERE=3;static ROOT=4;static WILDCARD=5;static BANG=6;static ID=7;static STRING=8;static channelNames=["DEFAULT_TOKEN_CHANNEL","HIDDEN"];static literalNames=[null,null,null,"'//'","'/'","'*'","'!'"];static symbolicNames=[null,"TOKEN_REF","RULE_REF","ANYWHERE","ROOT","WILDCARD","BANG","ID","STRING"];static modeNames=["DEFAULT_MODE"];static ruleNames=["ANYWHERE","ROOT","WILDCARD","BANG","ID","NameChar","NameStartChar","STRING"];constructor(A){super(A);this.interpreter=new k1(this,_._ATN,_.decisionsToDFA,new Z1)}get grammarFileName(){return"XPathLexer.g4"}get literalNames(){return _.literalNames}get symbolicNames(){return _.symbolicNames}get ruleNames(){return _.ruleNames}get serializedATN(){return _._serializedATN}get channelNames(){return _.channelNames}get modeNames(){return _.modeNames}action(A,R,U){switch(R){case 4:this.ID_action(A,U);break}}ID_action(A,R){switch(R){case 0:let U=this.text;if(U.charAt(0)===U.charAt(0).toUpperCase())this.type=_.TOKEN_REF;else this.type=_.RULE_REF;break}}static _serializedATN=[4,0,8,48,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,1,0,1,0,1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,4,1,4,5,4,29,8,4,10,4,12,4,32,9,4,1,4,1,4,1,5,1,5,1,6,1,6,1,7,1,7,5,7,42,8,7,10,7,12,7,45,9,7,1,7,1,7,1,43,0,8,1,3,3,4,5,5,7,6,9,7,11,0,13,0,15,8,1,0,2,784,0,0,8,14,27,48,57,65,90,95,95,97,122,127,159,170,170,173,173,181,181,186,186,192,214,216,246,248,705,710,721,736,740,748,748,750,750,768,884,886,887,890,893,895,895,902,902,904,906,908,908,910,929,931,1013,1015,1153,1155,1159,1162,1327,1329,1366,1369,1369,1376,1416,1425,1469,1471,1471,1473,1474,1476,1477,1479,1479,1488,1514,1519,1522,1536,1541,1552,1562,1564,1564,1568,1641,1646,1747,1749,1757,1759,1768,1770,1788,1791,1791,1807,1866,1869,1969,1984,2037,2042,2042,2045,2045,2048,2093,2112,2139,2144,2154,2160,2183,2185,2190,2192,2193,2200,2403,2406,2415,2417,2435,2437,2444,2447,2448,2451,2472,2474,2480,2482,2482,2486,2489,2492,2500,2503,2504,2507,2510,2519,2519,2524,2525,2527,2531,2534,2545,2556,2556,2558,2558,2561,2563,2565,2570,2575,2576,2579,2600,2602,2608,2610,2611,2613,2614,2616,2617,2620,2620,2622,2626,2631,2632,2635,2637,2641,2641,2649,2652,2654,2654,2662,2677,2689,2691,2693,2701,2703,2705,2707,2728,2730,2736,2738,2739,2741,2745,2748,2757,2759,2761,2763,2765,2768,2768,2784,2787,2790,2799,2809,2815,2817,2819,2821,2828,2831,2832,2835,2856,2858,2864,2866,2867,2869,2873,2876,2884,2887,2888,2891,2893,2901,2903,2908,2909,2911,2915,2918,2927,2929,2929,2946,2947,2949,2954,2958,2960,2962,2965,2969,2970,2972,2972,2974,2975,2979,2980,2984,2986,2990,3001,3006,3010,3014,3016,3018,3021,3024,3024,3031,3031,3046,3055,3072,3084,3086,3088,3090,3112,3114,3129,3132,3140,3142,3144,3146,3149,3157,3158,3160,3162,3165,3165,3168,3171,3174,3183,3200,3203,3205,3212,3214,3216,3218,3240,3242,3251,3253,3257,3260,3268,3270,3272,3274,3277,3285,3286,3293,3294,3296,3299,3302,3311,3313,3315,3328,3340,3342,3344,3346,3396,3398,3400,3402,3406,3412,3415,3423,3427,3430,3439,3450,3455,3457,3459,3461,3478,3482,3505,3507,3515,3517,3517,3520,3526,3530,3530,3535,3540,3542,3542,3544,3551,3558,3567,3570,3571,3585,3642,3648,3662,3664,3673,3713,3714,3716,3716,3718,3722,3724,3747,3749,3749,3751,3773,3776,3780,3782,3782,3784,3790,3792,3801,3804,3807,3840,3840,3864,3865,3872,3881,3893,3893,3895,3895,3897,3897,3902,3911,3913,3948,3953,3972,3974,3991,3993,4028,4038,4038,4096,4169,4176,4253,4256,4293,4295,4295,4301,4301,4304,4346,4348,4680,4682,4685,4688,4694,4696,4696,4698,4701,4704,4744,4746,4749,4752,4784,4786,4789,4792,4798,4800,4800,4802,4805,4808,4822,4824,4880,4882,4885,4888,4954,4957,4959,4992,5007,5024,5109,5112,5117,5121,5740,5743,5759,5761,5786,5792,5866,5870,5880,5888,5909,5919,5940,5952,5971,5984,5996,5998,6000,6002,6003,6016,6099,6103,6103,6108,6109,6112,6121,6155,6169,6176,6264,6272,6314,6320,6389,6400,6430,6432,6443,6448,6459,6470,6509,6512,6516,6528,6571,6576,6601,6608,6617,6656,6683,6688,6750,6752,6780,6783,6793,6800,6809,6823,6823,6832,6845,6847,6862,6912,6988,6992,7001,7019,7027,7040,7155,7168,7223,7232,7241,7245,7293,7296,7304,7312,7354,7357,7359,7376,7378,7380,7418,7424,7957,7960,7965,7968,8005,8008,8013,8016,8023,8025,8025,8027,8027,8029,8029,8031,8061,8064,8116,8118,8124,8126,8126,8130,8132,8134,8140,8144,8147,8150,8155,8160,8172,8178,8180,8182,8188,8203,8207,8234,8238,8255,8256,8276,8276,8288,8292,8294,8303,8305,8305,8319,8319,8336,8348,8400,8412,8417,8417,8421,8432,8450,8450,8455,8455,8458,8467,8469,8469,8473,8477,8484,8484,8486,8486,8488,8488,8490,8493,8495,8505,8508,8511,8517,8521,8526,8526,8544,8584,11264,11492,11499,11507,11520,11557,11559,11559,11565,11565,11568,11623,11631,11631,11647,11670,11680,11686,11688,11694,11696,11702,11704,11710,11712,11718,11720,11726,11728,11734,11736,11742,11744,11775,11823,11823,12293,12295,12321,12335,12337,12341,12344,12348,12353,12438,12441,12442,12445,12447,12449,12538,12540,12543,12549,12591,12593,12686,12704,12735,12784,12799,13312,19903,19968,42124,42192,42237,42240,42508,42512,42539,42560,42607,42612,42621,42623,42737,42775,42783,42786,42888,42891,42954,42960,42961,42963,42963,42965,42969,42994,43047,43052,43052,43072,43123,43136,43205,43216,43225,43232,43255,43259,43259,43261,43309,43312,43347,43360,43388,43392,43456,43471,43481,43488,43518,43520,43574,43584,43597,43600,43609,43616,43638,43642,43714,43739,43741,43744,43759,43762,43766,43777,43782,43785,43790,43793,43798,43808,43814,43816,43822,43824,43866,43868,43881,43888,44010,44012,44013,44016,44025,44032,55203,55216,55238,55243,55291,63744,64109,64112,64217,64256,64262,64275,64279,64285,64296,64298,64310,64312,64316,64318,64318,64320,64321,64323,64324,64326,64433,64467,64829,64848,64911,64914,64967,65008,65019,65024,65039,65056,65071,65075,65076,65101,65103,65136,65140,65142,65276,65279,65279,65296,65305,65313,65338,65343,65343,65345,65370,65382,65470,65474,65479,65482,65487,65490,65495,65498,65500,65529,65531,65536,65547,65549,65574,65576,65594,65596,65597,65599,65613,65616,65629,65664,65786,65856,65908,66045,66045,66176,66204,66208,66256,66272,66272,66304,66335,66349,66378,66384,66426,66432,66461,66464,66499,66504,66511,66513,66517,66560,66717,66720,66729,66736,66771,66776,66811,66816,66855,66864,66915,66928,66938,66940,66954,66956,66962,66964,66965,66967,66977,66979,66993,66995,67001,67003,67004,67072,67382,67392,67413,67424,67431,67456,67461,67463,67504,67506,67514,67584,67589,67592,67592,67594,67637,67639,67640,67644,67644,67647,67669,67680,67702,67712,67742,67808,67826,67828,67829,67840,67861,67872,67897,67968,68023,68030,68031,68096,68099,68101,68102,68108,68115,68117,68119,68121,68149,68152,68154,68159,68159,68192,68220,68224,68252,68288,68295,68297,68326,68352,68405,68416,68437,68448,68466,68480,68497,68608,68680,68736,68786,68800,68850,68864,68903,68912,68921,69248,69289,69291,69292,69296,69297,69373,69404,69415,69415,69424,69456,69488,69509,69552,69572,69600,69622,69632,69702,69734,69749,69759,69818,69821,69821,69826,69826,69837,69837,69840,69864,69872,69881,69888,69940,69942,69951,69956,69959,69968,70003,70006,70006,70016,70084,70089,70092,70094,70106,70108,70108,70144,70161,70163,70199,70206,70209,70272,70278,70280,70280,70282,70285,70287,70301,70303,70312,70320,70378,70384,70393,70400,70403,70405,70412,70415,70416,70419,70440,70442,70448,70450,70451,70453,70457,70459,70468,70471,70472,70475,70477,70480,70480,70487,70487,70493,70499,70502,70508,70512,70516,70656,70730,70736,70745,70750,70753,70784,70853,70855,70855,70864,70873,71040,71093,71096,71104,71128,71133,71168,71232,71236,71236,71248,71257,71296,71352,71360,71369,71424,71450,71453,71467,71472,71481,71488,71494,71680,71738,71840,71913,71935,71942,71945,71945,71948,71955,71957,71958,71960,71989,71991,71992,71995,72003,72016,72025,72096,72103,72106,72151,72154,72161,72163,72164,72192,72254,72263,72263,72272,72345,72349,72349,72368,72440,72704,72712,72714,72758,72760,72768,72784,72793,72818,72847,72850,72871,72873,72886,72960,72966,72968,72969,72971,73014,73018,73018,73020,73021,73023,73031,73040,73049,73056,73061,73063,73064,73066,73102,73104,73105,73107,73112,73120,73129,73440,73462,73472,73488,73490,73530,73534,73538,73552,73561,73648,73648,73728,74649,74752,74862,74880,75075,77712,77808,77824,78933,82944,83526,92160,92728,92736,92766,92768,92777,92784,92862,92864,92873,92880,92909,92912,92916,92928,92982,92992,92995,93008,93017,93027,93047,93053,93071,93760,93823,93952,94026,94031,94087,94095,94111,94176,94177,94179,94180,94192,94193,94208,100343,100352,101589,101632,101640,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,113664,113770,113776,113788,113792,113800,113808,113817,113821,113822,113824,113827,118528,118573,118576,118598,119141,119145,119149,119170,119173,119179,119210,119213,119362,119364,119808,119892,119894,119964,119966,119967,119970,119970,119973,119974,119977,119980,119982,119993,119995,119995,119997,120003,120005,120069,120071,120074,120077,120084,120086,120092,120094,120121,120123,120126,120128,120132,120134,120134,120138,120144,120146,120485,120488,120512,120514,120538,120540,120570,120572,120596,120598,120628,120630,120654,120656,120686,120688,120712,120714,120744,120746,120770,120772,120779,120782,120831,121344,121398,121403,121452,121461,121461,121476,121476,121499,121503,121505,121519,122624,122654,122661,122666,122880,122886,122888,122904,122907,122913,122915,122916,122918,122922,122928,122989,123023,123023,123136,123180,123184,123197,123200,123209,123214,123214,123536,123566,123584,123641,124112,124153,124896,124902,124904,124907,124909,124910,124912,124926,124928,125124,125136,125142,125184,125259,125264,125273,126464,126467,126469,126495,126497,126498,126500,126500,126503,126503,126505,126514,126516,126519,126521,126521,126523,126523,126530,126530,126535,126535,126537,126537,126539,126539,126541,126543,126545,126546,126548,126548,126551,126551,126553,126553,126555,126555,126557,126557,126559,126559,126561,126562,126564,126564,126567,126570,126572,126578,126580,126583,126585,126588,126590,126590,126592,126601,126603,126619,126625,126627,126629,126633,126635,126651,130032,130041,131072,173791,173824,177977,177984,178205,178208,183969,183984,191456,194560,195101,196608,201546,201552,205743,917505,917505,917536,917631,917760,917999,662,0,65,90,97,122,170,170,181,181,186,186,192,214,216,246,248,705,710,721,736,740,748,748,750,750,880,884,886,887,890,893,895,895,902,902,904,906,908,908,910,929,931,1013,1015,1153,1162,1327,1329,1366,1369,1369,1376,1416,1488,1514,1519,1522,1568,1610,1646,1647,1649,1747,1749,1749,1765,1766,1774,1775,1786,1788,1791,1791,1808,1808,1810,1839,1869,1957,1969,1969,1994,2026,2036,2037,2042,2042,2048,2069,2074,2074,2084,2084,2088,2088,2112,2136,2144,2154,2160,2183,2185,2190,2208,2249,2308,2361,2365,2365,2384,2384,2392,2401,2417,2432,2437,2444,2447,2448,2451,2472,2474,2480,2482,2482,2486,2489,2493,2493,2510,2510,2524,2525,2527,2529,2544,2545,2556,2556,2565,2570,2575,2576,2579,2600,2602,2608,2610,2611,2613,2614,2616,2617,2649,2652,2654,2654,2674,2676,2693,2701,2703,2705,2707,2728,2730,2736,2738,2739,2741,2745,2749,2749,2768,2768,2784,2785,2809,2809,2821,2828,2831,2832,2835,2856,2858,2864,2866,2867,2869,2873,2877,2877,2908,2909,2911,2913,2929,2929,2947,2947,2949,2954,2958,2960,2962,2965,2969,2970,2972,2972,2974,2975,2979,2980,2984,2986,2990,3001,3024,3024,3077,3084,3086,3088,3090,3112,3114,3129,3133,3133,3160,3162,3165,3165,3168,3169,3200,3200,3205,3212,3214,3216,3218,3240,3242,3251,3253,3257,3261,3261,3293,3294,3296,3297,3313,3314,3332,3340,3342,3344,3346,3386,3389,3389,3406,3406,3412,3414,3423,3425,3450,3455,3461,3478,3482,3505,3507,3515,3517,3517,3520,3526,3585,3632,3634,3635,3648,3654,3713,3714,3716,3716,3718,3722,3724,3747,3749,3749,3751,3760,3762,3763,3773,3773,3776,3780,3782,3782,3804,3807,3840,3840,3904,3911,3913,3948,3976,3980,4096,4138,4159,4159,4176,4181,4186,4189,4193,4193,4197,4198,4206,4208,4213,4225,4238,4238,4256,4293,4295,4295,4301,4301,4304,4346,4348,4680,4682,4685,4688,4694,4696,4696,4698,4701,4704,4744,4746,4749,4752,4784,4786,4789,4792,4798,4800,4800,4802,4805,4808,4822,4824,4880,4882,4885,4888,4954,4992,5007,5024,5109,5112,5117,5121,5740,5743,5759,5761,5786,5792,5866,5870,5880,5888,5905,5919,5937,5952,5969,5984,5996,5998,6000,6016,6067,6103,6103,6108,6108,6176,6264,6272,6276,6279,6312,6314,6314,6320,6389,6400,6430,6480,6509,6512,6516,6528,6571,6576,6601,6656,6678,6688,6740,6823,6823,6917,6963,6981,6988,7043,7072,7086,7087,7098,7141,7168,7203,7245,7247,7258,7293,7296,7304,7312,7354,7357,7359,7401,7404,7406,7411,7413,7414,7418,7418,7424,7615,7680,7957,7960,7965,7968,8005,8008,8013,8016,8023,8025,8025,8027,8027,8029,8029,8031,8061,8064,8116,8118,8124,8126,8126,8130,8132,8134,8140,8144,8147,8150,8155,8160,8172,8178,8180,8182,8188,8305,8305,8319,8319,8336,8348,8450,8450,8455,8455,8458,8467,8469,8469,8473,8477,8484,8484,8486,8486,8488,8488,8490,8493,8495,8505,8508,8511,8517,8521,8526,8526,8544,8584,11264,11492,11499,11502,11506,11507,11520,11557,11559,11559,11565,11565,11568,11623,11631,11631,11648,11670,11680,11686,11688,11694,11696,11702,11704,11710,11712,11718,11720,11726,11728,11734,11736,11742,11823,11823,12293,12295,12321,12329,12337,12341,12344,12348,12353,12438,12445,12447,12449,12538,12540,12543,12549,12591,12593,12686,12704,12735,12784,12799,13312,19903,19968,42124,42192,42237,42240,42508,42512,42527,42538,42539,42560,42606,42623,42653,42656,42735,42775,42783,42786,42888,42891,42954,42960,42961,42963,42963,42965,42969,42994,43009,43011,43013,43015,43018,43020,43042,43072,43123,43138,43187,43250,43255,43259,43259,43261,43262,43274,43301,43312,43334,43360,43388,43396,43442,43471,43471,43488,43492,43494,43503,43514,43518,43520,43560,43584,43586,43588,43595,43616,43638,43642,43642,43646,43695,43697,43697,43701,43702,43705,43709,43712,43712,43714,43714,43739,43741,43744,43754,43762,43764,43777,43782,43785,43790,43793,43798,43808,43814,43816,43822,43824,43866,43868,43881,43888,44002,44032,55203,55216,55238,55243,55291,63744,64109,64112,64217,64256,64262,64275,64279,64285,64285,64287,64296,64298,64310,64312,64316,64318,64318,64320,64321,64323,64324,64326,64433,64467,64829,64848,64911,64914,64967,65008,65019,65136,65140,65142,65276,65313,65338,65345,65370,65382,65470,65474,65479,65482,65487,65490,65495,65498,65500,65536,65547,65549,65574,65576,65594,65596,65597,65599,65613,65616,65629,65664,65786,65856,65908,66176,66204,66208,66256,66304,66335,66349,66378,66384,66421,66432,66461,66464,66499,66504,66511,66513,66517,66560,66717,66736,66771,66776,66811,66816,66855,66864,66915,66928,66938,66940,66954,66956,66962,66964,66965,66967,66977,66979,66993,66995,67001,67003,67004,67072,67382,67392,67413,67424,67431,67456,67461,67463,67504,67506,67514,67584,67589,67592,67592,67594,67637,67639,67640,67644,67644,67647,67669,67680,67702,67712,67742,67808,67826,67828,67829,67840,67861,67872,67897,67968,68023,68030,68031,68096,68096,68112,68115,68117,68119,68121,68149,68192,68220,68224,68252,68288,68295,68297,68324,68352,68405,68416,68437,68448,68466,68480,68497,68608,68680,68736,68786,68800,68850,68864,68899,69248,69289,69296,69297,69376,69404,69415,69415,69424,69445,69488,69505,69552,69572,69600,69622,69635,69687,69745,69746,69749,69749,69763,69807,69840,69864,69891,69926,69956,69956,69959,69959,69968,70002,70006,70006,70019,70066,70081,70084,70106,70106,70108,70108,70144,70161,70163,70187,70207,70208,70272,70278,70280,70280,70282,70285,70287,70301,70303,70312,70320,70366,70405,70412,70415,70416,70419,70440,70442,70448,70450,70451,70453,70457,70461,70461,70480,70480,70493,70497,70656,70708,70727,70730,70751,70753,70784,70831,70852,70853,70855,70855,71040,71086,71128,71131,71168,71215,71236,71236,71296,71338,71352,71352,71424,71450,71488,71494,71680,71723,71840,71903,71935,71942,71945,71945,71948,71955,71957,71958,71960,71983,71999,71999,72001,72001,72096,72103,72106,72144,72161,72161,72163,72163,72192,72192,72203,72242,72250,72250,72272,72272,72284,72329,72349,72349,72368,72440,72704,72712,72714,72750,72768,72768,72818,72847,72960,72966,72968,72969,72971,73008,73030,73030,73056,73061,73063,73064,73066,73097,73112,73112,73440,73458,73474,73474,73476,73488,73490,73523,73648,73648,73728,74649,74752,74862,74880,75075,77712,77808,77824,78895,78913,78918,82944,83526,92160,92728,92736,92766,92784,92862,92880,92909,92928,92975,92992,92995,93027,93047,93053,93071,93760,93823,93952,94026,94032,94032,94099,94111,94176,94177,94179,94179,94208,100343,100352,101589,101632,101640,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,113664,113770,113776,113788,113792,113800,113808,113817,119808,119892,119894,119964,119966,119967,119970,119970,119973,119974,119977,119980,119982,119993,119995,119995,119997,120003,120005,120069,120071,120074,120077,120084,120086,120092,120094,120121,120123,120126,120128,120132,120134,120134,120138,120144,120146,120485,120488,120512,120514,120538,120540,120570,120572,120596,120598,120628,120630,120654,120656,120686,120688,120712,120714,120744,120746,120770,120772,120779,122624,122654,122661,122666,122928,122989,123136,123180,123191,123197,123214,123214,123536,123565,123584,123627,124112,124139,124896,124902,124904,124907,124909,124910,124912,124926,124928,125124,125184,125251,125259,125259,126464,126467,126469,126495,126497,126498,126500,126500,126503,126503,126505,126514,126516,126519,126521,126521,126523,126523,126530,126530,126535,126535,126537,126537,126539,126539,126541,126543,126545,126546,126548,126548,126551,126551,126553,126553,126555,126555,126557,126557,126559,126559,126561,126562,126564,126564,126567,126570,126572,126578,126580,126583,126585,126588,126590,126590,126592,126601,126603,126619,126625,126627,126629,126633,126635,126651,131072,173791,173824,177977,177984,178205,178208,183969,183984,191456,194560,195101,196608,201546,201552,205743,47,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,15,1,0,0,0,1,17,1,0,0,0,3,20,1,0,0,0,5,22,1,0,0,0,7,24,1,0,0,0,9,26,1,0,0,0,11,35,1,0,0,0,13,37,1,0,0,0,15,39,1,0,0,0,17,18,5,47,0,0,18,19,5,47,0,0,19,2,1,0,0,0,20,21,5,47,0,0,21,4,1,0,0,0,22,23,5,42,0,0,23,6,1,0,0,0,24,25,5,33,0,0,25,8,1,0,0,0,26,30,3,13,6,0,27,29,3,11,5,0,28,27,1,0,0,0,29,32,1,0,0,0,30,28,1,0,0,0,30,31,1,0,0,0,31,33,1,0,0,0,32,30,1,0,0,0,33,34,6,4,0,0,34,10,1,0,0,0,35,36,7,0,0,0,36,12,1,0,0,0,37,38,7,1,0,0,38,14,1,0,0,0,39,43,5,39,0,0,40,42,9,0,0,0,41,40,1,0,0,0,42,45,1,0,0,0,43,44,1,0,0,0,43,41,1,0,0,0,44,46,1,0,0,0,45,43,1,0,0,0,46,47,5,39,0,0,47,16,1,0,0,0,3,0,30,43,1,1,4,0];static __ATN;static get _ATN(){if(!_.__ATN)_.__ATN=new n0().deserialize(_._serializedATN);return _.__ATN}static vocabulary=new K0(_.literalNames,_.symbolicNames,[]);get vocabulary(){return _.vocabulary}static decisionsToDFA=_._ATN.decisionToState.map((A,R)=>{return new x0(A,R)})},A6=class extends H2{static{q(this,"XPathLexerErrorListener")}syntaxError(_,A,R,U,N,Y){}},C1=class{static{q(this,"XPathElement")}invert;nodeName;constructor(_){this.nodeName=_,this.invert=!1}toString(){return"XPathElement["+(this.invert?"!":"")+this.nodeName+"]"}},R6=class extends C1{static{q(this,"XPathRuleAnywhereElement")}ruleIndex;constructor(_,A){super(_);this.ruleIndex=A}evaluate(_){return a0.findAllRuleNodes(_,this.ruleIndex)}toString(){return"XPathRuleAnywhereElement["+(this.invert?"!":"")+this.nodeName+"]"}},U6=class extends C1{static{q(this,"XPathRuleElement")}ruleIndex;constructor(_,A){super(_);this.ruleIndex=A}evaluate(_){let A=[];for(let R of a0.getChildren(_))if(R instanceof h){if(R.ruleIndex===this.ruleIndex&&!this.invert||R.ruleIndex!==this.ruleIndex&&this.invert)A.push(R)}return A}toString(){return"XPathRuleElement["+(this.invert?"!":"")+this.nodeName+"]"}},N6=class extends C1{static{q(this,"XPathTokenAnywhereElement")}tokenType;constructor(_,A){super(_);this.tokenType=A}evaluate(_){return a0.findAllTokenNodes(_,this.tokenType)}toString(){return"XPathTokenAnywhereElement["+(this.invert?"!":"")+this.nodeName+"]"}},Y6=class extends C1{static{q(this,"XPathTokenElement")}tokenType;constructor(_,A){super(_);this.tokenType=A}evaluate(_){let A=[];for(let R of a0.getChildren(_))if(R instanceof z0&&R.symbol){if(R.symbol.type===this.tokenType&&!this.invert||R.symbol.type!==this.tokenType&&this.invert)A.push(R)}return A}toString(){return"XPathTokenElement["+(this.invert?"!":"")+this.nodeName+"]"}},X6=class extends C1{static{q(this,"XPathWildcardAnywhereElement")}constructor(){super(e2.WILDCARD)}evaluate(_){if(this.invert)return[];return a0.descendants(_)}toString(){return"XPathWildcardAnywhereElement["+(this.invert?"!":"")+this.nodeName+"]"}},G6=class extends C1{static{q(this,"XPathWildcardElement")}constructor(){super(e2.WILDCARD)}evaluate(_){let A=[];if(this.invert)return A;for(let R of a0.getChildren(_))A.push(R);return A}toString(){return"XPathWildcardElement["+(this.invert?"!":"")+this.nodeName+"]"}},e2=class _{static{q(this,"XPath")}static WILDCARD="*";static NOT="!";path;elements;parser;constructor(A,R){this.parser=A,this.path=R,this.elements=this.split(R)}static findAll(A,R,U){return new _(U,R).evaluate(A)}split(A){let R=new I0(H0.fromString(A));R.recover=($)=>{throw $},R.removeErrorListeners(),R.addErrorListener(new A6);let U=new F2(R);try{U.fill()}catch($){if($ instanceof Z2){let I="Invalid tokens or characters at index "+R.column+" in path '"+A+"' -- "+$.message;throw RangeError(I)}throw $}let N=U.getTokens(),Y=[],X=N.length,Q=0;_:while(Q<X){let $=N[Q],J;switch($.type){case I0.ROOT:case I0.ANYWHERE:let I=$.type===I0.ANYWHERE;Q++,J=N[Q];let w=J.type===I0.BANG;if(w)Q++,J=N[Q];let C=this.getXPathElement(J,I);C.invert=w,Y.push(C),Q++;break;case I0.TOKEN_REF:case I0.RULE_REF:case I0.WILDCARD:Y.push(this.getXPathElement($,!1)),++Q;break;case B.EOF:break _;default:throw Error("Unknown path element "+$)}}return Y}evaluate(A){let R=new h(null);R.addChild(A);let U=new Set([R]),N=0;while(N<this.elements.length){let Y=new Set;for(let X of U)if(X.getChildCount()>0)this.elements[N].evaluate(X).forEach(($)=>{Y.add($)},Y);N++,U=Y}return U}getXPathElement(A,R){if(A.type===B.EOF)throw Error("Missing path element at end of path");let U=A.text;if(U==null)throw Error("Expected wordToken to have text content.");let N=this.parser.getTokenType(U),Y=this.parser.getRuleIndex(U);switch(A.type){case I0.WILDCARD:return R?new X6:new G6;case I0.TOKEN_REF:case I0.STRING:if(N===B.INVALID_TYPE)throw Error(U+" at index "+A.start+" isn't a valid token name");return R?new N6(U,N):new Y6(U,N);default:if(Y===-1)throw Error(U+" at index "+A.start+" isn't a valid rule name");return R?new R6(U,Y):new U6(U,Y)}}},V4=class{static{q(this,"Chunk")}},Q6=class{static{q(this,"ParseTreeMatch")}tree;pattern;labels;mismatchedNode;constructor(_,A,R,U){this.tree=_,this.pattern=A,this.labels=R,this.mismatchedNode=U}get(_){let A=this.labels.get(_);if(!A||A.length===0)return null;return A[A.length-1]}getAll(_){return this.labels.get(_)??[]}getLabels(){return this.labels}getMismatchedNode(){return this.mismatchedNode}succeeded(){return!this.mismatchedNode}getPattern(){return this.pattern}getTree(){return this.tree}toString(){return`Match ${this.succeeded()?"succeeded":"failed"}; found ${this.getLabels().size} labels`}},Z6=class{static{q(this,"ParseTreePattern")}patternRuleIndex;pattern;patternTree;matcher;constructor(_,A,R,U){this.matcher=_,this.patternRuleIndex=R,this.pattern=A,this.patternTree=U}match(_){return this.matcher.match(_,this)}matches(_){return this.matcher.match(_,this).succeeded()}findAll(_,A){let R=e2.findAll(_,A,this.matcher.getParser()),U=[];for(let N of R){let Y=this.match(N);if(Y.succeeded())U.push(Y)}return U}getMatcher(){return this.matcher}getPattern(){return this.pattern}getPatternRuleIndex(){return this.patternRuleIndex}getPatternTree(){return this.patternTree}},c1=class extends f{static{q(this,"InputMismatchException")}constructor(_){super({message:"",recognizer:_,input:_.inputStream,ctx:_.context});this.offendingToken=_.getCurrentToken()}},s1=class extends f{static{q(this,"FailedPredicateException")}ruleIndex=0;predicateIndex=0;predicate;constructor(_,A,R=null){super({message:$6(A??"no predicate",R??null),recognizer:_,input:_.inputStream,ctx:_.context});let N=_.atn.states[_.state].transitions[0];if(N instanceof C4)this.ruleIndex=N.ruleIndex,this.predicateIndex=N.predIndex;else this.ruleIndex=0,this.predicateIndex=0;this.predicate=A,this.offendingToken=_.getCurrentToken()}},$6=q((_,A)=>{if(A!==null)return A;return"failed predicate: {"+_+"}?"},"formatMessage"),P4=class{static{q(this,"DefaultErrorStrategy")}errorRecoveryMode=!1;lastErrorIndex=-1;lastErrorStates=new W0;nextTokensContext=null;nextTokenState=0;reset(_){this.endErrorCondition(_)}beginErrorCondition(_){this.errorRecoveryMode=!0}inErrorRecoveryMode(_){return this.errorRecoveryMode}endErrorCondition(_){this.errorRecoveryMode=!1,this.lastErrorStates=new W0,this.lastErrorIndex=-1}reportMatch(_){this.endErrorCondition(_)}reportError(_,A){if(this.inErrorRecoveryMode(_))return;if(this.beginErrorCondition(_),A instanceof Q1)this.reportNoViableAlternative(_,A);else if(A instanceof c1)this.reportInputMismatch(_,A);else if(A instanceof s1)this.reportFailedPredicate(_,A);else _.notifyErrorListeners(A.message,A.offendingToken,A)}recover(_,A){if(this.lastErrorIndex===_.inputStream?.index&&this.lastErrorStates.contains(_.state))_.consume();this.lastErrorIndex=_.inputStream?.index??0,this.lastErrorStates.addOne(_.state);let R=this.getErrorRecoverySet(_);this.consumeUntil(_,R)}sync(_){if(this.inErrorRecoveryMode(_))return;let A=_.atn.states[_.state],R=_.tokenStream.LA(1),U=_.atn.nextTokens(A);if(U.contains(R)){this.nextTokensContext=null,this.nextTokenState=j.INVALID_STATE_NUMBER;return}if(U.contains(B.EPSILON)){if(this.nextTokensContext===null)this.nextTokensContext=_.context,this.nextTokenState=_.state;return}switch(A.constructor.stateType){case j.BLOCK_START:case j.STAR_BLOCK_START:case j.PLUS_BLOCK_START:case j.STAR_LOOP_ENTRY:{if(this.singleTokenDeletion(_)!==null)return;throw new c1(_)}case j.PLUS_LOOP_BACK:case j.STAR_LOOP_BACK:{this.reportUnwantedToken(_);let N=new W0;N.addSet(_.getExpectedTokens());let Y=N.addSet(this.getErrorRecoverySet(_));this.consumeUntil(_,Y);break}default:}}reportNoViableAlternative(_,A){if(A.message.length>0){_.notifyErrorListeners(A.message,A.offendingToken,A);return}let R=_.tokenStream,U;if(R!==null&&A.startToken)if(A.startToken.type===B.EOF)U="<EOF>";else U=R.getTextFromRange(A.startToken,A.offendingToken);else U="<unknown input>";let N="no viable alternative at input "+this.escapeWSAndQuote(U);_.notifyErrorListeners(N,A.offendingToken,A)}reportInputMismatch(_,A){if(A.message.length>0){_.notifyErrorListeners(A.message,A.offendingToken,A);return}let R="mismatched input "+this.getTokenErrorDisplay(A.offendingToken)+" expecting "+A.getExpectedTokens().toStringWithVocabulary(_.vocabulary);_.notifyErrorListeners(R,A.offendingToken,A)}reportFailedPredicate(_,A){let U="rule "+_.ruleNames[_.context.ruleIndex]+" "+A.message;_.notifyErrorListeners(U,A.offendingToken,A)}reportUnwantedToken(_){if(this.inErrorRecoveryMode(_))return;this.beginErrorCondition(_);let A=_.getCurrentToken(),R=this.getTokenErrorDisplay(A),U=this.getExpectedTokens(_),N="extraneous input "+R+" expecting "+U.toStringWithVocabulary(_.vocabulary);_.notifyErrorListeners(N,A,null)}reportMissingToken(_){if(this.inErrorRecoveryMode(_))return;this.beginErrorCondition(_);let A=_.getCurrentToken(),U="missing "+this.getExpectedTokens(_).toStringWithVocabulary(_.vocabulary)+" at "+this.getTokenErrorDisplay(A);_.notifyErrorListeners(U,A,null)}recoverInline(_){let A=this.singleTokenDeletion(_);if(A)return _.consume(),A;if(this.singleTokenInsertion(_))return this.getMissingSymbol(_);throw new c1(_)}singleTokenInsertion(_){let A=_.tokenStream?.LA(1)??-1,R=_.atn,N=R.states[_.state].transitions[0].target;if(R.nextTokens(N,_.context??void 0).contains(A))return this.reportMissingToken(_),!0;return!1}singleTokenDeletion(_){let A=_.tokenStream?.LA(2)??-1;if(this.getExpectedTokens(_).contains(A)){this.reportUnwantedToken(_),_.consume();let U=_.getCurrentToken();return this.reportMatch(_),U}return null}getMissingSymbol(_){let A=_.getCurrentToken(),R=this.getExpectedTokens(_),U=B.INVALID_TYPE;if(R.length!==0)U=R.minElement;let N;if(U===B.EOF)N="<missing EOF>";else N="<missing "+_.vocabulary.getDisplayName(U)+">";let Y=A,X=_.tokenStream?.LT(-1);if(Y.type===B.EOF&&X!==null)Y=X;return _.getTokenFactory().create(Y.source,U,N,B.DEFAULT_CHANNEL,-1,-1,Y.line,Y.column)}getExpectedTokens(_){return _.getExpectedTokens()}getTokenErrorDisplay(_){if(_===null)return"<no token>";let A=_.text;if(!A)if(_.type===B.EOF)A="<EOF>";else A="<"+_.type+">";return this.escapeWSAndQuote(A)}escapeWSAndQuote(_){return _=_.replace(/\n/g,"\\n"),_=_.replace(/\r/g,"\\r"),_=_.replace(/\t/g,"\\t"),"'"+_+"'"}getErrorRecoverySet(_){let{atn:A,context:R}=_,U=new W0;while(R!==null&&R.invokingState>=0){let Y=A.states[R.invokingState].transitions[0],X=A.nextTokens(Y.followState);U.addSet(X),R=R.parent}return U.removeOne(B.EPSILON),U}consumeUntil(_,A){let R=_.tokenStream?.LA(1)??-1;while(R!==B.EOF&&!A.contains(R))_.consume(),R=_.tokenStream?.LA(1)??-1}},H6=class extends P4{static{q(this,"BailErrorStrategy")}recover(_,A){throw new o2(A)}recoverInline(_){let A=new c1(_);throw new o2(A)}sync(_){}},F6=class{static{q(this,"ListTokenSource")}sourceName;tokenFactory=M4.DEFAULT;tokens=[];i=0;eofToken=null;constructor(_,A){this.tokens=_,this.sourceName=A??""}get column(){if(this.i<this.tokens.length)return this.tokens[this.i].column;if(this.eofToken!==null)return this.eofToken.column;if(this.tokens.length>0){let _=this.tokens[this.tokens.length-1],A=_.text;if(A){let R=A.lastIndexOf(`
12
+ `);if(R>=0)return A.length-R-1}return _.column+_.stop-_.start+1}return 0}nextToken(){if(this.i>=this.tokens.length){if(this.eofToken===null){let A=-1;if(this.tokens.length>0){let U=this.tokens[this.tokens.length-1].stop;if(U!==-1)A=U+1}let R=Math.max(-1,A-1);this.eofToken=this.tokenFactory.create([this,this.inputStream],B.EOF,"EOF",B.DEFAULT_CHANNEL,A,R,this.line,this.column)}return this.eofToken}let _=this.tokens[this.i];if(this.i===this.tokens.length-1&&_.type===B.EOF)this.eofToken=_;return this.i++,_}get line(){if(this.i<this.tokens.length)return this.tokens[this.i].line;if(this.eofToken!==null)return this.eofToken.line;if(this.tokens.length>0){let _=this.tokens[this.tokens.length-1],A=_.line,R=_.text;if(R){for(let U of R)if(U===`
13
+ `)A++}return A}return 1}get inputStream(){if(this.i<this.tokens.length)return this.tokens[this.i].inputStream;if(this.eofToken!==null)return this.eofToken.inputStream;if(this.tokens.length>0)return this.tokens[this.tokens.length-1].inputStream;return null}getSourceName(){if(this.sourceName!==null)return this.sourceName;let _=this.inputStream;if(_!==null)return _.getSourceName();return"List"}},J6=class extends h{static{q(this,"InterpreterRuleContext")}#_;constructor(_,A,R){super(A,R);this.#_=_}get ruleIndex(){return this.#_}},I6=class{static{q(this,"TraceListener")}parser;constructor(_){this.parser=_}enterEveryRule(_){console.log("enter "+this.parser.ruleNames[_.ruleIndex]+", LT(1)="+this.parser.inputStream?.LT(1)?.text)}visitTerminal(_){console.log("consume "+_.getSymbol()+" rule "+this.parser.ruleNames[this.parser.context.ruleIndex])}exitEveryRule(_){console.log("exit "+this.parser.ruleNames[_.ruleIndex]+", LT(1)="+this.parser.inputStream?.LT(1)?.text)}visitErrorNode(_){}},_3=class extends O4{static{q(this,"Parser")}printer=null;buildParseTrees=!0;errorHandler=new P4;context=null;precedenceStack=[];parseListeners=null;syntaxErrors=0;matchedEOF=!1;tracer=null;bypassAltsAtnCache=null;#_;constructor(_){super();this.precedenceStack.push(0),this.syntaxErrors=0,this.#_=_}reset(_=!0){if(_)this.inputStream.seek(0);if(this.errorHandler.reset(this),this.context=null,this.syntaxErrors=0,this.matchedEOF=!1,this.setTrace(!1),this.precedenceStack=[],this.precedenceStack.push(0),this.interpreter)this.interpreter.reset()}match(_){let A=this.getCurrentToken();if(A.type===_){if(_===B.EOF)this.matchedEOF=!0;this.errorHandler.reportMatch(this),this.consume()}else if(A=this.errorHandler.recoverInline(this),this.buildParseTrees&&A.tokenIndex===-1)this.context.addErrorNode(this.createErrorNode(this.context,A));return A}matchWildcard(){let _=this.getCurrentToken();if(_.type>0)this.errorHandler.reportMatch(this),this.consume();else if(_=this.errorHandler.recoverInline(this),this.buildParseTrees&&_.tokenIndex===-1)this.context.addErrorNode(this.createErrorNode(this.context,_));return _}getParseListeners(){return this.parseListeners??[]}addParseListener(_){if(_===null)throw Error("listener");if(this.parseListeners===null)this.parseListeners=[];this.parseListeners.push(_)}removeParseListener(_){if(this.parseListeners!==null&&_!==null){let A=this.parseListeners.indexOf(_);if(A>=0)this.parseListeners.splice(A,1);if(this.parseListeners.length===0)this.parseListeners=null}}removeParseListeners(){this.parseListeners=null}triggerEnterRuleEvent(){if(this.parseListeners!==null){let _=this.context;this.parseListeners.forEach((A)=>{A.enterEveryRule(_),_.enterRule(A)})}}triggerExitRuleEvent(){if(this.parseListeners!==null){let _=this.context;this.parseListeners.slice(0).reverse().forEach((A)=>{_.exitRule(A),A.exitEveryRule(_)})}}getTokenFactory(){return this.inputStream.tokenSource.tokenFactory}setTokenFactory(_){this.inputStream.tokenSource.tokenFactory=_}compileParseTreePattern(_,A,R){if(!R){if(this.tokenStream!==null){let N=this.tokenStream.tokenSource;if(N instanceof C0)R=N}}if(!R)throw Error("Parser can't discover a lexer to use");return new K6(R,this).compile(_,A)}getATNWithBypassAlts(){let _=this.serializedATN;if(_===null)throw Error("The current parser does not support an ATN with bypass alternatives.");if(this.bypassAltsAtnCache!==null)return this.bypassAltsAtnCache;let A={readOnly:!1,verifyATN:!0,generateRuleBypassTransitions:!0};return this.bypassAltsAtnCache=new n0(A).deserialize(_),this.bypassAltsAtnCache}get numberOfSyntaxErrors(){return this.syntaxErrors}get inputStream(){return this.#_}set inputStream(_){this.tokenStream=_}get tokenStream(){return this.#_}set tokenStream(_){this.reset(!1),this.#_=_}getCurrentToken(){return this.inputStream.LT(1)}notifyErrorListeners(_,A,R){if(A=A??null,R=R??null,A===null)A=this.getCurrentToken();this.syntaxErrors+=1;let{line:U,column:N}=A;this.errorListenerDispatch.syntaxError(this,A,U,N,_,R)}consume(){let _=this.getCurrentToken();if(_.type!==B.EOF)this.tokenStream.consume();let A=this.parseListeners!==null&&this.parseListeners.length>0;if(this.buildParseTrees||A){let R;if(this.errorHandler.inErrorRecoveryMode(this))R=this.context.addErrorNode(this.createErrorNode(this.context,_));else R=this.context.addTokenNode(_);if(A)this.parseListeners.forEach((U)=>{if(R instanceof a1)U.visitErrorNode(R);else U.visitTerminal(R)})}return _}addContextToParseTree(){if(this.context?.parent)this.context.parent.addChild(this.context)}enterRule(_,A,R){if(this.state=A,this.context=_,this.context.start=this.inputStream.LT(1),this.buildParseTrees)this.addContextToParseTree();this.triggerEnterRuleEvent()}exitRule(){if(this.matchedEOF)this.context.stop=this.inputStream.LT(1);else this.context.stop=this.inputStream.LT(-1);this.triggerExitRuleEvent(),this.state=this.context.invokingState,this.context=this.context.parent}enterOuterAlt(_,A){if(_.setAltNumber(A),this.buildParseTrees&&this.context!==_){if(this.context?.parent)this.context.parent.removeLastChild(),this.context.parent.addChild(_)}this.context=_}getPrecedence(){if(this.precedenceStack.length===0)return-1;return this.precedenceStack[this.precedenceStack.length-1]}enterRecursionRule(_,A,R,U){this.state=A,this.precedenceStack.push(U),this.context=_,this.context.start=this.inputStream.LT(1),this.triggerEnterRuleEvent()}pushNewRecursionContext(_,A,R){let U=this.context;if(U.parent=_,U.invokingState=A,U.stop=this.inputStream.LT(-1),this.context=_,this.context.start=U.start,this.buildParseTrees)this.context.addChild(U);this.triggerEnterRuleEvent()}unrollRecursionContexts(_){this.precedenceStack.pop(),this.context.stop=this.inputStream.LT(-1);let A=this.context,R=this.getParseListeners();if(R!==null&&R.length>0)while(this.context!==_)this.triggerExitRuleEvent(),this.context=this.context.parent;else this.context=_;if(A.parent=_,this.buildParseTrees&&_!==null)_.addChild(A)}getInvokingContext(_){let A=this.context;while(A!==null){if(A.ruleIndex===_)return A;A=A.parent}return null}precpred(_,A){return A>=this.precedenceStack[this.precedenceStack.length-1]}isExpectedToken(_){let A=this.interpreter.atn,R=this.context,U=A.states[this.state],N=A.nextTokens(U);if(N.contains(_))return!0;if(!N.contains(B.EPSILON))return!1;while(R!==null&&R.invokingState>=0&&N.contains(B.EPSILON)){let X=A.states[R.invokingState].transitions[0];if(N=A.nextTokens(X.followState),N.contains(_))return!0;R=R.parent}if(N.contains(B.EPSILON)&&_===B.EOF)return!0;else return!1}getExpectedTokens(){return this.interpreter.atn.getExpectedTokens(this.state,this.context)}getExpectedTokensWithinCurrentRule(){let _=this.interpreter.atn,A=_.states[this.state];return _.nextTokens(A)}getRuleIndex(_){return this.getRuleIndexMap().get(_)??-1}getRuleInvocationStack(_){if(_=_??null,_===null)_=this.context;let A=[];while(_!==null){let R=_.ruleIndex;if(R<0)A.push("n/a");else A.push(this.ruleNames[R]);_=_.parent}return A}getDFAStrings(){return this.interpreter.decisionToDFA.toString()}dumpDFA(){let _=!1;for(let A of this.interpreter.decisionToDFA)if(A.length>0){if(_)console.log();if(this.printer)this.printer.println("Decision "+A.decision+":"),this.printer.print(A.toString(this.vocabulary));_=!0}}getSourceName(){return this.inputStream.getSourceName()}getParseInfo(){let _=this.interpreter;if(_ instanceof Y2)return new t5(_);return}setProfile(_){let A=this.interpreter,R=A.predictionMode;if(_){if(!(A instanceof Y2))this.interpreter=new Y2(this)}else if(A instanceof Y2){let U=A.sharedContextCache;if(U){let N=new n1(this,this.atn,A.decisionToDFA,U);this.interpreter=N}}this.interpreter.predictionMode=R}setTrace(_){if(!_)this.removeParseListener(this.tracer),this.tracer=null;else{if(this.tracer!==null)this.removeParseListener(this.tracer);this.tracer=new I6(this),this.addParseListener(this.tracer)}}createTerminalNode(_,A){return new z0(A)}createErrorNode(_,A){return new a1(A)}},q6=class extends _3{static{q(this,"ParserInterpreter")}rootContext;overrideDecisionRoot=null;parentContextStack=[];overrideDecisionAlt=-1;overrideDecisionReached=!1;decisionToDFA;sharedContextCache=new Z1;pushRecursionContextStates;#_=-1;#A=-1;#U;#R;#N;#Y;constructor(_,A,R,U,N){super(N);this.#U=_,this.#R=U,this.#N=R.slice(0),this.#Y=A,this.pushRecursionContextStates=new k0;for(let Y of U.states)if(Y instanceof c0&&Y.precedenceRuleDecision)this.pushRecursionContextStates.set(Y.stateNumber);this.decisionToDFA=U.decisionToState.map((Y,X)=>{return new x0(Y,X)}),this.interpreter=new n1(this,U,this.decisionToDFA,this.sharedContextCache)}reset(){super.reset(),this.overrideDecisionReached=!1,this.overrideDecisionRoot=null}get atn(){return this.#R}get vocabulary(){return this.#Y}get ruleNames(){return this.#N}get grammarFileName(){return this.#U}get atnState(){return this.#R.states[this.state]}parse(_){let A=this.#R.ruleToStartState[_];if(this.rootContext=this.createInterpreterRuleContext(null,j.INVALID_STATE_NUMBER,_),A.isLeftRecursiveRule)this.enterRecursionRule(this.rootContext,A.stateNumber,_,0);else this.enterRule(this.rootContext,A.stateNumber,_);while(!0){let R=this.atnState;switch(R.constructor.stateType){case j.RULE_STOP:{if(this.context?.isEmpty())if(A.isLeftRecursiveRule){let U=this.context,N=this.parentContextStack.pop();return this.unrollRecursionContexts(N[0]),U}else return this.exitRule(),this.rootContext;this.visitRuleStopState(R);break}default:{try{this.visitState(R)}catch(U){if(U instanceof f)this.state=this.#R.ruleToStopState[R.ruleIndex].stateNumber,this.errorHandler.reportError(this,U),this.recover(U);else throw U}break}}}}addDecisionOverride(_,A,R){this.#_=_,this.#A=A,this.overrideDecisionAlt=R}get overrideDecision(){return this.#_}get overrideDecisionInputIndex(){return this.#A}enterRecursionRule(_,A,R,U){this.parentContextStack.push([this.context,_.invokingState]),super.enterRecursionRule(_,A,R,U)}get serializedATN(){throw Error("The ParserInterpreter does not support the serializedATN property.")}visitState(_){let A=1;if(_ instanceof G1)A=this.visitDecisionState(_);let R=_.transitions[A-1];switch(R.transitionType){case O.EPSILON:if(this.pushRecursionContextStates.get(_.stateNumber)&&R.target.constructor.stateType!==j.LOOP_END){let $=this.parentContextStack[this.parentContextStack.length-1],J=this.createInterpreterRuleContext($[0],$[1],this.context.ruleIndex);this.pushNewRecursionContext(J,this.#R.ruleToStartState[_.ruleIndex].stateNumber,this.context.ruleIndex)}break;case O.ATOM:this.match(R.label.minElement);break;case O.RANGE:case O.SET:case O.NOT_SET:if(!R.matches(this.inputStream.LA(1),B.MIN_USER_TOKEN_TYPE,65535))this.recoverInline();this.matchWildcard();break;case O.WILDCARD:this.matchWildcard();break;case O.RULE:let U=R.target,N=U.ruleIndex,Y=this.createInterpreterRuleContext(this.context,_.stateNumber,N);if(U.isLeftRecursiveRule)this.enterRecursionRule(Y,U.stateNumber,N,R.precedence);else this.enterRule(Y,R.target.stateNumber,N);break;case O.PREDICATE:let X=R;if(!this.sempred(this.context,X.ruleIndex,X.predIndex))throw new s1(this);break;case O.ACTION:let Q=R;this.action(this.context,Q.ruleIndex,Q.actionIndex);break;case O.PRECEDENCE:if(!this.precpred(this.context,R.precedence)){let $=R.precedence;throw new s1(this,`precpred(_ctx, ${$})`)}break;default:throw Error("UnsupportedOperationException: Unrecognized ATN transition type.")}this.state=R.target.stateNumber}visitDecisionState(_){let A=1;if(_.transitions.length>1){this.errorHandler.sync(this);let R=_.decision;if(R===this.#_&&this.inputStream.index===this.#A&&!this.overrideDecisionReached)A=this.overrideDecisionAlt,this.overrideDecisionReached=!0;else A=this.interpreter.adaptivePredict(this.inputStream,R,this.context)}return A}createInterpreterRuleContext(_,A,R){return new J6(R,_,A)}visitRuleStopState(_){if(this.#R.ruleToStartState[_.ruleIndex].isLeftRecursiveRule){let[U,N]=this.parentContextStack.pop();this.unrollRecursionContexts(U),this.state=N}else this.exitRule();let R=this.#R.states[this.state].transitions[0];this.state=R.followState.stateNumber}recover(_){let A=this.inputStream.index;if(this.errorHandler.recover(this,_),this.inputStream.index===A){let R=_.offendingToken;if(!R)throw Error("Expected exception to have an offending token");let U=R.tokenSource,N=U?.inputStream??null,Y=[U,N];if(_ instanceof c1){let X=_.getExpectedTokens();if(!X)throw Error("Expected the exception to provide expected tokens");let Q=B.INVALID_TYPE;if(X.length!==0)Q=X.minElement;let $=this.getTokenFactory().create(Y,Q,R.text,B.DEFAULT_CHANNEL,-1,-1,R.line,R.column);this.context.addErrorNode(this.createErrorNode(this.context,$))}else{let X=this.getTokenFactory().create(Y,B.INVALID_TYPE,R.text,B.DEFAULT_CHANNEL,-1,-1,R.line,R.column);this.context.addErrorNode(this.createErrorNode(this.context,X))}}}recoverInline(){return this.errorHandler.recoverInline(this)}},W4=class extends Map{static{q(this,"MultiMap")}map(_,A){let R=this.get(_);if(!R)R=[],this.set(_,R);R.push(A)}getPairs(){let _=[];for(let A of this.keys()){let R=this.get(A)??[];for(let U of R)_.push([A,U])}return _}toString(){let _=[];return this.forEach((A,R)=>{_.push(`${R}=[${A.join(", ")}]`)}),`{${_.join(", ")}}`}},W6=class extends Error{static{q(this,"CannotInvokeStartRuleError")}constructor(_){super();this.cause=_}},z4=class{static{q(this,"RuleTagToken")}label;ruleName;bypassTokenType;constructor(_,A,R){this.ruleName=_,this.bypassTokenType=A,this.label=R}get channel(){return B.DEFAULT_CHANNEL}get text(){if(this.label!==void 0)return"<"+this.label+":"+this.ruleName+">";return"<"+this.ruleName+">"}get type(){return this.bypassTokenType}get line(){return 0}get column(){return-1}get tokenIndex(){return-1}get start(){return-1}get stop(){return-1}get tokenSource(){return null}get inputStream(){return null}toString(){return this.ruleName+":"+this.bypassTokenType}},z6=class extends Error{static{q(this,"StartRuleDoesNotConsumeFullPatternError")}},K4=class extends V4{static{q(this,"TagChunk")}tag;label;constructor(..._){let A,R;if(_.length===1)R=_[0];else A=_[0],R=_[1];super();if(!R)throw Error("tag cannot be null or empty");this.label=A,this.tag=R}toString(){if(this.label!==void 0)return this.label+":"+this.tag;return this.tag}},L1=class extends V4{static{q(this,"TextChunk")}text;constructor(_){super();this.text=_}toString(){return"'"+this.text+"'"}},L4=class extends Q2{static{q(this,"TokenTagToken")}tokenName;label;constructor(_,A,R){super({type:A,source:Q2.EMPTY_SOURCE});this.tokenName=_,this.label=R}get text(){if(this.label!==void 0)return"<"+this.label+":"+this.tokenName+">";return"<"+this.tokenName+">"}toString(){return this.tokenName+":"+this.type}},K6=class{static{q(this,"ParseTreePatternMatcher")}start="<";stop=">";escape="\\";lexer;parser;constructor(_,A){this.lexer=_,this.parser=A}setDelimiters(_,A,R){if(_===null||_.length===0)throw Error("start cannot be null or empty");if(A===null||A.length===0)throw Error("stop cannot be null or empty");this.start=_,this.stop=A,this.escape=R}matches(..._){switch(_.length){case 2:{let[A,R]=_,U=new W4;return this.matchImpl(A,R.getPatternTree(),U)===null}case 3:{let[A,R,U]=_,N=this.compile(R,U);return this.matches(A,N)}default:throw Error("Invalid number of arguments")}}match(..._){switch(_.length){case 2:{let[A,R]=_,U=new W4,N=this.matchImpl(A,R.getPatternTree(),U);return new Q6(A,R,U,N)}case 3:{let[A,R,U]=_,N=this.compile(R,U);return this.match(A,N)}default:throw Error("Invalid number of arguments")}}compile(_,A){let R=this.tokenize(_),U=new F6(R),N=new F2(U),Y=new q6(this.parser.grammarFileName,this.parser.vocabulary,this.parser.ruleNames,this.parser.getATNWithBypassAlts(),N);Y.removeErrorListeners();let X=null;try{Y.errorHandler=new H6,X=Y.parse(A)}catch(Q){if(Q instanceof o2)throw Q.cause;else if(Q instanceof f)throw Q;else if(Q instanceof Error)throw new W6(Q);else throw Q}if(N.LA(1)!==B.EOF)throw new z6;return new Z6(this,_,A,X)}getLexer(){return this.lexer}getParser(){return this.parser}tokenize(_){let A=this.split(_),R=[];for(let U of A)if(U instanceof K4){let N=U,Y=N.tag[0];if(Y===Y.toUpperCase()){let X=this.parser.getTokenType(N.tag);if(X===B.INVALID_TYPE)throw Error("Unknown token "+N.tag+" in pattern: "+_);let Q=new L4(N.tag,X,N.label);R.push(Q)}else if(Y===Y.toLowerCase()){let X=this.parser.getRuleIndex(N.tag);if(X===-1)throw Error("Unknown rule "+N.tag+" in pattern: "+_);let Q=this.parser.getATNWithBypassAlts().ruleToTokenType[X];R.push(new z4(N.tag,Q,N.label))}else throw Error("invalid tag: "+N.tag+" in pattern: "+_)}else{let N=U,Y=H0.fromString(N.text);this.lexer.inputStream=Y;let X=this.lexer.nextToken();while(X.type!==B.EOF)R.push(X),X=this.lexer.nextToken()}return R}split(_){let A=0,R=_.length,U=[],N=[],Y=[];while(A<R)if(A===_.indexOf(this.escape+this.start,A))A+=this.escape.length+this.start.length;else if(A===_.indexOf(this.escape+this.stop,A))A+=this.escape.length+this.stop.length;else if(A===_.indexOf(this.start,A))N.push(A),A+=this.start.length;else if(A===_.indexOf(this.stop,A))Y.push(A),A+=this.stop.length;else A++;if(N.length>Y.length)throw Error("unterminated tag in pattern: "+_);if(N.length<Y.length)throw Error("missing start tag in pattern: "+_);let X=N.length;for(let Q=0;Q<X;Q++)if(N[Q]>=Y[Q])throw Error("tag delimiters out of order in pattern: "+_);if(X===0){let Q=_.substring(0,R);U.push(new L1(Q))}if(X>0&&N[0]>0){let Q=_.substring(0,N[0]);U.push(new L1(Q))}for(let Q=0;Q<X;Q++){let $=_.substring(N[Q]+this.start.length,Y[Q]),J=$,I,w=$.indexOf(":");if(w>=0)I=$.substring(0,w),J=$.substring(w+1,$.length);if(U.push(new K4(I,J)),Q+1<X){let C=_.substring(Y[Q]+this.stop.length,N[Q+1]);U.push(new L1(C))}}if(X>0){let Q=Y[X-1]+this.stop.length;if(Q<R){let $=_.substring(Q,R);U.push(new L1($))}}for(let Q=0;Q<U.length;Q++){let $=U[Q];if($ instanceof L1){let J=$,I=J.text.replaceAll(this.escape,"");if(I.length<J.text.length)U[Q]=new L1(I)}}return U}matchImpl(_,A,R){if(_ instanceof z0&&A instanceof z0){let U=_,N=A,Y;if(U.getSymbol().type===N.getSymbol().type){if(N.getSymbol()instanceof L4){let X=N.getSymbol();if(R.map(X.tokenName,_),X.label!==void 0)R.map(X.label,_)}else if(U.getText()===N.getText());else if(!Y)Y=U}else if(!Y)Y=U;return Y}if(_ instanceof h&&A instanceof h){let U,N=this.getRuleTagToken(A);if(N){if(_.ruleIndex===A.ruleIndex){if(R.map(N.ruleName,_),N.label)R.map(N.label,_)}else if(!U)U=_;return U}if(_.getChildCount()!==A.getChildCount()){if(!U)U=_;return U}let Y=_.getChildCount();for(let X=0;X<Y;X++){let Q=this.matchImpl(_.getChild(X),A.getChild(X),R);if(Q)return Q}return U}return _}getRuleTagToken(_){if(_ instanceof h){if(_.getChildCount()===1&&_.getChild(0)instanceof z0){let A=_.getChild(0);if(A.getSymbol()instanceof z4)return A.getSymbol()}}return}},f8=class extends H2{static{q(this,"DiagnosticErrorListener")}exactOnly;constructor(_){super();this.exactOnly=_??!0}reportAmbiguity=q((_,A,R,U,N,Y,X)=>{if(this.exactOnly&&!N)return;let Q=this.getDecisionDescription(_,A),$=this.getConflictingAlts(Y,X),J=_.tokenStream?.getTextFromInterval(v.of(R,U)),I=`reportAmbiguity d=${Q}: ambigAlts=${$}, input='${J}'`;_.notifyErrorListeners(I,null,null)},"reportAmbiguity");reportAttemptingFullContext=q((_,A,R,U,N,Y)=>{let X=this.getDecisionDescription(_,A),Q=_.tokenStream?.getTextFromInterval(v.of(R,U)),$=`reportAttemptingFullContext d=${X}, input='${Q}'`;_.notifyErrorListeners($,null,null)},"reportAttemptingFullContext");reportContextSensitivity=q((_,A,R,U,N,Y)=>{let X=this.getDecisionDescription(_,A),Q=_.tokenStream?.getTextFromInterval(v.of(R,U)),$=`reportContextSensitivity d=${X}, input='${Q}'`;_.notifyErrorListeners($,null,null)},"reportContextSensitivity");getDecisionDescription=q((_,A)=>{let R=A.decision,U=A.atnStartState.ruleIndex,N=_.ruleNames;if(U<0||U>=N.length)return R.toString();let Y=N[U];if(Y.length===0)return R.toString();return`${R} (${Y})`},"getDecisionDescription");getConflictingAlts=q((_,A)=>{if(_)return _;let R=new k0;for(let U=0;U<A.configs.length;U++)R.set(A.configs[U].alt);return R},"getConflictingAlts")},V8=class extends C0{static{q(this,"LexerInterpreter")}decisionToDFA;sharedContextCache=new Z1;#_;#A;#U;#R;#N;#Y;constructor(_,A,R,U,N,Y,X){super(X);if(Y.grammarType!==P.LEXER)throw Error("IllegalArgumentException: The ATN must be a lexer ATN.");this.#_=_,this.#A=Y,this.#U=R.slice(0),this.#R=U.slice(0),this.#N=N.slice(0),this.#Y=A,this.decisionToDFA=Y.decisionToState.map((Q,$)=>{return new x0(Q,$)}),this.interpreter=new k1(this,Y,this.decisionToDFA,this.sharedContextCache)}get atn(){return this.#A}get grammarFileName(){return this.#_}get ruleNames(){return this.#U}get channelNames(){return this.#R}get modeNames(){return this.#N}get vocabulary(){return this.#Y}get serializedATN(){throw Error("The LexerInterpreter does not support the serializedATN property.")}},P8=class _{static{q(this,"RuntimeMetaData")}static VERSION="4.13.1";static getRuntimeVersion(){return _.VERSION}static checkVersion(A,R){let U=_.VERSION,N=!1,Y=!1;if(N=U!==A&&_.getMajorMinorVersion(U)!==_.getMajorMinorVersion(A),Y=U!==R&&_.getMajorMinorVersion(U)!==_.getMajorMinorVersion(R),N)console.error(`ANTLR Tool version ${A} used for code generation does not match the current runtime version ${U}`);if(Y)console.error(`ANTLR Runtime version ${R} used for parser compilation does not match the current runtime version ${U}`)}static getMajorMinorVersion(A){let R=A.indexOf("."),U=R>=0?A.indexOf(".",R+1):-1,N=A.indexOf("-"),Y=A.length;if(U>=0)Y=Math.min(Y,U);if(N>=0)Y=Math.min(Y,N);return A.substring(0,Y)}},b8=class _{static{q(this,"TokenStreamRewriter")}static DEFAULT_PROGRAM_NAME="default";static PROGRAM_INIT_SIZE=100;static MIN_TOKEN_INDEX=0;tokens;programs=new Map;lastRewriteTokenIndexes;constructor(A){this.tokens=A}getTokenStream(){return this.tokens}insertAfter(A,R,U=_.DEFAULT_PROGRAM_NAME){let N;if(typeof A==="number")N=A;else N=A.tokenIndex;let Y=this.getProgram(U),X=new B4(this.tokens,N,Y.length,R);Y.push(X)}insertBefore(A,R,U=_.DEFAULT_PROGRAM_NAME){let N;if(typeof A==="number")N=A;else N=A.tokenIndex;let Y=this.getProgram(U),X=new B1(this.tokens,N,Y.length,R);Y.push(X)}replaceSingle(A,R,U=_.DEFAULT_PROGRAM_NAME){this.replace(A,A,R,U)}replace(A,R,U,N=_.DEFAULT_PROGRAM_NAME){if(typeof A!=="number")A=A.tokenIndex;if(typeof R!=="number")R=R.tokenIndex;if(A>R||A<0||R<0||R>=this.tokens.size)throw RangeError(`replace: range invalid: ${A}..${R}(size=${this.tokens.size})`);let Y=this.getProgram(N),X=new X2(this.tokens,A,R,Y.length,U);Y.push(X)}delete(A,R,U=_.DEFAULT_PROGRAM_NAME){if(R==null)R=A;this.replace(A,R,null,U)}getProgram(A){let R=this.programs.get(A);if(R==null)R=this.initializeProgram(A);return R}initializeProgram(A){let R=[];return this.programs.set(A,R),R}getText(A,R=_.DEFAULT_PROGRAM_NAME){let U;if(A instanceof v)U=A;else U=new v(0,this.tokens.size-1);if(typeof A==="string")R=A;let N=this.programs.get(R),Y=U.start,X=U.stop;if(X>this.tokens.size-1)X=this.tokens.size-1;if(Y<0)Y=0;if(N==null||N.length===0)return this.tokens.getTextFromInterval(new v(Y,X));let Q=[],$=this.reduceToSingleOperationPerIndex(N),J=Y;while(J<=X&&J<this.tokens.size){let I=$.get(J);$.delete(J);let w=this.tokens.get(J);if(I==null){if(w.type!==B.EOF)Q.push(String(w.text));J++}else J=I.execute(Q)}if(X===this.tokens.size-1){for(let I of $.values())if(I&&I.index>=this.tokens.size-1)Q.push(String(I.text))}return Q.join("")}reduceToSingleOperationPerIndex(A){for(let U=0;U<A.length;U++){let N=A[U];if(N==null)continue;if(!(N instanceof X2))continue;let Y=N,X=this.getKindOfOps(A,B1,U);for(let $ of X)if($.index===Y.index)A[$.instructionIndex]=null,Y.text=String($.text)+(Y.text!=null?Y.text.toString():"");else if($.index>Y.index&&$.index<=Y.lastIndex)A[$.instructionIndex]=null;let Q=this.getKindOfOps(A,X2,U);for(let $ of Q){if($.index>=Y.index&&$.lastIndex<=Y.lastIndex){A[$.instructionIndex]=null;continue}let J=$.lastIndex<Y.index||$.index>Y.lastIndex;if($.text==null&&Y.text==null&&!J)A[$.instructionIndex]=null,Y.index=Math.min($.index,Y.index),Y.lastIndex=Math.max($.lastIndex,Y.lastIndex);else if(!J)throw Error(`replace op boundaries of ${Y} overlap with previous ${$}`)}}for(let U=0;U<A.length;U++){let N=A[U];if(N==null)continue;if(!(N instanceof B1))continue;let Y=N,X=this.getKindOfOps(A,B1,U);for(let $ of X)if($.index===Y.index){if($ instanceof B4)Y.text=this.catOpText($.text,Y.text),A[$.instructionIndex]=null;else if($ instanceof B1)Y.text=this.catOpText(Y.text,$.text),A[$.instructionIndex]=null}let Q=this.getKindOfOps(A,X2,U);for(let $ of Q){if(Y.index===$.index){$.text=this.catOpText(Y.text,$.text),A[U]=null;continue}if(Y.index>=$.index&&Y.index<=$.lastIndex)throw Error(`insert op ${Y} within boundaries of previous ${$}`)}}let R=new Map;for(let U of A){if(U==null)continue;if(R.get(U.index)!=null)throw Error("should only be one op per index");R.set(U.index,U)}return R}catOpText(A,R){let U="",N="";if(A!=null)U=A.toString();if(R!=null)N=R.toString();return U+N}getKindOfOps(A,R,U){return A.slice(0,U).filter((N)=>{return N&&N instanceof R})}},b4=class{static{q(this,"RewriteOperation")}instructionIndex;index;text;tokens;constructor(_,A,R,U){this.tokens=_,this.instructionIndex=R,this.index=A,this.text=U===void 0?"":U}execute(_){return this.index}toString(){return"<RewriteOperation@"+this.tokens.get(this.index)+':"'+this.text+'">'}},B1=class extends b4{static{q(this,"InsertBeforeOp")}constructor(_,A,R,U){super(_,A,R,U)}execute(_){if(this.text)_.push(this.text.toString());if(this.tokens.get(this.index).type!==B.EOF)_.push(String(this.tokens.get(this.index).text));return this.index+1}toString(){return"<InsertBeforeOp@"+this.tokens.get(this.index)+':"'+this.text+'">'}},B4=class extends B1{static{q(this,"InsertAfterOp")}constructor(_,A,R,U){super(_,A+1,R,U)}toString(){return"<InsertAfterOp@"+this.tokens.get(this.index)+':"'+this.text+'">'}},X2=class extends b4{static{q(this,"ReplaceOp")}lastIndex;constructor(_,A,R,U,N){super(_,A,U,N);this.lastIndex=R}execute(_){if(this.text)_.push(this.text.toString());return this.lastIndex+1}toString(){if(this.text==null)return"<DeleteOp@"+this.tokens.get(this.index)+".."+this.tokens.get(this.lastIndex)+">";return"<ReplaceOp@"+this.tokens.get(this.index)+".."+this.tokens.get(this.lastIndex)+':"'+this.text+'">'}},v8=class{static{q(this,"UnbufferedTokenStream")}tokenSource;tokens;n;p=0;numMarkers=0;lastToken;lastTokenBufferStart;currentTokenIndex=0;constructor(_,A){this.tokenSource=_,A=A??256,this.tokens=Array(A),this.n=0,this.fill(1)}get(_){let A=this.getBufferStartIndex();if(_<A||_>=A+this.n)throw Error("get("+_+") outside buffer: "+A+".."+(A+this.n));return this.tokens[_-A]}LT(_){if(_===-1)return this.lastToken;this.sync(_);let A=this.p+_-1;if(A<0)throw Error("LT("+_+") gives negative index");if(A>=this.n)return this.tokens[this.n-1];return this.tokens[A]}LA(_){return this.LT(_).type}getText(){return""}getTextFromContext(_){return this.getTextFromInterval(_.getSourceInterval())}getTextFromInterval(_){let A=this.getBufferStartIndex(),R=A+this.tokens.length-1,U=_.start,N=_.stop;if(U<A||N>R)throw Error("interval "+_+" not in token buffer window: "+A+".."+R);let Y=U-A,X=N-A,Q="";for(let $=Y;$<=X;$++){let J=this.tokens[$];Q+=J.text}return Q}getTextFromRange(_,A){return this.getTextFromInterval(v.of(_.tokenIndex,A.tokenIndex))}consume(){if(this.LA(1)===B.EOF)throw Error("cannot consume EOF");if(this.lastToken=this.tokens[this.p],this.p===this.n-1&&this.numMarkers===0)this.n=0,this.p=-1,this.lastTokenBufferStart=this.lastToken;this.p++,this.currentTokenIndex++,this.sync(1)}mark(){if(this.numMarkers===0)this.lastTokenBufferStart=this.lastToken;let _=-this.numMarkers-1;return this.numMarkers++,_}release(_){let A=-this.numMarkers;if(_!==A)throw Error("release() called with an invalid marker.");if(this.numMarkers--,this.numMarkers===0){if(this.p>0)this.tokens.copyWithin(0,this.p,this.n),this.n=this.n-this.p,this.p=0;this.lastTokenBufferStart=this.lastToken}}get index(){return this.currentTokenIndex}seek(_){if(_===this.currentTokenIndex)return;if(_>this.currentTokenIndex)this.sync(_-this.currentTokenIndex),_=Math.min(_,this.getBufferStartIndex()+this.n-1);let A=this.getBufferStartIndex(),R=_-A;if(R<0)throw Error("cannot seek to negative index "+_);else if(R>=this.n)throw Error("seek to index outside buffer: "+_+" not in "+A+".."+(A+this.n));if(this.p=R,this.currentTokenIndex=_,this.p===0)this.lastToken=this.lastTokenBufferStart;else this.lastToken=this.tokens[this.p-1]}get size(){throw Error("Unbuffered stream cannot know its size")}getSourceName(){return this.tokenSource.sourceName}setLine(_){this.tokenSource.line=_}setColumn(_){this.tokenSource.column=_}sync(_){let A=this.p+_-1-this.n+1;if(A>0)this.fill(A)}fill(_){for(let A=0;A<_;A++){if(this.n>0&&this.tokens[this.n-1].type===B.EOF)return A;let R=this.tokenSource.nextToken();this.add(R)}return _}add(_){if(this.n>=this.tokens.length)this.tokens.length=this.tokens.length*2;if(f4(_))_.setTokenIndex(this.getBufferStartIndex()+this.n);this.tokens[this.n++]=_}getBufferStartIndex(){return this.currentTokenIndex-this.p}};class J2{typeChecker;typeManager;expression;diagnostics;get arguments(){if(this.expression instanceof i)return this.expression.arguments;return[]}get isConstant(){if(!this.expression)return!1;return this.typeChecker.isConstantExpression(this.expression)}constructor(_,A,R,U){this.typeChecker=_;this.typeManager=A;this.expression=R;this.diagnostics=U}getArgumentsList(_=!1){if(_&&this.expression instanceof D0)return this.expression.arguments2??[];return this.arguments}checkArgument(_,A,R=!1){let U=this.getArgumentsList(R);if(_<0||_>=U.length)return null;let N=U[_];return this.visitExpression(N,A),N}checkTypeArgument(_){let A=this.arguments;if(_<0||_>=A.length)return null;let R=A[_];if(!(R instanceof A0))return this.diagnostics.report(new _0("ERROR",R,J2.DIAGNOSTIC_TYPEREF_EXPECTED)),R.type=W.Error,R;let U=this.typeManager.findOrNull(R.text);if(!U)return this.diagnostics.report(new _0("ERROR",R,E.GENERIC_INVALID_TYPE,R.text)),R.type=W.Error,R;return R.type=new W.Type(U),R.reference=new r(R.text,R.type),R}checkArgumentTypes(_,A=!0,R=!1){let U=this.getArgumentsList(R),N=[];for(let X of U){if(!X.getNullableType())this.visitExpression(X);N.push(X.type??W.Error)}let Y=M.fromList(N.map((X)=>X??W.Error));return this.typeChecker.checkTypeMatch(this.expression,_,Y,A)}collectTypes(..._){return M.fromList(_.filter((A)=>!!A).map((A)=>A.getNullableType()??W.Error))}visitNode(_){if(_)this.typeChecker.visitNodeOrNull(_)}visitExpression(_,A){if(!_)return;if(A)_.typeHint=A;this.typeChecker.visitNodeOrNull(_)}visitNodeList(_){if(!_)return;for(let A of _)this.typeChecker.visitNodeOrNull(A)}static DIAGNOSTIC_TYPEREF_EXPECTED="Type reference expected."}class s{inner;options=new d({allowArray:!1,allowDeclaration:!0,allowSwitch:!0});constructor(_){if(_ instanceof s)throw Error("ArrayType cannot wrap another ArrayType.");this.inner=_}get representation(){return`${this.inner.representation}array`}get code(){throw Error("ArrayType has no character representation.")}get baseType(){return 0}get defaultValue(){throw Error("ArrayType has no default value.")}toString(){return`ArrayType{inner=${this.inner}}`}}class o0 extends a{kind="Script";trigger;name;isStar;parameters;returnTokens;statements;block;symbol;returnType;triggerType;subjectReference=null;parameterType;constructor(_){super(_.source);if(this.trigger=_.trigger,this.name=_.name,this.isStar=_.isStar,this.parameters=_.parameters,this.returnTokens=_.returnTokens,this.statements=_.statements,this.addChild(this.trigger),this.addChild(this.name),this.parameters)this.addChildren(this.parameters);if(this.returnTokens)this.addChildren(this.returnTokens);this.addChildren(this.statements)}get nameString(){return this.isStar?`${this.name.text}*`:this.name.text}accept(_){return _.visitScript(this)}}class o1 extends i{kind="ClientScriptExpression";transmitList;constructor(_,A,R,U){super(_,A,R);this.transmitList=U,this.addChildren(this.transmitList)}accept(_){return _.visitClientScriptExpression(this)}}class p1 extends i{kind="JumpCallExpression";constructor(_,A,R){super(_,A,R)}accept(_){return _.visitJumpCallExpression(this)}}class i1 extends i{kind="ProcCallExpression";constructor(_,A,R){super(_,A,R)}accept(_){return _.visitProcCallExpression(this)}}class g extends a{constructor(_){super(_)}}class t1 extends g{kind="SwitchStatement";typeToken;condition;cases;defaultCase=null;type;constructor(_,A,R,U){super(_);this.typeToken=A,this.condition=R,this.cases=U,this.addChild(this.typeToken),this.addChild(this.condition),this.addChildren(this.cases)}accept(_){return _.visitSwitchStatement(this)}}import{readFileSync as L6}from"fs";import{readFile as B6}from"fs/promises";class T extends C0{static LPAREN=1;static RPAREN=2;static COLON=3;static SEMICOLON=4;static COMMA=5;static LBRACK=6;static RBRACK=7;static LBRACE=8;static RBRACE=9;static PLUS=10;static MINUS=11;static MUL=12;static DIV=13;static DOTMOD=14;static MOD=15;static AND=16;static OR=17;static EQ=18;static EXCL=19;static DOLLAR=20;static CARET=21;static TILDE=22;static AT=23;static GT=24;static GTE=25;static LT=26;static LTE=27;static IF=28;static ELSE=29;static WHILE=30;static CASE=31;static DEFAULT=32;static RETURN=33;static CALC=34;static TYPE_ARRAY=35;static DEF_TYPE=36;static SWITCH_TYPE=37;static INTEGER_LITERAL=38;static HEX_LITERAL=39;static COORD_LITERAL=40;static MAPZONE_LITERAL=41;static BOOLEAN_LITERAL=42;static CHAR_LITERAL=43;static NULL_LITERAL=44;static LINE_COMMENT=45;static BLOCK_COMMENT=46;static QUOTE_OPEN=47;static IDENTIFIER=48;static WHITESPACE=49;static QUOTE_CLOSE=50;static STRING_TEXT=51;static STRING_TAG=52;static STRING_CLOSE_TAG=53;static STRING_PARTIAL_TAG=54;static STRING_P_TAG=55;static STRING_EXPR_START=56;static STRING_EXPR_END=57;static String=1;static channelNames=["DEFAULT_TOKEN_CHANNEL","HIDDEN"];static literalNames=[null,"'('","')'","':'","';'","','","'['","']'","'{'","'}'","'+'","'-'","'*'","'/'","'.%'","'%'","'&'","'|'","'='","'!'","'$'","'^'","'~'","'@'",null,"'>='",null,"'<='","'if'","'else'","'while'","'case'","'default'","'return'","'calc'",null,null,null,null,null,null,null,null,null,"'null'"];static symbolicNames=[null,"LPAREN","RPAREN","COLON","SEMICOLON","COMMA","LBRACK","RBRACK","LBRACE","RBRACE","PLUS","MINUS","MUL","DIV","DOTMOD","MOD","AND","OR","EQ","EXCL","DOLLAR","CARET","TILDE","AT","GT","GTE","LT","LTE","IF","ELSE","WHILE","CASE","DEFAULT","RETURN","CALC","TYPE_ARRAY","DEF_TYPE","SWITCH_TYPE","INTEGER_LITERAL","HEX_LITERAL","COORD_LITERAL","MAPZONE_LITERAL","BOOLEAN_LITERAL","CHAR_LITERAL","NULL_LITERAL","LINE_COMMENT","BLOCK_COMMENT","QUOTE_OPEN","IDENTIFIER","WHITESPACE","QUOTE_CLOSE","STRING_TEXT","STRING_TAG","STRING_CLOSE_TAG","STRING_PARTIAL_TAG","STRING_P_TAG","STRING_EXPR_START","STRING_EXPR_END"];static modeNames=["DEFAULT_MODE","String"];static ruleNames=["LPAREN","RPAREN","COLON","SEMICOLON","COMMA","LBRACK","RBRACK","LBRACE","RBRACE","PLUS","MINUS","MUL","DIV","DOTMOD","MOD","AND","OR","EQ","EXCL","DOLLAR","CARET","TILDE","AT","GT","GTE","LT","LTE","IF","ELSE","WHILE","CASE","DEFAULT","RETURN","CALC","TYPE_ARRAY","DEF_TYPE","SWITCH_TYPE","INTEGER_LITERAL","HEX_LITERAL","COORD_LITERAL","MAPZONE_LITERAL","BOOLEAN_LITERAL","CHAR_LITERAL","NULL_LITERAL","LINE_COMMENT","BLOCK_COMMENT","Digit","CharEscapeSequence","QUOTE_OPEN","IDENTIFIER","WHITESPACE","QUOTE_CLOSE","STRING_TEXT","STRING_TAG","STRING_CLOSE_TAG","STRING_PARTIAL_TAG","STRING_P_TAG","STRING_EXPR_START","STRING_EXPR_END","StringEscapeSequence","Tag"];depth=0;constructor(_){super(_);this.interpreter=new k1(this,T._ATN,T.decisionsToDFA,new Z1)}get grammarFileName(){return"RuneScriptLexer.g4"}get literalNames(){return T.literalNames}get symbolicNames(){return T.symbolicNames}get ruleNames(){return T.ruleNames}get serializedATN(){return T._serializedATN}get channelNames(){return T.channelNames}get modeNames(){return T.modeNames}action(_,A,R){switch(A){case 23:this.GT_action(_,R);break;case 48:this.QUOTE_OPEN_action(_,R);break;case 51:this.QUOTE_CLOSE_action(_,R);break}}GT_action(_,A){switch(A){case 0:if(this.depth>0)this.type=T.STRING_EXPR_END,this.popMode();break}}QUOTE_OPEN_action(_,A){switch(A){case 1:this.depth++;break}}QUOTE_CLOSE_action(_,A){switch(A){case 2:this.depth--;break}}static _serializedATN=[4,0,57,456,6,-1,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,45,2,46,7,46,2,47,7,47,2,48,7,48,2,49,7,49,2,50,7,50,2,51,7,51,2,52,7,52,2,53,7,53,2,54,7,54,2,55,7,55,2,56,7,56,2,57,7,57,2,58,7,58,2,59,7,59,2,60,7,60,1,0,1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,4,1,4,1,5,1,5,1,6,1,6,1,7,1,7,1,8,1,8,1,9,1,9,1,10,1,10,1,11,1,11,1,12,1,12,1,13,1,13,1,13,1,14,1,14,1,15,1,15,1,16,1,16,1,17,1,17,1,18,1,18,1,19,1,19,1,20,1,20,1,21,1,21,1,22,1,22,1,23,1,23,1,23,1,24,1,24,1,24,1,25,1,25,1,26,1,26,1,26,1,27,1,27,1,27,1,28,1,28,1,28,1,28,1,28,1,29,1,29,1,29,1,29,1,29,1,29,1,30,1,30,1,30,1,30,1,30,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,33,1,33,1,33,1,33,1,33,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,35,1,35,1,35,1,35,1,35,1,35,1,35,1,36,1,36,1,36,1,36,1,36,1,36,1,36,1,36,1,36,1,36,1,37,3,37,247,8,37,1,37,4,37,250,8,37,11,37,12,37,251,1,38,1,38,1,38,4,38,257,8,38,11,38,12,38,258,1,39,4,39,262,8,39,11,39,12,39,263,1,39,1,39,4,39,268,8,39,11,39,12,39,269,1,39,1,39,4,39,274,8,39,11,39,12,39,275,1,39,1,39,4,39,280,8,39,11,39,12,39,281,1,39,1,39,4,39,286,8,39,11,39,12,39,287,1,40,4,40,291,8,40,11,40,12,40,292,1,40,1,40,4,40,297,8,40,11,40,12,40,298,1,40,1,40,4,40,303,8,40,11,40,12,40,304,1,41,1,41,1,41,1,41,1,41,1,41,1,41,1,41,1,41,3,41,316,8,41,1,42,1,42,1,42,3,42,321,8,42,1,42,1,42,1,43,1,43,1,43,1,43,1,43,1,44,1,44,1,44,1,44,5,44,334,8,44,10,44,12,44,337,9,44,1,44,3,44,340,8,44,1,44,1,44,1,45,1,45,1,45,1,45,5,45,348,8,45,10,45,12,45,351,9,45,1,45,1,45,1,45,1,45,1,45,1,46,1,46,1,47,1,47,1,47,1,48,1,48,1,48,1,48,1,48,1,49,4,49,369,8,49,11,49,12,49,370,1,50,4,50,374,8,50,11,50,12,50,375,1,50,1,50,1,51,1,51,1,51,1,51,1,51,1,52,1,52,4,52,387,8,52,11,52,12,52,388,3,52,391,8,52,1,53,1,53,1,53,1,53,4,53,397,8,53,11,53,12,53,398,3,53,401,8,53,1,53,1,53,1,54,1,54,1,54,1,54,1,54,1,54,1,55,1,55,1,55,1,55,1,56,1,56,1,56,1,56,1,56,4,56,420,8,56,11,56,12,56,421,1,56,1,56,1,57,1,57,1,57,1,57,1,58,1,58,1,59,1,59,1,59,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,1,60,3,60,455,8,60,2,335,349,0,61,2,1,4,2,6,3,8,4,10,5,12,6,14,7,16,8,18,9,20,10,22,11,24,12,26,13,28,14,30,15,32,16,34,17,36,18,38,19,40,20,42,21,44,22,46,23,48,24,50,25,52,26,54,27,56,28,58,29,60,30,62,31,64,32,66,33,68,34,70,35,72,36,74,37,76,38,78,39,80,40,82,41,84,42,86,43,88,44,90,45,92,46,94,0,96,0,98,47,100,48,102,49,104,50,106,51,108,52,110,53,112,54,114,55,116,56,118,57,120,0,122,0,2,0,1,11,2,0,88,88,120,120,3,0,48,57,65,70,97,102,4,0,10,10,13,13,39,39,92,92,1,1,10,10,1,0,48,57,2,0,39,39,92,92,6,0,43,43,46,46,48,58,65,90,95,95,97,122,3,0,9,10,13,13,32,32,5,0,10,10,13,13,34,34,60,60,92,92,2,0,60,60,62,62,3,0,34,34,60,60,92,92,479,0,2,1,0,0,0,0,4,1,0,0,0,0,6,1,0,0,0,0,8,1,0,0,0,0,10,1,0,0,0,0,12,1,0,0,0,0,14,1,0,0,0,0,16,1,0,0,0,0,18,1,0,0,0,0,20,1,0,0,0,0,22,1,0,0,0,0,24,1,0,0,0,0,26,1,0,0,0,0,28,1,0,0,0,0,30,1,0,0,0,0,32,1,0,0,0,0,34,1,0,0,0,0,36,1,0,0,0,0,38,1,0,0,0,0,40,1,0,0,0,0,42,1,0,0,0,0,44,1,0,0,0,0,46,1,0,0,0,0,48,1,0,0,0,0,50,1,0,0,0,0,52,1,0,0,0,0,54,1,0,0,0,0,56,1,0,0,0,0,58,1,0,0,0,0,60,1,0,0,0,0,62,1,0,0,0,0,64,1,0,0,0,0,66,1,0,0,0,0,68,1,0,0,0,0,70,1,0,0,0,0,72,1,0,0,0,0,74,1,0,0,0,0,76,1,0,0,0,0,78,1,0,0,0,0,80,1,0,0,0,0,82,1,0,0,0,0,84,1,0,0,0,0,86,1,0,0,0,0,88,1,0,0,0,0,90,1,0,0,0,0,92,1,0,0,0,0,98,1,0,0,0,0,100,1,0,0,0,0,102,1,0,0,0,1,104,1,0,0,0,1,106,1,0,0,0,1,108,1,0,0,0,1,110,1,0,0,0,1,112,1,0,0,0,1,114,1,0,0,0,1,116,1,0,0,0,1,118,1,0,0,0,2,124,1,0,0,0,4,126,1,0,0,0,6,128,1,0,0,0,8,130,1,0,0,0,10,132,1,0,0,0,12,134,1,0,0,0,14,136,1,0,0,0,16,138,1,0,0,0,18,140,1,0,0,0,20,142,1,0,0,0,22,144,1,0,0,0,24,146,1,0,0,0,26,148,1,0,0,0,28,150,1,0,0,0,30,153,1,0,0,0,32,155,1,0,0,0,34,157,1,0,0,0,36,159,1,0,0,0,38,161,1,0,0,0,40,163,1,0,0,0,42,165,1,0,0,0,44,167,1,0,0,0,46,169,1,0,0,0,48,171,1,0,0,0,50,174,1,0,0,0,52,177,1,0,0,0,54,179,1,0,0,0,56,182,1,0,0,0,58,185,1,0,0,0,60,190,1,0,0,0,62,196,1,0,0,0,64,201,1,0,0,0,66,209,1,0,0,0,68,216,1,0,0,0,70,221,1,0,0,0,72,228,1,0,0,0,74,235,1,0,0,0,76,246,1,0,0,0,78,253,1,0,0,0,80,261,1,0,0,0,82,290,1,0,0,0,84,315,1,0,0,0,86,317,1,0,0,0,88,324,1,0,0,0,90,329,1,0,0,0,92,343,1,0,0,0,94,357,1,0,0,0,96,359,1,0,0,0,98,362,1,0,0,0,100,368,1,0,0,0,102,373,1,0,0,0,104,379,1,0,0,0,106,390,1,0,0,0,108,392,1,0,0,0,110,404,1,0,0,0,112,410,1,0,0,0,114,414,1,0,0,0,116,425,1,0,0,0,118,429,1,0,0,0,120,431,1,0,0,0,122,454,1,0,0,0,124,125,5,40,0,0,125,3,1,0,0,0,126,127,5,41,0,0,127,5,1,0,0,0,128,129,5,58,0,0,129,7,1,0,0,0,130,131,5,59,0,0,131,9,1,0,0,0,132,133,5,44,0,0,133,11,1,0,0,0,134,135,5,91,0,0,135,13,1,0,0,0,136,137,5,93,0,0,137,15,1,0,0,0,138,139,5,123,0,0,139,17,1,0,0,0,140,141,5,125,0,0,141,19,1,0,0,0,142,143,5,43,0,0,143,21,1,0,0,0,144,145,5,45,0,0,145,23,1,0,0,0,146,147,5,42,0,0,147,25,1,0,0,0,148,149,5,47,0,0,149,27,1,0,0,0,150,151,5,46,0,0,151,152,5,37,0,0,152,29,1,0,0,0,153,154,5,37,0,0,154,31,1,0,0,0,155,156,5,38,0,0,156,33,1,0,0,0,157,158,5,124,0,0,158,35,1,0,0,0,159,160,5,61,0,0,160,37,1,0,0,0,161,162,5,33,0,0,162,39,1,0,0,0,163,164,5,36,0,0,164,41,1,0,0,0,165,166,5,94,0,0,166,43,1,0,0,0,167,168,5,126,0,0,168,45,1,0,0,0,169,170,5,64,0,0,170,47,1,0,0,0,171,172,5,62,0,0,172,173,6,23,0,0,173,49,1,0,0,0,174,175,5,62,0,0,175,176,5,61,0,0,176,51,1,0,0,0,177,178,5,60,0,0,178,53,1,0,0,0,179,180,5,60,0,0,180,181,5,61,0,0,181,55,1,0,0,0,182,183,5,105,0,0,183,184,5,102,0,0,184,57,1,0,0,0,185,186,5,101,0,0,186,187,5,108,0,0,187,188,5,115,0,0,188,189,5,101,0,0,189,59,1,0,0,0,190,191,5,119,0,0,191,192,5,104,0,0,192,193,5,105,0,0,193,194,5,108,0,0,194,195,5,101,0,0,195,61,1,0,0,0,196,197,5,99,0,0,197,198,5,97,0,0,198,199,5,115,0,0,199,200,5,101,0,0,200,63,1,0,0,0,201,202,5,100,0,0,202,203,5,101,0,0,203,204,5,102,0,0,204,205,5,97,0,0,205,206,5,117,0,0,206,207,5,108,0,0,207,208,5,116,0,0,208,65,1,0,0,0,209,210,5,114,0,0,210,211,5,101,0,0,211,212,5,116,0,0,212,213,5,117,0,0,213,214,5,114,0,0,214,215,5,110,0,0,215,67,1,0,0,0,216,217,5,99,0,0,217,218,5,97,0,0,218,219,5,108,0,0,219,220,5,99,0,0,220,69,1,0,0,0,221,222,3,100,49,0,222,223,5,97,0,0,223,224,5,114,0,0,224,225,5,114,0,0,225,226,5,97,0,0,226,227,5,121,0,0,227,71,1,0,0,0,228,229,5,100,0,0,229,230,5,101,0,0,230,231,5,102,0,0,231,232,5,95,0,0,232,233,1,0,0,0,233,234,3,100,49,0,234,73,1,0,0,0,235,236,5,115,0,0,236,237,5,119,0,0,237,238,5,105,0,0,238,239,5,116,0,0,239,240,5,99,0,0,240,241,5,104,0,0,241,242,5,95,0,0,242,243,1,0,0,0,243,244,3,100,49,0,244,75,1,0,0,0,245,247,5,45,0,0,246,245,1,0,0,0,246,247,1,0,0,0,247,249,1,0,0,0,248,250,3,94,46,0,249,248,1,0,0,0,250,251,1,0,0,0,251,249,1,0,0,0,251,252,1,0,0,0,252,77,1,0,0,0,253,254,5,48,0,0,254,256,7,0,0,0,255,257,7,1,0,0,256,255,1,0,0,0,257,258,1,0,0,0,258,256,1,0,0,0,258,259,1,0,0,0,259,79,1,0,0,0,260,262,3,94,46,0,261,260,1,0,0,0,262,263,1,0,0,0,263,261,1,0,0,0,263,264,1,0,0,0,264,265,1,0,0,0,265,267,5,95,0,0,266,268,3,94,46,0,267,266,1,0,0,0,268,269,1,0,0,0,269,267,1,0,0,0,269,270,1,0,0,0,270,271,1,0,0,0,271,273,5,95,0,0,272,274,3,94,46,0,273,272,1,0,0,0,274,275,1,0,0,0,275,273,1,0,0,0,275,276,1,0,0,0,276,277,1,0,0,0,277,279,5,95,0,0,278,280,3,94,46,0,279,278,1,0,0,0,280,281,1,0,0,0,281,279,1,0,0,0,281,282,1,0,0,0,282,283,1,0,0,0,283,285,5,95,0,0,284,286,3,94,46,0,285,284,1,0,0,0,286,287,1,0,0,0,287,285,1,0,0,0,287,288,1,0,0,0,288,81,1,0,0,0,289,291,3,94,46,0,290,289,1,0,0,0,291,292,1,0,0,0,292,290,1,0,0,0,292,293,1,0,0,0,293,294,1,0,0,0,294,296,5,95,0,0,295,297,3,94,46,0,296,295,1,0,0,0,297,298,1,0,0,0,298,296,1,0,0,0,298,299,1,0,0,0,299,300,1,0,0,0,300,302,5,95,0,0,301,303,3,94,46,0,302,301,1,0,0,0,303,304,1,0,0,0,304,302,1,0,0,0,304,305,1,0,0,0,305,83,1,0,0,0,306,307,5,116,0,0,307,308,5,114,0,0,308,309,5,117,0,0,309,316,5,101,0,0,310,311,5,102,0,0,311,312,5,97,0,0,312,313,5,108,0,0,313,314,5,115,0,0,314,316,5,101,0,0,315,306,1,0,0,0,315,310,1,0,0,0,316,85,1,0,0,0,317,320,5,39,0,0,318,321,3,96,47,0,319,321,8,2,0,0,320,318,1,0,0,0,320,319,1,0,0,0,321,322,1,0,0,0,322,323,5,39,0,0,323,87,1,0,0,0,324,325,5,110,0,0,325,326,5,117,0,0,326,327,5,108,0,0,327,328,5,108,0,0,328,89,1,0,0,0,329,330,5,47,0,0,330,331,5,47,0,0,331,335,1,0,0,0,332,334,9,0,0,0,333,332,1,0,0,0,334,337,1,0,0,0,335,336,1,0,0,0,335,333,1,0,0,0,336,339,1,0,0,0,337,335,1,0,0,0,338,340,7,3,0,0,339,338,1,0,0,0,340,341,1,0,0,0,341,342,6,44,1,0,342,91,1,0,0,0,343,344,5,47,0,0,344,345,5,42,0,0,345,349,1,0,0,0,346,348,9,0,0,0,347,346,1,0,0,0,348,351,1,0,0,0,349,350,1,0,0,0,349,347,1,0,0,0,350,352,1,0,0,0,351,349,1,0,0,0,352,353,5,42,0,0,353,354,5,47,0,0,354,355,1,0,0,0,355,356,6,45,1,0,356,93,1,0,0,0,357,358,7,4,0,0,358,95,1,0,0,0,359,360,5,92,0,0,360,361,7,5,0,0,361,97,1,0,0,0,362,363,5,34,0,0,363,364,6,48,2,0,364,365,1,0,0,0,365,366,6,48,3,0,366,99,1,0,0,0,367,369,7,6,0,0,368,367,1,0,0,0,369,370,1,0,0,0,370,368,1,0,0,0,370,371,1,0,0,0,371,101,1,0,0,0,372,374,7,7,0,0,373,372,1,0,0,0,374,375,1,0,0,0,375,373,1,0,0,0,375,376,1,0,0,0,376,377,1,0,0,0,377,378,6,50,1,0,378,103,1,0,0,0,379,380,5,34,0,0,380,381,6,51,4,0,381,382,1,0,0,0,382,383,6,51,5,0,383,105,1,0,0,0,384,391,3,120,59,0,385,387,8,8,0,0,386,385,1,0,0,0,387,388,1,0,0,0,388,386,1,0,0,0,388,389,1,0,0,0,389,391,1,0,0,0,390,384,1,0,0,0,390,386,1,0,0,0,391,107,1,0,0,0,392,393,5,60,0,0,393,400,3,122,60,0,394,396,5,61,0,0,395,397,8,9,0,0,396,395,1,0,0,0,397,398,1,0,0,0,398,396,1,0,0,0,398,399,1,0,0,0,399,401,1,0,0,0,400,394,1,0,0,0,400,401,1,0,0,0,401,402,1,0,0,0,402,403,5,62,0,0,403,109,1,0,0,0,404,405,5,60,0,0,405,406,5,47,0,0,406,407,1,0,0,0,407,408,3,122,60,0,408,409,5,62,0,0,409,111,1,0,0,0,410,411,5,60,0,0,411,412,3,122,60,0,412,413,5,61,0,0,413,113,1,0,0,0,414,415,5,60,0,0,415,416,5,112,0,0,416,417,5,44,0,0,417,419,1,0,0,0,418,420,8,9,0,0,419,418,1,0,0,0,420,421,1,0,0,0,421,419,1,0,0,0,421,422,1,0,0,0,422,423,1,0,0,0,423,424,5,62,0,0,424,115,1,0,0,0,425,426,5,60,0,0,426,427,1,0,0,0,427,428,6,57,6,0,428,117,1,0,0,0,429,430,5,62,0,0,430,119,1,0,0,0,431,432,5,92,0,0,432,433,7,10,0,0,433,121,1,0,0,0,434,435,5,98,0,0,435,455,5,114,0,0,436,437,5,99,0,0,437,438,5,111,0,0,438,455,5,108,0,0,439,440,5,115,0,0,440,441,5,116,0,0,441,455,5,114,0,0,442,443,5,115,0,0,443,444,5,104,0,0,444,445,5,97,0,0,445,455,5,100,0,0,446,455,5,117,0,0,447,448,5,105,0,0,448,449,5,109,0,0,449,455,5,103,0,0,450,451,5,103,0,0,451,455,5,116,0,0,452,453,5,108,0,0,453,455,5,116,0,0,454,434,1,0,0,0,454,436,1,0,0,0,454,439,1,0,0,0,454,442,1,0,0,0,454,446,1,0,0,0,454,447,1,0,0,0,454,450,1,0,0,0,454,452,1,0,0,0,455,123,1,0,0,0,26,0,1,246,251,258,263,269,275,281,287,292,298,304,315,320,335,339,349,370,375,388,390,398,400,421,454,7,1,23,0,0,1,0,1,48,1,5,1,0,1,51,2,4,0,0,5,0,0];static __ATN;static get _ATN(){if(!T.__ATN)T.__ATN=new n0().deserialize(T._serializedATN);return T.__ATN}static vocabulary=new K0(T.literalNames,T.symbolicNames,[]);get vocabulary(){return T.vocabulary}static decisionsToDFA=T._ATN.decisionToState.map((_,A)=>new x0(_,A))}class Z extends _3{static LPAREN=1;static RPAREN=2;static COLON=3;static SEMICOLON=4;static COMMA=5;static LBRACK=6;static RBRACK=7;static LBRACE=8;static RBRACE=9;static PLUS=10;static MINUS=11;static MUL=12;static DIV=13;static DOTMOD=14;static MOD=15;static AND=16;static OR=17;static EQ=18;static EXCL=19;static DOLLAR=20;static CARET=21;static TILDE=22;static AT=23;static GT=24;static GTE=25;static LT=26;static LTE=27;static IF=28;static ELSE=29;static WHILE=30;static CASE=31;static DEFAULT=32;static RETURN=33;static CALC=34;static TYPE_ARRAY=35;static DEF_TYPE=36;static SWITCH_TYPE=37;static INTEGER_LITERAL=38;static HEX_LITERAL=39;static COORD_LITERAL=40;static MAPZONE_LITERAL=41;static BOOLEAN_LITERAL=42;static CHAR_LITERAL=43;static NULL_LITERAL=44;static LINE_COMMENT=45;static BLOCK_COMMENT=46;static QUOTE_OPEN=47;static IDENTIFIER=48;static WHITESPACE=49;static QUOTE_CLOSE=50;static STRING_TEXT=51;static STRING_TAG=52;static STRING_CLOSE_TAG=53;static STRING_PARTIAL_TAG=54;static STRING_P_TAG=55;static STRING_EXPR_START=56;static STRING_EXPR_END=57;static RULE_scriptFile=0;static RULE_script=1;static RULE_parameterList=2;static RULE_parameter=3;static RULE_typeList=4;static RULE_statement=5;static RULE_blockStatement=6;static RULE_returnStatement=7;static RULE_ifStatement=8;static RULE_whileStatement=9;static RULE_switchStatement=10;static RULE_switchCase=11;static RULE_declarationStatement=12;static RULE_arrayDeclarationStatement=13;static RULE_assignmentStatement=14;static RULE_expressionStatement=15;static RULE_emptyStatement=16;static RULE_expressionList=17;static RULE_parenthesis=18;static RULE_singleExpression=19;static RULE_expression=20;static RULE_condition=21;static RULE_calc=22;static RULE_arithmetic=23;static RULE_call=24;static RULE_clientScript=25;static RULE_assignableVariableList=26;static RULE_assignableVariable=27;static RULE_localVariable=28;static RULE_localArrayVariable=29;static RULE_gameVariable=30;static RULE_constantVariable=31;static RULE_literal=32;static RULE_stringLiteral=33;static RULE_stringLiteralContent=34;static RULE_joinedString=35;static RULE_stringTag=36;static RULE_stringPTag=37;static RULE_stringExpression=38;static RULE_identifier=39;static RULE_advancedIdentifier=40;static literalNames=[null,"'('","')'","':'","';'","','","'['","']'","'{'","'}'","'+'","'-'","'*'","'/'","'.%'","'%'","'&'","'|'","'='","'!'","'$'","'^'","'~'","'@'",null,"'>='",null,"'<='","'if'","'else'","'while'","'case'","'default'","'return'","'calc'",null,null,null,null,null,null,null,null,null,"'null'"];static symbolicNames=[null,"LPAREN","RPAREN","COLON","SEMICOLON","COMMA","LBRACK","RBRACK","LBRACE","RBRACE","PLUS","MINUS","MUL","DIV","DOTMOD","MOD","AND","OR","EQ","EXCL","DOLLAR","CARET","TILDE","AT","GT","GTE","LT","LTE","IF","ELSE","WHILE","CASE","DEFAULT","RETURN","CALC","TYPE_ARRAY","DEF_TYPE","SWITCH_TYPE","INTEGER_LITERAL","HEX_LITERAL","COORD_LITERAL","MAPZONE_LITERAL","BOOLEAN_LITERAL","CHAR_LITERAL","NULL_LITERAL","LINE_COMMENT","BLOCK_COMMENT","QUOTE_OPEN","IDENTIFIER","WHITESPACE","QUOTE_CLOSE","STRING_TEXT","STRING_TAG","STRING_CLOSE_TAG","STRING_PARTIAL_TAG","STRING_P_TAG","STRING_EXPR_START","STRING_EXPR_END"];static ruleNames=["scriptFile","script","parameterList","parameter","typeList","statement","blockStatement","returnStatement","ifStatement","whileStatement","switchStatement","switchCase","declarationStatement","arrayDeclarationStatement","assignmentStatement","expressionStatement","emptyStatement","expressionList","parenthesis","singleExpression","expression","condition","calc","arithmetic","call","clientScript","assignableVariableList","assignableVariable","localVariable","localArrayVariable","gameVariable","constantVariable","literal","stringLiteral","stringLiteralContent","joinedString","stringTag","stringPTag","stringExpression","identifier","advancedIdentifier"];get grammarFileName(){return"RuneScriptParser.g4"}get literalNames(){return Z.literalNames}get symbolicNames(){return Z.symbolicNames}get ruleNames(){return Z.ruleNames}get serializedATN(){return Z._serializedATN}createFailedPredicateException(_,A){return new s1(this,_,A)}constructor(_){super(_);this.interpreter=new n1(this,Z._ATN,Z.decisionsToDFA,new Z1)}scriptFile(){let _=new u4(this.context,this.state);this.enterRule(_,0,Z.RULE_scriptFile);let A;try{this.enterOuterAlt(_,1);{this.state=85,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while(A===6)this.state=82,this.script(),this.state=87,this.errorHandler.sync(this),A=this.tokenStream.LA(1);this.state=88,this.match(Z.EOF)}}catch(R){if(R instanceof f)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}script(){let _=new I2(this.context,this.state);this.enterRule(_,2,Z.RULE_script);let A;try{this.enterOuterAlt(_,1);{if(this.state=90,this.match(Z.LBRACK),this.state=91,_._trigger=this.identifier(),this.state=92,this.match(Z.COMMA),this.state=93,_._name=this.identifier(),this.state=95,this.errorHandler.sync(this),A=this.tokenStream.LA(1),A===12)this.state=94,this.match(Z.MUL);switch(this.state=97,this.match(Z.RBRACK),this.state=111,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,5,this.context)){case 1:{{if(this.state=98,this.match(Z.LPAREN),this.state=100,this.errorHandler.sync(this),A=this.tokenStream.LA(1),A===35||A===48)this.state=99,this.parameterList();this.state=102,this.match(Z.RPAREN)}switch(this.state=109,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,4,this.context)){case 1:{if(this.state=104,this.match(Z.LPAREN),this.state=106,this.errorHandler.sync(this),A=this.tokenStream.LA(1),A===48)this.state=105,this.typeList();this.state=108,this.match(Z.RPAREN)}break}}break}this.state=116,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while((A&-32)===0&&(1<<A&1357955346)!==0||(A-32&-32)===0&&(1<<A-32&106495)!==0)this.state=113,this.statement(),this.state=118,this.errorHandler.sync(this),A=this.tokenStream.LA(1)}}catch(R){if(R instanceof f)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}parameterList(){let _=new U3(this.context,this.state);this.enterRule(_,4,Z.RULE_parameterList);let A;try{this.enterOuterAlt(_,1);{this.state=119,this.parameter(),this.state=124,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while(A===5)this.state=120,this.match(Z.COMMA),this.state=121,this.parameter(),this.state=126,this.errorHandler.sync(this),A=this.tokenStream.LA(1)}}catch(R){if(R instanceof f)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}parameter(){let _=new q2(this.context,this.state);this.enterRule(_,6,Z.RULE_parameter);let A;try{this.enterOuterAlt(_,1);{if(this.state=127,_._type_=this.tokenStream.LT(1),A=this.tokenStream.LA(1),!(A===35||A===48))_._type_=this.errorHandler.recoverInline(this);else this.errorHandler.reportMatch(this),this.consume();this.state=128,this.match(Z.DOLLAR),this.state=129,this.advancedIdentifier()}}catch(R){if(R instanceof f)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}typeList(){let _=new N3(this.context,this.state);this.enterRule(_,8,Z.RULE_typeList);let A;try{this.enterOuterAlt(_,1);{this.state=131,this.match(Z.IDENTIFIER),this.state=136,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while(A===5)this.state=132,this.match(Z.COMMA),this.state=133,this.match(Z.IDENTIFIER),this.state=138,this.errorHandler.sync(this),A=this.tokenStream.LA(1)}}catch(R){if(R instanceof f)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}statement(){let _=new L0(this.context,this.state);this.enterRule(_,10,Z.RULE_statement);try{switch(this.state=149,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,9,this.context)){case 1:this.enterOuterAlt(_,1),this.state=139,this.blockStatement();break;case 2:this.enterOuterAlt(_,2),this.state=140,this.returnStatement();break;case 3:this.enterOuterAlt(_,3),this.state=141,this.ifStatement();break;case 4:this.enterOuterAlt(_,4),this.state=142,this.whileStatement();break;case 5:this.enterOuterAlt(_,5),this.state=143,this.switchStatement();break;case 6:this.enterOuterAlt(_,6),this.state=144,this.declarationStatement();break;case 7:this.enterOuterAlt(_,7),this.state=145,this.arrayDeclarationStatement();break;case 8:this.enterOuterAlt(_,8),this.state=146,this.assignmentStatement();break;case 9:this.enterOuterAlt(_,9),this.state=147,this.expressionStatement();break;case 10:this.enterOuterAlt(_,10),this.state=148,this.emptyStatement();break}}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}blockStatement(){let _=new Y3(this.context,this.state);this.enterRule(_,12,Z.RULE_blockStatement);let A;try{this.enterOuterAlt(_,1);{this.state=151,this.match(Z.LBRACE),this.state=155,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while((A&-32)===0&&(1<<A&1357955346)!==0||(A-32&-32)===0&&(1<<A-32&106495)!==0)this.state=152,this.statement(),this.state=157,this.errorHandler.sync(this),A=this.tokenStream.LA(1);this.state=158,this.match(Z.RBRACE)}}catch(R){if(R instanceof f)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}returnStatement(){let _=new X3(this.context,this.state);this.enterRule(_,14,Z.RULE_returnStatement);let A;try{this.enterOuterAlt(_,1);{if(this.state=160,this.match(Z.RETURN),this.state=166,this.errorHandler.sync(this),A=this.tokenStream.LA(1),A===1){if(this.state=161,this.match(Z.LPAREN),this.state=163,this.errorHandler.sync(this),A=this.tokenStream.LA(1),(A&-32)===0&&(1<<A&15777794)!==0||(A-32&-32)===0&&(1<<A-32&106493)!==0)this.state=162,this.expressionList();this.state=165,this.match(Z.RPAREN)}this.state=168,this.match(Z.SEMICOLON)}}catch(R){if(R instanceof f)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}ifStatement(){let _=new G3(this.context,this.state);this.enterRule(_,16,Z.RULE_ifStatement);try{switch(this.enterOuterAlt(_,1),this.state=170,this.match(Z.IF),this.state=171,this.match(Z.LPAREN),this.state=172,this.condition(0),this.state=173,this.match(Z.RPAREN),this.state=174,this.statement(),this.state=177,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,13,this.context)){case 1:this.state=175,this.match(Z.ELSE),this.state=176,this.statement();break}}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}whileStatement(){let _=new Q3(this.context,this.state);this.enterRule(_,18,Z.RULE_whileStatement);try{this.enterOuterAlt(_,1),this.state=179,this.match(Z.WHILE),this.state=180,this.match(Z.LPAREN),this.state=181,this.condition(0),this.state=182,this.match(Z.RPAREN),this.state=183,this.statement()}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}switchStatement(){let _=new Z3(this.context,this.state);this.enterRule(_,20,Z.RULE_switchStatement);let A;try{this.enterOuterAlt(_,1);{this.state=185,this.match(Z.SWITCH_TYPE),this.state=186,this.parenthesis(),this.state=187,this.match(Z.LBRACE),this.state=191,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while(A===31)this.state=188,this.switchCase(),this.state=193,this.errorHandler.sync(this),A=this.tokenStream.LA(1);this.state=194,this.match(Z.RBRACE)}}catch(R){if(R instanceof f)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}switchCase(){let _=new W2(this.context,this.state);this.enterRule(_,22,Z.RULE_switchCase);let A;try{this.enterOuterAlt(_,1);{switch(this.state=196,this.match(Z.CASE),this.state=199,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,15,this.context)){case 1:this.state=197,this.match(Z.DEFAULT);break;case 2:this.state=198,this.expressionList();break}this.state=201,this.match(Z.COLON),this.state=205,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while((A&-32)===0&&(1<<A&1357955346)!==0||(A-32&-32)===0&&(1<<A-32&106495)!==0)this.state=202,this.statement(),this.state=207,this.errorHandler.sync(this),A=this.tokenStream.LA(1)}}catch(R){if(R instanceof f)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}declarationStatement(){let _=new $3(this.context,this.state);this.enterRule(_,24,Z.RULE_declarationStatement);let A;try{this.enterOuterAlt(_,1);{if(this.state=208,this.match(Z.DEF_TYPE),this.state=209,this.match(Z.DOLLAR),this.state=210,this.advancedIdentifier(),this.state=213,this.errorHandler.sync(this),A=this.tokenStream.LA(1),A===18)this.state=211,this.match(Z.EQ),this.state=212,this.expression();this.state=215,this.match(Z.SEMICOLON)}}catch(R){if(R instanceof f)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}arrayDeclarationStatement(){let _=new H3(this.context,this.state);this.enterRule(_,26,Z.RULE_arrayDeclarationStatement);try{this.enterOuterAlt(_,1),this.state=217,this.match(Z.DEF_TYPE),this.state=218,this.match(Z.DOLLAR),this.state=219,this.advancedIdentifier(),this.state=220,this.parenthesis(),this.state=221,this.match(Z.SEMICOLON)}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}assignmentStatement(){let _=new F3(this.context,this.state);this.enterRule(_,28,Z.RULE_assignmentStatement);try{this.enterOuterAlt(_,1),this.state=223,this.assignableVariableList(),this.state=224,this.match(Z.EQ),this.state=225,this.expressionList(),this.state=226,this.match(Z.SEMICOLON)}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}expressionStatement(){let _=new J3(this.context,this.state);this.enterRule(_,30,Z.RULE_expressionStatement);try{this.enterOuterAlt(_,1),this.state=228,this.expression(),this.state=229,this.match(Z.SEMICOLON)}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}emptyStatement(){let _=new I3(this.context,this.state);this.enterRule(_,32,Z.RULE_emptyStatement);try{this.enterOuterAlt(_,1),this.state=231,this.match(Z.SEMICOLON)}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}expressionList(){let _=new B0(this.context,this.state);this.enterRule(_,34,Z.RULE_expressionList);let A;try{this.enterOuterAlt(_,1);{this.state=233,this.expression(),this.state=238,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while(A===5)this.state=234,this.match(Z.COMMA),this.state=235,this.expression(),this.state=240,this.errorHandler.sync(this),A=this.tokenStream.LA(1)}}catch(R){if(R instanceof f)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}parenthesis(){let _=new j1(this.context,this.state);this.enterRule(_,36,Z.RULE_parenthesis);try{this.enterOuterAlt(_,1),this.state=241,this.match(Z.LPAREN),this.state=242,this.expression(),this.state=243,this.match(Z.RPAREN)}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}singleExpression(){let _=new S4(this.context,this.state);this.enterRule(_,38,Z.RULE_singleExpression);try{this.enterOuterAlt(_,1),this.state=245,this.expression(),this.state=246,this.match(Z.EOF)}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}expression(){let _=new l(this.context,this.state);this.enterRule(_,40,Z.RULE_expression);try{switch(this.state=258,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,19,this.context)){case 1:_=new m4(_),this.enterOuterAlt(_,1),this.state=248,this.parenthesis();break;case 2:_=new x4(_),this.enterOuterAlt(_,2),this.state=249,this.calc();break;case 3:_=new g4(_),this.enterOuterAlt(_,3),this.state=250,this.call();break;case 4:_=new l4(_),this.enterOuterAlt(_,4),this.state=251,this.localVariable();break;case 5:_=new d4(_),this.enterOuterAlt(_,5),this.state=252,this.localArrayVariable();break;case 6:_=new T4(_),this.enterOuterAlt(_,6),this.state=253,this.gameVariable();break;case 7:_=new y4(_),this.enterOuterAlt(_,7),this.state=254,this.constantVariable();break;case 8:_=new c4(_),this.enterOuterAlt(_,8),this.state=255,this.literal();break;case 9:_=new a4(_),this.enterOuterAlt(_,9),this.state=256,this.joinedString();break;case 10:_=new s4(_),this.enterOuterAlt(_,10),this.state=257,this.identifier();break}}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}condition(_){if(_===void 0)_=0;let A=this.context,R=this.state,U=new R0(this.context,R),N=U,Y=42;this.enterRecursionRule(U,42,Z.RULE_condition,_);let X;try{let Q;this.enterOuterAlt(U,1);{switch(this.state=266,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,20,this.context)){case 1:U=new n4(U),this.context=U,N=U,this.state=261,this.match(Z.LPAREN),this.state=262,this.condition(0),this.state=263,this.match(Z.RPAREN);break;case 2:U=new o4(U),this.context=U,N=U,this.state=265,this.expression();break}this.context.stop=this.tokenStream.LT(-1),this.state=282,this.errorHandler.sync(this),Q=this.interpreter.adaptivePredict(this.tokenStream,22,this.context);while(Q!==2&&Q!==P.INVALID_ALT_NUMBER){if(Q===1){if(this.parseListeners!=null)this.triggerExitRuleEvent();switch(N=U,this.state=280,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,21,this.context)){case 1:{if(U=new r1(new R0(A,R)),this.pushNewRecursionContext(U,Y,Z.RULE_condition),this.state=268,!this.precpred(this.context,5))throw this.createFailedPredicateException("this.precpred(this.context, 5)");if(this.state=269,U._op=this.tokenStream.LT(1),X=this.tokenStream.LA(1),!((X&-32)===0&&(1<<X&251658240)!==0))U._op=this.errorHandler.recoverInline(this);else this.errorHandler.reportMatch(this),this.consume();this.state=270,this.condition(6)}break;case 2:{if(U=new r1(new R0(A,R)),this.pushNewRecursionContext(U,Y,Z.RULE_condition),this.state=271,!this.precpred(this.context,4))throw this.createFailedPredicateException("this.precpred(this.context, 4)");if(this.state=272,U._op=this.tokenStream.LT(1),X=this.tokenStream.LA(1),!(X===18||X===19))U._op=this.errorHandler.recoverInline(this);else this.errorHandler.reportMatch(this),this.consume();this.state=273,this.condition(5)}break;case 3:{if(U=new r1(new R0(A,R)),this.pushNewRecursionContext(U,Y,Z.RULE_condition),this.state=274,!this.precpred(this.context,3))throw this.createFailedPredicateException("this.precpred(this.context, 3)");this.state=275,U._op=this.match(Z.AND),this.state=276,this.condition(4)}break;case 4:{if(U=new r1(new R0(A,R)),this.pushNewRecursionContext(U,Y,Z.RULE_condition),this.state=277,!this.precpred(this.context,2))throw this.createFailedPredicateException("this.precpred(this.context, 2)");this.state=278,U._op=this.match(Z.OR),this.state=279,this.condition(3)}break}}this.state=284,this.errorHandler.sync(this),Q=this.interpreter.adaptivePredict(this.tokenStream,22,this.context)}}}catch(Q){if(Q instanceof f)this.errorHandler.reportError(this,Q),this.errorHandler.recover(this,Q);else throw Q}finally{this.unrollRecursionContexts(A)}return U}calc(){let _=new q3(this.context,this.state);this.enterRule(_,44,Z.RULE_calc);try{this.enterOuterAlt(_,1),this.state=285,this.match(Z.CALC),this.state=286,this.match(Z.LPAREN),this.state=287,this.arithmetic(0),this.state=288,this.match(Z.RPAREN)}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}arithmetic(_){if(_===void 0)_=0;let A=this.context,R=this.state,U=new X0(this.context,R),N=U,Y=46;this.enterRecursionRule(U,46,Z.RULE_arithmetic,_);let X;try{let Q;this.enterOuterAlt(U,1);{switch(this.state=296,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,23,this.context)){case 1:U=new p4(U),this.context=U,N=U,this.state=291,this.match(Z.LPAREN),this.state=292,this.arithmetic(0),this.state=293,this.match(Z.RPAREN);break;case 2:U=new i4(U),this.context=U,N=U,this.state=295,this.expression();break}this.context.stop=this.tokenStream.LT(-1),this.state=312,this.errorHandler.sync(this),Q=this.interpreter.adaptivePredict(this.tokenStream,25,this.context);while(Q!==2&&Q!==P.INVALID_ALT_NUMBER){if(Q===1){if(this.parseListeners!=null)this.triggerExitRuleEvent();switch(N=U,this.state=310,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,24,this.context)){case 1:{if(U=new e1(new X0(A,R)),this.pushNewRecursionContext(U,Y,Z.RULE_arithmetic),this.state=298,!this.precpred(this.context,5))throw this.createFailedPredicateException("this.precpred(this.context, 5)");if(this.state=299,U._op=this.tokenStream.LT(1),X=this.tokenStream.LA(1),!((X&-32)===0&&(1<<X&45056)!==0))U._op=this.errorHandler.recoverInline(this);else this.errorHandler.reportMatch(this),this.consume();this.state=300,this.arithmetic(6)}break;case 2:{if(U=new e1(new X0(A,R)),this.pushNewRecursionContext(U,Y,Z.RULE_arithmetic),this.state=301,!this.precpred(this.context,4))throw this.createFailedPredicateException("this.precpred(this.context, 4)");if(this.state=302,U._op=this.tokenStream.LT(1),X=this.tokenStream.LA(1),!(X===10||X===11))U._op=this.errorHandler.recoverInline(this);else this.errorHandler.reportMatch(this),this.consume();this.state=303,this.arithmetic(5)}break;case 3:{if(U=new e1(new X0(A,R)),this.pushNewRecursionContext(U,Y,Z.RULE_arithmetic),this.state=304,!this.precpred(this.context,3))throw this.createFailedPredicateException("this.precpred(this.context, 3)");this.state=305,U._op=this.match(Z.AND),this.state=306,this.arithmetic(4)}break;case 4:{if(U=new e1(new X0(A,R)),this.pushNewRecursionContext(U,Y,Z.RULE_arithmetic),this.state=307,!this.precpred(this.context,2))throw this.createFailedPredicateException("this.precpred(this.context, 2)");this.state=308,U._op=this.match(Z.OR),this.state=309,this.arithmetic(3)}break}}this.state=314,this.errorHandler.sync(this),Q=this.interpreter.adaptivePredict(this.tokenStream,25,this.context)}}}catch(Q){if(Q instanceof f)this.errorHandler.reportError(this,Q),this.errorHandler.recover(this,Q);else throw Q}finally{this.unrollRecursionContexts(A)}return U}call(){let _=new f1(this.context,this.state);this.enterRule(_,48,Z.RULE_call);let A;try{switch(this.state=353,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,33,this.context)){case 1:_=new A3(_),this.enterOuterAlt(_,1);{if(this.state=315,this.identifier(),this.state=316,this.match(Z.MUL),this.state=317,this.match(Z.LPAREN),this.state=319,this.errorHandler.sync(this),A=this.tokenStream.LA(1),(A&-32)===0&&(1<<A&15777794)!==0||(A-32&-32)===0&&(1<<A-32&106493)!==0)this.state=318,this.expressionList();if(this.state=321,this.match(Z.RPAREN),this.state=322,this.match(Z.LPAREN),this.state=324,this.errorHandler.sync(this),A=this.tokenStream.LA(1),(A&-32)===0&&(1<<A&15777794)!==0||(A-32&-32)===0&&(1<<A-32&106493)!==0)this.state=323,this.expressionList();this.state=326,this.match(Z.RPAREN)}break;case 2:_=new A3(_),this.enterOuterAlt(_,2);{if(this.state=328,this.identifier(),this.state=329,this.match(Z.LPAREN),this.state=331,this.errorHandler.sync(this),A=this.tokenStream.LA(1),(A&-32)===0&&(1<<A&15777794)!==0||(A-32&-32)===0&&(1<<A-32&106493)!==0)this.state=330,this.expressionList();this.state=333,this.match(Z.RPAREN)}break;case 3:switch(_=new t4(_),this.enterOuterAlt(_,3),this.state=335,this.match(Z.TILDE),this.state=336,this.identifier(),this.state=342,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,30,this.context)){case 1:{if(this.state=337,this.match(Z.LPAREN),this.state=339,this.errorHandler.sync(this),A=this.tokenStream.LA(1),(A&-32)===0&&(1<<A&15777794)!==0||(A-32&-32)===0&&(1<<A-32&106493)!==0)this.state=338,this.expressionList();this.state=341,this.match(Z.RPAREN)}break}break;case 4:switch(_=new r4(_),this.enterOuterAlt(_,4),this.state=344,this.match(Z.AT),this.state=345,this.identifier(),this.state=351,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,32,this.context)){case 1:{if(this.state=346,this.match(Z.LPAREN),this.state=348,this.errorHandler.sync(this),A=this.tokenStream.LA(1),(A&-32)===0&&(1<<A&15777794)!==0||(A-32&-32)===0&&(1<<A-32&106493)!==0)this.state=347,this.expressionList();this.state=350,this.match(Z.RPAREN)}break}break}}catch(R){if(R instanceof f)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}clientScript(){let _=new e4(this.context,this.state);this.enterRule(_,50,Z.RULE_clientScript);let A;try{this.enterOuterAlt(_,1);{if(this.state=355,this.identifier(),this.state=361,this.errorHandler.sync(this),A=this.tokenStream.LA(1),A===1){if(this.state=356,this.match(Z.LPAREN),this.state=358,this.errorHandler.sync(this),A=this.tokenStream.LA(1),(A&-32)===0&&(1<<A&15777794)!==0||(A-32&-32)===0&&(1<<A-32&106493)!==0)this.state=357,_._args=this.expressionList();this.state=360,this.match(Z.RPAREN)}if(this.state=368,this.errorHandler.sync(this),A=this.tokenStream.LA(1),A===8){if(this.state=363,this.match(Z.LBRACE),this.state=365,this.errorHandler.sync(this),A=this.tokenStream.LA(1),(A&-32)===0&&(1<<A&15777794)!==0||(A-32&-32)===0&&(1<<A-32&106493)!==0)this.state=364,_._triggers=this.expressionList();this.state=367,this.match(Z.RBRACE)}this.state=370,this.match(Z.EOF)}}catch(R){if(R instanceof f)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}assignableVariableList(){let _=new W3(this.context,this.state);this.enterRule(_,52,Z.RULE_assignableVariableList);let A;try{this.enterOuterAlt(_,1);{this.state=372,this.assignableVariable(),this.state=377,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while(A===5)this.state=373,this.match(Z.COMMA),this.state=374,this.assignableVariable(),this.state=379,this.errorHandler.sync(this),A=this.tokenStream.LA(1)}}catch(R){if(R instanceof f)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}assignableVariable(){let _=new z2(this.context,this.state);this.enterRule(_,54,Z.RULE_assignableVariable);try{switch(this.state=383,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,39,this.context)){case 1:this.enterOuterAlt(_,1),this.state=380,this.localVariable();break;case 2:this.enterOuterAlt(_,2),this.state=381,this.localArrayVariable();break;case 3:this.enterOuterAlt(_,3),this.state=382,this.gameVariable();break}}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}localVariable(){let _=new K2(this.context,this.state);this.enterRule(_,56,Z.RULE_localVariable);try{this.enterOuterAlt(_,1),this.state=385,this.match(Z.DOLLAR),this.state=386,this.advancedIdentifier()}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}localArrayVariable(){let _=new L2(this.context,this.state);this.enterRule(_,58,Z.RULE_localArrayVariable);try{this.enterOuterAlt(_,1),this.state=388,this.match(Z.DOLLAR),this.state=389,this.advancedIdentifier(),this.state=390,this.parenthesis()}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}gameVariable(){let _=new B2(this.context,this.state);this.enterRule(_,60,Z.RULE_gameVariable);try{switch(this.state=396,this.errorHandler.sync(this),this.tokenStream.LA(1)){case Z.MOD:this.enterOuterAlt(_,1),this.state=392,this.match(Z.MOD),this.state=393,this.advancedIdentifier();break;case Z.DOTMOD:this.enterOuterAlt(_,2),this.state=394,this.match(Z.DOTMOD),this.state=395,this.advancedIdentifier();break;default:throw new Q1(this)}}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}constantVariable(){let _=new z3(this.context,this.state);this.enterRule(_,62,Z.RULE_constantVariable);try{this.enterOuterAlt(_,1),this.state=398,this.match(Z.CARET),this.state=399,this.advancedIdentifier()}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}literal(){let _=new g0(this.context,this.state);this.enterRule(_,64,Z.RULE_literal);try{switch(this.state=408,this.errorHandler.sync(this),this.tokenStream.LA(1)){case Z.INTEGER_LITERAL:_=new R3(_),this.enterOuterAlt(_,1),this.state=401,this.match(Z.INTEGER_LITERAL);break;case Z.HEX_LITERAL:_=new R3(_),this.enterOuterAlt(_,2),this.state=402,this.match(Z.HEX_LITERAL);break;case Z.COORD_LITERAL:_=new _5(_),this.enterOuterAlt(_,3),this.state=403,this.match(Z.COORD_LITERAL);break;case Z.BOOLEAN_LITERAL:_=new A5(_),this.enterOuterAlt(_,4),this.state=404,this.match(Z.BOOLEAN_LITERAL);break;case Z.CHAR_LITERAL:_=new R5(_),this.enterOuterAlt(_,5),this.state=405,this.match(Z.CHAR_LITERAL);break;case Z.NULL_LITERAL:_=new U5(_),this.enterOuterAlt(_,6),this.state=406,this.match(Z.NULL_LITERAL);break;case Z.QUOTE_OPEN:_=new N5(_),this.enterOuterAlt(_,7),this.state=407,this.stringLiteral();break;default:throw new Q1(this)}}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}stringLiteral(){let _=new K3(this.context,this.state);this.enterRule(_,66,Z.RULE_stringLiteral);let A;try{this.enterOuterAlt(_,1);{this.state=410,this.match(Z.QUOTE_OPEN),this.state=414,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while(A===51)this.state=411,this.stringLiteralContent(),this.state=416,this.errorHandler.sync(this),A=this.tokenStream.LA(1);this.state=417,this.match(Z.QUOTE_CLOSE)}}catch(R){if(R instanceof f)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}stringLiteralContent(){let _=new p0(this.context,this.state);this.enterRule(_,68,Z.RULE_stringLiteralContent);try{this.enterOuterAlt(_,1),this.state=419,this.match(Z.STRING_TEXT)}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}joinedString(){let _=new L3(this.context,this.state);this.enterRule(_,70,Z.RULE_joinedString);let A;try{this.enterOuterAlt(_,1);{this.state=421,this.match(Z.QUOTE_OPEN),this.state=428,this.errorHandler.sync(this),A=this.tokenStream.LA(1);while((A-51&-32)===0&&(1<<A-51&63)!==0){switch(this.state=426,this.errorHandler.sync(this),this.tokenStream.LA(1)){case Z.STRING_TEXT:this.state=422,this.stringLiteralContent();break;case Z.STRING_TAG:case Z.STRING_CLOSE_TAG:case Z.STRING_PARTIAL_TAG:this.state=423,this.stringTag();break;case Z.STRING_P_TAG:this.state=424,this.stringPTag();break;case Z.STRING_EXPR_START:this.state=425,this.stringExpression();break;default:throw new Q1(this)}this.state=430,this.errorHandler.sync(this),A=this.tokenStream.LA(1)}this.state=431,this.match(Z.QUOTE_CLOSE)}}catch(R){if(R instanceof f)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}stringTag(){let _=new O1(this.context,this.state);this.enterRule(_,72,Z.RULE_stringTag);let A;try{if(this.enterOuterAlt(_,1),this.state=433,A=this.tokenStream.LA(1),!((A-52&-32)===0&&(1<<A-52&7)!==0))this.errorHandler.recoverInline(this);else this.errorHandler.reportMatch(this),this.consume()}catch(R){if(R instanceof f)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}stringPTag(){let _=new M1(this.context,this.state);this.enterRule(_,74,Z.RULE_stringPTag);try{this.enterOuterAlt(_,1),this.state=435,this.match(Z.STRING_P_TAG)}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}stringExpression(){let _=new h1(this.context,this.state);this.enterRule(_,76,Z.RULE_stringExpression);try{this.enterOuterAlt(_,1),this.state=437,this.match(Z.STRING_EXPR_START),this.state=438,this.expression(),this.state=439,this.match(Z.STRING_EXPR_END)}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}identifier(){let _=new O0(this.context,this.state);this.enterRule(_,78,Z.RULE_identifier);let A;try{if(this.enterOuterAlt(_,1),this.state=441,A=this.tokenStream.LA(1),!((A-32&-32)===0&&(1<<A-32&71609)!==0))this.errorHandler.recoverInline(this);else this.errorHandler.reportMatch(this),this.consume()}catch(R){if(R instanceof f)this.errorHandler.reportError(this,R),this.errorHandler.recover(this,R);else throw R}finally{this.exitRule()}return _}advancedIdentifier(){let _=new l0(this.context,this.state);this.enterRule(_,80,Z.RULE_advancedIdentifier);try{switch(this.state=449,this.errorHandler.sync(this),this.tokenStream.LA(1)){case Z.DEFAULT:case Z.TYPE_ARRAY:case Z.DEF_TYPE:case Z.SWITCH_TYPE:case Z.HEX_LITERAL:case Z.COORD_LITERAL:case Z.MAPZONE_LITERAL:case Z.BOOLEAN_LITERAL:case Z.NULL_LITERAL:case Z.IDENTIFIER:this.enterOuterAlt(_,1),this.state=443,this.identifier();break;case Z.IF:this.enterOuterAlt(_,2),this.state=444,this.match(Z.IF);break;case Z.ELSE:this.enterOuterAlt(_,3),this.state=445,this.match(Z.ELSE);break;case Z.WHILE:this.enterOuterAlt(_,4),this.state=446,this.match(Z.WHILE);break;case Z.RETURN:this.enterOuterAlt(_,5),this.state=447,this.match(Z.RETURN);break;case Z.CALC:this.enterOuterAlt(_,6),this.state=448,this.match(Z.CALC);break;default:throw new Q1(this)}}catch(A){if(A instanceof f)this.errorHandler.reportError(this,A),this.errorHandler.recover(this,A);else throw A}finally{this.exitRule()}return _}sempred(_,A,R){switch(A){case 21:return this.condition_sempred(_,R);case 23:return this.arithmetic_sempred(_,R)}return!0}condition_sempred(_,A){switch(A){case 0:return this.precpred(this.context,5);case 1:return this.precpred(this.context,4);case 2:return this.precpred(this.context,3);case 3:return this.precpred(this.context,2)}return!0}arithmetic_sempred(_,A){switch(A){case 4:return this.precpred(this.context,5);case 5:return this.precpred(this.context,4);case 6:return this.precpred(this.context,3);case 7:return this.precpred(this.context,2)}return!0}static _serializedATN=[4,1,57,452,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,39,2,40,7,40,1,0,5,0,84,8,0,10,0,12,0,87,9,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,3,1,96,8,1,1,1,1,1,1,1,3,1,101,8,1,1,1,1,1,1,1,1,1,3,1,107,8,1,1,1,3,1,110,8,1,3,1,112,8,1,1,1,5,1,115,8,1,10,1,12,1,118,9,1,1,2,1,2,1,2,5,2,123,8,2,10,2,12,2,126,9,2,1,3,1,3,1,3,1,3,1,4,1,4,1,4,5,4,135,8,4,10,4,12,4,138,9,4,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,3,5,150,8,5,1,6,1,6,5,6,154,8,6,10,6,12,6,157,9,6,1,6,1,6,1,7,1,7,1,7,3,7,164,8,7,1,7,3,7,167,8,7,1,7,1,7,1,8,1,8,1,8,1,8,1,8,1,8,1,8,3,8,178,8,8,1,9,1,9,1,9,1,9,1,9,1,9,1,10,1,10,1,10,1,10,5,10,190,8,10,10,10,12,10,193,9,10,1,10,1,10,1,11,1,11,1,11,3,11,200,8,11,1,11,1,11,5,11,204,8,11,10,11,12,11,207,9,11,1,12,1,12,1,12,1,12,1,12,3,12,214,8,12,1,12,1,12,1,13,1,13,1,13,1,13,1,13,1,13,1,14,1,14,1,14,1,14,1,14,1,15,1,15,1,15,1,16,1,16,1,17,1,17,1,17,5,17,237,8,17,10,17,12,17,240,9,17,1,18,1,18,1,18,1,18,1,19,1,19,1,19,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,3,20,259,8,20,1,21,1,21,1,21,1,21,1,21,1,21,3,21,267,8,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,5,21,281,8,21,10,21,12,21,284,9,21,1,22,1,22,1,22,1,22,1,22,1,23,1,23,1,23,1,23,1,23,1,23,3,23,297,8,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,5,23,311,8,23,10,23,12,23,314,9,23,1,24,1,24,1,24,1,24,3,24,320,8,24,1,24,1,24,1,24,3,24,325,8,24,1,24,1,24,1,24,1,24,1,24,3,24,332,8,24,1,24,1,24,1,24,1,24,1,24,1,24,3,24,340,8,24,1,24,3,24,343,8,24,1,24,1,24,1,24,1,24,3,24,349,8,24,1,24,3,24,352,8,24,3,24,354,8,24,1,25,1,25,1,25,3,25,359,8,25,1,25,3,25,362,8,25,1,25,1,25,3,25,366,8,25,1,25,3,25,369,8,25,1,25,1,25,1,26,1,26,1,26,5,26,376,8,26,10,26,12,26,379,9,26,1,27,1,27,1,27,3,27,384,8,27,1,28,1,28,1,28,1,29,1,29,1,29,1,29,1,30,1,30,1,30,1,30,3,30,397,8,30,1,31,1,31,1,31,1,32,1,32,1,32,1,32,1,32,1,32,1,32,3,32,409,8,32,1,33,1,33,5,33,413,8,33,10,33,12,33,416,9,33,1,33,1,33,1,34,1,34,1,35,1,35,1,35,1,35,1,35,5,35,427,8,35,10,35,12,35,430,9,35,1,35,1,35,1,36,1,36,1,37,1,37,1,38,1,38,1,38,1,38,1,39,1,39,1,40,1,40,1,40,1,40,1,40,1,40,3,40,450,8,40,1,40,0,2,42,46,41,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,0,7,2,0,35,35,48,48,1,0,24,27,1,0,18,19,2,0,12,13,15,15,1,0,10,11,1,0,52,54,5,0,32,32,35,37,39,42,44,44,48,48,490,0,85,1,0,0,0,2,90,1,0,0,0,4,119,1,0,0,0,6,127,1,0,0,0,8,131,1,0,0,0,10,149,1,0,0,0,12,151,1,0,0,0,14,160,1,0,0,0,16,170,1,0,0,0,18,179,1,0,0,0,20,185,1,0,0,0,22,196,1,0,0,0,24,208,1,0,0,0,26,217,1,0,0,0,28,223,1,0,0,0,30,228,1,0,0,0,32,231,1,0,0,0,34,233,1,0,0,0,36,241,1,0,0,0,38,245,1,0,0,0,40,258,1,0,0,0,42,266,1,0,0,0,44,285,1,0,0,0,46,296,1,0,0,0,48,353,1,0,0,0,50,355,1,0,0,0,52,372,1,0,0,0,54,383,1,0,0,0,56,385,1,0,0,0,58,388,1,0,0,0,60,396,1,0,0,0,62,398,1,0,0,0,64,408,1,0,0,0,66,410,1,0,0,0,68,419,1,0,0,0,70,421,1,0,0,0,72,433,1,0,0,0,74,435,1,0,0,0,76,437,1,0,0,0,78,441,1,0,0,0,80,449,1,0,0,0,82,84,3,2,1,0,83,82,1,0,0,0,84,87,1,0,0,0,85,83,1,0,0,0,85,86,1,0,0,0,86,88,1,0,0,0,87,85,1,0,0,0,88,89,5,0,0,1,89,1,1,0,0,0,90,91,5,6,0,0,91,92,3,78,39,0,92,93,5,5,0,0,93,95,3,78,39,0,94,96,5,12,0,0,95,94,1,0,0,0,95,96,1,0,0,0,96,97,1,0,0,0,97,111,5,7,0,0,98,100,5,1,0,0,99,101,3,4,2,0,100,99,1,0,0,0,100,101,1,0,0,0,101,102,1,0,0,0,102,103,5,2,0,0,103,109,1,0,0,0,104,106,5,1,0,0,105,107,3,8,4,0,106,105,1,0,0,0,106,107,1,0,0,0,107,108,1,0,0,0,108,110,5,2,0,0,109,104,1,0,0,0,109,110,1,0,0,0,110,112,1,0,0,0,111,98,1,0,0,0,111,112,1,0,0,0,112,116,1,0,0,0,113,115,3,10,5,0,114,113,1,0,0,0,115,118,1,0,0,0,116,114,1,0,0,0,116,117,1,0,0,0,117,3,1,0,0,0,118,116,1,0,0,0,119,124,3,6,3,0,120,121,5,5,0,0,121,123,3,6,3,0,122,120,1,0,0,0,123,126,1,0,0,0,124,122,1,0,0,0,124,125,1,0,0,0,125,5,1,0,0,0,126,124,1,0,0,0,127,128,7,0,0,0,128,129,5,20,0,0,129,130,3,80,40,0,130,7,1,0,0,0,131,136,5,48,0,0,132,133,5,5,0,0,133,135,5,48,0,0,134,132,1,0,0,0,135,138,1,0,0,0,136,134,1,0,0,0,136,137,1,0,0,0,137,9,1,0,0,0,138,136,1,0,0,0,139,150,3,12,6,0,140,150,3,14,7,0,141,150,3,16,8,0,142,150,3,18,9,0,143,150,3,20,10,0,144,150,3,24,12,0,145,150,3,26,13,0,146,150,3,28,14,0,147,150,3,30,15,0,148,150,3,32,16,0,149,139,1,0,0,0,149,140,1,0,0,0,149,141,1,0,0,0,149,142,1,0,0,0,149,143,1,0,0,0,149,144,1,0,0,0,149,145,1,0,0,0,149,146,1,0,0,0,149,147,1,0,0,0,149,148,1,0,0,0,150,11,1,0,0,0,151,155,5,8,0,0,152,154,3,10,5,0,153,152,1,0,0,0,154,157,1,0,0,0,155,153,1,0,0,0,155,156,1,0,0,0,156,158,1,0,0,0,157,155,1,0,0,0,158,159,5,9,0,0,159,13,1,0,0,0,160,166,5,33,0,0,161,163,5,1,0,0,162,164,3,34,17,0,163,162,1,0,0,0,163,164,1,0,0,0,164,165,1,0,0,0,165,167,5,2,0,0,166,161,1,0,0,0,166,167,1,0,0,0,167,168,1,0,0,0,168,169,5,4,0,0,169,15,1,0,0,0,170,171,5,28,0,0,171,172,5,1,0,0,172,173,3,42,21,0,173,174,5,2,0,0,174,177,3,10,5,0,175,176,5,29,0,0,176,178,3,10,5,0,177,175,1,0,0,0,177,178,1,0,0,0,178,17,1,0,0,0,179,180,5,30,0,0,180,181,5,1,0,0,181,182,3,42,21,0,182,183,5,2,0,0,183,184,3,10,5,0,184,19,1,0,0,0,185,186,5,37,0,0,186,187,3,36,18,0,187,191,5,8,0,0,188,190,3,22,11,0,189,188,1,0,0,0,190,193,1,0,0,0,191,189,1,0,0,0,191,192,1,0,0,0,192,194,1,0,0,0,193,191,1,0,0,0,194,195,5,9,0,0,195,21,1,0,0,0,196,199,5,31,0,0,197,200,5,32,0,0,198,200,3,34,17,0,199,197,1,0,0,0,199,198,1,0,0,0,200,201,1,0,0,0,201,205,5,3,0,0,202,204,3,10,5,0,203,202,1,0,0,0,204,207,1,0,0,0,205,203,1,0,0,0,205,206,1,0,0,0,206,23,1,0,0,0,207,205,1,0,0,0,208,209,5,36,0,0,209,210,5,20,0,0,210,213,3,80,40,0,211,212,5,18,0,0,212,214,3,40,20,0,213,211,1,0,0,0,213,214,1,0,0,0,214,215,1,0,0,0,215,216,5,4,0,0,216,25,1,0,0,0,217,218,5,36,0,0,218,219,5,20,0,0,219,220,3,80,40,0,220,221,3,36,18,0,221,222,5,4,0,0,222,27,1,0,0,0,223,224,3,52,26,0,224,225,5,18,0,0,225,226,3,34,17,0,226,227,5,4,0,0,227,29,1,0,0,0,228,229,3,40,20,0,229,230,5,4,0,0,230,31,1,0,0,0,231,232,5,4,0,0,232,33,1,0,0,0,233,238,3,40,20,0,234,235,5,5,0,0,235,237,3,40,20,0,236,234,1,0,0,0,237,240,1,0,0,0,238,236,1,0,0,0,238,239,1,0,0,0,239,35,1,0,0,0,240,238,1,0,0,0,241,242,5,1,0,0,242,243,3,40,20,0,243,244,5,2,0,0,244,37,1,0,0,0,245,246,3,40,20,0,246,247,5,0,0,1,247,39,1,0,0,0,248,259,3,36,18,0,249,259,3,44,22,0,250,259,3,48,24,0,251,259,3,56,28,0,252,259,3,58,29,0,253,259,3,60,30,0,254,259,3,62,31,0,255,259,3,64,32,0,256,259,3,70,35,0,257,259,3,78,39,0,258,248,1,0,0,0,258,249,1,0,0,0,258,250,1,0,0,0,258,251,1,0,0,0,258,252,1,0,0,0,258,253,1,0,0,0,258,254,1,0,0,0,258,255,1,0,0,0,258,256,1,0,0,0,258,257,1,0,0,0,259,41,1,0,0,0,260,261,6,21,-1,0,261,262,5,1,0,0,262,263,3,42,21,0,263,264,5,2,0,0,264,267,1,0,0,0,265,267,3,40,20,0,266,260,1,0,0,0,266,265,1,0,0,0,267,282,1,0,0,0,268,269,10,5,0,0,269,270,7,1,0,0,270,281,3,42,21,6,271,272,10,4,0,0,272,273,7,2,0,0,273,281,3,42,21,5,274,275,10,3,0,0,275,276,5,16,0,0,276,281,3,42,21,4,277,278,10,2,0,0,278,279,5,17,0,0,279,281,3,42,21,3,280,268,1,0,0,0,280,271,1,0,0,0,280,274,1,0,0,0,280,277,1,0,0,0,281,284,1,0,0,0,282,280,1,0,0,0,282,283,1,0,0,0,283,43,1,0,0,0,284,282,1,0,0,0,285,286,5,34,0,0,286,287,5,1,0,0,287,288,3,46,23,0,288,289,5,2,0,0,289,45,1,0,0,0,290,291,6,23,-1,0,291,292,5,1,0,0,292,293,3,46,23,0,293,294,5,2,0,0,294,297,1,0,0,0,295,297,3,40,20,0,296,290,1,0,0,0,296,295,1,0,0,0,297,312,1,0,0,0,298,299,10,5,0,0,299,300,7,3,0,0,300,311,3,46,23,6,301,302,10,4,0,0,302,303,7,4,0,0,303,311,3,46,23,5,304,305,10,3,0,0,305,306,5,16,0,0,306,311,3,46,23,4,307,308,10,2,0,0,308,309,5,17,0,0,309,311,3,46,23,3,310,298,1,0,0,0,310,301,1,0,0,0,310,304,1,0,0,0,310,307,1,0,0,0,311,314,1,0,0,0,312,310,1,0,0,0,312,313,1,0,0,0,313,47,1,0,0,0,314,312,1,0,0,0,315,316,3,78,39,0,316,317,5,12,0,0,317,319,5,1,0,0,318,320,3,34,17,0,319,318,1,0,0,0,319,320,1,0,0,0,320,321,1,0,0,0,321,322,5,2,0,0,322,324,5,1,0,0,323,325,3,34,17,0,324,323,1,0,0,0,324,325,1,0,0,0,325,326,1,0,0,0,326,327,5,2,0,0,327,354,1,0,0,0,328,329,3,78,39,0,329,331,5,1,0,0,330,332,3,34,17,0,331,330,1,0,0,0,331,332,1,0,0,0,332,333,1,0,0,0,333,334,5,2,0,0,334,354,1,0,0,0,335,336,5,22,0,0,336,342,3,78,39,0,337,339,5,1,0,0,338,340,3,34,17,0,339,338,1,0,0,0,339,340,1,0,0,0,340,341,1,0,0,0,341,343,5,2,0,0,342,337,1,0,0,0,342,343,1,0,0,0,343,354,1,0,0,0,344,345,5,23,0,0,345,351,3,78,39,0,346,348,5,1,0,0,347,349,3,34,17,0,348,347,1,0,0,0,348,349,1,0,0,0,349,350,1,0,0,0,350,352,5,2,0,0,351,346,1,0,0,0,351,352,1,0,0,0,352,354,1,0,0,0,353,315,1,0,0,0,353,328,1,0,0,0,353,335,1,0,0,0,353,344,1,0,0,0,354,49,1,0,0,0,355,361,3,78,39,0,356,358,5,1,0,0,357,359,3,34,17,0,358,357,1,0,0,0,358,359,1,0,0,0,359,360,1,0,0,0,360,362,5,2,0,0,361,356,1,0,0,0,361,362,1,0,0,0,362,368,1,0,0,0,363,365,5,8,0,0,364,366,3,34,17,0,365,364,1,0,0,0,365,366,1,0,0,0,366,367,1,0,0,0,367,369,5,9,0,0,368,363,1,0,0,0,368,369,1,0,0,0,369,370,1,0,0,0,370,371,5,0,0,1,371,51,1,0,0,0,372,377,3,54,27,0,373,374,5,5,0,0,374,376,3,54,27,0,375,373,1,0,0,0,376,379,1,0,0,0,377,375,1,0,0,0,377,378,1,0,0,0,378,53,1,0,0,0,379,377,1,0,0,0,380,384,3,56,28,0,381,384,3,58,29,0,382,384,3,60,30,0,383,380,1,0,0,0,383,381,1,0,0,0,383,382,1,0,0,0,384,55,1,0,0,0,385,386,5,20,0,0,386,387,3,80,40,0,387,57,1,0,0,0,388,389,5,20,0,0,389,390,3,80,40,0,390,391,3,36,18,0,391,59,1,0,0,0,392,393,5,15,0,0,393,397,3,80,40,0,394,395,5,14,0,0,395,397,3,80,40,0,396,392,1,0,0,0,396,394,1,0,0,0,397,61,1,0,0,0,398,399,5,21,0,0,399,400,3,80,40,0,400,63,1,0,0,0,401,409,5,38,0,0,402,409,5,39,0,0,403,409,5,40,0,0,404,409,5,42,0,0,405,409,5,43,0,0,406,409,5,44,0,0,407,409,3,66,33,0,408,401,1,0,0,0,408,402,1,0,0,0,408,403,1,0,0,0,408,404,1,0,0,0,408,405,1,0,0,0,408,406,1,0,0,0,408,407,1,0,0,0,409,65,1,0,0,0,410,414,5,47,0,0,411,413,3,68,34,0,412,411,1,0,0,0,413,416,1,0,0,0,414,412,1,0,0,0,414,415,1,0,0,0,415,417,1,0,0,0,416,414,1,0,0,0,417,418,5,50,0,0,418,67,1,0,0,0,419,420,5,51,0,0,420,69,1,0,0,0,421,428,5,47,0,0,422,427,3,68,34,0,423,427,3,72,36,0,424,427,3,74,37,0,425,427,3,76,38,0,426,422,1,0,0,0,426,423,1,0,0,0,426,424,1,0,0,0,426,425,1,0,0,0,427,430,1,0,0,0,428,426,1,0,0,0,428,429,1,0,0,0,429,431,1,0,0,0,430,428,1,0,0,0,431,432,5,50,0,0,432,71,1,0,0,0,433,434,7,5,0,0,434,73,1,0,0,0,435,436,5,55,0,0,436,75,1,0,0,0,437,438,5,56,0,0,438,439,3,40,20,0,439,440,5,57,0,0,440,77,1,0,0,0,441,442,7,6,0,0,442,79,1,0,0,0,443,450,3,78,39,0,444,450,5,28,0,0,445,450,5,29,0,0,446,450,5,30,0,0,447,450,5,33,0,0,448,450,5,34,0,0,449,443,1,0,0,0,449,444,1,0,0,0,449,445,1,0,0,0,449,446,1,0,0,0,449,447,1,0,0,0,449,448,1,0,0,0,450,81,1,0,0,0,46,85,95,100,106,109,111,116,124,136,149,155,163,166,177,191,199,205,213,238,258,266,280,282,296,310,312,319,324,331,339,342,348,351,353,358,361,365,368,377,383,396,408,414,426,428,449];static __ATN;static get _ATN(){if(!Z.__ATN)Z.__ATN=new n0().deserialize(Z._serializedATN);return Z.__ATN}static vocabulary=new K0(Z.literalNames,Z.symbolicNames,[]);get vocabulary(){return Z.vocabulary}static decisionsToDFA=Z._ATN.decisionToState.map((_,A)=>new x0(_,A))}class u4 extends h{constructor(_,A){super(_,A)}EOF(){return this.getToken(Z.EOF,0)}script(_){if(_===void 0)return this.getRuleContexts(I2);return this.getRuleContext(_,I2)}get ruleIndex(){return Z.RULE_scriptFile}accept(_){if(_.visitScriptFile)return _.visitScriptFile(this);else return _.visitChildren(this)}}class I2 extends h{_trigger;_name;constructor(_,A){super(_,A)}LBRACK(){return this.getToken(Z.LBRACK,0)}COMMA(){return this.getToken(Z.COMMA,0)}RBRACK(){return this.getToken(Z.RBRACK,0)}identifier(_){if(_===void 0)return this.getRuleContexts(O0);return this.getRuleContext(_,O0)}MUL(){return this.getToken(Z.MUL,0)}statement(_){if(_===void 0)return this.getRuleContexts(L0);return this.getRuleContext(_,L0)}LPAREN(_){if(_===void 0)return this.getTokens(Z.LPAREN);else return this.getToken(Z.LPAREN,_)}RPAREN(_){if(_===void 0)return this.getTokens(Z.RPAREN);else return this.getToken(Z.RPAREN,_)}parameterList(){return this.getRuleContext(0,U3)}typeList(){return this.getRuleContext(0,N3)}get ruleIndex(){return Z.RULE_script}accept(_){if(_.visitScript)return _.visitScript(this);else return _.visitChildren(this)}}class U3 extends h{constructor(_,A){super(_,A)}parameter(_){if(_===void 0)return this.getRuleContexts(q2);return this.getRuleContext(_,q2)}COMMA(_){if(_===void 0)return this.getTokens(Z.COMMA);else return this.getToken(Z.COMMA,_)}get ruleIndex(){return Z.RULE_parameterList}accept(_){if(_.visitParameterList)return _.visitParameterList(this);else return _.visitChildren(this)}}class q2 extends h{_type_;constructor(_,A){super(_,A)}DOLLAR(){return this.getToken(Z.DOLLAR,0)}advancedIdentifier(){return this.getRuleContext(0,l0)}IDENTIFIER(){return this.getToken(Z.IDENTIFIER,0)}TYPE_ARRAY(){return this.getToken(Z.TYPE_ARRAY,0)}get ruleIndex(){return Z.RULE_parameter}accept(_){if(_.visitParameter)return _.visitParameter(this);else return _.visitChildren(this)}}class N3 extends h{constructor(_,A){super(_,A)}IDENTIFIER(_){if(_===void 0)return this.getTokens(Z.IDENTIFIER);else return this.getToken(Z.IDENTIFIER,_)}COMMA(_){if(_===void 0)return this.getTokens(Z.COMMA);else return this.getToken(Z.COMMA,_)}get ruleIndex(){return Z.RULE_typeList}accept(_){if(_.visitTypeList)return _.visitTypeList(this);else return _.visitChildren(this)}}class L0 extends h{constructor(_,A){super(_,A)}blockStatement(){return this.getRuleContext(0,Y3)}returnStatement(){return this.getRuleContext(0,X3)}ifStatement(){return this.getRuleContext(0,G3)}whileStatement(){return this.getRuleContext(0,Q3)}switchStatement(){return this.getRuleContext(0,Z3)}declarationStatement(){return this.getRuleContext(0,$3)}arrayDeclarationStatement(){return this.getRuleContext(0,H3)}assignmentStatement(){return this.getRuleContext(0,F3)}expressionStatement(){return this.getRuleContext(0,J3)}emptyStatement(){return this.getRuleContext(0,I3)}get ruleIndex(){return Z.RULE_statement}accept(_){if(_.visitStatement)return _.visitStatement(this);else return _.visitChildren(this)}}class Y3 extends h{constructor(_,A){super(_,A)}LBRACE(){return this.getToken(Z.LBRACE,0)}RBRACE(){return this.getToken(Z.RBRACE,0)}statement(_){if(_===void 0)return this.getRuleContexts(L0);return this.getRuleContext(_,L0)}get ruleIndex(){return Z.RULE_blockStatement}accept(_){if(_.visitBlockStatement)return _.visitBlockStatement(this);else return _.visitChildren(this)}}class X3 extends h{constructor(_,A){super(_,A)}RETURN(){return this.getToken(Z.RETURN,0)}SEMICOLON(){return this.getToken(Z.SEMICOLON,0)}LPAREN(){return this.getToken(Z.LPAREN,0)}RPAREN(){return this.getToken(Z.RPAREN,0)}expressionList(){return this.getRuleContext(0,B0)}get ruleIndex(){return Z.RULE_returnStatement}accept(_){if(_.visitReturnStatement)return _.visitReturnStatement(this);else return _.visitChildren(this)}}class G3 extends h{constructor(_,A){super(_,A)}IF(){return this.getToken(Z.IF,0)}LPAREN(){return this.getToken(Z.LPAREN,0)}condition(){return this.getRuleContext(0,R0)}RPAREN(){return this.getToken(Z.RPAREN,0)}statement(_){if(_===void 0)return this.getRuleContexts(L0);return this.getRuleContext(_,L0)}ELSE(){return this.getToken(Z.ELSE,0)}get ruleIndex(){return Z.RULE_ifStatement}accept(_){if(_.visitIfStatement)return _.visitIfStatement(this);else return _.visitChildren(this)}}class Q3 extends h{constructor(_,A){super(_,A)}WHILE(){return this.getToken(Z.WHILE,0)}LPAREN(){return this.getToken(Z.LPAREN,0)}condition(){return this.getRuleContext(0,R0)}RPAREN(){return this.getToken(Z.RPAREN,0)}statement(){return this.getRuleContext(0,L0)}get ruleIndex(){return Z.RULE_whileStatement}accept(_){if(_.visitWhileStatement)return _.visitWhileStatement(this);else return _.visitChildren(this)}}class Z3 extends h{constructor(_,A){super(_,A)}SWITCH_TYPE(){return this.getToken(Z.SWITCH_TYPE,0)}parenthesis(){return this.getRuleContext(0,j1)}LBRACE(){return this.getToken(Z.LBRACE,0)}RBRACE(){return this.getToken(Z.RBRACE,0)}switchCase(_){if(_===void 0)return this.getRuleContexts(W2);return this.getRuleContext(_,W2)}get ruleIndex(){return Z.RULE_switchStatement}accept(_){if(_.visitSwitchStatement)return _.visitSwitchStatement(this);else return _.visitChildren(this)}}class W2 extends h{constructor(_,A){super(_,A)}CASE(){return this.getToken(Z.CASE,0)}COLON(){return this.getToken(Z.COLON,0)}DEFAULT(){return this.getToken(Z.DEFAULT,0)}expressionList(){return this.getRuleContext(0,B0)}statement(_){if(_===void 0)return this.getRuleContexts(L0);return this.getRuleContext(_,L0)}get ruleIndex(){return Z.RULE_switchCase}accept(_){if(_.visitSwitchCase)return _.visitSwitchCase(this);else return _.visitChildren(this)}}class $3 extends h{constructor(_,A){super(_,A)}DEF_TYPE(){return this.getToken(Z.DEF_TYPE,0)}DOLLAR(){return this.getToken(Z.DOLLAR,0)}advancedIdentifier(){return this.getRuleContext(0,l0)}SEMICOLON(){return this.getToken(Z.SEMICOLON,0)}EQ(){return this.getToken(Z.EQ,0)}expression(){return this.getRuleContext(0,l)}get ruleIndex(){return Z.RULE_declarationStatement}accept(_){if(_.visitDeclarationStatement)return _.visitDeclarationStatement(this);else return _.visitChildren(this)}}class H3 extends h{constructor(_,A){super(_,A)}DEF_TYPE(){return this.getToken(Z.DEF_TYPE,0)}DOLLAR(){return this.getToken(Z.DOLLAR,0)}advancedIdentifier(){return this.getRuleContext(0,l0)}parenthesis(){return this.getRuleContext(0,j1)}SEMICOLON(){return this.getToken(Z.SEMICOLON,0)}get ruleIndex(){return Z.RULE_arrayDeclarationStatement}accept(_){if(_.visitArrayDeclarationStatement)return _.visitArrayDeclarationStatement(this);else return _.visitChildren(this)}}class F3 extends h{constructor(_,A){super(_,A)}assignableVariableList(){return this.getRuleContext(0,W3)}EQ(){return this.getToken(Z.EQ,0)}expressionList(){return this.getRuleContext(0,B0)}SEMICOLON(){return this.getToken(Z.SEMICOLON,0)}get ruleIndex(){return Z.RULE_assignmentStatement}accept(_){if(_.visitAssignmentStatement)return _.visitAssignmentStatement(this);else return _.visitChildren(this)}}class J3 extends h{constructor(_,A){super(_,A)}expression(){return this.getRuleContext(0,l)}SEMICOLON(){return this.getToken(Z.SEMICOLON,0)}get ruleIndex(){return Z.RULE_expressionStatement}accept(_){if(_.visitExpressionStatement)return _.visitExpressionStatement(this);else return _.visitChildren(this)}}class I3 extends h{constructor(_,A){super(_,A)}SEMICOLON(){return this.getToken(Z.SEMICOLON,0)}get ruleIndex(){return Z.RULE_emptyStatement}accept(_){if(_.visitEmptyStatement)return _.visitEmptyStatement(this);else return _.visitChildren(this)}}class B0 extends h{constructor(_,A){super(_,A)}expression(_){if(_===void 0)return this.getRuleContexts(l);return this.getRuleContext(_,l)}COMMA(_){if(_===void 0)return this.getTokens(Z.COMMA);else return this.getToken(Z.COMMA,_)}get ruleIndex(){return Z.RULE_expressionList}accept(_){if(_.visitExpressionList)return _.visitExpressionList(this);else return _.visitChildren(this)}}class j1 extends h{constructor(_,A){super(_,A)}LPAREN(){return this.getToken(Z.LPAREN,0)}expression(){return this.getRuleContext(0,l)}RPAREN(){return this.getToken(Z.RPAREN,0)}get ruleIndex(){return Z.RULE_parenthesis}accept(_){if(_.visitParenthesis)return _.visitParenthesis(this);else return _.visitChildren(this)}}class S4 extends h{constructor(_,A){super(_,A)}expression(){return this.getRuleContext(0,l)}EOF(){return this.getToken(Z.EOF,0)}get ruleIndex(){return Z.RULE_singleExpression}accept(_){if(_.visitSingleExpression)return _.visitSingleExpression(this);else return _.visitChildren(this)}}class l extends h{constructor(_,A){super(_,A)}get ruleIndex(){return Z.RULE_expression}copyFrom(_){super.copyFrom(_)}}class m4 extends l{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}parenthesis(){return this.getRuleContext(0,j1)}accept(_){if(_.visitParenthesizedExpression)return _.visitParenthesizedExpression(this);else return _.visitChildren(this)}}class x4 extends l{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}calc(){return this.getRuleContext(0,q3)}accept(_){if(_.visitCalcExpression)return _.visitCalcExpression(this);else return _.visitChildren(this)}}class g4 extends l{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}call(){return this.getRuleContext(0,f1)}accept(_){if(_.visitCallExpression)return _.visitCallExpression(this);else return _.visitChildren(this)}}class l4 extends l{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}localVariable(){return this.getRuleContext(0,K2)}accept(_){if(_.visitLocalVariableExpression)return _.visitLocalVariableExpression(this);else return _.visitChildren(this)}}class d4 extends l{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}localArrayVariable(){return this.getRuleContext(0,L2)}accept(_){if(_.visitLocalArrayVariableExpression)return _.visitLocalArrayVariableExpression(this);else return _.visitChildren(this)}}class T4 extends l{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}gameVariable(){return this.getRuleContext(0,B2)}accept(_){if(_.visitGameVariableExpression)return _.visitGameVariableExpression(this);else return _.visitChildren(this)}}class y4 extends l{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}constantVariable(){return this.getRuleContext(0,z3)}accept(_){if(_.visitConstantVariableExpression)return _.visitConstantVariableExpression(this);else return _.visitChildren(this)}}class c4 extends l{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}literal(){return this.getRuleContext(0,g0)}accept(_){if(_.visitLiteralExpression)return _.visitLiteralExpression(this);else return _.visitChildren(this)}}class a4 extends l{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}joinedString(){return this.getRuleContext(0,L3)}accept(_){if(_.visitJoinedStringExpression)return _.visitJoinedStringExpression(this);else return _.visitChildren(this)}}class s4 extends l{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}identifier(){return this.getRuleContext(0,O0)}accept(_){if(_.visitIdentifierExpression)return _.visitIdentifierExpression(this);else return _.visitChildren(this)}}class R0 extends h{constructor(_,A){super(_,A)}get ruleIndex(){return Z.RULE_condition}copyFrom(_){super.copyFrom(_)}}class n4 extends R0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}LPAREN(){return this.getToken(Z.LPAREN,0)}condition(){return this.getRuleContext(0,R0)}RPAREN(){return this.getToken(Z.RPAREN,0)}accept(_){if(_.visitConditionParenthesizedExpression)return _.visitConditionParenthesizedExpression(this);else return _.visitChildren(this)}}class o4 extends R0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}expression(){return this.getRuleContext(0,l)}accept(_){if(_.visitConditionNormalExpression)return _.visitConditionNormalExpression(this);else return _.visitChildren(this)}}class r1 extends R0{_op;constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}condition(_){if(_===void 0)return this.getRuleContexts(R0);return this.getRuleContext(_,R0)}LT(){return this.getToken(Z.LT,0)}GT(){return this.getToken(Z.GT,0)}LTE(){return this.getToken(Z.LTE,0)}GTE(){return this.getToken(Z.GTE,0)}EQ(){return this.getToken(Z.EQ,0)}EXCL(){return this.getToken(Z.EXCL,0)}AND(){return this.getToken(Z.AND,0)}OR(){return this.getToken(Z.OR,0)}accept(_){if(_.visitConditionBinaryExpression)return _.visitConditionBinaryExpression(this);else return _.visitChildren(this)}}class q3 extends h{constructor(_,A){super(_,A)}CALC(){return this.getToken(Z.CALC,0)}LPAREN(){return this.getToken(Z.LPAREN,0)}arithmetic(){return this.getRuleContext(0,X0)}RPAREN(){return this.getToken(Z.RPAREN,0)}get ruleIndex(){return Z.RULE_calc}accept(_){if(_.visitCalc)return _.visitCalc(this);else return _.visitChildren(this)}}class X0 extends h{constructor(_,A){super(_,A)}get ruleIndex(){return Z.RULE_arithmetic}copyFrom(_){super.copyFrom(_)}}class p4 extends X0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}LPAREN(){return this.getToken(Z.LPAREN,0)}arithmetic(){return this.getRuleContext(0,X0)}RPAREN(){return this.getToken(Z.RPAREN,0)}accept(_){if(_.visitArithmeticParenthesizedExpression)return _.visitArithmeticParenthesizedExpression(this);else return _.visitChildren(this)}}class i4 extends X0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}expression(){return this.getRuleContext(0,l)}accept(_){if(_.visitArithmeticNormalExpression)return _.visitArithmeticNormalExpression(this);else return _.visitChildren(this)}}class e1 extends X0{_op;constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}arithmetic(_){if(_===void 0)return this.getRuleContexts(X0);return this.getRuleContext(_,X0)}MUL(){return this.getToken(Z.MUL,0)}DIV(){return this.getToken(Z.DIV,0)}MOD(){return this.getToken(Z.MOD,0)}PLUS(){return this.getToken(Z.PLUS,0)}MINUS(){return this.getToken(Z.MINUS,0)}AND(){return this.getToken(Z.AND,0)}OR(){return this.getToken(Z.OR,0)}accept(_){if(_.visitArithmeticBinaryExpression)return _.visitArithmeticBinaryExpression(this);else return _.visitChildren(this)}}class f1 extends h{constructor(_,A){super(_,A)}get ruleIndex(){return Z.RULE_call}copyFrom(_){super.copyFrom(_)}}class A3 extends f1{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}identifier(){return this.getRuleContext(0,O0)}MUL(){return this.getToken(Z.MUL,0)}LPAREN(_){if(_===void 0)return this.getTokens(Z.LPAREN);else return this.getToken(Z.LPAREN,_)}RPAREN(_){if(_===void 0)return this.getTokens(Z.RPAREN);else return this.getToken(Z.RPAREN,_)}expressionList(_){if(_===void 0)return this.getRuleContexts(B0);return this.getRuleContext(_,B0)}accept(_){if(_.visitCommandCallExpression)return _.visitCommandCallExpression(this);else return _.visitChildren(this)}}class t4 extends f1{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}TILDE(){return this.getToken(Z.TILDE,0)}identifier(){return this.getRuleContext(0,O0)}LPAREN(){return this.getToken(Z.LPAREN,0)}RPAREN(){return this.getToken(Z.RPAREN,0)}expressionList(){return this.getRuleContext(0,B0)}accept(_){if(_.visitProcCallExpression)return _.visitProcCallExpression(this);else return _.visitChildren(this)}}class r4 extends f1{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}AT(){return this.getToken(Z.AT,0)}identifier(){return this.getRuleContext(0,O0)}LPAREN(){return this.getToken(Z.LPAREN,0)}RPAREN(){return this.getToken(Z.RPAREN,0)}expressionList(){return this.getRuleContext(0,B0)}accept(_){if(_.visitJumpCallExpression)return _.visitJumpCallExpression(this);else return _.visitChildren(this)}}class e4 extends h{_args;_triggers;constructor(_,A){super(_,A)}identifier(){return this.getRuleContext(0,O0)}EOF(){return this.getToken(Z.EOF,0)}LPAREN(){return this.getToken(Z.LPAREN,0)}RPAREN(){return this.getToken(Z.RPAREN,0)}LBRACE(){return this.getToken(Z.LBRACE,0)}RBRACE(){return this.getToken(Z.RBRACE,0)}expressionList(_){if(_===void 0)return this.getRuleContexts(B0);return this.getRuleContext(_,B0)}get ruleIndex(){return Z.RULE_clientScript}accept(_){if(_.visitClientScript)return _.visitClientScript(this);else return _.visitChildren(this)}}class W3 extends h{constructor(_,A){super(_,A)}assignableVariable(_){if(_===void 0)return this.getRuleContexts(z2);return this.getRuleContext(_,z2)}COMMA(_){if(_===void 0)return this.getTokens(Z.COMMA);else return this.getToken(Z.COMMA,_)}get ruleIndex(){return Z.RULE_assignableVariableList}accept(_){if(_.visitAssignableVariableList)return _.visitAssignableVariableList(this);else return _.visitChildren(this)}}class z2 extends h{constructor(_,A){super(_,A)}localVariable(){return this.getRuleContext(0,K2)}localArrayVariable(){return this.getRuleContext(0,L2)}gameVariable(){return this.getRuleContext(0,B2)}get ruleIndex(){return Z.RULE_assignableVariable}accept(_){if(_.visitAssignableVariable)return _.visitAssignableVariable(this);else return _.visitChildren(this)}}class K2 extends h{constructor(_,A){super(_,A)}DOLLAR(){return this.getToken(Z.DOLLAR,0)}advancedIdentifier(){return this.getRuleContext(0,l0)}get ruleIndex(){return Z.RULE_localVariable}accept(_){if(_.visitLocalVariable)return _.visitLocalVariable(this);else return _.visitChildren(this)}}class L2 extends h{constructor(_,A){super(_,A)}DOLLAR(){return this.getToken(Z.DOLLAR,0)}advancedIdentifier(){return this.getRuleContext(0,l0)}parenthesis(){return this.getRuleContext(0,j1)}get ruleIndex(){return Z.RULE_localArrayVariable}accept(_){if(_.visitLocalArrayVariable)return _.visitLocalArrayVariable(this);else return _.visitChildren(this)}}class B2 extends h{constructor(_,A){super(_,A)}MOD(){return this.getToken(Z.MOD,0)}advancedIdentifier(){return this.getRuleContext(0,l0)}DOTMOD(){return this.getToken(Z.DOTMOD,0)}get ruleIndex(){return Z.RULE_gameVariable}accept(_){if(_.visitGameVariable)return _.visitGameVariable(this);else return _.visitChildren(this)}}class z3 extends h{constructor(_,A){super(_,A)}CARET(){return this.getToken(Z.CARET,0)}advancedIdentifier(){return this.getRuleContext(0,l0)}get ruleIndex(){return Z.RULE_constantVariable}accept(_){if(_.visitConstantVariable)return _.visitConstantVariable(this);else return _.visitChildren(this)}}class g0 extends h{constructor(_,A){super(_,A)}get ruleIndex(){return Z.RULE_literal}copyFrom(_){super.copyFrom(_)}}class R3 extends g0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}INTEGER_LITERAL(){return this.getToken(Z.INTEGER_LITERAL,0)}HEX_LITERAL(){return this.getToken(Z.HEX_LITERAL,0)}accept(_){if(_.visitIntegerLiteral)return _.visitIntegerLiteral(this);else return _.visitChildren(this)}}class _5 extends g0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}COORD_LITERAL(){return this.getToken(Z.COORD_LITERAL,0)}accept(_){if(_.visitCoordLiteral)return _.visitCoordLiteral(this);else return _.visitChildren(this)}}class A5 extends g0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}BOOLEAN_LITERAL(){return this.getToken(Z.BOOLEAN_LITERAL,0)}accept(_){if(_.visitBooleanLiteral)return _.visitBooleanLiteral(this);else return _.visitChildren(this)}}class R5 extends g0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}CHAR_LITERAL(){return this.getToken(Z.CHAR_LITERAL,0)}accept(_){if(_.visitCharacterLiteral)return _.visitCharacterLiteral(this);else return _.visitChildren(this)}}class U5 extends g0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}NULL_LITERAL(){return this.getToken(Z.NULL_LITERAL,0)}accept(_){if(_.visitNullLiteral)return _.visitNullLiteral(this);else return _.visitChildren(this)}}class N5 extends g0{constructor(_){super(_.parent,_.invokingState);super.copyFrom(_)}stringLiteral(){return this.getRuleContext(0,K3)}accept(_){if(_.visitStringLiteralExpression)return _.visitStringLiteralExpression(this);else return _.visitChildren(this)}}class K3 extends h{constructor(_,A){super(_,A)}QUOTE_OPEN(){return this.getToken(Z.QUOTE_OPEN,0)}QUOTE_CLOSE(){return this.getToken(Z.QUOTE_CLOSE,0)}stringLiteralContent(_){if(_===void 0)return this.getRuleContexts(p0);return this.getRuleContext(_,p0)}get ruleIndex(){return Z.RULE_stringLiteral}accept(_){if(_.visitStringLiteral)return _.visitStringLiteral(this);else return _.visitChildren(this)}}class p0 extends h{constructor(_,A){super(_,A)}STRING_TEXT(){return this.getToken(Z.STRING_TEXT,0)}get ruleIndex(){return Z.RULE_stringLiteralContent}accept(_){if(_.visitStringLiteralContent)return _.visitStringLiteralContent(this);else return _.visitChildren(this)}}class L3 extends h{constructor(_,A){super(_,A)}QUOTE_OPEN(){return this.getToken(Z.QUOTE_OPEN,0)}QUOTE_CLOSE(){return this.getToken(Z.QUOTE_CLOSE,0)}stringLiteralContent(_){if(_===void 0)return this.getRuleContexts(p0);return this.getRuleContext(_,p0)}stringTag(_){if(_===void 0)return this.getRuleContexts(O1);return this.getRuleContext(_,O1)}stringPTag(_){if(_===void 0)return this.getRuleContexts(M1);return this.getRuleContext(_,M1)}stringExpression(_){if(_===void 0)return this.getRuleContexts(h1);return this.getRuleContext(_,h1)}get ruleIndex(){return Z.RULE_joinedString}accept(_){if(_.visitJoinedString)return _.visitJoinedString(this);else return _.visitChildren(this)}}class O1 extends h{constructor(_,A){super(_,A)}STRING_TAG(){return this.getToken(Z.STRING_TAG,0)}STRING_CLOSE_TAG(){return this.getToken(Z.STRING_CLOSE_TAG,0)}STRING_PARTIAL_TAG(){return this.getToken(Z.STRING_PARTIAL_TAG,0)}get ruleIndex(){return Z.RULE_stringTag}accept(_){if(_.visitStringTag)return _.visitStringTag(this);else return _.visitChildren(this)}}class M1 extends h{constructor(_,A){super(_,A)}STRING_P_TAG(){return this.getToken(Z.STRING_P_TAG,0)}get ruleIndex(){return Z.RULE_stringPTag}accept(_){if(_.visitStringPTag)return _.visitStringPTag(this);else return _.visitChildren(this)}}class h1 extends h{constructor(_,A){super(_,A)}STRING_EXPR_START(){return this.getToken(Z.STRING_EXPR_START,0)}expression(){return this.getRuleContext(0,l)}STRING_EXPR_END(){return this.getToken(Z.STRING_EXPR_END,0)}get ruleIndex(){return Z.RULE_stringExpression}accept(_){if(_.visitStringExpression)return _.visitStringExpression(this);else return _.visitChildren(this)}}class O0 extends h{constructor(_,A){super(_,A)}IDENTIFIER(){return this.getToken(Z.IDENTIFIER,0)}HEX_LITERAL(){return this.getToken(Z.HEX_LITERAL,0)}BOOLEAN_LITERAL(){return this.getToken(Z.BOOLEAN_LITERAL,0)}NULL_LITERAL(){return this.getToken(Z.NULL_LITERAL,0)}COORD_LITERAL(){return this.getToken(Z.COORD_LITERAL,0)}MAPZONE_LITERAL(){return this.getToken(Z.MAPZONE_LITERAL,0)}TYPE_ARRAY(){return this.getToken(Z.TYPE_ARRAY,0)}SWITCH_TYPE(){return this.getToken(Z.SWITCH_TYPE,0)}DEF_TYPE(){return this.getToken(Z.DEF_TYPE,0)}DEFAULT(){return this.getToken(Z.DEFAULT,0)}get ruleIndex(){return Z.RULE_identifier}accept(_){if(_.visitIdentifier)return _.visitIdentifier(this);else return _.visitChildren(this)}}class l0 extends h{constructor(_,A){super(_,A)}identifier(){return this.getRuleContext(0,O0)}IF(){return this.getToken(Z.IF,0)}ELSE(){return this.getToken(Z.ELSE,0)}WHILE(){return this.getToken(Z.WHILE,0)}RETURN(){return this.getToken(Z.RETURN,0)}CALC(){return this.getToken(Z.CALC,0)}get ruleIndex(){return Z.RULE_advancedIdentifier}accept(_){if(_.visitAdvancedIdentifier)return _.visitAdvancedIdentifier(this);else return _.visitChildren(this)}}class B3 extends j4{visitScriptFile;visitScript;visitParameterList;visitParameter;visitTypeList;visitStatement;visitBlockStatement;visitReturnStatement;visitIfStatement;visitWhileStatement;visitSwitchStatement;visitSwitchCase;visitDeclarationStatement;visitArrayDeclarationStatement;visitAssignmentStatement;visitExpressionStatement;visitEmptyStatement;visitExpressionList;visitParenthesis;visitSingleExpression;visitParenthesizedExpression;visitCalcExpression;visitCallExpression;visitLocalVariableExpression;visitLocalArrayVariableExpression;visitGameVariableExpression;visitConstantVariableExpression;visitLiteralExpression;visitJoinedStringExpression;visitIdentifierExpression;visitConditionParenthesizedExpression;visitConditionNormalExpression;visitConditionBinaryExpression;visitCalc;visitArithmeticParenthesizedExpression;visitArithmeticNormalExpression;visitArithmeticBinaryExpression;visitCommandCallExpression;visitProcCallExpression;visitJumpCallExpression;visitClientScript;visitAssignableVariableList;visitAssignableVariable;visitLocalVariable;visitLocalArrayVariable;visitGameVariable;visitConstantVariable;visitIntegerLiteral;visitCoordLiteral;visitBooleanLiteral;visitCharacterLiteral;visitNullLiteral;visitStringLiteralExpression;visitStringLiteral;visitStringLiteralContent;visitJoinedString;visitStringTag;visitStringPTag;visitStringExpression;visitIdentifier;visitAdvancedIdentifier}class D3 extends a{typeToken;name;symbol;constructor(_,A,R){super(_);this.typeToken=A,this.name=R,this.addChild(this.typeToken),this.addChild(this.name)}accept(_){return _.visitParameter(this)}}class w3 extends a{scripts;constructor(_,A){super(_);this.scripts=A,this.addChildren(this.scripts)}accept(_){return _.visitScriptFile(this)}}class E3 extends a{text;constructor(_,A){super(_);this.text=A}accept(_){return _.visitToken(this)}}class k3 extends e0{kind="ArithmeticExpression";constructor(_,A,R,U){super(_,A,R,U)}accept(_){return _.visitArithmeticExpression(this)}}class C3 extends n{kind="CalcExpression";expression;constructor(_,A){super(_);this.expression=A,this.addChild(this.expression)}accept(_){return _.visitCalcExpression(this)}}class O3 extends n{kind="JoinedStringExpression";parts;constructor(_,A){super(_);this.parts=A,this.addChildren(this.parts)}accept(_){return _.visitJoinedStringExpression(this)}}class M3 extends o{kind="BooleanLiteral";constructor(_,A){super(_,A)}accept(_){return _.visitBooleanLiteral(this)}}class h3 extends o{kind="CharacterLiteral";constructor(_,A){super(_,A)}accept(_){return _.visitCharacterLiteral(this)}}class j3 extends o{kind="CoordLiteral";constructor(_,A){super(_,A)}accept(_){return _.visitCoordLiteral(this)}}class D2 extends o{kind="IntegerLiteral";constructor(_,A){super(_,A)}accept(_){return _.visitIntegerLiteral(this)}}class f3 extends o{kind="NullLiteral";constructor(_){super(_,-1)}accept(_){return _.visitNullLiteral(this)}}class V3 extends g{kind="ArrayDeclarationStatement";typeToken;name;initializer;symbol;constructor(_,A,R,U){super(_);this.typeToken=A,this.name=R,this.initializer=U,this.addChild(this.typeToken),this.addChild(this.name),this.addChild(this.initializer)}accept(_){return _.visitArrayDeclarationStatement(this)}}class P3 extends g{kind="AssignmentStatement";vars;expressions;constructor(_,A,R){super(_);this.vars=A,this.expressions=R,this.addChildren(this.vars),this.addChildren(this.expressions)}accept(_){return _.visitAssignmentStatement(this)}}class b3 extends g{kind="BlockStatement";statements;scope;constructor(_,A){super(_);this.statements=A,this.addChildren(this.statements)}accept(_){return _.visitBlockStatement(this)}}class v3 extends g{kind="DeclarationStatement";typeToken;name;initializer;symbol;constructor(_,A,R,U){super(_);this.typeToken=A,this.name=R,this.initializer=U,this.addChild(this.typeToken),this.addChild(this.name),this.addChild(this.initializer)}accept(_){return _.visitDeclarationStatement(this)}}class u3 extends g{readonly="EmptyStatement";constructor(_){super(_)}accept(_){return _.visitEmptyStatement(this)}}class S3 extends g{kind="ExpressionStatement";expression;constructor(_,A){super(_);this.expression=A,this.addChild(this.expression)}accept(_){return _.visitExpressionStatement(this)}}class m3 extends g{kind="IfStatement";condition;thenStatement;elseStatement;constructor(_,A,R,U){super(_);this.condition=A,this.thenStatement=R,this.elseStatement=U,this.addChild(this.condition),this.addChild(this.thenStatement),this.addChild(this.elseStatement)}accept(_){return _.visitIfStatement(this)}}class x3 extends g{kind="ReturnStatement";expressions;constructor(_,A){super(_);this.expressions=A,this.addChildren(this.expressions)}accept(_){return _.visitReturnStatement(this)}}class g3 extends a{kind="SwitchCase";keys;statements;scope;constructor(_,A,R){super(_);this.keys=A,this.statements=R,this.addChildren(this.keys),this.addChildren(this.statements)}get isDefault(){return this.keys.length===0}accept(_){return _.visitSwitchCase(this)}}class l3 extends g{kind="WhileStatement";condition;thenStatement;constructor(_,A,R){super(_);this.condition=A,this.thenStatement=R,this.addChild(this.condition),this.addChild(this.thenStatement)}accept(_){return _.visitWhileStatement(this)}}class d3 extends B3{source;lineOffset;columnOffset;constructor(_,A,R){super();this.source=_,this.lineOffset=A,this.columnOffset=R}visitScriptFile=(_)=>{return new w3(this.location(_),_.script().map((A)=>this.visitNode(A)))};visitScript=(_)=>{let A=_.typeList()?.IDENTIFIER()?.map((R)=>this.toAstToken(R.symbol));return new o0({source:this.location(_),trigger:this.visitNode(_._trigger),name:this.visitNode(_._name),isStar:_.MUL()!==null,parameters:_.parameterList()?.parameter().map((R)=>this.visitNode(R))??null,returnTokens:A??null,statements:_.statement().map((R)=>this.visitNode(R))})};visitParameter=(_)=>{return new D3(this.location(_),this.toAstToken(_._type_),this.visitNode(_.advancedIdentifier()))};visitBlockStatement=(_)=>{return new b3(this.location(_),_.statement().map((A)=>this.visitNode(A)))};visitReturnStatement=(_)=>{return new x3(this.location(_),this.collectExpressionList(_.expressionList()))};visitIfStatement=(_)=>{let A=_.statement();if(!A[0])throw Error("IfStatement missing then statement.");return new m3(this.location(_),this.visitNode(_.condition()),this.visitNode(A[0]),A.length>1?this.visitNode(A[1]):null)};visitWhileStatement=(_)=>{return new l3(this.location(_),this.visitNode(_.condition()),this.visitNode(_.statement()))};visitSwitchStatement=(_)=>{return new t1(this.location(_),this.toAstToken(_.SWITCH_TYPE().symbol),this.extractParenthesisExpression(_.parenthesis()),_.switchCase().map((A)=>this.visitNode(A)))};visitSwitchCase=(_)=>{return new g3(this.location(_),this.collectExpressionList(_.expressionList()),_.statement()?.map((A)=>this.visitNode(A))??[])};visitDeclarationStatement=(_)=>{return new v3(this.location(_),this.toAstToken(_.DEF_TYPE().symbol),this.visitNode(_.advancedIdentifier()),_.expression()?this.visitNode(_.expression()):null)};visitArrayDeclarationStatement=(_)=>{return new V3(this.location(_),this.toAstToken(_.DEF_TYPE().symbol),this.visitNode(_.advancedIdentifier()),this.extractParenthesisExpression(_.parenthesis()))};visitAssignmentStatement=(_)=>{return new P3(this.location(_),_.assignableVariableList().assignableVariable().map((A)=>this.visitNode(A)),this.collectExpressionList(_.expressionList()))};visitExpressionStatement=(_)=>{return new S3(this.location(_),this.visitNode(_.expression()))};visitEmptyStatement=(_)=>{return new u3(this.location(_))};visitSingleExpression=(_)=>{return this.visitNode(_.expression())};visitParenthesizedExpression=(_)=>{return new b0(this.location(_),this.extractParenthesisExpression(_.parenthesis()))};visitConditionParenthesizedExpression=(_)=>{return new b0(this.location(_),this.visitNode(_.condition()))};visitArithmeticParenthesizedExpression=(_)=>{return new b0(this.location(_),this.visitNode(_.arithmetic()))};visitConditionBinaryExpression=(_)=>{return new _1(this.location(_),this.visitNode(_.condition(0)),this.toAstToken(_._op),this.visitNode(_.condition(1)))};visitArithmeticBinaryExpression=(_)=>{return new k3(this.location(_),this.visitNode(_.arithmetic(0)),this.toAstToken(_._op),this.visitNode(_.arithmetic(1)))};visitCalcExpression=(_)=>{return new C3(this.location(_),this.visitNode(_.calc().arithmetic()))};visitCommandCallExpression=(_)=>{let A=_.expressionList(),R=Array.isArray(A)?A:A?[A]:[],U=_.MUL()!==null?this.collectExpressionList(R[1]):null;return new D0(this.location(_),this.visitNode(_.identifier()),this.collectExpressionList(R[0]),U)};visitProcCallExpression=(_)=>{let A=_.expressionList(),R=Array.isArray(A)?A:A?[A]:[];return new i1(this.location(_),this.visitNode(_.identifier()),this.collectExpressionList(R[0]))};visitJumpCallExpression=(_)=>{let A=_.expressionList(),R=Array.isArray(A)?A:A?[A]:[];return new p1(this.location(_),this.visitNode(_.identifier()),this.collectExpressionList(R[0]))};visitClientScript=(_)=>{return new o1(this.location(_),this.visitNode(_.identifier()),this.collectExpressionList(_._args),this.collectExpressionList(_._triggers))};visitLocalVariable=(_)=>{return new d0(this.location(_),this.visitNode(_.advancedIdentifier()),null)};visitLocalArrayVariable=(_)=>{return new d0(this.location(_),this.visitNode(_.advancedIdentifier()),this.extractParenthesisExpression(_.parenthesis()))};visitGameVariable=(_)=>{let A=_.DOTMOD()!==null;return new d1(this.location(_),A,this.visitNode(_.advancedIdentifier()))};visitConstantVariable=(_)=>{return new R1(this.location(_),this.visitNode(_.advancedIdentifier()))};visitIntegerLiteral=(_)=>{let A=_.getText();if(A.length>1&&A[0]==="0"&&(A[1]==="x"||A[1]==="X"))return new D2(this.location(_),parseInt(A.slice(2),16));return new D2(this.location(_),parseInt(A,10))};visitCoordLiteral=(_)=>{let R=_.getText().split("_").map((Q)=>parseInt(Q,10)),U=R[1]<<6|R[3]&16383,N=R[2]<<6|R[4]&16383,Y=R[0]&3,X=N|U<<14|Y<<28|0;return new j3(this.location(_),X)};visitBooleanLiteral=(_)=>{return new M3(this.location(_),_.getText()==="true")};visitCharacterLiteral=(_)=>{let A=this.unescape(_.getText().slice(1,-1));if(A.length!==1)throw Error(`invalid character literal: text=${_.getText()}, cleaned=${A}`);return new h3(this.location(_),A)};visitStringLiteral=(_)=>{return new T0(this.location(_),this.unescape(_.getText().slice(1,-1)))};visitNullLiteral=(_)=>{return new f3(this.location(_))};visitJoinedString=(_)=>{let A=[];for(let R of _.children??[])if(R instanceof p0)A.push(new v0(this.location(R),this.unescape(R.getText())));else if(R instanceof O1)A.push(new v0(this.location(R),R.getText()));else if(R instanceof M1)A.push(new u2(this.location(R),R.getText()));else if(R instanceof h1){let U=this.visitNode(R.expression());A.push(new u0(this.location(R),U))}return new O3(this.location(_),A)};visitIdentifier=(_)=>{return new A0(this.location(_),_.getText())};visitAdvancedIdentifier=(_)=>{return new A0(this.location(_),_.getText())};visitConditionNormalExpression=(_)=>{return this.visitNode(_.expression())};visitArithmeticNormalExpression=(_)=>{return this.visitNode(_.expression())};visitCallExpression=(_)=>{return this.visitNode(_.call())};visitIdentifierExpression=(_)=>{return this.visitNode(_.identifier())};visitLiteralExpression=(_)=>{return this.visitNode(_.literal())};visitJoinedStringExpression=(_)=>{return this.visitNode(_.joinedString())};visitLocalVariableExpression=(_)=>{return this.visitNode(_.localVariable())};visitLocalArrayVariableExpression=(_)=>{return this.visitNode(_.localArrayVariable())};visitGameVariableExpression=(_)=>{return this.visitNode(_.gameVariable())};visitConstantVariableExpression=(_)=>{return this.visitNode(_.constantVariable())};location(_){let A=_.stop??_.start;return this.locationFromRange(_.start,A)}locationFromToken(_){return this.locationFromRange(_,_)}locationFromRange(_,A){let R=_.line===1?this.columnOffset:0,U=A.line===1?this.columnOffset:0,N=Math.max(A.text?.length??0,1);return{name:this.source,line:_.line+this.lineOffset,column:_.column+1+R,endLine:A.line+this.lineOffset,endColumn:A.column+1+U+N}}toAstToken(_){return new E3(this.locationFromToken(_),_.text??"")}visitNode(_){if(!_)throw Error("Expected parser context but received null/undefined.");return this.visit(_)}collectExpressionList(_){if(!_)return[];let A=_.expression();return(Array.isArray(A)?A:[A]).map((U)=>this.visitNode(U))}extractParenthesisExpression(_){return this.visitNode(_.expression())}unescape(_){let A="";for(let R=0;R<_.length;R+=1){let U=_[R];if(U==="\\"){let N=R===_.length-1?"\\":_[R+1];if(N==="\\"||N==="'"||N==='"'||N==="<")A+=N;else throw Error(`Unsupported escape sequence: \\${N}`);R+=1}else A+=U}return A}}class V1{static createScriptFile(_,A){let R=L6(_,"utf8"),U=H0.fromString(R);return U.name=_,this.invokeParser(U,(N)=>N.scriptFile(),A)}static async createScriptFileAsync(_,A){let R=await B6(_,"utf8"),U=H0.fromString(R);return U.name=_,this.invokeParser(U,(N)=>N.scriptFile(),A)}static createScriptFileFromString(_,A){let R=H0.fromString(_);return R.name="<source>",this.invokeParser(R,(U)=>U.scriptFile(),A)}static createScript(_,A){let R=H0.fromString(_);return R.name="<source>",this.invokeParser(R,(U)=>U.script(),A)}static invokeParser(_,A,R,U=0,N=0){let Y=new T(_),X=new F2(Y),Q=new Z(X);if(R)Y.removeErrorListeners(),Y.addErrorListener(R),Q.removeErrorListeners(),Q.addErrorListener(R);let $=A(Q);if(Q.numberOfSyntaxErrors>0)return null;return new d3(_.getSourceName(),U,N).visit($)}}class M0 extends P0{typeManager;triggerManager;rootTable;dynamicCommands;diagnostics;commandTrigger;procTrigger;clientscriptTrigger;labelTrigger;table;constantsBeingEvaluated;constructor(_,A,R,U,N){super();this.typeManager=_;this.triggerManager=A;this.rootTable=R;this.dynamicCommands=U;this.diagnostics=N;this.commandTrigger=this.triggerManager.find("command"),this.procTrigger=this.triggerManager.find("proc"),this.clientscriptTrigger=this.triggerManager.findOrNull("clientscript"),this.labelTrigger=this.triggerManager.findOrNull("label"),this.table=this.rootTable,this.constantsBeingEvaluated=new Set}scoped(_,A){let R=this.table;this.table=_,A(),this.table=R}visitScriptFile(_){this.visitNodes(_.scripts)}visitScript(_){this.scoped(_.block,()=>{this.visitNodes(_.statements)})}visitBlockStatement(_){this.scoped(_.scope,()=>{this.visitNodes(_.statements)})}visitReturnStatement(_){let A=_.findParentByType(o0);if(A==null){_.reportError(this.diagnostics,E.RETURN_ORPHAN);return}let R=M.toList(A.returnType),U=this.typeHintExpressionList(R,_.expressions),N=M.fromList(R),Y=M.fromList(U);this.checkTypeMatch(_,N,Y)}visitIfStatement(_){this.checkCondition(_.condition),this.visitNodeOrNull(_.thenStatement),this.visitNodeOrNull(_.elseStatement)}visitWhileStatement(_){this.checkCondition(_.condition),this.visitNodeOrNull(_.thenStatement)}checkCondition(_){_.typeHint=D.BOOLEAN;let A=this.findInvalidConditionExpression(_);if(A==null)this.visitNodeOrNull(_),this.checkTypeMatch(_,D.BOOLEAN,_.type??W.Error);else A.reportError(this.diagnostics,E.CONDITION_INVALID_NODE_TYPE)}findInvalidConditionExpression(_){if(_ instanceof _1){let A=_.operator.text;if(A==="|"||A==="&")return this.findInvalidConditionExpression(_.left)??this.findInvalidConditionExpression(_.right);else return null}else if(_ instanceof b0)return this.findInvalidConditionExpression(_.expression);else return _}visitSwitchStatement(_){let{type:A,condition:R}=_;R.typeHint=A,this.visitNodeOrNull(R),this.checkTypeMatch(R,A,R.type??W.Error);let U=null;for(let N of _.cases){if(N.isDefault)if(U==null)U=N;else N.reportError(this.diagnostics,E.SWITCH_DUPLICATE_DEFAULT);this.visitNodeOrNull(N)}_.defaultCase=U}visitSwitchCase(_){let A=_.findParentByType(t1);if(!A){_.reportError(this.diagnostics,E.CASE_WITHOUT_SWITCH);return}let R=A.type;for(let U of _.keys){if(U.typeHint=R,this.visitNodeOrNull(U),!this.isConstantExpression(U)){U.reportError(this.diagnostics,E.SWITCH_CASE_NOT_CONSTANT);continue}this.checkTypeMatch(U,R,U.type)}this.scoped(_.scope,()=>{this.visitNodes(_.statements)})}isConstantExpression(_){if(_ instanceof R1)return!0;if(_ instanceof T0){let A=_.subExpression;return A==null||this.isConstantExpression(A)}if(_ instanceof o)return!0;if(_ instanceof A0){let A=_.reference;return A==null||this.isConstantSymbol(A)}return!1}isConstantSymbol(_){return _ instanceof r||_ instanceof I1}visitDeclarationStatement(_){let A=_.typeToken.text.replace(/^def_/,""),R=_.name.text,U=this.typeManager.findOrNull(A);if(!U)_.typeToken.reportError(this.diagnostics,E.GENERIC_INVALID_TYPE,A);else if(U.options&&!U.options.allowDeclaration)_.typeToken.reportError(this.diagnostics,E.LOCAL_DECLARATION_INVALID_TYPE,U.representation);let N=new F0(R,U??W.Error);if(!this.table.insert(x.localVariable(),N))_.name.reportError(this.diagnostics,E.SCRIPT_LOCAL_REDECLARATION,R);let X=_.initializer;if(X!=null)X.typeHint=N.type,this.visitNodeOrNull(X),this.checkTypeMatch(X,N.type,X.type??W.Error);_.symbol=N}visitArrayDeclarationStatement(_){let A=_.typeToken.text.replace(/^def_/,""),R=_.name.text,U=this.typeManager.findOrNull(A);if(!U)_.typeToken.reportError(this.diagnostics,E.GENERIC_INVALID_TYPE,A);else if(U.options&&!U.options.allowDeclaration)_.typeToken.reportError(this.diagnostics,E.LOCAL_DECLARATION_INVALID_TYPE,U.representation);else if(U.options&&!U.options.allowArray)_.typeToken.reportError(this.diagnostics,E.LOCAL_ARRAY_INVALID_TYPE,U.representation);if(U)U=new s(U);else U=W.Error;let N=_.initializer;N.typeHint=D.INT,this.visitNodeOrNull(N),this.checkTypeMatch(N,D.INT,N.type??W.Error);let Y=new F0(R,U);if(!this.table.insert(x.localVariable(),Y))_.name.reportError(this.diagnostics,E.SCRIPT_LOCAL_REDECLARATION,R);_.symbol=Y}visitAssignmentStatement(_){let A=_.vars;this.visitNodes(A);let R=A.map((Q)=>this.getSafeType(Q)),U=this.typeHintExpressionList(R,_.expressions).map((Q)=>Q??W.Error),N=M.fromList(R),Y=M.fromList(U);this.checkTypeMatch(_,N,Y);let X=A.find((Q)=>Q instanceof d0&&Q.isArray);if(A.length>1&&X)X.reportError(this.diagnostics,E.ASSIGN_MULTI_ARRAY)}visitExpressionStatement(_){this.visitNodeOrNull(_.expression)}visitEmptyStatement(_){}visitParenthesizedExpression(_){let A=_.expression;A.typeHint=_.typeHint,this.visitNodeOrNull(A),_.type=A.type}visitConditionExpression(_){let{left:A,right:R,operator:U}=_;if(!this.checkBinaryConditionOperation(A,U,R)){_.type=W.Error;return}_.type=D.BOOLEAN}checkBinaryConditionOperation(_,A,R){let U;switch(A.text){case"&":case"|":U=M0.ALLOWED_LOGICAL_TYPES;break;case"<":case">":case"<=":case">=":U=M0.ALLOWED_RELATIONAL_TYPES;break;default:U=null}if(U!=null)_.typeHint=U[0],R.typeHint=U[0];else _.typeHint=_.typeHint??R.type??null,R.typeHint=R.typeHint??_.type??null;if(this.visitNodeOrNull(_),R.typeHint=R.typeHint??_.type,this.visitNodeOrNull(R),_.type==null||R.type==null)return A.reportError(this.diagnostics,E.BINOP_INVALID_TYPES,A.text,_.type?_.type.representation:"<null>",R.type?R.type.representation:"<null>"),!1;if(_.type instanceof M||R.type instanceof M){if(_.type instanceof M)_.reportError(this.diagnostics,E.BINOP_TUPLE_TYPE,"Left",_.type.representation);if(R.type instanceof M)R.reportError(this.diagnostics,E.BINOP_TUPLE_TYPE,"Right",R.type.representation);return!1}else if(_.type==W.Unit||R.type==W.Unit)return A.reportError(this.diagnostics,E.BINOP_INVALID_TYPES,A.text,_.type.representation,R.type.representation),!1;if(U!=null){if(!this.checkTypeMatchAny(_,U,_.type)||!this.checkTypeMatchAny(R,U,R.type))return A.reportError(this.diagnostics,E.BINOP_INVALID_TYPES,A.text,_.type.representation,R.type.representation),!1}if(!this.checkTypeMatch(_,_.type,R.type,!1))return A.reportError(this.diagnostics,E.BINOP_INVALID_TYPES,A.text,_.type.representation,R.type.representation),!1;else if(_.type==D.STRING&&R.type==D.STRING)return A.reportError(this.diagnostics,E.BINOP_INVALID_TYPES,A.text,_.type.representation,R.type.representation),!1;return!0}visitArithmeticExpression(_){let{left:A,right:R,operator:U}=_,N=_.typeHint??D.INT;if(A.typeHint=N,this.visitNodeOrNull(A),R.typeHint=N,this.visitNodeOrNull(R),A.type==null||R.type==null||!this.checkTypeMatchAny(A,M0.ALLOWED_ARITHMETIC_TYPES,A.type??W.Error)||!this.checkTypeMatchAny(A,M0.ALLOWED_ARITHMETIC_TYPES,R.type??W.Error)||!this.checkTypeMatch(A,N,A.type??W.Error,!1)||!this.checkTypeMatch(R,N,R.type??W.Error,!1)){U.reportError(this.diagnostics,E.BINOP_INVALID_TYPES,U.text,A.type?A.type.representation:"<null>",R.type?R.type.representation:"<null>"),_.type=W.Error;return}_.type=N}visitCalcExpression(_){let A=_.typeHint??D.INT,R=_.expression;if(R.typeHint=A,this.visitNodeOrNull(R),R.type==null||!this.checkTypeMatchAny(R,M0.ALLOWED_ARITHMETIC_TYPES,R.type??W.Error))R.reportError(this.diagnostics,E.ARITHMETIC_INVALID_TYPE,R.type?R.type.representation:"<null>"),_.type=W.Error;else _.type=R.type}visitCommandCallExpression(_){let A=_.nameString;if(this.checkDynamicCommand(A,_))return;this.checkCallExpression(_,this.commandTrigger,E.COMMAND_REFERENCE_UNRESOLVED)}visitProcCallExpression(_){this.checkCallExpression(_,this.procTrigger,E.PROC_REFERENCE_UNRESOLVED)}visitJumpCallExpression(_){if(!this.labelTrigger){_.reportError(this.diagnostics,"Jump expression not allowed.");return}let A=_.findParentByType(o0);if(!A)throw Error("Parent script not found.");if(A.triggerType===this.procTrigger){_.reportError(this.diagnostics,"Unable to jump to labels from within a proc.");return}this.checkCallExpression(_,this.labelTrigger,E.JUMP_REFERENCE_UNRESOLVED)}checkDynamicCommand(_,A){let R=this.dynamicCommands.get(_);if(!R)return!1;return(()=>{let U=new J2(this,this.typeManager,A,this.diagnostics);if(R.typeCheck(U),!A.getNullableType())A.reportError(this.diagnostics,E.CUSTOM_HANDLER_NOTYPE);if(A instanceof A0&&!A.reference||A instanceof i&&!A.symbol){let Y=this.rootTable.find(x.serverScript(this.commandTrigger),_);if(!Y)A.reportError(this.diagnostics,E.CUSTOM_HANDLER_NOSYMBOL);if(A instanceof A0)A.reference=Y;else if(A instanceof i)A.symbol=Y}})(),!0}checkCallExpression(_,A,R){let U=_.name.text,N=x.serverScript(A),Y=this.rootTable.find(N,U);if(!Y)_.type=W.Error,_.reportError(this.diagnostics,R,U);else _.symbol=Y,_.type=Y.returns;this.typeCheckArguments(Y,_,U)}visitClientScriptExpression(_){if(!this.clientscriptTrigger){_.reportError(this.diagnostics,E.TRIGGER_TYPE_NOT_FOUND,"clientscript");return}let A=_.typeHint;if(!(A instanceof W.Hook))throw Error("Expected MetaType Hook");let R=_.name.text,U=x.clientScript(this.clientscriptTrigger),N=this.rootTable.find(U,R);if(!N)_.reportError(this.diagnostics,E.CLIENTSCRIPT_REFERENCE_UNRESOLVED,R),_.type=W.Error;else _.symbol=N,_.type=A;this.typeCheckArguments(N,_,R);let Y=A.transmitListType;if(Y==W.Unit&&_.transmitList.length>0){_.transmitList[0].reportError(this.diagnostics,E.HOOK_TRANSMIT_LIST_UNEXPECTED),_.type=W.Error;return}for(let X of _.transmitList)X.typeHint=Y,this.visitNodeOrNull(X),this.checkTypeMatch(X,Y,X.type??W.Error)}typeCheckArguments(_,A,R){let U=_?.parameters??W.Error,N=U instanceof M?[...U.children]:[U],Y=this.typeHintExpressionList(N,A.arguments),X=M.fromList(N),Q=M.fromList(Y);if(X==W.Unit&&Q!=W.Unit){let $;if(A instanceof D0)$=E.COMMAND_NOARGS_EXPECTED;else if(A instanceof i1)$=E.PROC_NOARGS_EXPECTED;else if(A instanceof p1)$=E.JUMP_NOARGS_EXPECTED;else if(A instanceof o1)$=E.CLIENTSCRIPT_NOARGS_EXPECTED;else throw Error(`Unexpected callExpression type: ${A}`);A.reportError(this.diagnostics,$,R,Q.representation);return}this.checkTypeMatch(A,X,Q)}visitLocalVariableExpression(_){let A=_.name.text,R=this.table.find(x.localVariable(),A);if(!R){_.reportError(this.diagnostics,E.LOCAL_REFERENCE_UNRESOLVED,A),_.type=W.Error;return}let U=R.type instanceof s;if(!U&&_.isArray){_.reportError(this.diagnostics,E.LOCAL_REFERENCE_NOT_ARRAY,A),_.type=W.Error;return}if(U&&!_.isArray){_.reportError(this.diagnostics,E.LOCAL_ARRAY_REFERENCE_NOINDEX,A),_.type=W.Error;return}let N=_.index;if(R.type instanceof s&&N!=null)this.visitNodeOrNull(N),this.checkTypeMatch(N,D.INT,N.type??W.Error);_.reference=R,_.type=R.type instanceof s?R.type.inner:R.type}visitGameVariableExpression(_){let A=_.name.text,R=this.rootTable.findAll(A).find((U)=>U.type instanceof y0);if(!R||!(R.type instanceof y0)){_.type=W.Error,_.reportError(this.diagnostics,E.GAME_REFERENCE_UNRESOLVED,A);return}_.reference=R,_.type=R.type.inner}visitConstantVariableExpression(_){let A=_.name.text,R=_.typeHint;if(!R){_.reportError(this.diagnostics,E.CONSTANT_UNKNOWN_TYPE,A),_.type=W.Error;return}else if(R==W.Error){_.type=W.Error;return}let U=this.rootTable.find(x.constant(),A);if(!U){_.reportError(this.diagnostics,E.CONSTANT_REFERENCE_UNRESOLVED,A),_.type=W.Error;return}if(this.constantsBeingEvaluated.has(U)){let N=Array.from(this.constantsBeingEvaluated).map((Y)=>`^${Y.name}`).join(" -> ");N+=` -> ^${U.name}`,_.reportError(this.diagnostics,E.CONSTANT_CYCLIC_REF,N),_.type=W.Error;return}this.constantsBeingEvaluated.add(U);try{let{name:N,line:Y,column:X}=_.source,Q=this.typeManager.findOrNull("graphic"),$=R==D.STRING||Q!=null&&R==Q,J=H0.fromString(U.value);J.name=N;let I=$?new T0({name:N,line:Y-1,column:X-1,endLine:Y-1,endColumn:X},U.value):V1.invokeParser(J,(w)=>w.singleExpression(),M0.DISCARD_ERROR_LISTENER,Y-1,X-1);if(!I){_.reportError(this.diagnostics,E.CONSTANT_PARSE_ERROR,U.value,R.representation),_.type=W.Error;return}if(I.typeHint=R,this.visitNodeOrNull(I),!this.isConstantExpression(I)){_.reportError(this.diagnostics,E.CONSTANT_NONCONSTANT,U.value),_.type=W.Error;return}_.subExpression=I,_.type=I.type}finally{this.constantsBeingEvaluated.delete(U)}}visitIntegerLiteral(_){_.type=D.INT}visitCoordLiteral(_){_.type=D.COORD}visitBooleanLiteral(_){_.type=D.BOOLEAN}visitCharacterLiteral(_){_.type=D.CHAR}visitNullLiteral(_){let A=_.typeHint;if(A!=null){_.type=A;return}_.type=D.INT}visitStringLiteral(_){let A=_.typeHint;if(!A||this.typeManager.check(A,D.STRING))_.type=D.STRING;else if(A instanceof W.Hook)this.handleClientScriptExpression(_,A);else if(!M0.LITERAL_TYPES.has(A))_.symbol=this.resolveSymbol(_,_.value,A);else _.type=D.STRING}handleClientScriptExpression(_,A){let{name:R,line:U,column:N}=_.source,Y=new m1(R,this.diagnostics,U-1,N),X=H0.fromString(_.value);X.name=R;let Q=V1.invokeParser(X,($)=>$.clientScript(),Y,U-1,N);if(!Q){_.type=W.Error;return}Q.typeHint=A,this.visitNodeOrNull(Q),_.subExpression=Q,_.type=Q.type}visitJoinedStringExpression(_){_.parts.forEach((A)=>A.accept(this)),_.type=D.STRING}visitJoinedStringPart(_){if(_ instanceof u0){let A=_.expression;A.typeHint=D.STRING,A.accept(this),this.checkTypeMatch(A,D.STRING,A.type??W.Error)}}visitIdentifier(_){let{text:A,typeHint:R}=_;if(this.checkDynamicCommand(A,_))return;let U=this.resolveSymbol(_,A,R??void 0);if(!U)return;if(U instanceof V0&&U.trigger===this.commandTrigger&&U.parameters!==W.Unit)_.reportError(this.diagnostics,E.GENERIC_TYPE_MISMATCH,"<unit>",U.parameters.representation);_.reference=U}resolveSymbol(_,A,R){let U=null,N=null;for(let Y of this.table.findAll(A)){let X=this.symbolToType(Y);if(!X)continue;if(!R&&X instanceof W.Script)continue;else if(!R||this.typeManager.check(R,X)){U=Y,N=X;break}else if(!U)U=Y,N=X}if(!U)return _.type=W.Error,_.reportError(this.diagnostics,E.GENERIC_UNRESOLVED_SYMBOL,A),null;if(!N)return _.type=W.Error,_.reportError(this.diagnostics,E.UNSUPPORTED_SYMBOLTYPE_TO_TYPE,U.constructor.name),null;return _.type=N,U}symbolToType(_){if(_ instanceof V0)if(_.trigger===Y0)return _.returns;else return new W.Script(_.trigger,_.parameters,_.returns);else if(_ instanceof F0)if(_.type instanceof s)return _.type;else return null;else if(_ instanceof r)return _.type;else if(_ instanceof I1)return null;return null}visitToken(_){}visitNode(_){let A=_.parent;if(!A)_.reportInfo(this.diagnostics,`Unhandled node: ${_.constructor.name}.`);else _.reportInfo(this.diagnostics,`Unhandled node: ${_.constructor.name}. Parent: ${A.constructor.name}.`)}typeHintExpressionList(_,A){let R=[],U=0;for(let N of A)if(N.typeHint=U<_.length?_[U]:null,N.accept(this),R.push(this.getSafeType(N)),N.type instanceof M)U+=N.type.children.length;else U+=1;return R}checkTypeMatch(_,A,R,U=!0){let N=A instanceof M?A.children:[A],Y=R instanceof M?R.children:[R],X=!0;if(A===W.Error)X=!0;else if(N.length!==Y.length)X=!1;else for(let Q=0;Q<N.length;Q++)X=X&&this.typeManager.check(N[Q],Y[Q]);if(!X&&U){let Q=R===W.Unit?"<unit>":R.representation;_.reportError(this.diagnostics,E.GENERIC_TYPE_MISMATCH,Q,A.representation)}return X}checkTypeMatchAny(_,A,R){for(let U of A)if(this.checkTypeMatch(_,U,R,!1))return!0;return!1}visitNodeOrNull(_){if(!_)return;_.accept(this)}visitNodes(_){if(!_)return;for(let A of _)this.visitNodeOrNull(A)}getSafeType(_){return _&&_.type?_.type:W.Error}static ALLOWED_LOGICAL_TYPES=[D.BOOLEAN];static ALLOWED_RELATIONAL_TYPES=[D.INT,D.LONG];static ALLOWED_ARITHMETIC_TYPES=[D.INT,D.LONG];static LITERAL_TYPES=new Set([D.INT,D.BOOLEAN,D.COORD,D.STRING,D.CHAR,D.LONG]);static DISCARD_ERROR_LISTENER={syntaxError(_,A,R,U,N,Y){},reportAmbiguity:function(_,A,R,U,N,Y,X){},reportAttemptingFullContext:function(_,A,R,U,N,Y){},reportContextSensitivity:function(_,A,R,U,N,Y){}}}class w2{parent;symbols=new Map;constructor(_=null){this.parent=_}insert(_,A){let R=this;while(R){if(R.symbols.get(_)?.has(A.name))return!1;R=R.parent}let U=this.symbols.get(_);if(!U)U=new Map,this.symbols.set(_,U);return U.set(A.name,A),!0}find(_,A){let U=this.symbols.get(_)?.get(A);if(U)return U;return this.parent?.find(_,A)??null}findAll(_,A){let R=[];for(let U of this.symbols.values()){let N=U.get(_);if(N&&(!A||N instanceof A))R.push(N)}if(this.parent)R.push(...this.parent.findAll(_,A));return R}createSubTable(){return new w2(this)}}class T3{nameToTrigger=new Map;register(_,A){if(this.nameToTrigger.has(_))throw Error(`Trigger '${_}' is already registered.`);this.nameToTrigger.set(_,A)}registerTrigger(_){this.register(_.identifier,_)}registerAll(_){for(let A of _.ALL)this.registerTrigger(A)}find(_){let A=this.nameToTrigger.get(_);if(!A)throw Error(`Unable to find trigger '${_}'.`);return A}findOrNull(_){return this.nameToTrigger.get(_)??null}}class y3{nameToType=new Map;checkers=[];register(_,A){if(typeof _==="string"){if(this.nameToType.get(_))throw Error(`Type '${_} is already registered.`);if(!A)throw Error("Type must be provided.");this.nameToType.set(_,A)}else{let R=_.representation;if(this.nameToType.get(R))throw Error(`Type '${R}' is already registered.`);this.nameToType.set(R,_)}}registerNew(_,A,R=0,U=-1,N){let Y=new d;if(N)N(Y);let X={representation:_,code:A,baseType:R,defaultValue:U,options:Y};return this.register(X),X}registerAll(_){for(let A of _.ALL)this.register(A)}changeOptions(_,A){let R=this.nameToType.get(_);if(!R)throw Error(`'${_}' was not found.`);let U=R.options;A(U)}find(_,A=!1){let R=this.findOrNull(_,A);if(!R)throw Error(`Unable to find type: '${_}'.`);return R}findOrNull(_,A=!1){if(A&&_.endsWith("array")){let R=_.substring(0,_.length-5),U=this.findOrNull(R);if(!U||!U.options.allowArray)return null;return new s(U)}return this.nameToType.get(_)??null}addTypeChecker(_){this.checkers.push(_)}check(_,A){return this.checkers.some((R)=>R(_,A))}}class E2{scriptWriter;commandPointers;logger=console;sourcePaths;excludePaths;rootTable=new w2;symbolLoaders=[];dynamicCommandHandlers=new Map;types=new y3;triggers=new T3;static DEFAULT_DIAGNOSTICS_HANDLER=new x2;diagnosticsHandler=E2.DEFAULT_DIAGNOSTICS_HANDLER;constructor(_,A,R,U){this.scriptWriter=R;this.commandPointers=U;this.sourcePaths=_.map((N)=>this.normalizePath(N)),this.excludePaths=A.map((N)=>this.normalizePath(N)),this.types.registerAll(D),this.setupDefaultTypeCheckers(),this.triggers.registerTrigger(Y0)}setupDefaultTypeCheckers(){this.types.addTypeChecker((_,A)=>_===W.Any),this.types.addTypeChecker((_,A)=>A===W.Nothing),this.types.addTypeChecker((_,A)=>_===W.Error||A===W.Error),this.types.addTypeChecker((_,A)=>_===A),this.types.addTypeChecker((_,A)=>_ instanceof W.Script&&A instanceof W.Script&&_.trigger===A.trigger&&this.types.check(_.parameterType,A.parameterType)&&this.types.check(_.returnType,A.returnType)),this.types.addTypeChecker((_,A)=>_ instanceof W.Hook&&A instanceof W.Hook&&this.types.check(_.transmitListType,A.transmitListType)),this.types.addTypeChecker((_,A)=>{let R="inner"in _&&_.inner!=null,U="inner"in A&&A.inner!=null;if(!R||!U)return!1;if(_.constructor.name!==A.constructor.name)return!1;return this.types.check(_.inner,A.inner)}),this.types.addTypeChecker((_,A)=>{if(!(_ instanceof M)||!(A instanceof M))return!1;if(_.children.length!==A.children.length)return!1;for(let R=0;R<_.children.length;R++)if(!this.types.check(_.children[R],A.children[R]))return!1;return!0}),this.types.addTypeChecker((_,A)=>{return _.representation===A.representation})}addSymbolLoader(_){this.symbolLoaders.push(_)}addDynamicCommandHandler(_,A){if(this.dynamicCommandHandlers.has(_))throw Error(`A dynamic command handler with the name of '${_}' already exists.`);this.dynamicCommandHandlers.set(_,A)}run(_){if(this.loadSymbols(),this.compile(_),"close"in this.scriptWriter)this.scriptWriter.close()}loadSymbols(){for(let _ of this.symbolLoaders)_.load(this.rootTable,this)}compile(_){let[A,R]=this.parse(_);if(!A)return;if(!this.analyze(R))return;let[N,Y]=this.codegen(R);if(!N)return;if(!this.checkPointers(Y))return;this.write(Y)}parse(_){let A=new U1,R=[],U=0;for(let N of this.sourcePaths){let Y=this.walkTopDown(N);for(let X of Y){if(!X.endsWith(`.${_}`))continue;let Q=new m1(X,A),$=V1.createScriptFile(X,Q);if($)R.push($);U++}}return this.diagnosticsHandler.handleParse?.(A),[A.hasErrors()===!1,R]}analyze(_){let A=new U1,R=new g2(this.types,this.triggers,this.rootTable,A);for(let N of _)N.accept(R);let U=new M0(this.types,this.triggers,this.rootTable,this.dynamicCommandHandlers,A);for(let N of _)N.accept(U);return this.diagnosticsHandler.handleTypeChecking?.(A),!A.hasErrors()}codegen(_){let A=new U1,R=[];for(let U of _){let N=new e(this.rootTable,this.dynamicCommandHandlers,A);U.accept(N),R.push(...N.scripts)}return this.diagnosticsHandler.handleCodeGeneration?.(A),[A.hasErrors()===!1,R]}checkPointers(_){if(this.commandPointers.size<1)return!1;let A=new U1;return new m2(A,_,this.commandPointers).run(),this.diagnosticsHandler.handlePointerChecking?.(A),!A.hasErrors()}write(_){for(let A of _){if(this.isExcluded(A.sourceName))continue;this.scriptWriter.write(A)}}isExcluded(_){let A;try{A=$1.normalize($1.resolve(_))}catch{return!1}return this.excludePaths.some((R)=>{let U=$1.normalize(R);return A===U||A.startsWith(U+$1.sep)})}normalizePath(_){return $1.normalize($1.resolve(_))}walkTopDown(_){let A=[];for(let R of D6.readdirSync(_,{withFileTypes:!0})){let U=$1.join(_,R.name);if(R.isDirectory())A=A.concat(this.walkTopDown(U));else A.push(U)}return A}}class H1{addConstant(_,A,R){let U=new I1(A,R);if(!_.insert(x.constant(),U))throw Error(`Unable to add constant: name=${A}, value=${R}.`);return U}addBasic(_,A,R,U=!1){let N=new r(R,A,U);if(!_.insert(x.basic(A),N))throw Error(`Unable to add basic: type=${A}, name=${R}`);return N}}class c3 extends H1{symbols;constructor(_){super();this.symbols=_}load(_,A){for(let[R,U]of Object.entries(this.symbols.map))this.addConstant(_,R,U)}}class a3 extends H1{mapper;symbols;typeSupplier;constructor(_,A,R){super();this.mapper=_;this.symbols=A;this.typeSupplier=R}load(_,A){for(let[R,U]of Object.entries(this.symbols.map)){let N=parseInt(R),Y=W.Unit,X=this.symbols.vartype[R];if(X)Y=M.fromList(X.split(",").map((J)=>A.types.find(J)??W.Error));let Q=this.typeSupplier(Y),$=this.addBasic(_,Q,U);this.mapper.putSymbol(N,$)}}}class s3 extends H1{mapper;symbols;typeSupplier;constructor(_,A,R){super();this.mapper=_;this.symbols=A;this.typeSupplier=R}load(_,A){for(let[R,U]of Object.entries(this.symbols.map)){let N=parseInt(R),Y=W.Unit,X=this.symbols.vartype[R];if(typeof X<"u")Y=M.fromList(X.split(",").map((w)=>A.types.find(w)??W.Error));let Q=!1;if(typeof this.symbols.protect[R]<"u")Q=this.symbols.protect[R];let J=this.typeSupplier(Y),I=this.addBasic(_,J,U,Q);this.mapper.putSymbol(N,I)}}}class h0{inner;representation;code;baseType=0;defaultValue=-1;options;constructor(_){this.inner=_;this.representation=`dbcolumn<${_.representation}>`,this.options=new d({allowSwitch:!1,allowArray:!1,allowDeclaration:!1})}}class P1{withCount;constructor(_){this.withCount=_}typeCheck(_){let A=_.checkArgument(0,new h0(W.Any)),R=A?.type?.inner;_.checkArgument(1,R);let U=new M(new h0(R??W.Any),R??W.Any);if(R instanceof M)A.reportError(_.diagnostics,"Tuple columns are not supported.");else _.checkArgumentTypes(U);_.expression.type=this.withCount?D.INT:W.Unit}generateCode(_){let R=_.arguments[0].type.inner.baseType,U=(()=>{switch(R){case 0:return 0;case 2:return 1;case 1:return 2;default:throw Error(`Unsupported base type: ${R}.`)}})();_.visitNodes(_.arguments),_.instruction(H.PushConstantInt,U),_.command()}}class F extends l1{static ALL=[];constructor(_,A=0,R=-1,U){super();this.code=_,this.baseType=A,this.defaultValue=R,this.representation=U,this.options=new d,F.ALL.push(this)}static SEQ=new F("A",0,-1,"seq");static LOC_SHAPE=new F("H",0,-1,"locshape");static COMPONENT=new F("I",0,-1,"component");static IDKIT=new F("K",0,-1,"idkit");static MIDI=new F("M",0,-1,"midi");static NPC_MODE=new F("N",0,-1,"npc_mode");static NAMEDOBJ=new F("O",0,-1,"namedobj");static SYNTH=new F("P",0,-1,"synth");static AREA=new F("R",0,-1,"area");static STAT=new F("S",0,-1,"stat");static NPC_STAT=new F("T",0,-1,"npc_stat");static WRITEINV=new F("V",0,-1,"writeinv");static MAPAREA=new F("`",0,-1,"wma");static GRAPHIC=new F("d",0,-1,"graphic");static FONTMETRICS=new F("f",0,-1,"fontmetrics");static ENUM=new F("g",0,-1,"enum");static HUNT=new F("h",0,-1,"hunt");static JINGLE=new F("j",0,-1,"jingle");static LOC=new F("l",0,-1,"loc");static MODEL=new F("m",0,-1,"model");static NPC=new F("n",0,-1,"npc");static OBJ=new F("o",0,-1,"obj");static PLAYER_UID=new F("p",0,-1,"player_uid");static SPOTANIM=new F("t",0,-1,"spotanim");static NPC_UID=new F("u",0,-1,"npc_uid");static INV=new F("v",0,-1,"inv");static TEXTURE=new F("x",0,-1,"texture");static CATEGORY=new F("y",0,-1,"category");static MAPELEMENT=new F("µ",0,-1,"mapelement");static HITMARK=new F("×",0,-1,"hitmark");static STRUCT=new F("J",0,-1,"struct");static DBROW=new F("Ð",0,-1,"dbrow");static INTERFACE=new F("a",0,-1,"interface");static TOPLEVELINTERFACE=new F("F",0,-1,"toplevelinterface");static OVERLAYINTERFACE=new F("L",0,-1,"overlayinterface");static MOVESPEED=new F("Ý",0,-1,"movespeed");static ENTITYOVERLAY=new F("-",0,-1,"entityoverlay");static DBTABLE=new F("Ø",0,-1,"dbtable");static STRINGVECTOR=new F("¸",0,-1,"stringvector");static MESANIM=new F("Á",0,-1,"mesanim");static VERIFY_OBJECT=new F("®",0,-1,"verifyobj")}class n3{typeCheck(_){_.checkArgument(0,F.DBROW);let A=_.checkArgument(1,new h0(W.Any));_.checkArgument(2,D.INT);let R=A?.type?.inner,U=new M(F.DBROW,new h0(R??W.Any),D.INT);if(!_.checkArgumentTypes(U)){_.expression.type=W.Error;return}if(A==null){(A??_.expression).reportError(_.diagnostics,"Unable to extract type from argument."),_.expression.type=W.Error;return}_.expression.type=R}}class o3{typeCheck(_){let A=_.checkTypeArgument(0),R=_.checkTypeArgument(1);_.checkArgument(2,F.ENUM);let U=A?.type instanceof W.Type?A.type.inner:void 0,N=R?.type instanceof W.Type?R.type.inner:void 0;_.checkArgument(3,U);let Y=new M(new W.Type(U??W.Any),new W.Type(N??W.Any),F.ENUM,U??W.Any);_.checkArgumentTypes(Y),_.expression.type=N??W.Error}}class k2{queueType;constructor(_){this.queueType=_}typeCheck(_){_.checkArgument(0,this.queueType),_.checkArgument(1,D.INT),_.checkArgument(2,D.INT),_.checkArgument(3,D.INT);let A=[this.queueType,D.INT,D.INT,D.INT];_.checkArgumentTypes(M.fromList(A)),_.expression.type=W.Unit}}class C2{queueType;constructor(_){this.queueType=_}typeCheck(_){let A=_.checkArgument(0,this.queueType);_.checkArgument(1,D.INT),_.checkArgument(2,D.INT);let R=[this.queueType,D.INT,D.INT],U=[],N=A?.type;if(N instanceof W.Script&&N.trigger==this.queueType.trigger&&N.parameterType!=W.Unit)U.push(...M.toList(N.parameterType));_.checkArgumentTypes(M.fromList(R),!0,!1),_.checkArgumentTypes(M.fromList(U),!0,!0),_.expression.type=W.Unit}generateCode(_){let A=_.arguments;_.visitNodes(A);let R=_.arguments2;if(_.visitNodes(R),R.length>0){let U=R.map((N)=>N.type.code).filter((N)=>N!=null).join("");_.instruction(H.PushConstantString,U)}else _.instruction(H.PushConstantString,"");_.command()}}class F1{inner;representation;code;baseType=0;defaultValue=-1;options;constructor(_){this.inner=_;this.representation=`param<${_.representation}>`,this.options=new d({allowSwitch:!1,allowArray:!1,allowDeclaration:!1})}}class j0{type;constructor(_){this.type=_}typeCheck(_){let A=[];if(this.type!==null)A.push(this.type),_.checkArgument(0,this.type);let R=this.type===null?0:1,U=_.checkArgument(R,j0.PARAM_ANY),N=U?.type instanceof F1?U.type.inner:void 0;if(A.push(new F1(N??W.Any)),!_.checkArgumentTypes(M.fromList(A))){_.expression.type=W.Error;return}if(N==null){_.expression.reportError(_.diagnostics,"Param return type was not able to be found."),_.expression.type=W.Error;return}_.expression.type=N}static PARAM_ANY=new F1(W.Any)}class i0{queueType;constructor(_){this.queueType=_}typeCheck(_){_.checkArgument(0,this.queueType),_.checkArgument(1,D.INT),_.checkArgument(2,D.INT);let A=[this.queueType,D.INT,D.INT];_.checkArgumentTypes(M.fromList(A)),_.expression.type=W.Unit}}class t0{queueType;constructor(_){this.queueType=_}typeCheck(_){let A=_.checkArgument(0,this.queueType);_.checkArgument(1,D.INT);let R=[this.queueType,D.INT],U=[],N=A?.type;if(N instanceof W.Script&&N.trigger==this.queueType.trigger&&N.parameterType!=W.Unit)U.push(...M.toList(N.parameterType));_.checkArgumentTypes(M.fromList(R),!0,!1),_.checkArgumentTypes(M.fromList(U),!0,!0),_.expression.type=W.Unit}generateCode(_){let A=_.arguments;_.visitNodes(A);let R=_.arguments2;if(_.visitNodes(R),R.length>0){let U=R.map((N)=>N.type.code).filter((N)=>N!=null).join("");_.instruction(H.PushConstantString,U)}else _.instruction(H.PushConstantString,"");_.command()}}class b1{timerType;constructor(_){this.timerType=_}typeCheck(_){let A=_.checkArgument(0,this.timerType);_.checkArgument(1,D.INT);let R=A?.type,U=[this.timerType,D.INT];if(R instanceof W.Script&&R.trigger==this.timerType.trigger&&R.parameterType!=W.Unit)U.push(...M.toList(R.parameterType));_.checkArgumentTypes(M.fromList(U)),_.expression.type=W.Unit}generateCode(_){let A=_.arguments;if(_.visitNodes(A),A.length>2){let R=A.slice(2).map((U)=>U.type.code).filter((U)=>U!=null).join("");_.instruction(H.PushConstantString,R)}else _.instruction(H.PushConstantString,"");_.command()}}class p3 extends P0{visitBinaryExpression(_){return`${this.visit(_.left)} ${_.operator.text} ${this.visit(_.right)}`}visitCalcExpression(_){return`calc${this.visit(_.expression)}`}visitCommandCallExpression(_){let A="~"+this.visit(_.name);if(_.arguments.length>0)A+="(",A+=_.arguments.map((R)=>this.visit(R)).join(""),A+=")";return A}visitLocalVariableExpression(_){return`$${this.visit(_.name)}`}visitGameVariableExpression(_){return`%${this.visit(_.name)}`}visitConstantVariableExpression(_){return`^${this.visit(_.name)}`}visitCharacterLiteral(_){return`'${_.value}'`}visitNullLiteral(_){return"null"}visitStringLiteral(_){return`"${_.value}"`}visitLiteral(_){return String(_.value)}visitJoinedStringExpression(_){let A='"';for(let R of _.parts)A+=this.visit(R);return A+='"',A}visitJoinedStringPart(_){if(_ instanceof v0)return _.value;if(_ instanceof u0)return`<${this.visit(_.expression)}>`;throw Error(`Unsupported StringPart: ${_}`)}visitIdentifier(_){return _.text}visit(_){_.accept(this)}}class J1{typeCheck(_){if(_.arguments.length===0)_.expression.reportError(_.diagnostics,J1.DIAGNOSTIC_INVALID_SIGNATURE);else _.arguments.forEach((A,R)=>{_.checkArgument(R,W.Any);let U=A.type;if(U instanceof M)A.reportError(_.diagnostics,J1.DIAGNOSTIC_TUPLE_TYPE,U.representation);else if(U.baseType!==0&&U.baseType!==1)A.reportError(_.diagnostics,J1.DIAGNOSTIC_UNIT_TYPE,U.representation)});_.expression.type=D.STRING}generateCode(_){_.lineInstruction(_.expression);let A=0;_.arguments.forEach((R,U)=>{let N=R.accept(J1.EXPRESSION_GENERATOR);if(_.instruction(H.PushConstantString,`${N}=`),A++,_.visitNode(R),this.typeToString(_,R.type),U!==_.arguments.length-1)_.instruction(H.PushConstantString,", "),A++}),_.instruction(H.JoinString,A)}typeToString(_,A){let R;if(A===D.STRING)R="escape";else if(A.baseType===0)R="toString";else throw Error(`Unsupported type conversion to string: ${A}`);let U=_.rootTable.find(x.serverScript(Y0),R);if(U)_.instruction(H.Command,U)}static DIAGNOSTIC_INVALID_SIGNATURE="Type mismatch: '<unit>' was given but 'any...' was expected.";static DIAGNOSTIC_TUPLE_TYPE="Unable to dump multi-value types: %s";static DIAGNOSTIC_INVALID_BASE_TYPE="Unable to debug '%s' expressions.";static DIAGNOSTIC_UNIT_TYPE="Unable to debug expression with no return value.";static EXPRESSION_GENERATOR=new p3}class i3{typeCheck(_){_.checkArgumentTypes(W.Unit),_.expression.type=D.STRING}generateCode(_){let A=_.expression.findParentByType(o0);if(!A)throw Error("Script not found.");let R=`[${A.trigger.text}, ${A.name.text}]`;_.lineInstruction(_.expression),_.instruction(H.PushConstantString,R)}}class z{static ALL=[];id;subjectMode;allowParameters;parameters;allowReturns;returns;pointers;identifier;constructor({id:_,name:A,subjectMode:R,allowParameters:U=!1,parameters:N=null,allowReturns:Y=!1,returns:X=null,pointers:Q=null}){if(this.id=_,R==null)this.subjectMode=K.Name;else this.subjectMode=R;this.allowParameters=U,this.parameters=N,this.allowReturns=Y,this.returns=X,this.pointers=Q??null,this.identifier=A.toLowerCase(),z.ALL.push(this)}static PROC=new z({id:0,name:"PROC",subjectMode:K.Name,allowParameters:!0,allowReturns:!0,pointers:new Set(Object.values(G))});static LABEL=new z({id:1,name:"LABEL",subjectMode:K.Name,allowParameters:!0,pointers:new Set(Object.values(G))});static DEBUGPROC=new z({id:2,name:"DEBUGPROC",subjectMode:K.Name,allowParameters:!0,pointers:new Set([G.ACTIVE_PLAYER])});static APNPC1=new z({id:3,name:"APNPC1",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_NPC])});static APNPC2=new z({id:4,name:"APNPC2",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_NPC])});static APNPC3=new z({id:5,name:"APNPC3",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_NPC])});static APNPC4=new z({id:6,name:"APNPC4",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_NPC])});static APNPC5=new z({id:7,name:"APNPC5",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_NPC])});static APNPCU=new z({id:8,name:"APNPCU",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_USEITEM,G.LAST_USESLOT,G.ACTIVE_NPC])});static APNPCT=new z({id:9,name:"APNPCT",subjectMode:K.Type(F.COMPONENT,!1,!1),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_NPC])});static OPNPC1=new z({id:10,name:"OPNPC1",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_NPC])});static OPNPC2=new z({id:11,name:"OPNPC2",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_NPC])});static OPNPC3=new z({id:12,name:"OPNPC3",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_NPC])});static OPNPC4=new z({id:13,name:"OPNPC4",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_NPC])});static OPNPC5=new z({id:14,name:"OPNPC5",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_NPC])});static OPNPCU=new z({id:15,name:"OPNPCU",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_USEITEM,G.LAST_USESLOT,G.ACTIVE_NPC])});static OPNPCT=new z({id:16,name:"OPNPCT",subjectMode:K.Type(F.COMPONENT,!1,!1),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_NPC])});static AI_APNPC1=new z({id:17,name:"AI_APNPC1",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_NPC2])});static AI_APNPC2=new z({id:18,name:"AI_APNPC2",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_NPC2])});static AI_APNPC3=new z({id:19,name:"AI_APNPC3",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_NPC2])});static AI_APNPC4=new z({id:20,name:"AI_APNPC4",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_NPC2])});static AI_APNPC5=new z({id:21,name:"AI_APNPC5",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_NPC2])});static AI_OPNPC1=new z({id:24,name:"AI_OPNPC1",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_NPC2])});static AI_OPNPC2=new z({id:25,name:"AI_OPNPC2",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_NPC2])});static AI_OPNPC3=new z({id:26,name:"AI_OPNPC3",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_NPC2])});static AI_OPNPC4=new z({id:27,name:"AI_OPNPC4",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_NPC2])});static AI_OPNPC5=new z({id:28,name:"AI_OPNPC5",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_NPC2])});static APOBJ1=new z({id:31,name:"APOBJ1",subjectMode:K.Type(F.NAMEDOBJ),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_OBJ])});static APOBJ2=new z({id:32,name:"APOBJ2",subjectMode:K.Type(F.NAMEDOBJ),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_OBJ])});static APOBJ3=new z({id:33,name:"APOBJ3",subjectMode:K.Type(F.NAMEDOBJ),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_OBJ])});static APOBJ4=new z({id:34,name:"APOBJ4",subjectMode:K.Type(F.NAMEDOBJ),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_OBJ])});static APOBJ5=new z({id:35,name:"APOBJ5",subjectMode:K.Type(F.NAMEDOBJ),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_OBJ])});static APOBJU=new z({id:36,name:"APOBJU",subjectMode:K.Type(F.NAMEDOBJ),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_USEITEM,G.LAST_USESLOT,G.ACTIVE_OBJ])});static APOBJT=new z({id:37,name:"APOBJT",subjectMode:K.Type(F.COMPONENT,!1,!1),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_OBJ])});static OPOBJ1=new z({id:38,name:"OPOBJ1",subjectMode:K.Type(F.NAMEDOBJ),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_OBJ])});static OPOBJ2=new z({id:39,name:"OPOBJ2",subjectMode:K.Type(F.NAMEDOBJ),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_OBJ])});static OPOBJ3=new z({id:40,name:"OPOBJ3",subjectMode:K.Type(F.NAMEDOBJ),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_OBJ])});static OPOBJ4=new z({id:41,name:"OPOBJ4",subjectMode:K.Type(F.NAMEDOBJ),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_OBJ])});static OPOBJ5=new z({id:42,name:"OPOBJ5",subjectMode:K.Type(F.NAMEDOBJ),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_OBJ])});static OPOBJU=new z({id:43,name:"OPOBJU",subjectMode:K.Type(F.NAMEDOBJ),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_USEITEM,G.LAST_USESLOT,G.ACTIVE_OBJ])});static OPOBJT=new z({id:44,name:"OPOBJT",subjectMode:K.Type(F.COMPONENT,!1,!1),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_OBJ])});static AI_APOBJ1=new z({id:45,name:"AI_APOBJ1",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_OBJ])});static AI_APOBJ2=new z({id:46,name:"AI_APOBJ2",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_OBJ])});static AI_APOBJ3=new z({id:47,name:"AI_APOBJ3",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_OBJ])});static AI_APOBJ4=new z({id:48,name:"AI_APOBJ4",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_OBJ])});static AI_APOBJ5=new z({id:49,name:"AI_APOBJ5",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_OBJ])});static AI_OPOBJ1=new z({id:52,name:"AI_OPOBJ1",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_OBJ])});static AI_OPOBJ2=new z({id:53,name:"AI_OPOBJ2",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_OBJ])});static AI_OPOBJ3=new z({id:54,name:"AI_OPOBJ3",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_OBJ])});static AI_OPOBJ4=new z({id:55,name:"AI_OPOBJ4",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_OBJ])});static AI_OPOBJ5=new z({id:56,name:"AI_OPOBJ5",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_OBJ])});static APLOC1=new z({id:59,name:"APLOC1",subjectMode:K.Type(F.LOC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_LOC])});static APLOC2=new z({id:60,name:"APLOC2",subjectMode:K.Type(F.LOC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_LOC])});static APLOC3=new z({id:61,name:"APLOC3",subjectMode:K.Type(F.LOC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_LOC])});static APLOC4=new z({id:62,name:"APLOC4",subjectMode:K.Type(F.LOC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_LOC])});static APLOC5=new z({id:63,name:"APLOC5",subjectMode:K.Type(F.LOC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_LOC])});static APLOCU=new z({id:64,name:"APLOCU",subjectMode:K.Type(F.LOC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_USEITEM,G.LAST_USESLOT,G.ACTIVE_LOC])});static APLOCT=new z({id:65,name:"APLOCT",subjectMode:K.Type(F.COMPONENT,!1,!1),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_LOC])});static OPLOC1=new z({id:66,name:"OPLOC1",subjectMode:K.Type(F.LOC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_LOC])});static OPLOC2=new z({id:67,name:"OPLOC2",subjectMode:K.Type(F.LOC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_LOC])});static OPLOC3=new z({id:68,name:"OPLOC3",subjectMode:K.Type(F.LOC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_LOC])});static OPLOC4=new z({id:69,name:"OPLOC4",subjectMode:K.Type(F.LOC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_LOC])});static OPLOC5=new z({id:70,name:"OPLOC5",subjectMode:K.Type(F.LOC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_LOC])});static OPLOCU=new z({id:71,name:"OPLOCU",subjectMode:K.Type(F.LOC),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_USEITEM,G.LAST_USESLOT,G.ACTIVE_LOC])});static OPLOCT=new z({id:72,name:"OPLOCT",subjectMode:K.Type(F.COMPONENT,!1,!1),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_LOC])});static AI_APLOC1=new z({id:73,name:"AI_APLOC1",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_LOC])});static AI_APLOC2=new z({id:74,name:"AI_APLOC2",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_LOC])});static AI_APLOC3=new z({id:75,name:"AI_APLOC3",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_LOC])});static AI_APLOC4=new z({id:76,name:"AI_APLOC4",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_LOC])});static AI_APLOC5=new z({id:77,name:"AI_APLOC5",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_LOC])});static AI_OPLOC1=new z({id:80,name:"AI_OPLOC1",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_LOC])});static AI_OPLOC2=new z({id:81,name:"AI_OPLOC2",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_LOC])});static AI_OPLOC3=new z({id:82,name:"AI_OPLOC3",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_LOC])});static AI_OPLOC4=new z({id:83,name:"AI_OPLOC4",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_LOC])});static AI_OPLOC5=new z({id:84,name:"AI_OPLOC5",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_LOC])});static APPLAYER1=new z({id:87,name:"APPLAYER1",subjectMode:K.None,pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_PLAYER2])});static APPLAYER2=new z({id:88,name:"APPLAYER2",subjectMode:K.None,pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_PLAYER2])});static APPLAYER3=new z({id:89,name:"APPLAYER3",subjectMode:K.None,pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_PLAYER2])});static APPLAYER4=new z({id:90,name:"APPLAYER4",subjectMode:K.None,pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_PLAYER2])});static APPLAYER5=new z({id:91,name:"APPLAYER5",subjectMode:K.None,pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_PLAYER2])});static APPLAYERU=new z({id:92,name:"APPLAYERU",subjectMode:K.Type(F.NAMEDOBJ,!0,!1),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_USEITEM,G.LAST_USESLOT,G.ACTIVE_PLAYER2])});static APPLAYERT=new z({id:93,name:"APPLAYERT",subjectMode:K.Type(F.COMPONENT,!1,!1),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_PLAYER2])});static OPPLAYER1=new z({id:94,name:"OPPLAYER1",subjectMode:K.None,pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_PLAYER2])});static OPPLAYER2=new z({id:95,name:"OPPLAYER2",subjectMode:K.None,pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_PLAYER2])});static OPPLAYER3=new z({id:96,name:"OPPLAYER3",subjectMode:K.None,pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_PLAYER2])});static OPPLAYER4=new z({id:97,name:"OPPLAYER4",subjectMode:K.None,pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_PLAYER2])});static OPPLAYER5=new z({id:98,name:"OPPLAYER5",subjectMode:K.None,pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_PLAYER2])});static OPPLAYERU=new z({id:99,name:"OPPLAYERU",subjectMode:K.Type(F.NAMEDOBJ,!0,!1),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_USEITEM,G.LAST_USESLOT,G.ACTIVE_PLAYER2])});static OPPLAYERT=new z({id:100,name:"OPPLAYERT",subjectMode:K.Type(F.COMPONENT,!1,!1),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.ACTIVE_PLAYER2])});static AI_APPLAYER1=new z({id:101,name:"AI_APPLAYER1",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_PLAYER])});static AI_APPLAYER2=new z({id:102,name:"AI_APPLAYER2",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_PLAYER])});static AI_APPLAYER3=new z({id:103,name:"AI_APPLAYER3",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_PLAYER])});static AI_APPLAYER4=new z({id:104,name:"AI_APPLAYER4",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_PLAYER])});static AI_APPLAYER5=new z({id:105,name:"AI_APPLAYER5",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_PLAYER])});static AI_OPPLAYER1=new z({id:108,name:"AI_OPPLAYER1",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_PLAYER])});static AI_OPPLAYER2=new z({id:109,name:"AI_OPPLAYER2",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_PLAYER])});static AI_OPPLAYER3=new z({id:110,name:"AI_OPPLAYER3",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_PLAYER])});static AI_OPPLAYER4=new z({id:111,name:"AI_OPPLAYER4",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_PLAYER])});static AI_OPPLAYER5=new z({id:112,name:"AI_OPPLAYER5",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.ACTIVE_PLAYER])});static QUEUE=new z({id:116,name:"QUEUE",allowParameters:!0,pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER])});static AI_QUEUE1=new z({id:117,name:"AI_QUEUE1",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static AI_QUEUE2=new z({id:118,name:"AI_QUEUE2",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static AI_QUEUE3=new z({id:119,name:"AI_QUEUE3",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static AI_QUEUE4=new z({id:120,name:"AI_QUEUE4",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static AI_QUEUE5=new z({id:121,name:"AI_QUEUE5",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static AI_QUEUE6=new z({id:122,name:"AI_QUEUE6",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static AI_QUEUE7=new z({id:123,name:"AI_QUEUE7",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static AI_QUEUE8=new z({id:124,name:"AI_QUEUE8",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static AI_QUEUE9=new z({id:125,name:"AI_QUEUE9",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static AI_QUEUE10=new z({id:126,name:"AI_QUEUE10",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static AI_QUEUE11=new z({id:127,name:"AI_QUEUE11",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static AI_QUEUE12=new z({id:128,name:"AI_QUEUE12",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static AI_QUEUE13=new z({id:129,name:"AI_QUEUE13",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static AI_QUEUE14=new z({id:130,name:"AI_QUEUE14",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static AI_QUEUE15=new z({id:131,name:"AI_QUEUE15",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static AI_QUEUE16=new z({id:132,name:"AI_QUEUE16",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static AI_QUEUE17=new z({id:133,name:"AI_QUEUE17",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static AI_QUEUE18=new z({id:134,name:"AI_QUEUE18",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static AI_QUEUE19=new z({id:135,name:"AI_QUEUE19",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static AI_QUEUE20=new z({id:136,name:"AI_QUEUE20",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC,G.LAST_INT])});static SOFTTIMER=new z({id:137,name:"SOFTTIMER",allowParameters:!0,pointers:new Set([G.ACTIVE_PLAYER])});static TIMER=new z({id:138,name:"TIMER",allowParameters:!0,pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER])});static AI_TIMER=new z({id:139,name:"AI_TIMER",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC])});static OPHELD1=new z({id:140,name:"OPHELD1",subjectMode:K.Type(F.NAMEDOBJ),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_ITEM,G.LAST_SLOT])});static OPHELD2=new z({id:141,name:"OPHELD2",subjectMode:K.Type(F.NAMEDOBJ),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_ITEM,G.LAST_SLOT])});static OPHELD3=new z({id:142,name:"OPHELD3",subjectMode:K.Type(F.NAMEDOBJ),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_ITEM,G.LAST_SLOT])});static OPHELD4=new z({id:143,name:"OPHELD4",subjectMode:K.Type(F.NAMEDOBJ),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_ITEM,G.LAST_SLOT])});static OPHELD5=new z({id:144,name:"OPHELD5",subjectMode:K.Type(F.NAMEDOBJ),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_ITEM,G.LAST_SLOT])});static OPHELDU=new z({id:145,name:"OPHELDU",subjectMode:K.Type(F.NAMEDOBJ),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_ITEM,G.LAST_SLOT,G.LAST_USEITEM,G.LAST_USESLOT])});static OPHELDT=new z({id:146,name:"OPHELDT",subjectMode:K.Type(F.COMPONENT,!1,!1),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_ITEM,G.LAST_SLOT])});static IF_BUTTON=new z({id:147,name:"IF_BUTTON",subjectMode:K.Type(F.COMPONENT),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_COM])});static IF_CLOSE=new z({id:148,name:"IF_CLOSE",subjectMode:K.Type(F.INTERFACE),pointers:new Set([G.ACTIVE_PLAYER])});static INV_BUTTON1=new z({id:149,name:"INV_BUTTON1",subjectMode:K.Type(F.COMPONENT),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_ITEM,G.LAST_SLOT])});static INV_BUTTON2=new z({id:150,name:"INV_BUTTON2",subjectMode:K.Type(F.COMPONENT),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_ITEM,G.LAST_SLOT])});static INV_BUTTON3=new z({id:151,name:"INV_BUTTON3",subjectMode:K.Type(F.COMPONENT),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_ITEM,G.LAST_SLOT])});static INV_BUTTON4=new z({id:152,name:"INV_BUTTON4",subjectMode:K.Type(F.COMPONENT),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_ITEM,G.LAST_SLOT])});static INV_BUTTON5=new z({id:153,name:"INV_BUTTON5",subjectMode:K.Type(F.COMPONENT),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_ITEM,G.LAST_SLOT])});static INV_BUTTOND=new z({id:154,name:"INV_BUTTOND",subjectMode:K.Type(F.COMPONENT),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER,G.LAST_SLOT,G.LAST_TARGETSLOT])});static WALKTRIGGER=new z({id:155,name:"WALKTRIGGER",subjectMode:K.Name,pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER])});static AI_WALKTRIGGER=new z({id:156,name:"AI_WALKTRIGGER",subjectMode:K.Name,pointers:new Set([G.ACTIVE_NPC])});static LOGIN=new z({id:157,name:"LOGIN",subjectMode:K.None,pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER])});static LOGOUT=new z({id:158,name:"LOGOUT",subjectMode:K.None,allowReturns:!0,returns:D.BOOLEAN,pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER])});static TUTORIAL=new z({id:159,name:"TUTORIAL",subjectMode:K.None,pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER])});static ADVANCESTAT=new z({id:160,name:"ADVANCESTAT",subjectMode:K.Type(F.STAT),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER])});static MAPZONE=new z({id:161,name:"MAPZONE",subjectMode:K.Type(D.MAPZONE),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER])});static MAPZONEEXIT=new z({id:162,name:"MAPZONEEXIT",subjectMode:K.Type(D.MAPZONE),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER])});static ZONE=new z({id:163,name:"ZONE",subjectMode:K.Type(D.COORD),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER])});static ZONEEXIT=new z({id:164,name:"ZONEEXIT",subjectMode:K.Type(D.COORD),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER])});static CHANGESTAT=new z({id:165,name:"CHANGESTAT",subjectMode:K.Type(F.STAT),pointers:new Set([G.ACTIVE_PLAYER,G.P_ACTIVE_PLAYER])});static AI_SPAWN=new z({id:166,name:"AI_SPAWN",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC])});static AI_DESPAWN=new z({id:167,name:"AI_DESPAWN",subjectMode:K.Type(F.NPC),pointers:new Set([G.ACTIVE_NPC])})}class t3 extends E2{symbols;mapper;constructor(_,A,R,U,N,Y){super(_,A,R,U);this.symbols=N,this.mapper=Y}setup(){this.triggers.registerAll(z),this.types.registerAll(F),this.types.changeOptions("long",(_)=>{_.allowDeclaration=!1}),this.types.register("proc",new W.Script(z.PROC,W.Unit,W.Unit)),this.types.register("label",new W.Script(z.LABEL,W.Unit,W.Nothing)),this.types.addTypeChecker((_,A)=>_===F.OBJ&&A===F.NAMEDOBJ),this.addSymConstantLoaders(),this.types.register("walktrigger",new W.Script(z.WALKTRIGGER,W.Any,W.Nothing)),this.types.register("ai_walktrigger",new W.Script(z.AI_WALKTRIGGER,W.Any,W.Nothing)),this.types.register("queue",new W.Script(z.QUEUE,W.Any,W.Nothing)),this.addDynamicCommandHandler("queue",new i0(this.types.find("queue"))),this.addDynamicCommandHandler(".queue",new i0(this.types.find("queue"))),this.addDynamicCommandHandler("queue*",new t0(this.types.find("queue"))),this.addDynamicCommandHandler(".queue*",new t0(this.types.find("queue"))),this.addDynamicCommandHandler("longqueue",new k2(this.types.find("queue"))),this.addDynamicCommandHandler(".longqueue",new k2(this.types.find("queue"))),this.addDynamicCommandHandler("longqueue*",new C2(this.types.find("queue"))),this.addDynamicCommandHandler(".longqueue*",new C2(this.types.find("queue"))),this.types.register("timer",new W.Script(z.TIMER,W.Any,W.Nothing)),this.addDynamicCommandHandler("settimer",new b1(this.types.find("timer"))),this.addDynamicCommandHandler(".settimer",new b1(this.types.find("timer"))),this.addDynamicCommandHandler("lc_param",new j0(F.LOC)),this.addDynamicCommandHandler("loc_param",new j0(null)),this.addSymLoader("loc",F.LOC),this.addDynamicCommandHandler("nc_param",new j0(F.NPC)),this.addDynamicCommandHandler("npc_param",new j0(null)),this.addSymLoader("npc",F.NPC),this.addDynamicCommandHandler("oc_param",new j0(F.OBJ)),this.addDynamicCommandHandler("obj_param",new j0(null)),this.addSymLoader("obj",F.NAMEDOBJ),this.addSymLoader("component",F.COMPONENT),this.addSymLoader("interface",F.INTERFACE),this.addSymLoader("overlayinterface",F.OVERLAYINTERFACE),this.addSymLoader("fontmetrics",F.FONTMETRICS),this.addSymLoader("category",F.CATEGORY),this.addSymLoader("hunt",F.HUNT),this.addSymLoader("inv",F.INV),this.addSymLoader("idk",F.IDKIT),this.addSymLoader("mesanim",F.MESANIM),this.addSymLoaderWithSupplier("param",(_)=>new F1(_)),this.addSymLoader("seq",F.SEQ),this.addSymLoader("spotanim",F.SPOTANIM),this.types.register("varp",new Q0(W.Any)),this.addProtectedSymLoaderWithSupplier("varp",(_)=>new Q0(_)),this.addSymLoaderWithSupplier("varn",(_)=>new J0(_)),this.addSymLoaderWithSupplier("vars",(_)=>new z1(_)),this.addSymLoader("stat",F.STAT),this.addSymLoader("locshape",F.LOC_SHAPE),this.addSymLoader("movespeed",F.MOVESPEED),this.addSymLoader("npc_mode",F.NPC_MODE),this.addSymLoader("npc_stat",F.NPC_STAT),this.addSymLoader("model",F.MODEL),this.addSymLoader("synth",F.SYNTH),this.addSymLoader("midi",F.MIDI),this.addSymLoader("jingle",F.JINGLE),this.types.register("varbit",new Z0(W.Any)),this.addProtectedSymLoaderWithSupplier("varbit",(_)=>new Z0(_)),this.addDynamicCommandHandler("weakqueue",new i0(this.types.find("queue"))),this.addDynamicCommandHandler(".weakqueue",new i0(this.types.find("queue"))),this.addDynamicCommandHandler("weakqueue*",new t0(this.types.find("queue"))),this.addDynamicCommandHandler(".weakqueue*",new t0(this.types.find("queue"))),this.addDynamicCommandHandler("strongqueue",new i0(this.types.find("queue"))),this.addDynamicCommandHandler(".strongqueue",new i0(this.types.find("queue"))),this.addDynamicCommandHandler("strongqueue*",new t0(this.types.find("queue"))),this.addDynamicCommandHandler(".strongqueue*",new t0(this.types.find("queue"))),this.addDynamicCommandHandler("enum",new o3),this.addSymLoader("enum",F.ENUM),this.addDynamicCommandHandler("struct_param",new j0(F.STRUCT)),this.addSymLoader("struct",F.STRUCT),this.types.register("softtimer",new W.Script(z.SOFTTIMER,W.Any,W.Nothing)),this.addDynamicCommandHandler("softtimer",new b1(this.types.find("softtimer"))),this.addDynamicCommandHandler(".softtimer",new b1(this.types.find("softtimer"))),this.types.register("dbcolumn",new h0(W.Any)),this.addDynamicCommandHandler("db_find",new P1(!1)),this.addDynamicCommandHandler("db_find_refine",new P1(!1)),this.addDynamicCommandHandler("db_find_with_count",new P1(!0)),this.addDynamicCommandHandler("db_find_refine_with_count",new P1(!0)),this.addDynamicCommandHandler("db_getfield",new n3),this.addSymLoaderWithSupplier("dbcolumn",(_)=>new h0(_)),this.addSymLoader("dbrow",F.DBROW),this.addSymLoader("dbtable",F.DBTABLE),this.addDynamicCommandHandler("dump",new J1),this.addDynamicCommandHandler("script",new i3)}addSymConstantLoaders(){if(this.symbols.constant)this.addSymbolLoader(new c3(this.symbols.constant))}addSymLoader(_,A){this.addSymLoaderWithSupplier(_,()=>A)}addSymLoaderWithSupplier(_,A){if(this.symbols[_])this.addSymbolLoader(new a3(this.mapper,this.symbols[_],A))}addProtectedSymLoader(_,A){this.addProtectedSymLoaderWithSupplier(_,()=>A)}addProtectedSymLoaderWithSupplier(_,A){if(this.symbols[_])this.addSymbolLoader(new s3(this.mapper,this.symbols[_],A))}}class r3{commands=new Map;scripts=new Map;symbols=new Map;putSymbol(_,A){if(this.symbols.has(A)){if(A.context?.diagnostics)A.context.diagnostics.report(`Duplicate symbol: ${A}.`);return}this.symbols.set(A,_)}putCommand(_,A){if(this.commands.has(A))return;this.commands.set(A,_)}putScript(_,A){if(this.scripts.has(A))return;this.scripts.set(A,_)}get(_){if(_ instanceof V0)if(_.trigger===Y0){let R=_.name.substring(_.name.indexOf(".")+1),U=this.commands.get(R);if(U===void 0){if(_.context?.diagnostics)_.context.diagnostics.report(`Unable to find id for '${_}'.`);return-1}return U}else{let R=`[${_.trigger.identifier},${_.name}]`,U=this.scripts.get(R);if(U===void 0){if(_.context?.diagnostics)_.context.diagnostics.report(`Unable to find id for '${_}'.`);return-1}return U}let A=this.symbols.get(_);if(A===void 0)throw Error(`Unable to find id for '${_}'.`);return A}}import f0 from"fs";import _4 from"path";class U0{idProvider;constructor(_){this.idProvider=_}write(_){let A=this.createContext(_);for(let R of _.blocks){this.enterBlock(A,R);for(let U of R.instructions)this.writeInstruction(A,U),A.curIndex++}this.finishWrite(_,A)}close(){}writeInstruction(_,A){let{opcode:R,operand:U}=A;switch(R){case H.PushConstantInt:this.writePushConstantInt(_,U);break;case H.PushConstantString:this.writePushConstantString(_,U);break;case H.PushConstantLong:this.writePushConstantLong(_,U);break;case H.PushConstantSymbol:this.writePushConstantSymbol(_,U);break;case H.PushLocalVar:this.writePushLocalVar(_,U);break;case H.PopLocalVar:this.writePopLocalVar(_,U);break;case H.PushVar:this.writePushVar(_,U,!1);break;case H.PushVar2:this.writePushVar(_,U,!0);break;case H.PopVar:this.writePopVar(_,U,!1);break;case H.PopVar2:this.writePopVar(_,U,!0);break;case H.DefineArray:this.writeDefineArray(_,U);break;case H.Switch:this.writeSwitch(_,U);break;case H.Branch:case H.BranchNot:case H.BranchEquals:case H.BranchLessThan:case H.BranchGreaterThan:case H.BranchLessThanOrEquals:case H.BranchGreaterThanOrEquals:case H.LongBranchNot:case H.LongBranchEquals:case H.LongBranchLessThan:case H.LongBranchGreaterThan:case H.LongBranchLessThanOrEquals:case H.LongBranchGreaterThanOrEquals:case H.ObjBranchNot:case H.ObjBranchEquals:this.writeBranch(_,R,U);break;case H.JoinString:this.writeJoinString(_,U);break;case H.Discard:this.writeDiscard(_,U);break;case H.Gosub:this.writeGosub(_,U);break;case H.Jump:this.writeJump(_,U);break;case H.Command:this.writeCommand(_,U);break;case H.Return:this.writeReturn(_);break;case H.Add:case H.Sub:case H.Multiply:case H.Divide:case H.Modulo:case H.Or:case H.And:case H.LongAdd:case H.LongSub:case H.LongMultiply:case H.LongDivide:case H.LongModulo:case H.LongOr:case H.LongAnd:this.writeMath(_,R);break;case H.LineNumber:throw Error("LineNumber opcode should not exist.")}}enterBlock(_,A){throw Error("Not implemented")}writePushConstantInt(_,A){throw Error("Not implemented")}writePushConstantString(_,A){throw Error("Not implemented")}writePushConstantLong(_,A){throw Error("Not implemented")}writePushConstantSymbol(_,A){throw Error("Not implemented")}writePushLocalVar(_,A){throw Error("Not implemented")}writePopLocalVar(_,A){throw Error("Not implemented")}writePushVar(_,A,R){throw Error("Not implemented")}writePopVar(_,A,R){throw Error("Not implemented")}writeDefineArray(_,A){throw Error("Not implemented")}writeSwitch(_,A){throw Error("Not implemented")}writeBranch(_,A,R){throw Error("Not implemented")}writeJoinString(_,A){throw Error("Not implemented")}writeDiscard(_,A){throw Error("Not implemented")}writeJump(_,A){throw Error("Not implemented")}writeGosub(_,A){throw Error("Not implemented")}writeCommand(_,A){throw Error("Not implemented")}writeReturn(_){throw Error("Not implemented")}writeMath(_,A){throw Error("Not implemented")}static generateLineNumberTable(_){let A=new Map,R=0,U=-1;for(let N of _.blocks)for(let Y of N.instructions){let X=Y.source?.line;if(X!==void 0&&X!==U)A.set(R,X),U=X;R++}return A}static generateJumpTable(_){let A=new Map,R=0;for(let U of _.blocks)A.set(U.label,R),R+=U.instructions.length;return A}static getParameterCount(_,A){return _.parameters.filter((R)=>R.type.baseType===A).length}static getLocalCount(_,A){return _.all.filter((R)=>R.type.baseType===A&&(!(R.type instanceof s)||_.parameters.includes(R))).length}static getVariableId(_,A){if(A.type instanceof s)return _.all.filter((R)=>R.type instanceof s).indexOf(A);return _.all.filter((R)=>R.type.baseType===A.type.baseType&&(!(R.type instanceof s)||_.parameters.includes(R))).indexOf(A)}}class e3{script;curIndex=0;lineNumberTable;jumpTable;constructor(_){this.script=_;this.lineNumberTable=U0.generateLineNumberTable(_),this.jumpTable=U0.generateJumpTable(_)}close(){}}class L{id;largeOperand;constructor(_,A=!1){this.id=_;this.largeOperand=A}static PUSH_CONSTANT_INT=new L(0,!0);static PUSH_VARP=new L(1,!0);static POP_VARP=new L(2,!0);static PUSH_CONSTANT_STRING=new L(3,!0);static PUSH_VARN=new L(4,!0);static POP_VARN=new L(5,!0);static BRANCH=new L(6,!0);static BRANCH_NOT=new L(7,!0);static BRANCH_EQUALS=new L(8,!0);static BRANCH_LESS_THAN=new L(9,!0);static BRANCH_GREATER_THAN=new L(10,!0);static PUSH_VARS=new L(11,!0);static POP_VARS=new L(12,!0);static RETURN=new L(21);static GOSUB=new L(22);static JUMP=new L(23);static SWITCH=new L(24,!0);static PUSH_VARBIT=new L(25,!0);static POP_VARBIT=new L(27,!0);static BRANCH_LESS_THAN_OR_EQUALS=new L(31,!0);static BRANCH_GREATER_THAN_OR_EQUALS=new L(32,!0);static PUSH_INT_LOCAL=new L(33,!0);static POP_INT_LOCAL=new L(34,!0);static PUSH_STRING_LOCAL=new L(35,!0);static POP_STRING_LOCAL=new L(36,!0);static JOIN_STRING=new L(37,!0);static POP_INT_DISCARD=new L(38);static POP_STRING_DISCARD=new L(39);static GOSUB_WITH_PARAMS=new L(40,!0);static JUMP_WITH_PARAMS=new L(41,!0);static DEFINE_ARRAY=new L(44,!0);static PUSH_ARRAY_INT=new L(45,!0);static POP_ARRAY_INT=new L(46,!0);static ADD=new L(4600);static SUB=new L(4601);static MULTIPLY=new L(4602);static DIVIDE=new L(4603);static MODULO=new L(4611);static AND=new L(4614);static OR=new L(4615);static ALL=[L.PUSH_CONSTANT_INT,L.PUSH_VARP,L.POP_VARP,L.PUSH_CONSTANT_STRING,L.PUSH_VARN,L.POP_VARN,L.BRANCH,L.BRANCH_NOT,L.BRANCH_EQUALS,L.BRANCH_LESS_THAN,L.BRANCH_GREATER_THAN,L.PUSH_VARS,L.POP_VARS,L.RETURN,L.GOSUB,L.JUMP,L.SWITCH,L.PUSH_VARBIT,L.POP_VARBIT,L.BRANCH_LESS_THAN_OR_EQUALS,L.BRANCH_GREATER_THAN_OR_EQUALS,L.PUSH_INT_LOCAL,L.POP_INT_LOCAL,L.PUSH_STRING_LOCAL,L.POP_STRING_LOCAL,L.JOIN_STRING,L.POP_INT_DISCARD,L.POP_STRING_DISCARD,L.GOSUB_WITH_PARAMS,L.JUMP_WITH_PARAMS,L.DEFINE_ARRAY,L.PUSH_ARRAY_INT,L.POP_ARRAY_INT,L.ADD,L.SUB,L.MULTIPLY,L.DIVIDE,L.MODULO,L.AND,L.OR]}class _2 extends e3{lookupKey;static INITIAL_CAPACITY=512;instructionBuffer;switchBuffer;instructionCount=0;instructionOffset=0;switchOffset=0;constructor(_,A){super(_);this.lookupKey=A;this.instructionBuffer=Buffer.alloc(_2.INITIAL_CAPACITY),this.switchBuffer=Buffer.alloc(_2.INITIAL_CAPACITY)}ensureInstructionCapacity(_){if(this.instructionOffset+_>this.instructionBuffer.length){let A=Buffer.alloc(this.instructionBuffer.length*2);this.instructionBuffer.copy(A),this.instructionBuffer=A}}ensureSwitchCapacity(_){if(this.switchOffset+_>this.switchBuffer.length){let A=Buffer.alloc(this.switchBuffer.length*2);this.switchBuffer.copy(A),this.switchBuffer=A}}instruction(_,A){if(this.instructionCount++,this.ensureInstructionCapacity(_.largeOperand?6:4),this.instructionBuffer.writeUInt16BE(_.id,this.instructionOffset),this.instructionOffset+=2,_.largeOperand)this.instructionBuffer.writeInt32BE(A|0,this.instructionOffset),this.instructionOffset+=4;else this.instructionBuffer.writeUInt8(A,this.instructionOffset),this.instructionOffset+=1}instructionRaw(_,A){this.instructionCount++,this.ensureInstructionCapacity(3),this.instructionBuffer.writeUInt16BE(_,this.instructionOffset),this.instructionOffset+=2,this.instructionBuffer.writeUInt8(A,this.instructionOffset),this.instructionOffset+=1}instructionString(_,A){this.instructionCount++;let R=A.length+1;this.ensureInstructionCapacity(2+R),this.instructionBuffer.writeUInt16BE(_.id,this.instructionOffset),this.instructionOffset+=2,this.instructionOffset=this.writeString(this.instructionBuffer,A,this.instructionOffset)}switch(_,A){this.instruction(L.SWITCH,_);let R=this.switchOffset;this.ensureSwitchCapacity(2),this.switchOffset+=2;let U=A();this.switchBuffer.writeUInt16BE(U,R)}switchCase(_,A){this.ensureSwitchCapacity(8),this.switchBuffer.writeInt32BE(_,this.switchOffset),this.switchOffset+=4,this.switchBuffer.writeInt32BE(A,this.switchOffset),this.switchOffset+=4}finish(){let _=this.calculateBufferSize(),A=Buffer.alloc(_),R=0;if(R=this.writeString(A,this.script.fullName,R),R=this.writeString(A,this.script.sourceName,R),A.writeInt32BE(this.lookupKey,R),R+=4,this.script.trigger===z.DEBUGPROC){let N=M.toList(this.script.symbol.parameters);A.writeUInt8(N.length,R++);for(let Y of N){let X=Y.code?.charCodeAt(0)??-1;A.writeInt8(X,R++)}}else A.writeUInt8(0,R++);A.writeUInt16BE(this.lineNumberTable.size,R),R+=2;for(let[N,Y]of this.lineNumberTable)A.writeInt32BE(N,R),R+=4,A.writeInt32BE(Y,R),R+=4;this.instructionBuffer.copy(A,R,0,this.instructionOffset),R+=this.instructionOffset,A.writeInt32BE(this.instructionCount,R),R+=4;let U=this.script.locals;return A.writeUInt16BE(U0.getLocalCount(U,0),R),R+=2,A.writeUInt16BE(U0.getLocalCount(U,1),R),R+=2,A.writeUInt16BE(U0.getParameterCount(U,0),R),R+=2,A.writeUInt16BE(U0.getParameterCount(U,1),R),R+=2,A.writeUInt8(this.script.switchTables.length,R++),this.switchBuffer.copy(A,R,0,this.switchOffset),R+=this.switchOffset,A.writeUInt16BE(this.switchOffset+1,R),A}calculateBufferSize(){let _=0;if(_+=this.script.fullName.length+1,_+=this.script.sourceName.length+1,_+=4,this.script.trigger===z.DEBUGPROC){let A=M.toList(this.script.symbol.parameters);_+=1+A.length}else _+=1;return _+=this.lineNumberTable.size*8+2,_+=this.instructionOffset,_+=4,_+=8,_+=1,_+=this.switchOffset,_+=2,_}close(){}writeString(_,A,R){for(let U=0;U<A.length;U++)_.writeUInt8(A.charCodeAt(U)&255,R++);return _.writeUInt8(0,R++),R}}class A2 extends U0{constructor(_){super(_)}finishWrite(_,A){let R=A.finish();try{this.outputScript(_,R)}finally{}}createContext(_){let A=this.generateLookupKey(_);return new _2(_,A)}generateLookupKey(_){let A=_.trigger,R=_.trigger.subjectMode,U=_.subjectReference;if(R===K.Name)return-1;let N=A.id;if("type"in R&&U!=null){let Y=U.type,X;if(U.type===D.MAPZONE||U.type===D.COORD)X=parseInt(U.name,10);else X=this.idProvider.get(U);let Q=Y===F.CATEGORY?1:2;N+=Q<<8|X<<10}return N}enterBlock(_,A){}writePushConstantInt(_,A){_.instruction(L.PUSH_CONSTANT_INT,A)}writePushConstantString(_,A){_.instructionString(L.PUSH_CONSTANT_STRING,A)}writePushConstantLong(_,A){throw Error("Not supported.")}writePushConstantSymbol(_,A){let R;if(A instanceof F0)R=U0.getVariableId(_.script.locals,A);else if(A instanceof r&&A.type instanceof W.Type){let U=A.type;if(typeof U.inner.code==="string"&&U.inner.code.length>0)R=U.inner.code.charCodeAt(0);else throw Error(`Type has chno code: ${U.inner}.`)}else R=this.idProvider.get(A);_.instruction(L.PUSH_CONSTANT_INT,R)}writePushLocalVar(_,A){let R=U0.getVariableId(_.script.locals,A),U;if(A.type instanceof s)U=L.PUSH_ARRAY_INT;else if(A.type.baseType===1)U=L.PUSH_STRING_LOCAL;else if(A.type.baseType===0)U=L.PUSH_INT_LOCAL;else throw Error(`Unsupported local variable type: ${A.type}.`);_.instruction(U,R)}writePopLocalVar(_,A){let R=U0.getVariableId(_.script.locals,A),U;if(A.type instanceof s)U=L.POP_ARRAY_INT;else if(A.type.baseType===1)U=L.POP_STRING_LOCAL;else if(A.type.baseType===0)U=L.POP_INT_LOCAL;else throw Error(`Unsupported local variable type: ${A.type}.`);_.instruction(U,R)}writePushVar(_,A,R){let U=this.idProvider.get(A),N;if(A.type instanceof Q0)N=L.PUSH_VARP;else if(A.type instanceof Z0)N=L.PUSH_VARBIT;else if(A.type instanceof J0)N=L.PUSH_VARN;else if(A.type instanceof z1)N=L.PUSH_VARS;else throw Error(`Unsupported variable type: ${A.type}.`);let Y=U;if(R)Y+=65536;_.instruction(N,Y)}writePopVar(_,A,R){let U=this.idProvider.get(A),N;if(A.type instanceof Q0)N=L.POP_VARP;else if(A.type instanceof Z0)N=L.POP_VARBIT;else if(A.type instanceof J0)N=L.POP_VARN;else if(A.type instanceof z1)N=L.POP_VARS;else throw Error(`Unsupported variable typ: ${A.type}.`);let Y=U;if(R)Y+=65536;_.instruction(N,Y)}writeDefineArray(_,A){let R=U0.getVariableId(_.script.locals,A),U=A.type;if(typeof U.inner.code!=="string"||U.inner.code.length===0)throw Error(`Type has no char code: ${U.inner}.`);let N=U.inner.code.charCodeAt(0);_.instruction(L.DEFINE_ARRAY,R<<16|N)}writeSwitch(_,A){_.switch(A.id,()=>{let R=0;for(let U of A.cases.entries()){let N=_.jumpTable.get(U[1].label);if(N===void 0)throw Error(`Label not found: ${U[1].label}.`);let Y=N-_.curIndex-1;for(let X of U[1].keys)_.switchCase(this.findCaseKeyValue(X),Y);R+=U[1].keys.length}return R})}findCaseKeyValue(_){if(typeof _==="number")return _;return this.idProvider.get(_)}writeBranch(_,A,R){let U;switch(A){case H.Branch:U=L.BRANCH;break;case H.BranchNot:U=L.BRANCH_NOT;break;case H.BranchEquals:U=L.BRANCH_EQUALS;break;case H.BranchLessThan:U=L.BRANCH_LESS_THAN;break;case H.BranchGreaterThan:U=L.BRANCH_GREATER_THAN;break;case H.BranchLessThanOrEquals:U=L.BRANCH_LESS_THAN_OR_EQUALS;break;case H.BranchGreaterThanOrEquals:U=L.BRANCH_GREATER_THAN_OR_EQUALS;break;default:throw Error(`Unsupported opcode: ${A}.`)}let N=_.jumpTable.get(R);if(N===void 0)throw Error(`Label not found: ${R}.`);_.instruction(U,N-_.curIndex-1)}writeJoinString(_,A){_.instruction(L.JOIN_STRING,A)}writeDiscard(_,A){let R;switch(A){case 0:R=L.POP_INT_DISCARD;break;case 1:R=L.POP_STRING_DISCARD;break;default:throw Error(`Unsupported base type: ${A}.`)}_.instruction(R,0)}writeGosub(_,A){let R=this.idProvider.get(A);_.instruction(L.GOSUB_WITH_PARAMS,R)}writeJump(_,A){let R=this.idProvider.get(A);_.instruction(L.JUMP_WITH_PARAMS,R)}writeCommand(_,A){let R=this.idProvider.get(A),U=A.name.startsWith(".");_.instructionRaw(R,U?1:0)}writeReturn(_){_.instruction(L.RETURN,0)}writeMath(_,A){let R;switch(A){case H.Add:R=L.ADD;break;case H.Sub:R=L.SUB;break;case H.Multiply:R=L.MULTIPLY;break;case H.Divide:R=L.DIVIDE;break;case H.Modulo:R=L.MODULO;break;case H.Or:R=L.OR;break;case H.And:R=L.AND;break;default:throw Error(`Unsupported math opcode: ${A}`)}_.instruction(R,0)}}var PQ=W.Type;class O2 extends A2{output;buffers=new Map;static VERSION=26;constructor(_,A){super(A);if(this.output=_,!f0.existsSync(_))f0.mkdirSync(_,{recursive:!0});if(!f0.statSync(_).isDirectory())throw Error(`${_4.resolve(_)} is not a directory.`)}outputScript(_,A){let R=this.idProvider.get(_.symbol);this.buffers.set(R,Buffer.from(A))}close(){let _=_4.join(this.output,"script.dat"),A=_4.join(this.output,"script.idx"),R=f0.openSync(_,"w"),U=f0.openSync(A,"w");try{let N=[...this.buffers.keys()].sort((X,Q)=>X-Q),Y=N.length>0?N[N.length-1]:0;this.p4(R,Y+1),this.p4(U,Y+1),this.p4(R,O2.VERSION);for(let X=0;X<=Y;X++){let Q=this.buffers.get(X);if(!Q){this.p4(U,0);continue}this.p4(U,Q.length),f0.writeSync(R,Q)}}finally{f0.closeSync(R),f0.closeSync(U)}}p2(_,A){let R=Buffer.allocUnsafe(2);R.writeUInt16BE(A&65535,0),f0.writeSync(_,R)}p4(_,A){let R=Buffer.allocUnsafe(4);R.writeInt32BE(A,0),f0.writeSync(_,R)}}import r0 from"fs";import X5 from"path";import E6 from"zlib";var w6=(()=>{let _=new Int32Array(256);for(let A=0;A<256;A++){let R=A;for(let U=0;U<8;U++)if((R&1)===1)R=R>>>1^3988292384;else R>>>=1;_[A]=R}return _})();function Y5(_){let A=4294967295;for(let R=0;R<_.length;R++)A=A>>>8^w6[(A^_[R])&255];return~A|0}class M2{buffer;offset=0;constructor(_){this.buffer=Buffer.alloc(Math.max(64,_))}p1(_){this.ensure(1),this.buffer.writeUInt8(_&255,this.offset),this.offset+=1}p2(_){this.ensure(2),this.buffer.writeUInt16BE(_&65535,this.offset),this.offset+=2}p4(_){this.ensure(4),this.buffer.writeInt32BE(_|0,this.offset),this.offset+=4}pSmart2or4(_){if(_<32768)this.p2(_);else this.p4(_|2147483648)}pdata(_){this.ensure(_.length),_.copy(this.buffer,this.offset),this.offset+=_.length}toBuffer(){return this.buffer.subarray(0,this.offset)}ensure(_){if(this.offset+_<=this.buffer.length)return;let A=this.buffer.length*2;while(this.offset+_>A)A*=2;let R=Buffer.alloc(A);this.buffer.copy(R,0,0,this.offset),this.buffer=R}}class v1 extends A2{output;buffers=new Map;static INDEX_FORMAT=7;static INDEX_VERSION=1;static GROUP_VERSION=1;constructor(_,A){super(A);this.output=_;let R=X5.dirname(_);if(!r0.existsSync(R))r0.mkdirSync(R,{recursive:!0});if(!r0.statSync(R).isDirectory())throw Error(`${X5.resolve(R)} is not a directory.`)}outputScript(_,A){let R=this.idProvider.get(_.symbol);this.buffers.set(R,Buffer.from(A))}close(){let _=[...this.buffers.entries()].sort((N,Y)=>N[0]-Y[0]).map(([N,Y])=>{let X=this.packGroup(Y,0);return{groupId:N,packedGroup:X,checksum:Y5(X),version:v1.GROUP_VERSION}}),A=this.encodeIndex(_),R=this.packGroup(A,2),U=r0.openSync(this.output,"w");try{r0.writeSync(U,R);for(let N of _)r0.writeSync(U,N.packedGroup);for(let N of _)this.p4(U,N.packedGroup.length)}finally{r0.closeSync(U)}}encodeIndex(_){let A=new M2(128);A.p1(v1.INDEX_FORMAT),A.p4(v1.INDEX_VERSION),A.p1(0),A.pSmart2or4(_.length);let R=0;for(let U of _)A.pSmart2or4(U.groupId-R),R=U.groupId;for(let U of _)A.p4(U.checksum);for(let U of _)A.p4(U.version);for(let U of _)A.pSmart2or4(1);for(let U of _)A.pSmart2or4(0);return A.toBuffer()}packGroup(_,A){let R=new M2(_.length+16);if(R.p1(A),A===0)R.p4(_.length),R.pdata(_);else if(A===2){let U=E6.gzipSync(_);U[9]=0,R.p4(U.length),R.p4(_.length),R.pdata(U)}else throw Error(`Unsupported compression type ${A}`);return R.toBuffer()}p4(_,A){let R=Buffer.allocUnsafe(4);R.writeInt32BE(A,0),r0.writeSync(_,R)}}function k6(_){if(typeof _.symbols>"u"||typeof _.symbols.command>"u"||typeof _.symbols.runescript>"u")throw Error("Core symbols missing from compiler. Please provide command and runescript symbols.");let A=["../content/scripts"],R=[],U=!0,N={output:"./data/pack/server"},Y=null;if(typeof _<"u"){if(typeof _.sourcePaths<"u")A=_.sourcePaths;if(typeof _.excludePaths<"u")R=_.excludePaths;if(typeof _.checkPointers<"u")U=_.checkPointers;if(typeof _.writer<"u"){if(typeof _.writer.jag<"u")N=_.writer.jag,Y=null;else if(typeof _.writer.js5<"u")Y=_.writer.js5,N=null}}A.map((I)=>h2(I)),R.map((I)=>h2(I));let X=new r3,Q;if(N)Q=new O2(h2(N.output),X);else if(Y)Q=new v1(h2(Y.output),X);else throw Error("No writer configured.");let $=new Map;C6(_.symbols.command,_.symbols.runescript,X,$,U);let J=new t3(A,R,Q,$,_.symbols,X);J.setup(),J.run("rs2")}function C6(_,A,R,U,N){for(let[Y,X]of Object.entries(_.map)){let Q=parseInt(Y);if(N&&(_.require[Y]||_.set[Y]||_.corrupt[Y])){let $=u1(_.require[Y]),J=u1(_.require2[Y]),I=u1(_.set[Y]),w=u1(_.set2[Y]),C=_.conditional[Y]??!1,V=u1(_.corrupt[Y]),m=u1(_.corrupt2[Y]);if(U.set(X,{required:$,set:I,conditionalSet:C,corrupted:V}),J.size||w.size||m.size)U.set(`.${X}`,{required:J,set:w,conditionalSet:C,corrupted:m})}R.putCommand(Q,X)}for(let[Y,X]of Object.entries(A.map)){let Q=parseInt(Y);R.putScript(Q,X)}}function u1(_){if(!_||_==="none")return new Set;let A=new Set,R=_.split(",");for(let U of R){let N=G.forName(U);if(N)A.add(N);else throw Error(`Invalid pointer name: ${U}.`)}return A}export{k6 as CompileServerScript};