mathjslab
Version:
MathJSLab - An interpreter with language syntax like MATLAB®/Octave, ISBN 978-65-00-82338-7.
2 lines • 1.1 MB
JavaScript
/*! For license information please see mathjslab.node.esm2022.js.LICENSE.txt */
import{createRequire as __WEBPACK_EXTERNAL_createRequire}from"node:module";const __WEBPACK_EXTERNAL_createRequire_require=__WEBPACK_EXTERNAL_createRequire(import.meta.url);import{default as __WEBPACK_EXTERNAL_MODULE_crypto_default__}from"crypto";var __webpack_modules__={207(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{A:()=>MathJSLabLexer});var antlr4__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(990);class MathJSLabLexer extends antlr4__WEBPACK_IMPORTED_MODULE_0__.JG{static GLOBAL=1;static PERSISTENT=2;static IMPORT=3;static IF=4;static ENDIF=5;static END=6;static ENDRANGE=7;static ELSEIF=8;static ELSE=9;static SWITCH=10;static ENDSWITCH=11;static CASE=12;static OTHERWISE=13;static WHILE=14;static ENDWHILE=15;static DO=16;static UNTIL=17;static FOR=18;static ENDFOR=19;static PARFOR=20;static ENDPARFOR=21;static SPMD=22;static ENDSPMD=23;static BREAK=24;static CONTINUE=25;static RETURN=26;static FUNCTION=27;static ENDFUNCTION=28;static TRY=29;static CATCH=30;static END_TRY_CATCH=31;static UNWIND_PROTECT=32;static UNWIND_PROTECT_CLEANUP=33;static END_UNWIND_PROTECT=34;static CLASSDEF=35;static ENDCLASSDEF=36;static ENUMERATION=37;static ENDENUMERATION=38;static PROPERTIES=39;static ENDPROPERTIES=40;static EVENTS=41;static ENDEVENTS=42;static METHODS=43;static ENDMETHODS=44;static WSPACE=45;static STRING=46;static ARGUMENTS=47;static ENDARGUMENTS=48;static PLUS=49;static MINUS=50;static MUL=51;static DIV=52;static EQ=53;static COLON=54;static SEMICOLON=55;static COMMA=56;static DOT=57;static TILDE=58;static EXCLAMATION=59;static COMMAT=60;static QUESTION=61;static LPAREN=62;static RPAREN=63;static LBRACKET=64;static RBRACKET=65;static LCURLYBR=66;static RCURLYBR=67;static LEFTDIV=68;static ADD_EQ=69;static SUB_EQ=70;static MUL_EQ=71;static DIV_EQ=72;static LEFTDIV_EQ=73;static POW_EQ=74;static EMUL_EQ=75;static EDIV_EQ=76;static ELEFTDIV_EQ=77;static EPOW_EQ=78;static AND_EQ=79;static OR_EQ=80;static EXPR_AND_AND=81;static EXPR_OR_OR=82;static EXPR_AND=83;static EXPR_OR=84;static EXPR_LT=85;static EXPR_LE=86;static EXPR_EQ=87;static EXPR_NE=88;static EXPR_GE=89;static EXPR_GT=90;static EMUL=91;static EDIV=92;static ELEFTDIV=93;static PLUS_PLUS=94;static MINUS_MINUS=95;static POW=96;static EPOW=97;static TRANSPOSE=98;static HERMITIAN=99;static DQSTRING=100;static IDENTIFIER=101;static FLOAT_NUMBER=102;static NUMBER_DOT_OP=103;static LINE_CONTINUATION=104;static SPACE_OR_CONTINUATION=105;static NEWLINE=106;static BLOCK_COMMENT_START=107;static COMMENT_LINE=108;static INVALID=109;static SINGLEQ_STRING=110;static SINGLEQ_NL=111;static SINGLEQ_SINGLEQ=112;static SINGLEQ_END=113;static DOUBLEQ_STRING=114;static DOUBLEQ_NL=115;static DOUBLEQ_DOUBLEQ=116;static DOUBLEQ_ESCAPE=117;static DOUBLEQ_ESCAPE_OTHER=118;static DOUBLEQ_ESCAPE_OCT=119;static DOUBLEQ_ESCAPE_HEX=120;static DOUBLEQ_ESCAPE_UNICODE=121;static DOUBLEQ_END=122;static BLOCK_COMMENT_START_AGAIN=123;static BLOCK_COMMENT_END=124;static BLOCK_COMMENT_LINE=125;static BLOCK_COMMENT_EOF=126;static COMMAND_LINE_CONTINUATION=127;static COMMAND_CONTINUED_BLOCK_COMMENT_START=128;static COMMAND_CONTINUED_COMMENT_LINE=129;static COMMAND_CONTINUED_NEWLINE=130;static SKIP_SPACE=131;static COMMAND_LONE_DQUOTE=132;static COMMAND_LONE_SQUOTE=133;static COMMAND_UNCLOSED_DQUOTE=134;static COMMAND_UNCLOSED_SQUOTE=135;static COMMAND_DQSTRING=136;static COMMAND_SQSTRING=137;static SKIP_COMMENT_LINE=138;static COMMAND_SEPARATOR=139;static EXIT_AT_NEWLINE=140;static EXIT_AT_EOF=141;static UNQUOTED_STRING=142;static EOF=antlr4__WEBPACK_IMPORTED_MODULE_0__.ou.EOF;static SQ_STRING=1;static DQ_STRING=2;static BLOCK_COMMENT=3;static ANY_AS_STRING_UNTIL_END_OF_LINE=4;static channelNames=["DEFAULT_TOKEN_CHANNEL","HIDDEN"];static literalNames=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"'+'","'-'","'*'","'/'","'='","':'","';'","','","'.'","'~'","'!'","'@'","'?'","'('","')'","'['","']'","'{'","'}'","'\\'","'+='","'-='","'*='","'/='","'\\='",null,"'.*='","'./='","'.\\='",null,"'&='","'|='","'&&'","'||'","'&'","'|'","'<'","'<='","'=='",null,"'>='","'>'","'.*'","'./'","'.\\'","'++'","'--'",null,null,"'.''",null,null,null,null,null,null,null,null,null,null,null,null,null,"''''",null,null,null,"'\"\"'"];static symbolicNames=[null,"GLOBAL","PERSISTENT","IMPORT","IF","ENDIF","END","ENDRANGE","ELSEIF","ELSE","SWITCH","ENDSWITCH","CASE","OTHERWISE","WHILE","ENDWHILE","DO","UNTIL","FOR","ENDFOR","PARFOR","ENDPARFOR","SPMD","ENDSPMD","BREAK","CONTINUE","RETURN","FUNCTION","ENDFUNCTION","TRY","CATCH","END_TRY_CATCH","UNWIND_PROTECT","UNWIND_PROTECT_CLEANUP","END_UNWIND_PROTECT","CLASSDEF","ENDCLASSDEF","ENUMERATION","ENDENUMERATION","PROPERTIES","ENDPROPERTIES","EVENTS","ENDEVENTS","METHODS","ENDMETHODS","WSPACE","STRING","ARGUMENTS","ENDARGUMENTS","PLUS","MINUS","MUL","DIV","EQ","COLON","SEMICOLON","COMMA","DOT","TILDE","EXCLAMATION","COMMAT","QUESTION","LPAREN","RPAREN","LBRACKET","RBRACKET","LCURLYBR","RCURLYBR","LEFTDIV","ADD_EQ","SUB_EQ","MUL_EQ","DIV_EQ","LEFTDIV_EQ","POW_EQ","EMUL_EQ","EDIV_EQ","ELEFTDIV_EQ","EPOW_EQ","AND_EQ","OR_EQ","EXPR_AND_AND","EXPR_OR_OR","EXPR_AND","EXPR_OR","EXPR_LT","EXPR_LE","EXPR_EQ","EXPR_NE","EXPR_GE","EXPR_GT","EMUL","EDIV","ELEFTDIV","PLUS_PLUS","MINUS_MINUS","POW","EPOW","TRANSPOSE","HERMITIAN","DQSTRING","IDENTIFIER","FLOAT_NUMBER","NUMBER_DOT_OP","LINE_CONTINUATION","SPACE_OR_CONTINUATION","NEWLINE","BLOCK_COMMENT_START","COMMENT_LINE","INVALID","SINGLEQ_STRING","SINGLEQ_NL","SINGLEQ_SINGLEQ","SINGLEQ_END","DOUBLEQ_STRING","DOUBLEQ_NL","DOUBLEQ_DOUBLEQ","DOUBLEQ_ESCAPE","DOUBLEQ_ESCAPE_OTHER","DOUBLEQ_ESCAPE_OCT","DOUBLEQ_ESCAPE_HEX","DOUBLEQ_ESCAPE_UNICODE","DOUBLEQ_END","BLOCK_COMMENT_START_AGAIN","BLOCK_COMMENT_END","BLOCK_COMMENT_LINE","BLOCK_COMMENT_EOF","COMMAND_LINE_CONTINUATION","COMMAND_CONTINUED_BLOCK_COMMENT_START","COMMAND_CONTINUED_COMMENT_LINE","COMMAND_CONTINUED_NEWLINE","SKIP_SPACE","COMMAND_LONE_DQUOTE","COMMAND_LONE_SQUOTE","COMMAND_UNCLOSED_DQUOTE","COMMAND_UNCLOSED_SQUOTE","COMMAND_DQSTRING","COMMAND_SQSTRING","SKIP_COMMENT_LINE","COMMAND_SEPARATOR","EXIT_AT_NEWLINE","EXIT_AT_EOF","UNQUOTED_STRING"];static modeNames=["DEFAULT_MODE","SQ_STRING","DQ_STRING","BLOCK_COMMENT","ANY_AS_STRING_UNTIL_END_OF_LINE"];static ruleNames=["PLUS","MINUS","MUL","DIV","EQ","COLON","SEMICOLON","COMMA","DOT","TILDE","EXCLAMATION","COMMAT","QUESTION","LPAREN","RPAREN","LBRACKET","RBRACKET","LCURLYBR","RCURLYBR","LEFTDIV","ADD_EQ","SUB_EQ","MUL_EQ","DIV_EQ","LEFTDIV_EQ","POW_EQ","EMUL_EQ","EDIV_EQ","ELEFTDIV_EQ","EPOW_EQ","AND_EQ","OR_EQ","EXPR_AND_AND","EXPR_OR_OR","EXPR_AND","EXPR_OR","EXPR_LT","EXPR_LE","EXPR_EQ","EXPR_NE","EXPR_GE","EXPR_GT","EMUL","EDIV","ELEFTDIV","PLUS_PLUS","MINUS_MINUS","POW","EPOW","TRANSPOSE","HERMITIAN","DQSTRING","IDENTIFIER","FLOAT_NUMBER","NUMBER_DOT_OP","LINE_CONTINUATION","SPACE_OR_CONTINUATION","NEWLINE","BLOCK_COMMENT_START","COMMENT_LINE","INVALID","SINGLEQ_STRING","SINGLEQ_NL","SINGLEQ_SINGLEQ","SINGLEQ_END","DOUBLEQ_STRING","DOUBLEQ_NL","DOUBLEQ_DOUBLEQ","DOUBLEQ_ESCAPE","DOUBLEQ_ESCAPE_OTHER","DOUBLEQ_ESCAPE_OCT","DOUBLEQ_ESCAPE_HEX","DOUBLEQ_ESCAPE_UNICODE","DOUBLEQ_END","BLOCK_COMMENT_START_AGAIN","BLOCK_COMMENT_END","BLOCK_COMMENT_LINE","BLOCK_COMMENT_EOF","COMMAND_LINE_CONTINUATION","COMMAND_CONTINUED_BLOCK_COMMENT_START","COMMAND_CONTINUED_COMMENT_LINE","COMMAND_CONTINUED_NEWLINE","SKIP_SPACE","COMMAND_LONE_DQUOTE","COMMAND_LONE_SQUOTE","COMMAND_UNCLOSED_DQUOTE","COMMAND_UNCLOSED_SQUOTE","COMMAND_DQSTRING","COMMAND_SQSTRING","SKIP_COMMENT_LINE","COMMAND_SEPARATOR","EXIT_AT_NEWLINE","EXIT_AT_EOF","UNQUOTED_STRING","CCHAR","NL","SPACE","IDENT","FQIDENT","REAL_NUMBER","INTEGER_NUMBER","INTEGER_DIGITS","DECIMAL_DIGITS","BINARY_DIGITS","OCTAL_DIGITS","HEXADECIMAL_DIGITS","EXPONENT"];static keywordNames=[null,"global","persistent","import","if","endif","end","elseif","else","switch","endswitch","case","otherwise","while","endwhile","do","until","for","endfor","parfor","endparfor","spmd","endspmd","break","continue","return","function","endfunction","try","catch","end_try_catch","unwind_protect","unwind_protect_cleanup","end_unwind_protect","classdef","endclassdef","enumeration","endenumeration","properties","endproperties","events","endevents","methods","endmethods","arguments","endarguments"];static keywordTypes=[NaN,MathJSLabLexer.GLOBAL,MathJSLabLexer.PERSISTENT,MathJSLabLexer.IMPORT,MathJSLabLexer.IF,MathJSLabLexer.ENDIF,MathJSLabLexer.END,MathJSLabLexer.ELSEIF,MathJSLabLexer.ELSE,MathJSLabLexer.SWITCH,MathJSLabLexer.ENDSWITCH,MathJSLabLexer.CASE,MathJSLabLexer.OTHERWISE,MathJSLabLexer.WHILE,MathJSLabLexer.ENDWHILE,MathJSLabLexer.DO,MathJSLabLexer.UNTIL,MathJSLabLexer.FOR,MathJSLabLexer.ENDFOR,MathJSLabLexer.PARFOR,MathJSLabLexer.ENDPARFOR,MathJSLabLexer.SPMD,MathJSLabLexer.ENDSPMD,MathJSLabLexer.BREAK,MathJSLabLexer.CONTINUE,MathJSLabLexer.RETURN,MathJSLabLexer.FUNCTION,MathJSLabLexer.ENDFUNCTION,MathJSLabLexer.TRY,MathJSLabLexer.CATCH,MathJSLabLexer.END_TRY_CATCH,MathJSLabLexer.UNWIND_PROTECT,MathJSLabLexer.UNWIND_PROTECT_CLEANUP,MathJSLabLexer.END_UNWIND_PROTECT,MathJSLabLexer.CLASSDEF,MathJSLabLexer.ENDCLASSDEF,MathJSLabLexer.ENUMERATION,MathJSLabLexer.ENDENUMERATION,MathJSLabLexer.PROPERTIES,MathJSLabLexer.ENDPROPERTIES,MathJSLabLexer.EVENTS,MathJSLabLexer.ENDEVENTS,MathJSLabLexer.METHODS,MathJSLabLexer.ENDMETHODS,MathJSLabLexer.ARGUMENTS,MathJSLabLexer.ENDARGUMENTS];static keywordTypeByName=new Map(MathJSLabLexer.keywordNames.map((t,e)=>t?[t,MathJSLabLexer.keywordTypes[e]]:void 0).filter(t=>void 0!==t));commandNames=new Set;assignmentSensitiveCommandNames=new Set;static nonTerminalSign=new Set([MathJSLabLexer.PLUS,MathJSLabLexer.MINUS,MathJSLabLexer.MUL,MathJSLabLexer.DIV,MathJSLabLexer.EQ,MathJSLabLexer.COLON,MathJSLabLexer.DOT,MathJSLabLexer.TILDE,MathJSLabLexer.EXCLAMATION,MathJSLabLexer.COMMAT,MathJSLabLexer.QUESTION,MathJSLabLexer.LPAREN,MathJSLabLexer.LBRACKET,MathJSLabLexer.LCURLYBR,MathJSLabLexer.LEFTDIV,MathJSLabLexer.ADD_EQ,MathJSLabLexer.SUB_EQ,MathJSLabLexer.MUL_EQ,MathJSLabLexer.DIV_EQ,MathJSLabLexer.LEFTDIV_EQ,MathJSLabLexer.POW_EQ,MathJSLabLexer.EMUL_EQ,MathJSLabLexer.EDIV_EQ,MathJSLabLexer.ELEFTDIV_EQ,MathJSLabLexer.EPOW_EQ,MathJSLabLexer.AND_EQ,MathJSLabLexer.OR_EQ,MathJSLabLexer.EXPR_AND_AND,MathJSLabLexer.EXPR_OR_OR,MathJSLabLexer.EXPR_AND,MathJSLabLexer.EXPR_OR,MathJSLabLexer.EXPR_LT,MathJSLabLexer.EXPR_LE,MathJSLabLexer.EXPR_EQ,MathJSLabLexer.EXPR_NE,MathJSLabLexer.EXPR_GE,MathJSLabLexer.EXPR_GT,MathJSLabLexer.EMUL,MathJSLabLexer.EDIV,MathJSLabLexer.ELEFTDIV,MathJSLabLexer.PLUS_PLUS,MathJSLabLexer.MINUS_MINUS,MathJSLabLexer.POW,MathJSLabLexer.EPOW]);previousTokenType=antlr4__WEBPACK_IMPORTED_MODULE_0__.ou.EOF;parenthesisCount=0;continuedTokenType=null;commandContinued=!1;matrixContext=[];curlyBraceIsMatrixContext=[];indexingBraceCount=0;quotedString="";commandQuoteIsClosed(t){let e=1,r=this._input.LA(e);for(;r!==antlr4__WEBPACK_IMPORTED_MODULE_0__.ou.EOF&&10!==r&&13!==r;){if(r===t){if(this._input.LA(e+1)===t){e+=2,r=this._input.LA(e);continue}return!0}e++,r=this._input.LA(e)}return!1}commandIsFollowedByAssignment(t){const e=this._input.LA(t);if(61===e)return!0;const r=this._input.LA(t+1);return!(![43,45,42,47,92,94,38,124].includes(e)||61!==r)||46===e&&[42,47,92,94].includes(r)&&61===this._input.LA(t+2)}matrixWhitespaceIsSeparator(t=!1){let e=1;if(t)for(;9===this._input.LA(e)||32===this._input.LA(e);)e++;const r=this._input.LA(e);if(43!==r&&45!==r)return!this.matrixWhitespaceBeforeBinaryOperator(e);const s=this._input.LA(e+1);return 9!==s&&32!==s}matrixWhitespaceBeforeBinaryOperator(t){const e=this._input.LA(t),r=this._input.LA(t+1);return!![38,42,47,58,60,62,92,94,124].includes(e)||(46===e?[42,47,92,94].includes(r):61===e&&61===r||126===e&&61===r)}emit(){const t=super.emit();return null!==this.continuedTokenType&&t.type!==antlr4__WEBPACK_IMPORTED_MODULE_0__.ou.EOF&&t.type!==MathJSLabLexer.NEWLINE&&t.type!==MathJSLabLexer.WSPACE&&(this.continuedTokenType=null),t}constructor(t){super(t),this._interp=new antlr4__WEBPACK_IMPORTED_MODULE_0__.ay(this,MathJSLabLexer._ATN,MathJSLabLexer.DecisionsToDFA,new antlr4__WEBPACK_IMPORTED_MODULE_0__.tD)}get grammarFileName(){return"MathJSLabLexer.g4"}get literalNames(){return MathJSLabLexer.literalNames}get symbolicNames(){return MathJSLabLexer.symbolicNames}get ruleNames(){return MathJSLabLexer.ruleNames}get serializedATN(){return MathJSLabLexer._serializedATN}get channelNames(){return MathJSLabLexer.channelNames}get modeNames(){return MathJSLabLexer.modeNames}action(t,e,r){switch(e){case 0:this.PLUS_action(t,r);break;case 1:this.MINUS_action(t,r);break;case 2:this.MUL_action(t,r);break;case 3:this.DIV_action(t,r);break;case 4:this.EQ_action(t,r);break;case 5:this.COLON_action(t,r);break;case 6:this.SEMICOLON_action(t,r);break;case 7:this.COMMA_action(t,r);break;case 8:this.DOT_action(t,r);break;case 9:this.TILDE_action(t,r);break;case 10:this.EXCLAMATION_action(t,r);break;case 11:this.COMMAT_action(t,r);break;case 12:this.QUESTION_action(t,r);break;case 13:this.LPAREN_action(t,r);break;case 14:this.RPAREN_action(t,r);break;case 15:this.LBRACKET_action(t,r);break;case 16:this.RBRACKET_action(t,r);break;case 17:this.LCURLYBR_action(t,r);break;case 18:this.RCURLYBR_action(t,r);break;case 19:this.LEFTDIV_action(t,r);break;case 20:this.ADD_EQ_action(t,r);break;case 21:this.SUB_EQ_action(t,r);break;case 22:this.MUL_EQ_action(t,r);break;case 23:this.DIV_EQ_action(t,r);break;case 24:this.LEFTDIV_EQ_action(t,r);break;case 25:this.POW_EQ_action(t,r);break;case 26:this.EMUL_EQ_action(t,r);break;case 27:this.EDIV_EQ_action(t,r);break;case 28:this.ELEFTDIV_EQ_action(t,r);break;case 29:this.EPOW_EQ_action(t,r);break;case 30:this.AND_EQ_action(t,r);break;case 31:this.OR_EQ_action(t,r);break;case 32:this.EXPR_AND_AND_action(t,r);break;case 33:this.EXPR_OR_OR_action(t,r);break;case 34:this.EXPR_AND_action(t,r);break;case 35:this.EXPR_OR_action(t,r);break;case 36:this.EXPR_LT_action(t,r);break;case 37:this.EXPR_LE_action(t,r);break;case 38:this.EXPR_EQ_action(t,r);break;case 39:this.EXPR_NE_action(t,r);break;case 40:this.EXPR_GE_action(t,r);break;case 41:this.EXPR_GT_action(t,r);break;case 42:this.EMUL_action(t,r);break;case 43:this.EDIV_action(t,r);break;case 44:this.ELEFTDIV_action(t,r);break;case 45:this.PLUS_PLUS_action(t,r);break;case 46:this.MINUS_MINUS_action(t,r);break;case 47:this.POW_action(t,r);break;case 48:this.EPOW_action(t,r);break;case 49:this.TRANSPOSE_action(t,r);break;case 50:this.HERMITIAN_action(t,r);break;case 51:this.DQSTRING_action(t,r);break;case 52:this.IDENTIFIER_action(t,r);break;case 53:this.FLOAT_NUMBER_action(t,r);break;case 54:this.NUMBER_DOT_OP_action(t,r);break;case 55:this.LINE_CONTINUATION_action(t,r);break;case 56:this.SPACE_OR_CONTINUATION_action(t,r);break;case 57:this.NEWLINE_action(t,r);break;case 58:this.BLOCK_COMMENT_START_action(t,r);break;case 59:this.COMMENT_LINE_action(t,r);break;case 61:this.SINGLEQ_STRING_action(t,r);break;case 62:this.SINGLEQ_NL_action(t,r);break;case 63:this.SINGLEQ_SINGLEQ_action(t,r);break;case 64:this.SINGLEQ_END_action(t,r);break;case 65:this.DOUBLEQ_STRING_action(t,r);break;case 66:this.DOUBLEQ_NL_action(t,r);break;case 67:this.DOUBLEQ_DOUBLEQ_action(t,r);break;case 68:this.DOUBLEQ_ESCAPE_action(t,r);break;case 69:this.DOUBLEQ_ESCAPE_OTHER_action(t,r);break;case 70:this.DOUBLEQ_ESCAPE_OCT_action(t,r);break;case 71:this.DOUBLEQ_ESCAPE_HEX_action(t,r);break;case 72:this.DOUBLEQ_ESCAPE_UNICODE_action(t,r);break;case 73:this.DOUBLEQ_END_action(t,r);break;case 74:this.BLOCK_COMMENT_START_AGAIN_action(t,r);break;case 75:this.BLOCK_COMMENT_END_action(t,r);break;case 77:this.BLOCK_COMMENT_EOF_action(t,r);break;case 78:this.COMMAND_LINE_CONTINUATION_action(t,r);break;case 79:this.COMMAND_CONTINUED_BLOCK_COMMENT_START_action(t,r);break;case 83:this.COMMAND_LONE_DQUOTE_action(t,r);break;case 84:this.COMMAND_LONE_SQUOTE_action(t,r);break;case 85:this.COMMAND_UNCLOSED_DQUOTE_action(t,r);break;case 86:this.COMMAND_UNCLOSED_SQUOTE_action(t,r);break;case 87:this.COMMAND_DQSTRING_action(t,r);break;case 88:this.COMMAND_SQSTRING_action(t,r);break;case 90:this.COMMAND_SEPARATOR_action(t,r);break;case 91:this.EXIT_AT_NEWLINE_action(t,r);break;case 92:this.EXIT_AT_EOF_action(t,r);break;case 93:this.UNQUOTED_STRING_action(t,r)}}PLUS_action(t,e){0===e&&(this.previousTokenType=MathJSLabLexer.PLUS)}MINUS_action(t,e){1===e&&(this.previousTokenType=MathJSLabLexer.MINUS)}MUL_action(t,e){2===e&&(this.previousTokenType=MathJSLabLexer.MUL)}DIV_action(t,e){3===e&&(this.previousTokenType=MathJSLabLexer.DIV)}EQ_action(t,e){4===e&&(this.previousTokenType=MathJSLabLexer.EQ)}COLON_action(t,e){5===e&&(this.previousTokenType=MathJSLabLexer.COLON)}SEMICOLON_action(t,e){6===e&&(this.previousTokenType=MathJSLabLexer.SEMICOLON)}COMMA_action(t,e){7===e&&(this.previousTokenType=MathJSLabLexer.COMMA)}DOT_action(t,e){8===e&&(this.previousTokenType=MathJSLabLexer.DOT)}TILDE_action(t,e){9===e&&(this.previousTokenType=MathJSLabLexer.TILDE)}EXCLAMATION_action(t,e){10===e&&(this.previousTokenType=MathJSLabLexer.EXCLAMATION)}COMMAT_action(t,e){11===e&&(this.previousTokenType=MathJSLabLexer.COMMAT)}QUESTION_action(t,e){12===e&&(this.previousTokenType=MathJSLabLexer.QUESTION)}LPAREN_action(t,e){13===e&&(this.matrixContext.length>0&&this.matrixContext.push(MathJSLabLexer.LPAREN),this.parenthesisCount++,this.previousTokenType=MathJSLabLexer.LPAREN)}RPAREN_action(t,e){14===e&&(this.matrixContext.length>0&&this.matrixContext.pop(),this.parenthesisCount=Math.max(0,this.parenthesisCount-1),this.previousTokenType=MathJSLabLexer.RPAREN)}LBRACKET_action(t,e){15===e&&(this.matrixContext.push(MathJSLabLexer.LBRACKET),this.previousTokenType=MathJSLabLexer.LBRACKET)}RBRACKET_action(t,e){16===e&&(this.matrixContext.pop(),this.previousTokenType=MathJSLabLexer.RBRACKET)}LCURLYBR_action(t,e){if(17===e){const t=this.previousTokenType===MathJSLabLexer.RPAREN||this.previousTokenType===MathJSLabLexer.RBRACKET||this.previousTokenType===MathJSLabLexer.RCURLYBR||this.previousTokenType===MathJSLabLexer.IDENTIFIER||this.previousTokenType===MathJSLabLexer.FLOAT_NUMBER||this.previousTokenType===MathJSLabLexer.STRING||this.previousTokenType===MathJSLabLexer.ENDRANGE;this.curlyBraceIsMatrixContext.push(!t),t?this.indexingBraceCount++:this.matrixContext.push(MathJSLabLexer.LCURLYBR),this.previousTokenType=MathJSLabLexer.LCURLYBR}}RCURLYBR_action(t,e){18===e&&(this.curlyBraceIsMatrixContext.pop()??1?this.matrixContext.pop():this.indexingBraceCount=Math.max(0,this.indexingBraceCount-1),this.previousTokenType=MathJSLabLexer.RCURLYBR)}LEFTDIV_action(t,e){19===e&&(this.previousTokenType=MathJSLabLexer.LEFTDIV)}ADD_EQ_action(t,e){20===e&&(this.previousTokenType=MathJSLabLexer.ADD_EQ)}SUB_EQ_action(t,e){21===e&&(this.previousTokenType=MathJSLabLexer.SUB_EQ)}MUL_EQ_action(t,e){22===e&&(this.previousTokenType=MathJSLabLexer.MUL_EQ)}DIV_EQ_action(t,e){23===e&&(this.previousTokenType=MathJSLabLexer.DIV_EQ)}LEFTDIV_EQ_action(t,e){24===e&&(this.previousTokenType=MathJSLabLexer.LEFTDIV_EQ)}POW_EQ_action(t,e){25===e&&(this.previousTokenType=MathJSLabLexer.POW_EQ)}EMUL_EQ_action(t,e){26===e&&(this.previousTokenType=MathJSLabLexer.EMUL_EQ)}EDIV_EQ_action(t,e){27===e&&(this.previousTokenType=MathJSLabLexer.EDIV_EQ)}ELEFTDIV_EQ_action(t,e){28===e&&(this.previousTokenType=MathJSLabLexer.ELEFTDIV_EQ)}EPOW_EQ_action(t,e){29===e&&(this.previousTokenType=MathJSLabLexer.EPOW_EQ)}AND_EQ_action(t,e){30===e&&(this.previousTokenType=MathJSLabLexer.AND_EQ)}OR_EQ_action(t,e){31===e&&(this.previousTokenType=MathJSLabLexer.OR_EQ)}EXPR_AND_AND_action(t,e){32===e&&(this.previousTokenType=MathJSLabLexer.EXPR_AND_AND)}EXPR_OR_OR_action(t,e){33===e&&(this.previousTokenType=MathJSLabLexer.EXPR_OR_OR)}EXPR_AND_action(t,e){34===e&&(this.previousTokenType=MathJSLabLexer.EXPR_AND)}EXPR_OR_action(t,e){35===e&&(this.previousTokenType=MathJSLabLexer.EXPR_OR)}EXPR_LT_action(t,e){36===e&&(this.previousTokenType=MathJSLabLexer.EXPR_LT)}EXPR_LE_action(t,e){37===e&&(this.previousTokenType=MathJSLabLexer.EXPR_LE)}EXPR_EQ_action(t,e){38===e&&(this.previousTokenType=MathJSLabLexer.EXPR_EQ)}EXPR_NE_action(t,e){39===e&&(this.previousTokenType=MathJSLabLexer.EXPR_NE)}EXPR_GE_action(t,e){40===e&&(this.previousTokenType=MathJSLabLexer.EXPR_GE)}EXPR_GT_action(t,e){41===e&&(this.previousTokenType=MathJSLabLexer.EXPR_GT)}EMUL_action(t,e){42===e&&(this.previousTokenType=MathJSLabLexer.EMUL)}EDIV_action(t,e){43===e&&(this.previousTokenType=MathJSLabLexer.EDIV)}ELEFTDIV_action(t,e){44===e&&(this.previousTokenType=MathJSLabLexer.ELEFTDIV)}PLUS_PLUS_action(t,e){45===e&&(this.previousTokenType=MathJSLabLexer.PLUS_PLUS)}MINUS_MINUS_action(t,e){46===e&&(this.previousTokenType=MathJSLabLexer.MINUS_MINUS)}POW_action(t,e){47===e&&(this.previousTokenType=MathJSLabLexer.POW)}EPOW_action(t,e){48===e&&(this.previousTokenType=MathJSLabLexer.EPOW)}TRANSPOSE_action(t,e){49===e&&(this.previousTokenType=MathJSLabLexer.TRANSPOSE)}HERMITIAN_action(t,e){50===e&&(this.previousTokenType===MathJSLabLexer.RPAREN||this.previousTokenType===MathJSLabLexer.RBRACKET||this.previousTokenType===MathJSLabLexer.RCURLYBR||this.previousTokenType===MathJSLabLexer.IDENTIFIER||this.previousTokenType===MathJSLabLexer.FLOAT_NUMBER||this.previousTokenType===MathJSLabLexer.STRING||this.previousTokenType===MathJSLabLexer.ENDRANGE?this.previousTokenType=MathJSLabLexer.HERMITIAN:(this.pushMode(MathJSLabLexer.SQ_STRING),this.quotedString="",this.skip()))}DQSTRING_action(t,e){51===e&&(this.pushMode(MathJSLabLexer.DQ_STRING),this.quotedString="",this.skip())}IDENTIFIER_action(t,e){if(52===e)if(this.previousTokenType===MathJSLabLexer.DOT)this.previousTokenType=MathJSLabLexer.IDENTIFIER;else{const t=MathJSLabLexer.keywordTypeByName.get(this.text);if(void 0!==t)t===MathJSLabLexer.END?this._type=this.previousTokenType=this.parenthesisCount>0||this.matrixContext.length>0||this.indexingBraceCount>0?MathJSLabLexer.ENDRANGE:MathJSLabLexer.END:this._type=this.previousTokenType=t;else{const t=this.commandNames.has(this.text),e=this.previousTokenType===antlr4__WEBPACK_IMPORTED_MODULE_0__.ou.EOF||this.previousTokenType===MathJSLabLexer.NEWLINE||this.previousTokenType===MathJSLabLexer.SEMICOLON||this.previousTokenType===MathJSLabLexer.COMMA&&0===this.parenthesisCount&&0===this.matrixContext.length;let r=1,s=this._input.LA(r);for(;9===s||32===s;)s=this._input.LA(++r);const i=this.assignmentSensitiveCommandNames.has(this.text)&&this.commandIsFollowedByAssignment(r);t&&e&&(40!==s||r>1)&&!i&&this.pushMode(MathJSLabLexer.ANY_AS_STRING_UNTIL_END_OF_LINE),this.previousTokenType=MathJSLabLexer.IDENTIFIER}}}FLOAT_NUMBER_action(t,e){53===e&&(this.previousTokenType=MathJSLabLexer.FLOAT_NUMBER)}NUMBER_DOT_OP_action(t,e){54===e&&(this._input.seek(this._input.index-2),this._type=this.previousTokenType=MathJSLabLexer.FLOAT_NUMBER)}LINE_CONTINUATION_action(t,e){55===e&&(this.continuedTokenType=this.previousTokenType,this.skip())}SPACE_OR_CONTINUATION_action(t,e){56===e&&(this.text.includes("...")&&(this.continuedTokenType=this.previousTokenType),this.matrixContext.length>0&&this.previousTokenType!==MathJSLabLexer.LBRACKET&&this.previousTokenType!==MathJSLabLexer.COMMA&&this.previousTokenType!==MathJSLabLexer.SEMICOLON&&this.matrixContext[this.matrixContext.length-1]!==MathJSLabLexer.LPAREN&&!MathJSLabLexer.nonTerminalSign.has(this.previousTokenType)&&this.matrixWhitespaceIsSeparator(this.text.includes("..."))?this._type=this.previousTokenType=MathJSLabLexer.WSPACE:this.skip())}NEWLINE_action(t,e){57===e&&(this.continuedTokenType===this.previousTokenType||this.parenthesisCount>0||this.indexingBraceCount>0||this.matrixContext.length>0&&(this.previousTokenType===MathJSLabLexer.LBRACKET||this.previousTokenType===MathJSLabLexer.COMMA||this.previousTokenType===MathJSLabLexer.SEMICOLON)?this.skip():this.previousTokenType=MathJSLabLexer.NEWLINE)}BLOCK_COMMENT_START_action(t,e){58===e&&(this.pushMode(MathJSLabLexer.BLOCK_COMMENT),this.continuedTokenType===this.previousTokenType||this.parenthesisCount>0||this.matrixContext.length>0&&(this.previousTokenType===MathJSLabLexer.LBRACKET||this.previousTokenType===MathJSLabLexer.COMMA||this.previousTokenType===MathJSLabLexer.SEMICOLON)?this.skip():this._type=this.previousTokenType=MathJSLabLexer.NEWLINE)}COMMENT_LINE_action(t,e){switch(e){case 59:this.continuedTokenType===this.previousTokenType||this.parenthesisCount>0?this.skip():this._type=this.previousTokenType=MathJSLabLexer.NEWLINE;break;case 60:this._type=this.previousTokenType=MathJSLabLexer.EOF}}SINGLEQ_STRING_action(t,e){61===e&&(this.quotedString+=this.text,this.skip())}SINGLEQ_NL_action(t,e){62===e&&(this._type=this.previousTokenType=MathJSLabLexer.INVALID)}SINGLEQ_SINGLEQ_action(t,e){63===e&&(this.quotedString+="'",this.skip())}SINGLEQ_END_action(t,e){64===e&&(this.text=`'${this.quotedString}'`,this.popMode(),this._type=this.previousTokenType=MathJSLabLexer.STRING)}DOUBLEQ_STRING_action(t,e){65===e&&(this.quotedString+=this.text,this.skip())}DOUBLEQ_NL_action(t,e){66===e&&(this._type=this.previousTokenType=MathJSLabLexer.INVALID)}DOUBLEQ_DOUBLEQ_action(t,e){67===e&&(this.quotedString+='"',this.skip())}DOUBLEQ_ESCAPE_action(t,e){68===e&&(this.quotedString+=JSON.parse(`"${this.text}"`),this.skip())}DOUBLEQ_ESCAPE_OTHER_action(t,e){69===e&&(this.quotedString+=this.text.substring(1),this.skip())}DOUBLEQ_ESCAPE_OCT_action(t,e){70===e&&(this.quotedString+=JSON.parse(`"\\u${parseInt(this.text.substring(1),8).toString(16).padStart(4,"0")}"`),this.skip())}DOUBLEQ_ESCAPE_HEX_action(localctx,actionIndex){71===actionIndex&&(this.quotedString+=eval(`"\\x${this.text.substring(2)}"`),this.skip())}DOUBLEQ_ESCAPE_UNICODE_action(t,e){72===e&&(this.quotedString+=JSON.parse(`"\\u${this.text.substring(2).padStart(4,"0")}"`),this.skip())}DOUBLEQ_END_action(t,e){73===e&&(this.text=`"${this.quotedString}"`,this.popMode(),this._type=this.previousTokenType=MathJSLabLexer.STRING)}BLOCK_COMMENT_START_AGAIN_action(t,e){74===e&&(this.pushMode(MathJSLabLexer.BLOCK_COMMENT),this.skip())}BLOCK_COMMENT_END_action(t,e){75===e&&(this.popMode(),this.skip())}BLOCK_COMMENT_EOF_action(t,e){if(76===e)throw new SyntaxError("Block comment open at end of input.")}COMMAND_LINE_CONTINUATION_action(t,e){77===e&&(this.commandContinued=!0,this.skip())}COMMAND_CONTINUED_BLOCK_COMMENT_START_action(t,e){78===e&&(this.pushMode(MathJSLabLexer.BLOCK_COMMENT),this.skip())}COMMAND_LONE_DQUOTE_action(t,e){79===e&&(this.commandContinued=!1,this.text='"',this.previousTokenType=MathJSLabLexer.UNQUOTED_STRING,this._type=MathJSLabLexer.UNQUOTED_STRING)}COMMAND_LONE_SQUOTE_action(t,e){80===e&&(this.commandContinued=!1,this.text="'",this.previousTokenType=MathJSLabLexer.UNQUOTED_STRING,this._type=MathJSLabLexer.UNQUOTED_STRING)}COMMAND_UNCLOSED_DQUOTE_action(t,e){81===e&&(this.commandContinued=!1,this.previousTokenType=MathJSLabLexer.UNQUOTED_STRING,this._type=MathJSLabLexer.UNQUOTED_STRING)}COMMAND_UNCLOSED_SQUOTE_action(t,e){82===e&&(this.commandContinued=!1,this.previousTokenType=MathJSLabLexer.UNQUOTED_STRING,this._type=MathJSLabLexer.UNQUOTED_STRING)}COMMAND_DQSTRING_action(t,e){83===e&&(this.commandContinued=!1,this.pushMode(MathJSLabLexer.DQ_STRING),this.quotedString="",this.skip())}COMMAND_SQSTRING_action(t,e){84===e&&(this.commandContinued=!1,this.pushMode(MathJSLabLexer.SQ_STRING),this.quotedString="",this.skip())}COMMAND_SEPARATOR_action(t,e){85===e&&(this.commandContinued=!1,this.popMode(),this._type=this.previousTokenType=","===this.text?MathJSLabLexer.COMMA:MathJSLabLexer.SEMICOLON)}EXIT_AT_NEWLINE_action(t,e){86===e&&(this.commandContinued=!1,this.popMode(),this._type=this.previousTokenType=MathJSLabLexer.NEWLINE)}EXIT_AT_EOF_action(t,e){87===e&&(this.commandContinued=!1,this.popMode(),this._type=this.previousTokenType=MathJSLabLexer.EOF)}UNQUOTED_STRING_action(t,e){88===e&&(this.commandContinued=!1,this.previousTokenType=MathJSLabLexer.UNQUOTED_STRING)}sempred(t,e,r){switch(e){case 58:return this.BLOCK_COMMENT_START_sempred(t,r);case 74:return this.BLOCK_COMMENT_START_AGAIN_sempred(t,r);case 75:return this.BLOCK_COMMENT_END_sempred(t,r);case 79:return this.COMMAND_CONTINUED_BLOCK_COMMENT_START_sempred(t,r);case 80:return this.COMMAND_CONTINUED_COMMENT_LINE_sempred(t,r);case 81:return this.COMMAND_CONTINUED_NEWLINE_sempred(t,r);case 83:return this.COMMAND_LONE_DQUOTE_sempred(t,r);case 84:return this.COMMAND_LONE_SQUOTE_sempred(t,r);case 85:return this.COMMAND_UNCLOSED_DQUOTE_sempred(t,r);case 86:return this.COMMAND_UNCLOSED_SQUOTE_sempred(t,r);case 87:return this.COMMAND_DQSTRING_sempred(t,r);case 88:return this.COMMAND_SQSTRING_sempred(t,r)}return!0}BLOCK_COMMENT_START_sempred(t,e){return 0!==e||0===this.column}BLOCK_COMMENT_START_AGAIN_sempred(t,e){return 1!==e||0===this.column}BLOCK_COMMENT_END_sempred(t,e){return 2!==e||0===this.column}COMMAND_CONTINUED_BLOCK_COMMENT_START_sempred(t,e){return 3!==e||this.commandContinued}COMMAND_CONTINUED_COMMENT_LINE_sempred(t,e){return 4!==e||this.commandContinued}COMMAND_CONTINUED_NEWLINE_sempred(t,e){return 5!==e||this.commandContinued}COMMAND_LONE_DQUOTE_sempred(t,e){return 6!==e||[antlr4__WEBPACK_IMPORTED_MODULE_0__.ou.EOF,9,10,13,32].includes(this._input.LA(1))}COMMAND_LONE_SQUOTE_sempred(t,e){return 7!==e||[antlr4__WEBPACK_IMPORTED_MODULE_0__.ou.EOF,9,10,13,32].includes(this._input.LA(1))}COMMAND_UNCLOSED_DQUOTE_sempred(t,e){return 8!==e||!this.commandQuoteIsClosed(34)}COMMAND_UNCLOSED_SQUOTE_sempred(t,e){return 9!==e||!this.commandQuoteIsClosed(39)}COMMAND_DQSTRING_sempred(t,e){return 10!==e||this.commandQuoteIsClosed(34)}COMMAND_SQSTRING_sempred(t,e){return 11!==e||this.commandQuoteIsClosed(39)}static _serializedATN=[4,0,142,927,6,-1,6,-1,6,-1,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,2,61,7,61,2,62,7,62,2,63,7,63,2,64,7,64,2,65,7,65,2,66,7,66,2,67,7,67,2,68,7,68,2,69,7,69,2,70,7,70,2,71,7,71,2,72,7,72,2,73,7,73,2,74,7,74,2,75,7,75,2,76,7,76,2,77,7,77,2,78,7,78,2,79,7,79,2,80,7,80,2,81,7,81,2,82,7,82,2,83,7,83,2,84,7,84,2,85,7,85,2,86,7,86,2,87,7,87,2,88,7,88,2,89,7,89,2,90,7,90,2,91,7,91,2,92,7,92,2,93,7,93,2,94,7,94,2,95,7,95,2,96,7,96,2,97,7,97,2,98,7,98,2,99,7,99,2,100,7,100,2,101,7,101,2,102,7,102,2,103,7,103,2,104,7,104,2,105,7,105,2,106,7,106,1,0,1,0,1,0,1,1,1,1,1,1,1,2,1,2,1,2,1,3,1,3,1,3,1,4,1,4,1,4,1,5,1,5,1,5,1,6,1,6,1,6,1,7,1,7,1,7,1,8,1,8,1,8,1,9,1,9,1,9,1,10,1,10,1,10,1,11,1,11,1,11,1,12,1,12,1,12,1,13,1,13,1,13,1,14,1,14,1,14,1,15,1,15,1,15,1,16,1,16,1,16,1,17,1,17,1,17,1,18,1,18,1,18,1,19,1,19,1,19,1,20,1,20,1,20,1,20,1,20,1,21,1,21,1,21,1,21,1,21,1,22,1,22,1,22,1,22,1,22,1,23,1,23,1,23,1,23,1,23,1,24,1,24,1,24,1,24,1,24,1,25,1,25,1,25,1,25,1,25,3,25,310,8,25,1,25,1,25,1,26,1,26,1,26,1,26,1,26,1,26,1,27,1,27,1,27,1,27,1,27,1,27,1,28,1,28,1,28,1,28,1,28,1,28,1,29,1,29,1,29,1,29,1,29,1,29,1,29,3,29,339,8,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,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,35,1,35,1,35,1,36,1,36,1,36,1,37,1,37,1,37,1,37,1,37,1,38,1,38,1,38,1,38,1,38,1,39,1,39,1,39,1,39,3,39,386,8,39,1,39,1,39,1,40,1,40,1,40,1,40,1,40,1,41,1,41,1,41,1,42,1,42,1,42,1,42,1,42,1,43,1,43,1,43,1,43,1,43,1,44,1,44,1,44,1,44,1,44,1,45,1,45,1,45,1,45,1,45,1,46,1,46,1,46,1,46,1,46,1,47,1,47,1,47,3,47,426,8,47,1,47,1,47,1,48,1,48,1,48,1,48,1,48,3,48,435,8,48,1,48,1,48,1,49,1,49,1,49,1,49,1,49,1,50,1,50,1,50,1,51,1,51,1,51,1,52,1,52,1,52,1,53,1,53,3,53,455,8,53,1,53,1,53,1,54,1,54,1,54,1,54,1,54,1,55,1,55,1,55,1,55,1,55,5,55,469,8,55,10,55,12,55,472,9,55,1,55,1,55,1,55,1,56,1,56,1,56,1,56,1,56,1,56,5,56,483,8,56,10,56,12,56,486,9,56,1,56,1,56,3,56,490,8,56,3,56,492,8,56,1,56,1,56,1,57,1,57,1,57,1,58,1,58,3,58,501,8,58,1,58,1,58,1,58,3,58,506,8,58,1,58,1,58,1,58,1,59,1,59,5,59,513,8,59,10,59,12,59,516,9,59,1,59,1,59,1,59,1,59,1,59,3,59,523,8,59,1,60,1,60,1,61,4,61,528,8,61,11,61,12,61,529,1,61,1,61,1,62,1,62,1,62,1,63,1,63,1,63,1,63,1,63,1,64,1,64,1,64,1,65,4,65,546,8,65,11,65,12,65,547,1,65,1,65,1,66,1,66,1,66,1,67,1,67,1,67,1,67,1,67,1,68,1,68,1,68,1,68,1,69,1,69,1,69,1,69,1,70,1,70,1,70,3,70,571,8,70,1,70,3,70,574,8,70,1,70,1,70,1,71,1,71,1,71,1,71,3,71,582,8,71,1,71,1,71,1,72,1,72,1,72,1,72,3,72,590,8,72,1,72,3,72,593,8,72,1,72,3,72,596,8,72,1,72,1,72,1,73,1,73,1,73,1,74,1,74,3,74,605,8,74,1,74,1,74,1,74,3,74,610,8,74,1,74,1,74,1,74,1,75,1,75,3,75,617,8,75,1,75,1,75,1,75,3,75,622,8,75,1,75,3,75,625,8,75,1,75,1,75,1,76,5,76,630,8,76,10,76,12,76,633,9,76,1,76,1,76,1,76,1,76,1,77,5,77,640,8,77,10,77,12,77,643,9,77,1,77,1,77,1,77,1,78,1,78,1,78,1,78,1,78,5,78,653,8,78,10,78,12,78,656,9,78,1,78,1,78,1,78,1,79,1,79,3,79,663,8,79,1,79,1,79,1,79,3,79,668,8,79,1,79,1,79,1,79,1,80,1,80,1,80,5,80,676,8,80,10,80,12,80,679,9,80,1,80,1,80,1,80,1,80,1,81,1,81,1,81,1,81,1,81,1,82,1,82,1,82,1,82,1,83,1,83,1,83,1,83,1,84,1,84,1,84,1,84,1,85,1,85,1,85,5,85,705,8,85,10,85,12,85,708,9,85,1,85,1,85,1,86,1,86,1,86,5,86,715,8,86,10,86,12,86,718,9,86,1,86,1,86,1,87,1,87,1,87,1,87,1,88,1,88,1,88,1,88,1,89,1,89,5,89,732,8,89,10,89,12,89,735,9,89,1,89,1,89,1,90,1,90,1,90,1,91,1,91,1,91,1,92,1,92,1,92,1,93,1,93,5,93,750,8,93,10,93,12,93,753,9,93,1,93,1,93,1,94,1,94,1,95,1,95,3,95,761,8,95,1,95,3,95,764,8,95,1,96,4,96,767,8,96,11,96,12,96,768,1,97,1,97,5,97,773,8,97,10,97,12,97,776,9,97,1,98,1,98,3,98,780,8,98,1,98,1,98,3,98,784,8,98,1,98,5,98,787,8,98,10,98,12,98,790,9,98,1,99,1,99,3,99,794,8,99,1,99,3,99,797,8,99,1,99,1,99,3,99,801,8,99,1,99,1,99,3,99,805,8,99,1,99,1,99,1,99,1,99,3,99,811,8,99,1,99,3,99,814,8,99,1,99,1,99,3,99,818,8,99,1,99,1,99,3,99,822,8,99,1,99,1,99,1,99,1,99,3,99,828,8,99,1,99,3,99,831,8,99,1,99,1,99,3,99,835,8,99,1,99,1,99,3,99,839,8,99,1,99,1,99,1,99,1,99,3,99,845,8,99,1,99,3,99,848,8,99,1,99,1,99,3,99,852,8,99,1,99,1,99,3,99,856,8,99,3,99,858,8,99,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,3,100,869,8,100,1,101,1,101,1,101,1,101,1,101,1,101,1,101,1,101,3,101,879,8,101,3,101,881,8,101,1,102,1,102,3,102,885,8,102,1,102,5,102,888,8,102,10,102,12,102,891,9,102,1,103,1,103,3,103,895,8,103,1,103,5,103,898,8,103,10,103,12,103,901,9,103,1,104,1,104,3,104,905,8,104,1,104,5,104,908,8,104,10,104,12,104,911,9,104,1,105,1,105,3,105,915,8,105,1,105,5,105,918,8,105,10,105,12,105,921,9,105,1,106,3,106,924,8,106,1,106,1,106,1,631,0,107,5,49,7,50,9,51,11,52,13,53,15,54,17,55,19,56,21,57,23,58,25,59,27,60,29,61,31,62,33,63,35,64,37,65,39,66,41,67,43,68,45,69,47,70,49,71,51,72,53,73,55,74,57,75,59,76,61,77,63,78,65,79,67,80,69,81,71,82,73,83,75,84,77,85,79,86,81,87,83,88,85,89,87,90,89,91,91,92,93,93,95,94,97,95,99,96,101,97,103,98,105,99,107,100,109,101,111,102,113,103,115,104,117,105,119,106,121,107,123,108,125,109,127,110,129,111,131,112,133,113,135,114,137,115,139,116,141,117,143,118,145,119,147,120,149,121,151,122,153,123,155,124,157,125,159,126,161,127,163,128,165,129,167,130,169,131,171,132,173,133,175,134,177,135,179,136,181,137,183,138,185,139,187,140,189,141,191,142,193,0,195,0,197,0,199,0,201,0,203,0,205,0,207,0,209,0,211,0,213,0,215,0,217,0,5,0,1,2,3,4,25,2,0,73,74,105,106,5,0,39,39,42,42,47,47,92,92,94,94,2,0,10,10,13,13,3,0,10,10,13,13,39,39,4,0,10,10,13,13,34,34,92,92,8,0,34,34,39,39,92,92,98,98,102,102,110,110,114,114,116,116,1,0,48,55,3,0,48,57,65,70,97,102,3,0,9,10,13,13,32,32,2,0,44,44,59,59,7,0,9,10,13,13,32,32,34,34,39,39,44,44,59,59,5,0,9,10,13,13,32,32,44,44,59,59,2,0,35,35,37,37,2,0,9,9,32,32,3,0,65,90,95,95,97,122,4,0,48,57,65,90,95,95,97,122,2,0,68,69,100,101,2,0,66,66,98,98,2,0,80,80,112,112,2,0,79,79,111,111,2,0,88,88,120,120,2,0,115,115,117,117,1,0,48,57,1,0,48,49,2,0,43,43,45,45,987,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,1,0,0,0,0,47,1,0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,0,0,57,1,0,0,0,0,59,1,0,0,0,0,61,1,0,0,0,0,63,1,0,0,0,0,65,1,0,0,0,0,67,1,0,0,0,0,69,1,0,0,0,0,71,1,0,0,0,0,73,1,0,0,0,0,75,1,0,0,0,0,77,1,0,0,0,0,79,1,0,0,0,0,81,1,0,0,0,0,83,1,0,0,0,0,85,1,0,0,0,0,87,1,0,0,0,0,89,1,0,0,0,0,91,1,0,0,0,0,93,1,0,0,0,0,95,1,0,0,0,0,97,1,0,0,0,0,99,1,0,0,0,0,101,1,0,0,0,0,103,1,0,0,0,0,105,1,0,0,0,0,107,1,0,0,0,0,109,1,0,0,0,0,111,1,0,0,0,0,113,1,0,0,0,0,115,1,0,0,0,0,117,1,0,0,0,0,119,1,0,0,0,0,121,1,0,0,0,0,123,1,0,0,0,0,125,1,0,0,0,1,127,1,0,0,0,1,129,1,0,0,0,1,131,1,0,0,0,1,133,1,0,0,0,2,135,1,0,0,0,2,137,1,0,0,0,2,139,1,0,0,0,2,141,1,0,0,0,2,143,1,0,0,0,2,145,1,0,0,0,2,147,1,0,0,0,2,149,1,0,0,0,2,151,1,0,0,0,3,153,1,0,0,0,3,155,1,0,0,0,3,157,1,0,0,0,3,159,1,0,0,0,4,161,1,0,0,0,4,163,1,0,0,0,4,165,1,0,0,0,4,167,1,0,0,0,4,169,1,0,0,0,4,171,1,0,0,0,4,173,1,0,0,0,4,175,1,0,0,0,4,177,1,0,0,0,4,179,1,0,0,0,4,181,1,0,0,0,4,183,1,0,0,0,4,185,1,0,0,0,4,187,1,0,0,0,4,189,1,0,0,0,4,191,1,0,0,0,5,219,1,0,0,0,7,222,1,0,0,0,9,225,1,0,0,0,11,228,1,0,0,0,13,231,1,0,0,0,15,234,1,0,0,0,17,237,1,0,0,0,19,240,1,0,0,0,21,243,1,0,0,0,23,246,1,0,0,0,25,249,1,0,0,0,27,252,1,0,0,0,29,255,1,0,0,0,31,258,1,0,0,0,33,261,1,0,0,0,35,264,1,0,0,0,37,267,1,0,0,0,39,270,1,0,0,0,41,273,1,0,0,0,43,276,1,0,0,0,45,279,1,0,0,0,47,284,1,0,0,0,49,289,1,0,0,0,51,294,1,0,0,0,53,299,1,0,0,0,55,309,1,0,0,0,57,313,1,0,0,0,59,319,1,0,0,0,61,325,1,0,0,0,63,338,1,0,0,0,65,342,1,0,0,0,67,347,1,0,0,0,69,352,1,0,0,0,71,357,1,0,0,0,73,362,1,0,0,0,75,365,1,0,0,0,77,368,1,0,0,0,79,371,1,0,0,0,81,376,1,0,0,0,83,385,1,0,0,0,85,389,1,0,0,0,87,394,1,0,0,0,89,397,1,0,0,0,91,402,1,0,0,0,93,407,1,0,0,0,95,412,1,0,0,0,97,417,1,0,0,0,99,425,1,0,0,0,101,434,1,0,0,0,103,438,1,0,0,0,105,443,1,0,0,0,107,446,1,0,0,0,109,449,1,0,0,0,111,452,1,0,0,0,113,458,1,0,0,0,115,463,1,0,0,0,117,476,1,0,0,0,119,495,1,0,0,0,121,498,1,0,0,0,123,510,1,0,0,0,125,524,1,0,0,0,127,527,1,0,0,0,129,533,1,0,0,0,131,536,1,0,0,0,133,541,1,0,0,0,135,545,1,0,0,0,137,551,1,0,0,0,139,554,1,0,0,0,141,559,1,0,0,0,143,563,1,0,0,0,145,567,1,0,0,0,147,577,1,0,0,0,149,585,1,0,0,0,151,599,1,0,0,0,153,602,1,0,0,0,155,614,1,0,0,0,157,631,1,0,0,0,159,641,1,0,0,0,161,647,1,0,0,0,163,660,1,0,0,0,165,672,1,0,0,0,167,684,1,0,0,0,169,689,1,0,0,0,171,693,1,0,0,0,173,697,1,0,0,0,175,701,1,0,0,0,177,711,1,0,0,0,179,721,1,0,0,0,181,725,1,0,0,0,183,729,1,0,0,0,185,738,1,0,0,0,187,741,1,0,0,0,189,744,1,0,0,0,191,747,1,0,0,0,193,756,1,0,0,0,195,763,1,0,0,0,197,766,1,0,0,0,199,770,1,0,0,0,201,777,1,0,0,0,203,857,1,0,0,0,205,859,1,0,0,0,207,880,1,0,0,0,209,882,1,0,0,0,211,892,1,0,0,0,213,902,1,0,0,0,215,912,1,0,0,0,217,923,1,0,0,0,219,220,5,43,0,0,220,221,6,0,0,0,221,6,1,0,0,0,222,223,5,45,0,0,223,224,6,1,1,0,224,8,1,0,0,0,225,226,5,42,0,0,226,227,6,2,2,0,227,10,1,0,0,0,228,229,5,47,0,0,229,230,6,3,3,0,230,12,1,0,0,0,231,232,5,61,0,0,232,233,6,4,4,0,233,14,1,0,0,0,234,235,5,58,0,0,235,236,6,5,5,0,236,16,1,0,0,0,237,238,5,59,0,0,238,239,6,6,6,0,239,18,1,0,0,0,240,241,5,44,0,0,241,242,6,7,7,0,242,20,1,0,0,0,243,244,5,46,0,0,244,245,6,8,8,0,245,22,1,0,0,0,246,247,5,126,0,0,247,248,6,9,9,0,248,24,1,0,0,0,249,250,5,33,0,0,250,251,6,10,10,0,251,26,1,0,0,0,252,253,5,64,0,0,253,254,6,11,11,0,254,28,1,0,0,0,255,256,5,63,0,0,256,257,6,12,12,0,257,30,1,0,0,0,258,259,5,40,0,0,259,260,6,13,13,0,260,32,1,0,0,0,261,262,5,41,0,0,262,263,6,14,14,0,263,34,1,0,0,0,264,265,5,91,0,0,265,266,6,15,15,0,266,36,1,0,0,0,267,268,5,93,0,0,268,269,6,16,16,0,269,38,1,0,0,0,270,271,5,123,0,0,271,272,6,17,17,0,272,40,1,0,0,0,273,274,5,125,0,0,274,275,6,18,18,0,275,42,1,0,0,0,276,277,5,92,0,0,277,278,6,19,19,0,278,44,1,0,0,0,279,280,5,43,0,0,280,281,5,61,0,0,281,282,1,0,0,0,282,283,6,20,20,0,283,46,1,0,0,0,284,285,5,45,0,0,285,286,5,61,0,0,286,287,1,0,0,0,287,288,6,21,21,0,288,48,1,0,0,0,289,290,5,42,0,0,290,291,5,61,0,0,291,292,1,0,0,0,292,293,6,22,22,0,293,50,1,0,0,0,294,295,5,47,0,0,295,296,5,61,0,0,296,297,1,0,0,0,297,298,6,23,23,0,298,52,1,0,0,0,299,300,5,92,0,0,300,301,5,61,0,0,301,302,1,0,0,0,302,303,6,24,24,0,303,54,1,0,0,0,304,305,5,94,0,0,305,310,5,61,0,0,306,307,5,42,0,0,307,308,5,42,0,0,308,310,5,61,0,0,309,304,1,0,0,0,309,306,1,0,0,0,310,311,1,0,0,0,311,312,6,25,25,0,312,56,1,0,0,0,313,314,5,46,0,0,314,315,5,42,0,0,315,316,5,61,0,0,316,317,1,0,0,0,317,318,6,26,26,0,318,58,1,0,0,0,319,320,5,46,0,0,320,321,5,47,0,0,321,322,5,61,0,0,322,323,1,0,0,0,323,324,6,27,27,0,324,60,1,0,0,0,325,326,5,46,0,0,326,327,5,92,0,0,327,328,5,61,0,0,328,329,1,0,0,0,329,330,6,28,28,0,330,62,1,0,0,0,331,332,5,46,0,0,332,333,5,94,0,0,333,339,5,61,0,0,334,335,5,46,0,0,335,336,5,42,0,0,336,337,5,42,0,0,337,339,5,61,0,0,338,331,1,0,0,0,338,334,1,0,0,0,339,340,1,0,0,0,340,341,6,29,29,0,341,64,1,0,0,0,342,343,5,38,0,0,343,344,5,61,0,0,344,345,1,0,0,0,345,346,6,30,30,0,346,66,1,0,0,0,347,348,5,124,0,0,348,349,5,61,0,0,349,350,1,0,0,0,350,351,6,31,31,0,351,68,1,0,0,0,352,353,5,38,0,0,353,354,5,38,0,0,354,355,1,0,0,0,355,356,6,32,32,0,356,70,1,0,0,0,357,358,5,124,0,0,358,359,5,124,0,0,359,360,1,0,0,0,360,361,6,33,33,0,361,72,1,0,0,0,362,363,5,38,0,0,363,364,6,34,34,0,364,74,1,0,0,0,365,366,5,124,0,0,366,367,6,35,35,0,367,76,1,0,0,0,368,369,5,60,0,0,369,370,6,36,36,0,370,78,1,0,0,0,371,372,5,60,0,0,372,373,5,61,0,0,373,374,1,0,0,0,374,375,6,37,37,0,375,80,1,0,0,0,376,377,5,61,0,0,377,378,5,61,0,0,378,379,1,0,0,0,379,380,6,38,38,0,380,82,1,0,0,0,381,382,5,33,0,0,382,386,5,61,0,0,383,384,5,126,0,0,384,386,5,61,0,0,385,381,1,0,0,0,385,383,1,0,0,0,386,387,1,0,0,0,387,388,6,39,39,0,388,84,1,0,0,0,389,390,5,62,0,0,390,391,5,61,0,0,391,392,1,0,0,0,392,393,6,40,40,0,393,86,1,0,0,0,394,395,5,62,0,0,395,396,6,41,41,0,396,88,1,0,0,0,397,398,5,46,0,0,398,399,5,42,0,0,399,400,1,0,0,0,400,401,6,42,42,0,401,90,1,0,0,0,402,403,5,46,0,0,403,404,5,47,0,0,404,405,1,0,0,0,405,406,6,43,43,0,406,92,1,0,0,0,407,408,5,46,0,0,408,409,5,92,0,0,409,410,1,0,0,0,410,411,6,44,44,0,411,94,1,0,0,0,412,413,5,43,0,0,413,414,5,43,0,0,414,415,1,0,0,0,415,416,6,45,45,0,416,96,1,0,0,0,417,418,5,45,0,0,418,419,5,45,0,0,419,420,1,0,0,0,420,421,6,46,46,0,421,98,1,0,0,0,422,426,5,94,0,0,423,424,5,42,0,0,424,426,5,42,0,0,425,422,1,0,0,0,425,423,1,0,0,0,426,427,1,0,0,0,427,428,6,47,47,0,428,100,1,0,0,0,429,430,5,46,0,0,430,435,5,94,0,0,431,432,5,46,0,0,432,433,5,42,0,0,433,435,5,42,0,0,434,429,1,0,0,0,434,431,1,0,0,0,435,436,1,0,0,0,436,437,6,48,48,0,437,102,1,0,0,0,438,439,5,46,0,0,439,440,5,39,0,0,440,441,1,0,0,0,441,442,6,49,49,0,442,104,1,0,0,0,443,444,5,39,0,0,444,445,6,50,50,0,445,106,1,0,0,0,446,447,5,34,0,0,447,448,6,51,51,0,448,108,1,0,0,0,449,450,3,199,97,0,450,451,6,52,52,0,451,110,1,0,0,0,452,454,3,203,99,0,453,455,7,0,0,0,454,453,1,0,0,0,454,455,1,0,0,0,455,456,1,0,0,0,456,457,6,53,53,0,457,112,1,0,0,0,458,459,3,207,101,0,459,460,5,46,0,0,460,461,7,1,0,0,461,462,6,54,54,0,462,114,1,0,0,0,463,464,5,46,0,0,464,465,5,46,0,0,465,466,5,46,0,0,466,470,1,0,0,0,467,469,8,2,0,0,468,467,1,0,0,0,469,472,1,0,0,0,470,468,1,0,0,0,470,471,1,0,0,0,471,473,1,0,0,0,472,470,1,0,0,0,473,474,3,195,95,0,474,475,6,55,55,0,475,116,1,0,0,0,476,491,3,197,96,0,477,478,5,46,0,0,478,479,5,46,0,0,479,480,5,46,0,0,480,484,1,0,0,0,481,483,8,2,0,0,482,481,1,0,0,0,483,486,1,0,0,0,484,482,1,0,0,0,484,485,1,0,0,0,485,487,1,0,0,0,486,484,1,0,0,0,487,489,3,195,95,0,488,490,3,197,96,0,489,488,1,0,0,0,489,490,1,0,0,0,490,492,1,0,0,0,491,477,1,0,0,0,491,492,1,0,0,0,492,493,1,0,0,0,493,494,6,56,56,0,494,118,1,0,0,0,495,496,3,195,95,0,496,497,6,57,57,0,497,120,1,0,0,0,498,500,4,58,0,0,499,501,3,197,96,0,500,499,1,0,0,0,500,501,1,0,0,0,501,502,1,0,0,0,502,503,3,193,94,0,503,505,5,123,0,0,504,506,3,197,96,0,505,504,1,0,0,0,505,506,1,0,0,0,506,507,1,0,0,0,507,508,3,195,95,0,508,509,6,58,58,0,509,122,1,0,0,0,510,514,3,193,94,0,511,513,8,2,0,0,512,511,1,0,0,0,513,516,1,0,0,0,514,512,1,0,0,0,514,515,1,0,0,0,515,522,1,0,0,0,516,514,1,0,0,0,517,518,3,195,95,0,518,519,6,59,59,0,519,523,1,0,0,0,520,521,5,0,0,1,521,523,6,59,60,0,522,517,1,0,0,0,522,520,1,0,0,0,523,124,1,0,0,0,524,525,9,0,0,0,525,126,1,0,0,0,526,528,8,3,0,0,527,526,1,0,0,0,528,529,1,0,0,0,529,527,1,0,0,0,529,530,1,0,0,0,530,531,1,0,0,0,531,532,6,61,61,0,532,128,1,0,0,0,533,534,3,195,95,0,534,535,6,62,62,0,535,130,1,0,0,0,536,537,5,39,0,0,537,538,5,39,0,0,538,539,1,0,0,0,539,540,6,63,63,0,540,132,1,0,0,0,541,542,5,39,0,0,542,543,6,64,64,0,543,134,1,0,0,0,544,546,8,4,0,0,545,544,1,0,0,0,546,547,1,0,0,0,547,545,1,0,0,0,547,548,1,0,0,0,548,549,1,0,0,0,549,550,6,65,65,0,550,136,1,0,0,0,551,552,3,195,95,0,552,553,6,66,66,0,553,138,1,0,0,0,554,555,5,34,0,0,555,556,5,34,0,0,556,557,1,0,0,0,557,558,6,67,67,0,558,140,1,0,0,0,559,560,5,92,0,0,560,561,7,5,0,0,561,562,6,68,68,0,562,142,1,0,0,0,563,564,5,92,0,0,564,565,9,0,0,0,565,566,6,69,69,0,566,144,1,0,0,0,567,568,5,92,0,0,568,570,7,6,0,0,569,571,7,6,0,0,570,569,1,0,0,0,570,571,1,0,0,0,571,573,1,0,0,0,572,574,7,6,0,0,573,572,1,0,0,0,573,574,1,0,0,0,574,575,1,0,0,0,575,576,6,70,70,0,576,146,1,0,0,0,577,578,5,92,0,0,578,579,5,120,0,0,579,581,7,7,0,0,580,582,7,7,0,0,581,580,1,0,0,0,581,582,1,0,0,0,582,583,1,0,0,0,583,584,6,71,71,0,584,148,1,0,0,0,585,586,5,92,0,0,586,587,5,117,0,0,587,589,7,7,0,0,588,590,7,7,0,0,589,588,1,0,0,0,589,590,1,0,0,0,590,592,1,0,0,0,591,593,7,7,0,0,592,591,1,0,0,0,592,593,1,0,0,0,593,595,1,0,0,0,594,596,7,7,0,0,595,594,1,0,0,0,595,596,1,0,0,0,596,597,1,0,0,0,597,598,6,72,72,0,598,150,1,0,0,0,599,600,5,34,0,0,600,601,6,73,73,0,601,152,1,0,0,0,602,604,4,74,1,0,603,605,3,197,96,0,604,603,1,0,0,0,604,605,1,0,0,0,605,606,1,0,0,0,606,607,3,193,94,0,607,609,5,123,0,0,608,610,3,197,96,0,609,608,1,0,0,0,609,610,1,0,0,0,610,611,1,0,0,0,611,612,3,195,95,0,612,613,6,74,74,0,613,154,1,0,0,0,614,616,4,75,2,0,615,617,3,197,96,0,616,615,1,0,0,0,616,617,1,0,0,0,617,618,1,0,0,0,618,619,3,193,94,0,619,621,5,125,0,0,620,622,3,197,96,0,621,620,1,0,0,0,621,622,1,0,0,0,622,624,1,0,0,0,623,625,3,195,95,0,624,623,1,0,0,0,624,625,1,0,0,0,625,626,1,0,0,0,626,627,6,75,75,0,627,156,1,0,0,0,628,630,9,0,0,0,629,628,1,0,0,0,630,633,1,0,0,0,631,632,1,0,0,0,631,629,1,0,0,0,632,634,1,0,0,0,633,631,1,0,0,0,634,635,3,195,95,0,635,636,1,0,0,0,636,637,6,76,76,0,637,158,1,0,0,0,638,640,8,2,0,0,639,638,1,0,0,0,640,643,1,0,0,0,641,639,1,0,0,0,641,642,1,0,0,0,642,644,1,0,0,0,643,641,1,0,0,0,644,645,5,0,0,1,645,646,6,77,77,0,646,160,1,0,0,0,647,648,5,46,0,0,648,649,5,46,0,0,649,650,5,46,0,0,650,654,1,0,0,0,651,653,8,2,0,0,652,651,1,0,0,0,653,656,1,0,0,0,654,652,1,0,0,0,654,655,1,0,0,0,655,657,1,0,0,0,656,654,1,0,0,0,657,658,3,195,95,0,658,659,6,78,78,0,659,162,1,0,0,0,660,662,4,79,3,0,661,663,3,197,96,0,662,661,1,0,0,0,662,663,1,0,0,0,663,664,1,0,0,0,664,665,3,193,94,0,665,667,5,123,0,0,666,668,3,197,96,0,667,666,1,0,0,0,667,668,1,0,0,0,668,669,1,0,0,0,669,670,3,195,95,0,670,671,6,79,79,0,671,164,1,0,0,0,672,673,4,80,4,0,673,677,3,193,94,0,674,676,8,2,0,0,675,674,1,0,0,0,676,679,1,0,0,0,677,675,1,0,0,0,677,678,1,0,0,0,678,680,1,0,0,0,679,677,1,0,0,0,680,681,3,195,95,0,681,682,1,0,0,0,682,683,6,80,76,0,683,166,1,0,0,0,684,685,4,81,5,0,685,686,3,195,95,0,686,687,1,0,0,0,687,688,6,81,76,0,688,168,1,0,0,0,689,690,3,197,96,0,690,691,1,0,0,0,691,692,6,82,76,0,692,170,1,0,0,0,693,694,5,34,0,0,694,695,4,83,6,0,695,696,6,83,80,0,696,172,1,0,0,0,697,698,5,39,0,0,698,699,4,84,7,0,699,700,6,84,81,0,700,174,1,0,0,0,701,702,5,34,0,0,702,706,4,85,8,0,703,705,8,8,0,0,704,703,1,0,0,0,705,708,1,0,0,0,706,704,1,0,0,0,706,707,1,0,0,0,707,709,1,0,0,0,708,706,1,0,0,0,709,710,6,85,82,0,710,176,1,0,0,0,711,712,5,39,0,0,712,716,4,86,9,0,713,715,8,8,0,0,714,713,1,0,0,0,715,718,1,0,0,0,716,714,1,0,0,0,716,717,1,0,0,0,717,719,1,0,0,0,718,716,1,0,0,0,719,720,6,86,83,0,720,178,1,0,0,0,721,722,5,34,0,0,722,723,4,87,10,0,723,724,6,87,84,0,724,180,1,0,0,0,725,726,5,39,0,0,726,727,4,88,11,0,727,728,6,88,85,0,728,182,1,0,0,0,729,733,3,193,94,0,730,732,8,2,0,0,731,730,1,0,0,0,732,735,1,0,0,0,733,731,1,0,0,0,733,734,1,0,0,0,734,736,1,0,0,0,735,733,1,0,0,0,736,737,6,89,76,0,737,184,1,0,0,0,738,739,7,9,0,0,739,740,6,90,86,0,740,186,1,0,0,0,741,742,3,195,95,0,742,743,6,91,87,0,743,188,1,0,0,0,744,745,5,0,0,1,745,746,6,92,88,0,746,190,1,0,0,0,747,751,8,10,0,0,748,750,8,11,0,0,749,748,1,0,0,0,750,753,1,0,0,0,751,749,1,0,0,0,751,752,1,0,0,0,752,754,1,0,0,0,753,751,1,0,0,0,754,755,6,93,89,0,755,192,1,0,0,0,756,757,7,12,0,0,757,194,1,0,0,0,758,764,5,13,0,0,759,761,5,13,0,0,760,759,1,0,0,0,760,761,1,0,0,0,761,762,1,0,0,0,762,764,5,10,0,0,763,758,1,0,0,0,763,760,1,0,0,0,764,196,1,0,0,0,765,767,7,13,0,0,766,765,1,0,0,0,767,768,1,0,0,0,768,766,1,0,0,0,768,769,1,0,0,0,769,198,1,0,0,0,770,774,7,14,0,0,771,773,7,15,0,0,772,771,1,0,0,0,773,776,1,0,0,0,774,772,1,0,0,0,774,775,1,0,0,0,775,200,1,0,0,0,776,774,1,0,0,0,777,788,3,199,97,0,778,780,3,197,96,0,779,778,1,0,0,0,779,780,1,0,0,0,780,781,1,0,0,0,781,783,5,46,0,0,782,784,3,197,96,0,783,782,1,0,0,0,783,784,1,0,0,0,784,785,1,0,0,0,785,787,3,199,97,0,786,779,1,0,0,0,787,790,1,0,0,0,788,786,1,0,0,0,788,789,1,0,0,0,789,202,1,0,0,0,790,788,1,0,0,0,791,793,3,209,102,0,792,794,5,46,0,0,793,792,1,0,0,0,793,794,1,0,0,0,794,801,1,0,0,0,795,797,3,209,102,0,796,795,1,0,0,0,796,797,1,0,0,0,797,798,1,0,0,0,798,799,5,46,0,0,799,801,3,209,102,0,800,791,1,0,0,0,800,796,1,0,0,0,801,804,1,0,0,0,802,803,7,16,0,0,803,805,3,217,106,0,804,802,1,0,0,0,804,805,1,0,0,0,805,858,1,0,0,0,806,807,5,48,0,0,807,817,7,17,0,0,808,810,3,211,103,0,809,811,5,46,0,0,810,809,1,0,0,0,810,811,1,0,0,0,811,818,1,0,0,0,812,814,3,211,103,0,813,812,1,0,0,0,813,814,1,0,0,0,814,815,1,0,0,0,815,816,5,46,0,0,816,818,3,211,103,0,817,808,1,0,0,0,817,813,1,0,0,0,818,821,1,0,0,0,819,820,7,18,0,0,820,822,3,217,106,0,821,819,1,0,0,0,821,822,1,0,0,0,822,858,1,0,0,0,823,824,5,48,0,0,824,834,7,19,0,0,825,827,3,213,104,0,826,828,5,46,0,0,827,826,1,0,0,0,827,828,1,0,0,0,828,835,1,0,0,0,829,831,3,213,104,0,830,829,1,0,0,0,830,831,1,0,0,0,831,832,1,0,0,0,832,833,5,46,0,0,833,835,3,213,104,0,834,825,1,0,0,0,834,830,1,0,0,0,835,838,1,0,0,0,836,837,7,18,0,0,837,839,3,217,106,0,838,836,1,0,0,0,838,839,1,0,0,0,839,858,1,0,0,0,840,841,5,48,0,0,841,851,7,20,0,0,842,844,3,215,105,0,843,845,5,46,0,0,844,843,1,0,0,0,844,845,1,0,0,0,845,852,1,0,0,0,846,848,3,215,105,0,847,846,1,0,0,0,847,848,1,0,0,0,848,849,1,0,0,0,849,850,5,46,0,0,850,852,3,215,105,0,851,842,1,0,0,0,851,847,1,0,0,0,852,855,1,0,0,0,853,854,7,18,0,0,854,856,3,217,106,0,855,853,1,0,0,0,855,856,1,0,0,0,856,858,1,0,0,0,857,800,1,0,0,0,857,806,1,0,0,0,857,823,1,0,0,0,857,840,1,0,0,0,858,204,1,0,0,0,859,860,3,207,101,0,860,868,7,21,0,0,861,869,5,56,0,0,862,863,5,49,0,0,863,869,5,54,0,0,864,865,5,51,0,0,865,869,5,50,0,0,866,867,5,54,0,0,867,869,5,52,0,0,868,861,1,0,0,0,868,862,1,0,0,0,868,864,1,0,0,0,868,866,1,0,0,0,869,206,1,0,0,0,870,881,3,209,102,0,871,878,5,48,0,0,872,873,7,17,0,0,873,879,3,211,103,0,874,875,7,19,0,0,875,879,3,213,104,0,876,877,7,20,0,0,877,879,3,215,105,0,878,872,1,0,0,0,878,874,1,0,0,0,878,876,1,0,0,0,879,881,1,0,0,0,880,870,1,0,0,0,880,871,1,0,0,0,881,208,1,0,0,0,882,889,7,22,0,0,883,885,5,95,0,0,884,883,1,0,0,0,884,885,1,0,0,0,885,886,1,0,0,0,886,888,7,22,0,0,887,884,1,0,0,0,888,891,1,0,0,0,889,887,1,0,0,0,889,890,1,0,0,0,890,210,1,0,0,0,891,889,1,0,0,0,892,899,7,23,0,0,893,895,5,95,0,0,894,893,1,0,0,0,894,895,1,0,0,0,895,896,1,0,0,0,896,898,7,23,0,0,897,894,1,0,0,0,898,901,1,0,0,0,899,897,1,0,0,0,899,900,1,0,0,0,900,212,1,0,0,0,901,899,1,0,0,0,902,909,7,6,0,0,903,905,5,95,0,0,904,903,1,0,0,0,904,905,1,0,0,0,905,906,1,0,0,0,906,908,7,6,0,0,907,904,1,0,0,0,908,911,1,0,0,0,909,907,1,0,0,0,909,910,1,0,0,0,910,214,1,0,0,0,911,909,1,0,0,0,912,919,7,7,0,0,913,915,5,95,0,0,914,913,1,0,0,0,914,915,1,0,0,0,915,916,1,0,0,0,916,918,7,7,0,0,917,914,1,0,0,0,918,921,1,0,0,0,919,917,1,0,0,0,919,920,1,0,0,0,920,216,1,0,0,0,921,919,1,0,0,0,922,924,7,24,0,0,923,922,1,0,0,0,923,924,1,0,0,0,924,925,1,0,0,0,925,926,3,209,102,0,926,218,1,0,0,0,78,0,1,2,3,4,309,338,385,425,434,454,470,484,489,491,500,505,514,522,529,547,570,573,581,589,592,595,604,609,616,621,624,631,641,654,662,667,677,706,716,733,751,760,763,768,774,779,783,788,793,796,800,804,810,813,817,821,827,830,834,838,844,847,851,855,857,868,878,880,884,889,894,899,904,909,914,919,923,90,1,0,0,1,1,1,1,2,2,1,3,3,1,4,4,1,5,5,1,6,6,1,7,7,1,8,8,1,9,9,1,10,10,1,11,11,1,12,12,1,13,13,1,14,14,1,15,15,1,16,16,1,17,17,1,18,18,1,19,19,1,20,20,1,21,21,1,22,22,1,23,23,1,24,24,1,25,25,1,26,26,1,27,27,1,28,28,1,29,29,1,30,30,1,31,31,1,32,32,1,33,33,1,34,34,1,35,35,1,36,36,1,37,37,1,38,38,1,39,39,1,40,40,1,41,41,1,42,42,1,43,43,1,44,44,1,45,45,1,46,46,1,47,47,1,48,48,1,49,49,1,50,50,1,51,51,1,52,52,1,53,53,1,54,54,1,55,55,1,56,56,1,57,57,1,58,58,1,59,59,1,59,60,1,61,61,1,62,62,1,63,63,1,64,64,1,65,65,1,66,66,1,67,67,1,68,68,1,69,69,1,70,70,1,71,71,1,72,72,1,73,73,1,74,74,1,75,75,6,0,0,1,77,76,1,78,77,1,79,78,1,83,79,1,84,80,1,85,81,1,86,82,1,87,83,1,88,84,1,90,85,1,91,86,1,92,87,1,93,88];static __ATN;static get _ATN(){return MathJSLabLexer.__ATN||(MathJSLabLexer.__ATN=(new antlr4__WEBPACK_IMPORTED_MODULE_0__.fr).deserialize(MathJSLabLexer._serializedATN)),MathJSLabLexer.__ATN}static DecisionsToDFA=MathJSLabLexer._ATN.decisionToState.map((t,e)=>new antlr4__WEBPACK_IMPORTED_MODULE_0__.M8(t,e))}},896(t){t.exports=__WEBPACK_EXTERNAL_createRequire_require("fs")},990(t,e,r){r.d(e,{Dj:()=>or,JG:()=>tr,M8:()=>Xe,MG:()=>Ge,Pg:()=>nr,X2:()=>rr,ay:()=>er,eP:()=>Ye,fr:()=>We,iH:()=>Ke,iX:()=>sr,jB:()=>Qe,ou:()=>lr,pG:()=>Ze,re:()=>ir,tD:()=>ar});var s={d:(t,e)=>{for(var r in e)s.o(e,r)&&!s.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},i={};s.d(i,{MG:()=>Q,fr:()=>Nt,sR:()=>be,Zo:()=>Te,iH:()=>we,rt:()=>Pt,jB:()=>De,M8:()=>ce,$t:()=>_e,aq:()=>Ae,pG:()=>It,eP:()=>xe,tf:()=>Ie,KU:()=>ye,zW:()=>ve,IX:()=>S,mY:()=>E,a7:()=>K,JG:()=>Ut,ay:()=>Xt,X2:()=>re,WU:()=>me,Uw:()=>pe,gw:()=>fe,iX:()=>ke,re:()=>ie,Pg:()=>Be,tD:()=>ne,R$:()=>ee,Dj:()=>kt,m7:()=>U,NZ:()=>P,xo:()=>D,ou:()=>n,qC:()=>$e,mD:()=>m,Ay:()=>ze});class n{constructor(){this.source=null,this.type=null,this.channel=null,this.start=null,this.stop=null,this.tokenIndex=null,this.line=null,this.column=null,this._text=null}getTokenSource(){return this.source[0]}getInputStream(){return this.source[1]}get text(){return this._text}set text(t){this._text=t}}function a(t,e){if(!Array.isArray(t)||!Array.isArray(e))return!1;if(t===e)return!0;if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!(t[r]===e[r]||t[r].equals&&t[r].equals(e[r])))return!1;return!0}n.INVALID_TYPE=0,n.EPSILON=-2,n.MIN_USER_TOKEN_TYPE=1,n.EOF=-1,n.DEFAULT_CHANNEL=0,n.HIDDEN_CHANNEL=1;const o=Math.round(Math.random()*Math.pow(2,32));function l(t){if(!t)return 0;const e=typeof t,r="string"===e?t:!("object"!==e||!t.toString)&&t.toString();if(!r)return 0;let s,i;const n=3&r.length,a=r.length-n;let l=o;const c=3432918353,u=461845907;let h=0;for(;h<a;)i=255&r.charCodeAt(h)|(255&r.charCodeAt(++h))<<8|(255&r.charCodeAt(++h))<<16|(255&r.charCodeAt(++h))<<24,++h,i=(65535&i)*c+(((i>>>16)*c&65535)<<16)&4294967295,i=i<<15|i>>>17,i=(65535&i)*u+(((i>>>16)*u&65535)<<16)&4294967295,l^=i,l=l<<13|l>>>19,s=5*(65535&l)+((5*(l>>>16)&65535)<<16)&4294967295,l=27492+(65535&s)+((58964+(s>>>16)&65535)<<16);switch(i=0,n){case 3:i^=(255&r.charCodeAt(h+2))<<16;case 2:i^=(255&r.charCodeAt(h+1))<<8;case 1:i^=255&r.charCodeAt(h),i=(65535&i)*c+(((i>>>16)*c&65535)<<16)&4294967295,i=i<<15|i>>>17,i=(65535&i)*u+(((i>>>16)*u&65535)<<16)&4294967295,l^=i}return l^=r.length,l^=l>>>16,l=2246822507*(65535&l)+((2246822507*(l>>>16)&65535)<<16)&4294967295,l^=l>>>13,l=3266489909*(65535&l)+((3266489909*(l>>>16)&65535)<<16)&4294967295,l^=l>>>16,l>>>0}class c{constructor(){this.count=0,this.hash=0}update(){for(let t=0;t<arguments.length;t++){const e=arguments[t];if(null!=e)if(Array.isArray(e))this.update.apply(this,e);else{let t=0;switch(typeof e){case"undefined":case"function":continue;case"number":case"boolean":t=e;break;case"string":t=l(e);break;default:e.updateHashCode?e.updateHashCode(this):console.log("No updateHashCode for "+e.toString());continue}t*=3432918353,t=t<<15|t>>>17,t*=461845907,this.count=this.count+1;let r=this.hash^t;r=r<<13|r>>>19,r=5*r+3864292196,this.hash=r}}}finish(){let t=this.hash^4*this.count;return t^=t>>>16,t*=2246822507,t^=t>>>13,t*=3266489909,t^=t>>>16,t}static hashStuff(){const t=new c;return t.update.apply(t,arguments),t.finish()}}function u(t){return t?"string"==typeof t?l(t):t.hashCode():-1}function h(t,e){return t&&t.equals?t.equals(e):t===e}function d(t){return null===t?"null":t}function m(t){return Array.isArray(t)?"["+t.map(d).join(", ")+"]":"null"}class p{constructor(t,e){this.buckets=new Array(16),this.threshold=Math.floor(12),this.itemCount=0,this.hashFunction=t||u,this.equalsFunction=e||h}get(t){if(null==t)return t;const e=this._getBucket(t);if(!e)return null;for(const r of e)if(this.equalsFunction(r,t))return r;return null}add(t){return this.getOrAdd(t)===t}getOrAdd(t){this._expand();const e=this._getSlot(t);let r=this.buckets[e];if(!r)return r=[t],this.buckets[e]=r,this.itemCount++,t;for(const e of r)if(this.equalsFunction(e,t))return e;return r.push(t),this.itemCount++,t}has(t){return null!=this.get(t)}values(){return this.buckets.filter(t=>null!=t).flat(1)}toString(){return m(this.values())}get length(){return this.itemCount}_getSlot(t){return this.hashFunction(t)&this.buckets.length-1}_getBucket(t){return this.buckets[this._getSlot(t)]}_expand(){if(this.itemCount<=this.threshold)return;const t=this.buckets,e=2*this.buckets.length;this.buckets=new Array(e),this.threshold=Math.floor(.75*e);for(const e of t)if(e)for(const t of e){const e=this._getSlot(t);let r=this.buckets[e];r||(r=[],this.buckets[e]=r),r.push(t)}}}class f{hashCode(){const t=new c;return this.updateHashCode(t),t.finish()}evaluate(t,e){}evalPrecedence(t,e){return this}static andContext(t,e){if(null===t||t===f.NONE)return e;if(null===e||e===f.NONE)return t;const r=new g(t,e);return 1===r.opnds.length?r.opnds[0]:r}static orContext(t,e){if(null===t)return e;if(null===e)return t;if(t===f.NONE||e===f.NONE)return f.NONE;const r=new y(t,e);return 1===r.opnds.length?r.opnds[0]:r}}class g extends f{constructor(t,e){super();const r=new p;t instanceof g?t.opnds.map(function(t){r.add(t)}):r.add(t),e instanceof g?e.opnds.map(function(t){r.add(t)}):r.add(e);const s=x(r);if(s.length>0){let t=null;s.map(function(e){(null===t||e.precedence<t.precedence)&&(t=e)}),r.add(t)}this.opnds=Array.from(r.values())}equals(t){return this===t||t instanceof g&&a(this.opnds,t.opnds)}updateHashCode(t){t.update(this.opnds,"AND")}evaluate(t,e){for(let r=0;r<this.opnds.length;r++)if(!this.opnds[r].evaluate(t,e))return!1;return!0}evalPrecedence(t,e){let r=!1;const s=[];for(let i=0;i<this.opnds.length;i++){const n=this.opnds[i],a=n.evalPrecedence(t,e);if(r|=a!==n,null===a)return null;a!==f.NONE&&s.push(a)}if(!r)return this;if(0===s.length)return f.NONE;let i=null;return s.map(function(t){i=null===i?t:f.andContext(i,t)}),i}toString(){const t=this.opnds.map(t=>t.toString());return(t.length>3?t.slice(3):t).join("&&")}}class y extends f{constructor(t,e){super();const r=new p;t instanceof y?t.opnds.map(function(t){r.add(t)}):r.add(t),e instanceof y?e.opnds.map(function(t){r.add(t)}):r.add(e);const s=x(r);if(s.length>0){const t=s.sort(function(t,e){return t.compareTo(e)}),e=t[t.length-1];r.add(e)}this.opnds=Array.from(r.values())}equals(t){return this===t||t instanceof y&&a(this.opnds,t.opnds)}updateHashCode(t){t.update(this.opnds,"OR")}evaluate(t,e){for(let r=0;r<this.opnds.length;r++)if(this.opnds[r].evaluate(t,e))return!0;return!1}evalPrecedence(t,e){let r=!1;const s=[];for(let i=0;i<this.opnds.length;i++){const n=this.opnds[i],a=n.evalPrecedence(t,e);if(r|=a!==n,a===f.NONE)return f.NONE;null!==a&&s.push(a)}return r?(0===s.length||s.map(function(t){return t}),null):this}toString(){const t=this.opnds.map(t=>t.toString());return(t.length>3?t.slice(3):t).join("||")}}function x(t){const e=[];return t.values().map(function(t){t instanceof f.PrecedencePredicate&&e.push(t)}),e}function C(t,e){if(null===t){const t={state:null,alt:null,context:null,semanticContext:null};return e&&(t.reachesIntoOuterContext=0),t}{const r={};return r.state=t.state||null,r.alt=void 0===t.alt?null:t.alt,r.context=t.context||null,r.semanticContext=t.semanticContext||null,e&&(r.reachesIntoOuterContext=t.reachesIntoOuterContext||0,r.precedenceFilterSuppressed=t.precedenceFilterSuppressed||!1),r}}class A{constructor(t,e){this.checkContext(t,e),t=C(t),e=C(e,!0),this.state=null!==t.state?t.state:e.state,this.alt=null!==t.alt?t.alt:e.alt,this.context=null!==t.context?t.context:e.context,this.semanticContext=null!==t.semanticContext?t.semanticContext:null!==e.semanticContext?e.semanticContext:f.NONE,this.reachesIntoOuterContext=e.reachesIntoOuterContext,this.precedenceFilterSuppressed=e.precedenceFilterSuppressed}checkContext(t,e){null!==t.context&&void 0!==t.context||null!==e&&null!==e.context&&void 0!==e.context||(this.context=null)}hashCode(){const t=new c;return this.updateHashCode(t),t.finish()}updateHashCode(t){t.update(this.state.stateNumber,this.alt,this.context,this.semanticContext)}equals(t){return this===t||t instanceof A&&this.state.stateNumber===t.state.stateNumber&&this.alt===t.alt&&(null===this.context?null===t.context:this.context.equals(t.context))&&this.semanticContext.equals(t.semanticContext)&&this.precedenceFilterSuppressed===t.precedenceFilterSuppressed}hashCodeForConfigSet(){const t=new c;return t.update(this.state.stateNumber,this.alt,this.semanticContext),t.finish()}equalsForConfigSet(t){return this===t||t instanceof A&&this.state.stateNumber===t.state.stateNumber&&this.alt===t.alt&&this.semanticContext.equals(t.semanticContext)}toString(){return"("+this.state+","+this.alt+(null!==this.context?",["+this.context.toString()+"]":"")+(this.semanticContext!==f.NONE?","+this.semanticContext.toString():"")+(this.reachesIntoOuterContext>0?",up="+this.reachesIntoOuterContext:"")+")"}}class S{constructor(t,e){this.start=t,this.stop=e}clone(){return new S(this.start,this.stop)}contains(t){return t>=this.start&&t<this.stop}toString(){return this.start===this.stop-1?this.start.toString():this.start.toString()+".."+(this.stop-1).toString()}get length(){return this.stop-this.start}}S.INVALID_INTERVAL=new S(-1,-2);class E{constructor(){this.intervals=null,this.readOnly=!1}first(t){return null===this.intervals||0===this.intervals.length?n.INVALID_TYPE:this.intervals[0].start}addOne(t){this.addInterval(new S(t,t+1))}addRange(t,e){this.addInterval(new S(t,e+1))}addInterval(t){if(null===this.intervals)this.intervals=[],this.intervals.push(t.clone());else{for(let e=0;e<this.intervals.length;e++){const r=this.intervals[e];if(t.stop<r.start)return void this.intervals.splice(e,0,t);if(t.stop===r.start)return void(this.intervals[e]=new S(t.start,r.stop));if(t.start<=r.stop)return this.intervals[e]=new S(Math.min(r.start,t.start),Math.max(r.stop,t.stop)),void this.reduce(e)}this.intervals.push(t.clone())}}addSet(t){return null!==t.intervals&&t.intervals.forEach(t=>this.addInterval(t),this),this}reduce(t){if(t<this.intervals.length-1){const e=this.intervals[t],r=this.intervals[t+1];e.stop>=r.stop?(this.intervals.splice(t+1,1),this.reduce(t)):e.stop>=r.start&&(this.intervals[t]=new S(e.start,r.stop),this.intervals.splice(t+1,1))}}complement(t,e){const r=new E;return r.addInterval(new S(t,e+1)),null!==this.intervals&&this.intervals.forEach(t=>r.removeRange(t)),r}contains(t){if(null===this.intervals)return!1;for(let e=0;e<this.intervals.length;e++)if(this.intervals[e].contains(t))return!0;return!1}removeRange(t){if(t.start===t.stop-1)this.removeOne(t.start);else if(null!==this.intervals){let e=0;for(let r=0;r<this.intervals.length;r++){const r=this.intervals[e];if(t.stop<=r.start)return;if(t.start>r.start&&t.stop<r.stop){this.intervals[e]=new S(r.start,t.start);const s=new S(t.stop,r.stop);return void this.intervals.splice(e,0,s)}t.start<=r.start&&t.stop>=r.stop?(this.intervals.splice(e,1),e-=1):t.start<r.stop?this.intervals[e]=new S(r.start,t.start):t.stop<r.stop&&(this.intervals[e]=new S(t.stop,r.stop)),e+=1}}}removeOne(t){if(null!==this.intervals)for(let e=0;e<this.intervals.length;e++){const r=this.intervals[e];if(t<r.start)return;if(t===r.start&&t===r.stop-1)return void this.intervals.splice(e,1);if(t===r.start)return void(this.intervals[e]=new S(r.start+1,r.stop));if(t===r.stop-1)return void(this.intervals[e]=new S(r.start,r.stop-1));if(t<r.stop-1){const s=new S(r.start,t);return r.start=t+1,void this.intervals.splice(e,0,s)}}}toString(t,e,r){return t=t||null,e=e||null,r=r||!1,null===this.intervals?"{}":null!==t||null!==e?this.toTokenString(t,e):r?this.toCharString():this.toIndexString()}toCharString(){const t=[];for(let e=0;e<this.intervals.length;e++){const r=this.intervals[e];r.stop===r.start+1?r.start===n.EOF?t.push("<EOF>"):t.push("'"+String.fromCharCode(r.start)+"'"):t.push("'"+String.fromCharCode(r.start)+"'..'"+String.fromCharCode(r.stop-1)+"'")}return t.length>1?"{"+t.join(", ")+"}":t[0]}toIndexString(){const t=[];for(let e=0;e<this.intervals.length;e++){const r=this.intervals[e];r.stop===r.start+1?r.start===n.EOF?t.push("<EOF>"):t.push(r.start.toString()):t.push(r.start.toString()+".."+(r.stop-1).toString())}return t.length>1?"{"+t.join(", ")+"}":t[0]}toTokenString(t,e){const r=[];for(let s=0;s<this.intervals.length;s++){const i=this.intervals[s];for(let s=i.start;s<i.stop;s++)r.push(this.elementName(t,e,s))}return r.length>1?"{"+r.join(", ")+"}":r[0]}elementName(t,e,r){return r===n.EOF?"<EOF>":r===n.EPSILON?"<EPSILON>":t[r]||e[r]}get length(){return this.intervals.map(t=>t.length).reduce((t,e)=>t+e)}}class _{constructor(){this.atn=null,this.stateNumber=_.INVALID_STATE_NUMBER,this.stateType=null,this.ruleIndex=0,this.epsilonOnlyTransitions=!1,this.transitions=[],this.nextTokenWithinRule=null}toString(){return this.stateNumber}equals(t){return t instanceof _&&this.stateNumber===t.stateNumber}isNonGreedyExitState(){return!1}addTransition(t,e){void 0===e&&(e=-1),0===this.transitions.length?this.epsilonOnlyTransitions=t.isEpsilon:this.epsilonOnlyTransitions!==t.isEpsilon&&(this.epsilonOnlyTransitions=!1),-1===e?this.transitions.push(t):this.transitions.splice(e,1,t)}}_.INVALID_TYPE=0,_.BASIC=1,_.RULE_START=2,_.BLOCK_START=3,_.PLUS_BLOCK_START=4,_.STAR_BLOCK_START=5,_.TOKEN_START=6,_.RULE_STOP=7,_.BLOCK_END=8,_.STAR_LOOP_BACK=9,_.STAR_LOOP_ENTRY=10,_.PLUS_LOOP_BACK=11,_.LOOP_END=12,_.serializationNames=["INVALID","BASIC","RULE_START","BLOCK_START","PLUS_BLOCK_START","STAR_BLOCK_START","TOKEN_START","RULE_STOP","BLOCK_END","STAR_LOOP_BACK","STAR_LOOP_ENTRY","PLUS_LOOP_BACK","LOOP_END"],_.INVALID_STATE_NUMBER=-1;class b extends _{constructor(){return super(),this.stateType=_.RULE_STOP,this}}class M{constructor(t){if(null==t)throw"target cannot be null.";this.target=t,this.isEpsilon=!1,this.label=null}}M.EPSILON=1,M.RANGE=2,M.RULE=3,M.PREDICATE=4,M.ATOM=5,M.ACTION=6,M.SET=7,M.NOT_SET=8,M.WILDCARD=9,M.PRECEDENCE=10,M.serializationNames=["INVALID","EPSILON","RANGE","RULE","PREDICATE","ATOM","ACTION","SET","NOT_SET","WILDCARD","PRECEDENCE"],M.serializationTypes={EpsilonTransition:M.EPSILON,RangeTransition:M.RANGE,RuleTransition:M.RULE,PredicateTransition:M.PREDICATE,AtomTransition:M.ATOM,ActionTransition:M.ACTION,SetTransition:M.SET,NotSetTransition:M.NOT_SET,WildcardTransition:M.WILDCARD,PrecedencePredicateTransition:M.PRECEDENCE};class T extends M{constructor(t,e,r,s){super(t),this.ruleIndex=e,this.precedence=r,this.followState=s,this.serializationType=M.RULE,this.isEpsilon=!0}matches(t,e,r){return!1}}class v extends M{constructor(t,e){super(t),this.serializationType=M.SET,null!=e?this.label=e:(this.label=new E,this.label.addOne(n.INVALID_TYPE))}matches(t,e,r){return this.label.contains(t)}toString(){return this.label.toString()}}class L extends v{constructor(t,e){super(t,e),this.serializationType=M.NOT_SET}matches(t,e,r){return t>=e&&t<=r&&!super.matches(t,e,r)}toString(){return"~"+super.toString()}}class N extends M{constructor(t){super(t),this.serializationType=M.WILDCARD}matches(t,e,r){return t>=e&&t<=r}toString(){return"."}}class I extends M{constructor(t){super(t)}}class w{}class O extends w{}class R extends O{}class P extends R{get ruleContext(){throw new Error("missing interface implementation")}}class D extends R{}class F extends D{}const k={toStringTree:function(t,e,r){e=e||null,null!==(r=r||null)&&(e=r.ruleNames);let s=k.getNodeText(t,e);s=function(t){return t.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}(s);const i=t.getChildCount();if(0===i)return s;let n="("+s+" ";i>0&&(s=k.toStringTree(t.getChild(0),e),n=n.concat(s));for(let r=1;r<i;r++)s=k.toStringTree(t.getChild(r),e),n=n.concat(" "+s);return n=n.concat(")"),n},getNodeText:function(t,e,r){if(e=e||null,null!==(r=r||null)&&(e=r.ruleNames),null!==e){if(t instanceof P){const r=t.ruleContext.getAltNumber();return 0!=r?e[t.ruleIndex]+":"+r:e[t.ruleIndex]}if(t instanceof F)return t.toString();if(t instanceof D&&null!==t.symbol)return t.symbol.text}const s=t.getPayload();return s instanceof n?s.text:t.getPayload().toString()},getChildren:function(t){const e=[];for(let r=0;r<t.getChildCount();r++)e.push(t.getChild(r));return e},getAncestors:function(t){let e=[];for(t=t.getParent();null!==t;)e=[t].concat(e),t=t.getParent();return e},findAllTokenNodes:function(t,e){return k.findAllNodes(t,e,!0)},findAllRuleNodes:function(t,e){return k.findAllNodes(t,e,!1)},findAllNodes:function(t,e,r){const s=[];return k._findAllNodes(t,e,r,s),s},_findAllNodes:function(t,e,r,s){r&&t instanceof D?t.symbol.type===e&&s.push(t):!r&&t instanceof P&&t.ruleIndex===e&&s.push(t);for(let i=0;i<t.getChildCount();i++)k._findAllNodes(t.getChild(i),e,r,s)},descendants:function(t){let e=[t];for(let r=0;r<t.getChildCount();r++)e=e.concat(k.descendants(t.getChild(r)));return e}},V=k;class U extends P{constructor(t,e){super(),this.parentCtx=t||null,this.invokingState=e||-1}depth(){let t=0,e=this;for(;null!==e;)e=e.parentCtx,t+=1;return t}isEmpty(){return-1===this.invokingState}getSourceInterval(){return S.INVALID_INTERVAL}get ruleContext(){return this}getPayload(){return this}getText(){return 0===this.getChildCount()?"":this.children.map(function(t){return t.getText()}).join("")}getAltNumber(){return 0}setAltNumber(t){}getChild(t){return null}getChildCount(){return 0}accept(t){return t.visitChildren(this)}toStringTree(t,e){return V.toStringTree(this,t,e)}toString(t,e){t=t||null,e=e||null;let r=this,s="[";for(;null!==r&&r!==e;){if(null===t)r.isEmpty()||(s+=r.invokingState);else{const e=r.ruleIndex;s+=e>=0&&e<t.length?t[e]:""+e}null===r.parentCtx||null===t&&r.parentCtx.isEmpty()||(s+=" "),r=r.parentCtx}return s+="]",s}}class B{constructor(t){this.cachedHashCode=t}isEmpty(){return this===B.EMPTY}hasEmptyPath(){return this.getReturnState(this.length-1)===B.EMPTY_RETURN_STATE}hashCode(){return this.cachedHashCode}updateHashCode(t){t.update(this.cachedHashCode)}}B.EMPTY=null,B.EMPTY_RETURN_STATE=2147483647,B.globalNodeCount=1,B.id=B.globalNodeCount,B.trace_atn_sim=!1;class $ extends B{constructor(t,e){const r=new c;return r.update(t,e),super(r.finish()),this.parents=t,this.returnStates=e,this}isEmpty(){return this.returnStates[0]===B.EMPTY_RETURN_STATE}getParent(t){return this.parents[t]}getReturnState(t){return this.returnStates[t]}equals(t){return this===t||t instanceof $&&this.hashCode()===t.hashCode()&&a(this.returnStates,t.returnStates)&&a(this.parents,t.parents)}toString(){if(this.isEmpty())return"[]";{let t="[";for(let e=0;e<this.returnStates.length;e++)e>0&&(t+=", "),this.returnStates[e]!==B.EMPTY_RETURN_STATE?(t+=this.returnStates[e],null!==this.parents[e]?t=t+" "+this.parents[e]:t+="null"):t+="$";return t+"]"}}get length(){return this.returnStates.length}}class H extends B{constructor(t,e){let r=0;const s=new c;null!==t?s.update(t,e):s.update(1),r=s.finish(),super(r),this.parentCtx=t,this.returnState=e}getParent(t){return this.parentCtx}getReturnState(t){return this.returnState}equals(t){return this===t||t instanceof H&&this.hashCode()===t.hashCode()&&this.returnState===t.returnState&&(null==this.parentCtx?null==t.parentCtx:this.parentCtx.equals(t.parentCtx))}toString(){const t=null===this.parentCtx?"":this.parentCtx.toString();return 0===t.length?this.returnState===B.EMPTY_RETURN_STATE?"$":""+this.returnState:this.returnState+" "+t}get length(){return 1}static create(t,e){return e===B.EMPTY_RETURN_STATE&&null===t?B.EMPTY:new H(t,e)}}class q extends H{constructor(){super(null,B.EMPTY_RETURN_STATE)}isEmpty(){return!0}getParent(t){return null}getReturnState(t){return this.returnState}equals(t){return this===t}toString(){return"$"}}B.EMPTY=new q;class J{constructor(t,e){this.buckets=new Array(16),this.threshold=Math.floor(12),this.itemCount=0,this.hashFunction=t||u,this.equalsFunction=e||h}set(t,e){this._expand();const r=this._getSlot(t);let s=this.buckets[r];if(!s)return s=[[t,e]],this.buckets[r]=s,this.itemCount++,e;const i=s.find(e=>this.equalsFunction(e[0],t),this);if(i){const t=i[1];return i[1]=e,t}return s.push([t,e]),this.itemCount++,e}containsKey(t){const e=this._getBucket(t);return!!e&&!!e.find(e=>this.equalsFunction(e[0],t),this)}get(t){const e=this._getBucket(t);if(!e)return null;const r=e.find(e=>this.equalsFunction(e[0],t),this);return r?r[1]:null}entries(){return this.buckets.filter(t=>null!=t).flat(1)}getKeys(){return this.entries().map(t=>t[0])}getValues(){return this.entries().map(t=>t[1])}toString(){return"["+this.entries().map(t=>"{"+t[0]+":"+t[1]+"}").join(", ")+"]"}get length(){return this.itemCount}_getSlot(t){return this.hashFunction(t)&this.buckets.length-1}_getBucket(t){return this.buckets[this._getSlot(t)]}_expand(){if(this.itemCount<=this.threshold)return;const t=this.buckets,e=2*this.buckets.length;this.buckets=new Array(e),this.threshold=Math.floor(.75*e);for(const e of t)if(e)for(const t of e){const e=this._getSlot(t[0]);let r=this.buckets[e];r||(r=[],this.buckets[e]=r),r.push(t)}}}function j(t,e){if(null==e&&(e=U.EMPTY),null===e.parentCtx||e===U.EMPTY)return B.EMPTY;const r=j(t,e.parentCtx),s=t.states[e.invokingState].transitions[0];return H.create(r,s.followState.stateNumber)}function z(t,e,r){if(t.isEmpty())return t;let s=r.get(t)||null;if(null!==s)return s;if(s=e.get(t),null!==s)return r.set(t,s),s;let i=!1,n=[];for(let s=0;s<n.length;s++){const a=z(t.getParent(s),e,r);if(i||a!==t.getParent(s)){if(!i){n=[];for(let e=0;e<t.length;e++)n[e]=t.getParent(e);i=!0}n[s]=a}}if(!i)return e.add(t),r.set(t,t),t;let a=null;return a=0===n.length?B.EMPTY:1===n.length?H.create(n[0],t.getReturnState(0)):new $(n,t.returnStates),e.add(a),r.set(a,a),r.set(t,a),a}function G(t,e,r,s){if(t===e)return t;if(t instanceof H&&e instanceof H)return function(t,e,r,s){if(null!==s){let r=s.get(t,e);if(null!==r)return r;if(r=s.get(e,t),null!==r)return r}const i=function(t,e,r){if(r){if(t===B.EMPTY)return B.EMPTY;if(e===B.EMPTY)return B.EMPTY}else{if(t===B.EMPTY&&e===B.EMPTY)return B.EMPTY;if(t===B.EMPTY){const t=[e.returnState,B.EMPTY_RETURN_STATE],r=[e.parentCtx,null];return new $(r,t)}if(e===B.EMPTY){const e=[t.returnState,B.EMPTY_RETURN_STATE],r=[t.parentCtx,null];return new $(r,e)}}return null}(t,e,r);if(null!==i)return null!==s&&s.set(t,e,i),i;if(t.returnState===e.returnState){const i=G(t.parentCtx,e.parentCtx,r,s);if(i===t.parentCtx)return t;if(i===e.parentCtx)return e;const n=H.create(i,t.returnState);return null!==s&&s.set(t,e,n),n}{let r=null;if((t===e||null!==t.parentCtx&&t.parentCtx===e.parentCtx)&&(r=t.parentCtx),null!==r){const i=[t.returnState,e.returnState];t.returnState>e.returnState&&(i[0]=e.returnState,i[1]=t.returnState);const n=new $([r,r],i);return null!==s&&s.set(t,e,n),n}const i=[t.returnState,e.returnState];let n=[t.parentCtx,e.parentCtx];t.returnState>e.returnState&&(i[0]=e.returnState,i[1]=t.returnState,n=[e.parentCtx,t.parentCtx]);const a=new $(n,i);return null!==s&&s.set(t,e,a),a}}(t,e,r,s);if(r){if(t instanceof q)return t;if(e instanceof q)return e}return t instanceof H&&(t=new $([t.getParent()],[t.returnState])),e instanceof H&&(e=new $([e.getParent()],[e.returnState])),function(t,e,r,s){if(null!==s){let r=s.get(t,e);if(null!==r)return B.trace_atn_sim&&console.log("mergeArrays a="+t+",b="+e+" -> previous"),r;if(r=s.get(e,t),null!==r)return B.trace_atn_sim&&console.log("mergeArrays a="+t+",b="+e+" -> previous"),r}let i=0,n=0,a=0,o=new Array(t.returnStates.length+e.returnStates.length).fill(0),l=new Array(t.returnStates.length+e.returnStates.length).fill(null);for(;i<t.returnStates.length&&n<e.returnStates.length;){const c=t.parents[i],u=e.parents[n];if(t.returnStates[i]===e.returnStates[n]){const e=t.returnStates[i];e===B.EMPTY_RETURN_STATE&&null===c&&null===u||null!==c&&null!==u&&c===u?(l[a]=c,o[a]=e):(l[a]=G(c,u,r,s),o[a]=e),i+=1,n+=1}else t.returnStates[i]<e.returnStates[n]?(l[a]=c,o[a]=t.returnStates[i],i+=1):(l[a]=u,o[a]=e.returnStates[n],n+=1);a+=1}if(i<t.returnStates.length)for(let e=i;e<t.returnStates.length;e++)l[a]=t.parents[e],o[a]=t.returnStates[e],a+=1;else for(let t=n;t<e.returnStates.length;t++)l[a]=e.parents[t],o[a]=e.returnStates[t],a+=1;if(a<l.length){if(1===a){const r=H.create(l[0],o[0]);return null!==s&&s.set(t,e,r),r}l=l.slice(0,a),o=o.slice(0,a)}const c=new $(l,o);return c.equals(t)?(null!==s&&s.set(t,e,t),B.trace_atn_sim&&console.log("mergeArrays a="+t+",b="+e+" -> a"),t):c.equals(e)?(null!==s&&s.set(t,e,e),B.trace_atn_sim&&console.log("mergeArrays a="+t+",b="+e+" -> b"),e):(function(t){const e=new J;for(let r=0;r<t.length;r++){const s=t[r];e.containsKey(s)||e.set(s,s)}for(let r=0;r<t.length;r++)t[r]=e.get(t[r])}(l),null!==s&&s.set(t,e,c),B.trace_atn_sim&&console.log("mergeArrays a="+t+",b="+e+" -> "+c),c)}(t,e,r,s)}class W{constructor(){this.data=new Uint32Array(1)}set(t){W._checkIndex(t),this._resize(t),this.data[t>>>5]|=1<<t%32}get(t){W._checkIndex(t);const e=t>>>5;return!(e>=this.data.length||!(this.data[e]&1<<t%32))}clear(t){W._checkIndex(t);const e=t>>>5;e<this.data.length&&(this.data[e]&=~(1<<t))}or(t){const e=Math.min(this.data.length,t.data.length);for(let r=0;r<e;++r)this.data[r]|=t.data[r];if(this.data.length<t.data.length){this._resize((t.data.length<<5)-1);const r=t.data.length;for(let s=e;s<r;++s)this.data[s]=t.data[s]}}values(){const t=new Array(this.length);let e=0;const r=this.data.length;for(let s=0;s<r;++s){let r=this.data[s];for(;0!==r;){const i=r&-r;t[e++]=(s<<5)+W._bitCount(i-1),r^=i}}return t}minValue(){for(let t=0;t<this.data.length;++t){let e=this.data[t];if(0!==e){let r=0;for(;!(1&e);)r++,e>>=1;return r+32*t}}return 0}hashCode(){return c.hashStuff(this.values())}equals(t){return t instanceof W&&a(this.data,t.data)}toString(){return"{"+this.values().join(", ")+"}"}get length(){return this.data.map(t=>W._bitCount(t)).reduce((t,e)=>t+e,0)}_resize(t){const e=t+32>>>5;if(e<=this.data.length)return;const r=new Uint32Array(e);r.set(this.data),r.fill(0,this.data.length),this.data=r}static _checkIndex(t){if(t<0)throw new RangeError("index cannot be negative")}static _bitCount(t){return t=(t=(858993459&(t-=t>>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,0+(t+=t>>16)&63}}class K{constructor(t){this.atn=t}getDecisionLookahead(t){if(null===t)return null;const e=t.transitions.length,r=[];for(let s=0;s<e;s++){r[s]=new E;const e=new p,i=!1;this._LOOK(t.transition(s).target,null,B.EMPTY,r[s],e,new W,i,!1),(0===r[s].length||r[s].contains(K.HIT_PRED))&&(r[s]=null)}return r}LOOK(t,e,r){const s=new E,i=null!==(r=r||null)?j(t.atn,r):null;return this._LOOK(t,e,i,s,new p,new W,!0,!0),s}_LOOK(t,e,r,s,i,a,o,l){const c=new A({state:t,alt:0,context:r},null);if(!i.has(c)){if(i.add(c),t===e){if(null===r)return void s.addOne(n.EPSILON);if(r.isEmpty()&&l)return void s.addOne(n.EOF)}if(t instanceof b){if(null===r)return void s.addOne(n.EPSILON);if(r.isEmpty()&&l)return void s.addOne(n.EOF);if(r!==B.EMPTY){const n=a.get(t.ruleIndex);try{a.clear(t.ruleIndex);for(let t=0;t<r.length;t++){const n=this.atn.states[r.getReturnState(t)];this._LOOK(n,e,r.getParent(t),s,i,a,o,l)}}finally{n&&a.set(t.ruleIndex)}return}}for(let c=0;c<t.transitions.length;c++){const u=t.transitions[c];if(u.constructor===T){if(a.get(u.target.ruleIndex))continue;const t=H.create(r,u.followState.stateNumber);try{a.set(u.target.ruleIndex),this._LOOK(u.target,e,t,s,i,a,o,l)}finally{a.clear(u.target.ruleIndex)}}else if(u instanceof I)o?this._LOOK(u.target,e,r,s,i,a,o,l):s.addOne(K.HIT_PRED);else if(u.isEpsilon)this._LOOK(u.target,e,r,s,i,a,o,l);else if(u.constructor===N)s.addRange(n.MIN_USER_TOKEN_TYPE,this.atn.maxTokenType);else{let t=u.label;null!==t&&(u instanceof L&&(t=t.complement(n.MIN_USER_TOKEN_TYPE,this.atn.maxTokenType)),s.addSet(t))}}}}}K.HIT_PRED=n.INVALID_TYPE;class Q{constructor(t,e){this.grammarType=t,this.maxTokenType=e,this.states=[],this.decisionToState=[],this.ruleToStartState=[],this.ruleToStopState=null,this.modeNameToStartState={},this.ruleToTokenType=null,this.lexerActions=null,this.modeToStartState=[]}nextTokensInContext(t,e){return new K(this).LOOK(t,null,e)}nextTokensNoContext(t){return null!==t.nextTokenWithinRule||(t.nextTokenWithinRule=this.nextTokensInContext(t,null),t.nextTokenWithinRule.readOnly=!0),t.nextTokenWithinRule}nextTokens(t,e){return void 0===e?this.nextTokensNoContext(t):this.nextTokensInContext(t,e)}addState(t){null!==t&&(t.atn=this,t.stateNumber=this.states.length),this.states.push(t)}removeState(t){this.states[t.stateNumber]=null}defineDecisionState(t){return this.decisionToState.push(t),t.decision=this.decisionToState.length-1,t.decision}getDecisionState(t){return 0===this.decisionToState.length?null:this.decisionToState[t]}getExpectedTokens(t,e){if(t<0||t>=this.states.length)throw"Invalid state number.";const r=this.states[t];let s=this.nextTokens(r);if(!s.contains(n.EPSILON))return s;const i=new E;for(i.addSet(s),i.removeOne(n.EPSILON);null!==e&&e.invokingState>=0&&s.contains(n.EPSILON);){const t=this.states[e.invokingState].transitions[0];s=this.nextTokens(t.followState),i.addSet(s),i.removeOne(n.EPSILON),e=e.parentCtx}return s.contains(n.EPSILON)&&i.addOne(n.EOF),i}}Q.INVALID_ALT_NUMBER=0;class X extends _{constructor(){super(),this.stateType=_.BASIC}}class Z extends _{constructor(){return super(),this.decision=-1,this.nonGreedy=!1,this}}class Y extends Z{constructor(){return super(),this.endState=null,this}}class tt extends _{constructor(){return super(),this.stateType=_.BLOCK_END,this.startState=null,this}}class et extends _{constructor(){return super(),this.stateType=_.LOOP_END,this.loopBackState=null,this}}class rt extends _{constructor(){return super(),this.stateType=_.RULE_START,this.stopState=null,this.isPrecedenceRule=!1,this}}class st extends Z{constructor(){return super(),this.stateType=_.TOKEN_START,this}}class it extends Z{constructor(){return super(),this.stateType=_.PLUS_LOOP_BACK,this}}class nt extends _{constructor(){return super(),this.stateType=_.STAR_LOOP_BACK,this}}class at extends Z{constructor(){return super(),this.stateType=_.STAR_LOOP_ENTRY,this.loopBackState=null,this.isPrecedenceDecision=null,this}}class ot extends Y{constructor(){return super(),this.stateType=_.PLUS_BLOCK_START,this.loopBackState=null,this}}class lt extends Y{constructor(){return super(),this.stateType=_.STAR_BLOCK_START,this}}class ct extends Y{constructor(){return super(),this.stateType=_.BLOCK_START,this}}class ut extends M{constructor(t,e){super(t),this.label_=e,this.label=this.makeLabel(),this.serializationType=M.ATOM}makeLabel(){const t=new E;return t.addOne(this.label_),t}matches(t,e,r){return this.label_===t}toString(){return this.label_}}class ht extends M{constructor(t,e,r){super(t),this.serializationType=M.RANGE,this.start=e,this.stop=r,this.label=this.makeLabel()}makeLabel(){const t=new E;return t.addRange(this.start,this.stop),t}matches(t,e,r){return t>=this.start&&t<=this.stop}toString(){return"'"+String.fromCharCode(this.start)+"'..'"+String.fromCharCode(this.stop)+"'"}}class dt extends M{constructor(t,e,r,s){super(t),this.serializationType=M.ACTION,this.ruleIndex=e,this.actionIndex=void 0===r?-1:r,this.isCtxDependent=void 0!==s&&s,this.isEpsilon=!0}matches(t,e,r){return!1}toString(){return"action_"+this.ruleIndex+":"+this.actionIndex}}class mt extends M{constructor(t,e){super(t),this.serializationType=M.EPSILON,this.isEpsilon=!0,this.outermostPrecedenceReturn=e}matches(t,e,r){return!1}toString(){return"epsilon"}}class pt extends f{constructor(t,e,r){super(),this.ruleIndex=void 0===t?-1:t,this.predIndex=void 0===e?-1:e,this.isCtxDependent=void 0!==r&&r}evaluate(t,e){const r=this.isCtxDependent?e:null;return t.sempred(r,this.ruleIndex,this.predIndex)}updateHashCode(t){t.update(this.ruleIndex,this.predIndex,this.isCtxDependent)}equals(t){return this===t||t instanceof pt&&this.ruleIndex===t.ruleIndex&&this.predIndex===t.predIndex&&this.isCtxDependent===t.isCtxDependent}toString(){return"{"+this.ruleIndex+":"+this.predIndex+"}?"}}f.NONE=new pt;class ft extends I{constructor(t,e,r,s){super(t),this.serializationType=M.PREDICATE,this.ruleIndex=e,this.predIndex=r,this.isCtxDependent=s,this.isEpsilon=!0}matches(t,e,r){return!1}getPredicate(){return new pt(this.ruleIndex,this.predIndex,this.isCtxDependent)}toString(){return"pred_"+this.ruleIndex+":"+this.predIndex}}class gt extends f{constructor(t){super(),this.precedence=void 0===t?0:t}evaluate(t,e){return t.precpred(e,this.precedence)}evalPrecedence(t,e){return t.precpred(e,this.precedence)?f.NONE:null}compareTo(t){return this.precedence-t.precedence}updateHashCode(t){t.update(this.precedence)}equals(t){return this===t||t instanceof gt&&this.precedence===t.precedence}toString(){return"{"+this.precedence+">=prec}?"}}f.PrecedencePredicate=gt;class yt extends I{constructor(t,e){super(t),this.serializationType=M.PRECEDENCE,this.precedence=e,this.isEpsilon=!0}matches(t,e,r){return!1}getPredicate(){return new gt(this.precedence)}toString(){return this.precedence+" >= _p"}}class xt{constructor(t){void 0===t&&(t=null),this.readOnly=!1,this.verifyATN=null===t||t.verifyATN,this.generateRuleBypassTransitions=null!==t&&t.generateRuleBypassTransitions}}xt.defaultOptions=new xt,xt.defaultOptions.readOnly=!0;class Ct{constructor(t){this.actionType=t,this.isPositionDependent=!1}hashCode(){const t=new c;return this.updateHashCode(t),t.finish()}updateHashCode(t){t.update(this.actionType)}equals(t){return this===t}}class At extends Ct{constructor(){super(6)}execute(t){t.skip()}toString(){return"skip"}}At.INSTANCE=new At;class St extends Ct{constructor(t){super(0),this.channel=t}execute(t){t._channel=this.channel}updateHashCode(t){t.update(this.actionType,this.channel)}equals(t){return this===t||t instanceof St&&this.channel===t.channel}toString(){return"channel("+this.channel+")"}}class Et extends Ct{constructor(t,e){super(1),this.ruleIndex=t,this.actionIndex=e,this.isPositionDependent=!0}execute(t){t.action(null,this.ruleIndex,this.actionIndex)}updateHashCode(t){t.update(this.actionType,this.ruleIndex,this.actionIndex)}equals(t){return this===t||t instanceof Et&&this.ruleIndex===t.ruleIndex&&this.actionIndex===t.actionIndex}}class _t extends Ct{constructor(){super(3)}execute(t){t.more()}toString(){return"more"}}_t.INSTANCE=new _t;class bt extends Ct{constructor(t){super(7),this.type=t}execute(t){t.type=this.type}updateHashCode(t){t.update(this.actionType,this.type)}equals(t){return this===t||t instanceof bt&&this.type===t.type}toString(){return"type("+this.type+")"}}class Mt extends Ct{constructor(t){super(5),this.mode=t}execute(t){t.pushMode(this.mode)}updateHashCode(t){t.update(this.actionType,this.mode)}equals(t){return this===t||t instanceof Mt&&this.mode===t.mode}toString(){return"pushMode("+this.mode+")"}}class Tt extends Ct{constructor(){super(4)}execute(t){t.popMode()}toString(){return"popMode"}}Tt.INSTANCE=new Tt;class vt extends Ct{constructor(t){super(2),this.mode=t}execute(t){t.setMode(this.mode)}updateHashCode(t){t.update(this.actionType,this.mode)}equals(t){return this===t||t instanceof vt&&this.mode===t.mode}toString(){return"mode("+this.mode+")"}}function Lt(t,e){const r=[];return r[t-1]=e,r.map(function(t){return e})}class Nt{constructor(t){null==t&&(t=xt.defaultOptions),this.deserializationOptions=t,this.stateFactories=null,this.actionFactories=null}deserialize(t){const e=this.reset(t);this.checkVersion(e),e&&this.skipUUID();const r=this.readATN();this.readStates(r,e),this.readRules(r,e),this.readModes(r);const s=[];return this.readSets(r,s,this.readInt.bind(this)),e&&this.readSets(r,s,this.readInt32.bind(this)),this.readEdges(r,s),this.readDecisions(r),this.readLexerActions(r,e),this.markPrecedenceDecisions(r),this.verifyATN(r),this.deserializationOptions.generateRuleBypassTransitions&&1===r.grammarType&&(this.generateRuleBypassTransitions(r),this.verifyATN(r)),r}reset(t){if(3===(t.charCodeAt?t.charCodeAt(0):t[0])){const e=function(t){const e=t.charCodeAt(0);return e>1?e-2:e+65534},r=t.split("").map(e);return r[0]=t.charCodeAt(0),this.data=r,this.pos=0,!0}return this.data=t,this.pos=0,!1}skipUUID(){let t=0;for(;t++<8;)this.readInt()}checkVersion(t){const e=this.readInt();if(!t&&4!==e)throw"Could not deserialize ATN with version "+e+" (expected 4)."}readATN(){const t=this.readInt(),e=this.readInt();return new Q(t,e)}readStates(t,e){let r,s,i;const n=[],a=[],o=this.readInt();for(let r=0;r<o;r++){const r=this.readInt();if(r===_.INVALID_TYPE){t.addState(null);continue}let s=this.readInt();e&&65535===s&&(s=-1);const i=this.stateFactory(r,s);if(r===_.LOOP_END){const t=this.readInt();n.push([i,t])}else if(i instanceof Y){const t=this.readInt();a.push([i,t])}t.addState(i)}for(r=0;r<n.length;r++)s=n[r],s[0].loopBackState=t.states[s[1]];for(r=0;r<a.length;r++)s=a[r],s[0].endState=t.states[s[1]];let l=this.readInt();for(r=0;r<l;r++)i=this.readInt(),t.states[i].nonGreedy=!0;let c=this.readInt();for(r=0;r<c;r++)i=this.readInt(),t.states[i].isPrecedenceRule=!0}readRules(t,e){let r;const s=this.readInt();for(0===t.grammarType&&(t.ruleToTokenType=Lt(s,0)),t.ruleToStartState=Lt(s,0),r=0;r<s;r++){const s=this.readInt();if(t.ruleToStartState[r]=t.states[s],0===t.grammarType){let s=this.readInt();e&&65535===s&&(s=n.EOF),t.ruleToTokenType[r]=s}}for(t.ruleToStopState=Lt(s,0),r=0;r<t.states.length;r++){const e=t.states[r];e instanceof b&&(t.ruleToStopState[e.ruleIndex]=e,t.ruleToStartState[e.ruleIndex].stopState=e)}}readModes(t){const e=this.readInt();for(let r=0;r<e;r++){let e=this.readInt();t.modeToStartState.push(t.states[e])}}readSets(t,e,r){const s=this.readInt();for(let t=0;t<s;t++){const t=new E;e.push(t);const s=this.readInt();0!==this.readInt()&&t.addOne(-1);for(let e=0;e<s;e++){const e=r(),s=r();t.addRange(e,s)}}}readEdges(t,e){let r,s,i,n,a;const o=this.readInt();for(r=0;r<o;r++){const r=this.readInt(),s=this.readInt(),i=this.readInt(),a=this.readInt(),o=this.readInt(),l=this.readInt();n=this.edgeFactory(t,i,r,s,a,o,l,e),t.states[r].addTransition(n)}for(r=0;r<t.states.length;r++)for(i=t.states[r],s=0;s<i.transitions.length;s++){const e=i.transitions[s];if(!(e instanceof T))continue;let r=-1;t.ruleToStartState[e.target.ruleIndex].isPrecedenceRule&&0===e.precedence&&(r=e.target.ruleIndex),n=new mt(e.followState,r),t.ruleToStopState[e.target.ruleIndex].addTransition(n)}for(r=0;r<t.states.length;r++){if(i=t.states[r],i instanceof Y){if(null===i.endState)throw"IllegalState";if(null!==i.endState.startState)throw"IllegalState";i.endState.startState=i}if(i instanceof it)for(s=0;s<i.transitions.length;s++)a=i.transitions[s].target,a instanceof ot&&(a.loopBackState=i);else if(i instanceof nt)for(s=0;s<i.transitions.length;s++)a=i.transitions[s].target,a instanceof at&&(a.loopBackState=i)}}readDecisions(t){const e=this.readInt();for(let r=0;r<e;r++){const e=this.readInt(),s=t.states[e];t.decisionToState.push(s),s.decision=r}}readLexerActions(t,e){if(0===t.grammarType){const r=this.readInt();t.lexerActions=Lt(r,null);for(let s=0;s<r;s++){const r=this.readInt();let i=this.readInt();e&&65535===i&&(i=-1);let n=this.readInt();e&&65535===n&&(n=-1),t.lexerActions[s]=this.lexerActionFactory(r,i,n)}}}generateRuleBypassTransitions(t){let e;const r=t.ruleToStartState.length;for(e=0;e<r;e++)t.ruleToTokenType[e]=t.maxTokenType+e+1;for(e=0;e<r;e++)this.generateRuleBypassTransition(t,e)}generateRuleBypassTransition(t,e){let r,s;const i=new ct;i.ruleIndex=e,t.addState(i);const n=new tt;n.ruleIndex=e,t.addState(n),i.endState=n,t.defineDecisionState(i),n.startState=i;let a=null,o=null;if(t.ruleToStartState[e].isPrecedenceRule){for(o=null,r=0;r<t.states.length;r++)if(s=t.states[r],this.stateIsEndStateFor(s,e)){o=s,a=s.loopBackState.transitions[0];break}if(null===a)throw"Couldn't identify final state of the precedence rule prefix section."}else o=t.ruleToStopState[e];for(r=0;r<t.states.length;r++){s=t.states[r];for(let t=0;t<s.transitions.length;t++){const e=s.transitions[t];e!==a&&e.target===o&&(e.target=n)}}const l=t.ruleToStartState[e],c=l.transitions.length;for(;c>0;)i.addTransition(l.transitions[c-1]),l.transitions=l.transitions.slice(-1);t.ruleToStartState[e].addTransition(new mt(i)),n.addTransition(new mt(o));const u=new X;t.addState(u),u.addTransition(new ut(n,t.ruleToTokenType[e])),i.addTransition(new mt(u))}stateIsEndStateFor(t,e){if(t.ruleIndex!==e)return null;if(!(t instanceof at))return null;const r=t.transitions[t.transitions.length-1].target;return r instanceof et&&r.epsilonOnlyTransitions&&r.transitions[0].target instanceof b?t:null}markPrecedenceDecisions(t){for(let e=0;e<t.states.length;e++){const r=t.states[e];if(r instanceof at&&t.ruleToStartState[r.ruleIndex].isPrecedenceRule){const t=r.transitions[r.transitions.length-1].target;t instanceof et&&t.epsilonOnlyTransitions&&t.transitions[0].target instanceof b&&(r.isPrecedenceDecision=!0)}}}verifyATN(t){if(this.deserializationOptions.verifyATN)for(let e=0;e<t.states.length;e++){const r=t.states[e];if(null!==r)if(this.checkCondition(r.epsilonOnlyTransitions||r.transitions.length<=1),r instanceof ot)this.checkCondition(null!==r.loopBackState);else if(r instanceof at)if(this.checkCondition(null!==r.loopBackState),this.checkCondition(2===r.transitions.length),r.transitions[0].target instanceof lt)this.checkCondition(r.transitions[1].target instanceof et),this.checkCondition(!r.nonGreedy);else{if(!(r.transitions[0].target instanceof et))throw"IllegalState";this.checkCondition(r.transitions[1].target instanceof lt),this.checkCondition(r.nonGreedy)}else r instanceof nt?(this.checkCondition(1===r.transitions.length),this.checkCondition(r.transitions[0].target instanceof at)):r instanceof et?this.checkCondition(null!==r.loopBackState):r instanceof rt?this.checkCondition(null!==r.stopState):r instanceof Y?this.checkCondition(null!==r.endState):r instanceof tt?this.checkCondition(null!==r.startState):r instanceof Z?this.checkCondition(r.transitions.length<=1||r.decision>=0):this.checkCondition(r.transitions.length<=1||r instanceof b)}}checkCondition(t,e){if(!t)throw null==e&&(e="IllegalState"),e}readInt(){return this.data[this.pos++]}readInt32(){return this.readInt()|this.readInt()<<16}edgeFactory(t,e,r,s,i,a,o,l){const c=t.states[s];switch(e){case M.EPSILON:return new mt(c);case M.RANGE:return new ht(c,0!==o?n.EOF:i,a);case M.RULE:return new T(t.states[i],a,o,c);case M.PREDICATE:return new ft(c,i,a,0!==o);case M.PRECEDENCE:return new yt(c,i);case M.ATOM:return new ut(c,0!==o?n.EOF:i);case M.ACTION:return new dt(c,i,a,0!==o);case M.SET:return new v(c,l[i]);case M.NOT_SET:return new L(c,l[i]);case M.WILDCARD:return new N(c);default:throw"The specified transition type: "+e+" is not valid."}}stateFactory(t,e){if(null===this.stateFactories){const t=[];t[_.INVALID_TYPE]=null,t[_.BASIC]=()=>new X,t[_.RULE_START]=()=>new rt,t[_.BLOCK_START]=()=>new ct,t[_.PLUS_BLOCK_START]=()=>new ot,t[_.STAR_BLOCK_START]=()=>new lt,t[_.TOKEN_START]=()=>new st,t[_.RULE_STOP]=()=>new b,t[_.BLOCK_END]=()=>new tt,t[_.STAR_LOOP_BACK]=()=>new nt,t[_.STAR_LOOP_ENTRY]=()=>new at,t[_.PLUS_LOOP_BACK]=()=>new it,t[_.LOOP_END]=()=>new et,this.stateFactories=t}if(t>this.stateFactories.length||null===this.stateFactories[t])throw"The specified state type "+t+" is not valid.";{const r=this.stateFactories[t]();if(null!==r)return r.ruleIndex=e,r}}lexerActionFactory(t,e,r){if(null===this.actionFactories){const t=[];t[0]=(t,e)=>new St(t),t[1]=(t,e)=>new Et(t,e),t[2]=(t,e)=>new vt(t),t[3]=(t,e)=>_t.INSTANCE,t[4]=(t,e)=>Tt.INSTANCE,t[5]=(t,e)=>new Mt(t),t[6]=(t,e)=>At.INSTANCE,t[7]=(t,e)=>new bt(t),this.actionFactories=t}if(t>this.actionFactories.length||null===this.actionFactories[t])throw"The specified lexer action type "+t+" is not valid.";return this.actionFactories[t](e,r)}}class It{syntaxError(t,e,r,s,i,n){}reportAmbiguity(t,e,r,s,i,n,a){}reportAttemptingFullContext(t,e,r,s,i,n){}reportContextSensitivity(t,e,r,s,i,n){}}class wt extends It{constructor(){super()}syntaxError(t,e,r,s,i,n){console.error("line "+r+":"+s+" "+i)}}wt.INSTANCE=new wt;class Ot extends It{constructor(t){if(super(),null===t)throw"delegates";return this.delegates=t,this}syntaxError(t,e,r,s,i,n){this.delegates.map(a=>a.syntaxError(t,e,r,s,i,n))}reportAmbiguity(t,e,r,s,i,n,a){this.delegates.map(o=>o.reportAmbiguity(t,e,r,s,i,n,a))}reportAttemptingFullContext(t,e,r,s,i,n){this.delegates.map(a=>a.reportAttemptingFullContext(t,e,r,s,i,n))}reportContextSensitivity(t,e,r,s,i,n){this.delegates.map(a=>a.reportContextSensitivity(t,e,r,s,i,n))}}class Rt{constructor(){this._listeners=[wt.INSTANCE],this._interp=null,this._stateNumber=-1}checkVersion(t){const e="4.13.2";e!==t&&console.log("ANTLR runtime and generated code versions disagree: "+e+"!="+t)}addErrorListener(t){this._listeners.push(t)}removeErrorListeners(){this._listeners=[]}getLiteralNames(){return Object.getPrototypeOf(this).constructor.literalNames||[]}getSymbolicNames(){return Object.getPrototypeOf(this).constructor.symbolicNames||[]}getTokenNames(){if(!this.tokenNames){const t=this.getLiteralNames(),e=this.getSymbolicNames(),r=t.length>e.length?t.length:e.length;this.tokenNames=[];for(let s=0;s<r;s++)this.tokenNames[s]=t[s]||e[s]||"<INVALID"}return this.tokenNames}getTokenTypeMap(){const t=this.getTokenNames();if(null===t)throw"The current recognizer does not provide a list of token names.";let e=this.tokenTypeMapCache[t];return void 0===e&&(e=t.reduce(function(t,e,r){t[e]=r}),e.EOF=n.EOF,this.tokenTypeMapCache[t]=e),e}getRuleIndexMap(){const t=this.ruleNames;if(null===t)throw"The current recognizer does not provide a list of rule names.";let e=this.ruleIndexMapCache[t];return void 0===e&&(e=t.reduce(function(t,e,r){t[e]=r}),this.ruleIndexMapCache[t]=e),e}getTokenType(t){const e=this.getTokenTypeMap()[t];return void 0!==e?e:n.INVALID_TYPE}getErrorHeader(t){return"line "+t.getOffendingToken().line+":"+t.getOffendingToken().column}getTokenErrorDisplay(t){if(null===t)return"<no token>";let e=t.text;return null===e&&(e=t.type===n.EOF?"<EOF>":"<"+t.type+">"),e=e.replace("\n","\\n").replace("\r","\\r").replace("\t","\\t"),"'"+e+"'"}getErrorListenerDispatch(){return console.warn("Calling deprecated method in Recognizer class: getErrorListenerDispatch()"),this.getErrorListener()}getErrorListener(){return new Ot(this._listeners)}sempred(t,e,r){return!0}precpred(t,e){return!0}get atn(){return this._interp.atn}get state(){return this._stateNumber}set state(t){this._stateNumber=t}}Rt.tokenTypeMapCache={},Rt.ruleIndexMapCache={};class Pt extends n{constructor(t,e,r,s,i){super(),this.source=void 0!==t?t:Pt.EMPTY_SOURCE,this.type=void 0!==e?e:null,this.channel=void 0!==r?r:n.DEFAULT_CHANNEL,this.start=void 0!==s?s:-1,this.stop=void 0!==i?i:-1,this.tokenIndex=-1,null!==this.source[0]?(this.line=t[0].line,this.column=t[0].column):this.column=-1}clone(){const t=new Pt(this.source,this.type,this.channel,this.start,this.stop);return t.tokenIndex=this.tokenIndex,t.line=this.line,t.column=this.column,t.text=this.text,t}cloneWithType(t){const e=new Pt(this.source,t,this.channel,this.start,this.stop);return e.tokenIndex=this.tokenIndex,e.line=this.line,e.column=this.column,t===n.EOF&&(e.text=""),e}toString(){let t=this.text;return t=null!==t?t.replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"):"<no text>","[@"+this.tokenIndex+","+this.start+":"+this.stop+"='"+t+"',<"+this.type+">"+(this.channel>0?",channel="+this.channel:"")+","+this.line+":"+this.column+"]"}get text(){if(null!==this._text)return this._text;const t=this.getInputStream();if(null===t)return null;const e=t.size;return this.start<e&&this.stop<e?t.getText(this.start,this.stop):"<EOF>"}set text(t){this._text=t}}Pt.EMPTY_SOURCE=[null,null];class Dt{}class Ft extends Dt{constructor(t){super(),this.copyText=void 0!==t&&t}create(t,e,r,s,i,n,a,o){const l=new Pt(t,e,s,i,n);return l.line=a,l.column=o,null!==r?l.text=r:this.copyText&&null!==t[1]&&(l.text=t[1].getText(i,n)),l}createThin(t,e){const r=new Pt(null,t);return r.text=e,r}}Ft.DEFAULT=new Ft;class kt extends Error{constructor(t){super(t.message),Error.captureStackTrace&&Error.captureStackTrace(this,kt),this.message=t.message,this.recognizer=t.recognizer,this.input=t.input,this.ctx=t.ctx,this.offendingToken=null,this.offendingState=-1,null!==this.recognizer&&(this.offendingState=this.recognizer.state)}getExpectedTokens(){return null!==this.recognizer?this.recognizer.atn.getExpectedTokens(this.offendingState,this.ctx):null}toString(){return this.message}}class Vt extends kt{constructor(t,e,r,s){super({message:"",recognizer:t,input:e,ctx:null}),this.startIndex=r,this.deadEndConfigs=s}toString(){let t="";return this.startIndex>=0&&this.startIndex<this.input.size&&(t=this.input.getText(new S(this.startIndex,this.startIndex))),"LexerNoViableAltException"+t}}class Ut extends Rt{constructor(t){super(),this._input=t,this._factory=Ft.DEFAULT,this._tokenFactorySourcePair=[this,t],this._interp=null,this._token=null,this._tokenStartCharIndex=-1,this._tokenStartLine=-1,this._tokenStartColumn=-1,this._hitEOF=!1,this._channel=n.DEFAULT_CHANNEL,this._type=n.INVALID_TYPE,this._modeStack=[],this._mode=Ut.DEFAULT_MODE,this._text=null}reset(){null!==this._input&&this._input.seek(0),this._token=null,this._type=n.INVALID_TYPE,this._channel=n.DEFAULT_CHANNEL,this._tokenStartCharIndex=-1,this._tokenStartColumn=-1,this._tokenStartLine=-1,this._text=null,this._hitEOF=!1,this._mode=Ut.DEFAULT_MODE,this._modeStack=[],this._interp.reset()}nextToken(){if(null===this._input)throw"nextToken requires a non-null input stream.";const t=this._input.mark();try{for(;;){if(this._hitEOF)return this.emitEOF(),this._token;this._token=null,this._channel=n.DEFAULT_CHANNEL,this._tokenStartCharIndex=this._input.index,this._tokenStartColumn=this._interp.column,this._tokenStartLine=this._interp.line,this._text=null;let e=!1;for(;;){this._type=n.INVALID_TYPE;let r=Ut.SKIP;try{r=this._interp.match(this._input,this._mode)}catch(t){if(!(t instanceof kt))throw console.log(t.stack),t;this.notifyListeners(t),this.recover(t)}if(this._input.LA(1)===n.EOF&&(this._hitEOF=!0),this._type===n.INVALID_TYPE&&(this._type=r),this._type===Ut.SKIP){e=!0;break}if(this._type!==Ut.MORE)break}if(!e)return null===this._token&&this.emit(),this._token}}finally{this._input.release(t)}}skip(){this._type=Ut.SKIP}more(){this._type=Ut.MORE}mode(t){console.warn("Calling deprecated method in Lexer class: mode(...)"),this.setMode(t)}setMode(t){this._mode=t}getMode(){return this._mode}getModeStack(){return this._modeStack}pushMode(t){this._interp.debug&&console.log("pushMode "+t),this._modeStack.push(this._mode),this.setMode(t)}popMode(){if(0===this._modeStack.length)throw"Empty Stack";return this._interp.debug&&console.log("popMode back to "+this._modeStack.slice(0,-1)),this.setMode(this._modeStack.pop()),this._mode}emitToken(t){this._token=t}emit(){const t=this._factory.create(this._tokenFactorySourcePair,this._type,this._text,this._channel,this._tokenStartCharIndex,this.getCharIndex()-1,this._tokenStartLine,this._tokenStartColumn);return this.emitToken(t),t}emitEOF(){const t=this.column,e=this.line,r=this._factory.create(this._tokenFactorySourcePair,n.EOF,null,n.DEFAULT_CHANNEL,this._input.index,this._input.index-1,e,t);return this.emitToken(r),r}getCharIndex(){return this._input.index}getAllTokens(){const t=[];let e=this.nextToken();for(;e.type!==n.EOF;)t.push(e),e=this.nextToken();return t}notifyListeners(t){const e=this._tokenStartCharIndex,r=this._input.index,s=this._input.getText(e,r),i="token recognition error at: '"+this.getErrorDisplay(s)+"'";this.getErrorListener().syntaxError(this,null,this._tokenStartLine,this._tokenStartColumn,i,t)}getErrorDisplay(t){const e=[];for(let r=0;r<t.length;r++)e.push(t[r]);return e.join("")}getErrorDisplayForChar(t){return t.charCodeAt(0)===n.EOF?"<EOF>":"\n"===t?"\\n":"\t"===t?"\\t":"\r"===t?"\\r":t}getCharErrorDisplay(t){return"'"+this.getErrorDisplayForChar(t)+"'"}recover(t){this._input.LA(1)!==n.EOF&&(t instanceof Vt?this._interp.consume(this._input):this._input.consume())}get inputStream(){return this._input}set inputStream(t){this._input=null,this._tokenFactorySourcePair=[this,this._input],this.reset(),this._input=t,this._tokenFactorySourcePair=[this,this._input]}get sourceName(){return this._input.sourceName}get type(){return this._type}set type(t){this._type=t}get line(){return this._interp.line}set line(t){this._interp.line=t}get column(){return this._interp.column}set column(t){this._interp.column=t}get text(){return null!==this._text?this._text:this._interp.getText(this._input)}set text(t){this._text=t}}function Bt(t){return t.hashCodeForConfigSet()}function $t(t,e){return t===e||null!==t&&null!==e&&t.equalsForConfigSet(e)}Ut.DEFAULT_MODE=0,Ut.MORE=-2,Ut.SKIP=-3,Ut.DEFAULT_TOKEN_CHANNEL=n.DEFAULT_CHANNEL,Ut.HIDDEN=n.HIDDEN_CHANNEL,Ut.MIN_CHAR_VALUE=0,Ut.MAX_CHAR_VALUE=1114111;class Ht{constructor(t){this.configLookup=new p(Bt,$t),this.fullCtx=void 0===t||t,this.readOnly=!1,this.configs=[],this.uniqueAlt=0,this.conflictingAlts=null,this.hasSemanticContext=!1,this.dipsIntoOuterContext=!1,this.cachedHashCode=-1}add(t,e){if(void 0===e&&(e=null),this.readOnly)throw"This set is readonly";t.semanticContext!==f.NONE&&(this.hasSemanticContext=!0),t.reachesIntoOuterContext>0&&(this.dipsIntoOuterContext=!0);const r=this.configLookup.getOrAdd(t);if(r===t)return this.cachedHashCode=-1,this.configs.push(t),!0;const s=!this.fullCtx,i=G(r.context,t.context,s,e);return r.reachesIntoOuterContext=Math.max(r.reachesIntoOuterContext,t.reachesIntoOuterContext),t.precedenceFilterSuppressed&&(r.precedenceFilterSuppressed=!0),r.context=i,!0}getStates(){const t=new p;for(let e=0;e<this.configs.length;e++)t.add(this.configs[e].state);return t}getPredicates(){const t=[];for(let e=0;e<this.configs.length;e++){const r=this.configs[e].semanticContext;r!==f.NONE&&t.push(r.semanticContext)}return t}optimizeConfigs(t){if(this.readOnly)throw"This set is readonly";if(0!==this.configLookup.length)for(let e=0;e<this.configs.length;e++){const r=this.configs[e];r.context=t.getCachedContext(r.context)}}addAll(t){for(let e=0;e<t.length;e++)this.add(t[e]);return!1}equals(t){return this===t||t instanceof Ht&&a(this.configs,t.configs)&&this.fullCtx===t.fullCtx&&this.uniqueAlt===t.uniqueAlt&&this.conflictingAlts===t.conflictingAlts&&this.hasSemanticContext===t.hasSemanticContext&&this.dipsIntoOuterContext===t.dipsIntoOuterContext}hashCode(){const t=new c;return t.update(this.configs),t.finish()}updateHashCode(t){this.readOnly?(-1===this.cachedHashCode&&(this.cachedHashCode=this.hashCode()),t.update(this.cachedHashCode)):t.update(this.hashCode())}isEmpty(){return 0===this.configs.length}contains(t){if(null===this.configLookup)throw"This method is not implemented for readonly sets.";return this.configLookup.contains(t)}containsFast(t){if(null===this.configLookup)throw"This method is not implemented for readonly sets.";return this.configLookup.containsFast(t)}clear(){if(this.readOnly)throw"This set is readonly";this.configs=[],this.cachedHashCode=-1,this.configLookup=new p}setReadonly(t){this.readOnly=t,t&&(this.configLookup=null)}toString(){return m(this.configs)+(this.hasSemanticContext?",hasSemanticContext="+this.hasSemanticContext:"")+(this.uniqueAlt!==Q.INVALID_ALT_NUMBER?",uniqueAlt="+this.uniqueAlt:"")+(null!==this.conflictingAlts?",conflictingAlts="+this.conflictingAlts:"")+(this.dipsIntoOuterContext?",dipsIntoOuterContext":"")}get items(){return this.configs}get length(){return this.configs.length}}class qt{constructor(t,e){return null===t&&(t=-1),null===e&&(e=new Ht),this.stateNumber=t,this.configs=e,this.edges=null,this.isAcceptState=!1,this.prediction=0,this.lexerActionExecutor=null,this.requiresFullContext=!1,this.predicates=null,this}getAltSet(){const t=new p;if(null!==this.configs)for(let e=0;e<this.configs.length;e++){const r=this.configs[e];t.add(r.alt)}return 0===t.length?null:t}equals(t){return this===t||t instanceof qt&&this.configs.equals(t.configs)}toString(){let t=this.stateNumber+":"+this.configs;return this.isAcceptState&&(t+="=>",null!==this.predicates?t+=this.predicates:t+=this.prediction),t}hashCode(){const t=new c;return t.update(this.configs),t.finish()}}class Jt{constructor(t,e){return this.atn=t,this.sharedContextCache=e,this}getCachedContext(t){if(null===this.sharedContextCache)return t;const e=new J;return z(t,this.sharedContextCache,e)}}Jt.ERROR=new qt(2147483647,new Ht);class jt extends Ht{constructor(){super(),this.configLookup=new p}}class zt extends A{constructor(t,e){super(t,e);const r=t.lexerActionExecutor||null;return this.lexerActionExecutor=r||(null!==e?e.lexerActionExecutor:null),this.passedThroughNonGreedyDecision=null!==e&&this.checkNonGreedyDecision(e,this.state),this.hashCodeForConfigSet=zt.prototype.hashCode,this.equalsForConfigSet=zt.prototype.equals,this}updateHashCode(t){t.update(this.state.stateNumber,this.alt,this.context,this.semanticContext,this.passedThroughNonGreedyDecision,this.lexerActionExecutor)}equals(t){return this===t||t instanceof zt&&this.passedThroughNonGreedyDecision===t.passedThroughNonGreedyDecision&&(this.lexerActionExecutor?this.lexerActionExecutor.equals(t.lexerActionExecutor):!t.lexerActionExecutor)&&super.equals(t)}checkNonGreedyDecision(t,e){return t.passedThroughNonGreedyDecision||e instanceof Z&&e.nonGreedy}}class Gt extends Ct{constructor(t,e){super(e.actionType),this.offset=t,this.action=e,this.isPositionDependent=!0}execute(t){this.action.execute(t)}updateHashCode(t){t.update(this.actionType,this.offset,this.action)}equals(t){return this===t||t instanceof Gt&&this.offset===t.offset&&this.action===t.action}}class Wt{constructor(t){return this.lexerActions=null===t?[]:t,this.cachedHashCode=c.hashStuff(t),this}fixOffsetBeforeMatch(t){let e=null;for(let r=0;r<this.lexerActions.length;r++)!this.lexerActions[r].isPositionDependent||this.lexerActions[r]instanceof Gt||(null===e&&(e=this.lexerActions.concat([])),e[r]=new Gt(t,this.lexerActions[r]));return null===e?this:new Wt(e)}execute(t,e,r){let s=!1;const i=e.index;try{for(let n=0;n<this.lexerActions.length;n++){let a=this.lexerActions[n];if(a instanceof Gt){const t=a.offset;e.seek(r+t),a=a.action,s=r+t!==i}else a.isPositionDependent&&(e.seek(i),s=!1);a.execute(t)}}finally{s&&e.seek(i)}}hashCode(){return this.cachedHashCode}updateHashCode(t){t.update(this.cachedHashCode)}equals(t){if(this===t)return!0;if(t instanceof Wt){if(this.cachedHashCode!=t.cachedHashCode)return!1;if(this.lexerActions.length!=t.lexerActions.length)return!1;{const e=this.lexerActions.length;for(let r=0;r<e;++r)if(!this.lexerActions[r].equals(t.lexerActions[r]))return!1;return!0}}return!1}static append(t,e){if(null===t)return new Wt([e]);const r=t.lexerActions.concat([e]);return new Wt(r)}}function Kt(t){t.index=-1,t.line=0,t.column=-1,t.dfaState=null}class Qt{constructor(){Kt(this)}reset(){Kt(this)}}class Xt extends Jt{constructor(t,e,r,s){super(e,s),this.decisionToDFA=r,this.recog=t,this.startIndex=-1,this.line=1,this.column=0,this.mode=Ut.DEFAULT_MODE,this.prevAccept=new Qt}copyState(t){this.column=t.column,this.line=t.line,this.mode=t.mode,this.startIndex=t.startIndex}match(t,e){this.mode=e;const r=t.mark();try{this.startIndex=t.index,this.prevAccept.reset();const r=this.decisionToDFA[e];return null===r.s0?this.matchATN(t):this.execATN(t,r.s0)}finally{t.release(r)}}reset(){this.prevAccept.reset(),this.startIndex=-1,this.line=1,this.column=0,this.mode=Ut.DEFAULT_MODE}matchATN(t){const e=this.atn.modeToStartState[this.mode];Xt.debug&&console.log("matchATN mode "+this.mode+" start: "+e);const r=this.mode,s=this.computeStartState(t,e),i=s.hasSemanticContext;s.hasSemanticContext=!1;const n=this.addDFAState(s);i||(this.decisionToDFA[this.mode].s0=n);const a=this.execATN(t,n);return Xt.debug&&console.log("DFA after matchATN: "+this.decisionToDFA[r].toLexerString()),a}execATN(t,e){Xt.debug&&console.log("start state closure="+e.configs),e.isAcceptState&&this.captureSimState(this.prevAccept,t,e);let r=t.LA(1),s=e;for(;;){Xt.debug&&console.log("execATN loop starting closure: "+s.configs);let e=this.getExistingTargetState(s,r);if(null===e&&(e=this.computeTargetState(t,s,r)),e===Jt.ERROR)break;if(r!==n.EOF&&this.consume(t),e.isAcceptState&&(this.captureSimState(this.prevAccept,t,e),r===n.EOF))break;r=t.LA(1),s=e}return this.failOrAccept(this.prevAccept,t,s.configs,r)}getExistingTargetState(t,e){if(null===t.edges||e<Xt.MIN_DFA_EDGE||e>Xt.MAX_DFA_EDGE)return null;let r=t.edges[e-Xt.MIN_DFA_EDGE];return void 0===r&&(r=null),Xt.debug&&null!==r&&console.log("reuse state "+t.stateNumber+" edge to "+r.stateNumber),r}computeTargetState(t,e,r){const s=new jt;return this.getReachableConfigSet(t,e.configs,s,r),0===s.items.length?(s.hasSemanticContext||this.addDFAEdge(e,r,Jt.ERROR),Jt.ERROR):this.addDFAEdge(e,r,null,s)}failOrAccept(t,e,r,s){if(null!==this.prevAccept.dfaState){const r=t.dfaState.lexerActionExecutor;return this.accept(e,r,this.startIndex,t.index,t.line,t.column),t.dfaState.prediction}if(s===n.EOF&&e.index===this.startIndex)return n.EOF;throw new Vt(this.recog,e,this.startIndex,r)}getReachableConfigSet(t,e,r,s){let i=Q.INVALID_ALT_NUMBER;for(let a=0;a<e.items.length;a++){const o=e.items[a],l=o.alt===i;if(!l||!o.passedThroughNonGreedyDecision){Xt.debug&&console.log("testing %s at %s\n",this.getTokenName(s),o.toString(this.recog,!0));for(let e=0;e<o.state.transitions.length;e++){const a=o.state.transitions[e],c=this.getReachableTarget(a,s);if(null!==c){let e=o.lexerActionExecutor;null!==e&&(e=e.fixOffsetBeforeMatch(t.index-this.startIndex));const a=s===n.EOF,u=new zt({state:c,lexerActionExecutor:e},o);this.closure(t,u,r,l,!0,a)&&(i=o.alt)}}}}}accept(t,e,r,s,i,n){Xt.debug&&console.log("ACTION %s\n",e),t.seek(s),this.line=i,this.column=n,null!==e&&null!==this.recog&&e.execute(this.recog,t,r)}getReachableTarget(t,e){return t.matches(e,0,Ut.MAX_CHAR_VALUE)?t.target:null}computeStartState(t,e){const r=B.EMPTY,s=new jt;for(let i=0;i<e.transitions.length;i++){const n=e.transitions[i].target,a=new zt({state:n,alt:i+1,context:r},null);this.closure(t,a,s,!1,!1,!1)}return s}closure(t,e,r,s,i,n){let a=null;if(Xt.debug&&console.log("closure("+e.toString(this.recog,!0)+")"),e.state instanceof b){if(Xt.debug&&(null!==this.recog?console.log("closure at %s rule stop %s\n",this.recog.ruleNames[e.state.ruleIndex],e):console.log("closure at rule stop %s\n",e)),null===e.context||e.context.hasEmptyPath()){if(null===e.context||e.context.isEmpty())return r.add(e),!0;r.add(new zt({state:e.state,context:B.EMPTY},e)),s=!0}if(null!==e.context&&!e.context.isEmpty())for(let o=0;o<e.context.length;o++)if(e.context.getReturnState(o)!==B.EMPTY_RETURN_STATE){const l=e.context.getParent(o),c=this.atn.states[e.context.getReturnState(o)];a=new zt({state:c,context:l},e),s=this.closure(t,a,r,s,i,n)}return s}e.state.epsilonOnlyTransitions||s&&e.passedThroughNonGreedyDecision||r.add(e);for(let o=0;o<e.state.transitions.length;o++){const l=e.state.transitions[o];a=this.getEpsilonTarget(t,e,l,r,i,n),null!==a&&(s=this.closure(t,a,r,s,i,n))}return s}getEpsilonTarget(t,e,r,s,i,a){let o=null;if(r.serializationType===M.RULE){const t=H.create(e.context,r.followState.stateNumber);o=new zt({state:r.target,context:t},e)}else{if(r.serializationType===M.PRECEDENCE)throw"Precedence predicates are not supported in lexers.";if(r.serializationType===M.PREDICATE)Xt.debug&&console.log("EVAL rule "+r.ruleIndex+":"+r.predIndex),s.hasSemanticContext=!0,this.evaluatePredicate(t,r.ruleIndex,r.predIndex,i)&&(o=new zt({state:r.target},e));else if(r.serializationType===M.ACTION)if(null===e.context||e.context.hasEmptyPath()){const t=Wt.append(e.lexerActionExecutor,this.atn.lexerActions[r.actionIndex]);o=new zt({state:r.target,lexerActionExecutor:t},e)}else o=new zt({state:r.target},e);else r.serializationType===M.EPSILON?o=new zt({state:r.target},e):r.serializationType!==M.ATOM&&r.serializationType!==M.RANGE&&r.serializationType!==M.SET||a&&r.matches(n.EOF,0,Ut.MAX_CHAR_VALUE)&&(o=new zt({state:r.target},e))}return o}evaluatePredicate(t,e,r,s){if(null===this.recog)return!0;if(!s)return this.recog.sempred(null,e,r);const i=this.column,n=this.line,a=t.index,o=t.mark();try{return this.consume(t),this.recog.sempred(null,e,r)}finally{this.column=i,this.line=n,t.seek(a),t.release(o)}}captureSimState(t,e,r){t.index=e.index,t.line=this.line,t.column=this.column,t.dfaState=r}addDFAEdge(t,e,r,s){if(void 0===r&&(r=null),void 0===s&&(s=null),null===r&&null!==s){const t=s.hasSemanticContext;if(s.hasSemanticContext=!1,r=this.addDFAState(s),t)return r}return e<Xt.MIN_DFA_EDGE||e>Xt.MAX_DFA_EDGE||(Xt.debug&&console.log("EDGE "+t+" -> "+r+" upon "+e),null===t.edges&&(t.edges=[]),t.edges[e-Xt.MIN_DFA_EDGE]=r),r}addDFAState(t){const e=new qt(null,t);let r=null;for(let e=0;e<t.items.length;e++){const s=t.items[e];if(s.state instanceof b){r=s;break}}null!==r&&(e.isAcceptState=!0,e.lexerActionExecutor=r.lexerActionExecutor,e.prediction=this.atn.ruleToTokenType[r.state.ruleIndex]);const s=this.decisionToDFA[this.mode],i=s.states.get(e);if(null!==i)return i;const n=e;return n.stateNumber=s.states.length,t.setReadonly(!0),n.configs=t,s.states.add(n),n}getDFA(t){return this.decisionToDFA[t]}getText(t){return t.getText(this.startIndex,t.index-1)}consume(t){t.LA(1)==="\n".charCodeAt(0)?(this.line+=1,this.column=0):this.column+=1,t.consume()}getTokenName(t){return-1===t?"EOF":"'"+String.fromCharCode(t)+"'"}}Xt.debug=!1,Xt.dfa_debug=!1,Xt.MIN_DFA_EDGE=0,Xt.MAX_DFA_EDGE=127;class Zt{constructor(t,e){this.alt=e,this.pred=t}toString(){return"("+this.pred+", "+this.alt+")"}}class Yt{constructor(){this.data={}}get(t){return this.data["k-"+t]||null}set(t,e){this.data["k-"+t]=e}values(){return Object.keys(this.data).filter(t=>t.startsWith("k-")).map(t=>this.data[t],this)}}const te={SLL:0,LL:1,LL_EXACT_AMBIG_DETECTION:2,hasSLLConflictTerminatingPrediction:function(t,e){if(te.allConfigsInRuleStopStates(e))return!0;if(t===te.SLL&&e.hasSemanticContext){const t=new Ht;for(let r=0;r<e.items.length;r++){let s=e.items[r];s=new A({semanticContext:f.NONE},s),t.add(s)}e=t}const r=te.getConflictingAltSubsets(e);return te.hasConflictingAltSet(r)&&!te.hasStateAssociatedWithOneAlt(e)},hasConfigInRuleStopState:function(t){for(let e=0;e<t.items.length;e++)if(t.items[e].state instanceof b)return!0;return!1},allConfigsInRuleStopStates:function(t){for(let e=0;e<t.items.length;e++)if(!(t.items[e].state instanceof b))return!1;return!0},resolvesToJustOneViableAlt:function(t){return te.getSingleViableAlt(t)},allSubsetsConflict:function(t){return!te.hasNonConflictingAltSet(t)},hasNonConflictingAltSet:function(t){for(let e=0;e<t.length;e++)if(1===t[e].length)return!0;return!1},hasConflictingAltSet:function(t){for(let e=0;e<t.length;e++)if(t[e].length>1)return!0;return!1},allSubsetsEqual:function(t){let e=null;for(let r=0;r<t.length;r++){const s=t[r];if(null===e)e=s;else if(s!==e)return!1}return!0},getUniqueAlt:function(t){const e=te.getAlts(t);return 1===e.length?e.minValue():Q.INVALID_ALT_NUMBER},getAlts:function(t){const e=new W;return t.map(function(t){e.or(t)}),e},getConflictingAltSubsets:function(t){const e=new J;return e.hashFunction=function(t){c.hashStuff(t.state.stateNumber,t.context)},e.equalsFunction=function(t,e){return t.state.stateNumber===e.state.stateNumber&&t.context.equals(e.context)},t.items.map(function(t){let r=e.get(t);null===r&&(r=new W,e.set(t,r)),r.set(t.alt)}),e.getValues()},getStateToAltMap:function(t){const e=new Yt;return t.items.map(function(t){let r=e.get(t.state);null===r&&(r=new W,e.set(t.state,r)),r.set(t.alt)}),e},hasStateAssociatedWithOneAlt:function(t){const e=te.getStateToAltMap(t).values();for(let t=0;t<e.length;t++)if(1===e[t].length)return!0;return!1},getSingleViableAlt:function(t){let e=null;for(let r=0;r<t.length;r++){const s=t[r].minValue();if(null===e)e=s;else if(e!==s)return Q.INVALID_ALT_NUMBER}return e}},ee=te;class re extends kt{constructor(t,e,r,s,i,n){n=n||t._ctx,s=s||t.getCurrentToken(),r=r||t.getCurrentToken(),e=e||t.getInputStream(),super({message:"",recognizer:t,input:e,ctx:n}),this.deadEndConfigs=i,this.startToken=r,this.offendingToken=s}}class se{constructor(t){this.defaultMapCtor=t||J,this.cacheMap=new this.defaultMapCtor}get(t,e){const r=this.cacheMap.get(t)||null;return null===r?null:r.get(e)||null}set(t,e,r){let s=this.cacheMap.get(t)||null;null===s&&(s=new this.defaultMapCtor,this.cacheMap.set(t,s)),s.set(e,r)}}class ie extends Jt{constructor(t,e,r,s){super(e,s),this.parser=t,this.decisionToDFA=r,this.predictionMode=ee.LL,this._input=null,this._startIndex=0,this._outerContext=null,this._dfa=null,this.mergeCache=null,this.debug=!1,this.debug_closure=!1,this.debug_add=!1,this.trace_atn_sim=!1,this.dfa_debug=!1,this.retry_debug=!1}reset(){}adaptivePredict(t,e,r){(this.debug||this.trace_atn_sim)&&console.log("adaptivePredict decision "+e+" exec LA(1)=="+this.getLookaheadName(t)+" line "+t.LT(1).line+":"+t.LT(1).column),this._input=t,this._startIndex=t.index,this._outerContext=r;const s=this.decisionToDFA[e];this._dfa=s;const i=t.mark(),n=t.index;try{let e;if(e=s.precedenceDfa?s.getPrecedenceStartState(this.parser.getPrecedence()):s.s0,null===e){null===r&&(r=U.EMPTY),this.debug&&console.log("predictATN decision "+s.decision+" exec LA(1)=="+this.getLookaheadName(t)+", outerContext="+r.toString(this.parser.ruleNames));const i=!1;let n=this.computeStartState(s.atnStartState,U.EMPTY,i);s.precedenceDfa?(s.s0.configs=n,n=this.applyPrecedenceFilter(n),e=this.addDFAState(s,new qt(null,n)),s.setPrecedenceStartState(this.parser.getPrecedence(),e)):(e=this.addDFAState(s,new qt(null,n)),s.s0=e)}const i=this.execATN(s,e,t,n,r);return this.debug&&console.log("DFA after predictATN: "+s.toString(this.parser.literalNames,this.parser.symbolicNames)),i}finally{this._dfa=null,this.mergeCache=null,t.seek(n),t.release(i)}}execATN(t,e,r,s,i){let a;(this.debug||this.trace_atn_sim)&&console.log("execATN decision "+t.decision+", DFA state "+e+", LA(1)=="+this.getLookaheadName(r)+" line "+r.LT(1).line+":"+r.LT(1).column);let o=e;this.debug&&console.log("s0 = "+e);let l=r.LA(1);for(;;){let e=this.getExistingTargetState(o,l);if(null===e&&(e=this.computeTargetState(t,o,l)),e===Jt.ERROR){const t=this.noViableAlt(r,i,o.configs,s);if(r.seek(s),a=this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(o.configs,i),a!==Q.INVALID_ALT_NUMBER)return a;throw t}if(e.requiresFullContext&&this.predictionMode!==ee.SLL){let n=null;if(null!==e.predicates){this.debug&&console.log("DFA state has preds in DFA sim LL failover");const t=r.index;if(t!==s&&r.seek(s),n=this.evalSemanticContext(e.predicates,i,!0),1===n.length)return this.debug&&console.log("Full LL avoided"),n.minValue();t!==s&&r.seek(t)}this.dfa_debug&&console.log("ctx sensitive state "+i+" in "+e);const o=!0,l=this.computeStartState(t.atnStartState,i,o);return this.reportAttemptingFullContext(t,n,e.configs,s,r.index),a=this.execATNWithFullContext(t,e,l,r,s,i),a}if(e.isAcceptState){if(null===e.predicates)return e.prediction;const n=r.index;r.seek(s);const a=this.evalSemanticContext(e.predicates,i,!0);if(0===a.length)throw this.noViableAlt(r,i,e.configs,s);return 1===a.length||this.reportAmbiguity(t,e,s,n,!1,a,e.configs),a.minValue()}o=e,l!==n.EOF&&(r.consume(),l=r.LA(1))}}getExistingTargetState(t,e){const r=t.edges;return null===r?null:r[e+1]||null}computeTargetState(t,e,r){const s=this.computeReachSet(e.configs,r,!1);if(null===s)return this.addDFAEdge(t,e,r,Jt.ERROR),Jt.ERROR;let i=new qt(null,s);const n=this.getUniqueAlt(s);if(this.debug){const t=ee.getConflictingAltSubsets(s);console.log("SLL altSubSets="+m(t)+", configs="+s+", predict="+n+", allSubsetsConflict="+ee.allSubsetsConflict(t)+", conflictingAlts="+this.getConflictingAlts(s))}return n!==Q.INVALID_ALT_NUMBER?(i.isAcceptState=!0,i.configs.uniqueAlt=n,i.prediction=n):ee.hasSLLConflictTerminatingPrediction(this.predictionMode,s)&&(i.configs.conflictingAlts=this.getConflictingAlts(s),i.requiresFullContext=!0,i.isAcceptState=!0,i.prediction=i.configs.conflictingAlts.minValue()),i.isAcceptState&&i.configs.hasSemanticContext&&(this.predicateDFAState(i,this.atn.getDecisionState(t.decision)),null!==i.predicates&&(i.prediction=Q.INVALID_ALT_NUMBER)),i=this.addDFAEdge(t,e,r,i),i}predicateDFAState(t,e){const r=e.transitions.length,s=this.getConflictingAltsOrUniqueAlt(t.configs),i=this.getPredsForAmbigAlts(s,t.configs,r);null!==i?(t.predicates=this.getPredicatePredictions(s,i),t.prediction=Q.INVALID_ALT_NUMBER):t.prediction=s.minValue()}execATNWithFullContext(t,e,r,s,i,a){(this.debug||this.trace_atn_sim)&&console.log("execATNWithFullContext "+r);let o,l=!1,c=r;s.seek(i);let u=s.LA(1),h=-1;for(;;){if(o=this.computeReachSet(c,u,!0),null===o){const t=this.noViableAlt(s,a,c,i);s.seek(i);const e=this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(c,a);if(e!==Q.INVALID_ALT_NUMBER)return e;throw t}const t=ee.getConflictingAltSubsets(o);if(this.debug&&console.log("LL altSubSets="+t+", predict="+ee.getUniqueAlt(t)+", resolvesToJustOneViableAlt="+ee.resolvesToJustOneViableAlt(t)),o.uniqueAlt=this.getUniqueAlt(o),o.uniqueAlt!==Q.INVALID_ALT_NUMBER){h=o.uniqueAlt;break}if(this.predictionMode!==ee.LL_EXACT_AMBIG_DETECTION){if(h=ee.resolvesToJustOneViableAlt(t),h!==Q.INVALID_ALT_NUMBER)break}else if(ee.allSubsetsConflict(t)&&ee.allSubsetsEqual(t)){l=!0,h=ee.getSingleViableAlt(t);break}c=o,u!==n.EOF&&(s.consume(),u=s.LA(1))}return o.uniqueAlt!==Q.INVALID_ALT_NUMBER?(this.reportContextSensitivity(t,h,o,i,s.index),h):(this.reportAmbiguity(t,e,i,s.index,l,null,o),h)}computeReachSet(t,e,r){this.debug&&console.log("in computeReachSet, starting closure: "+t),null===this.mergeCache&&(this.mergeCache=new se);const s=new Ht(r);let i=null;for(let a=0;a<t.items.length;a++){const o=t.items[a];if(this.debug&&console.log("testing "+this.getTokenName(e)+" at "+o),o.state instanceof b)(r||e===n.EOF)&&(null===i&&(i=[]),i.push(o),this.debug_add&&console.log("added "+o+" to skippedStopStates"));else for(let t=0;t<o.state.transitions.length;t++){const r=o.state.transitions[t],i=this.getReachableTarget(r,e);if(null!==i){const t=new A({state:i},o);s.add(t,this.mergeCache),this.debug_add&&console.log("added "+t+" to intermediate")}}}let a=null;if(null===i&&e!==n.EOF&&(1===s.items.length||this.getUniqueAlt(s)!==Q.INVALID_ALT_NUMBER)&&(a=s),null===a){a=new Ht(r);const t=new p,i=e===n.EOF;for(let e=0;e<s.items.length;e++)this.closure(s.items[e],a,t,!1,r,i)}if(e===n.EOF&&(a=this.removeAllConfigsNotInRuleStopState(a,a===s)),!(null===i||r&&ee.hasConfigInRuleStopState(a)))for(let t=0;t<i.length;t++)a.add(i[t],this.mergeCache);return this.trace_atn_sim&&console.log("computeReachSet "+t+" -> "+a),0===a.items.length?null:a}removeAllConfigsNotInRuleStopState(t,e){if(ee.allConfigsInRuleStopStates(t))return t;const r=new Ht(t.fullCtx);for(let s=0;s<t.items.length;s++){const i=t.items[s];if(i.state instanceof b)r.add(i,this.mergeCache);else if(e&&i.state.epsilonOnlyTransitions&&this.atn.nextTokens(i.state).contains(n.EPSILON)){const t=this.atn.ruleToStopState[i.state.ruleIndex];r.add(new A({state:t},i),this.mergeCache)}}return r}computeStartState(t,e,r){const s=j(this.atn,e),i=new Ht(r);this.trace_atn_sim&&console.log("computeStartState from ATN state "+t+" initialContext="+s.toString(this.parser));for(let e=0;e<t.transitions.length;e++){const n=t.transitions[e].target,a=new A({state:n,alt:e+1,context:s},null),o=new p;this.closure(a,i,o,!0,r,!1)}return i}applyPrecedenceFilter(t){let e;const r=[],s=new Ht(t.fullCtx);for(let i=0;i<t.items.length;i++){if(e=t.items[i],1!==e.alt)continue;const n=e.semanticContext.evalPrecedence(this.parser,this._outerContext);null!==n&&(r[e.state.stateNumber]=e.context,n!==e.semanticContext?s.add(new A({semanticContext:n},e),this.mergeCache):s.add(e,this.mergeCache))}for(let i=0;i<t.items.length;i++)if(e=t.items[i],1!==e.alt){if(!e.precedenceFilterSuppressed){const t=r[e.state.stateNumber]||null;if(null!==t&&t.equals(e.context))continue}s.add(e,this.mergeCache)}return s}getReachableTarget(t,e){return t.matches(e,0,this.atn.maxTokenType)?t.target:null}getPredsForAmbigAlts(t,e,r){let s=[];for(let r=0;r<e.items.length;r++){const i=e.items[r];t.get(i.alt)&&(s[i.alt]=f.orContext(s[i.alt]||null,i.semanticContext))}let i=0;for(let t=1;t<r+1;t++){const e=s[t]||null;null===e?s[t]=f.NONE:e!==f.NONE&&(i+=1)}return 0===i&&(s=null),this.debug&&console.log("getPredsForAmbigAlts result "+m(s)),s}getPredicatePredictions(t,e){const r=[];let s=!1;for(let i=1;i<e.length;i++){const n=e[i];null!==t&&t.get(i)&&r.push(new Zt(n,i)),n!==f.NONE&&(s=!0)}return s?r:null}getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(t,e){const r=this.splitAccordingToSemanticValidity(t,e),s=r[0],i=r[1];let n=this.getAltThatFinishedDecisionEntryRule(s);return n!==Q.INVALID_ALT_NUMBER||i.items.length>0&&(n=this.getAltThatFinishedDecisionEntryRule(i),n!==Q.INVALID_ALT_NUMBER)?n:Q.INVALID_ALT_NUMBER}getAltThatFinishedDecisionEntryRule(t){const e=[];for(let r=0;r<t.items.length;r++){const s=t.items[r];(s.reachesIntoOuterContext>0||s.state instanceof b&&s.context.hasEmptyPath())&&e.indexOf(s.alt)<0&&e.push(s.alt)}return 0===e.length?Q.INVALID_ALT_NUMBER:Math.min.apply(null,e)}splitAccordingToSemanticValidity(t,e){const r=new Ht(t.fullCtx),s=new Ht(t.fullCtx);for(let i=0;i<t.items.length;i++){const n=t.items[i];n.semanticContext!==f.NONE?n.semanticContext.evaluate(this.parser,e)?r.add(n):s.add(n):r.add(n)}return[r,s]}evalSemanticContext(t,e,r){const s=new W;for(let i=0;i<t.length;i++){const n=t[i];if(n.pred===f.NONE){if(s.set(n.alt),!r)break;continue}const a=n.pred.evaluate(this.parser,e);if((this.debug||this.dfa_debug)&&console.log("eval pred "+n+"="+a),a&&((this.debug||this.dfa_debug)&&console.log("PREDICT "+n.alt),s.set(n.alt),!r))break}return s}closure(t,e,r,s,i,n){this.closureCheckingStopState(t,e,r,s,i,0,n)}closureCheckingStopState(t,e,r,s,i,n,a){if((this.trace_atn_sim||this.debug_closure)&&console.log("closure("+t.toString(this.parser,!0)+")"),t.state instanceof b){if(!t.context.isEmpty()){for(let o=0;o<t.context.length;o++){if(t.context.getReturnState(o)===B.EMPTY_RETURN_STATE){if(i){e.add(new A({state:t.state,context:B.EMPTY},t),this.mergeCache);continue}this.debug&&console.log("FALLING off rule "+this.getRuleName(t.state.ruleIndex)),this.closure_(t,e,r,s,i,n,a);continue}const l=this.atn.states[t.context.getReturnState(o)],c=t.context.getParent(o),u={state:l,alt:t.alt,context:c,semanticContext:t.semanticContext},h=new A(u,null);h.reachesIntoOuterContext=t.reachesIntoOuterContext,this.closureCheckingStopState(h,e,r,s,i,n-1,a)}return}if(i)return void e.add(t,this.mergeCache);this.debug&&console.log("FALLING off rule "+this.getRuleName(t.state.ruleIndex))}this.closure_(t,e,r,s,i,n,a)}closure_(t,e,r,s,i,n,a){const o=t.state;o.epsilonOnlyTransitions||e.add(t,this.mergeCache);for(let l=0;l<o.transitions.length;l++){if(0===l&&this.canDropLoopEntryEdgeInLeftRecursiveRule(t))continue;const c=o.transitions[l],u=s&&!(c instanceof dt),h=this.getEpsilonTarget(t,c,u,0===n,i,a);if(null!==h){let s=n;if(t.state instanceof b){if(null!==this._dfa&&this._dfa.precedenceDfa&&c.outermostPrecedenceReturn===this._dfa.atnStartState.ruleIndex&&(h.precedenceFilterSuppressed=!0),h.reachesIntoOuterContext+=1,r.getOrAdd(h)!==h)continue;e.dipsIntoOuterContext=!0,s-=1,this.debug&&console.log("dips into outer ctx: "+h)}else{if(!c.isEpsilon&&r.getOrAdd(h)!==h)continue;c instanceof T&&s>=0&&(s+=1)}this.closureCheckingStopState(h,e,r,u,i,s,a)}}}canDropLoopEntryEdgeInLeftRecursiveRule(t){const e=t.state;if(e.stateType!==_.STAR_LOOP_ENTRY)return!1;if(e.stateType!==_.STAR_LOOP_ENTRY||!e.isPrecedenceDecision||t.context.isEmpty()||t.context.hasEmptyPath())return!1;const r=t.context.length;for(let s=0;s<r;s++)if(this.atn.states[t.context.getReturnState(s)].ruleIndex!==e.ruleIndex)return!1;const s=e.transitions[0].target.endState.stateNumber,i=this.atn.states[s];for(let s=0;s<r;s++){const r=t.context.getReturnState(s),n=this.atn.states[r];if(1!==n.transitions.length||!n.transitions[0].isEpsilon)return!1;const a=n.transitions[0].target;if(!(n.stateType===_.BLOCK_END&&a===e||n===i||a===i||a.stateType===_.BLOCK_END&&1===a.transitions.length&&a.transitions[0].isEpsilon&&a.transitions[0].target===e))return!1}return!0}getRuleName(t){return null!==this.parser&&t>=0?this.parser.ruleNames[t]:"<rule "+t+">"}getEpsilonTarget(t,e,r,s,i,a){switch(e.serializationType){case M.RULE:return this.ruleTransition(t,e);case M.PRECEDENCE:return this.precedenceTransition(t,e,r,s,i);case M.PREDICATE:return this.predTransition(t,e,r,s,i);case M.ACTION:return this.actionTransition(t,e);case M.EPSILON:return new A({state:e.target},t);case M.ATOM:case M.RANGE:case M.SET:return a&&e.matches(n.EOF,0,1)?new A({state:e.target},t):null;default:return null}}actionTransition(t,e){if(this.debug){const t=-1===e.actionIndex?65535:e.actionIndex;console.log("ACTION edge "+e.ruleIndex+":"+t)}return new A({state:e.target},t)}precedenceTransition(t,e,r,s,i){this.debug&&(console.log("PRED (collectPredicates="+r+") "+e.precedence+">=_p, ctx dependent=true"),null!==this.parser&&console.log("context surrounding pred is "+m(this.parser.getRuleInvocationStack())));let n=null;if(r&&s)if(i){const r=this._input.index;this._input.seek(this._startIndex);const s=e.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(r),s&&(n=new A({state:e.target},t))}else{const r=f.andContext(t.semanticContext,e.getPredicate());n=new A({state:e.target,semanticContext:r},t)}else n=new A({state:e.target},t);return this.debug&&console.log("config from pred transition="+n),n}predTransition(t,e,r,s,i){this.debug&&(console.log("PRED (collectPredicates="+r+") "+e.ruleIndex+":"+e.predIndex+", ctx dependent="+e.isCtxDependent),null!==this.parser&&console.log("context surrounding pred is "+m(this.parser.getRuleInvocationStack())));let n=null;if(r&&(e.isCtxDependent&&s||!e.isCtxDependent))if(i){const r=this._input.index;this._input.seek(this._startIndex);const s=e.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(r),s&&(n=new A({state:e.target},t))}else{const r=f.andContext(t.semanticContext,e.getPredicate());n=new A({state:e.target,semanticContext:r},t)}else n=new A({state:e.target},t);return this.debug&&console.log("config from pred transition="+n),n}ruleTransition(t,e){this.debug&&console.log("CALL rule "+this.getRuleName(e.target.ruleIndex)+", ctx="+t.context);const r=e.followState,s=H.create(t.context,r.stateNumber);return new A({state:e.target,context:s},t)}getConflictingAlts(t){const e=ee.getConflictingAltSubsets(t);return ee.getAlts(e)}getConflictingAltsOrUniqueAlt(t){let e=null;return t.uniqueAlt!==Q.INVALID_ALT_NUMBER?(e=new W,e.set(t.uniqueAlt)):e=t.conflictingAlts,e}getTokenName(t){if(t===n.EOF)return"EOF";if(null!==this.parser&&null!==this.parser.literalNames){if(!(t>=this.parser.literalNames.length&&t>=this.parser.symbolicNames.length))return(this.parser.literalNames[t]||this.parser.symbolicNames[t])+"<"+t+">";console.log(t+" ttype out of range: "+this.parser.literalNames),console.log(""+this.parser.getInputStream().getTokens())}return""+t}getLookaheadName(t){return this.getTokenName(t.LA(1))}dumpDeadEndConfigs(t){console.log("dead end configs: ");const e=t.getDeadEndConfigs();for(let t=0;t<e.length;t++){const r=e[t];let s="no edges";if(r.state.transitions.length>0){const t=r.state.transitions[0];t instanceof ut?s="Atom "+this.getTokenName(t.label):t instanceof v&&(s=(t instanceof L?"~":"")+"Set "+t.set)}console.error(r.toString(this.parser,!0)+":"+s)}}noViableAlt(t,e,r,s){return new re(this.parser,t,t.get(s),t.LT(1),r,e)}getUniqueAlt(t){let e=Q.INVALID_ALT_NUMBER;for(let r=0;r<t.items.length;r++){const s=t.items[r];if(e===Q.INVALID_ALT_NUMBER)e=s.alt;else if(s.alt!==e)return Q.INVALID_ALT_NUMBER}return e}addDFAEdge(t,e,r,s){if(this.debug&&console.log("EDGE "+e+" -> "+s+" upon "+this.getTokenName(r)),null===s)return null;if(s=this.addDFAState(t,s),null===e||r<-1||r>this.atn.maxTokenType)return s;if(null===e.edges&&(e.edges=[]),e.edges[r+1]=s,this.debug){const e=null===this.parser?null:this.parser.literalNames,r=null===this.parser?null:this.parser.symbolicNames;console.log("DFA=\n"+t.toString(e,r))}return s}addDFAState(t,e){if(e===Jt.ERROR)return e;const r=t.states.get(e);return null!==r?(this.trace_atn_sim&&console.log("addDFAState "+e+" exists"),r):(e.stateNumber=t.states.length,e.configs.readOnly||(e.configs.optimizeConfigs(this),e.configs.setReadonly(!0)),this.trace_atn_sim&&console.log("addDFAState new "+e),t.states.add(e),this.debug&&console.log("adding new DFA state: "+e),e)}reportAttemptingFullContext(t,e,r,s,i){if(this.debug||this.retry_debug){const e=new S(s,i+1);console.log("reportAttemptingFullContext decision="+t.decision+":"+r+", input="+this.parser.getTokenStream().getText(e))}null!==this.parser&&this.parser.getErrorListener().reportAttemptingFullContext(this.parser,t,s,i,e,r)}reportContextSensitivity(t,e,r,s,i){if(this.debug||this.retry_debug){const e=new S(s,i+1);console.log("reportContextSensitivity decision="+t.decision+":"+r+", input="+this.parser.getTokenStream().getText(e))}null!==this.parser&&this.parser.getErrorListener().reportContextSensitivity(this.parser,t,s,i,e,r)}reportAmbiguity(t,e,r,s,i,n,a){if(this.debug||this.retry_debug){const t=new S(r,s+1);console.log("reportAmbiguity "+n+":"+a+", input="+this.parser.getTokenStream().getText(t))}null!==this.parser&&this.parser.getErrorListener().reportAmbiguity(this.parser,t,r,s,i,n,a)}}class ne{constructor(){this.cache=new J}add(t){if(t===B.EMPTY)return B.EMPTY;const e=this.cache.get(t)||null;return null!==e?e:(this.cache.set(t,t),t)}get(t){return this.cache.get(t)||null}get length(){return this.cache.length}}const ae={ATN:Q,ATNDeserializer:Nt,LexerATNSimulator:Xt,ParserATNSimulator:ie,PredictionMode:ee,PredictionContextCache:ne};class oe{constructor(t,e,r){this.dfa=t,this.literalNames=e||[],this.symbolicNames=r||[]}toString(){if(null===this.dfa.s0)return null;let t="";const e=this.dfa.sortedStates();for(let r=0;r<e.length;r++){const s=e[r];if(null!==s.edges){const e=s.edges.length;for(let r=0;r<e;r++){const e=s.edges[r]||null;null!==e&&2147483647!==e.stateNumber&&(t=t.concat(this.getStateString(s)),t=t.concat("-"),t=t.concat(this.getEdgeLabel(r)),t=t.concat("->"),t=t.concat(this.getStateString(e)),t=t.concat("\n"))}}}return 0===t.length?null:t}getEdgeLabel(t){return 0===t?"EOF":null!==this.literalNames||null!==this.symbolicNames?this.literalNames[t-1]||this.symbolicNames[t-1]:String.fromCharCode(t-1)}getStateString(t){const e=(t.isAcceptState?":":"")+"s"+t.stateNumber+(t.requiresFullContext?"^":"");return t.isAcceptState?null!==t.predicates?e+"=>"+m(t.predicates):e+"=>"+t.prediction.toString():e}}class le extends oe{constructor(t){super(t,null)}getEdgeLabel(t){return"'"+String.fromCharCode(t)+"'"}}class ce{constructor(t,e){if(void 0===e&&(e=0),this.atnStartState=t,this.decision=e,this._states=new p,this.s0=null,this.precedenceDfa=!1,t instanceof at&&t.isPrecedenceDecision){this.precedenceDfa=!0;const t=new qt(null,new Ht);t.edges=[],t.isAcceptState=!1,t.requiresFullContext=!1,this.s0=t}}getPrecedenceStartState(t){if(!this.precedenceDfa)throw"Only precedence DFAs may contain a precedence start state.";return t<0||t>=this.s0.edges.length?null:this.s0.edges[t]||null}setPrecedenceStartState(t,e){if(!this.precedenceDfa)throw"Only precedence DFAs may contain a precedence start state.";t<0||(this.s0.edges[t]=e)}setPrecedenceDfa(t){if(this.precedenceDfa!==t){if(this._states=new p,t){const t=new qt(null,new Ht);t.edges=[],t.isAcceptState=!1,t.requiresFullContext=!1,this.s0=t}else this.s0=null;this.precedenceDfa=t}}sortedStates(){return this._states.values().sort(function(t,e){return t.stateNumber-e.stateNumber})}toString(t,e){return t=t||null,e=e||null,null===this.s0?"":new oe(this,t,e).toString()}toLexerString(){return null===this.s0?"":new le(this).toString()}get states(){return this._states}}const ue={DFA:ce,DFASerializer:oe,LexerDFASerializer:le,PredPrediction:Zt},he={PredictionContext:B},de={Interval:S,IntervalSet:E};class me{visitTerminal(t){}visitErrorNode(t){}enterEveryRule(t){}exitEveryRule(t){}}class pe{visit(t){return Array.isArray(t)?t.map(function(t){return t.accept(this)},this):t.accept(this)}visitChildren(t){return t.children?this.visit(t.children):null}visitTerminal(t){}visitErrorNode(t){}}class fe{walk(t,e){if(e instanceof F||void 0!==e.isErrorNode&&e.isErrorNode())t.visitErrorNode(e);else if(e instanceof D)t.visitTerminal(e);else{this.enterRule(t,e);for(let r=0;r<e.getChildCount();r++){const s=e.getChild(r);this.walk(t,s)}this.exitRule(t,e)}}enterRule(t,e){const r=e.ruleContext;t.enterEveryRule(r),r.enterRule(t)}exitRule(t,e){const r=e.ruleContext;r.exitRule(t),t.exitEveryRule(r)}}fe.DEFAULT=new fe;const ge={Trees:V,RuleNode:P,ErrorNode:F,TerminalNode:D,ParseTreeListener:me,ParseTreeVisitor:pe,ParseTreeWalker:fe};class ye extends kt{constructor(t){super({message:"",recognizer:t,input:t.getInputStream(),ctx:t._ctx}),this.offendingToken=t.getCurrentToken()}}class xe extends kt{constructor(t,e,r){super({message:Ce(e,r||null),recognizer:t,input:t.getInputStream(),ctx:t._ctx});const s=t._interp.atn.states[t.state].transitions[0];s instanceof ft?(this.ruleIndex=s.ruleIndex,this.predicateIndex=s.predIndex):(this.ruleIndex=0,this.predicateIndex=0),this.predicate=e,this.offendingToken=t.getCurrentToken()}}function Ce(t,e){return null!==e?e:"failed predicate: {"+t+"}?"}class Ae extends It{constructor(t){super(),t=t||!0,this.exactOnly=t}reportAmbiguity(t,e,r,s,i,n,a){if(this.exactOnly&&!i)return;const o="reportAmbiguity d="+this.getDecisionDescription(t,e)+": ambigAlts="+this.getConflictingAlts(n,a)+", input='"+t.getTokenStream().getText(new S(r,s))+"'";t.notifyErrorListeners(o)}reportAttemptingFullContext(t,e,r,s,i,n){const a="reportAttemptingFullContext d="+this.getDecisionDescription(t,e)+", input='"+t.getTokenStream().getText(new S(r,s))+"'";t.notifyErrorListeners(a)}reportContextSensitivity(t,e,r,s,i,n){const a="reportContextSensitivity d="+this.getDecisionDescription(t,e)+", input='"+t.getTokenStream().getText(new S(r,s))+"'";t.notifyErrorListeners(a)}getDecisionDescription(t,e){const r=e.decision,s=e.atnStartState.ruleIndex,i=t.ruleNames;if(s<0||s>=i.length)return""+r;const n=i[s]||null;return null===n||0===n.length?""+r:`${r} (${n})`}getConflictingAlts(t,e){if(null!==t)return t;const r=new W;for(let t=0;t<e.items.length;t++)r.set(e.items[t].alt);return`{${r.values().join(", ")}}`}}class Se extends Error{constructor(){super(),Error.captureStackTrace(this,Se)}}class Ee{reset(t){}recoverInline(t){}recover(t,e){}sync(t){}inErrorRecoveryMode(t){}reportError(t){}}class _e extends Ee{constructor(){super(),this.errorRecoveryMode=!1,this.lastErrorIndex=-1,this.lastErrorStates=null,this.nextTokensContext=null,this.nextTokenState=0}reset(t){this.endErrorCondition(t)}beginErrorCondition(t){this.errorRecoveryMode=!0}inErrorRecoveryMode(t){return this.errorRecoveryMode}endErrorCondition(t){this.errorRecoveryMode=!1,this.lastErrorStates=null,this.lastErrorIndex=-1}reportMatch(t){this.endErrorCondition(t)}reportError(t,e){this.inErrorRecoveryMode(t)||(this.beginErrorCondition(t),e instanceof re?this.reportNoViableAlternative(t,e):e instanceof ye?this.reportInputMismatch(t,e):e instanceof xe?this.reportFailedPredicate(t,e):(console.log("unknown recognition error type: "+e.constructor.name),console.log(e.stack),t.notifyErrorListeners(e.getOffendingToken(),e.getMessage(),e)))}recover(t,e){this.lastErrorIndex===t.getInputStream().index&&null!==this.lastErrorStates&&this.lastErrorStates.indexOf(t.state)>=0&&t.consume(),this.lastErrorIndex=t._input.index,null===this.lastErrorStates&&(this.lastErrorStates=[]),this.lastErrorStates.push(t.state);const r=this.getErrorRecoverySet(t);this.consumeUntil(t,r)}sync(t){if(this.inErrorRecoveryMode(t))return;const e=t._interp.atn.states[t.state],r=t.getTokenStream().LA(1),s=t.atn.nextTokens(e);if(s.contains(r))return this.nextTokensContext=null,void(this.nextTokenState=_.INVALID_STATE_NUMBER);if(s.contains(n.EPSILON))null===this.nextTokensContext&&(this.nextTokensContext=t._ctx,this.nextTokensState=t._stateNumber);else switch(e.stateType){case _.BLOCK_START:case _.STAR_BLOCK_START:case _.PLUS_BLOCK_START:case _.STAR_LOOP_ENTRY:if(null!==this.singleTokenDeletion(t))return;throw new ye(t);case _.PLUS_LOOP_BACK:case _.STAR_LOOP_BACK:{this.reportUnwantedToken(t);const e=new E;e.addSet(t.getExpectedTokens());const r=e.addSet(this.getErrorRecoverySet(t));this.consumeUntil(t,r)}}}reportNoViableAlternative(t,e){const r=t.getTokenStream();let s;s=null!==r?e.startToken.type===n.EOF?"<EOF>":r.getText(new S(e.startToken.tokenIndex,e.offendingToken.tokenIndex)):"<unknown input>";const i="no viable alternative at input "+this.escapeWSAndQuote(s);t.notifyErrorListeners(i,e.offendingToken,e)}reportInputMismatch(t,e){const r="mismatched input "+this.getTokenErrorDisplay(e.offendingToken)+" expecting "+e.getExpectedTokens().toString(t.literalNames,t.symbolicNames);t.notifyErrorListeners(r,e.offendingToken,e)}reportFailedPredicate(t,e){const r="rule "+t.ruleNames[t._ctx.ruleIndex]+" "+e.message;t.notifyErrorListeners(r,e.offendingToken,e)}reportUnwantedToken(t){if(this.inErrorRecoveryMode(t))return;this.beginErrorCondition(t);const e=t.getCurrentToken(),r="extraneous input "+this.getTokenErrorDisplay(e)+" expecting "+this.getExpectedTokens(t).toString(t.literalNames,t.symbolicNames);t.notifyErrorListeners(r,e,null)}reportMissingToken(t){if(this.inErrorRecoveryMode(t))return;this.beginErrorCondition(t);const e=t.getCurrentToken(),r="missing "+this.getExpectedTokens(t).toString(t.literalNames,t.symbolicNames)+" at "+this.getTokenErrorDisplay(e);t.notifyErrorListeners(r,e,null)}recoverInline(t){const e=this.singleTokenDeletion(t);if(null!==e)return t.consume(),e;if(this.singleTokenInsertion(t))return this.getMissingSymbol(t);throw new ye(t)}singleTokenInsertion(t){const e=t.getTokenStream().LA(1),r=t._interp.atn,s=r.states[t.state].transitions[0].target;return!!r.nextTokens(s,t._ctx).contains(e)&&(this.reportMissingToken(t),!0)}singleTokenDeletion(t){const e=t.getTokenStream().LA(2);if(this.getExpectedTokens(t).contains(e)){this.reportUnwantedToken(t),t.consume();const e=t.getCurrentToken();return this.reportMatch(t),e}return null}getMissingSymbol(t){const e=t.getCurrentToken(),r=this.getExpectedTokens(t).first();let s;s=r===n.EOF?"<missing EOF>":"<missing "+t.literalNames[r]+">";let i=e;const a=t.getTokenStream().LT(-1);return i.type===n.EOF&&null!==a&&(i=a),t.getTokenFactory().create(i.source,r,s,n.DEFAULT_CHANNEL,-1,-1,i.line,i.column)}getExpectedTokens(t){return t.getExpectedTokens()}getTokenErrorDisplay(t){if(null===t)return"<no token>";let e=t.text;return null===e&&(e=t.type===n.EOF?"<EOF>":"<"+t.type+">"),this.escapeWSAndQuote(e)}escapeWSAndQuote(t){return"'"+(t=(t=(t=t.replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t"))+"'"}getErrorRecoverySet(t){const e=t._interp.atn;let r=t._ctx;const s=new E;for(;null!==r&&r.invokingState>=0;){const t=e.states[r.invokingState].transitions[0],i=e.nextTokens(t.followState);s.addSet(i),r=r.parentCtx}return s.removeOne(n.EPSILON),s}consumeUntil(t,e){let r=t.getTokenStream().LA(1);for(;r!==n.EOF&&!e.contains(r);)t.consume(),r=t.getTokenStream().LA(1)}}class be extends _e{constructor(){super()}recover(t,e){let r=t._ctx;for(;null!==r;)r.exception=e,r=r.parentCtx;throw new Se(e)}recoverInline(t){this.recover(t,new ye(t))}sync(t){}}const Me={RecognitionException:kt,NoViableAltException:re,LexerNoViableAltException:Vt,InputMismatchException:ye,FailedPredicateException:xe,DiagnosticErrorListener:Ae,BailErrorStrategy:be,DefaultErrorStrategy:_e,ErrorListener:It};class Te{constructor(t,e){if(this.name="<empty>",this.strdata=t,this.decodeToUnicodeCodePoints=e||!1,this._index=0,this.data=[],this.decodeToUnicodeCodePoints)for(let t=0;t<this.strdata.length;){const e=this.strdata.codePointAt(t);this.data.push(e),t+=e<=65535?1:2}else{this.data=new Array(this.strdata.length);for(let t=0;t<this.strdata.length;t++)this.data[t]=this.strdata.charCodeAt(t)}this._size=this.data.length}reset(){this._index=0}consume(){if(this._index>=this._size)throw"cannot consume EOF";this._index+=1}LA(t){if(0===t)return 0;t<0&&(t+=1);const e=this._index+t-1;return e<0||e>=this._size?n.EOF:this.data[e]}LT(t){return this.LA(t)}mark(){return-1}release(t){}seek(t){t<=this._index?this._index=t:this._index=Math.min(t,this._size)}getText(t,e){if(e>=this._size&&(e=this._size-1),t>=this._size)return"";if(this.decodeToUnicodeCodePoints){let r="";for(let s=t;s<=e;s++)r+=String.fromCodePoint(this.data[s]);return r}return this.strdata.slice(t,e+1)}toString(){return this.strdata}get index(){return this._index}get size(){return this._size}}class ve extends Te{constructor(t,e){super(t,e)}}const Le=r(896),Ne="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node;class Ie extends ve{static fromPath(t,e,r){if(!Ne)throw new Error("FileStream is only available when running in Node!");Le.readFile(t,e,function(t,e){let s=null;null!==e&&(s=new Te(e,!0)),r(t,s)})}constructor(t,e,r){if(!Ne)throw new Error("FileStream is only available when running in Node!");super(Le.readFileSync(t,e||"utf-8"),r),this.fileName=t}}const we={fromString:function(t){return new Te(t,!0)},fromBlob:function(t,e,r,s){const i=new window.FileReader;i.onload=function(t){const e=new Te(t.target.result,!0);r(e)},i.onerror=s,i.readAsText(t,e)},fromBuffer:function(t,e){return new Te(t.toString(e),!0)},fromPath:function(t,e,r){Ie.fromPath(t,e,r)},fromPathSync:function(t,e){return new Ie(t,e)}},Oe={arrayToString:m,stringToCharArray:function(t){let e=new Uint16Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}};class Re{}class Pe extends Re{constructor(t){super(),this.tokenSource=t,this.tokens=[],this.index=-1,this.fetchedEOF=!1}mark(){return 0}release(t){}reset(){this.seek(0)}seek(t){this.lazyInit(),this.index=this.adjustSeekIndex(t)}get size(){return this.tokens.length}get(t){return this.lazyInit(),this.tokens[t]}consume(){let t=!1;if(t=this.index>=0&&(this.fetchedEOF?this.index<this.tokens.length-1:this.index<this.tokens.length),!t&&this.LA(1)===n.EOF)throw"cannot consume EOF";this.sync(this.index+1)&&(this.index=this.adjustSeekIndex(this.index+1))}sync(t){const e=t-this.tokens.length+1;return!(e>0)||this.fetch(e)>=e}fetch(t){if(this.fetchedEOF)return 0;for(let e=0;e<t;e++){const t=this.tokenSource.nextToken();if(t.tokenIndex=this.tokens.length,this.tokens.push(t),t.type===n.EOF)return this.fetchedEOF=!0,e+1}return t}getTokens(t,e,r){if(void 0===r&&(r=null),t<0||e<0)return null;this.lazyInit();const s=[];e>=this.tokens.length&&(e=this.tokens.length-1);for(let i=t;i<e;i++){const t=this.tokens[i];if(t.type===n.EOF)break;(null===r||r.contains(t.type))&&s.push(t)}return s}LA(t){return this.LT(t).type}LB(t){return this.index-t<0?null:this.tokens[this.index-t]}LT(t){if(this.lazyInit(),0===t)return null;if(t<0)return this.LB(-t);const e=this.index+t-1;return this.sync(e),e>=this.tokens.length?this.tokens[this.tokens.length-1]:this.tokens[e]}adjustSeekIndex(t){return t}lazyInit(){-1===this.index&&this.setup()}setup(){this.sync(0),this.index=this.adjustSeekIndex(0)}setTokenSource(t){this.tokenSource=t,this.tokens=[],this.index=-1,this.fetchedEOF=!1}nextTokenOnChannel(t,e){if(this.sync(t),t>=this.tokens.length)return-1;let r=this.tokens[t];for(;r.channel!==e;){if(r.type===n.EOF)return-1;t+=1,this.sync(t),r=this.tokens[t]}return t}previousTokenOnChannel(t,e){for(;t>=0&&this.tokens[t].channel!==e;)t-=1;return t}getHiddenTokensToRight(t,e){if(void 0===e&&(e=-1),this.lazyInit(),t<0||t>=this.tokens.length)throw t+" not in 0.."+this.tokens.length-1;const r=this.nextTokenOnChannel(t+1,Ut.DEFAULT_TOKEN_CHANNEL),s=t+1,i=-1===r?this.tokens.length-1:r;return this.filterForChannel(s,i,e)}getHiddenTokensToLeft(t,e){if(void 0===e&&(e=-1),this.lazyInit(),t<0||t>=this.tokens.length)throw t+" not in 0.."+this.tokens.length-1;const r=this.previousTokenOnChannel(t-1,Ut.DEFAULT_TOKEN_CHANNEL);if(r===t-1)return null;const s=r+1,i=t-1;return this.filterForChannel(s,i,e)}filterForChannel(t,e,r){const s=[];for(let i=t;i<e+1;i++){const t=this.tokens[i];-1===r?t.channel!==Ut.DEFAULT_TOKEN_CHANNEL&&s.push(t):t.channel===r&&s.push(t)}return 0===s.length?null:s}getSourceName(){return this.tokenSource.getSourceName()}getText(t){this.lazyInit(),this.fill(),t||(t=new S(0,this.tokens.length-1));let e=t.start;e instanceof n&&(e=e.tokenIndex);let r=t.stop;if(r instanceof n&&(r=r.tokenIndex),null===e||null===r||e<0||r<0)return"";r>=this.tokens.length&&(r=this.tokens.length-1);let s="";for(let t=e;t<r+1;t++){const e=this.tokens[t];if(e.type===n.EOF)break;s+=e.text}return s}fill(){for(this.lazyInit();1e3===this.fetch(1e3););}}Object.defineProperty(Pe,"size",{get:function(){return this.tokens.length}});class De extends Pe{constructor(t,e){super(t),this.channel=void 0===e?n.DEFAULT_CHANNEL:e}adjustSeekIndex(t){return this.nextTokenOnChannel(t,this.channel)}LB(t){if(0===t||this.index-t<0)return null;let e=this.index,r=1;for(;r<=t;)e=this.previousTokenOnChannel(e-1,this.channel),r+=1;return e<0?null:this.tokens[e]}LT(t){if(this.lazyInit(),0===t)return null;if(t<0)return this.LB(-t);let e=this.index,r=1;for(;r<t;)this.sync(e+1)&&(e=this.nextTokenOnChannel(e+1,this.channel)),r+=1;return this.tokens[e]}getNumberOfOnChannelTokens(){let t=0;this.fill();for(let e=0;e<this.tokens.length;e++){const r=this.tokens[e];if(r.channel===this.channel&&(t+=1),r.type===n.EOF)break}return t}}class Fe extends me{constructor(t){super(),this.parser=t}enterEveryRule(t){console.log("enter "+this.parser.ruleNames[t.ruleIndex]+", LT(1)="+this.parser._input.LT(1).text)}visitTerminal(t){console.log("consume "+t.symbol+" rule "+this.parser.ruleNames[this.parser._ctx.ruleIndex])}exitEveryRule(t){console.log("exit "+this.parser.ruleNames[t.ruleIndex]+", LT(1)="+this.parser._input.LT(1).text)}}class ke extends Rt{constructor(t){super(),this._input=null,this._errHandler=new _e,this._precedenceStack=[],this._precedenceStack.push(0),this._ctx=null,this.buildParseTrees=!0,this._tracer=null,this._parseListeners=null,this._syntaxErrors=0,this.setInputStream(t)}reset(){null!==this._input&&this._input.seek(0),this._errHandler.reset(this),this._ctx=null,this._syntaxErrors=0,this.setTrace(!1),this._precedenceStack=[],this._precedenceStack.push(0),null!==this._interp&&this._interp.reset()}match(t){let e=this.getCurrentToken();return e.type===t?(this._errHandler.reportMatch(this),this.consume()):(e=this._errHandler.recoverInline(this),this.buildParseTrees&&-1===e.tokenIndex&&this._ctx.addErrorNode(e)),e}matchWildcard(){let t=this.getCurrentToken();return t.type>0?(this._errHandler.reportMatch(this),this.consume()):(t=this._errHandler.recoverInline(this),this.buildParseTrees&&-1===t.tokenIndex&&this._ctx.addErrorNode(t)),t}getParseListeners(){return this._parseListeners||[]}addParseListener(t){if(null===t)throw"listener";null===this._parseListeners&&(this._parseListeners=[]),this._parseListeners.push(t)}removeParseListener(t){if(null!==this._parseListeners){const e=this._parseListeners.indexOf(t);e>=0&&this._parseListeners.splice(e,1),0===this._parseListeners.length&&(this._parseListeners=null)}}removeParseListeners(){this._parseListeners=null}triggerEnterRuleEvent(){if(null!==this._parseListeners){const t=this._ctx;this._parseListeners.forEach(function(e){e.enterEveryRule(t),t.enterRule(e)})}}triggerExitRuleEvent(){if(null!==this._parseListeners){const t=this._ctx;this._parseListeners.slice(0).reverse().forEach(function(e){t.exitRule(e),e.exitEveryRule(t)})}}getTokenFactory(){return this._input.tokenSource._factory}setTokenFactory(t){this._input.tokenSource._factory=t}getATNWithBypassAlts(){const t=this.getSerializedATN();if(null===t)throw"The current parser does not support an ATN with bypass alternatives.";let e=this.bypassAltsAtnCache[t];if(null===e){const r=new xt;r.generateRuleBypassTransitions=!0,e=new Nt(r).deserialize(t),this.bypassAltsAtnCache[t]=e}return e}getInputStream(){return this.getTokenStream()}setInputStream(t){this.setTokenStream(t)}getTokenStream(){return this._input}setTokenStream(t){this._input=null,this.reset(),this._input=t}get syntaxErrorsCount(){return this._syntaxErrors}getCurrentToken(){return this._input.LT(1)}notifyErrorListeners(t,e,r){r=r||null,null===(e=e||null)&&(e=this.getCurrentToken()),this._syntaxErrors+=1;const s=e.line,i=e.column;this.getErrorListener().syntaxError(this,e,s,i,t,r)}consume(){const t=this.getCurrentToken();t.type!==n.EOF&&this.getInputStream().consume();const e=null!==this._parseListeners&&this._parseListeners.length>0;if(this.buildParseTrees||e){let r;r=this._errHandler.inErrorRecoveryMode(this)?this._ctx.addErrorNode(t):this._ctx.addTokenNode(t),r.invokingState=this.state,e&&this._parseListeners.forEach(function(t){r instanceof F||void 0!==r.isErrorNode&&r.isErrorNode()?t.visitErrorNode(r):r instanceof D&&t.visitTerminal(r)})}return t}addContextToParseTree(){null!==this._ctx.parentCtx&&this._ctx.parentCtx.addChild(this._ctx)}enterRule(t,e,r){this.state=e,this._ctx=t,this._ctx.start=this._input.LT(1),this.buildParseTrees&&this.addContextToParseTree(),this.triggerEnterRuleEvent()}exitRule(){this._ctx.stop=this._input.LT(-1),this.triggerExitRuleEvent(),this.state=this._ctx.invokingState,this._ctx=this._ctx.parentCtx}enterOuterAlt(t,e){t.setAltNumber(e),this.buildParseTrees&&this._ctx!==t&&null!==this._ctx.parentCtx&&(this._ctx.parentCtx.removeLastChild(),this._ctx.parentCtx.addChild(t)),this._ctx=t}getPrecedence(){return 0===this._precedenceStack.length?-1:this._precedenceStack[this._precedenceStack.length-1]}enterRecursionRule(t,e,r,s){this.state=e,this._precedenceStack.push(s),this._ctx=t,this._ctx.start=this._input.LT(1),this.triggerEnterRuleEvent()}pushNewRecursionContext(t,e,r){const s=this._ctx;s.parentCtx=t,s.invokingState=e,s.stop=this._input.LT(-1),this._ctx=t,this._ctx.start=s.start,this.buildParseTrees&&this._ctx.addChild(s),this.triggerEnterRuleEvent()}unrollRecursionContexts(t){this._precedenceStack.pop(),this._ctx.stop=this._input.LT(-1);const e=this._ctx,r=this.getParseListeners();if(null!==r&&r.length>0)for(;this._ctx!==t;)this.triggerExitRuleEvent(),this._ctx=this._ctx.parentCtx;else this._ctx=t;e.parentCtx=t,this.buildParseTrees&&null!==t&&t.addChild(e)}getInvokingContext(t){let e=this._ctx;for(;null!==e;){if(e.ruleIndex===t)return e;e=e.parentCtx}return null}precpred(t,e){return e>=this._precedenceStack[this._precedenceStack.length-1]}inContext(t){return!1}isExpectedToken(t){const e=this._interp.atn;let r=this._ctx;const s=e.states[this.state];let i=e.nextTokens(s);if(i.contains(t))return!0;if(!i.contains(n.EPSILON))return!1;for(;null!==r&&r.invokingState>=0&&i.contains(n.EPSILON);){const s=e.states[r.invokingState].transitions[0];if(i=e.nextTokens(s.followState),i.contains(t))return!0;r=r.parentCtx}return!(!i.contains(n.EPSILON)||t!==n.EOF)}getExpectedTokens(){return this._interp.atn.getExpectedTokens(this.state,this._ctx)}getExpectedTokensWithinCurrentRule(){const t=this._interp.atn,e=t.states[this.state];return t.nextTokens(e)}getRuleIndex(t){const e=this.getRuleIndexMap()[t];return null!==e?e:-1}getRuleInvocationStack(t){null===(t=t||null)&&(t=this._ctx);const e=[];for(;null!==t;){const r=t.ruleIndex;r<0?e.push("n/a"):e.push(this.ruleNames[r]),t=t.parentCtx}return e}getDFAStrings(){return this._interp.decisionToDFA.toString()}dumpDFA(){let t=!1;for(let e=0;e<this._interp.decisionToDFA.length;e++){const r=this._interp.decisionToDFA[e];r.states.length>0&&(t&&console.log(),this.printer.println("Decision "+r.decision+":"),this.printer.print(r.toString(this.literalNames,this.symbolicNames)),t=!0)}}getSourceName(){return this._input.getSourceName()}setTrace(t){t?(null!==this._tracer&&this.removeParseListener(this._tracer),this._tracer=new Fe(this),this.addParseListener(this._tracer)):(this.removeParseListener(this._tracer),this._tracer=null)}}ke.bypassAltsAtnCache={};class Ve extends D{constructor(t){super(),this.parentCtx=null,this.symbol=t}getChild(t){return null}getSymbol(){return this.symbol}getParent(){return this.parentCtx}getPayload(){return this.symbol}getSourceInterval(){if(null===this.symbol)return S.INVALID_INTERVAL;const t=this.symbol.tokenIndex;return new S(t,t)}getChildCount(){return 0}accept(t){return t.visitTerminal(this)}getText(){return this.symbol.text}toString(){return this.symbol.type===n.EOF?"<EOF>":this.symbol.text}}class Ue extends Ve{constructor(t){super(t)}isErrorNode(){return!0}accept(t){return t.visitErrorNode(this)}}class Be extends U{constructor(t,e){super(t,e),this.children=null,this.start=null,this.stop=null,this.exception=null}copyFrom(t){this.parentCtx=t.parentCtx,this.invokingState=t.invokingState,this.children=null,this.start=t.start,this.stop=t.stop,t.children&&(this.children=[],t.children.map(function(t){t instanceof Ue&&(this.children.push(t),t.parentCtx=this)},this))}enterRule(t){}exitRule(t){}addChild(t){return null===this.children&&(this.children=[]),this.children.push(t),t}removeLastChild(){null!==this.children&&this.children.pop()}addTokenNode(t){const e=new Ve(t);return this.addChild(e),e.parentCtx=this,e}addErrorNode(t){const e=new Ue(t);return this.addChild(e),e.parentCtx=this,e}getChild(t,e){if(e=e||null,null===this.children||t<0||t>=this.children.length)return null;if(null===e)return this.children[t];for(let r=0;r<this.children.length;r++){const s=this.children[r];if(s instanceof e){if(0===t)return s;t-=1}}return null}getToken(t,e){if(null===this.children||e<0||e>=this.children.length)return null;for(let r=0;r<this.children.length;r++){const s=this.children[r];if(s instanceof D&&s.symbol.type===t){if(0===e)return s;e-=1}}return null}getTokens(t){if(null===this.children)return[];{const e=[];for(let r=0;r<this.children.length;r++){const s=this.children[r];s instanceof D&&s.symbol.type===t&&e.push(s)}return e}}getTypedRuleContext(t,e){return this.getChild(e,t)}getTypedRuleContexts(t){if(null===this.children)return[];{const e=[];for(let r=0;r<this.children.length;r++){const s=this.children[r];s instanceof t&&e.push(s)}return e}}getChildCount(){return null===this.children?0:this.children.length}getSourceInterval(){return null===this.start||null===this.stop?S.INVALID_INTERVAL:new S(this.start.tokenIndex,this.stop.tokenIndex)}}U.EMPTY=new Be;class $e{static DEFAULT_PROGRAM_NAME="default";constructor(t){this.tokens=t,this.programs=new Map}getTokenStream(){return this.tokens}insertAfter(t,e){let r,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:$e.DEFAULT_PROGRAM_NAME;r="number"==typeof t?t:t.tokenIndex;let i=this.getProgram(s),n=new Je(this.tokens,r,i.length,e);i.push(n)}insertBefore(t,e){let r,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:$e.DEFAULT_PROGRAM_NAME;r="number"==typeof t?t:t.tokenIndex;const i=this.getProgram(s),n=new qe(this.tokens,r,i.length,e);i.push(n)}replaceSingle(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:$e.DEFAULT_PROGRAM_NAME;this.replace(t,t,e,r)}replace(t,e,r){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:$e.DEFAULT_PROGRAM_NAME;if("number"!=typeof t&&(t=t.tokenIndex),"number"!=typeof e&&(e=e.tokenIndex),t>e||t<0||e<0||e>=this.tokens.size)throw new RangeError(`replace: range invalid: ${t}..${e}(size=${this.tokens.size})`);let i=this.getProgram(s),n=new je(this.tokens,t,e,i.length,r);i.push(n)}delete(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:$e.DEFAULT_PROGRAM_NAME;void 0===e&&(e=t),this.replace(t,e,null,r)}getProgram(t){let e=this.programs.get(t);return null==e&&(e=this.initializeProgram(t)),e}initializeProgram(t){const e=[];return this.programs.set(t,e),e}getText(t){let e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:$e.DEFAULT_PROGRAM_NAME;e=t instanceof S?t:new S(0,this.tokens.size-1),"string"==typeof t&&(r=t);const s=this.programs.get(r);let i=e.start,a=e.stop;if(a>this.tokens.size-1&&(a=this.tokens.size-1),i<0&&(i=0),null==s||0===s.length)return this.tokens.getText(new S(i,a));let o=[],l=this.reduceToSingleOperationPerIndex(s),c=i;for(;c<=a&&c<this.tokens.size;){let t=l.get(c);l.delete(c);let e=this.tokens.get(c);null==t?(e.type!==n.EOF&&o.push(String(e.text)),c++):c=t.execute(o)}if(a===this.tokens.size-1)for(const t of l.values())t.index>=this.tokens.size-1&&o.push(t.text.toString());return o.join("")}reduceToSingleOperationPerIndex(t){for(let e=0;e<t.length;e++){let r=t[e];if(null==r)continue;if(!(r instanceof je))continue;let s=r,i=this.getKindOfOps(t,qe,e);for(let e of i)e.index===s.index?(t[e.instructionIndex]=void 0,s.text=e.text.toString()+(null!=s.text?s.text.toString():"")):e.index>s.index&&e.index<=s.lastIndex&&(t[e.instructionIndex]=void 0);let n=this.getKindOfOps(t,je,e);for(let e of n){if(e.index>=s.index&&e.lastIndex<=s.lastIndex){t[e.instructionIndex]=void 0;continue}let r=e.lastIndex<s.index||e.index>s.lastIndex;if(null!=e.text||null!=s.text||r){if(!r)throw new Error(`replace op boundaries of ${s} overlap with previous ${e}`)}else t[e.instructionIndex]=void 0,s.index=Math.min(e.index,s.index),s.lastIndex=Math.max(e.lastIndex,s.lastIndex)}}for(let e=0;e<t.length;e++){let r=t[e];if(null==r)continue;if(!(r instanceof qe))continue;let s=r,i=this.getKindOfOps(t,qe,e);for(let e of i)e.index===s.index&&(e instanceof Je?(s.text=this.catOpText(e.text,s.text),t[e.instructionIndex]=void 0):e instanceof qe&&(s.text=this.catOpText(s.text,e.text),t[e.instructionIndex]=void 0));let n=this.getKindOfOps(t,je,e);for(let r of n)if(s.index!==r.index){if(s.index>=r.index&&s.index<=r.lastIndex)throw new Error(`insert op ${s} within boundaries of previous ${r}`)}else r.text=this.catOpText(s.text,r.text),t[e]=void 0}let e=new Map;for(let r of t)if(null!=r){if(null!=e.get(r.index))throw new Error("should only be one op per index");e.set(r.index,r)}return e}catOpText(t,e){let r="",s="";return null!=t&&(r=t.toString()),null!=e&&(s=e.toString()),r+s}getKindOfOps(t,e,r){return t.slice(0,r).filter(t=>t&&t instanceof e)}}class He{constructor(t,e,r,s){this.tokens=t,this.instructionIndex=r,this.index=e,this.text=void 0===s?"":s}toString(){let t=this.constructor.name;const e=t.indexOf("$");return t=t.substring(e+1,t.length),"<"+t+"@"+this.tokens.get(this.index)+':"'+this.text+'">'}}class qe extends He{constructor(t,e,r,s){super(t,e,r,s)}execute(t){return this.text&&t.push(this.text.toString()),this.tokens.get(this.index).type!==n.EOF&&t.push(String(this.tokens.get(this.index).text)),this.index+1}}class Je extends qe{constructor(t,e,r,s){super(t,e+1,r,s)}}class je extends He{constructor(t,e,r,s,i){super(t,e,s,i),this.lastIndex=r}execute(t){return this.text&&t.push(this.text.toString()),this.lastIndex+1}toString(){return null==this.text?"<DeleteOp@"+this.tokens.get(this.index)+".."+this.tokens.get(this.lastIndex)+">":"<ReplaceOp@"+this.tokens.get(this.index)+".."+this.tokens.get(this.lastIndex)+':"'+this.text+'">'}}const ze={atn:ae,dfa:ue,context:he,misc:de,tree:ge,error:Me,Token:n,CommonToken:Pt,CharStreams:we,CharStream:Te,InputStream:ve,FileStream:Ie,CommonTokenStream:De,Lexer:Ut,Parser:ke,ParserRuleContext:Be,Interval:S,IntervalSet:E,LL1Analyzer:K,Utils:Oe,TokenStreamRewriter:$e};var Ge=i.MG,We=i.fr,Ke=i.iH,Qe=i.jB,Xe=i.M8,Ze=i.pG,Ye=i.eP,tr=i.JG,er=i.ay,rr=i.X2,sr=i.iX,ir=i.re,nr=i.Pg,ar=i.tD,or=i.Dj,lr=i.ou}};const __webpack_module_cache__={};function __webpack_require__(t){const e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;const r=__webpack_module_cache__[t]={exports:{}};return __webpack_modules__[t](r,r.exports,__webpack_require__),r.exports}__webpack_require__.d=(t,e)=>{if(Array.isArray(e))for(var r=0;r<e.length;){var s=e[r++],i=e[r++];__webpack_require__.o(t,s)?0===i&&r++:0===i?Object.defineProperty(t,s,{enumerable:!0,value:e[r++]}):Object.defineProperty(t,s,{enumerable:!0,get:i})}else for(var s in e)__webpack_require__.o(e,s)&&!__webpack_require__.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},__webpack_require__.o=(t,e)=>Object.hasOwn(t,e);var EXP_LIMIT=9e15,MAX_DIGITS=1e9,NUMERALS="0123456789abcdef",LN10="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",PI="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",DEFAULTS={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-EXP_LIMIT,maxE:EXP_LIMIT,crypto:!1},inexact,quadrant,external=!0,decimalError="[DecimalError] ",invalidArgument=decimalError+"Invalid argument: ",precisionLimitExceeded=decimalError+"Precision limit exceeded",cryptoUnavailable=decimalError+"crypto unavailable",tag="[object Decimal]",mathfloor=Math.floor,mathpow=Math.pow,isBinary=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,isHex=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,isOctal=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,isDecimal=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,BASE=1e7,LOG_BASE=7,MAX_SAFE_INTEGER=9007199254740991,LN10_PRECISION=LN10.length-1,PI_PRECISION=PI.length-1,P={toStringTag:tag};function digitsToString(t){var e,r,s,i=t.length-1,n="",a=t[0];if(i>0){for(n+=a,e=1;e<i;e++)s=t[e]+"",(r=LOG_BASE-s.length)&&(n+=getZeroString(r)),n+=s;a=t[e],(r=LOG_BASE-(s=a+"").length)&&(n+=getZeroString(r))}else if(0===a)return"0";for(;a%10==0;)a/=10;return n+a}function checkInt32(t,e,r){if(t!==~~t||t<e||t>r)throw Error(invalidArgument+t)}function checkRoundingDigits(t,e,r,s){var i,n,a,o;for(n=t[0];n>=10;n/=10)--e;return--e<0?(e+=LOG_BASE,i=0):(i=Math.ceil((e+1)/LOG_BASE),e%=LOG_BASE),n=mathpow(10,LOG_BASE-e),o=t[i]%n|0,null==s?e<3?(0==e?o=o/100|0:1==e&&(o=o/10|0),a=r<4&&99999==o||r>3&&49999==o||5e4==o||0==o):a=(r<4&&o+1==n||r>3&&o+1==n/2)&&(t[i+1]/n/100|0)==mathpow(10,e-2)-1||(o==n/2||0==o)&&!(t[i+1]/n/100|0):e<4?(0==e?o=o/1e3|0:1==e?o=o/100|0:2==e&&(o=o/10|0),a=(s||r<4)&&9999==o||!s&&r>3&&4999==o):a=((s||r<4)&&o+1==n||!s&&r>3&&o+1==n/2)&&(t[i+1]/n/1e3|0)==mathpow(10,e-3)-1,a}function convertBase(t,e,r){for(var s,i,n=[0],a=0,o=t.length;a<o;){for(i=n.length;i--;)n[i]*=e;for(n[0]+=NUMERALS.indexOf(t.charAt(a++)),s=0;s<n.length;s++)n[s]>r-1&&(void 0===n[s+1]&&(n[s+1]=0),n[s+1]+=n[s]/r|0,n[s]%=r)}return n.reverse()}function cosine(t,e){var r,s,i;if(e.isZero())return e;(s=e.d.length)<32?i=(1/tinyPow(4,r=Math.ceil(s/3))).toString():(r=16,i="2.3283064365386962890625e-10"),t.precision+=r,e=taylorSeries(t,1,e.times(i),new t(1));for(var n=r;n--;){var a=e.times(e);e=a.times(a).minus(a).times(8).plus(1)}return t.precision-=r,e}P.absoluteValue=P.abs=function(){var t=new this.constructor(this);return t.s<0&&(t.s=1),finalise(t)},P.ceil=function(){return finalise(new this.constructor(this),this.e+1,2)},P.clampedTo=P.clamp=function(t,e){var r=this,s=r.constructor;if(t=new s(t),e=new s(e),!t.s||!e.s)return new s(NaN);if(t.gt(e))throw Error(invalidArgument+e);return r.cmp(t)<0?t:r.cmp(e)>0?e:new s(r)},P.comparedTo=P.cmp=function(t){var e,r,s,i,n=this,a=n.d,o=(t=new n.constructor(t)).d,l=n.s,c=t.s;if(!a||!o)return l&&c?l!==c?l:a===o?0:!a^l<0?1:-1:NaN;if(!a[0]||!o[0])return a[0]?l:o[0]?-c:0;if(l!==c)return l;if(n.e!==t.e)return n.e>t.e^l<0?1:-1;for(e=0,r=(s=a.length)<(i=o.length)?s:i;e<r;++e)if(a[e]!==o[e])return a[e]>o[e]^l<0?1:-1;return s===i?0:s>i^l<0?1:-1},P.cosine=P.cos=function(){var t,e,r=this,s=r.constructor;return r.d?r.d[0]?(t=s.precision,e=s.rounding,s.precision=t+Math.max(r.e,r.sd())+LOG_BASE,s.rounding=1,r=cosine(s,toLessThanHalfPi(s,r)),s.precision=t,s.rounding=e,finalise(2==quadrant||3==quadrant?r.neg():r,t,e,!0)):new s(1):new s(NaN)},P.cubeRoot=P.cbrt=function(){var t,e,r,s,i,n,a,o,l,c,u=this,h=u.constructor;if(!u.isFinite()||u.isZero())return new h(u);for(external=!1,(n=u.s*mathpow(u.s*u,1/3))&&Math.abs(n)!=1/0?s=new h(n.toString()):(r=digitsToString(u.d),(n=((t=u.e)-r.length+1)%3)&&(r+=1==n||-2==n?"0":"00"),n=mathpow(r,1/3),t=mathfloor((t+1)/3)-(t%3==(t<0?-1:2)),(s=new h(r=n==1/0?"5e"+t:(r=n.toExponential()).slice(0,r.indexOf("e")+1)+t)).s=u.s),a=(t=h.precision)+3;;)if(c=(l=(o=s).times(o).times(o)).plus(u),s=divide(c.plus(u).times(o),c.plus(l),a+2,1),digitsToString(o.d).slice(0,a)===(r=digitsToString(s.d)).slice(0,a)){if("9999"!=(r=r.slice(a-3,a+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(finalise(s,t+1,1),e=!s.times(s).times(s).eq(u));break}if(!i&&(finalise(o,t+1,0),o.times(o).times(o).eq(u))){s=o;break}a+=4,i=1}return external=!0,finalise(s,t,h.rounding,e)},P.decimalPlaces=P.dp=function(){var t,e=this.d,r=NaN;if(e){if(r=((t=e.length-1)-mathfloor(this.e/LOG_BASE))*LOG_BASE,t=e[t])for(;t%10==0;t/=10)r--;r<0&&(r=0)}return r},P.dividedBy=P.div=function(t){return divide(this,new this.constructor(t))},P.dividedToIntegerBy=P.divToInt=function(t){var e=this.constructor;return finalise(divide(this,new e(t),0,1,1),e.precision,e.rounding)},P.equals=P.eq=function(t){return 0===this.cmp(t)},P.floor=function(){return finalise(new this.constructor(this),this.e+1,3)},P.greaterThan=P.gt=function(t){return this.cmp(t)>0},P.greaterThanOrEqualTo=P.gte=function(t){var e=this.cmp(t);return 1==e||0===e},P.hyperbolicCosine=P.cosh=function(){var t,e,r,s,i,n=this,a=n.constructor,o=new a(1);if(!n.isFinite())return new a(n.s?1/0:NaN);if(n.isZero())return o;r=a.precision,s=a.rounding,a.precision=r+Math.max(n.e,n.sd())+4,a.rounding=1,(i=n.d.length)<32?e=(1/tinyPow(4,t=Math.ceil(i/3))).toString():(t=16,e="2.3283064365386962890625e-10"),n=taylorSeries(a,1,n.times(e),new a(1),!0);for(var l,c=t,u=new a(8);c--;)l=n.times(n),n=o.minus(l.times(u.minus(l.times(u))));return finalise(n,a.precision=r,a.rounding=s,!0)},P.hyperbolicSine=P.sinh=function(){var t,e,r,s,i=this,n=i.constructor;if(!i.isFinite()||i.isZero())return new n(i);if(e=n.precision,r=n.rounding,n.precision=e+Math.max(i.e,i.sd())+4,n.rounding=1,(s=i.d.length)<3)i=taylorSeries(n,2,i,i,!0);else{t=(t=1.4*Math.sqrt(s))>16?16:0|t,i=taylorSeries(n,2,i=i.times(1/tinyPow(5,t)),i,!0);for(var a,o=new n(5),l=new n(16),c=new n(20);t--;)a=i.times(i),i=i.times(o.plus(a.times(l.times(a).plus(c))))}return n.precision=e,n.rounding=r,finalise(i,e,r,!0)},P.hyperbolicTangent=P.tanh=function(){var t,e,r=this,s=r.constructor;return r.isFinite()?r.isZero()?new s(r):(t=s.precision,e=s.rounding,s.precision=t+7,s.rounding=1,divide(r.sinh(),r.cosh(),s.precision=t,s.rounding=e)):new s(r.s)},P.inverseCosine=P.acos=function(){var t=this,e=t.constructor,r=t.abs().cmp(1),s=e.precision,i=e.rounding;return-1!==r?0===r?t.isNeg()?getPi(e,s,i):new e(0):new e(NaN):t.isZero()?getPi(e,s+4,i).times(.5):(e.precision=s+6,e.rounding=1,t=new e(1).minus(t).div(t.plus(1)).sqrt().atan(),e.precision=s,e.rounding=i,t.times(2))},P.inverseHyperbolicCosine=P.acosh=function(){var t,e,r=this,s=r.constructor;return r.lte(1)?new s(r.eq(1)?0:NaN):r.isFinite()?(t=s.precision,e=s.rounding,s.precision=t+Math.max(Math.abs(r.e),r.sd())+4,s.rounding=1,external=!1,r=r.times(r).minus(1).sqrt().plus(r),external=!0,s.precision=t,s.rounding=e,r.ln()):new s(r)},P.inverseHyperbolicSine=P.asinh=function(){var t,e,r=this,s=r.constructor;return!r.isFinite()||r.isZero()?new s(r):(t=s.precision,e=s.rounding,s.precision=t+2*Math.max(Math.abs(r.e),r.sd())+6,s.rounding=1,external=!1,r=r.times(r).plus(1).sqrt().plus(r),external=!0,s.precision=t,s.rounding=e,r.ln())},P.inverseHyperbolicTangent=P.atanh=function(){var t,e,r,s,i=this,n=i.constructor;return i.isFinite()?i.e>=0?new n(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(t=n.precision,e=n.rounding,s=i.sd(),Math.max(s,t)<2*-i.e-1?finalise(new n(i),t,e,!0):(n.precision=r=s-i.e,i=divide(i.plus(1),new n(1).minus(i),r+t,1),n.precision=t+4,n.rounding=1,i=i.ln(),n.precision=t,n.rounding=e,i.times(.5))):new n(NaN)},P.inverseSine=P.asin=function(){var t,e,r,s,i=this,n=i.constructor;return i.isZero()?new n(i):(e=i.abs().cmp(1),r=n.precision,s=n.rounding,-1!==e?0===e?((t=getPi(n,r+4,s).times(.5)).s=i.s,t):new n(NaN):(n.precision=r+6,n.rounding=1,i=i.div(new n(1).minus(i.times(i)).sqrt().plus(1)).atan(),n.precision=r,n.rounding=s,i.times(2)))},P.inverseTangent=P.atan=function(){var t,e,r,s,i,n,a,o,l,c=this,u=c.constructor,h=u.precision,d=u.rounding;if(c.isFinite()){if(c.isZero())return new u(c);if(c.abs().eq(1)&&h+4<=PI_PRECISION)return(a=getPi(u,h+4,d).times(.25)).s=c.s,a}else{if(!c.s)return new u(NaN);if(h+4<=PI_PRECISION)return(a=getPi(u,h+4,d).times(.5)).s=c.s,a}for(u.precision=o=h+10,u.rounding=1,t=r=Math.min(28,o/LOG_BASE+2|0);t;--t)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(external=!1,e=Math.ceil(o/LOG_BASE),s=1,l=c.times(c),a=new u(c),i=c;-1!==t;)if(i=i.times(l),n=a.minus(i.div(s+=2)),i=i.times(l),void 0!==(a=n.plus(i.div(s+=2))).d[e])for(t=e;a.d[t]===n.d[t]&&t--;);return r&&(a=a.times(2<<r-1)),external=!0,finalise(a,u.precision=h,u.rounding=d,!0)},P.isFinite=function(){return!!this.d},P.isInteger=P.isInt=function(){return!!this.d&&mathfloor(this.e/LOG_BASE)>this.d.length-2},P.isNaN=function(){return!this.s},P.isNegative=P.isNeg=function(){return this.s<0},P.isPositive=P.isPos=function(){return this.s>0},P.isZero=function(){return!!this.d&&0===this.d[0]},P.lessThan=P.lt=function(t){return this.cmp(t)<0},P.lessThanOrEqualTo=P.lte=function(t){return this.cmp(t)<1},P.logarithm=P.log=function(t){var e,r,s,i,n,a,o,l,c=this,u=c.constructor,h=u.precision,d=u.rounding;if(null==t)t=new u(10),e=!0;else{if(r=(t=new u(t)).d,t.s<0||!r||!r[0]||t.eq(1))return new u(NaN);e=t.eq(10)}if(r=c.d,c.s<0||!r||!r[0]||c.eq(1))return new u(r&&!r[0]?-1/0:1!=c.s?NaN:r?0:1/0);if(e)if(r.length>1)n=!0;else{for(i=r[0];i%10==0;)i/=10;n=1!==i}if(external=!1,a=naturalLogarithm(c,o=h+5),s=e?getLn10(u,o+10):naturalLogarithm(t,o),checkRoundingDigits((l=divide(a,s,o,1)).d,i=h,d))do{if(a=naturalLogarithm(c,o+=10),s=e?getLn10(u,o+10):naturalLogarithm(t,o),l=divide(a,s,o,1),!n){+digitsToString(l.d).slice(i+1,i+15)+1==1e14&&(l=finalise(l,h+1,0));break}}while(checkRoundingDigits(l.d,i+=10,d));return external=!0,finalise(l,h,d)},P.minus=P.sub=function(t){var e,r,s,i,n,a,o,l,c,u,h,d,m=this,p=m.constructor;if(t=new p(t),!m.d||!t.d)return m.s&&t.s?m.d?t.s=-t.s:t=new p(t.d||m.s!==t.s?m:NaN):t=new p(NaN),t;if(m.s!=t.s)return t.s=-t.s,m.plus(t);if(c=m.d,d=t.d,o=p.precision,l=p.rounding,!c[0]||!d[0]){if(d[0])t.s=-t.s;else{if(!c[0])return new p(3===l?-0:0);t=new p(m)}return external?finalise(t,o,l):t}if(r=mathfloor(t.e/LOG_BASE),u=mathfloor(m.e/LOG_BASE),c=c.slice(),n=u-r){for((h=n<0)?(e=c,n=-n,a=d.length):(e=d,r=u,a=c.length),n>(s=Math.max(Math.ceil(o/LOG_BASE),a)+2)&&(n=s,e.length=1),e.reverse(),s=n;s--;)e.push(0);e.reverse()}else{for((h=(s=c.length)<(a=d.length))&&(a=s),s=0;s<a;s++)if(c[s]!=d[s]){h=c[s]<d[s];break}n=0}for(h&&(e=c,c=d,d=e,t.s=-t.s),a=c.length,s=d.length-a;s>0;--s)c[a++]=0;for(s=d.length;s>n;){if(c[--s]<d[s]){for(i=s;i&&0===c[--i];)c[i]=BASE-1;--c[i],c[s]+=BASE}c[s]-=d[s]}for(;0===c[--a];)c.pop();for(;0===c[0];c.shift())--r;return c[0]?(t.d=c,t.e=getBase10Exponent(c,r),external?finalise(t,o,l):t):new p(3===l?-0:0)},P.modulo=P.mod=function(t){var e,r=this,s=r.constructor;return t=new s(t),!r.d||!t.s||t.d&&!t.d[0]?new s(NaN):!t.d||r.d&&!r.d[0]?finalise(new s(r),s.precision,s.rounding):(external=!1,9==s.modulo?(e=divide(r,t.abs(),0,3,1)).s*=t.s:e=divide(r,t,0,s.modulo,1),e=e.times(t),external=!0,r.minus(e))},P.naturalExponential=P.exp=function(){return naturalExponential(this)},P.naturalLogarithm=P.ln=function(){return naturalLogarithm(this)},P.negated=P.neg=function(){var t=new this.constructor(this);return t.s=-t.s,finalise(t)},P.plus=P.add=function(t){var e,r,s,i,n,a,o,l,c,u,h=this,d=h.constructor;if(t=new d(t),!h.d||!t.d)return h.s&&t.s?h.d||(t=new d(t.d||h.s===t.s?h:NaN)):t=new d(NaN),t;if(h.s!=t.s)return t.s=-t.s,h.minus(t);if(c=h.d,u=t.d,o=d.precision,l=d.rounding,!c[0]||!u[0])return u[0]||(t=new d(h)),external?finalise(t,o,l):t;if(n=mathfloor(h.e/LOG_BASE),s=mathfloor(t.e/LOG_BASE),c=c.slice(),i=n-s){for(i<0?(r=c,i=-i,a=u.length):(r=u,s=n,a=c.length),i>(a=(n=Math.ceil(o/LOG_BASE))>a?n+1:a+1)&&(i=a,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for((a=c.length)-(i=u.length)<0&&(i=a,r=u,u=c,c=r),e=0;i;)e=(c[--i]=c[i]+u[i]+e)/BASE|0,c[i]%=BASE;for(e&&(c.unshift(e),++s),a=c.length;0==c[--a];)c.pop();return t.d=c,t.e=getBase10Exponent(c,s),external?finalise(t,o,l):t},P.precision=P.sd=function(t){var e,r=this;if(void 0!==t&&t!==!!t&&1!==t&&0!==t)throw Error(invalidArgument+t);return r.d?(e=getPrecision(r.d),t&&r.e+1>e&&(e=r.e+1)):e=NaN,e},P.round=function(){var t=this,e=t.constructor;return finalise(new e(t),t.e+1,e.rounding)},P.sine=P.sin=function(){var t,e,r=this,s=r.constructor;return r.isFinite()?r.isZero()?new s(r):(t=s.precision,e=s.rounding,s.precision=t+Math.max(r.e,r.sd())+LOG_BASE,s.rounding=1,r=sine(s,toLessThanHalfPi(s,r)),s.precision=t,s.rounding=e,finalise(quadrant>2?r.neg():r,t,e,!0)):new s(NaN)},P.squareRoot=P.sqrt=function(){var t,e,r,s,i,n,a=this,o=a.d,l=a.e,c=a.s,u=a.constructor;if(1!==c||!o||!o[0])return new u(!c||c<0&&(!o||o[0])?NaN:o?a:1/0);for(external=!1,0==(c=Math.sqrt(+a))||c==1/0?(((e=digitsToString(o)).length+l)%2==0&&(e+="0"),c=Math.sqrt(e),l=mathfloor((l+1)/2)-(l<0||l%2),s=new u(e=c==1/0?"5e"+l:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+l)):s=new u(c.toString()),r=(l=u.precision)+3;;)if(s=(n=s).plus(divide(a,n,r+2,1)).times(.5),digitsToString(n.d).slice(0,r)===(e=digitsToString(s.d)).slice(0,r)){if("9999"!=(e=e.slice(r-3,r+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(finalise(s,l+1,1),t=!s.times(s).eq(a));break}if(!i&&(finalise(n,l+1,0),n.times(n).eq(a))){s=n;break}r+=4,i=1}return external=!0,finalise(s,l,u.rounding,t)},P.tangent=P.tan=function(){var t,e,r=this,s=r.constructor;return r.isFinite()?r.isZero()?new s(r):(t=s.precision,e=s.rounding,s.precision=t+10,s.rounding=1,(r=r.sin()).s=1,r=divide(r,new s(1).minus(r.times(r)).sqrt(),t+10,0),s.precision=t,s.rounding=e,finalise(2==quadrant||4==quadrant?r.neg():r,t,e,!0)):new s(NaN)},P.times=P.mul=function(t){var e,r,s,i,n,a,o,l,c,u=this,h=u.constructor,d=u.d,m=(t=new h(t)).d;if(t.s*=u.s,!(d&&d[0]&&m&&m[0]))return new h(!t.s||d&&!d[0]&&!m||m&&!m[0]&&!d?NaN:d&&m?0*t.s:t.s/0);for(r=mathfloor(u.e/LOG_BASE)+mathfloor(t.e/LOG_BASE),(l=d.length)<(c=m.length)&&(n=d,d=m,m=n,a=l,l=c,c=a),n=[],s=a=l+c;s--;)n.push(0);for(s=c;--s>=0;){for(e=0,i=l+s;i>s;)o=n[i]+m[s]*d[i-s-1]+e,n[i--]=o%BASE|0,e=o/BASE|0;n[i]=(n[i]+e)%BASE|0}for(;!n[--a];)n.pop();return e?++r:n.shift(),t.d=n,t.e=getBase10Exponent(n,r),external?finalise(t,h.precision,h.rounding):t},P.toBinary=function(t,e){return toStringBinary(this,2,t,e)},P.toDecimalPlaces=P.toDP=function(t,e){var r=this,s=r.constructor;return r=new s(r),void 0===t?r:(checkInt32(t,0,MAX_DIGITS),void 0===e?e=s.rounding:checkInt32(e,0,8),finalise(r,t+r.e+1,e))},P.toExponential=function(t,e){var r,s=this,i=s.constructor;return void 0===t?r=finiteToString(s,!0):(checkInt32(t,0,MAX_DIGITS),void 0===e?e=i.rounding:checkInt32(e,0,8),r=finiteToString(s=finalise(new i(s),t+1,e),!0,t+1)),s.isNeg()&&!s.isZero()?"-"+r:r},P.toFixed=function(t,e){var r,s,i=this,n=i.constructor;return void 0===t?r=finiteToString(i):(checkInt32(t,0,MAX_DIGITS),void 0===e?e=n.rounding:checkInt32(e,0,8),r=finiteToString(s=finalise(new n(i),t+i.e+1,e),!1,t+s.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r},P.toFraction=function(t){var e,r,s,i,n,a,o,l,c,u,h,d,m=this,p=m.d,f=m.constructor;if(!p)return new f(m);if(c=r=new f(1),s=l=new f(0),a=(n=(e=new f(s)).e=getPrecision(p)-m.e-1)%LOG_BASE,e.d[0]=mathpow(10,a<0?LOG_BASE+a:a),null==t)t=n>0?e:c;else{if(!(o=new f(t)).isInt()||o.lt(c))throw Error(invalidArgument+o);t=o.gt(e)?n>0?e:c:o}for(external=!1,o=new f(digitsToString(p)),u=f.precision,f.precision=n=p.length*LOG_BASE*2;h=divide(o,e,0,1,1),1!=(i=r.plus(h.times(s))).cmp(t);)r=s,s=i,i=c,c=l.plus(h.times(i)),l=i,i=e,e=o.minus(h.times(i)),o=i;return i=divide(t.minus(r),s,0,1,1),l=l.plus(i.times(c)),r=r.plus(i.times(s)),l.s=c.s=m.s,d=divide(c,s,n,1).minus(m).abs().cmp(divide(l,r,n,1).minus(m).abs())<1?[c,s]:[l,r],f.precision=u,external=!0,d},P.toHexadecimal=P.toHex=function(t,e){return toStringBinary(this,16,t,e)},P.toNearest=function(t,e){var r=this,s=r.constructor;if(r=new s(r),null==t){if(!r.d)return r;t=new s(1),e=s.rounding}else{if(t=new s(t),void 0===e?e=s.rounding:checkInt32(e,0,8),!r.d)return t.s?r:t;if(!t.d)return t.s&&(t.s=r.s),t}return t.d[0]?(external=!1,r=divide(r,t,0,e,1).times(t),external=!0,finalise(r)):(t.s=r.s,r=t),r},P.toNumber=function(){return+this},P.toOctal=function(t,e){return toStringBinary(this,8,t,e)},P.toPower=P.pow=function(t){var e,r,s,i,n,a,o=this,l=o.constructor,c=+(t=new l(t));if(!(o.d&&t.d&&o.d[0]&&t.d[0]))return new l(mathpow(+o,c));if((o=new l(o)).eq(1))return o;if(s=l.precision,n=l.rounding,t.eq(1))return finalise(o,s,n);if((e=mathfloor(t.e/LOG_BASE))>=t.d.length-1&&(r=c<0?-c:c)<=MAX_SAFE_INTEGER)return i=intPow(l,o,r,s),t.s<0?new l(1).div(i):finalise(i,s,n);if((a=o.s)<0){if(e<t.d.length-1)return new l(NaN);if(1&t.d[e]||(a=1),0==o.e&&1==o.d[0]&&1==o.d.length)return o.s=a,o}return(e=0!=(r=mathpow(+o,c))&&isFinite(r)?new l(r+"").e:mathfloor(c*(Math.log("0."+digitsToString(o.d))/Math.LN10+o.e+1)))>l.maxE+1||e<l.minE-1?new l(e>0?a/0:0):(external=!1,l.rounding=o.s=1,r=Math.min(12,(e+"").length),(i=naturalExponential(t.times(naturalLogarithm(o,s+r)),s)).d&&checkRoundingDigits((i=finalise(i,s+5,1)).d,s,n)&&(e=s+10,+digitsToString((i=finalise(naturalExponential(t.times(naturalLogarithm(o,e+r)),e),e+5,1)).d).slice(s+1,s+15)+1==1e14&&(i=finalise(i,s+1,0))),i.s=a,external=!0,l.rounding=n,finalise(i,s,n))},P.toPrecision=function(t,e){var r,s=this,i=s.constructor;return void 0===t?r=finiteToString(s,s.e<=i.toExpNeg||s.e>=i.toExpPos):(checkInt32(t,1,MAX_DIGITS),void 0===e?e=i.rounding:checkInt32(e,0,8),r=finiteToString(s=finalise(new i(s),t,e),t<=s.e||s.e<=i.toExpNeg,t)),s.isNeg()&&!s.isZero()?"-"+r:r},P.toSignificantDigits=P.toSD=function(t,e){var r=this.constructor;return void 0===t?(t=r.precision,e=r.rounding):(checkInt32(t,1,MAX_DIGITS),void 0===e?e=r.rounding:checkInt32(e,0,8)),finalise(new r(this),t,e)},P.toString=function(){var t=this,e=t.constructor,r=finiteToString(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()&&!t.isZero()?"-"+r:r},P.truncated=P.trunc=function(){return finalise(new this.constructor(this),this.e+1,1)},P.valueOf=P.toJSON=function(){var t=this,e=t.constructor,r=finiteToString(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()?"-"+r:r};var divide=function(){function t(t,e,r){var s,i=0,n=t.length;for(t=t.slice();n--;)s=t[n]*e+i,t[n]=s%r|0,i=s/r|0;return i&&t.unshift(i),t}function e(t,e,r,s){var i,n;if(r!=s)n=r>s?1:-1;else for(i=n=0;i<r;i++)if(t[i]!=e[i]){n=t[i]>e[i]?1:-1;break}return n}function r(t,e,r,s){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*s+t[r]-e[r];for(;!t[0]&&t.length>1;)t.shift()}return function(s,i,n,a,o,l){var c,u,h,d,m,p,f,g,y,x,C,A,S,E,_,b,M,T,v,L,N=s.constructor,I=s.s==i.s?1:-1,w=s.d,O=i.d;if(!(w&&w[0]&&O&&O[0]))return new N(s.s&&i.s&&(w?!O||w[0]!=O[0]:O)?w&&0==w[0]||!O?0*I:I/0:NaN);for(l?(m=1,u=s.e-i.e):(l=BASE,m=LOG_BASE,u=mathfloor(s.e/m)-mathfloor(i.e/m)),v=O.length,M=w.length,x=(y=new N(I)).d=[],h=0;O[h]==(w[h]||0);h++);if(O[h]>(w[h]||0)&&u--,null==n?(E=n=N.precision,a=N.rounding):E=o?n+(s.e-i.e)+1:n,E<0)x.push(1),p=!0;else{if(E=E/m+2|0,h=0,1==v){for(d=0,O=O[0],E++;(h<M||d)&&E--;h++)_=d*l+(w[h]||0),x[h]=_/O|0,d=_%O|0;p=d||h<M}else{for((d=l/(O[0]+1)|0)>1&&(O=t(O,d,l),w=t(w,d,l),v=O.length,M=w.length),b=v,A=(C=w.slice(0,v)).length;A<v;)C[A++]=0;(L=O.slice()).unshift(0),T=O[0],O[1]>=l/2&&++T;do{d=0,(c=e(O,C,v,A))<0?(S=C[0],v!=A&&(S=S*l+(C[1]||0)),(d=S/T|0)>1?(d>=l&&(d=l-1),1==(c=e(f=t(O,d,l),C,g=f.length,A=C.length))&&(d--,r(f,v<g?L:O,g,l))):(0==d&&(c=d=1),f=O.slice()),(g=f.length)<A&&f.unshift(0),r(C,f,A,l),-1==c&&(c=e(O,C,v,A=C.length))<1&&(d++,r(C,v<A?L:O,A,l)),A=C.length):0===c&&(d++,C=[0]),x[h++]=d,c&&C[0]?C[A++]=w[b]||0:(C=[w[b]],A=1)}while((b++<M||void 0!==C[0])&&E--);p=void 0!==C[0]}x[0]||x.shift()}if(1==m)y.e=u,inexact=p;else{for(h=1,d=x[0];d>=10;d/=10)h++;y.e=h+u*m-1,finalise(y,o?n+y.e+1:n,a,p)}return y}}();function finalise(t,e,r,s){var i,n,a,o,l,c,u,h,d,m=t.constructor;t:if(null!=e){if(!(h=t.d))return t;for(i=1,o=h[0];o>=10;o/=10)i++;if((n=e-i)<0)n+=LOG_BASE,a=e,l=(u=h[d=0])/mathpow(10,i-a-1)%10|0;else if((d=Math.ceil((n+1)/LOG_BASE))>=(o=h.length)){if(!s)break t;for(;o++<=d;)h.push(0);u=l=0,i=1,a=(n%=LOG_BASE)-LOG_BASE+1}else{for(u=o=h[d],i=1;o>=10;o/=10)i++;l=(a=(n%=LOG_BASE)-LOG_BASE+i)<0?0:u/mathpow(10,i-a-1)%10|0}if(s=s||e<0||void 0!==h[d+1]||(a<0?u:u%mathpow(10,i-a-1)),c=r<4?(l||s)&&(0==r||r==(t.s<0?3:2)):l>5||5==l&&(4==r||s||6==r&&(n>0?a>0?u/mathpow(10,i-a):0:h[d-1])%10&1||r==(t.s<0?8:7)),e<1||!h[0])return h.length=0,c?(e-=t.e+1,h[0]=mathpow(10,(LOG_BASE-e%LOG_BASE)%LOG_BASE),t.e=-e||0):h[0]=t.e=0,t;if(0==n?(h.length=d,o=1,d--):(h.length=d+1,o=mathpow(10,LOG_BASE-n),h[d]=a>0?(u/mathpow(10,i-a)%mathpow(10,a)|0)*o:0),c)for(;;){if(0==d){for(n=1,a=h[0];a>=10;a/=10)n++;for(a=h[0]+=o,o=1;a>=10;a/=10)o++;n!=o&&(t.e++,h[0]==BASE&&(h[0]=1));break}if(h[d]+=o,h[d]!=BASE)break;h[d--]=0,o=1}for(n=h.length;0===h[--n];)h.pop()}return external&&(t.e>m.maxE?(t.d=null,t.e=NaN):t.e<m.minE&&(t.e=0,t.d=[0])),t}function finiteToString(t,e,r){if(!t.isFinite())return nonFiniteToString(t);var s,i=t.e,n=digitsToString(t.d),a=n.length;return e?(r&&(s=r-a)>0?n=n.charAt(0)+"."+n.slice(1)+getZeroString(s):a>1&&(n=n.charAt(0)+"."+n.slice(1)),n=n+(t.e<0?"e":"e+")+t.e):i<0?(n="0."+getZeroString(-i-1)+n,r&&(s=r-a)>0&&(n+=getZeroString(s))):i>=a?(n+=getZeroString(i+1-a),r&&(s=r-i-1)>0&&(n=n+"."+getZeroString(s))):((s=i+1)<a&&(n=n.slice(0,s)+"."+n.slice(s)),r&&(s=r-a)>0&&(i+1===a&&(n+="."),n+=getZeroString(s))),n}function getBase10Exponent(t,e){var r=t[0];for(e*=LOG_BASE;r>=10;r/=10)e++;return e}function getLn10(t,e,r){if(e>LN10_PRECISION)throw external=!0,r&&(t.precision=r),Error(precisionLimitExceeded);return finalise(new t(LN10),e,1,!0)}function getPi(t,e,r){if(e>PI_PRECISION)throw Error(precisionLimitExceeded);return finalise(new t(PI),e,r,!0)}function getPrecision(t){var e=t.length-1,r=e*LOG_BASE+1;if(e=t[e]){for(;e%10==0;e/=10)r--;for(e=t[0];e>=10;e/=10)r++}return r}function getZeroString(t){for(var e="";t--;)e+="0";return e}function intPow(t,e,r,s){var i,n=new t(1),a=Math.ceil(s/LOG_BASE+4);for(external=!1;;){if(r%2&&truncate((n=n.times(e)).d,a)&&(i=!0),0===(r=mathfloor(r/2))){r=n.d.length-1,i&&0===n.d[r]&&++n.d[r];break}truncate((e=e.times(e)).d,a)}return external=!0,n}function isOdd(t){return 1&t.d[t.d.length-1]}function maxOrMin(t,e,r){for(var s,i,n=new t(e[0]),a=0;++a<e.length;){if(!(i=new t(e[a])).s){n=i;break}((s=n.cmp(i))===r||0===s&&n.s===r)&&(n=i)}return n}function naturalExponential(t,e){var r,s,i,n,a,o,l,c=0,u=0,h=0,d=t.constructor,m=d.rounding,p=d.precision;if(!t.d||!t.d[0]||t.e>17)return new d(t.d?t.d[0]?t.s<0?0:1/0:1:t.s?t.s<0?0:t:NaN);for(null==e?(external=!1,l=p):l=e,o=new d(.03125);t.e>-2;)t=t.times(o),h+=5;for(l+=s=Math.log(mathpow(2,h))/Math.LN10*2+5|0,r=n=a=new d(1),d.precision=l;;){if(n=finalise(n.times(t),l,1),r=r.times(++u),digitsToString((o=a.plus(divide(n,r,l,1))).d).slice(0,l)===digitsToString(a.d).slice(0,l)){for(i=h;i--;)a=finalise(a.times(a),l,1);if(null!=e)return d.precision=p,a;if(!(c<3&&checkRoundingDigits(a.d,l-s,m,c)))return finalise(a,d.precision=p,m,external=!0);d.precision=l+=10,r=n=o=new d(1),u=0,c++}a=o}}function naturalLogarithm(t,e){var r,s,i,n,a,o,l,c,u,h,d,m=1,p=t,f=p.d,g=p.constructor,y=g.rounding,x=g.precision;if(p.s<0||!f||!f[0]||!p.e&&1==f[0]&&1==f.length)return new g(f&&!f[0]?-1/0:1!=p.s?NaN:f?0:p);if(null==e?(external=!1,u=x):u=e,g.precision=u+=10,s=(r=digitsToString(f)).charAt(0),!(Math.abs(n=p.e)<15e14))return c=getLn10(g,u+2,x).times(n+""),p=naturalLogarithm(new g(s+"."+r.slice(1)),u-10).plus(c),g.precision=x,null==e?finalise(p,x,y,external=!0):p;for(;s<7&&1!=s||1==s&&r.charAt(1)>3;)s=(r=digitsToString((p=p.times(t)).d)).charAt(0),m++;for(n=p.e,s>1?(p=new g("0."+r),n++):p=new g(s+"."+r.slice(1)),h=p,l=a=p=divide(p.minus(1),p.plus(1),u,1),d=finalise(p.times(p),u,1),i=3;;){if(a=finalise(a.times(d),u,1),digitsToString((c=l.plus(divide(a,new g(i),u,1))).d).slice(0,u)===digitsToString(l.d).slice(0,u)){if(l=l.times(2),0!==n&&(l=l.plus(getLn10(g,u+2,x).times(n+""))),l=divide(l,new g(m),u,1),null!=e)return g.precision=x,l;if(!checkRoundingDigits(l.d,u-10,y,o))return finalise(l,g.precision=x,y,external=!0);g.precision=u+=10,c=a=p=divide(h.minus(1),h.plus(1),u,1),d=finalise(p.times(p),u,1),i=o=1}l=c,i+=2}}function nonFiniteToString(t){return String(t.s*t.s/0)}function parseDecimal(t,e){var r,s,i;for((r=e.indexOf("."))>-1&&(e=e.replace(".","")),(s=e.search(/e/i))>0?(r<0&&(r=s),r+=+e.slice(s+1),e=e.substring(0,s)):r<0&&(r=e.length),s=0;48===e.charCodeAt(s);s++);for(i=e.length;48===e.charCodeAt(i-1);--i);if(e=e.slice(s,i)){if(i-=s,t.e=r=r-s-1,t.d=[],s=(r+1)%LOG_BASE,r<0&&(s+=LOG_BASE),s<i){for(s&&t.d.push(+e.slice(0,s)),i-=LOG_BASE;s<i;)t.d.push(+e.slice(s,s+=LOG_BASE));e=e.slice(s),s=LOG_BASE-e.length}else s-=i;for(;s--;)e+="0";t.d.push(+e),external&&(t.e>t.constructor.maxE?(t.d=null,t.e=NaN):t.e<t.constructor.minE&&(t.e=0,t.d=[0]))}else t.e=0,t.d=[0];return t}function parseOther(t,e){var r,s,i,n,a,o,l,c,u;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),isDecimal.test(e))return parseDecimal(t,e)}else if("Infinity"===e||"NaN"===e)return+e||(t.s=NaN),t.e=NaN,t.d=null,t;if(isHex.test(e))r=16,e=e.toLowerCase();else if(isBinary.test(e))r=2;else{if(!isOctal.test(e))throw Error(invalidArgument+e);r=8}for((n=e.search(/p/i))>0?(l=+e.slice(n+1),e=e.substring(2,n)):e=e.slice(2),a=(n=e.indexOf("."))>=0,s=t.constructor,a&&(n=(o=(e=e.replace(".","")).length)-n,i=intPow(s,new s(r),n,2*n)),n=u=(c=convertBase(e,r,BASE)).length-1;0===c[n];--n)c.pop();return n<0?new s(0*t.s):(t.e=getBase10Exponent(c,u),t.d=c,external=!1,a&&(t=divide(t,i,4*o)),l&&(t=t.times(Math.abs(l)<54?mathpow(2,l):Decimal.pow(2,l))),external=!0,t)}function sine(t,e){var r,s=e.d.length;if(s<3)return e.isZero()?e:taylorSeries(t,2,e,e);r=(r=1.4*Math.sqrt(s))>16?16:0|r,e=taylorSeries(t,2,e=e.times(1/tinyPow(5,r)),e);for(var i,n=new t(5),a=new t(16),o=new t(20);r--;)i=e.times(e),e=e.times(n.plus(i.times(a.times(i).minus(o))));return e}function taylorSeries(t,e,r,s,i){var n,a,o,l,c=t.precision,u=Math.ceil(c/LOG_BASE);for(external=!1,l=r.times(r),o=new t(s);;){if(a=divide(o.times(l),new t(e++*e++),c,1),o=i?s.plus(a):s.minus(a),s=divide(a.times(l),new t(e++*e++),c,1),void 0!==(a=o.plus(s)).d[u]){for(n=u;a.d[n]===o.d[n]&&n--;);if(-1==n)break}n=o,o=s,s=a,a=n}return external=!0,a.d.length=u+1,a}function tinyPow(t,e){for(var r=t;--e;)r*=t;return r}function toLessThanHalfPi(t,e){var r,s=e.s<0,i=getPi(t,t.precision,1),n=i.times(.5);if((e=e.abs()).lte(n))return quadrant=s?4:1,e;if((r=e.divToInt(i)).isZero())quadrant=s?3:2;else{if((e=e.minus(r.times(i))).lte(n))return quadrant=isOdd(r)?s?2:3:s?4:1,e;quadrant=isOdd(r)?s?1:4:s?3:2}return e.minus(i).abs()}function toStringBinary(t,e,r,s){var i,n,a,o,l,c,u,h,d,m=t.constructor,p=void 0!==r;if(p?(checkInt32(r,1,MAX_DIGITS),void 0===s?s=m.rounding:checkInt32(s,0,8)):(r=m.precision,s=m.rounding),t.isFinite()){for(p?(i=2,16==e?r=4*r-3:8==e&&(r=3*r-2)):i=e,(a=(u=finiteToString(t)).indexOf("."))>=0&&(u=u.replace(".",""),(d=new m(1)).e=u.length-a,d.d=convertBase(finiteToString(d),10,i),d.e=d.d.length),n=l=(h=convertBase(u,10,i)).length;0==h[--l];)h.pop();if(h[0]){if(a<0?n--:((t=new m(t)).d=h,t.e=n,h=(t=divide(t,d,r,s,0,i)).d,n=t.e,c=inexact),a=h[r],o=i/2,c=c||void 0!==h[r+1],c=s<4?(void 0!==a||c)&&(0===s||s===(t.s<0?3:2)):a>o||a===o&&(4===s||c||6===s&&1&h[r-1]||s===(t.s<0?8:7)),h.length=r,c)for(;++h[--r]>i-1;)h[r]=0,r||(++n,h.unshift(1));for(l=h.length;!h[l-1];--l);for(a=0,u="";a<l;a++)u+=NUMERALS.charAt(h[a]);if(p){if(l>1)if(16==e||8==e){for(a=16==e?4:3,--l;l%a;l++)u+="0";for(l=(h=convertBase(u,i,e)).length;!h[l-1];--l);for(a=1,u="1.";a<l;a++)u+=NUMERALS.charAt(h[a])}else u=u.charAt(0)+"."+u.slice(1);u=u+(n<0?"p":"p+")+n}else if(n<0){for(;++n;)u="0"+u;u="0."+u}else if(++n>l)for(n-=l;n--;)u+="0";else n<l&&(u=u.slice(0,n)+"."+u.slice(n))}else u=p?"0p+0":"0";u=(16==e?"0x":2==e?"0b":8==e?"0o":"")+u}else u=nonFiniteToString(t);return t.s<0?"-"+u:u}function truncate(t,e){if(t.length>e)return t.length=e,!0}function abs(t){return new this(t).abs()}function acos(t){return new this(t).acos()}function acosh(t){return new this(t).acosh()}function add(t,e){return new this(t).plus(e)}function asin(t){return new this(t).asin()}function asinh(t){return new this(t).asinh()}function atan(t){return new this(t).atan()}function atanh(t){return new this(t).atanh()}function atan2(t,e){t=new this(t),e=new this(e);var r,s=this.precision,i=this.rounding,n=s+4;return t.s&&e.s?t.d||e.d?!e.d||t.isZero()?(r=e.s<0?getPi(this,s,i):new this(0)).s=t.s:!t.d||e.isZero()?(r=getPi(this,n,1).times(.5)).s=t.s:e.s<0?(this.precision=n,this.rounding=1,r=this.atan(divide(t,e,n,1)),e=getPi(this,n,1),this.precision=s,this.rounding=i,r=t.s<0?r.minus(e):r.plus(e)):r=this.atan(divide(t,e,n,1)):(r=getPi(this,n,1).times(e.s>0?.25:.75)).s=t.s:r=new this(NaN),r}function cbrt(t){return new this(t).cbrt()}function ceil(t){return finalise(t=new this(t),t.e+1,2)}function clamp(t,e,r){return new this(t).clamp(e,r)}function config(t){if(!t||"object"!=typeof t)throw Error(decimalError+"Object expected");var e,r,s,i=!0===t.defaults,n=["precision",1,MAX_DIGITS,"rounding",0,8,"toExpNeg",-EXP_LIMIT,0,"toExpPos",0,EXP_LIMIT,"maxE",0,EXP_LIMIT,"minE",-EXP_LIMIT,0,"modulo",0,9];for(e=0;e<n.length;e+=3)if(r=n[e],i&&(this[r]=DEFAULTS[r]),void 0!==(s=t[r])){if(!(mathfloor(s)===s&&s>=n[e+1]&&s<=n[e+2]))throw Error(invalidArgument+r+": "+s);this[r]=s}if(r="crypto",i&&(this[r]=DEFAULTS[r]),void 0!==(s=t[r])){if(!0!==s&&!1!==s&&0!==s&&1!==s)throw Error(invalidArgument+r+": "+s);if(s){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(cryptoUnavailable);this[r]=!0}else this[r]=!1}return this}function cos(t){return new this(t).cos()}function cosh(t){return new this(t).cosh()}function clone(t){var e,r,s;function i(t){var e,r,s,n=this;if(!(n instanceof i))return new i(t);if(n.constructor=i,isDecimalInstance(t))return n.s=t.s,void(external?!t.d||t.e>i.maxE?(n.e=NaN,n.d=null):t.e<i.minE?(n.e=0,n.d=[0]):(n.e=t.e,n.d=t.d.slice()):(n.e=t.e,n.d=t.d?t.d.slice():t.d));if("number"==(s=typeof t)){if(0===t)return n.s=1/t<0?-1:1,n.e=0,void(n.d=[0]);if(t<0?(t=-t,n.s=-1):n.s=1,t===~~t&&t<1e7){for(e=0,r=t;r>=10;r/=10)e++;return void(external?e>i.maxE?(n.e=NaN,n.d=null):e<i.minE?(n.e=0,n.d=[0]):(n.e=e,n.d=[t]):(n.e=e,n.d=[t]))}return 0*t!=0?(t||(n.s=NaN),n.e=NaN,void(n.d=null)):parseDecimal(n,t.toString())}if("string"===s)return 45===(r=t.charCodeAt(0))?(t=t.slice(1),n.s=-1):(43===r&&(t=t.slice(1)),n.s=1),isDecimal.test(t)?parseDecimal(n,t):parseOther(n,t);if("bigint"===s)return t<0?(t=-t,n.s=-1):n.s=1,parseDecimal(n,t.toString());throw Error(invalidArgument+t)}if(i.prototype=P,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=config,i.clone=clone,i.isDecimal=isDecimalInstance,i.abs=abs,i.acos=acos,i.acosh=acosh,i.add=add,i.asin=asin,i.asinh=asinh,i.atan=atan,i.atanh=atanh,i.atan2=atan2,i.cbrt=cbrt,i.ceil=ceil,i.clamp=clamp,i.cos=cos,i.cosh=cosh,i.div=div,i.exp=exp,i.floor=floor,i.hypot=hypot,i.ln=ln,i.log=log,i.log10=log10,i.log2=log2,i.max=max,i.min=min,i.mod=mod,i.mul=mul,i.pow=pow,i.random=random,i.round=round,i.sign=sign,i.sin=sin,i.sinh=sinh,i.sqrt=sqrt,i.sub=sub,i.sum=sum,i.tan=tan,i.tanh=tanh,i.trunc=trunc,void 0===t&&(t={}),t&&!0!==t.defaults)for(s=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<s.length;)t.hasOwnProperty(r=s[e++])||(t[r]=this[r]);return i.config(t),i}function div(t,e){return new this(t).div(e)}function exp(t){return new this(t).exp()}function floor(t){return finalise(t=new this(t),t.e+1,3)}function hypot(){var t,e,r=new this(0);for(external=!1,t=0;t<arguments.length;)if((e=new this(arguments[t++])).d)r.d&&(r=r.plus(e.times(e)));else{if(e.s)return external=!0,new this(1/0);r=e}return external=!0,r.sqrt()}function isDecimalInstance(t){return t instanceof Decimal||t&&t.toStringTag===tag||!1}function ln(t){return new this(t).ln()}function log(t,e){return new this(t).log(e)}function log2(t){return new this(t).log(2)}function log10(t){return new this(t).log(10)}function max(){return maxOrMin(this,arguments,-1)}function min(){return maxOrMin(this,arguments,1)}function mod(t,e){return new this(t).mod(e)}function mul(t,e){return new this(t).mul(e)}function pow(t,e){return new this(t).pow(e)}function random(t){var e,r,s,i,n=0,a=new this(1),o=[];if(void 0===t?t=this.precision:checkInt32(t,1,MAX_DIGITS),s=Math.ceil(t/LOG_BASE),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(s));n<s;)(i=e[n])>=429e7?e[n]=crypto.getRandomValues(new Uint32Array(1))[0]:o[n++]=i%1e7;else{if(!crypto.randomBytes)throw Error(cryptoUnavailable);for(e=crypto.randomBytes(s*=4);n<s;)(i=e[n]+(e[n+1]<<8)+(e[n+2]<<16)+((127&e[n+3])<<24))>=214e7?crypto.randomBytes(4).copy(e,n):(o.push(i%1e7),n+=4);n=s/4}else for(;n<s;)o[n++]=1e7*Math.random()|0;for(s=o[--n],t%=LOG_BASE,s&&t&&(i=mathpow(10,LOG_BASE-t),o[n]=(s/i|0)*i);0===o[n];n--)o.pop();if(n<0)r=0,o=[0];else{for(r=-1;0===o[0];r-=LOG_BASE)o.shift();for(s=1,i=o[0];i>=10;i/=10)s++;s<LOG_BASE&&(r-=LOG_BASE-s)}return a.e=r,a.d=o,a}function round(t){return finalise(t=new this(t),t.e+1,this.rounding)}function sign(t){return(t=new this(t)).d?t.d[0]?t.s:0*t.s:t.s||NaN}function sin(t){return new this(t).sin()}function sinh(t){return new this(t).sinh()}function sqrt(t){return new this(t).sqrt()}function sub(t,e){return new this(t).sub(e)}function sum(){var t=0,e=arguments,r=new this(e[t]);for(external=!1;r.s&&++t<e.length;)r=r.plus(e[t]);return external=!0,finalise(r,this.precision,this.rounding)}function tan(t){return new this(t).tan()}function tanh(t){return new this(t).tanh()}function trunc(t){return finalise(t=new this(t),t.e+1,1)}P[Symbol.for("nodejs.util.inspect.custom")]=P.toString,P[Symbol.toStringTag]="Decimal";var Decimal=P.constructor=clone(DEFAULTS);LN10=new Decimal(LN10),PI=new Decimal(PI);const decimal=null,ComplexInterfaceStaticKeyTable=["LOGICAL","REAL","COMPLEX","defaultSettings","settings","isInstanceOf","set","setNumberType","create","realSet","imagSet","realApply","imagApply","from","real","imag","isComplexValue","isRealValue","realIsInteger","imagIsInteger","realIsFinite","imagIsFinite","realIsNaN","imagIsNaN","realIsNegative","imagIsNegative","realIsZero","imagIsZero","realIsPositive","imagIsPositive","realToNumber","toBoolean","imagToNumber","realLessThan","imagLessThan","realLessThanOrEqualTo","imagLessThanOrEqualTo","realEquals","imagEquals","realGreaterThanOrEqualTo","imagGreaterThanOrEqualTo","realGreaterThan","imagGreaterThan","parse","unparseValue","unparse","toString","unparseMathMLValue","precedence","unparseMathML","copy","toMaxPrecisionValue","toMaxPrecision","epsilonValue","epsilon","random","eq","ne","compareValue","cmp","minMaxArrayReal","minMaxArrayRealWithIndex","minMaxArrayComplex","minMaxArrayComplexWithIndex","min","minWise","max","maxWise","lt","le","gt","ge","false","true","logical","toLogical","and","or","xor","not","zero","one","onediv2","minusonediv2","minusone","pi","pidiv2","onei","onediv2i","minusonediv2i","minusonei","two","sqrt2pi","e","NaN_0","inf_0","add","sub","neg","mul","mulAndSumTo","rdiv","ldiv","inv","power","root","absValue","abs2Value","abs","abs2","hypot","arg","conj","mod","rem","fix","ceil","floor","round","sign","sqrt","exp","log","logb","log2","log10","deg2rad","rad2deg","sin","sind","cos","cosd","tan","tand","csc","cscd","sec","secd","cot","cotd","asin","asind","acos","acosd","atan","atan2","atand","acsc","acscd","asec","asecd","acot","acotd","sinh","cosh","tanh","csch","sech","coth","asinh","acosh","atanh","acsch","asech","acoth","gamma","factorial","applyFunction","mapFunction","twoArgFunction"],roundingMode={ROUND_UP:0,ROUND_DOWN:1,ROUND_CEIL:2,ROUND_FLOOR:3,ROUND_HALF_UP:4,ROUND_HALF_DOWN:5,ROUND_HALF_EVEN:6,ROUND_HALF_CEIL:7,ROUND_HALF_FLOOR:8,EUCLID:9},roundingName=["up","down","ceil","floor","half_up","half_down","half_even","half_ceil","half_floor"],moduloName=["up","down",void 0,"floor",void 0,void 0,"half_even",void 0,void 0,"euclid"],numberClass={LOGICAL:0,REAL:1,COMPLEX:2},setNumberTypeFactory=t=>e=>{t.imagIsZero(e)?(t.realIsZero(e)||t.realEquals(e,1))&&e.type===t.LOGICAL||(e.type=t.REAL):e.type=t.COMPLEX},createFactory=t=>(e,r,s,i)=>new t(e,r,s,i),parseFactory=t=>e=>{const r="0"!==e[0]||"x"!==e[1]&&"X"!==e[1]?e.replace(/[dD]/,"e"):e.replace("_","");return/[ijIJ]$/.test(r)?t.create(0,r.slice(0,-1)):t.create(r,0)},precedenceFactory=t=>(e,r)=>{if(e.type!==t.LOGICAL){const s=t.toMaxPrecision(e);return t.realIsZero(s)||t.imagIsZero(s)?t.realIsZero(s)?t.imagIsZero(s)?t.realIsNegative(s)||t.imagIsNegative(s)?t.realIsNegative(s)&&t.imagIsNegative(s)?r.precedenceTable["-_"]:r.precedenceTable["+"]:r.precedenceTable["()"]:t.imagIsNegative(s)?r.precedenceTable["-_"]:r.precedenceTable["()"]:t.realIsNegative(s)?r.precedenceTable["-_"]:r.precedenceTable["()"]:r.precedenceTable["+"]}return r.precedenceTable["()"]},unparseValueFactory=(t,e)=>r=>{if(t.isFinite(r)){const s=t.unparse(r).split("e");return 1===s.length?s[0].slice(0,e.settings.toExpPos):s[0].slice(0,e.settings.toExpPos)+"e"+Number(s[1])}return t.isNaN(r)?"NaN":(t.isNeg(r)?"-":"")+"∞"},unparseFactory=t=>(e,r,s=0)=>{if(e.type!==t.LOGICAL){const i=t.toMaxPrecision(e);if(t.realIsZero(i)||t.imagIsZero(i)){if(t.realIsZero(i)){if(t.imagIsZero(i)){if(t.realIsNegative(i)||t.imagIsNegative(i)){if(t.realIsNegative(i)&&t.imagIsNegative(i)){const t="-0";return s>r.precedenceTable["-_"]?"("+t+")":t}if(t.realIsNegative(i)&&!t.imagIsNegative(i)){const t="-0+0i";return s>r.precedenceTable["+"]?"("+t+")":t}{const t="0-0i";return s>r.precedenceTable["+"]?"("+t+")":t}}return"0"}{const e=(t.imagEquals(i,1)?"":t.imagEquals(i,-1)?"-":t.unparseValue(i.im))+"i";return s>(t.imagIsNegative(i)?r.precedenceTable["-_"]:r.precedenceTable["()"])?"("+e+")":e}}{const e=t.unparseValue(i.re);return s>(t.realIsNegative(i)?r.precedenceTable["-_"]:r.precedenceTable["()"])?"("+e+")":e}}{const e=t.unparseValue(i.re)+(t.imagGreaterThan(i,0)?"+":"")+(t.imagEquals(i,1)?"":t.imagEquals(i,-1)?"-":t.unparseValue(i.im))+"i";return s>r.precedenceTable["+"]?"("+e+")":e}}return t.realIsZero(e)?"false":"true"},toStringFactory=t=>e=>{if(e.type!==t.LOGICAL){const r=t.toMaxPrecision(e);return t.realIsZero(r)||t.imagIsZero(r)?t.realIsZero(r)?t.imagIsZero(r)?t.realIsNegative(r)||t.imagIsNegative(r)?t.realIsNegative(r)&&t.imagIsNegative(r)?"-0":t.realIsNegative(r)&&!t.imagIsNegative(r)?"-0+0i":"0-0i":"0":(t.imagEquals(r,1)?"":t.imagEquals(r,-1)?"-":t.unparseValue(r.im))+"i":t.unparseValue(r.re):t.unparseValue(r.re)+(t.imagGreaterThan(r,0)?"+":"")+(t.imagEquals(r,1)?"":t.imagEquals(r,-1)?"-":t.unparseValue(r.im))+"i"}return t.realIsZero(e)?"false":"true"},unparseMathMLValueFactory=(t,e)=>r=>{if(t.isFinite(r)){const s=t.unparse(r).split("e");return 1==s.length?"<mn>"+s[0].slice(0,e.settings.toExpPos)+"</mn>":"<mn>"+s[0].slice(0,e.settings.toExpPos)+"</mn><mo>⋅</mo><msup><mrow><mn>10</mn></mrow><mrow><mn>"+Number(s[1])+"</mn></mrow></msup>"}return t.isNaN(r)?"<mi><b>NaN</b></mi>":(t.isNeg(r)?"<mo>-</mo>":"")+"<mi>∞</mi>"},unparseMathMLFactory=t=>(e,r,s=0)=>{if(e.type!==t.LOGICAL){const i=t.toMaxPrecision(e);if(t.realIsZero(i)||t.imagIsZero(i)){if(t.realIsZero(i)){if(t.imagIsZero(i)){if(t.realIsNegative(i)||t.imagIsNegative(i)){if(t.realIsNegative(i)&&t.imagIsNegative(i)){const t="<mn>-0</mn>";return s>r.precedenceTable["-_"]?`<mo fence="true" stretchy="true">(</mo>${t}<mo fence="true" stretchy="true">)</mo>`:t}if(t.realIsNegative(i)&&!t.imagIsNegative(i)){const t="<mn>-0</mn><mo>+</mo><mn>0</mn><mi>i</mi>";return s>r.precedenceTable["+"]?`<mo fence="true" stretchy="true">(</mo>${t}<mo fence="true" stretchy="true">)</mo>`:t}{const t="<mn>0</mn><mo>-</mo><mn>0</mn><mi>i</mi>";return s>r.precedenceTable["+"]?`<mo fence="true" stretchy="true">(</mo>${t}<mo fence="true" stretchy="true">)</mo>`:t}}return"<mn>0</mn>"}{const e=(t.imagEquals(i,1)?"":t.imagEquals(i,-1)?"<mo>-</mo>":t.unparseMathMLValue(i.im))+"<mi>i</mi>";return s>(t.imagIsNegative(i)?r.precedenceTable["-_"]:r.precedenceTable["()"])?`<mo fence="true" stretchy="true">(</mo>${e}<mo fence="true" stretchy="true">)</mo>`:e}}{const e=t.unparseMathMLValue(i.re);return s>(t.realIsNegative(i)?r.precedenceTable["-_"]:r.precedenceTable["()"])?`<mo fence="true" stretchy="true">(</mo>${e}<mo fence="true" stretchy="true">)</mo>`:e}}{const e=t.unparseMathMLValue(i.re)+(t.imagGreaterThan(i,0)?"<mo>+</mo>":"")+(t.imagEquals(i,1)?"":t.imagEquals(i,-1)?"<mo>-</mo>":t.unparseMathMLValue(i.im))+"<mi>i</mi>";return s>r.precedenceTable["+"]?`<mo fence="true" stretchy="true">(</mo>${e}<mo fence="true" stretchy="true">)</mo>`:e}}return t.realIsZero(e)?"<mi>false</mi>":"<mi>true</mi>"},toMaxPrecisionFactory=t=>e=>new t(t.toMaxPrecisionValue(e.re),t.toMaxPrecisionValue(e.im)),copyFactory=t=>e=>new t(e.re,e.im,e.type),epsilonFactory=t=>()=>new t(t.epsilonValue()),equalsFactory=(t,e=!0)=>e?(e,r)=>{const s=t.toMaxPrecision(e),i=t.toMaxPrecision(r);return t.realEquals(s,i.re)&&t.imagEquals(s,i.im)?t.true():t.false()}:(e,r)=>{const s=t.toMaxPrecision(e),i=t.toMaxPrecision(r);return t.realEquals(s,i.re)&&t.imagEquals(s,i.im)?t.false():t.true()},cmpFactory=t=>(e,r,s)=>{const i=t.toMaxPrecision(r),n=t.toMaxPrecision(s);if(t.imagIsZero(i)&&t.imagIsZero(n))return t.compareValue(e,i.re,n.re)?t.true():t.false();const a=t.toMaxPrecisionValue(t.abs(r).re),o=t.toMaxPrecisionValue(t.abs(s).re);return t.compareValue("eq",a,o)?t.compareValue(e,t.toMaxPrecisionValue(t.arg(r).re),t.toMaxPrecisionValue(t.arg(s).re))?t.true():t.false():t.compareValue(e,a,o)?t.true():t.false()},minMaxArrayRealFactory=t=>(e,...r)=>r.reduce((r,s)=>t.compareValue(e,r.re,s.re)?r:s,r[0]),minMaxArrayRealWithIndexFactory=t=>(e,...r)=>{let s=0;return[r.reduceRight((r,i,n)=>t.compareValue(e,r.re,i.re)?r:(s=n,i),r[r.length-1]),s]},minMaxArrayComplexFactory=t=>(e,...r)=>r.reduce((r,s)=>{const i=t.abs(r).re,n=t.abs(s).re;return t.compareValue("eq",i,n)?t.compareValue(e,t.arg(r).re,t.arg(s).re)?r:s:t.compareValue(e,i,n)?r:s},r[0]),minMaxArrayComplexWithIndexFactory=t=>(e,...r)=>{let s=0;return[r.reduceRight((r,i,n)=>{const a=t.abs(r).re,o=t.abs(i).re;return t.compareValue("eq",a,o)?t.compareValue(e,t.arg(r).re,t.arg(i).re)?r:(s=n,i):t.compareValue(e,a,o)?r:(s=n,i)},r[r.length-1]),s]},minMaxFactory=(t,e)=>(r,s)=>{if(t.imagIsZero(r)&&t.imagIsZero(s))return t.compareValue(e,r.re,s.re)?r:s;{const i=t.abs(r).re,n=t.abs(s).re;return t.compareValue("eq",i,n)?t.compareValue(e,t.arg(r).re,t.arg(s).re)?r:s:t.compareValue(e,i,n)?r:s}},minMaxWiseFactory=(t,e)=>(r,s)=>{if(r.type<=t.REAL&&r.type<=t.REAL)return t.compareValue(e,r.re,s.re)?r:s;{const i=t.abs(r).re,n=t.abs(s).re;return t.compareValue("eq",i,n)?t.compareValue(e,t.arg(r).re,t.arg(s).re)?r:s:t.compareValue(e,i,n)?r:s}},comparisonFactory=(t,e)=>(r,s)=>t.cmp(e,r,s),logicalFactory=t=>e=>{const r=t.toMaxPrecision(e);return new t(t.realIsZero(r)&&t.imagIsZero(r)?0:1,0,t.LOGICAL)},andFactory=t=>(e,r)=>{const s=t.toMaxPrecision(e),i=t.toMaxPrecision(r);return t.realIsZero(s)&&t.imagIsZero(s)||t.realIsZero(i)&&t.imagIsZero(i)?t.false():t.true()},orFactory=t=>(e,r)=>{const s=t.toMaxPrecision(e),i=t.toMaxPrecision(r);return t.realIsZero(s)&&t.imagIsZero(s)&&t.realIsZero(i)&&t.imagIsZero(i)?t.false():t.true()},xorFactory=t=>(e,r)=>{const s=t.toMaxPrecision(e),i=t.toMaxPrecision(r);return t.realIsZero(s)&&t.imagIsZero(s)&&(!t.realIsZero(i)||!t.imagIsZero(i))||(!t.realIsZero(s)||!t.imagIsZero(s))&&t.realIsZero(i)&&t.imagIsZero(i)?t.true():t.false()},notFactory=t=>e=>{const r=t.toMaxPrecision(e);return t.realIsZero(r)&&t.imagIsZero(r)?t.true():t.false()},literalFactory=(t,e,r,s)=>()=>new t(e,r,s),mulFactory=(t,e)=>(r,s)=>e.imagIsZero(r)&&e.imagIsZero(s)?new e(t.mul(r.re,s.re),t.ZERO):new e(t.sub(t.mul(r.re,s.re),t.mul(r.im,s.im)),t.add(t.mul(r.re,s.im),t.mul(r.im,s.re))),mulAndSumToFactory=(t,e)=>(r,s,i)=>(e.imagIsZero(s)&&e.imagIsZero(i)&&e.imagIsZero(r)?r.re=t.add(r.re,t.mul(s.re,i.re)):(r.re=t.add(r.re,t.sub(t.mul(s.re,i.re),t.mul(s.im,i.im))),r.im=t.add(r.im,t.add(t.mul(s.re,i.im),t.mul(s.im,i.re)))),r),rdivFactory=(t,e)=>(r,s)=>{if(t.isZero(s.im))return t.isFinite(s.re)?t.isZero(s.re)?new e(t.mul(r.re,t.INF),t.mul(r.im,t.INF)):new e(t.div(r.re,s.re),t.div(r.im,s.re)):t.isNaN(s.re)?(e.realIsFinite(s)||e.realIsNaN(s))&&(e.imagIsFinite(s)||e.imagIsNaN(s))?new e(NaN,0):e.zero():e.realIsFinite(r)&&e.imagIsFinite(r)?e.zero():new e(NaN,0);{const i=t.add(t.mul(s.re,s.re),t.mul(s.im,s.im));return t.isFinite(i)?t.isZero(i)?new e(t.mul(r.re,t.INF),e.imagIsZero(r)?t.ZERO:t.mul(r.im,t.INF)):new e(t.div(t.add(t.mul(r.re,s.re),t.mul(r.im,s.im)),i),t.div(t.sub(t.mul(r.im,s.re),t.mul(r.re,s.im)),i)):t.isNaN(i)?(e.realIsFinite(s)||e.realIsNaN(s))&&(e.imagIsFinite(s)||e.imagIsNaN(s))?new e(NaN,0):e.zero():e.realIsFinite(r)&&e.imagIsFinite(r)?e.zero():new e(NaN,0)}},ldivFactory=(t,e)=>{const r=rdivFactory(t,e);return(t,e)=>r(e,t)},invFactory=(t,e)=>r=>{const s=t.add(t.mul(r.re,r.re),t.mul(r.im,r.im));return t.isFinite(s)?t.isZero(s)?new e(1/0,0):new e(t.div(r.re,s),t.neg(t.div(r.im,s))):t.isNaN(s)&&(e.realIsFinite(r)||e.realIsNaN(r))&&(e.imagIsFinite(r)||e.imagIsNaN(r))?new e(NaN,0):e.zero()},powerFactory=(t,e)=>(r,s)=>{if(e.imagIsZero(r)&&e.imagIsZero(s)&&e.realGreaterThanOrEqualTo(r,0))return new e(t.pow(r.re,s.re),0);{const i=t.atan2(e.imagIsZero(r)?t.ZERO:r.im,e.realIsZero(r)?t.ZERO:r.re),n=t.add(t.mul(r.re,r.re),t.mul(r.im,r.im)),a=t.mul(t.pow(n,t.div(s.re,t.TWO)),t.exp(t.mul(t.mul(t.MINUSONE,s.im),i))),o=t.add(t.mul(s.re,i),t.mul(t.div(s.im,t.TWO),t.ln(n)));return new e(t.mul(a,t.cos(o)),e.imagIsZero(r)&&e.imagIsZero(s)&&(e.realGreaterThanOrEqualTo(s,1)||e.realLessThanOrEqualTo(s,-1))?0:t.mul(a,t.sin(o)))}},rootFactory=t=>(e,r)=>t.power(e,t.inv(r)),absValueFactory=t=>e=>t.sqrt(t.add(t.mul(e.re,e.re),t.mul(e.im,e.im))),abs2ValueFactory=t=>e=>t.add(t.mul(e.re,e.re),t.mul(e.im,e.im)),absFactory=(t,e)=>r=>e.imagIsZero(r)?new e(t.abs(r.re)):new e(e.absValue(r)),abs2Factory=(t,e)=>r=>{const s=t.abs(r.re);return e.imagIsZero(r)?new e(t.mul(s,s)):new e(e.abs2Value(r))},hypotFactory=t=>(e,r)=>new t(t.absValue(new t(t.absValue(e),t.absValue(r)))),argFactory=(t,e)=>r=>new e(t.atan2(e.imagIsZero(r)?t.ZERO:r.im,r.re),0),conjFactory=(t,e)=>r=>new e(r.re,t.neg(r.im)),modFactory=(t,e)=>(r,s)=>{if(!e.imagIsZero(r)||!e.imagIsZero(s))throw new Error("mod: not defined for complex numbers");return e.realIsZero(s)?r:new e(t.mod(r.re,s.re))},remFactory=(t,e)=>(r,s)=>{if(!e.imagIsZero(r)||!e.imagIsZero(s))throw new Error("rem: not defined for complex numbers");return new e(t.mod(r.re,s.re))},fixFactory=(t,e)=>r=>new e(t.trunc(r.re),t.trunc(r.im)),ceilFactory=(t,e)=>r=>new e(t.ceil(r.re),t.ceil(r.im)),floorFactory=(t,e)=>r=>new e(t.floor(r.re),t.floor(r.im)),roundFactory=(t,e)=>r=>new e(t.round(r.re),t.round(r.im)),signFactory=(t,e)=>r=>e.realIsZero(r)?e.imagIsZero(r)?e.zero():new e(0,t.div(r.im,e.absValue(r))):e.imagIsZero(r)?new e(t.div(r.re,e.absValue(r)),0):new e(t.div(r.re,e.absValue(r)),t.div(r.im,e.absValue(r))),sqrtFactory=(t,e)=>r=>{const s=e.absValue(r),i=t.atan2(e.imagIsZero(r)?t.ZERO:r.im,r.re);return new e(t.mul(t.sqrt(s),t.cos(t.div(i,t.TWO))),t.mul(t.sqrt(s),t.sin(t.div(i,t.TWO))))},expFactory=(t,e)=>r=>new e(t.mul(t.exp(r.re),t.cos(r.im)),t.mul(t.exp(r.re),t.sin(r.im))),logFactory=(t,e)=>r=>new e(t.ln(e.absValue(r)),t.atan2(e.imagIsZero(r)?t.ZERO:r.im,r.re)),logbFactory=(t,e)=>(r,s)=>{const i=e.absValue(r);if(t.isZero(i))return e.zero();{const n=t.atan2(e.imagIsZero(r)?t.ZERO:r.im,r.re),a=e.absValue(s),o=t.atan2(e.imagIsZero(s)?t.ZERO:s.im,s.re),l=t.add(t.mul(t.ln(i),t.ln(i)),t.mul(n,n));return new e(t.div(t.add(t.mul(t.ln(a),t.ln(i)),t.mul(o,n)),l),t.div(t.sub(t.mul(o,t.ln(i)),t.mul(t.ln(a),n)),l))}},log2Factory=t=>e=>t.logb(new t(2),e),log10Factory=t=>e=>t.logb(new t(10),e),deg2radFactory=(t,e)=>r=>new e(t.mul(t.div(t.PI,t.PI_DEG),r.re),t.mul(t.div(t.PI,t.PI_DEG),r.im)),rad2degFactory=(t,e)=>r=>new e(t.mul(t.div(t.PI_DEG,t.PI),r.re),t.mul(t.div(t.PI_DEG,t.PI),r.im)),sinFactory=(t,e)=>r=>new e(t.mul(t.sin(r.re),t.cosh(r.im)),t.mul(t.cos(r.re),t.sinh(r.im))),sindFactory=t=>e=>t.sin(t.deg2rad(e)),cosFactory=(t,e)=>r=>new e(t.mul(t.cos(r.re),t.cosh(r.im)),t.mul(t.sin(r.re),t.neg(t.sinh(r.im)))),cosdFactory=t=>e=>t.cos(t.deg2rad(e)),tanFactory=t=>e=>t.rdiv(t.sin(e),t.cos(e)),tandFactory=t=>e=>t.tan(t.deg2rad(e)),cscFactory=t=>e=>t.rdiv(t.one(),t.sin(e)),cscdFactory=t=>e=>t.csc(t.deg2rad(e)),secFactory=t=>e=>t.rdiv(t.one(),t.cos(e)),secdFactory=t=>e=>t.sec(t.deg2rad(e)),cotFactory=t=>e=>t.rdiv(t.cos(e),t.sin(e)),cotdFactory=t=>e=>t.rdiv(t.cos(e),t.sin(e)),asinFactory=t=>e=>t.mul(t.onei(),t.log(t.sub(t.sqrt(t.sub(t.one(),t.power(e,t.two()))),t.mul(t.onei(),e)))),asindFactory=t=>e=>t.rad2deg(t.asin(e)),acosFactory=t=>e=>t.sub(t.pidiv2(),t.asin(e)),acosdFactory=t=>e=>t.rad2deg(t.acos(e)),atanFactory=t=>e=>t.mul(t.minusonediv2i(),t.log(t.rdiv(t.sub(t.onei(),e),t.add(t.onei(),e)))),atan2Factory=(t,e)=>(r,s)=>{const i=t.div(t.add(t.mul(r.re,s.re),t.mul(r.im,s.im)),t.add(t.mul(s.re,s.re),t.mul(s.im,s.im))),n=t.div(t.sub(t.mul(r.im,s.re),t.mul(r.re,s.im)),t.add(t.mul(s.re,s.re),t.mul(s.im,s.im)));return e.create(t.mul(t.create(.5),t.atan(t.div(t.mul(t.create(2),i),t.sub(t.sub(t.create(1),t.mul(i,i)),t.mul(n,n))))),t.mul(t.create(-1/4),t.ln(t.div(t.add(t.mul(t.sub(t.create(1),n),t.sub(t.create(1),n)),t.mul(i,i)),t.add(t.mul(t.add(t.create(1),n),t.add(t.create(1),n)),t.mul(i,i))))))},atandFactory=t=>e=>t.rad2deg(t.atan(e)),acscFactory=t=>e=>t.asin(t.rdiv(t.one(),e)),acscdFactory=t=>e=>t.rad2deg(t.acsc(e)),asecFactory=t=>e=>t.acos(t.rdiv(t.one(),e)),asecdFactory=t=>e=>t.rad2deg(t.asec(e)),acotFactory=t=>e=>t.atan(t.rdiv(t.one(),e)),acotdFactory=t=>e=>t.rad2deg(t.acot(e)),sinhFactory=(t,e)=>r=>new e(t.mul(t.sinh(r.re),t.cos(r.im)),t.mul(t.cosh(r.re),t.sin(r.im))),coshFactory=(t,e)=>r=>new e(t.mul(t.cosh(r.re),t.cos(r.im)),t.mul(t.sinh(r.re),t.sin(r.im))),tanhFactory=t=>e=>t.rdiv(t.sinh(e),t.cosh(e)),cschFactory=t=>e=>t.rdiv(t.one(),t.sinh(e)),sechFactory=t=>e=>t.rdiv(t.one(),t.cosh(e)),cothFactory=t=>e=>t.rdiv(t.cosh(e),t.sinh(e)),asinhFactory=t=>e=>t.log(t.add(t.sqrt(t.add(t.one(),t.power(e,t.two()))),e)),acoshFactory=t=>e=>t.log(t.add(t.sqrt(t.add(t.minusone(),t.power(e,t.two()))),e)),atanhFactory=t=>e=>t.mul(t.onediv2(),t.log(t.rdiv(t.add(t.one(),e),t.sub(t.one(),e)))),acschFactory=t=>e=>t.rdiv(t.one(),t.asinh(e)),asechFactory=t=>e=>t.rdiv(t.one(),t.acosh(e)),acothFactory=t=>e=>t.rdiv(t.one(),t.atanh(e)),gammaFactory=t=>e=>{const r=["0.99999999999980993","676.5203681218851","-1259.1392167224028","771.32342877765313","-176.61502916214059","12.507343278686905","-0.13857109526572012","9.9843695780195716e-6","1.5056327351493116e-7"];if(t.realLessThan(e,.5))return t.rdiv(t.pi(),t.mul(t.sin(t.mul(t.pi(),e)),t.gamma(t.sub(t.one(),e))));{e=t.sub(e,t.one());let s=new t(r[0]);const i=t.add(e,new t(r.length-1.5));for(let i=1;i<r.length;i++)s=t.add(s,t.rdiv(new t(r[i]),t.add(e,new t(i))));return t.mul(t.mul(t.sqrt2pi(),t.power(i,t.add(e,new t(.5)))),t.mul(t.exp(t.neg(i)),s))}},factorialFactory=(t,e)=>r=>{if(!(e.realGreaterThanOrEqualTo(r,0)&&e.realIsInteger(r)&&e.imagIsZero(r)))throw new Error("factorial: all N must be real non-negative integers");const s=e.gamma(e.add(new e(t.round(r.re)),e.one()));return e.realApply(s,e.applyFunction.trunc),s},applyFunctionFactory=t=>({fix:e=>t.trunc(e),ceil:e=>t.ceil(e),floor:e=>t.floor(e),round:e=>t.round(e),sign:e=>t.create(t.sign(e)),trunc:e=>t.trunc(e)}),mapFunctionFactory=t=>({real:t.real,imag:t.imag,logical:t.logical,abs:t.abs,arg:t.arg,angle:t.arg,conj:t.conj,fix:t.fix,ceil:t.ceil,floor:t.floor,round:t.round,sign:t.sign,sqrt:t.sqrt,exp:t.exp,log:t.log,log2:t.log2,log10:t.log10,deg2rad:t.deg2rad,rad2deg:t.rad2deg,sin:t.sin,sind:t.sind,cos:t.cos,cosd:t.cosd,tan:t.tan,tand:t.tand,csc:t.csc,cscd:t.cscd,sec:t.sec,secd:t.secd,cot:t.cot,cotd:t.cotd,asin:t.asin,asind:t.asind,acos:t.acos,acosd:t.acosd,atan:t.atan,atand:t.atand,acsc:t.acsc,acscd:t.acscd,asec:t.asec,asecd:t.asecd,acot:t.acot,acotd:t.acotd,sinh:t.sinh,cosh:t.cosh,tanh:t.tanh,csch:t.csch,sech:t.sech,coth:t.coth,asinh:t.asinh,acosh:t.acosh,atanh:t.atanh,acsch:t.acsch,asech:t.asech,acoth:t.acoth,gamma:t.gamma,factorial:t.factorial}),twoArgFunctionFactory=t=>({root:t.root,hypot:t.hypot,power:t.power,logb:t.logb,atan2:t.atan2}),defaultSettings={precision:15,precisionCompare:0,rounding:roundingMode.ROUND_HALF_EVEN,toExpPos:21,toExpNeg:-7,minE:-324,maxE:308,modulo:roundingMode.ROUND_DOWN,crypto:!1},mathBackend=Math;mathBackend.add=(t,e)=>t+e,mathBackend.sub=(t,e)=>t-e,mathBackend.neg=t=>-t,mathBackend.mul=(t,e)=>t*e,mathBackend.div=(t,e)=>t/e,mathBackend.mod=(t,e)=>t%e,mathBackend.ln=Math.log,mathBackend.create=t=>Number(t),mathBackend.MINUSONE=-1,mathBackend.ZERO=0,mathBackend.TWO=2,mathBackend.PI_DEG=180,mathBackend.INF=1/0,mathBackend.unparse=t=>0===t?Object.is(t,-0)?"-0":"0":t.toString(),mathBackend.isZero=t=>0===t,mathBackend.isNeg=t=>0===t?Object.is(t,-0):t<0,mathBackend.isNaN=Number.isNaN,mathBackend.isFinite=Number.isFinite;class ComplexNumber{static LOGICAL=numberClass.LOGICAL;static REAL=numberClass.REAL;static COMPLEX=numberClass.COMPLEX;static defaultSettings=Object.assign({},defaultSettings);static settings=this.defaultSettings;static isInstanceOf=t=>t instanceof ComplexNumber;static set=t=>{};re;im;type;parent;static setNumberType=setNumberTypeFactory(ComplexNumber);constructor(t,e,r,s){this.re=void 0!==t?Number(t):0,this.im=void 0!==e?Number(e):0,this.type=r??ComplexNumber.COMPLEX,s&&(this.parent=s),ComplexNumber.setNumberType(this)}static create=(t,e,r,s)=>new ComplexNumber(t,e,r,s);static realSet=(t,e)=>{t.re=Number(e)};static imagSet=(t,e)=>{t.im=Number(e)};static realApply=(t,e)=>{t.re=e(t.re)};static imagApply=(t,e)=>{t.im=e(t.im)};static from=t=>new ComplexNumber(t.re,t.im,t.type);static real=t=>new ComplexNumber(t.re);static imag=t=>new ComplexNumber(t.im);static isComplexValue=t=>0!==t.im;static isRealValue=t=>0===t.im;static realIsInteger=t=>Number.isInteger(t.re);static imagIsInteger=t=>Number.isInteger(t.im);static realIsFinite=t=>Number.isFinite(t.re);static imagIsFinite=t=>Number.isFinite(t.im);static realIsNaN=t=>Number.isNaN(t.re);static imagIsNaN=t=>Number.isNaN(t.im);static realIsNegative=t=>t.re<0||Object.is(t.re,-0);static imagIsNegative=t=>t.im<0||Object.is(t.im,-0);static realIsZero=t=>0===t.re;static imagIsZero=t=>0===t.im;static realIsPositive=t=>t.re>=0;static imagIsPositive=t=>t.im>=0;static realToNumber=t=>t.re;static toBoolean=t=>t.type===ComplexNumber.LOGICAL?Boolean(t.re):Boolean(t.re)||Boolean(t.im);static imagToNumber=t=>t.im;static realLessThan=(t,e)=>t.re<Number(e);static imagLessThan=(t,e)=>t.im<Number(e);static realLessThanOrEqualTo=(t,e)=>t.re<=Number(e);static imagLessThanOrEqualTo=(t,e)=>t.im<=Number(e);static realEquals=(t,e)=>t.re===Number(e);static imagEquals=(t,e)=>t.im===Number(e);static realGreaterThanOrEqualTo=(t,e)=>t.re>=Number(e);static imagGreaterThanOrEqualTo=(t,e)=>t.im>=Number(e);static realGreaterThan=(t,e)=>t.re>Number(e);static imagGreaterThan=(t,e)=>t.im>Number(e);static parse=parseFactory(ComplexNumber);static precedence=precedenceFactory(ComplexNumber);static unparseValue=unparseValueFactory(Math,ComplexNumber);static unparse=unparseFactory(ComplexNumber);static toString=toStringFactory(ComplexNumber);toString(){return ComplexNumber.toString(this)}static unparseMathMLValue=unparseMathMLValueFactory(Math,ComplexNumber);static unparseMathML=unparseMathMLFactory(ComplexNumber);static copy=copyFactory(ComplexNumber);copy=()=>new ComplexNumber(this.re,this.im,this.type);static toMaxPrecisionValue=t=>{const e=this.settings.precision-this.settings.precisionCompare;return Number(Number(t.toPrecision(e)).toFixed(e))};static toMaxPrecision=toMaxPrecisionFactory(ComplexNumber);static epsilonValue(){return Math.max(Math.pow(10,-this.settings.precision+this.settings.precisionCompare),Number.EPSILON)}static epsilon=epsilonFactory(ComplexNumber);static random=t=>{if(void 0!==t&&15!==t){if(t<15)return new ComplexNumber(Math.random().toPrecision(t));throw new Error(`invalid number of significant digits: ${t}`)}return new ComplexNumber(Math.random())};static eq=equalsFactory(ComplexNumber,!0);static ne=equalsFactory(ComplexNumber,!1);static compareValue=(t,e,r)=>{switch(t){case"lt":return e<r;case"lte":return e<=r;case"eq":return e===r;case"gte":return e>=r;case"gt":return e>r}};static cmp=cmpFactory(ComplexNumber);static minMaxArrayReal=minMaxArrayRealFactory(ComplexNumber);static minMaxArrayRealWithIndex=minMaxArrayRealWithIndexFactory(ComplexNumber);static minMaxArrayComplex=minMaxArrayComplexFactory(ComplexNumber);static minMaxArrayComplexWithIndex=minMaxArrayComplexWithIndexFactory(ComplexNumber);static min=minMaxFactory(ComplexNumber,"lt");static minWise=minMaxWiseFactory(ComplexNumber,"lt");static max=minMaxFactory(ComplexNumber,"gte");static maxWise=minMaxWiseFactory(ComplexNumber,"gte");static lt=comparisonFactory(ComplexNumber,"lt");static le=comparisonFactory(ComplexNumber,"lte");static gt=comparisonFactory(ComplexNumber,"gt");static ge=comparisonFactory(ComplexNumber,"gte");static false=()=>new ComplexNumber(0,0,ComplexNumber.LOGICAL);static true=()=>new ComplexNumber(1,0,ComplexNumber.LOGICAL);static logical=logicalFactory(ComplexNumber);static toLogical=t=>ComplexNumber.logical(t);toLogical=()=>ComplexNumber.logical(this);static and=andFactory(ComplexNumber);static or=orFactory(ComplexNumber);static xor=xorFactory(ComplexNumber);static not=notFactory(ComplexNumber);static zero=literalFactory(ComplexNumber,0,0);static one=literalFactory(ComplexNumber,1,0);static onediv2=literalFactory(ComplexNumber,.5,0);static minusonediv2=literalFactory(ComplexNumber,-.5,0);static minusone=literalFactory(ComplexNumber,-1,0);static pi=literalFactory(ComplexNumber,Math.PI,0);static pidiv2=literalFactory(ComplexNumber,Math.PI/2,0);static onei=literalFactory(ComplexNumber,0,1);static onediv2i=literalFactory(ComplexNumber,0,.5);static minusonediv2i=literalFactory(ComplexNumber,0,-.5);static minusonei=literalFactory(ComplexNumber,0,-1);static two=literalFactory(ComplexNumber,2,0);static sqrt2pi=literalFactory(ComplexNumber,Math.sqrt(2*Math.PI),0);static e=literalFactory(ComplexNumber,Math.E,0);static NaN_0=literalFactory(ComplexNumber,NaN,0);static inf_0=literalFactory(ComplexNumber,1/0,0);static add=(t,e)=>new ComplexNumber(t.re+e.re,t.im+e.im);static sub=(t,e)=>new ComplexNumber(t.re-e.re,t.im-e.im);static neg=t=>new ComplexNumber(-t.re,-t.im);static mul=mulFactory(Math,ComplexNumber);static mulAndSumTo=mulAndSumToFactory(Math,ComplexNumber);static rdiv=rdivFactory(Math,ComplexNumber);static ldiv=ldivFactory(Math,ComplexNumber);static inv=invFactory(Math,ComplexNumber);static power=powerFactory(Math,ComplexNumber);static root=rootFactory(ComplexNumber);static absValue=absValueFactory(Math);static abs2Value=abs2ValueFactory(Math);static abs=absFactory(Math,ComplexNumber);static abs2=abs2Factory(Math,ComplexNumber);static hypot=hypotFactory(ComplexNumber);static arg=argFactory(Math,ComplexNumber);static conj=conjFactory(Math,ComplexNumber);static mod=modFactory(Math,ComplexNumber);static rem=remFactory(Math,ComplexNumber);static fix=fixFactory(Math,ComplexNumber);static ceil=ceilFactory(Math,ComplexNumber);static floor=floorFactory(Math,ComplexNumber);static round=roundFactory(Math,ComplexNumber);static sign=signFactory(Math,ComplexNumber);static sqrt=sqrtFactory(Math,ComplexNumber);static exp=expFactory(Math,ComplexNumber);static log=logFactory(Math,ComplexNumber);static logb=logbFactory(Math,ComplexNumber);static log2=log2Factory(ComplexNumber);static log10=log10Factory(ComplexNumber);static deg2rad=deg2radFactory(Math,ComplexNumber);static rad2deg=rad2degFactory(Math,ComplexNumber);static sin=sinFactory(Math,ComplexNumber);static sind=sindFactory(ComplexNumber);static cos=cosFactory(Math,ComplexNumber);static cosd=cosdFactory(ComplexNumber);static tan=tanFactory(ComplexNumber);static tand=tandFactory(ComplexNumber);static csc=cscFactory(ComplexNumber);static cscd=cscdFactory(ComplexNumber);static sec=secFactory(ComplexNumber);static secd=secdFactory(ComplexNumber);static cot=cotFactory(ComplexNumber);static cotd=cotdFactory(ComplexNumber);static asin=asinFactory(ComplexNumber);static asind=asindFactory(ComplexNumber);static acos=acosFactory(ComplexNumber);static acosd=acosdFactory(ComplexNumber);static atan=atanFactory(ComplexNumber);static atan2=atan2Factory(Math,ComplexNumber);static atand=atandFactory(ComplexNumber);static acsc=acscFactory(ComplexNumber);static acscd=acscdFactory(ComplexNumber);static asec=asecFactory(ComplexNumber);static asecd=asecdFactory(ComplexNumber);static acot=acotFactory(ComplexNumber);static acotd=acotdFactory(ComplexNumber);static sinh=sinhFactory(Math,ComplexNumber);static cosh=coshFactory(Math,ComplexNumber);static tanh=tanhFactory(ComplexNumber);static csch=cschFactory(ComplexNumber);static sech=sechFactory(ComplexNumber);static coth=cothFactory(ComplexNumber);static asinh=asinhFactory(ComplexNumber);static acosh=acoshFactory(ComplexNumber);static atanh=atanhFactory(ComplexNumber);static acsch=acschFactory(ComplexNumber);static asech=asechFactory(ComplexNumber);static acoth=acothFactory(ComplexNumber);static gamma=gammaFactory(ComplexNumber);static factorial=factorialFactory(Math,ComplexNumber);static applyFunction=applyFunctionFactory(Math);static mapFunction=mapFunctionFactory(ComplexNumber);static twoArgFunction=twoArgFunctionFactory(ComplexNumber)}ComplexNumber.set(ComplexNumber.defaultSettings);const src_ComplexNumber=null,ComplexConfigKeyTable=["precision","precisionCompare","rounding","toExpPos","minE","maxE","toExpNeg","modulo","crypto"],ComplexDecimal_defaultSettings={precision:336,rounding:Decimal.ROUND_HALF_DOWN,toExpPos:20,toExpNeg:-7,minE:-9e15,maxE:9e15,modulo:Decimal.ROUND_DOWN,crypto:!1};Decimal.set(ComplexDecimal_defaultSettings);const decimalBackend=Decimal;decimalBackend.create=t=>new Decimal(t),decimalBackend.neg=t=>t.neg(),decimalBackend.MINUSONE=new Decimal(-1),decimalBackend.ZERO=new Decimal(0),decimalBackend.TWO=new Decimal(2),decimalBackend.PI=Decimal.acos(-1),decimalBackend.PI_DEG=new Decimal(180),decimalBackend.INF=new Decimal(1/0),decimalBackend.unparse=t=>t.valueOf(),decimalBackend.isZero=t=>t.isZero(),decimalBackend.isNeg=t=>t.isNeg(),decimalBackend.isNaN=t=>t.isNaN(),decimalBackend.isFinite=t=>t.isFinite();const setComplexConfigValue=(t,e,r)=>{t[e]=r},setDecimalConfigValue=(t,e,r)=>{t[e]=r};class ComplexDecimal{static LOGICAL=numberClass.LOGICAL;static REAL=numberClass.REAL;static COMPLEX=numberClass.COMPLEX;static defaultSettings=Object.assign({precisionCompare:7},ComplexDecimal_defaultSettings);static settings=ComplexDecimal.defaultSettings;static isInstanceOf=t=>t instanceof ComplexDecimal;static set=t=>{const e={};ComplexConfigKeyTable.forEach(r=>{if(void 0!==t[r]){const s=t[r];"precisionCompare"!==r?(setComplexConfigValue(this.settings,r,s),setDecimalConfigValue(e,r,s)):setComplexConfigValue(this.settings,r,s)}}),Object.keys(e).length>0&&Decimal.set(e)};re;im;type;parent;static setNumberType=setNumberTypeFactory(ComplexDecimal);constructor(t,e,r,s){this.re=new Decimal(void 0!==t?t:0),this.im=new Decimal(void 0!==e?e:0),this.type=r??ComplexDecimal.COMPLEX,this.parent=s??void 0,ComplexDecimal.setNumberType(this)}static create=createFactory(ComplexDecimal);static realSet=(t,e)=>{t.re=new Decimal(e)};static imagSet=(t,e)=>{t.im=new Decimal(e)};static realApply=(t,e)=>{t.re=e(t.re)};static imagApply=(t,e)=>{t.im=e(t.im)};static from=t=>new ComplexDecimal(t.re,t.im,t.type,t.parent);static real=t=>new ComplexDecimal(t.re);static imag=t=>new ComplexDecimal(t.im);static isComplexValue=t=>!t.im.isZero();static isRealValue=t=>t.im.isZero();static realIsInteger=t=>t.re.isInteger();static imagIsInteger=t=>t.im.isInteger();static realIsFinite=t=>t.re.isFinite();static imagIsFinite=t=>t.im.isFinite();static realIsNaN=t=>t.re.isNaN();static imagIsNaN=t=>t.im.isNaN();static realIsNegative=t=>t.re.isNegative();static imagIsNegative=t=>t.im.isNegative();static realIsZero=t=>t.re.isZero();static imagIsZero=t=>t.im.isZero();static realIsPositive=t=>t.re.isPositive();static imagIsPositive=t=>t.im.isPositive();static realToNumber=t=>t.re.toNumber();static toBoolean=t=>t.type===ComplexDecimal.LOGICAL?Boolean(t.re.toNumber()):Boolean(t.re.toNumber())||Boolean(t.im.toNumber());static imagToNumber=t=>t.im.toNumber();static realLessThan=(t,e)=>t.re.lt(e);static imagLessThan=(t,e)=>t.im.lt(e);static realLessThanOrEqualTo=(t,e)=>t.re.lte(e);static imagLessThanOrEqualTo=(t,e)=>t.im.lte(e);static realEquals=(t,e)=>t.re.eq(e);static imagEquals=(t,e)=>t.im.eq(e);static realGreaterThanOrEqualTo=(t,e)=>t.re.gte(e);static imagGreaterThanOrEqualTo=(t,e)=>t.im.gte(e);static realGreaterThan=(t,e)=>t.re.gt(e);static imagGreaterThan=(t,e)=>t.im.gt(e);static parse=parseFactory(ComplexDecimal);static precedence=precedenceFactory(ComplexDecimal);static unparseValue=unparseValueFactory(Decimal,ComplexDecimal);static unparse=unparseFactory(ComplexDecimal);static toString=toStringFactory(ComplexDecimal);toString(){return ComplexDecimal.toString(this)}static unparseMathMLValue=unparseMathMLValueFactory(Decimal,ComplexDecimal);static unparseMathML=unparseMathMLFactory(ComplexDecimal);static copy=copyFactory(ComplexDecimal);copy=()=>new ComplexDecimal(this.re,this.im,this.type);static toMaxPrecisionValue=t=>{const e=this.settings.precision-this.settings.precisionCompare;return t.toSignificantDigits(e).toDecimalPlaces(e)};static toMaxPrecision=toMaxPrecisionFactory(ComplexDecimal);static epsilonValue=()=>Decimal.pow(10,-this.settings.precision+this.settings.precisionCompare);static epsilon=epsilonFactory(ComplexDecimal);static random=t=>new ComplexDecimal(Decimal.random(t));static eq=equalsFactory(ComplexDecimal,!0);static ne=equalsFactory(ComplexDecimal,!1);static compareValue=(t,e,r)=>e[t](r);static cmp=cmpFactory(ComplexDecimal);static minMaxArrayReal=minMaxArrayRealFactory(ComplexDecimal);static minMaxArrayRealWithIndex=minMaxArrayRealWithIndexFactory(ComplexDecimal);static minMaxArrayComplex=minMaxArrayComplexFactory(ComplexDecimal);static minMaxArrayComplexWithIndex=minMaxArrayComplexWithIndexFactory(ComplexDecimal);static min=minMaxFactory(ComplexDecimal,"lt");static minWise=minMaxWiseFactory(ComplexDecimal,"lt");static max=minMaxFactory(ComplexDecimal,"gte");static maxWise=minMaxWiseFactory(ComplexDecimal,"gte");static lt=comparisonFactory(ComplexDecimal,"lt");static le=comparisonFactory(ComplexDecimal,"lte");static gt=comparisonFactory(ComplexDecimal,"gt");static ge=comparisonFactory(ComplexDecimal,"gte");static false=literalFactory(ComplexDecimal,0,0,ComplexDecimal.LOGICAL);static true=literalFactory(ComplexDecimal,1,0,ComplexDecimal.LOGICAL);static logical=logicalFactory(ComplexDecimal);static toLogical=t=>ComplexDecimal.logical(t);toLogical=()=>ComplexDecimal.logical(this);static and=andFactory(ComplexDecimal);static or=orFactory(ComplexDecimal);static xor=xorFactory(ComplexDecimal);static not=notFactory(ComplexDecimal);static zero=literalFactory(ComplexDecimal,0,0);static one=literalFactory(ComplexDecimal,1,0);static onediv2=literalFactory(ComplexDecimal,.5,0);static minusonediv2=literalFactory(ComplexDecimal,-.5,0);static minusone=literalFactory(ComplexDecimal,-1,0);static pi=literalFactory(ComplexDecimal,Decimal.acos(-1),0);static pidiv2=literalFactory(ComplexDecimal,Decimal.div(Decimal.acos(-1),2),0);static onei=literalFactory(ComplexDecimal,0,1);static onediv2i=literalFactory(ComplexDecimal,0,.5);static minusonediv2i=literalFactory(ComplexDecimal,0,-.5);static minusonei=literalFactory(ComplexDecimal,0,-1);static two=literalFactory(ComplexDecimal,2,0);static sqrt2pi=literalFactory(ComplexDecimal,Decimal.sqrt(Decimal.mul(2,Decimal.acos(-1))),0);static e=literalFactory(ComplexDecimal,Decimal.exp(1),0);static NaN_0=literalFactory(ComplexDecimal,NaN,0);static inf_0=literalFactory(ComplexDecimal,1/0,0);static add=(t,e)=>new ComplexDecimal(Decimal.add(t.re,e.re),Decimal.add(t.im,e.im));static sub=(t,e)=>new ComplexDecimal(Decimal.sub(t.re,e.re),Decimal.sub(t.im,e.im));static neg=t=>new ComplexDecimal(t.re.neg(),t.im.neg());static mul=mulFactory(Decimal,ComplexDecimal);static mulAndSumTo=mulAndSumToFactory(Decimal,ComplexDecimal);static rdiv=rdivFactory(Decimal,ComplexDecimal);static ldiv=ldivFactory(Decimal,ComplexDecimal);static inv=invFactory(Decimal,ComplexDecimal);static power=powerFactory(Decimal,ComplexDecimal);static root=rootFactory(ComplexDecimal);static absValue=absValueFactory(Decimal);static abs2Value=abs2ValueFactory(Decimal);static abs=absFactory(Decimal,ComplexDecimal);static abs2=abs2Factory(Decimal,ComplexDecimal);static hypot=hypotFactory(ComplexDecimal);static arg=argFactory(Decimal,ComplexDecimal);static conj=conjFactory(Decimal,ComplexDecimal);static mod=modFactory(Decimal,ComplexDecimal);static rem=remFactory(Decimal,ComplexDecimal);static fix=fixFactory(Decimal,ComplexDecimal);static ceil=ceilFactory(Decimal,ComplexDecimal);static floor=floorFactory(Decimal,ComplexDecimal);static round=roundFactory(Decimal,ComplexDecimal);static sign=signFactory(Decimal,ComplexDecimal);static sqrt=sqrtFactory(Decimal,ComplexDecimal);static exp=expFactory(Decimal,ComplexDecimal);static log=logFactory(Decimal,ComplexDecimal);static logb=logbFactory(Decimal,ComplexDecimal);static log2=log2Factory(ComplexDecimal);static log10=log10Factory(ComplexDecimal);static deg2rad=deg2radFactory(Decimal,ComplexDecimal);static rad2deg=rad2degFactory(Decimal,ComplexDecimal);static sin=sinFactory(Decimal,ComplexDecimal);static sind=sindFactory(ComplexDecimal);static cos=cosFactory(Decimal,ComplexDecimal);static cosd=cosdFactory(ComplexDecimal);static tan=tanFactory(ComplexDecimal);static tand=tandFactory(ComplexDecimal);static csc=cscFactory(ComplexDecimal);static cscd=cscdFactory(ComplexDecimal);static sec=secFactory(ComplexDecimal);static secd=secdFactory(ComplexDecimal);static cot=cotFactory(ComplexDecimal);static cotd=cotdFactory(ComplexDecimal);static asin=asinFactory(ComplexDecimal);static asind=asindFactory(ComplexDecimal);static acos=acosFactory(ComplexDecimal);static acosd=acosdFactory(ComplexDecimal);static atan=atanFactory(ComplexDecimal);static atan2=atan2Factory(Decimal,ComplexDecimal);static atand=atandFactory(ComplexDecimal);static acsc=acscFactory(ComplexDecimal);static acscd=acscdFactory(ComplexDecimal);static asec=asecFactory(ComplexDecimal);static asecd=asecdFactory(ComplexDecimal);static acot=acotFactory(ComplexDecimal);static acotd=acotdFactory(ComplexDecimal);static sinh=sinhFactory(Decimal,ComplexDecimal);static cosh=coshFactory(Decimal,ComplexDecimal);static tanh=tanhFactory(ComplexDecimal);static csch=cschFactory(ComplexDecimal);static sech=sechFactory(ComplexDecimal);static coth=cothFactory(ComplexDecimal);static asinh=asinhFactory(ComplexDecimal);static acosh=acoshFactory(ComplexDecimal);static atanh=atanhFactory(ComplexDecimal);static acsch=acschFactory(ComplexDecimal);static asech=asechFactory(ComplexDecimal);static acoth=acothFactory(ComplexDecimal);static gamma=gammaFactory(ComplexDecimal);static factorial=factorialFactory(Decimal,ComplexDecimal);static applyFunction=applyFunctionFactory(Decimal);static mapFunction=mapFunctionFactory(ComplexDecimal);static twoArgFunction=twoArgFunctionFactory(ComplexDecimal)}ComplexDecimal.set(ComplexDecimal.defaultSettings);const src_ComplexDecimal=null,toNumber=t=>t instanceof Decimal?t.toNumber():Number(t);class Complex{static _engineBackend;static _engine;static get engineBackend(){return this._engineBackend}static get engine(){return this._engine}static set engine(t){switch(this._engine=t,t){case"number":this._engineBackend=ComplexNumber;break;case"decimal":this._engineBackend=ComplexDecimal;break;default:throw new Error(`invalid complex backend engine: '${t}'.`)}ComplexInterfaceStaticKeyTable.forEach(t=>{const e=this._engineBackend;this[t]=e[t]}),this.set(this.defaultSettings)}static LOGICAL;static REAL;static COMPLEX;static defaultSettings;static settings;static isInstanceOf;static set;static setNumberType;static create;static realSet;static imagSet;static realApply;static imagApply;static from;static real;static imag;static isComplexValue;static isRealValue;static realIsFinite;static imagIsFinite;static realIsNaN;static imagIsNaN;static realIsInteger;static imagIsInteger;static realIsNegative;static imagIsNegative;static realIsZero;static imagIsZero;static realIsPositive;static imagIsPositive;static realToNumber;static toBoolean;static imagToNumber;static realLessThan;static imagLessThan;static realLessThanOrEqualTo;static imagLessThanOrEqualTo;static realEquals;static imagEquals;static realGreaterThanOrEqualTo;static imagGreaterThanOrEqualTo;static realGreaterThan;static imagGreaterThan;static parse;static precedence;static unparseValue;static unparse;static toString;static unparseMathMLValue;static unparseMathML;static copy;static toMaxPrecisionValue;static toMaxPrecision;static epsilon;static random;static eq;static ne;static cmp;static minMaxArrayReal;static minMaxArrayRealWithIndex;static minMaxArrayComplex;static minMaxArrayComplexWithIndex;static min;static minWise;static max;static maxWise;static lt;static le;static gt;static ge;static false;static true;static toLogical;static logical;static and;static or;static xor;static not;static zero;static one;static onediv2;static minusonediv2;static minusone;static pi;static pidiv2;static onei;static onediv2i;static minusonediv2i;static minusonei;static two;static sqrt2pi;static e;static NaN_0;static inf_0;static add;static sub;static neg;static mul;static mulAndSumTo;static rdiv;static ldiv;static inv;static power;static root;static abs;static abs2;static hypot;static arg;static conj;static mod;static rem;static fix;static ceil;static floor;static round;static sign;static sqrt;static exp;static log;static logb;static log2;static log10;static deg2rad;static rad2deg;static sin;static sind;static cos;static cosd;static tan;static tand;static csc;static cscd;static sec;static secd;static cot;static cotd;static asin;static asind;static acos;static acosd;static atan;static atan2;static atand;static acsc;static acscd;static asec;static asecd;static acot;static acotd;static sinh;static cosh;static tanh;static csch;static sech;static coth;static asinh;static acosh;static atanh;static acsch;static asech;static acoth;static gamma;static factorial;static applyFunction;static mapFunction;static twoArgFunction}Complex.engine="decimal";const src_Complex=null,singleQuoteCharacter="'",doubleQuoteCharacter='"',stringClass=3;class CharString{characters;quote;static STRING=stringClass;type=CharString.STRING;parent;constructor(t,e=doubleQuoteCharacter){this.characters=t.split(""),this.quote=e}get str(){return this.characters.join("")}set str(t){this.characters=t.split("")}get length(){return this.characters.length}get dimension(){return[1,this.length]}static create=(t,e='"')=>new CharString(t,e);static isInstanceOf=t=>t instanceof CharString;static isChar=t=>CharString.isInstanceOf(t)&&t.quote===singleQuoteCharacter;static isString=t=>CharString.isInstanceOf(t)&&t.quote===doubleQuoteCharacter;static copy=t=>new CharString(t.str,t.quote);copy(){return new CharString(this.str,this.quote)}static vector=t=>t.characters.slice();vector(){return CharString.vector(this)}static toCharacterScalars=t=>t.characters.map(e=>new CharString(e,t.quote));toCharacterScalars(){return CharString.toCharacterScalars(this)}static fromCharacterScalars=(t,e=t[0]?.quote??doubleQuoteCharacter)=>new CharString(t.map(t=>t.str).join(""),e);static fromNumericCode=(t,e=doubleQuoteCharacter)=>{const r=Math.max(0,Math.min(65535,Math.trunc(t)));return new CharString(String.fromCharCode(r),e)};characterAt(t){const e=this.characters[t];return void 0===e?void 0:new CharString(e,this.quote)}select(t){return new CharString(t.map(t=>this.characters[t]).filter(t=>void 0!==t).join(""),this.quote)}static parse=t=>new CharString(t);static unparse=(t,e=0)=>t.str;static toString=t=>t.str;toString(){return this.str}static unparseEscaped=t=>{let e=JSON.stringify(t.str);return e=e.substring(1,e.length-1).replace(/\\\\/,"\\").replace(/\\\"/,'""'),'"'+e+'"'};static unparseMathML=(t,e=0)=>"<mi><pre>"+t.str+"</pre></mi>";static unparseEscapedMathML=t=>{let e=JSON.stringify(t.str);return e=e.substring(1,e.length-1).replace(/\\\\/,"\\").replace(/\\\"/,'""'),'<mi><pre>"'+e+'"</pre></mi>'};static logical=t=>t.str?Complex.true():Complex.false();static toLogical=t=>CharString.logical(t);toLogical(){return CharString.logical(this)}}const src_CharString=null;class RuntimeValue{static FUNCTION_HANDLE=5;static CLASS_INSTANCE=7;static structureFactory;static hasCopy=t=>!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof Reflect.get(t,"copy");static copy=t=>RuntimeValue.hasCopy(t)?t.copy():t;static hasOwnField=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);static registerStructureFactory=t=>{RuntimeValue.structureFactory=t};static createStructure=t=>{if(!RuntimeValue.structureFactory)throw new Error("runtime structure factory is not registered.");return RuntimeValue.structureFactory(t)};static isClassInstance=t=>"object"==typeof t&&null!==t&&Reflect.get(t,"type")===RuntimeValue.CLASS_INSTANCE&&RuntimeValue.isNamedClassDefinition(Reflect.get(t,"classDefinition"))&&RuntimeValue.isObjectRecord(Reflect.get(t,"properties"));static classDefinitionOfInstance=t=>RuntimeValue.isClassInstance(t)?t.classDefinition:void 0;static hasDimensions=t=>"object"==typeof t&&null!==t&&RuntimeValue.isNumericDimensionVector(Reflect.get(t,"dimension"));static isObjectRecord=t=>"object"==typeof t&&null!==t;static isNamedClassDefinition=t=>RuntimeValue.isObjectRecord(t)&&"string"==typeof Reflect.get(t,"name");static isNumericDimensionVector=t=>Array.isArray(t)&&t.every(t=>"number"==typeof t);static dimensions=(t,e=2)=>{const r=RuntimeValue.hasDimensions(t)?t.dimension.slice():[1,1];for(;r.length<e;)r.push(1);return r};static elementCount=t=>RuntimeValue.dimensions(t).reduce((t,e)=>t*e,1);static isEmpty=t=>RuntimeValue.dimensions(t).some(t=>0===t);static isScalar=t=>1===RuntimeValue.elementCount(t);static isMatrix=t=>2===RuntimeValue.dimensions(t).length;static isVector=t=>{const e=RuntimeValue.dimensions(t);return 2===e.length&&(1===e[0]||1===e[1])};static isRowVector=t=>{const e=RuntimeValue.dimensions(t);return 2===e.length&&1===e[0]};static isColumnVector=t=>{const e=RuntimeValue.dimensions(t);return 2===e.length&&1===e[1]};static isSquareMatrix=t=>{const e=RuntimeValue.dimensions(t);return 2===e.length&&e[0]===e[1]}}const src_RuntimeValue=null,nodeReturnList=(t,e)=>({type:"RETLIST",selector:t,handler:e}),throwErrorIfGreaterThanReturnList=(t,e)=>{if(e>t)throw new EvalError(`element number ${e} undefined in return list`)},nodeBoundedReturnList=(t,e,r)=>nodeReturnList((r,s)=>(throwErrorIfGreaterThanReturnList(t,r.length),e(r,s)),e=>(throwErrorIfGreaterThanReturnList(t,e),r?r(e):{length:e})),throwInvalidCallError=t=>{throw new EvalError(`Invalid call to ${t}.`)};class MultiArray{dimension;get dimensionR(){return[this.dimension[0],...this.dimension.slice(2)]}array;type;static isInstanceOf=t=>t instanceof MultiArray;static isIndexArgument(t){return Complex.isInstanceOf(t)||MultiArray.isInstanceOf(t)}static indexArguments(t,e="index"){return t.map((t,r)=>{if(!MultiArray.isIndexArgument(t))throw new EvalError(`${e}${r+1}: invalid subscript type.`);return t})}static numericElement=(t,e)=>{if(!Complex.isInstanceOf(t))throw new TypeError(`${e}: expected numeric array element.`);return t};static LOGICAL=Complex.LOGICAL;static REAL=Complex.REAL;static COMPLEX=Complex.COMPLEX;static STRING=CharString.STRING;static STRUCTURE=4;static FUNCTION_HANDLE=RuntimeValue.FUNCTION_HANDLE;isCell;parent;static invalidStructureReferenceMessage="value cannot be indexed with .";constructor(t,e,r){if(t)if(this.dimension=t.slice(),MultiArray.appendSingletonTail(this.dimension,2),MultiArray.removeSingletonTail(this.dimension),e)if("function"==typeof e)this.array=Array.from({length:t[0]*t.slice(2).reduce((t,e)=>t*e,1)},(r,s)=>Array.from({length:t[1]},(r,i)=>e(...MultiArray.rowColumnToSubscript(t,s,i))));else if(Array.isArray(e)&&Array.isArray(e[0]))this.array=e.map(t=>t.map(t=>RuntimeValue.copy(t)));else{this.array=new Array(this.dimensionR.reduce((t,e)=>t*e,1));for(let t=0;t<this.array.length;t++){this.array[t]=new Array(this.dimension[1]);for(let r=0;r<this.dimension[1];r++)this.array[t][r]=RuntimeValue.copy(e)}this.type=e.type}else this.array=Array.from({length:t[0]*t.slice(2).reduce((t,e)=>t*e,1)},e=>Array.from({length:t[1]},t=>Complex.zero())),this.type=-1;else this.dimension=[0,0],this.array=[],this.type=-1;this.isCell=r??!1}static isScalar=t=>!(t instanceof MultiArray&&t.dimension.reduce((t,e)=>t*e,1)>1);static isRowVector=t=>t instanceof MultiArray&&2===t.dimension.length&&1===t.dimension[0];static toRowVector=t=>{const e=new MultiArray([1,t.length]);return e.array[0]=t.slice(),e};static fromRowVector=t=>t.array[0];static isColumnVector=t=>t instanceof MultiArray&&2===t.dimension.length&&1===t.dimension[1];static toColumnVector=t=>{const e=new MultiArray([t.length,1]);return e.array.map((e,r,s)=>s[r][0]=t[r]),e};static fromColumnVector=t=>t.array.map(t=>t[0]);static arrayIsVector=t=>2===t.dimension.length&&(1===t.dimension[0]||1===t.dimension[1]);static isVector=t=>t instanceof MultiArray&&2===t.dimension.length&&(1===t.dimension[0]||1===t.dimension[1]);static toDiagonalMatrix=t=>{const e=new MultiArray([t.length,t.length]);return e.array.map((e,r,s)=>s[r][r]=t[r]),e};static isMatrix=t=>!(t instanceof MultiArray)||2===t.dimension.length;static isEmpty=t=>t instanceof MultiArray&&0===t.dimension.reduce((t,e)=>t*e,1);static isReducedArrayLine=t=>Array.isArray(t);static isReducedComplexArrayLine=t=>MultiArray.isReducedArrayLine(t)&&t.every(Complex.isInstanceOf);static isCellArray=t=>t instanceof MultiArray&&t.isCell;static isComplexMultiArray=t=>{let e=!1;for(let r=0;r<t.dimensionR.reduce((t,e)=>t*e,1);r++)for(let s=0;s<t.dimension[1];s++)if(Complex.isComplexValue(MultiArray.numericElement(t.array[r][s],"isComplexMultiArray"))){e=!0;break}return e};static setType=t=>{t.type=Math.max(...t.array.map(t=>Math.max(...t.map(t=>t.type))))};static arrayEquals=(t,e)=>t.length===e.length&&t.every((t,r)=>t===e[r]);static rangeArray=t=>{const e=[];for(let r=1;r<=t;r++)e.push(r);return e};static linearIndexToSubscript=(t,e)=>t.map((r,s)=>Math.floor(e/t.slice(0,s).reduce((t,e)=>t*e,1))%r+1);static subscriptToLinearIndex=(t,e)=>e.reduce((e,r,s)=>e+(r-1)*t.slice(0,s).reduce((t,e)=>t*e,1),0);static linearIndexToMultiArrayRowColumn=(t,e,r)=>{const s=t*e,i=r%s;return[Math.floor(r/s)*t+i%t,Math.floor(i/t)]};static subscriptToMultiArrayRowColumn=(t,e)=>{const r=e.reduce((e,r,s)=>e+(r-1)*t.slice(0,s).reduce((t,e)=>t*e,1),0),s=t[0]*t[1],i=r%s;return[Math.floor(r/s)*t[0]+i%t[0],Math.floor(i/t[0])]};static rowColumnToLinearIndex=(t,e,r)=>Math.floor(e/t[0])*t[0]*t[1]+r*t[0]+e%t[0];static rowColumnToSubscript=(t,e,r)=>{const s=Math.floor(e/t[0])*t[0]*t[1]+r*t[0]+e%t[0];return t.map((e,r)=>Math.floor(s/t.slice(0,r).reduce((t,e)=>t*e,1))%e+1)};static computeStrides=t=>{const e=new Array(t.length);let r=1;for(let s=0;s<t.length;s++)e[s]=r,r*=t[s];return e};static getStride=(t,e)=>t.dimension.slice(e+1).reduce((t,e)=>t*e,1);static pageSlice=(t,e)=>{const r=t.dimension;if(r.length<=2)return t.array.map(t=>t.map(t=>MultiArray.numericElement(t,"pageSlice")));const[s,i]=r.slice(-2),n=r.slice(0,-2).reduce((t,e)=>t*e,1);if(e>=n)throw new RangeError(`pageSlice: invalid page index ${e}/${n}`);const a=MultiArray.flatten(t).map(t=>MultiArray.numericElement(t,"pageSlice")),o=e*s*i,l=[];for(let t=0;t<s;t++){const e=[];for(let r=0;r<i;r++)e.push(a[o+t+r*s]);l.push(e)}return l};static setPage=(t,e,r)=>{const[s,i,...n]=t.dimension,a=n.reduce((t,e)=>t*e,1)||1;if(e>=a)throw new RangeError(`setPage: invalid page index ${e}/${a}`);const o=e*s;for(let e=0;e<s;e++)t.array[o+e].splice(0,i,...r[e])};static toFlatArray=t=>{const e=t.dimension,r=e.reduce((t,e)=>t*e,1),s=new Array(r);for(let i=0;i<r;i++){const[r,n]=MultiArray.linearIndexToMultiArrayRowColumn(e[0],e[1],i);if(!t.array[r]||void 0===t.array[r][n])throw new Error(`toFlatArray: missing element at linear ${i} -> array[${r}][${n}] is undefined.`);s[i]=MultiArray.numericElement(t.array[r][n],"toFlatArray")}return s};static fromFlatArray=(t,e)=>{const r=t.dimension,s=r.reduce((t,e)=>t*e,1);if(e.length!==s)throw new Error(`fromFlatArray: length mismatch (flat ${e.length} vs expected ${s}).`);const i=r[0],n=r.slice(2).reduce((t,e)=>t*e,1),a=i*Math.max(1,n);if(!Array.isArray(t.array)||t.array.length!==a){t.array=new Array(a);for(let e=0;e<a;e++)t.array[e]=new Array(r[1]).fill(void 0)}for(let i=0;i<s;i++){const[s,n]=MultiArray.linearIndexToMultiArrayRowColumn(r[0],r[1],i);t.array[s][n]=e[i]}};static sameSizeExcept=(t,e)=>{const r=t.dimension,s=e.dimension;if(r.length!==s.length)return!1;let i=!0;for(let t=0;t<r.length;t++)if(r[t]!==s[t]){i=!1;break}if(i)return!0;for(let t=0;t<r.length;t++)if(3===r[t]&&3===s[t]){let e=!0;for(let i=0;i<r.length;i++)if(i!==t&&r[i]!==s[i]){e=!1;break}if(e)return!0}return!1};static ind2subNumber=(t,e)=>(t=[...t,e+1]).map((r,s)=>Math.floor((e-1)/t.slice(0,s).reduce((t,e)=>t*e,1))%r).map(t=>t+1);static linearLength=t=>t.array.length*t.dimension[1];static getDimension=(t,e)=>e<t.dimension.length?t.dimension[e]:1;static removeSingletonTail=t=>{let e=t.length-1;for(;1===t[e]&&e>1;)t.pop(),e--};static appendSingletonTail=(t,e)=>{e>t.length&&t.push(...new Array(e-t.length).fill(1))};static firstNonSingleDimension=t=>{if(!t.dimension||0===t.dimension.length)return 0;const e=t.dimension.findIndex(t=>t>1);return e>=0?e:0};static linkArrayElementParent=(t,e)=>{t&&"object"==typeof t&&(t.parent=e)};static firstRow=(t,e)=>{const r=new MultiArray([1,t.length]);return r.array[0]=t,r.array[0].forEach(t=>MultiArray.linkArrayElementParent(t,r)),r.isCell=e??!1,r};static appendRow=(t,e)=>(e.forEach(e=>MultiArray.linkArrayElementParent(e,t)),t.array.push(e),t.dimension[0]++,t);static unparse=(t,e,r=0)=>{const s=t=>t.map(t=>e.Unparse(t)).join()+";\n";let i="";if(0===t.dimension.reduce((t,e)=>t*e,1))return`${t.isCell?"{ }":"[ ]"}(${t.dimension.join("x")})`;if(t.dimension.length>2){let e="";for(let r=0;r<t.array.length;r+=t.dimension[0])i=t.array.slice(r,r+t.dimension[0]).map(s).join(""),i=i.substring(0,i.length-2),e+=`${t.isCell?"{":"["}${i}${t.isCell?"}":"]"} (:,:,${MultiArray.linearIndexToSubscript(t.dimensionR,r).slice(1).join()})\n`;return e}return i=t.array.map(s).join(""),i=i.substring(0,i.length-2),`${t.isCell?"{":"["}${i}${t.isCell?"}":"]"}`};toString(){return`array ${this.dimension.join("x")}`}static unparseMathML=(t,e,r=0)=>{const s=t=>`<mtr>${t.map(t=>`<mtd>${e.UnparserMathML(t)}</mtd>`).join("")}</mtr>`,i=e=>`<mrow><mo fence="true" stretchy="true">${t.isCell?"{":"["}</mo><mtable>${e}</mtable><mo fence="true" stretchy="true">${t.isCell?"}":"]"}</mo></mrow>`;if(0===t.dimension.reduce((t,e)=>t*e,1))return`${i('<mspace width="0.5em"/>')}<mo fence="true" stretchy="true">(</mo><mn>${t.dimension.join("</mn><mi>×</mi><mn>")}</mn><mo fence="true" stretchy="true">)</mo>`;if(t.dimension.length>2){let e="";for(let r=0;r<t.array.length;r+=t.dimension[0]){const n=t.array.slice(r,r+t.dimension[0]).map(s).join(""),a=MultiArray.linearIndexToSubscript(t.dimensionR,r).slice(1).map(t=>`<mn>${t}</mn>`).join("<mo>,</mo>");e+=`<mtr><mtd><msub>${i(n)}<mrow><mo fence="true" stretchy="true">(</mo><mo>:</mo><mo>,</mo><mo>:</mo><mo>,</mo>${a}<mo fence="true" stretchy="true">)</mo></mrow></msub></mtd></mtr>`}return`<mtable>${e}</mtable>`}return i(t.array.map(s).join(""))};static fromCharString=t=>{if(t.length>0){const e=new MultiArray(t.dimension);return e.array=[t.vector().map(t=>Complex.create(t.charCodeAt(0)))],e.type=Complex.REAL,MultiArray.MultiArrayToScalar(e)}return MultiArray.emptyArray()};static characterVectorFromCharString=t=>{const e=new MultiArray(t.dimension);return e.array[0]=t.toCharacterScalars(),e.type=CharString.STRING,e};static charStringFromCharacterVectorResult=(t,e)=>{const r=MultiArray.isInstanceOf(t)?MultiArray.linearize(t):[t];if(0===r.length)return CharString.create("",e);if(!MultiArray.isCharStringList(r))throw new EvalError("character string indexing produced a non-character value.");return CharString.fromCharacterScalars(r,e)};static flatten=t=>{const e=[];for(let r=0;r<t.array[0].length;r++)for(let s=0;s<t.array.length;s++)e.push(t.array[s][r]);return e};static linearize=t=>{if(t instanceof MultiArray){const e=t.dimension[0],r=t.dimension[1],s=new Array(MultiArray.linearLength(t));let i=0;for(let n=0;n<t.array.length;n+=e)for(let a=0;a<r;a++)for(let r=0;r<e;r++)s[i++]=t.array[n+r][a];return s}return[t]};static emptyArray=t=>{const e=new MultiArray([0,0]);return e.isCell=t??!1,e};static isObjectRecord=t=>"object"==typeof t&&null!==t;static isElementRecord=t=>MultiArray.isObjectRecord(t)&&!Array.isArray(t)&&Object.values(t).every(t=>null!=t);static isStructureScalar=t=>MultiArray.isObjectRecord(t)&&Reflect.get(t,"type")===MultiArray.STRUCTURE&&MultiArray.isElementRecord(Reflect.get(t,"field"));static structureElements=t=>{if(MultiArray.isStructureScalar(t))return[t];if(t instanceof MultiArray&&!t.isCell){const e=MultiArray.linearize(t);return 0!==e.length&&e.every(MultiArray.isStructureScalar)?e:[]}return[]};static structureFieldValue=t=>t??MultiArray.emptyArray();static structureFieldNames=t=>Object.keys(MultiArray.structureElements(t)[0]?.field??{}).sort();static createStructureValue=t=>{const e=RuntimeValue.createStructure(t);if(!MultiArray.isStructureScalar(e))throw new Error("runtime structure factory returned an invalid structure value.");return e};static isCharStringList=t=>t.length>0&&t.every(t=>CharString.isInstanceOf(t));static cloneStructureFields=t=>{const e=MultiArray.createStructureValue({});return Object.keys(t.field).forEach(t=>{e.field[t]=MultiArray.emptyArray()}),e};static structureHasField=(t,e)=>{const r=MultiArray.structureElements(t);return r.length>0&&r.every(t=>RuntimeValue.hasOwnField(t.field,e))};static structureCollectFieldPath=(t,e)=>{if(0===e.length)return[t];const r=MultiArray.structureElements(t);if(r.length>0&&t instanceof MultiArray)return r.flatMap(t=>MultiArray.structureCollectFieldPath(t,e));if(MultiArray.isStructureScalar(t)){const r=t.field[e[0]];if(void 0===r)throw new EvalError(MultiArray.invalidStructureReferenceMessage);return 1===e.length?[r]:MultiArray.structureCollectFieldPath(r,e.slice(1))}throw new EvalError(MultiArray.invalidStructureReferenceMessage)};static getStructureField=(t,e)=>{const r=MultiArray.structureCollectFieldPath(t,e);return 1===r.length?r[0]:MultiArray.toRowVector(r)};static structureAssignFieldPath=(t,e,r)=>{if(t instanceof MultiArray){const s=MultiArray.structureElements(t);if(0===s.length)throw new EvalError(MultiArray.invalidStructureReferenceMessage);return void s.forEach(t=>MultiArray.structureAssignFieldPath(t,e,r))}if(!MultiArray.isStructureScalar(t)||0===e.length)throw new EvalError(MultiArray.invalidStructureReferenceMessage);if(1===e.length)return void(t.field[e[0]]=MultiArray.structureFieldValue(r));const s=e[0],i=t.field[s];if(void 0===i||MultiArray.isEmpty(i))t.field[s]=MultiArray.cloneStructureFields(t);else if(!MultiArray.isStructureScalar(i)&&0===MultiArray.structureElements(i).length)throw new EvalError(MultiArray.invalidStructureReferenceMessage);MultiArray.structureAssignFieldPath(t.field[s],e.slice(1),r)};static setEmptyStructureField=(t,e)=>{const r=MultiArray.structureElements(t);if(0===r.length)throw new EvalError(MultiArray.invalidStructureReferenceMessage);t.isCell||MultiArray.structureHasField(t,e)||r.forEach(t=>{t.field[e]=MultiArray.emptyArray()})};static blankValueForExpansion=t=>MultiArray.isStructureScalar(t)?MultiArray.cloneStructureFields(t):RuntimeValue.isClassInstance(t)?RuntimeValue.copy(t):CharString.isInstanceOf(t)?CharString.create(" ",t.quote):Complex.zero();static scalarToMultiArrayWithTest=(t,e)=>{if(t instanceof MultiArray&&e)return t;{const e=new MultiArray([1,1]);return e.array[0]=[t],e.type=t.type??-1,e}};static scalarToMultiArray=t=>MultiArray.scalarToMultiArrayWithTest(t,!(MultiArray.isInstanceOf(t)&&t.isCell));static scalarOrCellToMultiArray=t=>MultiArray.scalarToMultiArrayWithTest(t,!0);static MultiArrayToScalar=t=>t instanceof MultiArray&&2===t.dimension.length&&1===t.dimension[0]&&1===t.dimension[1]?t.array[0][0]:t;static firstElement=t=>t instanceof MultiArray&&t.dimension.reduce((t,e)=>t*e,1)>0?t.array[0][0]:t;static firstVector=t=>t instanceof MultiArray?1===t.dimension[0]?t.array[0]:t.array.map(t=>t[0]):[t];static copy=t=>{const e=new MultiArray(t.dimension,void 0,t.isCell);return e.array=t.array.map(t=>t.map(t=>RuntimeValue.copy(t))),e.type=t.type,e};copy(){const t=new MultiArray(this.dimension,void 0,this.isCell);return t.array=this.array.map(t=>t.map(t=>RuntimeValue.copy(t))),t.type=this.type,t}static toLogical=t=>{if(t.dimension.some(t=>0===t))return Complex.false();for(let e=0;e<t.array.length;e++){const r=t.array[e];for(let e=0;e<t.dimension[1];e++){const t=MultiArray.numericElement(r[e],"toLogical").toLogical();if(Complex.realEquals(t,0))return Complex.false()}}return Complex.true()};toLogical(){if(this.dimension.some(t=>0===t))return Complex.false();for(let t=0;t<this.array.length;t++){const e=this.array[t];for(let t=0;t<this.dimension[1];t++){const r=MultiArray.numericElement(e[t],"toLogical").toLogical();if(Complex.realEquals(r,0))return Complex.false()}}return Complex.true()}static expand=(t,e,r)=>{let s=t.dimension.slice(),i=e.slice();s.length<i.length&&(s=s.concat(new Array(i.length-s.length).fill(1))),i.length<s.length&&(i=i.concat(new Array(s.length-i.length).fill(1)));const n=i.map((t,e)=>Math.max(t,s[e]));if(MultiArray.arrayEquals(s,n))return;const a=r?MultiArray.blankValueForExpansion(r):t.isCell?MultiArray.emptyArray():MultiArray.blankValueForExpansion(t.array[0]?.[0]),o=new MultiArray(n,a,t.isCell);for(let e=0;e<MultiArray.linearLength(t);e++){const[r,s]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],e),i=MultiArray.linearIndexToSubscript(t.dimension,e),[n,a]=MultiArray.subscriptToMultiArrayRowColumn(o.dimension,i);o.array[n][a]=t.array[r][s]}MultiArray.removeSingletonTail(o.dimension),t.dimension=o.dimension,t.array=o.array};static reshape=(t,e,r=-1)=>{const s=t.dimension.reduce((t,e)=>t*e,1),i=e.slice();if(-1!==r){i[r]=1;const t=i.reduce((t,e)=>t*e,1);if(!(t<=s&&Number.isInteger(s/t)))throw new Error(`reshape: SIZE is not divisible by the product of known dimensions (= ${t})`);i[r]=s/t}else if(s!==i.reduce((t,e)=>t*e,1))throw new Error(`reshape: can't reshape ${t.dimension.join("x")} array to ${i.join("x")} array`);let n;return t.dimension[1]===i[1]?(n=MultiArray.copy(t),n.dimension=i):(n=new MultiArray(i),MultiArray.rawMapLinearIndex(t,(t,e)=>{const[r,s]=MultiArray.linearIndexToMultiArrayRowColumn(n.dimension[0],n.dimension[1],e);return n.array[r][s]=t,t})),n.type=t.type,n.isCell=t.isCell,MultiArray.removeSingletonTail(n.dimension),n};static expandRange=(t,e,r)=>{const s=[],i=r?Complex.realToNumber(r):1;for(let r=Complex.realToNumber(t),n=0;i>0?r<=Complex.realToNumber(e):r>=Complex.realToNumber(e);r+=i,n++)s[n]=Complex.create(r);const n=new MultiArray([1,s.length]);return n.array=[s],MultiArray.setType(n),n};static expandColon=t=>{const e=new MultiArray([t,1]);for(let r=0;r<t;r++)e.array[r]=[Complex.create(r+1)];return MultiArray.setType(e),e};static haveAnyComplex=t=>{for(let e=0;e<t.dimension[0];e++)for(let r=0;r<t.dimension[1];r++)if(!Complex.imagIsZero(MultiArray.numericElement(t.array[e][r],"haveAnyComplex")))return!0;return!1};static testInteger=(t,e,r,s)=>{const i=(t,e,r)=>{throw new RangeError((t?t+": ":"")+e+" must be "+r)};if(Complex.realIsInteger(t)&&!Complex.realLessThan(t,1)||i(e,r,"either integers greater than or equal 1 or logicals."),!Complex.imagEquals(t,0))throw i(e,r,"real."),new RangeError((e?e+": ":"")+r+" must be real.");const n=Complex.realToNumber(t),a=typeof s;return"undefined"!==a&&("number"===a?n>s&&i(e,r,"less than or equal to "+s+" "):(n<s[0]&&i(e,r,"greater than or equal to"+s[0]+" "),n>s&&i(e,r,"less than or equal to"+s[1]+" "))),n};static testIndex=(t,e)=>{if(!Complex.realIsInteger(t)||Complex.realLessThan(t,1))throw new RangeError((e?`${e}: `:"")+"subscripts must be either integers greater than or equal 1 or logicals.");if(!Complex.imagEquals(t,0))throw new RangeError((e?`${e}: `:"")+"subscripts must be real.");return Complex.realToNumber(t)};static testIndexBound=(t,e,r,s)=>{const i=MultiArray.testIndex(t,s);if(i>e)throw new RangeError(`${s?`${s}: `:""}out of bound ${e} (dimensions are ${r.join("x")}).`);return i};static parseSubscript=(t,e,r,s)=>{const i=e.map(t=>MultiArray.testIndex(t,`${r||""}${s?"("+e.map(t=>s.Unparse(t)).join()+")":""}`)),n=(e,s)=>{const n=t=>t>4?`...[x${t}]...`:new Array(t).fill("_").join(),a=n(e),o=n(i.length-e-1);throw new RangeError(`${r||""}(${a}${a?",":""}${i[e]}${o?",":""}${o}): out of bound ${s} (dimensions are ${t.join("x")}).`)},a=i.slice();if(MultiArray.removeSingletonTail(a),a.length>t.length){const e=i.map((e,r)=>e>t[r]).indexOf(!0);e>=0&&n(e,1)}let o;if(i.length<t.length){o=t.slice();const e=i.map((e,r)=>e>t[r]).indexOf(!0);if(e>=0)if(e===i.length-1){const t=o.slice(i.length-1).reduce((t,e)=>t*e,1);i[i.length-1]>t&&n(e,t)}else n(e,o[e])}else{o=t.concat(new Array(i.length-t.length).fill(1));const e=i.map((e,r)=>e>t[r]).indexOf(!0);e>=0&&n(e,o[e])}return a.reduce((e,r,s)=>e+(r-1)*t.slice(0,s).reduce((t,e)=>t*e,1),0)};static scalarOpMultiArray=(t,e,r)=>{const s=new MultiArray(r.dimension);return s.array=r.array.map(r=>r.map(r=>Complex[t](e,r))),MultiArray.setType(s),s};static MultiArrayOpScalar=(t,e,r)=>{const s=new MultiArray(e.dimension);return s.array=e.array.map(e=>e.map(e=>Complex[t](e,r))),MultiArray.setType(s),s};static leftOperation=(t,e)=>{const r=new MultiArray(e.dimension);return r.array=e.array.map(e=>e.map(e=>Complex[t](e))),MultiArray.setType(r),r};static elementWiseOperation=(t,e,r)=>{let s=e.dimension.slice(),i=r.dimension.slice();const n=Math.max(s.length,i.length);for(;s.length<n;)s.push(1);for(;i.length<n;)i.push(1);const a=new Array(n),o=new Array(n),l=new Array(n);for(let e=0;e<n;e++){const r=s[e],n=i[e];if(r===n)a[e]=r,o[e]=l[e]=!1;else if(1===r)a[e]=n,o[e]=!0,l[e]=!1;else{if(1!==n)throw new EvalError(`operator ${t}: nonconformant arguments (op1 is ${s.join("x")}, op2 is ${i.join("x")}).`);a[e]=r,o[e]=!1,l[e]=!0}}const c=MultiArray.computeStrides(s),u=MultiArray.computeStrides(i),h=MultiArray.computeStrides(a),d=a.reduce((t,e)=>t*e,1),m=new MultiArray(a),p=s[0],f=p*(s[1]||1),g=i[0],y=g*(i[1]||1),x=a[0],C=x*(a[1]||1);for(let s=0;s<d;s++){let i=0,d=0;for(let t=0;t<n;t++){const e=Math.floor(s/h[t])%a[t],r=o[t]?0:e,n=l[t]?0:e;i+=r*c[t],d+=n*u[t]}const A=Math.floor(i/f),S=i-A*f,E=A*p+S%p,_=Math.floor(S/p),b=Math.floor(d/y),M=d-b*y,T=b*g+M%g,v=Math.floor(M/g),L=Math.floor(s/C),N=s-L*C,I=L*x+N%x,w=Math.floor(N/x);m.array[I][w]=Complex[t](e.array[E][_],r.array[T][v])}return MultiArray.setType(m),m};static rawMap=(t,e)=>{const r=new MultiArray(t.dimension);return r.array=t.array.map(t=>t.map(e)),MultiArray.setType(r),r};static rawMapRowColumn=(t,e)=>{const r=new MultiArray(t.dimension);return r.array=t.array.map((t,r)=>t.map((t,s)=>e(t,r,s))),MultiArray.setType(r),r};static rawMapLinearIndex=(t,e)=>{const r=new MultiArray(t.dimension);return r.array=t.array.map((r,s)=>r.map((r,i)=>e(r,Math.floor(s/t.dimension[0])*t.dimension[0]*t.dimension[1]+i*t.dimension[0]+s%t.dimension[0],s,i))),MultiArray.setType(r),r};static alongDimensionMap=(t,e,r)=>{const s=new MultiArray(e.dimension);if(t>=e.dimension.length)s.array=e.array.map((t,e)=>t.map((t,s)=>r(t,0,e,s)));else{const i=e.dimension.slice();i[t]=1;const n=i.reduce((t,e)=>t*e,1),a=i.map(t=>MultiArray.rangeArray(t));for(let o=0;o<n;o++)for(let n=1;n<=e.dimension[t];n++){const l=a.slice();l[t]=[n];const c=MultiArray.linearIndexToSubscript(i,o).map((t,e)=>l[e][t-1]),[u,h]=MultiArray.subscriptToMultiArrayRowColumn(e.dimension,c);s.array[u]||(s.array[u]=[]),s.array[u][h]=r(e.array[u][h],c[t]-1,u,h)}}return MultiArray.setType(s),s};static sizeAlongDimension=(t,e)=>{const r=void 0!==e?Complex.realToNumber(MultiArray.firstElement(e))-1:Math.max(0,MultiArray.firstNonSingleDimension(t));return t.dimension[r]};static getElementAlongDimension=(t,e,r)=>{const s=t.dimension;if(e<0||e>=s.length)throw new RangeError(`getElementAlongDimension: invalid dimension ${e} for array of ${s.length}D`);if(r<0||r>=s[e])throw new RangeError(`getElementAlongDimension: index ${r} out of bounds for dimension ${e} of size ${s[e]}`);const i=new Array(s.length).fill(1);i[e]=r+1;const n=MultiArray.subscriptToLinearIndex(s,i),[a,o]=MultiArray.linearIndexToMultiArrayRowColumn(s[0],s[1],n);return t.array[a][o]};static divideElementByScalar=(t,e)=>MultiArray.isInstanceOf(t)?MultiArray.rawMap(t,t=>Complex.rdiv(t,e)):Complex.rdiv(t,e);static getMeanElementForPosition=(t,e,r)=>MultiArray.isInstanceOf(t)?MultiArray.getElementAlongDimension(t,e,r-1):t;static reduceToArray=(t,e)=>{if(t>=e.dimension.length){const t=new MultiArray(e.dimension);return t.array=e.array.map(t=>t.map(t=>[t])),t.type=e.type,t}{const r=e.dimension.slice();r[t]=1;const s=new MultiArray(r),i=e.dimension.slice();i[t]=1;const n=i.reduce((t,e)=>t*e,1);for(let r=1;r<=e.dimension[t];r++){const i=e.dimension.slice();i[t]=1;const a=i.map(t=>MultiArray.rangeArray(t));a[t]=[r];for(let t=0;t<n;t++){const n=MultiArray.linearIndexToSubscript(i,t).map((t,e)=>a[e][t-1]),o=MultiArray.subscriptToLinearIndex(e.dimension,n),[l,c]=MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],o),[u,h]=MultiArray.linearIndexToMultiArrayRowColumn(s.dimension[0],s.dimension[1],t);if(1===r)s.array[u][h]=[e.array[l][c]];else{const t=s.array[u][h];if(!MultiArray.isReducedArrayLine(t))throw new Error("reduceToArray: invalid reduced slot.");t.push(e.array[l][c])}}}return s.type=e.type,s}};static reduce=(t,e,r,s)=>{if(t>=e.dimension.length)return e;{const i=e.dimension.slice();i[t]=1;const n=new MultiArray(i),a=e.dimension.slice();a[t]=1;const o=a.reduce((t,e)=>t*e,1),l=a.map(t=>MultiArray.rangeArray(t));for(let t=0;t<o;t++){const i=MultiArray.linearIndexToSubscript(a,t).map((t,e)=>l[e][t-1]),o=MultiArray.subscriptToLinearIndex(e.dimension,i),[c,u]=MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],o),[h,d]=MultiArray.linearIndexToMultiArrayRowColumn(n.dimension[0],n.dimension[1],t);n.array[h][d]=s?r(s,e.array[c][u],t):e.array[c][u]}for(let s=2;s<=e.dimension[t];s++){const i=e.dimension.slice();i[t]=1;const a=i.map(t=>MultiArray.rangeArray(t));a[t]=[s];for(let s=0;s<o;s++){const o=MultiArray.linearIndexToSubscript(i,s).map((t,e)=>a[e][t-1]),l=MultiArray.subscriptToLinearIndex(e.dimension,o),[c,u]=MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],l),[h,d]=MultiArray.linearIndexToMultiArrayRowColumn(n.dimension[0],n.dimension[1],s),m=MultiArray.linearIndexToSubscript(n.dimension,s);m[t]=1;const[p,f]=MultiArray.subscriptToMultiArrayRowColumn(n.dimension,m);n.array[h][d]=r(n.array[p][f],e.array[c][u],s)}}return MultiArray.setType(n),MultiArray.MultiArrayToScalar(n)}};static concatenate=(t,e,...r)=>{const s=r.some(t=>!MultiArray.isEmpty(t))?r.filter(t=>!MultiArray.isEmpty(t)):r;let i,n;for(const t of s)for(const r of MultiArray.linearize(t)){const t=RuntimeValue.classDefinitionOfInstance(r);if(i){if(t&&t!==i)throw new Error(`${e}: object arrays must contain objects of the same class.`)}else i=t;if(MultiArray.isStructureScalar(r)){const t=MultiArray.structureFieldNames(r);if(n){if(!MultiArray.arrayEquals(t,n))throw new Error(`${e}: structure arrays must contain structures with the same fields.`)}else n=t}}const a=[],o=s.map(e=>{const r=e.dimension.slice();return MultiArray.appendSingletonTail(r,t+1),a.push(r[t]),r[t]=0,r});if(!o.every(t=>MultiArray.arrayEquals(t,o[0])))throw new EvalError(`${e}: dimension mismatch`);const l=o[0].slice();l[t]=a.reduce((t,e)=>t+e,0);const c=new MultiArray(l);return s.forEach((e,r)=>{const s=a.slice(0,r).reduce((t,e)=>t+e,0);for(let r=0;r<MultiArray.linearLength(e);r++){const i=e.dimension.slice();MultiArray.appendSingletonTail(i,t+1);const n=MultiArray.linearIndexToSubscript(i,r);n[t]+=s;const[a,o]=MultiArray.subscriptToMultiArrayRowColumn(c.dimension,n),[l,u]=MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],r);c.array[a][o]=e.array[l][u]}}),MultiArray.setType(c),c};static splitLastDimension=t=>{const e=[],r=t.dimension[t.dimension.length-1];for(let s=0;s<r;s++){const i=t.array.length/r,n=new MultiArray(t.dimension.slice(0,-1));n.array=t.array.slice(s*i,(s+1)*i),e.push(n)}return e};static evaluateRecursive=(t,e,r)=>{if(t.dimension.length>2)return MultiArray.concatenate(t.dimension.length-1,"evaluate",...MultiArray.splitLastDimension(t).map(t=>MultiArray.scalarToMultiArray(MultiArray.evaluateRecursive(t,e,r))));{const s=[],i=t.array.map(i=>{const n=i.flatMap(t=>(t=>{if(!e)return[t];e.context.pushCommaListExpansion();try{return e.context.expandCommaSeparatedList(e.Evaluator(t,r))}finally{e.context.popCommaListExpansion()}})(t)),a=n.length>1?e?.concatenateOverload?.("horzcat",n,t):void 0;if(void 0!==a)return s.push(a),MultiArray.scalarToMultiArray(a);if(s.push(void 0),MultiArray.isCharStringList(n)&&n.every(CharString.isChar)){const t=n[0].quote;return MultiArray.scalarToMultiArray(CharString.fromCharacterScalars(n,t))}return MultiArray.concatenate(1,"evaluate",...n.map(t=>MultiArray.scalarToMultiArray(t)))});if(1===i.length&&void 0!==s[0])return s[0];const n=i.map(t=>MultiArray.MultiArrayToScalar(t)),a=e?.concatenateOverload?.("vertcat",n,t);return void 0!==a?a:MultiArray.concatenate(0,"evaluate",...i)}};static evaluate=(t,e,r)=>{if(MultiArray.isEmpty(t))return t;if(t.isCell){const s=t.array.map(s=>s.flatMap(s=>(()=>{if(!e)return[s];e.context.pushCommaListExpansion();try{return e.context.expandCommaSeparatedList(e.Evaluator(s,r))}finally{e.context.popCommaListExpansion()}})().map(e=>(e&&(e.parent=t),e))));if(s.length>1&&s.some(t=>t.length!==s[0].length))throw new EvalError("evaluate: dimension mismatch");const i=new MultiArray([s.length,s[0]?.length??0],void 0,!0);return i.array=s,i.array.forEach(t=>t.forEach(t=>{t&&(t.parent=i)})),i}{const s=MultiArray.evaluateRecursive(t,e,r);return MultiArray.isInstanceOf(s)?(s.isCell=t.isCell,MultiArray.setType(s),2===s.dimension.length&&1===s.dimension[0]&&1===s.dimension[1]&&CharString.isInstanceOf(s.array[0][0])?s.array[0][0]:s):s}};static colon(t){const e=new MultiArray([1,t],Complex.zero());for(let r=0;r<t;r++)e.array[0][r]=Complex.create(r+1);return e}static computeIndexingStructure=(t,e)=>{if(0===e.length)throw new RangeError("invalid empty index list.");const r=t.length,s=e.length;if(1===e.length){const r=e[0],i=MultiArray.linearize(r),n=t.reduce((t,e)=>t*e,1);return{isLinear:!0,isLinearColonOnly:MultiArray.isInstanceOf(r)&&MultiArray.isColumnVector(r)&&i.length===n&&i.every((t,e)=>Complex.isInstanceOf(t)&&Complex.realToNumber(t)===e+1),linearIndexDimension:MultiArray.isInstanceOf(r)?r.dimension.slice():[1,1],originalIndexCount:s,args:[i],argsLength:[i.length],total:i.length}}const i=e.slice();for(;i.length<r;)i.push(MultiArray.colon(t[i.length]));const n=i.map((e,r)=>MultiArray.linearize(((e,r)=>{if(!MultiArray.isLogicalIndex(e))return e;const s=MultiArray.logicalMaskFromIndexArgument(e),i=MultiArray.linearizedLogicalMask(s),n=[];for(let e=0;e<i.length;e++){if(e>=t[r])throw new RangeError(`logical index out of bound ${t[r]}.`);Complex.realToNumber(i[e])&&n.push(Complex.create(e+1))}return MultiArray.toColumnVector(n)})(e,r))),a=n.map(t=>t.length),o=a.reduce((t,e)=>t*e,1);return{isLinear:!1,isLinearColonOnly:!1,originalIndexCount:s,args:n,argsLength:a,total:o}};static iterateWithLinearIndex=(t,e,r,s,i)=>{for(let n=0;n<t.total;n++){const a=MultiArray.linearIndexToSubscript(t.argsLength,n).map((e,r)=>t.args[r][e-1]);r(a,MultiArray.parseSubscript(e,a,s,i),n)}};static resolveIndexPlan=(t,e)=>{const r=t.length;if(e.isLinear)return{isLinear:!0,isColonOnly:e.isLinearColonOnly,isRowSelection:!1,isColumnSelection:!1,requiresCollapse:!1,activeDimensions:[0],isFullSlice:[e.isLinearColonOnly],isScalarIndex:[1===e.argsLength[0]]};const s=e.argsLength.slice();for(;s.length<r;)s.push(t[s.length]);const i=[],n=[],a=[];for(let e=0;e<r;e++){const r=s[e],o=r===t[e],l=1===r;i.push(o),n.push(l),o||a.push(e)}return{isLinear:!1,isColonOnly:!1,isRowSelection:2===e.originalIndexCount&&1===e.argsLength[0],isColumnSelection:2===e.originalIndexCount&&1===e.argsLength[1],requiresCollapse:e.originalIndexCount<r,activeDimensions:a,isFullSlice:i,isScalarIndex:n}};static getElementByLinearIndex=(t,e,r)=>{const[s,i]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],e);return r.length>0?MultiArray.getStructureField(t.array[s][i],r):t.array[s][i]};static setElementByLinearIndex=(t,e,r,s)=>{const[i,n]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],e);s.length>0?MultiArray.structureAssignFieldPath(t.array[i][n],s,r):t.array[i][n]=r};static collapseResult=(t,e,r,s)=>{if(!s.requiresCollapse)return t;const i=MultiArray.linearize(t);if(2===r.originalIndexCount&&1===r.argsLength[1]){const e=r.argsLength[0],s=new MultiArray([e,1]);for(let r=0;r<e;r++)s.array[r][0]=t.array[r][0];return MultiArray.setType(s),s}if(2===r.originalIndexCount&&1===r.argsLength[0]){const t=MultiArray.toRowVector(i);return MultiArray.setType(t),t}if(t.dimension.length>2){const e=t.dimension[0],r=i.length/e,s=new MultiArray([e,r]);let n=0;for(let t=0;t<r;t++)for(let r=0;r<e;r++)s.array[r][t]=i[n++];return MultiArray.setType(s),s}return t};static linearIndexResult=(t,e,r,s)=>{if(s.isColonOnly)return MultiArray.toColumnVector(e);const i=r.linearIndexDimension??[1,e.length];if(MultiArray.arrayIsVector(t)&&2===i.length&&(1===i[0]||1===i[1]))return MultiArray.isRowVector(t)?MultiArray.toRowVector(e):MultiArray.toColumnVector(e);const n=new MultiArray(i);for(let t=0;t<e.length;t++){const[r,s]=MultiArray.linearIndexToMultiArrayRowColumn(n.dimension[0],n.dimension[1],t);n.array[r][s]=e[t]}return n};static logicalIndexResult=(t,e,r)=>MultiArray.arrayIsVector(t)&&MultiArray.arrayIsVector(r)?MultiArray.isRowVector(t)?MultiArray.toRowVector(e):MultiArray.toColumnVector(e):MultiArray.arrayIsVector(r)&&MultiArray.isRowVector(r)?MultiArray.toRowVector(e):MultiArray.toColumnVector(e);static logicalMaskFromIndexArgument=t=>Complex.isInstanceOf(t)?MultiArray.scalarToMultiArray(t):t;static linearizedLogicalMask=(t,e)=>{const r=MultiArray.linearize(t);if(!r.every(Complex.isInstanceOf))throw new EvalError(`${e??""}: invalid logical index.`);return r};static logicalToLinearIndices=(t,e,r)=>{const s=MultiArray.linearize(t),i=MultiArray.linearizedLogicalMask(e,r);if(i.length>s.length)throw new EvalError(`${r??""}(${i.length}): out of bound ${s.length} (dimensions are ${t.dimension.join("x")})`);const n=[];for(let t=0;t<i.length;t++)Complex.realToNumber(i[t])&&n.push(t);return n};static logicalMaskToIndexList=(t,e,r)=>MultiArray.logicalToLinearIndices(t,e,r);static isLogicalIndex(t){return MultiArray.isInstanceOf(t)&&t.type===Complex.LOGICAL||Complex.isInstanceOf(t)&&t.type===Complex.LOGICAL}static applyLinearSelection=(t,e,r)=>{const s=[];for(const i of e)s.push(MultiArray.getElementByLinearIndex(t,i,r));return s};static applyLinearAssignment=(t,e,r,s)=>{const i=1===r.length;if(!i&&r.length!==e.length)throw new EvalError(`=: nonconformant arguments (op1 is ${e.length}x1, op2 is ${r.length}x1)`);for(let n=0;n<e.length;n++){const a=i?r[0]:r[n];MultiArray.setElementByLinearIndex(t,e[n],a,s)}};static resolveLinearIndices=(t,e,r,s)=>{if(1===r.length&&MultiArray.isLogicalIndex(r[0])){const s=MultiArray.logicalMaskFromIndexArgument(r[0]);return MultiArray.logicalToLinearIndices(t,s,e)}const i=MultiArray.computeIndexingStructure(t.dimension,r),n=[];return MultiArray.iterateWithLinearIndex(i,t.dimension,(t,e)=>{n.push(e)},e,s),n};static collectLinearIndices=(t,e,r,s)=>{const i=[];return MultiArray.iterateWithLinearIndex(t,e,(t,e)=>{i.push(e)},r,s),i};static applyDeletionFromIndices=(t,e)=>{const r=MultiArray.linearize(t),s=new Set(e),i=r.filter((t,e)=>!s.has(e));let n;n=MultiArray.arrayIsVector(t)&&MultiArray.isRowVector(t)?MultiArray.toRowVector(i):MultiArray.toColumnVector(i),t.array=n.array,t.dimension=n.dimension};static getElements=(t,e,r,s,i)=>{if(0===s.length)return t;const n=MultiArray.resolveLinearIndices(t,e,s,i),a=MultiArray.applyLinearSelection(t,n,r);if(1===s.length&&MultiArray.isLogicalIndex(s[0])){const e=MultiArray.logicalMaskFromIndexArgument(s[0]),r=MultiArray.logicalIndexResult(t,a,e);return MultiArray.setType(r),r}const o=MultiArray.computeIndexingStructure(t.dimension,s),l=MultiArray.resolveIndexPlan(t.dimension,o);if(o.isLinear){const e=MultiArray.linearIndexResult(t,a,o,l);return MultiArray.setType(e),e}const c=new MultiArray(o.argsLength);for(let t=0;t<a.length;t++){const[e,r]=MultiArray.subscriptToMultiArrayRowColumn(c.dimension,MultiArray.linearIndexToSubscript(c.dimension,t));c.array[e][r]=a[t]}return MultiArray.setType(c),MultiArray.collapseResult(c,t.dimension,o,l)};static setElementsNumerical=(t,e,r,s,i,n,a)=>{const o=MultiArray.linearize(i),l=r.length>0&&0===o.length?[i]:o;if(0===l.length){const r=t.resolveName(e);if(!(r&&r.node instanceof MultiArray))throw new RangeError(`A(I) = []: index out of bounds: value ${MultiArray.firstElement(s[0])} out of bound 0`);return void MultiArray.deleteElements(r.node,s,n,a)}if(0===s.length)throw new RangeError("invalid empty index list.");const c=t.resolveName(e),u=c?.node,h=MultiArray.computeIndexingStructure(u instanceof MultiArray?u.dimension:[1],s);if(1!==l.length&&l.length!==h.total)throw new RangeError(`=: nonconformant arguments (op1 is ${h.argsLength.join("x")}, op2 is ${i.dimension.join("x")})`);let d=c;const m=h.args.map(t=>Math.max(...t.map(t=>MultiArray.testIndex(t))));if(d)if(d.node instanceof MultiArray)if(h.isLinear){if(m[0]>MultiArray.linearLength(d.node))if(MultiArray.isEmpty(d.node)){const t=r.length>0?MultiArray.createStructureValue(r):d.node.isCell?void 0:MultiArray.blankValueForExpansion(l[0]);MultiArray.expand(d.node,[1,m[0]],t)}else{if(!MultiArray.arrayIsVector(d.node))throw new RangeError("Invalid resizing operation or ambiguous assignment to an out-of-bounds array element.");1===d.node.dimension[0]?MultiArray.expand(d.node,[1,m[0]]):MultiArray.expand(d.node,[m[0],1])}}else MultiArray.expand(d.node,m);else{const r=d.node,s=MultiArray.blankValueForExpansion(r);if(d=h.isLinear?t.defineName(e,new MultiArray([1,m[0]],s)):t.defineName(e,new MultiArray(m,s)),!(d.node instanceof MultiArray))throw new TypeError("internal error: index assignment target is not an array.");d.node.array[0][0]=r}else{const s=0===r.length&&i.isCell,n=r.length>0?MultiArray.createStructureValue(r):s?MultiArray.emptyArray():MultiArray.blankValueForExpansion(l[0]);d=h.isLinear?t.defineName(e,new MultiArray([1,m[0]],n,s)):t.defineName(e,new MultiArray(m,n,s))}if(!(d.node instanceof MultiArray))throw new TypeError("internal error: index assignment target is not an array.");const p=d.node;r.length>0&&MultiArray.setEmptyStructureField(p,r[0]);const f=p.dimension.slice(),g=MultiArray.collectLinearIndices(h,f,n,a);MultiArray.applyLinearAssignment(p,g,l,r)};static setElements=(t,e,r,s,i,n,a)=>{if(1===s.length&&MultiArray.isLogicalIndex(s[0])){const n=MultiArray.logicalMaskFromIndexArgument(s[0]),a=t.resolveName(e);if(!(a&&a.node instanceof MultiArray))throw new EvalError(`${e}(_): invalid matrix indexing.`);const o=a.node,l=MultiArray.logicalMaskToIndexList(o,n,e),c=MultiArray.linearize(i),u=r.length>0&&0===c.length?[i]:c;if(0===u.length){const t=MultiArray.linearize(o),e=new Set(l),r=t.filter((t,r)=>!e.has(r));let s;return s=MultiArray.isRowVector(o)?MultiArray.toRowVector(r):MultiArray.toColumnVector(r),o.array=s.array,void(o.dimension=s.dimension)}return void MultiArray.applyLinearAssignment(o,l,u,r)}MultiArray.setElementsNumerical(t,e,r,s,i,n,a)};static deleteElements=(t,e,r,s)=>{if(0===e.length)throw new RangeError("invalid empty index list.");const i=MultiArray.computeIndexingStructure(t.dimension,e);if(i.isLinear){const e=MultiArray.collectLinearIndices(i,t.dimension,r,s);return void MultiArray.applyDeletionFromIndices(t,e)}let n=-1;for(let e=0;e<i.argsLength.length;e++)if(i.argsLength[e]!==t.dimension[e]){if(-1!==n)throw new RangeError("a null assignment can only have one non-colon index");n=e}if(-1===n)throw new RangeError("a null assignment can only have one non-colon index");const a=MultiArray.collectLinearIndices(i,t.dimension,r,s),o=new Set(a),l=t.dimension.slice();l[n]=0;const c=MultiArray.linearize(t),u=[];for(let t=0;t<c.length;t++)o.has(t)||u.push(c[t]);const h=c.length/t.dimension[n],d=u.length/h;l[n]=d;const m=new MultiArray(l);let p=0;for(let t=0;t<u.length;t++){const[e,r]=MultiArray.subscriptToMultiArrayRowColumn(m.dimension,MultiArray.linearIndexToSubscript(m.dimension,t));m.array[e][r]=u[p++]}MultiArray.setType(m),t.array=m.array,t.dimension=m.dimension};static reduceFactory=(t,e,r)=>{switch(e){case"reduce":return void 0!==r?(e,s)=>{const i=MultiArray.scalarToMultiArray(e),n=void 0!==s?Complex.realToNumber(MultiArray.firstElement(s))-1:Math.max(0,MultiArray.firstNonSingleDimension(i));return MultiArray.reduce(n,i,t,r)}:(e,r)=>{const s=MultiArray.scalarToMultiArray(e),i=void 0!==r?Complex.realToNumber(MultiArray.firstElement(r))-1:Math.max(0,MultiArray.firstNonSingleDimension(s));return MultiArray.reduce(i,s,t)};case"cumulative":return void 0!==r?(e,s)=>{const i=MultiArray.scalarToMultiArray(e),n=void 0!==s?Complex.realToNumber(MultiArray.firstElement(s))-1:MultiArray.firstNonSingleDimension(i),a=MultiArray.alongDimensionMap(n,i,(o=void 0,(e,s)=>o=t(0===s?r:o,e)));var o;return MultiArray.setType(a),a}:(e,r)=>{const s=MultiArray.scalarToMultiArray(e),i=void 0!==r?Complex.realToNumber(MultiArray.firstElement(r))-1:MultiArray.firstNonSingleDimension(s),n=MultiArray.alongDimensionMap(i,s,(a=void 0,(e,r)=>a=0===r?e:t(a,e)));var a;return MultiArray.setType(n),n};case"cumcomparison":return(e,r)=>{const s=MultiArray.scalarToMultiArray(e),i=r?Complex.realToNumber(MultiArray.firstElement(r))-1:MultiArray.firstNonSingleDimension(s),n=new MultiArray(s.dimension);let a,o;const l=MultiArray.alongDimensionMap(i,s,(e,r,s,i)=>(0===r?(a=e,o=Complex.one()):Complex.realToNumber(Complex[t](e,a))&&(a=e,o=Complex.create(r+1)),n.array[s][i]=o,a));return MultiArray.setType(l),MultiArray.setType(n),nodeBoundedReturnList(2,(t,e)=>{if(1===t.length)return MultiArray.MultiArrayToScalar(l);if(2===t.length)return MultiArray.MultiArrayToScalar(0===e?l:n);throw new EvalError("unreachable cumulative comparison return-list selector branch.")},t=>({length:t}))};case"comparison":const s="lt"===t?"min":"max";return(...e)=>{const r=(e,r)=>{const i=MultiArray.reduceToArray(r,e),n=new MultiArray(i.dimension),a=new MultiArray(i.dimension);for(let e=0;e<a.array.length;e++)for(let r=0;r<a.array[e].length;r++){const o=i.array[e][r];if(!MultiArray.isReducedComplexArrayLine(o))throw new Error(`${s}: invalid reduced array slot.`);let l=o[0],c=1;for(let e=1;e<o.length;e++){const r=o[e];Complex.realToNumber(Complex[t](r,l))&&(l=r,c=e+1)}n.array[e][r]=l,a.array[e][r]=Complex.create(c)}return MultiArray.setType(n),MultiArray.setType(a),nodeBoundedReturnList(2,(t,e)=>{if(1===t.length)return MultiArray.MultiArrayToScalar(n);if(2===t.length)return MultiArray.MultiArrayToScalar(0===e?n:a);throw new EvalError("unreachable comparison return-list selector branch.")},t=>({length:t}))};switch(e.length){case 1:{const t=MultiArray.scalarToMultiArray(e[0]);return r(t,MultiArray.firstNonSingleDimension(t))}case 2:{const t=MultiArray.scalarToMultiArray(e[0]),i=e[1];if(MultiArray.isScalar(i))return r(t,MultiArray.testInteger(i,"reduceFactory","dimension",[1,1/0])-1);const n=MultiArray.scalarToMultiArray(i);return MultiArray.elementWiseOperation(s+"Wise",t,n)}case 3:if(!MultiArray.isEmpty(e[1]))throw new Error(`${s}: second argument must be [] or omitted`);return r(MultiArray.scalarToMultiArray(e[0]),Complex.realToNumber(MultiArray.firstElement(e[2]))-1);default:throwInvalidCallError(s)}};default:throw TypeError(`reduceFactory: invalid type argument: ${e}`)}}}const src_MultiArray=null;class Structure{static STRUCTURE=4;type=Structure.STRUCTURE;parent;field;static invalidReferenceMessage="value cannot be indexed with .";static isInstanceOf=t=>t instanceof Structure;constructor(t){if(this.field={},Array.isArray(t)){let e=this;for(let r=0;r<t.length-1;r++){const s=new Structure({});e.field[t[r]]=s,e=s}e.field[t[t.length-1]]=MultiArray.emptyArray()}else for(const[e,r]of Object.entries(t))this.field[e]=RuntimeValue.copy(r)}static structureElements=t=>{if(t instanceof Structure)return[t];if(t instanceof MultiArray&&!t.isCell){const e=MultiArray.linearize(t);return 0!==e.length&&e.every(Structure.isInstanceOf)?e:[]}return[]};static isStructure=t=>Structure.structureElements(t).length>0;static fieldNames=t=>Object.keys(Structure.structureElements(t)[0]?.field??{}).sort();static hasField=(t,e)=>{const r=Structure.structureElements(t);return r.length>0&&r.every(t=>RuntimeValue.hasOwnField(t.field,e))};static isMissingOrEmpty=t=>void 0===t||MultiArray.isEmpty(t);static ensureStructureLike=t=>{if(Structure.isMissingOrEmpty(t))return new Structure({});if(t instanceof Structure)return t;if(t instanceof MultiArray&&Structure.isStructure(t))return t;throw new EvalError(Structure.invalidReferenceMessage)};static assignFieldPath=(t,e,r)=>{if(t instanceof MultiArray){const s=Structure.structureElements(t);if(0===s.length)throw new EvalError(Structure.invalidReferenceMessage);return void s.forEach(t=>Structure.assignFieldPath(t,e,r))}if(0===e.length)throw new EvalError(Structure.invalidReferenceMessage);if(1===e.length)return void(t.field[e[0]]=r??MultiArray.emptyArray());const s=e[0],i=Structure.ensureStructureLike(t.field[s]);t.field[s]=i,Structure.assignFieldPath(i,e.slice(1),r)};static collectFieldPath=(t,e)=>{if(null==t)throw new EvalError(Structure.invalidReferenceMessage);if(0===e.length)return[t];if(t instanceof MultiArray&&Structure.isStructure(t))return Structure.structureElements(t).flatMap(t=>Structure.collectFieldPath(t,e));if(t instanceof Structure){const r=t.field[e[0]];if(void 0===r)throw new EvalError(Structure.invalidReferenceMessage);return 1===e.length?[r]:Structure.collectFieldPath(r,e.slice(1))}throw new EvalError(Structure.invalidReferenceMessage)};static setField=(t,e,r)=>{Structure.assignFieldPath(t,e,r)};static setNewField=(t,e,r)=>{Structure.assignFieldPath(t,e,r)};static getField=(t,e)=>{const r=Structure.collectFieldPath(t,e);return 1===r.length?r[0]:MultiArray.toRowVector(r)};static getFields=(t,e)=>Structure.collectFieldPath(t,e);static removeFields=(t,e)=>{if(t instanceof Structure){const r=Structure.copy(t);return e.forEach(t=>{delete r.field[t]}),r}if(0===Structure.structureElements(t).length)throw new EvalError(Structure.invalidReferenceMessage);const r=MultiArray.copy(t);return Structure.structureElements(r).forEach(t=>{e.forEach(e=>{delete t.field[e]})}),r};static orderFields=t=>{const e=t=>{const e=new Structure({});for(const r of Object.keys(t.field).sort())e.field[r]=RuntimeValue.copy(t.field[r]);return e};if(t instanceof Structure)return e(t);const r=Structure.structureElements(t);if(0===r.length)throw new EvalError(Structure.invalidReferenceMessage);const s=MultiArray.copy(t),i=r.map(e);for(let t=0;t<i.length;t++){const[e,r]=MultiArray.linearIndexToMultiArrayRowColumn(s.dimension[0],s.dimension[1],t);s.array[e][r]=i[t]}return s};static unparse=(t,e,r=0)=>`struct {\n${Object.entries(t.field).map(t=>`${t[0]}: ${e.Unparse(t[1])}`).join("\n")}\n}`;static unparseMathML=(t,e,r=0)=>{let s='<mtr><mtd columnspan="2"><mtext>struct {</mtext></mtd></mtr>';return s+=Object.entries(t.field).map(t=>`<mtr><mtd><mi>${t[0]}</mi><mo>:</mo></mtd><mtd>${e.UnparserMathML(t[1])}</mtd></mtr>`).join(""),s+='<mtr><mtd columnspan="2"><mtext>}</mtext></mtd></mtr>',`<mtable>${s}</mtable>`};static copy=t=>{const e=new Structure({});for(const[r,s]of Object.entries(t.field))e.field[r]=RuntimeValue.copy(s);return e};copy(){return Structure.copy(this)}static cloneFields=t=>{const e=new Structure({});return Object.keys(t.field).forEach(t=>{e.field[t]=MultiArray.emptyArray()}),e};static toLogical=t=>Object.keys(t.field).length>0?Complex.true():Complex.false();toLogical(){return Structure.toLogical(this)}static setEmptyField=(t,e)=>{const r=Structure.structureElements(t);if(0===r.length)throw new EvalError(Structure.invalidReferenceMessage);t.isCell||Structure.hasField(t,e)||r.forEach(t=>{t.field[e]=MultiArray.emptyArray()})}}const src_Structure=null;RuntimeValue.registerStructureFactory(t=>new Structure(t));class FunctionHandle{static FUNCTION_HANDLE=5;type=FunctionHandle.FUNCTION_HANDLE;parent;id;parameter=[];expression;closure;sourceName;className;disallowNestedResolution=!1;static isInstanceOf=t=>t instanceof FunctionHandle;static isAnonymous=t=>FunctionHandle.isInstanceOf(t)&&void 0===t.id;constructor(t,e=[],r=null,s){this.id=t,this.parameter=e??[],this.expression=r,s&&(this.closure=s)}static create=(t,e=[],r=null,s)=>new FunctionHandle(t,e,r,s);static unparse=(t,e,r=0)=>t.id?"@"+t.id:"@("+t.parameter.map(t=>e.Unparse(t)).join(",")+") "+e.Unparse(t.expression);static toString=t=>t.id?"@"+t.id:"@anonymous function handle";toString(){return FunctionHandle.toString(this)}static unparseMathML=(t,e,r=0)=>t.id?`<mo>@</mo><mi>${t.id}</mi>`:'<mo>@</mo><mo fence="true" stretchy="true">(</mo>'+t.parameter.map(t=>e.UnparserMathML(t)).join("<mo>,</mo>")+'<mo fence="true" stretchy="true">)</mo><mspace width="0.8em"/>'+e.UnparserMathML(t.expression);static copy=t=>{const e=new FunctionHandle(t.id,t.parameter.map(t=>FunctionHandle.copyNode(t)),FunctionHandle.copyNode(t.expression),t.closure);return e.parameter.forEach(t=>{t.parent=e}),e.expression&&(e.expression.parent=e),e.parent=t.parent,e.sourceName=t.sourceName,e.className=t.className,e.disallowNestedResolution=t.disallowNestedResolution,e};copy(){const t=FunctionHandle.copy(this);return t.parent=this.parent,t}static hasCopyMethod(t){return"function"==typeof t.copy}static isFunctionHandleNode(t){return!!t&&"object"==typeof t}static hasNodeType(t){return FunctionHandle.isFunctionHandleNode(t)&&"type"in t}static copyNodeValue(t){return Array.isArray(t)?t.map(t=>FunctionHandle.copyNodeValue(t)):FunctionHandle.isFunctionHandleNode(t)?FunctionHandle.copyNode(t):t}static copyNode(t){if(!t||"object"!=typeof t)return t;if(FunctionHandle.hasCopyMethod(t)){const e=t.copy();if(FunctionHandle.isFunctionHandleNode(e)||null==e)return e}const e={};for(const[r,s]of Object.entries(t))"parent"!==r&&Reflect.set(e,r,FunctionHandle.copyNodeValue(s));for(const t of Object.values(e))FunctionHandle.attachParent(t,e);return e}static attachParent(t,e){Array.isArray(t)?t.forEach(t=>FunctionHandle.attachParent(t,e)):FunctionHandle.hasNodeType(t)&&(t.parent=e)}static toLogical=t=>Complex.false();toLogical(){return Complex.false()}}const src_FunctionHandle=null,operatorTypes=["+","-",".*","*","./","/",".\\","\\",".^","^",".**","**","<","<=","==",">=",">","!=","~=","&","|","&&","||","=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|=","()","!","~","+_","-_","++_","--_",".'","'","_++","_--"],binaryOperatorTypes=["+","-",".*","*","./","/",".\\","\\",".^","^",".**","**","<","<=","==",">=",">","!=","~=","&","|","&&","||","=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|="],prefixOperatorTypes=["()","!","~","+_","-_","++_","--_"],postfixOperatorTypes=[".'","'","_++","_--"];class AST{static nodeString=CharString.create;static nodeNumber=Complex.parse;static firstRow=MultiArray.firstRow;static appendRow=MultiArray.appendRow;static emptyArray=MultiArray.emptyArray;static reload=()=>{AST.nodeString=CharString.create,AST.nodeNumber=Complex.parse,AST.firstRow=MultiArray.firstRow,AST.appendRow=MultiArray.appendRow,AST.emptyArray=MultiArray.emptyArray};static nodeCopy=t=>Object.assign({},t);static isNodeBase=t=>{if("object"!=typeof t||null===t||!("type"in t))return!1;const e=Reflect.get(t,"type");return"string"==typeof e||"number"==typeof e};static isNodeIdentifier=t=>AST.isNodeBase(t)&&"IDENT"===t.type&&"string"==typeof Reflect.get(t,"id");static isNodeList=t=>AST.isNodeBase(t)&&"LIST"===t.type&&Array.isArray(Reflect.get(t,"list"));static isNodeCmdWList=t=>AST.isNodeBase(t)&&"CMDWLIST"===t.type&&"string"==typeof Reflect.get(t,"id")&&Array.isArray(Reflect.get(t,"args"));static isNodeIndexExpr=t=>AST.isNodeBase(t)&&"IDX"===t.type&&("()"===Reflect.get(t,"delim")||"{}"===Reflect.get(t,"delim"))&&Array.isArray(Reflect.get(t,"args"));static isNodeSuperclassConstructor=t=>AST.isNodeBase(t)&&"SUPERCLASS_CTOR"===t.type&&AST.isNodeIdentifier(Reflect.get(t,"superclass"))&&Array.isArray(Reflect.get(t,"args"));static isNodeRange=t=>AST.isNodeBase(t)&&"RANGE"===t.type&&"start_"in t&&"stop_"in t;static isNodeColon=t=>AST.isNodeBase(t)&&":"===t.type;static isNodeEndRange=t=>AST.isNodeBase(t)&&"ENDRANGE"===t.type;static isNodeIndirectRef=t=>AST.isNodeBase(t)&&"."===t.type&&Array.isArray(Reflect.get(t,"field"));static isNodeReturnList=t=>AST.isNodeBase(t)&&"RETLIST"===t.type&&"function"==typeof Reflect.get(t,"selector")&&"function"==typeof Reflect.get(t,"handler");static isNodeIgnoredTarget=t=>AST.isNodeBase(t)&&"<~>"===t.type;static isNodeOperation=t=>AST.isNodeBase(t)&&operatorTypes.includes(t.type);static isNodeBinaryOperation=t=>AST.isNodeOperation(t)&&binaryOperatorTypes.includes(t.type)&&"left"in t&&"right"in t;static isNodePrefixOperation=t=>AST.isNodeOperation(t)&&prefixOperatorTypes.includes(t.type)&&"right"in t;static isNodePostfixOperation=t=>AST.isNodeOperation(t)&&postfixOperatorTypes.includes(t.type)&&"left"in t;static isNodeFunctionReturn=t=>AST.isNodeIdentifier(t)||AST.isNodeIgnoredTarget(t);static isNodeDeclarationElement=t=>AST.isNodeIdentifier(t)||AST.isNodeDefaultedParameter(t);static isNodeDefaultedParameter=t=>AST.isNodeBinaryOperation(t)&&"="===t.type&&AST.isNodeIdentifier(t.left);static isNodeFunctionParameter=t=>AST.isNodeIdentifier(t)||AST.isNodeIgnoredTarget(t)||AST.isNodeDefaultedParameter(t);static isNodeAssignmentTarget=t=>AST.isNodeIdentifier(t)||AST.isNodeIgnoredTarget(t)||AST.isNodeIndexExpr(t)||AST.isNodeIndirectRef(t)||MultiArray.isInstanceOf(t);static isNodeDeclaration=t=>AST.isNodeBase(t)&&("GLOBAL"===t.type||"PERSIST"===t.type);static isNodeImport=t=>AST.isNodeBase(t)&&"IMPORT"===t.type&&Array.isArray(t.imports);static isNodeStatement=t=>AST.isNodeDeclaration(t)||AST.isNodeImport(t)||AST.isNodeBase(t)&&("RETURN"===t.type||"BREAK"===t.type||"CONTINUE"===t.type||"IF"===t.type||"SWITCH"===t.type||"WHILE"===t.type||"DO_UNTIL"===t.type||"FOR"===t.type||"SPMD"===t.type||"TRY"===t.type||"UNWIND_PROTECT"===t.type)||AST.isNodeFunctionDefinition(t)||AST.isNodeClassDef(t);static isNodeClassMember=t=>AST.isNodeClassSection(t)||AST.isNodeClassAttribute(t)||AST.isNodeClassProperty(t)||AST.isNodeClassEvent(t)||AST.isNodeClassEnumeration(t);static isNodeProgramElement=t=>AST.isStrictNodeExpr(t)||AST.isNodeStatement(t)||AST.isNodeClassMember(t);static isNodeFunctionDefinition=t=>AST.isNodeBase(t)&&"FCNDEF"===t.type;static isNodeClassDef=t=>AST.isNodeBase(t)&&"CLASSDEF"===t.type;static isNodeMetaClass=t=>AST.isNodeBase(t)&&"METACLASS"===t.type&&AST.isNodeIdentifier(t.className);static isRuntimeExpressionValue=t=>null!=t&&(MultiArray.isInstanceOf(t)||Complex.isInstanceOf(t)||CharString.isInstanceOf(t)||"object"==typeof t&&"number"==typeof t.type);static isStrictNodeExpr=t=>AST.isRuntimeExpressionValue(t)||AST.isNodeBase(t)&&("VOID"===t.type||AST.isNodeIdentifier(t)||AST.isNodeCmdWList(t)||AST.isNodeIndexExpr(t)||AST.isNodeSuperclassConstructor(t)||AST.isNodeMetaClass(t)||AST.isNodeRange(t)||AST.isNodeColon(t)||AST.isNodeEndRange(t)||AST.isNodeOperation(t)||AST.isNodeIgnoredTarget(t)||AST.isNodeIndirectRef(t)||AST.isNodeImport(t)||AST.isNodeReturnList(t));static isExpressionBoundaryValue=t=>AST.isStrictNodeExpr(t)||AST.isNodeList(t);static requireStrictNodeExpr=(t,e="expression")=>{if(!AST.isStrictNodeExpr(t))throw new TypeError(`${e} is not an expression node.`);return t};static isNodeArguments=t=>AST.isNodeBase(t)&&"ARGS"===t.type&&Array.isArray(t.validation);static isNodeArgumentValidation=t=>AST.isNodeBase(t)&&"ARGVALID"===t.type&&"name"in t&&Array.isArray(t.size);static isNodeSwitchCase=t=>AST.isNodeBase(t)&&"CASE"===t.type;static isNodeClassSection=t=>AST.isNodeBase(t)&&"CLASS_SECTION"===t.type;static isNodeClassAttribute=t=>AST.isNodeBase(t)&&"CLASS_ATTRIBUTE"===t.type;static isNodeClassProperty=t=>AST.isNodeBase(t)&&"CLASS_PROPERTY"===t.type;static isNodeClassEvent=t=>AST.isNodeBase(t)&&"CLASS_EVENT"===t.type;static isNodeClassEnumeration=t=>AST.isNodeBase(t)&&"CLASS_ENUMERATION"===t.type;static nodeVoid=()=>({type:"VOID",omitAnswer:!0,omitOutput:!0});static nodeIdentifier=t=>({type:"IDENT",id:t.replace(/(\r\n|[\n\r])|[\ ]/gm,""),omitAnswer:!1,omitOutput:!1});static nodeMetaClass=t=>{const e={type:"METACLASS",className:t,omitAnswer:!1,omitOutput:!1};return e.className.parent=e,e};static factoryExpression=(t,e,r=!1)=>r&&AST.isNodeList(t)?t:AST.requireStrictNodeExpr(t,e);static factoryExpressionList=(t,e)=>t?t.list.map((t,r)=>AST.factoryExpression(t,`${e}${r+1}`)):[];static factoryCommandWordList=(t,e)=>t?t.list.map((t,r)=>{if(!CharString.isInstanceOf(t))throw new TypeError(`${e}${r+1} is not a command word.`);return t}):[];static factoryNodeList=(t,e,r)=>t.list.map((t,s)=>{if(!e(t))throw new TypeError(`${r}${s+1} has invalid node type.`);return t});static factoryProgramElementList=(t,e)=>AST.factoryNodeList(t,AST.isNodeProgramElement,e);static factoryArrayElementList=(t,e)=>AST.factoryExpressionList(t,e);static factoryArgumentClass=(t,e)=>{if(null===t||AST.isNodeList(t)&&0===t.list.length)return t;if(!AST.isNodeIdentifier(t)&&!AST.isNodeMetaClass(t))throw new TypeError(`${e} has invalid node type.`);return t};static nodeCmdWList=(t,e)=>{const r={type:"CMDWLIST",id:t.id,args:AST.factoryCommandWordList(e,"command argument ")};return t.parent=r,r.args.forEach(t=>{t.parent=r}),r.omitAnswer=!0,r.omitOutput=!1,r};static nodeEmptyCmdWList=t=>{const e={type:"CMDWLIST",id:t.id,args:[],parent:t.parent,index:t.index,start:t.start,stop:t.stop,omitAnswer:!0,omitOutput:t.omitOutput??!1};return t.parent=e,e};static nodeIndexExpr=(t,e=null,r="()")=>{const s={type:"IDX",expr:AST.factoryExpression(t,"indexed expression"),args:AST.factoryExpressionList(e,"index argument "),delim:r,omitAnswer:!1,omitOutput:!1};return s.expr.parent=s,s.args.forEach((t,e)=>{AST.isNodeBase(t)&&(t.parent=s,t.index=e)}),s};static nodeSuperclassConstructor=(t,e,r=null)=>{const s={type:"SUPERCLASS_CTOR",instance:AST.factoryExpression(t,"superclass constructor instance"),superclass:e,args:AST.factoryExpressionList(r,"superclass constructor argument "),omitAnswer:!1,omitOutput:!1};return s.instance.parent=s,s.superclass.parent=s,s.args.forEach(t=>{AST.isNodeBase(t)&&(t.parent=s)}),s};static nodeRange=(t,e,r)=>{const s={type:"RANGE",start_:AST.factoryExpression(t,"range start"),stop_:AST.factoryExpression(e,"range stop"),stride_:r?AST.factoryExpression(r,"range stride"):null,omitAnswer:!1,omitOutput:!1};return s.start_.parent=s,s.stop_.parent=s,r&&(s.stride_.parent=s),s};static nodeColon=()=>({type:":",omitAnswer:!1,omitOutput:!1});static nodeEndRange=()=>({type:"ENDRANGE",omitAnswer:!1,omitOutput:!1});static omitAnswerNodeOperation=new Set(["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|=","++_","--_","_++","_--"]);static assignmentNodeOperation=new Set(["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|="]);static anonymousFunctionForbiddenOperation=new Set(["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|=","++_","--_","_++","_--"]);static assertAnonymousFunctionExpression=t=>{if(AST.isNodeOperation(t)&&AST.anonymousFunctionForbiddenOperation.has(t.type))throw new SyntaxError("anonymous function bodies cannot contain assignment, increment, or decrement operators.");AST.isNodeBinaryOperation(t)?(AST.assertAnonymousFunctionExpression(t.left),AST.assertAnonymousFunctionExpression(t.right)):AST.isNodePrefixOperation(t)?AST.assertAnonymousFunctionExpression(t.right):AST.isNodePostfixOperation(t)?AST.assertAnonymousFunctionExpression(t.left):AST.isNodeIndexExpr(t)?(AST.assertAnonymousFunctionExpression(t.expr),t.args.forEach(AST.assertAnonymousFunctionExpression)):AST.isNodeSuperclassConstructor(t)?(AST.assertAnonymousFunctionExpression(t.instance),t.args.forEach(AST.assertAnonymousFunctionExpression)):AST.isNodeRange(t)?(AST.assertAnonymousFunctionExpression(t.start_),AST.assertAnonymousFunctionExpression(t.stop_),t.stride_&&AST.assertAnonymousFunctionExpression(t.stride_)):AST.isNodeIndirectRef(t)?(AST.assertAnonymousFunctionExpression(t.obj),t.field.forEach(t=>{"string"!=typeof t&&AST.assertAnonymousFunctionExpression(t)})):AST.isNodeList(t)?t.list.forEach(AST.assertAnonymousFunctionExpression):MultiArray.isInstanceOf(t)?MultiArray.linearize(t).forEach(AST.assertAnonymousFunctionExpression):FunctionHandle.isInstanceOf(t)&&t.expression&&AST.assertAnonymousFunctionExpression(t.expression)};static assertFunctionSignatureList=(t,e,r,s)=>{const i=new Set;t.forEach((n,a)=>{if(AST.isNodeIgnoredTarget(n))return;let o;if(AST.isNodeDefaultedParameter(n)){if("parameter"!==r||"anonymous function"===s)throw new SyntaxError(`invalid ${r} list in ${s}.`);o=n.left.id}else{if(!AST.isNodeIdentifier(n))throw new SyntaxError(`invalid ${r} list in ${s}.`);o=n.id}if(i.has(o))throw new SyntaxError(`duplicate ${r} name '${o}' in ${s}.`);if(i.add(o),o===e&&a!==t.length-1)throw new SyntaxError(`${e} must be the last ${r} in ${s}.`);if(AST.isNodeDefaultedParameter(n)&&o===e)throw new SyntaxError(`${e} default value is not supported in ${s}.`)})};static assertAnonymousFunctionParameters=t=>{AST.assertFunctionSignatureList(t,"varargin","parameter","anonymous function")};static nodeOperation=(t,e,r)=>{let s;switch(t){case"+":case"-":case".*":case"*":case"./":case"/":case".\\":case"\\":case".^":case"^":case".**":case"**":case"<":case"<=":case"==":case">=":case">":case"!=":case"~=":case"&":case"|":case"&&":case"||":case"=":case"+=":case"-=":case"*=":case"/=":case"\\=":case"^=":case"**=":case".*=":case"./=":case".\\=":case".^=":case".**=":case"&=":case"|=":if(void 0===r)throw new TypeError(`right operand for ${t} is missing.`);s={type:t,left:AST.factoryExpression(e,`left operand for ${t}`),right:AST.factoryExpression(r,`right operand for ${t}`,AST.assignmentNodeOperation.has(t))},s.left.parent=s,s.right.parent=s;break;case"()":case"!":case"~":case"+_":case"-_":case"++_":case"--_":s={type:t,right:AST.factoryExpression(e,`operand for ${t}`)},s.right.parent=s;break;case".'":case"'":case"_++":case"_--":s={type:t,left:AST.factoryExpression(e,`operand for ${t}`)},s.left.parent=s;break;default:s={type:`INVALID:${t}`}}return s.omitAnswer=AST.omitAnswerNodeOperation.has(s.type),s.omitOutput=!1,s};static nodeDefaultedParameter=(t,e)=>{const r=AST.nodeOperation("=",t,e);if(!AST.isNodeDefaultedParameter(r))throw new TypeError("defaulted parameter has invalid node type.");return r};static nodeIgnoredTarget=()=>({type:"<~>",omitAnswer:!0,omitOutput:!1});static nodeListFirst=t=>{const e={type:"LIST",list:t?[t]:[],omitAnswer:!1,omitOutput:!1};return t&&(e.list[0].parent=e),e};static appendNodeList=(t,e)=>(e.parent=t,t.list.push(e),t);static nodeList=t=>{const e={type:"LIST",list:t,omitAnswer:!1,omitOutput:!1};return e.list.forEach(t=>t.parent=e),e};static nodeFirstRow=(t=null,e)=>t?AST.firstRow(AST.factoryArrayElementList(t,"array element "),e):AST.emptyArray(e);static nodeAppendRow=(t,e=null)=>e?AST.appendRow(t,AST.factoryArrayElementList(e,"array element ")):t;static nodeIndirectRef=(t,e)=>{if(AST.isNodeIndirectRef(t))return t.field.push("string"==typeof e?e:AST.factoryExpression(e,"indirect reference field")),"string"!=typeof e&&(e.parent=t),t;{const r={type:".",obj:AST.factoryExpression(t,"indirect reference object"),field:["string"==typeof e?e:AST.factoryExpression(e,"indirect reference field")],omitAnswer:!1,omitOutput:!1};return r.obj.parent=r,"string"!=typeof e&&(e.parent=r),r}};static nodeReturnList=(t,e)=>({type:"RETLIST",selector:t,...void 0===e?{handler:t=>({length:t})}:"function"==typeof e?{handler:e}:e});static nodeCommaSeparatedReturnList=(t,e,r)=>{const s=AST.nodeReturnList(e,r);return s.commaSeparated=!0,s.returnListLength=t,s};static nodeBoundedReturnList=(t,e,r,s)=>AST.nodeReturnList((r,i)=>(AST.throwErrorIfGreaterThanReturnList(t,r.length,s),e(r,i)),e=>(AST.throwErrorIfGreaterThanReturnList(t,e,s),r?r(e):{length:e}));static ensureReturnList=t=>{if(AST.isNodeReturnList(t))return t;const e=t;return AST.nodeReturnList((t,r)=>{if(0===r)return e;throw AST.throwErrorIfGreaterThanReturnList(1,r+1),new EvalError("unreachable return-list selector branch.")})};static throwErrorIfGreaterThanReturnList=(t,e,r)=>{if(e>t){const e=`element number ${t+1} undefined in return list`;throw r&&r(e),new EvalError(e)}};static reduceToFirstIfReturnList=t=>{if(AST.isNodeReturnList(t)){const e=t.selector(t.handler(1),0);return e.parent=t.parent,e}return t};static throwInvalidCallError=(t,e=!0,r)=>{if(e){const e=`Invalid call to ${t}. Type 'help ${t}' to see correct usage.`;throw r&&r(e),new SyntaxError(e)}};static nodeFunctionHandle=(t=null,e=null,r=null)=>{const s=e?AST.factoryNodeList(e,AST.isNodeFunctionParameter,"function handle parameter "):[],i=r?AST.factoryExpression(r,"function handle expression"):null;t||(AST.assertAnonymousFunctionParameters(s),i&&AST.assertAnonymousFunctionExpression(i));const n=FunctionHandle.create(t?t.id:void 0,s,i);return n.parameter.forEach(t=>{t.parent=n}),n.expression&&(n.expression.parent=n),n};static nodeFunctionDefinition=(t,e,r,s,i)=>{const n=AST.factoryNodeList(e,AST.isNodeFunctionReturn,"function return "),a=AST.factoryNodeList(r,AST.isNodeFunctionParameter,"function parameter "),o=AST.factoryNodeList(s,AST.isNodeArguments,"function arguments block "),l=AST.factoryNodeList(i,AST.isNodeProgramElement,"function statement "),c={type:"FCNDEF",id:t.id,mapper:1===a.length&&1===n.length,ev:new Array(a.length).fill(!0),func:null,return:e,parameter:r,arguments:s,statements:i,omitAnswer:!0,omitOutput:!0};return c.return.parent=c,c.parameter.parent=c,c.arguments.parent=c,c.statements.parent=c,n.forEach(t=>t.parent=c),a.forEach(t=>t.parent=c),o.forEach(t=>t.parent=c),l.forEach(t=>t.parent=c),c};static nodeClassAttributeTable=t=>{const e={};for(const r of t)e[r.id]??=[],e[r.id].push(r);return e};static nodeClassSectionMemberGuard=t=>{switch(t){case"PROPERTIES":return AST.isNodeClassProperty;case"METHODS":return AST.isNodeFunctionDefinition;case"EVENTS":return AST.isNodeClassEvent;case"ENUMERATION":return AST.isNodeClassEnumeration;default:return t=>!1}};static nodeArgumentValidation=(t,e,r=null,s,i=null)=>{const n={type:"ARGVALID",name:AST.factoryExpression(t,"argument validation name"),size:AST.factoryExpressionList(e,"argument validation size "),class:AST.factoryArgumentClass(r,"argument validation class"),functions:AST.factoryExpressionList(s,"argument validation function "),default:i?AST.factoryExpression(i,"argument validation default"):null,omitAnswer:!0,omitOutput:!0};return n.name.parent=n,n.size.forEach(t=>{AST.isNodeBase(t)&&(t.parent=n)}),n.class&&(n.class.parent=n),n.functions.forEach(t=>{AST.isNodeBase(t)&&(t.parent=n)}),n.default&&(n.default.parent=n),n};static nodeArguments=(t,e)=>{const r=t?AST.isNodeList(t)?AST.factoryNodeList(t,AST.isNodeIdentifier,"arguments block attribute "):[t]:[],s={type:"ARGS",attribute:r[0]??null,attributes:r,validation:AST.factoryNodeList(e,AST.isNodeArgumentValidation,"arguments validation "),omitAnswer:!0,omitOutput:!0};return s.attributes.forEach(t=>t.parent=s),s.validation.forEach(t=>t.parent=s),s};static nodeDeclarationFirst=t=>({type:t,list:[],omitAnswer:!0,omitOutput:!0});static nodeReturn=()=>({type:"RETURN",omitAnswer:!0,omitOutput:!0});static nodeBreak=()=>({type:"BREAK",omitAnswer:!0,omitOutput:!0});static nodeContinue=()=>({type:"CONTINUE",omitAnswer:!0,omitOutput:!0});static getDeclarationNode=t=>"node"in t?t.node:t;static nodeAppendDeclaration=(t,e)=>{const r=AST.getDeclarationNode(e);if(!AST.isNodeDeclarationElement(r))throw new TypeError("declaration entry has invalid node type.");return r.parent=t,t.list.push(r),t};static nodeImport=()=>({type:"IMPORT",imports:[]});static nodeImportFirst=t=>{const e=AST.nodeImport();return e.omitAnswer=!0,e.omitOutput=!0,AST.nodeAppendImport(e,t)};static nodeAppendImport=(t,e)=>(e.parent=t,e.index=t.imports.length,t.imports.push(e),t);static nodeIfBegin=(t,e)=>{AST.factoryProgramElementList(e,"if body ");const r={type:"IF",expression:[AST.factoryExpression(t,"if condition")],then:[e],else:null,omitAnswer:!0,omitOutput:!0};return r.expression[0].parent=r,r.then[0].parent=r,r};static nodeIfAppendElse=(t,e)=>(AST.factoryProgramElementList(e.else,"else body "),t.else=e.else,t.else.parent=t,t);static nodeIfAppendElseIf=(t,e)=>(AST.factoryProgramElementList(e.then,"elseif body "),e.expression.parent=t,t.expression.push(e.expression),e.then.parent=t,t.then.push(e.then),t);static nodeElseIf=(t,e)=>{AST.factoryProgramElementList(e,"elseif body ");const r={type:"ELSEIF",expression:AST.factoryExpression(t,"elseif condition"),then:e,omitAnswer:!0,omitOutput:!0};return r.expression.parent=r,r.then.parent=r,r};static nodeElse=t=>{AST.factoryProgramElementList(t,"else body ");const e={type:"ELSE",else:t,omitAnswer:!0,omitOutput:!0};return e.else.parent=e,e};static nodeSwitch=(t,e,r=null)=>{r&&AST.factoryProgramElementList(r,"otherwise body ");const s={type:"SWITCH",expression:AST.factoryExpression(t,"switch expression"),cases:AST.factoryNodeList(e,AST.isNodeSwitchCase,"switch case "),otherwise:r,omitAnswer:!0,omitOutput:!0};return s.expression.parent=s,s.cases.forEach(t=>t.parent=s),s.otherwise&&(s.otherwise.parent=s),s};static nodeSwitchCase=(t,e)=>{AST.factoryProgramElementList(e,"case body ");const r={type:"CASE",expression:AST.factoryExpression(t,"case expression"),then:e,omitAnswer:!0,omitOutput:!0};return r.expression.parent=r,r.then.parent=r,r};static nodeWhile=(t,e)=>{AST.factoryProgramElementList(e,"while body ");const r={type:"WHILE",expression:AST.factoryExpression(t,"while condition"),body:e,omitAnswer:!0,omitOutput:!0};return r.expression.parent=r,r.body.parent=r,r};static nodeDoUntil=(t,e)=>{AST.factoryProgramElementList(t,"do body ");const r={type:"DO_UNTIL",body:t,expression:AST.factoryExpression(e,"until condition"),omitAnswer:!0,omitOutput:!0};return r.body.parent=r,r.expression.parent=r,r};static nodeFor=(t,e,r,s=!1,i=null)=>{AST.factoryProgramElementList(r,"for body ");const n={type:"FOR",target:AST.factoryExpression(t,"for target"),expression:AST.factoryExpression(e,"for expression"),workers:i?AST.factoryExpression(i,"for workers"):null,body:r,parallel:s,omitAnswer:!0,omitOutput:!0};return n.target.parent=n,n.expression.parent=n,n.workers&&(n.workers.parent=n),n.body.parent=n,n};static nodeSpmd=(t,e=null)=>{AST.factoryProgramElementList(t,"spmd body "),AST.factoryExpressionList(e,"spmd worker ");const r={type:"SPMD",workers:e,body:t,omitAnswer:!0,omitOutput:!0};return r.workers&&(r.workers.parent=r),r.body.parent=r,r};static nodeTry=(t,e=null,r=null)=>{AST.factoryProgramElementList(t,"try body "),e&&AST.factoryProgramElementList(e,"catch body ");const s={type:"TRY",body:t,catchIdentifier:r,catchBody:e,omitAnswer:!0,omitOutput:!0};return s.body.parent=s,s.catchIdentifier&&(s.catchIdentifier.parent=s),s.catchBody&&(s.catchBody.parent=s),s};static nodeUnwindProtect=(t,e)=>{AST.factoryProgramElementList(t,"unwind_protect body "),AST.factoryProgramElementList(e,"unwind_protect cleanup ");const r={type:"UNWIND_PROTECT",body:t,cleanup:e,omitAnswer:!0,omitOutput:!0};return r.body.parent=r,r.cleanup.parent=r,r};static nodeClassDef=(t,e,r=AST.nodeListFirst(),s=AST.nodeListFirst())=>{const i={type:"CLASSDEF",id:t.id,attributes:AST.factoryNodeList(r,AST.isNodeClassAttribute,"class attribute "),attributeTable:{},superclasses:AST.factoryNodeList(s,AST.isNodeIdentifier,"superclass "),sections:AST.factoryNodeList(e,AST.isNodeClassSection,"class section "),omitAnswer:!0,omitOutput:!0};return i.attributeTable=AST.nodeClassAttributeTable(i.attributes),i.attributes.forEach(t=>t.parent=i),i.superclasses.forEach(t=>t.parent=i),i.sections.forEach(t=>t.parent=i),i};static nodeClassSection=(t,e,r=AST.nodeListFirst())=>{const s=AST.factoryNodeList(e,AST.nodeClassSectionMemberGuard(t),`${t.toLowerCase()} member `),i={type:"CLASS_SECTION",kind:t,attributes:AST.factoryNodeList(r,AST.isNodeClassAttribute,"class section attribute "),attributeTable:{},members:e,omitAnswer:!0,omitOutput:!0};return i.attributeTable=AST.nodeClassAttributeTable(i.attributes),i.attributes.forEach(t=>t.parent=i),i.members.parent=i,s.forEach(t=>t.parent=i),i};static nodeClassProperty=(t,e=AST.nodeListFirst(),r=null,s=AST.nodeListFirst(),i=null)=>{const n=e&&"LIST"!==e.type?AST.factoryExpression(e,"argument validation default"):null,a=AST.isNodeList(e)?e:AST.nodeListFirst(),o=AST.nodeArgumentValidation(t,a,r,s,n??i),l={type:"CLASS_PROPERTY",id:t.id,validation:o,name:o.name,size:o.size,class:o.class,functions:o.functions,defaultValue:o.default,omitAnswer:!0,omitOutput:!0};return l.validation.parent=l,l};static nodeClassEvent=t=>({type:"CLASS_EVENT",id:t.id,omitAnswer:!0,omitOutput:!0});static nodeClassEnumeration=(t,e=AST.nodeListFirst())=>{const r={type:"CLASS_ENUMERATION",id:t.id,args:AST.factoryExpressionList(e,"enumeration argument "),omitAnswer:!0,omitOutput:!0};return r.args.forEach(t=>{AST.isNodeBase(t)&&(t.parent=r)}),r};static nodeClassAttribute=(t,e=null)=>{const r={type:"CLASS_ATTRIBUTE",id:t.id,value:e?AST.factoryExpression(e,"class attribute value"):null,omitAnswer:!0,omitOutput:!0};return r.value&&(r.value.parent=r),r}}const src_AST=null;class ClassMember{static defaultAccess="public";static isMetaClassNode=t=>AST.isNodeMetaClass(t);static isNegatedAttributeNode=t=>AST.isNodePrefixOperation(t)&&("~"===t.type||"!"===t.type);static classNameValue=t=>AST.isNodeIdentifier(t)?t.id:CharString.isInstanceOf(t)?t.str:this.isMetaClassNode(t)?t.className.id:null;static hasAttribute=(t,e)=>!0===this.attributeBooleanValue(t[e]?.[0]);static attributeBooleanValue=t=>{if(!t)return null;if(!t.value)return!0;const e=t.value;if(this.isNegatedAttributeNode(e))return!1;if(AST.isNodeIdentifier(e)){if("true"===e.id)return!0;if("false"===e.id)return!1}return null};static isSupportedAccess=t=>{if("public"===t||"protected"===t||"private"===t)return!0;const e=/^\?[A-Za-z]\w*(?:\.[A-Za-z]\w*)*$/;if(e.test(t))return!0;if(t.startsWith("{")&&t.endsWith("}")){const r=t.slice(1,-1).split(",");return r.length>0&&r.every(t=>e.test(t))}return!1};static attributeValue=t=>{if(!t||!t.value)return null;const e=t.value;if(AST.isNodeIdentifier(e))return e.id;if(CharString.isInstanceOf(e))return e.toString();if(this.isMetaClassNode(e))return`?${e.className.id}`;if(MultiArray.isInstanceOf(e)&&e.isCell){const t=MultiArray.linearize(e).map(t=>{const e=t;return this.isMetaClassNode(e)?`?${e.className.id}`:null});if(t.every(t=>"string"==typeof t))return`{${t.join(",")}}`}return null};static classNameListFromAttribute=t=>{if(!t||!t.value)return null;const e=this.classNameValue(t.value);if(e)return[e];if(MultiArray.isInstanceOf(t.value)&&t.value.isCell){const e=MultiArray.linearize(t.value).map(t=>this.classNameValue(t));if(e.every(t=>Boolean(t)))return e}return null};static positiveIntegerFromAttribute=t=>{const e=t?.value;if(!e||void 0===e.re||void 0===e.im||0!==Number(e.im))return null;const r=Number(e.re);return Number.isInteger(r)&&r>0?r:null};static accessFromAttributes=(t,e="Access",r=this.defaultAccess)=>this.attributeValue(t[e]?.[0])??r;static methodNameFromAttribute=(t,e)=>{const r=this.attributeValue(t[e]?.[0]);return r&&/^[A-Za-z]\w*(?:\.[A-Za-z]\w*)*$/.test(r)?r:null};static validateAccessAttribute=(t,e,r,s)=>{const i=t[e]?.[0];if(!i)return;const n=this.attributeValue(i);n&&this.isSupportedAccess(n)||s(`invalid ${e} attribute for ${r}.`)}}const src_ClassMember=null;class ClassDefinition{static CLASS_DEFINITION=6;static classAttributes=new Set(["Abstract","AllowedSubclasses","ConstructOnLoad","HandleCompatible","Hidden","InferiorClasses","RestrictsSubclassing","Sealed"]);static propertyAttributes=new Set(["AbortSet","Abstract","Access","Constant","Dependent","GetAccess","GetMethod","GetObservable","Hidden","NonCopyable","PartialMatchPriority","SetAccess","SetMethod","SetObservable","Transient"]);static methodAttributes=new Set(["Abstract","Access","Hidden","Sealed","Static"]);static eventAttributes=new Set(["Hidden","ListenAccess","NotifyAccess"]);static enumerationAttributes=new Set(["Hidden"]);static classBooleanAttributes=new Set(["Abstract","ConstructOnLoad","HandleCompatible","Hidden","RestrictsSubclassing","Sealed"]);static propertyBooleanAttributes=new Set(["AbortSet","Abstract","Constant","Dependent","GetObservable","Hidden","NonCopyable","SetObservable","Transient"]);static methodBooleanAttributes=new Set(["Abstract","Hidden","Sealed","Static"]);static eventBooleanAttributes=new Set(["Hidden"]);static enumerationBooleanAttributes=new Set(["Hidden"]);static builtinSuperclassNames=new Set(["handle","event.EventData","event.PropertyEvent","matlab.mixin.SetGet","matlab.mixin.SetGetExactNames"]);static sealedBuiltinSuperclassNames=new Set(["event.PropertyEvent"]);static eventDataInheritedPropertyNames=new Set(["Source","EventName"]);static firstByKey=(t,e)=>{const r=new Set;return t.filter(t=>{const s=e(t);return!r.has(s)&&(r.add(s),!0)})};type=ClassDefinition.CLASS_DEFINITION;parent;name;packageName;simpleName;ast;attributes;isAbstract;isSealed;isHidden;isConstructOnLoad;isHandleCompatible;explicitHandleCompatible;inferiorClasses;allowedSubclasses;hasAllowedSubclassesAttribute;isRestrictsSubclassing;isBuiltinHandleClass;superclasses;superclassDefinitions;sections;properties;propertyTable;methods;staticMethods;instanceMethods;methodsByAccess;methodTable;events;enumerations;enumerationTable;static isInstanceOf=t=>t instanceof ClassDefinition;constructor(t){this.ast=t,this.name=t.id;const e=this.name.lastIndexOf(".");this.packageName=e<0?"":this.name.slice(0,e),this.simpleName=e<0?this.name:this.name.slice(e+1),this.attributes=t.attributeTable;const r=ClassMember.hasAttribute(this.attributes,"Sealed");this.isHidden=ClassMember.hasAttribute(this.attributes,"Hidden"),this.isConstructOnLoad=ClassMember.hasAttribute(this.attributes,"ConstructOnLoad"),this.explicitHandleCompatible=ClassMember.attributeBooleanValue(this.attributes.HandleCompatible?.[0]),this.isHandleCompatible=!0===this.explicitHandleCompatible,this.inferiorClasses=ClassMember.classNameListFromAttribute(this.attributes.InferiorClasses?.[0])??[];const s=ClassMember.classNameListFromAttribute(this.attributes.AllowedSubclasses?.[0]);this.allowedSubclasses=s??[],this.hasAllowedSubclassesAttribute=null!==s,this.isBuiltinHandleClass="handle"===this.name,this.superclasses=t.superclasses.map(t=>t.id),this.superclassDefinitions=[],this.sections=t.sections,this.properties=[],this.propertyTable={},this.methods=[],this.staticMethods=[],this.instanceMethods=[],this.methodsByAccess={},this.methodTable={},this.events=[],this.enumerations=[],this.enumerationTable={},this.collectMembers(),this.isSealed=r||this.enumerations.length>0||this.hasAllowedSubclassesAttribute&&0===this.allowedSubclasses.length,this.isRestrictsSubclassing=this.isSealed||this.hasAllowedSubclassesAttribute||ClassMember.hasAttribute(this.attributes,"RestrictsSubclassing"),this.isAbstract=ClassMember.hasAttribute(this.attributes,"Abstract")||this.properties.some(t=>t.isAbstract)||this.methods.some(t=>t.isAbstract)}static create=t=>new ClassDefinition(t);static copy=t=>t;static unparse=(t,e)=>e.Unparse(t.ast);copy(){return ClassDefinition.copy(this)}validateLocalDefinition(t){this.validateSupportedAttributes(t),this.validateAccessAttributes(t),this.validateAttributeCombinations(t),this.validateDuplicateMembers(t),this.validatePropertyAccessors(t)}resolveSuperclasses(t,e){this.validateLocalDefinition(e),this.superclassDefinitions.length=0;for(const r of this.superclasses){if(ClassDefinition.sealedBuiltinSuperclassNames.has(r)&&e(`class ${this.name} cannot inherit from sealed class ${r}.`),ClassDefinition.builtinSuperclassNames.has(r))continue;r===this.name&&e(`class ${this.name} cannot inherit from itself.`);const s=t(r);s||e(`superclass '${r}' for class ${this.name} is not defined.`),s.isSealed&&e(`class ${this.name} cannot inherit from sealed class ${s.name}.`),s.allowedSubclasses.length>0&&!s.allowedSubclasses.includes(this.name)&&e(`class ${this.name} cannot inherit from class ${s.name}: subclass is not listed in AllowedSubclasses.`),this.superclassDefinitions.push(s)}this.validateInheritanceCycles(e),this.validateSealedMethodOverrides(e),this.validateInheritedMethodCompatibility(e),this.validateInheritedPropertyCompatibility(e),this.validateInheritedEventCompatibility(e),this.validateHandleCompatibility(e),this.validateResolvedClassRestrictions(e)}isSubclassOf(t){return this.superclassDefinitions.some(e=>e===t||e.isSubclassOf(t))}isSubclassOfName(t){return"handle"===t?this.isHandleClass():!!this.superclasses.includes(t)||this.superclassDefinitions.some(e=>e.name===t||e.isSubclassOfName(t))}isHandleClass(){return this.isBuiltinHandleClass||this.superclasses.includes("handle")||this.superclasses.includes("event.EventData")||this.superclasses.includes("matlab.mixin.SetGet")||this.superclasses.includes("matlab.mixin.SetGetExactNames")||this.superclassDefinitions.some(t=>t.isHandleClass())}isHandleCompatibleClass(){return this.isHandleClass()||this.isHandleCompatible}isSetGetClass(){return this.superclasses.includes("matlab.mixin.SetGet")||this.superclasses.includes("matlab.mixin.SetGetExactNames")||this.superclassDefinitions.some(t=>t.isSetGetClass())}isSetGetExactNamesClass(){return this.superclasses.includes("matlab.mixin.SetGetExactNames")||this.superclassDefinitions.some(t=>t.isSetGetExactNamesClass())}findSuperclass(t){for(const e of this.superclassDefinitions){if(e.name===t)return e;const r=e.findSuperclass(t);if(r)return r}}allProperties(){const t=ClassDefinition.firstByKey(this.superclassDefinitions.flatMap(t=>t.allProperties()),t=>t.name),e=new Set(this.properties.map(t=>t.name));return[...t.filter(t=>!e.has(t.name)),...this.properties]}allMethods(){const t=ClassDefinition.firstByKey(this.inheritedMethods(),t=>this.methodOverrideKey(t)),e=new Set(this.methods.map(t=>this.methodOverrideKey(t)));return[...t.filter(t=>!e.has(this.methodOverrideKey(t))),...this.methods]}inheritedMethods(){return this.superclassDefinitions.flatMap(t=>t.allMethods())}allEvents(){const t=ClassDefinition.firstByKey(this.superclassDefinitions.flatMap(t=>t.allEvents()),t=>t.name),e=new Set(this.events.map(t=>t.name));return[...t.filter(t=>!e.has(t.name)),...this.events]}allEnumerations(){const t=ClassDefinition.firstByKey(this.superclassDefinitions.flatMap(t=>t.allEnumerations()),t=>t.name),e=new Set(this.enumerations.map(t=>t.name));return[...t.filter(t=>!e.has(t.name)),...this.enumerations]}findProperty(t){return this.propertyTable[t]??this.superclassDefinitions.map(e=>e.findProperty(t)).find(t=>Boolean(t))}findMethod(t,e=()=>!0){const r=this.methodTable[t]?.find(e);return r??this.superclassDefinitions.map(r=>r.findMethod(t,e)).find(t=>Boolean(t))}findConstructor(){return this.methodTable[this.name]?.find(t=>!t.isStatic)??this.methodTable[this.simpleName]?.find(t=>!t.isStatic)}findEnumeration(t){return this.enumerationTable[t]??this.superclassDefinitions.map(e=>e.findEnumeration(t)).find(t=>Boolean(t))}findEvent(t){return this.events.find(e=>e.name===t)??this.superclassDefinitions.map(e=>e.findEvent(t)).find(t=>Boolean(t))}abstractMethodNames(){return new Set(this.unresolvedAbstractMethods().map(t=>t.name))}abstractPropertyNames(){return new Set(this.unresolvedAbstractProperties().map(t=>t.name))}unresolvedAbstractMethods(){const t=new Map;for(const e of this.superclassDefinitions)for(const r of e.unresolvedAbstractMethodEntries())t.set(r.key,r.method);for(const e of this.methods){const r=this.methodOverrideKey(e);e.isAbstract?t.set(r,e):t.delete(r)}return[...t.values()]}unresolvedAbstractProperties(){const t=new Map;for(const e of this.superclassDefinitions)for(const r of e.unresolvedAbstractPropertyEntries())t.set(r.key,r.property);for(const e of this.properties){const r=this.propertyOverrideKey(e);e.isAbstract?t.set(r,e):t.delete(r)}return[...t.values()]}isEffectivelyAbstract(){return this.isAbstract||this.unresolvedAbstractMethods().length>0||this.unresolvedAbstractProperties().length>0}unresolvedAbstractMethodEntries(){return this.unresolvedAbstractMethods().map(t=>({key:this.methodOverrideKey(t),method:t}))}unresolvedAbstractPropertyEntries(){return this.unresolvedAbstractProperties().map(t=>({key:this.propertyOverrideKey(t),property:t}))}methodOverrideKey(t){return`${t.isStatic?"static":"instance"}:${t.name}`}propertyOverrideKey(t){return t.name}validateSealedMethodOverrides(t){const e=new Map;for(const t of this.inheritedMethods())t.isSealed&&e.set(this.methodOverrideKey(t),t);for(const r of this.methods){const s=e.get(this.methodOverrideKey(r));s&&t(`method '${r.name}' in class ${this.name} cannot override sealed method from class ${s.classDefinition.name}.`)}}isPrivateMethodDefinition(t){return"private"===t.access}validateInheritedMethodCompatibility(t){const e=new Map;for(const t of this.inheritedMethods()){const r=this.methodOverrideKey(t),s=e.get(r)??[];s.some(e=>e.classDefinition===t.classDefinition&&e.name===t.name&&e.isStatic===t.isStatic)||s.push(t),e.set(r,s)}for(const r of this.methods)for(const s of e.get(this.methodOverrideKey(r))??[])this.isPrivateMethodDefinition(s)||r.access!==s.access&&t(`method '${r.name}' in class ${this.name} must match inherited Access from method in class ${s.classDefinition.name}.`);const r=new Set(this.methods.map(t=>this.methodOverrideKey(t)));for(const[s,i]of e){if(r.has(s))continue;const e=i.filter(t=>!t.isAbstract&&!this.isPrivateMethodDefinition(t));if(new Set(e.map(t=>t.classDefinition.name)).size<=1)continue;if(1===e.filter(t=>t.isSealed).length)continue;const n=e[0]?.name??s.slice(s.indexOf(":")+1);t(`class ${this.name} inherits incompatible method '${n}' from multiple superclasses.`)}}validateSupportedAttributes(t){this.validateAttributeNames(this.attributes,ClassDefinition.classAttributes,`class ${this.name}`,t),this.validateDuplicateAttributes(this.attributes,`class ${this.name}`,t),this.validateBooleanAttributes(this.attributes,ClassDefinition.classBooleanAttributes,`class ${this.name}`,t),this.validateClassNameListAttributes(this.attributes,new Set(["AllowedSubclasses","InferiorClasses"]),`class ${this.name}`,t);for(const e of this.sections){const r=`${e.kind.toLowerCase()} section of class ${this.name}`;switch(e.kind){case"PROPERTIES":this.validateAttributeNames(e.attributeTable,ClassDefinition.propertyAttributes,r,t),this.validateBooleanAttributes(e.attributeTable,ClassDefinition.propertyBooleanAttributes,r,t),this.validatePositiveIntegerAttributes(e.attributeTable,new Set(["PartialMatchPriority"]),r,t);break;case"METHODS":this.validateAttributeNames(e.attributeTable,ClassDefinition.methodAttributes,r,t),this.validateBooleanAttributes(e.attributeTable,ClassDefinition.methodBooleanAttributes,r,t);break;case"EVENTS":this.validateAttributeNames(e.attributeTable,ClassDefinition.eventAttributes,r,t),this.validateBooleanAttributes(e.attributeTable,ClassDefinition.eventBooleanAttributes,r,t);break;case"ENUMERATION":this.validateAttributeNames(e.attributeTable,ClassDefinition.enumerationAttributes,r,t),this.validateBooleanAttributes(e.attributeTable,ClassDefinition.enumerationBooleanAttributes,r,t)}this.validateDuplicateAttributes(e.attributeTable,r,t)}}validateAttributeNames(t,e,r,s){for(const i of Object.keys(t))e.has(i)||s(`unsupported ${i} attribute for ${r}.`)}validateDuplicateAttributes(t,e,r){for(const[s,i]of Object.entries(t))i.length>1&&r(`duplicate ${s} attribute for ${e}.`)}validateBooleanAttributes(t,e,r,s){for(const i of e){const e=t[i]?.[0];e&&null===ClassMember.attributeBooleanValue(e)&&s(`invalid boolean ${i} attribute for ${r}.`)}}validateClassNameListAttributes(t,e,r,s){for(const i of e){const e=t[i]?.[0];e&&null===ClassMember.classNameListFromAttribute(e)&&s(`invalid class-name list ${i} attribute for ${r}.`)}}validatePositiveIntegerAttributes(t,e,r,s){for(const i of e){const e=t[i]?.[0];e&&null===ClassMember.positiveIntegerFromAttribute(e)&&s(`invalid positive integer ${i} attribute for ${r}.`)}}validateAccessAttributes(t){for(const e of this.sections){const r=`${e.kind.toLowerCase()} section of class ${this.name}`;switch(e.kind){case"PROPERTIES":ClassMember.validateAccessAttribute(e.attributeTable,"Access",r,t),ClassMember.validateAccessAttribute(e.attributeTable,"GetAccess",r,t),ClassMember.validateAccessAttribute(e.attributeTable,"SetAccess",r,t);break;case"METHODS":ClassMember.validateAccessAttribute(e.attributeTable,"Access",r,t);break;case"EVENTS":ClassMember.validateAccessAttribute(e.attributeTable,"Access",r,t),ClassMember.validateAccessAttribute(e.attributeTable,"ListenAccess",r,t),ClassMember.validateAccessAttribute(e.attributeTable,"NotifyAccess",r,t)}}}validateInheritanceCycles(t){for(const e of this.superclassDefinitions){e===this&&t(`class ${this.name} cannot inherit from itself.`);const r=e.inheritanceCyclePath(this,[this.name,e.name],new Set([this]))??e.inheritanceNameCyclePath(this.name,[this.name,e.name],new Set([this.name]));r&&t(`circular class inheritance detected: ${r.join(" -> ")}.`)}}inheritanceCyclePath(t,e,r){if(this===t)return e;if(!r.has(this)){r.add(this);for(const s of this.superclassDefinitions){const i=s.inheritanceCyclePath(t,[...e,s.name],r);if(i)return i}}}inheritanceNameCyclePath(t,e,r){if(this.superclasses.includes(t))return[...e,t];if(!r.has(this.name)){r.add(this.name);for(const s of this.superclassDefinitions){const i=s.inheritanceNameCyclePath(t,[...e,s.name],r);if(i)return i}}}validatePropertyAccessors(t){const e=(e,r,s)=>{if(!s)return void(e.attributes[r]?.[0]&&t(`invalid ${r} attribute for property '${e.name}' in class ${this.name}.`));const i=this.findMethod(s,t=>!t.isStatic);i||t(`${r} method '${s}' for property '${e.name}' in class ${this.name} is not defined.`);const n=this.methodParameters(i).length,a=this.methodReturns(i),o=a.length;"GetMethod"!==r||1===n&&1===o&&!AST.isNodeIgnoredTarget(a[0])||t(`${r} method '${s}' for property '${e.name}' in class ${this.name} must declare one input and one output.`),"SetMethod"!==r||2===n&&1===o&&!AST.isNodeIgnoredTarget(a[0])||t(`${r} method '${s}' for property '${e.name}' in class ${this.name} must declare two inputs and one output.`)};for(const t of this.properties)e(t,"GetMethod",t.getMethodName),e(t,"SetMethod",t.setMethodName);for(const e of this.methods){const r=/^(get|set)\.(.+)$/.exec(e.name);if(!r)continue;const[,s,i]=r;this.findProperty(i)||t(`${s} accessor '${e.name}' in class ${this.name} does not match a class property.`),e.isStatic&&t(`${s} accessor '${e.name}' in class ${this.name} cannot be static.`);const n=this.methodParameters(e).length,a=this.methodReturns(e),o=a.length;"get"!==s||1===n&&1===o&&!AST.isNodeIgnoredTarget(a[0])||t(`get accessor '${e.name}' in class ${this.name} must declare one input and one output.`),"set"!==s||2===n&&1===o&&!AST.isNodeIgnoredTarget(a[0])||t(`set accessor '${e.name}' in class ${this.name} must declare two inputs and one output.`)}}validateResolvedClassRestrictions(t){this.events.length>0&&!this.isHandleClass()&&t(`class ${this.name} cannot define events because it is not a handle class.`),this.isSubclassOfName("event.EventData")&&!this.isConstructOnLoad&&t(`class ${this.name} must set ConstructOnLoad because it subclasses event.EventData.`);for(const e of this.properties)this.isSubclassOfName("event.EventData")&&ClassDefinition.eventDataInheritedPropertyNames.has(e.name)&&t(`class ${this.name} cannot redefine inherited event.EventData property '${e.name}'.`),e.isNonCopyable&&!this.isHandleClass()&&t(`NonCopyable property '${e.name}' in class ${this.name} requires a handle class.`),e.isAbortSet&&!this.isHandleClass()&&t(`AbortSet property '${e.name}' in class ${this.name} requires a handle class.`),1===e.partialMatchPriority||this.isSetGetClass()||t(`PartialMatchPriority property '${e.name}' in class ${this.name} requires matlab.mixin.SetGet.`)}validateHandleCompatibility(t){const e=this.superclasses.some(t=>ClassDefinition.builtinSuperclassNames.has(t))||this.superclassDefinitions.some(t=>t.isHandleClass()),r=this.superclassDefinitions.find(t=>!t.isHandleCompatibleClass());!1===this.explicitHandleCompatible&&e&&t(`class ${this.name} cannot set HandleCompatible to false while inheriting from a handle class.`),(!0===this.explicitHandleCompatible||e)&&r&&t(`class ${this.name} cannot combine handle semantics with non-handle-compatible superclass ${r.name}.`)}isPrivatePropertyDefinition(t){return"private"===t.getAccess&&"private"===t.setAccess}validateInheritedPropertyCompatibility(t){const e=new Map;for(const t of this.superclassDefinitions)for(const r of t.allProperties()){const t=e.get(r.name)??[];t.some(t=>t.classDefinition===r.classDefinition&&t.name===r.name)||t.push(r),e.set(r.name,t)}for(const r of this.properties)for(const s of e.get(r.name)??[])s.isAbstract?r.getAccess===s.getAccess&&r.setAccess===s.setAccess||t(`property '${r.name}' in class ${this.name} must match inherited GetAccess and SetAccess from abstract property in class ${s.classDefinition.name}.`):this.isPrivatePropertyDefinition(s)||t(`property '${r.name}' in class ${this.name} cannot redefine inherited property from class ${s.classDefinition.name}.`);for(const[r,s]of e){const e=s.filter(t=>!t.isAbstract&&!this.isPrivatePropertyDefinition(t));new Set(e.map(t=>t.classDefinition.name)).size>1&&!this.properties.some(t=>t.name===r)&&t(`class ${this.name} inherits incompatible property '${r}' from multiple superclasses.`)}}isPrivateEventDefinition(t){return"private"===t.listenAccess&&"private"===t.notifyAccess}validateInheritedEventCompatibility(t){const e=new Map;for(const t of this.superclassDefinitions)for(const r of t.allEvents()){const t=e.get(r.name)??[];t.some(t=>t.classDefinition===r.classDefinition&&t.name===r.name)||t.push(r),e.set(r.name,t)}for(const[r,s]of e){const e=s.filter(t=>!this.isPrivateEventDefinition(t));new Set(e.map(t=>t.classDefinition.name)).size>1&&t(`class ${this.name} inherits incompatible event '${r}' from multiple superclasses.`)}}validateAttributeCombinations(t){if(ClassMember.hasAttribute(this.attributes,"Abstract")&&ClassMember.hasAttribute(this.attributes,"Sealed")&&t(`class ${this.name} cannot be both abstract and sealed.`),this.isSealed){const e=this.methods.find(t=>t.isAbstract);e&&t(`sealed class ${this.name} cannot define abstract method '${e.name}'.`);const r=this.properties.find(t=>t.isAbstract);r&&t(`sealed class ${this.name} cannot define abstract property '${r.name}'.`)}for(const e of this.sections)"METHODS"===e.kind&&ClassMember.hasAttribute(e.attributeTable,"Abstract")&&ClassMember.hasAttribute(e.attributeTable,"Sealed")&&t(`methods section of class ${this.name} cannot be both abstract and sealed.`);for(const e of this.properties)e.isDependent&&e.isConstant&&t(`property '${e.name}' in class ${this.name} cannot be both dependent and constant.`),e.isAbstract&&e.isConstant&&t(`property '${e.name}' in class ${this.name} cannot be both abstract and constant.`),e.isAbstract&&e.getMethodName&&t(`abstract property '${e.name}' in class ${this.name} cannot define a GetMethod.`),e.isAbstract&&e.setMethodName&&t(`abstract property '${e.name}' in class ${this.name} cannot define a SetMethod.`),e.isDependent&&e.defaultValue&&t(`dependent property '${e.name}' in class ${this.name} cannot define a default value.`),e.isAbstract&&e.defaultValue&&t(`abstract property '${e.name}' in class ${this.name} cannot define a default value.`),e.isConstant&&!e.defaultValue&&t(`constant property '${e.name}' in class ${this.name} must define a default value.`);for(const e of this.methods){e.isAbstract&&e.node.statements.list.length>0&&t(`abstract method '${e.name}' in class ${this.name} cannot define a method body.`),e.isAbstract&&e.node.arguments.list.length>0&&t(`arguments blocks are not allowed in abstract method '${e.name}' of class ${this.name}.`),this.isConstructorMethodName(e.name)&&e.isStatic&&t(`constructor for class ${this.name} cannot be static.`),this.isConstructorMethodName(e.name)&&e.isAbstract&&t(`constructor for class ${this.name} cannot be abstract.`),"delete"===e.name&&e.node.arguments.list.length>0&&t(`arguments blocks are not allowed in delete method of class ${this.name}.`);const r=this.methodReturns(e);this.isConstructorMethodName(e.name)&&(1!==r.length||AST.isNodeIgnoredTarget(r[0]))&&t(`constructor for class ${this.name} must declare exactly one output.`),this.isConstructorMethodName(e.name)&&this.isConstructOnLoad&&!this.constructorAcceptsNoInputs(e)&&t(`ConstructOnLoad class ${this.name} constructor must support zero input arguments.`)}}constructorAcceptsNoInputs(t){return this.methodParameters(t).every(t=>AST.isNodeDefaultedParameter(t)||AST.isNodeIdentifier(t)&&"varargin"===t.id)}validateDuplicateMembers(t){this.validateDuplicateNames(this.properties.map(t=>t.name),"property",t),this.validateDuplicateNames(this.events.map(t=>t.name),"event",t),this.validateDuplicateNames(this.enumerations.map(t=>t.name),"enumeration member",t),this.validateDuplicateNames(this.methods.map(t=>this.methodOverrideKey(t)),"method",t,t=>t.slice(t.indexOf(":")+1)),this.validateCrossMemberNameConflicts(t)}validateCrossMemberNameConflicts(t){const e=new Map,r=(r,s)=>{r!==this.simpleName&&r!==this.name||t(`class ${this.name} cannot define ${s} with the same name as the class.`);const i=e.get(r);i&&t(`class ${this.name} has conflicting ${i} and ${s} named '${r}'.`),e.set(r,s)};for(const t of this.properties)r(t.name,"property");for(const t of this.methods)this.isConstructorMethodName(t.name)||t.name.startsWith("get.")||t.name.startsWith("set.")||r(t.name,"method");for(const t of this.events)r(t.name,"event");for(const t of this.enumerations)r(t.name,"enumeration member")}isConstructorMethodName(t){return t===this.name||t===this.simpleName}validateDuplicateNames(t,e,r,s=t=>t){const i=new Set;for(const n of t)i.has(n)&&r(`duplicate ${e} '${s(n)}' in class ${this.name}.`),i.add(n)}collectMembers(){for(const t of this.sections)switch(t.kind){case"PROPERTIES":this.collectProperties(t);break;case"METHODS":this.collectMethods(t);break;case"EVENTS":this.collectEvents(t);break;case"ENUMERATION":this.collectEnumerations(t)}}classSectionMembers(t,e){return t.members.list.map((r,s)=>{if(!e(r))throw new TypeError(`internal AST error: ${t.kind.toLowerCase()} member ${s+1} has invalid node type.`);return r})}checkedMethodHeaderList(t,e,r,s){return t.map((t,i)=>{if(!e(t))throw new TypeError(`internal AST error: method '${r}' ${s} ${i+1} has invalid node type.`);return t})}methodParameters(t){return this.checkedMethodHeaderList(t.node.parameter.list,AST.isNodeFunctionParameter,t.name,"parameter")}methodReturns(t){return this.checkedMethodHeaderList(t.node.return.list,AST.isNodeFunctionReturn,t.name,"return")}collectProperties(t){const e=ClassMember.accessFromAttributes(t.attributeTable),r=ClassMember.hasAttribute(t.attributeTable,"Constant"),s=ClassMember.hasAttribute(t.attributeTable,"Dependent"),i=ClassMember.hasAttribute(t.attributeTable,"Abstract");for(const n of this.classSectionMembers(t,AST.isNodeClassProperty)){const a={name:n.id,node:n,defaultValue:n.defaultValue,size:n.size,class:n.class,functions:n.functions,section:t,attributes:t.attributeTable,access:e,getAccess:ClassMember.accessFromAttributes(t.attributeTable,"GetAccess",e),setAccess:ClassMember.accessFromAttributes(t.attributeTable,"SetAccess",e),getMethodName:ClassMember.methodNameFromAttribute(t.attributeTable,"GetMethod"),setMethodName:ClassMember.methodNameFromAttribute(t.attributeTable,"SetMethod"),isConstant:r,isDependent:s,isAbstract:i,isHidden:ClassMember.hasAttribute(t.attributeTable,"Hidden"),isTransient:ClassMember.hasAttribute(t.attributeTable,"Transient"),isNonCopyable:ClassMember.hasAttribute(t.attributeTable,"NonCopyable"),isGetObservable:ClassMember.hasAttribute(t.attributeTable,"GetObservable"),isSetObservable:ClassMember.hasAttribute(t.attributeTable,"SetObservable"),isAbortSet:ClassMember.hasAttribute(t.attributeTable,"AbortSet"),partialMatchPriority:ClassMember.positiveIntegerFromAttribute(t.attributeTable.PartialMatchPriority?.[0])??1,classDefinition:this};this.properties.push(a),this.propertyTable[a.name]=a}}collectMethods(t){const e=ClassMember.accessFromAttributes(t.attributeTable),r=ClassMember.hasAttribute(t.attributeTable,"Static"),s=ClassMember.hasAttribute(t.attributeTable,"Abstract"),i=ClassMember.hasAttribute(t.attributeTable,"Sealed"),n=ClassMember.hasAttribute(t.attributeTable,"Hidden");for(const a of this.classSectionMembers(t,AST.isNodeFunctionDefinition)){const o={name:a.id,node:a,section:t,attributes:t.attributeTable,access:e,isStatic:r,isAbstract:s,isSealed:i,isHidden:n,classDefinition:this};this.methods.push(o),(r?this.staticMethods:this.instanceMethods).push(o),this.methodsByAccess[e]??=[],this.methodsByAccess[e].push(o),this.methodTable[o.name]??=[],this.methodTable[o.name].push(o)}}collectEvents(t){const e=ClassMember.accessFromAttributes(t.attributeTable),r=ClassMember.accessFromAttributes(t.attributeTable,"ListenAccess",e),s=ClassMember.accessFromAttributes(t.attributeTable,"NotifyAccess",e),i=ClassMember.hasAttribute(t.attributeTable,"Hidden");for(const n of this.classSectionMembers(t,AST.isNodeClassEvent))this.events.push({name:n.id,node:n,section:t,attributes:t.attributeTable,access:e,listenAccess:r,notifyAccess:s,isHidden:i,classDefinition:this})}collectEnumerations(t){const e=ClassMember.hasAttribute(t.attributeTable,"Hidden");for(const r of this.classSectionMembers(t,AST.isNodeClassEnumeration)){const s={name:r.id,node:r,args:r.args,section:t,attributes:t.attributeTable,isHidden:e,classDefinition:this};this.enumerations.push(s),this.enumerationTable[s.name]=s}}}const src_ClassDefinition=null;class ClassEventListener{static CLASS_EVENT_LISTENER=11;type=ClassEventListener.CLASS_EVENT_LISTENER;parent;source;kind;eventName;listenerKey;callback;enabled=!0;recursive=!1;notifying=!1;deleted=!1;static isInstanceOf=t=>t instanceof ClassEventListener;constructor(t,e,r,s=e,i="event.listener"){this.source=t,this.kind=i,this.eventName=e,this.listenerKey=s,this.callback=r}static create=(t,e,r,s=e,i="event.listener")=>new ClassEventListener(t,e,r,s,i);static isValid=t=>!t.deleted;static delete=t=>{t.deleted=!0,t.enabled=!1};static unparse=(t,e)=>`${t.kind} ${t.source.classDefinition.name}.${t.eventName}`;copy(){return this}}const src_ClassEventListener=null,expressionValue=(t,e,r,s)=>(AST.isExpressionBoundaryValue(t)||s(`${r} '${e}' is not an expression.`),t),expressionValues=(t,e,r,s)=>t.map((t,i)=>expressionValue(t,`${e}${i+1}`,r,s)),runtimeExpressionValue=(t,e,r,s)=>(expressionValue(t,e,r,s),AST.isRuntimeExpressionValue(t)||s(`${r} '${e}' is not a runtime value.`),t),runtimeExpressionValues=(t,e,r,s)=>t.map((t,i)=>runtimeExpressionValue(t,`${e}${i+1}`,r,s)),optionalRuntimeExpressionValue=t=>AST.isRuntimeExpressionValue(t)?t:void 0;class ClassInstance{static CLASS_INSTANCE=7;type=ClassInstance.CLASS_INSTANCE;parent;classDefinition;properties;listeners={};eventDataSource;eventDataEventName;deleted=!1;static isInstanceOf=t=>t instanceof ClassInstance;constructor(t,e={}){this.classDefinition=t,this.properties={};for(const[t,r]of Object.entries(e))this.properties[t]=ClassInstance.runtimePropertyValue(t,r)}static runtimePropertyValue=(t,e)=>runtimeExpressionValue(e,t,"property",t=>{throw new Error(t)});static propertyClassNames=t=>null===t?[]:AST.isNodeIdentifier(t)?[t.id]:AST.isNodeList(t)?t.list.flatMap(t=>AST.isNodeIdentifier(t)?[t.id]:[]):[];static implicitPropertyDefault=t=>{const e=ClassInstance.propertyClassNames(t.class);return e.includes("char")?CharString.create("","'"):e.includes("string")?CharString.create("",'"'):e.includes("cell")?MultiArray.emptyArray(!0):MultiArray.emptyArray()};static instantiate=(t,e)=>{const r={};for(const s of t.allProperties())s.isDependent||(r[s.name]=s.defaultValue?e(s.defaultValue):ClassInstance.implicitPropertyDefault(s));return new ClassInstance(t,r)};static throwIfDeleted=t=>{if(t.deleted)throw new Error(`invalid or deleted object for class ${t.classDefinition.name}.`)};static delete=t=>{t.classDefinition.isHandleClass()&&(t.deleted=!0)};static isValid=t=>t.classDefinition.isHandleClass()&&!t.deleted;static getProperty=(t,e)=>(ClassInstance.throwIfDeleted(t),t.properties[e]);static hasProperty=(t,e)=>RuntimeValue.hasOwnField(t.properties,e);static setProperty=(t,e,r)=>{if(ClassInstance.throwIfDeleted(t),!ClassInstance.hasProperty(t,e))throw new Error(`unknown property '${e}' for class ${t.classDefinition.name}.`);t.properties[e]=ClassInstance.runtimePropertyValue(e,r)};static addListener=(t,e,r,s=e,i="event.listener")=>{ClassInstance.throwIfDeleted(t);const n=ClassEventListener.create(t,e,r,s,i);return t.listeners[s]??=[],t.listeners[s].push(n),n};static listenersFor=(t,e)=>(ClassInstance.throwIfDeleted(t),t.listeners[e]?.filter(t=>ClassEventListener.isValid(t)&&t.enabled).slice()??[]);static copy=t=>{if(ClassInstance.throwIfDeleted(t),t.classDefinition.isHandleClass())return t;const e={};for(const[r,s]of Object.entries(t.properties))e[r]=RuntimeValue.copy(s);return new ClassInstance(t.classDefinition,e)};static methodArgument=t=>(ClassInstance.throwIfDeleted(t),t.classDefinition.isHandleClass()?t:ClassInstance.copy(t));static unparse=(t,e)=>{const r=Object.keys(t.properties);return`${t.classDefinition.name} object${r.length>0?` with properties: ${r.join(",")}`:""}`};copy(){return ClassInstance.copy(this)}}const src_ClassInstance=null;class ClassBoundMethod{static CLASS_BOUND_METHOD=8;type=ClassBoundMethod.CLASS_BOUND_METHOD;parent;instance;method;static isInstanceOf=t=>t instanceof ClassBoundMethod;constructor(t,e){this.instance=t,this.method=e}static bind=(t,e)=>new ClassBoundMethod(t,e);static copy=t=>new ClassBoundMethod(t.instance,t.method);static unparse=(t,e)=>`${t.instance.classDefinition.name}.${t.method.name} method`;copy(){return ClassBoundMethod.copy(this)}}const src_ClassBoundMethod=null;class ClassStaticMethod{static CLASS_STATIC_METHOD=9;type=ClassStaticMethod.CLASS_STATIC_METHOD;parent;classDefinition;method;static isInstanceOf=t=>t instanceof ClassStaticMethod;constructor(t,e){this.classDefinition=t,this.method=e}static bind=(t,e)=>new ClassStaticMethod(t,e);static copy=t=>new ClassStaticMethod(t.classDefinition,t.method);static unparse=(t,e)=>`${t.classDefinition.name}.${t.method.name} static method`;copy(){return ClassStaticMethod.copy(this)}}const src_ClassStaticMethod=null;class ClassEmptyMethod{static CLASS_EMPTY_METHOD=14;type=ClassEmptyMethod.CLASS_EMPTY_METHOD;parent;classDefinition;static isInstanceOf=t=>t instanceof ClassEmptyMethod;constructor(t){this.classDefinition=t}static bind=t=>new ClassEmptyMethod(t);static copy=t=>new ClassEmptyMethod(t.classDefinition);static unparse=(t,e)=>`${t.classDefinition.name}.empty static method`;copy(){return ClassEmptyMethod.copy(this)}}const src_ClassEmptyMethod=null;class ClassEnumerationValue{static CLASS_ENUMERATION_VALUE=10;type=ClassEnumerationValue.CLASS_ENUMERATION_VALUE;parent;classDefinition;enumeration;args;static isInstanceOf=t=>t instanceof ClassEnumerationValue;constructor(t,e,r=[]){this.classDefinition=t,this.enumeration=e,this.args=r}static create=(t,e,r=[])=>new ClassEnumerationValue(t,e,r);static copy=t=>new ClassEnumerationValue(t.classDefinition,t.enumeration,t.args.slice());static unparse=(t,e)=>`${t.classDefinition.name}.${t.enumeration.name}`;copy(){return ClassEnumerationValue.copy(this)}}const src_ClassEnumerationValue=null;class ClassEventData{static CLASS_EVENT_DATA=12;type=ClassEventData.CLASS_EVENT_DATA;parent;source;eventName;static isInstanceOf=t=>t instanceof ClassEventData;constructor(t,e){this.source=t,this.eventName=e}static create=(t,e)=>new ClassEventData(t,e);static getProperty=(t,e)=>{switch(e){case"Source":return t.source;case"EventName":return void 0===t.eventName?void 0:CharString.create(t.eventName);default:return}};static unparse=(t,e)=>t.source&&t.eventName?`event.EventData ${t.source.classDefinition.name}.${t.eventName}`:"event.EventData";copy(){return this}}const src_ClassEventData=null;class ClassPropertyEvent extends ClassEventData{static CLASS_PROPERTY_EVENT=13;type=ClassPropertyEvent.CLASS_PROPERTY_EVENT;propertyName;affectedObject;propertySource;static isInstanceOf=t=>t instanceof ClassPropertyEvent;constructor(t,e,r=e,s=t){super(t,r),this.propertyName=e,this.affectedObject=t,this.propertySource=s}static create=(t,e,r=e??"",s)=>new ClassPropertyEvent(t,e??"",r,s??t);static getProperty=(t,e)=>{if(!ClassPropertyEvent.isInstanceOf(t))return ClassEventData.getProperty(t,e);switch(e){case"Source":return t.propertySource;case"AffectedObject":return t.affectedObject;case"PropertyName":return CharString.create(t.propertyName);default:return ClassEventData.getProperty(t,e)}};static unparse=(t,e)=>ClassPropertyEvent.isInstanceOf(t)?`event.PropertyEvent ${t.affectedObject.classDefinition.name}.${t.propertyName}`:ClassEventData.unparse(t,e);copy(){return this}}const src_ClassPropertyEvent=null,stringArray=t=>{const e=MultiArray.toColumnVector(t.map(t=>CharString.create(t)));return e.isCell=!0,e},metaArray=t=>MultiArray.toColumnVector(t),bool=t=>t?Complex.true():Complex.false(),emptyString=()=>CharString.create(""),attributeNames=t=>stringArray(Object.keys(t).sort()),nodeName=t=>AST.isNodeIdentifier(t)?t.id:AST.isNodeIndirectRef(t)?`${nodeName(t.obj)}.${String(t.field[0])}`:void 0,expressionText=t=>{if(AST.isNodeList(t))return t.list.map(t=>expressionText(t)).join(",");if(!AST.isStrictNodeExpr(t))return"";return nodeName(t)||(CharString.isInstanceOf(t)?t.str:Complex.isInstanceOf(t)?t.toString():AST.isNodeIndexExpr(t)?`${expressionText(t.expr)}(${t.args.map(t=>expressionText(t)).join(",")})`:"")},defaultExpressionValue=t=>AST.isRuntimeExpressionValue(t)?t:CharString.create(expressionText(t)),validationStruct=t=>{const e=t.default??t.defaultValue??null;return new Structure({Name:CharString.create(nodeName(t.name)??""),Size:stringArray(t.size.map(t=>expressionText(t))),Class:t.class?CharString.create(expressionText(t.class)):emptyString(),Validators:stringArray(t.functions.map(t=>expressionText(t))),HasDefault:bool(Boolean(e)),DefaultValue:e??MultiArray.emptyArray()})},validationList=t=>{const e=MultiArray.toColumnVector(t.map(t=>validationStruct(t)));return e.isCell=!0,e},functionArgumentValidations=(t,e)=>t.node.arguments.list.flatMap(t=>(t.attribute?.id??null)===e?t.validation:[]),parameterNames=t=>t.flatMap(t=>AST.isNodeIdentifier(t)?[t.id]:AST.isNodeDefaultedParameter(t)?[t.left.id]:[]),returnNames=t=>t.flatMap(t=>AST.isNodeIdentifier(t)?[t.id]:[]);class ClassMetaObject{static CLASS_META=7;type=ClassMetaObject.CLASS_META;parent;static isInstanceOf=t=>t instanceof ClassMetaObject;static copy=t=>t;copy(){return ClassMetaObject.copy(this)}static unparse=(t,e)=>`${t.kind} ${t.displayName()}`}class ClassMetaClass extends ClassMetaObject{definition;propertyDefaultProvider;kind="meta.class";constructor(t,e){super(),this.definition=t,this.propertyDefaultProvider=e}static isInstanceOf=t=>t instanceof ClassMetaClass;static create=(t,e)=>new ClassMetaClass(t,e);displayName(){return this.definition.name}getProperty(t){switch(t){case"Name":return CharString.create(this.definition.name);case"Description":case"DetailedDescription":return emptyString();case"SuperclassList":return metaArray(this.definition.superclassDefinitions.map(t=>ClassMetaClass.create(t,this.propertyDefaultProvider)));case"SuperClasses":return stringArray(this.definition.superclasses);case"PropertyList":return metaArray(this.definition.allProperties().map(t=>ClassMetaProperty.create(t,this.propertyDefaultProvider)));case"MethodList":return metaArray(this.definition.allMethods().map(t=>ClassMetaMethod.create(t,this.propertyDefaultProvider)));case"EventList":return metaArray(this.definition.allEvents().map(t=>ClassMetaEvent.create(t,this.propertyDefaultProvider)));case"EnumerationMemberList":return metaArray(this.definition.allEnumerations().map(t=>ClassMetaEnumerationMember.create(t,this.propertyDefaultProvider)));case"Abstract":return bool(this.definition.isEffectivelyAbstract());case"Sealed":return bool(this.definition.isSealed);case"Hidden":return bool(this.definition.isHidden);case"ConstructOnLoad":return bool(this.definition.isConstructOnLoad);case"HandleCompatible":return bool(this.definition.isHandleCompatibleClass());case"InferiorClasses":return stringArray(this.definition.inferiorClasses);case"AllowedSubclasses":return stringArray(this.definition.allowedSubclasses);case"ContainingPackage":return CharString.create(this.definition.packageName);case"RestrictsSubclassing":return bool(this.definition.isRestrictsSubclassing);case"AttributeNames":return attributeNames(this.definition.attributes);default:return}}}class ClassMetaMember extends ClassMetaObject{member;propertyDefaultProvider;constructor(t,e){super(),this.member=t,this.propertyDefaultProvider=e}displayName(){return`${this.member.classDefinition.name}.${this.member.name}`}commonProperty(t){switch(t){case"Name":return CharString.create(this.member.name);case"DefiningClass":return ClassMetaClass.create(this.member.classDefinition,this.propertyDefaultProvider);case"Hidden":return bool("isHidden"in this.member&&this.member.isHidden);case"Description":case"DetailedDescription":return emptyString();case"AttributeNames":return attributeNames(this.member.attributes);default:return}}}class ClassMetaProperty extends ClassMetaMember{property;defaultProvider;kind="meta.property";static isInstanceOf=t=>t instanceof ClassMetaProperty;constructor(t,e){super(t,e),this.property=t,this.defaultProvider=e}static create=(t,e)=>new ClassMetaProperty(t,e);defaultValue(){return this.property.defaultValue?this.defaultProvider?.(this.property)??defaultExpressionValue(this.property.defaultValue):null}getProperty(t){const e=this.commonProperty(t);if(void 0!==e)return e;switch(t){case"GetAccess":return CharString.create(this.property.getAccess);case"SetAccess":return CharString.create(this.property.setAccess);case"Access":return CharString.create(this.property.access);case"Constant":return bool(this.property.isConstant);case"Dependent":return bool(this.property.isDependent);case"Abstract":return bool(this.property.isAbstract);case"Transient":return bool(this.property.isTransient);case"GetObservable":return bool(this.property.isGetObservable);case"SetObservable":return bool(this.property.isSetObservable);case"AbortSet":return bool(this.property.isAbortSet);case"HasDefault":return bool(Boolean(this.property.defaultValue));case"DefaultValue":return this.defaultValue()??MultiArray.emptyArray();case"Validation":return validationList(this.property.size.length>0||this.property.class||this.property.functions.length>0||this.property.defaultValue?[{name:this.property.node.name,size:this.property.size,class:this.property.class,functions:this.property.functions,defaultValue:this.defaultValue()}]:[]);case"GetMethod":return this.property.getMethodName?CharString.create(this.property.getMethodName):MultiArray.emptyArray();case"SetMethod":return this.property.setMethodName?CharString.create(this.property.setMethodName):MultiArray.emptyArray();case"NonCopyable":return bool(this.property.isNonCopyable);case"PartialMatchPriority":return Complex.create(this.property.partialMatchPriority);default:return}}}class ClassMetaMethod extends ClassMetaMember{method;kind="meta.method";constructor(t,e){super(t,e),this.method=t}static create=(t,e)=>new ClassMetaMethod(t,e);getProperty(t){const e=this.commonProperty(t);if(void 0!==e)return e;switch(t){case"Access":return CharString.create(this.method.access);case"Static":return bool(this.method.isStatic);case"Abstract":return bool(this.method.isAbstract);case"Sealed":return bool(this.method.isSealed);case"InputNames":return stringArray(parameterNames(this.method.node.parameter.list));case"OutputNames":return stringArray(returnNames(this.method.node.return.list));case"InputValidation":return validationList(functionArgumentValidations(this.method,null));case"OutputValidation":return validationList(functionArgumentValidations(this.method,"Output"));case"RepeatingInputValidation":return validationList(functionArgumentValidations(this.method,"Repeating"));default:return}}}class ClassMetaEvent extends ClassMetaMember{event;kind="meta.event";constructor(t,e){super(t,e),this.event=t}static create=(t,e)=>new ClassMetaEvent(t,e);getProperty(t){const e=this.commonProperty(t);if(void 0!==e)return e;switch(t){case"ListenAccess":return CharString.create(this.event.listenAccess);case"NotifyAccess":return CharString.create(this.event.notifyAccess);case"Access":return CharString.create(this.event.access);default:return}}}class ClassMetaEnumerationMember extends ClassMetaMember{enumeration;kind="meta.EnumerationMember";constructor(t,e){super(t,e),this.enumeration=t}static create=(t,e)=>new ClassMetaEnumerationMember(t,e);getProperty(t){const e=this.commonProperty(t);return void 0!==e?e:"ConstructorArguments"===t?0===this.enumeration.args.length?MultiArray.emptyArray():stringArray(this.enumeration.args.map(t=>expressionText(t))):void 0}}const ClassMeta=null,BLASConfigKeyTable=["blockThreshold","blockSize"],BLASConfigKeySet=new Set(BLASConfigKeyTable),BLAS_defaultSettings={blockThreshold:1e5,blockSize:64};class BLAS{static defaultSettings=Object.assign({},BLAS_defaultSettings);static settings=BLAS.defaultSettings;static set=t=>{Object.entries(t).forEach(t=>{if(!BLASConfigKeySet.has(t[0]))throw new Error(`BLAS.set: invalid configuration parameter: ${t[0]}`);BLAS.settings[t[0]]=t[1]})};static axpy=(t,e,r)=>{const s=e.length,i=e[0].length;for(let n=0;n<s;n++){const s=e[n],a=r[n];for(let e=0;e<i;e++)a[e]=Complex.add(a[e],Complex.mul(t,s[e]))}return r};static scal=(t,e,r,s)=>{if(Complex.realToNumber(Complex.eq(t,Complex.zero())))for(let t=r;t<s;t++)e[t]=Complex.zero();else if(!Complex.realToNumber(Complex.eq(t,Complex.one())))for(let i=r;i<s;i++)e[i]=Complex.mul(t,e[i])};static copy=t=>{if(Array.isArray(t))return Array.isArray(t[0])?Array.from({length:t.length},(e,r)=>Array.from({length:t[0].length},(e,s)=>Complex.copy(t[r][s]))):Array.from({length:t.length},(e,r)=>Complex.copy(t[r]));throw new Error("BLAS.copy: invalid argument")};static dotu=(t,e)=>{const r=t.length;let s=Complex.zero();for(let i=0;i<r;i++)Complex.mulAndSumTo(s,t[i],e[i]);return s};static dot=BLAS.dotu;static dotc=(t,e)=>{const r=t.length;let s=Complex.zero();for(let i=0;i<r;i++)Complex.mulAndSumTo(s,Complex.conj(t[i]),e[i]);return s};static nrm2sq=(t,e,r,s)=>{let i=Complex.zero();for(let n=r;n<s;n++)Complex.mulAndSumTo(i,t.array[n][e],Complex.conj(t.array[n][e]));return Complex.create(i.re)};static nrm2=t=>{let e=Complex.zero(),r=Complex.one();for(let s=0;s<t.length;s++){const i=t[s],n=Complex.abs(Complex.real(i)),a=Complex.abs(Complex.imag(i));if(Complex.toBoolean(Complex.ne(n,Complex.zero())))if(Complex.lt(e,n)){const t=Complex.rdiv(e,n);r=Complex.add(Complex.one(),Complex.mul(r,Complex.mul(t,t))),e=n}else{const t=Complex.rdiv(n,e);r=Complex.add(r,Complex.mul(t,t))}if(Complex.toBoolean(Complex.ne(a,Complex.zero())))if(Complex.lt(e,a)){const t=Complex.rdiv(e,a);r=Complex.add(Complex.one(),Complex.mul(r,Complex.mul(t,t))),e=a}else{const t=Complex.rdiv(a,e);r=Complex.add(r,Complex.mul(t,t))}}return Complex.toBoolean(Complex.eq(e,Complex.zero()))?Complex.zero():Complex.mul(e,Complex.sqrt(r))};static gemv=(t,e,r,s,i,n,a,o,l,c,u,h="N")=>{const d="N"===h?e:r,m="N"===h?r:e;for(let t=0;t<d;t++)o[l+t]=Complex.eq(u,Complex.zero())?Complex.zero():Complex.eq(u,Complex.one())?o[l+t]:Complex.mul(u,o[l+t]);for(let e=0;e<d;e++){let r=Complex.zero();for(let o=0;o<m;o++){const l="N"===h?t[s+e][i+o]:"T"===h?t[s+o][i+e]:Complex.conj(t[s+o][i+e]);Complex.mulAndSumTo(r,l,n[a+o])}Complex.mulAndSumTo(o[l+e],c,r)}};static trsv=(t,e,r)=>{const s=t.length;if(t.some(t=>t.length!==s))throw new Error("BLAS.trsv: A must be square.");if(e.length!==s)throw new Error("BLAS.trsv: x has incompatible dimension.");const i=Array.from({length:s},(t,r)=>[e[r]]);return BLAS.trsm(t,i,{side:"left",uplo:r.uplo,transA:r.transA,unitDiagonal:r.unitDiagonal}).map(t=>t[0])};static ger=(t,e,r,s,i,n,a,o,l,c,u,h)=>{if(!Complex.realIsZero(Complex.abs(n)))for(let d=0;d<s;d++){const s=a[o+d][l],m=Complex.mul(n,s),p=t[e+d];for(let t=0;t<i;t++)Complex.mulAndSumTo(p[r+t],m,Complex.conj(c[u+t][h]))}};static geru=(t,e,r,s,i,n)=>{if(!Complex.realIsZero(Complex.abs(r)))for(let a=0;a<t.length;a++){const o=t[a],l=s[i+a];for(let t=0;t<e.length;t++)Complex.mulAndSumTo(l[n+t],r,Complex.mul(o,e[t]))}};static gerc=(t,e,r,s,i=0,n=0)=>{for(let a=0;a<t.length;a++){const o=t[a],l=s[i+a];for(let t=0;t<e.length;t++)l[n+t]=Complex.add(l[n+t],Complex.mul(r,Complex.mul(o,Complex.conj(e[t]))))}};static gerc_nd=(t,e,r)=>{const s=[];for(let e=0;e<MultiArray.linearLength(t);e++){const[r,i]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],e);s.push(t.array[r][i])}const i=[];for(let t=0;t<MultiArray.linearLength(e);t++){const[r,s]=MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],t);i.push(e.array[r][s])}const n=s.length,a=i.length;if(r.dimension[0]!==n||r.dimension[1]!==a)throw new Error(`BLAS.gerc_nd: dimension mismatch (C is ${r.dimension[0]}x${r.dimension[1]}, x is ${n}, y is ${a})`);for(let t=0;t<n;t++){const e=Complex.conj(s[t]);for(let s=0;s<a;s++){const n=Complex.mul(e,i[s]);r.array[t][s]?r.array[t][s]=Complex.add(r.array[t][s],n):r.array[t][s]=Complex.copy(n)}}MultiArray.setType(r)};static gerc_nd_direct=(t,e,r)=>{const s=MultiArray.linearLength(t),i=MultiArray.linearLength(e);if(r.dimension[0]!==s||r.dimension[1]!==i)throw new Error(`BLAS.gerc_nd_direct: dimension mismatch (C is ${r.dimension[0]}x${r.dimension[1]}, x is ${s}, y is ${i})`);t.dimension[0],t.dimension[1],e.dimension[0],e.dimension[1],r.dimension[0],r.dimension[1];for(let n=0;n<s;n++){const[a,o]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1]||1,n),l=Complex.conj(t.array[a][o]);for(let t=0;t<i;t++){const[i,a]=MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1]||1,t),o=e.array[i][a],[c,u]=MultiArray.linearIndexToMultiArrayRowColumn(r.dimension[0],r.dimension[1],n+t*s);r.array[c][u]?r.array[c][u]=Complex.add(r.array[c][u],Complex.mul(l,o)):r.array[c][u]=Complex.mul(l,o)}}MultiArray.setType(r)};static gemm_kernel=(t,e,r,s,i,n,a,o,l)=>{for(let c=s;c<i;c++){const s=t[c],i=r[c];for(let t=n;t<a;t++){let r=i[t]??Complex.zero();for(let i=o;i<l;i++)Complex.mulAndSumTo(r,s[i],e[i][t]);i[t]=r}}};static gemm=(t,e,r,s,i,n,a,o,l)=>{if(Complex.realIsZero(Complex.abs(t)))for(let t=0;t<r;t++){const e=o[t];for(let t=0;t<n;t++)e[t]=Complex.mul(a,e[t])}else{if(!Complex.eq(a,Complex.one()))for(let t=0;t<r;t++){const e=o[t];for(let t=0;t<n;t++)e[t]=Complex.mul(a,e[t])}if(r*s*n>BLAS.settings.blockThreshold)for(let t=0;t<r;t+=l??BLAS.settings.blockSize){const a=Math.min(t+(l??BLAS.settings.blockSize),r);for(let r=0;r<s;r+=l??BLAS.settings.blockSize){const c=Math.min(r+(l??BLAS.settings.blockSize),s);for(let s=0;s<n;s+=l??BLAS.settings.blockSize){const u=Math.min(s+(l??BLAS.settings.blockSize),n);BLAS.gemm_kernel(e,i,o,t,a,s,u,r,c)}}}else for(let a=0;a<r;a++){const r=e[a],l=o[a];for(let e=0;e<n;e++){let n=Complex.zero();for(let t=0;t<s;t++)Complex.mulAndSumTo(n,r[t],i[t][e]);l[e]=Complex.add(l[e],Complex.mul(t,n))}}}};static gemm_block=(t,e,r,s,i,n)=>{const a=t.length,o=t[0]?.length??0,l=e.length,c=e[0]?.length??0;if(o!==l)throw new Error("BLAS.gemm_block: inner dimensions mismatch A.cols != B.rows");if(r.length!==a||r[0]?.length!==c)throw new Error("BLAS.gemm_block: output dimension mismatch with C");if(Complex.realIsZero(Complex.abs(s))){if(Complex.realIsZero(Complex.abs(i)))for(let t=0;t<a;t++)for(let e=0;e<c;e++)r[t][e]=Complex.zero();else if(Complex.toBoolean(Complex.ne(i,Complex.one())))for(let t=0;t<a;t++)for(let e=0;e<c;e++)r[t][e]=Complex.mul(i,r[t][e]);return}const u=Math.max(1,Math.floor(n??BLAS.settings.blockSize));for(let n=0;n<a;n+=u){const l=Math.min(n+u,a);for(let a=0;a<c;a+=u){const h=Math.min(a+u,c);for(let t=n;t<l;t++)for(let e=a;e<h;e++)Complex.realIsZero(Complex.abs(i))?r[t][e]=Complex.zero():Complex.toBoolean(Complex.ne(i,Complex.one()))&&(r[t][e]=Complex.mul(i,r[t][e]));for(let i=0;i<o;i+=u){const c=Math.min(i+u,o);for(let o=n;o<l;o++){const n=t[o],l=r[o];for(let t=i;t<c;t++){const r=n[t];if(!Complex.realIsZero(Complex.abs(r)))for(let i=a;i<h;i++){const n=Complex.mul(r,e[t][i]),a=Complex.mul(s,n);l[i]=Complex.add(l[i],a)}}}}}}};static trsm=(t,e,r)=>{const s=r?.side??"left",i=r?.uplo??"upper",n=r?.transA??"N",a=r?.unitDiagonal??!1,o=e.length,l=e[0]?.length??0;if(t.length!==t[0]?.length)throw new Error("BLAS.trsm: A must be square.");if("left"===s&&t.length!==o||"right"===s&&t.length!==l)throw new Error("BLAS.trsm: nonconformant dimensions.");const c=e.map(t=>t.map(t=>t)),u=(e,r)=>"N"===n?t[e][r]:"T"===n?t[r][e]:Complex.conj(t[r][e]);if("left"===s)if("upper"===i&&"N"===n||"lower"===i&&"N"!==n)for(let t=0;t<l;t++)for(let e=o-1;e>=0;e--){let r=c[e][t];for(let s=e+1;s<o;s++)r=Complex.sub(r,Complex.mul(u(e,s),c[s][t]));a||(r=Complex.rdiv(r,u(e,e))),c[e][t]=r}else for(let t=0;t<l;t++)for(let e=0;e<o;e++){let r=c[e][t];for(let s=0;s<e;s++)r=Complex.sub(r,Complex.mul(u(e,s),c[s][t]));a||(r=Complex.rdiv(r,u(e,e))),c[e][t]=r}else if("upper"===i&&"N"===n||"lower"===i&&"N"!==n)for(let t=0;t<o;t++)for(let e=0;e<l;e++){let r=c[t][e];for(let s=0;s<e;s++)r=Complex.sub(r,Complex.mul(c[t][s],u(s,e)));a||(r=Complex.rdiv(r,u(e,e))),c[t][e]=r}else for(let t=0;t<o;t++)for(let e=l-1;e>=0;e--){let r=c[t][e];for(let s=e+1;s<l;s++)r=Complex.sub(r,Complex.mul(c[t][s],u(s,e)));a||(r=Complex.rdiv(r,u(e,e))),c[t][e]=r}return c};static functions={axpy:BLAS.axpy,scal:BLAS.scal,copy:BLAS.copy,dotu:BLAS.dotu,dotc:BLAS.dotc,nrm2sq:BLAS.nrm2sq,nrm2:BLAS.nrm2,gemv:BLAS.gemv,trsv:BLAS.trsv,ger:BLAS.ger,geru:BLAS.geru,gerc:BLAS.gerc,gerc_nd:BLAS.gerc_nd,gerc_nd_direct:BLAS.gerc_nd_direct,gemm_kernel:BLAS.gemm_kernel,gemm:BLAS.gemm,gemm_block:BLAS.gemm_block,trsm:BLAS.trsm}}const src_BLAS=null,EXPECT_TOL=1e-14,LAPACKConfigKeyTable=["maxIterationFactor"],LAPACKConfigKeySet=new Set(LAPACKConfigKeyTable),LAPACK_defaultSettings={maxIterationFactor:1e3};class LAPACK{static defaultSettings=Object.assign({},LAPACK_defaultSettings);static settings=LAPACK.defaultSettings;static mtimes=(t,e)=>{const r=t.dimension[0],s=t.dimension[1],i=e.dimension[1];if(s!==e.dimension[0])throw new Error(`LAPACK.mtimes: nonconformant arguments (op1 is ${t.dimension.join("x")}, op2 is ${e.dimension.join("x")}).`);const n=new MultiArray([r,i]);return BLAS.gemm(Complex.one(),t.array,r,s,e.array,i,Complex.zero(),n.array),MultiArray.setType(n),n};static set=t=>{Object.entries(t).forEach(t=>{if(!LAPACKConfigKeySet.has(t[0]))throw new Error(`LAPACK.set: invalid configuration parameter: ${t[0]}`);LAPACK.settings[t[0]]=t[1]})};static is_hermitian=t=>{const e=t.length;if(0===e)return!0;if(t[0].length!==e)return!1;const r=EXPECT_TOL;for(let s=0;s<e;s++){const i=t[s][s];if(Math.abs(toNumber(i.im))>r)return!1;for(let i=s+1;i<e;i++){const e=t[s][i],n=t[i][s],a=toNumber(e.re)-toNumber(n.re),o=toNumber(e.im)+toNumber(n.im);if(Math.hypot(a,o)>r)return!1}}return!0};static is_positive_definite=t=>{const e=t.length;if(0===e)return!0;if(t[0].length!==e)return!1;if(!LAPACK.is_hermitian(t))return!1;const r=EXPECT_TOL,s=Array.from({length:e},(r,s)=>Array.from({length:e},(e,r)=>Complex.copy(t[s][r])));for(let t=0;t<e;t++){let i=s[t][t];for(let e=0;e<t;e++){const r=s[t][e];i=Complex.sub(i,Complex.mul(r,Complex.conj(r)))}if(Math.abs(toNumber(i.im))>r)return!1;if(toNumber(i.re)<=r)return!1;const n=Complex.create(Math.sqrt(toNumber(i.re)),0);s[t][t]=n;for(let r=t+1;r<e;r++){let e=s[r][t];for(let i=0;i<t;i++)e=Complex.sub(e,Complex.mul(s[r][i],Complex.conj(s[t][i])));s[r][t]=Complex.rdiv(e,n)}}return!0};static laswp=(t,e,r,s,i,n,a,o)=>{const l=e[0],c=e[1],u=2===e.length?1:e.slice(2).reduce((t,e)=>t*e,1),h=void 0===a?0:a,d=void 0===o?c-1:o;if(!i||0===i.length)return;const m=0===Math.min(...i);if(n>0)for(let e=r;e<=s;e+=n){const r=e-1,s=i[e-1],n=m?s:s-1;if(n!==r)for(let e=0;e<u;e++){const s=e*l+r,i=e*l+n;for(let e=h;e<=d;e++){const r=t[s][e];t[s][e]=t[i][e],t[i][e]=r}}}else for(let e=r;e>=s;e+=n){const r=e-1,s=i[e-1],n=m?s:s-1;if(n!==r)for(let e=0;e<u;e++){const s=e*l+r,i=e*l+n;for(let e=h;e<=d;e++){const r=t[s][e];t[s][e]=t[i][e],t[i][e]=r}}}};static laswp_rows=(t,e,r,s)=>{const i=r+1,n=i,a=[];a[i-1]=s+1,LAPACK.laswp(t,e,i,n,a,1)};static laswp_cols=(t,e,r,s)=>{const i=e[0]*(2===e.length?1:e.slice(2).reduce((t,e)=>t*e,1));for(let e=0;e<i;e++){const i=t[e][r];t[e][r]=t[e][s],t[e][s]=i}};static eye=(...t)=>{const e=t.flat(),r=e[0],s=e[1];if(2===e.length)return Array.from({length:r},(t,e)=>Array.from({length:s},(t,r)=>e===r?Complex.one():Complex.zero()));{const t=e.slice(2).reduce((t,e)=>t*e,1);return Array.from({length:r*t},(t,e)=>{const i=e%r;return Array.from({length:s},(t,e)=>i===e?Complex.one():Complex.zero())})}};static fillFactory=t=>(...e)=>{const r=e.flat();return Array.from({length:r[0]*r.slice(2).reduce((t,e)=>t*e,1)},()=>Array.from({length:r[1]},t))};static zeros=LAPACK.fillFactory(()=>Complex.zero());static ones=LAPACK.fillFactory(()=>Complex.one());static diag=(t,e=0,...r)=>{const s=r.length>0?r.flat():[t.length,t.length],i=s[0],n=s[1];if(2===s.length)return Array.from({length:i},(r,s)=>Array.from({length:n},(r,i)=>s+e===i?t[s]:Complex.zero()));{const r=s.slice(2).reduce((t,e)=>t*e,1);return Array.from({length:i*r},(r,s)=>{const a=s%i;return Array.from({length:n},(r,s)=>a+e===s?t[a]:Complex.zero())})}};static from_diag=(t,e=0)=>{const r=[];for(let s=0;s<t.length-Math.abs(e);s++)r[s]=e>0?t[s][s+e]:t[s-e][s];return r};static lassq=t=>{const e=t.dimension[0],r=t.dimension[1];let s=Complex.zero(),i=Complex.one();for(let n=0;n<e;n++)for(let e=0;e<r;e++){const r=t.array[n][e];if(!Complex.realIsZero(r)){const t=Complex.abs(r);if(Complex.lt(s,t)){if(!Complex.realIsZero(s)){const e=Complex.rdiv(s,t);Complex.mulAndSumTo(i,i,Complex.mul(e,e))}s=t}else{const e=Complex.rdiv(t,s);Complex.mulAndSumTo(i,e,e)}}}return{scale:s,sumsq:i}};static lange=(t,e)=>{const r=e.dimension[0],s=e.dimension[1];switch(t){case"F":{const{scale:t,sumsq:r}=LAPACK.lassq(e);return Complex.realIsZero(t)?Complex.zero():Complex.mul(t,Complex.sqrt(r))}case"M":{let t=Complex.zero();for(let i=0;i<r;i++)for(let r=0;r<s;r++){const s=Complex.abs(e.array[i][r]);Complex.lt(t,s)&&(t=s)}return t}default:throw new Error(`lange: norm '${t}' not implemented`)}};static triu_inplace=t=>{const e=t.dimension.length>2?t.dimension.slice(2).reduce((t,e)=>t*e,1):1,r=t.dimension[0];for(let s=0;s<e;s++){const e=s*r;for(let r=0;r<t.dimension[0];r++){const s=t.array[e+r];for(let e=0;e<Math.min(r,t.dimension[1]);e++)s[e]=Complex.zero()}}MultiArray.setType(t)};static tril_inplace=t=>{const e=t.dimension.length>2?t.dimension.slice(2).reduce((t,e)=>t*e,1):1,r=t.dimension[0];for(let s=0;s<e;s++){const e=s*r;for(let r=0;r<t.dimension[0];r++){const s=t.array[e+r];for(let e=r+1;e<t.dimension[1];e++)s[e]=Complex.zero()}}MultiArray.setType(t)};static trsm_left_upper_block=(t,e,r)=>{const s=t[0].length;for(let i=e+r;i<s;i++)for(let s=r-1;s>=0;s--){const n=e+s;let a=t[n][i];for(let o=s+1;o<r;o++){const r=t[n][e+o],s=t[e+o][i];a=Complex.sub(a,Complex.mul(r,s))}const o=t[n][e+s];t[n][i]=Complex.rdiv(a,o)}};static lapmt_matrix=t=>{const e=t.length,r=new MultiArray([e,e]);for(let s=0;s<e;s++){const e=t[s];r.array[e][s]=Complex.one()}return MultiArray.setType(r),r};static lapmt_apply=(t,e)=>{const r=t.dimension[0],s=t.dimension[1];if(e.length!==s)throw new EvalError(`lapmt_apply: jpvt length (${e.length}) must match number of columns (${s}).`);const i=new Array(r);for(let e=0;e<r;e++)i[e]=t.array[e].slice();for(let n=0;n<s;n++){const s=e[n];for(let e=0;e<r;e++)t.array[e][n]=i[e][s]}MultiArray.setType(t)};static dotc_col=(t,e,r)=>{const s=t.dimension[0];if(r+1>=s)return Complex.zero();{const i=t.array.slice(r+1,s).map(t=>t[e]);return BLAS.dotc(i,i)}};static dotc_row=(t,e,r)=>{const s=t.dimension[1];if(r+1>=s)return Complex.zero();{const i=t.array[e].slice(r+1,s);return BLAS.dotc(i,i)}};static larfg=(t,e,r,s)=>{const i=r-s,n=new Array(i);if(n[0]=e.array[s][s],"L"===t)for(let t=1;t<i;t++)n[t]=e.array[s+t][s];else for(let t=1;t<i;t++)n[t]=e.array[s][s+t];const a=n[0],o=Complex.abs(a),l=Complex.realIsZero(o)?Complex.one():Complex.rdiv(a,o);let c=Complex.zero();for(let t=1;t<i;t++)c=Complex.add(c,Complex.mul(n[t],Complex.conj(n[t])));if(1===i||Complex.realIsZero(Complex.abs(c))){const t=Complex.zero(),e=new Array(i).fill(Complex.zero());return e[0]=Complex.one(),{tau:t,v:e,phi:l,alpha:a}}const u=Complex.sqrt(Complex.add(Complex.mul(a,Complex.conj(a)),c)),h=Complex.mul(Complex.neg(l),u),d=Complex.rdiv(Complex.sub(h,a),h),m=Complex.sub(a,h),p=new Array(i);p[0]=Complex.one();for(let t=1;t<i;t++)p[t]=Complex.rdiv(n[t],m);return{tau:d,v:p,phi:l,alpha:h}};static larfg_novo=(t,e,r,s)=>{const i=r-s,n=new Array(i);if(n[0]=e.array[s][s],"L"===t)for(let t=1;t<i;t++)n[t]=e.array[s+t][s];else for(let t=1;t<i;t++)n[t]=e.array[s][s+t];const a=n[0],o=Complex.abs(a),l=Complex.realIsZero(o)?Complex.one():Complex.rdiv(a,o);let c=Complex.zero();for(let t=1;t<i;t++)c=Complex.add(c,Complex.mul(n[t],Complex.conj(n[t])));if(1===i||Complex.realIsZero(Complex.abs(c))){const t=Complex.zero(),e=new Array(i).fill(Complex.zero());return e[0]=Complex.one(),{tau:t,v:e,phi:l,alpha:a}}const u=Complex.sqrt(Complex.add(Complex.mul(a,Complex.conj(a)),c)),h=Complex.mul(Complex.neg(l),u),d=Complex.rdiv(Complex.sub(h,a),h),m=Complex.sub(a,h),p=new Array(i);p[0]=Complex.one();for(let t=1;t<i;t++)p[t]=Complex.rdiv(n[t],m);return{tau:d,v:p,phi:l,alpha:h}};static larf_left=(t,e,r,s,i)=>{if(Complex.realIsZero(Complex.abs(r)))return;const n=e.length;for(let a=i;a<t.dimension[1];a++){let i=Complex.zero();for(let r=0;r<n;r++)Complex.mulAndSumTo(i,Complex.conj(e[r]),t.array[s+r][a]);if(i=Complex.mul(r,i),!Complex.realIsZero(Complex.abs(i)))for(let r=0;r<n;r++)t.array[s+r][a]=Complex.sub(t.array[s+r][a],Complex.mul(e[r],i))}};static larf=(t,e,r,s,i,n)=>{if(Complex.realIsZero(Complex.abs(s)))return;const a=e.dimension[0],o=e.dimension[1],l=r.length;if("L"===t){const t=new Array(o-n).fill(Complex.zero());for(let s=0;s<o-n;s++){let a=Complex.zero();for(let t=0;t<l;t++){const o=e.array[i+t][n+s];Complex.mulAndSumTo(a,Complex.conj(r[t]),o)}t[s]=a}for(let a=0;a<l;a++){const l=r[a],c=e.array[i+a];for(let e=0;e<o-n;e++)c[n+e]=Complex.sub(c[n+e],Complex.mul(s,Complex.mul(l,t[e])))}}else{const t=a-i,o=r.length,l=new Array(t);for(let s=0;s<t;s++){let t=Complex.zero();const a=e.array[i+s];for(let e=0;e<o;e++)Complex.mulAndSumTo(t,a[n+e],Complex.conj(r[e]));l[s]=t}for(let a=0;a<t;a++){const t=l[a];if(Complex.realIsZero(Complex.abs(t)))continue;const c=e.array[i+a];for(let e=0;e<o;e++)c[n+e]=Complex.sub(c[n+e],Complex.mul(s,Complex.mul(t,r[e])))}}};static larf_right_adjoint=(t,e,r,s,i)=>{if(Complex.realIsZero(Complex.abs(r)))return;const n=t.dimension[0],a=e.length,o=new Array(n-s).fill(Complex.zero());for(let r=s;r<n;r++){let n=Complex.zero();for(let s=0;s<a;s++)n=Complex.add(n,Complex.mul(t.array[r][i+s],e[s]));o[r-s]=n}const l=Complex.conj(r);for(let r=s;r<n;r++)for(let n=0;n<a;n++){const a=Complex.mul(l,Complex.mul(o[r-s],Complex.conj(e[n])));t.array[r][i+n]=Complex.sub(t.array[r][i+n],a)}};static larf_left_block=(t,e,r,s,i,n)=>{if(Complex.realIsZero(Complex.abs(r)))return;const a=t.dimension[0],o=t.dimension[1],l=e.length;if(s<0||s>=a)throw new Error("larf_left_block: invalid rowStart");if(i<0||i>=o)throw new Error("larf_left_block: invalid colStart");if(l!==a-s)throw new Error("larf_left_block: v length must equal m - rowStart");const c=Math.max(1,Math.floor(n??BLAS.settings.blockSize)),u=new MultiArray([l,1]);for(let t=0;t<l;t++)u.array[t][0]=e[t];const h=new MultiArray([1,l]);for(let t=0;t<l;t++)h.array[0][t]=Complex.conj(e[t]);for(let e=i;e<o;e+=c){const i=Math.min(e+c,o)-e,n=new MultiArray([l,i]);for(let r=0;r<l;r++)for(let a=0;a<i;a++)n.array[r][a]=t.array[s+r][e+a];const a=new MultiArray([1,i]);BLAS.gemm_block(h.array,n.array,a.array,Complex.one(),Complex.zero(),c);for(let t=0;t<i;t++)a.array[0][t]=Complex.mul(r,a.array[0][t]);for(let t=0;t<l;t++){const e=u.array[t][0];if(!Complex.realIsZero(Complex.abs(e)))for(let r=0;r<i;r++){const s=Complex.mul(e,a.array[0][r]);n.array[t][r]=Complex.sub(n.array[t][r],s)}}for(let r=0;r<l;r++)for(let a=0;a<i;a++)t.array[s+r][e+a]=n.array[r][a]}};static geqr2=t=>{const e=MultiArray.copy(t),r=e.dimension[0],s=e.dimension[1],i=Math.min(r,s),n=new Array(i),a=new Array(i);for(let t=0;t<i;t++){const{tau:i,v:o,phi:l,alpha:c}=LAPACK.larfg("L",e,r,t);e.array[t][t]=c;for(let r=1;r<o.length;r++)e.array[t+r][t]=Complex.mul(i,o[r]);t+1<s&&LAPACK.larf("L",e,o,i,t,t+1),n[t]=i,a[t]=l}return MultiArray.setType(e),{R:e,taus:n,phis:a}};static geqp2=t=>{const e=t.dimension[0],r=t.dimension[1],s=new Array(Math.min(e,r)),i=new Array(Math.min(e,r)),n=new Array(r);for(let t=0;t<r;t++)n[t]=t;const a=new Array(r),o=new Array(r);for(let e=0;e<r;e++){const r=BLAS.nrm2(t.array.map(t=>t[e]));a[e]=r,o[e]=r}const l=Math.min(e,r);for(let c=0;c<l;c++){let l=c,u=a[c];for(let t=c+1;t<r;t++)Complex.toBoolean(Complex.gt(a[t],u))&&(u=a[t],l=t);if(l!==c){for(let r=0;r<e;r++){const e=t.array[r][c];t.array[r][c]=t.array[r][l],t.array[r][l]=e}const r=a[c];a[c]=a[l],a[l]=r;const s=o[c];o[c]=o[l],o[l]=s;const i=n[c];n[c]=n[l],n[l]=i}const{tau:h,v:d,alpha:m,phi:p}=LAPACK.larfg("L",t,e,c);s[c]=h,i[c]=p,t.array[c][c]=m;for(let e=1;e<d.length;e++)t.array[c+e][c]=Complex.mul(h,d[e]);c+1<r&&LAPACK.larf("L",t,d,h,c,c+1);for(let s=c+1;s<r;s++){if(Complex.toBoolean(Complex.eq(a[s],Complex.zero())))continue;const r=Complex.abs(t.array[c][s]),i=Complex.rdiv(r,a[s]),n=Complex.sub(Complex.one(),Complex.mul(i,i)),l=Complex.toBoolean(Complex.gt(n,Complex.zero()))?n:Complex.zero();if(a[s]=Complex.mul(a[s],Complex.sqrt(l)),Complex.toBoolean(Complex.le(a[s],Complex.mul(Complex.onediv2(),o[s])))){const r=BLAS.nrm2(t.array.slice(c+1,e).map(t=>t[s]));a[s]=r,o[s]=r}}}return MultiArray.setType(t),{R:t,taus:s,phis:i,jpvt:n}};static geqp3=t=>{const e=MultiArray.copy(t),r=e.dimension[0],s=e.dimension[1],i=Math.min(r,s),n=new Array(i),a=new Array(i),o=new Array(s);for(let t=0;t<s;t++)o[t]=t;const l=new Array(s),c=new Array(s);for(let t=0;t<s;t++){let s=Complex.zero();for(let i=0;i<r;i++){const r=e.array[i][t],n=Complex.abs(r);Complex.mulAndSumTo(s,n,n)}const i=Complex.sqrt(s);l[t]=i,c[t]=i}for(let t=0;t<i;t++){let i=t,u=l[t];for(let e=t+1;e<s;e++)Complex.toBoolean(Complex.gt(l[e],u))&&(u=l[e],i=e);if(i!==t){for(let s=0;s<r;s++){const r=e.array[s][t];e.array[s][t]=e.array[s][i],e.array[s][i]=r}const s=o[t];o[t]=o[i],o[i]=s;const n=l[t];l[t]=l[i],l[i]=n;const a=c[t];c[t]=c[i],c[i]=a}const{tau:h,v:d,phi:m,alpha:p}=LAPACK.larfg("L",e,r,t);if(e.array[t][t]=p,Complex.realIsZero(Complex.abs(h)))for(let r=1;r<d.length;r++)e.array[t+r][t]=Complex.zero();else for(let r=1;r<d.length;r++)e.array[t+r][t]=Complex.mul(h,d[r]);t+1<s&&!Complex.realIsZero(Complex.abs(h))&&LAPACK.larf("L",e,d,h,t,t+1),n[t]=h,a[t]=m;for(let s=t;s>=0;s--){const t=r-s,i=new Array(t);i[0]=Complex.one();const a=n[s];if(Complex.realIsZero(Complex.abs(a)))for(let e=1;e<t;e++)i[e]=Complex.zero();else for(let r=1;r<t;r++)i[r]=Complex.rdiv(e.array[s+r][s],a)}for(let i=t+1;i<s;i++)if(Complex.toBoolean(Complex.ne(l[i],Complex.zero()))){const s=e.array[t][i],n=Complex.abs(s),a=Complex.sub(Complex.one(),Complex.rdiv(Complex.mul(n,n),Complex.mul(l[i],l[i]))),o=Complex.toBoolean(Complex.gt(a,Complex.zero()))?Complex.sqrt(a):Complex.zero(),u=Complex.mul(l[i],o),h=Complex.onediv2();if(Complex.toBoolean(Complex.le(u,Complex.mul(h,c[i])))){let s=Complex.zero();for(let n=t+1;n<r;n++){const t=e.array[n][i],r=Complex.abs(t);Complex.mulAndSumTo(s,r,r)}const n=Complex.sqrt(s);l[i]=n,c[i]=n}else l[i]=u}}return MultiArray.setType(e),{R:e,taus:n,phis:a,jpvt:o}};static gelq2=t=>{const e=t.dimension[0],r=t.dimension[1],s=Math.min(e,r),i=new Array(s),n=new Array(s);for(let a=0;a<s;a++){const{tau:s,v:o,alpha:l,phi:c}=LAPACK.larfg("R",t,r,a);i[a]=s,n[a]=c,t.array[a][a]=l;for(let e=1;e<o.length;e++)t.array[a][a+e]=o[e];a+1<e&&!Complex.realIsZero(Complex.abs(s))&&LAPACK.larf("R",t,o,s,a+1,a)}return MultiArray.setType(t),{L:t,taus:i,phis:n}};static orgqr=(t,e)=>{const r=t.dimension[0],s=t.dimension[1],i=Math.min(r,s),n=new MultiArray([r,r]);n.array=LAPACK.eye(r,r);for(let s=i-1;s>=0;s--){const i=r-s,a=[Complex.one()],o=e[s];if(Complex.realIsZero(Complex.abs(o)))for(let t=1;t<i;t++)a[t]=Complex.zero();else for(let e=1;e<i;e++)a[e]=Complex.rdiv(t.array[s+e][s],o);LAPACK.larf("L",n,a,o,s,0)}return MultiArray.setType(n),n};static orglq=(t,e)=>{const r=t.dimension[1],s=e.length,i=new MultiArray([r,r]);i.array=LAPACK.eye(r,r);for(let n=s-1;n>=0;n--){const s=e[n];if(Complex.realIsZero(Complex.abs(s)))continue;const a=r-n,o=new Array(a);o[0]=Complex.one();for(let e=1;e<a;e++)o[e]=t.array[n][n+e];LAPACK.larf("R",i,o,s,0,n)}return MultiArray.setType(i),i};static getf2=(t,e,r,s,i,n)=>{const a=[t.length,t[0].length],[o,l]=a,c=Math.min(e+r,Math.min(o,l));for(let r=e;r<c;r++){let e=r,c=Complex.abs(t[r][r]);for(let s=r+1;s<o;s++){const i=Complex.abs(t[s][r]);Complex.toBoolean(Complex.gt(i,c))&&(c=i,e=s)}s[r]=e,e!==r&&(LAPACK.laswp_rows(t,a,r,e),void 0!==i&&i.swaps++);const u=t[r][r];if(Complex.toBoolean(Complex.eq(Complex.abs(u),Complex.zero())))void 0!==n&&0===n.info&&(n.info=r+1);else{for(let e=r+1;e<o;e++)t[e][r]=Complex.rdiv(t[e][r],u);for(let e=r+1;e<o;e++){const s=t[e][r];if(Complex.toBoolean(Complex.eq(Complex.abs(s),Complex.zero())))continue;const i=t[e],n=t[r];for(let t=r+1;t<l;t++)i[t]=Complex.sub(i[t],Complex.mul(s,n[t]))}}}};static getrf=(t,e)=>{const r=t.length,s=t[0].length,i=Math.min(r,s),n=new Array(i);for(let t=0;t<i;t++)n[t]=t;const a={swaps:0},o={info:0};for(let l=0;l<i;l+=e??BLAS.settings.blockSize){const c=Math.min(e??BLAS.settings.blockSize,i-l);LAPACK.getf2(t,l,c,n,a,o);for(let e=l;e<l+c&&e<i;e++){const r=n[e];if(r!==e&&a.swaps++,r!==e&&l>0)for(let s=0;s<l;s++){const i=t[e][s];t[e][s]=t[r][s],t[r][s]=i}}const u=c,h=r-(l+u),d=s-(l+u);if(l+u<s){const e=t,r=[];for(let t=0;t<h;t++){const s=l+u+t,i=new Array(u);for(let t=0;t<u;t++)i[t]=e[s][l+t];r.push(i)}const s=[];for(let t=0;t<u;t++){const r=l+t,i=new Array(d);for(let t=0;t<d;t++)i[t]=e[r][l+u+t];s.push(i)}const i=[];for(let t=0;t<h;t++){const r=l+u+t,s=new Array(d);for(let t=0;t<d;t++)s[t]=e[r][l+u+t];i.push(s)}BLAS.gemm(Complex.neg(Complex.one()),r,h,u,s,d,Complex.one(),i);for(let t=0;t<h;t++){const r=l+u+t;for(let s=0;s<d;s++)e[r][l+u+s]=i[t][s]}for(let t=0;t<u;t++){const r=l+t;for(let i=0;i<d;i++)e[r][l+u+i]=s[t][i]}for(let t=0;t<h;t++){const s=l+u+t;for(let i=0;i<u;i++)e[s][l+i]=r[t][i]}}}return{LU:t,piv:n,swaps:a.swaps,info:o.info}};static getrf_blocked=(t,e)=>{const r=t.length,s=t[0].length,i=Math.min(r,s),n=new Array(i);for(let t=0;t<i;t++)n[t]=t;const a={swaps:0},o={info:0};for(let l=0;l<i;l+=e??BLAS.settings.blockSize){const c=Math.min(e??BLAS.settings.blockSize,i-l);LAPACK.getf2(t,l,c,n,a,o),l+c<s&&LAPACK.trsm_left_upper_block(t,l,c),l+c<r&&l+c<s&&LAPACK.gemm_blocked(t,l,c)}return{LU:t,piv:n,info:o.info,swaps:a.swaps}};static gemm_blocked=(t,e,r,s=64)=>{const i=e+r,n=e+r,a=t.length-(e+r),o=t[0].length-(e+r);if(a<=0||o<=0)return;const l=r,c=s;for(let r=0;r<a;r+=c){const s=Math.min(r+c,a);for(let a=0;a<o;a+=c){const u=Math.min(a+c,o);for(let o=r;o<s;o++){const r=t[i+o];for(let s=a;s<u;s++){let a=Complex.zero();for(let r=0;r<l;r++){const l=t[i+o][e+r],c=t[e+r][n+s];a=Complex.add(a,Complex.mul(l,c))}r[n+s]=Complex.sub(r[n+s],a)}}}}};static getrs=(t,e,r)=>{const s=t.length,i=t[0].length,n=r[0].length??1,a=BLAS.copy(r);for(let t=0;t<e.length;t++){const r=e[t];if(r!==t){const e=a[t];a[t]=a[r],a[r]=e}}for(let e=0;e<n;e++)for(let r=0;r<s;r++){let s=a[r][e];for(let n=0;n<r&&n<i;n++)s=Complex.sub(s,Complex.mul(t[r][n],a[n][e]));a[r][e]=s}for(let e=0;e<n;e++)for(let r=Math.min(i,s)-1;r>=0;r--){let s=a[r][e];for(let n=r+1;n<i;n++)s=Complex.sub(s,Complex.mul(t[r][n],a[n][e]));const n=t[r][r];a[r][e]=Complex.rdiv(s,n)}return a};static gesv=(t,e)=>{const r=BLAS.copy(t),s=BLAS.copy(e),{LU:i,piv:n,info:a}=LAPACK.getrf(r);return 0!==a?{X:s,info:a}:{X:LAPACK.getrs(i,n,s),info:0}};static posv=(t,e)=>{const r=BLAS.copy(t),s=BLAS.copy(e),{LU:i,piv:n,info:a}=LAPACK.getrf(r);if(0!==a)throw new Error(`posv: matrix is singular or not positive definite (info = ${a})`);return LAPACK.getrs(i,n,s)};static potrf=(t,e)=>{const r=e?.uplo??"lower",s=t.dimension[0];if(t.dimension[0]!==t.dimension[1])throw new Error("LAPACK.potrf: A must be square");const i=MultiArray.copy(t);if("lower"===r){for(let t=0;t<s;t++){let e=Complex.realToNumber(i.array[t][t]);for(let r=0;r<t;r++){const s=i.array[t][r];e-=Complex.realToNumber(Complex.mul(s,Complex.conj(s)))}if(e<=0)throw new Error("LAPACK.potrf: matrix is not positive definite");i.array[t][t]=Complex.create(Math.sqrt(e));for(let e=t+1;e<s;e++){let r=i.array[e][t];for(let s=0;s<t;s++)r=Complex.sub(r,Complex.mul(i.array[e][s],Complex.conj(i.array[t][s])));i.array[e][t]=Complex.rdiv(r,i.array[t][t])}}for(let t=0;t<s;t++)for(let e=t+1;e<s;e++)i.array[t][e]=Complex.zero()}else{for(let t=0;t<s;t++){let e=Complex.realToNumber(i.array[t][t]);for(let r=0;r<t;r++){const s=i.array[r][t];e-=Complex.realToNumber(Complex.mul(s,Complex.conj(s)))}if(e<=0)throw new Error("LAPACK.potrf: matrix is not positive definite");i.array[t][t]=Complex.create(Math.sqrt(e));for(let e=t+1;e<s;e++){let r=i.array[t][e];for(let s=0;s<t;s++)r=Complex.sub(r,Complex.mul(Complex.conj(i.array[s][t]),i.array[s][e]));i.array[t][e]=Complex.rdiv(r,i.array[t][t])}}for(let t=1;t<s;t++)for(let e=0;e<t;e++)i.array[t][e]=Complex.zero()}return MultiArray.setType(i),i};static sysv=(t,e)=>{const r=BLAS.copy(t),s=BLAS.copy(e),{LU:i,piv:n,info:a}=LAPACK.getrf(r);if(0!==a)throw new Error(`sysv: matrix is singular (info = ${a})`);return LAPACK.getrs(i,n,s)};static mldivide=(t,e)=>{const[r,s]=t.dimension,[i,n]=e.dimension;if(s!==i)throw new EvalError(`operator \\: nonconformant arguments (op1 is ${t.dimension.join("x")}, op2 is ${e.dimension.join("x")}).`);let a,o,l;if(LAPACK.is_hermitian(t.array))if(LAPACK.is_positive_definite(t.array)){const r=LAPACK.posv(t.array,e.array);a=new MultiArray([r.length,r[0].length]),a.array=r,o=0,l="posv"}else{const r=LAPACK.sysv(t.array,e.array);a=new MultiArray([r.length,r[0].length]),a.array=r,o=0,l="sysv"}else{const r=LAPACK.gesv(t.array,e.array);a=new MultiArray([r.X.length,r.X[0].length]),a.array=r.X,o=r.info,l="gesv"}return{X:a,info:o,solver:l}};static larfg_original=t=>{const e=t.length;if(0===e)return{tau:Complex.zero(),v:[],phi:Complex.one(),alpha:Complex.zero()};const r=t[0];let s=Complex.zero();for(let r=1;r<e;r++){const e=Complex.abs(t[r]);Complex.mulAndSumTo(s,e,e)}const i=Complex.abs(r),n=Complex.realIsZero(i)?Complex.one():Complex.rdiv(r,i);if(1===e||Complex.realIsZero(Complex.abs(s))){const t=Complex.zero(),s=new Array(e);s[0]=Complex.one();for(let t=1;t<e;t++)s[t]=Complex.zero();return{tau:t,v:s,phi:n,alpha:r}}{const i=Complex.sqrt(Complex.add(Complex.mul(r,Complex.conj(r)),s)),a=Complex.mul(Complex.neg(n),i),o=Complex.rdiv(Complex.sub(a,r),a),l=Complex.sub(r,a),c=new Array(e);c[0]=Complex.one();for(let r=1;r<e;r++)c[r]=Complex.rdiv(t[r],l);return{tau:o,v:c,phi:n,alpha:a}}};static sytrd=(t,e)=>{const r=t.dimension[0],s=new Array(r),i=new Array(r-1),n=new Array(r-1);for(let a=0;a<r-1;a++){const o=r-a-1,l=new Array(o);for(let e=0;e<o;e++)l[e]=Complex.copy(t.array[a+1+e][a]);const{alpha:c,v:u,tau:h}=LAPACK.larfg_original(l);n[a]=h,i[a]=c,t.array[a+1][a]=c;for(let e=1;e<o;e++)t.array[a+1+e][a]=u[e];Complex.realIsZero(Complex.abs(h))||e(t,u,Complex.conj(h),a+1,a+1),s[a]=Complex.copy(t.array[a][a])}return s[r-1]=Complex.copy(t.array[r-1][r-1]),{diag:s,offdiag:i,taus:n}};static her2_zhtrd_update=(t,e,r,s,i)=>{if(Complex.realIsZero(Complex.abs(r)))return;const n=e.length,a=new Array(n);for(let o=0;o<n;o++){let l=Complex.zero();for(let r=0;r<n;r++)Complex.mulAndSumTo(l,t.array[s+o][i+r],e[r]);a[o]=Complex.mul(r,l)}let o=Complex.zero();for(let t=0;t<n;t++)Complex.mulAndSumTo(o,Complex.conj(e[t]),a[t]);const l=Complex.mul(Complex.minusonediv2(),Complex.mul(r,o));for(let t=0;t<n;t++)Complex.mulAndSumTo(a[t],l,e[t]);for(let r=0;r<n;r++)for(let o=r;o<n;o++){const n=Complex.add(Complex.mul(e[r],Complex.conj(a[o])),Complex.mul(a[r],Complex.conj(e[o]))),l=s+r,c=i+o;t.array[l][c]=Complex.sub(t.array[l][c],n),r!==o&&(t.array[c][l]=Complex.conj(t.array[l][c]))}};static hetrd=t=>LAPACK.sytrd(t,LAPACK.her2_zhtrd_update);static ungtr=(t,e)=>{const r=t.dimension[0],s=new MultiArray([r,r]);s.array=LAPACK.eye([r,r]);for(let i=r-2;i>=0;i--){const n=e[i];if(!n||Complex.realIsZero(Complex.abs(n)))continue;const a=r-i-1,o=new Array(a);o[0]=Complex.one();for(let e=1;e<a;e++)o[e]=Complex.copy(t.array[i+1+e][i]);const l=new Array(r);for(let t=0;t<r;t++){let e=Complex.zero();for(let r=0;r<a;r++)Complex.mulAndSumTo(e,Complex.conj(o[r]),s.array[i+1+r][t]);l[t]=e}for(let t=0;t<a;t++){const e=Complex.mul(n,o[t]);for(let n=0;n<r;n++)s.array[i+1+t][n]=Complex.sub(s.array[i+1+t][n],Complex.mul(e,l[n]))}}return s};static sytrd_blocked_w=(t,e)=>{const r=t.dimension[0];if(r!==t.dimension[1])throw new Error("sytrd_blocked_w: A must be square");const s=new Array(r),i=new Array(r),n=new Array(r);if(0===r)return{diag:s,offdiag:i,taus:n};if(1===r)return s[0]=t.array[0][0],i[0]=Complex.zero(),n[0]=Complex.zero(),{diag:s,offdiag:i,taus:n};const a=Math.max(1,Math.floor(e??BLAS.settings.blockSize));for(let e=0;e<r-1;e+=a){const o=Math.min(a,r-1-e),l=new Array(r-e-1),c=new Array(r-e-1);for(let t=0;t<r-e-1;t++)l[t]=new Array(o).fill(Complex.zero()),c[t]=new Array(o).fill(Complex.zero());for(let a=0;a<o;a++){const o=e+a,u=r-o-1,h=new Array(u);for(let e=0;e<u;e++)h[e]=t.array[o+1+e][o];const d=LAPACK.larfg_original(h),m=d.v,p=d.tau,f=d.alpha;n[o]=p,s[o]=t.array[o][o],i[o]=f;for(let e=0;e<u;e++)t.array[o+1+e][o]=m[e],l[e][a]=m[e];if(!Complex.realIsZero(Complex.abs(p)))for(let e=0;e<u;e++){let r=Complex.zero();for(let s=0;s<=e;s++)r=Complex.add(r,Complex.mul(l[s][a],Complex.conj(t.array[o+1+s][o+1+e])));c[e][a]=Complex.mul(p,r)}}for(let s=0;s<r-e-1;s++)for(let i=s;i<r-e-1;i++){let r=Complex.zero(),n=Complex.zero();for(let t=0;t<o;t++)r=Complex.add(r,Complex.mul(l[s][t],Complex.conj(c[i][t]))),n=Complex.add(n,Complex.mul(c[s][t],Complex.conj(l[i][t])));t.array[e+1+s][e+1+i]=Complex.sub(t.array[e+1+s][e+1+i],Complex.add(r,n)),s!==i&&(t.array[e+1+i][e+1+s]=Complex.conj(t.array[e+1+s][e+1+i]))}}return s[r-1]=t.array[r-1][r-1],i[r-1]=Complex.zero(),n[r-1]=Complex.zero(),{diag:s,offdiag:i,taus:n}};static tridiagonal_hermitian_to_dense=(t,e)=>{const r=t.length,s=Array.from({length:r},()=>Array.from({length:r},()=>Complex.zero()));for(let i=0;i<r;i++)s[i][i]=Complex.copy(t[i]),i<r-1&&(s[i][i+1]=Complex.copy(e[i]),s[i+1][i]=Complex.conj(e[i]));return s};static hermitian_to_real2n=t=>{const e=t.length,r=Array.from({length:2*e},t=>Array.from({length:2*e}));for(let s=0;s<e;s++)for(let i=0;i<e;i++){const n=t[s][i];r[s][i]=Complex.real(n),r[s][i+e]=Complex.neg(Complex.imag(n)),r[s+e][i]=Complex.imag(n),r[s+e][i+e]=Complex.real(n)}return r};static real2n_to_complex_eigenvectors=t=>{const e=t.length/2,r=Array.from({length:e},t=>Array.from({length:e}));for(let s=0;s<e;s++)for(let i=0;i<e;i++){const n=t[i][s],a=t[i+e][s];r[i][s]=Complex.create(n.re,a.re)}return r};static real2n_to_complex_eigenvalues=t=>{const e=t.length/2,r=new Array(e);for(let s=0;s<e;s++){const i=t[s].re,n=t[s+e].re;r[s]=Complex.create(i,n)}return r};static jacobi_real_symmetric_dense=(t,e=1e3,r=1e-14)=>{const s=t.length;if(0===s)return{D:[],V:[]};if(1===s)return{D:[t[0][0]],V:[[Complex.one()]]};const i=LAPACK.eye([s,s]);for(let n=0;n<toNumber(e);n++){let e=Complex.zero();for(let n=0;n<s-1;n++)for(let a=n+1;a<s;a++){const o=t[n][a];if(e=Complex.max(e,Complex.abs(o)),Complex.realLessThan(Complex.abs(o),r))continue;const l=t[n][n],c=t[a][a],u=Complex.mul(Complex.two(),o);if(Complex.toBoolean(Complex.eq(u,Complex.zero())))continue;const h=Complex.rdiv(Complex.sub(c,l),u),d=Complex.toBoolean(Complex.ge(h,Complex.zero()))?Complex.one():Complex.minusone(),m=Complex.rdiv(d,Complex.add(Complex.abs(h),Complex.sqrt(Complex.add(Complex.one(),Complex.mul(h,h))))),p=Complex.rdiv(Complex.one(),Complex.sqrt(Complex.add(Complex.one(),Complex.mul(m,m)))),f=Complex.mul(m,p);for(let e=0;e<s;e++)if(e!==n&&e!==a){const r=t[e][n],s=t[e][a];t[e][n]=Complex.sub(Complex.mul(p,r),Complex.mul(f,s)),t[n][e]=t[e][n],t[e][a]=Complex.add(Complex.mul(f,r),Complex.mul(p,s)),t[a][e]=t[e][a]}t[n][n]=Complex.add(Complex.sub(Complex.mul(Complex.mul(p,p),l),Complex.mul(Complex.mul(Complex.mul(Complex.two(),f),p),o)),Complex.mul(Complex.mul(f,f),c)),t[a][a]=Complex.add(Complex.add(Complex.mul(Complex.mul(f,f),l),Complex.mul(Complex.mul(Complex.mul(Complex.two(),f),p),o)),Complex.mul(Complex.mul(p,p),c)),t[n][a]=Complex.zero(),t[a][n]=Complex.zero();for(let t=0;t<s;t++){const e=i[t][n],r=i[t][a];i[t][n]=Complex.sub(Complex.mul(p,e),Complex.mul(f,r)),i[t][a]=Complex.add(Complex.mul(f,e),Complex.mul(p,r))}}if(Complex.realLessThan(e,r))break}return{D:LAPACK.from_diag(t),V:i}};static jacobi_symmetric_hermitian=(t,e,r)=>{const s=t.length,i=Array.from({length:s},(t,e)=>Array.from({length:s},(t,r)=>e===r?Complex.create(1):Complex.zero())),n=r??1e-12,a=e??Math.max(50,Math.floor(1e3/Math.max(1,s))),o=t=>{let e=0;for(let r=0;r<s;r++)for(let i=r+1;i<s;i++){const s=Complex.abs(t[r][i]),n=Complex.realToNumber(s);e+=n*n}return Math.sqrt(e)};for(let e=0;e<a;e++){let e=!1;for(let r=0;r<s-1;r++)for(let a=r+1;a<s;a++){const o=t[r][a];if(Complex.realToNumber(Complex.le(Complex.abs(o),Complex.create(n))))continue;const l=t[r][r],c=t[a][a],u=Complex.realToNumber(Complex.real(o)),h=Complex.realToNumber(Complex.real(l)),d=Complex.realToNumber(Complex.real(c)),m=.5*Math.atan2(2*u,d-h),p=Math.cos(m),f=Math.sin(m);for(let e=0;e<s;e++){if(e===r||e===a)continue;const s=t[e][r],i=t[e][a];t[e][r]=Complex.sub(Complex.mul(Complex.create(p),s),Complex.mul(Complex.create(f),i)),t[r][e]=Complex.conj(t[e][r]),t[e][a]=Complex.add(Complex.mul(Complex.create(f),s),Complex.mul(Complex.create(p),i)),t[a][e]=Complex.conj(t[e][a])}const g=Complex.add(Complex.sub(Complex.mul(Complex.create(p*p),l),Complex.mul(Complex.create(2*f*p),o)),Complex.mul(Complex.create(f*f),c)),y=Complex.add(Complex.add(Complex.mul(Complex.create(f*f),l),Complex.mul(Complex.create(2*f*p),o)),Complex.mul(Complex.create(p*p),c));t[r][r]=g,t[a][a]=y,t[r][a]=Complex.zero(),t[a][r]=Complex.zero();for(let t=0;t<s;t++){const e=i[t][r],s=i[t][a];i[t][r]=Complex.sub(Complex.mul(Complex.create(p),e),Complex.mul(Complex.create(f),s)),i[t][a]=Complex.add(Complex.mul(Complex.create(f),e),Complex.mul(Complex.create(p),s))}e=!0}if(!e)break;if(o(t)<=n)break}const l=new Array(s);for(let e=0;e<s;e++)l[e]=t[e][e];return{D:l,V:i}};static column_pivot=(t,e,r=0,s=t.length)=>{const i=t.slice(r,s).map(t=>Complex.abs(t[e])),n=i.reduce((t,e,r,s)=>Complex.toBoolean(Complex.gt(e,s[t]))?r:t,0);return{pivotRow:n,pivotAbs:i[n],pivotIsZero:Complex.realIsZero(i[n])}};static normalize_eigenvector_phases=(t,e=!0)=>{const r=t.length,s=t[0].length;for(let i=0;i<s;i++){const{pivotRow:s,pivotAbs:n,pivotIsZero:a}=LAPACK.column_pivot(t,i);if(a)continue;const o=t[s][i];let l=Complex.rdiv(Complex.conj(o),n);e&&Complex.realLessThan(Complex.mul(o,l),0)&&(l=Complex.neg(l));for(let e=0;e<r;e++)t[e][i]=Complex.mul(t[e][i],l)}};static steqr_vectors=(t,e,r=1e3*t.length)=>{const s=t.length,i=t.map(t=>Complex.copy(t)),n=e.map(t=>Complex.copy(t));n[s-1]=Complex.zero();let a=!1;for(let t=0;t<s;t++)if(Complex.isComplexValue(i[t])||t<s-1&&Complex.isComplexValue(n[t])){a=!0;break}const o=new Array(s);let l=i.slice(),c=new Array(s);if(a){o[0]=Complex.one();for(let t=0;t<s-1;t++){const e=n[t],r=Complex.abs(e);if(Complex.realIsZero(r))o[t+1]=Complex.copy(o[t]);else{const s=Complex.rdiv(Complex.conj(e),r);o[t+1]=Complex.mul(o[t],s)}}for(let t=0;t<s-1;t++){const e=Complex.mul(Complex.conj(o[t]),Complex.mul(n[t],o[t+1]));c[t]=Complex.abs(e)}}else for(let t=0;t<s-1;t++)c[t]=Complex.copy(n[t]);c[s-1]=Complex.zero();const u=LAPACK.tridiagonal_hermitian_to_dense(l,c),h=LAPACK.jacobi_real_symmetric_dense(u,r);let d=h.D.map(t=>Complex.copy(t)),m=h.V.map(t=>t.map(t=>Complex.copy(t)));if(a)for(let t=0;t<s;t++)for(let e=0;e<s;e++)m[t][e]=Complex.mul(o[t],m[t][e]);const p=d.map((t,e)=>({v:t,i:e})).sort((t,e)=>Complex.realToNumber(t.v)-Complex.realToNumber(e.v)),f=Array.from({length:s},()=>Array(s)),g=p.map(t=>t.v);for(let t=0;t<s;t++){const e=p[t].i;for(let r=0;r<s;r++)f[r][t]=Complex.copy(m[r][e])}return LAPACK.normalize_eigenvector_phases(f),{D:g,V:f,complex:a}};static steqr_vectors_tridiagonal=(t,e,r=1e3)=>{const s=t.length;if(0===s)return{D:[],V:[]};if(1===s)return{D:[Complex.copy(t[0])],V:[[Complex.one()]]};const i=t.map(t=>Complex.copy(t)),n=e.map(t=>Complex.copy(t)),a=Array.from({length:s},(t,e)=>Array.from({length:s},(t,r)=>e===r?Complex.one():Complex.zero())),o=Number.EPSILON||2220446049250313e-31;let l=0;for(;l<r;){let t=0;for(;t<s-1&&Complex.realLessThanOrEqualTo(Complex.abs(n[t]),o);)t++;if(t>=s-1)break;let e=t;for(;e<s-2&&Complex.realGreaterThan(Complex.abs(n[e]),o);)e++;const r=i[e],c=i[e+1],u=n[e],h=Complex.mul(Complex.sub(r,c),Complex.create(.5)),d=Complex.abs(h),m=Complex.power(Complex.abs(u),Complex.two()),p=Complex.add(d,Complex.sqrt(Complex.add(Complex.mul(d,d),m))),f=Complex.realGreaterThanOrEqualTo(h,0)?Complex.one():Complex.minusone(),g=Complex.sub(c,Complex.rdiv(Complex.mul(f,m),p));let y=Complex.sub(i[t],g),x=n[t];for(let r=t;r<=e;r++){const t=Complex.sqrt(Complex.add(Complex.power(Complex.abs(y),Complex.two()),Complex.power(Complex.abs(x),Complex.two())));if(Complex.realEquals(t,0))continue;const o=Complex.rdiv(y,t),l=Complex.rdiv(x,t),c=i[r],u=i[r+1];i[r]=Complex.add(Complex.mul(Complex.conj(o),Complex.mul(o,c)),Complex.mul(Complex.conj(l),Complex.mul(l,u))),i[r+1]=Complex.add(Complex.mul(Complex.conj(l),Complex.mul(l,c)),Complex.mul(Complex.conj(o),Complex.mul(o,u))),n[r]=Complex.zero(),r<e&&(y=n[r],x=n[r+1]);for(let t=0;t<s;t++){const e=a[t][r],s=a[t][r+1];a[t][r]=Complex.sub(Complex.mul(o,e),Complex.mul(l,s)),a[t][r+1]=Complex.add(Complex.mul(Complex.conj(l),e),Complex.mul(o,s))}}l++}return{D:i,V:a}};static steqr_values=(t,e,r)=>LAPACK.steqr_vectors(t,e,r).D;static orgtr=(t,e)=>{const r=t.dimension[0];if(r!==t.dimension[1])throw new Error("orgtr: A must be square");const s=new MultiArray([r,r]);s.array=LAPACK.eye(r,r);for(let i=r-2;i>=0;i--){const n=r-i-1,a=new Array(n);for(let e=0;e<n;e++)a[e]=t.array[i+1+e][i];const o=e[i];Complex.realIsZero(Complex.abs(o))||LAPACK.larf_left(s,a,o,i+1,0)}return MultiArray.setType(s),s};static orgtr_blocked=(t,e,r)=>{const s=t.dimension[0];if(s!==t.dimension[1])throw new Error("orgtr_blocked: A must be square");const i=new MultiArray([s,s]);i.array=LAPACK.eye(s,s);const n=Math.max(1,Math.floor(r??BLAS.settings.blockSize));for(let r=s-2-(s-2)%n;r>=0;r-=n){for(let a=Math.min(n,s-1-r)-1;a>=0;a--){const o=r+a,l=s-o-1;if(l<=0)continue;const c=new Array(l);for(let e=0;e<l;e++)c[e]=t.array[o+1+e][o];const u=e[o];Complex.realIsZero(Complex.abs(u))||LAPACK.larf_left_block(i,c,u,o+1,0,n)}if(0===r)break}return MultiArray.setType(i),i};static orgtr_blocked_w=(t,e,r)=>{const s=t.dimension[0];if(s!==t.dimension[1])throw new Error("orgtr_blocked_w: A must be square");const i=new MultiArray([s,s]);i.array=LAPACK.eye(s,s);const n=Math.max(1,Math.floor(r??BLAS.settings.blockSize));for(let r=s-2;r>=0;r-=n){const a=Math.min(n,r+1),o=new Array(s-r-1),l=new Array(s-r-1);for(let t=0;t<s-r-1;t++)o[t]=new Array(a).fill(Complex.zero()),l[t]=new Array(a).fill(Complex.zero());for(let e=0;e<a;e++){const i=r-a+1+e,n=s-i-1;for(let r=0;r<n;r++)o[r][e]=t.array[i+1+r][i]}for(let t=0;t<a;t++){const n=r-a+1+t,c=e[n],u=s-n-1;if(!Complex.realIsZero(Complex.abs(c)))for(let e=0;e<u;e++){let r=Complex.zero();for(let s=0;s<=e;s++)r=Complex.add(r,Complex.mul(o[s][t],Complex.conj(i.array[n+1+s][n+1+e])));l[e][t]=Complex.mul(c,r)}}for(let t=0;t<s-r-1;t++)for(let e=0;e<s;e++){let s=Complex.zero(),n=Complex.zero();for(let i=0;i<a;i++)s=Complex.add(s,Complex.mul(o[t][i],Complex.conj(l[e-r-1+t]?.[i]??Complex.zero()))),n=Complex.add(n,Complex.mul(l[t][i],Complex.conj(o[e-r-1+t]?.[i]??Complex.zero())));i.array[r+1+t][e]=Complex.sub(i.array[r+1+t][e],Complex.add(s,n))}}return i};static eig_symmetric=(t,e=!1)=>{t.dimension[0];const r=MultiArray.copy(t),{diag:s,offdiag:i,taus:n}=LAPACK.hetrd(r);if(e){let t=LAPACK.ungtr(r,n);const{D:e,V:a}=LAPACK.steqr_vectors(s,i),o=new MultiArray([a.length,a[0].length]);return o.array=a,t=LAPACK.mtimes(t,o),{D:MultiArray.toDiagonalMatrix(e),V:t}}return{D:MultiArray.toColumnVector(LAPACK.steqr_vectors(s,i).D)}};static eig_hermitian=(t,e=!1)=>{const r=t.dimension[0],s=MultiArray.copy(t);let i=!1;for(let t=0;t<r&&!i;t++)for(let e=0;e<r;e++){const r=s.array[t][e];if(!Complex.imagIsZero(r)){i=!0;break}}if(i){const{diag:t,offdiag:i,taus:n}=LAPACK.hetrd(s);if(!e){const{D:e}=LAPACK.steqr_vectors(t,i);return{D:MultiArray.toColumnVector(e)}}let a=LAPACK.ungtr(s,n);console.log("Q =",a);const{D:o,V:l}=LAPACK.steqr_vectors(t,i),c=new MultiArray([r,r]);return c.array=l,a=LAPACK.mtimes(a,c),{D:MultiArray.toDiagonalMatrix(o),V:a}}{const{diag:t,offdiag:i,taus:n}=LAPACK.hetrd(s);if(!e){const{D:e}=LAPACK.steqr_vectors(t,i);return{D:MultiArray.toColumnVector(e)}}let a=LAPACK.ungtr(s,n);const{D:o,V:l}=LAPACK.steqr_vectors(t,i),c=new MultiArray([r,r]);return c.array=l,a=LAPACK.mtimes(a,c),{D:MultiArray.toDiagonalMatrix(o),V:a}}};static functions={is_hermitian:LAPACK.is_hermitian,is_positive_definite:LAPACK.is_positive_definite,laswp:LAPACK.laswp,laswp_rows:LAPACK.laswp_rows,laswp_cols:LAPACK.laswp_cols,eye:LAPACK.eye,fillFactory:LAPACK.fillFactory,zeros:LAPACK.zeros,ones:LAPACK.ones,diag:LAPACK.diag,from_diag:LAPACK.from_diag,lassq:LAPACK.lassq,lange:LAPACK.lange,triu_inplace:LAPACK.triu_inplace,tril_inplace:LAPACK.tril_inplace,trsm_left_upper_block:LAPACK.trsm_left_upper_block,lapmt_matrix:LAPACK.lapmt_matrix,lapmt_apply:LAPACK.lapmt_apply,dotc_col:LAPACK.dotc_col,dotc_row:LAPACK.dotc_row,larfg:LAPACK.larfg,larf:LAPACK.larf,geqr2:LAPACK.geqr2,geqp2:LAPACK.geqp2,geqp3:LAPACK.geqp3,gelq2:LAPACK.gelq2,orgqr:LAPACK.orgqr,orglq:LAPACK.orglq,getf2:LAPACK.getf2,getrf:LAPACK.getrf,getrf_blocked:LAPACK.getrf_blocked,gemm_blocked:LAPACK.gemm_blocked,getrs:LAPACK.getrs,gesv:LAPACK.gesv,posv:LAPACK.posv,potrf:LAPACK.potrf,sysv:LAPACK.sysv,mldivide:LAPACK.mldivide,sytrd:LAPACK.sytrd,her2_zhtrd_update:LAPACK.her2_zhtrd_update,hetrd:LAPACK.hetrd,ungtr:LAPACK.ungtr,sytrd_blocked_w:LAPACK.sytrd_blocked_w,tridiagonal_hermitian_to_dense:LAPACK.tridiagonal_hermitian_to_dense,hermitian_to_real2n:LAPACK.hermitian_to_real2n,real2n_to_complex_eigenvectors:LAPACK.real2n_to_complex_eigenvectors,real2n_to_complex_eigenvalues:LAPACK.real2n_to_complex_eigenvalues,jacobi_real_symmetric_dense:LAPACK.jacobi_real_symmetric_dense,jacobi_symmetric_hermitian:LAPACK.jacobi_symmetric_hermitian,column_pivot:LAPACK.column_pivot,normalize_eigenvector_phases:LAPACK.normalize_eigenvector_phases,steqr_vectors:LAPACK.steqr_vectors,steqr_vectors_tridiagonal:LAPACK.steqr_vectors_tridiagonal,steqr_values:LAPACK.steqr_values,orgtr:LAPACK.orgtr,orgtr_blocked:LAPACK.orgtr_blocked,orgtr_blocked_w:LAPACK.orgtr_blocked_w,eig_symmetric:LAPACK.eig_symmetric,eig_hermitian:LAPACK.eig_hermitian}}const src_LAPACK=null,LinearAlgebraConfigKeyTable=["wasteLU","qrPhaseEpsilon"],LinearAlgebraConfigKeySet=new Set(LinearAlgebraConfigKeyTable),LinearAlgebra_defaultSettings={wasteLU:1e-15,qrPhaseEpsilon:1e-300};class LinearAlgebra{static defaultSettings=Object.assign({},LinearAlgebra_defaultSettings);static settings=LinearAlgebra.defaultSettings;static set=t=>{Object.entries(t).forEach(t=>{if(!LinearAlgebraConfigKeySet.has(t[0]))throw new Error(`LinearAlgebra.set: invalid configuration parameter: ${t[0]}`);LinearAlgebra.settings[t[0]]=t[1]})};static eyeSignature={inputs:[{arity:0},{arity:1,parameters:[{name:"dimensions",classes:["double"],validators:["dimension"],alternatives:[{name:"dimensions",validators:["dimensionVector","oneOrTwoElement"]}]}]},{arity:2,parameters:[{name:"rows",classes:["double"],validators:["dimension"]},{name:"columns",classes:["double"],validators:["dimension"]}]}],outputs:{arity:1}};static eye=(...t)=>{let e=0,r=0;if(0===t.length)return Complex.one();if(1===t.length)if(MultiArray.isInstanceOf(t[0])){const s=MultiArray.linearize(t[0]);if(0===s.length)throw new SyntaxError("eye (A): use eye (size (A)) instead");if(1===s.length)e=MultiArray.testIndex(s[0]),r=e;else{if(2!==s.length)throw new SyntaxError("eye (A): use eye (size (A)) instead");e=MultiArray.testIndex(s[0]),r=MultiArray.testIndex(s[1])}}else e=MultiArray.testIndex(t[0]),r=e;else 2===t.length&&Complex.isInstanceOf(t[0])&&Complex.isInstanceOf(t[1])?(e=MultiArray.testIndex(t[0]),r=MultiArray.testIndex(t[1])):AST.throwInvalidCallError("eye");const s=new MultiArray([e,r],Complex.zero());for(let t=0;t<Math.min(s.dimension[0],s.dimension[1]);t++)s.array[t][t]=Complex.one();return s};static diagSignature={inputs:[{arity:1,parameters:[{name:"value",classes:["double"]}]},{arity:2,parameters:[{name:"value",classes:["double"]},{name:"offset",classes:["double"],validators:["numeric","scalar","real","finite","integer"]}]},{arity:3,parameters:[{name:"value",classes:["double"],validators:["vector"]},{name:"rows",classes:["double"],validators:["dimension"]},{name:"columns",classes:["double"],validators:["dimension"]}]}],outputs:{arity:1}};static diag=(...t)=>{let e;if(t.length>0&&t.length<=3)if(MultiArray.isInstanceOf(t[0])){if(2!==t[0].dimension.length)throw new Error("Matrix must be 2-dimensional");if(1===t.length)if(1===t[0].dimension[0]&&t[0].dimension[1]>1){const r=t[0].dimension[1];e=new MultiArray([r,r]),e.array=LAPACK.diag(t[0].array[0])}else if(1===t[0].dimension[1]&&t[0].dimension[0]>1){const r=t[0].dimension[0];e=new MultiArray([r,r]),e.array=LAPACK.diag(t[0].array.map(t=>t[0]))}else e=MultiArray.toColumnVector(LAPACK.from_diag(t[0].array));else if(2===t.length){const r=Math.floor(Complex.realToNumber(MultiArray.firstElement(t[1])));if(1===t[0].dimension[0]&&t[0].dimension[1]>1){const s=t[0].dimension[1];e=new MultiArray([s,s]),e.array=LAPACK.diag(t[0].array[0],r)}else if(1===t[0].dimension[1]&&t[0].dimension[0]>1){const s=t[0].dimension[0];e=new MultiArray([s,s]),e.array=LAPACK.diag(t[0].array.map(t=>t[0]),r)}else e=MultiArray.toColumnVector(LAPACK.from_diag(t[0].array,r))}else{const r=Math.floor(Complex.realToNumber(MultiArray.firstElement(t[1]))),s=Math.floor(Complex.realToNumber(MultiArray.firstElement(t[2])));if(e=new MultiArray([r,s]),e.array=LAPACK.diag(t[0].array[0],0,[r,s]),1===t[0].dimension[0]&&t[0].dimension[1]>1)e.array=LAPACK.diag(t[0].array[0],0,r,s);else{if(!(1===t[0].dimension[1]&&t[0].dimension[0]>1))throw new Error("diag: V must be a vector");e.array=LAPACK.diag(t[0].array.map(t=>t[0]),0,r,s)}}}else e=new MultiArray([1,1],t[0].copy());else AST.throwInvalidCallError("diag");return e};static traceSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["matrix2d"]}]},outputs:{arity:1}};static trace=t=>{if(2===t.dimension.length)return t.array.map((t,e)=>t[e]?t[e]:Complex.zero()).reduce((t,e)=>Complex.add(t,e),Complex.zero());throw new Error("trace: only valid on 2-D objects")};static applyTranspose=(t,e=t=>t)=>{if(2===t.dimension.length){const r=new MultiArray([t.dimension[1],t.dimension[0]],void 0,t.isCell);for(let s=0;s<t.dimension[1];s++){r.array[s]=new Array(t.dimension[0]);for(let i=0;i<t.dimension[0];i++)r.array[s][i]=e(t.array[i][s]).copy()}return r.type=t.type,r.isCell=t.isCell,r}throw new Error("transpose not defined for N-D objects")};static transposeSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static transpose=t=>{const e=CharString.isInstanceOf(t)?MultiArray.characterVectorFromCharString(t):t;return Complex.isInstanceOf(e)?Complex.copy(e):LinearAlgebra.applyTranspose(e)};static ctransposeSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static ctranspose=t=>{const e=CharString.isInstanceOf(t)?MultiArray.characterVectorFromCharString(t):t;return Complex.isInstanceOf(e)?Complex.conj(e):LinearAlgebra.applyTranspose(e,t=>e.isCell||!Complex.isInstanceOf(t)?t:Complex.conj(t))};static mulSignature={inputs:{arity:2,parameters:[{name:"left",classes:["double"],validators:["matrix2d"]},{name:"right",classes:["double"],validators:["matrix2d"]}]},outputs:{arity:1}};static mul(t,e){if(t.dimension[1]!==e.dimension[0]||2!==t.dimension.length||2!==e.dimension.length)throw new EvalError(`operator *: nonconformant arguments (op1 is ${t.dimension.join("x")}, op2 is ${e.dimension.join("x")}).`);{const r=new MultiArray([t.dimension[0],e.dimension[1]]);return BLAS.gemm(Complex.one(),t.array,t.dimension[0],t.dimension[1],e.array,e.dimension[1],Complex.zero(),r.array),MultiArray.setType(r),r}}static powerSignature={inputs:{arity:2,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]},{name:"exponent",classes:["double"],validators:["numeric","scalar","real","finite","integer"]}]},outputs:{arity:1}};static multiplyMatrices=(t,e)=>{const r=new MultiArray([t.dimension[0],e.dimension[1]]);return BLAS.gemm(Complex.one(),t.array,t.dimension[0],t.dimension[1],e.array,e.dimension[1],Complex.zero(),r.array),MultiArray.setType(r),r};static formatDimensions=t=>t.dimension.join("x");static hermitianEigenExpansion=(t,e)=>{if(!LAPACK.is_hermitian(t.array))throw new Error("invalid exponent in '^'.");const r=LAPACK.jacobi_symmetric_hermitian(BLAS.copy(t.array),1e3,1e-14),s=new MultiArray([t.dimension[0],t.dimension[1]]);s.array=r.V;const i=MultiArray.toDiagonalMatrix(r.D.map(e)),n=LinearAlgebra.multiplyMatrices(s,i);return LinearAlgebra.multiplyMatrices(n,LinearAlgebra.ctranspose(s))};static power=(t,e)=>{if(2!==t.dimension.length||t.dimension[0]!==t.dimension[1])throw new EvalError("operator ^: only square matrices can be raised to scalar powers.");if(Complex.realIsInteger(e)&&Complex.imagEquals(e,0)){let r=Math.abs(Complex.realToNumber(e)),s=LinearAlgebra.eye(Complex.create(t.dimension[0],0)),i=Complex.realGreaterThan(e,0)||Complex.realEquals(e,0)?MultiArray.copy(t):LinearAlgebra.inv(t);for(;r>0;)r%2==1&&(s=LinearAlgebra.multiplyMatrices(s,i)),r=Math.floor(r/2),r>0&&(i=LinearAlgebra.multiplyMatrices(i,i));return s}return LinearAlgebra.hermitianEigenExpansion(t,t=>Complex.power(t,e))};static scalarPower=(t,e)=>{if(2!==e.dimension.length||e.dimension[0]!==e.dimension[1])throw new EvalError("operator ^: matrix exponent must be square when base is scalar.");return LinearAlgebra.hermitianEigenExpansion(e,e=>Complex.power(t,e))};static detSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]}]},outputs:{arity:1}};static det=t=>{if(2!==t.dimension.length||t.dimension[0]!==t.dimension[1])throw new EvalError("det: matrix must be square.");const e=t.dimension[0];if(0===e)return Complex.create(1,0);if(1===e)return t.array[0][0];if(2===e)return Complex.sub(Complex.mul(t.array[0][0],t.array[1][1]),Complex.mul(t.array[0][1],t.array[1][0]));const{U:r,swaps:s}=LinearAlgebra.luDecomposition(t);let i=Complex.one();for(let t=0;t<e;t++){const e=r.array[t][t];if(Complex.realIsZero(Complex.abs(e)))return Complex.zero();i=Complex.mul(i,e)}return s%2==1&&(i=Complex.neg(i)),i};static luDecomposition=t=>{const e=MultiArray.copy(t),{LU:r,piv:s,swaps:i}=LAPACK.getrf_blocked(e.array),n=e.dimension[0],a=e.dimension[1],o=Math.min(n,a),l=LinearAlgebra.eye(Complex.create(n));for(let t=0;t<o;t++)s[t]!==t&&LAPACK.laswp_rows(l.array,l.dimension,t,s[t]);const c=new MultiArray([n,n]),u=new MultiArray([n,a]);for(let t=0;t<n;t++)for(let r=0;r<a;r++)t>r?(c.array[t][r]=e.array[t][r],u.array[t][r]=Complex.zero()):t===r?(c.array[t][r]=Complex.one(),u.array[t][r]=e.array[t][r]):(c.array[t][r]=Complex.zero(),u.array[t][r]=e.array[t][r]);return{L:c,U:u,P:l,swaps:i}};static luSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]}]},outputs:{arity:-3}};static lu=t=>{if(!t||2!==t.dimension.length||t.dimension[0]!==t.dimension[1])throw new Error("PLU decomposition can only be applied to square matrices.");return AST.nodeBoundedReturnList(3,(t,e)=>{if(1===t.length)return t.U;switch(e){case 0:return t.L;case 1:return t.U;case 2:return t.P}},e=>{const{L:r,U:s,P:i}=LinearAlgebra.luDecomposition(t);return{length:e,L:r,U:s,P:i}})};static invSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]}]},outputs:{arity:1}};static inv=t=>{if(!t||2!==t.dimension.length||t.dimension[0]!==t.dimension[1])throw new Error("inv: matrix must be square.");const e=MultiArray.copy(t),{LU:r,piv:s,info:i,swaps:n}=LAPACK.getrf_blocked(e.array);if(0!==i){const e=t.dimension[0],r=new MultiArray([e,e]);for(let t=0;t<e;t++)for(let s=0;s<e;s++)r.array[t][s]=Complex.inf_0();return MultiArray.setType(r),r}{const e=t.dimension[0],i=LAPACK.eye([e,e]),n=LAPACK.getrs(r,s,i),a=new MultiArray([n.length,n[0].length]);return a.array=n,MultiArray.setType(a),a}};static condSignature={inputs:[{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["matrix2d"]}]},{arity:2,parameters:[{name:"matrix",classes:["double"],validators:["matrix2d"]},{name:"normType",alternatives:[{name:"numericNormType",classes:["double"],validators:["numeric","scalar","real"]},{name:"frobeniusNormType",classes:["char","string"],allowedStrings:["fro"]}]}]}],outputs:{arity:1}};static cond=(t,e=Complex.create(2))=>{if(t&&2===t.dimension.length||AST.throwInvalidCallError("cond"),0===t.dimension[0]||0===t.dimension[1])return Complex.zero();if(CharString.isInstanceOf(e))return"fro"!==e.str&&AST.throwInvalidCallError("cond"),LinearAlgebra.squareMatrixNormCondition(t,"fro");const r=Complex.realToNumber(MultiArray.firstElement(e));if(2===r){const e=LinearAlgebra.singularValuesSquared(t);if(0===e.length)return Complex.zero();const r=e[e.length-1],s=e[0];return s<=Math.max(1e-14*r,0)?Complex.inf_0():Complex.create(Math.sqrt(r/s))}if(1===r||r===1/0)return LinearAlgebra.squareMatrixNormCondition(t,r);throw AST.throwInvalidCallError("cond"),new EvalError("Invalid call to cond.")};static rankSignature={inputs:[{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["matrix2d"]}]},{arity:2,parameters:[{name:"matrix",classes:["double"],validators:["matrix2d"]},{name:"tolerance",classes:["double"],validators:["numeric","scalar","real","finite","nonnegative"]}]}],outputs:{arity:1}};static rank=(t,e)=>{t&&2===t.dimension.length||AST.throwInvalidCallError("rank");const r=LinearAlgebra.singularValues(t);if(0===r.length)return Complex.zero();const s=void 0===e?Math.max(t.dimension[0],t.dimension[1])*Number.EPSILON*r[r.length-1]:Complex.realToNumber(e);return(!Number.isFinite(s)||s<0||void 0!==e&&!Complex.imagIsZero(e))&&AST.throwInvalidCallError("rank"),Complex.create(LinearAlgebra.rankByElimination(t,s))};static squareMatrixNormCondition=(t,e)=>(t.dimension[0]!==t.dimension[1]&&AST.throwInvalidCallError("cond"),Complex.mul(LinearAlgebra.matrixNorm(t,e),LinearAlgebra.matrixNorm(LinearAlgebra.inv(t),e)));static matrixNorm=(t,e)=>{if(1===e){let e=0;for(let r=0;r<t.dimension[1];r++){let s=0;for(let e=0;e<t.dimension[0];e++)s+=Complex.realToNumber(Complex.abs(t.array[e][r]));e=Math.max(e,s)}return Complex.create(e)}if(e===1/0){let e=0;for(let r=0;r<t.dimension[0];r++){let s=0;for(let e=0;e<t.dimension[1];e++)s+=Complex.realToNumber(Complex.abs(t.array[r][e]));e=Math.max(e,s)}return Complex.create(e)}let r=Complex.zero();for(const e of MultiArray.linearize(t)){const t=Complex.abs(e);r=Complex.add(r,Complex.mul(t,t))}return Complex.sqrt(r)};static singularValuesSquared=t=>{const e=t.dimension[0],r=t.dimension[1],s=Math.min(e,r);if(0===s)return[];const i=Array.from({length:s},()=>Array.from({length:s},()=>Complex.zero()));if(e>=r)for(let s=0;s<r;s++)for(let n=s;n<r;n++){let r=Complex.zero();for(let i=0;i<e;i++)r=Complex.add(r,Complex.mul(Complex.conj(t.array[i][s]),t.array[i][n]));i[s][n]=r,i[n][s]=s===n?r:Complex.conj(r)}else for(let s=0;s<e;s++)for(let n=s;n<e;n++){let e=Complex.zero();for(let i=0;i<r;i++)e=Complex.add(e,Complex.mul(t.array[s][i],Complex.conj(t.array[n][i])));i[s][n]=e,i[n][s]=s===n?e:Complex.conj(e)}const{D:n}=LAPACK.jacobi_symmetric_hermitian(i,1e3,1e-14);return n.map(t=>Math.max(0,Complex.realToNumber(t))).sort((t,e)=>t-e)};static singularValues=t=>LinearAlgebra.singularValuesSquared(t).map(t=>Math.sqrt(t));static rankByElimination=(t,e)=>{const r=t.array.map(t=>t.map(t=>Complex.create(Complex.realToNumber(t),Complex.imagToNumber(t)))),s=t.dimension[0],i=t.dimension[1];let n=0;for(let t=0;t<i&&n<s;t++){let a=n,o=Complex.realToNumber(Complex.abs(r[a][t]));for(let e=n+1;e<s;e++){const s=Complex.realToNumber(Complex.abs(r[e][t]));s>o&&(o=s,a=e)}if(o<=e)continue;if(a!==n){const t=r[n];r[n]=r[a],r[a]=t}const l=r[n][t];for(let e=n+1;e<s;e++){const s=Complex.rdiv(r[e][t],l);if(!Complex.realIsZero(Complex.abs(s)))for(let a=t;a<i;a++)r[e][a]=Complex.sub(r[e][a],Complex.mul(s,r[n][a]))}n++}return n};static mldivide=(t,e)=>{if(2!==t.dimension.length||2!==e.dimension.length||t.dimension[0]!==t.dimension[1]||t.dimension[0]!==e.dimension[0])throw new EvalError(`operator \\: nonconformant arguments (op1 is ${LinearAlgebra.formatDimensions(t)}, op2 is ${LinearAlgebra.formatDimensions(e)}).`);return LAPACK.mldivide(t,e).X};static mrdivide=(t,e)=>{if(2!==t.dimension.length||2!==e.dimension.length||e.dimension[0]!==e.dimension[1]||t.dimension[1]!==e.dimension[1])throw new EvalError(`operator /: nonconformant arguments (op1 is ${LinearAlgebra.formatDimensions(t)}, op2 is ${LinearAlgebra.formatDimensions(e)}).`);return LinearAlgebra.ctranspose(LinearAlgebra.mldivide(LinearAlgebra.ctranspose(e),LinearAlgebra.ctranspose(t)))};static gaussSignature={inputs:{arity:2,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]},{name:"rightHandSide",classes:["double"]}]},outputs:{arity:1}};static gauss=(t,e)=>{if(t.dimension.length>2||t.dimension[0]!==t.dimension[1])throw new Error("invalid dimensions in function gauss.");const r=MultiArray.copy(t);let s,i,n;for(Math.min(e.dimension[0],e.dimension[1])===e.dimension[1]&&(e=LinearAlgebra.transpose(e)),s=0;s<r.dimension[0];s++)r.array[s].push(e.array[0][s]);const a=r.dimension[0];for(s=0;s<a;s++){let t=Complex.abs(r.array[s][s]),e=s;for(i=s+1;i<a;i++)Complex.realGreaterThan(Complex.abs(r.array[i][s]),t.re)&&(t=Complex.abs(r.array[i][s]),e=i);for(i=s;i<a+1;i++){const t=r.array[e][i];r.array[e][i]=r.array[s][i],r.array[s][i]=t}for(i=s+1;i<a;i++){const t=Complex.rdiv(Complex.neg(r.array[i][s]),r.array[s][s]);for(n=s;n<a+1;n++)r.array[i][n]=s===n?Complex.zero():Complex.add(r.array[i][n],Complex.mul(t,r.array[s][n]))}}const o=new MultiArray([1,a],Complex.zero());for(s=a-1;s>-1;s--)for(o.array[0][s]=Complex.rdiv(r.array[s][a],r.array[s][s]),i=s-1;i>-1;i--)r.array[i][a]=Complex.sub(r.array[i][a],Complex.mul(r.array[i][s],o.array[0][s]));return MultiArray.setType(o),o};static dotSignature={inputs:{arity:-3,min:2,max:3,parameters:[{name:"left",classes:["double"]},{name:"right",classes:["double"]},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static dot=(t,e,r)=>{if(!MultiArray.arrayEquals(t.dimension,e.dimension))throw new Error("dot: A and B must have the same size.");let s;if(s=void 0!==r?MultiArray.testIndex(r,"dot")-1:MultiArray.firstNonSingleDimension(t),s<0||s>=t.dimension.length)throw new Error("dot: dimension argument out of range.");const i=t.dimension,n=i.length,a=i.reduce((t,e)=>t*e,1),o=new Array(n);o[0]=1;for(let t=1;t<n;t++)o[t]=o[t-1]*i[t-1];const l=[...i];l[s]=1;const c=l.reduce((t,e)=>t*e,1),u=new Array(n);u[0]=1;for(let t=1;t<n;t++)u[t]=u[t-1]*l[t-1];const h=new MultiArray(l),d=l.slice(2).reduce((t,e)=>t*e,1),m=l[0]*Math.max(1,d),p=l[1]??1;h.array=new Array(m);for(let t=0;t<m;t++)h.array[t]=new Array(p);const f=i[0]*i[1],g=l[0]*l[1];for(let r=0;r<a;r++){let a=0;for(let t=0;t<n;t++){const e=Math.floor(r/o[t])%i[t];t!==s&&(a+=e*u[t])}const c=Math.floor(r/f),d=r-c*f,m=c*i[0]+d%i[0],p=Math.floor(d/i[0]);if(!t.array[m]||void 0===t.array[m][p])throw new Error(`dot_fast: invalid access to A at physical [${m},${p}] (linIdx=${r}).`);if(!e.array[m]||void 0===e.array[m][p])throw new Error(`dot_fast: invalid access to B at physical [${m},${p}] (linIdx=${r}).`);const y=t.array[m][p],x=e.array[m][p],C=Complex.mul(Complex.conj(y),x),A=Math.floor(a/g),S=a-A*g,E=A*l[0]+S%l[0],_=Math.floor(S/l[0]);void 0===h.array[E][_]||null===h.array[E][_]?h.array[E][_]=Complex.copy(C):h.array[E][_]=Complex.add(h.array[E][_],C)}return MultiArray.setType(h),1===c?h.array[0][0]:h};static crossSignature={inputs:{arity:-3,min:2,max:3,parameters:[{name:"left",classes:["double"]},{name:"right",classes:["double"]},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static dimensionArgumentToNumber=t=>{if("number"==typeof t)return t;if(MultiArray.isInstanceOf(t)){const e=MultiArray.linearize(t);return e.length>0?LinearAlgebra.dimensionArgumentToNumber(e[0]):void 0}return Complex.isInstanceOf(t)?Complex.realToNumber(t):void 0};static cross=(t,e,r)=>{const s=t.dimension.slice(),i=e.dimension.slice();let n;if(void 0!==r){const t=LinearAlgebra.dimensionArgumentToNumber(r);if(void 0===t||!Number.isFinite(t))throw new EvalError(`cross: invalid dimension ${String(r)}.`);const e=Math.floor(t);if(e<1)throw new EvalError(`cross: invalid dimension ${String(r)}.`);n=e-1}const a=Math.max(s.length,i.length,void 0!==n?n+1:0),o=s.slice(),l=i.slice();for(;o.length<a;)o.push(1);for(;l.length<a;)l.push(1);if(void 0===n&&(n=o.findIndex(t=>3===t),-1===n))throw new EvalError("cross: no dimension of length 3 found and dim not specified.");for(let t=0;t<a;t++)if(t!==n&&o[t]!==l[t])throw new EvalError("cross: A and B must have the same size, except along the operation dimension.");const c=o[n]??1,u=l[n]??1;if(3!==c||3!==u)throw new EvalError(`cross: inputs must have length 3 along the operation dimension (got ${c} and ${u}).`);const h=MultiArray.linearize(t),d=MultiArray.linearize(e),m=h.length,p=new Array(m),f=o.slice(0,n).reduce((t,e)=>t*e,1),g=o[n],y=f*g,x=Math.floor(m/y);if(3!==g)throw new EvalError(`cross: internal error, block length along dim ${n+1} must be 3.`);for(let t=0;t<x;t++){const e=t*y;for(let t=0;t<f;t++){const r=e+0*f+t,s=e+1*f+t,i=e+2*f+t;p[r]=Complex.sub(Complex.mul(h[s],d[i]),Complex.mul(h[i],d[s])),p[s]=Complex.sub(Complex.mul(h[i],d[r]),Complex.mul(h[r],d[i])),p[i]=Complex.sub(Complex.mul(h[r],d[s]),Complex.mul(h[s],d[r]))}}const C=new MultiArray(s);1===C.dimension.length&&C.dimension.push(1);for(let t=0;t<h.length;t++){const[e,r]=MultiArray.linearIndexToMultiArrayRowColumn(C.dimension[0],C.dimension[1],t);C.array[e][r]=p[t]??Complex.zero()}return MultiArray.setType(C),C};static kronSignature={inputs:{arity:2,parameters:[{name:"left",classes:["double"],validators:["matrix2d"]},{name:"right",classes:["double"],validators:["matrix2d"]}]},outputs:{arity:1}};static kron=(t,e)=>{const r=MultiArray.scalarToMultiArray(t),s=MultiArray.scalarToMultiArray(e);if(!r||r.dimension.length<2||!s||s.dimension.length<2)throw new Error("kron: inputs must be at least 2-D arrays");const i=r.dimension[0],n=r.dimension[1],a=s.dimension[0],o=s.dimension[1],l=new MultiArray([i*a,n*o]);for(let t=0;t<i;t++)for(let e=0;e<n;e++){const i=r.array[t][e];for(let r=0;r<a;r++)for(let n=0;n<o;n++){const c=s.array[r][n],u=Complex.mul(i,c);l.array[t*a+r][e*o+n]=u}}return MultiArray.setType(l),l};static qrPhaseNormalize=(t,e,r)=>{const s=Math.min(e.dimension[0],e.dimension[1]);for(let i=0;i<s;i++){if(Complex.realIsZero(Complex.abs(e.array[i][i])))continue;const s=Complex.neg(t[i]);for(let t=i;t<e.dimension[1];t++)e.array[i][t]=Complex.rdiv(e.array[i][t],s);if(void 0!==r)for(let t=0;t<r.dimension[0];t++)r.array[t][i]=Complex.mul(r.array[t][i],s)}if(Complex.imagGreaterThan(Complex.abs(e.array[0][0]),LinearAlgebra.settings.qrPhaseEpsilon))throw new Error("Phase normalization error: R(1,1) should be real.");if(Complex.realGreaterThan(e.array[0][0],0)){for(let t=0;t<e.dimension[1];t++)e.array[0][t]=Complex.neg(e.array[0][t]);if(void 0!==r)for(let t=0;t<r.dimension[0];t++)r.array[t][0]=Complex.neg(r.array[t][0])}};static lqPhaseNormalize=(t,e,r)=>{const s=Math.min(e.dimension[0],e.dimension[1]);for(let i=0;i<s;i++){const s=t[i];if(!Complex.realIsZero(Complex.abs(s))){for(let t=i;t<e.dimension[1];t++)e.array[i][t]=Complex.mul(e.array[i][t],s);if(r){const t=Complex.conj(s);for(let e=0;e<r.dimension[0];e++)r.array[e][i]=Complex.mul(r.array[e][i],t)}}}};static qrDecomposition=(t,e)=>{switch(e){case 1:{const{R:e,phis:r}=LAPACK.geqr2(t);return MultiArray.haveAnyComplex(e)&&LinearAlgebra.qrPhaseNormalize(r,e),{R:e}}case 2:{const{R:e,taus:r,phis:s}=LAPACK.geqr2(t),i=LAPACK.orgqr(e,r);return LAPACK.triu_inplace(e),MultiArray.haveAnyComplex(e)&&LinearAlgebra.qrPhaseNormalize(s,e,i),{Q:i,R:e}}case 3:{const{R:e,taus:r,phis:s,jpvt:i}=LAPACK.geqp3(t),n=LAPACK.orgqr(e,r);LAPACK.triu_inplace(e);const a=LAPACK.lapmt_matrix(i);return MultiArray.haveAnyComplex(e)&&LinearAlgebra.qrPhaseNormalize(s,e,n),{Q:n,R:e,P:a}}}};static qrSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["matrix2d"]}]},outputs:{arity:-3}};static qr=t=>{if(!t||2!==t.dimension.length)throw new Error("QR decomposition can only be applied to 2D matrices.");return AST.nodeBoundedReturnList(3,(t,e)=>{if(1===t.length){if(0===e)return t.R}else if(2===t.length){if(0===e)return t.Q;if(1===e)return t.R}else if(3===t.length){if(0===e)return t.Q;if(1===e)return t.R;if(2===e)return t.P}},e=>{if(1===e){const{R:r}=LinearAlgebra.qrDecomposition(t,1);return{length:e,R:r}}if(2===e){const{Q:r,R:s}=LinearAlgebra.qrDecomposition(t,2);return{length:e,R:s,Q:r}}{const{Q:r,R:s,P:i}=LinearAlgebra.qrDecomposition(t,3);return{length:e,R:s,Q:r,P:i}}})};static eigDecomposition_original=(t,e,r=32,s="asc")=>{if(!t||!t.dimension||2!==t.dimension.length)throw new Error("eigDecomposition: A must be a 2D MultiArray");const i=t.dimension[0];if(i!==t.dimension[1])throw new Error("eigDecomposition: A must be square");const n=MultiArray.copy(t),{diag:a,offdiag:o,taus:l}=LAPACK.sytrd_blocked_w(n,r);if(!Array.isArray(a)||!Array.isArray(o))throw new Error("eigDecomposition: sytrd_blocked_w did not return diag/offdiag arrays");if(1===e){const t=MultiArray.toColumnVector(LAPACK.steqr_values(a,o));if(!t||!t.array||t.dimension[0]!==i)throw new Error("eigDecomposition: steqr_values returned invalid MultiArray");if("none"===s)return MultiArray.setType(t),{values:t};const e=new Array(i);for(let r=0;r<i;r++)e[r]=t.array[r][0];const r=Array.from({length:i},(t,e)=>e).sort((t,r)=>{const i=Complex.realToNumber(e[t]),n=Complex.realToNumber(e[r]);return"asc"===s?i-n:n-i}).map(t=>e[t]),n=MultiArray.toColumnVector(r);return MultiArray.setType(n),{values:n}}{const t=LAPACK.steqr_vectors(a,o);if(!t||!t.D||!t.V)throw new Error("eigDecomposition: steqr_vectors returned invalid result");const c=MultiArray.toDiagonalMatrix(t.D),u=new MultiArray([t.V.length,t.V[0].length]);if(u.array=t.V,c.dimension[0]!==i)throw new Error("eigDecomposition: steqr_vectors returned D of unexpected size");if(u.dimension[0]!==i||u.dimension[1]!==i)throw new Error("eigDecomposition: steqr_vectors returned V of unexpected shape");const h=LAPACK.orgtr_blocked_w(n,l,r),d=new MultiArray([i,i]);for(let t=0;t<i;t++)for(let e=0;e<i;e++)d.array[t][e]=Complex.zero();BLAS.gemm_block(h.array,u.array,d.array,Complex.one(),Complex.zero(),r),MultiArray.setType(d);const m=new Array(i);for(let t=0;t<i;t++)m[t]=c.array[t][0];const p="none"===s?Array.from({length:i},(t,e)=>e):Array.from({length:i},(t,e)=>e).sort((t,e)=>{const r=Complex.realToNumber(m[t]),i=Complex.realToNumber(m[e]);return"asc"===s?r-i:i-r}),f=p.map(t=>m[t]),g=MultiArray.toColumnVector(f),y=new MultiArray([i,i]);for(let t=0;t<i;t++){const e=p[t];for(let r=0;r<i;r++)y.array[r][t]=d.array[r][e]}if(MultiArray.setType(g),MultiArray.setType(y),2===e)return{values:g,vectors:y};{const t=new MultiArray([i,i]);for(let e=0;e<i;e++)for(let r=0;r<i;r++)t.array[e][r]=Complex.zero();for(let e=0;e<i;e++)t.array[e][e]=a[e],e<i-1&&(t.array[e][e+1]=o[e],t.array[e+1][e]=Complex.conj(o[e]));return MultiArray.setType(t),{values:g,vectors:y,T:t}}}};static eigDecomposition=(t,e,r="asc",s)=>{const i=t.dimension[0],n=MultiArray.copy(t),{diag:a,offdiag:o,taus:l}=LAPACK.sytrd(n,LAPACK.larf_left);if(1===e){const{D:t}=LAPACK.steqr_vectors(a,o,1e4),e=Array.from({length:i},(t,e)=>e).sort((e,s)=>{const i=Complex.realToNumber(t[e]),n=Complex.realToNumber(t[s]);return"asc"===r?i-n:n-i}).map(e=>t[e]),s=MultiArray.toColumnVector(e);return MultiArray.setType(s),{values:s}}{const{D:t,V:e}=LAPACK.steqr_vectors_tridiagonal(a,o,1e4),r=new MultiArray([e.length,e[0].length]);return r.array=e,{values:MultiArray.toDiagonalMatrix(t),vectors:r}}};static eigSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]}]},outputs:{arity:-3}};static eig=t=>AST.nodeBoundedReturnList(3,(t,e)=>{if(1===t.length){if(0===e)return t.values}else if(2===t.length){if(0===e)return t.vectors;if(1===e)return t.values}else if(3===t.length){if(0===e)return t.vectors;if(1===e)return t.values;if(2===e)return t.T}},e=>{if(1===e){const{D:r}=LAPACK.eig_hermitian(t);return{length:e,values:r}}if(2===e){const{D:r,V:s}=LAPACK.eig_hermitian(t,!0);return{length:e,values:r,vectors:s}}{const{values:r,vectors:s,T:i}=LinearAlgebra.eigDecomposition(t,3);return{length:e,values:r,vectors:s,T:i}}});static testSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]}]},outputs:{arity:-3}};static test(t){return AST.nodeBoundedReturnList(3,(t,e)=>{if(1===t.length){if(0===e)return Complex.zero()}else if(2===t.length){if(0===e)return Complex.zero();if(1===e)return Complex.one()}else if(3===t.length){if(0===e)return Complex.zero();if(1===e)return Complex.one();if(2===e)return Complex.two()}},t=>({length:t}))}static functions={eye:{func:LinearAlgebra.eye,signature:LinearAlgebra.eyeSignature},transpose:{func:LinearAlgebra.transpose,signature:LinearAlgebra.transposeSignature},ctranspose:{func:LinearAlgebra.ctranspose,signature:LinearAlgebra.ctransposeSignature},diag:{func:LinearAlgebra.diag,signature:LinearAlgebra.diagSignature},trace:{func:LinearAlgebra.trace,signature:LinearAlgebra.traceSignature},det:{func:LinearAlgebra.det,signature:LinearAlgebra.detSignature},inv:{func:LinearAlgebra.inv,signature:LinearAlgebra.invSignature},cond:{func:LinearAlgebra.cond,signature:LinearAlgebra.condSignature},rank:{func:LinearAlgebra.rank,signature:LinearAlgebra.rankSignature},gauss:{func:LinearAlgebra.gauss,signature:LinearAlgebra.gaussSignature},lu:{func:LinearAlgebra.lu,signature:LinearAlgebra.luSignature},dot:{func:LinearAlgebra.dot,signature:LinearAlgebra.dotSignature},cross:{func:LinearAlgebra.cross,signature:LinearAlgebra.crossSignature},kron:{func:LinearAlgebra.kron,signature:LinearAlgebra.kronSignature},qr:{func:LinearAlgebra.qr,signature:LinearAlgebra.qrSignature},eig:{func:LinearAlgebra.eig,signature:LinearAlgebra.eigSignature},test:{func:LinearAlgebra.test,signature:LinearAlgebra.testSignature}}}const src_LinearAlgebra=null;class MathOperation{static elementWiseOperatorSymbols={add:"+",sub:"-",mod:"mod",rem:"rem",mul:".*",rdiv:"./",ldiv:".\\",power:".^",lt:"<",le:"<=",eq:"==",ge:">=",gt:">",ne:"~=",and:"&",or:"|",xor:"xor",minWise:"min",maxWise:"max"};static unaryOperatorSymbols={copy:"+",neg:"-",not:"~"};static copy=t=>RuntimeValue.copy(t);static elementWiseOperation=(t,e,r)=>{if(CharString.isInstanceOf(e)&&(e=MultiArray.fromCharString(e)),CharString.isInstanceOf(r)&&(r=MultiArray.fromCharString(r)),MathOperation.throwIfStructureBinaryOperand(MathOperation.elementWiseOperatorSymbols[t],e,r),MathOperation.throwIfCellBinaryOperand(MathOperation.elementWiseOperatorSymbols[t],e,r),("lt"===t||"le"===t||"eq"===t||"ge"===t||"gt"===t||"ne"===t)&&(MathOperation.hasClassInstanceOperand(e)||MathOperation.hasClassInstanceOperand(r)))return MathOperation.classInstanceRelationalOperation(t,e,r);if(Complex.isInstanceOf(e)&&Complex.isInstanceOf(r))return Complex[t](e,r);if(Complex.isInstanceOf(e)&&MultiArray.isInstanceOf(r))return MultiArray.scalarOpMultiArray(t,e,r);if(MultiArray.isInstanceOf(e)&&Complex.isInstanceOf(r))return MultiArray.MultiArrayOpScalar(t,e,r);if(MultiArray.isInstanceOf(e)&&MultiArray.isInstanceOf(r))return MultiArray.elementWiseOperation(t,e,r);throw new EvalError(`operator ${MathOperation.elementWiseOperatorSymbols[t]} is not defined for these operands.`)};static hasStructureOperand=t=>Structure.isInstanceOf(t)||MultiArray.isInstanceOf(t)&&Structure.isStructure(t);static hasCellOperand=t=>MultiArray.isInstanceOf(t)&&t.isCell;static throwIfCellBinaryOperand=(t,e,r)=>{if(MathOperation.hasCellOperand(e)||MathOperation.hasCellOperand(r))throw new EvalError(`operator ${t} is not defined for cell operands.`)};static throwIfStructureBinaryOperand=(t,e,r)=>{if(MathOperation.hasStructureOperand(e)||MathOperation.hasStructureOperand(r))throw new EvalError(`operator ${t} is not defined for struct operands.`)};static throwIfCellUnaryOperand=(t,e)=>{if(MathOperation.hasCellOperand(e))throw new EvalError(`operator ${t} is not defined for cell operands.`)};static throwIfStructureUnaryOperand=(t,e)=>{if(MathOperation.hasStructureOperand(e))throw new EvalError(`operator ${t} is not defined for struct operands.`)};static hasClassInstanceOperand=t=>ClassInstance.isInstanceOf(t)||MultiArray.isInstanceOf(t)&&MultiArray.linearize(t).some(t=>ClassInstance.isInstanceOf(t));static handleComparisonOrder=new WeakMap;static nextHandleComparisonOrder=1;static handleOrder=t=>{let e=MathOperation.handleComparisonOrder.get(t);return void 0===e&&(e=MathOperation.nextHandleComparisonOrder++,MathOperation.handleComparisonOrder.set(t,e)),e};static numericScalarValue=t=>{if(Complex.isInstanceOf(t))return t;if(MultiArray.isInstanceOf(t)&&RuntimeValue.isScalar(t)){const e=MultiArray.firstElement(t);return Complex.isInstanceOf(e)?e:void 0}};static classInstanceRelationalOperation=(t,e,r)=>{const s=(e,r)=>{const s=ClassInstance.isInstanceOf(e),i=ClassInstance.isInstanceOf(r);if(!s||!i)return Complex.false();if(!e.classDefinition.isHandleClass()||!r.classDefinition.isHandleClass())throw new EvalError(`binary operator '${t}' is not defined for value class operands.`);if(e.classDefinition.name!==r.classDefinition.name)return Complex.false();const n=MathOperation.handleOrder(e),a=MathOperation.handleOrder(r);return("lt"===t?n<a:"le"===t?n<=a:"eq"===t?e===r:"ge"===t?n>=a:"gt"===t?n>a:e!==r)?Complex.true():Complex.false()},i=MultiArray.scalarToMultiArray(e),n=MultiArray.scalarToMultiArray(r),a=i.dimension.slice(),o=n.dimension.slice(),l=Math.max(a.length,o.length);for(;a.length<l;)a.push(1);for(;o.length<l;)o.push(1);const c=new Array(l),u=new Array(l),h=new Array(l);for(let e=0;e<l;e++)if(a[e]===o[e])c[e]=a[e],u[e]=h[e]=!1;else if(1===a[e])c[e]=o[e],u[e]=!0,h[e]=!1;else{if(1!==o[e])throw new EvalError(`operator ${t}: nonconformant arguments (op1 is ${a.join("x")}, op2 is ${o.join("x")}).`);c[e]=a[e],u[e]=!1,h[e]=!0}const d=MultiArray.computeStrides(a),m=MultiArray.computeStrides(o),p=MultiArray.computeStrides(c),f=new MultiArray(c),g=c.reduce((t,e)=>t*e,1);for(let t=0;t<g;t++){let e=0,r=0;for(let s=0;s<l;s++){const i=Math.floor(t/p[s])%c[s];e+=(u[s]?0:i)*d[s],r+=(h[s]?0:i)*m[s]}const[g,y]=MultiArray.linearIndexToMultiArrayRowColumn(a[0],a[1],e),[x,C]=MultiArray.linearIndexToMultiArrayRowColumn(o[0],o[1],r),[A,S]=MultiArray.linearIndexToMultiArrayRowColumn(c[0],c[1],t);f.array[A][S]=s(i.array[g][y],n.array[x][C])}return f.type=Complex.LOGICAL,MultiArray.MultiArrayToScalar(f)};static leftOperation=(t,e)=>{if(CharString.isInstanceOf(e)&&(e=MultiArray.fromCharString(e)),MathOperation.throwIfStructureUnaryOperand(MathOperation.unaryOperatorSymbols[t],e),MathOperation.throwIfCellUnaryOperand(MathOperation.unaryOperatorSymbols[t],e),Complex.isInstanceOf(e))return Complex[t](e);if(MultiArray.isInstanceOf(e))return MultiArray.leftOperation(t,e);throw new EvalError(`operator ${MathOperation.unaryOperatorSymbols[t]} is not defined for this operand.`)};static plus=(t,e)=>MathOperation.elementWiseOperation("add",t,e);static minus=(t,e)=>MathOperation.elementWiseOperation("sub",t,e);static mod=(t,e)=>MathOperation.elementWiseOperation("mod",t,e);static rem=(t,e)=>MathOperation.elementWiseOperation("rem",t,e);static times=(t,e)=>MathOperation.elementWiseOperation("mul",t,e);static mtimes=(t,e)=>(CharString.isInstanceOf(t)&&(t=MultiArray.fromCharString(t)),CharString.isInstanceOf(e)&&(e=MultiArray.fromCharString(e)),MathOperation.throwIfStructureBinaryOperand("*",t,e),Complex.isInstanceOf(t)&&Complex.isInstanceOf(e)?Complex.mul(t,e):Complex.isInstanceOf(t)&&MultiArray.isInstanceOf(e)?MultiArray.scalarOpMultiArray("mul",t,e):MultiArray.isInstanceOf(t)&&Complex.isInstanceOf(e)?MultiArray.MultiArrayOpScalar("mul",t,e):LinearAlgebra.mul(t,e));static rdivide=(t,e)=>MathOperation.elementWiseOperation("rdiv",t,e);static mrdivide=(t,e)=>(CharString.isInstanceOf(t)&&(t=MultiArray.fromCharString(t)),CharString.isInstanceOf(e)&&(e=MultiArray.fromCharString(e)),MathOperation.throwIfStructureBinaryOperand("/",t,e),Complex.isInstanceOf(t)&&Complex.isInstanceOf(e)?Complex.rdiv(t,e):Complex.isInstanceOf(t)&&MultiArray.isInstanceOf(e)?MultiArray.scalarOpMultiArray("mul",t,LinearAlgebra.inv(e)):MultiArray.isInstanceOf(t)&&Complex.isInstanceOf(e)?MultiArray.scalarOpMultiArray("mul",Complex.inv(e),t):LinearAlgebra.mrdivide(t,e));static ldivide=(t,e)=>MathOperation.elementWiseOperation("ldiv",t,e);static mldivide=(t,e)=>{if(CharString.isInstanceOf(t)&&(t=MultiArray.fromCharString(t)),CharString.isInstanceOf(e)&&(e=MultiArray.fromCharString(e)),MathOperation.throwIfStructureBinaryOperand("\\",t,e),Complex.isInstanceOf(t)&&Complex.isInstanceOf(e))return Complex.ldiv(t,e);if(Complex.isInstanceOf(t)&&MultiArray.isInstanceOf(e))return MultiArray.scalarOpMultiArray("ldiv",t,e);if(MultiArray.isInstanceOf(t)&&Complex.isInstanceOf(e))throw new EvalError(`operator \\: nonconformant arguments (op1 is ${t.dimension.join("x")}, op2 is 1x1).`);return LinearAlgebra.mldivide(t,e)};static power=(t,e)=>MathOperation.elementWiseOperation("power",t,e);static mpower=(t,e)=>{CharString.isInstanceOf(t)&&(t=MultiArray.fromCharString(t)),CharString.isInstanceOf(e)&&(e=MultiArray.fromCharString(e)),MathOperation.throwIfStructureBinaryOperand("^",t,e);const r=MathOperation.numericScalarValue(t),s=MathOperation.numericScalarValue(e);if(r&&s)return Complex.power(r,s);if(MultiArray.isInstanceOf(t)&&s)return LinearAlgebra.power(t,s);if(r&&MultiArray.isInstanceOf(e))return LinearAlgebra.scalarPower(r,e);throw new Error("invalid exponent in '^'.")};static uplus=t=>MathOperation.leftOperation("copy",t);static uminus=t=>MathOperation.leftOperation("neg",t);static transpose=t=>(CharString.isInstanceOf(t)&&(t=MultiArray.characterVectorFromCharString(t)),MultiArray.isInstanceOf(t)?LinearAlgebra.transpose(t):RuntimeValue.copy(t));static ctranspose=t=>(CharString.isInstanceOf(t)&&(t=MultiArray.characterVectorFromCharString(t)),Complex.isInstanceOf(t)?Complex.conj(t):MultiArray.isInstanceOf(t)?LinearAlgebra.ctranspose(t):RuntimeValue.copy(t));static lt=(t,e)=>MathOperation.elementWiseOperation("lt",t,e);static le=(t,e)=>MathOperation.elementWiseOperation("le",t,e);static eq=(t,e)=>MathOperation.elementWiseOperation("eq",t,e);static ge=(t,e)=>MathOperation.elementWiseOperation("ge",t,e);static gt=(t,e)=>MathOperation.elementWiseOperation("gt",t,e);static ne=(t,e)=>MathOperation.elementWiseOperation("ne",t,e);static mand=(t,e)=>(CharString.isInstanceOf(t)&&(t=MultiArray.fromCharString(t)),CharString.isInstanceOf(e)&&(e=MultiArray.fromCharString(e)),Complex.isInstanceOf(t)&&Complex.isInstanceOf(e)?Complex.and(t,e):Complex.isInstanceOf(t)&&MultiArray.isInstanceOf(e)?Complex.and(t,MultiArray.toLogical(e)):MultiArray.isInstanceOf(t)&&Complex.isInstanceOf(e)?Complex.and(MultiArray.toLogical(t),e):Complex.and(MultiArray.toLogical(t),MultiArray.toLogical(e)));static mor=(t,e)=>(CharString.isInstanceOf(t)&&(t=MultiArray.fromCharString(t)),CharString.isInstanceOf(e)&&(e=MultiArray.fromCharString(e)),Complex.isInstanceOf(t)&&Complex.isInstanceOf(e)?Complex.or(t,e):Complex.isInstanceOf(t)&&MultiArray.isInstanceOf(e)?Complex.or(t,MultiArray.toLogical(e)):MultiArray.isInstanceOf(t)&&Complex.isInstanceOf(e)?Complex.or(MultiArray.toLogical(t),e):Complex.or(MultiArray.toLogical(t),MultiArray.toLogical(e)));static not=t=>{if(CharString.isInstanceOf(t)&&(t=MultiArray.fromCharString(t)),MathOperation.throwIfStructureUnaryOperand(MathOperation.unaryOperatorSymbols.not,t),MathOperation.throwIfCellUnaryOperand(MathOperation.unaryOperatorSymbols.not,t),Complex.isInstanceOf(t))return Complex.not(t);if(MultiArray.isInstanceOf(t))return MultiArray.leftOperation("not",t);throw new EvalError(`operator ${MathOperation.unaryOperatorSymbols.not} is not defined for this operand.`)};static and=(t,e)=>MathOperation.elementWiseOperation("and",t,e);static or=(t,e)=>MathOperation.elementWiseOperation("or",t,e);static xor=(t,e)=>MathOperation.elementWiseOperation("xor",t,e);static unaryOperations={uplus:MathOperation.uplus,uminus:MathOperation.uminus,not:MathOperation.not,transpose:MathOperation.transpose,ctranspose:MathOperation.ctranspose};static binaryOperations={minus:MathOperation.minus,mod:MathOperation.mod,rem:MathOperation.rem,rdivide:MathOperation.rdivide,mrdivide:MathOperation.mrdivide,ldivide:MathOperation.ldivide,mldivide:MathOperation.mldivide,power:MathOperation.power,mpower:MathOperation.mpower,lt:MathOperation.lt,le:MathOperation.le,ge:MathOperation.ge,gt:MathOperation.gt,eq:MathOperation.eq,ne:MathOperation.ne};static leftAssociativeMultipleOperations={plus:MathOperation.plus,times:MathOperation.times,mtimes:MathOperation.mtimes,and:MathOperation.and,or:MathOperation.or,xor:MathOperation.xor}}const src_MathOperation=null;class FunctionValidation{static matlabNameLengthMax=2048;static reservedKeywords=new Set(["global","persistent","import","if","endif","end","elseif","else","switch","endswitch","case","otherwise","while","endwhile","do","until","for","endfor","parfor","endparfor","spmd","endspmd","break","continue","return","function","endfunction","try","catch","end_try_catch","unwind_protect","unwind_protect_cleanup","end_unwind_protect","classdef","endclassdef","enumeration","endenumeration","properties","endproperties","events","endevents","methods","endmethods","arguments","endarguments"]);static className(t){if(Complex.isInstanceOf(t))return t.type===Complex.LOGICAL?"logical":"double";if(CharString.isInstanceOf(t))return CharString.isChar(t)?"char":"string";if(FunctionHandle.isInstanceOf(t))return"function_handle";if(ClassEventListener.isInstanceOf(t))return t.kind;if(ClassPropertyEvent.isInstanceOf(t))return"event.PropertyEvent";if(ClassEventData.isInstanceOf(t))return"event.EventData";if(ClassMetaObject.isInstanceOf(t))return t.kind;if(ClassInstance.isInstanceOf(t))return t.classDefinition.name;if(ClassEnumerationValue.isInstanceOf(t))return t.classDefinition.name;if(Structure.isStructure(t))return"struct";if(MultiArray.isInstanceOf(t)){if(t.isCell)return"cell";const e=MultiArray.linearize(t);return e.every(t=>Complex.isInstanceOf(t))?e.length>0&&e.every(t=>t.type===Complex.LOGICAL)?"logical":"double":e.length>0&&e.every(CharString.isChar)?"char":e.length>0&&e.every(CharString.isString)?"string":"array"}return"unknown"}static underlyingType(t){return this.className(t)}static numericElements(t,e={}){const r=t=>Complex.isInstanceOf(t)&&(e.includeLogical||t.type!==Complex.LOGICAL);if(Complex.isInstanceOf(t))return r(t)?[t]:void 0;if(MultiArray.isInstanceOf(t)&&!t.isCell){const e=MultiArray.linearize(t);return e.every(r)?e:void 0}}static isLogicalValue(t){const e=this.numericElements(t,{includeLogical:!0});return Boolean(e&&e.length>0&&e.every(t=>t.type===Complex.LOGICAL))}static isCharArray(t){if(CharString.isChar(t))return!0;if(!MultiArray.isInstanceOf(t)||t.isCell)return!1;const e=MultiArray.linearize(t);return e.length>0&&e.every(CharString.isChar)}static isStringArray(t){if(CharString.isString(t))return!0;if(!MultiArray.isInstanceOf(t)||t.isCell)return!1;const e=MultiArray.linearize(t);return e.length>0&&e.every(CharString.isString)}static isCellStringArray(t){if(!MultiArray.isInstanceOf(t)||!t.isCell)return!1;const e=MultiArray.linearize(t);return e.length>0&&e.every(CharString.isChar)}static isTextValue(t){return this.isCharArray(t)||this.isStringArray(t)||this.isCellStringArray(t)}static isTextScalarValue(t){if(CharString.isInstanceOf(t))return!0;if(!MultiArray.isInstanceOf(t)||t.isCell||1!==RuntimeValue.elementCount(t))return!1;const e=MultiArray.firstElement(t);return CharString.isString(e)}static textElements(t){if(CharString.isInstanceOf(t))return[t.str];if(MultiArray.isInstanceOf(t)){const e=MultiArray.linearize(t);return e.length>0&&e.every(CharString.isInstanceOf)?e.map(t=>t.str):void 0}}static variableNameElements(t){if(CharString.isInstanceOf(t))return[t.str];if(!MultiArray.isInstanceOf(t)||!t.isCell)return;const e=MultiArray.linearize(t);return e.length>0&&e.every(CharString.isChar)?e.map(t=>t.str):void 0}static isValidVariableNameText(t){return/^[A-Za-z]\w*$/.test(t)&&t.length<=this.matlabNameLengthMax&&!this.reservedKeywords.has(t)}static matchesClass(t,e){switch(e){case"double":case"single":return Boolean(this.numericElements(t));case"logical":return this.isLogicalValue(t);case"char":return this.isCharArray(t);case"string":return this.isStringArray(t);case"cell":return MultiArray.isInstanceOf(t)&&t.isCell;case"array":return MultiArray.isInstanceOf(t);case"struct":return Structure.isStructure(t);case"function_handle":return FunctionHandle.isInstanceOf(t);default:return!1}}static normalizeValidators(t=[]){const e=new Set(t),r=(...t)=>{for(const r of t)e.delete(r)};return e.has("dimensionGreaterThanOne")&&r("numeric","scalar","real","finite","integer","positive","nonnegative","dimension"),e.has("dimension")&&r("numeric","scalar","real","finite","integer","nonnegative"),e.has("dimensionVector")&&r("numeric","vector","real","finite","integer","nonnegative"),e.has("reshapeDimension")&&r("numeric","scalar","scalarOrEmpty","real","finite","integer","nonnegative"),e.has("reshapeDimensionVector")&&r("numeric","vector","real","finite","integer","nonnegative"),e.has("positive")&&r("nonnegative"),e.has("negative")&&r("nonpositive"),e.has("zeroOrOne")&&r("nonnegative"),e.has("textScalar")&&r("text","scalar","scalarOrEmpty","scalarOrVector"),e.has("squareMatrix")&&r("matrix2d"),e.has("scalar")&&r("scalarOrEmpty","scalarOrVector"),[...e]}static isDimensionValue(t,e){if(RuntimeValue.isEmpty(t))return e;const r=this.numericElements(t);return Boolean(r&&r.every(t=>Complex.imagIsZero(t)&&Complex.realIsFinite(t)&&Complex.realIsInteger(t)&&Complex.realGreaterThanOrEqualTo(t,0)))}static isDimensionVector(t,e){if(!RuntimeValue.isVector(t))return!1;const r=MultiArray.linearize(t),s=r.map(optionalRuntimeExpressionValue);return r.length>0&&s.every(t=>void 0!==t)&&s.every(t=>this.isDimensionValue(t,e))}static matchesParameter(t,e){return!(e.classes&&e.classes.length>0&&!e.classes.some(e=>this.matchesClass(t,e)))&&!(e.allowedStrings&&e.allowedStrings.length>0&&(!CharString.isInstanceOf(t)||!e.allowedStrings.includes(t.str)))&&!!(!e.identifier||CharString.isInstanceOf(t)&&this.isValidVariableNameText(t.str))&&this.normalizeValidators(e.validators).every(r=>this.matchesBuiltInValidator(t,r,e.allowInfinity))}static matchesBuiltInParameterBase(t,e){const r=this.normalizeValidators(e.validators),s=new Set(["dimension","dimensionGreaterThanOne","dimensionVector","reshapeDimension","reshapeDimensionVector"]),i={...e,validators:r.filter(t=>!s.has(t))};return!!this.matchesParameter(t,i)&&r.every(e=>{switch(e){case"dimension":return RuntimeValue.isScalar(t)&&this.isDimensionValue(t,!1);case"dimensionGreaterThanOne":return RuntimeValue.isScalar(t)&&this.isDimensionValue(t,!1)&&Complex.realGreaterThan(MultiArray.firstElement(t),1);case"dimensionVector":return this.isDimensionVector(t,!1);case"reshapeDimension":return(RuntimeValue.isScalar(t)||RuntimeValue.isEmpty(t))&&this.isDimensionValue(t,!0);case"reshapeDimensionVector":return this.isDimensionVector(t,!0);default:return!0}})}static matchesBuiltInParameter(t,e){const r=e.alternatives??[];return(Boolean(e.classes?.length||e.validators?.length||e.allowedStrings?.length||e.identifier)||0===r.length)&&this.matchesBuiltInParameterBase(t,e)||r.some(e=>this.matchesBuiltInParameter(t,e))}static argumentsMatchBuiltInParameters(t,e){if(!e)return!0;for(let r=0;r<t.length;r++){const s=e[Math.min(r,e.length-1)];if(!s||r>=e.length&&!s.variadic)continue;const i=s.variadic&&s.variadicGroup&&s.variadicGroup.length>0?s.variadicGroup[(r-Math.min(r,e.length-1))%s.variadicGroup.length]:s;if(!this.matchesBuiltInParameter(t[r],i))return!1}return!0}static matchesBuiltInValidator(t,e,r=!1){const s=this.numericElements(t),i=()=>this.numericElements(t,{includeLogical:!0}),n=t=>Boolean(r&&Complex.imagIsZero(t)&&Complex.realToNumber(t)===1/0);switch(e){case"numeric":case"float":return Boolean(s);case"numericOrLogical":return Boolean(this.numericElements(t,{includeLogical:!0}));case"text":return this.isTextValue(t);case"textScalar":return this.isTextScalarValue(t);case"nonzeroLengthText":{const e=this.textElements(t);return Boolean(e&&e.length>0&&e.every(t=>t.length>0))}case"validVariableName":{const e=this.variableNameElements(t);return Boolean(e&&e.length>0&&e.every(t=>this.isValidVariableNameText(t)))}case"scalar":return RuntimeValue.isScalar(t);case"scalarOrEmpty":return RuntimeValue.isScalar(t)||RuntimeValue.isEmpty(t);case"scalarOrVector":return RuntimeValue.isScalar(t)||RuntimeValue.isVector(t);case"empty":return RuntimeValue.isEmpty(t);case"matrix2d":return RuntimeValue.isMatrix(t);case"squareMatrix":return RuntimeValue.isSquareMatrix(t);case"vector":return RuntimeValue.isVector(t);case"rowVector":return RuntimeValue.isRowVector(t);case"columnVector":return RuntimeValue.isColumnVector(t);case"twoElement":return 2===RuntimeValue.elementCount(t);case"oneOrTwoElement":{const e=RuntimeValue.elementCount(t);return 1===e||2===e}case"nonempty":return!RuntimeValue.isEmpty(t);case"positive":return Boolean(i()?.every(t=>n(t)||Complex.imagIsZero(t)&&Complex.realGreaterThan(t,0)));case"nonnegative":return Boolean(i()?.every(t=>n(t)||Complex.imagIsZero(t)&&Complex.realGreaterThanOrEqualTo(t,0)));case"negative":return Boolean(i()?.every(t=>Complex.imagIsZero(t)&&Complex.realLessThan(t,0)));case"nonpositive":return Boolean(i()?.every(t=>Complex.imagIsZero(t)&&Complex.realLessThanOrEqualTo(t,0)));case"nonzero":return Boolean(i()?.every(t=>0!==Complex.realToNumber(t)||0!==Complex.imagToNumber(t)));case"nonnan":return!!CharString.isInstanceOf(t)||Boolean(i()?.every(t=>!Complex.realIsNaN(t)&&!Complex.imagIsNaN(t)));case"nonmissing":{const e=i();if(e)return e.every(t=>!Complex.realIsNaN(t)&&!Complex.imagIsNaN(t));if(CharString.isInstanceOf(t))return!0;if(MultiArray.isInstanceOf(t)){const e=MultiArray.linearize(t);return t.isCell?e.every(t=>!CharString.isChar(t)||t.str.length>0):e.length>0&&e.every(CharString.isInstanceOf)}return!0}case"nonsparse":return!0;case"sparse":default:return!1;case"zeroOrOne":return Boolean(i()?.every(t=>Complex.imagIsZero(t)&&(0===Complex.realToNumber(t)||1===Complex.realToNumber(t))));case"integer":return Boolean(i()?.every(t=>n(t)||Complex.imagIsZero(t)&&Complex.realIsInteger(t)));case"finite":return Boolean(i()?.every(t=>Complex.realIsFinite(t)&&Complex.imagIsFinite(t)));case"real":return Boolean(i()?.every(t=>Complex.imagIsZero(t)))}}static builtInValidatorForArgumentValidator(t){switch(t){case"mustBeNumeric":return"numeric";case"mustBeFloat":return"float";case"mustBeNumericOrLogical":return"numericOrLogical";case"mustBeText":return"text";case"mustBeTextScalar":return"textScalar";case"mustBeNonzeroLengthText":return"nonzeroLengthText";case"mustBeValidVariableName":return"validVariableName";case"mustBeScalarOrEmpty":return"scalarOrEmpty";case"mustBeScalar":return"scalar";case"mustBeMatrix":return"matrix2d";case"mustBeSquare":return"squareMatrix";case"mustBeVector":return"vector";case"mustBeRow":return"rowVector";case"mustBeColumn":return"columnVector";case"mustBeNonempty":return"nonempty";case"mustBePositive":return"positive";case"mustBeNonnegative":return"nonnegative";case"mustBeNegative":return"negative";case"mustBeNonpositive":return"nonpositive";case"mustBeNonzero":return"nonzero";case"mustBeNonNan":return"nonnan";case"mustBeNonmissing":return"nonmissing";case"mustBeNonsparse":return"nonsparse";case"mustBeSparse":return"sparse";case"mustBeInteger":return"integer";case"mustBeFinite":return"finite";case"mustBeReal":return"real";default:return}}}const src_FunctionValidation=null;class RuntimeEquality{static isObject=t=>!!t&&"object"==typeof t;static isComplexLike=t=>RuntimeEquality.isObject(t)&&Object.prototype.hasOwnProperty.call(t,"re")&&Object.prototype.hasOwnProperty.call(t,"im");static isCharStringLike=t=>RuntimeEquality.isObject(t)&&"string"==typeof t.str;static isArrayLike=t=>RuntimeEquality.isObject(t)&&Array.isArray(t.dimension)&&Array.isArray(t.array)&&"boolean"==typeof t.isCell;static isStructureLike=t=>RuntimeEquality.isObject(t)&&RuntimeEquality.isObject(t.field);static isFunctionHandleLike=t=>RuntimeEquality.isObject(t)&&5===t.type;static isClassInstanceLike=t=>RuntimeEquality.isObject(t)&&7===t.type&&RuntimeEquality.isObject(t.classDefinition)&&RuntimeEquality.isObject(t.properties);static isClassEnumerationValueLike=t=>RuntimeEquality.isObject(t)&&10===t.type&&RuntimeEquality.isObject(t.classDefinition)&&RuntimeEquality.isObject(t.enumeration)&&"string"==typeof t.enumeration.name&&Array.isArray(t.args);static scalarPartEqual=(t,e)=>{if(t===e)return!0;const r=RuntimeEquality.partToString(t),s=RuntimeEquality.partToString(e);return void 0!==r&&r===s};static partToString=t=>"number"==typeof t||"bigint"==typeof t||"boolean"==typeof t||"string"==typeof t?String(t):RuntimeEquality.isObject(t)&&"function"==typeof t.toString?t.toString():void 0;static valuesEqual=(t,e)=>t===e||(null===t||null===e||void 0===t||void 0===e?t===e:RuntimeEquality.isComplexLike(t)&&RuntimeEquality.isComplexLike(e)?RuntimeEquality.scalarPartEqual(t.re,e.re)&&RuntimeEquality.scalarPartEqual(t.im,e.im):RuntimeEquality.isCharStringLike(t)&&RuntimeEquality.isCharStringLike(e)?t.str===e.str:RuntimeEquality.isArrayLike(t)&&RuntimeEquality.isArrayLike(e)?RuntimeEquality.multiArraysEqual(t,e):RuntimeEquality.isStructureLike(t)&&RuntimeEquality.isStructureLike(e)?RuntimeEquality.structuresEqual(t,e):RuntimeEquality.isFunctionHandleLike(t)&&RuntimeEquality.isFunctionHandleLike(e)?t.id===e.id&&RuntimeEquality.functionHandleString(t)===RuntimeEquality.functionHandleString(e):RuntimeEquality.isClassInstanceLike(t)&&RuntimeEquality.isClassInstanceLike(e)?t.classDefinition===e.classDefinition&&(t.classDefinition.isHandleClass()||e.classDefinition.isHandleClass()?t===e:RuntimeEquality.propertyTablesEqual(t.properties,e.properties)):!(!RuntimeEquality.isClassEnumerationValueLike(t)||!RuntimeEquality.isClassEnumerationValueLike(e))&&t.classDefinition===e.classDefinition&&t.enumeration.name===e.enumeration.name&&RuntimeEquality.elementListsEqual(t.args,e.args));static functionHandleString=t=>t.id?"@"+t.id:"@anonymous function handle";static multiArraysEqual=(t,e)=>t.isCell===e.isCell&&RuntimeEquality.arrayEquals(t.dimension,e.dimension)&&RuntimeEquality.elementListsEqual(RuntimeEquality.linearize(t),RuntimeEquality.linearize(e));static structuresEqual=(t,e)=>RuntimeEquality.propertyTablesEqual(t.field,e.field);static propertyTablesEqual=(t,e)=>{const r=Object.keys(t).sort(),s=Object.keys(e).sort();return RuntimeEquality.arrayEquals(r,s)&&r.every(r=>RuntimeEquality.valuesEqual(t[r],e[r]))};static elementListsEqual=(t,e)=>t.length===e.length&&t.every((t,r)=>RuntimeEquality.valuesEqual(t,e[r]));static arrayEquals=(t,e)=>t.length===e.length&&t.every((t,r)=>t===e[r]);static linearize=t=>{const e=[];for(let r=0;r<t.array.length;r+=t.dimension[0])for(let s=0;s<t.dimension[1];s++)e.push(...t.array.slice(r,r+t.dimension[0]).map(t=>t[s]));return e}}const src_RuntimeEquality=null;class CoreFunctions{static throwErrorIfCellArray=(t,e)=>{if(MultiArray.isInstanceOf(e)&&e.isCell)throw new Error(`${t}: wrong type argument 'cell'`)};static classInstancesIn=t=>MultiArray.linearize(MultiArray.scalarToMultiArray(t)).filter(ClassInstance.isInstanceOf);static validateObjectArrayConcatenation=(t,e)=>{let r;for(const s of e.flatMap(t=>CoreFunctions.classInstancesIn(t)))if(r){if(s.classDefinition!==r)throw new Error(`${t}: object arrays must contain objects of the same class.`)}else r=s.classDefinition};static isemptySignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isempty=(t,...e)=>(AST.throwInvalidCallError("isempty",!(void 0!==t&&0===e.length)),RuntimeValue.isEmpty(t)?Complex.true():Complex.false());static isscalarSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isscalar=(t,...e)=>(AST.throwInvalidCallError("isscalar",!(void 0!==t&&0===e.length)),RuntimeValue.isScalar(t)?Complex.true():Complex.false());static ismatrixSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static ismatrix=(t,...e)=>(AST.throwInvalidCallError("ismatrix",!(void 0!==t&&0===e.length)),RuntimeValue.isMatrix(t)?Complex.true():Complex.false());static isvectorSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isvector=(t,...e)=>(AST.throwInvalidCallError("isvector",!(void 0!==t&&0===e.length)),RuntimeValue.isVector(t)?Complex.true():Complex.false());static iscellSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static iscell=(t,...e)=>(AST.throwInvalidCallError("iscell",!(void 0!==t&&0===e.length)),MultiArray.isCellArray(t)?Complex.true():Complex.false());static issparseSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static issparse=(t,...e)=>(AST.throwInvalidCallError("issparse",!(void 0!==t&&0===e.length)),Complex.false());static fullSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static full=(t,...e)=>(AST.throwInvalidCallError("full",!(void 0!==t&&0===e.length)),RuntimeValue.copy(t));static isNonzeroElement=t=>Complex.isInstanceOf(t)?0!==Complex.realToNumber(t)||0!==Complex.imagToNumber(t):CharString.isInstanceOf(t)?t.str.length>0&&t.str.split("").some(t=>0!==t.charCodeAt(0)):MultiArray.isInstanceOf(t)?MultiArray.linearize(t).some(CoreFunctions.isNonzeroElement):null!=t;static nnzSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static nnz=(t,...e)=>(AST.throwInvalidCallError("nnz",!(void 0!==t&&0===e.length)),Complex.create(MultiArray.linearize(MultiArray.scalarToMultiArray(t)).filter(CoreFunctions.isNonzeroElement).length));static nzmaxSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static nzmax=(t,...e)=>(AST.throwInvalidCallError("nzmax",!(void 0!==t&&0===e.length)),CoreFunctions.nnz(t));static nonzerosSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static nonzeros=(t,...e)=>(AST.throwInvalidCallError("nonzeros",!(void 0!==t&&0===e.length)),MultiArray.MultiArrayToScalar(MultiArray.toColumnVector(MultiArray.linearize(MultiArray.scalarToMultiArray(t)).filter(CoreFunctions.isNonzeroElement).map(RuntimeValue.copy))));static sparseDimension=(t,e,r)=>{const s=MultiArray.MultiArrayToScalar(t);if(!Complex.isInstanceOf(s)||!Complex.imagIsZero(s)||!Complex.realIsInteger(s)||Complex.realToNumber(s)<0)throw new Error(`${e}: argument ${r} must be a nonnegative integer scalar.`);return Complex.realToNumber(s)};static sparseTripletValues=(t,e,r,s)=>{const i=MultiArray.linearize(MultiArray.scalarToMultiArray(t));if(i.length===e)return i.map(RuntimeValue.copy);if(1===i.length)return new Array(e).fill(void 0).map(()=>RuntimeValue.copy(i[0]));throw new Error(`${r}: argument ${s} must be scalar or match the sparse triplet count.`)};static sparseSubscripts=(t,e,r,s)=>CoreFunctions.sparseTripletValues(t,e,r,s).map(t=>{if(!Complex.isInstanceOf(t)||!Complex.imagIsZero(t)||!Complex.realIsInteger(t)||Complex.realToNumber(t)<1)throw new Error(`${r}: argument ${s} must contain positive integer subscripts.`);return Complex.realToNumber(t)});static sparseSignature={inputs:{arity:-6,min:1,max:6,parameters:[{name:"value",variadic:!0}]},outputs:{arity:1}};static sparse=(...t)=>{if(AST.throwInvalidCallError("sparse",t.length<1||t.length>6),1===t.length)return RuntimeValue.copy(t[0]);if(2===t.length)return new MultiArray([CoreFunctions.sparseDimension(t[0],"sparse",1),CoreFunctions.sparseDimension(t[1],"sparse",2)],Complex.zero());const e=Math.max(...t.slice(0,3).map(t=>MultiArray.linearize(MultiArray.scalarToMultiArray(t)).length)),r=CoreFunctions.sparseSubscripts(t[0],e,"sparse",1),s=CoreFunctions.sparseSubscripts(t[1],e,"sparse",2),i=CoreFunctions.sparseTripletValues(t[2],e,"sparse",3),n=t.length>=5?CoreFunctions.sparseDimension(t[3],"sparse",4):r.reduce((t,e)=>Math.max(t,e),0),a=t.length>=5?CoreFunctions.sparseDimension(t[4],"sparse",5):s.reduce((t,e)=>Math.max(t,e),0);if(6===t.length&&CharString.isInstanceOf(t[5])&&!["sum","unique"].includes(t[5].str))throw new Error("sparse: option must be 'sum' or 'unique'.");const o=6===t.length&&CharString.isInstanceOf(t[5])&&"unique"===t[5].str,l=new MultiArray([n,a],Complex.zero());for(let t=0;t<e;t++){if(r[t]>n||s[t]>a)throw new Error("sparse: subscript indices out of range.");const e=r[t]-1,c=s[t]-1,u=i[t],h=l.array[e][c];l.array[e][c]=!o&&Complex.isInstanceOf(h)&&Complex.isInstanceOf(u)?Complex.add(h,u):RuntimeValue.copy(u)}return MultiArray.setType(l),MultiArray.MultiArrayToScalar(l)};static spallocSignature={inputs:[{arity:3,parameters:[{name:"m",validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"n",validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"nz",validators:["numeric","scalar","real","finite","integer","nonnegative"]}]},{arity:4,parameters:[{name:"m",validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"n",validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"nz",validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"typename",classes:["char","string"],allowedStrings:["double","single","logical"]}]}],outputs:{arity:1}};static spalloc=(t,e,r,s,...i)=>{AST.throwInvalidCallError("spalloc",!(void 0!==t&&void 0!==e&&void 0!==r&&0===i.length));const n=CoreFunctions.sparseDimension(t,"spalloc",1),a=CoreFunctions.sparseDimension(e,"spalloc",2);if(CoreFunctions.sparseDimension(r,"spalloc",3),!(void 0===s||CharString.isInstanceOf(s)&&["double","single","logical"].includes(s.str)))throw new Error("spalloc: typename must be 'double', 'single', or 'logical'.");const o=CharString.isInstanceOf(s)&&"logical"===s.str?Complex.false():Complex.zero();return MultiArray.MultiArrayToScalar(new MultiArray([n,a],o))};static isrowSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isrow=(t,...e)=>(AST.throwInvalidCallError("isrow",!(void 0!==t&&0===e.length)),RuntimeValue.isRowVector(t)?Complex.true():Complex.false());static iscolumnSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static iscolumn=(t,...e)=>(AST.throwInvalidCallError("iscolumn",!(void 0!==t&&0===e.length)),RuntimeValue.isColumnVector(t)?Complex.true():Complex.false());static isstructSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isstruct=(t,...e)=>(AST.throwInvalidCallError("isstruct",!(void 0!==t&&0===e.length)),Structure.isStructure(t)?Complex.true():Complex.false());static ischarSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static ischar=(t,...e)=>{AST.throwInvalidCallError("ischar",!(void 0!==t&&0===e.length));const r=optionalRuntimeExpressionValue(t);return r&&FunctionValidation.matchesClass(r,"char")?Complex.true():Complex.false()};static isstringSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isstring=(t,...e)=>{AST.throwInvalidCallError("isstring",!(void 0!==t&&0===e.length));const r=optionalRuntimeExpressionValue(t);return r&&FunctionValidation.matchesClass(r,"string")?Complex.true():Complex.false()};static iscellstrSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static iscellstr=(t,...e)=>(AST.throwInvalidCallError("iscellstr",!(void 0!==t&&0===e.length)),CoreFunctions.cellStringElements(t).accepted?Complex.true():Complex.false());static cellstrSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static cellstr=(t,...e)=>{if(AST.throwInvalidCallError("cellstr",!(void 0!==t&&0===e.length)),CharString.isInstanceOf(t)){const e=MultiArray.toColumnVector([new CharString(t.str,"'")]);return e.isCell=!0,e}if(MultiArray.isInstanceOf(t)&&t.isCell){if(!CoreFunctions.cellStringElements(t).accepted)throw new EvalError("cellstr: C must be a cell array of character vectors.");return RuntimeValue.copy(t)}if(MultiArray.isInstanceOf(t)&&!t.isCell){if(0===MultiArray.linearLength(t))return MultiArray.emptyArray(!0);const e=MultiArray.linearize(t);if(e.every(CharString.isString)){const e=MultiArray.rawMap(t,t=>new CharString(t.str,"'"));return e.isCell=!0,e}if(2===t.dimension.length&&e.every(CharString.isChar)){const e=MultiArray.toColumnVector(t.array.map(t=>new CharString(t.map(t=>t.str).join("").trimEnd(),"'")));return e.isCell=!0,e}}throw new EvalError("cellstr: input must be a string, character array, or cell array of character vectors.")};static charSignature={inputs:{arity:-1,min:1,parameters:[{name:"value",variadic:!0}]},outputs:{arity:1}};static char=(...t)=>{AST.throwInvalidCallError("char",0===t.length);const e=t.flatMap(t=>CoreFunctions.charRows(t));if(0===e.length)return MultiArray.emptyArray();if(1===e.length)return CharString.fromCharacterScalars(e[0]);const r=e.reduce((t,e)=>Math.max(t,e.length),0),s=new MultiArray([e.length,r]);for(let t=0;t<e.length;t++){const i=e[t][0]?.quote??"'";for(let n=0;n<r;n++)s.array[t][n]=e[t][n]??CharString.create(" ",i)}return MultiArray.setType(s),s};static charElement=(t,e="'")=>{if(CharString.isInstanceOf(t))return t;if(Complex.isInstanceOf(t)){if(0!==Complex.imagToNumber(t))throw new Error("char: numeric character codes must be real.");return CharString.fromNumericCode(Complex.realToNumber(t),e)}throw new Error("char: invalid conversion input.")};static charRows=t=>{if(CharString.isInstanceOf(t))return[t.toCharacterScalars()];if(Complex.isInstanceOf(t))return[[CoreFunctions.charElement(t)]];if(MultiArray.isInstanceOf(t)&&!t.isCell&&2===t.dimension.length)return t.array.map(t=>t.map(t=>CoreFunctions.charElement(t)));const e=CoreFunctions.cellStringElements(t);if(e.accepted)return e.values.map(t=>t.toCharacterScalars());throw new Error("char: invalid conversion input.")};static cellStringElements=t=>{if(!MultiArray.isInstanceOf(t)||!t.isCell)return{accepted:!1,values:[]};const e=MultiArray.linearize(t);return e.every(CharString.isChar)?{accepted:!0,values:e}:{accepted:!1,values:[]}};static doubleSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static double=(t,...e)=>{if(AST.throwInvalidCallError("double",!(void 0!==t&&0===e.length)),CharString.isInstanceOf(t))return MultiArray.fromCharString(t);if(Complex.isInstanceOf(t))return CoreFunctions.doubleElement(t);if(MultiArray.isInstanceOf(t)&&!t.isCell){const e=new MultiArray(t.dimension);return e.array=t.array.map(t=>t.map(t=>CoreFunctions.doubleElement(t))),e.type=0===MultiArray.linearLength(e)?Complex.REAL:e.type,MultiArray.linearLength(e)>0&&MultiArray.setType(e),MultiArray.MultiArrayToScalar(e)}throw new Error("double: invalid conversion input.")};static doubleElement=t=>{if(Complex.isInstanceOf(t))return Complex.create(Complex.realToNumber(t),Complex.imagToNumber(t));if(CharString.isInstanceOf(t)&&1===t.length)return Complex.create(t.str.charCodeAt(0));throw new Error("double: invalid conversion input.")};static logicalSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static logical=(t,...e)=>{if(AST.throwInvalidCallError("logical",!(void 0!==t&&0===e.length)),CharString.isInstanceOf(t))return CoreFunctions.logical(MultiArray.fromCharString(t));if(Complex.isInstanceOf(t))return CoreFunctions.logicalElement(t);if(MultiArray.isInstanceOf(t)&&!t.isCell){const e=new MultiArray(t.dimension);return e.array=t.array.map(t=>t.map(t=>CoreFunctions.logicalElement(t))),e.type=Complex.LOGICAL,MultiArray.linearLength(e)>0&&MultiArray.setType(e),MultiArray.MultiArrayToScalar(e)}throw new Error("logical: invalid conversion input.")};static logicalElement=t=>{if(Complex.isInstanceOf(t)){if(!Complex.imagIsZero(t)||Complex.realIsNaN(t))throw new Error("logical: complex and NaN values cannot be converted to logical.");return Complex.realIsZero(t)?Complex.false():Complex.true()}if(CharString.isInstanceOf(t)&&1===t.length)return 0===t.str.charCodeAt(0)?Complex.false():Complex.true();throw new Error("logical: invalid conversion input.")};static numericClassification=(t,e,r,s)=>{if(AST.throwInvalidCallError(t,!(void 0!==e&&0===r.length)),CharString.isInstanceOf(e))return CoreFunctions.numericClassification(t,MultiArray.fromCharString(e),[],s);if(Complex.isInstanceOf(e))return s(e)?Complex.true():Complex.false();if(MultiArray.isInstanceOf(e)&&!e.isCell){const r=new MultiArray(e.dimension);return r.array=e.array.map(e=>e.map(e=>s(CoreFunctions.numericClassificationElement(t,e))?Complex.true():Complex.false())),r.type=Complex.LOGICAL,MultiArray.MultiArrayToScalar(r)}throw new Error(`${t}: invalid conversion input.`)};static numericClassificationElement=(t,e)=>{if(Complex.isInstanceOf(e))return e;if(CharString.isInstanceOf(e)&&1===e.length)return Complex.create(e.str.charCodeAt(0));throw new Error(`${t}: invalid conversion input.`)};static isnanSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isnan=(t,...e)=>CoreFunctions.numericClassification("isnan",t,e,t=>Complex.realIsNaN(t)||Complex.imagIsNaN(t));static isinfSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isinf=(t,...e)=>CoreFunctions.numericClassification("isinf",t,e,t=>!Complex.realIsFinite(t)&&!Complex.realIsNaN(t)||!Complex.imagIsFinite(t)&&!Complex.imagIsNaN(t));static isfiniteSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isfinite=(t,...e)=>CoreFunctions.numericClassification("isfinite",t,e,t=>Complex.realIsFinite(t)&&Complex.imagIsFinite(t));static isfloatSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isfloat=(t,...e)=>{AST.throwInvalidCallError("isfloat",!(void 0!==t&&0===e.length));const r=optionalRuntimeExpressionValue(t);return r&&FunctionValidation.numericElements(r)?Complex.true():Complex.false()};static isintegerSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isinteger=(t,...e)=>(AST.throwInvalidCallError("isinteger",!(void 0!==t&&0===e.length)),Complex.false());static isnumericSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isnumeric=(t,...e)=>{AST.throwInvalidCallError("isnumeric",!(void 0!==t&&0===e.length));const r=optionalRuntimeExpressionValue(t);return r&&FunctionValidation.numericElements(r)?Complex.true():Complex.false()};static islogicalSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static islogical=(t,...e)=>{AST.throwInvalidCallError("islogical",!(void 0!==t&&0===e.length));const r=optionalRuntimeExpressionValue(t);return r&&FunctionValidation.isLogicalValue(r)?Complex.true():Complex.false()};static isrealSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isreal=(t,...e)=>{AST.throwInvalidCallError("isreal",!(void 0!==t&&0===e.length));const r=optionalRuntimeExpressionValue(t),s=r?FunctionValidation.numericElements(r,{includeLogical:!0}):void 0;return s&&s.every(t=>Complex.imagIsZero(t))?Complex.true():Complex.false()};static isvalidSignature={inputs:{arity:1,parameters:[{name:"handle"}]},outputs:{arity:1}};static isvalid=(t,...e)=>{AST.throwInvalidCallError("isvalid",!(void 0!==t&&0===e.length));const r=t=>{if(ClassEventListener.isInstanceOf(t))return ClassEventListener.isValid(t)?Complex.true():Complex.false();if(!ClassInstance.isInstanceOf(t)||!t.classDefinition.isHandleClass())throw new EvalError("isvalid: H must be a handle object.");return ClassInstance.isValid(t)?Complex.true():Complex.false()};return MultiArray.isInstanceOf(t)?MultiArray.MultiArrayToScalar(MultiArray.rawMap(t,r)):r(t)};static isobjectSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isobject=(t,...e)=>{AST.throwInvalidCallError("isobject",!(void 0!==t&&0===e.length));const r=t=>ClassInstance.isInstanceOf(t)||ClassEnumerationValue.isInstanceOf(t)||ClassMetaObject.isInstanceOf(t);if(MultiArray.isInstanceOf(t)){const e=MultiArray.linearize(t);return!t.isCell&&e.length>0&&e.every(r)?Complex.true():Complex.false()}return r(t)?Complex.true():Complex.false()};static classDefinitionFromValue=(t,e)=>{if(ClassDefinition.isInstanceOf(t))return t;if(ClassMetaClass.isInstanceOf(t))return t.definition;if(ClassInstance.isInstanceOf(t)||ClassEnumerationValue.isInstanceOf(t))return t.classDefinition;if(MultiArray.isInstanceOf(t)&&!t.isCell){const e=t=>ClassMetaClass.isInstanceOf(t)?t.definition:ClassInstance.isInstanceOf(t)||ClassEnumerationValue.isInstanceOf(t)?t.classDefinition:void 0,r=MultiArray.linearize(t).map(e);if(r.length>0&&r.every(t=>void 0!==t)){const t=r[0];if(r.every(e=>e===t))return t}}throw new EvalError(`${e}: input must be a class object.`)};static stringCellColumn=t=>{const e=MultiArray.toColumnVector(t.map(t=>CharString.create(t)));return e.isCell=!0,e};static listedNames=(t,e)=>{const r=new Set;for(const s of t)e(s)&&r.add(s.name);return[...r].sort()};static propertiesSignature={inputs:{arity:1,parameters:[{name:"object"}]},outputs:{arity:1}};static properties=(t,...e)=>{AST.throwInvalidCallError("properties",!(void 0!==t&&0===e.length));const r=CoreFunctions.classDefinitionFromValue(t,"properties");return CoreFunctions.stringCellColumn(CoreFunctions.listedNames(r.allProperties(),t=>!t.isHidden&&"public"===t.getAccess))};static fieldnamesSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static fieldnames=(t,...e)=>{if(AST.throwInvalidCallError("fieldnames",!(void 0!==t&&0===e.length)),Structure.isStructure(t))return CoreFunctions.stringCellColumn(Structure.fieldNames(t));const r=CoreFunctions.classDefinitionFromValue(t,"fieldnames");return CoreFunctions.stringCellColumn(CoreFunctions.listedNames(r.allProperties(),t=>!t.isHidden&&"public"===t.getAccess))};static isfieldSignature={inputs:{arity:2,parameters:[{name:"structure"},{name:"fieldName"}]},outputs:{arity:1}};static isfield=(t,e,...r)=>{AST.throwInvalidCallError("isfield",!(void 0!==t&&void 0!==e&&0===r.length));const s=Structure.isStructure(t),i=e=>{if(!CharString.isInstanceOf(e)){if(!s)return Complex.false();throw new EvalError("isfield: FIELD must be a string or cell array of strings.")}return Structure.hasField(t,e.str)?Complex.true():Complex.false()};if(MultiArray.isInstanceOf(e)){if(!e.isCell){if(!s)return Complex.false();throw new EvalError("isfield: FIELD must be a string or cell array of strings.")}const t=MultiArray.rawMap(e,i);return MultiArray.setType(t),MultiArray.MultiArrayToScalar(t)}return i(e)};static numfieldsSignature={inputs:{arity:1,parameters:[{name:"structure"}]},outputs:{arity:1}};static numfields=(t,...e)=>(AST.throwInvalidCallError("numfields",!(void 0!==t&&0===e.length&&Structure.isStructure(t))),Complex.create(Structure.fieldNames(t).length));static getfieldSignature={inputs:{arity:-2,min:2,parameters:[{name:"structure"},{name:"field",variadic:!0}]},outputs:{arity:1}};static getfield=(t,...e)=>(AST.throwInvalidCallError("getfield",!(void 0!==t&&e.length>0&&Structure.isStructure(t))),Structure.getField(t,e.map((t,e)=>CoreFunctions.stringArgument(t,"getfield",e+2))));static setfieldSignature={inputs:{arity:-3,min:3,parameters:[{name:"structure"},{name:"fieldOrValue",variadic:!0}]},outputs:{arity:1}};static setfield=(t,...e)=>{AST.throwInvalidCallError("setfield",!(void 0!==t&&e.length>=2&&Structure.isStructure(t)));const r=Structure.isInstanceOf(t)?Structure.copy(t):MultiArray.copy(t),s=e.slice(0,-1).map((t,e)=>CoreFunctions.stringArgument(t,"setfield",e+2));return Structure.setNewField(r,s,e[e.length-1]),r};static rmfieldSignature={inputs:{arity:2,parameters:[{name:"structure"},{name:"fields"}]},outputs:{arity:1}};static rmfield=(t,e,...r)=>(AST.throwInvalidCallError("rmfield",!(void 0!==t&&void 0!==e&&0===r.length&&Structure.isStructure(t))),Structure.removeFields(CoreFunctions.structureArgument(t,"rmfield"),CoreFunctions.fieldNameArguments(e,"rmfield",2)));static orderfieldsSignature={inputs:{arity:1,parameters:[{name:"structure"}]},outputs:{arity:1}};static orderfields=(t,...e)=>(AST.throwInvalidCallError("orderfields",!(void 0!==t&&0===e.length&&Structure.isStructure(t))),Structure.orderFields(CoreFunctions.structureArgument(t,"orderfields")));static struct2cellSignature={inputs:{arity:1,parameters:[{name:"structure"}]},outputs:{arity:1}};static struct2cell=(t,...e)=>{AST.throwInvalidCallError("struct2cell",!(void 0!==t&&0===e.length&&Structure.isStructure(t)));const r=CoreFunctions.structureArgument(t,"struct2cell"),s=Structure.fieldNames(r),i=Structure.structureElements(r),n=Structure.isInstanceOf(r)?[1,1]:r.dimension,a=new MultiArray([s.length,...n],void 0,!0);for(let t=0;t<i.length;t++){const e=MultiArray.linearIndexToSubscript(n,t);for(let r=0;r<s.length;r++){const[n,o]=MultiArray.subscriptToMultiArrayRowColumn(a.dimension,[r+1,...e]);a.array[n][o]=RuntimeValue.copy(i[t].field[s[r]])}}return MultiArray.setType(a),a.isCell=!0,a};static cell2structSignature={inputs:{arity:3,parameters:[{name:"cellArray",classes:["cell"]},{name:"fields"},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]},outputs:{arity:1}};static cell2struct=(t,e,r,...s)=>{AST.throwInvalidCallError("cell2struct",!(MultiArray.isInstanceOf(t)&&t.isCell&&void 0!==e&&void 0!==r&&0===s.length));const i=t,n=CoreFunctions.fieldNameArguments(e,"cell2struct",2),a=Complex.realToNumber(MultiArray.firstElement(r))-1,o=i.dimension.slice();if(MultiArray.appendSingletonTail(o,a+1),n.length!==o[a])throw new EvalError("cell2struct: number of fields does not match dimension.");const l=o.filter((t,e)=>e!==a),c=0===l.length?[1,1]:l,u=new MultiArray(c);for(let t=0;t<MultiArray.linearLength(u);t++){const e=MultiArray.linearIndexToSubscript(c,t),r=new Structure({});for(let t=0;t<n.length;t++){const s=[];let l=0;for(let r=0;r<o.length;r++)s[r]=r===a?t+1:e[l++]??1;const[c,u]=MultiArray.subscriptToMultiArrayRowColumn(i.dimension,s.slice(0,i.dimension.length));r.field[n[t]]=RuntimeValue.copy(i.array[c][u])}const[s,l]=MultiArray.linearIndexToMultiArrayRowColumn(u.dimension[0],u.dimension[1],t);u.array[s][l]=r}return MultiArray.setType(u),MultiArray.MultiArrayToScalar(u)};static methodsSignature={inputs:{arity:1,parameters:[{name:"object"}]},outputs:{arity:1}};static methods=(t,...e)=>{AST.throwInvalidCallError("methods",!(void 0!==t&&0===e.length));const r=CoreFunctions.classDefinitionFromValue(t,"methods");return CoreFunctions.stringCellColumn(CoreFunctions.listedNames(r.allMethods(),t=>!t.isHidden&&"public"===t.access))};static eventsSignature={inputs:{arity:1,parameters:[{name:"object"}]},outputs:{arity:1}};static events=(t,...e)=>{AST.throwInvalidCallError("events",!(void 0!==t&&0===e.length));const r=CoreFunctions.classDefinitionFromValue(t,"events");return CoreFunctions.stringCellColumn(CoreFunctions.listedNames(r.allEvents(),t=>!t.isHidden&&"public"===t.listenAccess))};static enumerationSignature={inputs:{arity:1,parameters:[{name:"object"}]},outputs:{arity:1}};static enumeration=(t,...e)=>{AST.throwInvalidCallError("enumeration",!(void 0!==t&&0===e.length));const r=CoreFunctions.classDefinitionFromValue(t,"enumeration");return CoreFunctions.stringCellColumn(CoreFunctions.listedNames(r.allEnumerations(),t=>!t.isHidden))};static superclassesSignature={inputs:{arity:1,parameters:[{name:"object"}]},outputs:{arity:1}};static superclasses=(t,...e)=>{AST.throwInvalidCallError("superclasses",!(void 0!==t&&0===e.length));const r=CoreFunctions.classDefinitionFromValue(t,"superclasses");return CoreFunctions.stringCellColumn(r.superclasses.slice().sort())};static stringArgument=(t,e,r)=>{if(!CharString.isInstanceOf(t))throw new EvalError(`${e}: argument ${r} must be a string.`);return t.str};static fieldNameArguments=(t,e,r)=>{if(CharString.isInstanceOf(t))return[t.str];if(MultiArray.isInstanceOf(t)&&t.isCell)return MultiArray.linearize(t).map(t=>CoreFunctions.stringArgument(t,e,r));throw new EvalError(`${e}: argument ${r} must be a string or cell array of strings.`)};static structureArgument=(t,e)=>{if(Structure.isInstanceOf(t)||MultiArray.isInstanceOf(t)&&Structure.isStructure(t))return t;throw new EvalError(`${e}: argument 1 must be a structure.`)};static ispropSignature={inputs:{arity:2,parameters:[{name:"object"},{name:"propertyName"}]},outputs:{arity:1}};static isprop=(t,e,...r)=>{if(AST.throwInvalidCallError("isprop",!(void 0!==t&&void 0!==e&&0===r.length)),!CharString.isInstanceOf(e))return Complex.false();const s=e.str;if(MultiArray.isInstanceOf(t)){if(t.isCell)return Complex.false();const e=MultiArray.rawMap(t,t=>CoreFunctions.classDefinitionFromValue(t,"isprop").findProperty(s)?Complex.true():Complex.false());return MultiArray.setType(e),MultiArray.MultiArrayToScalar(e)}return CoreFunctions.classDefinitionFromValue(t,"isprop").findProperty(s)?Complex.true():Complex.false()};static ismethodSignature={inputs:{arity:2,parameters:[{name:"object"},{name:"methodName",classes:["char","string"]}]},outputs:{arity:1}};static ismethod=(t,e,...r)=>{AST.throwInvalidCallError("ismethod",!(void 0!==t&&void 0!==e&&0===r.length));const s=CoreFunctions.classDefinitionFromValue(t,"ismethod"),i=CoreFunctions.stringArgument(e,"ismethod",2);return s.findMethod(i,t=>!t.isHidden&&"public"===t.access)?Complex.true():Complex.false()};static isequalSignature={inputs:{arity:-1,min:2,parameters:[{name:"value",variadic:!0}]},outputs:{arity:1}};static isequal=(t,...e)=>(AST.throwInvalidCallError("isequal",!(void 0!==t&&e.length>=1)),e.every(e=>CoreFunctions.valuesEqual(t,e))?Complex.true():Complex.false());static valuesEqual=(t,e)=>RuntimeEquality.valuesEqual(t,e);static ndimsSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static ndims=(t,...e)=>(AST.throwInvalidCallError("ndims",!(void 0!==t&&0===e.length)),Complex.create(RuntimeValue.dimensions(t).length));static rowsSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static rows=(t,...e)=>(AST.throwInvalidCallError("rows",!(void 0!==t&&0===e.length)),Complex.create(RuntimeValue.dimensions(t)[0]));static columnsSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static columns=(t,...e)=>(AST.throwInvalidCallError("columns",!(void 0!==t&&0===e.length)),Complex.create(RuntimeValue.dimensions(t)[1]));static lengthSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static Length=(t,...e)=>(AST.throwInvalidCallError("length",!(void 0!==t&&0===e.length)),Complex.create(Math.max(...RuntimeValue.dimensions(t))));static numelSignature={inputs:{arity:-2,min:1,parameters:[{name:"value"},{name:"index",variadic:!0}]},outputs:{arity:1}};static numel=(t,...e)=>{const r=RuntimeValue.dimensions(t);if(0===e.length)return Complex.create(RuntimeValue.elementCount(t));{const t=e.map((t,e)=>MultiArray.isInstanceOf(t)?MultiArray.linearLength(t):CharString.isInstanceOf(t)&&":"===t.str&&e<r.length?r[e]:1);return Complex.create(t.reduce((t,e)=>t*e,1))}};static findSignature={inputs:[{arity:1,parameters:[{name:"value",classes:["double"]}]},{arity:2,parameters:[{name:"value",classes:["double"]},{name:"count",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]}]},{arity:3,parameters:[{name:"value",classes:["double"]},{name:"count",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"direction",classes:["char","string"],allowedStrings:["first","last"]}]}],outputs:{arity:-3}};static find=(t,...e)=>{AST.throwInvalidCallError("find",e.length>2);const r=MultiArray.scalarToMultiArray(t);let s=1/0,i="first";e.length>=1&&(s=Complex.realToNumber(MultiArray.firstElement(e[0]))),2===e.length&&(i=e[1].str);let n=MultiArray.linearize(r).map((t,e)=>({index:e,value:t})).filter(({value:t})=>Boolean(Complex.realToNumber(t)||Complex.imagToNumber(t)));n="last"===i?n.slice(Math.max(0,n.length-s)):n.slice(0,s);const a=n.map(({index:t})=>Complex.create(t+1)),o=n.map(({index:t})=>Complex.create(MultiArray.linearIndexToSubscript(r.dimension,t)[0]??1)),l=n.map(({index:t})=>Complex.create(MultiArray.linearIndexToSubscript(r.dimension,t)[1]??1)),c=n.map(({value:t})=>t),u=t=>MultiArray.MultiArrayToScalar(MultiArray.toColumnVector(t));return AST.nodeBoundedReturnList(3,(t,e)=>{if(1===t.length)return u(a);switch(e){case 0:return u(o);case 1:return u(l);case 2:return u(c);default:throw new EvalError("unreachable find return-list selector branch.")}})};static sortSignature={inputs:[{arity:1,parameters:[{name:"value",classes:["double"]}]},{arity:2,parameters:[{name:"value",classes:["double"]},{name:"dimensionOrDirection",alternatives:[{name:"dimension",classes:["double"],validators:["dimension","positive"]},{name:"direction",classes:["char","string"],allowedStrings:["ascend","descend"]}]}]},{arity:3,parameters:[{name:"value",classes:["double"]},{name:"dimension",classes:["double"],validators:["dimension","positive"]},{name:"direction",classes:["char","string"],allowedStrings:["ascend","descend"]}]}],outputs:{arity:-2}};static sort=(t,...e)=>{AST.throwInvalidCallError("sort",e.length>2);const r=MultiArray.scalarToMultiArray(t);let s,i="ascend";e.length>=1&&(CharString.isInstanceOf(e[0])?i=e[0].str:s=Complex.realToNumber(MultiArray.firstElement(e[0]))-1),2===e.length&&(i=e[1].str),s=void 0===s?MultiArray.firstNonSingleDimension(r):s;const n=new MultiArray(r.dimension),a=new MultiArray(r.dimension),o=r.dimension.slice();o[s]=1;const l=o.reduce((t,e)=>t*e,1);for(let t=0;t<l;t++){const e=MultiArray.linearIndexToSubscript(o,t),l=Array.from({length:r.dimension[s]??1},(t,i)=>{const n=e.slice();n[s]=i+1;const a=MultiArray.subscriptToLinearIndex(r.dimension,n),[o,l]=MultiArray.linearIndexToMultiArrayRowColumn(r.dimension[0],r.dimension[1],a);return{index:i,value:r.array[o][l]}}).sort((t,e)=>{if(Complex.toBoolean(Complex.eq(t.value,e.value)))return t.index-e.index;const r="descend"===i?Complex.gt(t.value,e.value):Complex.lt(t.value,e.value);return Complex.toBoolean(r)?-1:1});for(let t=0;t<l.length;t++){const i=e.slice();i[s]=t+1;const o=MultiArray.subscriptToLinearIndex(r.dimension,i),[c,u]=MultiArray.linearIndexToMultiArrayRowColumn(r.dimension[0],r.dimension[1],o);n.array[c][u]=l[t].value,a.array[c][u]=Complex.create(l[t].index+1)}}return MultiArray.setType(n),a.type=Complex.REAL,AST.nodeBoundedReturnList(2,(t,e)=>0===e||1===t.length?MultiArray.MultiArrayToScalar(n):MultiArray.MultiArrayToScalar(a))};static ind2subSignature={inputs:{arity:2,parameters:[{name:"dimensions",classes:["double"],validators:["dimension"],alternatives:[{name:"dimensions",validators:["dimensionVector"]}]},{name:"index",classes:["double"],validators:["numeric","real","finite","integer","positive"]}]},outputs:{arity:-1}};static ind2sub=(t,e)=>(AST.throwInvalidCallError("ind2sub",!(void 0!==t&&void 0!==e)),AST.nodeReturnList((r,s)=>{if(1===r.length)return e;{let i=MultiArray.linearize(t).map(t=>Complex.realToNumber(t)),n=!1;r.length>i.length?(MultiArray.appendSingletonTail(i,r.length),n=!0):i=i.slice(0,r.length-1);const a=MultiArray.scalarToMultiArray(e),o=new MultiArray(a.dimension),l=a.array.map(t=>t.map(t=>MultiArray.ind2subNumber(i,Complex.realToNumber(t))));return s===r.length-1&&n?o.array=l.map(t=>t.map(t=>Complex.create(t[r.length]))):o.array=l.map(t=>t.map(t=>Complex.create(t[s]))),o.type=Complex.REAL,MultiArray.MultiArrayToScalar(o)}}));static sub2indSignature={inputs:{arity:-2,min:2,parameters:[{name:"dimensions",classes:["double"],validators:["dimension"],alternatives:[{name:"dimensions",validators:["dimensionVector"]}]},{name:"subscript",classes:["double"],validators:["numeric","real","finite","integer","positive"],variadic:!0}]},outputs:{arity:1}};static sub2ind=(t,...e)=>{AST.throwInvalidCallError("sub2ind",e.length<1);const r=MultiArray.linearize(t).map(t=>Complex.realToNumber(t)),s=e.map(t=>MultiArray.scalarToMultiArray(t));for(let t=1;t<s.length;t++)if(!MultiArray.arrayEquals(s[0].dimension,s[t].dimension))throw new Error("sub2ind: all subscripts must be of the same size.");MultiArray.appendSingletonTail(r,s.length);const i=new MultiArray(s[0].dimension);for(let t=0;t<MultiArray.linearLength(s[0]);t++){const e=s.map(e=>{const[r,s]=MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],t);return e.array[r][s]}),n=MultiArray.parseSubscript(r,e,"index "),[a,o]=MultiArray.linearIndexToMultiArrayRowColumn(i.dimension[0],i.dimension[1],t);i.array[a][o]=Complex.create(n+1)}return MultiArray.MultiArrayToScalar(i)};static sizeSignature={inputs:[{arity:1,parameters:[{name:"value"}]},{arity:-2,min:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["numeric","positive","integer","real"],variadic:!0}]}],outputs:{arity:-1}};static size=(t,...e)=>{AST.throwInvalidCallError("size",!(void 0!==t));const r=t=>{const e=Complex.realToNumber(t);if(e<1||!Complex.realIsInteger(t))throw new Error(`size: requested dimension DIM (= ${e}) out of range. DIM must be a positive integer.`);return e},s=RuntimeValue.dimensions(t);if(0===e.length){const t=new MultiArray([1,s.length]);return t.array[0]=s.map(t=>Complex.create(t)),t.type=Complex.REAL,t}{const t=1===e.length&&MultiArray.isInstanceOf(e[0])?MultiArray.linearize(e[0]).map(t=>(Complex.isInstanceOf(t)||AST.throwInvalidCallError("size"),r(t))):e.map(t=>(t=>{const e=MultiArray.firstElement(t);return Complex.isInstanceOf(e)||AST.throwInvalidCallError("size"),r(e)})(t));MultiArray.appendSingletonTail(s,Math.max(...t));const i=new MultiArray([1,t.length]);return i.array[0]=t.map(t=>Complex.create(s[t-1])),i.type=Complex.REAL,MultiArray.MultiArrayToScalar(i)}};static colonSignature={inputs:{arity:-3,min:2,max:3,parameters:[{name:"start",classes:["double"],validators:["scalar"]},{name:"incrementOrEnd",classes:["double"],validators:["scalar"]},{name:"end",classes:["double"],validators:["scalar"],optional:!0}]},outputs:{arity:1}};static colon=(...t)=>2===t.length?MultiArray.expandRange(MultiArray.firstElement(t[0]),MultiArray.firstElement(t[1])):3===t.length?MultiArray.expandRange(MultiArray.firstElement(t[0]),MultiArray.firstElement(t[2]),MultiArray.firstElement(t[1])):void AST.throwInvalidCallError("colon");static linspaceSignature={inputs:{arity:-3,min:2,max:3,parameters:[{name:"start",classes:["double"],validators:["scalarOrVector"]},{name:"end",classes:["double"],validators:["scalarOrVector"]},{name:"count",classes:["double"],validators:["numeric","scalar","real"],optional:!0}]},outputs:{arity:1}};static linspace=(...t)=>{let e=[],r=[],s=Complex.one();const i=()=>{const s="linspace: START, END must be scalars or vectors.";if(MultiArray.isInstanceOf(t[0])){if(!MultiArray.isVector(t[0]))throw new Error(s);e=MultiArray.linearize(t[0])}else e=[t[0]];if(MultiArray.isInstanceOf(t[1])){if(!MultiArray.isVector(t[1]))throw new Error(s);r=MultiArray.linearize(t[1])}else r=[t[1]]};if(2===t.length)i(),s=Complex.create(100);else if(3===t.length){if(i(),s=MultiArray.MultiArrayToScalar(t[2]),MultiArray.isInstanceOf(s))throw new Error("linspace: N must be a scalar.")}else AST.throwInvalidCallError("linspace");if(e.length!==r.length)throw new Error("linspace: vectors must be of equal length");Complex.realApply(s,Complex.applyFunction.floor),Complex.realIsNegative(s)&&Complex.realSet(s,0),Complex.imagSet(s,0);const n=new MultiArray([e.length,Complex.realToNumber(s)]);for(let t=0;t<e.length;t++){const i=Complex.rdiv(Complex.sub(r[t],e[t]),Complex.sub(s,Complex.one()));n.array[t][0]=e[t];for(let r=1;r<Complex.realToNumber(s)-1;r++)n.array[t][r]=Complex.add(e[t],Complex.mul(Complex.create(r),i));n.array[t][Complex.realToNumber(s)-1]=r[t]}return MultiArray.MultiArrayToScalar(n)};static logspaceSignature={inputs:{arity:-3,min:2,max:3,parameters:[{name:"start",classes:["double"],validators:["scalarOrVector"]},{name:"end",classes:["double"],validators:["scalarOrVector"]},{name:"count",classes:["double"],validators:["numeric","scalar","real"],optional:!0}]},outputs:{arity:1}};static logspace=(...t)=>{let e=[],r=[],s=Complex.one();const i=()=>{const s="logspace: START, END must be scalars or vectors.";if(MultiArray.isInstanceOf(t[0])){if(!MultiArray.isVector(t[0]))throw new Error(s);e=MultiArray.linearize(t[0])}else e=[t[0]];if(MultiArray.isInstanceOf(t[1])){if(!MultiArray.isVector(t[1]))throw new Error(s);r=MultiArray.linearize(t[1])}else r=[t[1]]};if(2===t.length)i(),s=Complex.create(50);else if(3===t.length){if(i(),s=MultiArray.MultiArrayToScalar(t[2]),MultiArray.isInstanceOf(s))throw new Error("logspace: N must be a scalar.")}else AST.throwInvalidCallError("logspace");if(e.length!==r.length)throw new Error("logspace: vectors must be of equal length");Complex.realApply(s,Complex.applyFunction.floor),Complex.realIsNegative(s)&&Complex.realSet(s,0),Complex.imagSet(s,0);const n=new MultiArray([e.length,Complex.realToNumber(s)]);for(let t=0;t<e.length;t++){Complex.realToNumber(Complex.eq(r[t],Complex.pi()))&&(r[t]=Complex.log10(Complex.pi()));const i=Complex.rdiv(Complex.sub(r[t],e[t]),Complex.sub(s,Complex.one()));n.array[t][0]=Complex.power(Complex.create(10),e[t]);for(let r=1;r<Complex.realToNumber(s)-1;r++)n.array[t][r]=Complex.power(Complex.create(10),Complex.add(e[t],Complex.mul(Complex.create(r),i)));n.array[t][Complex.realToNumber(s)-1]=Complex.power(Complex.create(10),r[t])}return MultiArray.MultiArrayToScalar(n)};static meshgridSignature={inputs:{arity:-3,min:1,max:3,parameters:[{name:"vector",classes:["double"],validators:["scalarOrVector"],variadic:!0}]},outputs:{arity:-3}};static meshgrid=(...t)=>{AST.throwInvalidCallError("meshgrid",t.length>3||t.length<1);const e=[];for(let r=0;r<3&&t.length>r;r++)if(MultiArray.isInstanceOf(t[r])){if(!MultiArray.isVector(t[r]))throw new Error("meshgrid: arguments must be vectors.");e[r]=MultiArray.firstVector(t[r])}else e[r]=[t[r]];return AST.nodeBoundedReturnList(3,(t,r)=>{const s=e;for(;s.length<t.length;)s[s.length]=s[s.length-1];const i=t.length>2?new MultiArray([s[1].length,s[0].length,s[2].length]):new MultiArray([s[1].length,s[0].length]);switch(r){case 0:for(let t=0;t<i.array.length;t++)i.array[t]=s[0];break;case 1:for(let t=0;t<i.array.length;t+=i.dimension[0])for(let e=0;e<i.dimension[0];e++)i.array[t+e]=new Array(i.dimension[1]).fill(s[1][e]);break;case 2:for(let t=0,e=0;t<i.array.length;t+=i.dimension[0],e++)for(let r=0;r<i.dimension[0];r++)i.array[t+r]=new Array(i.dimension[1]).fill(s[2][e])}return MultiArray.MultiArrayToScalar(i)})};static ndgridSignature={inputs:{arity:-1,min:1,parameters:[{name:"vector",classes:["double"],validators:["scalarOrVector"],variadic:!0}]},outputs:{arity:-1}};static ndgrid=(...t)=>{const e=[];for(let r=0;r<t.length;r++)if(MultiArray.isInstanceOf(t[r])){if(!MultiArray.isVector(t[r]))throw new Error("ndgrid: arguments must be vectors.");e[r]=t[r]}else e[r]=MultiArray.scalarToMultiArray(t[r]);return AST.nodeReturnList((t,r)=>{const s=e;if(1===s.length)for(;s.length<t.length;)s[s.length]=s[s.length-1];t.length>s.length&&AST.throwErrorIfGreaterThanReturnList(s.length,t.length);const i=s.map(t=>t.dimension[0]*t.dimension[1]),n=new Array(s.length).fill(1);return n[r]=i[r],i[r]=1,MultiArray.evaluate(new MultiArray(i,MultiArray.reshape(s[r],n)))})};static repmatSignature={inputs:[{arity:2,parameters:[{name:"value"},{name:"dimensions",classes:["double"],validators:["dimension"],alternatives:[{name:"dimensions",validators:["dimensionVector"]}]}]},{arity:-3,min:3,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension"],variadic:!0}]}],outputs:{arity:1}};static repmat=(t,...e)=>{let r;if(1===e.length)r=MultiArray.firstVector(e[0]);else{const t=new Array(e.length);if(r=e.map((e,r)=>{const s=MultiArray.MultiArrayToScalar(e);return t[r]=MultiArray.isInstanceOf(s)?1:0,s}),t.reduce((t,e)=>t+e,0))throw new Error("repmat: all input arguments must be scalar.")}const s=r.map(t=>Complex.realToNumber(t));return MultiArray.isInstanceOf(t)&&t.isCell?CoreFunctions.repmatCellArray(t,s):MultiArray.evaluate(new MultiArray(s,t))};static repmatCellArray=(t,e)=>{const r=Math.max(t.dimension.length,e.length,2),s=t.dimension.slice(),i=e.slice();MultiArray.appendSingletonTail(s,r),MultiArray.appendSingletonTail(i,r);const n=s.map((t,e)=>t*i[e]),a=new MultiArray(n,void 0,!0);for(let e=0;e<MultiArray.linearLength(a);e++){const r=MultiArray.linearIndexToSubscript(a.dimension,e).map((t,e)=>(t-1)%s[e]+1),i=MultiArray.subscriptToLinearIndex(s,r),[n,o]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],i),[l,c]=MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],e);a.array[l][c]=RuntimeValue.copy(t.array[n][o])}return a.isCell=!0,a};static reshapeSignature={inputs:[{arity:2,parameters:[{name:"value"},{name:"dimensions",classes:["double"],validators:["reshapeDimension"],alternatives:[{name:"dimensions",validators:["reshapeDimensionVector"]}]}]},{arity:-3,min:3,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["reshapeDimension"],variadic:!0}]}],outputs:{arity:1}};static reshape=(t,...e)=>{if(e.length<1)throw new Error("invalid call to reshape");const r=MultiArray.scalarOrCellToMultiArray(t);let s=-1;1===e.length&&MultiArray.isInstanceOf(e[0])&&(e=MultiArray.linearize(e[0]));const i=e.map((t,e)=>{if(MultiArray.isEmpty(t)){if(s<0)return s=e,1;throw new Error("reshape: only a single dimension can be unknown.")}return Complex.realToNumber(MultiArray.firstElement(t))});return MultiArray.reshape(r,i,s)};static squeezeSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static squeeze=(...t)=>{if(AST.throwInvalidCallError("squeeze",1!==t.length),!MultiArray.isInstanceOf(t[0]))return t[0];const e=t[0];if(e.dimension.length<=2)return e;const r=e.dimension.filter(t=>1!==t);for(;r.length<2;)r.push(1);return MultiArray.reshape(e,r)};static flipSignature={inputs:[{arity:1,parameters:[{name:"array"}]},{arity:2,parameters:[{name:"array"},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]}],outputs:{arity:1}};static flip=(t,e,...r)=>{AST.throwInvalidCallError("flip",!(void 0!==t&&0===r.length));const s=CharString.isInstanceOf(t)?MultiArray.characterVectorFromCharString(t):MultiArray.scalarOrCellToMultiArray(t),i=void 0===e?MultiArray.firstNonSingleDimension(s)+1:CoreFunctions.positiveIntegerScalar(e,"flip","DIM");return CoreFunctions.flipArray(s,i)};static fliplrSignature={inputs:{arity:1,parameters:[{name:"array"}]},outputs:{arity:1}};static fliplr=(t,...e)=>{AST.throwInvalidCallError("fliplr",!(void 0!==t&&0===e.length));const r=CharString.isInstanceOf(t)?MultiArray.characterVectorFromCharString(t):MultiArray.scalarOrCellToMultiArray(t);return CoreFunctions.flipArray(r,2)};static flipudSignature={inputs:{arity:1,parameters:[{name:"array"}]},outputs:{arity:1}};static flipud=(t,...e)=>{AST.throwInvalidCallError("flipud",!(void 0!==t&&0===e.length));const r=CharString.isInstanceOf(t)?MultiArray.characterVectorFromCharString(t):MultiArray.scalarOrCellToMultiArray(t);return CoreFunctions.flipArray(r,1)};static flipArray=(t,e)=>{const r=Math.max(t.dimension.length,e,2),s=t.dimension.slice();MultiArray.appendSingletonTail(s,r);const i=new MultiArray(s,void 0,t.isCell);for(let r=0;r<MultiArray.linearLength(t);r++){const n=MultiArray.linearIndexToSubscript(s,r),a=n.slice();a[e-1]=s[e-1]-n[e-1]+1;const[o,l]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],r),[c,u]=MultiArray.subscriptToMultiArrayRowColumn(i.dimension,a);i.array[c][u]=RuntimeValue.copy(t.array[o][l])}return i.isCell=t.isCell,i.type=t.type,MultiArray.removeSingletonTail(i.dimension),MultiArray.MultiArrayToScalar(i)};static rot90Signature={inputs:[{arity:1,parameters:[{name:"array"}]},{arity:2,parameters:[{name:"array"},{name:"k",classes:["double"],validators:["numeric","scalar","real","finite","integer"]}]}],outputs:{arity:1}};static rot90=(t,e,...r)=>{AST.throwInvalidCallError("rot90",!(void 0!==t&&0===r.length));const s=CharString.isInstanceOf(t)?MultiArray.characterVectorFromCharString(t):MultiArray.scalarOrCellToMultiArray(t),i=((void 0===e?1:CoreFunctions.integerScalar(e,"rot90","K"))%4+4)%4;if(0===i)return s;const n=s.dimension.slice();MultiArray.appendSingletonTail(n,2);const a=n.slice();i%2==1&&([a[0],a[1]]=[a[1],a[0]]);const o=new MultiArray(a,void 0,s.isCell);for(let t=0;t<MultiArray.linearLength(s);t++){const e=MultiArray.linearIndexToSubscript(n,t),r=e.slice();1===i?(r[0]=n[1]-e[1]+1,r[1]=e[0]):2===i?(r[0]=n[0]-e[0]+1,r[1]=n[1]-e[1]+1):(r[0]=e[1],r[1]=n[0]-e[0]+1);const[a,l]=MultiArray.linearIndexToMultiArrayRowColumn(s.dimension[0],s.dimension[1],t),[c,u]=MultiArray.subscriptToMultiArrayRowColumn(o.dimension,r);o.array[c][u]=RuntimeValue.copy(s.array[a][l])}return o.isCell=s.isCell,o.type=s.type,MultiArray.removeSingletonTail(o.dimension),MultiArray.MultiArrayToScalar(o)};static permuteSignature={inputs:{arity:2,parameters:[{name:"array"},{name:"order",classes:["double"],validators:["dimensionVector"]}]},outputs:{arity:1}};static permute=(t,e,...r)=>(AST.throwInvalidCallError("permute",!(void 0!==t&&void 0!==e&&0===r.length)),CoreFunctions.permuteArray(t,e,!1,"permute"));static ipermuteSignature={inputs:{arity:2,parameters:[{name:"array"},{name:"order",classes:["double"],validators:["dimensionVector"]}]},outputs:{arity:1}};static ipermute=(t,e,...r)=>(AST.throwInvalidCallError("ipermute",!(void 0!==t&&void 0!==e&&0===r.length)),CoreFunctions.permuteArray(t,e,!0,"ipermute"));static permuteArray=(t,e,r,s)=>{const i=CharString.isInstanceOf(t)?MultiArray.characterVectorFromCharString(t):MultiArray.scalarOrCellToMultiArray(t),n=CoreFunctions.permutationOrder(e,i.dimension.length,s),a=r?CoreFunctions.inversePermutation(n):n,o=Math.max(i.dimension.length,a.length,2),l=i.dimension.slice();MultiArray.appendSingletonTail(l,o);const c=a.map(t=>l[t-1]);MultiArray.appendSingletonTail(c,o);const u=new MultiArray(c,void 0,i.isCell);for(let t=0;t<MultiArray.linearLength(u);t++){const e=MultiArray.linearIndexToSubscript(u.dimension,t),r=new Array(o).fill(1);a.forEach((t,s)=>{r[t-1]=e[s]});const s=MultiArray.subscriptToLinearIndex(l,r),[n,c]=MultiArray.linearIndexToMultiArrayRowColumn(i.dimension[0],i.dimension[1],s),[h,d]=MultiArray.linearIndexToMultiArrayRowColumn(u.dimension[0],u.dimension[1],t);u.array[h][d]=RuntimeValue.copy(i.array[n][c])}return u.isCell=i.isCell,u.type=i.type,MultiArray.removeSingletonTail(u.dimension),MultiArray.MultiArrayToScalar(u)};static permutationOrder=(t,e,r)=>{const s=MultiArray.linearize(MultiArray.scalarToMultiArray(t)).map(t=>{if(!Complex.isInstanceOf(t))throw new EvalError(`${r}: ORDER must be a permutation vector.`);const e=Complex.realToNumber(t);if(!Number.isInteger(e)||e<1||0!==Complex.imagToNumber(t))throw new EvalError(`${r}: ORDER must be a permutation vector.`);return e}),i=Math.max(e,s.length,2),n=s.slice().sort((t,e)=>t-e);if(s.length!==i||n.some((t,e)=>t!==e+1))throw new EvalError(`${r}: ORDER must be a permutation vector.`);return s};static inversePermutation=t=>{const e=new Array(t.length);return t.forEach((t,r)=>{e[t-1]=r+1}),e};static circshiftSignature={inputs:[{arity:2,parameters:[{name:"array"},{name:"shifts",classes:["double"]}]},{arity:3,parameters:[{name:"array"},{name:"shift",classes:["double"],validators:["numeric","scalar","real","finite","integer"]},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]}],outputs:{arity:1}};static circshift=(t,e,r,...s)=>{AST.throwInvalidCallError("circshift",!(void 0!==t&&void 0!==e&&0===s.length));const i=CharString.isInstanceOf(t)?MultiArray.characterVectorFromCharString(t):MultiArray.scalarOrCellToMultiArray(t),n=CoreFunctions.integerVector(e,"circshift","SHIFTS");if(void 0!==r){const t=CoreFunctions.positiveIntegerScalar(r,"circshift","DIM");if(1!==n.length)throw new EvalError("circshift: SHIFT must be a scalar when DIM is specified.");return CoreFunctions.circularShiftArray(i,[n[0]],t)}if(1===n.length)return CoreFunctions.circularShiftArray(i,n,MultiArray.firstNonSingleDimension(i)+1);if(n.length>i.dimension.length)throw new EvalError("circshift: SHIFTS vector must not be longer than ndims(A).");return CoreFunctions.circularShiftArray(i,n)};static circularShiftArray=(t,e,r)=>{const s=Math.max(t.dimension.length,r??0,e.length,2),i=t.dimension.slice();MultiArray.appendSingletonTail(i,s);const n=new Array(s).fill(0);"number"==typeof r?n[r-1]=e[0]:e.forEach((t,e)=>{n[e]=t});const a=new MultiArray(i,void 0,t.isCell);for(let e=0;e<MultiArray.linearLength(t);e++){const r=MultiArray.linearIndexToSubscript(i,e).map((t,e)=>{const r=i[e];return((t-1+n[e])%r+r)%r+1}),[s,o]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],e),[l,c]=MultiArray.subscriptToMultiArrayRowColumn(a.dimension,r);a.array[l][c]=RuntimeValue.copy(t.array[s][o])}return a.isCell=t.isCell,a.type=t.type,MultiArray.removeSingletonTail(a.dimension),MultiArray.MultiArrayToScalar(a)};static shiftdimSignature={inputs:[{arity:1,parameters:[{name:"array"}]},{arity:2,parameters:[{name:"array"},{name:"shift",classes:["double"],validators:["numeric","scalar","real","finite","integer"]}]}],outputs:{arity:-2}};static shiftdim=(t,e,...r)=>{AST.throwInvalidCallError("shiftdim",!(void 0!==t&&0===r.length));const s=MultiArray.scalarOrCellToMultiArray(t);if(void 0===e){const t=CoreFunctions.leadingSingletonDimensions(s.dimension),e=CoreFunctions.shiftDimensions(s,t);return AST.nodeBoundedReturnList(2,(r,s)=>0===s?e:Complex.create(t))}const i=CoreFunctions.integerScalar(e,"shiftdim","N");return CoreFunctions.shiftDimensions(s,i)};static leadingSingletonDimensions=t=>{let e=0;for(;e<t.length-2&&1===t[e];)e++;return e};static shiftDimensions=(t,e)=>{if(0===e)return t;const r=t.dimension.slice(),s=0===r.length?0:e%r.length,i=e>0?r.slice(s).concat(r.slice(0,s)):new Array(-e).fill(1).concat(r);for(;i.length<2;)i.push(1);return MultiArray.reshape(t,i)};static integerVector=(t,e,r)=>MultiArray.linearize(MultiArray.scalarToMultiArray(t)).map(t=>{if(!Complex.isInstanceOf(t))throw new EvalError(`${e}: ${r} must contain integer values.`);const s=Complex.realToNumber(t);if(!Number.isInteger(s)||0!==Complex.imagToNumber(t)||!Number.isFinite(s))throw new EvalError(`${e}: ${r} must contain integer values.`);return s});static integerScalar=(t,e,r)=>{const s=MultiArray.MultiArrayToScalar(t);if(!Complex.isInstanceOf(s))throw new EvalError(`${e}: ${r} must be an integer scalar.`);const i=Complex.realToNumber(s);if(!Number.isInteger(i)||0!==Complex.imagToNumber(s)||!Number.isFinite(i))throw new EvalError(`${e}: ${r} must be an integer scalar.`);return i};static positiveIntegerScalar=(t,e,r)=>{const s=CoreFunctions.integerScalar(t,e,r);if(s<1)throw new EvalError(`${e}: ${r} must be a positive integer scalar.`);return s};static newFilled=(t,e,...r)=>{let s;if(0===r.length)return t;if(1===r.length){const t=MultiArray.scalarToMultiArray(r[0]);if(!MultiArray.isVector(t))throw new Error(`${e} (A): use ${e} (size (A)) instead.`);s=MultiArray.linearize(t).map(t=>Complex.realToNumber(t)),1===s.length&&(s[s.length]=s[0])}else s=r.map(t=>{if(MultiArray.isInstanceOf(t))throw new Error(`${e}: dimensions must be scalars.`);return Complex.realToNumber(t)});return MultiArray.MultiArrayToScalar(new MultiArray(s,t))};static newFilledEach=(t,...e)=>{let r;if(1===e.length)r=MultiArray.linearize(e[0]).map(t=>Complex.realToNumber(t));else{if(0===e.length)return t(0);r=e.map(t=>Complex.realToNumber(MultiArray.firstElement(t)))}1===r.length&&(r[r.length]=r[0]);const s=new MultiArray(r);for(let e=0;e<MultiArray.linearLength(s);e++){const[r,i]=MultiArray.linearIndexToMultiArrayRowColumn(s.dimension[0],s.dimension[1],e);s.array[r][i]=t(e)}return MultiArray.setType(s),MultiArray.MultiArrayToScalar(s)};static zerosSignature={inputs:[{arity:0},{arity:1,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],alternatives:[{name:"dimensions",validators:["numeric","vector","real","finite","integer","nonnegative"]}]}]},{arity:-2,min:2,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],variadic:!0}]}],outputs:{arity:1}};static zeros=(...t)=>CoreFunctions.newFilled(Complex.zero(),"zeros",...t);static onesSignature={inputs:[{arity:0},{arity:1,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],alternatives:[{name:"dimensions",validators:["numeric","vector","real","finite","integer","nonnegative"]}]}]},{arity:-2,min:2,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],variadic:!0}]}],outputs:{arity:1}};static ones=(...t)=>CoreFunctions.newFilled(Complex.one(),"ones",...t);static cellSignature={inputs:[{arity:0},{arity:1,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],alternatives:[{name:"dimensions",validators:["numeric","vector","real","finite","integer","nonnegative"]}]}]},{arity:-2,min:2,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],variadic:!0}]}],outputs:{arity:1}};static cell=(...t)=>{let e;if(0===t.length)return MultiArray.emptyArray(!0);if(1===t.length){const r=MultiArray.scalarToMultiArray(t[0]);if(!MultiArray.isVector(r))throw new Error("cell (A): use cell (size (A)) instead.");e=MultiArray.linearize(r).map(t=>Complex.realToNumber(t)),1===e.length&&(e[e.length]=e[0])}else e=t.map(t=>{if(MultiArray.isInstanceOf(t))throw new Error("cell: dimensions must be scalars.");return Complex.realToNumber(t)});return new MultiArray(e,()=>MultiArray.emptyArray(),!0)};static num2cellSignature={inputs:[{arity:1,parameters:[{name:"value"}]},{arity:2,parameters:[{name:"value"},{name:"dimensions",classes:["double"],validators:["numeric","vector","real","finite","integer","positive"],alternatives:[{name:"dimension",validators:["numeric","scalar","real","finite","integer","positive"]}]}]}],outputs:{arity:1}};static num2cell=(t,e,...r)=>{AST.throwInvalidCallError("num2cell",!(void 0!==t&&0===r.length));const s=CharString.isInstanceOf(t)?MultiArray.characterVectorFromCharString(t):MultiArray.isInstanceOf(t)?t:MultiArray.scalarToMultiArray(t);if(void 0===e){const t=new MultiArray(s.dimension,void 0,!0);for(let e=0;e<MultiArray.linearLength(s);e++){const[r,i]=MultiArray.linearIndexToMultiArrayRowColumn(s.dimension[0],s.dimension[1],e);t.array[r][i]=RuntimeValue.copy(s.array[r][i])}return t.isCell=!0,t}const i=[...new Set(MultiArray.linearize(MultiArray.scalarToMultiArray(e)).map(t=>Complex.realToNumber(t)-1))].sort((t,e)=>t-e);if(i.some(t=>t>=s.dimension.length))throw new EvalError("num2cell: DIM must be between 1 and ndims(A).");const n=s.dimension.slice();MultiArray.appendSingletonTail(n,Math.max(...i)+1);const a=n.map((t,e)=>i.includes(e)?1:t),o=n.map((t,e)=>i.includes(e)?t:1),l=new MultiArray(a,void 0,!0);for(let t=0;t<MultiArray.linearLength(l);t++){const e=MultiArray.linearIndexToSubscript(a,t),r=new MultiArray(o,void 0,s.isCell);for(let t=0;t<MultiArray.linearLength(r);t++){const a=MultiArray.linearIndexToSubscript(o,t),l=n.map((t,r)=>i.includes(r)?a[r]:e[r]),c=MultiArray.subscriptToLinearIndex(n,l),[u,h]=MultiArray.linearIndexToMultiArrayRowColumn(s.dimension[0],s.dimension[1],c),[d,m]=MultiArray.linearIndexToMultiArrayRowColumn(r.dimension[0],r.dimension[1],t);r.array[d][m]=RuntimeValue.copy(s.array[u][h])}MultiArray.setType(r);const[c,u]=MultiArray.linearIndexToMultiArrayRowColumn(l.dimension[0],l.dimension[1],t);l.array[c][u]=s.isCell?r:MultiArray.MultiArrayToScalar(r)}return l.isCell=!0,l};static cell2matSignature={inputs:{arity:1,parameters:[{name:"cellArray",classes:["cell"]}]},outputs:{arity:1}};static cell2mat=(t,...e)=>{AST.throwInvalidCallError("cell2mat",!(MultiArray.isInstanceOf(t)&&t.isCell&&0===e.length));const r=t;return MultiArray.isEmpty(r)?MultiArray.emptyArray():MultiArray.MultiArrayToScalar(CoreFunctions.cell2matCompose(r))};static cell2matBlock=t=>{if(MultiArray.isInstanceOf(t)&&t.isCell)throw new EvalError("cell2mat: nested cell contents are not supported.");return CharString.isInstanceOf(t)?MultiArray.characterVectorFromCharString(t):MultiArray.scalarToMultiArray(t)};static cell2matCompose=t=>{const e=[],r=Math.max(t.dimension.length,2),s=t.dimension.slice();MultiArray.appendSingletonTail(s,r);const i=s.map(t=>new Array(t));for(let n=0;n<MultiArray.linearLength(t);n++){const[a,o]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],n),l=CoreFunctions.cell2matBlock(t.array[a][o]);e[n]=l;const c=l.dimension.slice();MultiArray.appendSingletonTail(c,r);const u=MultiArray.linearIndexToSubscript(s,n);for(let t=0;t<r;t++){const e=u[t]-1,r=i[t][e];if(void 0===r)i[t][e]=c[t];else if(r!==c[t])throw new EvalError("cell2mat: dimension mismatch")}}const n=i.map(t=>{let e=0;return t.forEach(t=>{e+=t??0}),e}),a=i.map(t=>{let e=0;return t.map(t=>{const r=e;return e+=t??0,r})}),o=new MultiArray(n);for(let t=0;t<e.length;t++){const i=e[t],n=i.dimension.slice();MultiArray.appendSingletonTail(n,r);const l=MultiArray.linearIndexToSubscript(s,t);for(let t=0;t<MultiArray.linearLength(i);t++){const e=MultiArray.linearIndexToSubscript(n,t).map((t,e)=>a[e][l[e]-1]+t),[r,s]=MultiArray.linearIndexToMultiArrayRowColumn(i.dimension[0],i.dimension[1],t),[c,u]=MultiArray.subscriptToMultiArrayRowColumn(o.dimension,e);o.array[c][u]=RuntimeValue.copy(i.array[r][s])}}return MultiArray.setType(o),o};static mat2cellSignature={inputs:{arity:-2,min:2,parameters:[{name:"array"},{name:"dimensionSizes",classes:["double"],variadic:!0}]},outputs:{arity:1}};static mat2cell=(t,...e)=>{AST.throwInvalidCallError("mat2cell",!(void 0!==t&&e.length>0));const r=CharString.isInstanceOf(t)?MultiArray.characterVectorFromCharString(t):MultiArray.scalarToMultiArray(t);if(r.isCell)throw new EvalError("mat2cell: input must not be a cell array.");if(e.length!==r.dimension.length)throw new EvalError("mat2cell: number of dimension vectors must match ndims(A).");const s=e.map((t,e)=>CoreFunctions.mat2cellPartition(t,r.dimension[e],e+2)),i=new MultiArray(s.map(t=>t.length),void 0,!0),n=s.map(t=>{let e=0;return t.map(t=>{const r=e;return e+=t,r})});for(let t=0;t<MultiArray.linearLength(i);t++){const e=MultiArray.linearIndexToSubscript(i.dimension,t),a=e.map((t,e)=>s[e][t-1]),o=new MultiArray(a);for(let t=0;t<MultiArray.linearLength(o);t++){const s=MultiArray.linearIndexToSubscript(o.dimension,t).map((t,r)=>n[r][e[r]-1]+t),i=MultiArray.subscriptToLinearIndex(r.dimension,s),[a,l]=MultiArray.linearIndexToMultiArrayRowColumn(r.dimension[0],r.dimension[1],i),[c,u]=MultiArray.linearIndexToMultiArrayRowColumn(o.dimension[0],o.dimension[1],t);o.array[c][u]=RuntimeValue.copy(r.array[a][l])}MultiArray.setType(o);const[l,c]=MultiArray.linearIndexToMultiArrayRowColumn(i.dimension[0],i.dimension[1],t);i.array[l][c]=MultiArray.MultiArrayToScalar(o)}return i.isCell=!0,i};static mat2cellPartition=(t,e,r)=>{const s=MultiArray.linearize(MultiArray.scalarToMultiArray(t)).map(t=>{if(!Complex.isInstanceOf(t))throw new EvalError(`mat2cell: argument ${r} must contain nonnegative integer sizes.`);const e=Complex.realToNumber(t);if(!Number.isInteger(e)||e<0||0!==Complex.imagToNumber(t))throw new EvalError(`mat2cell: argument ${r} must contain nonnegative integer sizes.`);return e});if(s.reduce((t,e)=>t+e,0)!==e)throw new EvalError(`mat2cell: argument ${r} dimensions do not sum to input size.`);return s};static randSignature={inputs:[{arity:0},{arity:1,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],alternatives:[{name:"dimensions",validators:["numeric","vector","real","finite","integer","nonnegative"]}]}]},{arity:-2,min:2,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],variadic:!0}]}],outputs:{arity:1}};static rand=(...t)=>CoreFunctions.newFilledEach(()=>Complex.random(),...t);static randiSignature={inputs:[{arity:1,parameters:[{name:"range",alternatives:[{name:"imax",classes:["double"],validators:["numeric","scalar","real","finite","integer","positive"]},{name:"bounds",classes:["double"],validators:["numeric","vector","twoElement","real","finite","integer"]}]}]},{arity:2,parameters:[{name:"range",alternatives:[{name:"imax",classes:["double"],validators:["numeric","scalar","real","finite","integer","positive"]},{name:"bounds",classes:["double"],validators:["numeric","vector","twoElement","real","finite","integer"]}]},{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],alternatives:[{name:"dimensions",validators:["numeric","vector","real","finite","integer","nonnegative"]}]}]},{arity:-3,min:3,parameters:[{name:"range",alternatives:[{name:"imax",classes:["double"],validators:["numeric","scalar","real","finite","integer","positive"]},{name:"bounds",classes:["double"],validators:["numeric","vector","twoElement","real","finite","integer"]}]},{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],variadic:!0}]}],outputs:{arity:1}};static randi=(t,...e)=>{let r,s;if(MultiArray.isInstanceOf(t)){const e=MultiArray.linearize(t);if(2===e.length)r=e[0],s=e[1];else{if(!(e.length>0))throw new Error("bounds(1): out of bound 0 (dimensions are 0x0)");r=Complex.zero(),s=e[0]}}else r=Complex.zero(),s=t;if(!Complex.realIsInteger(r)||!Complex.realIsInteger(s))throw new Error("randi: must be integer bounds.");if(Complex.gt(s,r))return CoreFunctions.newFilledEach(Complex.realEquals(r,0)?()=>Complex.round(Complex.mul(s,Complex.random())):()=>Complex.round(Complex.add(Complex.mul(Complex.sub(s,r),Complex.random()),r)),...e);throw Complex.realEquals(r,0)?new Error("randi: require imax >= 1."):new Error("randi: require imax > imin.")};static catSignature={inputs:{arity:-2,min:2,parameters:[{name:"dimension",classes:["double"],validators:["dimension","positive"]},{name:"array",variadic:!0}]},outputs:{arity:1}};static cat=(t,...e)=>(CoreFunctions.validateObjectArrayConcatenation("cat",e),MultiArray.concatenate(Complex.realToNumber(MultiArray.firstElement(t))-1,"cat",...e.map(t=>MultiArray.scalarToMultiArray(t))));static horzcatSignature={inputs:{arity:-1,min:0,parameters:[{name:"array",variadic:!0}]},outputs:{arity:1}};static horzcat=(...t)=>0===t.length?MultiArray.emptyArray():(CoreFunctions.validateObjectArrayConcatenation("horzcat",t),MultiArray.concatenate(1,"horzcat",...t.map(t=>MultiArray.scalarToMultiArray(t))));static vertcatSignature={inputs:{arity:-1,min:0,parameters:[{name:"array",variadic:!0}]},outputs:{arity:1}};static vertcat=(...t)=>0===t.length?MultiArray.emptyArray():(CoreFunctions.validateObjectArrayConcatenation("vertcat",t),MultiArray.concatenate(0,"vertcat",...t.map(t=>MultiArray.scalarToMultiArray(t))));static allSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static all=MultiArray.reduceFactory((t,e)=>Complex.and(t,e),"reduce",Complex.one());static anySignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static any=MultiArray.reduceFactory((t,e)=>Complex.or(t,e),"reduce",Complex.zero());static sumSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static sum=MultiArray.reduceFactory((t,e)=>Complex.add(t,e),"reduce",Complex.zero());static prodSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static prod=MultiArray.reduceFactory((t,e)=>Complex.mul(t,e),"reduce",Complex.one());static sumsqSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static sumsq=MultiArray.reduceFactory((t,e)=>Complex.add(t,Complex.mul(e,e)),"reduce",Complex.zero());static cumsumSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static cumsum=MultiArray.reduceFactory((t,e)=>Complex.add(t,e),"cumulative");static cumprodSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static cumprod=MultiArray.reduceFactory((t,e)=>Complex.mul(t,e),"cumulative");static minSignature={inputs:[{arity:1,parameters:[{name:"value"}]},{arity:2,parameters:[{name:"value"},{name:"valueOrDimension",classes:["double"]}]},{arity:3,parameters:[{name:"value"},{name:"empty",classes:["double"],validators:["empty"]},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]}],outputs:{arity:-2}};static min=MultiArray.reduceFactory("lt","comparison");static maxSignature={inputs:[{arity:1,parameters:[{name:"value"}]},{arity:2,parameters:[{name:"value"},{name:"valueOrDimension",classes:["double"]}]},{arity:3,parameters:[{name:"value"},{name:"empty",classes:["double"],validators:["empty"]},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]}],outputs:{arity:-2}};static max=MultiArray.reduceFactory("gt","comparison");static cumminSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:-2}};static cummin=MultiArray.reduceFactory("lt","cumcomparison");static cummaxSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:-2}};static cummax=MultiArray.reduceFactory("gt","cumcomparison");static meanSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static mean=(t,e)=>{const r=MultiArray.scalarToMultiArray(t),s=void 0!==e?Complex.realToNumber(MultiArray.firstElement(e))-1:MultiArray.firstNonSingleDimension(r),i=CoreFunctions.sum(r,Complex.create(s+1)),n=Complex.create(r.dimension[s]);return MultiArray.divideElementByScalar(i,n)};static varianceSignature={inputs:[{arity:1,parameters:[{name:"value"}]},{arity:2,parameters:[{name:"value"},{name:"flagOrDimension",classes:["double"],validators:["numeric","scalar","real","finite","zeroOrOne"],alternatives:[{name:"dimension",validators:["dimensionGreaterThanOne"]}]}]},{arity:3,parameters:[{name:"value"},{name:"flag",classes:["double"],validators:["numeric","scalar","real","finite","zeroOrOne"]},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]}],outputs:{arity:1}};static variance=(t,e,r)=>{const s=MultiArray.scalarToMultiArray(t);let i,n=0;if(void 0!==e){const t=MultiArray.firstElement(e);if(void 0===r&&Complex.realIsInteger(t)&&Complex.realToNumber(t)>1)i=Complex.realToNumber(t)-1;else if(void 0!==r){n=1===Complex.realToNumber(t)?1:0;const e=MultiArray.firstElement(r);i=MultiArray.testInteger(e,"var","DIM",[1,1/0])-1}else n=1===Complex.realToNumber(t)?1:0,i=MultiArray.firstNonSingleDimension(s)}else if(void 0!==r){const t=MultiArray.firstElement(r);i=MultiArray.testInteger(t,"var","DIM",[1,1/0])-1}else i=MultiArray.firstNonSingleDimension(s);const a=s.dimension[i];if(a<=1)return Complex.zero();const o=MultiArray.reduce(i,s,(t,e)=>Complex.add(t,e),Complex.zero()),l=MultiArray.divideElementByScalar(o,Complex.create(a));let c;MultiArray.isInstanceOf(o)?c=o.dimension.slice():(c=s.dimension.slice(),c[i]=1);const u=new MultiArray(c),h=c.length>2?c.slice(2).reduce((t,e)=>t*e,1):1,d=c[0]*Math.max(1,h),m=c[1]??1;u.array=new Array(d);for(let t=0;t<d;t++)u.array[t]=new Array(m);const p=s.dimension.reduce((t,e)=>t*e,1);for(let t=0;t<p;t++){const e=MultiArray.linearIndexToSubscript(s.dimension,t).slice();let r;if(e[i]=1,MultiArray.isInstanceOf(l)){const t=l,s=MultiArray.subscriptToLinearIndex(t.dimension,e),[i,n]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],s);r=t.array[i][n]}else r=l;const[n,a]=MultiArray.linearIndexToMultiArrayRowColumn(s.dimension[0],s.dimension[1],t),o=s.array[n][a],h=Complex.sub(o,r),d=Complex.mul(h,h),m=MultiArray.subscriptToLinearIndex(c,e),[p,f]=MultiArray.linearIndexToMultiArrayRowColumn(c[0],c[1],m),g=u.array[p][f];u.array[p][f]=null==g?Complex.copy(d):Complex.add(g,d)}const f=Complex.create(a-(0===n?1:0)),g=MultiArray.divideElementByScalar(u,f);return MultiArray.isInstanceOf(g)&&MultiArray.setType(g),g};static stdSignature={inputs:[{arity:1,parameters:[{name:"value"}]},{arity:2,parameters:[{name:"value"},{name:"flagOrDimension",classes:["double"],validators:["numeric","scalar","real","finite","zeroOrOne"],alternatives:[{name:"dimension",validators:["dimensionGreaterThanOne"]}]}]},{arity:3,parameters:[{name:"value"},{name:"flag",classes:["double"],validators:["numeric","scalar","real","finite","zeroOrOne"]},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]}],outputs:{arity:1}};static std=(t,e,r)=>{const s=CoreFunctions.variance(t,e,r);if(MultiArray.isInstanceOf(s)){const t=MultiArray.rawMap(s,t=>Complex.sqrt(t));return MultiArray.setType(t),t}return Complex.sqrt(s)};static structSignature={inputs:[{arity:1,parameters:[{name:"structOrEmptyArray",alternatives:[{name:"field",classes:["char","string"]},{name:"struct",classes:["struct"]},{name:"emptyArray",classes:["double","cell","array"]}]}]},{arity:-1,min:0,parameters:[{name:"field",variadic:!0,variadicGroup:[{name:"field",classes:["char","string"]},{name:"value"}]}]}],outputs:{arity:1}};static struct=(...t)=>{const e='struct: additional arguments must occur as "field", VALUE pairs';if(0===t.length)return new Structure({});if(1===t.length){if(MultiArray.isInstanceOf(t[0])&&MultiArray.isEmpty(t[0]))return MultiArray.emptyArray();if(Structure.isInstanceOf(t[0]))return t[0].copy();throw new Error(e)}{if(t.length%2!=0)throw new Error(e);const r={};for(let s=0;s<t.length;s+=2){if(!CharString.isInstanceOf(t[s]))throw new Error(e);{const i=runtimeExpressionValue(t[s+1],t[s].str,"struct field",()=>{throw new Error(e)});r[t[s].str]=i}}return new Structure(r)}};static substructSignature={inputs:{arity:-1,min:2,parameters:[{name:"typeAndSubscript",variadic:!0,variadicGroup:[{name:"type",classes:["char","string"]},{name:"subscript"}]}]},outputs:{arity:1}};static substruct=(...t)=>{const e="substruct: arguments must occur as TYPE, SUBS pairs";if(t.length<2||t.length%2!=0)throw new Error(e);const r=[];for(let s=0;s<t.length;s+=2){const i=t[s],n=t[s+1];if(!CharString.isInstanceOf(i))throw new Error(e);r.push(CoreFunctions.createSubstructDescriptor(i.str,n))}return 1===r.length?r[0]:MultiArray.firstRow(r)};static createSubstructDescriptor=(t,e)=>{switch(t){case".":if(!CharString.isInstanceOf(e))throw new Error("substruct: dot subscripts must be character strings.");return new Structure({type:CharString.create(t),subs:e.copy()});case"()":case"{}":if(!MultiArray.isInstanceOf(e)||!e.isCell)throw new Error(`substruct: ${t} subscripts must be supplied as a cell array.`);return new Structure({type:CharString.create(t),subs:e.copy()});default:throw new Error("substruct: TYPE must be '.', '()', or '{}'.")}};static normSignature={inputs:[{arity:1,parameters:[{name:"value",classes:["double"]}]},{arity:2,parameters:[{name:"value",classes:["double"]},{name:"order",alternatives:[{name:"numericOrder",classes:["double"],validators:["numeric","scalar","real"]},{name:"frobeniusOrder",classes:["char","string"],allowedStrings:["fro"]}]}]}],outputs:{arity:1}};static isNonVectorMatrix2d=t=>MultiArray.isInstanceOf(t)&&2===t.dimension.length&&t.dimension[0]>1&&t.dimension[1]>1;static matrixNorm1=t=>{let e=0;for(let r=0;r<t.dimension[1];r++){let s=0;for(let e=0;e<t.dimension[0];e++)s+=Complex.realToNumber(Complex.abs(t.array[e][r]));e=Math.max(e,s)}return Complex.create(e)};static matrixNormInf=t=>{let e=0;for(let r=0;r<t.dimension[0];r++){let s=0;for(let e=0;e<t.dimension[1];e++)s+=Complex.realToNumber(Complex.abs(t.array[r][e]));e=Math.max(e,s)}return Complex.create(e)};static matrixNorm2=t=>{const e=t.dimension[1],r=Array.from({length:e},()=>Array.from({length:e},()=>Complex.zero()));for(let s=0;s<e;s++)for(let i=s;i<e;i++){let e=Complex.zero();for(let r=0;r<t.dimension[0];r++)e=Complex.add(e,Complex.mul(Complex.conj(t.array[r][s]),t.array[r][i]));r[s][i]=e,r[i][s]=s===i?e:Complex.conj(e)}const{D:s}=LAPACK.jacobi_symmetric_hermitian(r,1e3,1e-14),i=s.reduce((t,e)=>Math.max(t,Complex.realToNumber(e)),0);return Complex.sqrt(Complex.create(Math.max(0,i)))};static norm=(...t)=>{AST.throwInvalidCallError("norm",t.length<1||t.length>2);const e=t[0],r=MultiArray.linearize(MultiArray.scalarToMultiArray(e)).map(t=>Complex.abs(t)),s=2===t.length?t[1]:Complex.create(2);if(CharString.isInstanceOf(s))return"fro"!==s.str&&AST.throwInvalidCallError("norm"),Complex.sqrt(r.reduce((t,e)=>Complex.add(t,Complex.mul(e,e)),Complex.zero()));const i=Complex.realToNumber(MultiArray.firstElement(s));if(i===1/0)return CoreFunctions.isNonVectorMatrix2d(e)?CoreFunctions.matrixNormInf(e):r.reduce((t,e)=>Complex.realToNumber(e)>Complex.realToNumber(t)?e:t,Complex.zero());if(i===-1/0)return CoreFunctions.isNonVectorMatrix2d(e)&&AST.throwInvalidCallError("norm"),0===r.length?Complex.zero():r.reduce((t,e)=>Complex.realToNumber(e)<Complex.realToNumber(t)?e:t,Complex.inf_0());if(1===i)return CoreFunctions.isNonVectorMatrix2d(e)?CoreFunctions.matrixNorm1(e):r.reduce((t,e)=>Complex.add(t,e),Complex.zero());if(2===i)return CoreFunctions.isNonVectorMatrix2d(e)?CoreFunctions.matrixNorm2(e):Complex.sqrt(r.reduce((t,e)=>Complex.add(t,Complex.mul(e,e)),Complex.zero()));if(i>0&&Number.isFinite(i)){CoreFunctions.isNonVectorMatrix2d(e)&&AST.throwInvalidCallError("norm");const t=r.reduce((t,e)=>Complex.add(t,Complex.power(e,Complex.create(i))),Complex.zero());return Complex.power(t,Complex.create(1/i))}AST.throwInvalidCallError("norm")};static functions={isempty:{func:CoreFunctions.isempty,signature:CoreFunctions.isemptySignature},isscalar:{func:CoreFunctions.isscalar,signature:CoreFunctions.isscalarSignature},ismatrix:{func:CoreFunctions.ismatrix,signature:CoreFunctions.ismatrixSignature},isvector:{func:CoreFunctions.isvector,signature:CoreFunctions.isvectorSignature},iscell:{func:CoreFunctions.iscell,signature:CoreFunctions.iscellSignature},isrow:{func:CoreFunctions.isrow,signature:CoreFunctions.isrowSignature},iscolumn:{func:CoreFunctions.iscolumn,signature:CoreFunctions.iscolumnSignature},isstruct:{func:CoreFunctions.isstruct,signature:CoreFunctions.isstructSignature},issparse:{func:CoreFunctions.issparse,signature:CoreFunctions.issparseSignature},full:{func:CoreFunctions.full,signature:CoreFunctions.fullSignature},sparse:{func:CoreFunctions.sparse,signature:CoreFunctions.sparseSignature},spalloc:{func:CoreFunctions.spalloc,signature:CoreFunctions.spallocSignature},nnz:{func:CoreFunctions.nnz,signature:CoreFunctions.nnzSignature},nzmax:{func:CoreFunctions.nzmax,signature:CoreFunctions.nzmaxSignature},nonzeros:{func:CoreFunctions.nonzeros,signature:CoreFunctions.nonzerosSignature},ischar:{func:CoreFunctions.ischar,signature:CoreFunctions.ischarSignature},isstring:{func:CoreFunctions.isstring,signature:CoreFunctions.isstringSignature},iscellstr:{func:CoreFunctions.iscellstr,signature:CoreFunctions.iscellstrSignature},cellstr:{func:CoreFunctions.cellstr,signature:CoreFunctions.cellstrSignature},char:{func:CoreFunctions.char,signature:CoreFunctions.charSignature},double:{func:CoreFunctions.double,signature:CoreFunctions.doubleSignature},logical:{func:CoreFunctions.logical,signature:CoreFunctions.logicalSignature},isnan:{func:CoreFunctions.isnan,signature:CoreFunctions.isnanSignature},isinf:{func:CoreFunctions.isinf,signature:CoreFunctions.isinfSignature},isfinite:{func:CoreFunctions.isfinite,signature:CoreFunctions.isfiniteSignature},isfloat:{func:CoreFunctions.isfloat,signature:CoreFunctions.isfloatSignature},isinteger:{func:CoreFunctions.isinteger,signature:CoreFunctions.isintegerSignature},isnumeric:{func:CoreFunctions.isnumeric,signature:CoreFunctions.isnumericSignature},islogical:{func:CoreFunctions.islogical,signature:CoreFunctions.islogicalSignature},isreal:{func:CoreFunctions.isreal,signature:CoreFunctions.isrealSignature},isvalid:{func:CoreFunctions.isvalid,signature:CoreFunctions.isvalidSignature},isobject:{func:CoreFunctions.isobject,signature:CoreFunctions.isobjectSignature},properties:{func:CoreFunctions.properties,signature:CoreFunctions.propertiesSignature},fieldnames:{func:CoreFunctions.fieldnames,signature:CoreFunctions.fieldnamesSignature},isfield:{func:CoreFunctions.isfield,signature:CoreFunctions.isfieldSignature},methods:{func:CoreFunctions.methods,signature:CoreFunctions.methodsSignature},events:{func:CoreFunctions.events,signature:CoreFunctions.eventsSignature},enumeration:{func:CoreFunctions.enumeration,signature:CoreFunctions.enumerationSignature},superclasses:{func:CoreFunctions.superclasses,signature:CoreFunctions.superclassesSignature},isprop:{func:CoreFunctions.isprop,signature:CoreFunctions.ispropSignature},ismethod:{func:CoreFunctions.ismethod,signature:CoreFunctions.ismethodSignature},isequal:{func:CoreFunctions.isequal,signature:CoreFunctions.isequalSignature},ndims:{func:CoreFunctions.ndims,signature:CoreFunctions.ndimsSignature},rows:{func:CoreFunctions.rows,signature:CoreFunctions.rowsSignature},columns:{func:CoreFunctions.columns,signature:CoreFunctions.columnsSignature},length:{func:CoreFunctions.Length,signature:CoreFunctions.lengthSignature},numel:{func:CoreFunctions.numel,signature:CoreFunctions.numelSignature},find:{func:CoreFunctions.find,signature:CoreFunctions.findSignature},sort:{func:CoreFunctions.sort,signature:CoreFunctions.sortSignature},ind2sub:{func:CoreFunctions.ind2sub,signature:CoreFunctions.ind2subSignature},sub2ind:{func:CoreFunctions.sub2ind,signature:CoreFunctions.sub2indSignature},size:{func:CoreFunctions.size,signature:CoreFunctions.sizeSignature},colon:{func:CoreFunctions.colon,signature:CoreFunctions.colonSignature},linspace:{func:CoreFunctions.linspace,signature:CoreFunctions.linspaceSignature},logspace:{func:CoreFunctions.logspace,signature:CoreFunctions.logspaceSignature},meshgrid:{func:CoreFunctions.meshgrid,signature:CoreFunctions.meshgridSignature},ndgrid:{func:CoreFunctions.ndgrid,signature:CoreFunctions.ndgridSignature},repmat:{func:CoreFunctions.repmat,signature:CoreFunctions.repmatSignature},reshape:{func:CoreFunctions.reshape,signature:CoreFunctions.reshapeSignature},squeeze:{func:CoreFunctions.squeeze,signature:CoreFunctions.squeezeSignature},flip:{func:CoreFunctions.flip,signature:CoreFunctions.flipSignature},fliplr:{func:CoreFunctions.fliplr,signature:CoreFunctions.fliplrSignature},flipud:{func:CoreFunctions.flipud,signature:CoreFunctions.flipudSignature},rot90:{func:CoreFunctions.rot90,signature:CoreFunctions.rot90Signature},permute:{func:CoreFunctions.permute,signature:CoreFunctions.permuteSignature},ipermute:{func:CoreFunctions.ipermute,signature:CoreFunctions.ipermuteSignature},circshift:{func:CoreFunctions.circshift,signature:CoreFunctions.circshiftSignature},shiftdim:{func:CoreFunctions.shiftdim,signature:CoreFunctions.shiftdimSignature},zeros:{func:CoreFunctions.zeros,signature:CoreFunctions.zerosSignature},ones:{func:CoreFunctions.ones,signature:CoreFunctions.onesSignature},cell:{func:CoreFunctions.cell,signature:CoreFunctions.cellSignature},num2cell:{func:CoreFunctions.num2cell,signature:CoreFunctions.num2cellSignature},cell2mat:{func:CoreFunctions.cell2mat,signature:CoreFunctions.cell2matSignature},mat2cell:{func:CoreFunctions.mat2cell,signature:CoreFunctions.mat2cellSignature},rand:{func:CoreFunctions.rand,signature:CoreFunctions.randSignature},randi:{func:CoreFunctions.randi,signature:CoreFunctions.randiSignature},cat:{func:CoreFunctions.cat,signature:CoreFunctions.catSignature},horzcat:{func:CoreFunctions.horzcat,signature:CoreFunctions.horzcatSignature},vertcat:{func:CoreFunctions.vertcat,signature:CoreFunctions.vertcatSignature},all:{func:CoreFunctions.all,signature:CoreFunctions.allSignature},any:{func:CoreFunctions.any,signature:CoreFunctions.anySignature},sum:{func:CoreFunctions.sum,signature:CoreFunctions.sumSignature},prod:{func:CoreFunctions.prod,signature:CoreFunctions.prodSignature},sumsq:{func:CoreFunctions.sumsq,signature:CoreFunctions.sumsqSignature},max:{func:CoreFunctions.max,signature:CoreFunctions.maxSignature},min:{func:CoreFunctions.min,signature:CoreFunctions.minSignature},mean:{func:CoreFunctions.mean,signature:CoreFunctions.meanSignature},cumsum:{func:CoreFunctions.cumsum,signature:CoreFunctions.cumsumSignature},cumprod:{func:CoreFunctions.cumprod,signature:CoreFunctions.cumprodSignature},cummin:{func:CoreFunctions.cummin,signature:CoreFunctions.cumminSignature},cummax:{func:CoreFunctions.cummax,signature:CoreFunctions.cummaxSignature},var:{func:CoreFunctions.variance,signature:CoreFunctions.varianceSignature},std:{func:CoreFunctions.std,signature:CoreFunctions.stdSignature},struct:{func:CoreFunctions.struct,signature:CoreFunctions.structSignature},getfield:{func:CoreFunctions.getfield,signature:CoreFunctions.getfieldSignature},setfield:{func:CoreFunctions.setfield,signature:CoreFunctions.setfieldSignature},rmfield:{func:CoreFunctions.rmfield,signature:CoreFunctions.rmfieldSignature},orderfields:{func:CoreFunctions.orderfields,signature:CoreFunctions.orderfieldsSignature},numfields:{func:CoreFunctions.numfields,signature:CoreFunctions.numfieldsSignature},struct2cell:{func:CoreFunctions.struct2cell,signature:CoreFunctions.struct2cellSignature},cell2struct:{func:CoreFunctions.cell2struct,signature:CoreFunctions.cell2structSignature},substruct:{func:CoreFunctions.substruct,signature:CoreFunctions.substructSignature},norm:{func:CoreFunctions.norm,signature:CoreFunctions.normSignature}}}const src_CoreFunctions=null;class Configuration{static roundingName=roundingName;static moduloName=moduloName;static configuration={blockThreshold:{set:t=>BLAS.set({blockThreshold:MultiArray.testInteger(Configuration.requireComplex(t),"configure","blockThreshold configuration parameter")}),setDefault:()=>BLAS.set({blockThreshold:BLAS.defaultSettings.blockThreshold}),get:()=>Complex.create(BLAS.settings.blockThreshold)},blockSize:{set:t=>BLAS.set({blockSize:MultiArray.testInteger(Configuration.requireComplex(t),"configure","blockSize configuration parameter")}),setDefault:()=>BLAS.set({blockSize:BLAS.defaultSettings.blockSize}),get:()=>Complex.create(BLAS.settings.blockSize)},real:{set:t=>Complex.engine=Configuration.requireCharString(t).str,setDefault:()=>Complex.engine="decimal",get:()=>new CharString(Complex.engine)},precision:{set:t=>Complex.set({precision:Complex.realToNumber(Configuration.requireComplex(t))}),setDefault:()=>Complex.set({precision:Complex.defaultSettings.precision}),get:()=>Complex.create(Complex.settings.precision)},precisionCompare:{set:t=>Complex.set({precisionCompare:Complex.realToNumber(Configuration.requireComplex(t))}),setDefault:()=>Complex.set({precisionCompare:Complex.defaultSettings.precisionCompare}),get:()=>Complex.create(Complex.settings.precisionCompare)},rounding:{set:t=>{const e=Configuration.requireCharString(t),r=Configuration.roundingName.indexOf(e.str);if(!(r>0))throw new Error(`configure: invalid rounding mode: ${e.str}`);Complex.set({rounding:r})},setDefault:()=>Complex.set({rounding:Complex.defaultSettings.rounding}),get:()=>new CharString(Configuration.roundingName[Complex.settings.rounding])},toExpPos:{set:t=>Complex.set({toExpPos:Complex.realToNumber(Configuration.requireComplex(t))}),setDefault:()=>Complex.set({toExpPos:Complex.defaultSettings.toExpPos}),get:()=>Complex.create(Complex.settings.toExpPos)},toExpNeg:{set:t=>Complex.set({toExpNeg:Complex.realToNumber(Configuration.requireComplex(t))}),setDefault:()=>Complex.set({toExpNeg:Complex.defaultSettings.toExpNeg}),get:()=>Complex.create(Complex.settings.toExpNeg)},minE:{set:t=>Complex.set({minE:Complex.realToNumber(Configuration.requireComplex(t))}),setDefault:()=>Complex.set({minE:Complex.defaultSettings.minE}),get:()=>Complex.create(Complex.settings.minE)},maxE:{set:t=>Complex.set({maxE:Complex.realToNumber(Configuration.requireComplex(t))}),setDefault:()=>Complex.set({maxE:Complex.defaultSettings.maxE}),get:()=>Complex.create(Complex.settings.maxE)},modulo:{set:t=>{const e=Configuration.requireCharString(t),r=Configuration.moduloName.indexOf(e.str);if(!(r>0))throw new Error(`configure: invalid modulo mode: ${e.str}`);Complex.set({modulo:r})},setDefault:()=>Complex.set({modulo:Complex.defaultSettings.modulo}),get:()=>new CharString(Configuration.moduloName[Complex.settings.modulo])},crypto:{set:t=>Complex.set({crypto:Boolean(Complex.realToNumber(Configuration.requireComplex(t)))}),setDefault:()=>Complex.set({crypto:Complex.defaultSettings.crypto}),get:()=>Complex.create(Number(Complex.settings.crypto),0,Complex.LOGICAL)}};static requireComplex=t=>{if(Complex.isInstanceOf(t))return t;throw AST.throwInvalidCallError("configure"),new Error("unreachable")};static requireCharString=t=>{if(CharString.isInstanceOf(t))return t;throw AST.throwInvalidCallError("configure"),new Error("unreachable")};static configurationEntry=t=>Configuration.configuration[t];static configureSignature={inputs:{arity:-2,min:0,max:2,parameters:[{name:"configuration",optional:!0,alternatives:[{name:"name",classes:["char","string"]},{name:"configurationList",classes:["cell"]}]},{name:"value",optional:!0}]},outputs:{arity:1}};static configure(...t){const e=(t,e)=>{if(CharString.isInstanceOf(t)){const r=Configuration.configurationEntry(t.str);if(!r)throw new ReferenceError(`configure: invalid configuration: '${t.str}'.`);r.set(e)}else AST.throwInvalidCallError("configure")};if(0===t.length){for(const t in Configuration.configuration)Configuration.configuration[t].setDefault();return new CharString("All configuration set to default values.")}if(1===t.length&&MultiArray.isInstanceOf(t[0])){if(2===t[0].dimension[1])return t[0].array.forEach(t=>{e(t[0],t[1])}),new CharString(`${t[0].array.length} configuration values set.`);AST.throwInvalidCallError("configure")}else{if(2===t.length&&CharString.isInstanceOf(t[0]))return e(t[0],t[1]),new CharString(`Configuration parameter '${t[0].str}' set to '${Configuration.configuration[t[0].str].get().toString()}'`);AST.throwInvalidCallError("configure")}}static getconfigSignature={inputs:{arity:-1,min:0,max:1,parameters:[{name:"configuration",optional:!0,alternatives:[{name:"name",classes:["char","string"]},{name:"configurationList",classes:["cell"]}]}]},outputs:{arity:1}};static getconfig(...t){let e;const r=Object.keys(Configuration.configuration),s=t=>{t.forEach((t,r)=>{const s=Configuration.configuration[t].get();e.array[r]=[new CharString(t),s]})};if(0===t.length)return e=new MultiArray([r.length,2],null,!0),s(r),e;if(1===t.length){const r=MultiArray.linearize(MultiArray.scalarToMultiArray(t[0])).map(t=>{if(CharString.isInstanceOf(t)&&t.str in Configuration.configuration)return t.str;throw new Error("getconfig: invalid configuration parameter.")});return e=new MultiArray([r.length,2],null,!0),s(r),e}AST.throwInvalidCallError("getconfig")}static functions={configure:{func:Configuration.configure,signature:Configuration.configureSignature},getconfig:{func:Configuration.getconfig,signature:Configuration.getconfigSignature}}}const src_Configuration=null;class MathML{static format={"+":(t,e)=>t+'<mo form="infix" stretchy="true">+</mo>'+e,"-":(t,e)=>t+'<mo form="infix" stretchy="true">-</mo>'+e,".*":(t,e)=>t+'<mo form="infix" stretchy="true">.*</mo>'+e,"./":(t,e)=>t+'<mo form="infix" stretchy="true">./</mo>'+e,".\\":(t,e)=>t+'<mo form="infix" stretchy="true">.\\</mo>'+e,"\\":(t,e)=>t+'<mo form="infix" stretchy="true">\\</mo>'+e,".^":(t,e)=>t+'<mo form="infix" stretchy="true">.^</mo>'+e,".**":(t,e)=>t+'<mo form="infix" stretchy="true">.**</mo>'+e,"<":(t,e)=>t+'<mo form="infix" stretchy="true"><</mo>'+e,"<=":(t,e)=>t+'<mo form="infix" stretchy="true">≤</mo>'+e,">":(t,e)=>t+'<mo form="infix" stretchy="true">></mo>'+e,">=":(t,e)=>t+'<mo form="infix" stretchy="true">≥</mo>'+e,"==":(t,e)=>t+'<mo form="infix" stretchy="true">==</mo>'+e,"!=":(t,e)=>t+'<mo form="infix" stretchy="true">≠</mo>'+e,"~=":(t,e)=>t+'<mo form="infix" stretchy="true">≠</mo>'+e,"&":(t,e)=>t+'<mo form="infix" stretchy="true">&</mo>'+e,"|":(t,e)=>t+'<mo form="infix" stretchy="true">|</mo>'+e,"&&":(t,e)=>t+'<mo form="infix" stretchy="true">&&</mo>'+e,"||":(t,e)=>t+'<mo form="infix" stretchy="true">||</mo>'+e,"=":(t,e)=>t+'<mo form="infix" stretchy="true">=</mo>'+e,"+=":(t,e)=>t+'<mo form="infix" stretchy="true">+=</mo>'+e,"-=":(t,e)=>t+'<mo form="infix" stretchy="true">-=</mo>'+e,"*=":(t,e)=>t+'<mo form="infix" stretchy="true">*=</mo>'+e,"/=":(t,e)=>t+'<mo form="infix" stretchy="true">/=</mo>'+e,"\\=":(t,e)=>t+'<mo form="infix" stretchy="true">\\=</mo>'+e,"^=":(t,e)=>t+'<mo form="infix" stretchy="true">^=</mo>'+e,"**=":(t,e)=>t+'<mo form="infix" stretchy="true">**=</mo>'+e,".*=":(t,e)=>t+'<mo form="infix" stretchy="true">.*=</mo>'+e,"./=":(t,e)=>t+'<mo form="infix" stretchy="true">./=</mo>'+e,".\\=":(t,e)=>t+'<mo form="infix" stretchy="true">.\\=</mo>'+e,".^=":(t,e)=>t+'<mo form="infix" stretchy="true">.^=</mo>'+e,".**=":(t,e)=>t+'<mo form="infix" stretchy="true">.**=</mo>'+e,"&=":(t,e)=>t+'<mo form="infix" stretchy="true">&=</mo>'+e,"|=":(t,e)=>t+'<mo form="infix" stretchy="true">|=</mo>'+e,"*":(t,e)=>t+'<mo form="infix" stretchy="true">×</mo>'+e,"+_":t=>'<mo form="prefix" stretchy="true">+</mo>'+t,"-_":t=>'<mo form="prefix" stretchy="true">-</mo>'+t,"++_":t=>'<mo form="prefix" stretchy="true">++</mo>'+t,"--_":t=>'<mo form="prefix" stretchy="true">--</mo>'+t,"_++":t=>t+'<mo form="postfix" stretchy="true">++</mo>',"_--":t=>t+'<mo form="postfix" stretchy="true">--</mo>',"!":t=>'<mo form="prefix" stretchy="true">!</mo>'+t,"~":t=>'<mo form="prefix" stretchy="true">~</mo>'+t,"/":(t,e)=>"<mfrac><mrow>"+t+"</mrow><mrow>"+e+"</mrow></mfrac>","^":(t,e)=>"<msup><mrow>"+t+"</mrow><mrow>"+e+"</mrow></msup>","**":(t,e)=>"<msup><mrow>"+t+"</mrow><mrow>"+e+"</mrow></msup>",".'":t=>"<msup><mrow>"+t+"</mrow><mrow><mi>T</mi></mrow></msup>","'":t=>"<msup><mrow>"+t+"</mrow><mrow><mi>H</mi></mrow></msup>","()":(t,e,r)=>'<mo fence="true" stretchy="true">'+t+"</mo>"+e+'<mo fence="true" stretchy="true">'+r+"</mo>",IDENT:t=>"<mi>"+t+"</mi>",".":(t,e)=>t+"<mo>.</mo>"+e.join("<mo>.</mo>"),LIST:t=>"<mtable>"+t.map(t=>"<mtr><mtd>"+t+"</mtd></mtr>").join("")+"</mtable>",RANGE:(...t)=>t.length?t.join("<mo>:</mo>"):"<mo>:</mo>",ENDRANGE:()=>"<mi>end</mi>",":":()=>"<mo>:</mo>","<~>":()=>"<mo>~</mo>",IDX:(t,e,r,s)=>t+'<mrow><mo fence="true" stretchy="true">'+e+"</mo>"+r.join("<mo>,</mo>")+'<mo fence="true" stretchy="true">'+s+"</mo></mrow>",RETLIST:()=>"<mi>RETLIST</mi>",CMDWLIST:(t,e)=>"<mrow><mtext>"+t+"</mtext> "+e.join(" ")+"</mrow>",PERSIST:()=>"",FCNDEF:()=>"",VOID:()=>"",INVALID:()=>"<mi>invalid</mi>",UNDEFINED:()=>"<mi>undefined tree</mi>",ERROR:()=>"<mi>error</mi>",math:(t,e)=>"none"===e?t:'<math xmlns = "http://www.w3.org/1998/Math/MathML" display="'+e+'">'+t+"</math>",errorReplace:t=>t.replace(/\<mo\>\(\<\/mo\>\<mi\>error\<\/mi\><\mi\>error\<\/mi\>\<mi\>i\<\/mi\>\<mo\>\)\<\/mo\>/gi,"<mi>error</mi>"),abs:(...t)=>'<mrow><mo fence="true" stretchy="true">|</mo>'+t[0]+'<mo fence="true" stretchy="true">|</mo></mrow>',conj:(...t)=>'<mover accent="true"><mrow>'+t[0]+'</mrow><mo stretchy="true">‾</mo></mover>',sqrt:(...t)=>"<msqrt><mrow>"+t[0]+"</mrow></msqrt>",root:(...t)=>"<mroot><mrow>"+t[0]+"</mrow><mrow>"+t[1]+"</mrow></mroot>",exp:(...t)=>"<msup><mi>e</mi><mrow>"+t[0]+"</mrow></msup>",logb:(...t)=>"<mrow><msub><mi>log</mi><mrow>"+t[0]+"</mrow></msub><mrow>"+t[1]+"</mrow></mrow>",log2:(...t)=>"<mrow><msub><mi>log</mi><mrow><mn>2</mn></mrow></msub><mrow>"+t[0]+"</mrow></mrow>",log10:(...t)=>"<mrow><msub><mi>log</mi><mrow><mn>10</mn></mrow></msub><mrow>"+t[0]+"</mrow></mrow>",gamma:(...t)=>'<mi>Γ</mi><mrow><mo fence="true" stretchy="true">(</mo>'+t[0]+'<mo fence="true" stretchy="true">)</mo></mrow>',factorial:(...t)=>"<mrow>"+t[0]+'</mrow><mo format="postfix" stretchy="true">!</mo>'};static formatFunction=t=>{const e=MathML.format[t];return"function"==typeof e?e:void 0};static formatDynamic=(t,...e)=>{const r=MathML.formatFunction(t);if(!r)throw new Error(`MathML formatter '${t}' is not defined.`);return r(...e)}}const format=MathML.format,src_MathML=null;var antlr4_node=__webpack_require__(990),MathJSLabLexer=__webpack_require__(207);class MathJSLabParser extends antlr4_node.iX{static GLOBAL=1;static PERSISTENT=2;static IMPORT=3;static IF=4;static ENDIF=5;static END=6;static ENDRANGE=7;static ELSEIF=8;static ELSE=9;static SWITCH=10;static ENDSWITCH=11;static CASE=12;static OTHERWISE=13;static WHILE=14;static ENDWHILE=15;static DO=16;static UNTIL=17;static FOR=18;static ENDFOR=19;static PARFOR=20;static ENDPARFOR=21;static SPMD=22;static ENDSPMD=23;static BREAK=24;static CONTINUE=25;static RETURN=26;static FUNCTION=27;static ENDFUNCTION=28;static TRY=29;static CATCH=30;static END_TRY_CATCH=31;static UNWIND_PROTECT=32;static UNWIND_PROTECT_CLEANUP=33;static END_UNWIND_PROTECT=34;static CLASSDEF=35;static ENDCLASSDEF=36;static ENUMERATION=37;static ENDENUMERATION=38;static PROPERTIES=39;static ENDPROPERTIES=40;static EVENTS=41;static ENDEVENTS=42;static METHODS=43;static ENDMETHODS=44;static WSPACE=45;static STRING=46;static ARGUMENTS=47;static ENDARGUMENTS=48;static PLUS=49;static MINUS=50;static MUL=51;static DIV=52;static EQ=53;static COLON=54;static SEMICOLON=55;static COMMA=56;static DOT=57;static TILDE=58;static EXCLAMATION=59;static COMMAT=60;static QUESTION=61;static LPAREN=62;static RPAREN=63;static LBRACKET=64;static RBRACKET=65;static LCURLYBR=66;static RCURLYBR=67;static LEFTDIV=68;static ADD_EQ=69;static SUB_EQ=70;static MUL_EQ=71;static DIV_EQ=72;static LEFTDIV_EQ=73;static POW_EQ=74;static EMUL_EQ=75;static EDIV_EQ=76;static ELEFTDIV_EQ=77;static EPOW_EQ=78;static AND_EQ=79;static OR_EQ=80;static EXPR_AND_AND=81;static EXPR_OR_OR=82;static EXPR_AND=83;static EXPR_OR=84;static EXPR_LT=85;static EXPR_LE=86;static EXPR_EQ=87;static EXPR_NE=88;static EXPR_GE=89;static EXPR_GT=90;static EMUL=91;static EDIV=92;static ELEFTDIV=93;static PLUS_PLUS=94;static MINUS_MINUS=95;static POW=96;static EPOW=97;static TRANSPOSE=98;static HERMITIAN=99;static DQSTRING=100;static IDENTIFIER=101;static FLOAT_NUMBER=102;static NUMBER_DOT_OP=103;static LINE_CONTINUATION=104;static SPACE_OR_CONTINUATION=105;static NEWLINE=106;static BLOCK_COMMENT_START=107;static COMMENT_LINE=108;static INVALID=109;static SINGLEQ_STRING=110;static SINGLEQ_NL=111;static SINGLEQ_SINGLEQ=112;static SINGLEQ_END=113;static DOUBLEQ_STRING=114;static DOUBLEQ_NL=115;static DOUBLEQ_DOUBLEQ=116;static DOUBLEQ_ESCAPE=117;static DOUBLEQ_ESCAPE_OTHER=118;static DOUBLEQ_ESCAPE_OCT=119;static DOUBLEQ_ESCAPE_HEX=120;static DOUBLEQ_ESCAPE_UNICODE=121;static DOUBLEQ_END=122;static BLOCK_COMMENT_START_AGAIN=123;static BLOCK_COMMENT_END=124;static BLOCK_COMMENT_LINE=125;static BLOCK_COMMENT_EOF=126;static COMMAND_LINE_CONTINUATION=127;static COMMAND_CONTINUED_BLOCK_COMMENT_START=128;static COMMAND_CONTINUED_COMMENT_LINE=129;static COMMAND_CONTINUED_NEWLINE=130;static SKIP_SPACE=131;static COMMAND_LONE_DQUOTE=132;static COMMAND_LONE_SQUOTE=133;static COMMAND_UNCLOSED_DQUOTE=134;static COMMAND_UNCLOSED_SQUOTE=135;static COMMAND_DQSTRING=136;static COMMAND_SQSTRING=137;static SKIP_COMMENT_LINE=138;static COMMAND_SEPARATOR=139;static EXIT_AT_NEWLINE=140;static EXIT_AT_EOF=141;static UNQUOTED_STRING=142;static EOF=antlr4_node.ou.EOF;static RULE_input=0;static RULE_global_list=1;static RULE_list=2;static RULE_statement=3;static RULE_word_list_cmd=4;static RULE_command_word=5;static RULE_identifier=6;static RULE_qualified_identifier_part=7;static RULE_qualified_identifier=8;static RULE_string=9;static RULE_number=10;static RULE_end_range=11;static RULE_constant=12;static RULE_matrix=13;static RULE_matrix_row=14;static RULE_fcn_handle=15;static RULE_meta_class=16;static RULE_anon_fcn_handle=17;static RULE_primary_expr=18;static RULE_magic_colon=19;static RULE_magic_tilde=20;static RULE_list_element=21;static RULE_arg_list=22;static RULE_oper_expr=23;static RULE_power_expr=24;static RULE_colon_expr=25;static RULE_simple_expr=26;static RULE_expression=27;static RULE_assign_lhs=28;static RULE_assign_list=29;static RULE_command=30;static RULE_declaration=31;static RULE_declaration_element=32;static RULE_import_command=33;static RULE_import_name=34;static RULE_select_command=35;static RULE_if_command=36;static RULE_elseif_clause=37;static RULE_else_clause=38;static RULE_switch_command=39;static RULE_switch_case_list=40;static RULE_switch_case=41;static RULE_otherwise_case=42;static RULE_loop_command=43;static RULE_while_command=44;static RULE_do_until_command=45;static RULE_for_command=46;static RULE_spmd_command=47;static RULE_spmd_worker_spec=48;static RULE_jump_command=49;static RULE_except_command=50;static RULE_try_command=51;static RULE_catch_clause=52;static RULE_unwind_command=53;static RULE_unwind_cleanup_clause=54;static RULE_param_list=55;static RULE_param_list_elt=56;static RULE_return_list_elt=57;static RULE_return_list=58;static RULE_function=59;static RULE_function_name=60;static RULE_classdef_command=61;static RULE_class_attribute_list=62;static RULE_class_attribute=63;static RULE_class_method_name=64;static RULE_class_superclass_list=65;static RULE_class_section_list=66;static RULE_class_section=67;static RULE_properties_section=68;static RULE_class_property_list=69;static RULE_class_property=70;static RULE_methods_section=71;static RULE_class_method=72;static RULE_class_method_list=73;static RULE_events_section=74;static RULE_class_event_list=75;static RULE_class_event=76;static RULE_enumeration_section=77;static RULE_class_enumeration_list=78;static RULE_class_enumeration=79;static RULE_arguments_block_list=80;static RULE_arguments_block=81;static RULE_arguments_attribute_list=82;static RULE_args_validation_list=83;static RULE_arg_validation=84;static RULE_arg_validation_name=85;static RULE_sep_no_nl=86;static RULE_nl=87;static RULE_sep=88;static literalNames=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"'+'","'-'","'*'","'/'","'='","':'","';'","','","'.'","'~'","'!'","'@'","'?'","'('","')'","'['","']'","'{'","'}'","'\\'","'+='","'-='","'*='","'/='","'\\='",null,"'.*='","'./='","'.\\='",null,"'&='","'|='","'&&'","'||'","'&'","'|'","'<'","'<='","'=='",null,"'>='","'>'","'.*'","'./'","'.\\'","'++'","'--'",null,null,"'.''",null,null,null,null,null,null,null,null,null,null,null,null,null,"''''",null,null,null,"'\"\"'"];static symbolicNames=[null,"GLOBAL","PERSISTENT","IMPORT","IF","ENDIF","END","ENDRANGE","ELSEIF","ELSE","SWITCH","ENDSWITCH","CASE","OTHERWISE","WHILE","ENDWHILE","DO","UNTIL","FOR","ENDFOR","PARFOR","ENDPARFOR","SPMD","ENDSPMD","BREAK","CONTINUE","RETURN","FUNCTION","ENDFUNCTION","TRY","CATCH","END_TRY_CATCH","UNWIND_PROTECT","UNWIND_PROTECT_CLEANUP","END_UNWIND_PROTECT","CLASSDEF","ENDCLASSDEF","ENUMERATION","ENDENUMERATION","PROPERTIES","ENDPROPERTIES","EVENTS","ENDEVENTS","METHODS","ENDMETHODS","WSPACE","STRING","ARGUMENTS","ENDARGUMENTS","PLUS","MINUS","MUL","DIV","EQ","COLON","SEMICOLON","COMMA","DOT","TILDE","EXCLAMATION","COMMAT","QUESTION","LPAREN","RPAREN","LBRACKET","RBRACKET","LCURLYBR","RCURLYBR","LEFTDIV","ADD_EQ","SUB_EQ","MUL_EQ","DIV_EQ","LEFTDIV_EQ","POW_EQ","EMUL_EQ","EDIV_EQ","ELEFTDIV_EQ","EPOW_EQ","AND_EQ","OR_EQ","EXPR_AND_AND","EXPR_OR_OR","EXPR_AND","EXPR_OR","EXPR_LT","EXPR_LE","EXPR_EQ","EXPR_NE","EXPR_GE","EXPR_GT","EMUL","EDIV","ELEFTDIV","PLUS_PLUS","MINUS_MINUS","POW","EPOW","TRANSPOSE","HERMITIAN","DQSTRING","IDENTIFIER","FLOAT_NUMBER","NUMBER_DOT_OP","LINE_CONTINUATION","SPACE_OR_CONTINUATION","NEWLINE","BLOCK_COMMENT_START","COMMENT_LINE","INVALID","SINGLEQ_STRING","SINGLEQ_NL","SINGLEQ_SINGLEQ","SINGLEQ_END","DOUBLEQ_STRING","DOUBLEQ_NL","DOUBLEQ_DOUBLEQ","DOUBLEQ_ESCAPE","DOUBLEQ_ESCAPE_OTHER","DOUBLEQ_ESCAPE_OCT","DOUBLEQ_ESCAPE_HEX","DOUBLEQ_ESCAPE_UNICODE","DOUBLEQ_END","BLOCK_COMMENT_START_AGAIN","BLOCK_COMMENT_END","BLOCK_COMMENT_LINE","BLOCK_COMMENT_EOF","COMMAND_LINE_CONTINUATION","COMMAND_CONTINUED_BLOCK_COMMENT_START","COMMAND_CONTINUED_COMMENT_LINE","COMMAND_CONTINUED_NEWLINE","SKIP_SPACE","COMMAND_LONE_DQUOTE","COMMAND_LONE_SQUOTE","COMMAND_UNCLOSED_DQUOTE","COMMAND_UNCLOSED_SQUOTE","COMMAND_DQSTRING","COMMAND_SQSTRING","SKIP_COMMENT_LINE","COMMAND_SEPARATOR","EXIT_AT_NEWLINE","EXIT_AT_EOF","UNQUOTED_STRING"];static ruleNames=["input","global_list","list","statement","word_list_cmd","command_word","identifier","qualified_identifier_part","qualified_identifier","string","number","end_range","constant","matrix","matrix_row","fcn_handle","meta_class","anon_fcn_handle","primary_expr","magic_colon","magic_tilde","list_element","arg_list","oper_expr","power_expr","colon_expr","simple_expr","expression","assign_lhs","assign_list","command","declaration","declaration_element","import_command","import_name","select_command","if_command","elseif_clause","else_clause","switch_command","switch_case_list","switch_case","otherwise_case","loop_command","while_command","do_until_command","for_command","spmd_command","spmd_worker_spec","jump_command","except_command","try_command","catch_clause","unwind_command","unwind_cleanup_clause","param_list","param_list_elt","return_list_elt","return_list","function","function_name","classdef_command","class_attribute_list","class_attribute","class_method_name","class_superclass_list","class_section_list","class_section","properties_section","class_property_list","class_property","methods_section","class_method","class_method_list","events_section","class_event_list","class_event","enumeration_section","class_enumeration_list","class_enumeration","arguments_block_list","arguments_block","arguments_attribute_list","args_validation_list","arg_validation","arg_validation_name","sep_no_nl","nl","sep"];get grammarFileName(){return"MathJSLabParser.g4"}get literalNames(){return MathJSLabParser.literalNames}get symbolicNames(){return MathJSLabParser.symbolicNames}get ruleNames(){return MathJSLabParser.ruleNames}get serializedATN(){return MathJSLabParser._serializedATN}createFailedPredicateException(t,e){return new antlr4_node.eP(this,t,e)}markStatementRange(t,e){t.start={line:e.line,column:e.column},t.stop={line:this._input.LT(1).column>0?this._input.LT(1).line:this._input.LT(1).line-1,column:this._input.LT(1).column>0?this._input.LT(1).column-1:1/0}}markPreviousStatementOmitOutput(t,e){";"===e?.[0]&&(t.list[t.list.length-1].omitOutput=!0)}constructor(t){super(t),this._interp=new antlr4_node.re(this,MathJSLabParser._ATN,MathJSLabParser.DecisionsToDFA,new antlr4_node.tD)}input(){let t,e=new InputContext(this,this._ctx,this.state);this.enterRule(e,0,MathJSLabParser.RULE_input);try{switch(this.state=190,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,2,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=179,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=178,this.sep()),this.state=181,this.match(MathJSLabParser.EOF),e.node=null;break;case 2:this.enterOuterAlt(e,2),this.state=184,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=183,this.sep()),this.state=186,this.global_list(),this.state=187,this.match(MathJSLabParser.EOF),e.node=e.global_list().node}}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}global_list(){let t,e=new Global_listContext(this,this._ctx,this.state);this.enterRule(e,2,MathJSLabParser.RULE_global_list);try{let r;for(this.enterOuterAlt(e,1),this.state=192,this.statement(),this.markStatementRange(e.statement(e.i).node,e.statement(e.i).start),e.node=AST.nodeListFirst(e.statement(e.i++).node),this.state=200,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,3,this._ctx);2!==r&&r!==antlr4_node.MG.INVALID_ALT_NUMBER;)1===r&&(this.state=194,this.sep(),this.state=195,this.statement(),this.markStatementRange(e.statement(e.i).node,e.statement(e.i).start),this.markPreviousStatementOmitOutput(e.node,e.sep(e.i-1).getText()),e.node=AST.appendNodeList(e.node,e.statement(e.i++).node)),this.state=202,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,3,this._ctx);this.state=204,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=203,this.sep()),this.markPreviousStatementOmitOutput(e.node,e.sep(e.i-1)?.getText())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}list(){let t=new ListContext(this,this._ctx,this.state);this.enterRule(t,4,MathJSLabParser.RULE_list);try{let e;for(this.enterOuterAlt(t,1),this.state=208,this.statement(),this.markStatementRange(t.statement(t.i).node,t.statement(t.i).start),t.node=AST.nodeListFirst(t.statement(t.i++).node),this.state=216,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,5,this._ctx);2!==e&&e!==antlr4_node.MG.INVALID_ALT_NUMBER;)1===e&&(this.state=210,this.sep(),this.state=211,this.statement(),this.markStatementRange(t.statement(t.i).node,t.statement(t.i).start),this.markPreviousStatementOmitOutput(t.node,t.sep(t.i-1).getText()),t.node=AST.appendNodeList(t.node,t.statement(t.i++).node)),this.state=218,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,5,this._ctx);this.state=220,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,6,this._ctx)&&(this.state=219,this.sep()),this.markPreviousStatementOmitOutput(t.node,t.sep(t.i-1)?.getText())}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}statement(){let t=new StatementContext(this,this._ctx,this.state);this.enterRule(t,6,MathJSLabParser.RULE_statement);try{switch(this.state=233,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,7,this._ctx)){case 1:this.enterOuterAlt(t,1),this.state=224,this.command(),t.node=t.command().node;break;case 2:this.enterOuterAlt(t,2),this.state=227,this.word_list_cmd(),t.node=t.word_list_cmd().node;break;case 3:this.enterOuterAlt(t,3),this.state=230,this.expression(),t.node=t.expression().node}}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}word_list_cmd(){let t,e=new Word_list_cmdContext(this,this._ctx,this.state);this.enterRule(e,8,MathJSLabParser.RULE_word_list_cmd);try{for(this.enterOuterAlt(e,1),this.state=235,this.identifier(),this.state=236,this.command_word(),e.node=AST.nodeListFirst(e.command_word(e.i++).node),this.state=243,this._errHandler.sync(this),t=this._input.LA(1);46===t||142===t;)this.state=238,this.command_word(),AST.appendNodeList(e.node,e.command_word(e.i++).node),this.state=245,this._errHandler.sync(this),t=this._input.LA(1);e.node=AST.nodeCmdWList(e.identifier().node,e.node)}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}command_word(){let t=new Command_wordContext(this,this._ctx,this.state);this.enterRule(t,10,MathJSLabParser.RULE_command_word);try{this.enterOuterAlt(t,1),this.state=248,this.string_(),t.node=t.string_().node}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}identifier(){let t=new IdentifierContext(this,this._ctx,this.state);this.enterRule(t,12,MathJSLabParser.RULE_identifier);try{switch(this.state=261,this._errHandler.sync(this),this._input.LA(1)){case 101:this.enterOuterAlt(t,1),this.state=251,this.match(MathJSLabParser.IDENTIFIER),t.node=AST.nodeIdentifier(t.IDENTIFIER().getText());break;case 39:this.enterOuterAlt(t,2),this.state=253,this.match(MathJSLabParser.PROPERTIES),t.node=AST.nodeIdentifier("properties");break;case 43:this.enterOuterAlt(t,3),this.state=255,this.match(MathJSLabParser.METHODS),t.node=AST.nodeIdentifier("methods");break;case 41:this.enterOuterAlt(t,4),this.state=257,this.match(MathJSLabParser.EVENTS),t.node=AST.nodeIdentifier("events");break;case 37:this.enterOuterAlt(t,5),this.state=259,this.match(MathJSLabParser.ENUMERATION),t.node=AST.nodeIdentifier("enumeration");break;default:throw new antlr4_node.X2(this)}}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}qualified_identifier_part(){let t=new Qualified_identifier_partContext(this,this._ctx,this.state);this.enterRule(t,14,MathJSLabParser.RULE_qualified_identifier_part);try{switch(this.state=268,this._errHandler.sync(this),this._input.LA(1)){case 37:case 39:case 41:case 43:case 101:this.enterOuterAlt(t,1),this.state=263,this.identifier(),t.text=t.identifier().node.id;break;case 6:this.enterOuterAlt(t,2),this.state=266,this.match(MathJSLabParser.END),t.text="end";break;default:throw new antlr4_node.X2(this)}}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}qualified_identifier(){let t=new Qualified_identifierContext(this,this._ctx,this.state);this.enterRule(t,16,MathJSLabParser.RULE_qualified_identifier);try{let e;for(this.enterOuterAlt(t,1),this.state=270,this.qualified_identifier_part(),t.node=AST.nodeIdentifier(t.qualified_identifier_part(0).text),this.state=278,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,11,this._ctx);2!==e&&e!==antlr4_node.MG.INVALID_ALT_NUMBER;)1===e&&(this.state=272,this.match(MathJSLabParser.DOT),this.state=273,this.qualified_identifier_part(),t.node=AST.nodeIdentifier(t.node.id+"."+t.qualified_identifier_part(t.i++).text)),this.state=280,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,11,this._ctx)}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}string_(){let t=new StringContext(this,this._ctx,this.state);this.enterRule(t,18,MathJSLabParser.RULE_string);try{switch(this.state=285,this._errHandler.sync(this),this._input.LA(1)){case 46:this.enterOuterAlt(t,1);{this.state=281,this.match(MathJSLabParser.STRING);const e=t.STRING().getText();t.node=AST.nodeString(e.substring(1,e.length-1),e[0])}break;case 142:this.enterOuterAlt(t,2),this.state=283,this.match(MathJSLabParser.UNQUOTED_STRING),t.node=AST.nodeString(t.UNQUOTED_STRING().getText());break;default:throw new antlr4_node.X2(this)}}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}number_(){let t=new NumberContext(this,this._ctx,this.state);this.enterRule(t,20,MathJSLabParser.RULE_number);try{this.enterOuterAlt(t,1),this.state=287,this.match(MathJSLabParser.FLOAT_NUMBER),t.node=AST.nodeNumber(t.FLOAT_NUMBER().getText())}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}end_range(){let t=new End_rangeContext(this,this._ctx,this.state);this.enterRule(t,22,MathJSLabParser.RULE_end_range);try{this.enterOuterAlt(t,1),this.state=290,this.match(MathJSLabParser.ENDRANGE),t.node=AST.nodeEndRange()}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}constant(){let t=new ConstantContext(this,this._ctx,this.state);this.enterRule(t,24,MathJSLabParser.RULE_constant);try{switch(this.state=302,this._errHandler.sync(this),this._input.LA(1)){case 102:this.enterOuterAlt(t,1),this.state=293,this.number_(),t.node=t.number_().node;break;case 46:case 142:this.enterOuterAlt(t,2),this.state=296,this.string_(),t.node=t.string_().node;break;case 7:this.enterOuterAlt(t,3),this.state=299,this.end_range(),t.node=t.end_range().node;break;default:throw new antlr4_node.X2(this)}}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}matrix(){let t,e=new MatrixContext(this,this._ctx,this.state);this.enterRule(e,26,MathJSLabParser.RULE_matrix);try{let r;switch(this.state=366,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,28,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=304,this.match(MathJSLabParser.LBRACKET),this.state=305,this.match(MathJSLabParser.RBRACKET),e.node=AST.emptyArray();break;case 2:for(this.enterOuterAlt(e,2),this.state=307,this.match(MathJSLabParser.LBRACKET),this.state=312,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,15,this._ctx);2!==r&&r!==antlr4_node.MG.INVALID_ALT_NUMBER;){if(1===r)switch(this.state=310,this._errHandler.sync(this),this._input.LA(1)){case 55:this.state=308,this.match(MathJSLabParser.SEMICOLON);break;case 106:this.state=309,this.nl();break;default:throw new antlr4_node.X2(this)}this.state=314,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,15,this._ctx)}for(this.state=316,this._errHandler.sync(this),t=this._input.LA(1),(3===t||7===t||!(t-37&-32)&&1<<t-37&736768853||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=315,this.matrix_row()),e.node=AST.nodeFirstRow(e.matrix_row(e.i)?e.matrix_row(e.i++).node:null),this.state=331,this._errHandler.sync(this),t=this._input.LA(1);55===t||106===t;){this.state=321,this._errHandler.sync(this),r=1;do{if(1!==r)throw new antlr4_node.X2(this);switch(this.state=321,this._errHandler.sync(this),this._input.LA(1)){case 55:this.state=319,this.match(MathJSLabParser.SEMICOLON);break;case 106:this.state=320,this.nl();break;default:throw new antlr4_node.X2(this)}this.state=323,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,18,this._ctx)}while(2!==r&&r!==antlr4_node.MG.INVALID_ALT_NUMBER);this.state=326,this._errHandler.sync(this),t=this._input.LA(1),(3===t||7===t||!(t-37&-32)&&1<<t-37&736768853||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=325,this.matrix_row()),e.node=AST.nodeAppendRow(e.node,e.matrix_row(e.i)?e.matrix_row(e.i++).node:null),this.state=333,this._errHandler.sync(this),t=this._input.LA(1)}this.state=334,this.match(MathJSLabParser.RBRACKET);break;case 3:this.enterOuterAlt(e,3),this.state=335,this.match(MathJSLabParser.LCURLYBR),this.state=336,this.match(MathJSLabParser.RCURLYBR),e.node=AST.emptyArray(!0);break;case 4:for(this.enterOuterAlt(e,4),this.state=338,this.match(MathJSLabParser.LCURLYBR),this.state=343,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,22,this._ctx);2!==r&&r!==antlr4_node.MG.INVALID_ALT_NUMBER;){if(1===r)switch(this.state=341,this._errHandler.sync(this),this._input.LA(1)){case 55:this.state=339,this.match(MathJSLabParser.SEMICOLON);break;case 106:this.state=340,this.nl();break;default:throw new antlr4_node.X2(this)}this.state=345,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,22,this._ctx)}for(this.state=347,this._errHandler.sync(this),t=this._input.LA(1),(3===t||7===t||!(t-37&-32)&&1<<t-37&736768853||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=346,this.matrix_row()),e.node=AST.nodeFirstRow(e.matrix_row(e.i)?e.matrix_row(e.i++).node:null,!0),this.state=362,this._errHandler.sync(this),t=this._input.LA(1);55===t||106===t;){this.state=352,this._errHandler.sync(this),r=1;do{if(1!==r)throw new antlr4_node.X2(this);switch(this.state=352,this._errHandler.sync(this),this._input.LA(1)){case 55:this.state=350,this.match(MathJSLabParser.SEMICOLON);break;case 106:this.state=351,this.nl();break;default:throw new antlr4_node.X2(this)}this.state=354,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,25,this._ctx)}while(2!==r&&r!==antlr4_node.MG.INVALID_ALT_NUMBER);this.state=357,this._errHandler.sync(this),t=this._input.LA(1),(3===t||7===t||!(t-37&-32)&&1<<t-37&736768853||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=356,this.matrix_row()),e.node=AST.nodeAppendRow(e.node,e.matrix_row(e.i)?e.matrix_row(e.i++).node:null),this.state=364,this._errHandler.sync(this),t=this._input.LA(1)}this.state=365,this.match(MathJSLabParser.RCURLYBR)}}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}matrix_row(){let t,e=new Matrix_rowContext(this,this._ctx,this.state);this.enterRule(e,28,MathJSLabParser.RULE_matrix_row);try{let r;switch(this.state=387,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,32,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=368,t=this._input.LA(1),45!==t&&56!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=null;break;case 2:for(this.enterOuterAlt(e,2),this.state=371,this._errHandler.sync(this),t=this._input.LA(1),45!==t&&56!==t||(this.state=370,t=this._input.LA(1),45!==t&&56!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume())),this.state=373,this.list_element(),e.node=AST.nodeListFirst(e.list_element(e.i++).node),this.state=381,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,30,this._ctx);2!==r&&r!==antlr4_node.MG.INVALID_ALT_NUMBER;)1===r&&(this.state=375,t=this._input.LA(1),45!==t&&56!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=376,this.list_element(),e.node=AST.appendNodeList(e.node,e.list_element(e.i++).node)),this.state=383,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,30,this._ctx);this.state=385,this._errHandler.sync(this),t=this._input.LA(1),45!==t&&56!==t||(this.state=384,t=this._input.LA(1),45!==t&&56!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()))}}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}fcn_handle(){let t=new Fcn_handleContext(this,this._ctx,this.state);this.enterRule(t,30,MathJSLabParser.RULE_fcn_handle);try{this.enterOuterAlt(t,1),this.state=389,this.match(MathJSLabParser.COMMAT),this.state=390,this.qualified_identifier(),t.node=AST.nodeFunctionHandle(t.qualified_identifier().node)}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}meta_class(){let t=new Meta_classContext(this,this._ctx,this.state);this.enterRule(t,32,MathJSLabParser.RULE_meta_class);try{this.enterOuterAlt(t,1),this.state=393,this.match(MathJSLabParser.QUESTION),this.state=394,this.qualified_identifier(),t.node=AST.nodeMetaClass(t.qualified_identifier().node)}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}anon_fcn_handle(){let t=new Anon_fcn_handleContext(this,this._ctx,this.state);this.enterRule(t,34,MathJSLabParser.RULE_anon_fcn_handle);try{this.enterOuterAlt(t,1),this.state=397,this.match(MathJSLabParser.COMMAT),this.state=398,this.param_list(),this.state=399,this.expression(),t.node=AST.nodeFunctionHandle(null,t.param_list().node,t.expression().node)}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}primary_expr(){let t=new Primary_exprContext(this,this._ctx,this.state);this.enterRule(t,36,MathJSLabParser.RULE_primary_expr);try{switch(this.state=424,this._errHandler.sync(this),this._input.LA(1)){case 37:case 39:case 41:case 43:case 101:this.enterOuterAlt(t,1),this.state=402,this.identifier(),t.node=t.identifier().node;break;case 3:this.enterOuterAlt(t,2),this.state=405,this.match(MathJSLabParser.IMPORT),t.node=AST.nodeImport();break;case 7:case 46:case 102:case 142:this.enterOuterAlt(t,3),this.state=407,this.constant(),t.node=t.constant().node;break;case 60:this.enterOuterAlt(t,4),this.state=410,this.fcn_handle(),t.node=t.fcn_handle().node;break;case 61:this.enterOuterAlt(t,5),this.state=413,this.meta_class(),t.node=t.meta_class().node;break;case 64:case 66:this.enterOuterAlt(t,6),this.state=416,this.matrix(),t.node=t.matrix().node;break;case 62:this.enterOuterAlt(t,7),this.state=419,this.match(MathJSLabParser.LPAREN),this.state=420,this.expression(),this.state=421,this.match(MathJSLabParser.RPAREN),t.node=AST.nodeOperation("()",t.expression().node);break;default:throw new antlr4_node.X2(this)}}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}magic_colon(){let t=new Magic_colonContext(this,this._ctx,this.state);this.enterRule(t,38,MathJSLabParser.RULE_magic_colon);try{this.enterOuterAlt(t,1),this.state=426,this.match(MathJSLabParser.COLON),t.node=AST.nodeColon()}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}magic_tilde(){let t=new Magic_tildeContext(this,this._ctx,this.state);this.enterRule(t,40,MathJSLabParser.RULE_magic_tilde);try{this.enterOuterAlt(t,1),this.state=429,this.match(MathJSLabParser.TILDE),t.node=AST.nodeIgnoredTarget()}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}list_element(){let t=new List_elementContext(this,this._ctx,this.state);this.enterRule(t,42,MathJSLabParser.RULE_list_element);try{switch(this.state=441,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,34,this._ctx)){case 1:this.enterOuterAlt(t,1),this.state=432,this.expression(),t.node=t.expression().node;break;case 2:this.enterOuterAlt(t,2),this.state=435,this.magic_colon(),t.node=t.magic_colon().node;break;case 3:this.enterOuterAlt(t,3),this.state=438,this.magic_tilde(),t.node=t.magic_tilde().node}}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}arg_list(){let t,e=new Arg_listContext(this,this._ctx,this.state);this.enterRule(e,44,MathJSLabParser.RULE_arg_list);try{for(this.enterOuterAlt(e,1),this.state=443,this.list_element(),e.node=AST.nodeListFirst(e.list_element(e.i++).node),this.state=451,this._errHandler.sync(this),t=this._input.LA(1);56===t;)this.state=445,this.match(MathJSLabParser.COMMA),this.state=446,this.list_element(),e.node=AST.appendNodeList(e.node,e.list_element(e.i++).node),this.state=453,this._errHandler.sync(this),t=this._input.LA(1)}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}oper_expr(t){void 0===t&&(t=0);let e,r=this._ctx,s=this.state,i=new Oper_exprContext(this,this._ctx,s),n=i,a=46;this.enterRecursionRule(i,46,MathJSLabParser.RULE_oper_expr,t);try{let t;switch(this.enterOuterAlt(i,1),this.state=466,this._errHandler.sync(this),this._input.LA(1)){case 3:case 7:case 37:case 39:case 41:case 43:case 46:case 60:case 61:case 62:case 64:case 66:case 101:case 102:case 142:this.state=455,this.primary_expr(),i.node=i.primary_expr().node;break;case 49:case 50:case 94:case 95:this.state=458,i._op=this._input.LT(1),e=this._input.LA(1),49!==e&&50!==e&&94!==e&&95!==e?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=459,this.oper_expr(4),i.node=AST.nodeOperation(i._op.text+"_",i.oper_expr(0).node);break;case 58:case 59:this.state=462,i._op=this._input.LT(1),e=this._input.LA(1),58!==e&&59!==e?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=463,this.oper_expr(3),i.node=AST.nodeOperation(i._op.text,i.oper_expr(0).node);break;default:throw new antlr4_node.X2(this)}for(this._ctx.stop=this._input.LT(-1),this.state=527,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,41,this._ctx);2!==t&&t!==antlr4_node.MG.INVALID_ALT_NUMBER;){if(1===t)switch(null!=this._parseListeners&&this.triggerExitRuleEvent(),n=i,this.state=525,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,40,this._ctx)){case 1:if(i=new Oper_exprContext(this,r,s),this.pushNewRecursionContext(i,a,MathJSLabParser.RULE_oper_expr),this.state=468,!this.precpred(this._ctx,2))throw this.createFailedPredicateException("this.precpred(this._ctx, 2)");this.state=469,i._op=this._input.LT(1),e=this._input.LA(1),!(e-51&-32)&&1<<e-51&131075||!(e-91&-32)&&1<<e-91&7?(this._errHandler.reportMatch(this),this.consume()):i._op=this._errHandler.recoverInline(this),this.state=470,this.oper_expr(3),i.node=AST.nodeOperation(i._op.text,i.oper_expr(0).node,i.oper_expr(1).node);break;case 2:if(i=new Oper_exprContext(this,r,s),this.pushNewRecursionContext(i,a,MathJSLabParser.RULE_oper_expr),this.state=473,!this.precpred(this._ctx,1))throw this.createFailedPredicateException("this.precpred(this._ctx, 1)");this.state=474,i._op=this._input.LT(1),e=this._input.LA(1),49!==e&&50!==e?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=475,this.oper_expr(2),i.node=AST.nodeOperation(i._op.text,i.oper_expr(0).node,i.oper_expr(1).node);break;case 3:if(i=new Oper_exprContext(this,r,s),this.pushNewRecursionContext(i,a,MathJSLabParser.RULE_oper_expr),this.state=478,!this.precpred(this._ctx,12))throw this.createFailedPredicateException("this.precpred(this._ctx, 12)");this.state=479,i._op=this._input.LT(1),e=this._input.LA(1),94!==e&&95!==e?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),i.node=AST.nodeOperation("_"+i._op.text,i.oper_expr(0).node);break;case 4:if(i=new Oper_exprContext(this,r,s),this.pushNewRecursionContext(i,a,MathJSLabParser.RULE_oper_expr),this.state=481,!this.precpred(this._ctx,11))throw this.createFailedPredicateException("this.precpred(this._ctx, 11)");this.state=482,this.match(MathJSLabParser.LPAREN),this.state=484,this._errHandler.sync(this),e=this._input.LA(1),(3===e||7===e||!(e-37&-32)&&1<<e-37&736244309||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=483,this.arg_list()),this.state=486,this.match(MathJSLabParser.RPAREN),i.node=AST.nodeIndexExpr(i.oper_expr(0).node,i.arg_list()?i.arg_list().node:null,"()");break;case 5:if(i=new Oper_exprContext(this,r,s),this.pushNewRecursionContext(i,a,MathJSLabParser.RULE_oper_expr),this.state=488,!this.precpred(this._ctx,10))throw this.createFailedPredicateException("this.precpred(this._ctx, 10)");this.state=489,this.match(MathJSLabParser.LCURLYBR),this.state=491,this._errHandler.sync(this),e=this._input.LA(1),(3===e||7===e||!(e-37&-32)&&1<<e-37&736244309||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=490,this.arg_list()),this.state=493,this.match(MathJSLabParser.RCURLYBR),i.node=AST.nodeIndexExpr(i.oper_expr(0).node,i.arg_list()?i.arg_list().node:null,"{}");break;case 6:if(i=new Oper_exprContext(this,r,s),this.pushNewRecursionContext(i,a,MathJSLabParser.RULE_oper_expr),this.state=495,!this.precpred(this._ctx,9))throw this.createFailedPredicateException("this.precpred(this._ctx, 9)");this.state=496,this.match(MathJSLabParser.COMMAT),this.state=497,this.qualified_identifier(),this.state=498,this.match(MathJSLabParser.LPAREN),this.state=500,this._errHandler.sync(this),e=this._input.LA(1),(3===e||7===e||!(e-37&-32)&&1<<e-37&736244309||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=499,this.arg_list()),this.state=502,this.match(MathJSLabParser.RPAREN),i.node=AST.nodeSuperclassConstructor(i.oper_expr(0).node,i.qualified_identifier().node,i.arg_list()?i.arg_list().node:null);break;case 7:if(i=new Oper_exprContext(this,r,s),this.pushNewRecursionContext(i,a,MathJSLabParser.RULE_oper_expr),this.state=505,!this.precpred(this._ctx,8))throw this.createFailedPredicateException("this.precpred(this._ctx, 8)");this.state=506,i._op=this._input.LT(1),e=this._input.LA(1),98!==e&&99!==e?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),i.node=AST.nodeOperation(i._op.text,i.oper_expr(0).node);break;case 8:if(i=new Oper_exprContext(this,r,s),this.pushNewRecursionContext(i,a,MathJSLabParser.RULE_oper_expr),this.state=508,!this.precpred(this._ctx,7))throw this.createFailedPredicateException("this.precpred(this._ctx, 7)");this.state=509,this.match(MathJSLabParser.DOT),this.state=510,this.qualified_identifier_part(),i.node=AST.nodeIndirectRef(i.oper_expr(0).node,i.qualified_identifier_part().text);break;case 9:if(i=new Oper_exprContext(this,r,s),this.pushNewRecursionContext(i,a,MathJSLabParser.RULE_oper_expr),this.state=513,!this.precpred(this._ctx,6))throw this.createFailedPredicateException("this.precpred(this._ctx, 6)");this.state=514,this.match(MathJSLabParser.DOT),this.state=515,this.match(MathJSLabParser.LPAREN),this.state=516,this.expression(),this.state=517,this.match(MathJSLabParser.RPAREN),i.node=AST.nodeIndirectRef(i.oper_expr(0).node,i.expression().node);break;case 10:if(i=new Oper_exprContext(this,r,s),this.pushNewRecursionContext(i,a,MathJSLabParser.RULE_oper_expr),this.state=520,!this.precpred(this._ctx,5))throw this.createFailedPredicateException("this.precpred(this._ctx, 5)");this.state=521,i._op=this._input.LT(1),e=this._input.LA(1),96!==e&&97!==e?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=522,this.power_expr(0),i.node=AST.nodeOperation(i._op.text,i.oper_expr(0).node,i.power_expr().node)}this.state=529,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,41,this._ctx)}}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;i.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.unrollRecursionContexts(r)}return i}power_expr(t){void 0===t&&(t=0);let e,r=this._ctx,s=this.state,i=new Power_exprContext(this,this._ctx,s),n=i,a=48;this.enterRecursionRule(i,48,MathJSLabParser.RULE_power_expr,t);try{let t;switch(this.enterOuterAlt(i,1),this.state=542,this._errHandler.sync(this),this._input.LA(1)){case 3:case 7:case 37:case 39:case 41:case 43:case 46:case 60:case 61:case 62:case 64:case 66:case 101:case 102:case 142:this.state=531,this.primary_expr(),i.node=i.primary_expr().node;break;case 49:case 50:case 94:case 95:this.state=534,i._op=this._input.LT(1),e=this._input.LA(1),49!==e&&50!==e&&94!==e&&95!==e?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=535,this.power_expr(2),i.node=AST.nodeOperation(i._op.text+"_",i.power_expr().node);break;case 58:case 59:this.state=538,i._op=this._input.LT(1),e=this._input.LA(1),58!==e&&59!==e?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=539,this.power_expr(1),i.node=AST.nodeOperation(i._op.text,i.power_expr().node);break;default:throw new antlr4_node.X2(this)}for(this._ctx.stop=this._input.LT(-1),this.state=585,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,47,this._ctx);2!==t&&t!==antlr4_node.MG.INVALID_ALT_NUMBER;){if(1===t)switch(null!=this._parseListeners&&this.triggerExitRuleEvent(),n=i,this.state=583,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,46,this._ctx)){case 1:if(i=new Power_exprContext(this,r,s),this.pushNewRecursionContext(i,a,MathJSLabParser.RULE_power_expr),this.state=544,!this.precpred(this._ctx,8))throw this.createFailedPredicateException("this.precpred(this._ctx, 8)");this.state=545,i._op=this._input.LT(1),e=this._input.LA(1),94!==e&&95!==e?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),i.node=AST.nodeOperation("_"+i._op.text,i.power_expr().node);break;case 2:if(i=new Power_exprContext(this,r,s),this.pushNewRecursionContext(i,a,MathJSLabParser.RULE_power_expr),this.state=547,!this.precpred(this._ctx,7))throw this.createFailedPredicateException("this.precpred(this._ctx, 7)");this.state=548,this.match(MathJSLabParser.LPAREN),this.state=550,this._errHandler.sync(this),e=this._input.LA(1),(3===e||7===e||!(e-37&-32)&&1<<e-37&736244309||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=549,this.arg_list()),this.state=552,this.match(MathJSLabParser.RPAREN),i.node=AST.nodeIndexExpr(i.power_expr().node,i.arg_list()?i.arg_list().node:null,"()");break;case 3:if(i=new Power_exprContext(this,r,s),this.pushNewRecursionContext(i,a,MathJSLabParser.RULE_power_expr),this.state=554,!this.precpred(this._ctx,6))throw this.createFailedPredicateException("this.precpred(this._ctx, 6)");this.state=555,this.match(MathJSLabParser.LCURLYBR),this.state=557,this._errHandler.sync(this),e=this._input.LA(1),(3===e||7===e||!(e-37&-32)&&1<<e-37&736244309||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=556,this.arg_list()),this.state=559,this.match(MathJSLabParser.RCURLYBR),i.node=AST.nodeIndexExpr(i.power_expr().node,i.arg_list()?i.arg_list().node:null,"{}");break;case 4:if(i=new Power_exprContext(this,r,s),this.pushNewRecursionContext(i,a,MathJSLabParser.RULE_power_expr),this.state=561,!this.precpred(this._ctx,5))throw this.createFailedPredicateException("this.precpred(this._ctx, 5)");this.state=562,this.match(MathJSLabParser.COMMAT),this.state=563,this.qualified_identifier(),this.state=564,this.match(MathJSLabParser.LPAREN),this.state=566,this._errHandler.sync(this),e=this._input.LA(1),(3===e||7===e||!(e-37&-32)&&1<<e-37&736244309||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=565,this.arg_list()),this.state=568,this.match(MathJSLabParser.RPAREN),i.node=AST.nodeSuperclassConstructor(i.power_expr().node,i.qualified_identifier().node,i.arg_list()?i.arg_list().node:null);break;case 5:if(i=new Power_exprContext(this,r,s),this.pushNewRecursionContext(i,a,MathJSLabParser.RULE_power_expr),this.state=571,!this.precpred(this._ctx,4))throw this.createFailedPredicateException("this.precpred(this._ctx, 4)");this.state=572,this.match(MathJSLabParser.DOT),this.state=573,this.qualified_identifier_part(),i.node=AST.nodeIndirectRef(i.power_expr().node,i.qualified_identifier_part().text);break;case 6:if(i=new Power_exprContext(this,r,s),this.pushNewRecursionContext(i,a,MathJSLabParser.RULE_power_expr),this.state=576,!this.precpred(this._ctx,3))throw this.createFailedPredicateException("this.precpred(this._ctx, 3)");this.state=577,this.match(MathJSLabParser.DOT),this.state=578,this.match(MathJSLabParser.LPAREN),this.state=579,this.expression(),this.state=580,this.match(MathJSLabParser.RPAREN),i.node=AST.nodeIndirectRef(i.power_expr().node,i.expression().node)}this.state=587,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,47,this._ctx)}}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;i.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.unrollRecursionContexts(r)}return i}colon_expr(){let t=new Colon_exprContext(this,this._ctx,this.state);this.enterRule(t,50,MathJSLabParser.RULE_colon_expr);try{this.enterOuterAlt(t,1),this.state=588,this.oper_expr(0),this.state=589,this.match(MathJSLabParser.COLON),this.state=590,this.oper_expr(0),this.state=593,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,48,this._ctx)&&(this.state=591,this.match(MathJSLabParser.COLON),this.state=592,this.oper_expr(0)),t.oper_expr(2)?t.node=AST.nodeRange(t.oper_expr(0).node,t.oper_expr(2).node,t.oper_expr(1).node):t.node=AST.nodeRange(t.oper_expr(0).node,t.oper_expr(1).node)}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}simple_expr(t){void 0===t&&(t=0);let e,r=this._ctx,s=this.state,i=new Simple_exprContext(this,this._ctx,s),n=i;this.enterRecursionRule(i,52,MathJSLabParser.RULE_simple_expr,t);try{let t;switch(this.enterOuterAlt(i,1),this.state=604,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,49,this._ctx)){case 1:this.state=598,this.oper_expr(0),i.node=i.oper_expr().node;break;case 2:this.state=601,this.colon_expr(),i.node=i.colon_expr().node}for(this._ctx.stop=this._input.LT(-1),this.state=633,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,51,this._ctx);2!==t&&t!==antlr4_node.MG.INVALID_ALT_NUMBER;){if(1===t)switch(null!=this._parseListeners&&this.triggerExitRuleEvent(),n=i,this.state=631,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,50,this._ctx)){case 1:if(i=new Simple_exprContext(this,r,s),this.pushNewRecursionContext(i,52,MathJSLabParser.RULE_simple_expr),this.state=606,!this.precpred(this._ctx,5))throw this.createFailedPredicateException("this.precpred(this._ctx, 5)");this.state=607,i._op=this._input.LT(1),e=this._input.LA(1),e-85&-32||!(1<<e-85&63)?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=608,this.simple_expr(6),i.node=AST.nodeOperation(i._op.text,i.simple_expr(0).node,i.simple_expr(1).node);break;case 2:if(i=new Simple_exprContext(this,r,s),this.pushNewRecursionContext(i,52,MathJSLabParser.RULE_simple_expr),this.state=611,!this.precpred(this._ctx,4))throw this.createFailedPredicateException("this.precpred(this._ctx, 4)");this.state=612,i._op=this.match(MathJSLabParser.EXPR_AND),this.state=613,this.simple_expr(5),i.node=AST.nodeOperation(i._op.text,i.simple_expr(0).node,i.simple_expr(1).node);break;case 3:if(i=new Simple_exprContext(this,r,s),this.pushNewRecursionContext(i,52,MathJSLabParser.RULE_simple_expr),this.state=616,!this.precpred(this._ctx,3))throw this.createFailedPredicateException("this.precpred(this._ctx, 3)");this.state=617,i._op=this.match(MathJSLabParser.EXPR_OR),this.state=618,this.simple_expr(4),i.node=AST.nodeOperation(i._op.text,i.simple_expr(0).node,i.simple_expr(1).node);break;case 4:if(i=new Simple_exprContext(this,r,s),this.pushNewRecursionContext(i,52,MathJSLabParser.RULE_simple_expr),this.state=621,!this.precpred(this._ctx,2))throw this.createFailedPredicateException("this.precpred(this._ctx, 2)");this.state=622,i._op=this.match(MathJSLabParser.EXPR_AND_AND),this.state=623,this.simple_expr(3),i.node=AST.nodeOperation(i._op.text,i.simple_expr(0).node,i.simple_expr(1).node);break;case 5:if(i=new Simple_exprContext(this,r,s),this.pushNewRecursionContext(i,52,MathJSLabParser.RULE_simple_expr),this.state=626,!this.precpred(this._ctx,1))throw this.createFailedPredicateException("this.precpred(this._ctx, 1)");this.state=627,i._op=this.match(MathJSLabParser.EXPR_OR_OR),this.state=628,this.simple_expr(2),i.node=AST.nodeOperation(i._op.text,i.simple_expr(0).node,i.simple_expr(1).node)}this.state=635,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,51,this._ctx)}}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;i.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.unrollRecursionContexts(r)}return i}expression(){let t,e=new ExpressionContext(this,this._ctx,this.state);this.enterRule(e,54,MathJSLabParser.RULE_expression);try{switch(this.state=647,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,52,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=636,this.simple_expr(0),e.node=e.simple_expr().node;break;case 2:this.enterOuterAlt(e,2),this.state=639,this.simple_expr(0),this.state=640,e._op=this._input.LT(1),t=this._input.LA(1),t-53&-32||!(1<<t-53&268369921)?e._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=641,this.expression(),e.node=AST.nodeOperation(e._op.text,e.simple_expr().node,e.expression().node);break;case 3:this.enterOuterAlt(e,3),this.state=644,this.anon_fcn_handle(),e.node=e.anon_fcn_handle().node}}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}assign_lhs(){let t,e=new Assign_lhsContext(this,this._ctx,this.state);this.enterRule(e,56,MathJSLabParser.RULE_assign_lhs);try{switch(this.state=658,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,54,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=649,this.simple_expr(0),e.node=e.simple_expr().node;break;case 2:this.enterOuterAlt(e,2),this.state=652,this.match(MathJSLabParser.LBRACKET),this.state=654,this._errHandler.sync(this),t=this._input.LA(1),(3===t||7===t||!(t-37&-32)&&1<<t-37&736244309||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=653,this.assign_list()),this.state=656,this.match(MathJSLabParser.RBRACKET),e.node=AST.nodeFirstRow(e.assign_list()?e.assign_list().node:AST.nodeListFirst())}}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}assign_list(){let t,e=new Assign_listContext(this,this._ctx,this.state);this.enterRule(e,58,MathJSLabParser.RULE_assign_list);try{let r;for(this.enterOuterAlt(e,1),this.state=660,this.list_element(),e.node=AST.nodeListFirst(e.list_element(e.i++).node),this.state=668,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,55,this._ctx);2!==r&&r!==antlr4_node.MG.INVALID_ALT_NUMBER;)1===r&&(this.state=662,t=this._input.LA(1),45!==t&&56!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=663,this.list_element(),e.node=AST.appendNodeList(e.node,e.list_element(e.i++).node)),this.state=670,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,55,this._ctx);this.state=672,this._errHandler.sync(this),t=this._input.LA(1),45!==t&&56!==t||(this.state=671,t=this._input.LA(1),45!==t&&56!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()))}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}command(){let t=new CommandContext(this,this._ctx,this.state);this.enterRule(t,60,MathJSLabParser.RULE_command);try{switch(this.state=698,this._errHandler.sync(this),this._input.LA(1)){case 1:case 2:this.enterOuterAlt(t,1),this.state=674,this.declaration(),t.node=t.declaration().node;break;case 3:this.enterOuterAlt(t,2),this.state=677,this.import_command(),t.node=t.import_command().node;break;case 4:case 10:this.enterOuterAlt(t,3),this.state=680,this.select_command(),t.node=t.select_command().node;break;case 14:case 16:case 18:case 20:case 22:this.enterOuterAlt(t,4),this.state=683,this.loop_command(),t.node=t.loop_command().node;break;case 24:case 25:case 26:this.enterOuterAlt(t,5),this.state=686,this.jump_command(),t.node=t.jump_command().node;break;case 29:case 32:this.enterOuterAlt(t,6),this.state=689,this.except_command(),t.node=t.except_command().node;break;case 27:this.enterOuterAlt(t,7),this.state=692,this.function_(),t.node=t.function_().node;break;case 35:this.enterOuterAlt(t,8),this.state=695,this.classdef_command(),t.node=t.classdef_command().node;break;default:throw new antlr4_node.X2(this)}}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}declaration(){let t,e=new DeclarationContext(this,this._ctx,this.state);this.enterRule(e,62,MathJSLabParser.RULE_declaration);try{let r;switch(this.enterOuterAlt(e,1),this.state=704,this._errHandler.sync(this),this._input.LA(1)){case 1:this.state=700,this.match(MathJSLabParser.GLOBAL),e.node=AST.nodeDeclarationFirst("GLOBAL");break;case 2:this.state=702,this.match(MathJSLabParser.PERSISTENT),e.node=AST.nodeDeclarationFirst("PERSIST");break;default:throw new antlr4_node.X2(this)}for(this.state=706,this.declaration_element(),e.node=AST.nodeAppendDeclaration(e.node,e.declaration_element(e.i++).node),this.state=716,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,60,this._ctx);2!==r&&r!==antlr4_node.MG.INVALID_ALT_NUMBER;)1===r&&(this.state=709,this._errHandler.sync(this),t=this._input.LA(1),56===t&&(this.state=708,this.match(MathJSLabParser.COMMA)),this.state=711,this.declaration_element(),e.node=AST.nodeAppendDeclaration(e.node,e.declaration_element(e.i++).node)),this.state=718,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,60,this._ctx)}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}declaration_element(){let t=new Declaration_elementContext(this,this._ctx,this.state);this.enterRule(t,64,MathJSLabParser.RULE_declaration_element);try{switch(this.state=727,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,61,this._ctx)){case 1:this.enterOuterAlt(t,1),this.state=719,this.identifier(),t.node=t.identifier().node;break;case 2:this.enterOuterAlt(t,2),this.state=722,this.identifier(),this.state=723,this.match(MathJSLabParser.EQ),this.state=724,this.expression(),t.node=AST.nodeDefaultedParameter(t.identifier().node,t.expression().node)}}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}import_command(){let t,e=new Import_commandContext(this,this._ctx,this.state);this.enterRule(e,66,MathJSLabParser.RULE_import_command);try{let r;if(this.enterOuterAlt(e,1),this.state=729,this.match(MathJSLabParser.IMPORT),e.node=AST.nodeImport(),this.state=744,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,64,this._ctx))for(this.state=731,this.import_name(),e.node=AST.nodeImportFirst(e.import_name(e.i++).node),this.state=741,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,63,this._ctx);2!==r&&r!==antlr4_node.MG.INVALID_ALT_NUMBER;)1===r&&(this.state=734,this._errHandler.sync(this),t=this._input.LA(1),56===t&&(this.state=733,this.match(MathJSLabParser.COMMA)),this.state=736,this.import_name(),e.node=AST.nodeAppendImport(e.node,e.import_name(e.i++).node)),this.state=743,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,63,this._ctx)}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}import_name(){let t=new Import_nameContext(this,this._ctx,this.state);this.enterRule(t,68,MathJSLabParser.RULE_import_name);try{switch(this.state=757,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,66,this._ctx)){case 1:this.enterOuterAlt(t,1),this.state=746,this.qualified_identifier(),t.node=t.qualified_identifier().node;break;case 2:switch(this.enterOuterAlt(t,2),this.state=749,this.qualified_identifier(),this.state=753,this._errHandler.sync(this),this._input.LA(1)){case 57:this.state=750,this.match(MathJSLabParser.DOT),this.state=751,this.match(MathJSLabParser.MUL);break;case 91:this.state=752,this.match(MathJSLabParser.EMUL);break;default:throw new antlr4_node.X2(this)}t.node=AST.nodeIdentifier(t.qualified_identifier().node.id+".*")}}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}select_command(){let t=new Select_commandContext(this,this._ctx,this.state);this.enterRule(t,70,MathJSLabParser.RULE_select_command);try{switch(this.state=765,this._errHandler.sync(this),this._input.LA(1)){case 4:this.enterOuterAlt(t,1),this.state=759,this.if_command(),t.node=t.if_command().node;break;case 10:this.enterOuterAlt(t,2),this.state=762,this.switch_command(),t.node=t.switch_command().node;break;default:throw new antlr4_node.X2(this)}}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}if_command(){let t,e=new If_commandContext(this,this._ctx,this.state);this.enterRule(e,72,MathJSLabParser.RULE_if_command);try{for(this.enterOuterAlt(e,1),this.state=767,this.match(MathJSLabParser.IF),this.state=768,this.expression(),this.state=770,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=769,this.sep()),this.state=773,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=772,this.list()),e.node=AST.nodeIfBegin(e.expression().node,e.list()?e.list().node:AST.nodeListFirst()),this.state=781,this._errHandler.sync(this),t=this._input.LA(1);8===t;)this.state=776,this.elseif_clause(),e.node=AST.nodeIfAppendElseIf(e.node,e.elseif_clause(e.i++).node),this.state=783,this._errHandler.sync(this),t=this._input.LA(1);this.state=785,this._errHandler.sync(this),t=this._input.LA(1),9===t&&(this.state=784,this.else_clause()),e.else_clause()&&(e.node=AST.nodeIfAppendElse(e.node,e.else_clause().node)),this.state=788,t=this._input.LA(1),5!==t&&6!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}elseif_clause(){let t,e=new Elseif_clauseContext(this,this._ctx,this.state);this.enterRule(e,74,MathJSLabParser.RULE_elseif_clause);try{this.enterOuterAlt(e,1),this.state=790,this.match(MathJSLabParser.ELSEIF),this.state=792,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=791,this.sep()),this.state=794,this.expression(),this.state=796,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=795,this.sep()),this.state=799,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=798,this.list()),e.node=AST.nodeElseIf(e.expression().node,e.list()?e.list().node:AST.nodeListFirst())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}else_clause(){let t,e=new Else_clauseContext(this,this._ctx,this.state);this.enterRule(e,76,MathJSLabParser.RULE_else_clause);try{this.enterOuterAlt(e,1),this.state=803,this.match(MathJSLabParser.ELSE),this.state=805,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=804,this.sep()),this.state=808,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=807,this.list()),e.node=AST.nodeElse(e.list()?e.list().node:AST.nodeListFirst())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}switch_command(){let t,e=new Switch_commandContext(this,this._ctx,this.state);this.enterRule(e,78,MathJSLabParser.RULE_switch_command);try{this.enterOuterAlt(e,1),this.state=812,this.match(MathJSLabParser.SWITCH),this.state=813,this.expression(),this.state=815,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=814,this.sep()),this.state=818,this._errHandler.sync(this),t=this._input.LA(1),12===t&&(this.state=817,this.switch_case_list()),this.state=821,this._errHandler.sync(this),t=this._input.LA(1),13===t&&(this.state=820,this.otherwise_case()),this.state=823,t=this._input.LA(1),6!==t&&11!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=AST.nodeSwitch(e.expression().node,e.switch_case_list()?e.switch_case_list().node:AST.nodeListFirst(),e.otherwise_case()?e.otherwise_case().node:null)}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}switch_case_list(){let t,e=new Switch_case_listContext(this,this._ctx,this.state);this.enterRule(e,80,MathJSLabParser.RULE_switch_case_list);try{let r;for(this.enterOuterAlt(e,1),this.state=826,this.switch_case(),e.node=AST.nodeListFirst(e.switch_case(e.i++).node),this.state=836,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,81,this._ctx);2!==r&&r!==antlr4_node.MG.INVALID_ALT_NUMBER;)1===r&&(this.state=829,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=828,this.sep()),this.state=831,this.switch_case(),e.node=AST.appendNodeList(e.node,e.switch_case(e.i++).node)),this.state=838,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,81,this._ctx);this.state=840,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=839,this.sep())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}switch_case(){let t,e=new Switch_caseContext(this,this._ctx,this.state);this.enterRule(e,82,MathJSLabParser.RULE_switch_case);try{this.enterOuterAlt(e,1),this.state=842,this.match(MathJSLabParser.CASE),this.state=844,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=843,this.sep()),this.state=846,this.expression(),this.state=848,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,84,this._ctx)&&(this.state=847,this.sep()),this.state=851,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=850,this.list()),e.node=AST.nodeSwitchCase(e.expression().node,e.list()?e.list().node:AST.nodeListFirst())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}otherwise_case(){let t,e=new Otherwise_caseContext(this,this._ctx,this.state);this.enterRule(e,84,MathJSLabParser.RULE_otherwise_case);try{this.enterOuterAlt(e,1),this.state=855,this.match(MathJSLabParser.OTHERWISE),this.state=857,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,86,this._ctx)&&(this.state=856,this.sep()),this.state=860,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=859,this.list()),this.state=863,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=862,this.sep()),e.node=e.list()?e.list().node:AST.nodeListFirst()}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}loop_command(){let t=new Loop_commandContext(this,this._ctx,this.state);this.enterRule(t,86,MathJSLabParser.RULE_loop_command);try{switch(this.state=879,this._errHandler.sync(this),this._input.LA(1)){case 14:this.enterOuterAlt(t,1),this.state=867,this.while_command(),t.node=t.while_command().node;break;case 16:this.enterOuterAlt(t,2),this.state=870,this.do_until_command(),t.node=t.do_until_command().node;break;case 18:case 20:this.enterOuterAlt(t,3),this.state=873,this.for_command(),t.node=t.for_command().node;break;case 22:this.enterOuterAlt(t,4),this.state=876,this.spmd_command(),t.node=t.spmd_command().node;break;default:throw new antlr4_node.X2(this)}}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}while_command(){let t,e=new While_commandContext(this,this._ctx,this.state);this.enterRule(e,88,MathJSLabParser.RULE_while_command);try{this.enterOuterAlt(e,1),this.state=881,this.match(MathJSLabParser.WHILE),this.state=882,this.expression(),this.state=884,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=883,this.sep()),this.state=887,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=886,this.list()),this.state=889,t=this._input.LA(1),6!==t&&15!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=AST.nodeWhile(e.expression().node,e.list()?e.list().node:AST.nodeListFirst())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}do_until_command(){let t,e=new Do_until_commandContext(this,this._ctx,this.state);this.enterRule(e,90,MathJSLabParser.RULE_do_until_command);try{this.enterOuterAlt(e,1),this.state=892,this.match(MathJSLabParser.DO),this.state=894,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=893,this.sep()),this.state=897,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=896,this.list()),this.state=899,this.match(MathJSLabParser.UNTIL),this.state=900,this.expression(),e.node=AST.nodeDoUntil(e.list()?e.list().node:AST.nodeListFirst(),e.expression().node)}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}for_command(){let t,e=new For_commandContext(this,this._ctx,this.state);this.enterRule(e,92,MathJSLabParser.RULE_for_command);try{switch(this.state=963,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,103,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=903,this.match(MathJSLabParser.FOR),this.state=904,this.assign_lhs(),this.state=905,this.match(MathJSLabParser.EQ),this.state=906,this.expression(),this.state=908,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=907,this.sep()),this.state=911,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=910,this.list()),this.state=913,t=this._input.LA(1),6!==t&&19!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=AST.nodeFor(e.assign_lhs().node,e.expression(0).node,e.list()?e.list().node:AST.nodeListFirst());break;case 2:this.enterOuterAlt(e,2),this.state=916,this.match(MathJSLabParser.FOR),this.state=917,this.match(MathJSLabParser.LPAREN),this.state=918,this.assign_lhs(),this.state=919,this.match(MathJSLabParser.EQ),this.state=920,this.expression(),this.state=921,this.match(MathJSLabParser.RPAREN),this.state=923,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=922,this.sep()),this.state=926,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=925,this.list()),this.state=928,t=this._input.LA(1),6!==t&&19!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=AST.nodeFor(e.assign_lhs().node,e.expression(0).node,e.list()?e.list().node:AST.nodeListFirst());break;case 3:this.enterOuterAlt(e,3),this.state=931,this.match(MathJSLabParser.PARFOR),this.state=932,this.assign_lhs(),this.state=933,this.match(MathJSLabParser.EQ),this.state=934,this.expression(),this.state=936,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=935,this.sep()),this.state=939,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=938,this.list()),this.state=941,t=this._input.LA(1),6!==t&&21!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=AST.nodeFor(e.assign_lhs().node,e.expression(0).node,e.list()?e.list().node:AST.nodeListFirst(),!0);break;case 4:this.enterOuterAlt(e,4),this.state=944,this.match(MathJSLabParser.PARFOR),this.state=945,this.match(MathJSLabParser.LPAREN),this.state=946,this.assign_lhs(),this.state=947,this.match(MathJSLabParser.EQ),this.state=948,this.expression(),this.state=951,this._errHandler.sync(this),t=this._input.LA(1),56===t&&(this.state=949,this.match(MathJSLabParser.COMMA),this.state=950,this.expression()),this.state=953,this.match(MathJSLabParser.RPAREN),this.state=955,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=954,this.sep()),this.state=958,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=957,this.list()),this.state=960,t=this._input.LA(1),6!==t&&21!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=AST.nodeFor(e.assign_lhs().node,e.expression(0).node,e.list()?e.list().node:AST.nodeListFirst(),!0,e.expression(1)?e.expression(1).node:null)}}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}spmd_command(){let t,e=new Spmd_commandContext(this,this._ctx,this.state);this.enterRule(e,94,MathJSLabParser.RULE_spmd_command);try{this.enterOuterAlt(e,1),this.state=965,this.match(MathJSLabParser.SPMD),this.state=967,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,104,this._ctx)&&(this.state=966,this.spmd_worker_spec()),this.state=970,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=969,this.sep()),this.state=973,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=972,this.list()),this.state=975,t=this._input.LA(1),6!==t&&23!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=AST.nodeSpmd(e.list()?e.list().node:AST.nodeListFirst(),e.spmd_worker_spec()?e.spmd_worker_spec().node:null)}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}spmd_worker_spec(){let t,e=new Spmd_worker_specContext(this,this._ctx,this.state);this.enterRule(e,96,MathJSLabParser.RULE_spmd_worker_spec);try{this.enterOuterAlt(e,1),this.state=978,this.match(MathJSLabParser.LPAREN),this.state=979,this.expression(),e.node=AST.nodeListFirst(e.expression(e.i++).node),this.state=985,this._errHandler.sync(this),t=this._input.LA(1),56===t&&(this.state=981,this.match(MathJSLabParser.COMMA),this.state=982,this.expression(),e.node=AST.appendNodeList(e.node,e.expression(e.i++).node)),this.state=987,this.match(MathJSLabParser.RPAREN)}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}jump_command(){let t=new Jump_commandContext(this,this._ctx,this.state);this.enterRule(t,98,MathJSLabParser.RULE_jump_command);try{switch(this.state=995,this._errHandler.sync(this),this._input.LA(1)){case 24:this.enterOuterAlt(t,1),this.state=989,this.match(MathJSLabParser.BREAK),t.node=AST.nodeBreak();break;case 25:this.enterOuterAlt(t,2),this.state=991,this.match(MathJSLabParser.CONTINUE),t.node=AST.nodeContinue();break;case 26:this.enterOuterAlt(t,3),this.state=993,this.match(MathJSLabParser.RETURN),t.node=AST.nodeReturn();break;default:throw new antlr4_node.X2(this)}}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}except_command(){let t=new Except_commandContext(this,this._ctx,this.state);this.enterRule(t,100,MathJSLabParser.RULE_except_command);try{switch(this.state=1003,this._errHandler.sync(this),this._input.LA(1)){case 29:this.enterOuterAlt(t,1),this.state=997,this.try_command(),t.node=t.try_command().node;break;case 32:this.enterOuterAlt(t,2),this.state=1e3,this.unwind_command(),t.node=t.unwind_command().node;break;default:throw new antlr4_node.X2(this)}}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}try_command(){let t,e=new Try_commandContext(this,this._ctx,this.state);this.enterRule(e,102,MathJSLabParser.RULE_try_command);try{switch(this.state=1025,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,114,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=1005,this.match(MathJSLabParser.TRY),this.state=1007,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1006,this.sep()),this.state=1010,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=1009,this.list()),this.state=1012,this.catch_clause(),this.state=1013,t=this._input.LA(1),6!==t&&31!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=AST.nodeTry(e.list()?e.list().node:AST.nodeListFirst(),e.catch_clause().body,e.catch_clause().identifierNode);break;case 2:this.enterOuterAlt(e,2),this.state=1016,this.match(MathJSLabParser.TRY),this.state=1018,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1017,this.sep()),this.state=1021,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=1020,this.list()),this.state=1023,t=this._input.LA(1),6!==t&&31!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=AST.nodeTry(e.list()?e.list().node:AST.nodeListFirst())}}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}catch_clause(){let t,e=new Catch_clauseContext(this,this._ctx,this.state);this.enterRule(e,104,MathJSLabParser.RULE_catch_clause);try{this.enterOuterAlt(e,1),this.state=1027,this.match(MathJSLabParser.CATCH),this.state=1029,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1028,this.sep()),this.state=1032,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=1031,this.list()),e.identifierNode=null,e.body=e.list()?e.list().node:AST.nodeListFirst(),!e.sep()&&e.body.list.length>0&&AST.isNodeIdentifier(e.body.list[0])&&(e.identifierNode=e.body.list.shift(),e.body.list.forEach((t,e)=>{t.index=e}))}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}unwind_command(){let t,e=new Unwind_commandContext(this,this._ctx,this.state);this.enterRule(e,106,MathJSLabParser.RULE_unwind_command);try{this.enterOuterAlt(e,1),this.state=1036,this.match(MathJSLabParser.UNWIND_PROTECT),this.state=1038,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1037,this.sep()),this.state=1041,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=1040,this.list()),this.state=1043,this.unwind_cleanup_clause(),this.state=1044,t=this._input.LA(1),6!==t&&34!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=AST.nodeUnwindProtect(e.list()?e.list().node:AST.nodeListFirst(),e.unwind_cleanup_clause().node)}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}unwind_cleanup_clause(){let t,e=new Unwind_cleanup_clauseContext(this,this._ctx,this.state);this.enterRule(e,108,MathJSLabParser.RULE_unwind_cleanup_clause);try{this.enterOuterAlt(e,1),this.state=1047,this.match(MathJSLabParser.UNWIND_PROTECT_CLEANUP),this.state=1049,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1048,this.sep()),this.state=1052,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=1051,this.list()),e.node=e.list()?e.list().node:AST.nodeListFirst()}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}param_list(){let t,e=new Param_listContext(this,this._ctx,this.state);this.enterRule(e,110,MathJSLabParser.RULE_param_list);try{if(this.enterOuterAlt(e,1),this.state=1056,this.match(MathJSLabParser.LPAREN),e.node=AST.nodeListFirst(),this.state=1069,this._errHandler.sync(this),t=this._input.LA(1),!(t-37&-32)&&1<<t-37&2097237||101===t)for(this.state=1058,this.param_list_elt(),e.node=AST.appendNodeList(e.node,e.param_list_elt(e.i++).node),this.state=1066,this._errHandler.sync(this),t=this._input.LA(1);56===t;)this.state=1060,this.match(MathJSLabParser.COMMA),this.state=1061,this.param_list_elt(),e.node=AST.appendNodeList(e.node,e.param_list_elt(e.i++).node),this.state=1068,this._errHandler.sync(this),t=this._input.LA(1);this.state=1071,this.match(MathJSLabParser.RPAREN)}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}param_list_elt(){let t=new Param_list_eltContext(this,this._ctx,this.state);this.enterRule(t,112,MathJSLabParser.RULE_param_list_elt);try{switch(this.state=1079,this._errHandler.sync(this),this._input.LA(1)){case 37:case 39:case 41:case 43:case 101:this.enterOuterAlt(t,1),this.state=1073,this.declaration_element(),t.node=t.declaration_element().node;break;case 58:this.enterOuterAlt(t,2),this.state=1076,this.magic_tilde(),t.node=t.magic_tilde().node;break;default:throw new antlr4_node.X2(this)}}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}return_list_elt(){let t=new Return_list_eltContext(this,this._ctx,this.state);this.enterRule(t,114,MathJSLabParser.RULE_return_list_elt);try{switch(this.state=1087,this._errHandler.sync(this),this._input.LA(1)){case 37:case 39:case 41:case 43:case 101:this.enterOuterAlt(t,1),this.state=1081,this.identifier(),t.node=t.identifier().node;break;case 58:this.enterOuterAlt(t,2),this.state=1084,this.magic_tilde(),t.node=t.magic_tilde().node;break;default:throw new antlr4_node.X2(this)}}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}return_list(){let t,e=new Return_listContext(this,this._ctx,this.state);this.enterRule(e,116,MathJSLabParser.RULE_return_list);try{switch(this.state=1108,this._errHandler.sync(this),this._input.LA(1)){case 37:case 39:case 41:case 43:case 58:case 101:this.enterOuterAlt(e,1),this.state=1089,this.return_list_elt(),e.node=AST.nodeListFirst(e.return_list_elt(0).node);break;case 64:if(this.enterOuterAlt(e,2),this.state=1092,this.match(MathJSLabParser.LBRACKET),e.node=AST.nodeListFirst(),this.state=1105,this._errHandler.sync(this),t=this._input.LA(1),!(t-37&-32)&&1<<t-37&2097237||101===t)for(this.state=1094,this.return_list_elt(),e.node=AST.appendNodeList(e.node,e.return_list_elt(e.i++).node),this.state=1102,this._errHandler.sync(this),t=this._input.LA(1);45===t||56===t;)this.state=1096,t=this._input.LA(1),45!==t&&56!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=1097,this.return_list_elt(),e.node=AST.appendNodeList(e.node,e.return_list_elt(e.i++).node),this.state=1104,this._errHandler.sync(this),t=this._input.LA(1);this.state=1107,this.match(MathJSLabParser.RBRACKET);break;default:throw new antlr4_node.X2(this)}}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}function_(){let t,e=new FunctionContext(this,this._ctx,this.state);this.enterRule(e,118,MathJSLabParser.RULE_function);try{this.enterOuterAlt(e,1),this.state=1110,this.match(MathJSLabParser.FUNCTION),this.state=1114,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,128,this._ctx)&&(this.state=1111,this.return_list(),this.state=1112,this.match(MathJSLabParser.EQ)),this.state=1116,this.function_name(),this.state=1118,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,129,this._ctx)&&(this.state=1117,this.param_list()),this.state=1121,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1120,this.sep()),this.state=1124,this._errHandler.sync(this),t=this._input.LA(1),47===t&&(this.state=1123,this.arguments_block_list()),this.state=1127,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=1126,this.list()),this.state=1129,t=this._input.LA(1),t- -1&-32||!(1<<t- -1&536871041)?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=AST.nodeFunctionDefinition(e.function_name().node,e.return_list()?e.return_list().node:AST.nodeListFirst(),e.param_list()?e.param_list().node:AST.nodeListFirst(),e.arguments_block_list()?e.arguments_block_list().node:AST.nodeListFirst(),e.list()?e.list().node:AST.nodeListFirst())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}function_name(){let t=new Function_nameContext(this,this._ctx,this.state);this.enterRule(t,120,MathJSLabParser.RULE_function_name);try{this.enterOuterAlt(t,1),this.state=1132,this.qualified_identifier(),t.node=t.qualified_identifier().node}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}classdef_command(){let t,e=new Classdef_commandContext(this,this._ctx,this.state);this.enterRule(e,122,MathJSLabParser.RULE_classdef_command);try{this.enterOuterAlt(e,1),this.state=1135,this.match(MathJSLabParser.CLASSDEF),this.state=1137,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1136,this.class_attribute_list()),this.state=1139,this.qualified_identifier(),this.state=1141,this._errHandler.sync(this),t=this._input.LA(1),85===t&&(this.state=1140,this.class_superclass_list()),this.state=1144,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1143,this.sep()),this.state=1147,this._errHandler.sync(this),t=this._input.LA(1),!(t-37&-32)&&1<<t-37&85&&(this.state=1146,this.class_section_list()),this.state=1149,t=this._input.LA(1),-1!==t&&6!==t&&36!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=AST.nodeClassDef(e.qualified_identifier().node,e.class_section_list()?e.class_section_list().node:AST.nodeListFirst(),e.class_attribute_list()?e.class_attribute_list().node:AST.nodeListFirst(),e.class_superclass_list()?e.class_superclass_list().node:AST.nodeListFirst())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_attribute_list(){let t,e=new Class_attribute_listContext(this,this._ctx,this.state);this.enterRule(e,124,MathJSLabParser.RULE_class_attribute_list);try{if(this.enterOuterAlt(e,1),this.state=1152,this.match(MathJSLabParser.LPAREN),e.node=AST.nodeListFirst(),this.state=1165,this._errHandler.sync(this),t=this._input.LA(1),!(t-37&-32)&&1<<t-37&6291541||101===t)for(this.state=1154,this.class_attribute(),e.node=AST.appendNodeList(e.node,e.class_attribute(e.i++).node),this.state=1162,this._errHandler.sync(this),t=this._input.LA(1);56===t;)this.state=1156,this.match(MathJSLabParser.COMMA),this.state=1157,this.class_attribute(),e.node=AST.appendNodeList(e.node,e.class_attribute(e.i++).node),this.state=1164,this._errHandler.sync(this),t=this._input.LA(1);this.state=1167,this.match(MathJSLabParser.RPAREN),this.state=1169,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,139,this._ctx)&&(this.state=1168,this.sep())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_attribute(){let t,e=new Class_attributeContext(this,this._ctx,this.state);this.enterRule(e,126,MathJSLabParser.RULE_class_attribute);try{switch(this.state=1182,this._errHandler.sync(this),this._input.LA(1)){case 37:case 39:case 41:case 43:case 101:this.enterOuterAlt(e,1),this.state=1171,this.identifier(),this.state=1174,this._errHandler.sync(this),t=this._input.LA(1),53===t&&(this.state=1172,this.match(MathJSLabParser.EQ),this.state=1173,this.expression()),e.node=AST.nodeClassAttribute(e.identifier().node,e.expression()?e.expression().node:null);break;case 58:case 59:this.enterOuterAlt(e,2),this.state=1178,e._op=this._input.LT(1),t=this._input.LA(1),58!==t&&59!==t?e._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=1179,this.identifier(),e.node=AST.nodeClassAttribute(e.identifier().node,AST.nodeOperation(e._op.text,e.identifier().node));break;default:throw new antlr4_node.X2(this)}}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_method_name(){let t,e=new Class_method_nameContext(this,this._ctx,this.state);this.enterRule(e,128,MathJSLabParser.RULE_class_method_name);try{for(this.enterOuterAlt(e,1),this.state=1184,this.identifier(),e.node=AST.nodeIdentifier(e.identifier(0).node.id),this.state=1192,this._errHandler.sync(this),t=this._input.LA(1);57===t;)this.state=1186,this.match(MathJSLabParser.DOT),this.state=1187,this.identifier(),e.node=AST.nodeIdentifier(e.node.id+"."+e.identifier(e.i++).node.id),this.state=1194,this._errHandler.sync(this),t=this._input.LA(1)}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_superclass_list(){let t,e=new Class_superclass_listContext(this,this._ctx,this.state);this.enterRule(e,130,MathJSLabParser.RULE_class_superclass_list);try{let r;for(this.enterOuterAlt(e,1),this.state=1195,this.match(MathJSLabParser.EXPR_LT),this.state=1196,this.qualified_identifier(),e.node=AST.nodeListFirst(e.qualified_identifier(e.i++).node),this.state=1204,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,143,this._ctx);2!==r&&r!==antlr4_node.MG.INVALID_ALT_NUMBER;)1===r&&(this.state=1198,t=this._input.LA(1),56!==t&&83!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=1199,this.qualified_identifier(),e.node=AST.appendNodeList(e.node,e.qualified_identifier(e.i++).node)),this.state=1206,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,143,this._ctx)}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_section_list(){let t,e=new Class_section_listContext(this,this._ctx,this.state);this.enterRule(e,132,MathJSLabParser.RULE_class_section_list);try{let r;for(this.enterOuterAlt(e,1),this.state=1207,this.class_section(),e.node=AST.nodeListFirst(e.class_section(e.i++).node),this.state=1217,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,145,this._ctx);2!==r&&r!==antlr4_node.MG.INVALID_ALT_NUMBER;)1===r&&(this.state=1210,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1209,this.sep()),this.state=1212,this.class_section(),e.node=AST.appendNodeList(e.node,e.class_section(e.i++).node)),this.state=1219,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,145,this._ctx);this.state=1221,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1220,this.sep())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_section(){let t=new Class_sectionContext(this,this._ctx,this.state);this.enterRule(t,134,MathJSLabParser.RULE_class_section);try{switch(this.state=1235,this._errHandler.sync(this),this._input.LA(1)){case 39:this.enterOuterAlt(t,1),this.state=1223,this.properties_section(),t.node=t.properties_section().node;break;case 43:this.enterOuterAlt(t,2),this.state=1226,this.methods_section(),t.node=t.methods_section().node;break;case 41:this.enterOuterAlt(t,3),this.state=1229,this.events_section(),t.node=t.events_section().node;break;case 37:this.enterOuterAlt(t,4),this.state=1232,this.enumeration_section(),t.node=t.enumeration_section().node;break;default:throw new antlr4_node.X2(this)}}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}properties_section(){let t,e=new Properties_sectionContext(this,this._ctx,this.state);this.enterRule(e,136,MathJSLabParser.RULE_properties_section);try{this.enterOuterAlt(e,1),this.state=1237,this.match(MathJSLabParser.PROPERTIES),this.state=1239,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1238,this.class_attribute_list()),this.state=1242,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1241,this.sep()),this.state=1245,this._errHandler.sync(this),t=this._input.LA(1),(!(t-37&-32)&&1<<t-37&85||101===t)&&(this.state=1244,this.class_property_list()),this.state=1247,t=this._input.LA(1),6!==t&&40!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=AST.nodeClassSection("PROPERTIES",e.class_property_list()?e.class_property_list().node:AST.nodeListFirst(),e.class_attribute_list()?e.class_attribute_list().node:AST.nodeListFirst())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_property_list(){let t,e=new Class_property_listContext(this,this._ctx,this.state);this.enterRule(e,138,MathJSLabParser.RULE_class_property_list);try{let r;for(this.enterOuterAlt(e,1),this.state=1250,this.class_property(),e.node=AST.nodeListFirst(e.class_property(e.i++).node),this.state=1258,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,151,this._ctx);2!==r&&r!==antlr4_node.MG.INVALID_ALT_NUMBER;)1===r&&(this.state=1252,this.sep(),this.state=1253,this.class_property(),e.node=AST.appendNodeList(e.node,e.class_property(e.i++).node)),this.state=1260,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,151,this._ctx);this.state=1262,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1261,this.sep())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_property(){let t,e=new Class_propertyContext(this,this._ctx,this.state);this.enterRule(e,140,MathJSLabParser.RULE_class_property);try{this.enterOuterAlt(e,1),this.state=1264,this.identifier(),this.state=1269,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1265,this.match(MathJSLabParser.LPAREN),this.state=1266,this.arg_list(),this.state=1267,this.match(MathJSLabParser.RPAREN)),this.state=1272,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,154,this._ctx)&&(this.state=1271,this.qualified_identifier()),this.state=1278,this._errHandler.sync(this),t=this._input.LA(1),66===t&&(this.state=1274,this.match(MathJSLabParser.LCURLYBR),this.state=1275,this.arg_list(),this.state=1276,this.match(MathJSLabParser.RCURLYBR)),this.state=1282,this._errHandler.sync(this),t=this._input.LA(1),53===t&&(this.state=1280,this.match(MathJSLabParser.EQ),this.state=1281,this.expression()),e.node=AST.nodeClassProperty(e.identifier().node,e.LPAREN()?e.arg_list(0).node:AST.nodeListFirst(),e.qualified_identifier()?e.qualified_identifier().node:null,e.LCURLYBR()?e.arg_list(e.LPAREN()?1:0).node:AST.nodeListFirst(),e.expression()?e.expression().node:null)}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}methods_section(){let t,e=new Methods_sectionContext(this,this._ctx,this.state);this.enterRule(e,142,MathJSLabParser.RULE_methods_section);try{this.enterOuterAlt(e,1),this.state=1286,this.match(MathJSLabParser.METHODS),this.state=1288,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1287,this.class_attribute_list()),this.state=1291,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1290,this.sep()),this.state=1294,this._errHandler.sync(this),t=this._input.LA(1),(27===t||!(t-37&-32)&&1<<t-37&136314965||101===t)&&(this.state=1293,this.class_method_list()),this.state=1296,t=this._input.LA(1),6!==t&&44!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=AST.nodeClassSection("METHODS",e.class_method_list()?e.class_method_list().node:AST.nodeListFirst(),e.class_attribute_list()?e.class_attribute_list().node:AST.nodeListFirst())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_method(){let t,e=new Class_methodContext(this,this._ctx,this.state);this.enterRule(e,144,MathJSLabParser.RULE_class_method);try{switch(this.state=1316,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,162,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=1299,this.function_(),e.node=e.function_().node;break;case 2:this.enterOuterAlt(e,2),this.state=1302,this.class_method_name(),this.state=1304,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1303,this.param_list()),e.node=AST.nodeFunctionDefinition(e.class_method_name().node,AST.nodeListFirst(),e.param_list()?e.param_list().node:AST.nodeListFirst(),AST.nodeListFirst(),AST.nodeListFirst()),e.node.attributes={...e.node.attributes??{},prototype:!0};break;case 3:this.enterOuterAlt(e,3),this.state=1308,this.return_list(),this.state=1309,this.match(MathJSLabParser.EQ),this.state=1310,this.class_method_name(),this.state=1312,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1311,this.param_list()),e.node=AST.nodeFunctionDefinition(e.class_method_name().node,e.return_list().node,e.param_list()?e.param_list().node:AST.nodeListFirst(),AST.nodeListFirst(),AST.nodeListFirst()),e.node.attributes={...e.node.attributes??{},prototype:!0}}}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_method_list(){let t,e=new Class_method_listContext(this,this._ctx,this.state);this.enterRule(e,146,MathJSLabParser.RULE_class_method_list);try{let r;for(this.enterOuterAlt(e,1),this.state=1318,this.class_method(),e.node=AST.nodeListFirst(e.class_method(e.i++).node),this.state=1328,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,164,this._ctx);2!==r&&r!==antlr4_node.MG.INVALID_ALT_NUMBER;)1===r&&(this.state=1321,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1320,this.sep()),this.state=1323,this.class_method(),e.node=AST.appendNodeList(e.node,e.class_method(e.i++).node)),this.state=1330,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,164,this._ctx);this.state=1332,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1331,this.sep())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}events_section(){let t,e=new Events_sectionContext(this,this._ctx,this.state);this.enterRule(e,148,MathJSLabParser.RULE_events_section);try{this.enterOuterAlt(e,1),this.state=1334,this.match(MathJSLabParser.EVENTS),this.state=1336,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1335,this.class_attribute_list()),this.state=1339,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1338,this.sep()),this.state=1342,this._errHandler.sync(this),t=this._input.LA(1),(!(t-37&-32)&&1<<t-37&85||101===t)&&(this.state=1341,this.class_event_list()),this.state=1344,t=this._input.LA(1),6!==t&&42!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=AST.nodeClassSection("EVENTS",e.class_event_list()?e.class_event_list().node:AST.nodeListFirst(),e.class_attribute_list()?e.class_attribute_list().node:AST.nodeListFirst())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_event_list(){let t,e=new Class_event_listContext(this,this._ctx,this.state);this.enterRule(e,150,MathJSLabParser.RULE_class_event_list);try{let r;for(this.enterOuterAlt(e,1),this.state=1347,this.class_event(),e.node=AST.nodeListFirst(e.class_event(e.i++).node),this.state=1357,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,170,this._ctx);2!==r&&r!==antlr4_node.MG.INVALID_ALT_NUMBER;)1===r&&(this.state=1350,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1349,this.sep()),this.state=1352,this.class_event(),e.node=AST.appendNodeList(e.node,e.class_event(e.i++).node)),this.state=1359,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,170,this._ctx);this.state=1361,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1360,this.sep())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_event(){let t=new Class_eventContext(this,this._ctx,this.state);this.enterRule(t,152,MathJSLabParser.RULE_class_event);try{this.enterOuterAlt(t,1),this.state=1363,this.identifier(),t.node=AST.nodeClassEvent(t.identifier().node)}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}enumeration_section(){let t,e=new Enumeration_sectionContext(this,this._ctx,this.state);this.enterRule(e,154,MathJSLabParser.RULE_enumeration_section);try{this.enterOuterAlt(e,1),this.state=1366,this.match(MathJSLabParser.ENUMERATION),this.state=1368,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1367,this.class_attribute_list()),this.state=1371,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1370,this.sep()),this.state=1374,this._errHandler.sync(this),t=this._input.LA(1),(!(t-37&-32)&&1<<t-37&85||101===t)&&(this.state=1373,this.class_enumeration_list()),this.state=1376,t=this._input.LA(1),6!==t&&38!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=AST.nodeClassSection("ENUMERATION",e.class_enumeration_list()?e.class_enumeration_list().node:AST.nodeListFirst(),e.class_attribute_list()?e.class_attribute_list().node:AST.nodeListFirst())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_enumeration_list(){let t,e=new Class_enumeration_listContext(this,this._ctx,this.state);this.enterRule(e,156,MathJSLabParser.RULE_class_enumeration_list);try{let r;for(this.enterOuterAlt(e,1),this.state=1379,this.class_enumeration(),e.node=AST.nodeListFirst(e.class_enumeration(e.i++).node),this.state=1389,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,176,this._ctx);2!==r&&r!==antlr4_node.MG.INVALID_ALT_NUMBER;)1===r&&(this.state=1382,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1381,this.sep()),this.state=1384,this.class_enumeration(),e.node=AST.appendNodeList(e.node,e.class_enumeration(e.i++).node)),this.state=1391,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,176,this._ctx);this.state=1393,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1392,this.sep())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_enumeration(){let t,e=new Class_enumerationContext(this,this._ctx,this.state);this.enterRule(e,158,MathJSLabParser.RULE_class_enumeration);try{this.enterOuterAlt(e,1),this.state=1395,this.identifier(),this.state=1401,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1396,this.match(MathJSLabParser.LPAREN),this.state=1398,this._errHandler.sync(this),t=this._input.LA(1),(3===t||7===t||!(t-37&-32)&&1<<t-37&736244309||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=1397,this.arg_list()),this.state=1400,this.match(MathJSLabParser.RPAREN)),e.node=AST.nodeClassEnumeration(e.identifier().node,e.arg_list()?e.arg_list().node:AST.nodeListFirst())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}arguments_block_list(){let t,e=new Arguments_block_listContext(this,this._ctx,this.state);this.enterRule(e,160,MathJSLabParser.RULE_arguments_block_list);try{let r;for(this.enterOuterAlt(e,1),this.state=1405,this.arguments_block(),e.node=AST.nodeListFirst(e.arguments_block(e.i++).node),this.state=1415,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,181,this._ctx);2!==r&&r!==antlr4_node.MG.INVALID_ALT_NUMBER;)1===r&&(this.state=1408,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1407,this.sep()),this.state=1410,this.arguments_block(),e.node=AST.appendNodeList(e.node,e.arguments_block(e.i++).node)),this.state=1417,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,181,this._ctx);this.state=1419,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1418,this.sep())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}arguments_block(){let t,e=new Arguments_blockContext(this,this._ctx,this.state);this.enterRule(e,162,MathJSLabParser.RULE_arguments_block);try{this.enterOuterAlt(e,1),this.state=1421,this.match(MathJSLabParser.ARGUMENTS),this.state=1423,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,183,this._ctx)&&(this.state=1422,this.sep()),this.state=1431,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1425,this.match(MathJSLabParser.LPAREN),this.state=1426,this.arguments_attribute_list(),this.state=1427,this.match(MathJSLabParser.RPAREN),this.state=1429,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,184,this._ctx))&&(this.state=1428,this.sep()),this.state=1434,this._errHandler.sync(this),t=this._input.LA(1),(!(t-37&-32)&&1<<t-37&85||101===t)&&(this.state=1433,this.args_validation_list()),this.state=1437,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1436,this.sep()),this.state=1439,t=this._input.LA(1),6!==t&&48!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=AST.nodeArguments(e.arguments_attribute_list()?e.arguments_attribute_list().node:null,e.args_validation_list()?e.args_validation_list().node:AST.nodeListFirst())}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}arguments_attribute_list(){let t,e=new Arguments_attribute_listContext(this,this._ctx,this.state);this.enterRule(e,164,MathJSLabParser.RULE_arguments_attribute_list);try{for(this.enterOuterAlt(e,1),this.state=1442,this.identifier(),e.node=AST.nodeListFirst(e.identifier(e.i++).node),this.state=1450,this._errHandler.sync(this),t=this._input.LA(1);56===t;)this.state=1444,this.match(MathJSLabParser.COMMA),this.state=1445,this.identifier(),e.node=AST.appendNodeList(e.node,e.identifier(e.i++).node),this.state=1452,this._errHandler.sync(this),t=this._input.LA(1)}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}args_validation_list(){let t=new Args_validation_listContext(this,this._ctx,this.state);this.enterRule(t,166,MathJSLabParser.RULE_args_validation_list);try{let e;for(this.enterOuterAlt(t,1),this.state=1453,this.arg_validation(),t.node=AST.nodeListFirst(t.arg_validation(t.i++).node),this.state=1461,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,189,this._ctx);2!==e&&e!==antlr4_node.MG.INVALID_ALT_NUMBER;)1===e&&(this.state=1455,this.sep(),this.state=1456,this.arg_validation(),t.node=AST.appendNodeList(t.node,t.arg_validation(t.i++).node)),this.state=1463,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,189,this._ctx)}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}arg_validation(){let t,e=new Arg_validationContext(this,this._ctx,this.state);this.enterRule(e,168,MathJSLabParser.RULE_arg_validation);try{this.enterOuterAlt(e,1),this.state=1464,this.arg_validation_name(),this.state=1469,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1465,this.match(MathJSLabParser.LPAREN),this.state=1466,this.arg_list(),this.state=1467,this.match(MathJSLabParser.RPAREN)),this.state=1472,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,191,this._ctx)&&(this.state=1471,this.qualified_identifier()),this.state=1478,this._errHandler.sync(this),t=this._input.LA(1),66===t&&(this.state=1474,this.match(MathJSLabParser.LCURLYBR),this.state=1475,this.arg_list(),this.state=1476,this.match(MathJSLabParser.RCURLYBR)),this.state=1482,this._errHandler.sync(this),t=this._input.LA(1),53===t&&(this.state=1480,this.match(MathJSLabParser.EQ),this.state=1481,this.expression()),e.node=AST.nodeArgumentValidation(e.arg_validation_name().node,e.LPAREN()?e.arg_list(0).node:AST.nodeListFirst(),e.qualified_identifier()?e.qualified_identifier().node:AST.nodeListFirst(),e.LCURLYBR()?e.LPAREN()?e.arg_list(1).node:e.arg_list(0).node:AST.nodeListFirst(),e.expression()?e.expression().node:null)}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}arg_validation_name(){let t,e=new Arg_validation_nameContext(this,this._ctx,this.state);this.enterRule(e,170,MathJSLabParser.RULE_arg_validation_name);try{for(this.enterOuterAlt(e,1),this.state=1486,this.identifier(),e.node=e.identifier(0).node,this.state=1494,this._errHandler.sync(this),t=this._input.LA(1);57===t;)this.state=1488,this.match(MathJSLabParser.DOT),this.state=1489,this.identifier(),e.node=AST.nodeIndirectRef(e.node,e.identifier(e.i++).node.id),this.state=1496,this._errHandler.sync(this),t=this._input.LA(1)}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}sep_no_nl(){let t,e=new Sep_no_nlContext(this,this._ctx,this.state);this.enterRule(e,172,MathJSLabParser.RULE_sep_no_nl);try{this.enterOuterAlt(e,1),this.state=1498,this._errHandler.sync(this),t=this._input.LA(1);do{this.state=1497,t=this._input.LA(1),55!==t&&56!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=1500,this._errHandler.sync(this),t=this._input.LA(1)}while(55===t||56===t)}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}nl(){let t=new NlContext(this,this._ctx,this.state);this.enterRule(t,174,MathJSLabParser.RULE_nl);try{let e;this.enterOuterAlt(t,1),this.state=1503,this._errHandler.sync(this),e=1;do{if(1!==e)throw new antlr4_node.X2(this);this.state=1502,this.match(MathJSLabParser.NEWLINE),this.state=1505,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,196,this._ctx)}while(2!==e&&e!==antlr4_node.MG.INVALID_ALT_NUMBER)}catch(e){if(!(e instanceof antlr4_node.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}sep(){let t,e=new SepContext(this,this._ctx,this.state);this.enterRule(e,176,MathJSLabParser.RULE_sep);try{let r;this.enterOuterAlt(e,1),this.state=1508,this._errHandler.sync(this),r=1;do{if(1!==r)throw new antlr4_node.X2(this);this.state=1507,t=this._input.LA(1),55!==t&&56!==t&&106!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=1510,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,197,this._ctx)}while(2!==r&&r!==antlr4_node.MG.INVALID_ALT_NUMBER)}catch(t){if(!(t instanceof antlr4_node.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}sempred(t,e,r){switch(e){case 23:return this.oper_expr_sempred(t,r);case 24:return this.power_expr_sempred(t,r);case 26:return this.simple_expr_sempred(t,r)}return!0}oper_expr_sempred(t,e){switch(e){case 0:return this.precpred(this._ctx,2);case 1:return this.precpred(this._ctx,1);case 2:return this.precpred(this._ctx,12);case 3:return this.precpred(this._ctx,11);case 4:return this.precpred(this._ctx,10);case 5:return this.precpred(this._ctx,9);case 6:return this.precpred(this._ctx,8);case 7:return this.precpred(this._ctx,7);case 8:return this.precpred(this._ctx,6);case 9:return this.precpred(this._ctx,5)}return!0}power_expr_sempred(t,e){switch(e){case 10:return this.precpred(this._ctx,8);case 11:return this.precpred(this._ctx,7);case 12:return this.precpred(this._ctx,6);case 13:return this.precpred(this._ctx,5);case 14:return this.precpred(this._ctx,4);case 15:return this.precpred(this._ctx,3)}return!0}simple_expr_sempred(t,e){switch(e){case 16:return this.precpred(this._ctx,5);case 17:return this.precpred(this._ctx,4);case 18:return this.precpred(this._ctx,3);case 19:return this.precpred(this._ctx,2);case 20:return this.precpred(this._ctx,1)}return!0}static _serializedATN=[4,1,142,1513,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,2,61,7,61,2,62,7,62,2,63,7,63,2,64,7,64,2,65,7,65,2,66,7,66,2,67,7,67,2,68,7,68,2,69,7,69,2,70,7,70,2,71,7,71,2,72,7,72,2,73,7,73,2,74,7,74,2,75,7,75,2,76,7,76,2,77,7,77,2,78,7,78,2,79,7,79,2,80,7,80,2,81,7,81,2,82,7,82,2,83,7,83,2,84,7,84,2,85,7,85,2,86,7,86,2,87,7,87,2,88,7,88,1,0,3,0,180,8,0,1,0,1,0,1,0,3,0,185,8,0,1,0,1,0,1,0,1,0,3,0,191,8,0,1,1,1,1,1,1,1,1,1,1,1,1,5,1,199,8,1,10,1,12,1,202,9,1,1,1,3,1,205,8,1,1,1,1,1,1,2,1,2,1,2,1,2,1,2,1,2,5,2,215,8,2,10,2,12,2,218,9,2,1,2,3,2,221,8,2,1,2,1,2,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,3,3,234,8,3,1,4,1,4,1,4,1,4,1,4,1,4,5,4,242,8,4,10,4,12,4,245,9,4,1,4,1,4,1,5,1,5,1,5,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,3,6,262,8,6,1,7,1,7,1,7,1,7,1,7,3,7,269,8,7,1,8,1,8,1,8,1,8,1,8,1,8,5,8,277,8,8,10,8,12,8,280,9,8,1,9,1,9,1,9,1,9,3,9,286,8,9,1,10,1,10,1,10,1,11,1,11,1,11,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,12,3,12,303,8,12,1,13,1,13,1,13,1,13,1,13,1,13,5,13,311,8,13,10,13,12,13,314,9,13,1,13,3,13,317,8,13,1,13,1,13,1,13,4,13,322,8,13,11,13,12,13,323,1,13,3,13,327,8,13,1,13,5,13,330,8,13,10,13,12,13,333,9,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,5,13,342,8,13,10,13,12,13,345,9,13,1,13,3,13,348,8,13,1,13,1,13,1,13,4,13,353,8,13,11,13,12,13,354,1,13,3,13,358,8,13,1,13,5,13,361,8,13,10,13,12,13,364,9,13,1,13,3,13,367,8,13,1,14,1,14,1,14,3,14,372,8,14,1,14,1,14,1,14,1,14,1,14,1,14,5,14,380,8,14,10,14,12,14,383,9,14,1,14,3,14,386,8,14,3,14,388,8,14,1,15,1,15,1,15,1,15,1,16,1,16,1,16,1,16,1,17,1,17,1,17,1,17,1,17,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,3,18,425,8,18,1,19,1,19,1,19,1,20,1,20,1,20,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,3,21,442,8,21,1,22,1,22,1,22,1,22,1,22,1,22,5,22,450,8,22,10,22,12,22,453,9,22,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,3,23,467,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,1,23,1,23,1,23,1,23,3,23,485,8,23,1,23,1,23,1,23,1,23,1,23,3,23,492,8,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,3,23,501,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,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,5,23,526,8,23,10,23,12,23,529,9,23,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,3,24,543,8,24,1,24,1,24,1,24,1,24,1,24,1,24,3,24,551,8,24,1,24,1,24,1,24,1,24,1,24,3,24,558,8,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,3,24,567,8,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,5,24,584,8,24,10,24,12,24,587,9,24,1,25,1,25,1,25,1,25,1,25,3,25,594,8,25,1,25,1,25,1,26,1,26,1,26,1,26,1,26,1,26,1,26,3,26,605,8,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,5,26,632,8,26,10,26,12,26,635,9,26,1,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,3,27,648,8,27,1,28,1,28,1,28,1,28,1,28,3,28,655,8,28,1,28,1,28,3,28,659,8,28,1,29,1,29,1,29,1,29,1,29,1,29,5,29,667,8,29,10,29,12,29,670,9,29,1,29,3,29,673,8,29,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,3,30,699,8,30,1,31,1,31,1,31,1,31,3,31,705,8,31,1,31,1,31,1,31,3,31,710,8,31,1,31,1,31,1,31,5,31,715,8,31,10,31,12,31,718,9,31,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,3,32,728,8,32,1,33,1,33,1,33,1,33,1,33,3,33,735,8,33,1,33,1,33,1,33,5,33,740,8,33,10,33,12,33,743,9,33,3,33,745,8,33,1,34,1,34,1,34,1,34,1,34,1,34,1,34,3,34,754,8,34,1,34,1,34,3,34,758,8,34,1,35,1,35,1,35,1,35,1,35,1,35,3,35,766,8,35,1,36,1,36,1,36,3,36,771,8,36,1,36,3,36,774,8,36,1,36,1,36,1,36,1,36,5,36,780,8,36,10,36,12,36,783,9,36,1,36,3,36,786,8,36,1,36,1,36,1,36,1,37,1,37,3,37,793,8,37,1,37,1,37,3,37,797,8,37,1,37,3,37,800,8,37,1,37,1,37,1,38,1,38,3,38,806,8,38,1,38,3,38,809,8,38,1,38,1,38,1,39,1,39,1,39,3,39,816,8,39,1,39,3,39,819,8,39,1,39,3,39,822,8,39,1,39,1,39,1,39,1,40,1,40,1,40,3,40,830,8,40,1,40,1,40,1,40,5,40,835,8,40,10,40,12,40,838,9,40,1,40,3,40,841,8,40,1,41,1,41,3,41,845,8,41,1,41,1,41,3,41,849,8,41,1,41,3,41,852,8,41,1,41,1,41,1,42,1,42,3,42,858,8,42,1,42,3,42,861,8,42,1,42,3,42,864,8,42,1,42,1,42,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,43,3,43,880,8,43,1,44,1,44,1,44,3,44,885,8,44,1,44,3,44,888,8,44,1,44,1,44,1,44,1,45,1,45,3,45,895,8,45,1,45,3,45,898,8,45,1,45,1,45,1,45,1,45,1,46,1,46,1,46,1,46,1,46,3,46,909,8,46,1,46,3,46,912,8,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,3,46,924,8,46,1,46,3,46,927,8,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,3,46,937,8,46,1,46,3,46,940,8,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,3,46,952,8,46,1,46,1,46,3,46,956,8,46,1,46,3,46,959,8,46,1,46,1,46,1,46,3,46,964,8,46,1,47,1,47,3,47,968,8,47,1,47,3,47,971,8,47,1,47,3,47,974,8,47,1,47,1,47,1,47,1,48,1,48,1,48,1,48,1,48,1,48,1,48,3,48,986,8,48,1,48,1,48,1,49,1,49,1,49,1,49,1,49,1,49,3,49,996,8,49,1,50,1,50,1,50,1,50,1,50,1,50,3,50,1004,8,50,1,51,1,51,3,51,1008,8,51,1,51,3,51,1011,8,51,1,51,1,51,1,51,1,51,1,51,1,51,3,51,1019,8,51,1,51,3,51,1022,8,51,1,51,1,51,3,51,1026,8,51,1,52,1,52,3,52,1030,8,52,1,52,3,52,1033,8,52,1,52,1,52,1,53,1,53,3,53,1039,8,53,1,53,3,53,1042,8,53,1,53,1,53,1,53,1,53,1,54,1,54,3,54,1050,8,54,1,54,3,54,1053,8,54,1,54,1,54,1,55,1,55,1,55,1,55,1,55,1,55,1,55,1,55,5,55,1065,8,55,10,55,12,55,1068,9,55,3,55,1070,8,55,1,55,1,55,1,56,1,56,1,56,1,56,1,56,1,56,3,56,1080,8,56,1,57,1,57,1,57,1,57,1,57,1,57,3,57,1088,8,57,1,58,1,58,1,58,1,58,1,58,1,58,1,58,1,58,1,58,1,58,1,58,5,58,1101,8,58,10,58,12,58,1104,9,58,3,58,1106,8,58,1,58,3,58,1109,8,58,1,59,1,59,1,59,1,59,3,59,1115,8,59,1,59,1,59,3,59,1119,8,59,1,59,3,59,1122,8,59,1,59,3,59,1125,8,59,1,59,3,59,1128,8,59,1,59,1,59,1,59,1,60,1,60,1,60,1,61,1,61,3,61,1138,8,61,1,61,1,61,3,61,1142,8,61,1,61,3,61,1145,8,61,1,61,3,61,1148,8,61,1,61,1,61,1,61,1,62,1,62,1,62,1,62,1,62,1,62,1,62,1,62,5,62,1161,8,62,10,62,12,62,1164,9,62,3,62,1166,8,62,1,62,1,62,3,62,1170,8,62,1,63,1,63,1,63,3,63,1175,8,63,1,63,1,63,1,63,1,63,1,63,1,63,3,63,1183,8,63,1,64,1,64,1,64,1,64,1,64,1,64,5,64,1191,8,64,10,64,12,64,1194,9,64,1,65,1,65,1,65,1,65,1,65,1,65,1,65,5,65,1203,8,65,10,65,12,65,1206,9,65,1,66,1,66,1,66,3,66,1211,8,66,1,66,1,66,1,66,5,66,1216,8,66,10,66,12,66,1219,9,66,1,66,3,66,1222,8,66,1,67,1,67,1,67,1,67,1,67,1,67,1,67,1,67,1,67,1,67,1,67,1,67,3,67,1236,8,67,1,68,1,68,3,68,1240,8,68,1,68,3,68,1243,8,68,1,68,3,68,1246,8,68,1,68,1,68,1,68,1,69,1,69,1,69,1,69,1,69,1,69,5,69,1257,8,69,10,69,12,69,1260,9,69,1,69,3,69,1263,8,69,1,70,1,70,1,70,1,70,1,70,3,70,1270,8,70,1,70,3,70,1273,8,70,1,70,1,70,1,70,1,70,3,70,1279,8,70,1,70,1,70,3,70,1283,8,70,1,70,1,70,1,71,1,71,3,71,1289,8,71,1,71,3,71,1292,8,71,1,71,3,71,1295,8,71,1,71,1,71,1,71,1,72,1,72,1,72,1,72,1,72,3,72,1305,8,72,1,72,1,72,1,72,1,72,1,72,1,72,3,72,1313,8,72,1,72,1,72,3,72,1317,8,72,1,73,1,73,1,73,3,73,1322,8,73,1,73,1,73,1,73,5,73,1327,8,73,10,73,12,73,1330,9,73,1,73,3,73,1333,8,73,1,74,1,74,3,74,1337,8,74,1,74,3,74,1340,8,74,1,74,3,74,1343,8,74,1,74,1,74,1,74,1,75,1,75,1,75,3,75,1351,8,75,1,75,1,75,1,75,5,75,1356,8,75,10,75,12,75,1359,9,75,1,75,3,75,1362,8,75,1,76,1,76,1,76,1,77,1,77,3,77,1369,8,77,1,77,3,77,1372,8,77,1,77,3,77,1375,8,77,1,77,1,77,1,77,1,78,1,78,1,78,3,78,1383,8,78,1,78,1,78,1,78,5,78,1388,8,78,10,78,12,78,1391,9,78,1,78,3,78,1394,8,78,1,79,1,79,1,79,3,79,1399,8,79,1,79,3,79,1402,8,79,1,79,1,79,1,80,1,80,1,80,3,80,1409,8,80,1,80,1,80,1,80,5,80,1414,8,80,10,80,12,80,1417,9,80,1,80,3,80,1420,8,80,1,81,1,81,3,81,1424,8,81,1,81,1,81,1,81,1,81,3,81,1430,8,81,3,81,1432,8,81,1,81,3,81,1435,8,81,1,81,3,81,1438,8,81,1,81,1,81,1,81,1,82,1,82,1,82,1,82,1,82,1,82,5,82,1449,8,82,10,82,12,82,1452,9,82,1,83,1,83,1,83,1,83,1,83,1,83,5,83,1460,8,83,10,83,12,83,1463,9,83,1,84,1,84,1,84,1,84,1,84,3,84,1470,8,84,1,84,3,84,1473,8,84,1,84,1,84,1,84,1,84,3,84,1479,8,84,1,84,1,84,3,84,1483,8,84,1,84,1,84,1,85,1,85,1,85,1,85,1,85,1,85,5,85,1493,8,85,10,85,12,85,1496,9,85,1,86,4,86,1499,8,86,11,86,12,86,1500,1,87,4,87,1504,8,87,11,87,12,87,1505,1,88,4,88,1509,8,88,11,88,12,88,1510,1,88,0,3,46,48,52,89,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,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,0,28,2,0,45,45,56,56,2,0,49,50,94,95,1,0,58,59,3,0,51,52,68,68,91,93,1,0,49,50,1,0,94,95,1,0,98,99,1,0,96,97,1,0,85,90,2,0,53,53,69,80,1,0,5,6,2,0,6,6,11,11,2,0,6,6,15,15,2,0,6,6,19,19,2,0,6,6,21,21,2,0,6,6,23,23,2,0,6,6,31,31,2,0,6,6,34,34,2,1,6,6,28,28,2,1,6,6,36,36,2,0,56,56,83,83,2,0,6,6,40,40,2,0,6,6,44,44,2,0,6,6,42,42,2,0,6,6,38,38,2,0,6,6,48,48,1,0,55,56,2,0,55,56,106,106,1666,0,190,1,0,0,0,2,192,1,0,0,0,4,208,1,0,0,0,6,233,1,0,0,0,8,235,1,0,0,0,10,248,1,0,0,0,12,261,1,0,0,0,14,268,1,0,0,0,16,270,1,0,0,0,18,285,1,0,0,0,20,287,1,0,0,0,22,290,1,0,0,0,24,302,1,0,0,0,26,366,1,0,0,0,28,387,1,0,0,0,30,389,1,0,0,0,32,393,1,0,0,0,34,397,1,0,0,0,36,424,1,0,0,0,38,426,1,0,0,0,40,429,1,0,0,0,42,441,1,0,0,0,44,443,1,0,0,0,46,466,1,0,0,0,48,542,1,0,0,0,50,588,1,0,0,0,52,604,1,0,0,0,54,647,1,0,0,0,56,658,1,0,0,0,58,660,1,0,0,0,60,698,1,0,0,0,62,704,1,0,0,0,64,727,1,0,0,0,66,729,1,0,0,0,68,757,1,0,0,0,70,765,1,0,0,0,72,767,1,0,0,0,74,790,1,0,0,0,76,803,1,0,0,0,78,812,1,0,0,0,80,826,1,0,0,0,82,842,1,0,0,0,84,855,1,0,0,0,86,879,1,0,0,0,88,881,1,0,0,0,90,892,1,0,0,0,92,963,1,0,0,0,94,965,1,0,0,0,96,978,1,0,0,0,98,995,1,0,0,0,100,1003,1,0,0,0,102,1025,1,0,0,0,104,1027,1,0,0,0,106,1036,1,0,0,0,108,1047,1,0,0,0,110,1056,1,0,0,0,112,1079,1,0,0,0,114,1087,1,0,0,0,116,1108,1,0,0,0,118,1110,1,0,0,0,120,1132,1,0,0,0,122,1135,1,0,0,0,124,1152,1,0,0,0,126,1182,1,0,0,0,128,1184,1,0,0,0,130,1195,1,0,0,0,132,1207,1,0,0,0,134,1235,1,0,0,0,136,1237,1,0,0,0,138,1250,1,0,0,0,140,1264,1,0,0,0,142,1286,1,0,0,0,144,1316,1,0,0,0,146,1318,1,0,0,0,148,1334,1,0,0,0,150,1347,1,0,0,0,152,1363,1,0,0,0,154,1366,1,0,0,0,156,1379,1,0,0,0,158,1395,1,0,0,0,160,1405,1,0,0,0,162,1421,1,0,0,0,164,1442,1,0,0,0,166,1453,1,0,0,0,168,1464,1,0,0,0,170,1486,1,0,0,0,172,1498,1,0,0,0,174,1503,1,0,0,0,176,1508,1,0,0,0,178,180,3,176,88,0,179,178,1,0,0,0,179,180,1,0,0,0,180,181,1,0,0,0,181,182,5,0,0,1,182,191,6,0,-1,0,183,185,3,176,88,0,184,183,1,0,0,0,184,185,1,0,0,0,185,186,1,0,0,0,186,187,3,2,1,0,187,188,5,0,0,1,188,189,6,0,-1,0,189,191,1,0,0,0,190,179,1,0,0,0,190,184,1,0,0,0,191,1,1,0,0,0,192,193,3,6,3,0,193,200,6,1,-1,0,194,195,3,176,88,0,195,196,3,6,3,0,196,197,6,1,-1,0,197,199,1,0,0,0,198,194,1,0,0,0,199,202,1,0,0,0,200,198,1,0,0,0,200,201,1,0,0,0,201,204,1,0,0,0,202,200,1,0,0,0,203,205,3,176,88,0,204,203,1,0,0,0,204,205,1,0,0,0,205,206,1,0,0,0,206,207,6,1,-1,0,207,3,1,0,0,0,208,209,3,6,3,0,209,216,6,2,-1,0,210,211,3,176,88,0,211,212,3,6,3,0,212,213,6,2,-1,0,213,215,1,0,0,0,214,210,1,0,0,0,215,218,1,0,0,0,216,214,1,0,0,0,216,217,1,0,0,0,217,220,1,0,0,0,218,216,1,0,0,0,219,221,3,176,88,0,220,219,1,0,0,0,220,221,1,0,0,0,221,222,1,0,0,0,222,223,6,2,-1,0,223,5,1,0,0,0,224,225,3,60,30,0,225,226,6,3,-1,0,226,234,1,0,0,0,227,228,3,8,4,0,228,229,6,3,-1,0,229,234,1,0,0,0,230,231,3,54,27,0,231,232,6,3,-1,0,232,234,1,0,0,0,233,224,1,0,0,0,233,227,1,0,0,0,233,230,1,0,0,0,234,7,1,0,0,0,235,236,3,12,6,0,236,237,3,10,5,0,237,243,6,4,-1,0,238,239,3,10,5,0,239,240,6,4,-1,0,240,242,1,0,0,0,241,238,1,0,0,0,242,245,1,0,0,0,243,241,1,0,0,0,243,244,1,0,0,0,244,246,1,0,0,0,245,243,1,0,0,0,246,247,6,4,-1,0,247,9,1,0,0,0,248,249,3,18,9,0,249,250,6,5,-1,0,250,11,1,0,0,0,251,252,5,101,0,0,252,262,6,6,-1,0,253,254,5,39,0,0,254,262,6,6,-1,0,255,256,5,43,0,0,256,262,6,6,-1,0,257,258,5,41,0,0,258,262,6,6,-1,0,259,260,5,37,0,0,260,262,6,6,-1,0,261,251,1,0,0,0,261,253,1,0,0,0,261,255,1,0,0,0,261,257,1,0,0,0,261,259,1,0,0,0,262,13,1,0,0,0,263,264,3,12,6,0,264,265,6,7,-1,0,265,269,1,0,0,0,266,267,5,6,0,0,267,269,6,7,-1,0,268,263,1,0,0,0,268,266,1,0,0,0,269,15,1,0,0,0,270,271,3,14,7,0,271,278,6,8,-1,0,272,273,5,57,0,0,273,274,3,14,7,0,274,275,6,8,-1,0,275,277,1,0,0,0,276,272,1,0,0,0,277,280,1,0,0,0,278,276,1,0,0,0,278,279,1,0,0,0,279,17,1,0,0,0,280,278,1,0,0,0,281,282,5,46,0,0,282,286,6,9,-1,0,283,284,5,142,0,0,284,286,6,9,-1,0,285,281,1,0,0,0,285,283,1,0,0,0,286,19,1,0,0,0,287,288,5,102,0,0,288,289,6,10,-1,0,289,21,1,0,0,0,290,291,5,7,0,0,291,292,6,11,-1,0,292,23,1,0,0,0,293,294,3,20,10,0,294,295,6,12,-1,0,295,303,1,0,0,0,296,297,3,18,9,0,297,298,6,12,-1,0,298,303,1,0,0,0,299,300,3,22,11,0,300,301,6,12,-1,0,301,303,1,0,0,0,302,293,1,0,0,0,302,296,1,0,0,0,302,299,1,0,0,0,303,25,1,0,0,0,304,305,5,64,0,0,305,306,5,65,0,0,306,367,6,13,-1,0,307,312,5,64,0,0,308,311,5,55,0,0,309,311,3,174,87,0,310,308,1,0,0,0,310,309,1,0,0,0,311,314,1,0,0,0,312,310,1,0,0,0,312,313,1,0,0,0,313,316,1,0,0,0,314,312,1,0,0,0,315,317,3,28,14,0,316,315,1,0,0,0,316,317,1,0,0,0,317,318,1,0,0,0,318,331,6,13,-1,0,319,322,5,55,0,0,320,322,3,174,87,0,321,319,1,0,0,0,321,320,1,0,0,0,322,323,1,0,0,0,323,321,1,0,0,0,323,324,1,0,0,0,324,326,1,0,0,0,325,327,3,28,14,0,326,325,1,0,0,0,326,327,1,0,0,0,327,328,1,0,0,0,328,330,6,13,-1,0,329,321,1,0,0,0,330,333,1,0,0,0,331,329,1,0,0,0,331,332,1,0,0,0,332,334,1,0,0,0,333,331,1,0,0,0,334,367,5,65,0,0,335,336,5,66,0,0,336,337,5,67,0,0,337,367,6,13,-1,0,338,343,5,66,0,0,339,342,5,55,0,0,340,342,3,174,87,0,341,339,1,0,0,0,341,340,1,0,0,0,342,345,1,0,0,0,343,341,1,0,0,0,343,344,1,0,0,0,344,347,1,0,0,0,345,343,1,0,0,0,346,348,3,28,14,0,347,346,1,0,0,0,347,348,1,0,0,0,348,349,1,0,0,0,349,362,6,13,-1,0,350,353,5,55,0,0,351,353,3,174,87,0,352,350,1,0,0,0,352,351,1,0,0,0,353,354,1,0,0,0,354,352,1,0,0,0,354,355,1,0,0,0,355,357,1,0,0,0,356,358,3,28,14,0,357,356,1,0,0,0,357,358,1,0,0,0,358,359,1,0,0,0,359,361,6,13,-1,0,360,352,1,0,0,0,361,364,1,0,0,0,362,360,1,0,0,0,362,363,1,0,0,0,363,365,1,0,0,0,364,362,1,0,0,0,365,367,5,67,0,0,366,304,1,0,0,0,366,307,1,0,0,0,366,335,1,0,0,0,366,338,1,0,0,0,367,27,1,0,0,0,368,369,7,0,0,0,369,388,6,14,-1,0,370,372,7,0,0,0,371,370,1,0,0,0,371,372,1,0,0,0,372,373,1,0,0,0,373,374,3,42,21,0,374,381,6,14,-1,0,375,376,7,0,0,0,376,377,3,42,21,0,377,378,6,14,-1,0,378,380,1,0,0,0,379,375,1,0,0,0,380,383,1,0,0,0,381,379,1,0,0,0,381,382,1,0,0,0,382,385,1,0,0,0,383,381,1,0,0,0,384,386,7,0,0,0,385,384,1,0,0,0,385,386,1,0,0,0,386,388,1,0,0,0,387,368,1,0,0,0,387,371,1,0,0,0,388,29,1,0,0,0,389,390,5,60,0,0,390,391,3,16,8,0,391,392,6,15,-1,0,392,31,1,0,0,0,393,394,5,61,0,0,394,395,3,16,8,0,395,396,6,16,-1,0,396,33,1,0,0,0,397,398,5,60,0,0,398,399,3,110,55,0,399,400,3,54,27,0,400,401,6,17,-1,0,401,35,1,0,0,0,402,403,3,12,6,0,403,404,6,18,-1,0,404,425,1,0,0,0,405,406,5,3,0,0,406,425,6,18,-1,0,407,408,3,24,12,0,408,409,6,18,-1,0,409,425,1,0,0,0,410,411,3,30,15,0,411,412,6,18,-1,0,412,425,1,0,0,0,413,414,3,32,16,0,414,415,6,18,-1,0,415,425,1,0,0,0,416,417,3,26,13,0,417,418,6,18,-1,0,418,425,1,0,0,0,419,420,5,62,0,0,420,421,3,54,27,0,421,422,5,63,0,0,422,423,6,18,-1,0,423,425,1,0,0,0,424,402,1,0,0,0,424,405,1,0,0,0,424,407,1,0,0,0,424,410,1,0,0,0,424,413,1,0,0,0,424,416,1,0,0,0,424,419,1,0,0,0,425,37,1,0,0,0,426,427,5,54,0,0,427,428,6,19,-1,0,428,39,1,0,0,0,429,430,5,58,0,0,430,431,6,20,-1,0,431,41,1,0,0,0,432,433,3,54,27,0,433,434,6,21,-1,0,434,442,1,0,0,0,435,436,3,38,19,0,436,437,6,21,-1,0,437,442,1,0,0,0,438,439,3,40,20,0,439,440,6,21,-1,0,440,442,1,0,0,0,441,432,1,0,0,0,441,435,1,0,0,0,441,438,1,0,0,0,442,43,1,0,0,0,443,444,3,42,21,0,444,451,6,22,-1,0,445,446,5,56,0,0,446,447,3,42,21,0,447,448,6,22,-1,0,448,450,1,0,0,0,449,445,1,0,0,0,450,453,1,0,0,0,451,449,1,0,0,0,451,452,1,0,0,0,452,45,1,0,0,0,453,451,1,0,0,0,454,455,6,23,-1,0,455,456,3,36,18,0,456,457,6,23,-1,0,457,467,1,0,0,0,458,459,7,1,0,0,459,460,3,46,23,4,460,461,6,23,-1,0,461,467,1,0,0,0,462,463,7,2,0,0,463,464,3,46,23,3,464,465,6,23,-1,0,465,467,1,0,0,0,466,454,1,0,0,0,466,458,1,0,0,0,466,462,1,0,0,0,467,527,1,0,0,0,468,469,10,2,0,0,469,470,7,3,0,0,470,471,3,46,23,3,471,472,6,23,-1,0,472,526,1,0,0,0,473,474,10,1,0,0,474,475,7,4,0,0,475,476,3,46,23,2,476,477,6,23,-1,0,477,526,1,0,0,0,478,479,10,12,0,0,479,480,7,5,0,0,480,526,6,23,-1,0,481,482,10,11,0,0,482,484,5,62,0,0,483,485,3,44,22,0,484,483,1,0,0,0,484,485,1,0,0,0,485,486,1,0,0,0,486,487,5,63,0,0,487,526,6,23,-1,0,488,489,10,10,0,0,489,491,5,66,0,0,490,492,3,44,22,0,491,490,1,0,0,0,491,492,1,0,0,0,492,493,1,0,0,0,493,494,5,67,0,0,494,526,6,23,-1,0,495,496,10,9,0,0,496,497,5,60,0,0,497,498,3,16,8,0,498,500,5,62,0,0,499,501,3,44,22,0,500,499,1,0,0,0,500,501,1,0,0,0,501,502,1,0,0,0,502,503,5,63,0,0,503,504,6,23,-1,0,504,526,1,0,0,0,505,506,10,8,0,0,506,507,7,6,0,0,507,526,6,23,-1,0,508,509,10,7,0,0,509,510,5,57,0,0,510,511,3,14,7,0,511,512,6,23,-1,0,512,526,1,0,0,0,513,514,10,6,0,0,514,515,5,57,0,0,515,516,5,62,0,0,516,517,3,54,27,0,517,518,5,63,0,0,518,519,6,23,-1,0,519,526,1,0,0,0,520,521,10,5,0,0,521,522,7,7,0,0,522,523,3,48,24,0,523,524,6,23,-1,0,524,526,1,0,0,0,525,468,1,0,0,0,525,473,1,0,0,0,525,478,1,0,0,0,525,481,1,0,0,0,525,488,1,0,0,0,525,495,1,0,0,0,525,505,1,0,0,0,525,508,1,0,0,0,525,513,1,0,0,0,525,520,1,0,0,0,526,529,1,0,0,0,527,525,1,0,0,0,527,528,1,0,0,0,528,47,1,0,0,0,529,527,1,0,0,0,530,531,6,24,-1,0,531,532,3,36,18,0,532,533,6,24,-1,0,533,543,1,0,0,0,534,535,7,1,0,0,535,536,3,48,24,2,536,537,6,24,-1,0,537,543,1,0,0,0,538,539,7,2,0,0,539,540,3,48,24,1,540,541,6,24,-1,0,541,543,1,0,0,0,542,530,1,0,0,0,542,534,1,0,0,0,542,538,1,0,0,0,543,585,1,0,0,0,544,545,10,8,0,0,545,546,7,5,0,0,546,584,6,24,-1,0,547,548,10,7,0,0,548,550,5,62,0,0,549,551,3,44,22,0,550,549,1,0,0,0,550,551,1,0,0,0,551,552,1,0,0,0,552,553,5,63,0,0,553,584,6,24,-1,0,554,555,10,6,0,0,555,557,5,66,0,0,556,558,3,44,22,0,557,556,1,0,0,0,557,558,1,0,0,0,558,559,1,0,0,0,559,560,5,67,0,0,560,584,6,24,-1,0,561,562,10,5,0,0,562,563,5,60,0,0,563,564,3,16,8,0,564,566,5,62,0,0,565,567,3,44,22,0,566,565,1,0,0,0,566,567,1,0,0,0,567,568,1,0,0,0,568,569,5,63,0,0,569,570,6,24,-1,0,570,584,1,0,0,0,571,572,10,4,0,0,572,573,5,57,0,0,573,574,3,14,7,0,574,575,6,24,-1,0,575,584,1,0,0,0,576,577,10,3,0,0,577,578,5,57,0,0,578,579,5,62,0,0,579,580,3,54,27,0,580,581,5,63,0,0,581,582,6,24,-1,0,582,584,1,0,0,0,583,544,1,0,0,0,583,547,1,0,0,0,583,554,1,0,0,0,583,561,1,0,0,0,583,571,1,0,0,0,583,576,1,0,0,0,584,587,1,0,0,0,585,583,1,0,0,0,585,586,1,0,0,0,586,49,1,0,0,0,587,585,1,0,0,0,588,589,3,46,23,0,589,590,5,54,0,0,590,593,3,46,23,0,591,592,5,54,0,0,592,594,3,46,23,0,593,591,1,0,0,0,593,594,1,0,0,0,594,595,1,0,0,0,595,596,6,25,-1,0,596,51,1,0,0,0,597,598,6,26,-1,0,598,599,3,46,23,0,599,600,6,26,-1,0,600,605,1,0,0,0,601,602,3,50,25,0,602,603,6,26,-1,0,603,605,1,0,0,0,604,597,1,0,0,0,604,601,1,0,0,0,605,633,1,0,0,0,606,607,10,5,0,0,607,608,7,8,0,0,608,609,3,52,26,6,609,610,6,26,-1,0,610,632,1,0,0,0,611,612,10,4,0,0,612,613,5,83,0,0,613,614,3,52,26,5,614,615,6,26,-1,0,615,632,1,0,0,0,616,617,10,3,0,0,617,618,5,84,0,0,618,619,3,52,26,4,619,620,6,26,-1,0,620,632,1,0,0,0,621,622,10,2,0,0,622,623,5,81,0,0,623,624,3,52,26,3,624,625,6,26,-1,0,625,632,1,0,0,0,626,627,10,1,0,0,627,628,5,82,0,0,628,629,3,52,26,2,629,630,6,26,-1,0,630,632,1,0,0,0,631,606,1,0,0,0,631,611,1,0,0,0,631,616,1,0,0,0,631,621,1,0,0,0,631,626,1,0,0,0,632,635,1,0,0,0,633,631,1,0,0,0,633,634,1,0,0,0,634,53,1,0,0,0,635,633,1,0,0,0,636,637,3,52,26,0,637,638,6,27,-1,0,638,648,1,0,0,0,639,640,3,52,26,0,640,641,7,9,0,0,641,642,3,54,27,0,642,643,6,27,-1,0,643,648,1,0,0,0,644,645,3,34,17,0,645,646,6,27,-1,0,646,648,1,0,0,0,647,636,1,0,0,0,647,639,1,0,0,0,647,644,1,0,0,0,648,55,1,0,0,0,649,650,3,52,26,0,650,651,6,28,-1,0,651,659,1,0,0,0,652,654,5,64,0,0,653,655,3,58,29,0,654,653,1,0,0,0,654,655,1,0,0,0,655,656,1,0,0,0,656,657,5,65,0,0,657,659,6,28,-1,0,658,649,1,0,0,0,658,652,1,0,0,0,659,57,1,0,0,0,660,661,3,42,21,0,661,668,6,29,-1,0,662,663,7,0,0,0,663,664,3,42,21,0,664,665,6,29,-1,0,665,667,1,0,0,0,666,662,1,0,0,0,667,670,1,0,0,0,668,666,1,0,0,0,668,669,1,0,0,0,669,672,1,0,0,0,670,668,1,0,0,0,671,673,7,0,0,0,672,671,1,0,0,0,672,673,1,0,0,0,673,59,1,0,0,0,674,675,3,62,31,0,675,676,6,30,-1,0,676,699,1,0,0,0,677,678,3,66,33,0,678,679,6,30,-1,0,679,699,1,0,0,0,680,681,3,70,35,0,681,682,6,30,-1,0,682,699,1,0,0,0,683,684,3,86,43,0,684,685,6,30,-1,0,685,699,1,0,0,0,686,687,3,98,49,0,687,688,6,30,-1,0,688,699,1,0,0,0,689,690,3,100,50,0,690,691,6,30,-1,0,691,699,1,0,0,0,692,693,3,118,59,0,693,694,6,30,-1,0,694,699,1,0,0,0,695,696,3,122,61,0,696,697,6,30,-1,0,697,699,1,0,0,0,698,674,1,0,0,0,698,677,1,0,0,0,698,680,1,0,0,0,698,683,1,0,0,0,698,686,1,0,0,0,698,689,1,0,0,0,698,692,1,0,0,0,698,695,1,0,0,0,699,61,1,0,0,0,700,701,5,1,0,0,701,705,6,31,-1,0,702,703,5,2,0,0,703,705,6,31,-1,0,704,700,1,0,0,0,704,702,1,0,0,0,705,706,1,0,0,0,706,707,3,64,32,0,707,716,6,31,-1,0,708,710,5,56,0,0,709,708,1,0,0,0,709,710,1,0,0,0,710,711,1,0,0,0,711,712,3,64,32,0,712,713,6,31,-1,0,713,715,1,0,0,0,714,709,1,0,0,0,715,718,1,0,0,0,716,714,1,0,0,0,716,717,1,0,0,0,717,63,1,0,0,0,718,716,1,0,0,0,719,720,3,12,6,0,720,721,6,32,-1,0,721,728,1,0,0,0,722,723,3,12,6,0,723,724,5,53,0,0,724,725,3,54,27,0,725,726,6,32,-1,0,726,728,1,0,0,0,727,719,1,0,0,0,727,722,1,0,0,0,728,65,1,0,0,0,729,730,5,3,0,0,730,744,6,33,-1,0,731,732,3,68,34,0,732,741,6,33,-1,0,733,735,5,56,0,0,734,733,1,0,0,0,734,735,1,0,0,0,735,736,1,0,0,0,736,737,3,68,34,0,737,738,6,33,-1,0,738,740,1,0,0,0,739,734,1,0,0,0,740,743,1,0,0,0,741,739,1,0,0,0,741,742,1,0,0,0,742,745,1,0,0,0,743,741,1,0,0,0,744,731,1,0,0,0,744,745,1,0,0,0,745,67,1,0,0,0,746,747,3,16,8,0,747,748,6,34,-1,0,748,758,1,0,0,0,749,753,3,16,8,0,750,751,5,57,0,0,751,754,5,51,0,0,752,754,5,91,0,0,753,750,1,0,0,0,753,752,1,0,0,0,754,755,1,0,0,0,755,756,6,34,-1,0,756,758,1,0,0,0,757,746,1,0,0,0,757,749,1,0,0,0,758,69,1,0,0,0,759,760,3,72,36,0,760,761,6,35,-1,0,761,766,1,0,0,0,762,763,3,78,39,0,763,764,6,35,-1,0,764,766,1,0,0,0,765,759,1,0,0,0,765,762,1,0,0,0,766,71,1,0,0,0,767,768,5,4,0,0,768,770,3,54,27,0,769,771,3,176,88,0,770,769,1,0,0,0,770,771,1,0,0,0,771,773,1,0,0,0,772,774,3,4,2,0,773,772,1,0,0,0,773,774,1,0,0,0,774,775,1,0,0,0,775,781,6,36,-1,0,776,777,3,74,37,0,777,778,6,36,-1,0,778,780,1,0,0,0,779,776,1,0,0,0,780,783,1,0,0,0,781,779,1,0,0,0,781,782,1,0,0,0,782,785,1,0,0,0,783,781,1,0,0,0,784,786,3,76,38,0,785,784,1,0,0,0,785,786,1,0,0,0,786,787,1,0,0,0,787,788,6,36,-1,0,788,789,7,10,0,0,789,73,1,0,0,0,790,792,5,8,0,0,791,793,3,176,88,0,792,791,1,0,0,0,792,793,1,0,0,0,793,794,1,0,0,0,794,796,3,54,27,0,795,797,3,176,88,0,796,795,1,0,0,0,796,797,1,0,0,0,797,799,1,0,0,0,798,800,3,4,2,0,799,798,1,0,0,0,799,800,1,0,0,0,800,801,1,0,0,0,801,802,6,37,-1,0,802,75,1,0,0,0,803,805,5,9,0,0,804,806,3,176,88,0,805,804,1,0,0,0,805,806,1,0,0,0,806,808,1,0,0,0,807,809,3,4,2,0,808,807,1,0,0,0,808,809,1,0,0,0,809,810,1,0,0,0,810,811,6,38,-1,0,811,77,1,0,0,0,812,813,5,10,0,0,813,815,3,54,27,0,814,816,3,176,88,0,815,814,1,0,0,0,815,816,1,0,0,0,816,818,1,0,0,0,817,819,3,80,40,0,818,817,1,0,0,0,818,819,1,0,0,0,819,821,1,0,0,0,820,822,3,84,42,0,821,820,1,0,0,0,821,822,1,0,0,0,822,823,1,0,0,0,823,824,7,11,0,0,824,825,6,39,-1,0,825,79,1,0,0,0,826,827,3,82,41,0,827,836,6,40,-1,0,828,830,3,176,88,0,829,828,1,0,0,0,829,830,1,0,0,0,830,831,1,0,0,0,831,832,3,82,41,0,832,833,6,40,-1,0,833,835,1,0,0,0,834,829,1,0,0,0,835,838,1,0,0,0,836,834,1,0,0,0,836,837,1,0,0,0,837,840,1,0,0,0,838,836,1,0,0,0,839,841,3,176,88,0,840,839,1,0,0,0,840,841,1,0,0,0,841,81,1,0,0,0,842,844,5,12,0,0,843,845,3,176,88,0,844,843,1,0,0,0,844,845,1,0,0,0,845,846,1,0,0,0,846,848,3,54,27,0,847,849,3,176,88,0,848,847,1,0,0,0,848,849,1,0,0,0,849,851,1,0,0,0,850,852,3,4,2,0,851,850,1,0,0,0,851,852,1,0,0,0,852,853,1,0,0,0,853,854,6,41,-1,0,854,83,1,0,0,0,855,857,5,13,0,0,856,858,3,176,88,0,857,856,1,0,0,0,857,858,1,0,0,0,858,860,1,0,0,0,859,861,3,4,2,0,860,859,1,0,0,0,860,861,1,0,0,0,861,863,1,0,0,0,862,864,3,176,88,0,863,862,1,0,0,0,863,864,1,0,0,0,864,865,1,0,0,0,865,866,6,42,-1,0,866,85,1,0,0,0,867,868,3,88,44,0,868,869,6,43,-1,0,869,880,1,0,0,0,870,871,3,90,45,0,871,872,6,43,-1,0,872,880,1,0,0,0,873,874,3,92,46,0,874,875,6,43,-1,0,875,880,1,0,0,0,876,877,3,94,47,0,877,878,6,43,-1,0,878,880,1,0,0,0,879,867,1,0,0,0,879,870,1,0,0,0,879,873,1,0,0,0,879,876,1,0,0,0,880,87,1,0,0,0,881,882,5,14,0,0,882,884,3,54,27,0,883,885,3,176,88,0,884,883,1,0,0,0,884,885,1,0,0,0,885,887,1,0,0,0,886,888,3,4,2,0,887,886,1,0,0,0,887,888,1,0,0,0,888,889,1,0,0,0,889,890,7,12,0,0,890,891,6,44,-1,0,891,89,1,0,0,0,892,894,5,16,0,0,893,895,3,176,88,0,894,893,1,0,0,0,894,895,1,0,0,0,895,897,1,0,0,0,896,898,3,4,2,0,897,896,1,0,0,0,897,898,1,0,0,0,898,899,1,0,0,0,899,900,5,17,0,0,900,901,3,54,27,0,901,902,6,45,-1,0,902,91,1,0,0,0,903,904,5,18,0,0,904,905,3,56,28,0,905,906,5,53,0,0,906,908,3,54,27,0,907,909,3,176,88,0,908,907,1,0,0,0,908,909,1,0,0,0,909,911,1,0,0,0,910,912,3,4,2,0,911,910,1,0,0,0,911,912,1,0,0,0,912,913,1,0,0,0,913,914,7,13,0,0,914,915,6,46,-1,0,915,964,1,0,0,0,916,917,5,18,0,0,917,918,5,62,0,0,918,919,3,56,28,0,919,920,5,53,0,0,920,921,3,54,27,0,921,923,5,63,0,0,922,924,3,176,88,0,923,922,1,0,0,0,923,924,1,0,0,0,924,926,1,0,0,0,925,927,3,4,2,0,926,925,1,0,0,0,926,927,1,0,0,0,927,928,1,0,0,0,928,929,7,13,0,0,929,930,6,46,-1,0,930,964,1,0,0,0,931,932,5,20,0,0,932,933,3,56,28,0,933,934,5,53,0,0,934,936,3,54,27,0,935,937,3,176,88,0,936,935,1,0,0,0,936,937,1,0,0,0,937,939,1,0,0,0,938,940,3,4,2,0,939,938,1,0,0,0,939,940,1,0,0,0,940,941,1,0,0,0,941,942,7,14,0,0,942,943,6,46,-1,0,943,964,1,0,0,0,944,945,5,20,0,0,945,946,5,62,0,0,946,947,3,56,28,0,947,948,5,53,0,0,948,951,3,54,27,0,949,950,5,56,0,0,950,952,3,54,27,0,951,949,1,0,0,0,951,952,1,0,0,0,952,953,1,0,0,0,953,955,5,63,0,0,954,956,3,176,88,0,955,954,1,0,0,0,955,956,1,0,0,0,956,958,1,0,0,0,957,959,3,4,2,0,958,957,1,0,0,0,958,959,1,0,0,0,959,960,1,0,0,0,960,961,7,14,0,0,961,962,6,46,-1,0,962,964,1,0,0,0,963,903,1,0,0,0,963,916,1,0,0,0,963,931,1,0,0,0,963,944,1,0,0,0,964,93,1,0,0,0,965,967,5,22,0,0,966,968,3,96,48,0,967,966,1,0,0,0,967,968,1,0,0,0,968,970,1,0,0,0,969,971,3,176,88,0,970,969,1,0,0,0,970,971,1,0,0,0,971,973,1,0,0,0,972,974,3,4,2,0,973,972,1,0,0,0,973,974,1,0,0,0,974,975,1,0,0,0,975,976,7,15,0,0,976,977,6,47,-1,0,977,95,1,0,0,0,978,979,5,62,0,0,979,980,3,54,27,0,980,985,6,48,-1,0,981,982,5,56,0,0,982,983,3,54,27,0,983,984,6,48,-1,0,984,986,1,0,0,0,985,981,1,0,0,0,985,986,1,0,0,0,986,987,1,0,0,0,987,988,5,63,0,0,988,97,1,0,0,0,989,990,5,24,0,0,990,996,6,49,-1,0,991,992,5,25,0,0,992,996,6,49,-1,0,993,994,5,26,0,0,994,996,6,49,-1,0,995,989,1,0,0,0,995,991,1,0,0,0,995,993,1,0,0,0,996,99,1,0,0,0,997,998,3,102,51,0,998,999,6,50,-1,0,999,1004,1,0,0,0,1e3,1001,3,106,53,0,1001,1002,6,50,-1,0,1002,1004,1,0,0,0,1003,997,1,0,0,0,1003,1e3,1,0,0,0,1004,101,1,0,0,0,1005,1007,5,29,0,0,1006,1008,3,176,88,0,1007,1006,1,0,0,0,1007,1008,1,0,0,0,1008,1010,1,0,0,0,1009,1011,3,4,2,0,1010,1009,1,0,0,0,1010,1011,1,0,0,0,1011,1012,1,0,0,0,1012,1013,3,104,52,0,1013,1014,7,16,0,0,1014,1015,6,51,-1,0,1015,1026,1,0,0,0,1016,1018,5,29,0,0,1017,1019,3,176,88,0,1018,1017,1,0,0,0,1018,1019,1,0,0,0,1019,1021,1,0,0,0,1020,1022,3,4,2,0,1021,1020,1,0,0,0,1021,1022,1,0,0,0,1022,1023,1,0,0,0,1023,1024,7,16,0,0,1024,1026,6,51,-1,0,1025,1005,1,0,0,0,1025,1016,1,0,0,0,1026,103,1,0,0,0,1027,1029,5,30,0,0,1028,1030,3,176,88,0,1029,1028,1,0,0,0,1029,1030,1,0,0,0,1030,1032,1,0,0,0,1031,1033,3,4,2,0,1032,1031,1,0,0,0,1032,1033,1,0,0,0,1033,1034,1,0,0,0,1034,1035,6,52,-1,0,1035,105,1,0,0,0,1036,1038,5,32,0,0,1037,1039,3,176,88,0,1038,1037,1,0,0,0,1038,1039,1,0,0,0,1039,1041,1,0,0,0,1040,1042,3,4,2,0,1041,1040,1,0,0,0,1041,1042,1,0,0,0,1042,1043,1,0,0,0,1043,1044,3,108,54,0,1044,1045,7,17,0,0,1045,1046,6,53,-1,0,1046,107,1,0,0,0,1047,1049,5,33,0,0,1048,1050,3,176,88,0,1049,1048,1,0,0,0,1049,1050,1,0,0,0,1050,1052,1,0,0,0,1051,1053,3,4,2,0,1052,1051,1,0,0,0,1052,1053,1,0,0,0,1053,1054,1,0,0,0,1054,1055,6,54,-1,0,1055,109,1,0,0,0,1056,1057,5,62,0,0,1057,1069,6,55,-1,0,1058,1059,3,112,56,0,1059,1066,6,55,-1,0,1060,1061,5,56,0,0,1061,1062,3,112,56,0,1062,1063,6,55,-1,0,1063,1065,1,0,0,0,1064,1060,1,0,0,0,1065,1068,1,0,0,0,1066,1064,1,0,0,0,1066,1067,1,0,0,0,1067,1070,1,0,0,0,1068,1066,1,0,0,0,1069,1058,1,0,0,0,1069,1070,1,0,0,0,1070,1071,1,0,0,0,1071,1072,5,63,0,0,1072,111,1,0,0,0,1073,1074,3,64,32,0,1074,1075,6,56,-1,0,1075,1080,1,0,0,0,1076,1077,3,40,20,0,1077,1078,6,56,-1,0,1078,1080,1,0,0,0,1079,1073,1,0,0,0,1079,1076,1,0,0,0,1080,113,1,0,0,0,1081,1082,3,12,6,0,1082,1083,6,57,-1,0,1083,1088,1,0,0,0,1084,1085,3,40,20,0,1085,1086,6,57,-1,0,1086,1088,1,0,0,0,1087,1081,1,0,0,0,1087,1084,1,0,0,0,1088,115,1,0,0,0,1089,1090,3,114,57,0,1090,1091,6,58,-1,0,1091,1109,1,0,0,0,1092,1093,5,64,0,0,1093,1105,6,58,-1,0,1094,1095,3,114,57,0,1095,1102,6,58,-1,0,1096,1097,7,0,0,0,1097,1098,3,114,57,0,1098,1099,6,58,-1,0,1099,1101,1,0,0,0,1100,1096,1,0,0,0,1101,1104,1,0,0,0,1102,1100,1,0,0,0,1102,1103,1,0,0,0,1103,1106,1,0,0,0,1104,1102,1,0,0,0,1105,1094,1,0,0,0,1105,1106,1,0,0,0,1106,1107,1,0,0,0,1107,1109,5,65,0,0,1108,1089,1,0,0,0,1108,1092,1,0,0,0,1109,117,1,0,0,0,1110,1114,5,27,0,0,1111,1112,3,116,58,0,1112,1113,5,53,0,0,1113,1115,1,0,0,0,1114,1111,1,0,0,0,1114,1115,1,0,0,0,1115,1116,1,0,0,0,1116,1118,3,120,60,0,1117,1119,3,110,55,0,1118,1117,1,0,0,0,1118,1119,1,0,0,0,1119,1121,1,0,0,0,1120,1122,3,176,88,0,1121,1120,1,0,0,0,1121,1122,1,0,0,0,1122,1124,1,0,0,0,1123,1125,3,160,80,0,1124,1123,1,0,0,0,1124,1125,1,0,0,0,1125,1127,1,0,0,0,1126,1128,3,4,2,0,1127,1126,1,0,0,0,1127,1128,1,0,0,0,1128,1129,1,0,0,0,1129,1130,7,18,0,0,1130,1131,6,59,-1,0,1131,119,1,0,0,0,1132,1133,3,16,8,0,1133,1134,6,60,-1,0,1134,121,1,0,0,0,1135,1137,5,35,0,0,1136,1138,3,124,62,0,1137,1136,1,0,0,0,1137,1138,1,0,0,0,1138,1139,1,0,0,0,1139,1141,3,16,8,0,1140,1142,3,130,65,0,1141,1140,1,0,0,0,1141,1142,1,0,0,0,1142,1144,1,0,0,0,1143,1145,3,176,88,0,1144,1143,1,0,0,0,1144,1145,1,0,0,0,1145,1147,1,0,0,0,1146,1148,3,132,66,0,1147,1146,1,0,0,0,1147,1148,1,0,0,0,1148,1149,1,0,0,0,1149,1150,7,19,0,0,1150,1151,6,61,-1,0,1151,123,1,0,0,0,1152,1153,5,62,0,0,1153,1165,6,62,-1,0,1154,1155,3,126,63,0,1155,1162,6,62,-1,0,1156,1157,5,56,0,0,1157,1158,3,126,63,0,1158,1159,6,62,-1,0,1159,1161,1,0,0,0,1160,1156,1,0,0,0,1161,1164,1,0,0,0,1162,1160,1,0,0,0,1162,1163,1,0,0,0,1163,1166,1,0,0,0,1164,1162,1,0,0,0,1165,1154,1,0,0,0,1165,1166,1,0,0,0,1166,1167,1,0,0,0,1167,1169,5,63,0,0,1168,1170,3,176,88,0,1169,1168,1,0,0,0,1169,1170,1,0,0,0,1170,125,1,0,0,0,1171,1174,3,12,6,0,1172,1173,5,53,0,0,1173,1175,3,54,27,0,1174,1172,1,0,0,0,1174,1175,1,0,0,0,1175,1176,1,0,0,0,1176,1177,6,63,-1,0,1177,1183,1,0,0,0,1178,1179,7,2,0,0,1179,1180,3,12,6,0,1180,1181,6,63,-1,0,1181,1183,1,0,0,0,1182,1171,1,0,0,0,1182,1178,1,0,0,0,1183,127,1,0,0,0,1184,1185,3,12,6,0,1185,1192,6,64,-1,0,1186,1187,5,57,0,0,1187,1188,3,12,6,0,1188,1189,6,64,-1,0,1189,1191,1,0,0,0,1190,1186,1,0,0,0,1191,1194,1,0,0,0,1192,1190,1,0,0,0,1192,1193,1,0,0,0,1193,129,1,0,0,0,1194,1192,1,0,0,0,1195,1196,5,85,0,0,1196,1197,3,16,8,0,1197,1204,6,65,-1,0,1198,1199,7,20,0,0,1199,1200,3,16,8,0,1200,1201,6,65,-1,0,1201,1203,1,0,0,0,1202,1198,1,0,0,0,1203,1206,1,0,0,0,1204,1202,1,0,0,0,1204,1205,1,0,0,0,1205,131,1,0,0,0,1206,1204,1,0,0,0,1207,1208,3,134,67,0,1208,1217,6,66,-1,0,1209,1211,3,176,88,0,1210,1209,1,0,0,0,1210,1211,1,0,0,0,1211,1212,1,0,0,0,1212,1213,3,134,67,0,1213,1214,6,66,-1,0,1214,1216,1,0,0,0,1215,1210,1,0,0,0,1216,1219,1,0,0,0,1217,1215,1,0,0,0,1217,1218,1,0,0,0,1218,1221,1,0,0,0,1219,1217,1,0,0,0,1220,1222,3,176,88,0,1221,1220,1,0,0,0,1221,1222,1,0,0,0,1222,133,1,0,0,0,1223,1224,3,136,68,0,1224,1225,6,67,-1,0,1225,1236,1,0,0,0,1226,1227,3,142,71,0,1227,1228,6,67,-1,0,1228,1236,1,0,0,0,1229,1230,3,148,74,0,1230,1231,6,67,-1,0,1231,1236,1,0,0,0,1232,1233,3,154,77,0,1233,1234,6,67,-1,0,1234,1236,1,0,0,0,1235,1223,1,0,0,0,1235,1226,1,0,0,0,1235,1229,1,0,0,0,1235,1232,1,0,0,0,1236,135,1,0,0,0,1237,1239,5,39,0,0,1238,1240,3,124,62,0,1239,1238,1,0,0,0,1239,1240,1,0,0,0,1240,1242,1,0,0,0,1241,1243,3,176,88,0,1242,1241,1,0,0,0,1242,1243,1,0,0,0,1243,1245,1,0,0,0,1244,1246,3,138,69,0,1245,1244,1,0,0,0,1245,1246,1,0,0,0,1246,1247,1,0,0,0,1247,1248,7,21,0,0,1248,1249,6,68,-1,0,1249,137,1,0,0,0,1250,1251,3,140,70,0,1251,1258,6,69,-1,0,1252,1253,3,176,88,0,1253,1254,3,140,70,0,1254,1255,6,69,-1,0,1255,1257,1,0,0,0,1256,1252,1,0,0,0,1257,1260,1,0,0,0,1258,1256,1,0,0,0,1258,1259,1,0,0,0,1259,1262,1,0,0,0,1260,1258,1,0,0,0,1261,1263,3,176,88,0,1262,1261,1,0,0,0,1262,1263,1,0,0,0,1263,139,1,0,0,0,1264,1269,3,12,6,0,1265,1266,5,62,0,0,1266,1267,3,44,22,0,1267,1268,5,63,0,0,1268,1270,1,0,0,0,1269,1265,1,0,0,0,1269,1270,1,0,0,0,1270,1272,1,0,0,0,1271,1273,3,16,8,0,1272,1271,1,0,0,0,1272,1273,1,0,0,0,1273,1278,1,0,0,0,1274,1275,5,66,0,0,1275,1276,3,44,22,0,1276,1277,5,67,0,0,1277,1279,1,0,0,0,1278,1274,1,0,0,0,1278,1279,1,0,0,0,1279,1282,1,0,0,0,1280,1281,5,53,0,0,1281,1283,3,54,27,0,1282,1280,1,0,0,0,1282,1283,1,0,0,0,1283,1284,1,0,0,0,1284,1285,6,70,-1,0,1285,141,1,0,0,0,1286,1288,5,43,0,0,1287,1289,3,124,62,0,1288,1287,1,0,0,0,1288,1289,1,0,0,0,1289,1291,1,0,0,0,1290,1292,3,176,88,0,1291,1290,1,0,0,0,1291,1292,1,0,0,0,1292,1294,1,0,0,0,1293,1295,3,146,73,0,1294,1293,1,0,0,0,1294,1295,1,0,0,0,1295,1296,1,0,0,0,1296,1297,7,22,0,0,1297,1298,6,71,-1,0,1298,143,1,0,0,0,1299,1300,3,118,59,0,1300,1301,6,72,-1,0,1301,1317,1,0,0,0,1302,1304,3,128,64,0,1303,1305,3,110,55,0,1304,1303,1,0,0,0,1304,1305,1,0,0,0,1305,1306,1,0,0,0,1306,1307,6,72,-1,0,1307,1317,1,0,0,0,1308,1309,3,116,58,0,1309,1310,5,53,0,0,1310,1312,3,128,64,0,1311,1313,3,110,55,0,1312,1311,1,0,0,0,1312,1313,1,0,0,0,1313,1314,1,0,0,0,1314,1315,6,72,-1,0,1315,1317,1,0,0,0,1316,1299,1,0,0,0,1316,1302,1,0,0,0,1316,1308,1,0,0,0,1317,145,1,0,0,0,1318,1319,3,144,72,0,1319,1328,6,73,-1,0,1320,1322,3,176,88,0,1321,1320,1,0,0,0,1321,1322,1,0,0,0,1322,1323,1,0,0,0,1323,1324,3,144,72,0,1324,1325,6,73,-1,0,1325,1327,1,0,0,0,1326,1321,1,0,0,0,1327,1330,1,0,0,0,1328,1326,1,0,0,0,1328,1329,1,0,0,0,1329,1332,1,0,0,0,1330,1328,1,0,0,0,1331,1333,3,176,88,0,1332,1331,1,0,0,0,1332,1333,1,0,0,0,1333,147,1,0,0,0,1334,1336,5,41,0,0,1335,1337,3,124,62,0,1336,1335,1,0,0,0,1336,1337,1,0,0,0,1337,1339,1,0,0,0,1338,1340,3,176,88,0,1339,1338,1,0,0,0,1339,1340,1,0,0,0,1340,1342,1,0,0,0,1341,1343,3,150,75,0,1342,1341,1,0,0,0,1342,1343,1,0,0,0,1343,1344,1,0,0,0,1344,1345,7,23,0,0,1345,1346,6,74,-1,0,1346,149,1,0,0,0,1347,1348,3,152,76,0,1348,1357,6,75,-1,0,1349,1351,3,176,88,0,1350,1349,1,0,0,0,1350,1351,1,0,0,0,1351,1352,1,0,0,0,1352,1353,3,152,76,0,1353,1354,6,75,-1,0,1354,1356,1,0,0,0,1355,1350,1,0,0,0,1356,1359,1,0,0,0,1357,1355,1,0,0,0,1357,1358,1,0,0,0,1358,1361,1,0,0,0,1359,1357,1,0,0,0,1360,1362,3,176,88,0,1361,1360,1,0,0,0,1361,1362,1,0,0,0,1362,151,1,0,0,0,1363,1364,3,12,6,0,1364,1365,6,76,-1,0,1365,153,1,0,0,0,1366,1368,5,37,0,0,1367,1369,3,124,62,0,1368,1367,1,0,0,0,1368,1369,1,0,0,0,1369,1371,1,0,0,0,1370,1372,3,176,88,0,1371,1370,1,0,0,0,1371,1372,1,0,0,0,1372,1374,1,0,0,0,1373,1375,3,156,78,0,1374,1373,1,0,0,0,1374,1375,1,0,0,0,1375,1376,1,0,0,0,1376,1377,7,24,0,0,1377,1378,6,77,-1,0,1378,155,1,0,0,0,1379,1380,3,158,79,0,1380,1389,6,78,-1,0,1381,1383,3,176,88,0,1382,1381,1,0,0,0,1382,1383,1,0,0,0,1383,1384,1,0,0,0,1384,1385,3,158,79,0,1385,1386,6,78,-1,0,1386,1388,1,0,0,0,1387,1382,1,0,0,0,1388,1391,1,0,0,0,1389,1387,1,0,0,0,1389,1390,1,0,0,0,1390,1393,1,0,0,0,1391,1389,1,0,0,0,1392,1394,3,176,88,0,1393,1392,1,0,0,0,1393,1394,1,0,0,0,1394,157,1,0,0,0,1395,1401,3,12,6,0,1396,1398,5,62,0,0,1397,1399,3,44,22,0,1398,1397,1,0,0,0,1398,1399,1,0,0,0,1399,1400,1,0,0,0,1400,1402,5,63,0,0,1401,1396,1,0,0,0,1401,1402,1,0,0,0,1402,1403,1,0,0,0,1403,1404,6,79,-1,0,1404,159,1,0,0,0,1405,1406,3,162,81,0,1406,1415,6,80,-1,0,1407,1409,3,176,88,0,1408,1407,1,0,0,0,1408,1409,1,0,0,0,1409,1410,1,0,0,0,1410,1411,3,162,81,0,1411,1412,6,80,-1,0,1412,1414,1,0,0,0,1413,1408,1,0,0,0,1414,1417,1,0,0,0,1415,1413,1,0,0,0,1415,1416,1,0,0,0,1416,1419,1,0,0,0,1417,1415,1,0,0,0,1418,1420,3,176,88,0,1419,1418,1,0,0,0,1419,1420,1,0,0,0,1420,161,1,0,0,0,1421,1423,5,47,0,0,1422,1424,3,176,88,0,1423,1422,1,0,0,0,1423,1424,1,0,0,0,1424,1431,1,0,0,0,1425,1426,5,62,0,0,1426,1427,3,164,82,0,1427,1429,5,63,0,0,1428,1430,3,176,88,0,1429,1428,1,0,0,0,1429,1430,1,0,0,0,1430,1432,1,0,0,0,1431,1425,1,0,0,0,1431,1432,1,0,0,0,1432,1434,1,0,0,0,1433,1435,3,166,83,0,1434,1433,1,0,0,0,1434,1435,1,0,0,0,1435,1437,1,0,0,0,1436,1438,3,176,88,0,1437,1436,1,0,0,0,1437,1438,1,0,0,0,1438,1439,1,0,0,0,1439,1440,7,25,0,0,1440,1441,6,81,-1,0,1441,163,1,0,0,0,1442,1443,3,12,6,0,1443,1450,6,82,-1,0,1444,1445,5,56,0,0,1445,1446,3,12,6,0,1446,1447,6,82,-1,0,1447,1449,1,0,0,0,1448,1444,1,0,0,0,1449,1452,1,0,0,0,1450,1448,1,0,0,0,1450,1451,1,0,0,0,1451,165,1,0,0,0,1452,1450,1,0,0,0,1453,1454,3,168,84,0,1454,1461,6,83,-1,0,1455,1456,3,176,88,0,1456,1457,3,168,84,0,1457,1458,6,83,-1,0,1458,1460,1,0,0,0,1459,1455,1,0,0,0,1460,1463,1,0,0,0,1461,1459,1,0,0,0,1461,1462,1,0,0,0,1462,167,1,0,0,0,1463,1461,1,0,0,0,1464,1469,3,170,85,0,1465,1466,5,62,0,0,1466,1467,3,44,22,0,1467,1468,5,63,0,0,1468,1470,1,0,0,0,1469,1465,1,0,0,0,1469,1470,1,0,0,0,1470,1472,1,0,0,0,1471,1473,3,16,8,0,1472,1471,1,0,0,0,1472,1473,1,0,0,0,1473,1478,1,0,0,0,1474,1475,5,66,0,0,1475,1476,3,44,22,0,1476,1477,5,67,0,0,1477,1479,1,0,0,0,1478,1474,1,0,0,0,1478,1479,1,0,0,0,1479,1482,1,0,0,0,1480,1481,5,53,0,0,1481,1483,3,54,27,0,1482,1480,1,0,0,0,1482,1483,1,0,0,0,1483,1484,1,0,0,0,1484,1485,6,84,-1,0,1485,169,1,0,0,0,1486,1487,3,12,6,0,1487,1494,6,85,-1,0,1488,1489,5,57,0,0,1489,1490,3,12,6,0,1490,1491,6,85,-1,0,1491,1493,1,0,0,0,1492,1488,1,0,0,0,1493,1496,1,0,0,0,1494,1492,1,0,0,0,1494,1495,1,0,0,0,1495,171,1,0,0,0,1496,1494,1,0,0,0,1497,1499,7,26,0,0,1498,1497,1,0,0,0,1499,1500,1,0,0,0,1500,1498,1,0,0,0,1500,1501,1,0,0,0,1501,173,1,0,0,0,1502,1504,5,106,0,0,1503,1502,1,0,0,0,1504,1505,1,0,0,0,1505,1503,1,0,0,0,1505,1506,1,0,0,0,1506,175,1,0,0,0,1507,1509,7,27,0,0,1508,1507,1,0,0,0,1509,1510,1,0,0,0,1510,1508,1,0,0,0,1510,1511,1,0,0,0,1511,177,1,0,0,0,198,179,184,190,200,204,216,220,233,243,261,268,278,285,302,310,312,316,321,323,326,331,341,343,347,352,354,357,362,366,371,381,385,387,424,441,451,466,484,491,500,525,527,542,550,557,566,583,585,593,604,631,633,647,654,658,668,672,698,704,709,716,727,734,741,744,753,757,765,770,773,781,785,792,796,799,805,808,815,818,821,829,836,840,844,848,851,857,860,863,879,884,887,894,897,908,911,923,926,936,939,951,955,958,963,967,970,973,985,995,1003,1007,1010,1018,1021,1025,1029,1032,1038,1041,1049,1052,1066,1069,1079,1087,1102,1105,1108,1114,1118,1121,1124,1127,1137,1141,1144,1147,1162,1165,1169,1174,1182,1192,1204,1210,1217,1221,1235,1239,1242,1245,1258,1262,1269,1272,1278,1282,1288,1291,1294,1304,1312,1316,1321,1328,1332,1336,1339,1342,1350,1357,1361,1368,1371,1374,1382,1389,1393,1398,1401,1408,1415,1419,1423,1429,1431,1434,1437,1450,1461,1469,1472,1478,1482,1494,1500,1505,1510];static __ATN;static get _ATN(){return MathJSLabParser.__ATN||(MathJSLabParser.__ATN=(new antlr4_node.fr).deserialize(MathJSLabParser._serializedATN)),MathJSLabParser.__ATN}static DecisionsToDFA=MathJSLabParser._ATN.decisionToState.map((t,e)=>new antlr4_node.M8(t,e))}class InputContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}EOF(){return this.getToken(MathJSLabParser.EOF,0)}sep(){return this.getTypedRuleContext(SepContext,0)}global_list(){return this.getTypedRuleContext(Global_listContext,0)}get ruleIndex(){return MathJSLabParser.RULE_input}}class Global_listContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}statement_list(){return this.getTypedRuleContexts(StatementContext)}statement(t){return this.getTypedRuleContext(StatementContext,t)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(t){return this.getTypedRuleContext(SepContext,t)}get ruleIndex(){return MathJSLabParser.RULE_global_list}}class ListContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}statement_list(){return this.getTypedRuleContexts(StatementContext)}statement(t){return this.getTypedRuleContext(StatementContext,t)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(t){return this.getTypedRuleContext(SepContext,t)}get ruleIndex(){return MathJSLabParser.RULE_list}}class StatementContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}command(){return this.getTypedRuleContext(CommandContext,0)}word_list_cmd(){return this.getTypedRuleContext(Word_list_cmdContext,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}get ruleIndex(){return MathJSLabParser.RULE_statement}}class Word_list_cmdContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}identifier(){return this.getTypedRuleContext(IdentifierContext,0)}command_word_list(){return this.getTypedRuleContexts(Command_wordContext)}command_word(t){return this.getTypedRuleContext(Command_wordContext,t)}get ruleIndex(){return MathJSLabParser.RULE_word_list_cmd}}class Command_wordContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}string_(){return this.getTypedRuleContext(StringContext,0)}get ruleIndex(){return MathJSLabParser.RULE_command_word}}class IdentifierContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}IDENTIFIER(){return this.getToken(MathJSLabParser.IDENTIFIER,0)}PROPERTIES(){return this.getToken(MathJSLabParser.PROPERTIES,0)}METHODS(){return this.getToken(MathJSLabParser.METHODS,0)}EVENTS(){return this.getToken(MathJSLabParser.EVENTS,0)}ENUMERATION(){return this.getToken(MathJSLabParser.ENUMERATION,0)}get ruleIndex(){return MathJSLabParser.RULE_identifier}}class Qualified_identifier_partContext extends antlr4_node.Pg{text;constructor(t,e,r){super(e,r),this.parser=t}identifier(){return this.getTypedRuleContext(IdentifierContext,0)}END(){return this.getToken(MathJSLabParser.END,0)}get ruleIndex(){return MathJSLabParser.RULE_qualified_identifier_part}}class Qualified_identifierContext extends antlr4_node.Pg{node;i=1;constructor(t,e,r){super(e,r),this.parser=t}qualified_identifier_part_list(){return this.getTypedRuleContexts(Qualified_identifier_partContext)}qualified_identifier_part(t){return this.getTypedRuleContext(Qualified_identifier_partContext,t)}DOT_list(){return this.getTokens(MathJSLabParser.DOT)}DOT(t){return this.getToken(MathJSLabParser.DOT,t)}get ruleIndex(){return MathJSLabParser.RULE_qualified_identifier}}class StringContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}STRING(){return this.getToken(MathJSLabParser.STRING,0)}UNQUOTED_STRING(){return this.getToken(MathJSLabParser.UNQUOTED_STRING,0)}get ruleIndex(){return MathJSLabParser.RULE_string}}class NumberContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}FLOAT_NUMBER(){return this.getToken(MathJSLabParser.FLOAT_NUMBER,0)}get ruleIndex(){return MathJSLabParser.RULE_number}}class End_rangeContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}ENDRANGE(){return this.getToken(MathJSLabParser.ENDRANGE,0)}get ruleIndex(){return MathJSLabParser.RULE_end_range}}class ConstantContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}number_(){return this.getTypedRuleContext(NumberContext,0)}string_(){return this.getTypedRuleContext(StringContext,0)}end_range(){return this.getTypedRuleContext(End_rangeContext,0)}get ruleIndex(){return MathJSLabParser.RULE_constant}}class MatrixContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}LBRACKET(){return this.getToken(MathJSLabParser.LBRACKET,0)}RBRACKET(){return this.getToken(MathJSLabParser.RBRACKET,0)}SEMICOLON_list(){return this.getTokens(MathJSLabParser.SEMICOLON)}SEMICOLON(t){return this.getToken(MathJSLabParser.SEMICOLON,t)}nl_list(){return this.getTypedRuleContexts(NlContext)}nl(t){return this.getTypedRuleContext(NlContext,t)}matrix_row_list(){return this.getTypedRuleContexts(Matrix_rowContext)}matrix_row(t){return this.getTypedRuleContext(Matrix_rowContext,t)}LCURLYBR(){return this.getToken(MathJSLabParser.LCURLYBR,0)}RCURLYBR(){return this.getToken(MathJSLabParser.RCURLYBR,0)}get ruleIndex(){return MathJSLabParser.RULE_matrix}}class Matrix_rowContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}COMMA_list(){return this.getTokens(MathJSLabParser.COMMA)}COMMA(t){return this.getToken(MathJSLabParser.COMMA,t)}WSPACE_list(){return this.getTokens(MathJSLabParser.WSPACE)}WSPACE(t){return this.getToken(MathJSLabParser.WSPACE,t)}list_element_list(){return this.getTypedRuleContexts(List_elementContext)}list_element(t){return this.getTypedRuleContext(List_elementContext,t)}get ruleIndex(){return MathJSLabParser.RULE_matrix_row}}class Fcn_handleContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}COMMAT(){return this.getToken(MathJSLabParser.COMMAT,0)}qualified_identifier(){return this.getTypedRuleContext(Qualified_identifierContext,0)}get ruleIndex(){return MathJSLabParser.RULE_fcn_handle}}class Meta_classContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}QUESTION(){return this.getToken(MathJSLabParser.QUESTION,0)}qualified_identifier(){return this.getTypedRuleContext(Qualified_identifierContext,0)}get ruleIndex(){return MathJSLabParser.RULE_meta_class}}class Anon_fcn_handleContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}COMMAT(){return this.getToken(MathJSLabParser.COMMAT,0)}param_list(){return this.getTypedRuleContext(Param_listContext,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}get ruleIndex(){return MathJSLabParser.RULE_anon_fcn_handle}}class Primary_exprContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}identifier(){return this.getTypedRuleContext(IdentifierContext,0)}IMPORT(){return this.getToken(MathJSLabParser.IMPORT,0)}constant(){return this.getTypedRuleContext(ConstantContext,0)}fcn_handle(){return this.getTypedRuleContext(Fcn_handleContext,0)}meta_class(){return this.getTypedRuleContext(Meta_classContext,0)}matrix(){return this.getTypedRuleContext(MatrixContext,0)}LPAREN(){return this.getToken(MathJSLabParser.LPAREN,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}RPAREN(){return this.getToken(MathJSLabParser.RPAREN,0)}get ruleIndex(){return MathJSLabParser.RULE_primary_expr}}class Magic_colonContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}COLON(){return this.getToken(MathJSLabParser.COLON,0)}get ruleIndex(){return MathJSLabParser.RULE_magic_colon}}class Magic_tildeContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}TILDE(){return this.getToken(MathJSLabParser.TILDE,0)}get ruleIndex(){return MathJSLabParser.RULE_magic_tilde}}class List_elementContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}expression(){return this.getTypedRuleContext(ExpressionContext,0)}magic_colon(){return this.getTypedRuleContext(Magic_colonContext,0)}magic_tilde(){return this.getTypedRuleContext(Magic_tildeContext,0)}get ruleIndex(){return MathJSLabParser.RULE_list_element}}class Arg_listContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}list_element_list(){return this.getTypedRuleContexts(List_elementContext)}list_element(t){return this.getTypedRuleContext(List_elementContext,t)}COMMA_list(){return this.getTokens(MathJSLabParser.COMMA)}COMMA(t){return this.getToken(MathJSLabParser.COMMA,t)}get ruleIndex(){return MathJSLabParser.RULE_arg_list}}class Oper_exprContext extends antlr4_node.Pg{node;_op;constructor(t,e,r){super(e,r),this.parser=t}primary_expr(){return this.getTypedRuleContext(Primary_exprContext,0)}oper_expr_list(){return this.getTypedRuleContexts(Oper_exprContext)}oper_expr(t){return this.getTypedRuleContext(Oper_exprContext,t)}PLUS_PLUS(){return this.getToken(MathJSLabParser.PLUS_PLUS,0)}MINUS_MINUS(){return this.getToken(MathJSLabParser.MINUS_MINUS,0)}PLUS(){return this.getToken(MathJSLabParser.PLUS,0)}MINUS(){return this.getToken(MathJSLabParser.MINUS,0)}TILDE(){return this.getToken(MathJSLabParser.TILDE,0)}EXCLAMATION(){return this.getToken(MathJSLabParser.EXCLAMATION,0)}MUL(){return this.getToken(MathJSLabParser.MUL,0)}DIV(){return this.getToken(MathJSLabParser.DIV,0)}LEFTDIV(){return this.getToken(MathJSLabParser.LEFTDIV,0)}EMUL(){return this.getToken(MathJSLabParser.EMUL,0)}EDIV(){return this.getToken(MathJSLabParser.EDIV,0)}ELEFTDIV(){return this.getToken(MathJSLabParser.ELEFTDIV,0)}LPAREN(){return this.getToken(MathJSLabParser.LPAREN,0)}RPAREN(){return this.getToken(MathJSLabParser.RPAREN,0)}arg_list(){return this.getTypedRuleContext(Arg_listContext,0)}LCURLYBR(){return this.getToken(MathJSLabParser.LCURLYBR,0)}RCURLYBR(){return this.getToken(MathJSLabParser.RCURLYBR,0)}COMMAT(){return this.getToken(MathJSLabParser.COMMAT,0)}qualified_identifier(){return this.getTypedRuleContext(Qualified_identifierContext,0)}TRANSPOSE(){return this.getToken(MathJSLabParser.TRANSPOSE,0)}HERMITIAN(){return this.getToken(MathJSLabParser.HERMITIAN,0)}DOT(){return this.getToken(MathJSLabParser.DOT,0)}qualified_identifier_part(){return this.getTypedRuleContext(Qualified_identifier_partContext,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}power_expr(){return this.getTypedRuleContext(Power_exprContext,0)}POW(){return this.getToken(MathJSLabParser.POW,0)}EPOW(){return this.getToken(MathJSLabParser.EPOW,0)}get ruleIndex(){return MathJSLabParser.RULE_oper_expr}}class Power_exprContext extends antlr4_node.Pg{node;_op;constructor(t,e,r){super(e,r),this.parser=t}primary_expr(){return this.getTypedRuleContext(Primary_exprContext,0)}power_expr(){return this.getTypedRuleContext(Power_exprContext,0)}PLUS_PLUS(){return this.getToken(MathJSLabParser.PLUS_PLUS,0)}MINUS_MINUS(){return this.getToken(MathJSLabParser.MINUS_MINUS,0)}PLUS(){return this.getToken(MathJSLabParser.PLUS,0)}MINUS(){return this.getToken(MathJSLabParser.MINUS,0)}TILDE(){return this.getToken(MathJSLabParser.TILDE,0)}EXCLAMATION(){return this.getToken(MathJSLabParser.EXCLAMATION,0)}LPAREN(){return this.getToken(MathJSLabParser.LPAREN,0)}RPAREN(){return this.getToken(MathJSLabParser.RPAREN,0)}arg_list(){return this.getTypedRuleContext(Arg_listContext,0)}LCURLYBR(){return this.getToken(MathJSLabParser.LCURLYBR,0)}RCURLYBR(){return this.getToken(MathJSLabParser.RCURLYBR,0)}COMMAT(){return this.getToken(MathJSLabParser.COMMAT,0)}qualified_identifier(){return this.getTypedRuleContext(Qualified_identifierContext,0)}DOT(){return this.getToken(MathJSLabParser.DOT,0)}qualified_identifier_part(){return this.getTypedRuleContext(Qualified_identifier_partContext,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}get ruleIndex(){return MathJSLabParser.RULE_power_expr}}class Colon_exprContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}oper_expr_list(){return this.getTypedRuleContexts(Oper_exprContext)}oper_expr(t){return this.getTypedRuleContext(Oper_exprContext,t)}COLON_list(){return this.getTokens(MathJSLabParser.COLON)}COLON(t){return this.getToken(MathJSLabParser.COLON,t)}get ruleIndex(){return MathJSLabParser.RULE_colon_expr}}class Simple_exprContext extends antlr4_node.Pg{node;_op;constructor(t,e,r){super(e,r),this.parser=t}oper_expr(){return this.getTypedRuleContext(Oper_exprContext,0)}colon_expr(){return this.getTypedRuleContext(Colon_exprContext,0)}simple_expr_list(){return this.getTypedRuleContexts(Simple_exprContext)}simple_expr(t){return this.getTypedRuleContext(Simple_exprContext,t)}EXPR_LT(){return this.getToken(MathJSLabParser.EXPR_LT,0)}EXPR_LE(){return this.getToken(MathJSLabParser.EXPR_LE,0)}EXPR_GT(){return this.getToken(MathJSLabParser.EXPR_GT,0)}EXPR_GE(){return this.getToken(MathJSLabParser.EXPR_GE,0)}EXPR_EQ(){return this.getToken(MathJSLabParser.EXPR_EQ,0)}EXPR_NE(){return this.getToken(MathJSLabParser.EXPR_NE,0)}EXPR_AND(){return this.getToken(MathJSLabParser.EXPR_AND,0)}EXPR_OR(){return this.getToken(MathJSLabParser.EXPR_OR,0)}EXPR_AND_AND(){return this.getToken(MathJSLabParser.EXPR_AND_AND,0)}EXPR_OR_OR(){return this.getToken(MathJSLabParser.EXPR_OR_OR,0)}get ruleIndex(){return MathJSLabParser.RULE_simple_expr}}class ExpressionContext extends antlr4_node.Pg{node;_op;constructor(t,e,r){super(e,r),this.parser=t}simple_expr(){return this.getTypedRuleContext(Simple_exprContext,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}EQ(){return this.getToken(MathJSLabParser.EQ,0)}ADD_EQ(){return this.getToken(MathJSLabParser.ADD_EQ,0)}SUB_EQ(){return this.getToken(MathJSLabParser.SUB_EQ,0)}MUL_EQ(){return this.getToken(MathJSLabParser.MUL_EQ,0)}EMUL_EQ(){return this.getToken(MathJSLabParser.EMUL_EQ,0)}DIV_EQ(){return this.getToken(MathJSLabParser.DIV_EQ,0)}EDIV_EQ(){return this.getToken(MathJSLabParser.EDIV_EQ,0)}LEFTDIV_EQ(){return this.getToken(MathJSLabParser.LEFTDIV_EQ,0)}ELEFTDIV_EQ(){return this.getToken(MathJSLabParser.ELEFTDIV_EQ,0)}POW_EQ(){return this.getToken(MathJSLabParser.POW_EQ,0)}EPOW_EQ(){return this.getToken(MathJSLabParser.EPOW_EQ,0)}AND_EQ(){return this.getToken(MathJSLabParser.AND_EQ,0)}OR_EQ(){return this.getToken(MathJSLabParser.OR_EQ,0)}anon_fcn_handle(){return this.getTypedRuleContext(Anon_fcn_handleContext,0)}get ruleIndex(){return MathJSLabParser.RULE_expression}}class Assign_lhsContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}simple_expr(){return this.getTypedRuleContext(Simple_exprContext,0)}LBRACKET(){return this.getToken(MathJSLabParser.LBRACKET,0)}RBRACKET(){return this.getToken(MathJSLabParser.RBRACKET,0)}assign_list(){return this.getTypedRuleContext(Assign_listContext,0)}get ruleIndex(){return MathJSLabParser.RULE_assign_lhs}}class Assign_listContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}list_element_list(){return this.getTypedRuleContexts(List_elementContext)}list_element(t){return this.getTypedRuleContext(List_elementContext,t)}COMMA_list(){return this.getTokens(MathJSLabParser.COMMA)}COMMA(t){return this.getToken(MathJSLabParser.COMMA,t)}WSPACE_list(){return this.getTokens(MathJSLabParser.WSPACE)}WSPACE(t){return this.getToken(MathJSLabParser.WSPACE,t)}get ruleIndex(){return MathJSLabParser.RULE_assign_list}}class CommandContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}declaration(){return this.getTypedRuleContext(DeclarationContext,0)}import_command(){return this.getTypedRuleContext(Import_commandContext,0)}select_command(){return this.getTypedRuleContext(Select_commandContext,0)}loop_command(){return this.getTypedRuleContext(Loop_commandContext,0)}jump_command(){return this.getTypedRuleContext(Jump_commandContext,0)}except_command(){return this.getTypedRuleContext(Except_commandContext,0)}function_(){return this.getTypedRuleContext(FunctionContext,0)}classdef_command(){return this.getTypedRuleContext(Classdef_commandContext,0)}get ruleIndex(){return MathJSLabParser.RULE_command}}class DeclarationContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}declaration_element_list(){return this.getTypedRuleContexts(Declaration_elementContext)}declaration_element(t){return this.getTypedRuleContext(Declaration_elementContext,t)}GLOBAL(){return this.getToken(MathJSLabParser.GLOBAL,0)}PERSISTENT(){return this.getToken(MathJSLabParser.PERSISTENT,0)}COMMA_list(){return this.getTokens(MathJSLabParser.COMMA)}COMMA(t){return this.getToken(MathJSLabParser.COMMA,t)}get ruleIndex(){return MathJSLabParser.RULE_declaration}}class Declaration_elementContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}identifier(){return this.getTypedRuleContext(IdentifierContext,0)}EQ(){return this.getToken(MathJSLabParser.EQ,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}get ruleIndex(){return MathJSLabParser.RULE_declaration_element}}class Import_commandContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}IMPORT(){return this.getToken(MathJSLabParser.IMPORT,0)}import_name_list(){return this.getTypedRuleContexts(Import_nameContext)}import_name(t){return this.getTypedRuleContext(Import_nameContext,t)}COMMA_list(){return this.getTokens(MathJSLabParser.COMMA)}COMMA(t){return this.getToken(MathJSLabParser.COMMA,t)}get ruleIndex(){return MathJSLabParser.RULE_import_command}}class Import_nameContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}qualified_identifier(){return this.getTypedRuleContext(Qualified_identifierContext,0)}DOT(){return this.getToken(MathJSLabParser.DOT,0)}MUL(){return this.getToken(MathJSLabParser.MUL,0)}EMUL(){return this.getToken(MathJSLabParser.EMUL,0)}get ruleIndex(){return MathJSLabParser.RULE_import_name}}class Select_commandContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}if_command(){return this.getTypedRuleContext(If_commandContext,0)}switch_command(){return this.getTypedRuleContext(Switch_commandContext,0)}get ruleIndex(){return MathJSLabParser.RULE_select_command}}class If_commandContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}IF(){return this.getToken(MathJSLabParser.IF,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}END(){return this.getToken(MathJSLabParser.END,0)}ENDIF(){return this.getToken(MathJSLabParser.ENDIF,0)}sep(){return this.getTypedRuleContext(SepContext,0)}list(){return this.getTypedRuleContext(ListContext,0)}elseif_clause_list(){return this.getTypedRuleContexts(Elseif_clauseContext)}elseif_clause(t){return this.getTypedRuleContext(Elseif_clauseContext,t)}else_clause(){return this.getTypedRuleContext(Else_clauseContext,0)}get ruleIndex(){return MathJSLabParser.RULE_if_command}}class Elseif_clauseContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}ELSEIF(){return this.getToken(MathJSLabParser.ELSEIF,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(t){return this.getTypedRuleContext(SepContext,t)}list(){return this.getTypedRuleContext(ListContext,0)}get ruleIndex(){return MathJSLabParser.RULE_elseif_clause}}class Else_clauseContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}ELSE(){return this.getToken(MathJSLabParser.ELSE,0)}sep(){return this.getTypedRuleContext(SepContext,0)}list(){return this.getTypedRuleContext(ListContext,0)}get ruleIndex(){return MathJSLabParser.RULE_else_clause}}class Switch_commandContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}SWITCH(){return this.getToken(MathJSLabParser.SWITCH,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}END(){return this.getToken(MathJSLabParser.END,0)}ENDSWITCH(){return this.getToken(MathJSLabParser.ENDSWITCH,0)}sep(){return this.getTypedRuleContext(SepContext,0)}switch_case_list(){return this.getTypedRuleContext(Switch_case_listContext,0)}otherwise_case(){return this.getTypedRuleContext(Otherwise_caseContext,0)}get ruleIndex(){return MathJSLabParser.RULE_switch_command}}class Switch_case_listContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}switch_case_list(){return this.getTypedRuleContexts(Switch_caseContext)}switch_case(t){return this.getTypedRuleContext(Switch_caseContext,t)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(t){return this.getTypedRuleContext(SepContext,t)}get ruleIndex(){return MathJSLabParser.RULE_switch_case_list}}class Switch_caseContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}CASE(){return this.getToken(MathJSLabParser.CASE,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(t){return this.getTypedRuleContext(SepContext,t)}list(){return this.getTypedRuleContext(ListContext,0)}get ruleIndex(){return MathJSLabParser.RULE_switch_case}}class Otherwise_caseContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}OTHERWISE(){return this.getToken(MathJSLabParser.OTHERWISE,0)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(t){return this.getTypedRuleContext(SepContext,t)}list(){return this.getTypedRuleContext(ListContext,0)}get ruleIndex(){return MathJSLabParser.RULE_otherwise_case}}class Loop_commandContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}while_command(){return this.getTypedRuleContext(While_commandContext,0)}do_until_command(){return this.getTypedRuleContext(Do_until_commandContext,0)}for_command(){return this.getTypedRuleContext(For_commandContext,0)}spmd_command(){return this.getTypedRuleContext(Spmd_commandContext,0)}get ruleIndex(){return MathJSLabParser.RULE_loop_command}}class While_commandContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}WHILE(){return this.getToken(MathJSLabParser.WHILE,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}END(){return this.getToken(MathJSLabParser.END,0)}ENDWHILE(){return this.getToken(MathJSLabParser.ENDWHILE,0)}sep(){return this.getTypedRuleContext(SepContext,0)}list(){return this.getTypedRuleContext(ListContext,0)}get ruleIndex(){return MathJSLabParser.RULE_while_command}}class Do_until_commandContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}DO(){return this.getToken(MathJSLabParser.DO,0)}UNTIL(){return this.getToken(MathJSLabParser.UNTIL,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}sep(){return this.getTypedRuleContext(SepContext,0)}list(){return this.getTypedRuleContext(ListContext,0)}get ruleIndex(){return MathJSLabParser.RULE_do_until_command}}class For_commandContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}FOR(){return this.getToken(MathJSLabParser.FOR,0)}assign_lhs(){return this.getTypedRuleContext(Assign_lhsContext,0)}EQ(){return this.getToken(MathJSLabParser.EQ,0)}expression_list(){return this.getTypedRuleContexts(ExpressionContext)}expression(t){return this.getTypedRuleContext(ExpressionContext,t)}END(){return this.getToken(MathJSLabParser.END,0)}ENDFOR(){return this.getToken(MathJSLabParser.ENDFOR,0)}sep(){return this.getTypedRuleContext(SepContext,0)}list(){return this.getTypedRuleContext(ListContext,0)}LPAREN(){return this.getToken(MathJSLabParser.LPAREN,0)}RPAREN(){return this.getToken(MathJSLabParser.RPAREN,0)}PARFOR(){return this.getToken(MathJSLabParser.PARFOR,0)}ENDPARFOR(){return this.getToken(MathJSLabParser.ENDPARFOR,0)}COMMA(){return this.getToken(MathJSLabParser.COMMA,0)}get ruleIndex(){return MathJSLabParser.RULE_for_command}}class Spmd_commandContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}SPMD(){return this.getToken(MathJSLabParser.SPMD,0)}END(){return this.getToken(MathJSLabParser.END,0)}ENDSPMD(){return this.getToken(MathJSLabParser.ENDSPMD,0)}spmd_worker_spec(){return this.getTypedRuleContext(Spmd_worker_specContext,0)}sep(){return this.getTypedRuleContext(SepContext,0)}list(){return this.getTypedRuleContext(ListContext,0)}get ruleIndex(){return MathJSLabParser.RULE_spmd_command}}class Spmd_worker_specContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}LPAREN(){return this.getToken(MathJSLabParser.LPAREN,0)}expression_list(){return this.getTypedRuleContexts(ExpressionContext)}expression(t){return this.getTypedRuleContext(ExpressionContext,t)}RPAREN(){return this.getToken(MathJSLabParser.RPAREN,0)}COMMA(){return this.getToken(MathJSLabParser.COMMA,0)}get ruleIndex(){return MathJSLabParser.RULE_spmd_worker_spec}}class Jump_commandContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}BREAK(){return this.getToken(MathJSLabParser.BREAK,0)}CONTINUE(){return this.getToken(MathJSLabParser.CONTINUE,0)}RETURN(){return this.getToken(MathJSLabParser.RETURN,0)}get ruleIndex(){return MathJSLabParser.RULE_jump_command}}class Except_commandContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}try_command(){return this.getTypedRuleContext(Try_commandContext,0)}unwind_command(){return this.getTypedRuleContext(Unwind_commandContext,0)}get ruleIndex(){return MathJSLabParser.RULE_except_command}}class Try_commandContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}TRY(){return this.getToken(MathJSLabParser.TRY,0)}catch_clause(){return this.getTypedRuleContext(Catch_clauseContext,0)}END(){return this.getToken(MathJSLabParser.END,0)}END_TRY_CATCH(){return this.getToken(MathJSLabParser.END_TRY_CATCH,0)}sep(){return this.getTypedRuleContext(SepContext,0)}list(){return this.getTypedRuleContext(ListContext,0)}get ruleIndex(){return MathJSLabParser.RULE_try_command}}class Catch_clauseContext extends antlr4_node.Pg{body;identifierNode;constructor(t,e,r){super(e,r),this.parser=t}CATCH(){return this.getToken(MathJSLabParser.CATCH,0)}sep(){return this.getTypedRuleContext(SepContext,0)}list(){return this.getTypedRuleContext(ListContext,0)}get ruleIndex(){return MathJSLabParser.RULE_catch_clause}}class Unwind_commandContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}UNWIND_PROTECT(){return this.getToken(MathJSLabParser.UNWIND_PROTECT,0)}unwind_cleanup_clause(){return this.getTypedRuleContext(Unwind_cleanup_clauseContext,0)}END(){return this.getToken(MathJSLabParser.END,0)}END_UNWIND_PROTECT(){return this.getToken(MathJSLabParser.END_UNWIND_PROTECT,0)}sep(){return this.getTypedRuleContext(SepContext,0)}list(){return this.getTypedRuleContext(ListContext,0)}get ruleIndex(){return MathJSLabParser.RULE_unwind_command}}class Unwind_cleanup_clauseContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}UNWIND_PROTECT_CLEANUP(){return this.getToken(MathJSLabParser.UNWIND_PROTECT_CLEANUP,0)}sep(){return this.getTypedRuleContext(SepContext,0)}list(){return this.getTypedRuleContext(ListContext,0)}get ruleIndex(){return MathJSLabParser.RULE_unwind_cleanup_clause}}class Param_listContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}LPAREN(){return this.getToken(MathJSLabParser.LPAREN,0)}RPAREN(){return this.getToken(MathJSLabParser.RPAREN,0)}param_list_elt_list(){return this.getTypedRuleContexts(Param_list_eltContext)}param_list_elt(t){return this.getTypedRuleContext(Param_list_eltContext,t)}COMMA_list(){return this.getTokens(MathJSLabParser.COMMA)}COMMA(t){return this.getToken(MathJSLabParser.COMMA,t)}get ruleIndex(){return MathJSLabParser.RULE_param_list}}class Param_list_eltContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}declaration_element(){return this.getTypedRuleContext(Declaration_elementContext,0)}magic_tilde(){return this.getTypedRuleContext(Magic_tildeContext,0)}get ruleIndex(){return MathJSLabParser.RULE_param_list_elt}}class Return_list_eltContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}identifier(){return this.getTypedRuleContext(IdentifierContext,0)}magic_tilde(){return this.getTypedRuleContext(Magic_tildeContext,0)}get ruleIndex(){return MathJSLabParser.RULE_return_list_elt}}class Return_listContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}return_list_elt_list(){return this.getTypedRuleContexts(Return_list_eltContext)}return_list_elt(t){return this.getTypedRuleContext(Return_list_eltContext,t)}LBRACKET(){return this.getToken(MathJSLabParser.LBRACKET,0)}RBRACKET(){return this.getToken(MathJSLabParser.RBRACKET,0)}COMMA_list(){return this.getTokens(MathJSLabParser.COMMA)}COMMA(t){return this.getToken(MathJSLabParser.COMMA,t)}WSPACE_list(){return this.getTokens(MathJSLabParser.WSPACE)}WSPACE(t){return this.getToken(MathJSLabParser.WSPACE,t)}get ruleIndex(){return MathJSLabParser.RULE_return_list}}class FunctionContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}FUNCTION(){return this.getToken(MathJSLabParser.FUNCTION,0)}function_name(){return this.getTypedRuleContext(Function_nameContext,0)}END(){return this.getToken(MathJSLabParser.END,0)}ENDFUNCTION(){return this.getToken(MathJSLabParser.ENDFUNCTION,0)}EOF(){return this.getToken(MathJSLabParser.EOF,0)}return_list(){return this.getTypedRuleContext(Return_listContext,0)}EQ(){return this.getToken(MathJSLabParser.EQ,0)}param_list(){return this.getTypedRuleContext(Param_listContext,0)}sep(){return this.getTypedRuleContext(SepContext,0)}arguments_block_list(){return this.getTypedRuleContext(Arguments_block_listContext,0)}list(){return this.getTypedRuleContext(ListContext,0)}get ruleIndex(){return MathJSLabParser.RULE_function}}class Function_nameContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}qualified_identifier(){return this.getTypedRuleContext(Qualified_identifierContext,0)}get ruleIndex(){return MathJSLabParser.RULE_function_name}}class Classdef_commandContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}CLASSDEF(){return this.getToken(MathJSLabParser.CLASSDEF,0)}qualified_identifier(){return this.getTypedRuleContext(Qualified_identifierContext,0)}END(){return this.getToken(MathJSLabParser.END,0)}ENDCLASSDEF(){return this.getToken(MathJSLabParser.ENDCLASSDEF,0)}EOF(){return this.getToken(MathJSLabParser.EOF,0)}class_attribute_list(){return this.getTypedRuleContext(Class_attribute_listContext,0)}class_superclass_list(){return this.getTypedRuleContext(Class_superclass_listContext,0)}sep(){return this.getTypedRuleContext(SepContext,0)}class_section_list(){return this.getTypedRuleContext(Class_section_listContext,0)}get ruleIndex(){return MathJSLabParser.RULE_classdef_command}}class Class_attribute_listContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}LPAREN(){return this.getToken(MathJSLabParser.LPAREN,0)}RPAREN(){return this.getToken(MathJSLabParser.RPAREN,0)}class_attribute_list(){return this.getTypedRuleContexts(Class_attributeContext)}class_attribute(t){return this.getTypedRuleContext(Class_attributeContext,t)}sep(){return this.getTypedRuleContext(SepContext,0)}COMMA_list(){return this.getTokens(MathJSLabParser.COMMA)}COMMA(t){return this.getToken(MathJSLabParser.COMMA,t)}get ruleIndex(){return MathJSLabParser.RULE_class_attribute_list}}class Class_attributeContext extends antlr4_node.Pg{node;_op;constructor(t,e,r){super(e,r),this.parser=t}identifier(){return this.getTypedRuleContext(IdentifierContext,0)}EQ(){return this.getToken(MathJSLabParser.EQ,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}TILDE(){return this.getToken(MathJSLabParser.TILDE,0)}EXCLAMATION(){return this.getToken(MathJSLabParser.EXCLAMATION,0)}get ruleIndex(){return MathJSLabParser.RULE_class_attribute}}class Class_method_nameContext extends antlr4_node.Pg{node;i=1;constructor(t,e,r){super(e,r),this.parser=t}identifier_list(){return this.getTypedRuleContexts(IdentifierContext)}identifier(t){return this.getTypedRuleContext(IdentifierContext,t)}DOT_list(){return this.getTokens(MathJSLabParser.DOT)}DOT(t){return this.getToken(MathJSLabParser.DOT,t)}get ruleIndex(){return MathJSLabParser.RULE_class_method_name}}class Class_superclass_listContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}EXPR_LT(){return this.getToken(MathJSLabParser.EXPR_LT,0)}qualified_identifier_list(){return this.getTypedRuleContexts(Qualified_identifierContext)}qualified_identifier(t){return this.getTypedRuleContext(Qualified_identifierContext,t)}EXPR_AND_list(){return this.getTokens(MathJSLabParser.EXPR_AND)}EXPR_AND(t){return this.getToken(MathJSLabParser.EXPR_AND,t)}COMMA_list(){return this.getTokens(MathJSLabParser.COMMA)}COMMA(t){return this.getToken(MathJSLabParser.COMMA,t)}get ruleIndex(){return MathJSLabParser.RULE_class_superclass_list}}class Class_section_listContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}class_section_list(){return this.getTypedRuleContexts(Class_sectionContext)}class_section(t){return this.getTypedRuleContext(Class_sectionContext,t)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(t){return this.getTypedRuleContext(SepContext,t)}get ruleIndex(){return MathJSLabParser.RULE_class_section_list}}class Class_sectionContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}properties_section(){return this.getTypedRuleContext(Properties_sectionContext,0)}methods_section(){return this.getTypedRuleContext(Methods_sectionContext,0)}events_section(){return this.getTypedRuleContext(Events_sectionContext,0)}enumeration_section(){return this.getTypedRuleContext(Enumeration_sectionContext,0)}get ruleIndex(){return MathJSLabParser.RULE_class_section}}class Properties_sectionContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}PROPERTIES(){return this.getToken(MathJSLabParser.PROPERTIES,0)}END(){return this.getToken(MathJSLabParser.END,0)}ENDPROPERTIES(){return this.getToken(MathJSLabParser.ENDPROPERTIES,0)}class_attribute_list(){return this.getTypedRuleContext(Class_attribute_listContext,0)}sep(){return this.getTypedRuleContext(SepContext,0)}class_property_list(){return this.getTypedRuleContext(Class_property_listContext,0)}get ruleIndex(){return MathJSLabParser.RULE_properties_section}}class Class_property_listContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}class_property_list(){return this.getTypedRuleContexts(Class_propertyContext)}class_property(t){return this.getTypedRuleContext(Class_propertyContext,t)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(t){return this.getTypedRuleContext(SepContext,t)}get ruleIndex(){return MathJSLabParser.RULE_class_property_list}}class Class_propertyContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}identifier(){return this.getTypedRuleContext(IdentifierContext,0)}LPAREN(){return this.getToken(MathJSLabParser.LPAREN,0)}arg_list_list(){return this.getTypedRuleContexts(Arg_listContext)}arg_list(t){return this.getTypedRuleContext(Arg_listContext,t)}RPAREN(){return this.getToken(MathJSLabParser.RPAREN,0)}qualified_identifier(){return this.getTypedRuleContext(Qualified_identifierContext,0)}LCURLYBR(){return this.getToken(MathJSLabParser.LCURLYBR,0)}RCURLYBR(){return this.getToken(MathJSLabParser.RCURLYBR,0)}EQ(){return this.getToken(MathJSLabParser.EQ,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}get ruleIndex(){return MathJSLabParser.RULE_class_property}}class Methods_sectionContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}METHODS(){return this.getToken(MathJSLabParser.METHODS,0)}END(){return this.getToken(MathJSLabParser.END,0)}ENDMETHODS(){return this.getToken(MathJSLabParser.ENDMETHODS,0)}class_attribute_list(){return this.getTypedRuleContext(Class_attribute_listContext,0)}sep(){return this.getTypedRuleContext(SepContext,0)}class_method_list(){return this.getTypedRuleContext(Class_method_listContext,0)}get ruleIndex(){return MathJSLabParser.RULE_methods_section}}class Class_methodContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}function_(){return this.getTypedRuleContext(FunctionContext,0)}class_method_name(){return this.getTypedRuleContext(Class_method_nameContext,0)}param_list(){return this.getTypedRuleContext(Param_listContext,0)}return_list(){return this.getTypedRuleContext(Return_listContext,0)}EQ(){return this.getToken(MathJSLabParser.EQ,0)}get ruleIndex(){return MathJSLabParser.RULE_class_method}}class Class_method_listContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}class_method_list(){return this.getTypedRuleContexts(Class_methodContext)}class_method(t){return this.getTypedRuleContext(Class_methodContext,t)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(t){return this.getTypedRuleContext(SepContext,t)}get ruleIndex(){return MathJSLabParser.RULE_class_method_list}}class Events_sectionContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}EVENTS(){return this.getToken(MathJSLabParser.EVENTS,0)}END(){return this.getToken(MathJSLabParser.END,0)}ENDEVENTS(){return this.getToken(MathJSLabParser.ENDEVENTS,0)}class_attribute_list(){return this.getTypedRuleContext(Class_attribute_listContext,0)}sep(){return this.getTypedRuleContext(SepContext,0)}class_event_list(){return this.getTypedRuleContext(Class_event_listContext,0)}get ruleIndex(){return MathJSLabParser.RULE_events_section}}class Class_event_listContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}class_event_list(){return this.getTypedRuleContexts(Class_eventContext)}class_event(t){return this.getTypedRuleContext(Class_eventContext,t)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(t){return this.getTypedRuleContext(SepContext,t)}get ruleIndex(){return MathJSLabParser.RULE_class_event_list}}class Class_eventContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}identifier(){return this.getTypedRuleContext(IdentifierContext,0)}get ruleIndex(){return MathJSLabParser.RULE_class_event}}class Enumeration_sectionContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}ENUMERATION(){return this.getToken(MathJSLabParser.ENUMERATION,0)}END(){return this.getToken(MathJSLabParser.END,0)}ENDENUMERATION(){return this.getToken(MathJSLabParser.ENDENUMERATION,0)}class_attribute_list(){return this.getTypedRuleContext(Class_attribute_listContext,0)}sep(){return this.getTypedRuleContext(SepContext,0)}class_enumeration_list(){return this.getTypedRuleContext(Class_enumeration_listContext,0)}get ruleIndex(){return MathJSLabParser.RULE_enumeration_section}}class Class_enumeration_listContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}class_enumeration_list(){return this.getTypedRuleContexts(Class_enumerationContext)}class_enumeration(t){return this.getTypedRuleContext(Class_enumerationContext,t)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(t){return this.getTypedRuleContext(SepContext,t)}get ruleIndex(){return MathJSLabParser.RULE_class_enumeration_list}}class Class_enumerationContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}identifier(){return this.getTypedRuleContext(IdentifierContext,0)}LPAREN(){return this.getToken(MathJSLabParser.LPAREN,0)}RPAREN(){return this.getToken(MathJSLabParser.RPAREN,0)}arg_list(){return this.getTypedRuleContext(Arg_listContext,0)}get ruleIndex(){return MathJSLabParser.RULE_class_enumeration}}class Arguments_block_listContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}arguments_block_list(){return this.getTypedRuleContexts(Arguments_blockContext)}arguments_block(t){return this.getTypedRuleContext(Arguments_blockContext,t)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(t){return this.getTypedRuleContext(SepContext,t)}get ruleIndex(){return MathJSLabParser.RULE_arguments_block_list}}class Arguments_blockContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}ARGUMENTS(){return this.getToken(MathJSLabParser.ARGUMENTS,0)}END(){return this.getToken(MathJSLabParser.END,0)}ENDARGUMENTS(){return this.getToken(MathJSLabParser.ENDARGUMENTS,0)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(t){return this.getTypedRuleContext(SepContext,t)}LPAREN(){return this.getToken(MathJSLabParser.LPAREN,0)}arguments_attribute_list(){return this.getTypedRuleContext(Arguments_attribute_listContext,0)}RPAREN(){return this.getToken(MathJSLabParser.RPAREN,0)}args_validation_list(){return this.getTypedRuleContext(Args_validation_listContext,0)}get ruleIndex(){return MathJSLabParser.RULE_arguments_block}}class Arguments_attribute_listContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}identifier_list(){return this.getTypedRuleContexts(IdentifierContext)}identifier(t){return this.getTypedRuleContext(IdentifierContext,t)}COMMA_list(){return this.getTokens(MathJSLabParser.COMMA)}COMMA(t){return this.getToken(MathJSLabParser.COMMA,t)}get ruleIndex(){return MathJSLabParser.RULE_arguments_attribute_list}}class Args_validation_listContext extends antlr4_node.Pg{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}arg_validation_list(){return this.getTypedRuleContexts(Arg_validationContext)}arg_validation(t){return this.getTypedRuleContext(Arg_validationContext,t)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(t){return this.getTypedRuleContext(SepContext,t)}get ruleIndex(){return MathJSLabParser.RULE_args_validation_list}}class Arg_validationContext extends antlr4_node.Pg{node;constructor(t,e,r){super(e,r),this.parser=t}arg_validation_name(){return this.getTypedRuleContext(Arg_validation_nameContext,0)}LPAREN(){return this.getToken(MathJSLabParser.LPAREN,0)}arg_list_list(){return this.getTypedRuleContexts(Arg_listContext)}arg_list(t){return this.getTypedRuleContext(Arg_listContext,t)}RPAREN(){return this.getToken(MathJSLabParser.RPAREN,0)}qualified_identifier(){return this.getTypedRuleContext(Qualified_identifierContext,0)}LCURLYBR(){return this.getToken(MathJSLabParser.LCURLYBR,0)}RCURLYBR(){return this.getToken(MathJSLabParser.RCURLYBR,0)}EQ(){return this.getToken(MathJSLabParser.EQ,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}get ruleIndex(){return MathJSLabParser.RULE_arg_validation}}class Arg_validation_nameContext extends antlr4_node.Pg{node;i=1;constructor(t,e,r){super(e,r),this.parser=t}identifier_list(){return this.getTypedRuleContexts(IdentifierContext)}identifier(t){return this.getTypedRuleContext(IdentifierContext,t)}DOT_list(){return this.getTokens(MathJSLabParser.DOT)}DOT(t){return this.getToken(MathJSLabParser.DOT,t)}get ruleIndex(){return MathJSLabParser.RULE_arg_validation_name}}class Sep_no_nlContext extends antlr4_node.Pg{constructor(t,e,r){super(e,r),this.parser=t}COMMA_list(){return this.getTokens(MathJSLabParser.COMMA)}COMMA(t){return this.getToken(MathJSLabParser.COMMA,t)}SEMICOLON_list(){return this.getTokens(MathJSLabParser.SEMICOLON)}SEMICOLON(t){return this.getToken(MathJSLabParser.SEMICOLON,t)}get ruleIndex(){return MathJSLabParser.RULE_sep_no_nl}}class NlContext extends antlr4_node.Pg{constructor(t,e,r){super(e,r),this.parser=t}NEWLINE_list(){return this.getTokens(MathJSLabParser.NEWLINE)}NEWLINE(t){return this.getToken(MathJSLabParser.NEWLINE,t)}get ruleIndex(){return MathJSLabParser.RULE_nl}}class SepContext extends antlr4_node.Pg{constructor(t,e,r){super(e,r),this.parser=t}COMMA_list(){return this.getTokens(MathJSLabParser.COMMA)}COMMA(t){return this.getToken(MathJSLabParser.COMMA,t)}SEMICOLON_list(){return this.getTokens(MathJSLabParser.SEMICOLON)}SEMICOLON(t){return this.getToken(MathJSLabParser.SEMICOLON,t)}NEWLINE_list(){return this.getTokens(MathJSLabParser.NEWLINE)}NEWLINE(t){return this.getToken(MathJSLabParser.NEWLINE,t)}get ruleIndex(){return MathJSLabParser.RULE_sep}}class InterpreterError extends Error{stackFrames;constructor(t,e){super(t),this.name="InterpreterError",this.stackFrames=e}format(){let t=`Error: ${this.message}`;if(!this.stackFrames||0===this.stackFrames.length)return t;const e=[];for(const t of this.stackFrames){const r=this.getFrameName(t);if(!r||"<anonymous>"===r)continue;let s="";const i=t.callSite;if(i?.start){const{line:t,column:e}=i.start;void 0!==t&&void 0!==e?s=` (line ${t}, column ${e})`:void 0!==t&&(s=` (line ${t})`)}e.push(`Error in ${r}${s}`)}return e.length>0&&(t+="\n"+e.join("\n")),t}getFrameName(t){if(t.name)return t.name;const e=t.func;if(!e)return"";switch(e.type){case"BUILTIN":return e.node.id??"<builtin>";case"LAMBDA":return"<anonymous>";case"FCNDEF":return e.node.id??"<function>";default:return"<unknown>"}}toString(){return this.format()}}class InterpreterError_EvalError extends InterpreterError{constructor(t,e){super(t,e),this.name="EvalError"}}class InterpreterError_ReferenceError extends InterpreterError{constructor(t,e){super(t,e),this.name="ReferenceError"}}class UndefinedReferenceError extends InterpreterError_ReferenceError{identifier;constructor(t,e){super(`'${t}' undefined.`,e),this.identifier=t,this.name="UndefinedReferenceError"}}class CircularReferenceError extends InterpreterError{chain;constructor(t,e){super(`Circular reference detected: ${t.join(" → ")}`,e),this.chain=t,this.name="CircularReferenceError"}}class InterpreterError_SyntaxError extends InterpreterError{constructor(t,e){super(t,e),this.name="SyntaxError"}}class SyntaxDiagnostic{static benignEndOfInputMessages=new Set(["mismatched input '' expecting {';', SP}","missing ';' at ''","mismatched input '' expecting","mismatched input '' expecting "]);static error=(t,e,r,s="")=>{const i=`syntax error at ${Math.max(1,e)}:${Math.max(1,r+1)}: ${SyntaxDiagnostic.normalizeMessage(t)}`,n=SyntaxDiagnostic.sourceLine(s,e);if(!n)return new InterpreterError_SyntaxError(i);const a=SyntaxDiagnostic.displayColumn(n,r);return new InterpreterError_SyntaxError(`${i}\n${n}\n${" ".repeat(a)}^`)};static isBenignEndOfInput=t=>SyntaxDiagnostic.benignEndOfInputMessages.has(t);static normalizeMessage=t=>t.replace(/\bEOF\b/g,(t,e,r)=>"<"===r[e-1]&&">"===r[e+t.length]?t:"<EOF>");static displayColumn=(t,e)=>{const r=Math.max(0,Math.min(e,t.length));return[...t.slice(0,r)].reduce((t,e)=>t+("\t"===e?4:1),0)};static sourceLine=(t,e)=>t.replace(/\r\n?/g,"\n").split("\n")[e-1]??""}const src_SyntaxDiagnostic=null;class LexerErrorListener extends antlr4_node.pG{source;constructor(t=""){super(),this.source=t}syntaxError(t,e,r,s,i,n){if(!SyntaxDiagnostic.isBenignEndOfInput(i))throw SyntaxDiagnostic.error(i,r,s,this.source)}}const src_LexerErrorListener=null;class ParserErrorListener extends antlr4_node.pG{source;constructor(t=""){super(),this.source=t}syntaxError(t,e,r,s,i,n){if(!SyntaxDiagnostic.isBenignEndOfInput(i))throw SyntaxDiagnostic.error(i,r,s,this.source)}}const src_ParserErrorListener=null;function substSymbol(t){const e=["alpha","beta","gamma","delta","epsilon","zeta","eta","theta","iota","kappa","lambda","mu","nu","xi","omicron","pi","rho","sigma","tau","upsilon","phi","chi","psi","omega"],r=[["alfa","alpha"],["Alfa","Alpha"],["gama","gamma"],["Gama","Gamma"],["épsilon","epsilon"],["Épsilon","Epsilon"],["dzeta","zeta"],["Dzeta","Zeta"],["teta","theta"],["Teta","Theta"],["capa","kappa"],["Capa","Kappa"],["kapa","kappa"],["Kapa","Kappa"],["mi","mu"],["Mi","Mu"],["ni","nu"],["Ni","Nu"],["csi","xi"],["Csi","Xi"],["ksi","xi"],["Ksi","Xi"],["ômicron","omicron"],["Ômicron","Omicron"],["ómicron","omicron"],["Ómicron","Omicron"],["ro","rho"],["Ro","Rho"],["rô","rho"],["Rô","Rho"],["úpsilon","upsilon"],["Úpsilon","Upsilon"],["ipsilon","upsilon"],["Ipsilon","Upsilon"],["ípsilon","upsilon"],["Ípsilon","Upsilon"],["ypsilon","upsilon"],["Ypsilon","Upsilon"],["ýpsilon","upsilon"],["Ýpsilon","Upsilon"],["fi","phi"],["Fi","Phi"],["qui","chi"],["Qui","Chi"],["ômega","omega"],["Ômega","Omega"]];let s;for(let e=0;e<r.length;e++)s=new RegExp("([^a-zA-Z0-9])("+r[e][0]+")(?![a-zA-Z0-9;])","g"),t=t.replace(s,"$1"+r[e][1]),s=new RegExp("^("+r[e][0]+")(?![a-zA-Z0-9;])","g"),t=t.replace(s,r[e][1]);for(let r=0;r<e.length;r++)s=new RegExp("([^a-zA-Z0-9])(["+e[r][0]+e[r][0].toUpperCase()+"]"+e[r].substring(1)+")(?![a-zA-Z0-9;])","g"),t=t.replace(s,"$1&$2;"),s=new RegExp("^(["+e[r][0]+e[r][0].toUpperCase()+"]"+e[r].substring(1)+")(?![a-zA-Z0-9;])","g"),t=t.replace(s,"&$1;");return t.replace(/^[Ii]nf$/,"∞").replace(/^NaN$|^nan$/,"<b>NaN</b>")}const src_substSymbol=null;class DiagnosticMessage{static formatArgument(t,e,r){const s=r.expressionValue(t,"diagnostic format argument");if("s"===e)return CharString.isInstanceOf(s)?s.str:r.unparse(s).trimEnd();const i=MultiArray.isInstanceOf(s)?MultiArray.MultiArrayToScalar(s):s;Complex.isInstanceOf(i)&&Complex.imagIsZero(i)||r.throwEvalError("diagnostic format argument must be a real numeric scalar.");const n=Complex.realToNumber(i);switch(e){case"d":case"i":return Math.trunc(n).toString();case"f":return n.toFixed(6);case"g":return n.toString();default:return r.unparse(s).trimEnd()}}static format(t,e,r){let s=0;return t.replace(/%([-+0 #]*)(\d*)(?:\.(\d+))?([sdifg%])/g,(t,i,n,a,o)=>{if("%"===o)return"%";if(s>=e.length&&r.throwEvalError("not enough arguments for diagnostic format string."),"f"===o&&void 0!==a){const t=r.expressionValue(e[s++],"diagnostic format argument"),i=MultiArray.isInstanceOf(t)?MultiArray.MultiArrayToScalar(t):t;return Complex.isInstanceOf(i)&&Complex.imagIsZero(i)||r.throwEvalError("diagnostic format argument must be a real numeric scalar."),Complex.realToNumber(i).toFixed(Number(a))}return this.formatArgument(e[s++],o,r)})}static parts(t,e,r,s){const i=r(t[0],`${e} identifier or message`);if(t.length>=2){const r=s.expressionValue(t[1],`${e} message`);if(i.str.includes(":")&&CharString.isInstanceOf(r))return{identifier:i.str,message:this.format(r.str,t.slice(2),s)}}return{identifier:"",message:this.format(i.str,t.slice(1),s)}}}const src_DiagnosticMessage=null;class FunctionArguments{static isIdentifier(t){return AST.isNodeIdentifier(t)}static isDefaultedIdentifier(t){return AST.isNodeDefaultedParameter(t)}static parameterName(t){return this.isIdentifier(t)?t.id:this.isDefaultedIdentifier(t)?t.left.id:void 0}static checkedList(t,e,r){return t.map((t,s)=>{if(!e(t))throw new TypeError(`internal AST error: ${r} ${s+1} has invalid node type.`);return t})}static runtimeArgumentValue(t,e,r){return runtimeExpressionValue(t,e,"Argument value",r)}static functionParameters(t){return this.checkedList(t.parameter.list,AST.isNodeFunctionParameter,"function parameter")}static functionReturns(t){return this.checkedList(t.return.list,AST.isNodeFunctionReturn,"function return")}static argumentBlocks(t){return this.checkedList(t.arguments.list,AST.isNodeArguments,"function arguments block")}static argumentValidations(t){return this.checkedList(t.validation,AST.isNodeArgumentValidation,"arguments validation")}static supportedArgumentValidators=new Set(["mustBeNumeric","mustBeFloat","mustBeNumericOrLogical","mustBeText","mustBeTextScalar","mustBeNonzeroLengthText","mustBeValidVariableName","mustBeFile","mustBeFolder","mustBeScalarOrEmpty","mustBeScalar","mustBeMatrix","mustBeSquare","mustBeVector","mustBeRow","mustBeColumn","mustBeNonempty","mustBePositive","mustBeNonnegative","mustBeNegative","mustBeNonpositive","mustBeNonzero","mustBeNonNan","mustBeNonmissing","mustBeNonsparse","mustBeSparse","mustBeInteger","mustBeOdd","mustBeFinite","mustBeReal"]);static supportedComparatorValidators=new Set(["mustBeGreaterThan","mustBeGreaterThanOrEqual","mustBeLessThan","mustBeLessThanOrEqual"]);static supportedRangeValidators=new Set(["mustBeInRange","mustBeBetween"]);static supportedMembershipValidators=new Set(["mustBeMember"]);static supportedClassRelationshipValidators=new Set(["mustBeA","mustBeUnderlyingType"]);static supportedRangeOptions=new Set(["inclusive","exclude-lower","exclude-upper","exclude-both"]);static supportedBetweenOptions=new Set(["closed","open","openleft","openright","closedleft","closedright"]);static supportedBlockAttributes=new Set(["Input","Output","Repeating"]);static blockAttributeNames(t){return t.attributes?.length?t.attributes.map(t=>t.id):t.attribute?[t.attribute.id]:[]}static blockKind(t,e){const r=this.blockAttributeNames(t);if(0===r.length)return"Input";const s=new Set;for(const t of r)this.supportedBlockAttributes.has(t)||e(`unsupported arguments block attribute '${t}'.`),s.has(t)&&e(`duplicate arguments block attribute '${t}'.`),s.add(t);const i=s.has("Input"),n=s.has("Output"),a=s.has("Repeating");return i&&n&&e("arguments block attributes 'Input' and 'Output' cannot be combined."),(s.size>2||!i&&!n&&!a)&&e(`unsupported arguments block attribute list '${r.join(",")}'.`),a&&n?"OutputRepeating":a?"Repeating":n?"Output":"Input"}static argumentSizeDimensionDisplay(t){return"number"==typeof t?String(t):"any"===t.type?":":t.name}static argumentSizeDisplay(t){const e=t.map(t=>this.argumentSizeDimensionDisplay(t));return t.some(t=>"number"!=typeof t&&"any"===t.type)?`(${e.join(",")})`:e.join("x")}static literalNumericSize(t,e,r){Complex.isInstanceOf(t)&&Complex.realIsInteger(t)&&Complex.imagIsZero(t)||r(`arguments block size validation for '${e}' must use positive integer, symbolic, or ':' dimensions.`);const s=Complex.realToNumber(t);return s<1&&r(`arguments block size validation for '${e}' must use positive integer dimensions.`),s}static validationName(t,e){const r=t.name;return AST.isNodeIdentifier(r)||e("arguments block declaration must be an identifier."),r.id}static nameValueTarget(t,e){const r=t.name;if(AST.isNodeIndirectRef(r))return AST.isNodeIdentifier(r.obj)&&1===r.field.length&&"string"==typeof r.field[0]||e("arguments block name-value declaration must be a single dotted identifier."),{parameter:r.obj.id,field:r.field[0]}}static validationDisplayName(t,e){const r=this.nameValueTarget(t,e);return r?`${r.parameter}.${r.field}`:this.validationName(t,e)}static nameValueReferenceDisplay(t,e,r,s=new WeakSet){if(null!==t&&"object"==typeof t&&!s.has(t)){if(s.add(t),AST.isNodeIdentifier(t)&&e.has(t.id))return t.id;if(AST.isNodeIndirectRef(t)&&AST.isNodeIdentifier(t.obj)&&e.has(t.obj.id)){const e=t.field[0],s="string"==typeof e?`${t.obj.id}.${e}`:t.obj.id;return s===r?void 0:s}if(AST.isNodeIndexExpr(t))return this.nameValueReferenceDisplay(t.expr,e,r,s)??this.firstNameValueReferenceDisplay(t.args,e,r,s);if(AST.isNodeRange(t))return this.nameValueReferenceDisplay(t.start_,e,r,s)??this.nameValueReferenceDisplay(t.stop_,e,r,s)??this.nameValueReferenceDisplay(t.stride_,e,r,s);if(AST.isNodeBinaryOperation(t))return this.nameValueReferenceDisplay(t.left,e,r,s)??this.nameValueReferenceDisplay(t.right,e,r,s);if(AST.isNodePrefixOperation(t))return this.nameValueReferenceDisplay(t.right,e,r,s);if(AST.isNodePostfixOperation(t))return this.nameValueReferenceDisplay(t.left,e,r,s);if(AST.isNodeSuperclassConstructor(t))return this.nameValueReferenceDisplay(t.instance,e,r,s)??this.firstNameValueReferenceDisplay(t.args,e,r,s);if(!AST.isNodeMetaClass(t))return AST.isNodeList(t)?this.firstNameValueReferenceDisplay(t.list,e,r,s):MultiArray.isInstanceOf(t)?this.firstNameValueReferenceDisplay(MultiArray.linearize(t),e,r,s):void 0}}static firstNameValueReferenceDisplay(t,e,r,s=new WeakSet){for(const i of t){const t=this.nameValueReferenceDisplay(i,e,r,s);if(t)return t}}static literalArgumentSize(t,e){if(!t.size.some(t=>void 0!==t))return;const r=this.validationDisplayName(t,e);return t.size.map(t=>AST.isNodeIdentifier(t)?{type:"symbol",name:t.id}:":"===t?.type?{type:"any"}:FunctionArguments.literalNumericSize(t,r,e))}static argumentClassNames(t,e){const r=t.class;if(!r||AST.isNodeList(r)&&0===r.list.length)return;const s=this.validationDisplayName(t,e),i=AST.isNodeList(r)?r.list:[r];i.every(AST.isNodeIdentifier)||e(`arguments block class validation for '${s}' must use class identifiers.`);const n=i.map(t=>t.id);return[...new Set(n)]}static argumentClassName(t,e){const r=this.argumentClassNames(t,e);return r&&1===r.length?r[0]:void 0}static argumentClassDisplay(t){return 1===t.length?t[0]:t.slice(0,-1).join(", ")+" or "+t[t.length-1]}static argumentValidators(t,e){const r=this.validationDisplayName(t,e);return t.functions.map(t=>AST.isNodeIdentifier(t)&&this.supportedArgumentValidators.has(t.id)?{name:t.id}:AST.isNodeIdentifier(t)?{name:t.id,custom:"implicit"}:AST.isNodeIndexExpr(t)&&"()"===t.delim&&AST.isNodeIdentifier(t.expr)&&this.supportedComparatorValidators.has(t.expr.id)&&2===t.args.length?{name:t.expr.id,value:t.args[0],bounds:[t.args[1]]}:AST.isNodeIndexExpr(t)&&"()"===t.delim&&AST.isNodeIdentifier(t.expr)&&this.supportedRangeValidators.has(t.expr.id)&&(3===t.args.length||4===t.args.length)?{name:t.expr.id,value:t.args[0],bounds:t.args.slice(1)}:AST.isNodeIndexExpr(t)&&"()"===t.delim&&AST.isNodeIdentifier(t.expr)&&this.supportedMembershipValidators.has(t.expr.id)&&2===t.args.length||AST.isNodeIndexExpr(t)&&"()"===t.delim&&AST.isNodeIdentifier(t.expr)&&this.supportedClassRelationshipValidators.has(t.expr.id)&&2===t.args.length?{name:t.expr.id,value:t.args[0],bounds:[t.args[1]]}:(AST.isNodeIndexExpr(t)&&AST.isNodeIdentifier(t.expr)&&(this.supportedComparatorValidators.has(t.expr.id)||this.supportedRangeValidators.has(t.expr.id)||this.supportedMembershipValidators.has(t.expr.id)||this.supportedClassRelationshipValidators.has(t.expr.id))&&e(`arguments block function validation for '${r}' has invalid ${t.expr.id} arguments.`),AST.isNodeIndexExpr(t)&&"()"===t.delim&&AST.isNodeIdentifier(t.expr)?{name:t.expr.id,custom:"explicit",expression:t}:void e(`arguments block function validation for '${r}' must be a validator identifier or function call.`)))}static valueSize(t){return RuntimeValue.dimensions(t)}static textElements(t){if(CharString.isInstanceOf(t))return[t.str];if(MultiArray.isInstanceOf(t)){const e=MultiArray.linearize(t);return e.every(CharString.isInstanceOf)?e.map(t=>t.str):void 0}}static classNameElements(t){const e=this.textElements(t);if(e&&0!==e.length&&!e.some(t=>0===t.length))return[...new Set(e)]}static membershipElements(t){return MultiArray.isInstanceOf(t)?MultiArray.linearize(t).map(t=>this.runtimeArgumentValue(t,"mustBeMember element",t=>{throw new EvalError(t)})):[t]}static validateArgumentFunction(t,e,r,s,i,n,a={},o="arguments block"){const l=FunctionValidation.numericElements(e),c=()=>i(`${o} validation failed for '${t}': ${r}.`),u=(t=0)=>{const e=s[t],r=void 0!==e?FunctionValidation.numericElements(e):void 0;return r&&1===r.length&&Complex.imagIsZero(r[0])||c(),Complex.realToNumber(r[0])},h=(t,e=0)=>{const r=u(e);return Boolean(l&&l.every(e=>Complex.imagIsZero(e)&&t(e,r)))},d=FunctionValidation.builtInValidatorForArgumentValidator(r);if(d)FunctionValidation.matchesBuiltInValidator(e,d)||c();else switch(r){case"mustBeFile":{const t=FunctionValidation.matchesBuiltInValidator(e,"textScalar")?this.textElements(e):void 0;return void(t&&1===t.length&&a.fileExists&&a.fileExists(t[0])||c())}case"mustBeFolder":{const t=FunctionValidation.matchesBuiltInValidator(e,"text")?this.textElements(e):void 0;return void(t&&0!==t.length&&a.folderExists&&t.every(a.folderExists)||c())}case"mustBeOdd":return void(l&&l.every(t=>Complex.realIsInteger(t)&&Complex.imagIsZero(t)&&1===Math.abs(Complex.realToNumber(t)%2))||c());case"mustBeGreaterThan":return void(h((t,e)=>Complex.realGreaterThan(t,e))||c());case"mustBeGreaterThanOrEqual":return void(h((t,e)=>Complex.realGreaterThanOrEqualTo(t,e))||c());case"mustBeLessThan":return void(h((t,e)=>Complex.realLessThan(t,e))||c());case"mustBeLessThanOrEqual":return void(h((t,e)=>Complex.realLessThanOrEqualTo(t,e))||c());case"mustBeInRange":{const t=u(0),e=u(1),r=s[2],i=void 0===r?"inclusive":CharString.isInstanceOf(r)?r.str:void 0;void 0!==i&&this.supportedRangeOptions.has(i)||c();const n="exclude-lower"===i||"exclude-both"===i?e=>Complex.realGreaterThan(e,t):e=>Complex.realGreaterThanOrEqualTo(e,t),a="exclude-upper"===i||"exclude-both"===i?t=>Complex.realLessThan(t,e):t=>Complex.realLessThanOrEqualTo(t,e);return void(l&&l.every(t=>Complex.imagIsZero(t)&&n(t)&&a(t))||c())}case"mustBeBetween":{const t=u(0),e=u(1),r=s[2],i=void 0===r?"closed":CharString.isInstanceOf(r)?r.str:void 0;void 0!==i&&this.supportedBetweenOptions.has(i)||c();const n="open"===i||"openleft"===i||"closedright"===i?e=>Complex.realGreaterThan(e,t):e=>Complex.realGreaterThanOrEqualTo(e,t),a="open"===i||"openright"===i||"closedleft"===i?t=>Complex.realLessThan(t,e):t=>Complex.realLessThanOrEqualTo(t,e);return void(l&&l.every(t=>Complex.imagIsZero(t)&&n(t)&&a(t))||c())}case"mustBeMember":{const t=FunctionValidation.numericElements(s[0]);if(l&&t)return void(l.every(e=>t.some(t=>Complex.imagEquals(e,Complex.imagToNumber(t))&&Complex.realEquals(e,Complex.realToNumber(t))))||c());const r=this.textElements(e),i=this.textElements(s[0]);if(r&&i)return void(r.every(t=>i.includes(t))||c());const n=this.membershipElements(e),a=this.membershipElements(s[0]);if(n.every(t=>a.some(e=>RuntimeEquality.valuesEqual(t,e))))return;return void c()}default:n(`${o} function validation for '${t}' uses unsupported validator '${r}'.`)}}static validateArgumentValidation(t,e,r,s=!1,i=this.validationDisplayName(t,r.throwSyntaxError),n="arguments block"){const a=this.literalArgumentSize(t,r.throwSyntaxError),o=this.argumentClassNames(t,r.throwSyntaxError),l=this.argumentValidators(t,r.throwSyntaxError);if(!a&&!o&&0===l.length)return;const c=r.resolveEntry(t,s);let u;c&&void 0!==c.node||r.throwEvalError(`'${i}' undefined.`);const h=()=>u??=this.runtimeArgumentValue(c.node,i,r.throwEvalError);if(a){const t=this.valueSize(h()),s=Math.max(a.length,t.length);s>a.length&&a.push(...new Array(s-a.length).fill(1)),MultiArray.appendSingletonTail(t,s),a.every((r,s)=>{if("number"==typeof r)return r===t[s];if("any"===r.type)return!0;const i=e.get(r.name);return void 0===i?(e.set(r.name,t[s]),!0):i===t[s]})||r.throwEvalError(`${n} validation failed for '${i}': expected size ${this.argumentSizeDisplay(a)}, got ${t.join("x")}.`)}const d=r.matchesClass??((t,e)=>FunctionValidation.matchesClass(t,e));o&&!o.some(t=>d(h(),t))&&r.throwEvalError(`${n} validation failed for '${i}': expected class ${this.argumentClassDisplay(o)}, got ${FunctionValidation.className(h())}.`);for(const t of l){if("explicit"===t.custom){r.evaluate(t.expression);continue}if("implicit"===t.custom){AST.isStrictNodeExpr(c.node)||r.throwEvalError(`${n} validation failed for '${i}': validator input is not an expression.`),r.evaluate(AST.nodeIndexExpr(AST.nodeIdentifier(t.name),AST.nodeList([c.node])));continue}const e=t.value?this.runtimeArgumentValue(r.evaluate(t.value),i,r.throwEvalError):h(),s=t.bounds?.map((t,e)=>this.runtimeArgumentValue(r.evaluate(t),`${i} bound ${e+1}`,r.throwEvalError))??[];if("mustBeA"===t.name){const a=[this.classNameElements(s[0]),t.bounds?.[0]&&AST.isExpressionBoundaryValue(t.bounds[0])?this.classNameElements(this.runtimeArgumentValue(t.bounds[0],`${i} class names`,r.throwEvalError)):void 0].filter(t=>Boolean(t));0!==a.length&&a.some(t=>t.some(t=>d(e,t)))||r.throwEvalError(`${n} validation failed for '${i}': mustBeA.`);continue}if("mustBeUnderlyingType"===t.name){const a=[this.classNameElements(s[0]),t.bounds?.[0]&&AST.isExpressionBoundaryValue(t.bounds[0])?this.classNameElements(this.runtimeArgumentValue(t.bounds[0],`${i} underlying types`,r.throwEvalError)):void 0].filter(t=>Boolean(t));0!==a.length&&a.some(t=>t.includes(FunctionValidation.underlyingType(e)))||r.throwEvalError(`${n} validation failed for '${i}': mustBeUnderlyingType.`);continue}this.validateArgumentFunction(i,e,t.name,s,r.throwEvalError,r.throwSyntaxError,r,n)}}static validateFunctionArguments(t,e,r,s,i=!1){const n=new Map;for(const a of this.argumentBlocks(t))if(this.blockKind(a,r.throwSyntaxError)===e)for(const t of this.argumentValidations(a))s&&!s.has(this.validationName(t,r.throwSyntaxError))||this.nameValueTarget(t,r.throwSyntaxError)&&void 0===r.resolveEntry(t,i)?.node||this.validateArgumentValidation(t,n,r,i)}static validateRepeatingArguments(t,e,r){for(const s of this.argumentBlocks(t)){if("Repeating"!==this.blockKind(s,r.throwSyntaxError))continue;const i=this.argumentValidations(s);e.length%i.length!==0&&r.throwEvalError(`invalid number of repeating arguments in function ${t.id}`);for(let t=0;t<e.length/i.length;t++){const s=new Map;i.forEach((n,a)=>{const o=e[t*i.length+a],l=this.validationName(n,r.throwSyntaxError);r.validateRepeatingValue(n,l,o,`${l}{${t+1}}`,s)})}}}static outputRepeatingInfo(t,e){const r=this.functionReturns(t).map(t=>AST.isNodeIgnoredTarget(t)?null:t.id);let s;for(const i of this.argumentBlocks(t)){if("OutputRepeating"!==this.blockKind(i,e))continue;s&&e(`function ${t.id} can contain only one arguments (Output,Repeating) block.`);const n=this.argumentValidations(i);1!==n.length&&e(`arguments (Output,Repeating) requires exactly one declaration in function ${t.id}.`);const a=n[0];this.nameValueTarget(a,e)&&e(`arguments (Output,Repeating) declaration in function ${t.id} must be a return identifier.`);const o=this.validationName(a,e),l=r.indexOf(o);l<0&&e(`arguments block declaration '${o}' does not match a return value in function ${t.id}.`),l!==r.length-1&&e(`arguments (Output,Repeating) declaration '${o}' must be the last return in function ${t.id}.`),"varargout"===o&&1!==r.length&&e(`arguments (Output,Repeating) declaration 'varargout' must be the only return in function ${t.id}.`),s={name:o,fixedReturnCount:l}}return s}static outputRepeatingName(t,e){return this.outputRepeatingInfo(t,e)?.name}static validateRepeatingOutputArguments(t,e,r){for(const s of this.argumentBlocks(t)){if("OutputRepeating"!==this.blockKind(s,r.throwSyntaxError))continue;const t=this.argumentValidations(s)[0],i=this.validationName(t,r.throwSyntaxError);e.forEach(e=>{r.validateRepeatingValue(t,i,e.value,`${i}{${e.index}}`,new Map)})}}static validateBlocks(t,e){t.attributes?.nested&&t.arguments.list.length>0&&e(`arguments blocks are not allowed in nested function ${t.id}.`);const r=new Set(this.functionParameters(t).map(t=>this.parameterName(t)).filter(t=>void 0!==t)),s=new Set(this.functionReturns(t).filter(AST.isNodeIdentifier).map(t=>t.id)),i=new Set;for(const r of this.argumentBlocks(t))if("Input"===this.blockKind(r,e))for(const t of this.argumentValidations(r)){const r=this.nameValueTarget(t,e);r&&i.add(r.parameter)}const n=r.has("varargin"),a=new Set,o=new Map,l=new Set,c=new Set,u=new Set,h=new Set;let d=!1,m=!1,p=!1,f=!1,g=!1;for(const y of this.argumentBlocks(t)){const x=this.blockKind(y,e);if("Input"!==x&&"Repeating"!==x||!g||e(`input arguments blocks must appear before output arguments blocks in function ${t.id}.`),"Input"===x){const r=this.argumentValidations(y).some(t=>!this.nameValueTarget(t,e));m&&r&&e(`ordinary input arguments blocks cannot follow repeating arguments block in function ${t.id}.`)}"Repeating"===x&&(m&&e(`function ${t.id} can contain only one arguments (Repeating) block.`),f&&e(`arguments (Repeating) block must appear before name-value arguments in function ${t.id}.`),m=!0),"Output"!==x&&"OutputRepeating"!==x||(g=!0),"OutputRepeating"===x&&(d&&e(`function ${t.id} can contain only one arguments (Output,Repeating) block.`),d=!0,this.outputRepeatingInfo(t,e)),"Repeating"!==x||n||e(`arguments (Repeating) requires a varargin parameter in function ${t.id}.`),"Repeating"!==x&&"OutputRepeating"!==x||0!==y.validation.length||e(`arguments (${"OutputRepeating"===x?"Output,Repeating":"Repeating"}) requires at least one declaration in function ${t.id}.`);const C="Output"===x?s:"Input"===x?r:void 0;for(const s of this.argumentValidations(y)){const n=this.nameValueTarget(s,e),d=n?`${n.parameter}.${n.field}`:this.validationName(s,e);if(n){"Input"!==x&&e(`arguments block name-value declaration '${d}' is only supported for input arguments.`),r.has(n.parameter)||e(`arguments block declaration '${d}' does not match a function parameter in function ${t.id}.`);const s=`${n.parameter}.${n.field}`;a.has(s)&&e(`duplicate arguments block name-value declaration '${d}' in function ${t.id}.`);const i=n.field.toLowerCase(),u=o.get(i);u&&e(`duplicate arguments block name-value field '${u}' in function ${t.id}.`),c.has(n.parameter)&&e(`arguments block parameter '${n.parameter}' cannot have both ordinary and name-value declarations in function ${t.id}.`),a.add(s),o.set(i,n.field),l.add(n.parameter),f=!0}else C&&!C.has(d)&&e(`arguments block declaration '${d}' does not match a ${"Output"===x?"return value":"function parameter"} in function ${t.id}.`);n||"Input"!==x||(c.has(d)&&e(`duplicate arguments block declaration '${d}' in function ${t.id}.`),l.has(d)&&e(`arguments block parameter '${d}' cannot have both ordinary and name-value declarations in function ${t.id}.`),f&&"varargin"!==d&&e(`ordinary input arguments must appear before name-value arguments in function ${t.id}.`),p&&!s.default&&"varargin"!==d&&e(`required input arguments cannot follow optional input arguments in function ${t.id}.`),c.add(d),s.default&&(p=!0)),n||"Repeating"!==x||(u.has(d)&&e(`duplicate arguments (Repeating) declaration '${d}' in function ${t.id}.`),u.add(d)),n||"Output"!==x||(h.has(d)&&e(`duplicate arguments block output declaration '${d}' in function ${t.id}.`),h.add(d));const m=s.size.some(t=>void 0!==t),g=Boolean(s.class&&(!AST.isNodeList(s.class)||s.class.list.length>0)),y=s.functions.some(t=>void 0!==t);if(m&&this.literalArgumentSize(s,e),g&&this.argumentClassNames(s,e),y&&this.argumentValidators(s,e),s.default&&"Input"!==x&&e(`arguments block default for '${d}' is only supported for input parameters.`),n&&s.default){const r=this.nameValueReferenceDisplay(s.default,i);r&&e(`arguments block name-value default for '${d}' cannot reference name-value argument '${r}' in function ${t.id}.`)}if(n&&y){const r=this.firstNameValueReferenceDisplay(s.functions,i,d);r&&e(`arguments block name-value validation for '${d}' cannot reference name-value argument '${r}' in function ${t.id}.`)}s.default&&!n&&"varargin"===d&&e("arguments block default for 'varargin' is not supported.")}}}static nameValueParameters(t,e){const r=new Set;for(const s of this.argumentBlocks(t))if("Input"===this.blockKind(s,e))for(const t of this.argumentValidations(s)){const s=this.nameValueTarget(t,e);s&&r.add(s.parameter)}return r}static nameValueDeclarations(t,e){const r=new Map;for(const s of this.argumentBlocks(t))if("Input"===this.blockKind(s,e))for(const t of this.argumentValidations(s)){const s=this.nameValueTarget(t,e);if(!s)continue;let i=r.get(s.parameter);i||(i=new Map,r.set(s.parameter,i)),i.set(s.field,t)}return r}static inputArgumentDefaults(t,e){const r=new Map;for(const e of this.functionParameters(t))this.isDefaultedIdentifier(e)&&r.set(e.left.id,e.right);for(const s of this.argumentBlocks(t))if("Input"===this.blockKind(s,e))for(const t of this.argumentValidations(s))!this.nameValueTarget(t,e)&&t.default&&r.set(this.validationName(t,e),t.default);return r}static splitCallNameValueArguments(t,e,r,s){const i=this.nameValueDeclarations(t,s),n=new Set([...i.values()].flatMap(t=>[...t.keys()])),a=this.functionParameters(t),o=a[a.length-1],l=a.length>0&&"varargin"===this.parameterName(o),c=l?a.length-1:a.length,u=this.nameValueParameters(t,s),h=a.slice(0,c).filter(t=>{const e=this.parameterName(t);return"<~>"===t.type||!e||!u.has(e)}),d=this.inputArgumentDefaults(t,s);let m=h.length;for(;m>0;){const t=h[m-1],e=this.parameterName(t);if(!e||!d.has(e))break;m--}const p=[],f=new Map;let g=!1;const y=[...n],x=t=>y.some(e=>e.toLowerCase().startsWith(t.toLowerCase())),C=(e,s)=>{g=!0;const i=(e=>{if(n.has(e))return e;const s=e.toLowerCase(),i=y.filter(t=>t.toLowerCase()===s);if(1===i.length)return i[0];i.length>1&&r(`ambiguous name-value argument '${e}' in function ${t.id}`);const a=y.filter(t=>t.toLowerCase().startsWith(s));if(1===a.length)return a[0];a.length>1&&r(`ambiguous name-value argument '${e}' in function ${t.id}`),r(`unknown name-value argument '${e}' in function ${t.id}`)})(e);f.set(i,s)};for(let s=0;s<e.length;s++){const n=e[s];AST.isNodeDefaultedParameter(n)&&i.size>0?C(n.left.id,n.right):CharString.isInstanceOf(n)&&i.size>0&&(p.length>=m&&x(n.str)||!l&&p.length>=h.length)?(s+1>=e.length&&r(`missing value for name-value argument '${n.str}' in function ${t.id}`),C(n.str,e[++s])):(g&&r(`positional arguments cannot follow name-value arguments in function ${t.id}`),p.push(n))}return{positional:p,named:f}}static outputNamesToValidate(t,e,r=[]){const s=this.functionReturns(t).map(t=>AST.isNodeIgnoredTarget(t)?null:t.id),i=s.length>0&&"varargout"===s[s.length-1];if(1===s.length&&i)return;const n=i?s.slice(0,-1):s;return new Set(n.slice(0,Math.min(Math.max(e,1),n.length)).filter((t,e)=>null!==t&&(r[e]??!0)))}}const src_FunctionArguments=null;class FunctionSignature{static inputSignatures(t){const e=t.signature?.inputs;return e?Array.isArray(e)?e:[e]:[]}static outputSignatures(t){const e=t.signature?.outputs;return e?Array.isArray(e)?e:[e]:[]}static arityMinimum(t){return t.min??(t.arity<0?Math.max(Math.abs(t.arity)-1,0):t.arity)}static arityMaximum(t){return t.max??(t.arity<0?1/0:t.arity)}static variadicPosition(t,e=!1){const r=t.parameters?.findIndex(t=>t.variadic)??-1;return e&&r>=0?r+1:t.arity<0?Math.abs(t.arity):r>=0?r+1:void 0}static declaredArity(t){if(0===t.length)return;const e=t.map(t=>this.arityMinimum(t)),r=t.map(t=>this.arityMaximum(t));if(!r.some(t=>t===1/0)&&e.every((t,e)=>t===r[e])&&e.every(t=>t===e[0]))return e[0];if(r.some(t=>t===1/0)){const e=t.filter((t,e)=>r[e]===1/0).map(e=>this.variadicPosition(e,t.length>1)).filter(t=>"number"==typeof t);if(e.length>0)return-Math.min(...e)}const s=r.filter(t=>t!==1/0);return s.length>0?-Math.max(...s):-Math.max(...t.map(t=>this.variadicPosition(t)??Math.abs(t.arity)))}static arityMatches(t,e){const r=this.arityMinimum(t),s=this.arityMaximum(t);return e>=r&&e<=s}static matchingInputSignatures(t,e){return this.inputSignatures(t).filter(t=>this.arityMatches(t,e))}static inputArityIsValid(t,e){const r=this.inputSignatures(t);return 0===r.length||r.some(t=>this.arityMatches(t,e))}static inputParametersAreValid(t,e){const r=this.matchingInputSignatures(t,e.length);return 0===r.length||r.some(t=>FunctionValidation.argumentsMatchBuiltInParameters(e,t.parameters))}}const src_FunctionSignature=null;class FunctionArity{static checkedList(t,e,r){return t.map((t,s)=>{if(!e(t))throw new TypeError(`internal AST error: ${r} ${s+1} has invalid node type.`);return t})}static inputArity(t){switch(t.type){case"LAMBDA":{const e=this.checkedList(t.node.parameter,AST.isNodeFunctionParameter,"function handle parameter");return this.identifierListArity(e,"varargin")}case"FCNDEF":{const e=this.checkedList(t.node.parameter.list,AST.isNodeFunctionParameter,"function parameter");return this.identifierListArity(e,"varargin")}case"STATIC_METHOD":{const e=this.checkedList(t.node.method.node.parameter.list,AST.isNodeFunctionParameter,"static method parameter");return this.identifierListArity(e,"varargin")}case"BUILTIN":return FunctionSignature.declaredArity(FunctionSignature.inputSignatures(t.node))??t.node.func.length}}static outputArity(t){switch(t.type){case"LAMBDA":return 1;case"FCNDEF":{const e=this.checkedList(t.node.return.list,AST.isNodeFunctionReturn,"function return");return this.identifierListArity(e,"varargout")}case"STATIC_METHOD":{const e=this.checkedList(t.node.method.node.return.list,AST.isNodeFunctionReturn,"static method return");return this.identifierListArity(e,"varargout")}case"BUILTIN":return FunctionSignature.declaredArity(FunctionSignature.outputSignatures(t.node))??1}}static countBound(t,e,r,s){const i=MultiArray.isInstanceOf(e)&&MultiArray.isScalar(e)?MultiArray.firstElement(e):e;Complex.isInstanceOf(i)&&Complex.imagIsZero(i)&&(r||Number.isFinite(Complex.realToNumber(i)))||s(`${t}: bounds must be real scalar numbers.`);const n=Complex.realToNumber(i);return(n<0||!Number.isInteger(n)&&(!r||n!==1/0))&&s(`${t}: bounds must be nonnegative integers.`),n}static checkFunctionCount(t,e,r,s,i,n){const a=this.countBound(t,e,!1,i),o=this.countBound(t,r,!0,i);o<a&&i(`${t}: maximum count must be greater than or equal to minimum count.`),(s<a||s>o)&&n(`${t}: invalid number of ${"nargoutchk"===t?"output":"input"} arguments.`)}static identifierListArity(t,e){const r=t[t.length-1];return t.length>0&&AST.isNodeIdentifier(r)&&r.id===e?-t.length:t.length}}const src_FunctionArity=null;class FunctionWorkspace{static ensurePersistentTable(t){return t.attributes||(t.attributes={}),t.attributes.persistent||(t.attributes.persistent=Object.create(null)),t.attributes.persistent}static copyVisibleScopeEntries(t,e,r=!0){if(!e)return;const s=[];let i=e;for(;i&&(s.unshift(i),i.resolveParentNames);)i=i.parent;for(const e of s)Object.assign(t.nameTable,e.nameTable),r&&Object.assign(t.functionTable,e.functionTable)}static inputName(t,e,r,s=!0,i){const n=MultiArray.isInstanceOf(e)&&MultiArray.isScalar(e)?MultiArray.firstElement(e):e;Complex.isInstanceOf(n)&&Complex.imagIsZero(n)||r("inputname: argument number must be a positive integer.");const a=Complex.realToNumber(n);(!Number.isInteger(a)||a<1)&&r("inputname: argument number must be a positive integer.");const o=t[a-1];return o?AST.isNodeIdentifier(o)?new CharString(o.id):new CharString(!s&&i?i(o).trim():""):new CharString("")}static resolveWorkspace(t,e,r,s){switch(t){case"base":return e;case"caller":return r;default:s(`unsupported workspace '${t}'.`)}}static evaluateWithCatch(t,e,r,s,i=()=>!0,n){try{return s(e,t)}catch(e){if(void 0===r||!i(e))throw e;return n?.(e),s(r,t)}}static assignIn(t,e,r){const s=RuntimeValue.copy(r);return t.assignName?t.assignName(e,s):t.defineName(e,s),AST.nodeVoid()}static declarePersistent(t,e,r,s){const i=this.ensurePersistentTable(r);s.nameTable?.[t]?.persistent||(void 0!==e&&void 0===i[t]?i[t]=RuntimeValue.copy(e):void 0===i[t]&&(i[t]=AST.emptyArray()),s.defineName(t,RuntimeValue.copy(i[t])).persistent=!0)}static loadPersistentVariables(t,e){const r=this.ensurePersistentTable(t);for(const t of Object.keys(r))void 0===r[t]&&(r[t]=AST.emptyArray()),e.defineName(t,RuntimeValue.copy(r[t])).persistent=!0}static storePersistentVariables(t,e){const r=this.ensurePersistentTable(t);for(const t of Object.keys(r)){const s=e.hasLocalName(t)?e.nameTable[t]:void 0;s&&void 0!==s.node&&(r[t]=RuntimeValue.copy(runtimeExpressionValue(s.node,t,"persistent variable",t=>{throw new EvalError(t)})))}}static declareGlobal(t,e,r,s,i,n){r.add(t);let a=s[t];a||(a=s[t]={}),a.global=!0;const o=Boolean(a.globalInitialized||n?.has(t));void 0===e||o?void 0===a.node&&(a.node=AST.emptyArray()):(a.node=RuntimeValue.copy(e),delete a.undefinedReference,a.globalInitialized=!0,n?.add(t)),i[t]=a}static clearGlobalVariables(t,e,r,s){const i=s?s.filter(e=>t.has(e)):[...t],n=new Set,a=t=>{for(;t&&!n.has(t);){n.add(t);for(const e of i)t.nameTable[e]?.global&&delete t.nameTable[e];for(const e of Object.values(t.functionTable))a(e.definingScope);t=t.parent}};a(e);for(const t of r)a(t);if(s)for(const e of i)t.delete(e);else t.clear()}}const src_FunctionWorkspace=null;class FunctionIntrospection{static metadataString(t,e){if(t&&"object"==typeof t&&e in t){const r=t[e];return"string"==typeof r?r:void 0}}static functionNames(t){return Object.keys(t.functionTable).filter(e=>"FCNDEF"===t.functionTable[e]?.type)}static nearestFunctionScope(t,e){if(!t)return{scope:e,hasFunctionFrame:!1};if(this.functionNames(t.scope).length>0)return{scope:t.scope,hasFunctionFrame:!0};let r=t.scope.parent;for(;r;){if(this.functionNames(r).length>0)return{scope:r,excludeName:this.metadataString(t.func?.node,"id"),hasFunctionFrame:!0};r=r.parent}return{scope:t.scope,hasFunctionFrame:!0}}static localFunctionHandles(t,e){const r=this.nearestFunctionFrame(t),{scope:s,excludeName:i,hasFunctionFrame:n}=this.nearestFunctionScope(r,e),a=this.functionNames(s).filter(t=>t!==i).sort(),o=new MultiArray([a.length,1],null,!0);return o.array=a.map(t=>{const e=n?s:void 0;return[FunctionHandle.create(t,[],null,e)]}),o}static frameName(t){if(t.name)return t.name;const e=t.func;if(!e)return"";switch(e.type){case"BUILTIN":return this.metadataString(e.node,"id")??"<builtin>";case"LAMBDA":return"<anonymous>";case"FCNDEF":return this.metadataString(e.node,"id")??"<function>";default:return""}}static frameFile(t){return this.metadataString(t.func?.node,"sourceName")??""}static dbstackResult(t,e,r){const s=this.dbstackSkip(t,r),i=e.filter(t=>"FCNDEF"===t.func?.type||"LAMBDA"===t.func?.type).slice().reverse().slice(s),n=new MultiArray([i.length,1]);return n.array=i.map(t=>[new Structure({file:new CharString(this.frameFile(t)),name:new CharString(this.frameName(t)),line:Complex.create(t.callSite?.start?.line??0)})]),n.type=Structure.STRUCTURE,n}static nearestFunctionFrame(t){let e=t;for(;e&&"FCNDEF"!==e.func?.type;)e=e.parentFrame;return e}static dbstackSkip(t,e){let r=0;for(const s of t){const t=MultiArray.isInstanceOf(s)&&MultiArray.isScalar(s)?MultiArray.firstElement(s):s;if(Complex.isInstanceOf(t)){const s=Complex.realToNumber(t);(!Complex.imagIsZero(t)||!Number.isInteger(s)||s<0)&&e("dbstack: omitted frame count must be a nonnegative integer."),r=s}else CharString.isInstanceOf(t)?"-completenames"!==t.str&&e(`dbstack: unsupported option '${t.str}'.`):e("dbstack: arguments must be a frame count or option string.")}return r}}const src_FunctionIntrospection=null;class FunctionLookup{static runtimeClassNames=new Set(["double","single","logical","char","cell","struct","function_handle","event.listener","event.proplistener","event.EventData","event.PropertyEvent","handle","meta.class","meta.property","meta.method","meta.event","meta.EnumerationMember","matlab.mixin.SetGet","matlab.mixin.SetGetExactNames"]);static existCode(t,e,r,s,i=!1,n=!1){const a=e?.trim().toLowerCase(),o=r&&void 0!==r.node&&!ClassDefinition.isInstanceOf(r.node)?1:0,l="FCNDEF"===s?.type?2:"BUILTIN"===s?.type?5:0,c=i||r&&ClassDefinition.isInstanceOf(r.node)||this.isRuntimeClassName(t)?8:0,u=n?2:0;switch(a){case void 0:return o||l||c||u;case"var":case"variable":return o;case"builtin":return 5===l?5:0;case"file":return 2===l?2:5===l?5:u;case"function":return 2===l?2:5===l?5:0;case"class":return c;default:return 0}}static existCodeFromResolution(t,e,r){const s="variable"===r?.kind?r.entry:void 0,i="function"===r?.kind||"builtin"===r?.kind?r.functionDefinition:void 0,n="class"===r?.kind,a="script"===r?.kind,o="function"===r?.kind&&!r.functionDefinition,l="class"===r?.kind&&!r.classDefinition;if("directory"===r?.kind){const t=e?.trim().toLowerCase();switch(t){case void 0:case"dir":case"file":return 7;default:return 0}}if(o){const t=e?.trim().toLowerCase();switch(t){case void 0:case"file":case"function":return 2;default:return 0}}if(l){const t=e?.trim().toLowerCase();switch(t){case void 0:case"class":return 8;case"file":return 2;default:return 0}}return this.existCode(t,e,s,i,n,a)}static whichResult(t,e,r,s,i,n=!1,a=!1,o){return s&&!s.id?new CharString(`${i(s).trim()} is an anonymous function`):s||!e||void 0===e.node||ClassDefinition.isInstanceOf(e.node)?"FCNDEF"===r?.type?new CharString(`${t} is a ${r.attributes?.nested?"nested":"user-defined"} function`):"BUILTIN"===r?.type?new CharString(`${r.id} is a built-in function`):o?new CharString(`${o.className}.${o.methodName} is a static method`):n||e&&ClassDefinition.isInstanceOf(e.node)||this.isRuntimeClassName(t)?new CharString(`${t} is a class`):new CharString(a?`${t} is a script`:`${t} not found`):new CharString(`${t} is a variable`)}static whichResultFromResolution(t,e,r,s,i){if("function"===e?.kind&&!e.functionDefinition)return new CharString(`${t} is a user-defined function`);if("directory"===e?.kind)return new CharString(`${t} is a folder`);const n="variable"===e?.kind?e.entry:void 0,a="function"===e?.kind||"builtin"===e?.kind?e.functionDefinition:void 0;return this.whichResult(t,n,a,r,s,"class"===e?.kind,"script"===e?.kind,i)}static func2str(t,e){return new CharString(t.id??e(t).trim())}static str2func(t,e,r){const s=t.trim();if(0===s.length&&r("str2func: function name cannot be empty."),!s.startsWith("@"))return FunctionHandle.create(s);const i=e(s);return FunctionHandle.isInstanceOf(i)||r("str2func: invalid function handle string."),i}static functionsInfo(t,e,r,s,i=()=>MultiArray.emptyArray(!0),n=()=>{}){let a="anonymous",o=t.sourceName??"";if(t.id){const s=e(t.id),i=t.closure?.resolveFunction(s)??r(t.id);if("FCNDEF"===i?.type)a=i.attributes?.nested?"nested":"simple",o=i.sourceName??"";else{const e=n(t.id,t);a="simple",o=e?.sourceName??o}}const l="simple"===a?MultiArray.emptyArray(!0):i(t);return new Structure({function:this.func2str(t,s),type:new CharString(a),file:new CharString(o),workspace:l})}static resolveHandleFunction(t,e,r,s){const i=r(e);return t.closure?.resolveFunction(i)??s(e)}static isRuntimeClassName(t){return this.runtimeClassNames.has(t)}}const src_FunctionLookup=null;class Scope{parent;nameTable;functionTable;undefinedReferenceTable;importTable;resolveParentNames;assignExistingParentNames;rejectDynamicNameCreation;staticWorkspaceNameSet;globalDeclarationTarget;constructor(t,e=Object.create(null),r=Object.create(null),s=Object.create(null),i={explicit:Object.create(null),wildcard:[]},n=!0,a=!1,o=!1,l){this.parent=t,this.nameTable=e,this.functionTable=r,this.undefinedReferenceTable=s,this.importTable=i,this.resolveParentNames=n,this.assignExistingParentNames=a,this.rejectDynamicNameCreation=o,this.staticWorkspaceNameSet=l}static create=(t,e=!0)=>new Scope(t,Object.create(null),Object.create(null),Object.create(null),{explicit:Object.create(null),wildcard:[]},e);defineName(t,e,r){const s=this.nameTable[t];if(s)return s.node=e,r?s.undefinedReference=r:delete s.undefinedReference,s;if(!this.canCreateLocalName(t))throw new Error(`Attempt to add variable '${t}' to a static workspace.`);return this.nameTable[t]=r?{undefinedReference:r,node:e}:{node:e}}assignName(t,e,r){if(this.assignExistingParentNames&&!this.hasLocalName(t)&&this.parent){const s=this.parent.resolveName(t);if(s)return s.node=e,r?s.undefinedReference=r:delete s.undefinedReference,s}if(!this.canCreateLocalName(t))throw new Error(`Attempt to add variable '${t}' to a static workspace.`);return this.defineName(t,e,r)}canCreateLocalName(t){return!this.rejectDynamicNameCreation||this.hasLocalName(t)||Boolean(this.staticWorkspaceNameSet?.has(t))}allowStaticWorkspaceName(t){(this.staticWorkspaceNameSet??=new Set).add(t)}allowStaticWorkspaceNames(t){for(const e of t)this.allowStaticWorkspaceName(e)}defineNameTable(t){for(const[e,r]of Object.entries(t))this.nameTable[e]={node:r}}resolveName(t){return this.nameTable[t]||(this.resolveParentNames&&this.parent?this.parent.resolveName(t):void 0)}hasLocalName(t){return t in this.nameTable}removeName(t){delete this.nameTable[t]}clearName(t){let e=this;for(;e;)delete e.nameTable[t],e=e.parent}defineFunction(t,e){return this.functionTable[t]=e}defineFunctionTable(t){Object.assign(this.functionTable,t)}resolveFunction(t){return this.functionTable[t]||(this.parent?this.parent.resolveFunction(t):void 0)}hasLocalFunction(t){return t in this.functionTable}removeFunction(t){delete this.functionTable[t]}clearFunction(t){let e=this;for(;e;)delete e.functionTable[t],e=e.parent}bindParameters(t,e){for(let r=0;r<t.length;r++)this.defineName(t[r],e[r])}bindParametersChecked(t,e){if(t.length!==e.length)throw new Error(`Arity mismatch: expected ${t.length} argument(s), got ${e.length}`);this.bindParameters(t,e)}defineUndefinedReference(t,e){const r=this.resolveUndefinedReference(t);return r?(r.add(e),r):this.undefinedReferenceTable[t]=new Set([e])}resolveUndefinedReference(t){return this.undefinedReferenceTable[t]||(this.parent?this.parent.resolveUndefinedReference(t):void 0)}removeUndefinedReference(t){delete this.undefinedReferenceTable[t]}clearUndefinedReference(t){let e=this;for(;e;)delete e.undefinedReferenceTable[t],e=e.parent}defineImport(t){if(t.endsWith(".*")){const e=t.slice(0,-2);return void(e&&!this.importTable.wildcard.includes(e)&&this.importTable.wildcard.push(e))}const e=t.split(".").pop()??t;if(e){const r=this.importTable.explicit[e]??=[];r.includes(t)||r.push(t)}}clearImports(){this.importTable.explicit=Object.create(null),this.importTable.wildcard=[]}importSnapshot(){return{explicit:Scope.cloneExplicitImports(this.importTable.explicit),wildcard:this.importTable.wildcard.slice()}}restoreImports(t){this.importTable={explicit:Scope.cloneExplicitImports(t.explicit),wildcard:t.wildcard.slice()}}importList(){const t=[],e=new Set;let r=this;for(;r;){for(const s of Object.values(r.importTable.explicit))for(const r of s)e.has(r)||(e.add(r),t.push(r));for(const s of r.importTable.wildcard){const r=`${s}.*`;e.has(r)||(e.add(r),t.push(r))}r=r.parent}return t}importedNameCandidates(t){const e=[];let r=this;for(;r;){const s=r.importTable.explicit[t];if(s?.length){e.push(...s);break}for(const s of r.importTable.wildcard)e.push(`${s}.${t}`);r=r.parent}return e}snapshot(t){const e=this.parent?this.parent.snapshot(t):void 0,r=Scope.create(e);for(const[e,s]of Object.entries(this.nameTable))r.nameTable[e]={...s,node:void 0!==s.node?t(s.node):s.node};r.functionTable={...this.functionTable},r.undefinedReferenceTable=Object.create(null);for(const[t,e]of Object.entries(this.undefinedReferenceTable))r.undefinedReferenceTable[t]=new Set(e);return r.importTable.explicit=Scope.cloneExplicitImports(this.importTable.explicit),r.importTable.wildcard=[...this.importTable.wildcard],r.assignExistingParentNames=this.assignExistingParentNames,r.rejectDynamicNameCreation=this.rejectDynamicNameCreation,r.staticWorkspaceNameSet=this.staticWorkspaceNameSet?new Set(this.staticWorkspaceNameSet):void 0,r}capture(t,e=!0){const r=Scope.create(this,e);for(const[e,s]of Object.entries(this.nameTable))r.nameTable[e]={...s,node:void 0!==s.node?t(s.node):s.node};r.functionTable={...this.functionTable},r.undefinedReferenceTable=Object.create(null);for(const[t,e]of Object.entries(this.undefinedReferenceTable))r.undefinedReferenceTable[t]=new Set(e);return r.importTable.explicit=Scope.cloneExplicitImports(this.importTable.explicit),r.importTable.wildcard=[...this.importTable.wildcard],r.assignExistingParentNames=this.assignExistingParentNames,r.rejectDynamicNameCreation=this.rejectDynamicNameCreation,r.staticWorkspaceNameSet=this.staticWorkspaceNameSet?new Set(this.staticWorkspaceNameSet):void 0,r}static cloneExplicitImports(t){const e=Object.create(null);for(const[r,s]of Object.entries(t))e[r]=s.slice();return e}}const src_Scope=null;class CallFrame{scope;func;callSite;name;nargin;nargout;inputArgs;parentFrame;outputMask;constructor(t,e,r,s,i=0,n=0,a=[],o,l=[]){this.scope=t,this.func=e,this.callSite=r,this.name=s,this.nargin=i,this.nargout=n,this.inputArgs=a,this.parentFrame=o,this.outputMask=l}}const src_CallFrame=null,Callables={builtin:t=>({type:"BUILTIN",node:t}),lambda:t=>({type:"LAMBDA",node:t}),functionDefinition:t=>({type:"FCNDEF",node:t}),staticMethod:t=>({type:"STATIC_METHOD",node:t}),fromFunctionNode(t){return"BUILTIN"===t.type?this.builtin(t):this.functionDefinition(t)},isBuiltin:t=>"BUILTIN"===t.type,isLambda:t=>"LAMBDA"===t.type,isFunctionDefinition:t=>"FCNDEF"===t.type,isStaticMethod:t=>"STATIC_METHOD"===t.type},Callable=null,normalizeEntry=(t,e,r)=>{if(void 0!==e)return"string"==typeof e?{name:t,sourceName:r,source:e}:{name:e.name??t,sourceName:e.sourceName??r,source:e.source}},sourceNameFromKey=t=>/[\\/]/.test(t)||/\.m(?:[?#].*)?$/i.test(t)?t.replace(/\\/g,"/"):void 0,sourceLookupPath=t=>t.replace(/\\/g,"/").split(/[?#]/,1)[0],normalizeScriptName=t=>sourceLookupPath(t).split("/").pop()?.replace(/\.m$/i,"")??t,canonicalNameFromPath=t=>{const e=sourceLookupPath(t).replace(/^\.\//,"").replace(/\.m$/i,"").split("/").filter(Boolean),r=[];for(let t=0;t<e.length;t++){const s=e[t];if(s.startsWith("+"))r.push(s.slice(1));else if(s.startsWith("@")){const i=s.slice(1);r.push(i),t===e.length-2&&e[t+1]===i&&t++}else t===e.length-1&&r.push(s)}return r.join(".")},virtualDirectoryPath=t=>sourceLookupPath(t).replace(/^\.\//,"").replace(/\/+$/g,""),virtualDirectoryCandidates=t=>{const e=virtualDirectoryPath(t),r=[e];if(!/[\\/]/.test(e)&&!e.startsWith("+")&&!e.startsWith("@")){const t=e.split(".").filter(Boolean).map(t=>`+${t}`).join("/");t&&r.push(t)}return[...new Set(r)]},sourcePathFromCanonicalName=t=>{if(!t.includes(".")||/[\\/]/.test(t))return;const e=t.split(".").filter(Boolean),r=e.pop();return r?`${e.map(t=>`+${t}`).join("/")}/${r}.m`:void 0},sourcePathCandidates=(t,e)=>{const r=[t],s=sourcePathFromCanonicalName(t);if(s&&r.push(s),"string"!=typeof e){if(e.name){r.push(e.name);const t=sourcePathFromCanonicalName(e.name);t&&r.push(t)}e.sourceName&&r.push(e.sourceName)}return r.map(virtualDirectoryPath)},sourceTablesHaveDirectory=(t,e)=>{const r=virtualDirectoryCandidates(t);return e.some(t=>Boolean(t&&Object.entries(t).some(([t,e])=>sourcePathCandidates(t,e).some(t=>r.some(e=>t!==e&&t.startsWith(`${e}/`))))))},canonicalSourceNameCandidates=t=>{const e=canonicalNameFromPath(t);return[...new Set([t,e])]},scriptSourceNameCandidates=t=>{const e=canonicalNameFromPath(t);return[...new Set([t,normalizeScriptName(t),e,normalizeScriptName(e)])]},resolveFromCandidates=(t,e,r)=>{for(const s of t){const t=e?.[s]??r?.(s);if(void 0!==t)return normalizeEntry(s,t,sourceNameFromKey(s))}},resolveManifestEntry=(t,e)=>{for(const r of t){const t=e[r];if(t)return normalizeEntry(r,t)}},resolveNormalizedTableEntry=(t,e,r,s=t=>t)=>{if(!e)return;const i=new Set(t.map(r));for(const[t,n]of Object.entries(e)){if(i.has(r(t)))return normalizeEntry(s(t),n,sourceNameFromKey(t));if("string"!=typeof n&&n.name&&i.has(r(n.name)))return normalizeEntry(s(n.name),n,sourceNameFromKey(n.name));if("string"!=typeof n&&n.sourceName&&i.has(r(n.sourceName)))return normalizeEntry(s(n.sourceName),n,sourceNameFromKey(n.sourceName))}},joinUrl=(t,e)=>/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?e:t?`${t.replace(/\/+$/,"")}/${e.replace(/^\/+/,"")}`:e;class TableSourceResolver{config;constructor(t){this.config=t}static create=(t={})=>new TableSourceResolver(t);resolve(t,e){switch(t){case"function":{const t=canonicalSourceNameCandidates(e);return resolveFromCandidates(t,this.config.functionSourceTable,this.config.functionSourceProvider)??resolveNormalizedTableEntry(t,this.config.functionSourceTable,canonicalNameFromPath,canonicalNameFromPath)}case"script":return resolveFromCandidates(scriptSourceNameCandidates(e),this.config.scriptSourceTable,this.config.scriptSourceProvider)??resolveNormalizedTableEntry(scriptSourceNameCandidates(e),this.config.scriptSourceTable,normalizeScriptName);case"class":{const t=canonicalSourceNameCandidates(e);return resolveFromCandidates(t,this.config.classSourceTable,this.config.classSourceProvider)??resolveNormalizedTableEntry(t,this.config.classSourceTable,canonicalNameFromPath,canonicalNameFromPath)}}}hasDirectory(t){return sourceTablesHaveDirectory(t,[this.config.functionSourceTable,this.config.scriptSourceTable,this.config.classSourceTable])}}class ManifestSourceResolver{sources;constructor(t){this.sources=t}static fromTable=t=>{const e={function:Object.create(null),script:Object.create(null),class:Object.create(null)};for(const[r,s]of Object.entries(t)){const t="string"==typeof s?[r]:[r,...s.sourceName?[s.sourceName]:[],...s.name?[s.name]:[]];for(const r of t){const t=canonicalNameFromPath(r),i=normalizeScriptName(r),n=sourceNameFromKey(r),a=normalizeEntry(t,s,n),o=normalizeEntry(i,s,n);for(const t of canonicalSourceNameCandidates(r))e.function[t]=a,e.class[t]=a;for(const t of scriptSourceNameCandidates(r))e.script[t]=o}}return new ManifestSourceResolver(e)};static fromManifest=async(t,e=globalThis.fetch)=>{if(!e)throw new Error("ManifestSourceResolver.fromManifest requires a fetch implementation.");const r={function:Object.create(null),script:Object.create(null),class:Object.create(null)};for(const s of t.files){const i="string"==typeof s?{path:s}:s,n=joinUrl(t.baseUrl,i.path),a=await e(n);if(!1===a.ok)throw new Error(`failed to fetch ${n}: ${a.status??""} ${a.statusText??""}`.trim());const o=i.sourceName??i.path,l=i.name??canonicalNameFromPath(o),c={name:l,sourceName:o,source:await a.text()},u=i.kind?[i.kind]:["function","script","class"];for(const t of u){const e="script"===t?[...scriptSourceNameCandidates(i.path),...scriptSourceNameCandidates(o),...scriptSourceNameCandidates(l)]:[...canonicalSourceNameCandidates(i.path),...canonicalSourceNameCandidates(o),...canonicalSourceNameCandidates(l)];for(const s of e)r[t][s]=c;"script"===t&&(r.script[normalizeScriptName(l)]=c)}}return new ManifestSourceResolver(r)};resolve(t,e){return"script"===t?resolveManifestEntry(scriptSourceNameCandidates(e),this.sources.script):resolveManifestEntry(canonicalSourceNameCandidates(e),this.sources[t])}hasDirectory(t){return sourceTablesHaveDirectory(t,[this.sources.function,this.sources.script,this.sources.class])}}const SourceResolver=null;class FunctionCall{static defaultArgumentMarker={useDefaultArgument:!0};static isIdentifier(t){return AST.isNodeIdentifier(t)}static isDefaultedIdentifier(t){return AST.isNodeDefaultedParameter(t)}static parameterName(t){return this.isIdentifier(t)?t.id:this.isDefaultedIdentifier(t)?t.left.id:void 0}static isNamed(t,e){return this.parameterName(t)===e}static checkedList(t,e,r){return t.map((t,s)=>{if(!e(t))throw new TypeError(`internal AST error: ${r} ${s+1} has invalid node type.`);return t})}static returnExpression(t,e,r){return expressionValue(t,e,"Return variable",r)}static evaluatedArgument(t,e,r){return expressionValue(t,e,"Argument value",r)}static isDefaultArgumentMarker(t){return!0===t.useDefaultArgument}static callArgumentRequestsDefault(t){return AST.isNodeBase(t)&&":"===t.type}static requireEvaluatedArgument(t,e,r){return this.isDefaultArgumentMarker(t)&&r(`invalid use of default argument marker ':' for ${e}.`),t}static expressionArgumentValues(t,e,r){return t.map((t,s)=>this.requireEvaluatedArgument(t,`${e} ${s+1}`,r))}static inputLayout(t,e){const r=this.checkedList(t.parameter.list,AST.isNodeFunctionParameter,"function parameter"),s=r.length>0&&this.isNamed(r[r.length-1],"varargin"),i=s?r.length-1:r.length,n=r.slice(0,i).filter(t=>{const r=this.parameterName(t);return"<~>"===t.type||!r||!e.has(r)});return{params:r,hasVarargin:s,fixedParamCount:i,positionalParams:n,positionalParamCount:n.length}}static lambdaInputLayout(t){const e=t.length>0&&this.isNamed(t[t.length-1],"varargin");return{hasVarargin:e,fixedParamCount:e?t.length-1:t.length}}static returnLayout(t,e){const r=this.checkedList(t.return.list,AST.isNodeFunctionReturn,"function return"),s=r.map(t=>AST.isNodeIgnoredTarget(t)?"~":t.id),i=s.length>0&&"varargout"===s[s.length-1],n=e??(i?"varargout":void 0),a=void 0===n?-1:s.indexOf(n);return{returnNames:r,hasVarargout:i,variableOutputName:n,fixedReturnCount:a>=0?a:r.length,names:s}}static minimumPositionalCount(t,e){let r=t.length;for(;r>0;){const s=t[r-1],i=this.parameterName(s);if(!i||!e.has(i))break;r--}return r}static validateLambdaInputArity(t,e,r,s){(e&&t<r||!e&&t!==r)&&s("invalid number of arguments.")}static validateFunctionInputArity(t,e,r,s,i,n){(r&&e<i||!r&&(e<i||e>s))&&n(`invalid number of arguments in function ${t.id}`)}static validateFunctionOutputArity(t,e,r,s){!e&&t.length>0&&r>t.length&&AST.throwErrorIfGreaterThanReturnList(t.length,r,s)}static prepareFunctionCall(t,e,r,s){const i=this.inputLayout(t,s.nameValueParameters(t)),n=this.returnLayout(t,s.outputRepeatingName?.(t));let a=s.splitCallArguments(t,e);if(a.rawPositionalCount=a.positional.length,s.expandPositionalArguments){const e=a.positional.flatMap(t=>this.callArgumentRequestsDefault(t)?[t]:s.expandPositionalArguments([t])),r=s.splitCallArguments(t,e),i=new Map(r.named);for(const[t,e]of a.named)i.set(t,e);a={positional:r.positional,rawPositionalCount:a.rawPositionalCount,named:i}}const o=s.inputDefaults(t),l=this.minimumPositionalCount(i.positionalParams,o);return this.validateFunctionInputArity(t,a.positional.length,i.hasVarargin,i.positionalParamCount,l,s.throwEvalError),this.validateFunctionOutputArity(n.returnNames,void 0!==n.variableOutputName,r,s.throwEvalError),{inputLayout:i,returnLayout:n,callArguments:a,inputDefaults:o,minFixedParamCount:l}}static vararginCell(t){return MultiArray.firstRow(this.expressionArgumentValues(t,"varargin argument",t=>{throw new EvalError(t)}),!0)}static emptyVarargoutCell(t,e){return new MultiArray([1,Math.max(t-e,1)],()=>{},!0)}static initializeFixedReturnSlots(t,e){for(const r of t)AST.isNodeIgnoredTarget(r)||"varargout"===r.id||Object.prototype.hasOwnProperty.call(e,r.id)||(e[r.id]={})}static evaluateCallArguments(t,e,r,s,i=0,n=!1){return t.map((t,a)=>(AST.isNodeBase(t)&&(t.parent=e,t.index=i+a),n&&this.callArgumentRequestsDefault(t)?this.defaultArgumentMarker:this.evaluatedArgument(r(t),`argument ${i+a+1}`,s)))}static evaluateNameValueArguments(t,e,r,s){const i=new Map;for(const[n,a]of t)AST.isNodeBase(a)&&(a.parent=e),i.set(n,this.evaluatedArgument(r(a),n,s));return i}static bindLambdaInputs(t,e,r,s,i,n,a,o){for(let s=0;s<i;s++){const i=t[s],l=this.requireEvaluatedArgument(this.evaluateCallArguments([e[s]],r,a,o,s)[0],`argument ${s+1}`,o);this.isIdentifier(i)&&n(i.id,l)}s&&n("varargin",this.vararginCell(this.evaluateCallArguments(e.slice(i),r,a,o,i)))}static bindPositionalInputs(t,e,r,s,i,n,a){for(let o=0;o<e.positionalParamCount;o++){const l=e.positionalParams[o],c=this.parameterName(l);if(o<r.length){const e=r[o];if(!c)continue;if(this.isDefaultArgumentMarker(e)){const e=s.get(c);e||a(`invalid use of default argument marker ':' in function ${t.id}`),i(c,this.evaluatedArgument(n(c,e),c,a))}else i(c,e)}else{c||a(`invalid number of arguments in function ${t.id}`);const e=s.get(c);e||a(`invalid number of arguments in function ${t.id}`),i(c,this.evaluatedArgument(n(c,e),c,a))}}r.slice(e.positionalParamCount).some(t=>this.isDefaultArgumentMarker(t))&&a(`invalid use of default argument marker ':' in function ${t.id}`)}static bindVarargin(t,e,r){t.hasVarargin&&r("varargin",this.vararginCell(e.slice(t.positionalParamCount)))}static bindVarargout(t,e,r){t.variableOutputName&&r(t.variableOutputName,this.emptyVarargoutCell(e,t.fixedReturnCount))}static variableReturnKey(t,e){return`${t.variableOutputName??"varargout"}${e}`}static ignoredReturnValue(){return MultiArray.emptyArray()}static createReturnList(t,e,r,s=[]){const{fixedReturnCount:i,names:n,variableOutputName:a}=t,o=void 0!==a,l=t=>s[t]??!0;return 0===n.length?AST.nodeVoid():AST.nodeReturnList((e,s)=>{if(o){if(s<i){if("~"===n[s])return this.ignoredReturnValue();const t=e[n[s]];return void 0===t&&r(`Undefined return value '${n[s]}'`),t}const a=s-i,o=e[this.variableReturnKey(t,a)];return void 0===o&&AST.throwErrorIfGreaterThanReturnList(s,s+1,r),o}const a=n[s];if("~"===a)return this.ignoredReturnValue();const l=e[a];return void 0===l&&r(`Undefined return value '${a}'`),l},s=>{!o&&s>n.length&&AST.throwErrorIfGreaterThanReturnList(n.length,s,r);const c={length:s};if(o){for(let t=0;t<Math.min(s,i);t++){if(!l(t))continue;const s=n[t];if("~"===s)continue;const i=e[s];i&&i.node||r(`Undefined return variable '${s}'`),c[s]=this.returnExpression(i.node,s,r)}const o=e[a];o&&o.node instanceof MultiArray&&o.node.isCell||r(`Undefined return variable '${a}'`);const u=MultiArray.linearize(o.node);for(let e=i;e<s;e++){if(!l(e))continue;const s=u[e-i];void 0===s&&AST.throwErrorIfGreaterThanReturnList(e,e+1,r),c[this.variableReturnKey(t,e-i)]=this.returnExpression(s,`${a}{${e-i+1}}`,r)}return c}for(let t=0;t<s;t++){if(!l(t))continue;const s=n[t];if("~"===s)continue;const i=e[s];i&&i.node||r(`Undefined return variable '${s}'`),c[s]=this.returnExpression(i.node,s,r)}return c})}}const src_FunctionCall=null;class FunctionStack{static currentFunctionDefinition(t){return this.currentFunctionFrame(t)?.func?.node}static currentFunctionFrame(t){for(let e=t.length-1;e>=0;e--)if("FCNDEF"===t[e].func?.type)return t[e]}static currentFunctionCountFrame(t){for(let e=t.length-1;e>=0;e--){const r=t[e].func?.type;if("FCNDEF"===r||"LAMBDA"===r)return t[e]}}static currentFunctionName(t){return this.currentFunctionFrame(t)?.name??""}static currentArgumentCount(t){return this.currentFunctionCountFrame(t)?.nargin}static currentOutputCount(t){return this.currentFunctionCountFrame(t)?.nargout}static callerWorkspace(t,e,r,s=!1,i=!1){const n=this.currentFunctionCountFrame(t);if("LAMBDA"===n?.func?.type&&!s&&i)return this.anonymousCallerWorkspace(n,e,r);const a=this.skipBuiltInFrames(n?.parentFrame),o=a?.scope??e;return!s&&i?this.variableOnlyCallerWorkspace(o,r):o}static anonymousCallerWorkspace(t,e,r){const s=this.skipBuiltInFrames(t.parentFrame),i=r(),n=new Map;return this.copyVisibleVariablesWithSources(i,s?.scope??e,n),this.copyVisibleVariablesWithSources(i,t.scope,n),i.rejectDynamicNameCreation=t.scope.rejectDynamicNameCreation,i.staticWorkspaceNameSet=t.scope.staticWorkspaceNameSet?new Set(t.scope.staticWorkspaceNameSet):void 0,i.globalDeclarationTarget=t.scope,this.attachVariableOnlyWriteThrough(i,e=>n.get(e)??t.scope),i}static variableOnlyCallerWorkspace(t,e){const r=e();return FunctionWorkspace.copyVisibleScopeEntries(r,t,!1),r.rejectDynamicNameCreation=t.rejectDynamicNameCreation,r.staticWorkspaceNameSet=t.staticWorkspaceNameSet?new Set(t.staticWorkspaceNameSet):void 0,r.globalDeclarationTarget=t,this.attachVariableOnlyWriteThrough(r,()=>t),r}static copyVisibleVariablesWithSources(t,e,r){const s=[];let i=e;for(;i&&(s.push(i),i.resolveParentNames);)i=i.parent;for(let e=s.length-1;e>=0;e--){const i=s[e];Object.assign(t.nameTable,i.nameTable);for(const t of Object.keys(i.nameTable))r.set(t,i)}}static attachVariableOnlyWriteThrough(t,e){const r=(e,r)=>{const s=e.rejectDynamicNameCreation;t.rejectDynamicNameCreation&&(e.rejectDynamicNameCreation=!0);try{return r()}finally{e.rejectDynamicNameCreation=s}};t.defineName=(s,i,n)=>{const a=e(s),o=r(a,()=>a.defineName(s,i,n));return t.nameTable[s]=o,o},t.assignName=(s,i,n)=>{const a=e(s),o=a.assignName?.bind(a),l=r(a,()=>o?o(s,i,n):a.defineName(s,i,n));return t.nameTable[s]=l,l},t.removeName=r=>{const s=e(r);s.removeName?s.removeName(r):delete s.nameTable[r],delete t.nameTable[r]},t.clearName=r=>{const s=e(r);s.clearName?s.clearName(r):s.removeName?s.removeName(r):delete s.nameTable[r],delete t.nameTable[r]}}static skipBuiltInFrames(t){for(;"BUILTIN"===t?.func?.type;)t=t.parentFrame;return t}}const src_FunctionStack=null;class ReturnSignal extends Error{constructor(){super("return"),this.name="ReturnSignal"}}class BreakSignal extends Error{constructor(){super("break"),this.name="BreakSignal"}}class ContinueSignal extends Error{constructor(){super("continue"),this.name="ContinueSignal"}}class Context{interpreter;globalScope;builtInFunctionTable;allowForwardReference;globalNameSet;globalInitializedNameSet;forwardReferenceTargetStack;requestedOutputCountStack;requestedOutputMaskStack;commaListExpansionStack;classAccessStack;static bareZeroArgumentBuiltins=new Set(["lastwarn","lasterr","lasterror","localfunctions","mfilename"]);static operatorFunctionNames=new Set(["uplus","uminus","not","transpose","ctranspose","minus","mod","rem","rdivide","mrdivide","ldivide","mldivide","power","mpower","lt","le","ge","gt","eq","ne","plus","times","mtimes","and","or","xor","colon","cat","horzcat","vertcat"]);static classBuiltinMethodFunctionNames=new Set(["size","numel","length","ndims","rows","columns","isempty","isequal","double","char","logical","cell","cellstr","num2cell","cell2mat","cell2struct","mat2cell","isscalar","ismatrix","isvector","isrow","iscolumn","iscell","iscellstr","isstruct","struct","fieldnames","properties","methods","events","enumeration","superclasses","isfield","isprop","ismethod","numfields","getfield","setfield","rmfield","orderfields","struct2cell","ischar","isstring","issparse","full","sparse","spalloc","nnz","nzmax","nonzeros","isnan","isinf","isfinite","isfloat","isinteger","isnumeric","islogical","isreal","isobject","isvalid","find","ind2sub","sub2ind","sort","all","any","sum","prod","sumsq","cumsum","cumprod","min","max","cummin","cummax","mean","var","std","linspace","logspace","meshgrid","ndgrid","zeros","ones","rand","randi","repmat","reshape","squeeze","flip","fliplr","flipud","rot90","permute","ipermute","circshift","shiftdim","norm"]);callStack=[];loadContext(t,e){t?this.globalScope=t:(this.globalScope=Scope.create(),this.globalScope.nameTable=Object.create(null),this.globalScope.functionTable=Object.create(null),this.globalScope.undefinedReferenceTable=Object.create(null)),this.globalNameSet=new Set,this.globalInitializedNameSet=new Set,this.callStack=e??[new CallFrame(this.globalScope)]}constructor(t,e,r,s=Object.create(null),i=!0,n=new Set,a=new Set,o=[],l=[],c=[],u=[],h=[]){this.interpreter=t,this.globalScope=e,this.builtInFunctionTable=s,this.allowForwardReference=i,this.globalNameSet=n,this.globalInitializedNameSet=a,this.forwardReferenceTargetStack=o,this.requestedOutputCountStack=l,this.requestedOutputMaskStack=c,this.commaListExpansionStack=u,this.classAccessStack=h,this.loadContext(e,r)}static create=(t,e,r)=>new Context(t,e,r);nativeNameTable;nativeNameSet;aliasNameTable;aliasNameFunction=t=>t;setAliasNameTable(t){if(t){this.aliasNameTable=Object.create(null);for(const[e,r]of Object.entries(t))this.aliasNameTable[e]=r;this.aliasNameFunction=t=>{for(const[e,r]of Object.entries(this.aliasNameTable))if(r.test(t))return e;return t}}else this.aliasNameFunction=t=>t}get builtInFunctionList(){return Object.keys(this.builtInFunctionTable)}get currentFrame(){return this.callStack[this.callStack.length-1]}get currentScope(){return this.currentFrame.scope}resolveName(t){return this.currentScope.resolveName(t)}resolveSymbol(t,e=this.currentScope,r={}){const s=r.variables??!0,i=r.classes??!0,n=r.loadClasses??!0,a=r.loadFunctions??!0,o=r.functions??!0,l=r.imports??!0,c=this.aliasNameFunction(t),u=r=>{const s=this.aliasNameFunction(r);if(i){const r=this.resolveClassDefinitionByExactName(s,e,!1);if(r)return{kind:"class",name:t,resolvedName:s,source:"import",classDefinition:r}}if(o){const r=e.resolveFunction(s);if(r)return{kind:"BUILTIN"===r.type?"builtin":"function",name:t,resolvedName:s,source:"BUILTIN"===r.type?"builtin":"import",functionDefinition:r};if(a){const r=this.interpreter?.loadFunctionDefinition(s,e);if(r)return{kind:"function",name:t,resolvedName:s,source:"import",functionDefinition:r}}}if(i&&n){const r=this.resolveClassDefinitionByExactName(s,e,!0);if(r)return{kind:"class",name:t,resolvedName:s,source:"import",classDefinition:r}}};if(s){const r=e.resolveName(c);if(r&&void 0!==r.node&&!ClassDefinition.isInstanceOf(r.node))return{kind:"variable",name:t,resolvedName:c,source:"local",entry:r}}if(i){const r=this.resolveClassDefinitionByExactName(c,e,!1);if(r)return{kind:"class",name:t,resolvedName:c,source:"local",classDefinition:r}}if(o){const r=e.resolveFunction(c);if(r)return{kind:"BUILTIN"===r.type?"builtin":"function",name:t,resolvedName:c,source:"BUILTIN"===r.type?"builtin":"local",functionDefinition:r};if(a){const r=this.interpreter?.loadFunctionDefinition(c,e);if(r)return{kind:"function",name:t,resolvedName:c,source:"local",functionDefinition:r}}}if(i&&n){const r=this.resolveClassDefinitionByExactName(c,e,!0);if(r)return{kind:"class",name:t,resolvedName:c,source:"local",classDefinition:r}}if(l&&!c.includes(".")){const t=[...new Map(e.importedNameCandidates(c).map(u).filter(t=>void 0!==t).map(t=>[t.resolvedName,t])).values()];if(t.length>1&&this.throwEvalError(`imported name '${c}' is ambiguous: ${t.map(t=>t.resolvedName).join(", ")}.`),1===t.length)return t[0]}if(o){const e=this.builtInFunctionTable[c];if(e)return{kind:"builtin",name:t,resolvedName:c,source:"builtin",functionDefinition:e}}}resolveFunction(t,e=this.currentScope){return this.resolveSymbol(t,e,{variables:!1,classes:!1})?.functionDefinition}resolveClassDefinition(t,e=this.currentScope){return this.resolveSymbol(t,e,{variables:!1,functions:!1})?.classDefinition}resolveClassDefinitionByExactName(t,e=this.currentScope,r=!0){const s=e.resolveName(t);if(s&&ClassDefinition.isInstanceOf(s.node))return s.node;if(!r)return;const i=this.interpreter?.loadClassDefinition(t,e);if(!i)return;const n=this.globalScope??e;return this.defineClassDefinition(i,n),i}defineImport(t,e=this.currentScope){const r=t.trim(),s=r.endsWith(".*")?r.slice(0,-2):void 0;r&&(s||r.includes("."))&&""!==s||this.throwSyntaxError("import: imported name must be qualified."),e.defineImport(t)}assignName(t,e){this.currentScope.defineName(t,e)}resolvedIdentifierExpression(t,e,r){const s=expressionValue(t.node,e,"Identifier value",t=>this.throwEvalError(t));return s.parent=r,s}unresolvedCallTargetExpression(t){return AST.isNodeIdentifier(t)||this.throwEvalError("invalid unresolved call target."),t}assignFunction(t,e){this.currentScope.defineFunction(t,e)}defineClassDefinition(t,e=this.currentScope){return e.defineName(t.name,t),t}createChildScope(t=this.currentScope){return Scope.create(t)}pushForwardReferenceTargets(t){this.forwardReferenceTargetStack.push(t)}popForwardReferenceTargets(){return this.forwardReferenceTargetStack.pop()}pushRequestedOutputCount(t){this.requestedOutputCountStack.push(t)}popRequestedOutputCount(){return this.requestedOutputCountStack.pop()}pushRequestedOutputMask(t){this.requestedOutputMaskStack.push({depth:this.requestedOutputCountStack.length,mask:t.slice()})}popRequestedOutputMask(){return this.requestedOutputMaskStack.pop()?.mask}get requestedOutputCount(){return this.requestedOutputCountStack[this.requestedOutputCountStack.length-1]??1}requestedOutputMask(t=this.requestedOutputCount){const e=this.requestedOutputMaskStack[this.requestedOutputMaskStack.length-1],r=e?.depth===this.requestedOutputCountStack.length?e.mask:void 0;return Array.from({length:t},(t,e)=>r?.[e]??!0)}pushCommaListExpansion(t=!0){this.commaListExpansionStack.push(t)}popCommaListExpansion(){return this.commaListExpansionStack.pop()}get commaListExpansionEnabled(){return this.commaListExpansionStack[this.commaListExpansionStack.length-1]??!1}canAccessClassMember(t,e="public"){if("public"===e)return!0;if("private"===e)return this.classAccessStack.includes(t);if("protected"===e)return this.classAccessStack.some(e=>e===t||e.isSubclassOf(t));const r=e.startsWith("{")&&e.endsWith("}")?e.slice(1,-1).split(","):[e];return r.every(t=>t.startsWith("?"))?r.some(t=>{const e=t.slice(1);return this.classAccessStack.some(t=>t.name===e||t.isSubclassOfName(e))}):this.classAccessStack.includes(t)}currentClassAccessName(){const t=this.classAccessStack[this.classAccessStack.length-1]?.name;if(t)return t;for(let t=this.callStack.length-1;t>=0;t--){const e=this.callStack[t].func?.node?.className;if(e)return e}return""}withClassAccess(t,e){this.classAccessStack.push(t);try{return e()}finally{this.classAccessStack.pop()}}get currentForwardReferenceTargets(){return this.forwardReferenceTargetStack[this.forwardReferenceTargetStack.length-1]??[]}getUndefinedReferenceChain(t,e){const r=[t],s=new Set(r);let i=t;for(;;){const t=this.getNextUndefinedReference(i,e);if(!t)return r;if(r.push(t),s.has(t))return r;s.add(t),i=t}}getNextUndefinedReference(t,e){const r=e.resolveName(t);if(r)return this.findPendingIdentifier(r.node,e,r.undefinedReference)??r.undefinedReference}findPendingIdentifier(t,e,r,s=new WeakSet){if(!t||"object"!=typeof t)return;if(s.has(t))return;s.add(t);const i=t;if(AST.isNodeIdentifier(t)){const s=e.resolveName(t.id);if(s?.undefinedReference||!s&&t.id===r)return t.id}for(const t of Object.keys(i)){if("parent"===t||"start"===t||"stop"===t)continue;const n=i[t];if(Array.isArray(n))for(const t of n){const i=this.findPendingIdentifier(t,e,r,s);if(i)return i}else{const t=this.findPendingIdentifier(n,e,r,s);if(t)return t}}}throwIfCircularReference(t,e){const r=this.getUndefinedReferenceChain(t,e),s=r[r.length-1],i=r.slice(0,-1).indexOf(s);i>=0&&this.throwCircularReferenceError(r.slice(i));const n=this.currentForwardReferenceTargets.find(t=>r.includes(t));n&&this.throwCircularReferenceError([...r.slice(0,r.indexOf(n)+1),t])}resolveCallable(t){if(FunctionHandle.isInstanceOf(t)){if(t.id){const e=t.closure??this.currentScope,r=this.resolveSymbol(t.id,e,{variables:!1,classes:!1}),s=r?.functionDefinition;if(t.disallowNestedResolution&&"FCNDEF"===s?.type&&s.attributes?.nested&&this.throwReferenceError(`'${t.id}' undefined.`),s)return Callables.fromFunctionNode(s);const i=this.interpreter?.resolveStaticMethod(t.id,e);if(i)return Callables.staticMethod(i);s||this.throwReferenceError(`'${t.id}' undefined.`)}if(FunctionHandle.isAnonymous(t))return Callables.lambda(t)}}resolveIdentifier(t,e){const r=t.id,s=this.resolveSymbol(r,e,{classes:!1,functions:!1,imports:!1});if("variable"===s?.kind){const i=s.entry;return this.allowForwardReference&&i.undefinedReference&&(this.throwIfCircularReference(r,e),this.throwUndefinedReferenceError(i.undefinedReference)),this.resolvedIdentifierExpression(i,r,t)}if("nargin"===r&&!AST.isNodeIndexExpr(t.parent))return this.currentFunctionArgumentCount(r);if("nargout"===r&&!AST.isNodeIndexExpr(t.parent))return this.currentFunctionOutputCount(r);if("meta"===r)return new Structure({class:new Structure({fromName:FunctionHandle.create("__meta_class_fromName")})});const i=this.resolveSymbol(r,e,{variables:!1});switch(i?.kind){case"variable":{const s=i.entry;return this.allowForwardReference&&s.undefinedReference&&(this.throwIfCircularReference(r,e),this.throwUndefinedReferenceError(s.undefinedReference)),this.resolvedIdentifierExpression(s,r,t)}case"class":return i.classDefinition.parent=t,i.classDefinition;case"function":case"builtin":if(AST.isNodeIndexExpr(t.parent)){const e=FunctionHandle.create(i.resolvedName);return e.parent=t,e}if("builtin"===i.kind&&Context.bareZeroArgumentBuiltins.has(r))return this.callCallable(Callables.builtin(i.functionDefinition),[],t);AST.throwInvalidCallError(r,!0,t=>this.throwSyntaxError(t))}const n=AST.isNodeIndexExpr(t.parent)?this.interpreter?.resolveStaticMethod(r,e):void 0;return n?(n.parent=t,n):AST.isNodeIndexExpr(t.parent)?this.unresolvedCallTargetExpression(t):void this.throwUndefinedReferenceError(r)}expandCommaSeparatedList(t){if(!AST.isNodeReturnList(t)||!t.commaSeparated)return[this.reducedCommaListScalar(t)];const e=t.returnListLength??t.handler(0).length,r=t.handler(e),s=[];for(let i=0;i<e;i++)s.push(t.selector(r,i));return s}reducedCommaListScalar(t){return AST.reduceToFirstIfReturnList(t)}evaluateCommaListExpression(t){this.pushRequestedOutputCount(1),this.pushCommaListExpansion();try{return this.expandCommaSeparatedList(this.rawEvaluationResult(t,this.currentScope))}finally{this.popCommaListExpansion(),this.popRequestedOutputCount()}}expandCommaListArguments(t){return t.flatMap(t=>this.expressionValues(this.evaluateCommaListExpression(t),"arg"))}evaluateExpandedArgument(t,e="arg"){return this.expressionValues(this.evaluateCommaListExpression(t),e)}evaluateArgs(t,e,r){return t.flatMap((t,e)=>{if("all"===r)return this.evaluateExpandedArgument(t);const s=r;return s.length>0&&e<s.length&&!s[e]?[t]:this.evaluateExpandedArgument(t)})}evaluateBuiltInArgs(t,e,r){if("feval"===t.id||"builtin"===t.id)return e.length>0?[this.evaluateArgs([e[0]],r,"all")[0],...e.slice(1)]:[];if("set"!==this.aliasNameFunction(t.id))return this.evaluateArgs(e,r,t.ev);const s=[];return e.forEach((e,i)=>{if(i>0&&AST.isNodeBinaryOperation(e)&&"="===e.type&&AST.isNodeIdentifier(e.left))return s.push(new CharString(e.left.id)),void s.push(...this.evaluateArgs([e.right],r,t.ev));s.push(...this.evaluateArgs([e],r,t.ev))}),s}throwEvalError(t){throw new InterpreterError_EvalError(t,this.getStackTrace())}throwReferenceError(t){throw new InterpreterError_ReferenceError(t,this.getStackTrace())}throwUndefinedReferenceError(t){throw new UndefinedReferenceError(t,this.getStackTrace())}throwCircularReferenceError(t){throw new CircularReferenceError(t,this.getStackTrace())}throwSyntaxError(t){throw new InterpreterError_SyntaxError(t,this.getStackTrace())}getCurrentFunctionDefinition(){return FunctionStack.currentFunctionDefinition(this.callStack)}isInsideUserFunction(){return void 0!==this.getCurrentFunctionDefinition()}currentFunctionSourceName(){for(let t=this.callStack.length-1;t>=0;t--){const e=this.callStack[t].func?.node,r=e&&"object"==typeof e&&"sourceName"in e?e.sourceName:void 0;if(r)return"string"==typeof r?r:""}return""}getCurrentFunctionCountFrame(){return FunctionStack.currentFunctionCountFrame(this.callStack)}getCallerWorkspace(t=!1,e=!1){return FunctionStack.callerWorkspace(this.callStack,this.globalScope,t=>Scope.create(t),t,e)}resolveWorkspace(t,e=!1,r=!1){return FunctionWorkspace.resolveWorkspace(t,this.globalScope,this.getCallerWorkspace(e,r),t=>this.throwSyntaxError(t))}currentFunctionArgumentCount(t){const e=FunctionStack.currentArgumentCount(this.callStack);return void 0===e&&this.throwEvalError(`${t} is only valid inside a function.`),Complex.create(e)}currentFunctionArgumentCountOrZero(){return Complex.create(FunctionStack.currentArgumentCount(this.callStack)??0)}currentFunctionOutputCount(t){const e=FunctionStack.currentOutputCount(this.callStack);return void 0===e&&this.throwEvalError(`${t} is only valid inside a function.`),Complex.create(e)}currentFunctionOutputCountOrZero(){return Complex.create(FunctionStack.currentOutputCount(this.callStack)??0)}currentFunctionOutputIsRequested(t){const e=this.getCurrentFunctionCountFrame();e||this.throwEvalError("isargout is only valid inside a function.");const r=t=>{Complex.isInstanceOf(t)&&Complex.imagIsZero(t)||this.throwEvalError("isargout: argument must be a positive integer.");const r=Complex.realToNumber(t);return(!Number.isInteger(r)||r<1)&&this.throwEvalError("isargout: argument must be a positive integer."),r<=e.nargout&&(e.outputMask?.[r-1]??1)?Complex.true():Complex.false()};if(MultiArray.isInstanceOf(t)){const e=new MultiArray(t.dimension,void 0,!1);for(let s=0;s<MultiArray.linearLength(t);s++){const[i,n]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],s);e.array[i][n]=r(t.array[i][n])}return MultiArray.setType(e),e}return r(t)}currentFunctionInputName(t,e=!0,r){const s=this.getCurrentFunctionCountFrame();return s||this.throwEvalError("inputname is only valid inside a function."),FunctionWorkspace.inputName(s.inputArgs,t,t=>this.throwSyntaxError(t),e,r)}currentFunctionName(){return FunctionStack.currentFunctionName(this.callStack)}declarePersistent(t,e,r){const s=this.getCurrentFunctionDefinition();s||this.throwSyntaxError("persistent declaration is only valid inside a function."),FunctionWorkspace.declarePersistent(t,e,s,r)}loadPersistentVariables(t,e){FunctionWorkspace.loadPersistentVariables(t,e)}storePersistentVariables(t,e){FunctionWorkspace.storePersistentVariables(t,e)}declareGlobal(t,e,r){const s=r.globalDeclarationTarget??r;FunctionWorkspace.declareGlobal(t,e,this.globalNameSet,this.globalScope.nameTable,s.nameTable,this.globalInitializedNameSet)}clearGlobalVariables(t){FunctionWorkspace.clearGlobalVariables(this.globalNameSet,this.globalScope,this.callStack.map(t=>t.scope),t)}clearClassDefinitions(){const t=[this.globalScope,...this.callStack.map(t=>t.scope)].filter(t=>void 0!==t);for(const e of t)for(const t of Object.keys(e.nameTable))ClassDefinition.isInstanceOf(e.nameTable[t]?.node)&&e.removeName(t)}clearCurrentVariables(t){const e=this.nativeNameSet instanceof Set?this.nativeNameSet:new Set,r=t||Object.keys(this.currentScope.nameTable);for(const t of r){const r=this.currentScope.nameTable[t];e.has(t)||ClassDefinition.isInstanceOf(r?.node)||this.currentScope.removeName(t)}}resolveCallSite(t){let e=t;for(;e;){if(e.start)return e;e=e.parent}}static debugIdentifier(t){const e=t?.id;return"string"==typeof e?e:void 0}builtInInputSignatures(t){return FunctionSignature.inputSignatures(t)}builtInOutputSignatures(t){return FunctionSignature.outputSignatures(t)}builtInDeclaredArity(t){return FunctionSignature.declaredArity(t)}validateBuiltInInputArity(t,e){AST.throwInvalidCallError(t.id,!FunctionSignature.inputArityIsValid(t,e),t=>this.throwSyntaxError(t))}validateBuiltInInputParameters(t,e){AST.throwInvalidCallError(t.id,!FunctionSignature.inputParametersAreValid(t,e),t=>this.throwSyntaxError(t))}valueDimensions(t){return RuntimeValue.dimensions(t)}sizeReturnList(t){const e=this.valueDimensions(t),r=this.requestedOutputMask(Math.max(this.requestedOutputCount,e.length)),s=t=>r[t]??!0;return AST.nodeReturnList((t,e)=>{const r=t[`dim${e}`];return void 0===r&&AST.throwErrorIfGreaterThanReturnList(t.length,e+1,t=>this.throwEvalError(t)),r},t=>{const r=e.slice();MultiArray.appendSingletonTail(r,Math.max(t,2));const i={length:t};for(let e=0;e<t;e++){if(!s(e))continue;const n=e===t-1?r.slice(e).reduce((t,e)=>t*e,1):r[e];i[`dim${e}`]=Complex.create(n)}return i})}callClassBuiltinMethod(t,e,r){const s=this.aliasNameFunction(t.id);if(AST.isNodeIdentifier(r)&&"builtin"===r.id)return;if(!Context.classBuiltinMethodFunctionNames.has(s)||0===e.length)return;const i=e[0];if(!ClassInstance.isInstanceOf(i))return;const n=i.classDefinition.findMethod(s,t=>!t.isStatic);if(!n)return;this.canAccessClassMember(n.classDefinition,n.access)||this.throwEvalError(`method '${s}' has ${n.access} access for class ${i.classDefinition.name}.`);const a=e.slice(1).map((t,e)=>expressionValue(t,`argument ${e+2}`,"Argument value",t=>this.throwEvalError(t)));return this.callClassInstanceMethod(i,n,a,r)}callFunctionDefinition(t,e,r,s){const i=t.node,{inputLayout:n,returnLayout:a,callArguments:o,inputDefaults:l}=FunctionCall.prepareFunctionCall(i,e,s,{nameValueParameters:t=>this.interpreter.getFunctionNameValueParameters(t),splitCallArguments:(t,e)=>this.interpreter.splitFunctionCallNameValueArguments(t,e),expandPositionalArguments:t=>this.expandCommaListArguments(t),inputDefaults:t=>this.interpreter.getFunctionInputArgumentDefaults(t),outputRepeatingName:t=>this.interpreter.getFunctionOutputRepeatingName(t),throwEvalError:t=>this.throwEvalError(t)}),c=Scope.create(i.definingScope??this.currentScope);c.assignExistingParentNames=Boolean(i.attributes?.nested),this.interpreter.configureFunctionWorkspace(i,c),FunctionCall.initializeFixedReturnSlots(a.returnNames,c.nameTable);const u=t=>{this.pushRequestedOutputCount(1);try{return this.evaluatedExpressionValue(t,this.currentScope,"argument")}finally{this.popRequestedOutputCount()}},h=FunctionCall.evaluateCallArguments(o.positional,r,u,t=>this.throwEvalError(t),0,!0),d=FunctionCall.evaluateNameValueArguments(o.named,r,u,t=>this.throwEvalError(t));FunctionCall.bindPositionalInputs(i,n,h,l,(t,e)=>c.defineName(t,e),(t,e)=>{this.pushRequestedOutputCount(1);try{return this.evaluatedExpressionValue(e,c,"default argument")}finally{this.popRequestedOutputCount()}},t=>this.throwEvalError(t)),this.interpreter.bindFunctionNameValueArguments(i,c,d),FunctionCall.bindVarargin(n,h,(t,e)=>c.defineName(t,e)),FunctionCall.bindVarargout(a,s,(t,e)=>c.defineName(t,e));const m=o.positional.length+e.length-(o.rawPositionalCount??o.positional.length);let p;this.pushCallStackFrame(new CallFrame(c,t,this.resolveCallSite(r),i.id,m,s,e,void 0,this.requestedOutputMask(s))),this.loadPersistentVariables(i,c);try{this.interpreter.applyScopedImports(i.statements,c),this.interpreter.registerNestedFunctions(i,c),this.interpreter.validateFunctionInputArguments(i,c),this.interpreter.validateFunctionRepeatingArguments(i,c,FunctionCall.expressionArgumentValues(h.slice(n.positionalParamCount),"repeating argument",t=>this.throwEvalError(t)));try{i.statements.list.length>0&&this.evaluatedExecutionResult(i.statements,c)}catch(t){if(!(t instanceof ReturnSignal))throw t}const t=this.requestedOutputMask(s);this.interpreter.validateFunctionOutputArguments(i,c,s,t),p=FunctionCall.createReturnList(a,c.nameTable,t=>this.throwEvalError(t),t)}finally{this.storePersistentVariables(i,c),this.popCallStackFrame()}return p}instantiateClassDefaults(t){const e=ClassInstance.instantiate(t,t=>{this.pushRequestedOutputCount(1);try{return this.runtimeExpressionValue(this.evaluatedExecutionResult(t,this.currentScope),"property default")}finally{this.popRequestedOutputCount()}});return this.interpreter.validateClassInstancePropertyDefaults(e,this.currentScope),e}constructClassInstance(t,e,r){if(t.isEffectivelyAbstract()){const e=[...t.unresolvedAbstractMethods().map(t=>t.name),...t.unresolvedAbstractProperties().map(t=>t.name)];this.throwEvalError(e.length>0?`cannot instantiate abstract class ${t.name}: missing implementations for ${e.join(", ")}.`:`cannot instantiate abstract class ${t.name}.`)}const s=this.instantiateClassDefaults(t);return this.constructClassInstanceWithInstance(t,s,e,r)}constructSuperclassInstance(t,e,r,s){return t.classDefinition.isSubclassOf(e)||this.throwEvalError(`class ${e.name} is not a superclass of class ${t.classDefinition.name}.`),this.constructClassInstanceWithInstance(e,t,r,s)}constructClassInstanceWithInstance(t,e,r,s){const i=t.findConstructor();if(!i)return r.length>0&&this.throwEvalError(`constructor for class ${t.name} accepts no input arguments.`),e;this.ensureConcreteClassMethod(i);const n=i.node,{inputLayout:a,returnLayout:o,callArguments:l,inputDefaults:c}=FunctionCall.prepareFunctionCall(n,r,1,{nameValueParameters:t=>this.interpreter.getFunctionNameValueParameters(t),splitCallArguments:(t,e)=>this.interpreter.splitFunctionCallNameValueArguments(t,e),expandPositionalArguments:t=>this.expandCommaListArguments(t),inputDefaults:t=>this.interpreter.getFunctionInputArgumentDefaults(t),outputRepeatingName:t=>this.interpreter.getFunctionOutputRepeatingName(t),throwEvalError:t=>this.throwEvalError(t)}),u=Scope.create(n.definingScope??this.currentScope);this.interpreter.configureFunctionWorkspace(n,u),FunctionCall.initializeFixedReturnSlots(o.returnNames,u.nameTable);const h=o.returnNames[0];h&&"<~>"!==h.type&&u.defineName(h.id,e);const d=t=>{this.pushRequestedOutputCount(1);try{return this.evaluatedExpressionValue(t,this.currentScope,"argument")}finally{this.popRequestedOutputCount()}},m=FunctionCall.evaluateCallArguments(l.positional,s,d,t=>this.throwEvalError(t),0,!0),p=FunctionCall.evaluateNameValueArguments(l.named,s,d,t=>this.throwEvalError(t));FunctionCall.bindPositionalInputs(n,a,m,c,(t,e)=>u.defineName(t,e),(t,e)=>{this.pushRequestedOutputCount(1);try{return this.evaluatedExpressionValue(e,u,"default argument")}finally{this.popRequestedOutputCount()}},t=>this.throwEvalError(t)),this.interpreter.bindFunctionNameValueArguments(n,u,p),FunctionCall.bindVarargin(a,m,(t,e)=>u.defineName(t,e)),FunctionCall.bindVarargout(o,1,(t,e)=>u.defineName(t,e));const f=Callables.fromFunctionNode(n),g=l.positional.length+r.length-(l.rawPositionalCount??l.positional.length);this.pushCallStackFrame(new CallFrame(u,f,this.resolveCallSite(s),n.id,g,1,r)),this.loadPersistentVariables(n,u),this.classAccessStack.push(t);try{this.interpreter.applyScopedImports(n.statements,u),this.interpreter.registerNestedFunctions(n,u),this.interpreter.validateFunctionInputArguments(n,u),this.interpreter.validateFunctionRepeatingArguments(n,u,FunctionCall.expressionArgumentValues(m.slice(a.positionalParamCount),"repeating argument",t=>this.throwEvalError(t)));try{n.statements.list.length>0&&this.evaluatedExecutionResult(n.statements,u)}catch(t){if(!(t instanceof ReturnSignal))throw t}this.interpreter.validateFunctionOutputArguments(n,u,1)}finally{this.classAccessStack.pop(),this.storePersistentVariables(n,u),this.popCallStackFrame()}if(!h||"<~>"===h.type)return e;const y=u.nameTable[h.id]?.node;return ClassInstance.isInstanceOf(y)&&(y.classDefinition===t||y.classDefinition.isSubclassOf(t))||this.throwEvalError(`constructor for class ${t.name} must return an object of class ${t.name}.`),y}callClassInstanceMethod(t,e,r,s){e.isAbstract&&this.throwEvalError(`cannot call abstract method '${e.name}' for class ${e.classDefinition.name}.`),this.ensureConcreteClassMethod(e);try{ClassInstance.throwIfDeleted(t)}catch(t){this.throwEvalError(t.message)}return this.withClassAccess(e.classDefinition,()=>this.callFunctionDefinition(Callables.functionDefinition(e.node),[this.classMethodReceiverArgument(t),...r],s,this.requestedOutputCount))}classMethodReceiverArgument(t){return expressionValue(ClassInstance.methodArgument(t),"obj","Argument value",t=>this.throwEvalError(t))}callClassStaticMethod(t,e,r){return t.isAbstract&&this.throwEvalError(`cannot call abstract method '${t.name}' for class ${t.classDefinition.name}.`),this.ensureConcreteClassMethod(t),this.withClassAccess(t.classDefinition,()=>this.callFunctionDefinition(Callables.functionDefinition(t.node),e,r,this.requestedOutputCount))}ensureConcreteClassMethod(t){if(!t.node.attributes?.prototype)return;const e=this.interpreter?.loadClassMethodDefinition(t.classDefinition.name,t.name,this.currentScope);e||this.throwEvalError(`method '${t.name}' for class ${t.classDefinition.name} is declared without a body.`),this.validateLoadedClassMethodSignature(t,e),t.node=e}validateLoadedClassMethodSignature(t,e){e.parameter.list.length===t.node.parameter.list.length&&e.return.list.length===t.node.return.list.length||this.throwEvalError(`method '${t.name}' for class ${t.classDefinition.name} external definition does not match its classdef prototype.`)}callClassEmptyMethod(t,e,r){const s=this.evaluateArgs(e,r,"all"),i=(0===s.length?[Complex.zero(),Complex.zero()]:1===s.length&&MultiArray.isInstanceOf(s[0])?MultiArray.linearize(s[0]):s).map(e=>(Complex.isInstanceOf(e)&&Complex.imagEquals(e,0)&&Complex.realIsInteger(e)&&!Complex.realLessThan(e,0)||this.throwEvalError(`${t.classDefinition.name}.empty dimensions must be nonnegative integer scalars.`),Complex.realToNumber(e)));return 0===i.length&&this.throwEvalError(`${t.classDefinition.name}.empty requires at least one dimension.`),i.some(t=>0===t)||this.throwEvalError(`${t.classDefinition.name}.empty requires at least one zero dimension.`),new MultiArray(i)}expressionValues(t,e){return expressionValues(t,e,"Argument value",t=>this.throwEvalError(t))}expressionValue(t,e){return expressionValue(t,e,"Argument value",t=>this.throwEvalError(t))}runtimeExpressionValue(t,e){return runtimeExpressionValue(t,e,"Argument value",t=>this.throwEvalError(t))}evaluatedExecutionResult(t,e=this.currentScope){return AST.reduceToFirstIfReturnList(this.rawEvaluationResult(t,e))}rawEvaluationResult(t,e=this.currentScope){return this.interpreter.Evaluator(t,e)}evaluatedExpressionValue(t,e,r){return this.expressionValue(this.evaluatedExecutionResult(t,e),r)}returnExpression(t,e){return expressionValue(t,e,"Return value",t=>this.throwEvalError(t))}returnExpressions(t,e){return expressionValues(t,e,"Return value",t=>this.throwEvalError(t))}scalarArrayReturnExpression(t,e){return this.returnExpression(MultiArray.MultiArrayToScalar(t),e)}allVoidArrayResults(t){return MultiArray.linearize(t).every(t=>AST.isNodeBase(t)&&"VOID"===t.type)}reducedClassMethodResult(t,e,r,s){this.pushRequestedOutputCount(1);try{return AST.reduceToFirstIfReturnList(this.callClassInstanceMethod(t,e,r,s))}finally{this.popRequestedOutputCount()}}classInstanceArrayElement(t,e,r,s){const i=t.array[e][r];return ClassInstance.isInstanceOf(i)||this.throwUndefinedReferenceError(s),i}callClassBoundMethodArray(t,e,r){const s=MultiArray.linearize(t);if(s.length>0&&s.every(t=>ClassBoundMethod.isInstanceOf(t)&&"delete"===t.method.name)){for(const t of s)ClassBoundMethod.isInstanceOf(t)||this.throwEvalError("internal error: bound method array contains a non-method value."),this.deleteClassInstance(t.instance,r);return AST.nodeVoid()}const i=new MultiArray(t.dimension);for(let s=0;s<MultiArray.linearLength(t);s++){const[n,a]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],s),o=t.array[n][a];ClassBoundMethod.isInstanceOf(o)||this.throwEvalError("internal error: bound method array contains a non-method value."),i.array[n][a]=this.reducedClassMethodResult(o.instance,o.method,e,r)}if(MultiArray.setType(i),this.allVoidArrayResults(i))return AST.nodeVoid();if(this.requestedOutputCount>1){const t=MultiArray.linearize(i);return this.valueReturnList(t)}return this.scalarArrayReturnExpression(i,"ans")}callClassBoundMethodValue(t,e,r){return ClassBoundMethod.isInstanceOf(t)?this.callClassInstanceMethod(t.instance,t.method,e,r):this.callClassBoundMethodArray(t,e,r)}callFunctionalClassMethodArray(t,e,r,s){if(0!==MultiArray.linearLength(e)&&MultiArray.linearize(e).every(t=>ClassInstance.isInstanceOf(t))||this.throwUndefinedReferenceError(t),"delete"===t){for(let r=0;r<MultiArray.linearLength(e);r++){const[i,n]=MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],r);this.deleteClassInstance(this.classInstanceArrayElement(e,i,n,t),s)}return AST.nodeVoid()}const i=new MultiArray(e.dimension);for(let n=0;n<MultiArray.linearLength(e);n++){const[a,o]=MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],n),l=this.classInstanceArrayElement(e,a,o,t),c=l.classDefinition.findMethod(t,t=>!t.isStatic);c||this.throwEvalError(`unknown method '${t}' for class ${l.classDefinition.name}.`),this.canAccessClassMember(c.classDefinition,c.access)||this.throwEvalError(`method '${t}' has ${c.access} access for class ${l.classDefinition.name}.`),i.array[a][o]=this.reducedClassMethodResult(l,c,r,s)}if(MultiArray.setType(i),this.allVoidArrayResults(i))return AST.nodeVoid();if(this.requestedOutputCount>1){const t=MultiArray.linearize(i);return this.valueReturnList(t)}return this.scalarArrayReturnExpression(i,"ans")}deleteClassInstance(t,e){t.classDefinition.isHandleClass()||this.throwEvalError("delete is only supported for handle class instances.");try{ClassInstance.throwIfDeleted(t)}catch(t){this.throwEvalError(t.message)}const r=t.classDefinition.findMethod("delete",t=>!t.isStatic);return r&&this.callClassInstanceMethod(t,r,[],e),ClassInstance.delete(t),AST.nodeVoid()}evaluateFunctionalClassMethodReceiver(t,e){if(0===t.length)return;const r=t[0];if(!this.interpreter)return r;let s;AST.isNodeBase(r)&&(r.parent=e,r.index=0),this.pushRequestedOutputCount(1);try{s=this.evaluatedExpressionValue(r,this.currentScope,"method receiver")}finally{this.popRequestedOutputCount()}return s}isFunctionalClassMethodReceiver(t){return ClassInstance.isInstanceOf(t)||ClassEventListener.isInstanceOf(t)||MultiArray.isInstanceOf(t)&&MultiArray.linearLength(t)>0&&MultiArray.linearize(t).every(t=>ClassInstance.isInstanceOf(t)||ClassEventListener.isInstanceOf(t))}callFunctionalClassMethod(t,e,r,s=this.evaluateFunctionalClassMethodReceiver(e,r)){if(s||this.throwUndefinedReferenceError(t),"delete"===t&&ClassEventListener.isInstanceOf(s))return ClassEventListener.delete(s),AST.nodeVoid();if("delete"===t&&MultiArray.isInstanceOf(s)&&MultiArray.linearLength(s)>0&&MultiArray.linearize(s).every(ClassEventListener.isInstanceOf)){for(const t of MultiArray.linearize(s))ClassEventListener.isInstanceOf(t)||this.throwEvalError("internal error: event listener array contains a non-listener value."),ClassEventListener.delete(t);return AST.nodeVoid()}if(MultiArray.isInstanceOf(s)&&MultiArray.linearLength(s)>0&&MultiArray.linearize(s).every(t=>ClassInstance.isInstanceOf(t)))return this.callFunctionalClassMethodArray(t,s,e.slice(1),r);if(ClassInstance.isInstanceOf(s)||this.throwUndefinedReferenceError(t),"delete"===t)return this.deleteClassInstance(s,r);const i=s.classDefinition.findMethod(t,t=>!t.isStatic);return i||this.throwEvalError(`unknown method '${t}' for class ${s.classDefinition.name}.`),this.canAccessClassMember(i.classDefinition,i.access)||this.throwEvalError(`method '${t}' has ${i.access} access for class ${s.classDefinition.name}.`),this.callClassInstanceMethod(s,i,e.slice(1),r)}callCallable(t,e,r){const s=this.requestedOutputCount;switch(t.type){case"BUILTIN":{const i=t.node,n=this.aliasNameFunction(i.id),a=this.callCallableFunctionalOperatorOverload(i,e,r);if(a)return a;const o=this.evaluateBuiltInArgs(i,e,r);this.validateBuiltInInputArity(i,o.length),this.pushCallStackFrame(new CallFrame(this.currentScope,t,this.resolveCallSite(r),i.id,o.length,s,e));try{const t=this.callClassBuiltinMethod(i,o,r);return void 0!==t?t:(this.validateBuiltInInputParameters(i,o),i.mapper&&1!==o.length&&this.throwEvalError(`Invalid call to ${n}.`),"size"===n&&1===o.length&&s>1?this.sizeReturnList(o[0]):i.mapper&&1===o.length&&MultiArray.isInstanceOf(o[0])?MultiArray.rawMap(o[0],i.func):i.func(...o))}finally{this.popCallStackFrame()}}case"LAMBDA":{const i=t.node,n=i.parameter,{hasVarargin:a,fixedParamCount:o}=FunctionCall.lambdaInputLayout(n),l=this.expandCommaListArguments(e);FunctionCall.validateLambdaInputArity(l.length,a,o,t=>this.throwEvalError(t));const c=Scope.create(i.closure??this.currentScope);this.configureAnonymousFunctionWorkspace(i,c),FunctionCall.bindLambdaInputs(n,l,r,a,o,(t,e)=>c.defineName(t,e),t=>{this.pushRequestedOutputCount(1);try{return this.evaluatedExpressionValue(t,this.currentScope,"argument")}finally{this.popRequestedOutputCount()}},t=>this.throwEvalError(t)),this.pushCallStackFrame(new CallFrame(c,t,this.resolveCallSite(r),FunctionHandle.toString(i),l.length,s,e,void 0,this.requestedOutputMask(s)));try{return this.rawEvaluationResult(i.expression,c)}finally{this.popCallStackFrame()}}case"FCNDEF":return this.callFunctionDefinition(t,e,r,s);case"STATIC_METHOD":return this.callClassStaticMethod(t.node.method,e,r);default:throw new Error("Invalid callable.")}}configureAnonymousFunctionWorkspace(t,e){const r=new Set;for(const e of t.parameter)AST.isNodeIdentifier(e)&&r.add(e.id);this.collectAnonymousExpressionNames(t.expression,r),e.allowStaticWorkspaceNames(r)}collectAnonymousExpressionNames(t,e,r=new WeakSet){if(!t||"object"!=typeof t||r.has(t))return;r.add(t),AST.isNodeIdentifier(t)&&e.add(t.id);const s=t;for(const[t,i]of Object.entries(s))if("parent"!==t&&"start"!==t&&"stop"!==t)if(Array.isArray(i))for(const t of i)this.collectAnonymousExpressionNames(t,e,r);else this.collectAnonymousExpressionNames(i,e,r)}valueReturnList(t){const e=this.requestedOutputMask(t.length),r=t=>e[t]??!0;return AST.nodeCommaSeparatedReturnList(t.length,(t,e)=>{const r=t[`out${e}`];return void 0===r&&AST.throwErrorIfGreaterThanReturnList(e,e+1,t=>this.throwEvalError(t)),r},e=>{AST.throwErrorIfGreaterThanReturnList(t.length,e,t=>this.throwEvalError(t));const s={length:e};for(let i=0;i<e;i++)r(i)&&(s[`out${i}`]=this.returnExpression(t[i],`out${i+1}`));return s})}callFunctionalOperatorOverload(t,e,r){if("()"===e.delim&&"callable"===t.kind&&Callables.isBuiltin(t.callable)&&Context.operatorFunctionNames.has(t.callable.node.id))return this.interpreter?.callFunctionalOperatorOverload(t.callable.node,r,e)}callCallableFunctionalOperatorOverload(t,e,r){if((!AST.isNodeIdentifier(r)||"builtin"!==r.id)&&Context.operatorFunctionNames.has(t.id))return this.interpreter?.callFunctionalOperatorOverload(t,e,r)}resolveCallDispatch(t,e,r=[]){const s=this.resolveCallable(t);if(!s&&FunctionHandle.isInstanceOf(t))throw new Error("Unexpected non-callable FunctionHandle.");if(s)return{kind:"callable",callable:s,expr:t};if(ClassBoundMethod.isInstanceOf(t))return{kind:"bound-method",expr:t};if(MultiArray.isInstanceOf(t)&&MultiArray.linearLength(t)>0&&MultiArray.linearize(t).every(t=>ClassBoundMethod.isInstanceOf(t)))return{kind:"bound-method-array",expr:t};if(ClassStaticMethod.isInstanceOf(t))return{kind:"static-method",expr:t};if(ClassEmptyMethod.isInstanceOf(t))return{kind:"empty-method",expr:t};if(ClassDefinition.isInstanceOf(t))return{kind:"constructor",expr:t};if(AST.isNodeIdentifier(t)&&"()"===e.delim){const s=this.evaluateFunctionalClassMethodReceiver(r,e);return this.isFunctionalClassMethodReceiver(s)?{kind:"functional-class-method",expr:t,functionalName:t.id,functionalReceiver:s}:{kind:"undefined-function",expr:t,functionalName:t.id}}return{kind:"indexing",expr:t}}applyCallDispatch(t,e,r){switch(t.kind){case"callable":return this.callCallable(t.callable,e,r);case"bound-method":return this.callClassInstanceMethod(t.expr.instance,t.expr.method,e,r);case"bound-method-array":return this.callClassBoundMethodArray(t.expr,e,r);case"static-method":return this.callClassStaticMethod(t.expr.method,e,r);case"empty-method":return this.callClassEmptyMethod(t.expr,e,r);case"constructor":return this.constructClassInstance(t.expr,e,r);case"functional-class-method":return this.callFunctionalClassMethod(t.functionalName,e,r,t.functionalReceiver);case"undefined-function":this.throwUndefinedReferenceError(t.functionalName);case"indexing":return}}applyNativeIndexing(t,e,r){const s=()=>{const t=this.evaluateArgs(e,r,"all").map(t=>this.interpreter?.convertIndexArgument(t,r)??t);return MultiArray.indexArguments(t)};if(CharString.isInstanceOf(t)){"{}"===r.delim&&this.throwEvalError("matrix cannot be indexed with {");const e=MultiArray.characterVectorFromCharString(t),i=s(),n=MultiArray.getElements(e,r.expr.id,[],i);return n.parent=r,MultiArray.charStringFromCharacterVectorResult(n,t.quote)}"{}"!==r.delim||MultiArray.isInstanceOf(t)&&t.isCell||this.throwEvalError("matrix cannot be indexed with {");const i=MultiArray.scalarOrCellToMultiArray(t),n=s(),a=MultiArray.getElements(i,r.expr.id,[],n);if(a.parent=r,i.isCell&&"()"===r.delim)return MultiArray.isInstanceOf(a)||this.throwEvalError("internal error: cell parenthesis indexing did not produce a cell array."),a.isCell=!0,a;if(i.isCell&&"{}"===r.delim&&(this.requestedOutputCount>1||this.commaListExpansionEnabled)){const t=MultiArray.linearize(a);if(t.length>1)return this.valueReturnList(this.returnExpressions(t,"out"))}return MultiArray.MultiArrayToScalar(a)}apply(t,e,r){this.interpreter.debug&&console.log("[APPLY]",{exprType:t?.type,isFunctionHandle:FunctionHandle.isInstanceOf(t),exprId:Context.debugIdentifier(t),delim:r.delim,argsCount:e.length});const s=this.resolveCallDispatch(t,r,e),i=this.callFunctionalOperatorOverload(s,r,e);if(i)return i;this.interpreter.debug&&console.log("[DISPATCH]",s.kind,"callable"===s.kind?s.callable.type:"");return this.applyCallDispatch(s,e,r)||(this.interpreter.debug&&console.warn("[FALLBACK → INDEX]",{exprType:t?.type,exprId:Context.debugIdentifier(t)}),this.applyNativeIndexing(t,e,r))}defineBuiltInFunction(t,e,r=!1,s=[],i){this.builtInFunctionTable[t]={type:"BUILTIN",id:t,mapper:r,ev:s,func:e,definingScope:this.globalScope,signature:i}}assignBuiltInFunctionTable(t){t&&Object.assign(this.builtInFunctionTable,t)}defineUnaryOperatorFunction(t,e){this.builtInFunctionTable[t]={type:"BUILTIN",id:t,mapper:!1,ev:[],func:(...r)=>{if(1===r.length)return e(r[0]);this.throwEvalError(`Invalid call to ${t}. Type 'help ${t}' to see correct usage.`)},definingScope:this.globalScope,signature:{inputs:{arity:1},outputs:{arity:1}}}}defineBinaryOperatorFunction(t,e){this.builtInFunctionTable[t]={type:"BUILTIN",id:t,mapper:!1,ev:[],func:(r,...s)=>{if(1===s.length)return e(r,s[0]);this.throwEvalError(`Invalid call to ${t}. Type 'help ${t}' to see correct usage.`)},definingScope:this.globalScope,signature:{inputs:{arity:2},outputs:{arity:1}}}}defineLeftAssociativeMultipleOperationFunction(t,e){this.builtInFunctionTable[t]={type:"BUILTIN",id:t,mapper:!1,ev:[],func:(r,...s)=>{if(1===s.length)return e(r,s[0]);if(s.length>1){let t=e(r,s[0]);for(let r=1;r<s.length;r++)t=e(t,s[r]);return t}this.throwEvalError(`Invalid call to ${t}. Type 'help ${t}' to see correct usage.`)},definingScope:this.globalScope,signature:{inputs:{arity:-2},outputs:{arity:1}}}}pushCallStackFrame(t){const e=this.currentFrame;t.parentFrame=e,this.callStack.push(t)}popCallStackFrame(){return this.callStack.pop()}getStackTrace(){return this.callStack.filter(t=>void 0!==t.func).slice().reverse()}}const src_Context=null;var Interpreter_Scope,Interpreter_CallFrame,Interpreter_Context,Interpreter_InterpreterError,Interpreter_EvalError,Interpreter_ReferenceError,Interpreter_UndefinedReferenceError,Interpreter_CircularReferenceError,Interpreter_SyntaxError;class Interpreter{static nameLengthMax=63;static keywordNames=MathJSLabLexer.A.keywordNames.filter(t=>"string"==typeof t&&t.length>0).sort();static keywordNameSet=new Set(Interpreter.keywordNames);static publicArgumentValidators=["mustBeNumeric","mustBeFloat","mustBeNumericOrLogical","mustBeText","mustBeTextScalar","mustBeNonzeroLengthText","mustBeValidVariableName","mustBeFile","mustBeFolder","mustBeScalarOrEmpty","mustBeScalar","mustBeMatrix","mustBeSquare","mustBeVector","mustBeRow","mustBeColumn","mustBeNonempty","mustBePositive","mustBeNonnegative","mustBeNegative","mustBeNonpositive","mustBeNonzero","mustBeNonNan","mustBeNonmissing","mustBeNonsparse","mustBeSparse","mustBeInteger","mustBeOdd","mustBeFinite","mustBeReal","mustBeGreaterThan","mustBeGreaterThanOrEqual","mustBeLessThan","mustBeLessThanOrEqual","mustBeInRange","mustBeBetween","mustBeMember","mustBeA","mustBeUnderlyingType"];static response={EXTERNAL:-2,WARNING:-1,OK:0,LEX_ERROR:1,PARSER_ERROR:2,EVAL_ERROR:3};_debug=!1;get debug(){return this._debug}set debug(t){this._debug=t}context;commandWordListTable={clear:{preserveAssignment:!0,func:(...t)=>(this.Clear(...t),AST.nodeVoid())},run:{preserveAssignment:!0,func:(...t)=>(1!==t.length&&this.context.throwEvalError("Invalid call to run."),this.RunScriptFile(t[0],this.context.currentScope))},source:{preserveAssignment:!0,func:(...t)=>{(t.length<1||t.length>2)&&this.context.throwEvalError("Invalid call to source.");const e=2===t.length?this.context.resolveWorkspace(t[1]):this.context.currentScope;return this.RunScriptFile(t[0],e)}},exist:{preserveAssignment:!0,func:(...t)=>((t.length<1||t.length>2)&&AST.throwInvalidCallError("exist",!0,t=>this.context.throwSyntaxError(t)),Complex.create(this.existCode(t[0],t[1])))},which:{preserveAssignment:!0,func:(...t)=>{const e=t.join(" ").match(/^\(([\s\S]*)\)$/);if(e){const t=this.evaluatedExecutionResult(this.Parse(e[1]),this.context.currentScope),r="LIST"===t.type&&1===t.list.length?t.list[0]:t;return this.functions.which.func(r)}return AST.throwInvalidCallError("which",t.length<1,t=>this.context.throwSyntaxError(t)),new CharString(t.map(t=>this.whichResult(t).str).join("\n"))}},who:{func:(...t)=>this.whoResultFromPatterns(t)},whos:{func:(...t)=>this.whosResultFromPatterns(t)},isglobal:{func:(...t)=>(AST.throwInvalidCallError("isglobal",1!==t.length,t=>this.context.throwSyntaxError(t)),this.isGlobalName(t[0])?Complex.true():Complex.false())},dbstack:{func:(...t)=>{const e=t.map(t=>/^\d+$/.test(t)?Complex.create(Number(t)):new CharString(t));return this.dbstackResult(e)}},warning:{func:(...t)=>{const e=this.warningControlResult(t.map(t=>new CharString(t)));return e?"query"===t[0]?.toLowerCase()?e:AST.nodeVoid():this.warningResult(this.diagnosticCommandArguments(t))}},error:{func:(...t)=>this.errorResult(this.diagnosticCommandArguments(t))},__operators__:{func:(...t)=>{const e=Object.keys(this.opTable).sort(),r=new MultiArray([e.length,1],null,!0);return r.array=e.map(t=>[new CharString(t)]),r}},__keywords__:{func:(...t)=>{const e=MathJSLabLexer.A.keywordNames.slice(1).sort(),r=new MultiArray([e.length,1],null,!0);return r.array=e.map(t=>[new CharString(t)]),r}},__builtins__:{func:(...t)=>{const e=new MultiArray([this.context.builtInFunctionList.length,1],null,!0);return e.array=this.context.builtInFunctionList.sort().map(t=>[new CharString(t)]),e}},__list_functions__:{func:(...t)=>MultiArray.emptyArray(!0)},__dump_symtab_info__:{func:(...t)=>MultiArray.emptyArray(!0)}};commandWordListNameSet=new Set;assignmentSensitiveCommandNameSet=new Set;static assignmentOperatorNames=new Set(["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|="]);sourceResolver=TableSourceResolver.create();pathValidationCallbacks={};refreshCommandWordListNames(){this.commandWordListNameSet=new Set(Object.keys(this.commandWordListTable)),this.assignmentSensitiveCommandNameSet=new Set(Object.entries(this.commandWordListTable).filter(([,t])=>t.preserveAssignment).map(([t])=>t))}loadingFunctionNames=new Set;loadingClassNames=new Set;loadingClassMethodNames=new Set;scriptExecutionDepth=0;scriptSourceNameStack=[];_exitStatus;lastError;lastWarning={message:"",identifier:""};globalWarningState="on";warningIdentifierStates=new Map;get exitStatus(){return this._exitStatus}incDecOpFactory(t,e){return(r,s)=>{const i=t?void 0:RuntimeValue.copy(this.evaluatedExpressionValue(r,s,("plus"===e?"increment":"decrement")+" target")),n=AST.nodeOperation("plus"===e?"+=":"-=",this.cloneAssignmentTarget(r),Complex.one());return n.parent=r.parent,this.Evaluator(n,s),t?this.evaluatedExpressionValue(r,s,("plus"===e?"increment":"decrement")+" target"):i}}opTable={"+":MathOperation.plus,"-":MathOperation.minus,".*":MathOperation.times,"*":MathOperation.mtimes,"./":MathOperation.rdivide,"/":MathOperation.mrdivide,".\\":MathOperation.ldivide,"\\":MathOperation.mldivide,".^":MathOperation.power,"^":MathOperation.mpower,"+_":MathOperation.uplus,"-_":MathOperation.uminus,".'":MathOperation.transpose,"'":MathOperation.ctranspose,"<":MathOperation.lt,"<=":MathOperation.le,"==":MathOperation.eq,">=":MathOperation.ge,">":MathOperation.gt,"!=":MathOperation.ne,"&":MathOperation.and,"|":MathOperation.or,"!":MathOperation.not,"&&":MathOperation.mand,"||":MathOperation.mor,"++_":this.incDecOpFactory(!0,"plus"),"--_":this.incDecOpFactory(!0,"minus"),"_++":this.incDecOpFactory(!1,"plus"),"_--":this.incDecOpFactory(!1,"minus")};static binaryOperatorMethodTable={"+":"plus","-":"minus",".*":"times","*":"mtimes","./":"rdivide","/":"mrdivide",".\\":"ldivide","\\":"mldivide",".^":"power","^":"mpower","<":"lt","<=":"le","==":"eq",">=":"ge",">":"gt","!=":"ne","~=":"ne","&":"and","|":"or","&&":"and","||":"or"};static unaryOperatorMethodTable={"+_":"uplus","-_":"uminus","!":"not","~":"not",".'":"transpose","'":"ctranspose"};static precedence=[["min","=","+=","-=","*=","/=","\\="],["||"],["&&"],["|"],["&"],["!=","<",">","<=",">="],["+","-"],[".*","*","./","/",".\\","\\"],["^",".**","**",".'","'"],["!","~","-_","+_"],["preMax","_.^","_.**","_^","_**","__.'","__'","__++"],["max","()","IDENT","ENDRANGE",":","<~>","."]];precedenceTable;nodePrecedence(t){if("number"==typeof t.type)return Complex.isInstanceOf(t)?Complex.precedence(t,this):this.precedenceTable.max;if(AST.isNodeIndexExpr(t)){const e=AST.isNodeIdentifier(t.expr)?this.context.aliasNameFunction(t.expr.id):"";return AST.isNodeIdentifier(t.expr)&&e in this.context.builtInFunctionTable&&(this.context.builtInFunctionTable[e].UnparserMathML||e in MathML.format)?this.precedenceTable.max:this.precedenceTable.preMax}return"RANGE"===t.type?t.start_&&t.stop_?this.precedenceTable.min:this.precedenceTable.max:this.precedenceTable[t.type]||0}functionArityCallable(t,e){let r;if(FunctionHandle.isInstanceOf(e))r=e;else if(CharString.isInstanceOf(e)){const s=e.str.trim();0===s.length&&this.context.throwEvalError(`${t}: function name cannot be empty.`),r=s.startsWith("@")?this.functionHandleFromString(e):this.createResolvedFunctionHandle(s,this.context.currentScope,void 0,!1,!0)}else this.context.throwSyntaxError(`${t}: argument must be a function handle or function name.`);const s=this.context.resolveCallable(r);return s||this.context.throwEvalError(`${t}: invalid function.`),s}functionArgumentArity(t){return FunctionArity.inputArity(t)}functionOutputArity(t){return FunctionArity.outputArity(t)}functionHandleFromString(t,e=!1){const r=this.context.globalScope??this.context.currentScope,s=e?r:this.context.currentScope,i=FunctionLookup.str2func(t.str,t=>{const e=this.evaluatedExecutionResult(this.Parse(t),r);return"LIST"===e.type&&1===e.list.length?e.list[0]:e},t=>this.context.throwEvalError(t));if(!i.id||i.closure)return i;if(!e){const t=this.createResolvedFunctionHandle(i.id,s,i,"importsOnly");if(t.closure)return t}return this.createResolvedFunctionHandle(i.id,r,i,"global")}resolveRuntimeSymbol(t,e=this.context.currentScope,r={}){return this.context.resolveSymbol(t,e,r)}resolveRuntimeFunction(t,e=this.context.currentScope,r={}){return this.resolveRuntimeSymbol(t,e,{...r,variables:!1,classes:!1})}resolveRuntimeClass(t,e=this.context.currentScope,r={}){return this.resolveRuntimeSymbol(t,e,{...r,variables:!1,functions:!1})}createResolvedFunctionHandle(t,e=this.context.currentScope,r,s=!1,i=!1){const n=this.resolveRuntimeFunction(t,e,{loadFunctions:!1}),a=n?.functionDefinition?void 0:this.lookupFunctionSourceResolution(t,e),o=n??a,l=this.context.aliasNameFunction(t),c=t.includes(".")&&o?o.resolvedName:l,u=FunctionHandle.create(c);u.parent=r,u.sourceName=a?.sourceName,u.disallowNestedResolution=i;const h=!t.includes(".")&&this.resolveImportedStaticMethod(t,e);return(!0===s?"FCNDEF"===n?.functionDefinition?.type||"import"===a?.source||h:"importsOnly"===s&&("import"===a?.source||h))&&(u.closure=e.capture(t=>MathOperation.copy(t),this.context.allowForwardReference)),"global"===s&&(u.closure=e),u}localFunctionHandles(){return FunctionIntrospection.localFunctionHandles(this.context.currentFrame,this.context.currentScope)}functionHandleWorkspaceValue(t,e){return this.runtimeExpressionValue(RuntimeValue.copy(t),`workspace ${e}`)}functionHandleWorkspaceInfo(t){if(!t.closure)return MultiArray.emptyArray(!0);const e={};for(const[r,s]of Object.entries(t.closure.nameTable))!s||s.global||void 0===s.node||ClassDefinition.isInstanceOf(s.node)||(e[r]=this.functionHandleWorkspaceValue(s.node,r));const r=MultiArray.scalarToMultiArray(new Structure(e));return r.isCell=!0,r}staticMethodInfo(t,e){const r=this.resolveStaticMethod(t,e);return r?{className:r.classDefinition.name,methodName:r.method.name,sourceName:r.method.node.sourceName}:void 0}dbstackResult(t){const e=FunctionIntrospection.dbstackResult(t,this.context.callStack,t=>this.context.throwSyntaxError(t));if(this.context.requestedOutputCount>1){const t=MultiArray.linearLength(e)>0?1:0;return this.valueReturnList([e,Complex.create(t)])}return e}currentMFilename(){const t=this.currentHandleSourceName();if(!t)return this.context.currentFunctionName();const e=t.replace(/\\/g,"/").split(/[?#]/,1)[0].split("/").pop()?.replace(/\.m$/i,"");return e||this.context.currentFunctionName()}currentMFilenameFullPath(){return this.currentHandleSourceName()||this.context.currentFunctionName()}currentHandleSourceName(){return this.context.currentFunctionSourceName()||this.scriptSourceNameStack[this.scriptSourceNameStack.length-1]}currentHandleClassName(){return this.context.currentClassAccessName()||void 0}exceptionToStruct(t){if(Structure.isInstanceOf(t))return Structure.copy(t);const e=t,r=void 0!==e?.publicStack?this.runtimeExpressionValue(RuntimeValue.copy(e.publicStack),"error stack"):FunctionIntrospection.dbstackResult([],t instanceof InterpreterError&&t.stackFrames?t.stackFrames.slice().reverse():this.context.callStack,t=>this.context.throwSyntaxError(t));return new Structure({message:new CharString(e?.message??String(t)),identifier:new CharString(e?.identifier??""),stack:r})}lastErrorStruct(){return this.lastError?this.exceptionToStruct(this.lastError):this.emptyLastErrorStruct()}emptyLastErrorStruct(){return new Structure({message:new CharString(""),identifier:new CharString(""),stack:MultiArray.emptyArray()})}resetLastError(){this.lastError=void 0}rememberLastError(t){return this.lastError=t,this.exceptionToStruct(t)}normalizeLastErrorStruct(t){const e=t.field,r=void 0===e.message?new CharString(""):e.message,s=void 0===e.identifier?new CharString(""):e.identifier,i=void 0===e.stack?MultiArray.emptyArray():e.stack;return CharString.isInstanceOf(r)&&CharString.isInstanceOf(s)||this.context.throwEvalError("lasterror: error structure message and identifier fields must be strings."),new Structure({message:r,identifier:s,stack:this.runtimeExpressionValue(i,"error stack")})}lastErrorResult(t=[]){const e=this.lastErrorStruct();if(0===t.length)return e;if(CharString.isInstanceOf(t[0])&&"reset"===t[0].str)return this.resetLastError(),e;if(Structure.isInstanceOf(t[0]))return this.lastError=this.normalizeLastErrorStruct(t[0]),e;throw AST.throwInvalidCallError("lasterror"),new Error("unreachable")}lastErrorMessageResult(t=[]){t.length>0&&(this.lastError=this.normalizeLastErrorStruct(new Structure({message:this.charControlArgument(t[0],"error message"),identifier:2===t.length?this.charControlArgument(t[1],"error identifier"):new CharString("")})));const e=this.lastErrorStruct();return this.valueReturnList([this.charControlArgument(e.field.message,"error message"),this.charControlArgument(e.field.identifier,"error identifier")])}setLastWarning(t,e=""){this.lastWarning={message:t,identifier:e}}resetWarningState(){this.setLastWarning(""),this.globalWarningState="on",this.warningIdentifierStates.clear()}warningState(t="all"){return"last"===t?this.warningState(this.lastWarning.identifier||"all"):"all"===t||0===t.length?this.globalWarningState:this.warningIdentifierStates.get(t)??this.globalWarningState}isWarningState(t){return"on"===t||"off"===t||"error"===t}warningStateStruct(t="all"){const e="last"===t?this.lastWarning.identifier||"all":t;return new Structure({identifier:new CharString(e),state:new CharString(this.warningState(e))})}warningStateSnapshot(){const t=[...this.warningIdentifierStates.keys()].sort(),e=[this.warningStateStruct("all"),...t.map(t=>this.warningStateStruct(t))];if(1===e.length)return e[0];const r=new MultiArray([e.length,1]);return e.forEach((t,e)=>{r.array[e][0]=t}),MultiArray.setType(r),r}warningStateStructParts(t){const e=t.field.identifier,r=t.field.state;return CharString.isInstanceOf(e)&&CharString.isInstanceOf(r)&&this.isWarningState(r.str)||this.context.throwEvalError("warning: state structure must contain string identifier and state fields."),{identifier:e.str,state:r.str}}restoreWarningState(t,e){const r="last"===t?this.lastWarning.identifier||"all":t;"all"===r||0===r.length?this.globalWarningState=e:this.warningIdentifierStates.set(r,e)}restoreWarningStateStruct(t){let e;if(Structure.isInstanceOf(t))e=[t];else{if(!MultiArray.isInstanceOf(t)||!Structure.isStructure(t))throw AST.throwInvalidCallError("warning"),new Error("unreachable");e=MultiArray.linearize(t).map(t=>{if(!Structure.isInstanceOf(t))throw AST.throwInvalidCallError("warning"),new Error("unreachable");return t})}for(const t of e){const e=this.warningStateStructParts(t);this.restoreWarningState(e.identifier,e.state)}return AST.nodeVoid()}warningControlResult(t){if(0===t.length)return this.warningStateSnapshot();if(1===t.length&&(Structure.isInstanceOf(t[0])||MultiArray.isInstanceOf(t[0])&&Structure.isStructure(t[0])))return this.restoreWarningStateStruct(t[0]);if(!CharString.isInstanceOf(t[0]))return;const e=t[0].str.toLowerCase();if(!this.isWarningState(e)&&"query"!==e)return;if(t.length>2||2===t.length&&!CharString.isInstanceOf(t[1]))return;const r=2===t.length?t[1].str:"all";if("query"===e)return 1===t.length?this.warningStateSnapshot():this.warningStateStruct(r);const s=this.warningStateStruct(r),i="last"===r?this.lastWarning.identifier||"all":r;return this.restoreWarningState(i,e),s}diagnosticMessageParts(t,e){return DiagnosticMessage.parts(t,e,(t,e)=>this.charControlArgument(t,e),{expressionValue:(t,e)=>this.expressionValue(t,e),unparse:t=>this.Unparse(t),throwEvalError:t=>this.context.throwEvalError(t)})}diagnosticCommandArguments(t){return t.length>1&&t[0].includes(":")?[new CharString(t[0]),new CharString(t.slice(1).join(" "))]:[new CharString(t.join(" "))]}warningResult(t){const e=this.warningControlResult(t);if(e)return e;const{identifier:r,message:s}=this.diagnosticMessageParts(t,"warning");if(this.setLastWarning(s,r),"error"===this.warningState(r))try{this.context.throwEvalError(s)}catch(t){throw r&&(t.identifier=r),t}return this._exitStatus=Interpreter.response.WARNING,AST.nodeVoid()}errorResult(t){if(1===t.length&&Structure.isInstanceOf(t[0])){const e=this.charControlArgument(t[0].field.message??new CharString(""),"error structure message").str,r=this.charControlArgument(t[0].field.identifier??new CharString(""),"error structure identifier").str;if(!e)return AST.nodeVoid();try{this.context.throwEvalError(e)}catch(t){throw r&&(t.identifier=r),t}}const{identifier:e,message:r}=this.diagnosticMessageParts(t,"error");if(!e&&!r)return AST.nodeVoid();try{this.context.throwEvalError(r)}catch(t){throw e&&(t.identifier=e),t}}assertUsesDiagnosticForm(t){return 1===t.length||t.length>=2&&CharString.isInstanceOf(t[1])&&!CharString.isInstanceOf(t[0])}assertNumericElements(t,e){const r=MultiArray.scalarToMultiArray(t),s=MultiArray.linearize(r);return!r.isCell&&s.every(Complex.isInstanceOf)||this.context.throwEvalError(`assert: ${e} must be numeric when tolerance is specified.`),{dimensions:r.dimension.slice(),elements:s}}assertValuesEqualWithinTolerance(t,e,r){const s=this.assertNumericElements(t,"actual value"),i=this.assertNumericElements(e,"expected value");if(s.dimensions.length!==i.dimensions.length||s.dimensions.some((t,e)=>t!==i.dimensions[e]))return!1;const n=this.validateattributesNumericScalar(r,"assert tolerance"),a=Math.abs(n),o=n<0;return s.elements.every((t,e)=>{const r=i.elements[e],s=Complex.abs(Complex.sub(t,r));return Complex.realToNumber(s)<=(o?a*Complex.realToNumber(Complex.abs(r)):a)})}assertComparisonParts(t){return t.length<=2?{diagnostic:[]}:CharString.isInstanceOf(t[2])?{diagnostic:t.slice(2)}:{tolerance:t[2],diagnostic:t.slice(3)}}assertComparisonResult(t){AST.throwInvalidCallError("assert",t.length<2,t=>this.context.throwEvalError(t));const e=this.expressionValue(t[0],"assert actual value"),r=this.expressionValue(t[1],"assert expected value"),s=this.assertComparisonParts(t);return(s.tolerance?this.assertValuesEqualWithinTolerance(e,r,s.tolerance):RuntimeEquality.valuesEqual(e,r))?AST.nodeVoid():s.diagnostic.length>0?this.errorResult(s.diagnostic):void this.context.throwEvalError("assertion failed: observed value does not match expected value.")}assertResult(t){return AST.throwInvalidCallError("assert",0===t.length,t=>this.context.throwEvalError(t)),this.assertUsesDiagnosticForm(t)?this.toBoolean(this.expressionValue(t[0],"assert condition"))?AST.nodeVoid():(1===t.length&&this.context.throwEvalError("assertion failed."),this.errorResult(t.slice(1))):this.assertComparisonResult(t)}validationTextList(t,e,r){if(CharString.isInstanceOf(t))return[t.str];if(MultiArray.isInstanceOf(t)){const e=MultiArray.linearize(t);if(e.every(CharString.isInstanceOf))return e.map(t=>t.str)}this.context.throwEvalError(`${e}: ${r} must be a string or cell array of strings.`)}validationTextItem(t,e,r){if(CharString.isInstanceOf(t))return t.str;this.context.throwEvalError(`${e}: ${r} must be a string.`)}validationListItems(t,e,r){return CharString.isInstanceOf(t)?[t]:MultiArray.isInstanceOf(t)?MultiArray.linearize(t):void this.context.throwEvalError(`${e}: ${r} must be a string or cell array.`)}validatestringResult(t){const e=this.charControlArgument(t[0],"validatestring string").str,r=this.validationTextList(t[1],"validatestring","valid strings"),s=e.toLowerCase(),i=this.validatestringDiagnosticPrefix(t),n=r.filter(t=>t.toLowerCase()===s);if(n.length>0)return new CharString(n[0]);const a=r.filter(t=>t.toLowerCase().startsWith(s));if(1===a.length)return new CharString(a[0]);a.length>1&&this.context.throwEvalError(`${i} ambiguous string '${e}'.`),this.context.throwEvalError(`${i} expected one of: ${r.join(", ")}.`)}validatestringDiagnosticPrefix(t){if(t.length<3)return"validatestring:";const e=this.charControlArgument(t[2],"validatestring function name").str;if(t.length<4)return`validatestring: input for function '${e}'`;const r=this.charControlArgument(t[3],"validatestring variable name").str;return t.length<5?`validatestring: variable '${r}' for function '${e}'`:`validatestring: argument ${this.validateattributesNumericScalar(t[4],"validatestring argument position")} '${r}' for function '${e}'`}validateattributesValidator(t){switch(t.toLowerCase()){case"scalar":return"scalar";case"vector":return"vector";case"row":return"rowVector";case"column":return"columnVector";case"2d":return"matrix2d";case"square":return"squareMatrix";case"nonempty":return"nonempty";case"empty":return"empty";case"real":return"real";case"finite":return"finite";case"nonnan":return"nonnan";case"positive":return"positive";case"nonnegative":return"nonnegative";case"negative":return"negative";case"nonpositive":return"nonpositive";case"nonzero":return"nonzero";case"integer":return"integer";case"nonsparse":return"nonsparse";case"sparse":return"sparse";default:return}}validateattributesDimensions(t){return CharString.isString(t)?[1,1]:RuntimeValue.dimensions(t)}validateattributesRealNumericElements(t,e){const r=MultiArray.linearize(MultiArray.scalarToMultiArray(t));return r.every(t=>Complex.isInstanceOf(t)&&Complex.imagIsZero(t))||this.context.throwEvalError(`validateattributes: ${e} requires real numeric input.`),r}validateattributesNumericScalar(t,e){const r=MultiArray.isInstanceOf(t)&&RuntimeValue.isScalar(t)?MultiArray.firstElement(t):t;return Complex.isInstanceOf(r)&&Complex.imagIsZero(r)||this.context.throwEvalError(`validateattributes: attribute '${e}' parameter must be a real numeric scalar.`),Complex.realToNumber(r)}validateattributesNumericVector(t,e){const r=MultiArray.scalarToMultiArray(t),s=MultiArray.linearize(r);return!r.isCell&&RuntimeValue.isVector(r)&&s.every(t=>Complex.isInstanceOf(t)&&Complex.imagIsZero(t))||this.context.throwEvalError(`validateattributes: attribute '${e}' parameter must be a real numeric vector.`),s.map(t=>Complex.realToNumber(t))}validateattributesNumericComparison(t,e,r){const s=this.validateattributesRealNumericElements(t,e);switch(e){case">":return s.every(t=>Complex.realGreaterThan(t,r));case">=":return s.every(t=>Complex.realGreaterThanOrEqualTo(t,r));case"<":return s.every(t=>Complex.realLessThan(t,r));case"<=":return s.every(t=>Complex.realLessThanOrEqualTo(t,r));default:return!1}}validateattributesMonotonicColumns(t,e){const r=MultiArray.scalarToMultiArray(t);r.isCell&&this.context.throwEvalError(`validateattributes: ${e} requires real numeric input.`);for(let t=0;t<r.array.length;t+=r.dimension[0])for(let s=0;s<r.dimension[1];s++)for(let i=1;i<r.dimension[0];i++){const n=r.array[t+i-1][s],a=r.array[t+i][s];if(Complex.isInstanceOf(n)&&Complex.imagIsZero(n)&&Complex.isInstanceOf(a)&&Complex.imagIsZero(a)||this.context.throwEvalError(`validateattributes: ${e} requires real numeric input.`),!("increasing"===e?Complex.realGreaterThan(a,Complex.realToNumber(n)):"decreasing"===e?Complex.realLessThan(a,Complex.realToNumber(n)):"nondecreasing"===e?Complex.realGreaterThanOrEqualTo(a,Complex.realToNumber(n)):Complex.realLessThanOrEqualTo(a,Complex.realToNumber(n))))return!1}return!0}validateattributesSpecialAttribute(t,e){const r=e.toLowerCase();switch(r){case"3d":return this.validateattributesDimensions(t).length<=3;case"scalartext":return CharString.isInstanceOf(t)||MultiArray.isInstanceOf(t)&&!t.isCell&&RuntimeValue.isScalar(t)&&CharString.isInstanceOf(MultiArray.firstElement(t));case"even":case"odd":return this.validateattributesRealNumericElements(t,e).every(t=>Complex.realIsInteger(t)&&Math.abs(Complex.realToNumber(t)%2)===("odd"===r?1:0));case"binary":return this.validateattributesRealNumericElements(t,e).every(t=>Complex.realEquals(t,0)||Complex.realEquals(t,1));case"diag":case"diagonal":{const r=this.validateattributesDimensions(t);if(2!==r.length||r[0]!==r[1])return!1;const s=MultiArray.scalarToMultiArray(t);s.isCell&&this.context.throwEvalError(`validateattributes: ${e} requires real numeric input.`);for(let t=0;t<r[0];t++)for(let i=0;i<r[1];i++){const r=s.array[t][i];if(Complex.isInstanceOf(r)&&Complex.imagIsZero(r)||this.context.throwEvalError(`validateattributes: ${e} requires real numeric input.`),t!==i&&!Complex.realEquals(r,0))return!1}return!0}case"increasing":case"decreasing":case"nondecreasing":case"nonincreasing":return this.validateattributesMonotonicColumns(t,r);default:return}}validateattributesMatchesValidator(t,e){return!("scalar"!==e||!CharString.isString(t))||FunctionValidation.matchesBuiltInValidator(t,e)}validateattributesParameterizedAttribute(t,e,r,s){const i=this.validateattributesDimensions(t);switch(e.toLowerCase()){case"size":{const t=this.validateattributesNumericVector(r,e);return void(t.length<=i.length&&t.every((t,e)=>Number.isNaN(t)||i[e]===t)&&i.slice(t.length).every(t=>1===t)||this.context.throwEvalError(`validateattributes: ${s} must have size ${t.join("x")}.`))}case"numel":{const i=this.validateattributesNumericVector(r,e);return void(i.includes(RuntimeValue.elementCount(t))||this.context.throwEvalError(`validateattributes: ${s} must have ${i.join(" or ")} elements.`))}case"numrows":case"nrows":{const t=this.validateattributesNumericScalar(r,e);return void(i[0]!==t&&this.context.throwEvalError(`validateattributes: ${s} must have ${t} rows.`))}case"numcols":case"ncols":{const t=this.validateattributesNumericScalar(r,e);return void(i[1]!==t&&this.context.throwEvalError(`validateattributes: ${s} must have ${t} columns.`))}case"ndims":{const t=this.validateattributesNumericScalar(r,e);return void(i.length!==t&&this.context.throwEvalError(`validateattributes: ${s} must have ${t} dimensions.`))}case">":case">=":case"<":case"<=":{const i=this.validateattributesNumericScalar(r,e);return void(this.validateattributesNumericComparison(t,e,i)||this.context.throwEvalError(`validateattributes: ${s} must be ${e} ${i}.`))}default:this.context.throwEvalError(`validateattributes: unsupported attribute '${e}'.`)}}validateattributesSubject(t){if(t.length>=6){const e=this.charControlArgument(t[3],"validateattributes function name").str,r=this.charControlArgument(t[4],"validateattributes variable name").str;return`argument ${this.validateattributesNumericScalar(t[5],"validateattributes argument position")} '${r}' for function '${e}'`}return t.length>=5?this.charControlArgument(t[4],"validateattributes variable name").str:t.length>=4?CharString.isInstanceOf(t[3])?`input for function '${this.charControlArgument(t[3],"validateattributes function name").str}'`:`argument ${this.validateattributesNumericScalar(t[3],"validateattributes argument position")}`:"input"}validateattributesMatchesClass(t,e){switch(e.toLowerCase()){case"numeric":return FunctionValidation.matchesBuiltInValidator(t,"numeric");case"float":return FunctionValidation.matchesBuiltInValidator(t,"float");case"integer":return FunctionValidation.matchesBuiltInValidator(t,"integer");case"object":return ClassInstance.isInstanceOf(t)||MultiArray.isInstanceOf(t)&&MultiArray.linearize(t).some(ClassInstance.isInstanceOf);default:return FunctionValidation.matchesClass(t,e)||this.valueIsRuntimeClass(t,e)}}validateattributesResult(t){const e=this.expressionValue(t[0],"validateattributes value"),r=this.validationTextList(t[1],"validateattributes","class list"),s=this.validationListItems(t[2],"validateattributes","attribute list"),i=this.validateattributesSubject(t);r.length>0&&!r.some(t=>this.validateattributesMatchesClass(e,t))&&this.context.throwEvalError(`validateattributes: ${i} must be one of: ${r.join(", ")}.`);for(let t=0;t<s.length;t++){const r=this.validationTextItem(s[t],"validateattributes","attribute"),n=this.validateattributesValidator(r);if(!n){const n=this.validateattributesSpecialAttribute(e,r);if(void 0!==n){n||this.context.throwEvalError(`validateattributes: ${i} must be ${r}.`);continue}t+1>=s.length&&this.context.throwEvalError(`validateattributes: attribute '${r}' requires a parameter.`),this.validateattributesParameterizedAttribute(e,r,s[++t],i);continue}this.validateattributesMatchesValidator(e,n)||this.context.throwEvalError(`validateattributes: ${i} must be ${r}.`)}return AST.nodeVoid()}mustBeArity(t){switch(t){case"mustBeGreaterThan":case"mustBeGreaterThanOrEqual":case"mustBeLessThan":case"mustBeLessThanOrEqual":case"mustBeMember":case"mustBeA":case"mustBeUnderlyingType":return{min:2,max:2};case"mustBeInRange":case"mustBeBetween":return{min:3,max:4};default:return{min:1,max:1}}}mustBeResult(t,e){const r=this.mustBeArity(t);AST.throwInvalidCallError(t,e.length<r.min||e.length>r.max,t=>this.context.throwEvalError(t));const s=this.runtimeExpressionValue(e[0],`${t} value`),i=e.slice(1).map((e,r)=>this.runtimeExpressionValue(e,`${t} bound ${r+1}`));return"mustBeA"===t?(this.validationTextList(i[0],t,"class list").some(t=>this.valueMatchesValidationClass(s,t,this.context.currentScope))||this.context.throwEvalError(`${t} validation failed for 'input': ${t}.`),AST.nodeVoid()):"mustBeUnderlyingType"===t?(this.validationTextList(i[0],t,"type list").includes(FunctionValidation.underlyingType(s))||this.context.throwEvalError(`${t} validation failed for 'input': ${t}.`),AST.nodeVoid()):(FunctionArguments.validateArgumentFunction("input",s,t,i,t=>this.context.throwEvalError(t),t=>this.context.throwSyntaxError(t),this.pathValidationCallbacks,t),AST.nodeVoid())}mustBeFunctionEntries(){return Object.fromEntries(Interpreter.publicArgumentValidators.map(t=>[t,{func:(...e)=>this.mustBeResult(t,e),signature:{inputs:{arity:-1,min:1,parameters:[{name:"argument",variadic:!0}]},outputs:{arity:0}}}]))}commandWordListResult(t){if(void 0!==t)return"string"==typeof t?new CharString(t):"number"==typeof t?Complex.create(t):"boolean"==typeof t?t?Complex.true():Complex.false():t}rethrowResult(t){Structure.isInstanceOf(t)||this.context.throwEvalError("rethrow: input must be an error structure.");const e=t.field.message,r=t.field.identifier,s=t.field.stack;CharString.isInstanceOf(e)&&CharString.isInstanceOf(r)&&void 0!==s||this.context.throwEvalError("rethrow: input must be an error structure.");const i=this.runtimeExpressionValue(s,"error stack");try{this.context.throwEvalError(e.str)}catch(t){throw t.publicStack=i,r.str&&(t.identifier=r.str),t}}lastWarningResult(t=[]){return 1===t.length?this.setLastWarning(this.charControlArgument(t[0],"warning message").str):2===t.length&&this.setLastWarning(this.charControlArgument(t[0],"warning message").str,this.charControlArgument(t[1],"warning identifier").str),this.valueReturnList([new CharString(this.lastWarning.message),new CharString(this.lastWarning.identifier)])}dealResult(t){const e=this.context.requestedOutputMask(Math.max(this.context.requestedOutputCount,t.length)),r=t=>e[t]??!0;return AST.nodeCommaSeparatedReturnList(t.length,(t,e)=>{const r=t[`out${e}`];return void 0===r&&AST.throwErrorIfGreaterThanReturnList(e,e+1,t=>this.context.throwEvalError(t)),r},e=>{1!==t.length&&1!==e&&e!==t.length&&this.context.throwEvalError("deal: nargin and nargout must match unless there is exactly one input.");const s={length:e};for(let i=0;i<e;i++){if(!r(i))continue;const e=1===t.length?t[0]:t[i];s[`out${i}`]=this.returnListValue(e,`out${i+1}`)}return s})}positiveIntegerIndex(t,e){const r=MultiArray.isInstanceOf(t)&&MultiArray.isScalar(t)?MultiArray.firstElement(t):t;Complex.isInstanceOf(r)&&Complex.imagIsZero(r)||this.context.throwEvalError(`${e} must be a positive integer.`);const s=Complex.realToNumber(r);return(!Number.isInteger(s)||s<1)&&this.context.throwEvalError(`${e} must be a positive integer.`),s}nthargoutIndexes(t){if(!MultiArray.isInstanceOf(t))return{indexes:[this.positiveIntegerIndex(t,"nthargout index")],vector:!1};const e=MultiArray.linearize(t);return 0===e.length&&this.context.throwEvalError("nthargout index must be a positive integer."),{indexes:e.map(t=>this.positiveIntegerIndex(t,"nthargout index")),vector:e.length>1}}nthargoutCallable(t){let e=this.expressionValue(t,"nthargout function");if(CharString.isInstanceOf(e)){const t=e.str.trim();0===t.length&&this.context.throwEvalError("nthargout: function name cannot be empty."),e=t.startsWith("@")?this.functionHandleFromString(e):this.createResolvedFunctionHandle(t,this.context.currentScope,void 0,!1,!0)}const r=this.context.resolveCallable(e);return r||this.context.throwEvalError("nthargout: function must be a function handle or function name."),r}nthargoutResult(t){const{indexes:e,vector:r}=this.nthargoutIndexes(t[0]),s=t.length>=3&&Complex.isInstanceOf(MultiArray.isInstanceOf(t[1])&&MultiArray.isScalar(t[1])?MultiArray.firstElement(t[1]):t[1]),i=s?this.positiveIntegerIndex(t[1],"nthargout total output count"):Math.max(...e);i<Math.max(...e)&&this.context.throwEvalError("nthargout total output count must be at least the largest requested output index.");const n=s?2:1,a=this.nthargoutCallable(t[n]);let o;this.context.pushRequestedOutputCount(i),this.context.pushRequestedOutputMask(Array.from({length:i},()=>!0));try{o=this.context.callCallable(a,this.callArgumentValues(t.slice(n+1),"nthargout"),AST.nodeIdentifier("nthargout"))}finally{this.context.popRequestedOutputMask(),this.context.popRequestedOutputCount()}const l=AST.ensureReturnList(this.expressionValue(o,"nthargout result")),c=l.handler(i),u=e.map(t=>this.returnListValue(l.selector(c,t-1),`nthargout output ${t}`));if(!r)return u[0];const h=MultiArray.toRowVector(u);return h.isCell=!0,h}expressionValue(t,e){return expressionValue(t,e,"Expression value",t=>this.context.throwEvalError(t))}runtimeExpressionValue(t,e){return runtimeExpressionValue(t,e,"Expression value",t=>this.context.throwEvalError(t))}evaluatedExpressionValue(t,e,r){return this.expressionValue(AST.reduceToFirstIfReturnList(this.Evaluator(t,e)),r)}evaluatedExecutionResult(t,e){return AST.reduceToFirstIfReturnList(this.Evaluator(t,e))}scopedExpressionValue(t,e,r){const s=t.resolveName(e);return s&&void 0!==s.node||this.context.throwEvalError(`internal error: missing scoped expression '${e}'.`),this.expressionValue(s.node,r)}scopedMultiArrayValue(t,e,r){const s=this.scopedExpressionValue(t,e,r);return MultiArray.isInstanceOf(s)||this.context.throwEvalError(`internal error: scoped expression '${e}' is not an array.`),s}callArgumentValues(t,e){return t.map((t,r)=>this.expressionValue(t,`${e}${r+1}`))}charControlArgument(t,e){const r=this.expressionValue(t,e);return CharString.isInstanceOf(r)||this.context.throwEvalError(`${e} must be a character string.`),r}charStringList(t,e){return t.every(CharString.isInstanceOf)||this.context.throwEvalError(`${e} must contain character strings.`),t}functionHandleControlArgument(t,e){const r=this.expressionValue(t,e);return FunctionHandle.isInstanceOf(r)||this.context.throwEvalError(`${e} must be a function handle.`),r}booleanControlArgument(t,e){return this.toBoolean(this.expressionValue(t,e))}workerCountControlArgument(t,e){const r=this.expressionValue(t,e),s=MultiArray.isScalar(r)?MultiArray.firstElement(r):r;Complex.isInstanceOf(s)&&0===Complex.imagToNumber(s)||this.context.throwEvalError(`${e} must be a nonnegative integer.`);const i=Complex.realToNumber(s);return(!Number.isFinite(i)||!Number.isInteger(i)||i<0)&&this.context.throwEvalError(`${e} must be a nonnegative integer.`),i}classMethodArgumentValues(t,e){return t.map((t,r)=>this.expressionValue(t,`${e}${r+1}`))}reducedClassMethodResult(t,e,r,s){return AST.reduceToFirstIfReturnList(this.context.callClassInstanceMethod(t,e,r,s))}reducedClassMethodResultWithOutputCount(t,e,r,s,i){return AST.reduceToFirstIfReturnList(this.callClassInstanceMethodWithOutputCount(t,e,r,s,i))}classSubsasgnResult(t,e,r,s){const i=this.reducedClassMethodResult(t,e,r,s);return ClassInstance.isInstanceOf(i)||this.context.throwEvalError(`subsasgn for class ${t.classDefinition.name} must return an object of class ${t.classDefinition.name}.`),i.classDefinition===t.classDefinition||i.classDefinition.isSubclassOf(t.classDefinition)||this.context.throwEvalError(`subsasgn for class ${t.classDefinition.name} must return an object of class ${t.classDefinition.name}.`),i}reducedAssignmentValue(t){return AST.reduceToFirstIfReturnList(t)}structureAssignmentValue(t,e){return this.runtimeExpressionValue(this.reducedAssignmentValue(t),e)}assignStructureFieldValue(t,e,r,s){if(s&&MultiArray.isInstanceOf(t)&&Structure.isStructure(t)){const s=Structure.structureElements(t),i=MultiArray.isInstanceOf(r)?MultiArray.linearize(r):[r];if(i.length===s.length)return void s.forEach((t,r)=>{Structure.setNewField(t,e,this.runtimeExpressionValue(i[r],`field ${e.join(".")} element ${r+1}`))})}Structure.setNewField(t,e,r)}reducedIndexingResult(t){return AST.reduceToFirstIfReturnList(t)}assignmentValues(t,e){return MultiArray.linearize(this.expressionValue(t,e)).map((t,r)=>this.expressionValue(t,`${e}${r+1}`))}classPropertyPathAssignmentValues(t,e,r){return 1===e||r.tailDescriptors&&r.tailDescriptors.length>0&&MultiArray.isInstanceOf(t)&&MultiArray.isEmpty(t)?[this.expressionValue(t,"assignment")]:this.assignmentValues(t,"assignment")}expressionList(t,e){return t.map((t,r)=>this.expressionValue(t,`${e}${r+1}`))}linearExpressionValues(t,e){const r=this.expressionValue(t,e);return MultiArray.isInstanceOf(r)?MultiArray.linearize(r).map((t,r)=>this.expressionValue(t,`${e}${r+1}`)):[r]}copyExpressionValue(t,e){const r=this.expressionValue(t,e);return this.expressionValue(RuntimeValue.copy(r),e)}forLoopValues(t,e){if(Structure.isInstanceOf(t)){const r=MultiArray.isRowVector(e)?MultiArray.linearize(this.expressionValue(e,"for target")).length:1;return Object.entries(t.field).map(([t,e])=>{const s=this.expressionValue(e,t);return r>1?this.expressionValue(new MultiArray([1,2],[[s,CharString.create(t)]]),t):s})}if(CharString.isInstanceOf(t))return t.toCharacterScalars();if(!MultiArray.isInstanceOf(t))return[this.expressionValue(t,"for")];if(0===t.dimension[0]||0===t.dimension[1])return[];if(1===t.dimension[0]&&!t.isCell)return t.array[0].map((t,e)=>this.expressionValue(t,`for${e+1}`));const r=[];for(let e=0;e<t.dimension[1];e++){const s=new MultiArray([t.dimension[0],1],void 0,t.isCell);for(let r=0;r<t.dimension[0];r++)s.array[r][0]=t.array[r][e];r.push(this.expressionValue(s,`for${e+1}`))}return r}forLoopAssignmentValue(t,e){if(!MultiArray.isRowVector(t))return this.copyExpressionValue(e,"for");const r=this.linearExpressionValues(e,"for");return AST.nodeReturnList((t,e)=>{if(e<r.length)return this.copyExpressionValue(r[e],`for${e+1}`);AST.throwErrorIfGreaterThanReturnList(r.length,e+1,t=>this.context.throwEvalError(t))},t=>(t>r.length&&AST.throwErrorIfGreaterThanReturnList(r.length,t,t=>this.context.throwEvalError(t)),{length:t}))}validateParforHeader(t,e){AST.isNodeIdentifier(t)||this.context.throwEvalError("parfor loop variable must be a simple identifier.");const r=(()=>MultiArray.isInstanceOf(e)?((e.isCell||1!==e.dimension[0])&&this.context.throwEvalError("parfor range must be a row vector of consecutive integer values."),MultiArray.linearize(e)):[e])().map((t,e)=>{const r=this.expressionValue(t,`parfor range ${e+1}`);Complex.isInstanceOf(r)&&0===Complex.imagToNumber(r)||this.context.throwEvalError("parfor range must be a row vector of consecutive integer values.");const s=Complex.realToNumber(r);return Number.isFinite(s)&&Number.isInteger(s)||this.context.throwEvalError("parfor range must be a row vector of consecutive integer values."),s});if(r.length<=1)return;const s=r[1]-r[0];1!==Math.abs(s)&&this.context.throwEvalError("parfor range must be a row vector of consecutive integer values.");for(let t=2;t<r.length;t++)r[t]-r[t-1]!==s&&this.context.throwEvalError("parfor range must be a row vector of consecutive integer values.")}validateParforBody(t,e){const r=new Set(["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|="]),s=t=>AST.isNodeIdentifier(t)?t.id===e:AST.isNodeIndexExpr(t)?s(t.expr):AST.isNodeIndirectRef(t)?s(t.obj):AST.isNodeList(t)?t.list.some(s):!!MultiArray.isInstanceOf(t)&&MultiArray.linearize(t).some(s),i=t=>{if(AST.isNodeBase(t)){if("BREAK"!==t.type&&"RETURN"!==t.type||this.context.throwEvalError(("BREAK"===t.type?"break":"return")+" is not allowed inside a parfor loop."),AST.isNodeDeclaration(t)&&this.context.throwEvalError(("GLOBAL"===t.type?"global":"persistent")+" declarations are not allowed inside a parfor loop."),AST.isNodeCmdWList(t)&&"clear"===t.id&&this.context.throwEvalError("clear is not allowed inside a parfor loop."),(t=>AST.isNodeIndexExpr(t)&&AST.isNodeIdentifier(t.expr)&&"clear"===t.expr.id&&"()"===t.delim)(t)&&this.context.throwEvalError("clear is not allowed inside a parfor loop."),"SPMD"===t.type&&this.context.throwEvalError("spmd is not allowed inside a parfor loop."),"FOR"===t.type&&!0===Reflect.get(t,"parallel")&&this.context.throwEvalError("nested parfor loops are not allowed."),AST.isNodeBinaryOperation(t))return r.has(t.type)&&s(t.left)&&this.context.throwEvalError(`assignment to parfor loop variable '${e}' is not allowed.`),i(t.left),void i(t.right);if(AST.isNodePrefixOperation(t))return"++_"!==t.type&&"--_"!==t.type||!s(t.right)||this.context.throwEvalError(`assignment to parfor loop variable '${e}' is not allowed.`),void i(t.right);if(AST.isNodePostfixOperation(t))return"_++"!==t.type&&"_--"!==t.type||!s(t.left)||this.context.throwEvalError(`assignment to parfor loop variable '${e}' is not allowed.`),void i(t.left);if(AST.isNodeIndexExpr(t))return i(t.expr),void t.args.forEach(i);if(AST.isNodeIndirectRef(t))return i(t.obj),void t.field.forEach(t=>{"string"!=typeof t&&i(t)});if(AST.isNodeList(t))t.list.forEach(i);else switch(t.type){case"IF":Reflect.get(t,"expression").forEach(i),Reflect.get(t,"then").forEach(i),Reflect.get(t,"else")&&i(Reflect.get(t,"else"));break;case"SWITCH":i(Reflect.get(t,"expression")),Reflect.get(t,"cases").forEach(i),Reflect.get(t,"otherwise")&&i(Reflect.get(t,"otherwise"));break;case"CASE":i(Reflect.get(t,"expression")),i(Reflect.get(t,"then"));break;case"WHILE":case"DO_UNTIL":i(Reflect.get(t,"expression")),i(Reflect.get(t,"body"));break;case"FOR":i(Reflect.get(t,"target")),i(Reflect.get(t,"expression")),i(Reflect.get(t,"body"));break;case"TRY":i(Reflect.get(t,"body")),Reflect.get(t,"catchBody")&&i(Reflect.get(t,"catchBody"));break;case"UNWIND_PROTECT":i(Reflect.get(t,"body")),i(Reflect.get(t,"cleanup"))}}};i(t)}validateSpmdBody(t){const e=t=>{if(FunctionHandle.isInstanceOf(t))void 0===t.id&&this.context.throwEvalError("anonymous function definitions are not allowed inside an spmd block.");else if(AST.isNodeBase(t)){if("BREAK"!==t.type&&"CONTINUE"!==t.type&&"RETURN"!==t.type||this.context.throwEvalError(("BREAK"===t.type?"break":"CONTINUE"===t.type?"continue":"return")+" is not allowed inside an spmd block."),AST.isNodeDeclaration(t)&&this.context.throwEvalError(("GLOBAL"===t.type?"global":"persistent")+" declarations are not allowed inside an spmd block."),AST.isNodeCmdWList(t)&&"clear"===t.id&&this.context.throwEvalError("clear is not allowed inside an spmd block."),(t=>AST.isNodeIndexExpr(t)&&AST.isNodeIdentifier(t.expr)&&"clear"===t.expr.id&&"()"===t.delim)(t)&&this.context.throwEvalError("clear is not allowed inside an spmd block."),"SPMD"===t.type&&this.context.throwEvalError("nested spmd blocks are not allowed."),"FOR"===t.type&&!0===Reflect.get(t,"parallel")&&this.context.throwEvalError("parfor is not allowed inside an spmd block."),AST.isNodeBinaryOperation(t))return e(t.left),void e(t.right);if(AST.isNodePrefixOperation(t))e(t.right);else if(AST.isNodePostfixOperation(t))e(t.left);else{if(AST.isNodeIndexExpr(t))return e(t.expr),void t.args.forEach(e);if(AST.isNodeIndirectRef(t))return e(t.obj),void t.field.forEach(t=>{"string"!=typeof t&&e(t)});if(AST.isNodeList(t))t.list.forEach(e);else switch(t.type){case"IF":Reflect.get(t,"expression").forEach(e),Reflect.get(t,"then").forEach(e),Reflect.get(t,"else")&&e(Reflect.get(t,"else"));break;case"SWITCH":e(Reflect.get(t,"expression")),Reflect.get(t,"cases").forEach(e),Reflect.get(t,"otherwise")&&e(Reflect.get(t,"otherwise"));break;case"CASE":e(Reflect.get(t,"expression")),e(Reflect.get(t,"then"));break;case"WHILE":case"DO_UNTIL":e(Reflect.get(t,"expression")),e(Reflect.get(t,"body"));break;case"FOR":e(Reflect.get(t,"target")),e(Reflect.get(t,"expression")),Reflect.get(t,"workers")&&e(Reflect.get(t,"workers")),e(Reflect.get(t,"body"));break;case"TRY":e(Reflect.get(t,"body")),Reflect.get(t,"catchBody")&&e(Reflect.get(t,"catchBody"));break;case"UNWIND_PROTECT":e(Reflect.get(t,"body")),e(Reflect.get(t,"cleanup"))}}}};e(t)}cloneAssignmentTarget(t){if(Complex.isInstanceOf(t)||CharString.isInstanceOf(t)||Structure.isInstanceOf(t)||FunctionHandle.isInstanceOf(t)||ClassDefinition.isInstanceOf(t)||ClassInstance.isInstanceOf(t)||ClassBoundMethod.isInstanceOf(t)||ClassStaticMethod.isInstanceOf(t)||ClassEmptyMethod.isInstanceOf(t)||ClassEnumerationValue.isInstanceOf(t)||ClassMetaObject.isInstanceOf(t))return this.copyExpressionValue(t,"assignment target");if(AST.isNodeIdentifier(t))return AST.nodeIdentifier(t.id);if(AST.isNodeIgnoredTarget(t))return AST.nodeIgnoredTarget();if(AST.isNodeIndexExpr(t))return AST.nodeIndexExpr(this.cloneAssignmentTarget(t.expr),AST.nodeList(t.args.map(t=>this.cloneAssignmentTarget(t))),t.delim);if(AST.isNodeIndirectRef(t)){const e=t.field[0];let r=AST.nodeIndirectRef(this.cloneAssignmentTarget(t.obj),"string"==typeof e?e:this.cloneAssignmentTarget(e));for(let e=1;e<t.field.length;e++){const s=t.field[e];r=AST.nodeIndirectRef(r,"string"==typeof s?s:this.cloneAssignmentTarget(s))}return r}if(MultiArray.isInstanceOf(t)){const e=t,r=new MultiArray(e.dimension,void 0,e.isCell);for(let t=0;t<e.dimension[0];t++)for(let s=0;s<e.dimension[1];s++)r.array[t][s]=this.cloneAssignmentTarget(e.array[t][s]);return MultiArray.setType(r),this.expressionValue(r,"assignment target")}return this.expressionValue(AST.nodeCopy(this.expressionValue(t,"assignment target")),"assignment target")}returnListValue(t,e){return expressionValue(t,e,"Return value",t=>this.context.throwEvalError(t))}valueReturnList(t,e){const r=e??this.context.requestedOutputMask(t.length),s=t=>r[t]??!0;return AST.nodeCommaSeparatedReturnList(t.length,(t,e)=>{const r=t[`out${e}`];return void 0===r&&AST.throwErrorIfGreaterThanReturnList(e,e+1,t=>this.context.throwEvalError(t)),r},e=>{AST.throwErrorIfGreaterThanReturnList(t.length,e,t=>this.context.throwEvalError(t));const r={length:e};for(let i=0;i<e;i++)s(i)&&(r[`out${i}`]=this.returnListValue(t[i],`out${i+1}`));return r})}compoundAssignmentOperand(t,e){if(!AST.isNodeReturnList(t)||!t.commaSeparated)return this.expressionValue(t,e);const r=t.returnListLength??t.handler(0).length,s=t.handler(r),i=[];for(let n=0;n<r;n++)i.push(this.expressionValue(t.selector(s,n),`${e}${n+1}`));return MultiArray.toRowVector(i)}nestedAssignmentValue(t){const e=t.list[0];return AST.isNodeBinaryOperation(e)&&"="===e.type||this.context.throwEvalError("invalid nested assignment result."),this.expressionValue(e.right,"assignment result")}evalStringInScope(t,e,r={}){const s=this.Parse(t);s.parent=null,this.validateDeclarationPlacement(s);const i=this.pushDynamicNameCreationGuard(e);this.context.pushCallStackFrame(new CallFrame(e));try{const t=r.requestedOutputCount??this.context.requestedOutputCount,i=r.requestedOutputMask??this.context.requestedOutputMask(t);this.context.pushRequestedOutputCount(t),this.context.pushRequestedOutputMask(i);try{if(AST.isNodeList(s)&&1===s.list.length&&!s.list[0].omitOutput){let t=s.list[0];return AST.isNodeIdentifier(t)&&!e.resolveName(t.id)&&this.commandWordListNameSet.has(t.id)&&(t=AST.nodeEmptyCmdWList(t),s.list[0]=t),t.index=0,this.Evaluator(t,e)}const t=this.Evaluator(s,e);return AST.isNodeList(t)&&1===t.list.length&&AST.isNodeReturnList(t.list[0])?t.list[0]:t}catch(t){if(r.topLevelReturn&&t instanceof ReturnSignal)return AST.nodeVoid();throw t}finally{this.context.popRequestedOutputMask(),this.context.popRequestedOutputCount()}}finally{this.context.popCallStackFrame(),i()}}pushDynamicNameCreationGuard(t){const e=t.rejectDynamicNameCreation;return t.staticWorkspaceNameSet&&(t.rejectDynamicNameCreation=!0),()=>{t.rejectDynamicNameCreation=e}}isEvalCatchableError(t){return!(t instanceof ReturnSignal||t instanceof BreakSignal||t instanceof ContinueSignal)}evalcResult(t,e){const r=this.context.requestedOutputCount,s=Math.max(r-1,1),i=this.context.requestedOutputMask(r),n=Array.from({length:s},(t,e)=>i[e+1]??!0);let a;a=FunctionWorkspace.evaluateWithCatch(this.context.currentScope,t,e,(t,e)=>this.evalStringInScope(t,e,{requestedOutputCount:s,requestedOutputMask:n}),t=>this.isEvalCatchableError(t),t=>this.rememberLastError(t));const o=new Array(s);let l=a;if(AST.isNodeReturnList(a)){const t=a.handler(s);for(let e=0;e<s;e++)n[e]&&(o[e]=this.returnListValue(a.selector(t,e),`evalc output ${e+1}`));const e=o.filter(t=>void 0!==t);l=0===e.length?AST.nodeVoid():1===e.length?e[0]:AST.nodeList(e.map(t=>this.returnListValue(t,"evalc display value")))}else"VOID"!==a.type&&(o[0]=this.returnListValue(a,"evalc output 1"));const c=new CharString(this.Unparse(l));return r>1?this.valueReturnList([c,...o],i):c}topLevelClassDefinitions(t){return AST.isNodeClassDef(t)?[t]:AST.isNodeList(t)?t.list.filter(AST.isNodeClassDef):[]}topLevelFunctionDefinitions(t){return AST.isNodeFunctionDefinition(t)?[t]:AST.isNodeList(t)?t.list.filter(AST.isNodeFunctionDefinition):[]}parseFunctionSource(t,e){const r=t.split(".").pop()??t,s=this.Parse(e);this.validateDeclarationPlacement(s);const i=this.topLevelFunctionDefinitions(s),n=i.find(e=>e.id===r||e.id===t);return n||this.context.throwEvalError(`function '${t}' could not be loaded: source does not contain primary function ${r}.`),n.id=t,{primary:n,subfunctions:i.filter(t=>t!==n)}}resolveFunctionSource(t){return this.sourceResolver.resolve("function",t)}hasFunctionSource(t){return Boolean(this.validFunctionSource(t))}validFunctionSource(t){const e=this.resolveFunctionSource(t);if(void 0!==e)try{const r=this.parseFunctionSource(e.name??t,e.source);return this.validateFunctionFileDefinitions(r.primary,r.subfunctions,`function file ${e.name??t}`),e}catch(t){return}}validateFunctionFileDefinitions(t,e,r=`function file ${t.id}`){this.validateFunctionSignature(t),this.validateFunctionArgumentsBlocks(t);const s=new Set([t.id]);for(const t of e)s.has(t.id)&&this.context.throwSyntaxError(`duplicate function '${t.id}' in ${r}.`),s.add(t.id),this.validateFunctionSignature(t),this.validateFunctionArgumentsBlocks(t)}registerFunctionFileDefinition(t,e,r,s=t.id){this.validateFunctionFileDefinitions(t,e,`function file ${t.id}`);const i=Scope.create(r,!1);i.defineFunction(t.id,t),t.definingScope=i,t.sourceName=s,(t.attributes?.nested||t.attributes?.subfunction)&&(t.attributes={...t.attributes},delete t.attributes.nested,delete t.attributes.subfunction);for(const t of e)t.definingScope=i,t.sourceName=s,t.attributes={...t.attributes??{},subfunction:!0},delete t.attributes.nested,i.defineFunction(t.id,t);return r.defineFunction(t.id,t),t}LoadFunctionFile(t,e,r=this.context.globalScope??this.context.currentScope,s=t){const i=this.parseFunctionSource(t,e);return this.registerFunctionFileDefinition(i.primary,i.subfunctions,r,s)}loadFunctionDefinition(t,e){const r=this.resolveFunctionSource(t);if(r&&!this.loadingFunctionNames.has(t)){this.loadingFunctionNames.add(t);try{return this.LoadFunctionFile(r.name??t,r.source,this.context.globalScope??e,r.sourceName??r.name??t)}finally{this.loadingFunctionNames.delete(t)}}}resolveScriptSource(t){return this.sourceResolver.resolve("script",t)}hasScriptSource(t){return Boolean(this.validScriptSource(t))}validScriptSource(t){const e=this.resolveScriptSource(t);if(void 0!==e)try{const t=this.Parse(e.source);return this.validateDeclarationPlacement(t),e}catch(t){return}}executeScriptTree(t,e,r){const s=this.topLevelFunctionDefinitions(t),i=new Map,n=e.importSnapshot(),a=this.pushDynamicNameCreationGuard(e);for(const t of s)i.has(t.id)||i.set(t.id,e.functionTable[t.id]);this.scriptExecutionDepth++,this.scriptSourceNameStack.push(r);try{return this.applyScopedImports(t,e),this.Evaluator(t,e)}catch(t){if(t instanceof ReturnSignal)return AST.nodeVoid();throw t}finally{this.scriptSourceNameStack.pop(),this.scriptExecutionDepth--,a();for(const[t,r]of i)r?e.defineFunction(t,r):e.removeFunction(t);e.restoreImports(n)}}LoadScriptFile(t,e,r=this.context.currentScope,s=t){const i=this.Parse(e);return i.parent=null,this.validateDeclarationPlacement(i),this.executeScriptTree(i,r,s)}RunScriptFile(t,e=this.context.currentScope){const r=this.resolveScriptSource(t);return r||this.context.throwEvalError(`script '${t}' could not be loaded.`),this.LoadScriptFile(r.name??t,r.source,e,r.sourceName??r.name??t)}parseClassSource(t,e){const r=this.tryParseClassSource(t,e);if(!r){const e=t.split(".").pop()??t;this.context.throwEvalError(`class '${t}' could not be loaded: source does not contain classdef ${e}.`)}return r}tryParseClassSource(t,e){const r=t.split(".").pop()??t,s=this.Parse(e);this.validateDeclarationPlacement(s);const i=this.topLevelClassDefinitions(s).find(t=>t.id===r);if(i)return i.id=t,i}isFunctionOnlySource(t){const e=this.Parse(t);return this.validateDeclarationPlacement(e),0===this.topLevelClassDefinitions(e).length&&this.topLevelFunctionDefinitions(e).length>0}parseClassMethodSource(t,e,r,s){const i=new Set([e,r]);e.includes(".")||i.add(r.split(".").pop()??r);const n=this.Parse(s);this.validateDeclarationPlacement(n);const a=this.topLevelFunctionDefinitions(n),o=a.find(t=>i.has(t.id));return o||this.context.throwEvalError(`method '${e}' for class ${t} could not be loaded: source does not contain primary function ${e}.`),o.id=e,o.attributes?.prototype&&(o.attributes={...o.attributes},delete o.attributes.prototype),{primary:o,subfunctions:a.filter(t=>t!==o)}}resolveClassSource(t){return this.sourceResolver.resolve("class",t)}hasClassSource(t){return Boolean(this.validClassSource(t))}validClassSource(t){const e=this.resolveClassSource(t);if(void 0!==e)try{const r=this.tryParseClassSource(e.name??t,e.source);if(!r)return;return ClassDefinition.create(r).validateLocalDefinition(t=>this.context.throwEvalError(t)),e}catch(t){return}}attachClassDefinitionSourceName(t,e){for(const r of t.methods)r.node.sourceName=e}loadClassDefinition(t,e){const r=this.resolveClassSource(t);if(r&&!this.loadingClassNames.has(t)){this.loadingClassNames.add(t);try{const s=this.tryParseClassSource(r.name??t,r.source);if(!s){if(this.isFunctionOnlySource(r.source))return;return void this.parseClassSource(r.name??t,r.source)}const i=ClassDefinition.create(s);return this.attachClassDefinitionSourceName(i,r.sourceName??r.name??t),i.resolveSuperclasses(t=>this.context.resolveClassDefinition(t,e),t=>this.context.throwEvalError(t)),i}finally{this.loadingClassNames.delete(t)}}}loadClassMethodDefinition(t,e,r){const s=`${t}.${e}`,i=this.resolveClassSource(s);if(i&&!this.loadingClassMethodNames.has(s)){this.loadingClassMethodNames.add(s);try{const n=this.parseClassMethodSource(t,e,i.name??s,i.source),a=Scope.create(this.context.globalScope??r,!1);this.validateFunctionFileDefinitions(n.primary,n.subfunctions,`method file ${s}`),n.primary.definingScope=a,n.primary.sourceName=i.sourceName??i.name??s,a.defineFunction(n.primary.id,n.primary);for(const t of n.subfunctions)t.definingScope=a,t.sourceName=i.sourceName??i.name??s,t.attributes={...t.attributes??{},subfunction:!0},delete t.attributes.nested,a.defineFunction(t.id,t);return n.primary}finally{this.loadingClassMethodNames.delete(s)}}}qualifiedReferenceParts(t){if("IDENT"===t.obj.type&&!t.field.some(t=>"string"!=typeof t))return[t.obj.id,...t.field]}resolveClassDefinitionMemberChain(t,e,r){let s=t;for(const t of e)if(ClassDefinition.isInstanceOf(s)){const e=s.findProperty(t);if(e?.isConstant){this.assertCanReadClassProperty(e,t,s.name),s=e.defaultValue?this.evaluatedExpressionValue(e.defaultValue,r,`constant property ${t}`):MultiArray.emptyArray();continue}const i=s.findEnumeration(t);if(i){const t=i.args.map((t,e)=>this.runtimeExpressionValue(this.evaluatedExpressionValue(t,r,`enumeration argument ${e+1}`),`enumeration argument ${e+1}`));s=ClassEnumerationValue.create(i.classDefinition,i,t);continue}if("empty"===t){s=ClassEmptyMethod.bind(s);continue}const n=s.findMethod(t,t=>t.isStatic);if(n){this.context.canAccessClassMember(n.classDefinition,n.access)||this.context.throwEvalError(`method '${t}' has ${n.access} access for class ${s.name}.`),s=ClassStaticMethod.bind(s,n);continue}this.context.throwEvalError(`unknown static method '${t}' for class ${s.name}.`)}else s=Structure.getField(s,[t]);return s}resolveQualifiedAccess(t,e){const r=this.qualifiedReferenceParts(t);if(!r||r.length<2||this.hasConcreteName(e,r[0]))return;for(let t=r.length;t>=2;t--){const s=r.slice(0,t).join("."),i=this.resolveRuntimeClass(s,e,{imports:!1});if("class"===i?.kind)return{kind:"class-member-chain",parts:r,prefixLength:t,resolvedName:i.resolvedName,classDefinition:i.classDefinition}}const s=r.join("."),i=this.resolveRuntimeFunction(s,e,{imports:!1});if(i?.functionDefinition){const e=FunctionHandle.create(i.resolvedName);return e.parent=t,{kind:"function",parts:r,prefixLength:r.length,resolvedName:i.resolvedName,functionHandle:e}}}resolveQualifiedNameAccess(t,e){const r=this.resolveQualifiedAccess(t,e);if(r)switch(r.kind){case"class-member-chain":return r.classDefinition.parent=t,this.resolveClassDefinitionMemberChain(r.classDefinition,r.parts.slice(r.prefixLength),e);case"function":return r.functionHandle}}hasConcreteName(t,e){const r=t.resolveName(e);return void 0!==r?.node&&!r.undefinedReference}resolveImportedStaticMethod(t,e){const r=[...new Map(e.importedNameCandidates(t).map(t=>this.importedStaticMethodCandidate(t,e)).filter(t=>void 0!==t).map(t=>[t.name,t.method])).entries()];return r.length>1&&this.context.throwEvalError(`imported name '${t}' is ambiguous: ${r.map(([t])=>t).join(", ")}.`),r[0]?.[1]}resolveStaticMethod(t,e){const r=this.context.aliasNameFunction(t);if(!r.includes("."))return this.resolveImportedStaticMethod(r,e);const s=r.split("."),i=s[s.length-1],n=s.slice(0,-1).join("."),a=this.resolveRuntimeClass(n,e,{imports:!1});if("class"!==a?.kind||!a.classDefinition)return;const o=a.classDefinition.findMethod(i,t=>t.isStatic);return o?(this.context.canAccessClassMember(o.classDefinition,o.access)||this.context.throwEvalError(`method '${i}' has ${o.access} access for class ${a.classDefinition.name}.`),ClassStaticMethod.bind(a.classDefinition,o)):void 0}importedStaticMethodCandidate(t,e){const r=t.split(".");if(r.length<2)return;const s=r[r.length-1],i=r.slice(0,-1).join("."),n=this.resolveRuntimeClass(i,e,{imports:!1});if("class"!==n?.kind||!n.classDefinition)return;const a=n.classDefinition.findMethod(s,t=>t.isStatic);return a?(this.context.canAccessClassMember(a.classDefinition,a.access)||this.context.throwEvalError(`method '${s}' has ${a.access} access for class ${n.classDefinition.name}.`),{name:t,method:ClassStaticMethod.bind(n.classDefinition,a)}):void 0}hasQualifiedNameAccessOperand(t,e){return AST.isNodeIndirectRef(t)?void 0!==this.resolveQualifiedAccess(t,e)||this.hasQualifiedNameAccessOperand(t.obj,e):!!AST.isNodeIndexExpr(t)&&this.hasQualifiedNameAccessOperand(t.expr,e)}resolveMetaclassLiteral(t,e){const r=t.split(".");for(let t=r.length;t>=1;t--){const s=r.slice(0,t).join("."),i=this.context.resolveClassDefinition(s,e);if(!i)continue;let n=this.createClassMetaClass(i,e);for(const e of r.slice(t))if(ClassMetaObject.isInstanceOf(n)){const t=n.getProperty(e);void 0===t&&this.context.throwEvalError(`unknown property '${e}' for ${n.kind}.`),n=t}else n=Structure.getField(n,[e]);return n}this.context.throwEvalError(`metaclass: class '${t}' is not defined.`)}createClassMetaClass(t,e=this.context.currentScope){return ClassMetaClass.create(t,t=>t.defaultValue?this.runtimeExpressionValue(this.evaluatedExpressionValue(t.defaultValue,e,`property ${t.name} default`),`property ${t.name} default`):void 0)}createClassMetaProperty(t,e=this.context.currentScope){return ClassMetaProperty.create(t,t=>t.defaultValue?this.runtimeExpressionValue(this.evaluatedExpressionValue(t.defaultValue,e,`property ${t.name} default`),`property ${t.name} default`):void 0)}functionCountMessage(t,e){return"nargchk"===t?"low"===e?{message:"Not enough input arguments.",identifier:"MATLAB:nargchk:notEnoughInputs"}:{message:"Too many input arguments.",identifier:"MATLAB:nargchk:tooManyInputs"}:"narginchk"===t?"low"===e?{message:"Not enough input arguments.",identifier:"MATLAB:narginchk:notEnoughInputs"}:{message:"Too many input arguments.",identifier:"MATLAB:narginchk:tooManyInputs"}:"low"===e?{message:"Not enough output arguments.",identifier:"MATLAB:nargoutchk:notEnoughOutputs"}:{message:"Too many output arguments.",identifier:"MATLAB:nargoutchk:tooManyOutputs"}}functionCountStatus(t,e,r,s){const i=FunctionArity.countBound(t,e,!1,t=>this.context.throwSyntaxError(t)),n=FunctionArity.countBound(t,r,!0,t=>this.context.throwSyntaxError(t));return n<i&&this.context.throwSyntaxError(`${t}: maximum count must be greater than or equal to minimum count.`),s<i?"low":s>n?"high":"ok"}checkFunctionCount(t,e,r){const s="narginchk"===t?Complex.realToNumber(this.context.currentFunctionArgumentCountOrZero()):Complex.realToNumber(this.context.currentFunctionOutputCountOrZero());return"ok"!==this.functionCountStatus(t,e,r,s)&&this.context.throwEvalError(`${t}: invalid number of ${"narginchk"===t?"input":"output"} arguments.`),AST.nodeVoid()}functionCountMessageResult(t,e){const r=FunctionArity.countBound(t,e[2],!1,t=>this.context.throwSyntaxError(t)),s=this.functionCountStatus(t,e[0],e[1],r);if(4===e.length){const r=this.charControlArgument(e[3],`${t} output kind`).str;if(AST.throwInvalidCallError(t,"struct"!==r&&"string"!==r,t=>this.context.throwSyntaxError(t)),"string"===r)return"ok"===s?new CharString(""):CharString.create(this.functionCountMessage(t,s).message,"'");if("ok"===s)return new Structure({});const i=this.functionCountMessage(t,s);return new Structure({message:CharString.create(i.message,"'"),identifier:CharString.create(i.identifier,"'")})}return"ok"===s?new CharString(""):CharString.create(this.functionCountMessage(t,s).message,"'")}nargoutchkResult(t){return 2===t.length?this.checkFunctionCount("nargoutchk",t[0],t[1]):this.functionCountMessageResult("nargoutchk",t)}nargchkResult(t){return this.functionCountMessageResult("nargchk",t)}lookupImportedSourceResolution(t,e,r,s){const i=this.context.aliasNameFunction(t),n=s(i);if(n)return{kind:r,name:t,resolvedName:i,source:"local",sourceName:n.sourceName??n.name??i};if(!i.includes(".")){const n=[...new Map(e.importedNameCandidates(i).map(t=>this.context.aliasNameFunction(t)).map(t=>({importedCanonical:t,source:s(t)})).filter(t=>void 0!==t.source).map(({importedCanonical:e,source:s})=>[e,{kind:r,name:t,resolvedName:e,source:"import",sourceName:s.sourceName??s.name??e}])).values()];if(n.length>1&&this.context.throwEvalError(`imported name '${i}' is ambiguous: ${n.map(t=>t.resolvedName).join(", ")}.`),1===n.length)return n[0]}}lookupClassSourceResolution(t,e){return this.lookupImportedSourceResolution(t,e,"class",t=>this.validClassSource(t))}lookupFunctionSourceResolution(t,e){return this.lookupImportedSourceResolution(t,e,"function",t=>this.validFunctionSource(t))}lookupScriptSourceResolution(t){const e=this.context.aliasNameFunction(t),r=this.validScriptSource(e);if(r)return{kind:"script",name:t,resolvedName:e,source:"local",sourceName:r.sourceName??r.name??e}}lookupDirectorySourceResolution(t){const e=this.context.aliasNameFunction(t);return this.sourceResolver.hasDirectory(e)?{kind:"directory",name:t,resolvedName:e,source:"local"}:void 0}resolveLookupSymbol(t,e,r=this.context.currentScope){const s=e?.trim().toLowerCase();if("dir"===s)return this.lookupDirectorySourceResolution(t);if("builtin"===s){const e=this.context.aliasNameFunction(t),r=this.context.builtInFunctionTable[e];return r?{kind:"builtin",name:t,resolvedName:e,source:"builtin",functionDefinition:r}:void 0}const i="class"===s||void 0===s,n=i||"file"===s,a="file"===s||void 0===s,o="class"!==s&&"var"!==s&&"variable"!==s,l=this.resolveRuntimeSymbol(t,r,{variables:"class"!==s&&"file"!==s&&"function"!==s,classes:i,loadClasses:!1,functions:o,loadFunctions:!1});if(l){if(o&&"builtin"===l.kind){const e=this.lookupFunctionSourceResolution(t,r);if(e)return e}return l}return(o?this.lookupFunctionSourceResolution(t,r):void 0)??(n?this.lookupClassSourceResolution(t,r):void 0)??(a?this.lookupScriptSourceResolution(t):void 0)??("file"===s||void 0===s?this.lookupDirectorySourceResolution(t):void 0)}existCode(t,e){const r=this.resolveLookupSymbol(t,e);return FunctionLookup.existCodeFromResolution(t,e,r)}whichResult(t,e){const r=e?.closure??this.context.currentScope,s=e?e.id?this.resolveLookupSymbol(e.id,"function",r):void 0:this.resolveLookupSymbol(t),i=!s&&t?this.staticMethodInfo(t,r):void 0;return FunctionLookup.whichResultFromResolution(t,s,e,t=>FunctionHandle.unparse(t,this),i)}isClassName(t,e=this.context.currentScope){return FunctionLookup.isRuntimeClassName(t)||Boolean(this.resolveRuntimeClass(t,e,{loadClasses:!1}))||Boolean(this.lookupClassSourceResolution(t,e))}valueIsRuntimeClass(t,e){switch(e){case"double":case"logical":case"char":case"cell":case"struct":case"function_handle":return this.getValueClassName(t)===e;case"event.listener":return ClassEventListener.isInstanceOf(t);case"event.proplistener":return ClassEventListener.isInstanceOf(t)&&"event.proplistener"===t.kind;case"event.EventData":return ClassEventData.isInstanceOf(t)||ClassInstance.isInstanceOf(t)&&t.classDefinition.isSubclassOfName("event.EventData");case"event.PropertyEvent":return ClassPropertyEvent.isInstanceOf(t);default:if(MultiArray.isInstanceOf(t)){const r=MultiArray.linearize(t);return r.length>0&&r.every(t=>this.valueIsRuntimeClass(t,e))}return ClassMetaObject.isInstanceOf(t)?t.kind===e:(ClassInstance.isInstanceOf(t)||!!ClassEnumerationValue.isInstanceOf(t))&&(t.classDefinition.name===e||t.classDefinition.isSubclassOfName(e))}}valueMatchesValidationClass(t,e,r,s=!1){if(FunctionValidation.matchesClass(t,e)||this.valueIsRuntimeClass(t,e))return!0;const i=this.context.resolveClassDefinition(e,r);if(!i)return!1;const n=t=>!(!ClassInstance.isInstanceOf(t)&&!ClassEnumerationValue.isInstanceOf(t))&&(t.classDefinition===i||t.classDefinition.isSubclassOf(i));if(MultiArray.isInstanceOf(t)){const e=MultiArray.linearize(t);return!(0!==e.length||!s||!MultiArray.isEmpty(t))||e.length>0&&e.every(n)}return n(t)}classIntrospectionArgument(t,e){if(!CharString.isInstanceOf(e))return e;const r=e.str,s=this.context.resolveClassDefinition(r);if(s)return s;this.context.throwEvalError(`${t}: class '${r}' is not defined.`)}metaclassArgument(t){if(ClassMetaClass.isInstanceOf(t))return t;if(ClassDefinition.isInstanceOf(t))return this.createClassMetaClass(t);if(ClassInstance.isInstanceOf(t)||ClassEnumerationValue.isInstanceOf(t))return this.createClassMetaClass(t.classDefinition);if(CharString.isInstanceOf(t)){const e=this.context.resolveClassDefinition(t.str);if(e)return this.createClassMetaClass(e);this.context.throwEvalError(`metaclass: class '${t.str}' is not defined.`)}this.context.throwEvalError("metaclass: input must be a class object or class name.")}eventData(t,e){return ClassEventData.create(t,e)}propertyEventData(t,e,r=e,s=t){return ClassPropertyEvent.create(t,e,r,s)}isEventDataObject(t){return ClassEventData.isInstanceOf(t)||ClassInstance.isInstanceOf(t)&&t.classDefinition.isSubclassOfName("event.EventData")}prepareEventDataObject(t,e,r){return ClassEventData.isInstanceOf(r)?(r.source=t,r.eventName=e):ClassInstance.isInstanceOf(r)&&(r.eventDataSource=t,r.eventDataEventName=e),r}propertyEventKey(t,e){return`${t}:${e}`}validateClassEventAccess(t,e,r){const s=t.classDefinition.findEvent(e);if(s){const i="listen"===r?s.listenAccess:s.notifyAccess;return this.context.canAccessClassMember(s.classDefinition,i)||this.context.throwEvalError(`event '${e}' has ${i} ${r} access for class ${t.classDefinition.name}.`),s}const i=t.classDefinition.findProperty(e);i&&(i.isGetObservable||i.isSetObservable)||this.context.throwEvalError(`unknown event '${e}' for class ${t.classDefinition.name}.`)}validatePropertyEventAccess(t,e,r){const s=t.classDefinition.findProperty(e);switch(s||this.context.throwEvalError(`unknown property '${e}' for class ${t.classDefinition.name}.`),r){case"PreGet":case"PostGet":return void(s.isGetObservable||this.context.throwEvalError(`property '${e}' is not GetObservable for class ${t.classDefinition.name}.`));case"PreSet":case"PostSet":return void(s.isSetObservable||this.context.throwEvalError(`property '${e}' is not SetObservable for class ${t.classDefinition.name}.`));default:this.context.throwEvalError(`unknown property event '${r}' for class ${t.classDefinition.name}.`)}}propertyListenerName(t,e,r){if(CharString.isInstanceOf(e))return e.str;if(ClassMetaProperty.isInstanceOf(e)){const r=t.classDefinition.findProperty(e.property.name);return r&&r===e.property||this.context.throwEvalError(`property '${e.property.name}' is not a property of class ${t.classDefinition.name}.`),e.property.name}this.context.throwEvalError(`${r}: property name must be a string or meta.property.`)}propertyListenerNameList(t,e,r){return MultiArray.linearize(e).map((e,s)=>this.propertyListenerName(t,this.expressionValue(e,`property${s+1}`),r))}addClassPropertyListenerArray(t,e,r,s,i){e.classDefinition.isHandleClass()||this.context.throwEvalError(`${t}: source must be a handle object.`),CharString.isInstanceOf(s)||this.context.throwEvalError(`${t}: property event name must be a string.`),FunctionHandle.isInstanceOf(i)||this.context.throwEvalError(`${t}: callback must be a function handle.`);const n=this.propertyListenerNameList(e,r,t),a=new MultiArray(r.dimension);for(let t=0;t<n.length;t++){const r=n[t];this.validatePropertyEventAccess(e,r,s.str);const[o,l]=MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],t);a.array[o][l]=ClassInstance.addListener(e,s.str,i,this.propertyEventKey(r,s.str),"event.proplistener")}return MultiArray.setType(a),a}addClassListenerForSource(t,e,r,s,i,n){const a=4===n?i:s;if(e.classDefinition.isHandleClass()||this.context.throwEvalError(`${t}: source must be a handle object.`),FunctionHandle.isInstanceOf(a)||this.context.throwEvalError(`${t}: callback must be a function handle.`),4===n){CharString.isInstanceOf(s)||this.context.throwEvalError(`${t}: property event name must be a string.`);const i=this.propertyListenerName(e,r,t);return this.validatePropertyEventAccess(e,i,s.str),ClassInstance.addListener(e,s.str,a,this.propertyEventKey(i,s.str),"event.proplistener")}CharString.isInstanceOf(r)||this.context.throwEvalError(`${t}: event name must be a string.`),this.validateClassEventAccess(e,r.str,"listen");const o=e.classDefinition.findProperty(r.str);return ClassInstance.addListener(e,r.str,a,r.str,o?"event.proplistener":"event.listener")}addClassListener(t,...e){const[r,s,i,n]=e;if(MultiArray.isInstanceOf(r)&&this.hasClassInstanceElement(r)){const a=new MultiArray(r.dimension),o=MultiArray.linearize(r);for(let r=0;r<o.length;r++){const l=this.expressionValue(o[r],`source${r+1}`);ClassInstance.isInstanceOf(l)||this.context.throwEvalError(`${t}: source array must contain class instances.`);const[c,u]=MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],r);a.array[c][u]=this.addClassListenerForSource(t,l,s,i,n,e.length)}return MultiArray.setType(a),a}return ClassInstance.isInstanceOf(r)||this.context.throwEvalError(`${t}: source must be a class instance.`),4===e.length&&MultiArray.isInstanceOf(s)?this.addClassPropertyListenerArray(t,r,s,i,n):this.addClassListenerForSource(t,r,s,i,n,e.length)}createClassEventListenerForSource(t,e,r){return ClassInstance.isInstanceOf(t)||this.context.throwEvalError("event.listener: source must be a class instance."),t.classDefinition.isHandleClass()||this.context.throwEvalError("event.listener: source must be a handle object."),CharString.isInstanceOf(e)||this.context.throwEvalError("event.listener: event name must be a string."),FunctionHandle.isInstanceOf(r)||this.context.throwEvalError("event.listener: callback must be a function handle."),this.validateClassEventAccess(t,e.str,"listen")||this.context.throwEvalError("event.listener: event name must name a class event."),ClassInstance.addListener(t,e.str,r,e.str,"event.listener")}createClassEventListener(...t){const[e,r,s]=t;if(MultiArray.isInstanceOf(e)&&this.hasClassInstanceElement(e)){const t=new MultiArray(e.dimension),i=MultiArray.linearize(e);for(let e=0;e<i.length;e++){const n=this.expressionValue(i[e],`source${e+1}`);ClassInstance.isInstanceOf(n)||this.context.throwEvalError("event.listener: source array must contain class instances.");const[a,o]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],e);t.array[a][o]=this.createClassEventListenerForSource(n,r,s)}return MultiArray.setType(t),t}return ClassInstance.isInstanceOf(e)||this.context.throwEvalError("event.listener: source must be a class instance."),this.createClassEventListenerForSource(e,r,s)}createClassPropertyListener(...t){return 4!==t.length&&AST.throwInvalidCallError("event.proplistener",!0,t=>this.context.throwEvalError(t)),this.addClassListener("listener",...t)}notifyClassEventForSource(t,e,r){t.classDefinition.isHandleClass()||this.context.throwEvalError("notify: source must be a handle object."),this.validateClassEventAccess(t,e,"notify"),this.dispatchClassEvent(t,e,r?this.prepareEventDataObject(t,e,r):this.eventData(t,e))}notifyClassEvent(t,e,r){if(CharString.isInstanceOf(e)||this.context.throwEvalError("notify: event name must be a string."),void 0===r||this.isEventDataObject(r)||this.context.throwEvalError("notify: event data must be an event.EventData object."),MultiArray.isInstanceOf(t)&&this.hasClassInstanceElement(t)){for(const s of MultiArray.linearize(t)){const t=this.expressionValue(s,"source");ClassInstance.isInstanceOf(t)||this.context.throwEvalError("notify: source array must contain class instances."),this.notifyClassEventForSource(t,e.str,r)}return AST.nodeVoid()}return ClassInstance.isInstanceOf(t)||this.context.throwEvalError("notify: source must be a class instance."),this.notifyClassEventForSource(t,e.str,r),AST.nodeVoid()}dispatchClassEvent(t,e,r=this.eventData(t,e)){for(const s of ClassInstance.listenersFor(t,e))if(!s.notifying||s.recursive){s.notifying=!0;try{this.context.apply(this.expressionValue(s.callback,"event callback"),this.classMethodArgumentValues([t,r],"event"),AST.nodeIdentifier("notify"))}finally{s.notifying=!1}}}dispatchClassPropertyEvent(t,e,r){const s=t.classDefinition.findProperty(e);s||this.context.throwEvalError(`unknown property '${e}' for class ${t.classDefinition.name}.`);const i=this.createClassMetaProperty(s),n=this.propertyEventData(t,e,r,i);for(const s of ClassInstance.listenersFor(t,this.propertyEventKey(e,r)))if(!s.notifying||s.recursive){s.notifying=!0;try{this.context.apply(this.expressionValue(s.callback,"property event callback"),this.classMethodArgumentValues([i,n],"property event"),AST.nodeIdentifier("addlistener"))}finally{s.notifying=!1}}if("PostGet"===r||"PostSet"===r){const r=this.propertyEventData(t,e,e,i);for(const s of ClassInstance.listenersFor(t,e))if(!s.notifying||s.recursive){s.notifying=!0;try{this.context.apply(this.expressionValue(s.callback,"property event callback"),this.classMethodArgumentValues([i,r],"property event"),AST.nodeIdentifier("addlistener"))}finally{s.notifying=!1}}}}resolveClassEventDataField(t,e){const r=ClassPropertyEvent.isInstanceOf(t)?ClassPropertyEvent.getProperty(t,e):ClassEventData.getProperty(t,e);return void 0===r&&("Source"!==e&&"EventName"!==e||this.context.throwEvalError(`event data ${e} is not assigned until notify dispatch.`),this.context.throwEvalError(`unknown property '${e}' for ${ClassPropertyEvent.isInstanceOf(t)?"event.PropertyEvent":"event.EventData"}.`)),r}setClassEventDataField(t,e){this.context.throwEvalError(`cannot assign to read-only property '${e}' for ${ClassPropertyEvent.isInstanceOf(t)?"event.PropertyEvent":"event.EventData"}.`)}resolveClassEventListenerField(t,e){switch(ClassEventListener.isValid(t)||this.context.throwEvalError("invalid or deleted event listener."),e){case"Callback":return t.callback;case"Enabled":return t.enabled?Complex.true():Complex.false();case"EventName":return CharString.create(t.eventName);case"Recursive":return t.recursive?Complex.true():Complex.false();case"Source":case"Object":return t.source;default:this.context.throwEvalError(`unknown property '${e}' for ${t.kind}.`)}}removeClassEventListenerRegistration(t){if(!ClassInstance.isInstanceOf(t.source))return;const e=t.source.listeners[t.listenerKey];if(!e)return;const r=e.indexOf(t);r>=0&&e.splice(r,1),0===e.length&&delete t.source.listeners[t.listenerKey]}addClassEventListenerRegistration(t,e){ClassInstance.isInstanceOf(t.source)&&(t.source.listeners[e]??=[],t.source.listeners[e].includes(t)||t.source.listeners[e].push(t))}setClassEventListenerEventName(t,e){CharString.isInstanceOf(e)||this.context.throwEvalError("event listener EventName must be a string."),ClassInstance.isInstanceOf(t.source)||this.context.throwEvalError(`cannot assign EventName for ${t.kind}.`);let r=e.str;if("event.proplistener"===t.kind){const[s,i]=t.listenerKey.split(":");void 0===i&&this.context.throwEvalError(`cannot assign EventName for ${t.kind}.`),this.validatePropertyEventAccess(t.source,s,e.str),r=this.propertyEventKey(s,e.str)}else this.validateClassEventAccess(t.source,e.str,"listen")||this.context.throwEvalError("event listener EventName must name a class event.");this.removeClassEventListenerRegistration(t),t.eventName=e.str,t.listenerKey=r,this.addClassEventListenerRegistration(t,r)}setClassEventListenerSource(t,e){if(ClassInstance.isInstanceOf(e)||this.context.throwEvalError("event listener Source must be a class instance."),e.classDefinition.isHandleClass()||this.context.throwEvalError("event listener Source must be a handle object."),"event.proplistener"===t.kind){const[r,s]=t.listenerKey.split(":");void 0===s?this.validateClassEventAccess(e,t.eventName,"listen"):this.validatePropertyEventAccess(e,r,t.eventName)}else this.validateClassEventAccess(e,t.eventName,"listen")||this.context.throwEvalError("event listener Source must define the listener EventName as a class event.");this.removeClassEventListenerRegistration(t),t.source=e,this.addClassEventListenerRegistration(t,t.listenerKey)}setClassEventListenerField(t,e,r){switch(ClassEventListener.isValid(t)||this.context.throwEvalError("invalid or deleted event listener."),e){case"Callback":return FunctionHandle.isInstanceOf(r)||this.context.throwEvalError("event listener Callback must be a function handle."),void(t.callback=r);case"Enabled":return void(t.enabled=this.toBoolean(r));case"EventName":return void this.setClassEventListenerEventName(t,r);case"Recursive":return void(t.recursive=this.toBoolean(r));case"Source":case"Object":return void this.setClassEventListenerSource(t,r);default:this.context.throwEvalError(`cannot assign to read-only property '${e}' for ${t.kind}.`)}}resolveSetGetProperty(t,e,r){t.classDefinition.isSetGetClass()||this.context.throwEvalError(`${r}: first argument must be a matlab.mixin.SetGet object.`);const s=t.classDefinition.allProperties(),i=s.filter(t=>t.name===e);if(1===i.length)return i[0];i.length>1&&this.context.throwEvalError(`${r}: ambiguous property name '${e}' for class ${t.classDefinition.name}.`),t.classDefinition.isSetGetExactNamesClass()&&this.context.throwEvalError(`${r}: unknown property '${e}' for class ${t.classDefinition.name}.`);const n=e.toLowerCase(),a=s.filter(t=>t.name.toLowerCase()===n);if(1===a.length)return a[0];a.length>1&&this.context.throwEvalError(`${r}: ambiguous property name '${e}' for class ${t.classDefinition.name}.`);const o=s.filter(t=>t.name.toLowerCase().startsWith(n));0===o.length&&this.context.throwEvalError(`${r}: unknown property '${e}' for class ${t.classDefinition.name}.`);const l=Math.min(...o.map(t=>t.partialMatchPriority)),c=o.filter(t=>t.partialMatchPriority===l);return 1!==c.length&&this.context.throwEvalError(`${r}: ambiguous partial property name '${e}' for class ${t.classDefinition.name}.`),c[0]}isSetGetSettableProperty(t){return!(t.isConstant||"public"!==t.setAccess||t.isDependent&&!t.setMethodName&&!t.classDefinition.findMethod(`set.${t.name}`,t=>!t.isStatic))}assertSetGetSettableProperty(t,e){this.isSetGetSettableProperty(t)||this.context.throwEvalError(`${e}: property '${t.name}' is not publicly settable for class ${t.classDefinition.name}.`)}setGetObject(t,e){if(MultiArray.isInstanceOf(t)&&this.hasClassInstanceElement(t))return this.setGetArrayRepresentative(t,e),t;ClassInstance.isInstanceOf(t)||this.context.throwEvalError(`${e}: first argument must be a matlab.mixin.SetGet object.`);try{ClassInstance.throwIfDeleted(t)}catch(t){this.context.throwEvalError(t.message)}return t.classDefinition.isSetGetClass()||this.context.throwEvalError(`${e}: first argument must be a matlab.mixin.SetGet object.`),t}setGetArrayRepresentative(t,e){const r=MultiArray.linearize(t);0===r.length&&this.context.throwEvalError(`${e}: first argument must be a nonempty matlab.mixin.SetGet object array.`);const s=r[0];ClassInstance.isInstanceOf(s)||this.context.throwEvalError(`${e}: first argument must be a matlab.mixin.SetGet object.`);for(const t of r){ClassInstance.isInstanceOf(t)||this.context.throwEvalError(`${e}: first argument must be a matlab.mixin.SetGet object.`);try{ClassInstance.throwIfDeleted(t)}catch(t){this.context.throwEvalError(t.message)}t.classDefinition.isSetGetClass()||this.context.throwEvalError(`${e}: first argument must be a matlab.mixin.SetGet object.`)}return s}setGetStructure(t){const e={};for(const r of t.classDefinition.allProperties().filter(t=>!t.isHidden&&"public"===t.getAccess))e[r.name]=this.runtimeExpressionValue(this.resolveClassInstanceField(t,r.name,AST.nodeIdentifier("get")),`property ${r.name}`);return new Structure(e)}setGetStructureArray(t){const e=new MultiArray([MultiArray.linearLength(t),1]);for(let r=0;r<MultiArray.linearLength(t);r++){const[s,i]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],r),n=t.array[s][i];ClassInstance.isInstanceOf(n)||this.context.throwEvalError("get: first argument must be a matlab.mixin.SetGet object."),e.array[r][0]=this.setGetStructure(n)}return MultiArray.setType(e),e}setGetPropertyNames(t,e){if(CharString.isInstanceOf(t))return[t.str];if(MultiArray.isInstanceOf(t)&&t.isCell){const r=MultiArray.linearize(t);if(r.every(CharString.isInstanceOf))return this.charStringList(r,`${e} property name cell array`).map(t=>t.str)}return AST.throwInvalidCallError(e),[]}getSetGetPropertyCell(t,e){const r=ClassInstance.isInstanceOf(t)?[t]:MultiArray.linearize(t),s=new MultiArray([r.length,e.length],void 0,!0);return r.forEach((t,r)=>{ClassInstance.isInstanceOf(t)||this.context.throwEvalError("get: first argument must be a matlab.mixin.SetGet object."),e.forEach((e,i)=>{s.array[r][i]=this.resolveClassInstanceField(t,e.name,AST.nodeIdentifier("get"))})}),MultiArray.setType(s),s}setSetGetPropertyCell(t,e,r){e.isCell&&1===e.dimension[0]||this.context.throwEvalError("set: property name cell array must be 1-by-N."),r.isCell||AST.throwInvalidCallError("set");const s=MultiArray.linearize(e);s.every(CharString.isInstanceOf)||AST.throwInvalidCallError("set");const i=ClassInstance.isInstanceOf(t)?[t]:MultiArray.linearize(t),n=s.length;r.dimension[0]===i.length&&r.dimension[1]===n||this.context.throwEvalError(`set: property value cell array must be ${i.length}-by-${n}.`);const a=ClassInstance.isInstanceOf(t)?t:this.setGetArrayRepresentative(t,"set"),o=this.charStringList(s,"set property name cell array").map(t=>{const e=this.resolveSetGetProperty(a,t.str,"set");return this.assertSetGetSettableProperty(e,"set"),e});i.forEach((e,s)=>{ClassInstance.isInstanceOf(e)||this.context.throwEvalError("set: first argument must be a matlab.mixin.SetGet object."),o.forEach((i,n)=>{const a=this.assignClassInstanceField(e,i.name,r.array[s][n],AST.nodeIdentifier("set"),this.context.currentScope);if(MultiArray.isInstanceOf(t)){const[e,r]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],s);t.array[e][r]=a}})}),MultiArray.isInstanceOf(t)&&MultiArray.setType(t)}assignSetGetProperty(t,e,r){const s=ClassInstance.isInstanceOf(t)?t:this.setGetArrayRepresentative(t,"set"),i=this.resolveSetGetProperty(s,e,"set");this.assertSetGetSettableProperty(i,"set"),ClassInstance.isInstanceOf(t)?this.assignClassInstanceField(t,i.name,r,AST.nodeIdentifier("set"),this.context.currentScope):this.assignClassArrayField(t,i.name,r,AST.nodeIdentifier("set"),this.context.currentScope)}setGetSettableStructure(t){const e={};for(const r of t.classDefinition.allProperties().filter(t=>!t.isHidden&&this.isSetGetSettableProperty(t)))e[r.name]=MultiArray.emptyArray(!0);return new Structure(e)}getSetGetProperty(t){const e=this.setGetObject(t[0],"get");if(1===t.length)return ClassInstance.isInstanceOf(e)?this.setGetStructure(e):this.setGetStructureArray(e);2===t.length&&CharString.isInstanceOf(t[1])||2===t.length&&MultiArray.isInstanceOf(t[1])&&t[1].isCell||AST.throwInvalidCallError("get");const r=ClassInstance.isInstanceOf(e)?e:this.setGetArrayRepresentative(e,"get"),s=this.setGetPropertyNames(t[1],"get").map(t=>this.resolveSetGetProperty(r,t,"get"));if(ClassInstance.isInstanceOf(e)&&CharString.isInstanceOf(t[1]))return this.resolveClassInstanceField(e,s[0].name,AST.nodeIdentifier("get"));if(MultiArray.isInstanceOf(e)&&CharString.isInstanceOf(t[1])){const t=new MultiArray(e.dimension,void 0,!0);for(let r=0;r<MultiArray.linearLength(e);r++){const[i,n]=MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],r),a=e.array[i][n];ClassInstance.isInstanceOf(a)||this.context.throwEvalError("get: first argument must be a matlab.mixin.SetGet object."),t.array[i][n]=this.resolveClassInstanceField(a,s[0].name,AST.nodeIdentifier("get"))}return MultiArray.setType(t),t}return this.getSetGetPropertyCell(e,s)}setSetGetProperties(t){const e=this.setGetObject(t[0],"set");if(1===t.length){if(ClassInstance.isInstanceOf(e))return this.setGetSettableStructure(e);AST.throwInvalidCallError("set")}if(2===t.length){if(CharString.isInstanceOf(t[1])){const r=ClassInstance.isInstanceOf(e)?e:this.setGetArrayRepresentative(e,"set"),s=this.resolveSetGetProperty(r,t[1].str,"set");return this.assertSetGetSettableProperty(s,"set"),MultiArray.emptyArray(!0)}if(Structure.isInstanceOf(t[1])){for(const[r,s]of Object.entries(t[1].field))this.assignSetGetProperty(e,r,s);return AST.nodeVoid()}AST.throwInvalidCallError("set")}if(Structure.isInstanceOf(t[1])){(t.length-2)%2!=0&&AST.throwInvalidCallError("set");for(const[r,s]of Object.entries(t[1].field))this.assignSetGetProperty(e,r,s);for(let r=2;r<t.length;r+=2){const s=t[r];CharString.isInstanceOf(s)||AST.throwInvalidCallError("set"),this.assignSetGetProperty(e,s.str,t[r+1])}return AST.nodeVoid()}if(MultiArray.isInstanceOf(t[1])&&t[1].isCell){MultiArray.isInstanceOf(t[2])&&t[2].isCell||AST.throwInvalidCallError("set"),this.setSetGetPropertyCell(e,t[1],t[2]),(t.length-3)%2!=0&&AST.throwInvalidCallError("set");for(let r=3;r<t.length;r+=2){const s=t[r];CharString.isInstanceOf(s)||AST.throwInvalidCallError("set"),this.assignSetGetProperty(e,s.str,t[r+1])}return AST.nodeVoid()}t.length%2==0&&AST.throwInvalidCallError("set");for(let r=1;r<t.length;r+=2){const s=t[r];CharString.isInstanceOf(s)||AST.throwInvalidCallError("set"),this.assignSetGetProperty(e,s.str,t[r+1])}return AST.nodeVoid()}functions={unparse:{func:t=>new CharString(this.Unparse(t)),signature:{inputs:{arity:1},outputs:{arity:1}}},clear:{func:(...t)=>(this.Clear(...t.map(t=>this.charControlArgument(t,"clear name").str)),AST.nodeVoid()),signature:{inputs:{arity:-1,min:0,parameters:[{name:"name",classes:["char","string"],variadic:!0}]},outputs:{arity:0}}},who:{func:(...t)=>this.whoResult(t),signature:{inputs:{arity:-1,min:0,parameters:[{name:"pattern",classes:["char","string"],variadic:!0}]},outputs:{arity:1}}},whos:{func:(...t)=>this.whosResult(t),signature:{inputs:{arity:-1,min:0,parameters:[{name:"pattern",classes:["char","string"],variadic:!0}]},outputs:{arity:1}}},iskeyword:{func:(...t)=>this.isKeywordResult(t),signature:{inputs:{arity:-1,min:0,max:1,parameters:[{name:"name",classes:["char","string","cell"],optional:!0}]},outputs:{arity:1}}},isvarname:{func:(...t)=>this.isVarNameResult(t),signature:{inputs:{arity:1,parameters:[{name:"name",classes:["char","string","cell"]}]},outputs:{arity:1}}},isglobal:{func:(...t)=>this.isGlobalResult(t),signature:{inputs:{arity:1,parameters:[{name:"name",classes:["char","string","cell"]}]},outputs:{arity:1}}},namelengthmax:{func:(...t)=>(AST.throwInvalidCallError("namelengthmax",0!==t.length,t=>this.context.throwEvalError(t)),Complex.create(Interpreter.nameLengthMax)),signature:{inputs:{arity:0},outputs:{arity:1}}},class:{func:(...t)=>new CharString(this.getValueClassName(t[0])),signature:{inputs:{arity:1},outputs:{arity:1}}},isa:{func:(...t)=>this.valueIsRuntimeClass(t[0],this.charControlArgument(t[1],"class name").str)?Complex.true():Complex.false(),signature:{inputs:{arity:2,parameters:[{name:"value"},{name:"className",classes:["char","string"]}]},outputs:{arity:1}}},isclass:{func:(...t)=>this.isClassName(this.charControlArgument(t[0],"class name").str)?Complex.true():Complex.false(),signature:{inputs:{arity:1,parameters:[{name:"className",classes:["char","string"]}]},outputs:{arity:1}}},metaclass:{func:(...t)=>this.metaclassArgument(t[0]),signature:{inputs:{arity:1,parameters:[{name:"object"}]},outputs:{arity:1}}},__meta_class_fromName:{func:(...t)=>{const e=this.context.resolveClassDefinition(this.charControlArgument(t[0],"class name").str);return e?this.createClassMetaClass(e):MultiArray.emptyArray()},signature:{inputs:{arity:1,parameters:[{name:"className",classes:["char","string"]}]},outputs:{arity:1}}},properties:{func:(...t)=>CoreFunctions.properties(this.classIntrospectionArgument("properties",t[0])),signature:CoreFunctions.propertiesSignature},fieldnames:{func:(...t)=>CoreFunctions.fieldnames(this.classIntrospectionArgument("fieldnames",t[0])),signature:CoreFunctions.fieldnamesSignature},methods:{func:(...t)=>CoreFunctions.methods(this.classIntrospectionArgument("methods",t[0])),signature:CoreFunctions.methodsSignature},events:{func:(...t)=>CoreFunctions.events(this.classIntrospectionArgument("events",t[0])),signature:CoreFunctions.eventsSignature},enumeration:{func:(...t)=>CoreFunctions.enumeration(this.classIntrospectionArgument("enumeration",t[0])),signature:CoreFunctions.enumerationSignature},superclasses:{func:(...t)=>CoreFunctions.superclasses(this.classIntrospectionArgument("superclasses",t[0])),signature:CoreFunctions.superclassesSignature},isprop:{func:(...t)=>CoreFunctions.isprop(this.classIntrospectionArgument("isprop",t[0]),t[1]),signature:CoreFunctions.ispropSignature},ismethod:{func:(...t)=>CoreFunctions.ismethod(this.classIntrospectionArgument("ismethod",t[0]),t[1]),signature:CoreFunctions.ismethodSignature},addlistener:{func:(...t)=>this.addClassListener("addlistener",...t),signature:{inputs:[{arity:3,parameters:[{name:"source"},{name:"eventName",classes:["char","string"]},{name:"callback"}]},{arity:4,parameters:[{name:"source"},{name:"propertyName"},{name:"propertyEventName",classes:["char","string"]},{name:"callback"}]}],outputs:{arity:1}}},listener:{func:(...t)=>this.addClassListener("listener",...t),signature:{inputs:[{arity:3,parameters:[{name:"source"},{name:"eventName",classes:["char","string"]},{name:"callback"}]},{arity:4,parameters:[{name:"source"},{name:"propertyName"},{name:"propertyEventName",classes:["char","string"]},{name:"callback"}]}],outputs:{arity:1}}},"event.listener":{func:(...t)=>this.createClassEventListener(...t),signature:{inputs:{arity:3,parameters:[{name:"source"},{name:"eventName",classes:["char","string"]},{name:"callback"}]},outputs:{arity:1}}},"event.EventData":{func:()=>ClassEventData.create(),signature:{inputs:{arity:0},outputs:{arity:1}}},"event.proplistener":{func:(...t)=>this.createClassPropertyListener(...t),signature:{inputs:{arity:4,parameters:[{name:"source"},{name:"propertyName"},{name:"propertyEventName",classes:["char","string"]},{name:"callback"}]},outputs:{arity:1}}},notify:{func:(...t)=>this.notifyClassEvent(t[0],t[1],t[2]),signature:{inputs:[{arity:2,parameters:[{name:"source"},{name:"eventName",classes:["char","string"]}]},{arity:3,parameters:[{name:"source"},{name:"eventName",classes:["char","string"]},{name:"eventData"}]}],outputs:{arity:0}}},get:{func:(...t)=>this.getSetGetProperty(t),signature:{inputs:[{arity:1,parameters:[{name:"object"}]},{arity:2,parameters:[{name:"object"},{name:"propertyName",classes:["char","string","cell"]}]}],outputs:{arity:-1}}},set:{func:(...t)=>this.setSetGetProperties(t),signature:{inputs:[{arity:1,parameters:[{name:"object"}]},{arity:2,parameters:[{name:"object"},{name:"propertyNameOrStruct"}]},{arity:-1,min:3,parameters:[{name:"object"},{name:"propertyName",classes:["char","string","cell","struct"]},{name:"propertyValue",variadic:!0}]}],outputs:{arity:-1,min:0,max:1}}},mfilename:{func:(...t)=>{const e=1===t.length?this.charControlArgument(t[0],"mfilename option").str:"";return new CharString("class"===e?this.context.currentClassAccessName():"fullpath"===e?this.currentMFilenameFullPath():this.currentMFilename())},signature:{inputs:{arity:-1,min:0,max:1,parameters:[{name:"option",classes:["char","string"],optional:!0}]},outputs:{arity:-1}}},dbstack:{func:(...t)=>this.dbstackResult(t),signature:{inputs:{arity:-2,min:0,max:2,parameters:[{name:"optionOrCount",optional:!0,variadic:!0,alternatives:[{name:"option",classes:["char","string"],allowedStrings:["-completenames"]},{name:"count",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]}]}]},outputs:{arity:-1}}},lasterror:{func:(...t)=>this.lastErrorResult(t),signature:{inputs:{arity:-1,min:0,max:1,parameters:[{name:"error",optional:!0,alternatives:[{name:"reset",classes:["char","string"],allowedStrings:["reset"]},{name:"errorStruct",classes:["struct"]}]}]},outputs:{arity:-1}}},lasterr:{func:(...t)=>this.lastErrorMessageResult(t),signature:{inputs:{arity:-2,min:0,max:2,parameters:[{name:"message",classes:["char","string"],optional:!0},{name:"identifier",classes:["char","string"],optional:!0}]},outputs:{arity:-2}}},lastwarn:{func:(...t)=>this.lastWarningResult(t),signature:{inputs:{arity:-2,min:0,max:2,parameters:[{name:"message",classes:["char","string"],optional:!0},{name:"identifier",classes:["char","string"],optional:!0}]},outputs:{arity:-2}}},deal:{func:(...t)=>this.dealResult(t),signature:{inputs:{arity:-1,min:1,parameters:[{name:"value",variadic:!0}]},outputs:{arity:-1}}},subsref:{func:(...t)=>this.subsrefResult(t[0],t[1]),signature:{inputs:{arity:2,parameters:[{name:"value"},{name:"subscript",classes:["struct"]}]},outputs:{arity:-1,min:0}}},subsasgn:{func:(...t)=>this.subsasgnResult(t[0],t[1],t[2]),signature:{inputs:{arity:3,parameters:[{name:"value"},{name:"subscript",classes:["struct"]},{name:"newValue"}]},outputs:{arity:1}}},warning:{func:(...t)=>this.warningResult(t),signature:{inputs:[{arity:0},{arity:1,parameters:[{name:"stateStruct",classes:["struct"]}]},{arity:-1,min:1,parameters:[{name:"message",classes:["char","string"]},{name:"formatValue",variadic:!0}]},{arity:-2,min:2,parameters:[{name:"identifier",classes:["char","string"]},{name:"message",classes:["char","string"]},{name:"formatValue",variadic:!0}]}],outputs:{arity:-1,min:0,max:1}}},error:{func:(...t)=>this.errorResult(t),signature:{inputs:[{arity:1,parameters:[{name:"errorStruct",classes:["struct"]}]},{arity:-1,min:1,parameters:[{name:"message",classes:["char","string"]},{name:"formatValue",variadic:!0}]},{arity:-2,min:2,parameters:[{name:"identifier",classes:["char","string"]},{name:"message",classes:["char","string"]},{name:"formatValue",variadic:!0}]}],outputs:{arity:0}}},assert:{func:(...t)=>this.assertResult(t),signature:{inputs:{arity:-1,min:1,parameters:[{name:"argument",variadic:!0}]},outputs:{arity:0}}},rethrow:{func:(...t)=>this.rethrowResult(t[0]),signature:{inputs:{arity:1,parameters:[{name:"errorStruct",classes:["struct"]}]},outputs:{arity:0}}},exist:{func:(...t)=>Complex.create(this.existCode(this.charControlArgument(t[0],"name").str,2===t.length?this.charControlArgument(t[1],"kind").str:void 0)),signature:{inputs:{arity:-2,min:1,max:2,parameters:[{name:"name",classes:["char","string"]},{name:"kind",classes:["char","string"],optional:!0}]},outputs:{arity:1}}},which:{func:(...t)=>{if(FunctionHandle.isInstanceOf(t[0])){const e=this.functionHandleControlArgument(t[0],"function handle");return this.whichResult(e.id??FunctionHandle.unparse(e,this).trim(),e)}return this.whichResult(this.charControlArgument(t[0],"name").str)},signature:{inputs:{arity:1,parameters:[{name:"name",classes:["char","string","function_handle"]}]},outputs:{arity:1}}},validatestring:{func:(...t)=>this.validatestringResult(t),signature:{inputs:{arity:-1,min:2,max:5,parameters:[{name:"string",classes:["char","string"]},{name:"validStrings",classes:["char","string","cell"]},{name:"functionName",classes:["char","string"],optional:!0},{name:"variableName",classes:["char","string"],optional:!0},{name:"argumentPosition",optional:!0}]},outputs:{arity:1}}},validateattributes:{func:(...t)=>this.validateattributesResult(t),signature:{inputs:{arity:-1,min:3,max:6,parameters:[{name:"value"},{name:"classes",classes:["char","string","cell"]},{name:"attributes",classes:["char","string","cell"]},{name:"functionNameOrArgumentPosition",optional:!0},{name:"variableName",classes:["char","string"],optional:!0},{name:"argumentPosition",optional:!0}]},outputs:{arity:0}}},...this.mustBeFunctionEntries(),func2str:{func:(...t)=>FunctionLookup.func2str(this.functionHandleControlArgument(t[0],"function handle"),t=>FunctionHandle.unparse(t,this)),signature:{inputs:{arity:1,parameters:[{name:"functionHandle",classes:["function_handle"]}]},outputs:{arity:1}}},str2func:{func:(...t)=>{const e=t.length>1?this.charControlArgument(t[1],"scope").str.trim().toLowerCase():"";return this.functionHandleFromString(this.charControlArgument(t[0],"source"),"global"===e)},signature:{inputs:{arity:-1,min:1,max:2,parameters:[{name:"source",classes:["char","string"]},{name:"scope",classes:["char","string"],allowedStrings:["global"],optional:!0}]},outputs:{arity:1}}},builtin:{func:(...t)=>{const e=this.charControlArgument(t[0],"builtin function").str.trim();0===e.length&&this.context.throwEvalError("builtin: function name cannot be empty.");const r=this.context.aliasNameFunction(e),s=this.context.builtInFunctionTable[r];return s||this.context.throwEvalError(`builtin: '${e}' is not a built-in function.`),this.context.callCallable(Callables.builtin(s),this.callArgumentValues(t.slice(1),"builtin"),AST.nodeIdentifier("builtin"))},signature:{inputs:{arity:-1,min:1,parameters:[{name:"function",classes:["char","string"]},{name:"argument",variadic:!0}]},outputs:{arity:-1}}},feval:{func:(...t)=>{let e=this.expressionValue(t[0],"feval target");if(CharString.isInstanceOf(e)){const r=e.str.trim();0===r.length&&this.context.throwEvalError("feval: function name cannot be empty.");const s=r.startsWith("@")?void 0:this.resolveStaticMethod(r,this.context.currentScope);if(s)return this.context.callClassStaticMethod(s.method,this.callArgumentValues(t.slice(1),"feval"),AST.nodeIdentifier("feval"));e=r.startsWith("@")?this.functionHandleFromString(e):this.createResolvedFunctionHandle(r,this.context.currentScope,void 0,!1,!0)}const r=this.context.resolveCallable(e);return r||this.context.throwEvalError("feval: first argument must be a function handle or function name."),this.context.callCallable(r,this.callArgumentValues(t.slice(1),"feval"),AST.nodeIdentifier("feval"))},signature:{inputs:{arity:-1,min:1,parameters:[{name:"function",classes:["char","string","function_handle"]},{name:"argument",variadic:!0}]},outputs:{arity:-1}}},spfun:{func:(...t)=>{const e=this.context.resolveCallable(this.expressionValue(t[0],"spfun function"));e||this.context.throwEvalError("spfun: first argument must be a function handle.");const r=MultiArray.scalarToMultiArray(this.expressionValue(t[1],"spfun input")),s=new MultiArray(r.dimension,Complex.zero()),i=MultiArray.linearize(r);for(let t=0;t<i.length;t++){if(!CoreFunctions.isNonzeroElement(i[t]))continue;const n=this.expressionValue(RuntimeValue.copy(i[t]),"spfun value"),a=this.expressionValue(this.context.callCallable(e,[n],AST.nodeIdentifier("spfun")),"spfun result"),o=MultiArray.MultiArrayToScalar(a);MultiArray.isInstanceOf(o)&&this.context.throwEvalError("spfun: function must return a scalar value for each nonzero element.");const[l,c]=MultiArray.linearIndexToMultiArrayRowColumn(r.dimension[0],r.dimension[1],t);s.array[l][c]=RuntimeValue.copy(o)}return MultiArray.setType(s),MultiArray.MultiArrayToScalar(s)},signature:{inputs:{arity:2,parameters:[{name:"function",classes:["function_handle"]},{name:"value",alternatives:[{name:"numericValue",classes:["double"]},{name:"logicalValue",classes:["logical"]}]}]},outputs:{arity:1}}},functions:{func:(...t)=>{const e=this.functionHandleControlArgument(t[0],"function handle"),r=e.closure??this.context.currentScope;return FunctionLookup.functionsInfo(e,t=>this.context.aliasNameFunction(t),t=>this.context.resolveSymbol(t,r,{variables:!1,classes:!1,loadFunctions:!1})?.functionDefinition,t=>FunctionHandle.unparse(t,this),t=>this.functionHandleWorkspaceInfo(t),(t,e)=>this.staticMethodInfo(t,e?.closure??this.context.currentScope))},signature:{inputs:{arity:1,parameters:[{name:"functionHandle",classes:["function_handle"]}]},outputs:{arity:1}}},localfunctions:{func:(...t)=>this.localFunctionHandles(),signature:{inputs:{arity:0},outputs:{arity:1}}},nargin:{func:(...t)=>0===t.length?this.context.currentFunctionArgumentCount("nargin"):Complex.create(this.functionArgumentArity(this.functionArityCallable("nargin",t[0]))),signature:{inputs:{arity:-1,min:0,max:1,parameters:[{name:"function",classes:["char","string","function_handle"],optional:!0}]},outputs:{arity:1}}},narginchk:{func:(...t)=>this.checkFunctionCount("narginchk",t[0],t[1]),signature:{inputs:{arity:2,parameters:[{name:"min",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"max",classes:["double"],validators:["numeric","scalar","real","integer","nonnegative"],allowInfinity:!0}]},outputs:{arity:0}}},nargchk:{func:(...t)=>this.nargchkResult(t),signature:{inputs:{arity:-1,min:3,max:4,parameters:[{name:"min",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"max",classes:["double"],validators:["numeric","scalar","real","integer","nonnegative"],allowInfinity:!0},{name:"inputCount",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"outputKind",classes:["char","string"],allowedStrings:["struct","string"],optional:!0}]},outputs:{arity:1}}},nargout:{func:(...t)=>0===t.length?this.context.currentFunctionOutputCount("nargout"):Complex.create(this.functionOutputArity(this.functionArityCallable("nargout",t[0]))),signature:{inputs:{arity:-1,min:0,max:1,parameters:[{name:"function",classes:["char","string","function_handle"],optional:!0}]},outputs:{arity:1}}},isargout:{func:(...t)=>this.context.currentFunctionOutputIsRequested(t[0]),signature:{inputs:{arity:1,parameters:[{name:"outputNumber",classes:["double"],validators:["numeric","real","integer","positive"]}]},outputs:{arity:1}}},nargoutchk:{func:(...t)=>this.nargoutchkResult(t),signature:{inputs:{arity:-1,min:2,max:4,parameters:[{name:"min",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"max",classes:["double"],validators:["numeric","scalar","real","integer","nonnegative"],allowInfinity:!0},{name:"outputCount",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],optional:!0},{name:"outputKind",classes:["char","string"],allowedStrings:["struct","string"],optional:!0}]},outputs:{arity:1}}},nthargout:{func:(...t)=>this.nthargoutResult(t),signature:{inputs:{arity:-2,min:2,parameters:[{name:"outputNumber",classes:["double"],validators:["numeric","real","integer","positive"]},{name:"functionOrTotalOutputCount"},{name:"argument",variadic:!0}]},outputs:{arity:1}}},inputname:{func:(...t)=>{const e=2!==t.length||this.booleanControlArgument(t[1],"inputname onlyVariableNames");return this.context.currentFunctionInputName(t[0],e,t=>this.Unparse(t))},signature:{inputs:[{arity:1,parameters:[{name:"argumentNumber",classes:["double"],validators:["numeric","scalar","real","finite","integer","positive"]}]},{arity:2,parameters:[{name:"argumentNumber",classes:["double"],validators:["numeric","scalar","real","finite","integer","positive"]},{name:"onlyVariableNames",classes:["logical"],validators:["scalar"]}]}],outputs:{arity:1}}},eval:{func:(...t)=>FunctionWorkspace.evaluateWithCatch(this.context.currentScope,this.charControlArgument(t[0],"eval code").str,2===t.length?this.charControlArgument(t[1],"eval catch code").str:void 0,(t,e)=>this.evalStringInScope(t,e),t=>this.isEvalCatchableError(t),t=>this.rememberLastError(t)),signature:{inputs:{arity:-2,min:1,max:2,parameters:[{name:"code",classes:["char","string"]},{name:"catchCode",classes:["char","string"],optional:!0}]},outputs:{arity:-1}}},evalc:{func:(...t)=>this.evalcResult(this.charControlArgument(t[0],"evalc code").str,2===t.length?this.charControlArgument(t[1],"evalc catch code").str:void 0),signature:{inputs:{arity:-2,min:1,max:2,parameters:[{name:"code",classes:["char","string"]},{name:"catchCode",classes:["char","string"],optional:!0}]},outputs:{arity:-1}}},evalin:{func:(...t)=>{const e=this.charControlArgument(t[0],"workspace").str,r=this.context.resolveWorkspace(e,!1,"caller"===e);return FunctionWorkspace.evaluateWithCatch(r,this.charControlArgument(t[1],"evalin code").str,3===t.length?this.charControlArgument(t[2],"evalin catch code").str:void 0,(t,r)=>this.evalStringInScope(t,r,{topLevelReturn:"base"===e}),t=>this.isEvalCatchableError(t),t=>this.rememberLastError(t))},signature:{inputs:{arity:-3,min:2,max:3,parameters:[{name:"workspace",classes:["char","string"],allowedStrings:["base","caller"]},{name:"code",classes:["char","string"]},{name:"catchCode",classes:["char","string"],optional:!0}]},outputs:{arity:-1}}},run:{func:(...t)=>this.RunScriptFile(this.charControlArgument(t[0],"script").str,this.context.currentScope),signature:{inputs:{arity:1,parameters:[{name:"script",classes:["char","string"]}]},outputs:{arity:1}}},source:{func:(...t)=>{const e=2===t.length?this.context.resolveWorkspace(this.charControlArgument(t[1],"workspace").str):this.context.currentScope;return this.RunScriptFile(this.charControlArgument(t[0],"script").str,e)},signature:{inputs:{arity:-2,min:1,max:2,parameters:[{name:"script",classes:["char","string"]},{name:"workspace",classes:["char","string"],allowedStrings:["base","caller"],optional:!0}]},outputs:{arity:1}}},assignin:{func:(...t)=>{const e=this.context.resolveWorkspace(this.charControlArgument(t[0],"workspace").str,!0),r=this.pushDynamicNameCreationGuard(e);try{return FunctionWorkspace.assignIn(e,this.charControlArgument(t[1],"name").str,this.runtimeExpressionValue(t[2],"assignin value"))}finally{r()}},signature:{inputs:{arity:3,parameters:[{name:"workspace",classes:["char","string"],allowedStrings:["base","caller"]},{name:"name",classes:["char","string"],identifier:!0},{name:"value"}]},outputs:{arity:0}}}};unparseMathMLFunctions={logb:t=>{let e=this.UnparserMathML(t.args[1]);return this.nodePrecedence(t.args[1])<this.precedenceTable.max&&(e=MathML.format["()"]("(",e,")")),MathML.format.logb(this.UnparserMathML(t.args[0]),e)},log2:t=>{let e=this.UnparserMathML(t.args[0]);return this.nodePrecedence(t.args[0])<this.precedenceTable.max&&(e=MathML.format["()"]("(",e,")")),MathML.format.log2(e)},log10:t=>{let e=this.UnparserMathML(t.args[0]);return this.nodePrecedence(t.args[0])<this.precedenceTable.max&&(e=MathML.format["()"]("(",e,")")),MathML.format.log10(e)},factorial:t=>{let e=this.UnparserMathML(t.args[0]);return this.nodePrecedence(t.args[0])<this.precedenceTable.max&&(e=MathML.format["()"]("(",e,")")),MathML.format.factorial(e)}};loadInterpreter(t){this._exitStatus=Interpreter.response.OK,this.resetLastError(),this.resetWarningState(),AST.reload(),this.context.loadContext(),this.context.nativeNameTable=Interpreter.nativeNameTableFactory(),this.context.nativeNameSet=new Set(Object.keys(this.context.nativeNameTable)),this.context.globalScope.defineNameTable(this.context.nativeNameTable);for(const t in this.functions)this.context.defineBuiltInFunction(t,this.functions[t].func,!1,[],this.functions[t].signature);const e={inputs:{arity:1,parameters:[{name:"value",classes:["double"]}]},outputs:{arity:1}};for(const t in Complex.mapFunction)this.context.defineBuiltInFunction(t,Complex.mapFunction[t],!0,[],e);const r={inputs:{arity:2,parameters:[{name:"left",classes:["double"]},{name:"right",classes:["double"]}]},outputs:{arity:1}},s={logb:{inputs:{arity:2,parameters:[{name:"value",classes:["double"]},{name:"base",classes:["double"]}]},outputs:{arity:1}}};for(const t in Complex.twoArgFunction)this.context.defineBuiltInFunction(t,Complex.twoArgFunction[t],!1,[],s[t]??r);for(const t in Configuration.functions)this.context.defineBuiltInFunction(t,Configuration.functions[t].func,!1,[],Configuration.functions[t].signature);for(const t in CoreFunctions.functions)this.context.defineBuiltInFunction(t,CoreFunctions.functions[t].func,!1,[],CoreFunctions.functions[t].signature);for(const t of["properties","fieldnames","methods","events","enumeration","superclasses","isprop","ismethod"])this.context.defineBuiltInFunction(t,this.functions[t].func,!1,[],this.functions[t].signature);for(const t in LinearAlgebra.functions)this.context.defineBuiltInFunction(t,LinearAlgebra.functions[t].func,!1,[],LinearAlgebra.functions[t].signature);for(const t in MathOperation.leftAssociativeMultipleOperations)this.context.defineLeftAssociativeMultipleOperationFunction(t,MathOperation.leftAssociativeMultipleOperations[t]);for(const t in MathOperation.binaryOperations)this.context.defineBinaryOperatorFunction(t,MathOperation.binaryOperations[t]);for(const t in MathOperation.unaryOperations)this.context.defineUnaryOperatorFunction(t,MathOperation.unaryOperations[t]);for(const t in this.unparseMathMLFunctions)this.context.builtInFunctionTable[t].UnparserMathML=this.unparseMathMLFunctions[t];t?(this.context.setAliasNameTable(t.aliasNameTable),this.context.assignBuiltInFunctionTable(t.externalFunctionTable),this.sourceResolver=t.sourceResolver??TableSourceResolver.create({functionSourceTable:t.functionSourceTable??t.externalFunctionSourceTable??Object.create(null),functionSourceProvider:t.functionSourceProvider,scriptSourceTable:t.scriptSourceTable??t.externalScriptSourceTable??Object.create(null),scriptSourceProvider:t.scriptSourceProvider,classSourceTable:t.classSourceTable??t.externalClassSourceTable??Object.create(null),classSourceProvider:t.classSourceProvider}),this.pathValidationCallbacks={fileExists:t.fileExists,folderExists:t.folderExists},t.externalCmdWListTable&&Object.assign(this.commandWordListTable,t.externalCmdWListTable)):(this.context.aliasNameFunction=t=>t,this.sourceResolver=TableSourceResolver.create(),this.pathValidationCallbacks={}),this.refreshCommandWordListNames()}constructor(t,e){this.opTable["**"]=this.opTable["^"],this.opTable[".**"]=this.opTable[".^"],this.opTable["~="]=this.opTable["!="],this.opTable["~"]=this.opTable["!"],this.precedenceTable={},Interpreter.precedence.forEach((t,e)=>{t.forEach(t=>{this.precedenceTable[t]=e+1})}),this.precedenceTable["**"]=this.precedenceTable["^"],this.precedenceTable[".**"]=this.precedenceTable[".^"],this.precedenceTable["_**"]=this.precedenceTable["_^"],this.precedenceTable["_.**"]=this.precedenceTable["_.^"],this.precedenceTable["~="]=this.precedenceTable["!="],this.precedenceTable["~"]=this.precedenceTable["!"],e?(this.context=e,this.context.interpreter=this):this.context=Context.create(this),this.loadInterpreter(t)}static Create=(t,e)=>new Interpreter(t,e);Parse(t){const e=antlr4_node.iH.fromString(t),r=new MathJSLabLexer.A(e);r.commandNames=this.commandWordListNameSet,r.assignmentSensitiveCommandNames=this.assignmentSensitiveCommandNameSet;const s=new antlr4_node.jB(r),i=new MathJSLabParser(s);return i.buildParseTrees=!0,r.removeErrorListeners(),r.addErrorListener(new LexerErrorListener(t)),i.removeErrorListeners(),i.addErrorListener(new ParserErrorListener(t)),this._debug,i.input().node??AST.nodeVoid()}static nativeNameTableFactory=()=>({false:Complex.false(),true:Complex.true(),i:Complex.onei(),I:Complex.onei(),j:Complex.onei(),J:Complex.onei(),e:Complex.e(),pi:Complex.pi(),inf:Complex.inf_0(),Inf:Complex.inf_0(),nan:Complex.NaN_0(),NaN:Complex.NaN_0()});Restart(){this.loadInterpreter()}Clear(...t){if(0===t.length)this.context.clearCurrentVariables();else{const e=this.clearCommandOptions(t);if(!e)return;this.clearCommandCategory(e)}}clearAllWorkspaceCategories(){this.context.clearCurrentVariables(),this.context.clearGlobalVariables(),this.context.clearClassDefinitions(),this.context.currentScope.clearImports(),this.clearUserFunctions()}clearCommandOptions(t){const e={category:"visible",regexp:!1,exclusive:!1,patterns:[]};for(let r=0;r<t.length;r++)switch(t[r]){case"all":case"-all":case"-a":return void this.clearAllWorkspaceCategories();case"import":return(this.context.isInsideUserFunction()||this.scriptExecutionDepth>0)&&this.context.throwEvalError("clear import is not allowed inside a function or script."),void this.context.currentScope.clearImports();case"variables":case"-variables":case"-v":e.category="variables";break;case"functions":case"-functions":case"-f":e.category="functions";break;case"classes":case"-classes":case"-c":e.category="classes";break;case"global":case"-global":case"-g":e.category="global";break;case"regexp":case"-regexp":case"-r":e.regexp=!0;break;case"-exclusive":case"-x":e.exclusive=!0;break;default:return e.patterns=t.slice(r),e}return e}clearCommandCategory(t){switch(t.category){case"variables":return void this.context.clearCurrentVariables(this.selectClearPatternMatches(t.patterns,this.clearVariableCandidates(),t));case"functions":return void this.clearUserFunctions(this.selectClearPatternMatches(t.patterns,this.clearFunctionCandidates(),t));case"classes":return void this.clearClassDefinitions(this.selectClearPatternMatches(t.patterns,this.clearClassCandidates(),t));case"global":return void this.context.clearGlobalVariables(this.selectClearPatternMatches(t.patterns,[...this.context.globalNameSet],t));case"visible":return void this.clearVisibleSymbols(t)}}clearVisibleSymbols(t){if(0===t.patterns.length){if(t.regexp||t.exclusive)return;return void this.context.clearCurrentVariables()}const e={regexp:t.regexp,exclusive:t.exclusive};if(t.exclusive)this.context.clearCurrentVariables(this.selectClearPatternMatches(t.patterns,this.clearVariableCandidates(),e));else if(t.regexp||t.patterns.some(t=>this.clearPatternHasWildcards(t)))for(const r of this.selectClearPatternMatches(t.patterns,this.clearVisibleCandidates(),e)??[])this.clearNamedSymbol(r);else for(const e of t.patterns)this.clearNamedSymbol(e)}clearPatternHasWildcards(t){return/[*?\[]/.test(t)}clearPatternRegExp(t){let e="^";for(let r=0;r<t.length;r++){const s=t[r];if("*"===s)e+=".*";else if("?"===s)e+=".";else if("["===s){const s=t.indexOf("]",r+1);s>r+1?(e+=`[${t.slice(r+1,s).replace(/\\/g,"\\\\")}]`,r=s):e+="\\["}else e+=s.replace(/[\\^$+?.()|{}]/g,"\\$&")}return new RegExp(e+"$")}clearPatternOptions(t,e={}){let r=e.regexp??!1,s=e.exclusive??!1,i=0;for(;i<t.length;){const e=t[i];if("-regexp"===e||"-r"===e||"regexp"===e)r=!0,i++;else{if("-exclusive"!==e&&"-x"!==e)break;s=!0,i++}}return{patterns:t.slice(i),regexp:r,exclusive:s}}clearPatternMatches(t,e,r){return r?new RegExp(e).test(t):this.clearPatternRegExp(e).test(t)}selectClearPatternMatches(t,e,r={}){if(!t)return;if(0===t.length)return r.regexp||r.exclusive?[]:void 0;const s=this.clearPatternOptions(t,r);if(0===s.patterns.length)return r.regexp||r.exclusive?[]:void 0;if(s.exclusive)return e.filter(t=>!s.patterns.some(e=>this.clearPatternMatches(t,e,s.regexp)));const i=[],n=t=>{i.includes(t)||i.push(t)};for(const t of s.patterns)s.regexp||this.clearPatternHasWildcards(t)?e.filter(e=>this.clearPatternMatches(e,t,s.regexp)).forEach(n):n(t);return i}clearVariableCandidates(){return Object.keys(this.context.currentScope.nameTable).filter(t=>{const e=this.context.currentScope.nameTable[t];return!this.context.nativeNameSet.has(t)&&!ClassDefinition.isInstanceOf(e?.node)})}visibleWorkspaceVariableEntries(){return Object.entries(this.context.currentScope.nameTable).filter(([t,e])=>!this.context.nativeNameSet.has(t)&&!ClassDefinition.isInstanceOf(e?.node)).sort(([t],[e])=>t.localeCompare(e))}workspaceListingOptions(t,e){const r={globalOnly:!1,regexp:!1,patterns:[]};for(let s=0;s<t.length;s++){const i=t[s],n=i.toLowerCase();"global"===n||"-global"===n?r.globalOnly=!0:"-regexp"===n||"-r"===n||"regexp"===n?r.regexp=!0:"-file"===n||"file"===n?this.context.throwEvalError(`${e}: MAT-file workspace listing is not supported in the browser runtime.`):r.patterns.push(i)}return r}workspaceVariableNamesByPatterns(t,e){const r=this.workspaceListingOptions(t,e),s=this.visibleWorkspaceVariableEntries().filter(([t])=>!r.globalOnly||this.context.globalNameSet.has(t)).map(([t])=>t);if(0===r.patterns.length)return r.regexp?[]:s;const i=[],n=t=>{i.includes(t)||i.push(t)};for(const t of r.patterns){const e=this.clearPatternHasWildcards(t);s.filter(s=>r.regexp||e?this.clearPatternMatches(s,t,r.regexp):s===t).forEach(n)}return i}whoResult(t){const e=t.map(t=>this.charControlArgument(t,"who pattern").str);return this.whoResultFromPatterns(e)}whoResultFromPatterns(t){const e=MultiArray.toColumnVector(this.workspaceVariableNamesByPatterns(t,"who").map(t=>CharString.create(t,"'")));return e.isCell=!0,e}whosValueSize(t){return MultiArray.isInstanceOf(t)?t.dimension:CharString.isChar(t)?[1,t.str.length]:[1,1]}whosValueBytes(t){return Complex.isInstanceOf(t)?16:CharString.isInstanceOf(t)?2*t.str.length:MultiArray.isInstanceOf(t)?MultiArray.linearize(t).reduce((t,e)=>t+this.whosValueBytes(this.expressionValue(e,"whos element")),0):Structure.isInstanceOf(t)?Object.values(t.field).reduce((t,e)=>t+this.whosValueBytes(this.expressionValue(e,"whos field")),0):0}whosValueIsComplex(t){return Complex.isInstanceOf(t)?!Complex.isRealValue(t):MultiArray.isInstanceOf(t)&&MultiArray.linearize(t).some(t=>Complex.isInstanceOf(t)&&!Complex.isRealValue(t))}whosResult(t){const e=t.map(t=>this.charControlArgument(t,"whos pattern").str);return this.whosResultFromPatterns(e)}whosResultFromPatterns(t){const e=new Set(this.workspaceVariableNamesByPatterns(t,"whos")),r=this.visibleWorkspaceVariableEntries().filter(([t])=>e.has(t)),s=MultiArray.toColumnVector(r.map(([t,e])=>{const r=this.expressionValue(e.node,`workspace variable ${t}`);return new Structure({name:CharString.create(t,"'"),size:MultiArray.toRowVector(this.whosValueSize(r).map(t=>Complex.create(t))),bytes:Complex.create(this.whosValueBytes(r)),class:CharString.create(this.getValueClassName(r),"'"),global:this.context.globalNameSet.has(t)?Complex.true():Complex.false(),sparse:Complex.false(),complex:this.whosValueIsComplex(r)?Complex.true():Complex.false(),nesting:new Structure({function:CharString.create("","'"),level:Complex.create(0)}),persistent:Complex.false()})}));return MultiArray.setType(s),s}keywordListResult(){const t=MultiArray.toColumnVector(Interpreter.keywordNames.map(t=>CharString.create(t,"'")));return t.isCell=!0,t}textNamePredicateResult(t,e,r){if(CharString.isInstanceOf(t))return r(t.str)?Complex.true():Complex.false();MultiArray.isInstanceOf(t)||AST.throwInvalidCallError(e,!0,t=>this.context.throwEvalError(t));const s=new MultiArray(t.dimension);for(let e=0;e<MultiArray.linearLength(t);e++){const[i,n]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],e),a=t.array[i][n];s.array[i][n]=CharString.isInstanceOf(a)&&r(a.str)?Complex.true():Complex.false()}return MultiArray.setType(s),MultiArray.MultiArrayToScalar(s)}isKeywordResult(t){return AST.throwInvalidCallError("iskeyword",t.length>1,t=>this.context.throwEvalError(t)),0===t.length?this.keywordListResult():this.textNamePredicateResult(t[0],"iskeyword",t=>Interpreter.keywordNameSet.has(t))}isVarNameResult(t){return AST.throwInvalidCallError("isvarname",1!==t.length,t=>this.context.throwEvalError(t)),this.textNamePredicateResult(t[0],"isvarname",t=>/^[A-Za-z][A-Za-z0-9_]*$/.test(t)&&t.length<=Interpreter.nameLengthMax&&!Interpreter.keywordNameSet.has(t))}isGlobalName(t){return this.context.globalNameSet.has(t)}isGlobalResult(t){return AST.throwInvalidCallError("isglobal",1!==t.length,t=>this.context.throwEvalError(t)),this.textNamePredicateResult(t[0],"isglobal",t=>this.isGlobalName(t))}clearFunctionCandidates(){return this.visibleUserFunctionNames()}visibleUserFunctionNames(){const t=[],e=new Set;let r=this.context.currentScope;for(;r;){for(const[s,i]of Object.entries(r.functionTable))e.has(s)||"FCNDEF"!==i?.type||(t.push(s),e.add(s));r=r.parent}return t}hasVisibleUserFunction(t){let e=this.context.currentScope;for(;e;){if("FCNDEF"===e.functionTable[t]?.type)return!0;e=e.parent}return!1}clearVisibleUserFunction(t){return!!this.hasVisibleUserFunction(t)&&(this.context.currentScope.clearFunction(t),!0)}clearClassCandidates(){return Object.keys(this.context.currentScope.nameTable).filter(t=>ClassDefinition.isInstanceOf(this.context.currentScope.nameTable[t]?.node))}clearVisibleCandidates(){return[...this.clearVariableCandidates(),...this.clearFunctionCandidates(),...this.clearClassCandidates()]}clearClassDefinitions(t){if(t)for(const e of t)this.clearNamedSymbol(e);else this.context.clearClassDefinitions()}clearNamedPattern(t){if(!this.clearPatternHasWildcards(t))return void this.clearNamedSymbol(t);const e=[...this.clearVariableCandidates(),...this.clearFunctionCandidates(),...this.clearClassCandidates()];for(const r of this.selectClearPatternMatches([t],e)??[])this.clearNamedSymbol(r)}clearNamedSymbol(t){const e=this.resolveRuntimeSymbol(t,this.context.currentScope,{loadClasses:!1,loadFunctions:!1}),r=e?.resolvedName??this.context.aliasNameFunction(t),s=new Set([t,r]);let i=!1;for(const t of s)this.context.currentScope.hasLocalName(t)&&(this.context.currentScope.removeName(t),i=!0,this.context.nativeNameSet.has(t)&&this.context.globalScope.defineName(t,this.context.nativeNameTable[t]));if(!i)for(const t of s)if(this.clearVisibleUserFunction(t))break}clearUserFunctions(t){const e=t||this.clearFunctionCandidates();for(const t of e){const e=this.resolveRuntimeSymbol(t,this.context.currentScope,{variables:!1,classes:!1,loadClasses:!1,loadFunctions:!1}),r=e?.resolvedName??this.context.aliasNameFunction(t);for(const e of new Set([t,r]))this.clearVisibleUserFunction(e)}}validateAssignment(t,e,r=this.context.currentScope){const s="invalid left hand side of assignment",i=(t,e,r,s)=>{const i={done:!1},n=()=>AST.nodeList([this.expressionValue(Complex.create(r+1),"index")]),a=t=>{if(AST.isNodeIdentifier(t)){const r=AST.nodeIdentifier(t.id);return"insert-at-identifier"!==s||i.done?r:(i.done=!0,AST.nodeIndexExpr(r,n(),e))}if(AST.isNodeIgnoredTarget(t))return AST.nodeIgnoredTarget();if(AST.isNodeIndexExpr(t)){const r=a(t.expr);return"replace-first-index"!==s||i.done?AST.nodeIndexExpr(r,AST.nodeList(t.args.map(t=>this.cloneAssignmentTarget(t))),t.delim):(i.done=!0,AST.nodeIndexExpr(r,n(),e))}if(AST.isNodeIndirectRef(t)){const e=t.field[0];let r=AST.nodeIndirectRef(a(t.obj),"string"==typeof e?e:this.cloneAssignmentTarget(e));for(let e=1;e<t.field.length;e++){const s=t.field[e];r=AST.nodeIndirectRef(r,"string"==typeof s?s:this.cloneAssignmentTarget(s))}return r}return this.cloneAssignmentTarget(t)};return a(t)},n=s=>{if(e||!s.descriptors||0===s.descriptors.length)return[s];const n=r.resolveName(s.id);if(!n||!MultiArray.isInstanceOf(n.node))return[s];const a=this.readNativeSubscriptDescriptor(s.descriptors[0],"subsasgn"),o=s.descriptors[1]?this.readNativeSubscriptDescriptor(s.descriptors[1],"subsasgn"):void 0,l=n.node.isCell&&"()"===a.type&&"{}"===o?.type;if(n.node.isCell&&"{}"!==a.type&&!l)return[s];if(!n.node.isCell&&!Structure.isStructure(n.node)&&!this.hasClassInstanceElement(n.node))return[s];const c="()"===a.type,u="{}"===a.type,h=c||u?MultiArray.resolveLinearIndices(n.node,s.id,this.nativeDescriptorIndexList(a,n.node),this):MultiArray.resolveLinearIndices(n.node,s.id,[MultiArray.expandColon(MultiArray.linearLength(n.node))],this),d=u?"{}":"()";return h.map(e=>{const n=i(t,d,e,c||u?"replace-first-index":"insert-at-identifier");return this.collectSubsasgnAssignmentTarget(n,r)||{id:s.id,index:[this.expressionValue(Complex.create(e+1),"index")],delimiter:d,field:[],descriptors:[this.createSubscriptDescriptor(d,[this.expressionValue(Complex.create(e+1),"index")],t,r)]}})};if(AST.isNodeIdentifier(t))return[{id:t.id,field:[]}];if(AST.isNodeIndexExpr(t)&&AST.isNodeIdentifier(t.expr)){if(!e&&"{}"===t.delim){const e=r.resolveName(t.expr.id);if(e&&MultiArray.isInstanceOf(e.node)&&e.node.isCell){const s=this.evaluatedIndexArguments(t.args,r);return MultiArray.resolveLinearIndices(e.node,t.expr.id,s).map(e=>({id:t.expr.id,index:[this.expressionValue(Complex.create(e+1),"index")],delimiter:t.delim,field:[]}))}}return[{id:t.expr.id,index:t.args,delimiter:t.delim,field:[]}]}if(AST.isNodeIndirectRef(t)){const i=t.field.map(t=>"string"==typeof t?t:this.evaluatedDynamicFieldName(t,r,`${s}: dynamic structure field names must be strings.`));if(AST.isNodeIdentifier(t.obj)){if(!e){const e=r.resolveName(t.obj.id);if(e&&MultiArray.isInstanceOf(e.node)&&(Structure.isStructure(e.node)||this.hasClassInstanceElement(e.node)))return MultiArray.resolveLinearIndices(e.node,t.obj.id,[MultiArray.expandColon(MultiArray.linearLength(e.node))],this).map(e=>({id:t.obj.id,index:[this.expressionValue(Complex.create(e+1),"index")],delimiter:"()",field:i}))}return[{id:t.obj.id,field:i}]}if(AST.isNodeIndexExpr(t.obj)&&AST.isNodeIdentifier(t.obj.expr)){if(!e&&"{}"===t.obj.delim){const e=r.resolveName(t.obj.expr.id);if(e&&MultiArray.isInstanceOf(e.node)&&e.node.isCell){const s=this.evaluatedIndexArguments(t.obj.args,r);return MultiArray.resolveLinearIndices(e.node,t.obj.expr.id,s,this).map(e=>({id:t.obj.expr.id,index:[this.expressionValue(Complex.create(e+1),"index")],delimiter:t.obj.delim,field:[],descriptors:[this.createSubscriptDescriptor(t.obj.delim,[this.expressionValue(Complex.create(e+1),"index")],t.obj,r),...i.map(e=>this.createDotSubscriptDescriptor(e,t,r))]}))}}if(!e&&"()"===t.obj.delim){const e=r.resolveName(t.obj.expr.id);if(e&&MultiArray.isInstanceOf(e.node)&&(Structure.isStructure(e.node)||this.hasClassInstanceElement(e.node))){const s=this.evaluatedIndexArguments(t.obj.args,r);return MultiArray.resolveLinearIndices(e.node,t.obj.expr.id,s,this).map(e=>({id:t.obj.expr.id,index:[this.expressionValue(Complex.create(e+1),"index")],delimiter:t.obj.delim,field:i,descriptors:[this.createSubscriptDescriptor(t.obj.delim,[this.expressionValue(Complex.create(e+1),"index")],t.obj,r),...i.map(e=>this.createDotSubscriptDescriptor(e,t,r))]}))}}return[{id:t.obj.expr.id,index:t.obj.args,delimiter:t.obj.delim,field:i,descriptors:[this.createSubscriptDescriptor(t.obj.delim,t.obj.args,t.obj,r),...i.map(e=>this.createDotSubscriptDescriptor(e,t,r))]}]}{const e=this.collectSubsasgnAssignmentTarget(t,r);if(e)return n(e);this.context.throwEvalError(`${s}.`)}}else{if(AST.isNodeIgnoredTarget(t))return[{id:"~",field:[]}];if(e&&MultiArray.isRowVector(t))return t.array[0].flatMap(t=>this.validateAssignment(t,!1,r));{const e=this.collectSubsasgnAssignmentTarget(t,r);if(e)return n(e);this.context.throwEvalError(`${s}.`)}}}toBoolean(t){if(MultiArray.isInstanceOf(t)){if(t.isCell&&this.context.throwEvalError("invalid conversion from cell to logical."),this.hasClassInstanceElement(t)){const e=this.classUnaryOperatorArray(t,"logical",AST.nodeIdentifier("logical"));if(e)return this.toBoolean(this.expressionValue(e,"logical conversion"));this.context.throwEvalError(`invalid conversion from ${this.getValueClassName(t)} to logical.`)}return this.complexConditionValue(MultiArray.toLogical(t))}if(Complex.isInstanceOf(t))return this.complexConditionValue(t);if(CharString.isInstanceOf(t))return!!t.str;if(ClassInstance.isInstanceOf(t)){const e=this.classUnaryOperatorMethod(t,"logical");if(e)return this.toBoolean(this.expressionValue(this.reducedClassMethodResult(e.receiver,e.method,[],AST.nodeIdentifier("logical")),"logical conversion"))}this.context.throwEvalError(`invalid conversion from ${this.getValueClassName(t)} to logical.`)}complexConditionValue(t){return Boolean(Complex.realToNumber(t)||Complex.imagToNumber(t))}evaluatedCondition(t,e,r){return this.toBoolean(this.evaluatedConditionExpression(t,e,r))}evaluatedConditionExpression(t,e,r){return!AST.isNodeBinaryOperation(t)||"&"!==t.type&&"|"!==t.type&&"&&"!==t.type&&"||"!==t.type?this.evaluatedExpressionValue(t,e,r):this.evaluateConditionalLogicalOperation(t,e)}evaluateConditionalLogicalOperation(t,e){const r=this.evaluatedCondition(t.left,e,"left condition operand");return"&"===t.type||"&&"===t.type?r&&this.evaluatedCondition(t.right,e,"right condition operand")?Complex.true():Complex.false():r||this.evaluatedCondition(t.right,e,"right condition operand")?Complex.true():Complex.false()}switchComparableValue(t){return MultiArray.isInstanceOf(t)&&!t.isCell&&2===t.dimension.length&&1===t.dimension[0]&&1===t.dimension[1]?this.expressionValue(t.array[0][0],"switch value"):t}switchCaseMatches(t,e){const r=MultiArray.isInstanceOf(e)&&e.isCell?this.expressionList(MultiArray.linearize(e),"switch case"):[e];for(const e of r)if(this.switchCandidateMatches(t,e))return!0;return!1}switchCandidateMatches(t,e){const r=this.switchComparableValue(e),s=this.switchComparableValue(t),i=this.classBinaryOperatorMethod(r,s,"eq");return i?this.toBoolean(this.expressionValue(this.reducedClassMethodResult(i.receiver,i.method,i.args,AST.nodeIdentifier("switch")),"switch case")):RuntimeEquality.valuesEqual(s,r)}classDefinitionForOperatorValue(t){return ClassInstance.isInstanceOf(t)?t.classDefinition:void 0}classNameForOperatorValue(t){return ClassInstance.isInstanceOf(t)?t.classDefinition.name:this.getValueClassName(t)}classDeclaresInferior(t,e){if(!t)return!1;const r=this.classDefinitionForOperatorValue(e),s=this.classNameForOperatorValue(e);return t.inferiorClasses.some(t=>t===s||!!r&&(r.name===t||r.isSubclassOfName(t)))}classBinaryOperatorMethod(t,e,r){const s=s=>{if(!ClassInstance.isInstanceOf(s))return;const i=s.classDefinition.findMethod(r,t=>!t.isStatic);return i?(this.context.canAccessClassMember(i.classDefinition,i.access)||this.context.throwEvalError(`method '${r}' has ${i.access} access for class ${s.classDefinition.name}.`),{receiver:s,method:i,args:this.classMethodArgumentValues([s===t?e:t],"operator")}):void 0},i=this.classDefinitionForOperatorValue(t),n=this.classDefinitionForOperatorValue(e);return this.classDeclaresInferior(n,t)&&!this.classDeclaresInferior(i,e)?s(e)??s(t):s(t)??s(e)}hasClassInstanceElement(t){return ClassInstance.isInstanceOf(t)||MultiArray.isInstanceOf(t)&&MultiArray.linearize(t).some(t=>ClassInstance.isInstanceOf(t))}classBinaryOperatorArray(t,e,r,s){if(!this.hasClassInstanceElement(t)&&!this.hasClassInstanceElement(e))return;const i=MultiArray.scalarToMultiArray(t),n=MultiArray.scalarToMultiArray(e),a=i.dimension.slice(),o=n.dimension.slice(),l=Math.max(a.length,o.length);for(;a.length<l;)a.push(1);for(;o.length<l;)o.push(1);const c=new Array(l),u=new Array(l),h=new Array(l);for(let t=0;t<l;t++)a[t]===o[t]?(c[t]=a[t],u[t]=h[t]=!1):1===a[t]?(c[t]=o[t],u[t]=!0,h[t]=!1):1===o[t]?(c[t]=a[t],u[t]=!1,h[t]=!0):this.context.throwEvalError(`operator ${r}: nonconformant arguments (op1 is ${a.join("x")}, op2 is ${o.join("x")}).`);const d=i.array[0]?.[0],m=n.array[0]?.[0];if(!this.classBinaryOperatorMethod(d,m,r))return;const p=MultiArray.computeStrides(a),f=MultiArray.computeStrides(o),g=MultiArray.computeStrides(c),y=new MultiArray(c),x=c.reduce((t,e)=>t*e,1);for(let t=0;t<x;t++){let e=0,d=0;for(let r=0;r<l;r++){const s=Math.floor(t/g[r])%c[r];e+=(u[r]?0:s)*p[r],d+=(h[r]?0:s)*f[r]}const[m,x]=MultiArray.linearIndexToMultiArrayRowColumn(a[0],a[1],e),[C,A]=MultiArray.linearIndexToMultiArrayRowColumn(o[0],o[1],d),[S,E]=MultiArray.linearIndexToMultiArrayRowColumn(c[0],c[1],t),_=this.classBinaryOperatorMethod(i.array[m][x],n.array[C][A],r);_||this.context.throwEvalError(`operator ${r} is not defined for class array element.`),y.array[S][E]=this.reducedClassMethodResult(_.receiver,_.method,_.args,s)}return MultiArray.setType(y),MultiArray.MultiArrayToScalar(y)}evaluateBinaryOperatorWithClassDispatch(t,e,r,s,i){const n=this.classBinaryOperatorArray(t,e,r,i);if(n)return n;const a=this.classBinaryOperatorMethod(t,e,r);return a?this.context.callClassInstanceMethod(a.receiver,a.method,a.args,i):MathOperation[s](t,e)}classVariadicOperatorMethod(t,e){for(let r=0;r<t.length;r++){const s=t[r];if(!ClassInstance.isInstanceOf(s))continue;const i=s.classDefinition.findMethod(e,t=>!t.isStatic);if(i)return this.context.canAccessClassMember(i.classDefinition,i.access)||this.context.throwEvalError(`method '${e}' has ${i.access} access for class ${s.classDefinition.name}.`),{receiver:s,method:i,args:this.classMethodArgumentValues(t.filter((t,e)=>e!==r),"operator")}}}evaluateColonWithClassDispatch(t,e){if(!t.some(t=>this.hasClassInstanceElement(t)))return;const r=this.classVariadicOperatorMethod(t,"colon");if(r)return this.context.callClassInstanceMethod(r.receiver,r.method,r.args,e);this.context.throwEvalError("operator colon is not defined for class operands.")}concatenateOverload(t,e,r){const s=e.map((e,r)=>this.expressionValue(e,`${t} argument ${r+1}`));if(!s.some(t=>this.hasClassInstanceElement(t)))return;const i=this.classVariadicOperatorMethod(s,t);return i?this.reducedClassMethodResult(i.receiver,i.method,i.args,r):void 0}callFunctionalOperatorOverload(t,e,r){const s=t.id,i=MathOperation.unaryOperations[s],n=MathOperation.binaryOperations[s],a=MathOperation.leftAssociativeMultipleOperations[s],o="colon"===s,l="cat"===s,c="horzcat"===s||"vertcat"===s;if(!(i||n||a||o||l||c))return;const u=this.context.evaluateBuiltInArgs(t,e,r).map((t,e)=>this.expressionValue(t,`operator argument ${e+1}`));if(this.context.validateBuiltInInputArity(t,u.length),(!u.some(t=>this.hasClassInstanceElement(t))||l||c)&&this.context.validateBuiltInInputParameters(t,u),o)return 2!==u.length&&3!==u.length&&AST.throwInvalidCallError(s,!1,t=>this.context.throwEvalError(t)),this.evaluateColonWithClassDispatch(u,r)??CoreFunctions.colon(...u);if(l){const t=this.concatenateOverload(s,u,r);if(t)return t;const[e,...i]=u;return CoreFunctions.cat(e,...i)}if(c){return this.concatenateOverload(s,u,r)||("horzcat"===s?CoreFunctions.horzcat:CoreFunctions.vertcat)(...u)}if(i){1!==u.length&&AST.throwInvalidCallError(s,!1,t=>this.context.throwEvalError(t));const t=u[0],e=this.classUnaryOperatorArray(t,s,r);if(e)return e;const n=this.classUnaryOperatorMethod(t,s);return n?this.context.callClassInstanceMethod(n.receiver,n.method,[],r):i(t)}if(n)return 2!==u.length&&AST.throwInvalidCallError(s,!1,t=>this.context.throwEvalError(t)),this.evaluateBinaryOperatorWithClassDispatch(u[0],u[1],s,s,r);if(a){u.length<2&&AST.throwInvalidCallError(s,!1,t=>this.context.throwEvalError(t));let t=this.evaluateBinaryOperatorWithClassDispatch(u[0],u[1],s,s,r);for(let e=2;e<u.length;e++)t=this.evaluateBinaryOperatorWithClassDispatch(t,u[e],s,s,r);return t}}requireBinaryOperation(t){if(AST.isNodeBinaryOperation(t))return t;this.context.throwEvalError(`invalid binary operation AST node '${t.type}'.`)}requirePrefixOperation(t){if(AST.isNodePrefixOperation(t))return t;this.context.throwEvalError(`invalid prefix operation AST node '${t.type}'.`)}requirePostfixOperation(t){if(AST.isNodePostfixOperation(t))return t;this.context.throwEvalError(`invalid postfix operation AST node '${t.type}'.`)}evaluateBinaryOperation(t,e){const r=this.evaluatedExpressionValue(t.left,e,"left operand"),s=this.evaluatedExpressionValue(t.right,e,"right operand"),i=Interpreter.binaryOperatorMethodTable[t.type];return i?this.evaluateBinaryOperatorWithClassDispatch(r,s,i,i,t):this.opTable[t.type](r,s)}evaluateShortCircuitOperation(t,e){const r=this.evaluatedExpressionValue(t.left,e,"left operand"),s=this.toBoolean(r);return"&&"===t.type?s&&this.toBoolean(this.evaluatedExpressionValue(t.right,e,"right operand"))?Complex.true():Complex.false():s||this.toBoolean(this.evaluatedExpressionValue(t.right,e,"right operand"))?Complex.true():Complex.false()}classUnaryOperatorMethod(t,e){if(!ClassInstance.isInstanceOf(t))return;const r=t.classDefinition.findMethod(e,t=>!t.isStatic);return r?(this.context.canAccessClassMember(r.classDefinition,r.access)||this.context.throwEvalError(`method '${e}' has ${r.access} access for class ${t.classDefinition.name}.`),{receiver:t,method:r}):void 0}classUnaryOperatorArray(t,e,r){if(!MultiArray.isInstanceOf(t)||!this.hasClassInstanceElement(t))return;const s=t.array[0]?.[0];if(!this.classUnaryOperatorMethod(s,e))return;const i=new MultiArray(t.dimension);for(let s=0;s<MultiArray.linearLength(t);s++){const[n,a]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],s),o=this.classUnaryOperatorMethod(t.array[n][a],e);o||this.context.throwEvalError(`operator ${e} is not defined for class array element.`),i.array[n][a]=this.reducedClassMethodResult(o.receiver,o.method,[],r)}return MultiArray.setType(i),MultiArray.MultiArrayToScalar(i)}evaluateUnaryOperation(t,e){const r=AST.isNodePrefixOperation(t)?t.right:t.left,s=this.evaluatedExpressionValue(r,e,"unary operand"),i=Interpreter.unaryOperatorMethodTable[t.type];if(i){const e=this.classUnaryOperatorArray(s,i,t);if(e)return e;const r=this.classUnaryOperatorMethod(s,i);if(r)return this.context.callClassInstanceMethod(r.receiver,r.method,[],t)}return this.opTable[t.type](s)}resolveClassInstanceField(t,e,r){try{ClassInstance.throwIfDeleted(t)}catch(t){this.context.throwEvalError(t.message)}if(t.classDefinition.isSubclassOfName("event.EventData")){if("Source"===e)return t.eventDataSource||this.context.throwEvalError("event data Source is not assigned until notify dispatch."),t.eventDataSource;if("EventName"===e)return t.eventDataEventName||this.context.throwEvalError("event data EventName is not assigned until notify dispatch."),CharString.create(t.eventDataEventName)}if(!this.context.canAccessClassMember(t.classDefinition,"private")){const s=this.callClassDotSubsref(t,e,r,this.context.currentScope);if(void 0!==s)return s}const s=t.classDefinition.findProperty(e);if(s?.getMethodName){this.assertCanReadClassProperty(s,e,t.classDefinition.name),s.isGetObservable&&this.dispatchClassPropertyEvent(t,e,"PreGet");const i=t.classDefinition.findMethod(s.getMethodName,t=>!t.isStatic);i||this.context.throwEvalError(`GetMethod '${s.getMethodName}' for property '${e}' in class ${t.classDefinition.name} is not defined.`);const n=this.reducedClassMethodResult(t,i,[],r);return s.isGetObservable&&this.dispatchClassPropertyEvent(t,e,"PostGet"),n}if(s?.isDependent){this.assertCanReadClassProperty(s,e,t.classDefinition.name),s.isGetObservable&&this.dispatchClassPropertyEvent(t,e,"PreGet");const i=t.classDefinition.findMethod(`get.${e}`,t=>!t.isStatic);i||this.context.throwEvalError(`dependent property '${e}' for class ${t.classDefinition.name} has no get accessor.`);const n=this.reducedClassMethodResult(t,i,[],r);return s.isGetObservable&&this.dispatchClassPropertyEvent(t,e,"PostGet"),n}const i=ClassInstance.getProperty(t,e);if(void 0!==i)return s&&(this.assertCanReadClassProperty(s,e,t.classDefinition.name),s.isGetObservable&&(this.dispatchClassPropertyEvent(t,e,"PreGet"),this.dispatchClassPropertyEvent(t,e,"PostGet"))),i;const n=t.classDefinition.findMethod(e,t=>!t.isStatic);if(n)return this.context.canAccessClassMember(n.classDefinition,n.access)||this.context.throwEvalError(`method '${e}' has ${n.access} access for class ${t.classDefinition.name}.`),ClassBoundMethod.bind(t,n);this.context.throwEvalError(`unknown property or method '${e}' for class ${t.classDefinition.name}.`)}assertCanReadClassProperty(t,e,r){this.context.canAccessClassMember(t.classDefinition,t.getAccess)||this.context.throwEvalError(`property '${e}' has ${t.getAccess} get access for class ${r}.`)}assertCanWriteClassProperty(t,e,r){this.context.canAccessClassMember(t.classDefinition,t.setAccess)||this.context.throwEvalError(`property '${e}' has ${t.setAccess} set access for class ${r}.`)}shouldAbortClassPropertySet(t,e,r){return e.isAbortSet&&!e.isDependent&&ClassInstance.hasProperty(t,e.name)&&RuntimeEquality.valuesEqual(ClassInstance.getProperty(t,e.name),r)}assignClassInstanceField(t,e,r,s,i){if(!this.context.canAccessClassMember(t.classDefinition,"private")){const n=this.callClassDotSubsasgn(t,e,r,s,i);if(n)return n}!t.classDefinition.isSubclassOfName("event.EventData")||"Source"!==e&&"EventName"!==e||this.context.throwEvalError(`cannot assign to read-only property '${e}' for class ${t.classDefinition.name}.`);const n=t.classDefinition.findProperty(e);if(n&&this.assertCanWriteClassProperty(n,e,t.classDefinition.name),n?.isConstant&&this.context.throwEvalError(`cannot assign to constant property '${e}' for class ${t.classDefinition.name}.`),n&&this.shouldAbortClassPropertySet(t,n,r))return t;if(n?.isSetObservable&&this.dispatchClassPropertyEvent(t,e,"PreSet"),n?.setMethodName||n?.isDependent){this.validateClassPropertyValue(n,r,i);const a=n.setMethodName??`set.${e}`,o=t.classDefinition.findMethod(a,t=>!t.isStatic);o||(n.setMethodName&&this.context.throwEvalError(`SetMethod '${n.setMethodName}' for property '${e}' in class ${t.classDefinition.name} is not defined.`),this.context.throwEvalError(`cannot assign to dependent property '${e}' for class ${t.classDefinition.name} without a set accessor.`));const l=this.reducedClassMethodResult(t,o,this.classMethodArgumentValues([r],`set.${e}`),s);return ClassInstance.isInstanceOf(l)||this.context.throwEvalError(`set accessor for property '${e}' must return an object of class ${t.classDefinition.name}.`),n.isSetObservable&&this.dispatchClassPropertyEvent(l,e,"PostSet"),l}n&&this.validateClassPropertyValue(n,r,i);try{ClassInstance.setProperty(t,e,r)}catch(t){this.context.throwEvalError(t.message)}return n?.isSetObservable&&this.dispatchClassPropertyEvent(t,e,"PostSet"),t}assignNestedClassInstanceField(t,e,r,s,i){if(1===e.length)return this.assignClassInstanceField(t,e[0],r,s,i);const n=e[0],a=e.slice(1);let o,l=this.resolveClassInstanceField(t,n,s);if(MultiArray.isEmpty(l)&&(l=new Structure({})),Structure.isInstanceOf(l)){const t=Structure.copy(l);Structure.setNewField(t,a,this.runtimeExpressionValue(r,`field ${e.join(".")}`)),o=t}else ClassInstance.isInstanceOf(l)?o=this.assignNestedClassInstanceField(l,a,r,s,i):this.context.throwEvalError("value cannot be indexed with .");return this.assignClassInstanceField(t,n,o,s,i)}assignClassArrayField(t,e,r,s,i){const n=MultiArray.copy(t),a=this.assignmentValues(r,"assignment"),o=MultiArray.linearLength(n);1!==a.length&&a.length!==o&&this.context.throwEvalError(`assignment value count ${a.length} does not match object array length ${o}.`);for(let t=0;t<o;t++){const[r,o]=MultiArray.linearIndexToMultiArrayRowColumn(n.dimension[0],n.dimension[1],t),l=n.array[r][o];ClassInstance.isInstanceOf(l)||this.context.throwEvalError("object array field assignment requires class instance elements."),n.array[r][o]=this.assignClassInstanceField(l,e,1===a.length?a[0]:a[t],s,i)}return MultiArray.setType(n),n}assignNestedClassArrayField(t,e,r,s,i){if(1===e.length)return this.assignClassArrayField(t,e[0],r,s,i);const n=MultiArray.copy(t),a=this.assignmentValues(r,"assignment"),o=MultiArray.linearLength(n);1!==a.length&&a.length!==o&&this.context.throwEvalError(`assignment value count ${a.length} does not match object array length ${o}.`);for(let t=0;t<o;t++){const[r,o]=MultiArray.linearIndexToMultiArrayRowColumn(n.dimension[0],n.dimension[1],t),l=n.array[r][o];ClassInstance.isInstanceOf(l)||this.context.throwEvalError("object array field assignment requires class instance elements."),n.array[r][o]=this.assignNestedClassInstanceField(l,e,1===a.length?a[0]:a[t],s,i)}return MultiArray.setType(n),n}assignClassArrayIndexedField(t,e,r,s,i,n,a){const o=this.evaluatedIndexArguments(r,a),l=MultiArray.getElements(e,t,[],o),c=this.assignmentValues(l,"selection"),u=1===c.length?[i]:this.assignmentValues(i,"assignment");1!==u.length&&u.length!==c.length&&this.context.throwEvalError(`assignment value count ${u.length} does not match selected object count ${c.length}.`);const h=MultiArray.isInstanceOf(l)?l:MultiArray.scalarToMultiArray(this.expressionValue(l,"selection")),d=new MultiArray(h.dimension);for(let t=0;t<c.length;t++){const e=c[t];ClassInstance.isInstanceOf(e)||this.context.throwEvalError("object array indexed field assignment requires class instance elements.");const[r,i]=MultiArray.linearIndexToMultiArrayRowColumn(d.dimension[0],d.dimension[1],t);d.array[r][i]=this.assignClassInstanceField(e,s,1===u.length?u[0]:u[t],n,a)}return MultiArray.setType(d),MultiArray.setElements(a,t,[],o,d),this.scopedMultiArrayValue(a,t,"object array assignment result")}assignClassArrayIndexedNestedField(t,e,r,s,i,n,a){if(1===s.length)return this.assignClassArrayIndexedField(t,e,r,s[0],i,n,a);const o=this.evaluatedIndexArguments(r,a),l=MultiArray.getElements(e,t,[],o),c=this.assignmentValues(l,"selection"),u=1===c.length?[i]:this.assignmentValues(i,"assignment");1!==u.length&&u.length!==c.length&&this.context.throwEvalError(`assignment value count ${u.length} does not match selected object count ${c.length}.`);const h=MultiArray.isInstanceOf(l)?l:MultiArray.scalarToMultiArray(this.expressionValue(l,"selection")),d=new MultiArray(h.dimension);for(let t=0;t<c.length;t++){const e=c[t];ClassInstance.isInstanceOf(e)||this.context.throwEvalError("object array indexed field assignment requires class instance elements.");const[r,i]=MultiArray.linearIndexToMultiArrayRowColumn(d.dimension[0],d.dimension[1],t);d.array[r][i]=this.assignNestedClassInstanceField(e,s,1===u.length?u[0]:u[t],n,a)}return MultiArray.setType(d),MultiArray.setElements(a,t,[],o,d),this.scopedMultiArrayValue(a,t,"object array assignment result")}assignClassArrayDescriptorField(t,e,r,s,i,n){const a=MultiArray.copy(t),o=MultiArray.getElements(a,"",[],e),l=this.assignmentValues(o,"selection"),c=1===l.length?[s]:this.assignmentValues(s,"assignment");1!==c.length&&c.length!==l.length&&this.context.throwEvalError(`assignment value count ${c.length} does not match selected object count ${l.length}.`);const u=MultiArray.isInstanceOf(o)?o:MultiArray.scalarToMultiArray(this.expressionValue(o,"selection")),h=new MultiArray(u.dimension);for(let t=0;t<l.length;t++){const e=l[t];ClassInstance.isInstanceOf(e)||this.context.throwEvalError("object array indexed field assignment requires class instance elements.");const[s,a]=MultiArray.linearIndexToMultiArrayRowColumn(h.dimension[0],h.dimension[1],t);h.array[s][a]=this.assignNestedClassInstanceField(e,r,1===c.length?c[0]:c[t],i,n)}MultiArray.setType(h);const d=Scope.create();return d.defineName("__object_array_subsasgn__",a),MultiArray.setElements(d,"__object_array_subsasgn__",[],e,h,void 0,this),this.scopedMultiArrayValue(d,"__object_array_subsasgn__","object array assignment result")}evaluatedIndexArguments(t,e){return MultiArray.indexArguments(t.map((t,r)=>this.convertIndexArgument(this.evaluatedExpressionValue(t,e,`index${r+1}`),t)),"index")}evaluatedDynamicFieldName(t,e,r){const s=this.evaluatedExpressionValue(t,e,"dynamic field name");return CharString.isInstanceOf(s)||this.context.throwEvalError(r),s.str}evaluatedCommaSeparatedReceiver(t,e){this.context.pushRequestedOutputCount(1),this.context.pushCommaListExpansion();try{const r=this.Evaluator(t,e);return AST.isNodeReturnList(r)&&r.commaSeparated?this.context.expandCommaSeparatedList(r):void 0}finally{this.context.popCommaListExpansion(),this.context.popRequestedOutputCount()}}chainedCommaListResult(t){return 1===t.length?this.returnListValue(t[0],"out1"):this.context.requestedOutputCount>1||this.context.commaListExpansionEnabled?this.valueReturnList(t):AST.nodeList(this.expressionList(t,"out"))}chainedCommaItemApply(t,e,r){this.context.pushRequestedOutputCount(1);try{const s=this.context.apply(this.expressionValue(t,"indexed expression"),e,r);return this.reducedIndexingResult(s)}finally{this.context.popRequestedOutputCount()}}dottedCommaReceiver(t,e){const r=t=>{try{return this.evaluatedCommaSeparatedReceiver(t,e)}catch{return}};let s=t.obj;for(let e=0;e<t.field.length;e++){const i=r(s);if(i)return{values:i,fields:t.field.slice(e)};s=AST.nodeIndirectRef(AST.isNodeIndirectRef(s)?{...s,field:[...s.field]}:s,t.field[e])}const i=r(s);return i?{values:i,fields:[]}:void 0}resolveDotFieldChain(t,e,r,s){if(ClassInstance.isInstanceOf(t))return this.resolveClassFieldChain(t,e,r);if(MultiArray.isInstanceOf(t)&&this.hasClassInstanceElement(t))return this.resolveClassFieldChain(t,e,r);if(ClassEventListener.isInstanceOf(t)){let s=t;for(const t of e)s=ClassEventListener.isInstanceOf(s)?this.resolveClassEventListenerField(s,t):ClassInstance.isInstanceOf(s)?this.resolveClassInstanceField(s,t,r):Structure.getField(s,[t]);return s}if(ClassEventData.isInstanceOf(t)||ClassPropertyEvent.isInstanceOf(t)){let s=t;for(const t of e)if(ClassEventData.isInstanceOf(s)||ClassPropertyEvent.isInstanceOf(s))s=this.resolveClassEventDataField(s,t);else if(ClassInstance.isInstanceOf(s))s=this.resolveClassInstanceField(s,t,r);else if(ClassMetaObject.isInstanceOf(s)){const e=s.getProperty(t);void 0===e&&this.context.throwEvalError(`unknown property '${t}' for ${s.kind}.`),s=e}else s=Structure.getField(s,[t]);return s}if(ClassMetaObject.isInstanceOf(t)){let r=t;for(const t of e)if(ClassMetaObject.isInstanceOf(r)){const e=r.getProperty(t);void 0===e&&this.context.throwEvalError(`unknown property '${t}' for ${r.kind}.`),r=e}else r=Structure.getField(r,[t]);return r}if(ClassDefinition.isInstanceOf(t))return this.resolveClassDefinitionMemberChain(t,e,s);const i=Structure.getFields(t,e);return 1===i.length?i[0]:this.context.requestedOutputCount>1||this.context.commaListExpansionEnabled?this.valueReturnList(i):AST.nodeList(i)}resolveClassArrayField(t,e,r,s=!0){const i=new MultiArray(t.dimension);for(let s=0;s<MultiArray.linearLength(t);s++){const[n,a]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],s),o=t.array[n][a];ClassInstance.isInstanceOf(o)||this.context.throwEvalError("object array field access requires class instance elements."),i.array[n][a]=this.resolveClassInstanceField(o,e,r)}MultiArray.setType(i);const n=MultiArray.linearize(i);return s&&(this.context.requestedOutputCount>1||this.context.commaListExpansionEnabled)&&!n.every(t=>ClassBoundMethod.isInstanceOf(t))?this.valueReturnList(n):i}resolveClassFieldChain(t,e,r){let s=t;for(let t=0;t<e.length;t++){const i=e[t],n=t===e.length-1;s=ClassInstance.isInstanceOf(s)?this.resolveClassInstanceField(s,i,r):MultiArray.isInstanceOf(s)&&this.hasClassInstanceElement(s)?this.resolveClassArrayField(s,i,r,n):this.resolveStructureLikeField(s,i,n)}return s}evaluatedCallArguments(t,e,r){return t.map((t,s)=>this.evaluatedExpressionValue(t,e,`${r}${s+1}`))}isClassInstanceArray(t){return MultiArray.isInstanceOf(t)&&MultiArray.linearLength(t)>0&&MultiArray.linearize(t).every(ClassInstance.isInstanceOf)}isClassEventListenerArray(t){return MultiArray.isInstanceOf(t)&&MultiArray.linearLength(t)>0&&MultiArray.linearize(t).every(ClassEventListener.isInstanceOf)}inheritedHandleMethodCall(t,e){if("()"!==t.delim||!AST.isNodeIndirectRef(t.expr)||this.hasQualifiedNameAccessOperand(t.expr,e))return;const r=t.expr,s=r.field[r.field.length-1];if("string"!=typeof s||!["addlistener","delete","isvalid","notify"].includes(s))return;const i=r.field.slice(0,-1).map(t=>"string"==typeof t?t:this.evaluatedDynamicFieldName(t,e,"Dynamic structure field names must be strings."));let n=this.evaluatedExpressionValue(r.obj,e,`${s} receiver`);if(i.length>0&&(n=this.resolveDotFieldChain(n,i,r,e)),ClassEventListener.isInstanceOf(n))switch(s){case"delete":return AST.throwInvalidCallError("delete",0!==t.args.length,t=>this.context.throwEvalError(t)),ClassEventListener.delete(n),AST.nodeVoid();case"isvalid":return AST.throwInvalidCallError("isvalid",0!==t.args.length,t=>this.context.throwEvalError(t)),CoreFunctions.isvalid(n);default:return}if(this.isClassEventListenerArray(n))switch(s){case"delete":AST.throwInvalidCallError("delete",0!==t.args.length,t=>this.context.throwEvalError(t));for(const t of MultiArray.linearize(n))ClassEventListener.isInstanceOf(t)||this.context.throwEvalError("internal error: event listener array contains a non-listener value."),ClassEventListener.delete(t);return AST.nodeVoid();case"isvalid":return AST.throwInvalidCallError("isvalid",0!==t.args.length,t=>this.context.throwEvalError(t)),CoreFunctions.isvalid(n);default:return}const a=ClassInstance.isInstanceOf(n)?n.classDefinition:this.isClassInstanceArray(n)?MultiArray.linearize(n).find(ClassInstance.isInstanceOf).classDefinition:void 0;if(!a?.isHandleClass())return;if("delete"!==s&&a.findMethod(s,t=>!t.isStatic))return;const o=()=>this.evaluatedCallArguments(t.args,e,`${s} argument `);if(ClassInstance.isInstanceOf(n))switch(s){case"addlistener":return this.addClassListener("addlistener",n,...o());case"delete":return AST.throwInvalidCallError("delete",0!==t.args.length,t=>this.context.throwEvalError(t)),this.context.deleteClassInstance(n,t);case"isvalid":return AST.throwInvalidCallError("isvalid",0!==t.args.length,t=>this.context.throwEvalError(t)),CoreFunctions.isvalid(n);case"notify":{const t=o();return AST.throwInvalidCallError("notify",t.length<1||t.length>2,t=>this.context.throwEvalError(t)),this.notifyClassEvent(n,t[0],t[1])}default:return}if(this.isClassInstanceArray(n))switch(s){case"addlistener":return this.addClassListener("addlistener",n,...o());case"delete":AST.throwInvalidCallError("delete",0!==t.args.length,t=>this.context.throwEvalError(t));for(const e of MultiArray.linearize(n))ClassInstance.isInstanceOf(e)||this.context.throwEvalError("internal error: object array contains a non-object value."),this.context.deleteClassInstance(e,t);return AST.nodeVoid();case"isvalid":return AST.throwInvalidCallError("isvalid",0!==t.args.length,t=>this.context.throwEvalError(t)),CoreFunctions.isvalid(n);case"notify":{const t=o();return AST.throwInvalidCallError("notify",t.length<1||t.length>2,t=>this.context.throwEvalError(t)),this.notifyClassEvent(n,t[0],t[1])}default:return}}resolveNestedClassInstanceIndexedField(t,e,r,s){const i=this.resolveClassFieldChain(t,e,s);return this.nativeSubscriptScalar(i,r)}resolveClassArrayDescriptorIndexedField(t,e,r,s,i,n){const a=MultiArray.getElements(t,"",[],e,this),o=MultiArray.isInstanceOf(a)?a:MultiArray.scalarToMultiArray(this.expressionValue(a,"selection")),l=new MultiArray(n??o.dimension),c=MultiArray.linearize(o);for(let t=0;t<c.length;t++){const e=c[t];ClassInstance.isInstanceOf(e)||this.context.throwEvalError("object array indexed field access requires class instance elements.");const[n,a]=MultiArray.linearIndexToMultiArrayRowColumn(l.dimension[0],l.dimension[1],t);l.array[n][a]=this.resolveNestedClassInstanceIndexedField(e,r,s,i)}MultiArray.setType(l);const u=MultiArray.linearize(l);return 1===u.length?this.expressionValue(MultiArray.MultiArrayToScalar(l),"indexed property"):(this.context.requestedOutputCount>1||this.context.commaListExpansionEnabled)&&!u.every(t=>ClassBoundMethod.isInstanceOf(t))?this.valueReturnList(u):l}resolveStructureLikeField(t,e,r){if(MultiArray.isInstanceOf(t)&&Structure.isStructure(t)){const s=Structure.getFields(t,[e]);return r&&s.length>1?AST.nodeList(this.expressionList(s,e)):MultiArray.MultiArrayToScalar(MultiArray.toRowVector(s))}return Structure.getField(t,[e])}createSubscriptDescriptor(t,e,r,s){const i=new MultiArray([1,e.length]);i.isCell=!0;for(let t=0;t<e.length;t++){const r=e[t];i.array[0][t]=":"===r.type?CharString.create(":"):this.evaluatedExpressionValue(r,s,`subscript${t+1}`)}return MultiArray.setType(i),new Structure({type:CharString.create(t),subs:i})}createSubsrefDescriptor(t,e){return this.createSubscriptDescriptor(t.delim,t.args,t,e)}createDotSubscriptDescriptor(t,e,r){return this.expressionValue(CharString.create(t),"dot subscript"),new Structure({type:CharString.create("."),subs:CharString.create(t)})}createSubscriptDescriptorArray(t){if(1===t.length)return t[0];const e=new MultiArray([1,t.length]);for(let r=0;r<t.length;r++)e.array[0][r]=t[r];return MultiArray.setType(e),e}numericScalarToNumber(t,e){const r=MultiArray.firstElement(t);return Complex.isInstanceOf(r)||this.context.throwEvalError(e),Complex.realToNumber(r)}callClassInstanceMethodWithOutputCount(t,e,r,s,i,n){this.context.pushRequestedOutputCount(i),n&&this.context.pushRequestedOutputMask(n);try{return this.context.callClassInstanceMethod(t,e,r,s)}finally{n&&this.context.popRequestedOutputMask(),this.context.popRequestedOutputCount()}}callClassNumArgumentsFromSubscript(t,e,r){const s=t.classDefinition.findMethod("numArgumentsFromSubscript",t=>!t.isStatic);if(!s)return;this.context.canAccessClassMember(s.classDefinition,s.access)||this.context.throwEvalError(`method 'numArgumentsFromSubscript' has ${s.access} access for class ${t.classDefinition.name}.`);const i=this.reducedClassMethodResultWithOutputCount(t,s,this.classMethodArgumentValues([e,CharString.create("subsref")],"numArgumentsFromSubscript"),r,1),n=this.numericScalarToNumber(i,`numArgumentsFromSubscript for class ${t.classDefinition.name} must return a numeric scalar.`);return(!Number.isFinite(n)||!Number.isInteger(n)||n<0)&&this.context.throwEvalError(`numArgumentsFromSubscript for class ${t.classDefinition.name} must return a nonnegative integer scalar.`),n}callClassSubsrefMethod(t,e,r,s){const i=this.context.requestedOutputCount;if(i<=1)return this.reducedClassMethodResult(t,e,this.classMethodArgumentValues([r],"subsref"),s);const n=this.callClassNumArgumentsFromSubscript(t,r,s)??i;AST.throwErrorIfGreaterThanReturnList(n,i,t=>this.context.throwEvalError(t));const a=this.context.requestedOutputMask(i),o=t=>a[t]??!0;return AST.nodeReturnList((t,e)=>{const r=t[`out${e}`];return void 0===r&&AST.throwErrorIfGreaterThanReturnList(e,e+1,t=>this.context.throwEvalError(t)),r},i=>{AST.throwErrorIfGreaterThanReturnList(n,i,t=>this.context.throwEvalError(t));const l=this.callClassInstanceMethodWithOutputCount(t,e,this.classMethodArgumentValues([r],"subsref"),s,i,a.slice(0,i)),c={length:i};if(AST.isNodeReturnList(l)){const t=l.handler(i);for(let e=0;e<i;e++)o(e)&&(c[`out${e}`]=l.selector(t,e));return c}return i>1&&AST.throwErrorIfGreaterThanReturnList(1,i,t=>this.context.throwEvalError(t)),c.out0=l,c})}callClassSubsref(t,e,r){const s=t.classDefinition.findMethod("subsref",t=>!t.isStatic);if(!s)return;this.context.canAccessClassMember(s.classDefinition,s.access)||this.context.throwEvalError(`method 'subsref' has ${s.access} access for class ${t.classDefinition.name}.`);const i=this.createSubsrefDescriptor(e,r);return this.callClassSubsrefMethod(t,s,i,e)}callClassSubsrefDescriptors(t,e,r){const s=t.classDefinition.findMethod("subsref",t=>!t.isStatic);if(!s)return;this.context.canAccessClassMember(s.classDefinition,s.access)||this.context.throwEvalError(`method 'subsref' has ${s.access} access for class ${t.classDefinition.name}.`);const i=this.createSubscriptDescriptorArray(e);return this.callClassSubsrefMethod(t,s,i,r)}callClassDotSubsref(t,e,r,s){const i=t.classDefinition.findMethod("subsref",t=>!t.isStatic);if(!i)return;this.context.canAccessClassMember(i.classDefinition,i.access)||this.context.throwEvalError(`method 'subsref' has ${i.access} access for class ${t.classDefinition.name}.`);const n=this.createDotSubscriptDescriptor(e,r,s);return this.callClassSubsrefMethod(t,i,n,r)}collectClassSubsrefChain(t,e){if("IDX"===t.type){const r=this.collectClassSubsrefChain(t.expr,e);if(!r){const r=this.evaluatedExpressionValue(t.expr,e,"subsref chain receiver");if(MultiArray.isInstanceOf(r)&&this.hasClassInstanceElement(r)){const s=this.reducedIndexingResult(this.context.apply(r,t.args,t));if(ClassInstance.isInstanceOf(s))return{instance:s,descriptors:[this.createSubsrefDescriptor(t,e)]}}return}return r.descriptors.push(this.createSubsrefDescriptor(t,e)),r}if("."===t.type){const r=this.collectClassSubsrefChain(t.obj,e);if(!r)return;for(const s of t.field){const i="string"==typeof s?s:this.evaluatedDynamicFieldName(s,e,"Dynamic structure field names must be strings.");r.descriptors.push(this.createDotSubscriptDescriptor(i,t,e))}return r}const r=this.evaluatedExpressionValue(t,e,"subsref chain receiver");return ClassInstance.isInstanceOf(r)?{instance:r,descriptors:[]}:void 0}collectSubsasgnAssignmentTarget(t,e){const r=t=>{if(AST.isNodeIdentifier(t))return{id:t.id,descriptors:[]};if(AST.isNodeIndexExpr(t)){const s=r(t.expr);if(!s)return;return s.descriptors.push(this.createSubscriptDescriptor(t.delim,t.args,t,e)),s}if(AST.isNodeIndirectRef(t)){const s=r(t.obj);if(!s)return;for(const r of t.field){const i="string"==typeof r?r:this.evaluatedDynamicFieldName(r,e,"invalid left hand side of assignment: dynamic structure field names must be strings.");s.descriptors.push(this.createDotSubscriptDescriptor(i,t,e))}return s}},s=r(t);return s&&s.descriptors.length>0?{id:s.id,field:[],descriptors:s.descriptors}:void 0}indexedAssignmentRhs(t,e,r,s=!1){return"{}"===t?(void 0!==r&&MultiArray.isInstanceOf(r)&&!r.isCell&&this.context.throwEvalError("matrix cannot be indexed with {"),MultiArray.firstRow([this.runtimeExpressionValue(e,"cell assignment value")],!0)):s?new MultiArray([1,1],[[this.runtimeExpressionValue(e,"cell assignment value")]]):!s&&"()"===t&&MultiArray.isInstanceOf(e)&&e.isCell?(void 0!==r&&MultiArray.isInstanceOf(r)&&!r.isCell&&this.context.throwEvalError("cell array assignment requires a cell array target."),e):"()"===t&&MultiArray.isInstanceOf(r)&&r.isCell?(MultiArray.isInstanceOf(e)&&!e.isCell&&MultiArray.isEmpty(e)||MultiArray.isInstanceOf(e)&&e.isCell||this.context.throwEvalError("cell array assignment requires a cell array value."),e):MultiArray.scalarToMultiArray(this.runtimeExpressionValue(e,"indexed assignment value"))}readNativeSubscriptDescriptor(t,e="subsasgn"){const r=t.field.type,s=t.field.subs;if((!CharString.isInstanceOf(r)||"()"!==r.str&&"{}"!==r.str&&"."!==r.str)&&this.context.throwEvalError(`invalid ${e} descriptor.`),"."===r.str){if(CharString.isInstanceOf(s))return{type:".",subs:[s]};if(MultiArray.isInstanceOf(s)&&s.isCell){const t=this.descriptorSubscripts(s);if(1===t.length&&CharString.isInstanceOf(t[0]))return{type:".",subs:t}}this.context.throwEvalError(`invalid ${e} descriptor.`)}return MultiArray.isInstanceOf(s)&&s.isCell||this.context.throwEvalError(`invalid ${e} descriptor.`),{type:r.str,subs:this.descriptorSubscripts(s)}}descriptorSubscripts(t){return MultiArray.linearize(t).map((t,e)=>this.expressionValue(t,`subscript${e+1}`))}subscriptDescriptorStructures(t,e){const r=Structure.structureElements(t);return 0===r.length&&this.context.throwEvalError(`${e}: subscript argument must be a structure array.`),r.forEach(t=>this.readNativeSubscriptDescriptor(t,e)),r}nativeSubsrefNativeDescriptors(t,e){let r=t;for(let t=0;t<e.length;t++){const s=e[t],i=t===e.length-1,n=t=>{if("()"===s.type&&(ClassBoundMethod.isInstanceOf(t)||MultiArray.isInstanceOf(t)&&MultiArray.linearLength(t)>0&&MultiArray.linearize(t).every(ClassBoundMethod.isInstanceOf))){const e=s.subs.map((t,e)=>this.expressionValue(t,`subsref method argument ${e+1}`));return this.context.callClassBoundMethodValue(t,e,AST.nodeIdentifier("subsref"))}return"."===s.type?this.nativeDotSubsrefResult(t,s):"{}"===s.type?this.nativeBraceSubsrefResult(t,s):i&&"()"===s.type?this.nativeParenSubsrefResult(t,s):this.nativeSubscriptScalar(t,s)};r=AST.isNodeReturnList(r)&&r.commaSeparated?this.chainedCommaListResult(this.context.expandCommaSeparatedList(r).map(t=>n(t))):n(r)}return r}nativeSubsrefDescriptors(t,e){return this.nativeSubsrefNativeDescriptors(t,e.map(t=>this.readNativeSubscriptDescriptor(t,"subsref")))}nativeDotSubsrefResult(t,e){const r=e.subs[0];CharString.isInstanceOf(r)||this.context.throwEvalError("invalid subsref descriptor.");const s=Structure.getFields(t,[r.str]);return s.length>1?this.valueReturnList(s):this.expressionValue(s[0],`field ${r.str}`)}nativeBraceSubsrefResult(t,e){MultiArray.isInstanceOf(t)&&t.isCell||this.context.throwEvalError("matrix cannot be indexed with {");const r=MultiArray.getElements(t,"",[],this.nativeDescriptorIndexList(e,t),this),s=MultiArray.linearize(r);return s.length>1?this.valueReturnList(s):this.expressionValue(MultiArray.MultiArrayToScalar(r),"indexed value")}nativeParenSubsrefResult(t,e){if(CharString.isInstanceOf(t)){const r=MultiArray.characterVectorFromCharString(t),s=MultiArray.getElements(r,"",[],this.nativeDescriptorIndexList(e,r),this);return MultiArray.charStringFromCharacterVectorResult(s,t.quote)}MultiArray.isInstanceOf(t)||this.context.throwEvalError("matrix cannot be indexed with (");const r=MultiArray.getElements(t,"",[],this.nativeDescriptorIndexList(e,t),this);return t.isCell?(MultiArray.isInstanceOf(r)||this.context.throwEvalError("internal error: cell parenthesis indexing did not produce a cell array."),r.isCell=!0,r):this.expressionValue(MultiArray.MultiArrayToScalar(r),"indexed value")}numericCodeToCharString(t,e='"'){return 0!==Complex.imagToNumber(t)&&this.context.throwEvalError("character string assignment requires real character codes."),CharString.fromNumericCode(Complex.realToNumber(t),e)}charStringAssignmentElement(t,e='"'){return CharString.isInstanceOf(t)?t:Complex.isInstanceOf(t)?this.numericCodeToCharString(t,e):void this.context.throwEvalError("character string assignment requires character or numeric values.")}charStringAssignmentRhs(t,e='"'){if(CharString.isInstanceOf(t))return MultiArray.characterVectorFromCharString(t);if(MultiArray.isInstanceOf(t)&&!t.isCell){const r=new MultiArray(t.dimension);for(let s=0;s<MultiArray.linearLength(t);s++){const[i,n]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],s);r.array[i][n]=this.charStringAssignmentElement(t.array[i][n],e)}return MultiArray.setType(r),r}return MultiArray.scalarToMultiArray(this.charStringAssignmentElement(t,e))}publicObjectArraySubscriptTarget(t,e){if(!MultiArray.isInstanceOf(t)||!this.hasClassInstanceElement(t)||0===e.length)return;const r=this.readNativeSubscriptDescriptor(e[0]);if("."===r.type)return;const s=this.singleOutputNativeSubscriptScalar(t,r);return ClassInstance.isInstanceOf(s)?s:void 0}singleOutputNativeSubscriptScalar(t,e){this.context.pushRequestedOutputCount(1);try{return this.reducedIndexingResult(this.nativeSubscriptScalar(t,e))}finally{this.context.popRequestedOutputCount()}}publicCellContentSubscriptSelection(t,e){if(!MultiArray.isInstanceOf(t)||!t.isCell||0===e.length)return;const r=this.readNativeSubscriptDescriptor(e[0]);if("{}"===r.type){const s=this.singleOutputNativeSubscriptScalar(t,r);return ClassInstance.isInstanceOf(s)?{instance:s,objectDescriptors:e.slice(1),contentDescriptor:r}:void 0}if("()"!==r.type||e.length<2)return;const s=this.readNativeSubscriptDescriptor(e[1]);if("{}"!==s.type)return;const i=this.nativeParenSubsrefResult(t,r);if(!MultiArray.isInstanceOf(i)||!i.isCell)return;const n=this.singleOutputNativeSubscriptScalar(i,s);return ClassInstance.isInstanceOf(n)?{instance:n,objectDescriptors:e.slice(2),contentDescriptor:s,outerDescriptor:r,selectedCell:i}:void 0}dotDescriptorFieldChain(t,e="subsasgn"){const r=[];for(const s of t){if("."!==s.type)return;const t=s.subs[0];CharString.isInstanceOf(t)||this.context.throwEvalError(`invalid ${e} descriptor.`),r.push(t.str)}return r}classPropertyDescriptorChain(t,e){const r={fields:[]};let s=0;if("()"===t[0]?.type)r.leadingIndex=t[0],s=1;else if("{}"===t[0]?.type)return;for(;s<t.length;s++){const i=t[s];if("."!==i.type)break;const n=i.subs[0];CharString.isInstanceOf(n)||this.context.throwEvalError(`invalid ${e} descriptor.`),r.fields.push(n.str)}if(0!==r.fields.length){if(s<t.length){if(s!==t.length-1||"."===t[s].type)return;r.finalIndex=t[s]}return r}}classPropertyDescriptorPath(t,e){const r={fields:[]};let s=0;if("()"===t[0]?.type)r.leadingIndex=t[0],s=1;else if("{}"===t[0]?.type)return;for(;s<t.length&&"."===t[s].type;s++){const i=t[s].subs[0];CharString.isInstanceOf(i)||this.context.throwEvalError(`invalid ${e} descriptor.`),r.fields.push(i.str)}if(0!==r.fields.length)return r.tailDescriptors=t.slice(s),1===r.tailDescriptors.length&&(r.finalIndex=r.tailDescriptors[0]),r}indexedClassPropertyValue(t,e,r){return MultiArray.isInstanceOf(t)||this.context.throwEvalError(`matrix cannot be indexed with ${e.type[0]}`),this.setNativeIndexedValue(t,e,r)}assignNestedClassInstanceIndexedField(t,e,r,s,i,n){const a=this.resolveClassFieldChain(t,e,i),o=this.indexedClassPropertyValue(a,r,s);return this.assignNestedClassInstanceField(t,e,o,i,n)}resolveClassSubsrefDescriptors(t,e,r){const s=this.classPropertyDescriptorPath(e,"subsref");if(ClassInstance.isInstanceOf(t)){if(!s||s.leadingIndex)return;const e=this.resolveClassFieldChain(t,s.fields,r);return s.tailDescriptors&&s.tailDescriptors.length>0?this.nativeSubsrefNativeDescriptors(e,s.tailDescriptors):e}if(s&&MultiArray.isInstanceOf(t)&&this.hasClassInstanceElement(t)&&0!==e.length){if(s.leadingIndex){const e=this.nativeDescriptorIndexList(s.leadingIndex,t);return this.resolveClassArrayPropertyPath(t,e,s,r)}return this.resolveClassArrayPropertyPath(t,[MultiArray.expandColon(MultiArray.linearLength(t))],s,r,t.dimension)}}assignClassArrayDescriptorIndexedField(t,e,r,s,i,n,a){const o=MultiArray.copy(t),l=MultiArray.getElements(o,"",[],e),c=this.assignmentValues(l,"selection"),u=1===c.length?[i]:this.assignmentValues(i,"assignment");1!==u.length&&u.length!==c.length&&this.context.throwEvalError(`assignment value count ${u.length} does not match selected object count ${c.length}.`);const h=MultiArray.isInstanceOf(l)?l:MultiArray.scalarToMultiArray(this.expressionValue(l,"selection")),d=new MultiArray(h.dimension);for(let t=0;t<c.length;t++){const e=c[t];ClassInstance.isInstanceOf(e)||this.context.throwEvalError("object array indexed field assignment requires class instance elements.");const[i,o]=MultiArray.linearIndexToMultiArrayRowColumn(d.dimension[0],d.dimension[1],t);d.array[i][o]=this.assignNestedClassInstanceIndexedField(e,r,s,1===u.length?u[0]:u[t],n,a)}MultiArray.setType(d);const m=Scope.create();return m.defineName("__object_array_subsasgn__",o),MultiArray.setElements(m,"__object_array_subsasgn__",[],e,d,void 0,this),this.scopedMultiArrayValue(m,"__object_array_subsasgn__","object array assignment result")}resolveClassArrayPropertyPath(t,e,r,s,i){const n=MultiArray.getElements(t,"",[],e,this),a=MultiArray.isInstanceOf(n)?n:MultiArray.scalarToMultiArray(this.expressionValue(n,"selection")),o=MultiArray.linearize(a),l=(t,e)=>{ClassInstance.isInstanceOf(t)||this.context.throwEvalError("object array indexed property access requires class instance elements."),e&&this.context.pushRequestedOutputCount(1);try{const e=this.resolveClassFieldChain(t,r.fields,s);return r.tailDescriptors&&r.tailDescriptors.length>0?this.nativeSubsrefNativeDescriptors(e,r.tailDescriptors):e}finally{e&&this.context.popRequestedOutputCount()}};if(1===o.length&&!i)return l(o[0],!1);const c=new MultiArray(i??a.dimension);for(let t=0;t<o.length;t++){const[e,r]=MultiArray.linearIndexToMultiArrayRowColumn(c.dimension[0],c.dimension[1],t);c.array[e][r]=l(o[t],!0)}MultiArray.setType(c);const u=MultiArray.linearize(c);return 1===u.length?this.expressionValue(MultiArray.MultiArrayToScalar(c),"indexed property"):(this.context.requestedOutputCount>1||this.context.commaListExpansionEnabled)&&!u.every(t=>ClassBoundMethod.isInstanceOf(t))?this.valueReturnList(u):c}resolveClassCellContentPropertyPath(t,e,r,s){const i=MultiArray.getElements(t,"",[],this.nativeDescriptorIndexList(e,t),this),n=MultiArray.isInstanceOf(i)?i:MultiArray.scalarToMultiArray(this.expressionValue(i,"selection")),a=MultiArray.linearize(n),o=(t,e)=>{ClassInstance.isInstanceOf(t)||this.context.throwEvalError("cell content property access requires class instance elements."),e&&this.context.pushRequestedOutputCount(1);try{const e=this.resolveClassFieldChain(t,r.fields,s);return r.tailDescriptors&&r.tailDescriptors.length>0?this.nativeSubsrefNativeDescriptors(e,r.tailDescriptors):e}finally{e&&this.context.popRequestedOutputCount()}};if(1===a.length)return o(a[0],!1);const l=new MultiArray(n.dimension);for(let t=0;t<a.length;t++){const[e,r]=MultiArray.linearIndexToMultiArrayRowColumn(l.dimension[0],l.dimension[1],t);l.array[e][r]=o(a[t],!0)}MultiArray.setType(l);const c=MultiArray.linearize(l);return this.context.requestedOutputCount>1||this.context.commaListExpansionEnabled?this.valueReturnList(c):l}selectedCellContentsAreClassInstances(t,e){this.context.pushRequestedOutputCount(1);try{const r=MultiArray.getElements(t,"",[],this.nativeDescriptorIndexList(e,t),this),s=MultiArray.isInstanceOf(r)?r:MultiArray.scalarToMultiArray(this.expressionValue(r,"selection"));return MultiArray.linearize(s).every(t=>ClassInstance.isInstanceOf(t))}finally{this.context.popRequestedOutputCount()}}assignClassInstancePropertyPath(t,e,r,s,i){if(!e.tailDescriptors||0===e.tailDescriptors.length)return this.assignNestedClassInstanceField(t,e.fields,r,s,i);const n=this.resolveClassFieldChain(t,e.fields,s),a=this.assignNativeSubsasgnNativeDescriptors(n,e.tailDescriptors,r);return this.assignNestedClassInstanceField(t,e.fields,a,s,i)}assignClassArrayPropertyPath(t,e,r,s,i,n){const a=MultiArray.copy(t),o=MultiArray.getElements(a,"",[],e),l=this.assignmentValues(o,"selection"),c=this.classPropertyPathAssignmentValues(s,l.length,r);1!==c.length&&c.length!==l.length&&this.context.throwEvalError(`assignment value count ${c.length} does not match selected object count ${l.length}.`);const u=MultiArray.isInstanceOf(o)?o:MultiArray.scalarToMultiArray(this.expressionValue(o,"selection")),h=new MultiArray(u.dimension);for(let t=0;t<l.length;t++){const e=l[t];ClassInstance.isInstanceOf(e)||this.context.throwEvalError("object array indexed field assignment requires class instance elements.");const[s,a]=MultiArray.linearIndexToMultiArrayRowColumn(h.dimension[0],h.dimension[1],t);h.array[s][a]=this.assignClassInstancePropertyPath(e,r,1===c.length?c[0]:c[t],i,n)}MultiArray.setType(h);const d=Scope.create();return d.defineName("__object_array_subsasgn__",a),MultiArray.setElements(d,"__object_array_subsasgn__",[],e,h,void 0,this),this.scopedMultiArrayValue(d,"__object_array_subsasgn__","object array assignment result")}assignClassCellContentPropertyPath(t,e,r,s,i,n){const a=MultiArray.copy(t),o=this.nativeDescriptorIndexList(e,a),l=MultiArray.getElements(a,"",[],o),c=MultiArray.isInstanceOf(l)?l:MultiArray.scalarToMultiArray(this.expressionValue(l,"selection")),u=MultiArray.linearize(c).map((t,e)=>this.expressionValue(t,`selection${e+1}`)),h=this.classPropertyPathAssignmentValues(s,u.length,r);1!==h.length&&h.length!==u.length&&this.context.throwEvalError(`assignment value count ${h.length} does not match selected object count ${u.length}.`);const d=new MultiArray(c.dimension);for(let t=0;t<u.length;t++){const e=u[t];ClassInstance.isInstanceOf(e)||this.context.throwEvalError("cell content property assignment requires class instance elements.");const[s,a]=MultiArray.linearIndexToMultiArrayRowColumn(d.dimension[0],d.dimension[1],t);d.array[s][a]=this.assignClassInstancePropertyPath(e,r,1===h.length?h[0]:h[t],i,n)}MultiArray.setType(d);const m=1===u.length?this.expressionValue(MultiArray.MultiArrayToScalar(d),"cell object assignment value"):d,p=this.setNativeIndexedValue(a,e,m);return MultiArray.isInstanceOf(p)||this.context.throwEvalError("internal error: cell object assignment result is not an array."),p}assignClassSubsasgnDescriptors(t,e,r,s){const i=this.context.currentScope;if(MultiArray.isInstanceOf(t)&&t.isCell&&"{}"===e[0]?.type){const n=this.classPropertyDescriptorPath(e.slice(1),"subsasgn");if(n&&!n.leadingIndex&&this.selectedCellContentsAreClassInstances(t,e[0]))return this.assignClassCellContentPropertyPath(t,e[0],n,r,s,i)}if(MultiArray.isInstanceOf(t)&&t.isCell&&"()"===e[0]?.type&&"{}"===e[1]?.type){const n=this.nativeParenSubsrefResult(t,e[0]);if(MultiArray.isInstanceOf(n)&&n.isCell){const a=this.classPropertyDescriptorPath(e.slice(2),"subsasgn");if(a&&!a.leadingIndex&&this.selectedCellContentsAreClassInstances(n,e[1])){const o=this.assignClassCellContentPropertyPath(n,e[1],a,r,s,i);return this.setNativeIndexedValue(t,e[0],o)}}}const n=this.classPropertyDescriptorPath(e,"subsasgn");if(ClassInstance.isInstanceOf(t)){if(!n||n.leadingIndex)return;return this.assignClassInstancePropertyPath(ClassInstance.copy(t),n,r,s,i)}if(n&&MultiArray.isInstanceOf(t)&&this.hasClassInstanceElement(t)){if(n.leadingIndex){const e=this.nativeDescriptorIndexList(n.leadingIndex,t);return this.assignClassArrayPropertyPath(t,e,n,r,s,i)}return this.assignClassArrayPropertyPath(t,[MultiArray.expandColon(MultiArray.linearLength(t))],n,r,s,i)}}resolveClassCellSubsrefDescriptors(t,e,r){if(!MultiArray.isInstanceOf(t)||!t.isCell||"{}"!==e[0]?.type){if(MultiArray.isInstanceOf(t)&&t.isCell&&"()"===e[0]?.type&&"{}"===e[1]?.type){const s=this.nativeParenSubsrefResult(t,e[0]);if(MultiArray.isInstanceOf(s)&&s.isCell){const t=this.classPropertyDescriptorPath(e.slice(2),"subsref");if(t&&!t.leadingIndex&&this.selectedCellContentsAreClassInstances(s,e[1]))return this.resolveClassCellContentPropertyPath(s,e[1],t,r)}}return}const s=this.classPropertyDescriptorPath(e.slice(1),"subsref");if(s&&!s.leadingIndex&&this.selectedCellContentsAreClassInstances(t,e[0]))return this.resolveClassCellContentPropertyPath(t,e[0],s,r)}subsrefResult(t,e){const r=this.subscriptDescriptorStructures(e,"subsref"),s=r.map(t=>this.readNativeSubscriptDescriptor(t,"subsref"));if(ClassInstance.isInstanceOf(t)){const e=this.callClassSubsrefDescriptors(t,r,AST.nodeIdentifier("subsref"));if(void 0!==e)return e;const i=this.resolveClassSubsrefDescriptors(t,s,AST.nodeIdentifier("subsref"));if(void 0!==i)return i}const i=this.publicObjectArraySubscriptTarget(t,r);if(i){const t=this.callClassSubsrefDescriptors(i,r,AST.nodeIdentifier("subsref"));if(void 0!==t)return t}const n=this.publicCellContentSubscriptSelection(t,r);if(n&&n.objectDescriptors.length>0){const t=this.callClassSubsrefDescriptors(n.instance,n.objectDescriptors,AST.nodeIdentifier("subsref"));if(void 0!==t)return t}const a=this.resolveClassSubsrefDescriptors(t,s,AST.nodeIdentifier("subsref"));if(void 0!==a)return a;const o=this.resolveClassCellSubsrefDescriptors(t,s,AST.nodeIdentifier("subsref"));return void 0!==o?o:this.nativeSubsrefDescriptors(t,r)}subsasgnResult(t,e,r){const s=this.subscriptDescriptorStructures(e,"subsasgn"),i=s.map(t=>this.readNativeSubscriptDescriptor(t,"subsasgn"));if(ClassInstance.isInstanceOf(t)){const e=this.callClassSubsasgnDescriptors(t,s,r,AST.nodeIdentifier("subsasgn"));if(void 0!==e)return e;const n=this.assignClassSubsasgnDescriptors(t,i,r,AST.nodeIdentifier("subsasgn"));if(void 0!==n)return n}const n=this.publicObjectArraySubscriptTarget(t,s);if(n){const e=this.callClassSubsasgnDescriptors(n,s,r,AST.nodeIdentifier("subsasgn"));if(void 0!==e)return MultiArray.isInstanceOf(t)||this.context.throwEvalError("internal error: object-array subsasgn target is not an array."),this.setNativeIndexedValue(t,this.readNativeSubscriptDescriptor(s[0]),e)}const a=this.publicCellContentSubscriptSelection(t,s);if(a&&a.objectDescriptors.length>0){const e=this.callClassSubsasgnDescriptors(a.instance,a.objectDescriptors,r,AST.nodeIdentifier("subsasgn"));if(void 0!==e){if(MultiArray.isInstanceOf(t)||this.context.throwEvalError("internal error: cell-object subsasgn target is not an array."),a.outerDescriptor&&a.selectedCell){const r=this.setNativeIndexedValue(a.selectedCell,a.contentDescriptor,e);return MultiArray.isInstanceOf(r)&&r.isCell||this.context.throwEvalError("internal error: selected cell-object subsasgn result is not a cell array."),this.setNativeIndexedValue(t,a.outerDescriptor,r)}return this.setNativeIndexedValue(t,a.contentDescriptor,e)}}const o=this.assignClassSubsasgnDescriptors(t,i,r,AST.nodeIdentifier("subsasgn"));return void 0!==o?o:this.assignNativeSubsasgnDescriptors(t,s,r)}nativeDescriptorIndexList(t,e){return t.subs.map((r,s)=>{if(CharString.isInstanceOf(r)&&":"===r.str)return 1===t.subs.length?MultiArray.expandColon(MultiArray.linearLength(e)):MultiArray.expandColon(MultiArray.getDimension(e,s));const i=this.convertIndexArgument(r,AST.nodeIdentifier("subsindex"));return MultiArray.isIndexArgument(i)||this.context.throwEvalError(`subscript${s+1}: invalid subscript type.`),i})}nativeSubscriptScalar(t,e){if("."===e.type){const r=e.subs[0];return CharString.isInstanceOf(r)||this.context.throwEvalError("invalid subsasgn descriptor."),this.expressionValue(Structure.getField(t,[r.str]),`field ${r.str}`)}if(CharString.isInstanceOf(t)){"{}"===e.type&&this.context.throwEvalError("matrix cannot be indexed with {");const r=MultiArray.characterVectorFromCharString(t),s=MultiArray.getElements(r,"",[],this.nativeDescriptorIndexList(e,r),this);return MultiArray.charStringFromCharacterVectorResult(s,t.quote)}MultiArray.isInstanceOf(t)||this.context.throwEvalError(`matrix cannot be indexed with ${e.type[0]}`),"{}"!==e.type||t.isCell||this.context.throwEvalError("matrix cannot be indexed with {");const r=this.nativeDescriptorIndexList(e,t),s=MultiArray.getElements(t,"",[],r,this);return"()"===e.type&&t.isCell?(MultiArray.isInstanceOf(s)||this.context.throwEvalError("internal error: cell parenthesis indexing did not produce a cell array."),s.isCell=!0,s):this.expressionValue(MultiArray.MultiArrayToScalar(s),"indexed value")}setNativeIndexedValue(t,e,r){if(CharString.isInstanceOf(t)){"{}"===e.type&&this.context.throwEvalError("matrix cannot be indexed with {");const s=MultiArray.characterVectorFromCharString(t),i=Scope.create();return i.defineName("__subsasgn__",s),MultiArray.setElements(i,"__subsasgn__",[],this.nativeDescriptorIndexList(e,s),this.charStringAssignmentRhs(r,t.quote),void 0,this),MultiArray.charStringFromCharacterVectorResult(this.scopedExpressionValue(i,"__subsasgn__","character assignment result"),t.quote)}"{}"!==e.type||t.isCell||this.context.throwEvalError("matrix cannot be indexed with {");const s=MultiArray.copy(t);let i=this.indexedAssignmentRhs(e.type,r,s);if("{}"===e.type&&MultiArray.isInstanceOf(r)&&!r.isCell)try{const t=MultiArray.linearize(MultiArray.getElements(s,"",[],this.nativeDescriptorIndexList(e,s),this)).length;t>1&&t===MultiArray.linearLength(r)&&(i=MultiArray.firstRow(MultiArray.linearize(r),!0))}catch{i=this.indexedAssignmentRhs(e.type,r,s)}const n=Scope.create();return n.defineName("__subsasgn__",s),MultiArray.setElements(n,"__subsasgn__",[],this.nativeDescriptorIndexList(e,s),i,void 0,this),this.scopedMultiArrayValue(n,"__subsasgn__","indexed assignment result")}blankNativeSubsasgnValue(t){return t&&"."!==t.type?"()"===t.type&&1===t.subs.length?new MultiArray([1,0],void 0,!1):"{}"===t.type&&1===t.subs.length?new MultiArray([1,0],void 0,!0):MultiArray.emptyArray("{}"===t.type):new Structure({})}nativeSubscriptScalarForAssignment(t,e,r){try{return this.nativeSubscriptScalar(t,e)}catch(e){if(MultiArray.isInstanceOf(t))return this.blankNativeSubsasgnValue(r);throw e}}assignNativeSubsasgnNativeDescriptors(t,e,r){if(0===e.length)return r;const s=(t,e,r)=>1===e||r&&MultiArray.isInstanceOf(t)&&MultiArray.isEmpty(t)?[this.expressionValue(t,"assignment")]:this.assignmentValues(t,"assignment"),i=(t,n,a=r)=>{const o=e[n];if(!o)return a;if("."===o.type){const r=o.subs[0];CharString.isInstanceOf(r)||this.context.throwEvalError("invalid subsasgn descriptor."),MultiArray.isEmpty(t)&&(t=new Structure({})),Structure.isInstanceOf(t)||Structure.isStructure(t)||this.context.throwEvalError("value cannot be indexed with .");const l=Structure.isInstanceOf(t)?Structure.copy(t):MultiArray.isInstanceOf(t)?MultiArray.copy(t):void 0;l||this.context.throwEvalError("value cannot be indexed with .");const c=Structure.structureElements(l);if(c.length>1&&n<e.length-1){const t=s(a,c.length,!0);return 1!==t.length&&t.length!==c.length&&this.context.throwEvalError(`assignment value count ${t.length} does not match selected structure count ${c.length}.`),c.forEach((s,a)=>{let o;try{o=this.expressionValue(Structure.getField(s,[r.str]),`field ${r.str}`)}catch{o=this.blankNativeSubsasgnValue(e[n+1])}const l=i(o,n+1,1===t.length?t[0]:t[a]);Structure.setNewField(s,[r.str],this.runtimeExpressionValue(l,`field ${r.str}`))}),l}let u;try{u=this.expressionValue(Structure.getField(l,[r.str]),`field ${r.str}`)}catch{u=this.blankNativeSubsasgnValue(e[n+1])}const h=n===e.length-1?a:i(u,n+1,a);return Structure.setNewField(l,[r.str],this.runtimeExpressionValue(h,`field ${r.str}`)),l}MultiArray.isInstanceOf(t)||CharString.isInstanceOf(t)||this.context.throwEvalError(`matrix cannot be indexed with ${o.type[0]}`);const l=n===e.length-1?a:i(this.nativeSubscriptScalarForAssignment(t,o,e[n+1]),n+1,a);return this.setNativeIndexedValue(t,o,l)};return i(t,0)}assignNativeSubsasgnDescriptors(t,e,r){return this.assignNativeSubsasgnNativeDescriptors(t,e.map(t=>this.readNativeSubscriptDescriptor(t,"subsasgn")),r)}shouldUseNativeChainedSubsasgn(t){if(t.length>2)return!0;if(t.length<2)return!1;const[e,r]=t.map(t=>this.readNativeSubscriptDescriptor(t).type);return!("()"===e&&"."===r)}callClassSubsasgn(t,e,r,s,i,n){const a=t.classDefinition.findMethod("subsasgn",t=>!t.isStatic);if(!a)return;this.context.canAccessClassMember(a.classDefinition,a.access)||this.context.throwEvalError(`method 'subsasgn' has ${a.access} access for class ${t.classDefinition.name}.`);const o=this.createSubsasgnDescriptor(e,r,i,n);return this.classSubsasgnResult(t,a,this.classMethodArgumentValues([o,s],"subsasgn"),i)}callClassSubsasgnDescriptors(t,e,r,s){const i=t.classDefinition.findMethod("subsasgn",t=>!t.isStatic);if(!i)return;this.context.canAccessClassMember(i.classDefinition,i.access)||this.context.throwEvalError(`method 'subsasgn' has ${i.access} access for class ${t.classDefinition.name}.`);const n=this.createSubscriptDescriptorArray(e);return this.classSubsasgnResult(t,i,this.classMethodArgumentValues([n,r],"subsasgn"),s)}createSubsasgnDescriptor(t,e,r,s){return this.createSubscriptDescriptor(e,t,r,s)}callClassDotSubsasgn(t,e,r,s,i){const n=t.classDefinition.findMethod("subsasgn",t=>!t.isStatic);if(!n)return;this.context.canAccessClassMember(n.classDefinition,n.access)||this.context.throwEvalError(`method 'subsasgn' has ${n.access} access for class ${t.classDefinition.name}.`);const a=this.createDotSubscriptDescriptor(e,s,i);return this.classSubsasgnResult(t,n,this.classMethodArgumentValues([a,r],"subsasgn"),s)}callClassEnd(t,e,r,s){const i=t.classDefinition.findMethod("end",t=>!t.isStatic);if(i)return this.context.canAccessClassMember(i.classDefinition,i.access)||this.context.throwEvalError(`method 'end' has ${i.access} access for class ${t.classDefinition.name}.`),this.reducedClassMethodResult(t,i,this.classMethodArgumentValues([Complex.create(e),Complex.create(r)],"end"),s)}callClassSubsindex(t,e){const r=t.classDefinition.findMethod("subsindex",t=>!t.isStatic);return r||this.context.throwEvalError(`object of class ${t.classDefinition.name} cannot be used as an index without a subsindex method.`),this.context.canAccessClassMember(r.classDefinition,r.access)||this.context.throwEvalError(`method 'subsindex' has ${r.access} access for class ${t.classDefinition.name}.`),this.reducedClassMethodResultWithOutputCount(t,r,[],e,1)}zeroBasedSubsindexValue(t,e,r){const s=(t,e)=>{const r=this.expressionValue(t,e);Complex.isInstanceOf(r)&&Complex.imagIsZero(r)||this.context.throwEvalError("subsindex must return zero-based real integer indices.");const s=Complex.realToNumber(r);return(!Number.isInteger(s)||s<0)&&this.context.throwEvalError("subsindex must return zero-based real integer indices."),Complex.create(s+1)},i=this.expressionValue(t,r);if(MultiArray.isInstanceOf(i)){const t=new MultiArray(i.dimension,void 0,!1);for(let e=0;e<MultiArray.linearLength(i);e++){const[n,a]=MultiArray.linearIndexToMultiArrayRowColumn(i.dimension[0],i.dimension[1],e);t.array[n][a]=s(this.expressionValue(i.array[n][a],`${r}${e+1}`),`${r}${e+1}`)}return MultiArray.setType(t),t.parent=e,t}return s(i,r)}convertIndexArgument(t,e){if(ClassInstance.isInstanceOf(t))return this.zeroBasedSubsindexValue(this.callClassSubsindex(t,e),e,"subsindex");if(MultiArray.isInstanceOf(t)&&this.hasClassInstanceElement(t)){const r=new MultiArray(t.dimension,void 0,!1);for(let s=0;s<MultiArray.linearLength(t);s++){const[i,n]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],s),a=t.array[i][n];ClassInstance.isInstanceOf(a)||this.context.throwEvalError("object index arrays must contain class instance elements.");const o=this.zeroBasedSubsindexValue(this.callClassSubsindex(a,e),e,`subsindex${s+1}`);Complex.isInstanceOf(o)||this.context.throwEvalError("subsindex for object index arrays must return scalar indices."),r.array[i][n]=o}return MultiArray.setType(r),r.parent=e,r}return t}solveUndefined(t,e=this.context.currentScope,r=[]){if(this.context.allowForwardReference){const s=r.indexOf(t);s>=0&&this.context.throwCircularReferenceError([...r.slice(s),t]);const i=e.undefinedReferenceTable[t];if(void 0!==i){const s=[...i].filter(t=>t),n=new Set,a=[];s.forEach(t=>{if(void 0!==e.nameTable[t])try{e.nameTable[t].node=this.evaluatedExecutionResult(e.nameTable[t].node,e),delete e.nameTable[t].undefinedReference,a.push(t)}catch(r){r instanceof UndefinedReferenceError?(n.add(r.identifier),e.nameTable[t].undefinedReference=r.identifier):n.add(t)}}),e.undefinedReferenceTable[t]=n,a.forEach(s=>this.solveUndefined(s,e,[...r,t]))}}}isLocalUndefinedReference(t){if(!(t instanceof UndefinedReferenceError))return!1;const e=this.context.callStack.filter(t=>void 0!==t.func),r=e[e.length-1];return t.stackFrames?.[0]===r}registerFunctionDefinition(t,e,r){this.validateFunctionSignature(t),this.validateDeclarationPlacement(t),r?t.attributes={...t.attributes??{},nested:!0}:t.attributes?.nested&&(t.attributes={...t.attributes},delete t.attributes.nested),this.validateFunctionArgumentsBlocks(t),e.defineFunction(t.id,t),t.definingScope=r?e:e.capture(t=>MathOperation.copy(t),this.context.allowForwardReference)}isNodeInsideExecutableBlock(t){const e=t.parent,r=e?.parent;return AST.isNodeBase(r)&&("IF"===r.type||"SWITCH"===r.type||"CASE"===r.type||"WHILE"===r.type||"DO_UNTIL"===r.type||"FOR"===r.type||"SPMD"===r.type||"TRY"===r.type||"UNWIND_PROTECT"===r.type)}validateDeclarationPlacement(t){const e=(t,r)=>{if(t)if(AST.isNodeList(t))t.list.forEach(t=>e(t,r));else{if(AST.isNodeFunctionDefinition(t))return this.isNodeInsideExecutableBlock(t)&&this.context.throwSyntaxError(`function definition '${t.id}' is not allowed inside a control block.`),e(t.arguments,!0),void e(t.statements,!0);if(AST.isNodeClassDef(t))return this.isNodeInsideExecutableBlock(t)&&this.context.throwSyntaxError(`class definition '${t.id}' is not allowed inside a control block.`),r&&this.context.throwSyntaxError(`class definition '${t.id}' is not allowed inside a function.`),void t.sections.forEach(t=>e(t,r));switch(AST.isNodeImport(t)&&t.imports.length>0&&this.isNodeInsideExecutableBlock(t)&&this.context.throwSyntaxError("import declaration is not allowed inside a control block."),"PERSIST"!==t.type||r||this.context.throwSyntaxError("persistent declaration is only valid inside a function."),t.type){case"IF":t.then.forEach(t=>e(t,r)),e(t.else,r);break;case"SWITCH":t.cases.forEach(t=>e(t,r)),e(t.otherwise,r);break;case"CASE":e(t.then,r);break;case"WHILE":case"DO_UNTIL":case"FOR":case"SPMD":e(t.body,r);break;case"TRY":e(t.body,r),e(t.catchBody,r);break;case"UNWIND_PROTECT":e(t.body,r),e(t.cleanup,r);break;case"CLASS_SECTION":e(t.members,r)}}};e(t,!1)}preregisterScriptLocalFunctions(t,e){if(null!==t.parent)return;if("FCNDEF"===this.context.currentFrame?.func?.type)return;const r=this.scriptSourceNameStack[this.scriptSourceNameStack.length-1];for(const s of t.list)AST.isNodeFunctionDefinition(s)&&e.functionTable[s.id]!==s&&(s.sourceName=r,this.registerFunctionDefinition(s,e,!1))}getArgumentValidationName(t){return FunctionArguments.validationName(t,t=>this.context.throwSyntaxError(t))}getNameValueArgumentTarget(t){return FunctionArguments.nameValueTarget(t,t=>this.context.throwSyntaxError(t))}getArgumentValidationDisplayName(t){return FunctionArguments.validationDisplayName(t,t=>this.context.throwSyntaxError(t))}validateFunctionArgumentsBlocks(t){FunctionArguments.validateBlocks(t,t=>this.context.throwSyntaxError(t))}validateFunctionSignatureList(t,e,r,s,i){const n=new Set;t.forEach((a,o)=>{if(e(a)||this.context.throwSyntaxError(`invalid ${s} list in ${i}.`),AST.isNodeIgnoredTarget(a))return;let l;AST.isNodeDefaultedParameter(a)?("parameter"===s&&"anonymous function"!==i||this.context.throwSyntaxError(`invalid ${s} list in ${i}.`),l=a.left.id):AST.isNodeIdentifier(a)?l=a.id:this.context.throwSyntaxError(`invalid ${s} list in ${i}.`),n.has(l)&&this.context.throwSyntaxError(`duplicate ${s} name '${l}' in ${i}.`),n.add(l),l===r&&o!==t.length-1&&this.context.throwSyntaxError(`${r} must be the last ${s} in ${i}.`),"="===a.type&&l===r&&this.context.throwSyntaxError(`${r} default value is not supported in ${i}.`)})}validateFunctionSignature(t){const e=`function ${t.id}`;this.validateFunctionSignatureList(t.parameter.list,AST.isNodeFunctionParameter,"varargin","parameter",e),this.validateFunctionSignatureList(t.return.list,AST.isNodeFunctionReturn,"varargout","return",e),this.validateFunctionDeclarations(t,e)}validateAnonymousFunctionSignature(t){this.validateFunctionSignatureList(t.parameter,AST.isNodeFunctionParameter,"varargin","parameter","anonymous function")}declarationName(t,e){const r=AST.getDeclarationNode(t);return AST.isNodeIdentifier(r)?r.id:AST.isNodeDefaultedParameter(r)?r.left.id:void this.context.throwSyntaxError(`invalid ${e} declaration.`)}signatureNameSet(t){const e=new Set;return t.forEach(t=>{AST.isNodeDefaultedParameter(t)?e.add(t.left.id):AST.isNodeIdentifier(t)&&e.add(t.id)}),e}collectIdentifierReferences(t,e){t&&"object"==typeof t&&(AST.isNodeIdentifier(t)?e.add(t.id):AST.isNodeFunctionDefinition(t)||AST.isNodeClassDef(t)||t instanceof CharString||t instanceof Complex||t instanceof FunctionHandle||(MultiArray.isInstanceOf(t)?MultiArray.linearize(t).forEach(t=>this.collectIdentifierReferences(t,e)):Structure.isInstanceOf(t)?Object.values(t.field).forEach(t=>this.collectIdentifierReferences(t,e)):Object.entries(t).forEach(([t,r])=>{"parent"!==t&&this.collectIdentifierReferences(r,e)})))}validateFunctionDeclarations(t,e){const r=this.signatureNameSet(t.parameter.list),s=this.signatureNameSet(t.return.list),i=new Set,n=new Set,a=new Set,o=t=>{t.list.forEach(o=>{const l=this.declarationName(o,"PERSIST"===t.type?"persistent":"global"),c="PERSIST"===t.type?"persistent":"global",u="PERSIST"===t.type?n:a;(r.has(l)||s.has(l))&&this.context.throwSyntaxError(`can't make function parameter ${l} ${c}.`),!u.has(l)&&i.has(l)&&this.context.throwSyntaxError(`${c} declaration '${l}' must appear before any use in ${e}.`),u.add(l)})},l=t=>{if(AST.isNodeDeclaration(t))return o(t),void this.collectIdentifierReferences(t,i);switch(t.type){case"IF":return t.expression.forEach(t=>this.collectIdentifierReferences(t,i)),t.then.forEach(c),void(t.else&&c(t.else));case"SWITCH":return this.collectIdentifierReferences(t.expression,i),t.cases.forEach(t=>{this.collectIdentifierReferences(t.expression,i),c(t.then)}),void(t.otherwise&&c(t.otherwise));case"WHILE":return this.collectIdentifierReferences(t.expression,i),void c(t.body);case"DO_UNTIL":return c(t.body),void this.collectIdentifierReferences(t.expression,i);case"FOR":return this.collectIdentifierReferences(t.target,i),this.collectIdentifierReferences(t.expression,i),this.collectIdentifierReferences(t.workers,i),void c(t.body);case"SPMD":return this.collectIdentifierReferences(t.workers,i),void c(t.body);case"TRY":return c(t.body),this.collectIdentifierReferences(t.catchIdentifier,i),void(t.catchBody&&c(t.catchBody));case"UNWIND_PROTECT":return c(t.body),void c(t.cleanup);case"FCNDEF":case"CLASSDEF":return;default:this.collectIdentifierReferences(t,i)}},c=t=>{t.list.forEach(t=>{l(t)})};c(t.statements)}getValueClassName(t){if(MultiArray.isInstanceOf(t)&&!t.isCell){const e=MultiArray.linearize(t);if(e.length>0){const t=this.objectArrayClassName(e);if(t)return t}}return FunctionValidation.className(t)}objectArrayClassName(t){const e=t.map(t=>ClassInstance.isInstanceOf(t)||ClassEnumerationValue.isInstanceOf(t)?t.classDefinition.name:ClassMetaObject.isInstanceOf(t)?t.kind:void 0);if(!e.every(t=>void 0!==t))return;const r=e[0];return e.every(t=>t===r)?r:void 0}getArgumentValidationEntry(t,e,r){const s=this.getNameValueArgumentTarget(t);if(!s){const s=this.getArgumentValidationName(t);return r?e.nameTable[s]:e.resolveName(s)}const i=r?e.nameTable[s.parameter]:e.resolveName(s.parameter);if(i&&void 0!==i.node)try{return{node:Structure.getField(i.node,[s.field])}}catch{return}}validateArgumentValidation(t,e,r,s=!1,i=this.getArgumentValidationDisplayName(t)){FunctionArguments.validateArgumentValidation(t,r,{resolveEntry:(t,r)=>this.getArgumentValidationEntry(t,e,r),evaluate:t=>this.evaluatedExpressionValue(t,e,"argument validation expression"),matchesClass:(t,r)=>this.valueMatchesValidationClass(t,r,e),...this.pathValidationCallbacks,throwEvalError:t=>this.context.throwEvalError(t),throwSyntaxError:t=>this.context.throwSyntaxError(t)},s,i)}classPropertyValidationNode(t){return{type:"ARGVALID",name:t.node.name,size:t.size,class:t.class,functions:t.functions,default:t.defaultValue,omitAnswer:!0,omitOutput:!0}}validateClassPropertyValue(t,e,r,s=!1){const i=this.classPropertyValidationNode(t),n=Scope.create(r);n.defineName(t.name,e),FunctionArguments.validateArgumentValidation(i,new Map,{resolveEntry:()=>({node:e}),evaluate:t=>this.evaluatedExpressionValue(t,n,"property validation expression"),matchesClass:(t,e)=>this.valueMatchesValidationClass(t,e,n,s),...this.pathValidationCallbacks,throwEvalError:t=>this.context.throwEvalError(t),throwSyntaxError:t=>this.context.throwSyntaxError(t)},!1,t.name,"property")}validateClassInstancePropertyDefaults(t,e){for(const r of t.classDefinition.allProperties())!r.isDependent&&ClassInstance.hasProperty(t,r.name)&&this.validateClassPropertyValue(r,ClassInstance.getProperty(t,r.name),e,!0)}validateFunctionArguments(t,e,r,s,i=!1){FunctionArguments.validateFunctionArguments(t,r,{resolveEntry:(t,r)=>this.getArgumentValidationEntry(t,e,r),evaluate:t=>this.evaluatedExpressionValue(t,e,"argument validation expression"),matchesClass:(t,r)=>this.valueMatchesValidationClass(t,r,e),...this.pathValidationCallbacks,throwEvalError:t=>this.context.throwEvalError(t),throwSyntaxError:t=>this.context.throwSyntaxError(t)},s,i)}validateFunctionInputArguments(t,e){this.validateFunctionArguments(t,e,"Input")}validateFunctionRepeatingArguments(t,e,r){FunctionArguments.validateRepeatingArguments(t,r,{evaluate:t=>this.evaluatedExpressionValue(t,e,"repeating argument validation expression"),...this.pathValidationCallbacks,throwEvalError:t=>this.context.throwEvalError(t),throwSyntaxError:t=>this.context.throwSyntaxError(t),validateRepeatingValue:(t,r,s,i,n)=>{const a=Scope.create(e);a.defineName(r,s),this.validateArgumentValidation(t,a,n,!0,i)}})}getFunctionNameValueParameters(t){return FunctionArguments.nameValueParameters(t,t=>this.context.throwSyntaxError(t))}getFunctionNameValueDeclarations(t){return FunctionArguments.nameValueDeclarations(t,t=>this.context.throwSyntaxError(t))}splitFunctionCallNameValueArguments(t,e){return FunctionArguments.splitCallNameValueArguments(t,e,t=>this.context.throwEvalError(t),t=>this.context.throwSyntaxError(t))}bindFunctionNameValueArguments(t,e,r){const s=this.getFunctionNameValueDeclarations(t);for(const[t,i]of s){const s=new Structure({});for(const[r,n]of i)if(n.default){this.context.pushRequestedOutputCount(1);try{Structure.setNewField(s,[r],this.runtimeExpressionValue(this.evaluatedExpressionValue(n.default,e,`name-value default ${t}.${r}`),`name-value default ${t}.${r}`))}finally{this.context.popRequestedOutputCount()}}for(const[t,e]of r)i.has(t)&&Structure.setNewField(s,[t],this.runtimeExpressionValue(e,`name-value argument ${t}`));e.defineName(t,s)}}registerNestedFunctions(t,e){for(const r of t.statements.list){if(!AST.isNodeFunctionDefinition(r))continue;const s={...r,attributes:{...r.attributes??{},nested:!0}};this.validateFunctionSignature(s),this.validateFunctionArgumentsBlocks(s),s.definingScope=e,s.sourceName=t.sourceName,e.defineFunction(s.id,s)}}configureFunctionWorkspace(t,e){(t.attributes?.nested||this.functionContainsNestedDefinitions(t))&&e.allowStaticWorkspaceNames(this.staticWorkspaceTextNames(t))}functionContainsNestedDefinitions(t){return t.statements.list.some(AST.isNodeFunctionDefinition)}staticWorkspaceTextNames(t){const e=new Set,r=t=>{for(const r of t)AST.isNodeIdentifier(r)?e.add(r.id):AST.isNodeDefaultedParameter(r)&&e.add(r.left.id)};return r(t.parameter.list),r(t.return.list),this.collectStaticWorkspaceTextNames(t.statements,e),e}collectStaticWorkspaceTextNames(t,e){if(!AST.isNodeFunctionDefinition(t)){if(AST.isNodeIdentifier(t))e.add(t.id);else if(AST.isNodeDeclaration(t))for(const r of t.list)AST.isNodeIdentifier(r)?e.add(r.id):AST.isNodeDefaultedParameter(r)&&e.add(r.left.id);else AST.isNodeBinaryOperation(t)&&Interpreter.assignmentOperatorNames.has(t.type)&&this.collectStaticAssignmentTargetNames(t.left,e);if(t&&"object"==typeof t)for(const[r,s]of Object.entries(t))if("parent"!==r&&"start"!==r&&"stop"!==r)if(Array.isArray(s))for(const t of s)t&&"object"==typeof t&&this.collectStaticWorkspaceTextNames(t,e);else s&&"object"==typeof s&&this.collectStaticWorkspaceTextNames(s,e)}}collectStaticAssignmentTargetNames(t,e){if(AST.isNodeIdentifier(t))e.add(t.id);else if(!AST.isNodeIgnoredTarget(t))if(AST.isNodeIndexExpr(t))this.collectStaticAssignmentTargetNames(t.expr,e);else if(AST.isNodeIndirectRef(t))this.collectStaticAssignmentTargetNames(t.obj,e);else if(MultiArray.isInstanceOf(t))for(const r of MultiArray.linearize(t))this.collectStaticAssignmentTargetNames(r,e)}applyScopedImports(t,e){const r=AST.isNodeList(t)?t.list:[t];for(const t of r)if(AST.isNodeImport(t))for(const r of t.imports)this.context.defineImport(r.id,e)}validateFunctionOutputArguments(t,e,r,s=[]){const i=FunctionArguments.outputNamesToValidate(t,r,s);i&&this.validateFunctionArguments(t,e,"Output",i,!0);const n=FunctionArguments.outputRepeatingInfo(t,t=>this.context.throwSyntaxError(t));if(!n)return;const a=Math.max(r-n.fixedReturnCount,0);if(0===a)return;const o=e.nameTable[n.name];o&&o.node instanceof MultiArray&&o.node.isCell||this.context.throwEvalError(`Undefined return variable '${n.name}'`);const l=MultiArray.linearize(o.node).slice(0,a).map((t,e)=>(s[n.fixedReturnCount+e]??1)&&void 0!==t?{value:this.expressionValue(t,`${n.name}{${e+1}}`),index:e+1}:void 0).filter(t=>void 0!==t);FunctionArguments.validateRepeatingOutputArguments(t,l,{evaluate:t=>this.evaluatedExpressionValue(t,e,"repeating output validation expression"),...this.pathValidationCallbacks,throwEvalError:t=>this.context.throwEvalError(t),throwSyntaxError:t=>this.context.throwSyntaxError(t),validateRepeatingValue:(t,r,s,i,n)=>{const a=Scope.create(e);a.defineName(r,s),this.validateArgumentValidation(t,a,n,!0,i)}})}getFunctionInputArgumentDefaults(t){return FunctionArguments.inputArgumentDefaults(t,t=>this.context.throwSyntaxError(t))}getFunctionOutputRepeatingName(t){return FunctionArguments.outputRepeatingName(t,t=>this.context.throwSyntaxError(t))}Evaluator(t,e=this.context.currentScope){if(this._debug&&console.log(`Interpreter(\ntree:${JSON.stringify(t,(t,e)=>"parent"!==t?e:null!==e||"root",2)},\n);`),!t)return null;if(FunctionHandle.isInstanceOf(t)){const r=t.id&&!t.closure?this.resolveRuntimeFunction(t.id,e,{loadFunctions:!1}):void 0,s=!t.id||t.closure||r?.functionDefinition?void 0:this.lookupFunctionSourceResolution(t.id,e);if(r?.functionDefinition){const s=FunctionHandle.copy(t);return s.id=t.id.includes(".")?r.resolvedName:this.context.aliasNameFunction(t.id),"FCNDEF"===r.functionDefinition.type&&(s.closure=e.capture(t=>MathOperation.copy(t),this.context.allowForwardReference)),s}if(s){const r=FunctionHandle.copy(t);return r.id=t.id.includes(".")?s.resolvedName:this.context.aliasNameFunction(t.id),r.sourceName=s.sourceName,"import"===s.source&&(r.closure=e.capture(t=>MathOperation.copy(t),this.context.allowForwardReference)),r}if(t.id&&!t.closure&&this.resolveImportedStaticMethod(t.id,e)){const r=FunctionHandle.copy(t);return r.closure=e.capture(t=>MathOperation.copy(t),this.context.allowForwardReference),r}if(!t.id&&!t.closure){this.validateAnonymousFunctionSignature(t);const r=FunctionHandle.copy(t);return r.closure=e.snapshot(t=>MathOperation.copy(t)),r.sourceName=this.currentHandleSourceName(),r.className=this.currentHandleClassName(),r}return t}if(Complex.isInstanceOf(t)||CharString.isInstanceOf(t)||Structure.isInstanceOf(t)||ClassDefinition.isInstanceOf(t)||ClassInstance.isInstanceOf(t)||ClassBoundMethod.isInstanceOf(t)||ClassStaticMethod.isInstanceOf(t)||ClassEmptyMethod.isInstanceOf(t)||ClassEnumerationValue.isInstanceOf(t)||ClassEventListener.isInstanceOf(t)||ClassEventData.isInstanceOf(t)||ClassPropertyEvent.isInstanceOf(t)||ClassMetaObject.isInstanceOf(t))return t;if(MultiArray.isInstanceOf(t))return MultiArray.evaluate(t,this,e);switch(t.type){case"VOID":return t;case"+":case"-":case".*":case"*":case"./":case"/":case".\\":case"\\":case".^":case"^":case".**":case"**":case"<":case"<=":case"==":case">=":case">":case"!=":case"~=":case"&":case"|":return this.evaluateBinaryOperation(this.requireBinaryOperation(t),e);case"&&":case"||":return this.evaluateShortCircuitOperation(this.requireBinaryOperation(t),e);case"()":return this.evaluatedExpressionValue(this.requirePrefixOperation(t).right,e,"parenthesized expression");case"!":case"~":case"+_":case"-_":return this.evaluateUnaryOperation(this.requirePrefixOperation(t),e);case"++_":case"--_":return this.opTable[t.type](this.requirePrefixOperation(t).right,e);case".'":case"'":return this.evaluateUnaryOperation(this.requirePostfixOperation(t),e);case"_++":case"_--":return this.opTable[t.type](this.requirePostfixOperation(t).left,e);case"=":case"+=":case"-=":case"*=":case"/=":case"\\=":case"^=":case"**=":case".*=":case"./=":case".\\=":case".^=":case".**=":case"&=":case"|=":{const r=this.requireBinaryOperation(t),s=this.validateAssignment(r.left,!0,e),i=r.type,n=i.substring(0,i.length-1);let a,o,l;s.length>1&&n.length>0&&this.context.throwEvalError("computed multiple assignment not allowed."),this.context.pushForwardReferenceTargets(s.map(({id:t})=>t).filter(t=>"~"!==t)),this.context.pushRequestedOutputCount(s.length),this.context.pushRequestedOutputMask(s.map(({id:t})=>"~"!==t));try{a=AST.isNodeReturnList(r.right)?r.right:MathOperation.copy(this.Evaluator(r.right,e))}catch(t){if(!this.context.allowForwardReference)throw t;if(!this.isLocalUndefinedReference(t))throw t;l=t,a=MathOperation.copy(r.right),o=t.identifier}finally{this.context.popRequestedOutputMask(),this.context.popRequestedOutputCount(),this.context.popForwardReferenceTargets()}const c=AST.ensureReturnList(a),u=AST.nodeListFirst(),h=c.handler(s.length),d=t=>{const e=c.selector(h,t);return void 0===e&&AST.throwErrorIfGreaterThanReturnList(t,t+1,t=>this.context.throwEvalError(t)),e};for(let i=0;i<s.length;i++){const{id:a,index:c,delimiter:h,field:m,descriptors:p}=s[i];if("~"!==a){if(p&&p.length>0&&!n){const r=e.resolveName(a),s=this.evaluatedExpressionValue(d(i),e,"assignment value");if(r&&ClassInstance.isInstanceOf(r.node)&&!this.context.canAccessClassMember(r.node.classDefinition,"private")){const e=this.callClassSubsasgnDescriptors(r.node,p,s,t);if(e){r.node=e,AST.appendNodeList(u,AST.nodeOperation("=",AST.nodeIdentifier(a),RuntimeValue.copy(r.node)));continue}}if(r&&(ClassInstance.isInstanceOf(r.node)||MultiArray.isInstanceOf(r.node)&&this.hasClassInstanceElement(r.node))){const e=this.assignClassSubsasgnDescriptors(r.node,p.map(t=>this.readNativeSubscriptDescriptor(t,"subsasgn")),s,t);if(void 0!==e){r.node=e,AST.appendNodeList(u,AST.nodeOperation("=",AST.nodeIdentifier(a),RuntimeValue.copy(r.node)));continue}}if(!r&&this.shouldUseNativeChainedSubsasgn(p)){const t=this.readNativeSubscriptDescriptor(p[0]),r=this.blankNativeSubsasgnValue(t),i=this.assignNativeSubsasgnDescriptors(r,p,s),n=e.defineName(a,i);AST.appendNodeList(u,AST.nodeOperation("=",AST.nodeIdentifier(a),n.node));continue}if(r&&this.shouldUseNativeChainedSubsasgn(p)&&(MultiArray.isInstanceOf(r.node)||Structure.isInstanceOf(r.node)||Structure.isStructure(r.node))&&(!MultiArray.isInstanceOf(r.node)||!this.hasClassInstanceElement(r.node))){r.node=this.assignNativeSubsasgnDescriptors(r.node,p,s),AST.appendNodeList(u,AST.nodeOperation("=",AST.nodeIdentifier(a),RuntimeValue.copy(r.node)));continue}}if(p&&p.length>0&&n){const t=e.resolveName(a);if(t||this.context.throwEvalError(`in computed assignment ${a} OP= X, ${a} must be defined first.`),this.shouldUseNativeChainedSubsasgn(p)&&(MultiArray.isInstanceOf(t.node)||Structure.isInstanceOf(t.node)||Structure.isStructure(t.node))&&(!MultiArray.isInstanceOf(t.node)||!this.hasClassInstanceElement(t.node))){const r=this.nativeSubsrefDescriptors(t.node,p),s=this.evaluatedExpressionValue(AST.nodeOperation(n,this.compoundAssignmentOperand(r,"compound assignment target value"),this.evaluatedExpressionValue(d(i),e,"assignment value")),e,"compound assignment value");t.node=this.assignNativeSubsasgnDescriptors(t.node,p,s),AST.appendNodeList(u,AST.nodeOperation("=",AST.nodeIdentifier(a),RuntimeValue.copy(t.node)));continue}}if(c)if(n){const t=e.resolveName(a);if(void 0!==t){if(!FunctionHandle.isInstanceOf(t.node)){const s=this.evaluatedIndexArguments(c,e);if(m.length>0&&AST.isNodeIndexExpr(r.left)&&AST.isNodeIndirectRef(r.left.expr)&&(Structure.isInstanceOf(t.node)||MultiArray.isInstanceOf(t.node)&&Structure.isStructure(t.node))){const r=Structure.getField(t.node,m);if(MultiArray.isInstanceOf(r)&&!MultiArray.isEmpty(r)){const o=this.evaluatedExpressionValue(AST.nodeOperation(n,MultiArray.getElements(r,"__field_assignment__",[],s,this),MultiArray.scalarToMultiArray(this.evaluatedExpressionValue(d(i),e,"assignment value"))),e,"compound field assignment value"),l=Scope.create();l.defineName("__field_assignment__",r),MultiArray.setElements(l,"__field_assignment__",[],s,this.indexedAssignmentRhs(h,o,r),void 0,this),Structure.setNewField(t.node,m,this.runtimeExpressionValue(this.scopedExpressionValue(l,"__field_assignment__","field assignment result"),"field assignment result")),AST.appendNodeList(u,AST.nodeOperation("=",AST.nodeIdentifier(a),RuntimeValue.copy(t.node)));continue}}MultiArray.setElements(e,a,m,s,MultiArray.scalarToMultiArray(this.evaluatedExpressionValue(AST.nodeOperation(n,MultiArray.getElements(t.node,a,m,s),MultiArray.scalarToMultiArray(this.evaluatedExpressionValue(d(i),e,"assignment value"))),e,"compound assignment value"))),AST.appendNodeList(u,AST.nodeOperation("=",AST.nodeIdentifier(a),RuntimeValue.copy(t.node)));continue}this.context.throwEvalError("can't perform indexed assignment for function handle type.")}else this.context.throwEvalError(`in computed assignment ${a}(index) OP= X, ${a} must be defined first.`)}else{const s=this.evaluatedExpressionValue(d(i),e,"assignment value"),n=e.resolveName(a);if(n&&ClassInstance.isInstanceOf(n.node)&&0===m.length){const r=this.callClassSubsasgn(n.node,c,h??"()",s,t,e);if(r){n.node=r,AST.appendNodeList(u,AST.nodeOperation("=",AST.nodeIdentifier(a),RuntimeValue.copy(n.node)));continue}}if(n&&MultiArray.isInstanceOf(n.node)&&0===m.length&&this.hasClassInstanceElement(n.node)){const r=this.evaluatedIndexArguments(c,e);try{const i=MultiArray.MultiArrayToScalar(this.reducedIndexingResult(MultiArray.getElements(n.node,a,[],r)));if(ClassInstance.isInstanceOf(i)){const n=this.callClassSubsasgn(i,c,h??"()",s,t,e);if(n){MultiArray.setElements(e,a,[],r,MultiArray.scalarToMultiArray(n)),AST.appendNodeList(u,AST.nodeOperation("=",AST.nodeIdentifier(a),e.resolveName(a).node));continue}}}catch(t){if(!(t instanceof RangeError))throw t}}if(n&&MultiArray.isInstanceOf(n.node)&&m.length>0&&this.hasClassInstanceElement(n.node)){n.node=this.assignClassArrayIndexedNestedField(a,n.node,c,m,s,r.left,e),AST.appendNodeList(u,AST.nodeOperation("=",AST.nodeIdentifier(a),RuntimeValue.copy(n.node)));continue}if(n&&CharString.isInstanceOf(n.node)&&0===m.length){"{}"===h&&this.context.throwEvalError("matrix cannot be indexed with {");const t=MultiArray.characterVectorFromCharString(n.node),r=Scope.create();r.defineName("__char_assignment__",t),MultiArray.setElements(r,"__char_assignment__",[],this.evaluatedIndexArguments(c,e),this.charStringAssignmentRhs(s,n.node.quote),void 0,this),n.node=MultiArray.charStringFromCharacterVectorResult(this.scopedMultiArrayValue(r,"__char_assignment__","character assignment result"),n.node.quote),AST.appendNodeList(u,AST.nodeOperation("=",AST.nodeIdentifier(a),RuntimeValue.copy(n.node)));continue}if(n&&m.length>0&&AST.isNodeIndexExpr(r.left)&&AST.isNodeIndirectRef(r.left.expr)&&(Structure.isInstanceOf(n.node)||MultiArray.isInstanceOf(n.node)&&Structure.isStructure(n.node))){const t=Structure.getField(n.node,m);if(MultiArray.isInstanceOf(t)&&!MultiArray.isEmpty(t)){const r=Scope.create();r.defineName("__field_assignment__",t),MultiArray.setElements(r,"__field_assignment__",[],this.evaluatedIndexArguments(c,e),this.indexedAssignmentRhs(h,s,t)),Structure.setNewField(n.node,m,this.runtimeExpressionValue(this.scopedExpressionValue(r,"__field_assignment__","field assignment result"),"field assignment result")),AST.appendNodeList(u,AST.nodeOperation("=",AST.nodeIdentifier(a),RuntimeValue.copy(n.node)));continue}}MultiArray.setElements(e,a,m,this.evaluatedIndexArguments(c,e),this.indexedAssignmentRhs(h,s,0===m.length?n?.node:void 0,m.length>0)),AST.appendNodeList(u,AST.nodeOperation("=",AST.nodeIdentifier(a),RuntimeValue.copy(e.resolveName(a).node)))}else{const s=d(i);s.parent=r.right;let c=s;try{if(m.length>0){let r=e.resolveName(a);n.length&&void 0===r&&this.context.throwEvalError(`in computed assignment ${a}.${m.join(".")} OP= X, ${a}.${m.join(".")} must be defined first.`),void 0===r?r=e.defineName(a,new Structure({})):MultiArray.isInstanceOf(r.node)&&!r.node.isCell&&MultiArray.isEmpty(r.node)&&(r.node=new Structure({}));const i=()=>Structure.isInstanceOf(r.node)||MultiArray.isInstanceOf(r.node)&&Structure.isStructure(r.node)?this.expressionValue(Structure.getField(r.node,m),`field ${m.join(".")}`):ClassInstance.isInstanceOf(r.node)||MultiArray.isInstanceOf(r.node)&&this.hasClassInstanceElement(r.node)?this.expressionValue(this.resolveClassFieldChain(r.node,m,t),`field ${m.join(".")}`):void this.context.throwEvalError("in indexed assignment."),o=n.length?void 0!==l?AST.nodeOperation(n,i(),s):this.Evaluator(AST.nodeOperation(n,i(),s)):s;if(c=o,Structure.isInstanceOf(r.node))this.assignStructureFieldValue(r.node,m,this.structureAssignmentValue(o,`field ${m.join(".")}`),!1);else if(MultiArray.isInstanceOf(r.node)&&Structure.isStructure(r.node))this.assignStructureFieldValue(r.node,m,this.structureAssignmentValue(o,`field ${m.join(".")}`),n.length>0);else if(ClassInstance.isInstanceOf(r.node)){const s=this.reducedAssignmentValue(o);r.node=this.assignNestedClassInstanceField(r.node,m,s,t,e)}else MultiArray.isInstanceOf(r.node)&&this.hasClassInstanceElement(r.node)?r.node=this.assignNestedClassArrayField(r.node,m,this.reducedAssignmentValue(o),t,e):ClassEventListener.isInstanceOf(r.node)?(1!==m.length&&this.context.throwEvalError(`cannot assign nested property '${m.join(".")}' for ${r.node.kind}.`),this.setClassEventListenerField(r.node,m[0],this.reducedAssignmentValue(o))):ClassEventData.isInstanceOf(r.node)||ClassPropertyEvent.isInstanceOf(r.node)?(1!==m.length&&this.context.throwEvalError(`cannot assign nested property '${m.join(".")}' for ${ClassPropertyEvent.isInstanceOf(r.node)?"event.PropertyEvent":"event.EventData"}.`),this.setClassEventDataField(r.node,m[0])):this.context.throwEvalError("in indexed assignment.");AST.appendNodeList(u,AST.nodeOperation("=",AST.nodeIdentifier(a),RuntimeValue.copy(r.node)))}else{const t=n.length?void 0!==l?AST.nodeOperation(n,AST.nodeIdentifier(a),s):this.Evaluator(AST.nodeOperation(n,AST.nodeIdentifier(a),s)):s;let r;if(c=t,o)if(this.context.allowForwardReference)e.defineUndefinedReference(o,a),r=e.assignName(a,this.reducedAssignmentValue(t),o);else{if(l)throw l;this.context.throwUndefinedReferenceError(o)}else r=e.assignName(a,this.reducedAssignmentValue(t));if(this.solveUndefined(a,e),AST.appendNodeList(u,AST.nodeOperation("=",AST.nodeIdentifier(a),RuntimeValue.copy(r.node))),l)throw l}}catch(t){throw this.context.allowForwardReference&&this.isLocalUndefinedReference(t)&&e.assignName(a,c,o),t}}}}return t.parent&&t.parent.parent?this.nestedAssignmentValue(u):1===u.list.length?u.list[0]:u}case"IDENT":return this.context.resolveIdentifier(t,e);case"RETURN":throw new ReturnSignal;case"BREAK":throw new BreakSignal;case"CONTINUE":throw new ContinueSignal;case"FCNDEF":{const r=AST.isNodeFunctionDefinition(t)?t:this.context.throwEvalError(`invalid function definition AST node '${t.type}'.`);return this.isNodeInsideExecutableBlock(r)&&this.context.throwSyntaxError(`function definition '${r.id}' is not allowed inside a control block.`),"FCNDEF"===this.context.currentFrame?.func?.type&&e.hasLocalFunction(r.id)||e.functionTable[r.id]===r||this.registerFunctionDefinition(r,e,"FCNDEF"===this.context.currentFrame?.func?.type),AST.nodeVoid()}case"CLASSDEF":{const r=AST.isNodeClassDef(t)?t:this.context.throwEvalError(`invalid class definition AST node '${t.type}'.`);this.isNodeInsideExecutableBlock(r)&&this.context.throwSyntaxError(`class definition '${r.id}' is not allowed inside a control block.`);const s=ClassDefinition.create(r);s.resolveSuperclasses(t=>this.context.resolveClassDefinition(t,e),t=>this.context.throwEvalError(t)),this.context.defineClassDefinition(s,e)}return AST.nodeVoid();case"GLOBAL":for(const r of t.list){const t=AST.getDeclarationNode(r);if(AST.isNodeIdentifier(t))this.context.declareGlobal(t.id,void 0,e);else if(AST.isNodeDefaultedParameter(t)){const r=this.runtimeExpressionValue(this.evaluatedExpressionValue(t.right,e,`global ${t.left.id} default`),`global ${t.left.id} default`);this.context.declareGlobal(t.left.id,r,e)}else this.context.throwSyntaxError("invalid global declaration.")}return AST.nodeVoid();case"PERSIST":for(const r of t.list){const t=AST.getDeclarationNode(r);if(AST.isNodeIdentifier(t))this.context.declarePersistent(t.id,void 0,e);else if(AST.isNodeDefaultedParameter(t)){const r=this.runtimeExpressionValue(this.evaluatedExpressionValue(t.right,e,`persistent ${t.left.id} default`),`persistent ${t.left.id} default`);this.context.declarePersistent(t.left.id,r,e)}else this.context.throwSyntaxError("invalid persistent declaration.")}return AST.nodeVoid();case"IMPORT":if(0===t.imports.length){const t=MultiArray.toColumnVector(e.importList().map(t=>CharString.create(t)));return t.isCell=!0,t}for(const r of t.imports)this.context.defineImport(r.id,e);return AST.nodeVoid();case".":{const r=this.resolveQualifiedNameAccess(t,e);if(void 0!==r)return r;if(!this.hasQualifiedNameAccessOperand(t,e)){const r=this.collectClassSubsrefChain(t,e);if(r&&r.descriptors.length>0&&!this.context.canAccessClassMember(r.instance.classDefinition,"private")){const e=this.callClassSubsrefDescriptors(r.instance,r.descriptors,t);if(void 0!==e)return e}}const s=t.field.map(t=>"string"==typeof t?t:this.evaluatedDynamicFieldName(t,e,"Dynamic structure field names must be strings.")),i=this.evaluatedCommaSeparatedReceiver(t.obj,e);if(i)return this.chainedCommaListResult(i.map(r=>this.resolveDotFieldChain(r,s,t,e)));const n=this.evaluatedExpressionValue(t.obj,e,"dot receiver");return this.resolveDotFieldChain(n,s,t,e)}case"SUPERCLASS_CTOR":{const r=t,s="IDENT"===r.instance.type?e.resolveName(r.instance.id)?.node:void 0;if("IDENT"===r.instance.type&&!ClassInstance.isInstanceOf(s)){0===r.args.length&&this.context.throwEvalError(`superclass method '${r.instance.id}' requires an object argument.`);const t=this.evaluatedExpressionValue(r.args[0],e,"superclass method receiver");ClassInstance.isInstanceOf(t)||this.context.throwEvalError(`superclass method '${r.instance.id}' requires a class instance.`);const s=t.classDefinition.findSuperclass(r.superclass.id);s||this.context.throwEvalError(`class ${r.superclass.id} is not a superclass of class ${t.classDefinition.name}.`),this.context.canAccessClassMember(s,"protected")||this.context.throwEvalError(`superclass method '${r.instance.id}' is only accessible from class methods.`);const i=s.findMethod(r.instance.id,t=>!t.isStatic);return i||this.context.throwEvalError(`unknown superclass method '${r.instance.id}' for class ${s.name}.`),this.context.canAccessClassMember(i.classDefinition,i.access)||this.context.throwEvalError(`method '${r.instance.id}' has ${i.access} access for class ${t.classDefinition.name}.`),this.context.callClassInstanceMethod(t,i,r.args.slice(1),r)}const i=ClassInstance.isInstanceOf(s)?s:this.evaluatedExpressionValue(r.instance,e,"superclass constructor receiver");ClassInstance.isInstanceOf(i)||this.context.throwEvalError("superclass constructor target must be a class instance.");const n=i.classDefinition.findSuperclass(r.superclass.id);return n||this.context.throwEvalError(`class ${r.superclass.id} is not a superclass of class ${i.classDefinition.name}.`),this.context.canAccessClassMember(n,"protected")||this.context.throwEvalError(`superclass constructor '${r.superclass.id}' is only accessible from class methods.`),this.context.constructSuperclassInstance(i,n,r.args,r)}case"METACLASS":return this.resolveMetaclassLiteral(t.className.id,e);case"LIST":{this.preregisterScriptLocalFunctions(t,e);const r={type:"LIST",list:new Array(t.list.length),parent:null===t.parent?null:t};let s=0,i=!1;for(let n=0;n<t.list.length;n++){let a;AST.isNodeIdentifier(t.list[n])&&!e.resolveName(t.list[n].id)&&this.commandWordListNameSet.has(t.list[n].id)&&(t.list[n]=AST.nodeEmptyCmdWList(t.list[n])),t.list[n].index=n;try{a=this.evaluatedExecutionResult(t.list[n],e)}catch(e){if(e instanceof ReturnSignal&&null===t.parent&&!this.context.isInsideUserFunction()&&0===this.scriptExecutionDepth){i=!0;break}throw e}if("LIST"===a.type)for(let i=0;i<a.list.length;i++){const n=a.list[i];"VOID"!==n.type&&(a.list[i].parent=r,a.list[i].index=s,r.list[s]=n,null!==t.parent||n.omitAnswer||e.defineName("ans",n),s++)}else if("VOID"===a.type){const e=t.list[n];e.omitAnswer=!0,e.omitOutput=!0,e.parent=r,e.index=s,r.list[s]=e,s++}else a.parent=r,a.index=s,r.list[s]=a,null!==t.parent||a.omitAnswer||e.defineName("ans",a),s++}if(r.list.length=s,i&&0===s)return AST.nodeVoid();const n=r.list.filter(t=>!t.omitOutput);return n.length>0&&n.length<r.list.length&&(r.list=n,r.list.forEach((t,e)=>{t.parent=r,t.index=e})),r}case"RANGE":{const r=this.evaluatedExpressionValue(t.start_,e,"range start"),s=this.evaluatedExpressionValue(t.stop_,e,"range stop"),i=t.stride_?this.evaluatedExpressionValue(t.stride_,e,"range stride"):null;return this.evaluateColonWithClassDispatch(i?[r,i,s]:[r,s],t)||MultiArray.expandRange(r,s,i)}case"ENDRANGE":{let r=t.parent,s=t.index;for(;AST.isNodeBase(r)&&"IDX"!==r.type;)s=r.index,r=r.parent;if(AST.isNodeIndexExpr(r)){const t=this.evaluatedExpressionValue(r.expr,e,"indexed expression");if(ClassInstance.isInstanceOf(t)){const e=this.callClassEnd(t,s+1,r.args.length,r);return void 0!==e?e:Complex.one()}return MultiArray.isInstanceOf(t)?1===r.args.length?Complex.create(MultiArray.linearLength(t)):Complex.create(MultiArray.getDimension(t,s)):CharString.isInstanceOf(t)?Complex.create(t.length):Complex.one()}this.context.throwSyntaxError("indeterminate end of range. The word 'end' to refer a value is valid only in indexing.")}case":":if(AST.isNodeIndexExpr(t.parent)){const r=this.evaluatedExpressionValue(t.parent.expr,e,"indexed expression");return MultiArray.isInstanceOf(r)?1===t.parent.args.length?MultiArray.expandColon(MultiArray.linearLength(r)):MultiArray.expandColon(MultiArray.getDimension(r,t.index)):CharString.isInstanceOf(r)?MultiArray.expandColon(r.length):Complex.one()}this.context.throwSyntaxError("indeterminate colon. The colon to refer a range is valid only in indexing.");case"IDX":{t.expr||this.context.throwReferenceError(`'${t.id}' undefined.`);const r=this.inheritedHandleMethodCall(t,e);if(void 0!==r)return r;if(!this.hasQualifiedNameAccessOperand(t,e)&&AST.isNodeIndirectRef(t.expr)){const r=this.dottedCommaReceiver(t.expr,e);if(r){const s=r.fields.map(t=>"string"==typeof t?t:this.evaluatedDynamicFieldName(t,e,"Dynamic structure field names must be strings."));return this.chainedCommaListResult(r.values.map(r=>{const i=this.resolveDotFieldChain(r,s,t.expr,e);return this.chainedCommaItemApply(i,t.args,t)}))}}if(!this.hasQualifiedNameAccessOperand(t,e)){const r=this.collectClassSubsrefChain(t,e);if(r&&r.descriptors.length>0){const e=this.callClassSubsrefDescriptors(r.instance,r.descriptors,t);if(void 0!==e)return e}}const s=this.evaluatedCommaSeparatedReceiver(t.expr,e);if(s)return this.chainedCommaListResult(s.map(e=>this.chainedCommaItemApply(e,t.args,t)));const i=this.evaluatedExpressionValue(t.expr,e,"indexed expression");if(ClassInstance.isInstanceOf(i)){const r=this.callClassSubsref(i,t,e);if(void 0!==r)return r}return this.context.apply(i,t.args,t)}case"CMDWLIST":{const e=this.commandWordListTable[t.id];e||this.context.throwUndefinedReferenceError(t.id);const r=this.commandWordListResult(e.func(...t.args.map(t=>t.str)));return void 0!==r?r:t}case"IF":for(let r=0;r<t.expression.length;r++)if(this.evaluatedCondition(t.expression[r],e,"if condition"))return this.evaluatedExecutionResult(t.then[r],e);return t.else?this.evaluatedExecutionResult(t.else,e):{type:"LIST",list:[],parent:t};case"SWITCH":{const r=this.evaluatedExpressionValue(t.expression,e,"switch expression");for(const s of t.cases){const t=this.evaluatedExpressionValue(s.expression,e,"switch case");if(this.switchCaseMatches(r,t))return this.evaluatedExecutionResult(s.then,e)}return t.otherwise?this.evaluatedExecutionResult(t.otherwise,e):{type:"LIST",list:[],parent:t}}case"WHILE":{let r={type:"LIST",list:[],parent:t};for(;;){if(!this.evaluatedCondition(t.expression,e,"while condition"))return r;try{r=this.evaluatedExecutionResult(t.body,e)}catch(t){if(t instanceof ContinueSignal)continue;if(t instanceof BreakSignal)return r;throw t}}}case"DO_UNTIL":{let r={type:"LIST",list:[],parent:t};for(;;){try{r=this.evaluatedExecutionResult(t.body,e)}catch(t){if(t instanceof BreakSignal)return r;if(!(t instanceof ContinueSignal))throw t}if(this.evaluatedCondition(t.expression,e,"until condition"))return r}}case"FOR":{let r={type:"LIST",list:[],parent:t};t.workers&&this.workerCountControlArgument(this.evaluatedExpressionValue(t.workers,e,"parfor workers"),"parfor workers");const s=this.evaluatedExpressionValue(t.expression,e,"for expression");t.parallel&&(this.validateParforHeader(t.target,s),this.validateParforBody(t.body,t.target.id));const i=this.forLoopValues(s,t.target);for(const s of i){const i=AST.nodeOperation("=",this.cloneAssignmentTarget(t.target),this.forLoopAssignmentValue(t.target,s));this.Evaluator(i,e);try{r=this.evaluatedExecutionResult(t.body,e)}catch(t){if(t instanceof ContinueSignal)continue;if(t instanceof BreakSignal)return r;throw t}}return r}case"SPMD":if(this.validateSpmdBody(t.body),t.workers){const r=t.workers.list.map((t,r)=>this.workerCountControlArgument(this.evaluatedExpressionValue(this.expressionValue(t,`spmd worker ${r+1}`),e,`spmd worker ${r+1}`),`spmd worker ${r+1}`));2===r.length&&r[0]>r[1]&&this.context.throwEvalError("spmd minimum worker count cannot exceed maximum worker count.")}const r=["spmdIndex","spmdSize"],s=new Map;r.forEach(t=>{s.set(t,e.hasLocalName(t)?{...e.nameTable[t]}:void 0)}),e.defineName("spmdIndex",Complex.one()),e.defineName("spmdSize",Complex.one());try{return this.evaluatedExecutionResult(t.body,e)}finally{r.forEach(t=>{const r=s.get(t);r?e.nameTable[t]=r:e.removeName(t)})}case"TRY":try{return this.evaluatedExecutionResult(t.body,e)}catch(r){if(r instanceof ReturnSignal||r instanceof BreakSignal||r instanceof ContinueSignal)throw r;const s=this.rememberLastError(r);return t.catchBody?(t.catchIdentifier&&e.defineName(t.catchIdentifier.id,s),this.evaluatedExecutionResult(t.catchBody,e)):{type:"LIST",list:[],parent:t}}case"UNWIND_PROTECT":{let r,s={type:"LIST",list:[],parent:t},i=!1;try{s=this.evaluatedExecutionResult(t.body,e)}catch(t){r=t,i=!0}if(this.evaluatedExecutionResult(t.cleanup,e),i)throw r;return s}default:this.context.throwEvalError(`evaluating undefined type '${t.type}'.`)}}Evaluate(t){try{return this._exitStatus=Interpreter.response.OK,t.parent=null,this.validateDeclarationPlacement(t),this.Evaluator(t)}catch(t){if(t instanceof ReturnSignal&&!this.context.isInsideUserFunction()&&0===this.scriptExecutionDepth)return AST.nodeVoid();if(this._exitStatus=Interpreter.response.EVAL_ERROR,t instanceof BreakSignal)try{this.context.throwEvalError("break is only valid inside a loop.")}catch(t){throw this.lastError=t,t}if(t instanceof ContinueSignal)try{this.context.throwEvalError("continue is only valid inside a loop.")}catch(t){throw this.lastError=t,t}throw this.lastError=t,t}}Execute(t){try{return this.Evaluate(this.Parse(t))}catch(t){throw this.lastError=t,t}}Unparse(t,e=0){const r=(t,e)=>t+" "+e.list.map(t=>this.Unparse(AST.getDeclarationNode(t))).join(" "),s=t=>t.map(t=>this.Unparse(t)).join(","),i=t=>!!t&&"LIST"===t.type&&0===t.list.length,n=t=>t.length>0?"("+t.map(t=>this.Unparse(t)).join(",")+")":"",a=t=>{const e=0===t.return.list.length?"":1===t.return.list.length?this.Unparse(t.return.list[0]):"["+s(t.return.list)+"]",r="("+s(t.parameter.list)+")";if(t.attributes?.prototype)return(e?e+"=":"")+t.id+r;const i=t.arguments.list.length>0?"\n"+t.arguments.list.map(t=>this.Unparse(t)).join("\n"):"";return"FUNCTION "+(e?e+"=":"")+t.id+r+i+(t.statements.list.length>0?"\n"+this.Unparse(t.statements).trimEnd():"")+"\nENDFUNCTION"},o=(t,e)=>{const r=this.nodePrecedence(e),s=this.Unparse(e.left,r);return(this.nodePrecedence(e.left)<r?"("+s+")":s)+t},l=(t,e)=>{const r=this.nodePrecedence(e),s=this.Unparse(e.right,r);return t+(this.nodePrecedence(e.right)<r?"("+s+")":s)},c=t=>AST.isNodeOperation(t)&&"string"==typeof t.type&&["!","~","+_","-_","++_","--_"].includes(t.type),u=t=>AST.isNodeOperation(t)&&"()"===t.type&&c(this.requirePrefixOperation(t).right),h=t=>{const e=this.nodePrecedence(t);return this.nodePrecedence(t.left)<e||("^"===t.type||".^"===t.type||"**"===t.type||".**"===t.type)&&(c(t.left)||u(t.left))};try{if(!t)return"";if(void 0===t)return"<UNDEFINED>";if(Complex.isInstanceOf(t))return Complex.unparse(t,this,e);if(CharString.isInstanceOf(t))return CharString.unparse(t,e);if(MultiArray.isInstanceOf(t))return MultiArray.unparse(t,this,e);if(Structure.isInstanceOf(t))return Structure.unparse(t,this,e);if(FunctionHandle.isInstanceOf(t))return FunctionHandle.unparse(t,this,e);if(ClassDefinition.isInstanceOf(t))return ClassDefinition.unparse(t,this);if(ClassInstance.isInstanceOf(t))return ClassInstance.unparse(t,this);if(ClassBoundMethod.isInstanceOf(t))return ClassBoundMethod.unparse(t,this);if(ClassStaticMethod.isInstanceOf(t))return ClassStaticMethod.unparse(t,this);if(ClassEmptyMethod.isInstanceOf(t))return ClassEmptyMethod.unparse(t,this);if(ClassEnumerationValue.isInstanceOf(t))return ClassEnumerationValue.unparse(t,this);if(ClassEventListener.isInstanceOf(t))return ClassEventListener.unparse(t,this);if(ClassPropertyEvent.isInstanceOf(t))return ClassPropertyEvent.unparse(t,this);if(ClassEventData.isInstanceOf(t))return ClassEventData.unparse(t,this);if(ClassMetaObject.isInstanceOf(t))return ClassMetaObject.unparse(t,this);switch(t.type){case"+":case"-":case".*":case"*":case"./":case"/":case".\\":case"\\":case".^":case"^":case".**":case"**":case"<":case"<=":case"==":case">=":case">":case"!=":case"~=":case"&":case"|":case"&&":case"||":case"=":case"+=":case"-=":case"*=":case"/=":case"\\=":case"^=":case"**=":case".*=":case"./=":case".\\=":case".^=":case".**=":case"&=":case"|=":{const e=this.requireBinaryOperation(t),r=this.nodePrecedence(t),s=this.Unparse(e.left,r),i=this.Unparse(e.right,r);return(h(e)?"("+s+")":s)+t.type+(this.nodePrecedence(e.right)<r?"("+i+")":i)}case"()":{const r=this.requirePrefixOperation(t),s=this.nodePrecedence(r.right),i=this.Unparse(r.right,s);return s<e?"("+i+")":i}case"!":case"~":return l(t.type,this.requirePrefixOperation(t));case"+_":return l("+",this.requirePrefixOperation(t));case"-_":return l("-",this.requirePrefixOperation(t));case"++_":return l("++",this.requirePrefixOperation(t));case"--_":return l("--",this.requirePrefixOperation(t));case".'":case"'":return o(t.type,this.requirePostfixOperation(t));case"_++":return o("++",this.requirePostfixOperation(t));case"_--":return o("--",this.requirePostfixOperation(t));case"IDENT":case"CLASS_EVENT":return t.id;case".":return this.Unparse(t.obj)+"."+t.field.map(t=>"string"==typeof t?t:"("+this.Unparse(t)+")").join(".");case"LIST":return t.list.map(t=>this.Unparse(t)).join("\n")+"\n";case"RANGE":return t.start_&&t.stop_?t.stride_?this.Unparse(t.start_)+":"+this.Unparse(t.stride_)+":"+this.Unparse(t.stop_):this.Unparse(t.start_)+":"+this.Unparse(t.stop_):":";case"ENDRANGE":return"end";case":":return":";case"<~>":return"~";case"IDX":return this.Unparse(t.expr)+t.delim[0]+t.args.map(t=>this.Unparse(t)).join(",")+t.delim[1];case"SUPERCLASS_CTOR":return this.Unparse(t.instance)+"@"+this.Unparse(t.superclass)+"("+t.args.map(t=>this.Unparse(t).trimEnd()).join(",")+")";case"METACLASS":return"?"+this.Unparse(t.className);case"RETLIST":return"<RETLIST>";case"CMDWLIST":return(t.id+" "+t.args.map(t=>this.Unparse(t)).join(" ")).trimEnd();case"ARGVALID":{const e=t.size.length>0?"("+s(t.size)+")":"",r=t.class&&!i(t.class)?" "+this.Unparse(t.class).trimEnd():"",n=t.functions.length>0?" {"+s(t.functions)+"}":"",a=t.default?"="+this.Unparse(t.default):"";return this.Unparse(t.name)+e+r+n+a}case"ARGS":return"ARGUMENTS"+(t.attributes.length>0?" ("+t.attributes.map(t=>this.Unparse(t)).join(",")+")":"")+(t.validation.length>0?"\n"+t.validation.map(t=>this.Unparse(t)).join("\n"):"")+"\nENDARGUMENTS";case"GLOBAL":return r("global",t);case"PERSIST":return r("persistent",t);case"IMPORT":return"import"+(t.imports.length>0?" "+t.imports.map(t=>this.Unparse(t)).join(" "):"");case"RETURN":return"return";case"BREAK":return"break";case"CONTINUE":return"continue";case"IF":let c="IF "+this.Unparse(t.expression[0])+"\n";c+=this.Unparse(t.then[0])+"\n";for(let e=1;e<t.expression.length;e++)c+="ELSEIF "+this.Unparse(t.expression[e])+"\n",c+=this.Unparse(t.then[e])+"\n";return t.else&&(c+="ELSE\n"+this.Unparse(t.else)+"\n"),c+="ENDIF",c;case"SWITCH":let u="SWITCH "+this.Unparse(t.expression)+"\n";for(const e of t.cases)u+="CASE "+this.Unparse(e.expression)+"\n",u+=this.Unparse(e.then)+"\n";return t.otherwise&&(u+="OTHERWISE\n"+this.Unparse(t.otherwise)+"\n"),u+="ENDSWITCH",u;case"WHILE":return"WHILE "+this.Unparse(t.expression)+"\n"+this.Unparse(t.body)+"\nENDWHILE";case"DO_UNTIL":return"DO\n"+this.Unparse(t.body)+"\nUNTIL "+this.Unparse(t.expression);case"FOR":return(t.parallel?"PARFOR ":"FOR ")+(t.workers?"(":"")+this.Unparse(t.target)+"="+this.Unparse(t.expression)+(t.workers?","+this.Unparse(t.workers)+")":"")+"\n"+this.Unparse(t.body)+(t.parallel?"\nENDPARFOR":"\nENDFOR");case"SPMD":return"SPMD"+(t.workers?" ("+t.workers.list.map(t=>this.Unparse(t)).join(",")+")":"")+"\n"+this.Unparse(t.body)+"\nENDSPMD";case"TRY":return"TRY\n"+this.Unparse(t.body)+(t.catchBody?"\nCATCH"+(t.catchIdentifier?" "+this.Unparse(t.catchIdentifier):"")+"\n"+this.Unparse(t.catchBody):"")+"\nEND_TRY_CATCH";case"UNWIND_PROTECT":return"UNWIND_PROTECT\n"+this.Unparse(t.body)+"\nUNWIND_PROTECT_CLEANUP\n"+this.Unparse(t.cleanup)+"\nEND_UNWIND_PROTECT";case"CLASSDEF":return"CLASSDEF "+n(t.attributes)+(t.attributes.length>0?" ":"")+t.id+(t.superclasses.length>0?" < "+t.superclasses.map(t=>this.Unparse(t)).join("&"):"")+(t.sections.length>0?"\n"+t.sections.map(t=>this.Unparse(t)).join("\n"):"")+"\nENDCLASSDEF";case"CLASS_SECTION":return t.kind+(t.attributes.length>0?" "+n(t.attributes):"")+(t.members.list.length>0?"\n"+this.Unparse(t.members).trimEnd():"")+"\n"+(t=>{switch(t){case"PROPERTIES":return"ENDPROPERTIES";case"METHODS":return"ENDMETHODS";case"EVENTS":return"ENDEVENTS";case"ENUMERATION":return"ENDENUMERATION";default:return"END"}})(t.kind);case"CLASS_PROPERTY":return t.id+(t.size.length>0?"("+s(t.size)+")":"")+(t.class&&!i(t.class)?" "+this.Unparse(t.class).trimEnd():"")+(t.functions.length>0?" {"+s(t.functions)+"}":"")+(t.defaultValue?"="+this.Unparse(t.defaultValue).trimEnd():"");case"CLASS_ENUMERATION":return t.id+(t.args.length>0?"("+t.args.map(t=>this.Unparse(t).trimEnd()).join(",")+")":"");case"CLASS_ATTRIBUTE":return!t.value||"~"!==t.value.type&&"!"!==t.value.type?t.id+(t.value?"="+this.Unparse(t.value).trimEnd():""):t.value.type+t.id;case"FCNDEF":return a(t);case"VOID":return"";default:return"<INVALID>"}}catch{return"<ERROR>"}}UnparserMathML(t,e=0){const r=(t,e)=>`<mrow><mi>${t}</mi><mspace width="0.4em"/>${e.list.map(t=>this.UnparserMathML(AST.getDeclarationNode(t))).join('<mspace width="0.4em"/>')}</mrow>`,s=t=>t.map(t=>this.UnparserMathML(t)).join("<mo>,</mo>"),i=(t,e)=>`<mtr><mtd><mo><b>${t}</b></mo></mtd>${void 0===e?"":`<mtd>${e}</mtd>`}</mtr>`,n=t=>`<mtr><mtd></mtd><mtd>${this.UnparserMathML(t)}</mtd></mtr>`,a=(t,e,r,s)=>`<mtable>${i(t,s)}${n(e)}${i(r)}</mtable>`,o=(t,e,r)=>MathML.format["()"](t,e,r),l=t=>t.length>0?o("(",s(t),")"):"",c=t=>{const e=t.size.length>0?o("(",s(t.size),")"):"",r=!t.class||(i=t.class)&&"LIST"===i.type&&0===i.list.length?"":'<mspace width="0.33em"/>'+this.UnparserMathML(t.class);var i;const n=t.functions.length>0?'<mspace width="0.33em"/>'+o("{",s(t.functions),"}"):"",a=t.default?"<mo>=</mo>"+this.UnparserMathML(t.default):"";return`<mrow>${this.UnparserMathML(t.name)}${e}${r}${n}${a}</mrow>`},u=t=>{const e=0===t.return.list.length?"":1===t.return.list.length?this.UnparserMathML(t.return.list[0]):o("[",s(t.return.list),"]"),r=o("(",s(t.parameter.list),")");return`${e?e+"<mo>=</mo>":""}${MathML.format.IDENT(t.id)}${r}`};try{if(!t)return MathML.format.UNDEFINED();if(void 0===t)return MathML.format.UNDEFINED();if(Complex.isInstanceOf(t))return Complex.unparseMathML(t,this,e);if(CharString.isInstanceOf(t))return CharString.unparseMathML(t,e);if(MultiArray.isInstanceOf(t))return MultiArray.unparseMathML(t,this,e);if(Structure.isInstanceOf(t))return Structure.unparseMathML(t,this,e);if(FunctionHandle.isInstanceOf(t))return FunctionHandle.unparseMathML(t,this,e);switch(t.type){case"()":{const r=this.requirePrefixOperation(t),s=this.nodePrecedence(r.right),i=this.UnparserMathML(r.right,s);return s<e?MathML.format["()"]("(",i,")"):i}case"+":case"-":case"*":case".*":case"./":case".\\":case"\\":case".^":case".**":case"<":case">":case"==":case"&":case"|":case"&&":case"||":case"=":case"+=":case"-=":case"*=":case"/=":case"\\=":case"^=":case"**=":case".*=":case"./=":case".\\=":case".^=":case".**=":case"&=":case"|=":case"<=":case">=":case"!=":case"~=":{const e=this.requireBinaryOperation(t),r=this.nodePrecedence(t),s=this.UnparserMathML(e.left,r),i=this.UnparserMathML(e.right,r);return MathML.formatDynamic(t.type,this.nodePrecedence(e.left)<r?MathML.format["()"]("(",s,")"):s,this.nodePrecedence(e.right)<r?MathML.format["()"]("(",i,")"):i)}case"/":{const e=this.requireBinaryOperation(t);return MathML.formatDynamic(t.type,this.UnparserMathML(e.left),this.UnparserMathML(e.right))}case"**":case"^":{const e=this.requireBinaryOperation(t);return MathML.formatDynamic(t.type,this.UnparserMathML(e.left,this.precedenceTable["_"+t.type]),this.UnparserMathML(e.right))}case"!":case"~":case"+_":case"-_":case"++_":case"--_":{const e=this.requirePrefixOperation(t);return MathML.formatDynamic(t.type,this.UnparserMathML(e.right))}case"_++":case"_--":case".'":case"'":{const e=this.requirePostfixOperation(t);return MathML.formatDynamic(t.type,this.UnparserMathML(e.left,this.precedenceTable["_"+t.type]))}case"IDENT":return MathML.format.IDENT(substSymbol(t.id));case".":return MathML.format["."](this.UnparserMathML(t.obj),t.field.map(t=>"string"==typeof t?MathML.format.IDENT(t):MathML.format["()"]("(",this.UnparserMathML(t),")")));case"LIST":return MathML.format.LIST(t.list.map(t=>this.UnparserMathML(t)));case"RANGE":return t.start_&&t.stop_?t.stride_?MathML.format.RANGE(this.UnparserMathML(t.start_),this.UnparserMathML(t.stride_),this.UnparserMathML(t.stop_)):MathML.format.RANGE(this.UnparserMathML(t.start_),this.UnparserMathML(t.stop_)):MathML.format.RANGE();case"ENDRANGE":case":":case"<~>":return MathML.formatDynamic(t.type);case"IDX":if(0===t.args.length)return MathML.format.IDX(this.UnparserMathML(t.expr),t.delim[0],[],t.delim[1]);{let r;if("IDENT"===t.expr.type){const e=this.context.aliasNameFunction(t.expr.id);r=e in this.context.builtInFunctionTable&&this.context.builtInFunctionTable[e].UnparserMathML?this.context.builtInFunctionTable[e].UnparserMathML(t):e in this.context.builtInFunctionTable&&MathML.formatFunction(e)?MathML.formatDynamic(e,...t.args.map(t=>this.UnparserMathML(t))):MathML.format.IDX(MathML.format.IDENT(substSymbol(t.expr.id)),t.delim[0],t.args.map(t=>this.UnparserMathML(t)),t.delim[1])}else r=MathML.format.IDX(this.UnparserMathML(t.expr,e),t.delim[0],t.args.map(t=>this.UnparserMathML(t)),t.delim[1]);return this.nodePrecedence(t)>e?r:MathML.format["()"]("(",r,")")}case"RETLIST":return MathML.format.RETLIST();case"CMDWLIST":return MathML.format.CMDWLIST(t.id,t.args.map(t=>this.UnparserMathML(t)));case"ARGVALID":return c(t);case"ARGS":return`<mtable>${i("arguments",t.attributes.length>0?t.attributes.map(t=>this.UnparserMathML(t)).join("<mo>,</mo>"):void 0)}${t.validation.map(t=>n(t)).join("")}${i("endarguments")}</mtable>`;case"GLOBAL":return r("global",t);case"PERSIST":return r("persistent",t);case"IMPORT":return"<mrow><mi>import</mi>"+(t.imports.length>0?'<mspace width="0.33em"/>'+t.imports.map(t=>this.UnparserMathML(t)).join("<mo>,</mo>"):"")+"</mrow>";case"RETURN":return"<mi>return</mi>";case"BREAK":return"<mi>break</mi>";case"CONTINUE":return"<mi>continue</mi>";case"IF":const h=t.expression.map((e,r)=>`${i(0===r?"if":"elseif",this.UnparserMathML(e))}${n(t.then[r])}`),d=t.else?`${i("else")}${n(t.else)}`:"";return`<mtable>${h.join("")}${d}${i("endif")}</mtable>`;case"SWITCH":return`<mtable>${i("switch",this.UnparserMathML(t.expression))}${t.cases.map(t=>`${i("case",this.UnparserMathML(t.expression))}${n(t.then)}`).join("")}${t.otherwise?`${i("otherwise")}${n(t.otherwise)}`:""}${i("endswitch")}</mtable>`;case"WHILE":return a("while",t.body,"endwhile",this.UnparserMathML(t.expression));case"DO_UNTIL":return`<mtable>${i("do")}${n(t.body)}${i("until",this.UnparserMathML(t.expression))}</mtable>`;case"FOR":return a(t.parallel?"parfor":"for",t.body,t.parallel?"endparfor":"endfor",this.UnparserMathML(t.target)+'<mo form="infix" stretchy="true">=</mo>'+this.UnparserMathML(t.expression)+(t.workers?"<mo>,</mo>"+this.UnparserMathML(t.workers):""));case"SPMD":return a("spmd",t.body,"endspmd",t.workers?this.UnparserMathML(t.workers):void 0);case"TRY":return`<mtable>${i("try")}${n(t.body)}${t.catchBody?i("catch",t.catchIdentifier?this.UnparserMathML(t.catchIdentifier):void 0)+n(t.catchBody):""}${i("end_try_catch")}</mtable>`;case"UNWIND_PROTECT":return`<mtable>${i("unwind_protect")}${n(t.body)}${i("unwind_protect_cleanup")}${n(t.cleanup)}${i("end_unwind_protect")}</mtable>`;case"CLASSDEF":return`<mtable>${i("classdef",`${l(t.attributes)}${t.attributes.length>0?'<mspace width="0.33em"/>':""}${MathML.format.IDENT(t.id)}${t.superclasses.length>0?'<mspace width="0.33em"/><mo><</mo><mspace width="0.33em"/>'+t.superclasses.map(t=>this.UnparserMathML(t)).join("<mo>&</mo>"):""}`)}${t.sections.map(t=>n(t)).join("")}${i("endclassdef")}</mtable>`;case"CLASS_SECTION":return`<mtable>${i(t.kind.toLowerCase(),t.attributes.length>0?l(t.attributes):void 0)}${n(t.members)}${i((t=>{switch(t){case"PROPERTIES":return"endproperties";case"METHODS":return"endmethods";case"EVENTS":return"endevents";case"ENUMERATION":return"endenumeration";default:return"end"}})(t.kind))}</mtable>`;case"CLASS_PROPERTY":return c(t.validation);case"CLASS_EVENT":return MathML.format.IDENT(t.id);case"CLASS_ENUMERATION":return`<mrow>${MathML.format.IDENT(t.id)}${t.args.length>0?o("(",s(t.args),")"):""}</mrow>`;case"CLASS_ATTRIBUTE":return!t.value||"~"!==t.value.type&&"!"!==t.value.type?`<mrow>${MathML.format.IDENT(t.id)}${t.value?"<mo>=</mo>"+this.UnparserMathML(t.value):""}</mrow>`:`<mrow><mo>${t.value.type}</mo>${MathML.format.IDENT(t.id)}</mrow>`;case"FCNDEF":return(t=>{if(t.attributes?.prototype)return u(t);const e=t.arguments.list.map(t=>n(t)).join("");return`<mtable>${i("function",u(t))}${e}${n(t.statements)}${i("endfunction")}</mtable>`})(t);case"VOID":return MathML.format.VOID();default:return MathML.format.INVALID()}}catch(t){if(this._debug)throw t;return MathML.format.ERROR()}}UnparseMathML(t,e="block"){let r=this.UnparserMathML(t);return r?MathML.format.math(MathML.format.errorReplace(r),e):"<b>Unparse error.</b>"}ToMathML(t,e="block"){return this.UnparseMathML(this.Parse(t),e)}Interprets(t,e="none"){const r=this.Parse(t),s=this.Evaluate(r);return{input:t,inputParsed:r,inputUnparsed:this.Unparse(s),inputUnparsedMathML:this.UnparseMathML(s),evaluated:s,evaluatedUnparsed:this.Unparse(s),evaluatedUnparsedMathML:this.UnparseMathML(s,e)}}}const src_Interpreter=null;globalThis.crypto=__WEBPACK_EXTERNAL_MODULE_crypto_default__;const __webpack_exports__doubleQuoteCharacter='"',__webpack_exports__singleQuoteCharacter="'",__webpack_exports__stringClass=3;export{AST,CallFrame,CharString,CircularReferenceError,ClassBoundMethod,ClassDefinition,ClassEmptyMethod,ClassEnumerationValue,ClassEventData,ClassEventListener,ClassInstance,ClassMember,ClassMetaClass,ClassMetaEnumerationMember,ClassMetaEvent,ClassMetaMember,ClassMetaMethod,ClassMetaObject,ClassMetaProperty,ClassPropertyEvent,ClassStaticMethod,Complex,ComplexDecimal,ComplexNumber,Configuration,Context,CoreFunctions,Decimal,InterpreterError_EvalError as EvalError,FunctionHandle,Interpreter,InterpreterError,LinearAlgebra,ManifestSourceResolver,MathML,MathOperation,MultiArray,InterpreterError_ReferenceError as ReferenceError,Scope,Structure,InterpreterError_SyntaxError as SyntaxError,TableSourceResolver,UndefinedReferenceError,__webpack_exports__doubleQuoteCharacter as doubleQuoteCharacter,__webpack_exports__singleQuoteCharacter as singleQuoteCharacter,__webpack_exports__stringClass as stringClass};