@guihz/trading-vue-editor-tes 0.0.194 → 0.0.195
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/assets/{parserTccWorker-BmFWyyKc.js → parserTccWorker-BRdbggcL.js} +1 -1
- package/lib/assets/{scriptsRunWorker-BVxwT154.js → scriptsRunWorker-BD3Df3Mn.js} +2 -2
- package/lib/components/editor/parseScript/buildInVarNamespace/syminfo.d.ts +2 -2
- package/lib/trading-vue-editor.js +2 -2
- package/lib/trading-vue-editor.umd.cjs +1 -1
- package/package.json +1 -1
@@ -10,7 +10,7 @@ var Zg=Object.defineProperty;var Qg=(po,pi,Or)=>pi in po?Zg(po,pi,{enumerable:!0
|
|
10
10
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var c,_=!0,o=!1;return{s:function(){m=m.call(f)},n:function(){var u=m.next();return _=u.done,u},e:function(u){o=!0,c=u},f:function(){try{_||m.return==null||m.return()}finally{if(o)throw c}}}}function Ym(f,i){(i==null||i>f.length)&&(i=f.length);for(var m=0,a=new Array(i);m<i;m++)a[m]=f[m];return a}function ru(f,i){if(!(f instanceof i))throw new TypeError("Cannot call a class as a function")}function Jm(f,i){for(var m=0;m<i.length;m++){var a=i[m];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(f,Zm(a.key),a)}}function iu(f,i,m){return i&&Jm(f.prototype,i),m&&Jm(f,m),Object.defineProperty(f,"prototype",{writable:!1}),f}function Zm(f){var i=function(m,a){if(ts(m)!=="object"||m===null)return m;var p=m[Symbol.toPrimitive];if(p!==void 0){var c=p.call(m,"string");if(ts(c)!=="object")return c;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(m)}(f);return ts(i)==="symbol"?i:String(i)}Yi.EMPTY=new op;var tl,nl,cp,Qm=function(){function f(i){ru(this,f),this.tokens=i,this.programs=new Map}return iu(f,[{key:"getTokenStream",value:function(){return this.tokens}},{key:"insertAfter",value:function(i,m){var a,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:f.DEFAULT_PROGRAM_NAME;a=typeof i=="number"?i:i.tokenIndex;var c=this.getProgram(p),_=new t_(this.tokens,a,c.length,m);c.push(_)}},{key:"insertBefore",value:function(i,m){var a,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:f.DEFAULT_PROGRAM_NAME;a=typeof i=="number"?i:i.tokenIndex;var c=this.getProgram(p),_=new rs(this.tokens,a,c.length,m);c.push(_)}},{key:"replaceSingle",value:function(i,m){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:f.DEFAULT_PROGRAM_NAME;this.replace(i,i,m,a)}},{key:"replace",value:function(i,m,a){var p=arguments.length>3&&arguments[3]!==void 0?arguments[3]:f.DEFAULT_PROGRAM_NAME;if(typeof i!="number"&&(i=i.tokenIndex),typeof m!="number"&&(m=m.tokenIndex),i>m||i<0||m<0||m>=this.tokens.size)throw new RangeError("replace: range invalid: ".concat(i,"..").concat(m,"(size=").concat(this.tokens.size,")"));var c=this.getProgram(p),_=new rl(this.tokens,i,m,c.length,a);c.push(_)}},{key:"delete",value:function(i,m){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:f.DEFAULT_PROGRAM_NAME;m===void 0&&(m=i),this.replace(i,m,null,a)}},{key:"getProgram",value:function(i){var m=this.programs.get(i);return m==null&&(m=this.initializeProgram(i)),m}},{key:"initializeProgram",value:function(i){var m=[];return this.programs.set(i,m),m}},{key:"getText",value:function(i){var m,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f.DEFAULT_PROGRAM_NAME;m=i instanceof ve?i:new ve(0,this.tokens.size-1),typeof i=="string"&&(a=i);var p=this.programs.get(a),c=m.start,_=m.stop;if(_>this.tokens.size-1&&(_=this.tokens.size-1),c<0&&(c=0),p==null||p.length===0)return this.tokens.getText(new ve(c,_));for(var o=[],u=this.reduceToSingleOperationPerIndex(p),E=c;E<=_&&E<this.tokens.size;){var x=u.get(E);u.delete(E);var T=this.tokens.get(E);x==null?(T.type!==n.EOF&&o.push(String(T.text)),E++):E=x.execute(o)}if(_===this.tokens.size-1){var I,te=ns(u.values());try{for(te.s();!(I=te.n()).done;){var Re=I.value;Re.index>=this.tokens.size-1&&o.push(Re.text.toString())}}catch(De){te.e(De)}finally{te.f()}}return o.join("")}},{key:"reduceToSingleOperationPerIndex",value:function(i){for(var m=0;m<i.length;m++){var a=i[m];if(a!=null&&a instanceof rl){var p,c=a,_=ns(this.getKindOfOps(i,rs,m));try{for(_.s();!(p=_.n()).done;){var o=p.value;o.index===c.index?(i[o.instructionIndex]=void 0,c.text=o.text.toString()+(c.text!=null?c.text.toString():"")):o.index>c.index&&o.index<=c.lastIndex&&(i[o.instructionIndex]=void 0)}}catch(Cr){_.e(Cr)}finally{_.f()}var u,E=ns(this.getKindOfOps(i,rl,m));try{for(E.s();!(u=E.n()).done;){var x=u.value;if(x.index>=c.index&&x.lastIndex<=c.lastIndex)i[x.instructionIndex]=void 0;else{var T=x.lastIndex<c.index||x.index>c.lastIndex;if(x.text!=null||c.text!=null||T){if(!T)throw new Error("replace op boundaries of ".concat(c," overlap with previous ").concat(x))}else i[x.instructionIndex]=void 0,c.index=Math.min(x.index,c.index),c.lastIndex=Math.max(x.lastIndex,c.lastIndex)}}}catch(Cr){E.e(Cr)}finally{E.f()}}}for(var I=0;I<i.length;I++){var te=i[I];if(te!=null&&te instanceof rs){var Re,De=te,He=ns(this.getKindOfOps(i,rs,I));try{for(He.s();!(Re=He.n()).done;){var at=Re.value;at.index===De.index&&(at instanceof t_?(De.text=this.catOpText(at.text,De.text),i[at.instructionIndex]=void 0):at instanceof rs&&(De.text=this.catOpText(De.text,at.text),i[at.instructionIndex]=void 0))}}catch(Cr){He.e(Cr)}finally{He.f()}var ze,_n=ns(this.getKindOfOps(i,rl,I));try{for(_n.s();!(ze=_n.n()).done;){var pn=ze.value;if(De.index!==pn.index){if(De.index>=pn.index&&De.index<=pn.lastIndex)throw new Error("insert op ".concat(De," within boundaries of previous ").concat(pn))}else pn.text=this.catOpText(De.text,pn.text),i[I]=void 0}}catch(Cr){_n.e(Cr)}finally{_n.f()}}}var zn,Vr=new Map,Ri=ns(i);try{for(Ri.s();!(zn=Ri.n()).done;){var wi=zn.value;if(wi!=null){if(Vr.get(wi.index)!=null)throw new Error("should only be one op per index");Vr.set(wi.index,wi)}}}catch(Cr){Ri.e(Cr)}finally{Ri.f()}return Vr}},{key:"catOpText",value:function(i,m){var a="",p="";return i!=null&&(a=i.toString()),m!=null&&(p=m.toString()),a+p}},{key:"getKindOfOps",value:function(i,m,a){return i.slice(0,a).filter(function(p){return p&&p instanceof m})}}]),f}();tl=Qm,cp="default",(nl=Zm(nl="DEFAULT_PROGRAM_NAME"))in tl?Object.defineProperty(tl,nl,{value:cp,enumerable:!0,configurable:!0,writable:!0}):tl[nl]=cp;var e_=function(){function f(i,m,a,p){ru(this,f),this.tokens=i,this.instructionIndex=a,this.index=m,this.text=p===void 0?"":p}return iu(f,[{key:"toString",value:function(){var i=this.constructor.name,m=i.indexOf("$");return"<"+(i=i.substring(m+1,i.length))+"@"+this.tokens.get(this.index)+':"'+this.text+'">'}}]),f}(),rs=function(f){ap(m,f);var i=up(m);function m(a,p,c,_){return ru(this,m),i.call(this,a,p,c,_)}return iu(m,[{key:"execute",value:function(a){return this.text&&a.push(this.text.toString()),this.tokens.get(this.index).type!==n.EOF&&a.push(String(this.tokens.get(this.index).text)),this.index+1}}]),m}(e_),t_=function(f){ap(m,f);var i=up(m);function m(a,p,c,_){return ru(this,m),i.call(this,a,p+1,c,_)}return iu(m)}(rs),rl=function(f){ap(m,f);var i=up(m);function m(a,p,c,_,o){var u;return ru(this,m),(u=i.call(this,a,p,_,o)).lastIndex=c,u}return iu(m,[{key:"execute",value:function(a){return this.text&&a.push(this.text.toString()),this.lastIndex+1}},{key:"toString",value:function(){return this.text==null?"<DeleteOp@"+this.tokens.get(this.index)+".."+this.tokens.get(this.lastIndex)+">":"<ReplaceOp@"+this.tokens.get(this.index)+".."+this.tokens.get(this.lastIndex)+':"'+this.text+'">'}}]),m}(e_);const Jg={atn:Eg,dfa:xg,context:Cg,misc:Og,tree:wg,error:Bg,Token:n,CommonToken:Is,CharStreams:Gm,CharStream:tu,InputStream:tu,CommonTokenStream:Wm,Lexer:ar,Parser:tp,ParserRuleContext:op,Interval:ve,IntervalSet:ie,LL1Analyzer:Bo,Utils:jg,TokenStreamRewriter:Qm}})();var Dr=kt.dx,lp=kt.q2;kt.FO,kt.xf,kt.Gy;var n_=kt.s4,r_=kt.c7,fp=kt._7;kt.gp;var i_=kt.cK,o_=kt.zs,a_=kt.AV;kt.Xp,kt.VS,kt.ul;var s_=kt.hW,u_=kt.x1,di=kt.z5;kt.oN;var c_=kt.TB;kt.u1;var l_=kt._b,f_=kt.$F,Ye=kt._T,hp=kt.db,h_=kt.Zx,Je=kt._x;kt.r8,kt.JI,kt.TP;var pp=kt.WU;kt.Nj,kt.ZP;const L=class L extends l_{get grammarFileName(){return"tccScriptParser.g4"}get literalNames(){return L.literalNames}get symbolicNames(){return L.symbolicNames}get ruleNames(){return L.ruleNames}get serializedATN(){return L._serializedATN}createFailedPredicateException(e,n){return new o_(this,e,n)}constructor(e){super(e),this._interp=new f_(this,L._ATN,L.DecisionsToDFA,new hp)}program(){let e=new p_(this,this._ctx,this.state);this.enterRule(e,0,L.RULE_program);let n;try{this.enterOuterAlt(e,1);{for(this.state=106,this._errHandler.sync(this),n=this._input.LA(1);n===4||n===6||!(n-36&-32)&&1<<n-36&38635767;){switch(this.state=104,this._errHandler.sync(this),this._input.LA(1)){case 61:this.state=102,this.match(L.NEWLINE);break;case 4:case 6:case 36:case 37:case 38:case 40:case 41:case 42:case 43:case 47:case 51:case 52:case 54:case 55:case 58:this.state=103,this.globalStmt();break;default:throw new di(this)}this.state=108,this._errHandler.sync(this),n=this._input.LA(1)}this.state=109,this.match(L.EOF)}}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}globalStmt(){let e=new il(this,this._ctx,this.state);this.enterRule(e,2,L.RULE_globalStmt);let n;try{switch(this.state=123,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,3,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=111,this.variableDeclarationStmt(),this.state=113,this._errHandler.sync(this),n=this._input.LA(1),n===8&&(this.state=112,this.match(L.Comma)),this.state=115,this.match(L.NEWLINE);break;case 2:this.enterOuterAlt(e,2),this.state=117,this.blockStmt();break;case 3:this.enterOuterAlt(e,3),this.state=118,this.importStmt();break;case 4:this.enterOuterAlt(e,4),this.state=119,this.arrowFunction();break;case 5:this.enterOuterAlt(e,5),this.state=120,this.arrowMethod();break;case 6:this.enterOuterAlt(e,6),this.state=121,this.typeStatement();break;case 7:this.enterOuterAlt(e,7),this.state=122,this.enumStatement();break}}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}blockStmt(){let e=new dp(this,this._ctx,this.state);this.enterRule(e,4,L.RULE_blockStmt);try{let n;this.enterOuterAlt(e,1);{for(this.state=130,this._errHandler.sync(this),n=this._interp.adaptivePredict(this._input,4,this._ctx);n!==2&&n!==Dr.INVALID_ALT_NUMBER;)n===1&&(this.state=125,this.variableDeclarationStmt(),this.state=126,this.match(L.Comma)),this.state=132,this._errHandler.sync(this),n=this._interp.adaptivePredict(this._input,4,this._ctx);switch(this.state=135,this._errHandler.sync(this),this._input.LA(1)){case 4:case 6:case 38:case 40:case 51:case 54:case 55:case 58:this.state=133,this.varBlockStmt();break;case 37:case 41:case 42:case 43:this.state=134,this.blockExpression();break;default:throw new di(this)}}}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}stmt(){let e=new ol(this,this._ctx,this.state);this.enterRule(e,6,L.RULE_stmt);let n;try{switch(this.state=144,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,7,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=137,this.simpleStmt(),this.state=139,this._errHandler.sync(this),n=this._input.LA(1),n===8&&(this.state=138,this.match(L.Comma)),this.state=141,this.match(L.NEWLINE);break;case 2:this.enterOuterAlt(e,2),this.state=143,this.expressionBlockSequence();break}}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}simpleStmt(){let e=new al(this,this._ctx,this.state);this.enterRule(e,8,L.RULE_simpleStmt);try{switch(this.state=150,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,8,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=146,this.expressionSequence();break;case 2:this.enterOuterAlt(e,2),this.state=147,this.blockSequence();break;case 3:this.enterOuterAlt(e,3),this.state=148,this.brackethesized();break;case 4:this.enterOuterAlt(e,4),this.state=149,this.flowStmt();break}}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}flowStmt(){let e=new mp(this,this._ctx,this.state);this.enterRule(e,10,L.RULE_flowStmt);let n;try{this.enterOuterAlt(e,1),this.state=152,n=this._input.LA(1),n===34||n===39?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this)}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}block(){let e=new is(this,this._ctx,this.state);this.enterRule(e,12,L.RULE_block);let n;try{switch(this.state=161,this._errHandler.sync(this),this._input.LA(1)){case 4:case 6:case 12:case 13:case 31:case 32:case 33:case 34:case 38:case 39:case 40:case 46:case 51:case 54:case 55:case 56:case 57:case 58:this.enterOuterAlt(e,1),this.state=154,this.simpleStmt(),this.state=156,this._errHandler.sync(this),n=this._input.LA(1),n===8&&(this.state=155,this.match(L.Comma)),this.state=158,this.match(L.NEWLINE);break;case 61:this.enterOuterAlt(e,2),this.state=160,this.blockLine();break;default:throw new di(this)}}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}blockLine(){let e=new mo(this,this._ctx,this.state);this.enterRule(e,14,L.RULE_blockLine);let n;try{this.enterOuterAlt(e,1);{this.state=163,this.match(L.NEWLINE),this.state=164,this.match(L.INDENT),this.state=166,this._errHandler.sync(this),n=this._input.LA(1);do this.state=165,this.stmt(),this.state=168,this._errHandler.sync(this),n=this._input.LA(1);while(!(n&-32)&&1<<n&2147496016||!(n-32&-32)&&1<<n-32&130568167);this.state=170,this.match(L.DEDENT)}}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}variableDeclarationStmt(){let e=new ou(this,this._ctx,this.state);this.enterRule(e,16,L.RULE_variableDeclarationStmt);try{let n;this.enterOuterAlt(e,1);{switch(this.state=174,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,12,this._ctx)){case 1:this.state=172,this.methodStmt();break;case 2:this.state=173,this.variableDeclarationList();break}for(this.state=183,this._errHandler.sync(this),n=this._interp.adaptivePredict(this._input,14,this._ctx);n!==2&&n!==Dr.INVALID_ALT_NUMBER;){if(n===1)switch(this.state=176,this.match(L.Comma),this.state=179,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,13,this._ctx)){case 1:this.state=177,this.methodStmt();break;case 2:this.state=178,this.variableDeclarationList();break}this.state=185,this._errHandler.sync(this),n=this._interp.adaptivePredict(this._input,14,this._ctx)}}}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}variableDeclarationList(){let e=new Ni(this,this._ctx,this.state);this.enterRule(e,18,L.RULE_variableDeclarationList);try{switch(this.state=194,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,15,this._ctx)){case 1:e=new m_(this,e),this.enterOuterAlt(e,1),this.state=186,this.varArrayDeclaration(),this.state=187,this.match(L.Assign),this.state=188,this.singleExpression(0);break;case 2:e=new d_(this,e),this.enterOuterAlt(e,2),this.state=190,this.name(),this.state=191,this.assignmentOperator(),this.state=192,this.singleExpression(0);break}}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}varModifier(){let e=new sl(this,this._ctx,this.state);this.enterRule(e,20,L.RULE_varModifier);let n;try{this.enterOuterAlt(e,1),this.state=196,n=this._input.LA(1),n===38||n===40?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this)}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}blockSequence(){let e=new _p(this,this._ctx,this.state);this.enterRule(e,22,L.RULE_blockSequence);try{let n;this.enterOuterAlt(e,1);{switch(this.state=200,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,16,this._ctx)){case 1:this.state=198,this.singleExpression(0);break;case 2:this.state=199,this.variableDeclarationList();break}for(this.state=209,this._errHandler.sync(this),n=this._interp.adaptivePredict(this._input,18,this._ctx);n!==2&&n!==Dr.INVALID_ALT_NUMBER;){if(n===1)switch(this.state=202,this.match(L.Comma),this.state=205,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,17,this._ctx)){case 1:this.state=203,this.singleExpression(0);break;case 2:this.state=204,this.variableDeclarationList();break}this.state=211,this._errHandler.sync(this),n=this._interp.adaptivePredict(this._input,18,this._ctx)}}}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}expressionSequence(){let e=new ul(this,this._ctx,this.state);this.enterRule(e,24,L.RULE_expressionSequence);try{let n;for(this.enterOuterAlt(e,1),this.state=212,this.singleExpression(0),this.state=217,this._errHandler.sync(this),n=this._interp.adaptivePredict(this._input,19,this._ctx);n!==2&&n!==Dr.INVALID_ALT_NUMBER;)n===1&&(this.state=213,this.match(L.Comma),this.state=214,this.singleExpression(0)),this.state=219,this._errHandler.sync(this),n=this._interp.adaptivePredict(this._input,19,this._ctx)}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}expressionBlockSequence(){let e=new yp(this,this._ctx,this.state);this.enterRule(e,26,L.RULE_expressionBlockSequence);try{let n;this.enterOuterAlt(e,1);{for(this.state=228,this._errHandler.sync(this),n=this._interp.adaptivePredict(this._input,21,this._ctx);n!==2&&n!==Dr.INVALID_ALT_NUMBER;){if(n===1){switch(this.state=222,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,20,this._ctx)){case 1:this.state=220,this.singleExpression(0);break;case 2:this.state=221,this.variableDeclarationList();break}this.state=224,this.match(L.Comma)}this.state=230,this._errHandler.sync(this),n=this._interp.adaptivePredict(this._input,21,this._ctx)}switch(this.state=233,this._errHandler.sync(this),this._input.LA(1)){case 4:case 6:case 38:case 40:case 51:case 54:case 55:case 58:this.state=231,this.varBlockStmt();break;case 37:case 41:case 42:case 43:this.state=232,this.blockExpression();break;default:throw new di(this)}}}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}varBlockStmt(){let e=new cl(this,this._ctx,this.state);this.enterRule(e,28,L.RULE_varBlockStmt);try{this.enterOuterAlt(e,1);{switch(this.state=241,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,23,this._ctx)){case 1:this.state=235,this.varArrayDeclaration(),this.state=236,this.match(L.Assign);break;case 2:this.state=238,this.name(),this.state=239,this.assignmentOperator();break}this.state=243,this.blockExpression()}}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}varArrayDeclaration(){let e=new os(this,this._ctx,this.state);this.enterRule(e,30,L.RULE_varArrayDeclaration);let n;try{switch(this.state=263,this._errHandler.sync(this),this._input.LA(1)){case 38:case 40:case 51:case 54:case 55:case 58:e=new y_(this,e),this.enterOuterAlt(e,1);{switch(this.state=246,this._errHandler.sync(this),n=this._input.LA(1),(n===38||n===40)&&(this.state=245,this.varModifier()),this.state=249,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,25,this._ctx)){case 1:this.state=248,this.typeGather();break}this.state=251,this.identifier()}break;case 4:e=new __(this,e),this.enterOuterAlt(e,2);{for(this.state=252,this.match(L.OpenBracket),this.state=253,this.identifier(),this.state=258,this._errHandler.sync(this),n=this._input.LA(1);n===8;)this.state=254,this.match(L.Comma),this.state=255,this.identifier(),this.state=260,this._errHandler.sync(this),n=this._input.LA(1);this.state=261,this.match(L.CloseBracket)}break;default:throw new di(this)}}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}blockExpression(){let e=new au(this,this._ctx,this.state);this.enterRule(e,32,L.RULE_blockExpression);try{switch(this.state=269,this._errHandler.sync(this),this._input.LA(1)){case 43:this.enterOuterAlt(e,1),this.state=265,this.ifStatement();break;case 37:this.enterOuterAlt(e,2),this.state=266,this.forStatement();break;case 42:this.enterOuterAlt(e,3),this.state=267,this.whileStatement();break;case 41:this.enterOuterAlt(e,4),this.state=268,this.switchStatement();break;default:throw new di(this)}}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}singleExpression(e){e===void 0&&(e=0);let n=this._ctx,r=this.state,s=new Ve(this,this._ctx,r),l=s,h=34;this.enterRecursionRule(s,34,L.RULE_singleExpression,e);let d;try{let v;this.enterOuterAlt(s,1);{switch(this.state=283,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,29,this._ctx)){case 1:s=new k_(this,s),this._ctx=s,l=s,this.state=272,this.methodStmt();break;case 2:s=new C_(this,s),this._ctx=s,l=s,this.state=273,d=this._input.LA(1),d===12||d===13?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this),this.state=274,this.singleExpression(12);break;case 3:s=new O_(this,s),this._ctx=s,l=s,this.state=275,this.match(L.Not),this.state=276,this.singleExpression(11);break;case 4:s=new T_(this,s),this._ctx=s,l=s,this.state=277,this.name();break;case 5:s=new A_(this,s),this._ctx=s,l=s,this.state=278,this.literal();break;case 6:s=new g_(this,s),this._ctx=s,l=s,this.state=279,this.match(L.OpenParen),this.state=280,this.singleExpression(0),this.state=281,this.match(L.CloseParen);break}for(this._ctx.stop=this._input.LT(-1),this.state=316,this._errHandler.sync(this),v=this._interp.adaptivePredict(this._input,31,this._ctx);v!==2&&v!==Dr.INVALID_ALT_NUMBER;){if(v===1)switch(this._parseListeners!=null&&this.triggerExitRuleEvent(),l=s,this.state=314,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,30,this._ctx)){case 1:{if(s=new w_(this,new Ve(this,n,r)),this.pushNewRecursionContext(s,h,L.RULE_singleExpression),this.state=285,!this.precpred(this._ctx,10))throw this.createFailedPredicateException("this.precpred(this._ctx, 10)");this.state=286,d=this._input.LA(1),!(d&-32)&&1<<d&114688?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this),this.state=287,this.singleExpression(11)}break;case 2:{if(s=new b_(this,new Ve(this,n,r)),this.pushNewRecursionContext(s,h,L.RULE_singleExpression),this.state=288,!this.precpred(this._ctx,9))throw this.createFailedPredicateException("this.precpred(this._ctx, 9)");this.state=289,d=this._input.LA(1),d===12||d===13?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this),this.state=290,this.singleExpression(10)}break;case 3:{if(s=new v_(this,new Ve(this,n,r)),this.pushNewRecursionContext(s,h,L.RULE_singleExpression),this.state=291,!this.precpred(this._ctx,8))throw this.createFailedPredicateException("this.precpred(this._ctx, 8)");this.state=292,d=this._input.LA(1),!(d&-32)&&1<<d&3932160?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this),this.state=293,this.singleExpression(9)}break;case 4:{if(s=new R_(this,new Ve(this,n,r)),this.pushNewRecursionContext(s,h,L.RULE_singleExpression),this.state=294,!this.precpred(this._ctx,7))throw this.createFailedPredicateException("this.precpred(this._ctx, 7)");this.state=295,d=this._input.LA(1),d===22||d===23?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this),this.state=296,this.singleExpression(8)}break;case 5:{if(s=new S_(this,new Ve(this,n,r)),this.pushNewRecursionContext(s,h,L.RULE_singleExpression),this.state=297,!this.precpred(this._ctx,6))throw this.createFailedPredicateException("this.precpred(this._ctx, 6)");this.state=298,this.match(L.And),this.state=299,this.singleExpression(7)}break;case 6:{if(s=new x_(this,new Ve(this,n,r)),this.pushNewRecursionContext(s,h,L.RULE_singleExpression),this.state=300,!this.precpred(this._ctx,5))throw this.createFailedPredicateException("this.precpred(this._ctx, 5)");this.state=301,this.match(L.Or),this.state=302,this.singleExpression(6)}break;case 7:{if(s=new E_(this,new Ve(this,n,r)),this.pushNewRecursionContext(s,h,L.RULE_singleExpression),this.state=303,!this.precpred(this._ctx,4))throw this.createFailedPredicateException("this.precpred(this._ctx, 4)");this.state=304,this.match(L.QuestionMark),this.state=305,this.singleExpression(0),this.state=306,this.match(L.Colon),this.state=307,this.singleExpression(4)}break;case 8:{if(s=new D_(this,new Ve(this,n,r)),this.pushNewRecursionContext(s,h,L.RULE_singleExpression),this.state=309,!this.precpred(this._ctx,13))throw this.createFailedPredicateException("this.precpred(this._ctx, 13)");this.state=310,this.match(L.OpenBracket),this.state=311,this.singleExpression(0),this.state=312,this.match(L.CloseBracket)}break}this.state=318,this._errHandler.sync(this),v=this._interp.adaptivePredict(this._input,31,this._ctx)}}}catch(v){if(v instanceof Je)s.exception=v,this._errHandler.reportError(this,v),this._errHandler.recover(this,v);else throw v}finally{this.unrollRecursionContexts(n)}return s}brackethesized(){let e=new ll(this,this._ctx,this.state);this.enterRule(e,36,L.RULE_brackethesized);try{this.enterOuterAlt(e,1),this.state=319,this.match(L.OpenBracket),this.state=320,this.expressionSequence(),this.state=321,this.match(L.CloseBracket)}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}arguments(){let e=new gp(this,this._ctx,this.state);this.enterRule(e,38,L.RULE_arguments);let n;try{let r;this.enterOuterAlt(e,1);{if(this.state=323,this.match(L.OpenParen),this.state=335,this._errHandler.sync(this),n=this._input.LA(1),!(n&-32)&&1<<n&2147496016||!(n-32&-32)&&1<<n-32&130564099){for(this.state=324,this.argument(),this.state=329,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,32,this._ctx);r!==2&&r!==Dr.INVALID_ALT_NUMBER;)r===1&&(this.state=325,this.match(L.Comma),this.state=326,this.argument()),this.state=331,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,32,this._ctx);this.state=333,this._errHandler.sync(this),n=this._input.LA(1),n===8&&(this.state=332,this.match(L.Comma))}this.state=337,this.match(L.CloseParen)}}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}argument(){let e=new fl(this,this._ctx,this.state);this.enterRule(e,40,L.RULE_argument);try{this.enterOuterAlt(e,1);{switch(this.state=342,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,35,this._ctx)){case 1:this.state=339,this.identifier(),this.state=340,this.match(L.Assign);break}switch(this.state=346,this._errHandler.sync(this),this._input.LA(1)){case 6:case 12:case 13:case 31:case 32:case 33:case 46:case 51:case 54:case 55:case 56:case 57:case 58:this.state=344,this.singleExpression(0);break;case 4:this.state=345,this.brackethesized();break;default:throw new di(this)}}}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}ifStatement(){let e=new bp(this,this._ctx,this.state);this.enterRule(e,42,L.RULE_ifStatement);let n;try{let r;this.enterOuterAlt(e,1);{for(this.state=348,this.match(L.If),this.state=349,this.singleExpression(0),this.state=350,this.blockLine(),this.state=358,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,37,this._ctx);r!==2&&r!==Dr.INVALID_ALT_NUMBER;)r===1&&(this.state=351,this.match(L.Else),this.state=352,this.match(L.If),this.state=353,this.singleExpression(0),this.state=354,this.blockLine()),this.state=360,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,37,this._ctx);this.state=363,this._errHandler.sync(this),n=this._input.LA(1),n===48&&(this.state=361,this.match(L.Else),this.state=362,this.blockLine())}}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}forStatement(){let e=new su(this,this._ctx,this.state);this.enterRule(e,44,L.RULE_forStatement);let n;try{switch(this.state=397,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,43,this._ctx)){case 1:e=new N_(this,e),this.enterOuterAlt(e,1);{switch(this.state=365,this.match(L.For),this.state=367,this._errHandler.sync(this),n=this._input.LA(1),(n===38||n===40)&&(this.state=366,this.varModifier()),this.state=370,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,40,this._ctx)){case 1:this.state=369,this.typeGather();break}this.state=372,this.identifier(),this.state=373,this.match(L.Assign),this.state=374,this.singleExpression(0),this.state=375,this.match(L.To),this.state=376,this.singleExpression(0),this.state=379,this._errHandler.sync(this),n=this._input.LA(1),n===50&&(this.state=377,this.match(L.By),this.state=378,this.singleExpression(0)),this.state=381,this.blockLine()}break;case 2:e=new I_(this,e),this.enterOuterAlt(e,2);{switch(this.state=383,this.match(L.For),this.state=391,this._errHandler.sync(this),this._input.LA(1)){case 51:case 54:case 55:case 58:this.state=384,this.identifier();break;case 4:this.state=385,this.match(L.OpenBracket),this.state=386,this.identifier(),this.state=387,this.match(L.Comma),this.state=388,this.identifier(),this.state=389,this.match(L.CloseBracket);break;default:throw new di(this)}this.state=393,this.match(L.In),this.state=394,this.singleExpression(0),this.state=395,this.blockLine()}break}}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}switchStatement(){let e=new vp(this,this._ctx,this.state);this.enterRule(e,46,L.RULE_switchStatement);let n;try{this.enterOuterAlt(e,1);{switch(this.state=399,this.match(L.Switch),this.state=401,this._errHandler.sync(this),n=this._input.LA(1),(!(n&-32)&&1<<n&2147496e3||!(n-32&-32)&&1<<n-32&130564099)&&(this.state=400,this.singleExpression(0)),this.state=403,this.match(L.NEWLINE),this.state=404,this.match(L.INDENT),this.state=417,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,47,this._ctx)){case 1:{this.state=406,this._errHandler.sync(this),n=this._input.LA(1);do this.state=405,this.caseClause(),this.state=408,this._errHandler.sync(this),n=this._input.LA(1);while(!(n&-32)&&1<<n&2147496e3||!(n-32&-32)&&1<<n-32&130564099)}break;case 2:{for(this.state=413,this._errHandler.sync(this),n=this._input.LA(1);!(n&-32)&&1<<n&2147496e3||!(n-32&-32)&&1<<n-32&130564099;)this.state=410,this.caseClause(),this.state=415,this._errHandler.sync(this),n=this._input.LA(1);this.state=416,this.defaultCaluse()}break}this.state=419,this.match(L.DEDENT)}}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}caseClause(){let e=new hl(this,this._ctx,this.state);this.enterRule(e,48,L.RULE_caseClause);try{this.enterOuterAlt(e,1),this.state=421,this.singleExpression(0),this.state=422,this.match(L.ARROW),this.state=423,this.block()}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}defaultCaluse(){let e=new Ep(this,this._ctx,this.state);this.enterRule(e,50,L.RULE_defaultCaluse);try{this.enterOuterAlt(e,1),this.state=425,this.match(L.ARROW),this.state=426,this.block()}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}whileStatement(){let e=new Sp(this,this._ctx,this.state);this.enterRule(e,52,L.RULE_whileStatement);try{this.enterOuterAlt(e,1),this.state=428,this.match(L.While),this.state=429,this.singleExpression(0),this.state=430,this.blockLine()}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}importStmt(){let e=new Tp(this,this._ctx,this.state);this.enterRule(e,54,L.RULE_importStmt);let n;try{let r;this.enterOuterAlt(e,1);{for(this.state=432,this.importElement(),this.state=437,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,48,this._ctx);r!==2&&r!==Dr.INVALID_ALT_NUMBER;)r===1&&(this.state=433,this.match(L.Comma),this.state=434,this.importElement()),this.state=439,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,48,this._ctx);this.state=441,this._errHandler.sync(this),n=this._input.LA(1),n===8&&(this.state=440,this.match(L.Comma)),this.state=443,this.match(L.NEWLINE)}}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}importElement(){let e=new pl(this,this._ctx,this.state);this.enterRule(e,56,L.RULE_importElement);let n;try{this.enterOuterAlt(e,1),this.state=445,this.match(L.Import),this.state=446,this.identifier(),this.state=447,this.match(L.Divide),this.state=448,this.identifier(),this.state=449,this.match(L.Divide),this.state=450,this.match(L.IntegerLiteral),this.state=453,this._errHandler.sync(this),n=this._input.LA(1),n===53&&(this.state=451,this.match(L.As),this.state=452,this.identifier())}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}literal(){let e=new Ap(this,this._ctx,this.state);this.enterRule(e,58,L.RULE_literal);let n;try{this.enterOuterAlt(e,1),this.state=455,n=this._input.LA(1),!(n-31&-32)&&1<<n-31&100663303?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this)}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}methodStmt(){let e=new uu(this,this._ctx,this.state);this.enterRule(e,60,L.RULE_methodStmt);try{let n;for(this.enterOuterAlt(e,1),this.state=457,this.methodElement(),this.state=462,this._errHandler.sync(this),n=this._interp.adaptivePredict(this._input,51,this._ctx);n!==2&&n!==Dr.INVALID_ALT_NUMBER;)n===1&&(this.state=458,this.match(L.Point),this.state=459,this.methodElement()),this.state=464,this._errHandler.sync(this),n=this._interp.adaptivePredict(this._input,51,this._ctx)}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}methodElement(){let e=new as(this,this._ctx,this.state);this.enterRule(e,62,L.RULE_methodElement);try{this.enterOuterAlt(e,1),this.state=465,this.methodName(),this.state=466,this.arguments()}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}methodName(){let e=new xp(this,this._ctx,this.state);this.enterRule(e,64,L.RULE_methodName);let n;try{let r;this.enterOuterAlt(e,1);{switch(this.state=481,this._errHandler.sync(this),this._input.LA(1)){case 51:case 54:case 55:case 58:for(this.state=473,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,52,this._ctx);r!==2&&r!==Dr.INVALID_ALT_NUMBER;)r===1&&(this.state=468,this.identifier(),this.state=469,this.match(L.Point)),this.state=475,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,52,this._ctx);break;case 6:this.state=476,this.match(L.OpenParen),this.state=477,this.singleExpression(0),this.state=478,this.match(L.CloseParen),this.state=479,this.match(L.Point);break;default:throw new di(this)}this.state=483,this.identifier(),this.state=492,this._errHandler.sync(this),n=this._input.LA(1),n===18&&(this.state=484,this.match(L.LessThan),this.state=485,this.typeName(),this.state=488,this._errHandler.sync(this),n=this._input.LA(1),n===8&&(this.state=486,this.match(L.Comma),this.state=487,this.typeName()),this.state=490,this.match(L.MoreThan))}}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}arrowFunction(){let e=new Cp(this,this._ctx,this.state);this.enterRule(e,66,L.RULE_arrowFunction);let n;try{this.enterOuterAlt(e,1),this.state=495,this._errHandler.sync(this),n=this._input.LA(1),n===36&&(this.state=494,this.match(L.Export)),this.state=497,this.identifier(),this.state=498,this.arrowFunctionParameters(),this.state=499,this.match(L.ARROW),this.state=500,this.block()}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}arrowFunctionParameters(){let e=new Op(this,this._ctx,this.state);this.enterRule(e,68,L.RULE_arrowFunctionParameters);let n;try{this.enterOuterAlt(e,1),this.state=502,this.match(L.OpenParen),this.state=504,this._errHandler.sync(this),n=this._input.LA(1),!(n-51&-32)&&1<<n-51&153&&(this.state=503,this.formalParameterList()),this.state=506,this.match(L.CloseParen)}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}formalParameterList(){let e=new dl(this,this._ctx,this.state);this.enterRule(e,70,L.RULE_formalParameterList);let n;try{for(this.enterOuterAlt(e,1),this.state=508,this.formalParameterArg(),this.state=513,this._errHandler.sync(this),n=this._input.LA(1);n===8;)this.state=509,this.match(L.Comma),this.state=510,this.formalParameterArg(),this.state=515,this._errHandler.sync(this),n=this._input.LA(1)}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}formalParameterArg(){let e=new ml(this,this._ctx,this.state);this.enterRule(e,72,L.RULE_formalParameterArg);let n;try{this.enterOuterAlt(e,1);{switch(this.state=517,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,59,this._ctx)){case 1:this.state=516,this.typeGather();break}this.state=519,this.identifier(),this.state=522,this._errHandler.sync(this),n=this._input.LA(1),n===9&&(this.state=520,this.match(L.Assign),this.state=521,this.singleExpression(0))}}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}arrowMethod(){let e=new Dp(this,this._ctx,this.state);this.enterRule(e,74,L.RULE_arrowMethod);let n;try{this.enterOuterAlt(e,1),this.state=525,this._errHandler.sync(this),n=this._input.LA(1),n===36&&(this.state=524,this.match(L.Export)),this.state=527,this.match(L.Method),this.state=528,this.identifier(),this.state=529,this.arrowMethodParameters(),this.state=530,this.match(L.ARROW),this.state=531,this.block()}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}arrowMethodParameters(){let e=new kp(this,this._ctx,this.state);this.enterRule(e,76,L.RULE_arrowMethodParameters);let n;try{this.enterOuterAlt(e,1),this.state=533,this.match(L.OpenParen),this.state=534,this.typeGather(),this.state=535,this.identifier(),this.state=538,this._errHandler.sync(this),n=this._input.LA(1),n===9&&(this.state=536,this.match(L.Assign),this.state=537,this.singleExpression(0)),this.state=542,this._errHandler.sync(this),n=this._input.LA(1),n===8&&(this.state=540,this.match(L.Comma),this.state=541,this.formalParameterList()),this.state=544,this.match(L.CloseParen)}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}typeStatement(){let e=new Rp(this,this._ctx,this.state);this.enterRule(e,78,L.RULE_typeStatement);let n;try{this.enterOuterAlt(e,1);{this.state=547,this._errHandler.sync(this),n=this._input.LA(1),n===36&&(this.state=546,this.match(L.Export)),this.state=549,this.match(L.Type),this.state=550,this.identifier(),this.state=551,this.match(L.NEWLINE),this.state=552,this.match(L.INDENT),this.state=554,this._errHandler.sync(this),n=this._input.LA(1);do this.state=553,this.typeElement(),this.state=556,this._errHandler.sync(this),n=this._input.LA(1);while(!(n-40&-32)&&1<<n-40&313345);this.state=558,this.match(L.DEDENT)}}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}typeElement(){let e=new _l(this,this._ctx,this.state);this.enterRule(e,80,L.RULE_typeElement);let n;try{this.enterOuterAlt(e,1);{switch(this.state=561,this._errHandler.sync(this),n=this._input.LA(1),n===40&&(this.state=560,this.match(L.Varip)),this.state=564,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,67,this._ctx)){case 1:this.state=563,this.typeGather();break}this.state=566,this.identifier(),this.state=569,this._errHandler.sync(this),n=this._input.LA(1),n===9&&(this.state=567,this.match(L.Assign),this.state=568,this.singleExpression(0)),this.state=571,this.match(L.NEWLINE)}}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}assignmentOperator(){let e=new yl(this,this._ctx,this.state);this.enterRule(e,82,L.RULE_assignmentOperator);let n;try{this.enterOuterAlt(e,1),this.state=573,n=this._input.LA(1),!(n&-32)&&1<<n&1593835520?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this)}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}typeMap(){let e=new gl(this,this._ctx,this.state);this.enterRule(e,84,L.RULE_typeMap);try{this.enterOuterAlt(e,1),this.state=575,this.match(L.Map),this.state=576,this.match(L.LessThan),this.state=577,this.typeName(),this.state=578,this.match(L.Comma),this.state=579,this.typeName(),this.state=580,this.match(L.MoreThan)}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}typeSeries(){let e=new wp(this,this._ctx,this.state);this.enterRule(e,86,L.RULE_typeSeries);try{switch(this.enterOuterAlt(e,1),this.state=582,this.typeName(),this.state=586,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,69,this._ctx)){case 1:this.state=583,this.typeName();break;case 2:this.state=584,this.typeArray();break;case 3:this.state=585,this.typeMap();break}}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}typeArray(){let e=new bl(this,this._ctx,this.state);this.enterRule(e,88,L.RULE_typeArray);try{switch(this.state=597,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,70,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=588,this.typeName(),this.state=589,this.match(L.LessThan),this.state=590,this.typeName(),this.state=591,this.match(L.MoreThan);break;case 2:this.enterOuterAlt(e,2),this.state=593,this.typeName(),this.state=594,this.match(L.OpenBracket),this.state=595,this.match(L.CloseBracket);break}}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}typeGather(){let e=new $o(this,this._ctx,this.state);this.enterRule(e,90,L.RULE_typeGather);try{switch(this.state=603,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,71,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=599,this.typeName();break;case 2:this.enterOuterAlt(e,2),this.state=600,this.typeArray();break;case 3:this.enterOuterAlt(e,3),this.state=601,this.typeMap();break;case 4:this.enterOuterAlt(e,4),this.state=602,this.typeSeries();break}}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}identifier(){let e=new yn(this,this._ctx,this.state);this.enterRule(e,92,L.RULE_identifier);let n;try{this.enterOuterAlt(e,1),this.state=605,n=this._input.LA(1),!(n-51&-32)&&1<<n-51&153?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this)}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}typeName(){let e=new mi(this,this._ctx,this.state);this.enterRule(e,94,L.RULE_typeName);let n;try{this.enterOuterAlt(e,1),this.state=607,this.identifier(),this.state=610,this._errHandler.sync(this),n=this._input.LA(1),n===3&&(this.state=608,this.match(L.Point),this.state=609,this.identifier())}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}name(){let e=new cu(this,this._ctx,this.state);this.enterRule(e,96,L.RULE_name);try{let n;switch(this.state=633,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,76,this._ctx)){case 1:this.enterOuterAlt(e,1);{for(this.state=620,this._errHandler.sync(this),n=this._interp.adaptivePredict(this._input,74,this._ctx);n!==2&&n!==Dr.INVALID_ALT_NUMBER;){if(n===1){switch(this.state=614,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,73,this._ctx)){case 1:this.state=612,this.identifier();break;case 2:this.state=613,this.methodElement();break}this.state=616,this.match(L.Point)}this.state=622,this._errHandler.sync(this),n=this._interp.adaptivePredict(this._input,74,this._ctx)}this.state=623,this.identifier()}break;case 2:this.enterOuterAlt(e,2);{this.state=624,this.match(L.OpenParen),this.state=625,this.singleExpression(0),this.state=626,this.match(L.CloseParen),this.state=629,this._errHandler.sync(this),n=1;do{switch(n){case 1:this.state=627,this.match(L.Point),this.state=628,this.identifier();break;default:throw new di(this)}this.state=631,this._errHandler.sync(this),n=this._interp.adaptivePredict(this._input,75,this._ctx)}while(n!==2&&n!==Dr.INVALID_ALT_NUMBER)}break}}catch(n){if(n instanceof Je)e.exception=n,this._errHandler.reportError(this,n),this._errHandler.recover(this,n);else throw n}finally{this.exitRule()}return e}enumStatement(){let e=new Np(this,this._ctx,this.state);this.enterRule(e,98,L.RULE_enumStatement);let n;try{this.enterOuterAlt(e,1);{this.state=636,this._errHandler.sync(this),n=this._input.LA(1),n===36&&(this.state=635,this.match(L.Export)),this.state=638,this.match(L.Enum),this.state=639,this.identifier(),this.state=640,this.match(L.NEWLINE),this.state=641,this.match(L.INDENT),this.state=643,this._errHandler.sync(this),n=this._input.LA(1);do this.state=642,this.enumElement(),this.state=645,this._errHandler.sync(this),n=this._input.LA(1);while(!(n-51&-32)&&1<<n-51&153);this.state=647,this.match(L.DEDENT)}}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}enumElement(){let e=new vl(this,this._ctx,this.state);this.enterRule(e,100,L.RULE_enumElement);let n;try{this.enterOuterAlt(e,1),this.state=649,this.identifier(),this.state=652,this._errHandler.sync(this),n=this._input.LA(1),n===9&&(this.state=650,this.match(L.Assign),this.state=651,this.match(L.StringLiteral)),this.state=654,this.match(L.NEWLINE)}catch(r){if(r instanceof Je)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}sempred(e,n,r){switch(n){case 17:return this.singleExpression_sempred(e,r)}return!0}singleExpression_sempred(e,n){switch(n){case 0:return this.precpred(this._ctx,10);case 1:return this.precpred(this._ctx,9);case 2:return this.precpred(this._ctx,8);case 3:return this.precpred(this._ctx,7);case 4:return this.precpred(this._ctx,6);case 5:return this.precpred(this._ctx,5);case 6:return this.precpred(this._ctx,4);case 7:return this.precpred(this._ctx,13)}return!0}static get _ATN(){return L.__ATN||(L.__ATN=new lp().deserialize(L._serializedATN)),L.__ATN}};k(L,"INDENT",1),k(L,"DEDENT",2),k(L,"Point",3),k(L,"OpenBracket",4),k(L,"CloseBracket",5),k(L,"OpenParen",6),k(L,"CloseParen",7),k(L,"Comma",8),k(L,"Assign",9),k(L,"QuestionMark",10),k(L,"Colon",11),k(L,"Plus",12),k(L,"Minus",13),k(L,"Multiply",14),k(L,"Divide",15),k(L,"Modulus",16),k(L,"Hashtag",17),k(L,"LessThan",18),k(L,"MoreThan",19),k(L,"LessThanEquals",20),k(L,"GreaterThanEquals",21),k(L,"Equals_",22),k(L,"NotEquals",23),k(L,"MultiplyAssign",24),k(L,"DivideAssign",25),k(L,"ModulusAssign",26),k(L,"PlusAssign",27),k(L,"MinusAssign",28),k(L,"ARROW",29),k(L,"ColonEquals",30),k(L,"BooleanLiteral",31),k(L,"IntegerLiteral",32),k(L,"DecimalLiteral",33),k(L,"Break",34),k(L,"And",35),k(L,"Export",36),k(L,"For",37),k(L,"Var",38),k(L,"Continue",39),k(L,"Varip",40),k(L,"Switch",41),k(L,"While",42),k(L,"If",43),k(L,"In",44),k(L,"Or",45),k(L,"Not",46),k(L,"Method",47),k(L,"Else",48),k(L,"To",49),k(L,"By",50),k(L,"Type",51),k(L,"Import",52),k(L,"As",53),k(L,"Enum",54),k(L,"Map",55),k(L,"ColorLiteral",56),k(L,"StringLiteral",57),k(L,"Identifier",58),k(L,"HIDDEN_",59),k(L,"COMMENT_",60),k(L,"NEWLINE",61),k(L,"EOF",pp.EOF),k(L,"RULE_program",0),k(L,"RULE_globalStmt",1),k(L,"RULE_blockStmt",2),k(L,"RULE_stmt",3),k(L,"RULE_simpleStmt",4),k(L,"RULE_flowStmt",5),k(L,"RULE_block",6),k(L,"RULE_blockLine",7),k(L,"RULE_variableDeclarationStmt",8),k(L,"RULE_variableDeclarationList",9),k(L,"RULE_varModifier",10),k(L,"RULE_blockSequence",11),k(L,"RULE_expressionSequence",12),k(L,"RULE_expressionBlockSequence",13),k(L,"RULE_varBlockStmt",14),k(L,"RULE_varArrayDeclaration",15),k(L,"RULE_blockExpression",16),k(L,"RULE_singleExpression",17),k(L,"RULE_brackethesized",18),k(L,"RULE_arguments",19),k(L,"RULE_argument",20),k(L,"RULE_ifStatement",21),k(L,"RULE_forStatement",22),k(L,"RULE_switchStatement",23),k(L,"RULE_caseClause",24),k(L,"RULE_defaultCaluse",25),k(L,"RULE_whileStatement",26),k(L,"RULE_importStmt",27),k(L,"RULE_importElement",28),k(L,"RULE_literal",29),k(L,"RULE_methodStmt",30),k(L,"RULE_methodElement",31),k(L,"RULE_methodName",32),k(L,"RULE_arrowFunction",33),k(L,"RULE_arrowFunctionParameters",34),k(L,"RULE_formalParameterList",35),k(L,"RULE_formalParameterArg",36),k(L,"RULE_arrowMethod",37),k(L,"RULE_arrowMethodParameters",38),k(L,"RULE_typeStatement",39),k(L,"RULE_typeElement",40),k(L,"RULE_assignmentOperator",41),k(L,"RULE_typeMap",42),k(L,"RULE_typeSeries",43),k(L,"RULE_typeArray",44),k(L,"RULE_typeGather",45),k(L,"RULE_identifier",46),k(L,"RULE_typeName",47),k(L,"RULE_name",48),k(L,"RULE_enumStatement",49),k(L,"RULE_enumElement",50),k(L,"literalNames",[null,null,null,"'.'","'['","']'","'('","')'","','","'='","'?'","':'","'+'","'-'","'*'","'/'","'%'","'#'","'<'","'>'","'<='","'>='","'=='","'!='","'*='","'/='","'%='","'+='","'-='","'=>'","':='",null,null,null,"'break'","'and'","'export'","'for'","'var'","'continue'","'varip'","'switch'","'while'","'if'","'in'","'or'","'not'","'method'","'else'","'to'","'by'","'type'","'import'","'as'","'enum'","'map'"]),k(L,"symbolicNames",[null,"INDENT","DEDENT","Point","OpenBracket","CloseBracket","OpenParen","CloseParen","Comma","Assign","QuestionMark","Colon","Plus","Minus","Multiply","Divide","Modulus","Hashtag","LessThan","MoreThan","LessThanEquals","GreaterThanEquals","Equals_","NotEquals","MultiplyAssign","DivideAssign","ModulusAssign","PlusAssign","MinusAssign","ARROW","ColonEquals","BooleanLiteral","IntegerLiteral","DecimalLiteral","Break","And","Export","For","Var","Continue","Varip","Switch","While","If","In","Or","Not","Method","Else","To","By","Type","Import","As","Enum","Map","ColorLiteral","StringLiteral","Identifier","HIDDEN_","COMMENT_","NEWLINE"]),k(L,"ruleNames",["program","globalStmt","blockStmt","stmt","simpleStmt","flowStmt","block","blockLine","variableDeclarationStmt","variableDeclarationList","varModifier","blockSequence","expressionSequence","expressionBlockSequence","varBlockStmt","varArrayDeclaration","blockExpression","singleExpression","brackethesized","arguments","argument","ifStatement","forStatement","switchStatement","caseClause","defaultCaluse","whileStatement","importStmt","importElement","literal","methodStmt","methodElement","methodName","arrowFunction","arrowFunctionParameters","formalParameterList","formalParameterArg","arrowMethod","arrowMethodParameters","typeStatement","typeElement","assignmentOperator","typeMap","typeSeries","typeArray","typeGather","identifier","typeName","name","enumStatement","enumElement"]),k(L,"_serializedATN",[4,1,61,657,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,1,0,1,0,5,0,105,8,0,10,0,12,0,108,9,0,1,0,1,0,1,1,1,1,3,1,114,8,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,124,8,1,1,2,1,2,1,2,5,2,129,8,2,10,2,12,2,132,9,2,1,2,1,2,3,2,136,8,2,1,3,1,3,3,3,140,8,3,1,3,1,3,1,3,3,3,145,8,3,1,4,1,4,1,4,1,4,3,4,151,8,4,1,5,1,5,1,6,1,6,3,6,157,8,6,1,6,1,6,1,6,3,6,162,8,6,1,7,1,7,1,7,4,7,167,8,7,11,7,12,7,168,1,7,1,7,1,8,1,8,3,8,175,8,8,1,8,1,8,1,8,3,8,180,8,8,5,8,182,8,8,10,8,12,8,185,9,8,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9,3,9,195,8,9,1,10,1,10,1,11,1,11,3,11,201,8,11,1,11,1,11,1,11,3,11,206,8,11,5,11,208,8,11,10,11,12,11,211,9,11,1,12,1,12,1,12,5,12,216,8,12,10,12,12,12,219,9,12,1,13,1,13,3,13,223,8,13,1,13,1,13,5,13,227,8,13,10,13,12,13,230,9,13,1,13,1,13,3,13,234,8,13,1,14,1,14,1,14,1,14,1,14,1,14,3,14,242,8,14,1,14,1,14,1,15,3,15,247,8,15,1,15,3,15,250,8,15,1,15,1,15,1,15,1,15,1,15,5,15,257,8,15,10,15,12,15,260,9,15,1,15,1,15,3,15,264,8,15,1,16,1,16,1,16,1,16,3,16,270,8,16,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,3,17,284,8,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,5,17,315,8,17,10,17,12,17,318,9,17,1,18,1,18,1,18,1,18,1,19,1,19,1,19,1,19,5,19,328,8,19,10,19,12,19,331,9,19,1,19,3,19,334,8,19,3,19,336,8,19,1,19,1,19,1,20,1,20,1,20,3,20,343,8,20,1,20,1,20,3,20,347,8,20,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,5,21,357,8,21,10,21,12,21,360,9,21,1,21,1,21,3,21,364,8,21,1,22,1,22,3,22,368,8,22,1,22,3,22,371,8,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,3,22,380,8,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,3,22,392,8,22,1,22,1,22,1,22,1,22,3,22,398,8,22,1,23,1,23,3,23,402,8,23,1,23,1,23,1,23,4,23,407,8,23,11,23,12,23,408,1,23,5,23,412,8,23,10,23,12,23,415,9,23,1,23,3,23,418,8,23,1,23,1,23,1,24,1,24,1,24,1,24,1,25,1,25,1,25,1,26,1,26,1,26,1,26,1,27,1,27,1,27,5,27,436,8,27,10,27,12,27,439,9,27,1,27,3,27,442,8,27,1,27,1,27,1,28,1,28,1,28,1,28,1,28,1,28,1,28,1,28,3,28,454,8,28,1,29,1,29,1,30,1,30,1,30,5,30,461,8,30,10,30,12,30,464,9,30,1,31,1,31,1,31,1,32,1,32,1,32,5,32,472,8,32,10,32,12,32,475,9,32,1,32,1,32,1,32,1,32,1,32,3,32,482,8,32,1,32,1,32,1,32,1,32,1,32,3,32,489,8,32,1,32,1,32,3,32,493,8,32,1,33,3,33,496,8,33,1,33,1,33,1,33,1,33,1,33,1,34,1,34,3,34,505,8,34,1,34,1,34,1,35,1,35,1,35,5,35,512,8,35,10,35,12,35,515,9,35,1,36,3,36,518,8,36,1,36,1,36,1,36,3,36,523,8,36,1,37,3,37,526,8,37,1,37,1,37,1,37,1,37,1,37,1,37,1,38,1,38,1,38,1,38,1,38,3,38,539,8,38,1,38,1,38,3,38,543,8,38,1,38,1,38,1,39,3,39,548,8,39,1,39,1,39,1,39,1,39,1,39,4,39,555,8,39,11,39,12,39,556,1,39,1,39,1,40,3,40,562,8,40,1,40,3,40,565,8,40,1,40,1,40,1,40,3,40,570,8,40,1,40,1,40,1,41,1,41,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,43,1,43,1,43,1,43,3,43,587,8,43,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,3,44,598,8,44,1,45,1,45,1,45,1,45,3,45,604,8,45,1,46,1,46,1,47,1,47,1,47,3,47,611,8,47,1,48,1,48,3,48,615,8,48,1,48,1,48,5,48,619,8,48,10,48,12,48,622,9,48,1,48,1,48,1,48,1,48,1,48,1,48,4,48,630,8,48,11,48,12,48,631,3,48,634,8,48,1,49,3,49,637,8,49,1,49,1,49,1,49,1,49,1,49,4,49,644,8,49,11,49,12,49,645,1,49,1,49,1,50,1,50,1,50,3,50,653,8,50,1,50,1,50,1,50,0,1,34,51,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,0,9,2,0,34,34,39,39,2,0,38,38,40,40,1,0,12,13,1,0,14,16,1,0,18,21,1,0,22,23,2,0,31,33,56,57,2,0,24,28,30,30,3,0,51,51,54,55,58,58,707,0,106,1,0,0,0,2,123,1,0,0,0,4,130,1,0,0,0,6,144,1,0,0,0,8,150,1,0,0,0,10,152,1,0,0,0,12,161,1,0,0,0,14,163,1,0,0,0,16,174,1,0,0,0,18,194,1,0,0,0,20,196,1,0,0,0,22,200,1,0,0,0,24,212,1,0,0,0,26,228,1,0,0,0,28,241,1,0,0,0,30,263,1,0,0,0,32,269,1,0,0,0,34,283,1,0,0,0,36,319,1,0,0,0,38,323,1,0,0,0,40,342,1,0,0,0,42,348,1,0,0,0,44,397,1,0,0,0,46,399,1,0,0,0,48,421,1,0,0,0,50,425,1,0,0,0,52,428,1,0,0,0,54,432,1,0,0,0,56,445,1,0,0,0,58,455,1,0,0,0,60,457,1,0,0,0,62,465,1,0,0,0,64,481,1,0,0,0,66,495,1,0,0,0,68,502,1,0,0,0,70,508,1,0,0,0,72,517,1,0,0,0,74,525,1,0,0,0,76,533,1,0,0,0,78,547,1,0,0,0,80,561,1,0,0,0,82,573,1,0,0,0,84,575,1,0,0,0,86,582,1,0,0,0,88,597,1,0,0,0,90,603,1,0,0,0,92,605,1,0,0,0,94,607,1,0,0,0,96,633,1,0,0,0,98,636,1,0,0,0,100,649,1,0,0,0,102,105,5,61,0,0,103,105,3,2,1,0,104,102,1,0,0,0,104,103,1,0,0,0,105,108,1,0,0,0,106,104,1,0,0,0,106,107,1,0,0,0,107,109,1,0,0,0,108,106,1,0,0,0,109,110,5,0,0,1,110,1,1,0,0,0,111,113,3,16,8,0,112,114,5,8,0,0,113,112,1,0,0,0,113,114,1,0,0,0,114,115,1,0,0,0,115,116,5,61,0,0,116,124,1,0,0,0,117,124,3,4,2,0,118,124,3,54,27,0,119,124,3,66,33,0,120,124,3,74,37,0,121,124,3,78,39,0,122,124,3,98,49,0,123,111,1,0,0,0,123,117,1,0,0,0,123,118,1,0,0,0,123,119,1,0,0,0,123,120,1,0,0,0,123,121,1,0,0,0,123,122,1,0,0,0,124,3,1,0,0,0,125,126,3,16,8,0,126,127,5,8,0,0,127,129,1,0,0,0,128,125,1,0,0,0,129,132,1,0,0,0,130,128,1,0,0,0,130,131,1,0,0,0,131,135,1,0,0,0,132,130,1,0,0,0,133,136,3,28,14,0,134,136,3,32,16,0,135,133,1,0,0,0,135,134,1,0,0,0,136,5,1,0,0,0,137,139,3,8,4,0,138,140,5,8,0,0,139,138,1,0,0,0,139,140,1,0,0,0,140,141,1,0,0,0,141,142,5,61,0,0,142,145,1,0,0,0,143,145,3,26,13,0,144,137,1,0,0,0,144,143,1,0,0,0,145,7,1,0,0,0,146,151,3,24,12,0,147,151,3,22,11,0,148,151,3,36,18,0,149,151,3,10,5,0,150,146,1,0,0,0,150,147,1,0,0,0,150,148,1,0,0,0,150,149,1,0,0,0,151,9,1,0,0,0,152,153,7,0,0,0,153,11,1,0,0,0,154,156,3,8,4,0,155,157,5,8,0,0,156,155,1,0,0,0,156,157,1,0,0,0,157,158,1,0,0,0,158,159,5,61,0,0,159,162,1,0,0,0,160,162,3,14,7,0,161,154,1,0,0,0,161,160,1,0,0,0,162,13,1,0,0,0,163,164,5,61,0,0,164,166,5,1,0,0,165,167,3,6,3,0,166,165,1,0,0,0,167,168,1,0,0,0,168,166,1,0,0,0,168,169,1,0,0,0,169,170,1,0,0,0,170,171,5,2,0,0,171,15,1,0,0,0,172,175,3,60,30,0,173,175,3,18,9,0,174,172,1,0,0,0,174,173,1,0,0,0,175,183,1,0,0,0,176,179,5,8,0,0,177,180,3,60,30,0,178,180,3,18,9,0,179,177,1,0,0,0,179,178,1,0,0,0,180,182,1,0,0,0,181,176,1,0,0,0,182,185,1,0,0,0,183,181,1,0,0,0,183,184,1,0,0,0,184,17,1,0,0,0,185,183,1,0,0,0,186,187,3,30,15,0,187,188,5,9,0,0,188,189,3,34,17,0,189,195,1,0,0,0,190,191,3,96,48,0,191,192,3,82,41,0,192,193,3,34,17,0,193,195,1,0,0,0,194,186,1,0,0,0,194,190,1,0,0,0,195,19,1,0,0,0,196,197,7,1,0,0,197,21,1,0,0,0,198,201,3,34,17,0,199,201,3,18,9,0,200,198,1,0,0,0,200,199,1,0,0,0,201,209,1,0,0,0,202,205,5,8,0,0,203,206,3,34,17,0,204,206,3,18,9,0,205,203,1,0,0,0,205,204,1,0,0,0,206,208,1,0,0,0,207,202,1,0,0,0,208,211,1,0,0,0,209,207,1,0,0,0,209,210,1,0,0,0,210,23,1,0,0,0,211,209,1,0,0,0,212,217,3,34,17,0,213,214,5,8,0,0,214,216,3,34,17,0,215,213,1,0,0,0,216,219,1,0,0,0,217,215,1,0,0,0,217,218,1,0,0,0,218,25,1,0,0,0,219,217,1,0,0,0,220,223,3,34,17,0,221,223,3,18,9,0,222,220,1,0,0,0,222,221,1,0,0,0,223,224,1,0,0,0,224,225,5,8,0,0,225,227,1,0,0,0,226,222,1,0,0,0,227,230,1,0,0,0,228,226,1,0,0,0,228,229,1,0,0,0,229,233,1,0,0,0,230,228,1,0,0,0,231,234,3,28,14,0,232,234,3,32,16,0,233,231,1,0,0,0,233,232,1,0,0,0,234,27,1,0,0,0,235,236,3,30,15,0,236,237,5,9,0,0,237,242,1,0,0,0,238,239,3,96,48,0,239,240,3,82,41,0,240,242,1,0,0,0,241,235,1,0,0,0,241,238,1,0,0,0,242,243,1,0,0,0,243,244,3,32,16,0,244,29,1,0,0,0,245,247,3,20,10,0,246,245,1,0,0,0,246,247,1,0,0,0,247,249,1,0,0,0,248,250,3,90,45,0,249,248,1,0,0,0,249,250,1,0,0,0,250,251,1,0,0,0,251,264,3,92,46,0,252,253,5,4,0,0,253,258,3,92,46,0,254,255,5,8,0,0,255,257,3,92,46,0,256,254,1,0,0,0,257,260,1,0,0,0,258,256,1,0,0,0,258,259,1,0,0,0,259,261,1,0,0,0,260,258,1,0,0,0,261,262,5,5,0,0,262,264,1,0,0,0,263,246,1,0,0,0,263,252,1,0,0,0,264,31,1,0,0,0,265,270,3,42,21,0,266,270,3,44,22,0,267,270,3,52,26,0,268,270,3,46,23,0,269,265,1,0,0,0,269,266,1,0,0,0,269,267,1,0,0,0,269,268,1,0,0,0,270,33,1,0,0,0,271,272,6,17,-1,0,272,284,3,60,30,0,273,274,7,2,0,0,274,284,3,34,17,12,275,276,5,46,0,0,276,284,3,34,17,11,277,284,3,96,48,0,278,284,3,58,29,0,279,280,5,6,0,0,280,281,3,34,17,0,281,282,5,7,0,0,282,284,1,0,0,0,283,271,1,0,0,0,283,273,1,0,0,0,283,275,1,0,0,0,283,277,1,0,0,0,283,278,1,0,0,0,283,279,1,0,0,0,284,316,1,0,0,0,285,286,10,10,0,0,286,287,7,3,0,0,287,315,3,34,17,11,288,289,10,9,0,0,289,290,7,2,0,0,290,315,3,34,17,10,291,292,10,8,0,0,292,293,7,4,0,0,293,315,3,34,17,9,294,295,10,7,0,0,295,296,7,5,0,0,296,315,3,34,17,8,297,298,10,6,0,0,298,299,5,35,0,0,299,315,3,34,17,7,300,301,10,5,0,0,301,302,5,45,0,0,302,315,3,34,17,6,303,304,10,4,0,0,304,305,5,10,0,0,305,306,3,34,17,0,306,307,5,11,0,0,307,308,3,34,17,4,308,315,1,0,0,0,309,310,10,13,0,0,310,311,5,4,0,0,311,312,3,34,17,0,312,313,5,5,0,0,313,315,1,0,0,0,314,285,1,0,0,0,314,288,1,0,0,0,314,291,1,0,0,0,314,294,1,0,0,0,314,297,1,0,0,0,314,300,1,0,0,0,314,303,1,0,0,0,314,309,1,0,0,0,315,318,1,0,0,0,316,314,1,0,0,0,316,317,1,0,0,0,317,35,1,0,0,0,318,316,1,0,0,0,319,320,5,4,0,0,320,321,3,24,12,0,321,322,5,5,0,0,322,37,1,0,0,0,323,335,5,6,0,0,324,329,3,40,20,0,325,326,5,8,0,0,326,328,3,40,20,0,327,325,1,0,0,0,328,331,1,0,0,0,329,327,1,0,0,0,329,330,1,0,0,0,330,333,1,0,0,0,331,329,1,0,0,0,332,334,5,8,0,0,333,332,1,0,0,0,333,334,1,0,0,0,334,336,1,0,0,0,335,324,1,0,0,0,335,336,1,0,0,0,336,337,1,0,0,0,337,338,5,7,0,0,338,39,1,0,0,0,339,340,3,92,46,0,340,341,5,9,0,0,341,343,1,0,0,0,342,339,1,0,0,0,342,343,1,0,0,0,343,346,1,0,0,0,344,347,3,34,17,0,345,347,3,36,18,0,346,344,1,0,0,0,346,345,1,0,0,0,347,41,1,0,0,0,348,349,5,43,0,0,349,350,3,34,17,0,350,358,3,14,7,0,351,352,5,48,0,0,352,353,5,43,0,0,353,354,3,34,17,0,354,355,3,14,7,0,355,357,1,0,0,0,356,351,1,0,0,0,357,360,1,0,0,0,358,356,1,0,0,0,358,359,1,0,0,0,359,363,1,0,0,0,360,358,1,0,0,0,361,362,5,48,0,0,362,364,3,14,7,0,363,361,1,0,0,0,363,364,1,0,0,0,364,43,1,0,0,0,365,367,5,37,0,0,366,368,3,20,10,0,367,366,1,0,0,0,367,368,1,0,0,0,368,370,1,0,0,0,369,371,3,90,45,0,370,369,1,0,0,0,370,371,1,0,0,0,371,372,1,0,0,0,372,373,3,92,46,0,373,374,5,9,0,0,374,375,3,34,17,0,375,376,5,49,0,0,376,379,3,34,17,0,377,378,5,50,0,0,378,380,3,34,17,0,379,377,1,0,0,0,379,380,1,0,0,0,380,381,1,0,0,0,381,382,3,14,7,0,382,398,1,0,0,0,383,391,5,37,0,0,384,392,3,92,46,0,385,386,5,4,0,0,386,387,3,92,46,0,387,388,5,8,0,0,388,389,3,92,46,0,389,390,5,5,0,0,390,392,1,0,0,0,391,384,1,0,0,0,391,385,1,0,0,0,392,393,1,0,0,0,393,394,5,44,0,0,394,395,3,34,17,0,395,396,3,14,7,0,396,398,1,0,0,0,397,365,1,0,0,0,397,383,1,0,0,0,398,45,1,0,0,0,399,401,5,41,0,0,400,402,3,34,17,0,401,400,1,0,0,0,401,402,1,0,0,0,402,403,1,0,0,0,403,404,5,61,0,0,404,417,5,1,0,0,405,407,3,48,24,0,406,405,1,0,0,0,407,408,1,0,0,0,408,406,1,0,0,0,408,409,1,0,0,0,409,418,1,0,0,0,410,412,3,48,24,0,411,410,1,0,0,0,412,415,1,0,0,0,413,411,1,0,0,0,413,414,1,0,0,0,414,416,1,0,0,0,415,413,1,0,0,0,416,418,3,50,25,0,417,406,1,0,0,0,417,413,1,0,0,0,418,419,1,0,0,0,419,420,5,2,0,0,420,47,1,0,0,0,421,422,3,34,17,0,422,423,5,29,0,0,423,424,3,12,6,0,424,49,1,0,0,0,425,426,5,29,0,0,426,427,3,12,6,0,427,51,1,0,0,0,428,429,5,42,0,0,429,430,3,34,17,0,430,431,3,14,7,0,431,53,1,0,0,0,432,437,3,56,28,0,433,434,5,8,0,0,434,436,3,56,28,0,435,433,1,0,0,0,436,439,1,0,0,0,437,435,1,0,0,0,437,438,1,0,0,0,438,441,1,0,0,0,439,437,1,0,0,0,440,442,5,8,0,0,441,440,1,0,0,0,441,442,1,0,0,0,442,443,1,0,0,0,443,444,5,61,0,0,444,55,1,0,0,0,445,446,5,52,0,0,446,447,3,92,46,0,447,448,5,15,0,0,448,449,3,92,46,0,449,450,5,15,0,0,450,453,5,32,0,0,451,452,5,53,0,0,452,454,3,92,46,0,453,451,1,0,0,0,453,454,1,0,0,0,454,57,1,0,0,0,455,456,7,6,0,0,456,59,1,0,0,0,457,462,3,62,31,0,458,459,5,3,0,0,459,461,3,62,31,0,460,458,1,0,0,0,461,464,1,0,0,0,462,460,1,0,0,0,462,463,1,0,0,0,463,61,1,0,0,0,464,462,1,0,0,0,465,466,3,64,32,0,466,467,3,38,19,0,467,63,1,0,0,0,468,469,3,92,46,0,469,470,5,3,0,0,470,472,1,0,0,0,471,468,1,0,0,0,472,475,1,0,0,0,473,471,1,0,0,0,473,474,1,0,0,0,474,482,1,0,0,0,475,473,1,0,0,0,476,477,5,6,0,0,477,478,3,34,17,0,478,479,5,7,0,0,479,480,5,3,0,0,480,482,1,0,0,0,481,473,1,0,0,0,481,476,1,0,0,0,482,483,1,0,0,0,483,492,3,92,46,0,484,485,5,18,0,0,485,488,3,94,47,0,486,487,5,8,0,0,487,489,3,94,47,0,488,486,1,0,0,0,488,489,1,0,0,0,489,490,1,0,0,0,490,491,5,19,0,0,491,493,1,0,0,0,492,484,1,0,0,0,492,493,1,0,0,0,493,65,1,0,0,0,494,496,5,36,0,0,495,494,1,0,0,0,495,496,1,0,0,0,496,497,1,0,0,0,497,498,3,92,46,0,498,499,3,68,34,0,499,500,5,29,0,0,500,501,3,12,6,0,501,67,1,0,0,0,502,504,5,6,0,0,503,505,3,70,35,0,504,503,1,0,0,0,504,505,1,0,0,0,505,506,1,0,0,0,506,507,5,7,0,0,507,69,1,0,0,0,508,513,3,72,36,0,509,510,5,8,0,0,510,512,3,72,36,0,511,509,1,0,0,0,512,515,1,0,0,0,513,511,1,0,0,0,513,514,1,0,0,0,514,71,1,0,0,0,515,513,1,0,0,0,516,518,3,90,45,0,517,516,1,0,0,0,517,518,1,0,0,0,518,519,1,0,0,0,519,522,3,92,46,0,520,521,5,9,0,0,521,523,3,34,17,0,522,520,1,0,0,0,522,523,1,0,0,0,523,73,1,0,0,0,524,526,5,36,0,0,525,524,1,0,0,0,525,526,1,0,0,0,526,527,1,0,0,0,527,528,5,47,0,0,528,529,3,92,46,0,529,530,3,76,38,0,530,531,5,29,0,0,531,532,3,12,6,0,532,75,1,0,0,0,533,534,5,6,0,0,534,535,3,90,45,0,535,538,3,92,46,0,536,537,5,9,0,0,537,539,3,34,17,0,538,536,1,0,0,0,538,539,1,0,0,0,539,542,1,0,0,0,540,541,5,8,0,0,541,543,3,70,35,0,542,540,1,0,0,0,542,543,1,0,0,0,543,544,1,0,0,0,544,545,5,7,0,0,545,77,1,0,0,0,546,548,5,36,0,0,547,546,1,0,0,0,547,548,1,0,0,0,548,549,1,0,0,0,549,550,5,51,0,0,550,551,3,92,46,0,551,552,5,61,0,0,552,554,5,1,0,0,553,555,3,80,40,0,554,553,1,0,0,0,555,556,1,0,0,0,556,554,1,0,0,0,556,557,1,0,0,0,557,558,1,0,0,0,558,559,5,2,0,0,559,79,1,0,0,0,560,562,5,40,0,0,561,560,1,0,0,0,561,562,1,0,0,0,562,564,1,0,0,0,563,565,3,90,45,0,564,563,1,0,0,0,564,565,1,0,0,0,565,566,1,0,0,0,566,569,3,92,46,0,567,568,5,9,0,0,568,570,3,34,17,0,569,567,1,0,0,0,569,570,1,0,0,0,570,571,1,0,0,0,571,572,5,61,0,0,572,81,1,0,0,0,573,574,7,7,0,0,574,83,1,0,0,0,575,576,5,55,0,0,576,577,5,18,0,0,577,578,3,94,47,0,578,579,5,8,0,0,579,580,3,94,47,0,580,581,5,19,0,0,581,85,1,0,0,0,582,586,3,94,47,0,583,587,3,94,47,0,584,587,3,88,44,0,585,587,3,84,42,0,586,583,1,0,0,0,586,584,1,0,0,0,586,585,1,0,0,0,587,87,1,0,0,0,588,589,3,94,47,0,589,590,5,18,0,0,590,591,3,94,47,0,591,592,5,19,0,0,592,598,1,0,0,0,593,594,3,94,47,0,594,595,5,4,0,0,595,596,5,5,0,0,596,598,1,0,0,0,597,588,1,0,0,0,597,593,1,0,0,0,598,89,1,0,0,0,599,604,3,94,47,0,600,604,3,88,44,0,601,604,3,84,42,0,602,604,3,86,43,0,603,599,1,0,0,0,603,600,1,0,0,0,603,601,1,0,0,0,603,602,1,0,0,0,604,91,1,0,0,0,605,606,7,8,0,0,606,93,1,0,0,0,607,610,3,92,46,0,608,609,5,3,0,0,609,611,3,92,46,0,610,608,1,0,0,0,610,611,1,0,0,0,611,95,1,0,0,0,612,615,3,92,46,0,613,615,3,62,31,0,614,612,1,0,0,0,614,613,1,0,0,0,615,616,1,0,0,0,616,617,5,3,0,0,617,619,1,0,0,0,618,614,1,0,0,0,619,622,1,0,0,0,620,618,1,0,0,0,620,621,1,0,0,0,621,623,1,0,0,0,622,620,1,0,0,0,623,634,3,92,46,0,624,625,5,6,0,0,625,626,3,34,17,0,626,629,5,7,0,0,627,628,5,3,0,0,628,630,3,92,46,0,629,627,1,0,0,0,630,631,1,0,0,0,631,629,1,0,0,0,631,632,1,0,0,0,632,634,1,0,0,0,633,620,1,0,0,0,633,624,1,0,0,0,634,97,1,0,0,0,635,637,5,36,0,0,636,635,1,0,0,0,636,637,1,0,0,0,637,638,1,0,0,0,638,639,5,54,0,0,639,640,3,92,46,0,640,641,5,61,0,0,641,643,5,1,0,0,642,644,3,100,50,0,643,642,1,0,0,0,644,645,1,0,0,0,645,643,1,0,0,0,645,646,1,0,0,0,646,647,1,0,0,0,647,648,5,2,0,0,648,99,1,0,0,0,649,652,3,92,46,0,650,651,5,9,0,0,651,653,5,57,0,0,652,650,1,0,0,0,652,653,1,0,0,0,653,654,1,0,0,0,654,655,5,61,0,0,655,101,1,0,0,0,80,104,106,113,123,130,135,139,144,150,156,161,168,174,179,183,194,200,205,209,217,222,228,233,241,246,249,258,263,269,283,314,316,329,333,335,342,346,358,363,367,370,379,391,397,401,408,413,417,437,441,453,462,473,481,488,492,495,504,513,517,522,525,538,542,547,556,561,564,569,586,597,603,610,614,620,631,633,636,645,652]),k(L,"__ATN"),k(L,"DecisionsToDFA",L._ATN.decisionToState.map((e,n)=>new fp(e,n)));let F=L;class p_ extends Ye{constructor(e,n,r){super(n,r),this.parser=e}EOF(){return this.getToken(F.EOF,0)}NEWLINE_list(){return this.getTokens(F.NEWLINE)}NEWLINE(e){return this.getToken(F.NEWLINE,e)}globalStmt_list(){return this.getTypedRuleContexts(il)}globalStmt(e){return this.getTypedRuleContext(il,e)}get ruleIndex(){return F.RULE_program}accept(e){return e.visitProgram?e.visitProgram(this):e.visitChildren(this)}}class il extends Ye{constructor(e,n,r){super(n,r),this.parser=e}variableDeclarationStmt(){return this.getTypedRuleContext(ou,0)}NEWLINE(){return this.getToken(F.NEWLINE,0)}Comma(){return this.getToken(F.Comma,0)}blockStmt(){return this.getTypedRuleContext(dp,0)}importStmt(){return this.getTypedRuleContext(Tp,0)}arrowFunction(){return this.getTypedRuleContext(Cp,0)}arrowMethod(){return this.getTypedRuleContext(Dp,0)}typeStatement(){return this.getTypedRuleContext(Rp,0)}enumStatement(){return this.getTypedRuleContext(Np,0)}get ruleIndex(){return F.RULE_globalStmt}accept(e){return e.visitGlobalStmt?e.visitGlobalStmt(this):e.visitChildren(this)}}class dp extends Ye{constructor(e,n,r){super(n,r),this.parser=e}varBlockStmt(){return this.getTypedRuleContext(cl,0)}blockExpression(){return this.getTypedRuleContext(au,0)}variableDeclarationStmt_list(){return this.getTypedRuleContexts(ou)}variableDeclarationStmt(e){return this.getTypedRuleContext(ou,e)}Comma_list(){return this.getTokens(F.Comma)}Comma(e){return this.getToken(F.Comma,e)}get ruleIndex(){return F.RULE_blockStmt}accept(e){return e.visitBlockStmt?e.visitBlockStmt(this):e.visitChildren(this)}}class ol extends Ye{constructor(e,n,r){super(n,r),this.parser=e}simpleStmt(){return this.getTypedRuleContext(al,0)}NEWLINE(){return this.getToken(F.NEWLINE,0)}Comma(){return this.getToken(F.Comma,0)}expressionBlockSequence(){return this.getTypedRuleContext(yp,0)}get ruleIndex(){return F.RULE_stmt}accept(e){return e.visitStmt?e.visitStmt(this):e.visitChildren(this)}}class al extends Ye{constructor(e,n,r){super(n,r),this.parser=e}expressionSequence(){return this.getTypedRuleContext(ul,0)}blockSequence(){return this.getTypedRuleContext(_p,0)}brackethesized(){return this.getTypedRuleContext(ll,0)}flowStmt(){return this.getTypedRuleContext(mp,0)}get ruleIndex(){return F.RULE_simpleStmt}accept(e){return e.visitSimpleStmt?e.visitSimpleStmt(this):e.visitChildren(this)}}class mp extends Ye{constructor(e,n,r){super(n,r),this.parser=e}Break(){return this.getToken(F.Break,0)}Continue(){return this.getToken(F.Continue,0)}get ruleIndex(){return F.RULE_flowStmt}accept(e){return e.visitFlowStmt?e.visitFlowStmt(this):e.visitChildren(this)}}class is extends Ye{constructor(e,n,r){super(n,r),this.parser=e}simpleStmt(){return this.getTypedRuleContext(al,0)}NEWLINE(){return this.getToken(F.NEWLINE,0)}Comma(){return this.getToken(F.Comma,0)}blockLine(){return this.getTypedRuleContext(mo,0)}get ruleIndex(){return F.RULE_block}accept(e){return e.visitBlock?e.visitBlock(this):e.visitChildren(this)}}class mo extends Ye{constructor(e,n,r){super(n,r),this.parser=e}NEWLINE(){return this.getToken(F.NEWLINE,0)}INDENT(){return this.getToken(F.INDENT,0)}DEDENT(){return this.getToken(F.DEDENT,0)}stmt_list(){return this.getTypedRuleContexts(ol)}stmt(e){return this.getTypedRuleContext(ol,e)}get ruleIndex(){return F.RULE_blockLine}accept(e){return e.visitBlockLine?e.visitBlockLine(this):e.visitChildren(this)}}class ou extends Ye{constructor(e,n,r){super(n,r),this.parser=e}methodStmt_list(){return this.getTypedRuleContexts(uu)}methodStmt(e){return this.getTypedRuleContext(uu,e)}variableDeclarationList_list(){return this.getTypedRuleContexts(Ni)}variableDeclarationList(e){return this.getTypedRuleContext(Ni,e)}Comma_list(){return this.getTokens(F.Comma)}Comma(e){return this.getToken(F.Comma,e)}get ruleIndex(){return F.RULE_variableDeclarationStmt}accept(e){return e.visitVariableDeclarationStmt?e.visitVariableDeclarationStmt(this):e.visitChildren(this)}}class Ni extends Ye{constructor(e,n,r){super(n,r),this.parser=e}get ruleIndex(){return F.RULE_variableDeclarationList}copyFrom(e){super.copyFrom(e)}}class d_ extends Ni{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}name(){return this.getTypedRuleContext(cu,0)}assignmentOperator(){return this.getTypedRuleContext(yl,0)}singleExpression(){return this.getTypedRuleContext(Ve,0)}accept(e){return e.visitAgainAssign?e.visitAgainAssign(this):e.visitChildren(this)}}class m_ extends Ni{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}varArrayDeclaration(){return this.getTypedRuleContext(os,0)}Assign(){return this.getToken(F.Assign,0)}singleExpression(){return this.getTypedRuleContext(Ve,0)}accept(e){return e.visitDeclareAssign?e.visitDeclareAssign(this):e.visitChildren(this)}}class sl extends Ye{constructor(e,n,r){super(n,r),this.parser=e}Var(){return this.getToken(F.Var,0)}Varip(){return this.getToken(F.Varip,0)}get ruleIndex(){return F.RULE_varModifier}accept(e){return e.visitVarModifier?e.visitVarModifier(this):e.visitChildren(this)}}class _p extends Ye{constructor(e,n,r){super(n,r),this.parser=e}singleExpression_list(){return this.getTypedRuleContexts(Ve)}singleExpression(e){return this.getTypedRuleContext(Ve,e)}variableDeclarationList_list(){return this.getTypedRuleContexts(Ni)}variableDeclarationList(e){return this.getTypedRuleContext(Ni,e)}Comma_list(){return this.getTokens(F.Comma)}Comma(e){return this.getToken(F.Comma,e)}get ruleIndex(){return F.RULE_blockSequence}accept(e){return e.visitBlockSequence?e.visitBlockSequence(this):e.visitChildren(this)}}class ul extends Ye{constructor(e,n,r){super(n,r),this.parser=e}singleExpression_list(){return this.getTypedRuleContexts(Ve)}singleExpression(e){return this.getTypedRuleContext(Ve,e)}Comma_list(){return this.getTokens(F.Comma)}Comma(e){return this.getToken(F.Comma,e)}get ruleIndex(){return F.RULE_expressionSequence}accept(e){return e.visitExpressionSequence?e.visitExpressionSequence(this):e.visitChildren(this)}}class yp extends Ye{constructor(e,n,r){super(n,r),this.parser=e}varBlockStmt(){return this.getTypedRuleContext(cl,0)}blockExpression(){return this.getTypedRuleContext(au,0)}Comma_list(){return this.getTokens(F.Comma)}Comma(e){return this.getToken(F.Comma,e)}singleExpression_list(){return this.getTypedRuleContexts(Ve)}singleExpression(e){return this.getTypedRuleContext(Ve,e)}variableDeclarationList_list(){return this.getTypedRuleContexts(Ni)}variableDeclarationList(e){return this.getTypedRuleContext(Ni,e)}get ruleIndex(){return F.RULE_expressionBlockSequence}accept(e){return e.visitExpressionBlockSequence?e.visitExpressionBlockSequence(this):e.visitChildren(this)}}class cl extends Ye{constructor(e,n,r){super(n,r),this.parser=e}blockExpression(){return this.getTypedRuleContext(au,0)}varArrayDeclaration(){return this.getTypedRuleContext(os,0)}Assign(){return this.getToken(F.Assign,0)}name(){return this.getTypedRuleContext(cu,0)}assignmentOperator(){return this.getTypedRuleContext(yl,0)}get ruleIndex(){return F.RULE_varBlockStmt}accept(e){return e.visitVarBlockStmt?e.visitVarBlockStmt(this):e.visitChildren(this)}}class os extends Ye{constructor(e,n,r){super(n,r),this.parser=e}get ruleIndex(){return F.RULE_varArrayDeclaration}copyFrom(e){super.copyFrom(e)}}class __ extends os{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}OpenBracket(){return this.getToken(F.OpenBracket,0)}identifier_list(){return this.getTypedRuleContexts(yn)}identifier(e){return this.getTypedRuleContext(yn,e)}CloseBracket(){return this.getToken(F.CloseBracket,0)}Comma_list(){return this.getTokens(F.Comma)}Comma(e){return this.getToken(F.Comma,e)}accept(e){return e.visitVarMultiple?e.visitVarMultiple(this):e.visitChildren(this)}}class y_ extends os{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}identifier(){return this.getTypedRuleContext(yn,0)}varModifier(){return this.getTypedRuleContext(sl,0)}typeGather(){return this.getTypedRuleContext($o,0)}accept(e){return e.visitVarSingle?e.visitVarSingle(this):e.visitChildren(this)}}class au extends Ye{constructor(e,n,r){super(n,r),this.parser=e}ifStatement(){return this.getTypedRuleContext(bp,0)}forStatement(){return this.getTypedRuleContext(su,0)}whileStatement(){return this.getTypedRuleContext(Sp,0)}switchStatement(){return this.getTypedRuleContext(vp,0)}get ruleIndex(){return F.RULE_blockExpression}accept(e){return e.visitBlockExpression?e.visitBlockExpression(this):e.visitChildren(this)}}class Ve extends Ye{constructor(e,n,r){super(n,r),this.parser=e}get ruleIndex(){return F.RULE_singleExpression}copyFrom(e){super.copyFrom(e)}}class g_ extends Ve{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}OpenParen(){return this.getToken(F.OpenParen,0)}singleExpression(){return this.getTypedRuleContext(Ve,0)}CloseParen(){return this.getToken(F.CloseParen,0)}accept(e){return e.visitParenthesizedExpression?e.visitParenthesizedExpression(this):e.visitChildren(this)}}class b_ extends Ve{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}singleExpression_list(){return this.getTypedRuleContexts(Ve)}singleExpression(e){return this.getTypedRuleContext(Ve,e)}Plus(){return this.getToken(F.Plus,0)}Minus(){return this.getToken(F.Minus,0)}accept(e){return e.visitAdditiveExpression?e.visitAdditiveExpression(this):e.visitChildren(this)}}class v_ extends Ve{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}singleExpression_list(){return this.getTypedRuleContexts(Ve)}singleExpression(e){return this.getTypedRuleContext(Ve,e)}LessThan(){return this.getToken(F.LessThan,0)}MoreThan(){return this.getToken(F.MoreThan,0)}LessThanEquals(){return this.getToken(F.LessThanEquals,0)}GreaterThanEquals(){return this.getToken(F.GreaterThanEquals,0)}accept(e){return e.visitRelationalExpression?e.visitRelationalExpression(this):e.visitChildren(this)}}class E_ extends Ve{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}singleExpression_list(){return this.getTypedRuleContexts(Ve)}singleExpression(e){return this.getTypedRuleContext(Ve,e)}QuestionMark(){return this.getToken(F.QuestionMark,0)}Colon(){return this.getToken(F.Colon,0)}accept(e){return e.visitTernaryExpression?e.visitTernaryExpression(this):e.visitChildren(this)}}class S_ extends Ve{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}singleExpression_list(){return this.getTypedRuleContexts(Ve)}singleExpression(e){return this.getTypedRuleContext(Ve,e)}And(){return this.getToken(F.And,0)}accept(e){return e.visitLogicalAndExpression?e.visitLogicalAndExpression(this):e.visitChildren(this)}}class T_ extends Ve{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}name(){return this.getTypedRuleContext(cu,0)}accept(e){return e.visitNameExpression?e.visitNameExpression(this):e.visitChildren(this)}}class A_ extends Ve{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}literal(){return this.getTypedRuleContext(Ap,0)}accept(e){return e.visitLiteralExpression?e.visitLiteralExpression(this):e.visitChildren(this)}}class x_ extends Ve{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}singleExpression_list(){return this.getTypedRuleContexts(Ve)}singleExpression(e){return this.getTypedRuleContext(Ve,e)}Or(){return this.getToken(F.Or,0)}accept(e){return e.visitLogicalOrExpression?e.visitLogicalOrExpression(this):e.visitChildren(this)}}class C_ extends Ve{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}singleExpression(){return this.getTypedRuleContext(Ve,0)}Minus(){return this.getToken(F.Minus,0)}Plus(){return this.getToken(F.Plus,0)}accept(e){return e.visitUnaryExpression?e.visitUnaryExpression(this):e.visitChildren(this)}}class O_ extends Ve{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}Not(){return this.getToken(F.Not,0)}singleExpression(){return this.getTypedRuleContext(Ve,0)}accept(e){return e.visitNotExpression?e.visitNotExpression(this):e.visitChildren(this)}}class D_ extends Ve{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}singleExpression_list(){return this.getTypedRuleContexts(Ve)}singleExpression(e){return this.getTypedRuleContext(Ve,e)}OpenBracket(){return this.getToken(F.OpenBracket,0)}CloseBracket(){return this.getToken(F.CloseBracket,0)}accept(e){return e.visitMemberIndexExpression?e.visitMemberIndexExpression(this):e.visitChildren(this)}}class k_ extends Ve{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}methodStmt(){return this.getTypedRuleContext(uu,0)}accept(e){return e.visitMethodExpression?e.visitMethodExpression(this):e.visitChildren(this)}}class R_ extends Ve{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}singleExpression_list(){return this.getTypedRuleContexts(Ve)}singleExpression(e){return this.getTypedRuleContext(Ve,e)}Equals_(){return this.getToken(F.Equals_,0)}NotEquals(){return this.getToken(F.NotEquals,0)}accept(e){return e.visitEqualityExpression?e.visitEqualityExpression(this):e.visitChildren(this)}}class w_ extends Ve{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}singleExpression_list(){return this.getTypedRuleContexts(Ve)}singleExpression(e){return this.getTypedRuleContext(Ve,e)}Multiply(){return this.getToken(F.Multiply,0)}Divide(){return this.getToken(F.Divide,0)}Modulus(){return this.getToken(F.Modulus,0)}accept(e){return e.visitMultiplicativeExpression?e.visitMultiplicativeExpression(this):e.visitChildren(this)}}class ll extends Ye{constructor(e,n,r){super(n,r),this.parser=e}OpenBracket(){return this.getToken(F.OpenBracket,0)}expressionSequence(){return this.getTypedRuleContext(ul,0)}CloseBracket(){return this.getToken(F.CloseBracket,0)}get ruleIndex(){return F.RULE_brackethesized}accept(e){return e.visitBrackethesized?e.visitBrackethesized(this):e.visitChildren(this)}}class gp extends Ye{constructor(e,n,r){super(n,r),this.parser=e}OpenParen(){return this.getToken(F.OpenParen,0)}CloseParen(){return this.getToken(F.CloseParen,0)}argument_list(){return this.getTypedRuleContexts(fl)}argument(e){return this.getTypedRuleContext(fl,e)}Comma_list(){return this.getTokens(F.Comma)}Comma(e){return this.getToken(F.Comma,e)}get ruleIndex(){return F.RULE_arguments}accept(e){return e.visitArguments?e.visitArguments(this):e.visitChildren(this)}}class fl extends Ye{constructor(e,n,r){super(n,r),this.parser=e}singleExpression(){return this.getTypedRuleContext(Ve,0)}brackethesized(){return this.getTypedRuleContext(ll,0)}identifier(){return this.getTypedRuleContext(yn,0)}Assign(){return this.getToken(F.Assign,0)}get ruleIndex(){return F.RULE_argument}accept(e){return e.visitArgument?e.visitArgument(this):e.visitChildren(this)}}class bp extends Ye{constructor(e,n,r){super(n,r),this.parser=e}If_list(){return this.getTokens(F.If)}If(e){return this.getToken(F.If,e)}singleExpression_list(){return this.getTypedRuleContexts(Ve)}singleExpression(e){return this.getTypedRuleContext(Ve,e)}blockLine_list(){return this.getTypedRuleContexts(mo)}blockLine(e){return this.getTypedRuleContext(mo,e)}Else_list(){return this.getTokens(F.Else)}Else(e){return this.getToken(F.Else,e)}get ruleIndex(){return F.RULE_ifStatement}accept(e){return e.visitIfStatement?e.visitIfStatement(this):e.visitChildren(this)}}class su extends Ye{constructor(e,n,r){super(n,r),this.parser=e}get ruleIndex(){return F.RULE_forStatement}copyFrom(e){super.copyFrom(e)}}class N_ extends su{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}For(){return this.getToken(F.For,0)}identifier(){return this.getTypedRuleContext(yn,0)}Assign(){return this.getToken(F.Assign,0)}singleExpression_list(){return this.getTypedRuleContexts(Ve)}singleExpression(e){return this.getTypedRuleContext(Ve,e)}To(){return this.getToken(F.To,0)}blockLine(){return this.getTypedRuleContext(mo,0)}varModifier(){return this.getTypedRuleContext(sl,0)}typeGather(){return this.getTypedRuleContext($o,0)}By(){return this.getToken(F.By,0)}accept(e){return e.visitForToStatement?e.visitForToStatement(this):e.visitChildren(this)}}class I_ extends su{constructor(e,n){super(e,n.parentCtx,n.invokingState),super.copyFrom(n)}For(){return this.getToken(F.For,0)}In(){return this.getToken(F.In,0)}singleExpression(){return this.getTypedRuleContext(Ve,0)}blockLine(){return this.getTypedRuleContext(mo,0)}identifier_list(){return this.getTypedRuleContexts(yn)}identifier(e){return this.getTypedRuleContext(yn,e)}OpenBracket(){return this.getToken(F.OpenBracket,0)}Comma(){return this.getToken(F.Comma,0)}CloseBracket(){return this.getToken(F.CloseBracket,0)}accept(e){return e.visitForInStatement?e.visitForInStatement(this):e.visitChildren(this)}}class vp extends Ye{constructor(e,n,r){super(n,r),this.parser=e}Switch(){return this.getToken(F.Switch,0)}NEWLINE(){return this.getToken(F.NEWLINE,0)}INDENT(){return this.getToken(F.INDENT,0)}DEDENT(){return this.getToken(F.DEDENT,0)}singleExpression(){return this.getTypedRuleContext(Ve,0)}defaultCaluse(){return this.getTypedRuleContext(Ep,0)}caseClause_list(){return this.getTypedRuleContexts(hl)}caseClause(e){return this.getTypedRuleContext(hl,e)}get ruleIndex(){return F.RULE_switchStatement}accept(e){return e.visitSwitchStatement?e.visitSwitchStatement(this):e.visitChildren(this)}}class hl extends Ye{constructor(e,n,r){super(n,r),this.parser=e}singleExpression(){return this.getTypedRuleContext(Ve,0)}ARROW(){return this.getToken(F.ARROW,0)}block(){return this.getTypedRuleContext(is,0)}get ruleIndex(){return F.RULE_caseClause}accept(e){return e.visitCaseClause?e.visitCaseClause(this):e.visitChildren(this)}}class Ep extends Ye{constructor(e,n,r){super(n,r),this.parser=e}ARROW(){return this.getToken(F.ARROW,0)}block(){return this.getTypedRuleContext(is,0)}get ruleIndex(){return F.RULE_defaultCaluse}accept(e){return e.visitDefaultCaluse?e.visitDefaultCaluse(this):e.visitChildren(this)}}class Sp extends Ye{constructor(e,n,r){super(n,r),this.parser=e}While(){return this.getToken(F.While,0)}singleExpression(){return this.getTypedRuleContext(Ve,0)}blockLine(){return this.getTypedRuleContext(mo,0)}get ruleIndex(){return F.RULE_whileStatement}accept(e){return e.visitWhileStatement?e.visitWhileStatement(this):e.visitChildren(this)}}class Tp extends Ye{constructor(e,n,r){super(n,r),this.parser=e}importElement_list(){return this.getTypedRuleContexts(pl)}importElement(e){return this.getTypedRuleContext(pl,e)}NEWLINE(){return this.getToken(F.NEWLINE,0)}Comma_list(){return this.getTokens(F.Comma)}Comma(e){return this.getToken(F.Comma,e)}get ruleIndex(){return F.RULE_importStmt}accept(e){return e.visitImportStmt?e.visitImportStmt(this):e.visitChildren(this)}}class pl extends Ye{constructor(e,n,r){super(n,r),this.parser=e}Import(){return this.getToken(F.Import,0)}identifier_list(){return this.getTypedRuleContexts(yn)}identifier(e){return this.getTypedRuleContext(yn,e)}Divide_list(){return this.getTokens(F.Divide)}Divide(e){return this.getToken(F.Divide,e)}IntegerLiteral(){return this.getToken(F.IntegerLiteral,0)}As(){return this.getToken(F.As,0)}get ruleIndex(){return F.RULE_importElement}accept(e){return e.visitImportElement?e.visitImportElement(this):e.visitChildren(this)}}class Ap extends Ye{constructor(e,n,r){super(n,r),this.parser=e}BooleanLiteral(){return this.getToken(F.BooleanLiteral,0)}ColorLiteral(){return this.getToken(F.ColorLiteral,0)}StringLiteral(){return this.getToken(F.StringLiteral,0)}IntegerLiteral(){return this.getToken(F.IntegerLiteral,0)}DecimalLiteral(){return this.getToken(F.DecimalLiteral,0)}get ruleIndex(){return F.RULE_literal}accept(e){return e.visitLiteral?e.visitLiteral(this):e.visitChildren(this)}}class uu extends Ye{constructor(e,n,r){super(n,r),this.parser=e}methodElement_list(){return this.getTypedRuleContexts(as)}methodElement(e){return this.getTypedRuleContext(as,e)}Point_list(){return this.getTokens(F.Point)}Point(e){return this.getToken(F.Point,e)}get ruleIndex(){return F.RULE_methodStmt}accept(e){return e.visitMethodStmt?e.visitMethodStmt(this):e.visitChildren(this)}}class as extends Ye{constructor(e,n,r){super(n,r),this.parser=e}methodName(){return this.getTypedRuleContext(xp,0)}arguments(){return this.getTypedRuleContext(gp,0)}get ruleIndex(){return F.RULE_methodElement}accept(e){return e.visitMethodElement?e.visitMethodElement(this):e.visitChildren(this)}}class xp extends Ye{constructor(e,n,r){super(n,r),this.parser=e}identifier_list(){return this.getTypedRuleContexts(yn)}identifier(e){return this.getTypedRuleContext(yn,e)}OpenParen(){return this.getToken(F.OpenParen,0)}singleExpression(){return this.getTypedRuleContext(Ve,0)}CloseParen(){return this.getToken(F.CloseParen,0)}Point_list(){return this.getTokens(F.Point)}Point(e){return this.getToken(F.Point,e)}LessThan(){return this.getToken(F.LessThan,0)}typeName_list(){return this.getTypedRuleContexts(mi)}typeName(e){return this.getTypedRuleContext(mi,e)}MoreThan(){return this.getToken(F.MoreThan,0)}Comma(){return this.getToken(F.Comma,0)}get ruleIndex(){return F.RULE_methodName}accept(e){return e.visitMethodName?e.visitMethodName(this):e.visitChildren(this)}}class Cp extends Ye{constructor(e,n,r){super(n,r),this.parser=e}identifier(){return this.getTypedRuleContext(yn,0)}arrowFunctionParameters(){return this.getTypedRuleContext(Op,0)}ARROW(){return this.getToken(F.ARROW,0)}block(){return this.getTypedRuleContext(is,0)}Export(){return this.getToken(F.Export,0)}get ruleIndex(){return F.RULE_arrowFunction}accept(e){return e.visitArrowFunction?e.visitArrowFunction(this):e.visitChildren(this)}}class Op extends Ye{constructor(e,n,r){super(n,r),this.parser=e}OpenParen(){return this.getToken(F.OpenParen,0)}CloseParen(){return this.getToken(F.CloseParen,0)}formalParameterList(){return this.getTypedRuleContext(dl,0)}get ruleIndex(){return F.RULE_arrowFunctionParameters}accept(e){return e.visitArrowFunctionParameters?e.visitArrowFunctionParameters(this):e.visitChildren(this)}}class dl extends Ye{constructor(e,n,r){super(n,r),this.parser=e}formalParameterArg_list(){return this.getTypedRuleContexts(ml)}formalParameterArg(e){return this.getTypedRuleContext(ml,e)}Comma_list(){return this.getTokens(F.Comma)}Comma(e){return this.getToken(F.Comma,e)}get ruleIndex(){return F.RULE_formalParameterList}accept(e){return e.visitFormalParameterList?e.visitFormalParameterList(this):e.visitChildren(this)}}class ml extends Ye{constructor(e,n,r){super(n,r),this.parser=e}identifier(){return this.getTypedRuleContext(yn,0)}typeGather(){return this.getTypedRuleContext($o,0)}Assign(){return this.getToken(F.Assign,0)}singleExpression(){return this.getTypedRuleContext(Ve,0)}get ruleIndex(){return F.RULE_formalParameterArg}accept(e){return e.visitFormalParameterArg?e.visitFormalParameterArg(this):e.visitChildren(this)}}class Dp extends Ye{constructor(e,n,r){super(n,r),this.parser=e}Method(){return this.getToken(F.Method,0)}identifier(){return this.getTypedRuleContext(yn,0)}arrowMethodParameters(){return this.getTypedRuleContext(kp,0)}ARROW(){return this.getToken(F.ARROW,0)}block(){return this.getTypedRuleContext(is,0)}Export(){return this.getToken(F.Export,0)}get ruleIndex(){return F.RULE_arrowMethod}accept(e){return e.visitArrowMethod?e.visitArrowMethod(this):e.visitChildren(this)}}class kp extends Ye{constructor(e,n,r){super(n,r),this.parser=e}OpenParen(){return this.getToken(F.OpenParen,0)}typeGather(){return this.getTypedRuleContext($o,0)}identifier(){return this.getTypedRuleContext(yn,0)}CloseParen(){return this.getToken(F.CloseParen,0)}Assign(){return this.getToken(F.Assign,0)}singleExpression(){return this.getTypedRuleContext(Ve,0)}Comma(){return this.getToken(F.Comma,0)}formalParameterList(){return this.getTypedRuleContext(dl,0)}get ruleIndex(){return F.RULE_arrowMethodParameters}accept(e){return e.visitArrowMethodParameters?e.visitArrowMethodParameters(this):e.visitChildren(this)}}class Rp extends Ye{constructor(e,n,r){super(n,r),this.parser=e}Type(){return this.getToken(F.Type,0)}identifier(){return this.getTypedRuleContext(yn,0)}NEWLINE(){return this.getToken(F.NEWLINE,0)}INDENT(){return this.getToken(F.INDENT,0)}DEDENT(){return this.getToken(F.DEDENT,0)}Export(){return this.getToken(F.Export,0)}typeElement_list(){return this.getTypedRuleContexts(_l)}typeElement(e){return this.getTypedRuleContext(_l,e)}get ruleIndex(){return F.RULE_typeStatement}accept(e){return e.visitTypeStatement?e.visitTypeStatement(this):e.visitChildren(this)}}class _l extends Ye{constructor(e,n,r){super(n,r),this.parser=e}identifier(){return this.getTypedRuleContext(yn,0)}NEWLINE(){return this.getToken(F.NEWLINE,0)}Varip(){return this.getToken(F.Varip,0)}typeGather(){return this.getTypedRuleContext($o,0)}Assign(){return this.getToken(F.Assign,0)}singleExpression(){return this.getTypedRuleContext(Ve,0)}get ruleIndex(){return F.RULE_typeElement}accept(e){return e.visitTypeElement?e.visitTypeElement(this):e.visitChildren(this)}}class yl extends Ye{constructor(e,n,r){super(n,r),this.parser=e}ColonEquals(){return this.getToken(F.ColonEquals,0)}MultiplyAssign(){return this.getToken(F.MultiplyAssign,0)}DivideAssign(){return this.getToken(F.DivideAssign,0)}ModulusAssign(){return this.getToken(F.ModulusAssign,0)}PlusAssign(){return this.getToken(F.PlusAssign,0)}MinusAssign(){return this.getToken(F.MinusAssign,0)}get ruleIndex(){return F.RULE_assignmentOperator}accept(e){return e.visitAssignmentOperator?e.visitAssignmentOperator(this):e.visitChildren(this)}}class gl extends Ye{constructor(e,n,r){super(n,r),this.parser=e}Map(){return this.getToken(F.Map,0)}LessThan(){return this.getToken(F.LessThan,0)}Comma(){return this.getToken(F.Comma,0)}typeName_list(){return this.getTypedRuleContexts(mi)}typeName(e){return this.getTypedRuleContext(mi,e)}MoreThan(){return this.getToken(F.MoreThan,0)}get ruleIndex(){return F.RULE_typeMap}accept(e){return e.visitTypeMap?e.visitTypeMap(this):e.visitChildren(this)}}class wp extends Ye{constructor(e,n,r){super(n,r),this.parser=e}typeName_list(){return this.getTypedRuleContexts(mi)}typeName(e){return this.getTypedRuleContext(mi,e)}typeArray(){return this.getTypedRuleContext(bl,0)}typeMap(){return this.getTypedRuleContext(gl,0)}get ruleIndex(){return F.RULE_typeSeries}accept(e){return e.visitTypeSeries?e.visitTypeSeries(this):e.visitChildren(this)}}class bl extends Ye{constructor(e,n,r){super(n,r),this.parser=e}typeName_list(){return this.getTypedRuleContexts(mi)}typeName(e){return this.getTypedRuleContext(mi,e)}LessThan(){return this.getToken(F.LessThan,0)}MoreThan(){return this.getToken(F.MoreThan,0)}OpenBracket(){return this.getToken(F.OpenBracket,0)}CloseBracket(){return this.getToken(F.CloseBracket,0)}get ruleIndex(){return F.RULE_typeArray}accept(e){return e.visitTypeArray?e.visitTypeArray(this):e.visitChildren(this)}}class $o extends Ye{constructor(e,n,r){super(n,r),this.parser=e}typeName(){return this.getTypedRuleContext(mi,0)}typeArray(){return this.getTypedRuleContext(bl,0)}typeMap(){return this.getTypedRuleContext(gl,0)}typeSeries(){return this.getTypedRuleContext(wp,0)}get ruleIndex(){return F.RULE_typeGather}accept(e){return e.visitTypeGather?e.visitTypeGather(this):e.visitChildren(this)}}class yn extends Ye{constructor(e,n,r){super(n,r),this.parser=e}Identifier(){return this.getToken(F.Identifier,0)}Map(){return this.getToken(F.Map,0)}Type(){return this.getToken(F.Type,0)}Enum(){return this.getToken(F.Enum,0)}get ruleIndex(){return F.RULE_identifier}accept(e){return e.visitIdentifier?e.visitIdentifier(this):e.visitChildren(this)}}class mi extends Ye{constructor(e,n,r){super(n,r),this.parser=e}identifier_list(){return this.getTypedRuleContexts(yn)}identifier(e){return this.getTypedRuleContext(yn,e)}Point(){return this.getToken(F.Point,0)}get ruleIndex(){return F.RULE_typeName}accept(e){return e.visitTypeName?e.visitTypeName(this):e.visitChildren(this)}}class cu extends Ye{constructor(e,n,r){super(n,r),this.parser=e}identifier_list(){return this.getTypedRuleContexts(yn)}identifier(e){return this.getTypedRuleContext(yn,e)}Point_list(){return this.getTokens(F.Point)}Point(e){return this.getToken(F.Point,e)}methodElement_list(){return this.getTypedRuleContexts(as)}methodElement(e){return this.getTypedRuleContext(as,e)}OpenParen(){return this.getToken(F.OpenParen,0)}singleExpression(){return this.getTypedRuleContext(Ve,0)}CloseParen(){return this.getToken(F.CloseParen,0)}get ruleIndex(){return F.RULE_name}accept(e){return e.visitName?e.visitName(this):e.visitChildren(this)}}class Np extends Ye{constructor(e,n,r){super(n,r),this.parser=e}Enum(){return this.getToken(F.Enum,0)}identifier(){return this.getTypedRuleContext(yn,0)}NEWLINE(){return this.getToken(F.NEWLINE,0)}INDENT(){return this.getToken(F.INDENT,0)}DEDENT(){return this.getToken(F.DEDENT,0)}Export(){return this.getToken(F.Export,0)}enumElement_list(){return this.getTypedRuleContexts(vl)}enumElement(e){return this.getTypedRuleContext(vl,e)}get ruleIndex(){return F.RULE_enumStatement}accept(e){return e.visitEnumStatement?e.visitEnumStatement(this):e.visitChildren(this)}}class vl extends Ye{constructor(e,n,r){super(n,r),this.parser=e}identifier(){return this.getTypedRuleContext(yn,0)}NEWLINE(){return this.getToken(F.NEWLINE,0)}Assign(){return this.getToken(F.Assign,0)}StringLiteral(){return this.getToken(F.StringLiteral,0)}get ruleIndex(){return F.RULE_enumElement}accept(e){return e.visitEnumElement?e.visitEnumElement(this):e.visitChildren(this)}}class P_ extends s_{constructor(n){super(n);k(this,"tokens");k(this,"indents");k(this,"opened");this.tokens=[],this.indents=[],this.opened=0}reset(){this.tokens=[],this.indents=[],this.opened=0,super.reset()}emitToken(n){super.emitToken(n),this.tokens.push(n)}nextToken(){if(this._input.LA(1)===F.EOF&&this.indents.length){for(this.tokens=this.tokens.filter(function(r){return r.type!==F.EOF}),this.emitToken(this.commonToken(F.NEWLINE,`
|
11
11
|
`));this.indents.length;)this.emitToken(this.createDedent()),this.indents.pop();this.emitToken(this.commonToken(F.EOF,"<EOF>"))}const n=super.nextToken();return this.tokens.length?this.tokens.shift():n}createDedent(){return this.commonToken(F.DEDENT,"")}getCharIndex(){return this._input.index}commonToken(n,r){const s=this.getCharIndex()-1,l=r.length?s-r.length+1:s;return new n_([this,this._input],n,0,l,s)}getIndentationCount(n){let r=0;for(let s=0;s<n.length;s++)n[s]===" "?r+=4-r%4:r++;return r}atStartOfInput(){return this.getCharIndex()===0}openBrace(){this.opened++}closeBrace(){this.opened--}onNewLine(){const n=this.text.replace(/[^\r\n]+/g,""),r=this.text.replace(/[\r\n]+/g,""),s=this._input.LA(1),l=this._input.LA(2),h=this.getIndentationCount(r);if(this.opened>0||l!=-1&&(s===13||s===10||s===47&&l===47||h%4))this.skip();else{this.emitToken(this.commonToken(F.NEWLINE,n));const d=this.indents.length?this.indents[this.indents.length-1]:0;if(h===d)this.skip();else if(h>d)this.indents.push(h),this.emitToken(this.commonToken(F.INDENT,r));else for(;this.indents.length&&this.indents[this.indents.length-1]>h;)this.emitToken(this.createDedent()),this.indents.pop()}}}const we=class we extends P_{constructor(e){super(e),this._interp=new u_(this,we._ATN,we.DecisionsToDFA,new hp)}get grammarFileName(){return"tccScriptLexer.g4"}get literalNames(){return we.literalNames}get symbolicNames(){return we.symbolicNames}get ruleNames(){return we.ruleNames}get serializedATN(){return we._serializedATN}get channelNames(){return we.channelNames}get modeNames(){return we.modeNames}action(e,n,r){switch(n){case 1:this.OpenBracket_action(e,r);break;case 2:this.CloseBracket_action(e,r);break;case 3:this.OpenParen_action(e,r);break;case 4:this.CloseParen_action(e,r);break;case 58:this.NEWLINE_action(e,r);break}}OpenBracket_action(e,n){switch(n){case 0:this.openBrace();break}}CloseBracket_action(e,n){switch(n){case 1:this.closeBrace();break}}OpenParen_action(e,n){switch(n){case 2:this.openBrace();break}}CloseParen_action(e,n){switch(n){case 3:this.closeBrace();break}}NEWLINE_action(e,n){switch(n){case 4:this.onNewLine();break}}sempred(e,n,r){switch(n){case 58:return this.NEWLINE_sempred(e,r)}return!0}NEWLINE_sempred(e,n){switch(n){case 0:return this.atStartOfInput()}return!0}static get _ATN(){return we.__ATN||(we.__ATN=new lp().deserialize(we._serializedATN)),we.__ATN}};k(we,"INDENT",1),k(we,"DEDENT",2),k(we,"Point",3),k(we,"OpenBracket",4),k(we,"CloseBracket",5),k(we,"OpenParen",6),k(we,"CloseParen",7),k(we,"Comma",8),k(we,"Assign",9),k(we,"QuestionMark",10),k(we,"Colon",11),k(we,"Plus",12),k(we,"Minus",13),k(we,"Multiply",14),k(we,"Divide",15),k(we,"Modulus",16),k(we,"Hashtag",17),k(we,"LessThan",18),k(we,"MoreThan",19),k(we,"LessThanEquals",20),k(we,"GreaterThanEquals",21),k(we,"Equals_",22),k(we,"NotEquals",23),k(we,"MultiplyAssign",24),k(we,"DivideAssign",25),k(we,"ModulusAssign",26),k(we,"PlusAssign",27),k(we,"MinusAssign",28),k(we,"ARROW",29),k(we,"ColonEquals",30),k(we,"BooleanLiteral",31),k(we,"IntegerLiteral",32),k(we,"DecimalLiteral",33),k(we,"Break",34),k(we,"And",35),k(we,"Export",36),k(we,"For",37),k(we,"Var",38),k(we,"Continue",39),k(we,"Varip",40),k(we,"Switch",41),k(we,"While",42),k(we,"If",43),k(we,"In",44),k(we,"Or",45),k(we,"Not",46),k(we,"Method",47),k(we,"Else",48),k(we,"To",49),k(we,"By",50),k(we,"Type",51),k(we,"Import",52),k(we,"As",53),k(we,"Enum",54),k(we,"Map",55),k(we,"ColorLiteral",56),k(we,"StringLiteral",57),k(we,"Identifier",58),k(we,"HIDDEN_",59),k(we,"COMMENT_",60),k(we,"NEWLINE",61),k(we,"EOF",pp.EOF),k(we,"channelNames",["DEFAULT_TOKEN_CHANNEL","HIDDEN"]),k(we,"literalNames",[null,null,null,"'.'","'['","']'","'('","')'","','","'='","'?'","':'","'+'","'-'","'*'","'/'","'%'","'#'","'<'","'>'","'<='","'>='","'=='","'!='","'*='","'/='","'%='","'+='","'-='","'=>'","':='",null,null,null,"'break'","'and'","'export'","'for'","'var'","'continue'","'varip'","'switch'","'while'","'if'","'in'","'or'","'not'","'method'","'else'","'to'","'by'","'type'","'import'","'as'","'enum'","'map'"]),k(we,"symbolicNames",[null,"INDENT","DEDENT","Point","OpenBracket","CloseBracket","OpenParen","CloseParen","Comma","Assign","QuestionMark","Colon","Plus","Minus","Multiply","Divide","Modulus","Hashtag","LessThan","MoreThan","LessThanEquals","GreaterThanEquals","Equals_","NotEquals","MultiplyAssign","DivideAssign","ModulusAssign","PlusAssign","MinusAssign","ARROW","ColonEquals","BooleanLiteral","IntegerLiteral","DecimalLiteral","Break","And","Export","For","Var","Continue","Varip","Switch","While","If","In","Or","Not","Method","Else","To","By","Type","Import","As","Enum","Map","ColorLiteral","StringLiteral","Identifier","HIDDEN_","COMMENT_","NEWLINE"]),k(we,"modeNames",["DEFAULT_MODE"]),k(we,"ruleNames",["Point","OpenBracket","CloseBracket","OpenParen","CloseParen","Comma","Assign","QuestionMark","Colon","Plus","Minus","Multiply","Divide","Modulus","Hashtag","LessThan","MoreThan","LessThanEquals","GreaterThanEquals","Equals_","NotEquals","MultiplyAssign","DivideAssign","ModulusAssign","PlusAssign","MinusAssign","ARROW","ColonEquals","BooleanLiteral","IntegerLiteral","DecimalLiteral","Break","And","Export","For","Var","Continue","Varip","Switch","While","If","In","Or","Not","Method","Else","To","By","Type","Import","As","Enum","Map","ColorLiteral","StringLiteral","Identifier","HIDDEN_","COMMENT_","NEWLINE","SHORT_STRING","DIGIT","DIGITS","HEX_DIGIT","SPACES","COMMENT","EXP"]),k(we,"_serializedATN",[4,0,61,447,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,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,6,1,6,1,7,1,7,1,8,1,8,1,9,1,9,1,10,1,10,1,11,1,11,1,12,1,12,1,13,1,13,1,14,1,14,1,15,1,15,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,21,1,21,1,21,1,22,1,22,1,22,1,23,1,23,1,23,1,24,1,24,1,24,1,25,1,25,1,25,1,26,1,26,1,26,1,27,1,27,1,27,1,28,1,28,1,28,1,28,1,28,1,28,1,28,1,28,1,28,3,28,214,8,28,1,29,1,29,1,30,1,30,1,30,3,30,221,8,30,1,30,1,30,1,30,1,30,3,30,227,8,30,3,30,229,8,30,1,30,3,30,232,8,30,3,30,234,8,30,1,31,1,31,1,31,1,31,1,31,1,31,1,32,1,32,1,32,1,32,1,33,1,33,1,33,1,33,1,33,1,33,1,33,1,34,1,34,1,34,1,34,1,35,1,35,1,35,1,35,1,36,1,36,1,36,1,36,1,36,1,36,1,36,1,36,1,36,1,37,1,37,1,37,1,37,1,37,1,37,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,39,1,39,1,39,1,39,1,39,1,39,1,40,1,40,1,40,1,41,1,41,1,41,1,42,1,42,1,42,1,43,1,43,1,43,1,43,1,44,1,44,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,47,1,47,1,47,1,48,1,48,1,48,1,48,1,48,1,49,1,49,1,49,1,49,1,49,1,49,1,49,1,50,1,50,1,50,1,51,1,51,1,51,1,51,1,51,1,52,1,52,1,52,1,52,1,53,1,53,1,53,1,53,1,53,1,53,1,53,1,53,1,53,1,53,1,53,1,53,1,53,1,53,1,53,1,53,1,53,1,53,3,53,362,8,53,1,54,1,54,1,55,1,55,5,55,368,8,55,10,55,12,55,371,9,55,1,56,1,56,1,56,1,56,1,57,1,57,1,57,1,57,1,58,1,58,1,58,3,58,384,8,58,1,58,1,58,3,58,388,8,58,1,58,3,58,391,8,58,3,58,393,8,58,1,58,1,58,1,59,1,59,1,59,1,59,5,59,401,8,59,10,59,12,59,404,9,59,1,59,1,59,1,59,1,59,1,59,5,59,411,8,59,10,59,12,59,414,9,59,1,59,3,59,417,8,59,1,60,1,60,1,61,4,61,422,8,61,11,61,12,61,423,1,62,1,62,1,63,4,63,429,8,63,11,63,12,63,430,1,64,1,64,1,64,1,64,5,64,437,8,64,10,64,12,64,440,9,64,1,65,1,65,3,65,444,8,65,1,65,1,65,0,0,66,1,3,3,4,5,5,7,6,9,7,11,8,13,9,15,10,17,11,19,12,21,13,23,14,25,15,27,16,29,17,31,18,33,19,35,20,37,21,39,22,41,23,43,24,45,25,47,26,49,27,51,28,53,29,55,30,57,31,59,32,61,33,63,34,65,35,67,36,69,37,71,38,73,39,75,40,77,41,79,42,81,43,83,44,85,45,87,46,89,47,91,48,93,49,95,50,97,51,99,52,101,53,103,54,105,55,107,56,109,57,111,58,113,59,115,60,117,61,119,0,121,0,123,0,125,0,127,0,129,0,131,0,1,0,10,3,0,65,90,95,95,97,122,4,0,48,57,65,90,95,95,97,122,1,0,39,39,1,0,34,34,1,0,48,57,3,0,48,57,65,70,97,102,3,0,9,9,32,32,160,160,2,0,10,10,12,13,2,0,69,69,101,101,2,0,43,43,45,45,460,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,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,1,133,1,0,0,0,3,135,1,0,0,0,5,138,1,0,0,0,7,141,1,0,0,0,9,144,1,0,0,0,11,147,1,0,0,0,13,149,1,0,0,0,15,151,1,0,0,0,17,153,1,0,0,0,19,155,1,0,0,0,21,157,1,0,0,0,23,159,1,0,0,0,25,161,1,0,0,0,27,163,1,0,0,0,29,165,1,0,0,0,31,167,1,0,0,0,33,169,1,0,0,0,35,171,1,0,0,0,37,174,1,0,0,0,39,177,1,0,0,0,41,180,1,0,0,0,43,183,1,0,0,0,45,186,1,0,0,0,47,189,1,0,0,0,49,192,1,0,0,0,51,195,1,0,0,0,53,198,1,0,0,0,55,201,1,0,0,0,57,213,1,0,0,0,59,215,1,0,0,0,61,233,1,0,0,0,63,235,1,0,0,0,65,241,1,0,0,0,67,245,1,0,0,0,69,252,1,0,0,0,71,256,1,0,0,0,73,260,1,0,0,0,75,269,1,0,0,0,77,275,1,0,0,0,79,282,1,0,0,0,81,288,1,0,0,0,83,291,1,0,0,0,85,294,1,0,0,0,87,297,1,0,0,0,89,301,1,0,0,0,91,308,1,0,0,0,93,313,1,0,0,0,95,316,1,0,0,0,97,319,1,0,0,0,99,324,1,0,0,0,101,331,1,0,0,0,103,334,1,0,0,0,105,339,1,0,0,0,107,361,1,0,0,0,109,363,1,0,0,0,111,365,1,0,0,0,113,372,1,0,0,0,115,376,1,0,0,0,117,392,1,0,0,0,119,416,1,0,0,0,121,418,1,0,0,0,123,421,1,0,0,0,125,425,1,0,0,0,127,428,1,0,0,0,129,432,1,0,0,0,131,441,1,0,0,0,133,134,5,46,0,0,134,2,1,0,0,0,135,136,5,91,0,0,136,137,6,1,0,0,137,4,1,0,0,0,138,139,5,93,0,0,139,140,6,2,1,0,140,6,1,0,0,0,141,142,5,40,0,0,142,143,6,3,2,0,143,8,1,0,0,0,144,145,5,41,0,0,145,146,6,4,3,0,146,10,1,0,0,0,147,148,5,44,0,0,148,12,1,0,0,0,149,150,5,61,0,0,150,14,1,0,0,0,151,152,5,63,0,0,152,16,1,0,0,0,153,154,5,58,0,0,154,18,1,0,0,0,155,156,5,43,0,0,156,20,1,0,0,0,157,158,5,45,0,0,158,22,1,0,0,0,159,160,5,42,0,0,160,24,1,0,0,0,161,162,5,47,0,0,162,26,1,0,0,0,163,164,5,37,0,0,164,28,1,0,0,0,165,166,5,35,0,0,166,30,1,0,0,0,167,168,5,60,0,0,168,32,1,0,0,0,169,170,5,62,0,0,170,34,1,0,0,0,171,172,5,60,0,0,172,173,5,61,0,0,173,36,1,0,0,0,174,175,5,62,0,0,175,176,5,61,0,0,176,38,1,0,0,0,177,178,5,61,0,0,178,179,5,61,0,0,179,40,1,0,0,0,180,181,5,33,0,0,181,182,5,61,0,0,182,42,1,0,0,0,183,184,5,42,0,0,184,185,5,61,0,0,185,44,1,0,0,0,186,187,5,47,0,0,187,188,5,61,0,0,188,46,1,0,0,0,189,190,5,37,0,0,190,191,5,61,0,0,191,48,1,0,0,0,192,193,5,43,0,0,193,194,5,61,0,0,194,50,1,0,0,0,195,196,5,45,0,0,196,197,5,61,0,0,197,52,1,0,0,0,198,199,5,61,0,0,199,200,5,62,0,0,200,54,1,0,0,0,201,202,5,58,0,0,202,203,5,61,0,0,203,56,1,0,0,0,204,205,5,116,0,0,205,206,5,114,0,0,206,207,5,117,0,0,207,214,5,101,0,0,208,209,5,102,0,0,209,210,5,97,0,0,210,211,5,108,0,0,211,212,5,115,0,0,212,214,5,101,0,0,213,204,1,0,0,0,213,208,1,0,0,0,214,58,1,0,0,0,215,216,3,123,61,0,216,60,1,0,0,0,217,218,5,46,0,0,218,220,3,123,61,0,219,221,3,131,65,0,220,219,1,0,0,0,220,221,1,0,0,0,221,234,1,0,0,0,222,231,3,123,61,0,223,228,5,46,0,0,224,226,3,123,61,0,225,227,3,131,65,0,226,225,1,0,0,0,226,227,1,0,0,0,227,229,1,0,0,0,228,224,1,0,0,0,228,229,1,0,0,0,229,232,1,0,0,0,230,232,3,131,65,0,231,223,1,0,0,0,231,230,1,0,0,0,232,234,1,0,0,0,233,217,1,0,0,0,233,222,1,0,0,0,234,62,1,0,0,0,235,236,5,98,0,0,236,237,5,114,0,0,237,238,5,101,0,0,238,239,5,97,0,0,239,240,5,107,0,0,240,64,1,0,0,0,241,242,5,97,0,0,242,243,5,110,0,0,243,244,5,100,0,0,244,66,1,0,0,0,245,246,5,101,0,0,246,247,5,120,0,0,247,248,5,112,0,0,248,249,5,111,0,0,249,250,5,114,0,0,250,251,5,116,0,0,251,68,1,0,0,0,252,253,5,102,0,0,253,254,5,111,0,0,254,255,5,114,0,0,255,70,1,0,0,0,256,257,5,118,0,0,257,258,5,97,0,0,258,259,5,114,0,0,259,72,1,0,0,0,260,261,5,99,0,0,261,262,5,111,0,0,262,263,5,110,0,0,263,264,5,116,0,0,264,265,5,105,0,0,265,266,5,110,0,0,266,267,5,117,0,0,267,268,5,101,0,0,268,74,1,0,0,0,269,270,5,118,0,0,270,271,5,97,0,0,271,272,5,114,0,0,272,273,5,105,0,0,273,274,5,112,0,0,274,76,1,0,0,0,275,276,5,115,0,0,276,277,5,119,0,0,277,278,5,105,0,0,278,279,5,116,0,0,279,280,5,99,0,0,280,281,5,104,0,0,281,78,1,0,0,0,282,283,5,119,0,0,283,284,5,104,0,0,284,285,5,105,0,0,285,286,5,108,0,0,286,287,5,101,0,0,287,80,1,0,0,0,288,289,5,105,0,0,289,290,5,102,0,0,290,82,1,0,0,0,291,292,5,105,0,0,292,293,5,110,0,0,293,84,1,0,0,0,294,295,5,111,0,0,295,296,5,114,0,0,296,86,1,0,0,0,297,298,5,110,0,0,298,299,5,111,0,0,299,300,5,116,0,0,300,88,1,0,0,0,301,302,5,109,0,0,302,303,5,101,0,0,303,304,5,116,0,0,304,305,5,104,0,0,305,306,5,111,0,0,306,307,5,100,0,0,307,90,1,0,0,0,308,309,5,101,0,0,309,310,5,108,0,0,310,311,5,115,0,0,311,312,5,101,0,0,312,92,1,0,0,0,313,314,5,116,0,0,314,315,5,111,0,0,315,94,1,0,0,0,316,317,5,98,0,0,317,318,5,121,0,0,318,96,1,0,0,0,319,320,5,116,0,0,320,321,5,121,0,0,321,322,5,112,0,0,322,323,5,101,0,0,323,98,1,0,0,0,324,325,5,105,0,0,325,326,5,109,0,0,326,327,5,112,0,0,327,328,5,111,0,0,328,329,5,114,0,0,329,330,5,116,0,0,330,100,1,0,0,0,331,332,5,97,0,0,332,333,5,115,0,0,333,102,1,0,0,0,334,335,5,101,0,0,335,336,5,110,0,0,336,337,5,117,0,0,337,338,5,109,0,0,338,104,1,0,0,0,339,340,5,109,0,0,340,341,5,97,0,0,341,342,5,112,0,0,342,106,1,0,0,0,343,344,5,35,0,0,344,345,3,125,62,0,345,346,3,125,62,0,346,347,3,125,62,0,347,348,3,125,62,0,348,349,3,125,62,0,349,350,3,125,62,0,350,362,1,0,0,0,351,352,5,35,0,0,352,353,3,125,62,0,353,354,3,125,62,0,354,355,3,125,62,0,355,356,3,125,62,0,356,357,3,125,62,0,357,358,3,125,62,0,358,359,3,125,62,0,359,360,3,125,62,0,360,362,1,0,0,0,361,343,1,0,0,0,361,351,1,0,0,0,362,108,1,0,0,0,363,364,3,119,59,0,364,110,1,0,0,0,365,369,7,0,0,0,366,368,7,1,0,0,367,366,1,0,0,0,368,371,1,0,0,0,369,367,1,0,0,0,369,370,1,0,0,0,370,112,1,0,0,0,371,369,1,0,0,0,372,373,3,127,63,0,373,374,1,0,0,0,374,375,6,56,4,0,375,114,1,0,0,0,376,377,3,129,64,0,377,378,1,0,0,0,378,379,6,57,5,0,379,116,1,0,0,0,380,381,4,58,0,0,381,393,3,127,63,0,382,384,5,13,0,0,383,382,1,0,0,0,383,384,1,0,0,0,384,385,1,0,0,0,385,388,5,10,0,0,386,388,2,12,13,0,387,383,1,0,0,0,387,386,1,0,0,0,388,390,1,0,0,0,389,391,3,127,63,0,390,389,1,0,0,0,390,391,1,0,0,0,391,393,1,0,0,0,392,380,1,0,0,0,392,387,1,0,0,0,393,394,1,0,0,0,394,395,6,58,6,0,395,118,1,0,0,0,396,402,5,39,0,0,397,401,8,2,0,0,398,399,5,92,0,0,399,401,5,39,0,0,400,397,1,0,0,0,400,398,1,0,0,0,401,404,1,0,0,0,402,400,1,0,0,0,402,403,1,0,0,0,403,405,1,0,0,0,404,402,1,0,0,0,405,417,5,39,0,0,406,412,5,34,0,0,407,411,8,3,0,0,408,409,5,92,0,0,409,411,5,34,0,0,410,407,1,0,0,0,410,408,1,0,0,0,411,414,1,0,0,0,412,410,1,0,0,0,412,413,1,0,0,0,413,415,1,0,0,0,414,412,1,0,0,0,415,417,5,34,0,0,416,396,1,0,0,0,416,406,1,0,0,0,417,120,1,0,0,0,418,419,7,4,0,0,419,122,1,0,0,0,420,422,3,121,60,0,421,420,1,0,0,0,422,423,1,0,0,0,423,421,1,0,0,0,423,424,1,0,0,0,424,124,1,0,0,0,425,426,7,5,0,0,426,126,1,0,0,0,427,429,7,6,0,0,428,427,1,0,0,0,429,430,1,0,0,0,430,428,1,0,0,0,430,431,1,0,0,0,431,128,1,0,0,0,432,433,5,47,0,0,433,434,5,47,0,0,434,438,1,0,0,0,435,437,8,7,0,0,436,435,1,0,0,0,437,440,1,0,0,0,438,436,1,0,0,0,438,439,1,0,0,0,439,130,1,0,0,0,440,438,1,0,0,0,441,443,7,8,0,0,442,444,7,9,0,0,443,442,1,0,0,0,443,444,1,0,0,0,444,445,1,0,0,0,445,446,3,123,61,0,446,132,1,0,0,0,22,0,213,220,226,228,231,233,361,369,383,387,390,392,400,402,410,412,416,423,430,438,443,7,1,1,0,1,2,1,1,3,2,1,4,3,0,1,0,0,2,0,1,58,4]),k(we,"__ATN"),k(we,"DecisionsToDFA",we._ATN.decisionToState.map((e,n)=>new fp(e,n)));let El=we;var U=(t=>(t.BOOL="bool",t.INT="int",t.FLOAT="float",t.ARRAY="array",t.BOX="box",t.CHART_POINT="chart.point",t.COLOR="color",t.CONST="const",t.LABEL="label",t.LINE="line",t.LINEFILL="linefill",t.MAP="map",t.MATRIX="matrix",t.POLYLINE="polyline",t.SERIES="series",t.SIMPLE="simple",t.STRING="string",t.TABLE="table",t.UNDETERMINED="undetermined type",t.INPUT="input",t.NA="na",t.VOID="void",t.ENUM="enum",t))(U||{}),le=(t=>(t.FlowStmt="FlowStmt",t.DeclareAssign="DeclareAssign",t.VarBlockStmt="VarBlockStmt",t.VarSingle="VarSingle",t.VarMultiple="VarMultiple",t.ParenthesizedExpression="ParenthesizedExpression",t.AdditiveExpression="AdditiveExpression",t.RelationalExpression="RelationalExpression",t.EqualityExpression="EqualityExpression",t.TernaryExpression="TernaryExpression",t.UnaryExpression="UnaryExpression",t.NotExpression="NotExpression",t.MemberIndexExpression="MemberIndexExpression",t.MethodExpression="MethodExpression",t.LogicalAndExpression="LogicalAndExpression",t.LogicalOrExpression="LogicalOrExpression",t.MultiplicativeExpression="MultiplicativeExpression",t.Brackethesized="Brackethesized",t.IfStatement="IfStatement",t.ForToStatement="ForToStatement",t.ForInStatement="ForInStatement",t.SwitchStatement="SwitchStatement",t.CaseClause="CaseClause",t.DefaultCaluse="DefaultCaluse",t.WhileStatement="WhileStatement",t.ImportElement="ImportElement",t.Literal="Literal",t.ArrowFunction="ArrowFunction",t.ArrowMethod="ArrowMethod",t.TypeStatement="TypeStatement",t.Name="Name",t.AgainAssign="AgainAssign",t.EnumStatement="EnumStatement",t))(le||{}),Kt=(t=>(t.description="description",t.field="field",t.function="function",t.param="param",t.returns="returns",t.type="type",t.variable="variable",t.enum="enum",t))(Kt||{}),Ii=(t=>(t.library="library",t.indicator="indicator",t.strategy="strategy",t))(Ii||{});const de={onlyInLoop:"'$text' is only allowed inside loops",invalidType:"Invalid argument 'expr$index' in 'operator SQBR' call",typeUseError:"Cannot specify a type form '$text' without also specifying the type.",notTypeKeyword:"'$text' is not a valid type keyword in variable declaration",undeclared:"Undeclared identifier '$name'",repeatVar:"'$name' is already defined",typeRepeatErr:"$keyword '$name' is already defined.",typeMismatch:"Cannot call '$operator' with argument '$index'. An argument of '$typeE' type was used but a '$typeR' is expected.",assignTypeMismatch:"Cannot assign a value of the `$typeE` type to the '$name' variable. The variable is declared with the `$typeR` type.",voidNotVar:"Void expression cannot be assigned to a variable",declareTypeErr:"Declared type '$type' is not compatible with assigned type '$valueType'",mapKeyValErr:"Cannot put <$typeA, $typeB> pairs into a map containing `$typeC` keys and `$typeD` values. The maps passed into the `$name()` function must have the same key types and value types.",inputSourceErr:"Invalid value for the '$name' parameter of the '$funcName' function. Possible values: [open, high, low, close, hl2, hlc3, ohlc4, hlcc4, volume].",buildInUseErr:"Cannot use '$name' as the default value of a type's field. The default value cannot be a function, variable or calculation.",argsLenErr:"Too many arguments passed into the `$name()` function call. Passed $lenA arguments but expected $lenB.",requiredParamErr:"No value assigned to the `$argName` parameter in $name()",argsSyntaxErr:"Syntax error after the argument for `$argName`. Arguments without their parameter name cannot be used after arguments with parameter names.",requestArgsErr:"Type $type cannot be used in $name '$argName' argument",mapKeyErr:"Incorrect `key` type `$type` in the variable. The `key` type must be one of the following: int, float, string, bool, color.",templateErr:"Incorrect number of arguments for the template: $countA expected, $countB passed.",templateNoSupportErr:"The '$name()' function does not support templates",ifOrSwitchTypeErr:"Return type of one of the '$keyword' blocks is not compatible with return type of other block(s) ($types)",argsNameErr:"The '$name' function does not have an argument with the name '$argName'",noFiledErr:"Object has no field $name",methodNotExistErr:"Could not find method or method reference '$methodName' for '$name'",tupleVarErr:"Syntax error: The quantities of tuple elements on each side of the assignment operator do not match. The right side has $indexA but the left side has $indexB.",tupleLeftVarErr:"Invalid assignment. Cannot assign a tuple to a variable '$name'.",tupleRightVarErr:"Cannot assign a variable to a tuple. The right side must be a function call or structure ('if', 'switch', 'for', 'while') returning a tuple with the same number of elements.",tempateTypeErr:"Syntax error: Only templates for arrays and matrices consist of a single type identifier enclosed in angle brackets.",qualifierErr:"'$name' is not a valid type qualifier. Possible values: 'const', 'simple', 'series'",notFindFuncErr:"Could not find function or function reference '$name'",naVarErr:"Value with NA type cannot be assigned to a variable that was defined without type keyword",notHistoryErr:"Variable '$name' doesn't have history values",defaultValueErr:"The default value cannot be a function, variable or calculation.",defaultValueTypeErr:"Default value of type $typeE can not be assigned to an argument of type $typeR",typeFieldErr:"In a type declaration, all fields without a default value must be explicitly typified.",unaryErr:"Syntax error at input '$sign'",funcArgAssignErr:"Function arguments cannot be mutable ('$name')",declaredErr:"A variable declared with the '$prefix' keyword cannot accept values of the '$type' form. Assign a '$prefix' value to this variable or remove the '$prefix' keyword from its declaration.",globalFuncErr:"Cannot use '$name' in local scope",onlyStatementErr:"Scripts must contain one declaration statement: `indicator()`, `strategy()` or `library()`, Your script has $count.",modifyGlobalVarErr:"Cannot modify global variable '$name' in function",inputDefvalErr:"Arguments of input function must be of constant type, or 'source' builtin variables.",objectIsNaErr:"Cannot access the '$name' $type of an na object. The object is 'na'.",buidinAssignErr:"Cannot assign a new value to the built-in variable '$name'.",buidinVarErr:"Cannot shadow the built-in variable `$name` because it has already been used as a built-in.",useNaErr:"Cannot use an `na` value of an unspecified type in the `$name` function.",libraryTitleErr:"Invalid argument 'title' in 'library' call. It cannot contain spaces, special characters or begin with a digit.",exportFuncArgErr:"All exported functions args should be typified",indiRunErr:"An indicator must contain at least one of the following: any `plot*()` function, `barcolor()`, `bgcolor()`, `hline()`, `alertcondition()`, or any drawing (line, label, box, table, polyline).",libraryExportErr:"A library must contain at least one exported function, method, or type.",strategyRunErr:"A strategy must contain at least one of the following: any `strategy.*()` function that creates orders, any `plot*()` function, `barcolor()`, `bgcolor()`, `hline()`, or any drawing (line, label, box, table, polyline).",exportUseErr:"Only libraries can contain exported $type.",funcRepeatErr:"The '$name' function has overloads with the same parameters. The type of parameters must be different in overloaded versions of functions.",importMultipleErr:"Cannot import a library more than once",importNotExitErr:"The user '$username' does not have a published library titled '$libraryName'",importNameRepeatErr:"More than one import uses the same alias: $name. Previous usage at line: $line",exportFuncHasInputErr:"The exported function '$func' depends on the '$name' input variable, which is not allowed.",libraryTitleIsKeywordErr:"Invalid argument 'title' in 'library' call. Token: '$name' can't be used as library title.",exportFuncUseGlobalVarErr:"Cannot use global variables in exported functions. Function: $func",loopRuntimeErr:"Loop takes too long to execute (> 500 ms)",paramsErr:"Invalid value '$value' for '$param' parameter of the '$func' function. Possible values: $targetVal",displayErr:"Invalid argument 'display' in '$func' call. Possible values: $values",exportFuncUseReqErr:"Cannot use `request.*()` call in exported function `$name()`",requestExprErr:"Type series $type cannot be used in $name 'expression' argument",argDefaultErr:"The default value assigned to a parameter must be either a literal value (e.g., `5`) or a built-in variable (e.g., `close`)",overloadFuncErr:"Cannot use global variables or any values qualified as 'input' in the local scopes of overloaded functions or methods. Remove any global variables or inputs from the scopes of all '$name()' overloads.",againAssignErr:"Unable to determine the object for the field assignment. Try putting the object into a separate variable before assigning values to its fields.",requestUserInLoopErr:"Cannot use `request.*()` call within loops or conditional structures.",enumVarNameErr:"Invalid enum name '$name': `bool`, `int`, `float`, `string`, and `color` are not allowed.",enumVarNameBuiltinErr:"Invalid object name: $name. Namespaces of built-ins cannot be used.",typeNameErr:"Invalid user-defined type name '$name': `bool`, `int`, `float`, `string`, and `color` are not allowed.",enumUseErr:"Cannot use the '$name' as a value. Use one of the enum's fields instead.",conditionalErr:"'$name' conditional expression must be of a bool type!",fortoErr:'The value of the "for" loop must be a number.',indicatorUseStrategyFuncErr:"You cannot use strategy $type ($name) in indicator script.",arrEmptyErr:"Array must not be empty",arrLengthDiffErr:"Arrays have different lengths",arrTypeErr:"数组类型错误,array.$name方法只能使用$type类型数组!",inputOptErr:"input's defval should be in options, but '$defval' is not in [$args]",mathRandomErr:"min must be less than max",matrixRehapeErr:"New matrix must be of same area as original matrix",strategyExitErr:"strategy.exit must have at least one of the following parameters: 'profit', 'limit', 'loss', 'stop' or one of the following pairs: 'trail_offset' and 'trail_price' / 'trail_points'. To close the position at market price, use 'strategy.close'",arrLenErr:"Invalid array length",mergeCellErr:"error: start_column > end_column or start_row > end_row"},sr={repeatVar:"Shadowing variable '$name' which exists in parent scope. Did you want to use the ':=' operator instead of '=' ?",typeMismatch:"The `$index` parameter of the `$operator` function accepts a '$type' argument. To avoid potential unexpected results, pass a '$type' value or expression to this parameter.",moreSameArg:"More than one '$arg' arguments are supplied. Only the first one will be used.",localScopeGetHistory:"The variable '$name' is declared in local scope, which may not be executed at every update. So, obtaining its historical values may lead to unexpected results",localScopeWarning:"The function '$name' should be called on each calculation for consistency. It is recommended to extract the call from this scope",strategyCalcTickWarn:"Strategies without `calc_on_every_tick = true` only calculate on confirmed chart bars. In this case, `barstate.islast` may not initially return `true` on realtime bars, as the last bar is unconfirmed until it closes. If you need to check whether a bar is the latest before it closes, enable `calc_on_every_tick` in the `strategy()` function.",conditionWarning:"The `condition` parameter of the `$name` accepts a 'bool' argument. To avoid potential unexpected results, pass a 'bool' value or expression to this parameter.",lineWidthWarning:"Passing a value below 1 to `linewidth` will be replaced with 1 during compilation.",boolVarNumWarning:"The `$name` variable casts a numeric value to the 'bool' type. To avoid potential unexpected results, assign a 'bool' value to this variable."},Pi=[U.SERIES,U.SIMPLE,U.INPUT,U.CONST],lu=[U.INT,U.FLOAT,U.BOOL,U.COLOR,U.STRING],Sl=["indicator","strategy","library"],Tl=["plot","plotbar","plotchar","plotarrow","plotshape","plotcandle","hline","alertcondition","barcolor","bgcolor","fill"],F_=[...Tl,"indicator","library","strategy","strategy.risk.max_drawdown","strategy.risk.allow_entry_in","strategy.risk.max_cons_loss_days","max_intraday_filled_orders","strategy.risk.max_intraday_loss","strategy.risk.max_position_size"],L_=[...Tl,"table.new","label.new","line.new","box.new","polyline.new","linefill.new"],M_=["strategy.entry","strategy.order","strategy.exit","strategy.close","strategy.cancel","strategy.close_all","strategy.cancel_all"],Ip=["strategy","input","table","color","line","linefill","label","box"],Al=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"],B_=/^\/\/\s*@(description|field|function|param|returns|type|enum|variable)/,Rn=["case","catch","default","delete","do","finally","function","instanceof","new","return","this","throw","try","typeof","void","with"],Pp=["session","ta","syminfo","timeframe","strategy","barstate","label","line","linefill","box","table","chart","earnings","polyline","math","adjustment","hline","position","size","plot","format","dayofweek","shape","location","scale","currency","barmerge","xloc","yloc","extend","display","text","font","order","alert","dividends","splits","color","input","str","request","ticker","array","matrix","runtime","log","map"];var Fp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},U_={exports:{}};(function(t,e){(function(n,r){t.exports=r()})(Fp,function(){var n=1e3,r=6e4,s=36e5,l="millisecond",h="second",d="minute",v="hour",S="day",C="week",A="month",R="quarter",B="year",M="date",b="Invalid Date",y=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,g=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,O={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(ge){var re=["th","st","nd","rd"],pe=ge%100;return"["+ge+(re[(pe-20)%10]||re[pe]||re[0])+"]"}},w=function(ge,re,pe){var fe=String(ge);return!fe||fe.length>=re?ge:""+Array(re+1-fe.length).join(pe)+ge},D={s:w,z:function(ge){var re=-ge.utcOffset(),pe=Math.abs(re),fe=Math.floor(pe/60),Oe=pe%60;return(re<=0?"+":"-")+w(fe,2,"0")+":"+w(Oe,2,"0")},m:function ge(re,pe){if(re.date()<pe.date())return-ge(pe,re);var fe=12*(pe.year()-re.year())+(pe.month()-re.month()),Oe=re.clone().add(fe,A),Ie=pe-Oe<0,ve=re.clone().add(fe+(Ie?-1:1),A);return+(-(fe+(pe-Oe)/(Ie?Oe-ve:ve-Oe))||0)},a:function(ge){return ge<0?Math.ceil(ge)||0:Math.floor(ge)},p:function(ge){return{M:A,y:B,w:C,d:S,D:M,h:v,m:d,s:h,ms:l,Q:R}[ge]||String(ge||"").toLowerCase().replace(/s$/,"")},u:function(ge){return ge===void 0}},H="en",X={};X[H]=O;var ee="$isDayjsObject",z=function(ge){return ge instanceof Q||!(!ge||!ge[ee])},Y=function ge(re,pe,fe){var Oe;if(!re)return H;if(typeof re=="string"){var Ie=re.toLowerCase();X[Ie]&&(Oe=Ie),pe&&(X[Ie]=pe,Oe=Ie);var ve=re.split("-");if(!Oe&&ve.length>1)return ge(ve[0])}else{var Ue=re.name;X[Ue]=re,Oe=Ue}return!fe&&Oe&&(H=Oe),Oe||!fe&&H},V=function(ge,re){if(z(ge))return ge.clone();var pe=typeof re=="object"?re:{};return pe.date=ge,pe.args=arguments,new Q(pe)},ne=D;ne.l=Y,ne.i=z,ne.w=function(ge,re){return V(ge,{locale:re.$L,utc:re.$u,x:re.$x,$offset:re.$offset})};var Q=function(){function ge(pe){this.$L=Y(pe.locale,null,!0),this.parse(pe),this.$x=this.$x||pe.x||{},this[ee]=!0}var re=ge.prototype;return re.parse=function(pe){this.$d=function(fe){var Oe=fe.date,Ie=fe.utc;if(Oe===null)return new Date(NaN);if(ne.u(Oe))return new Date;if(Oe instanceof Date)return new Date(Oe);if(typeof Oe=="string"&&!/Z$/i.test(Oe)){var ve=Oe.match(y);if(ve){var Ue=ve[2]-1||0,J=(ve[7]||"0").substring(0,3);return Ie?new Date(Date.UTC(ve[1],Ue,ve[3]||1,ve[4]||0,ve[5]||0,ve[6]||0,J)):new Date(ve[1],Ue,ve[3]||1,ve[4]||0,ve[5]||0,ve[6]||0,J)}}return new Date(Oe)}(pe),this.init()},re.init=function(){var pe=this.$d;this.$y=pe.getFullYear(),this.$M=pe.getMonth(),this.$D=pe.getDate(),this.$W=pe.getDay(),this.$H=pe.getHours(),this.$m=pe.getMinutes(),this.$s=pe.getSeconds(),this.$ms=pe.getMilliseconds()},re.$utils=function(){return ne},re.isValid=function(){return this.$d.toString()!==b},re.isSame=function(pe,fe){var Oe=V(pe);return this.startOf(fe)<=Oe&&Oe<=this.endOf(fe)},re.isAfter=function(pe,fe){return V(pe)<this.startOf(fe)},re.isBefore=function(pe,fe){return this.endOf(fe)<V(pe)},re.$g=function(pe,fe,Oe){return ne.u(pe)?this[fe]:this.set(Oe,pe)},re.unix=function(){return Math.floor(this.valueOf()/1e3)},re.valueOf=function(){return this.$d.getTime()},re.startOf=function(pe,fe){var Oe=this,Ie=!!ne.u(fe)||fe,ve=ne.p(pe),Ue=function(Et,Mt){var gt=ne.w(Oe.$u?Date.UTC(Oe.$y,Mt,Et):new Date(Oe.$y,Mt,Et),Oe);return Ie?gt:gt.endOf(S)},J=function(Et,Mt){return ne.w(Oe.toDate()[Et].apply(Oe.toDate("s"),(Ie?[0,0,0,0]:[23,59,59,999]).slice(Mt)),Oe)},ie=this.$W,ue=this.$M,Ae=this.$D,be="set"+(this.$u?"UTC":"");switch(ve){case B:return Ie?Ue(1,0):Ue(31,11);case A:return Ie?Ue(1,ue):Ue(0,ue+1);case C:var At=this.$locale().weekStart||0,jt=(ie<At?ie+7:ie)-At;return Ue(Ie?Ae-jt:Ae+(6-jt),ue);case S:case M:return J(be+"Hours",0);case v:return J(be+"Minutes",1);case d:return J(be+"Seconds",2);case h:return J(be+"Milliseconds",3);default:return this.clone()}},re.endOf=function(pe){return this.startOf(pe,!1)},re.$set=function(pe,fe){var Oe,Ie=ne.p(pe),ve="set"+(this.$u?"UTC":""),Ue=(Oe={},Oe[S]=ve+"Date",Oe[M]=ve+"Date",Oe[A]=ve+"Month",Oe[B]=ve+"FullYear",Oe[v]=ve+"Hours",Oe[d]=ve+"Minutes",Oe[h]=ve+"Seconds",Oe[l]=ve+"Milliseconds",Oe)[Ie],J=Ie===S?this.$D+(fe-this.$W):fe;if(Ie===A||Ie===B){var ie=this.clone().set(M,1);ie.$d[Ue](J),ie.init(),this.$d=ie.set(M,Math.min(this.$D,ie.daysInMonth())).$d}else Ue&&this.$d[Ue](J);return this.init(),this},re.set=function(pe,fe){return this.clone().$set(pe,fe)},re.get=function(pe){return this[ne.p(pe)]()},re.add=function(pe,fe){var Oe,Ie=this;pe=Number(pe);var ve=ne.p(fe),Ue=function(ue){var Ae=V(Ie);return ne.w(Ae.date(Ae.date()+Math.round(ue*pe)),Ie)};if(ve===A)return this.set(A,this.$M+pe);if(ve===B)return this.set(B,this.$y+pe);if(ve===S)return Ue(1);if(ve===C)return Ue(7);var J=(Oe={},Oe[d]=r,Oe[v]=s,Oe[h]=n,Oe)[ve]||1,ie=this.$d.getTime()+pe*J;return ne.w(ie,this)},re.subtract=function(pe,fe){return this.add(-1*pe,fe)},re.format=function(pe){var fe=this,Oe=this.$locale();if(!this.isValid())return Oe.invalidDate||b;var Ie=pe||"YYYY-MM-DDTHH:mm:ssZ",ve=ne.z(this),Ue=this.$H,J=this.$m,ie=this.$M,ue=Oe.weekdays,Ae=Oe.months,be=Oe.meridiem,At=function(Mt,gt,Ot,Zt){return Mt&&(Mt[gt]||Mt(fe,Ie))||Ot[gt].slice(0,Zt)},jt=function(Mt){return ne.s(Ue%12||12,Mt,"0")},Et=be||function(Mt,gt,Ot){var Zt=Mt<12?"AM":"PM";return Ot?Zt.toLowerCase():Zt};return Ie.replace(g,function(Mt,gt){return gt||function(Ot){switch(Ot){case"YY":return String(fe.$y).slice(-2);case"YYYY":return ne.s(fe.$y,4,"0");case"M":return ie+1;case"MM":return ne.s(ie+1,2,"0");case"MMM":return At(Oe.monthsShort,ie,Ae,3);case"MMMM":return At(Ae,ie);case"D":return fe.$D;case"DD":return ne.s(fe.$D,2,"0");case"d":return String(fe.$W);case"dd":return At(Oe.weekdaysMin,fe.$W,ue,2);case"ddd":return At(Oe.weekdaysShort,fe.$W,ue,3);case"dddd":return ue[fe.$W];case"H":return String(Ue);case"HH":return ne.s(Ue,2,"0");case"h":return jt(1);case"hh":return jt(2);case"a":return Et(Ue,J,!0);case"A":return Et(Ue,J,!1);case"m":return String(J);case"mm":return ne.s(J,2,"0");case"s":return String(fe.$s);case"ss":return ne.s(fe.$s,2,"0");case"SSS":return ne.s(fe.$ms,3,"0");case"Z":return ve}return null}(Mt)||ve.replace(":","")})},re.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},re.diff=function(pe,fe,Oe){var Ie,ve=this,Ue=ne.p(fe),J=V(pe),ie=(J.utcOffset()-this.utcOffset())*r,ue=this-J,Ae=function(){return ne.m(ve,J)};switch(Ue){case B:Ie=Ae()/12;break;case A:Ie=Ae();break;case R:Ie=Ae()/3;break;case C:Ie=(ue-ie)/6048e5;break;case S:Ie=(ue-ie)/864e5;break;case v:Ie=ue/s;break;case d:Ie=ue/r;break;case h:Ie=ue/n;break;default:Ie=ue}return Oe?Ie:ne.a(Ie)},re.daysInMonth=function(){return this.endOf(A).$D},re.$locale=function(){return X[this.$L]},re.locale=function(pe,fe){if(!pe)return this.$L;var Oe=this.clone(),Ie=Y(pe,fe,!0);return Ie&&(Oe.$L=Ie),Oe},re.clone=function(){return ne.w(this.$d,this)},re.toDate=function(){return new Date(this.valueOf())},re.toJSON=function(){return this.isValid()?this.toISOString():null},re.toISOString=function(){return this.$d.toISOString()},re.toString=function(){return this.$d.toUTCString()},ge}(),_e=Q.prototype;return V.prototype=_e,[["$ms",l],["$s",h],["$m",d],["$H",v],["$W",S],["$M",A],["$y",B],["$D",M]].forEach(function(ge){_e[ge[1]]=function(re){return this.$g(re,ge[0],ge[1])}}),V.extend=function(ge,re){return ge.$i||(ge(re,Q,V),ge.$i=!0),V},V.locale=Y,V.isDayjs=z,V.unix=function(ge){return V(1e3*ge)},V.en=X[H],V.Ls=X,V.p={},V})})(U_);function ye(t,e){return t.replace(/\$(\w+)/g,(n,r)=>String(e[r])||n)}function Lp(t){var e=encodeURI(t),n=btoa(e);return n}class V_ extends c_{constructor(){super(...arguments);k(this,"visitProgram");k(this,"visitGlobalStmt");k(this,"visitBlockStmt");k(this,"visitStmt");k(this,"visitSimpleStmt");k(this,"visitFlowStmt");k(this,"visitBlock");k(this,"visitBlockLine");k(this,"visitVariableDeclarationStmt");k(this,"visitDeclareAssign");k(this,"visitAgainAssign");k(this,"visitVarModifier");k(this,"visitBlockSequence");k(this,"visitExpressionSequence");k(this,"visitExpressionBlockSequence");k(this,"visitVarBlockStmt");k(this,"visitVarSingle");k(this,"visitVarMultiple");k(this,"visitBlockExpression");k(this,"visitParenthesizedExpression");k(this,"visitAdditiveExpression");k(this,"visitRelationalExpression");k(this,"visitTernaryExpression");k(this,"visitLogicalAndExpression");k(this,"visitNameExpression");k(this,"visitLiteralExpression");k(this,"visitLogicalOrExpression");k(this,"visitUnaryExpression");k(this,"visitNotExpression");k(this,"visitMemberIndexExpression");k(this,"visitMethodExpression");k(this,"visitEqualityExpression");k(this,"visitMultiplicativeExpression");k(this,"visitBrackethesized");k(this,"visitArguments");k(this,"visitArgument");k(this,"visitIfStatement");k(this,"visitForToStatement");k(this,"visitForInStatement");k(this,"visitSwitchStatement");k(this,"visitCaseClause");k(this,"visitDefaultCaluse");k(this,"visitWhileStatement");k(this,"visitImportStmt");k(this,"visitImportElement");k(this,"visitLiteral");k(this,"visitMethodStmt");k(this,"visitMethodElement");k(this,"visitMethodName");k(this,"visitArrowFunction");k(this,"visitArrowFunctionParameters");k(this,"visitFormalParameterList");k(this,"visitFormalParameterArg");k(this,"visitArrowMethod");k(this,"visitArrowMethodParameters");k(this,"visitTypeStatement");k(this,"visitTypeElement");k(this,"visitAssignmentOperator");k(this,"visitTypeMap");k(this,"visitTypeSeries");k(this,"visitTypeArray");k(this,"visitTypeGather");k(this,"visitIdentifier");k(this,"visitTypeName");k(this,"visitName");k(this,"visitEnumStatement");k(this,"visitEnumElement")}}class j_ extends V_{constructor(n){super();k(this,"_buildinVariables");k(this,"_buildinTypes");k(this,"_buildinConstants");k(this,"_buildinMethods");k(this,"_buildinFunctions");this._buildinVariables=new Map,this._buildinConstants=new Map,this._buildinFunctions=new Map,this._buildinTypes=new Map,this._buildinMethods=new Map,this._buildinHandle(n)}_buildinHandle(n){for(const r in n){const s=new Map(Object.entries(n[r]));switch(r){case"constants":this._buildinConstants=s;break;case"functions":this._buildinFunctions=s;break;case"methods":this._buildinMethods=s;break;case"types":this._buildinTypes=s;break;case"variables":this._buildinVariables=s;break}}}_typeHandle(n=[],r){if(!n.length)return U.UNDETERMINED;if(n=n.filter(h=>!h.endsWith(U.NA)),!n.length)return`${U.SIMPLE} ${U.NA}`;let s=100,l="";for(const h of n){if(h===U.UNDETERMINED)return U.UNDETERMINED;h.startsWith(U.SERIES)?s=0:h.startsWith(U.SIMPLE)&&s>0?s=1:h.startsWith(U.INPUT)&&s>1?s=2:h.startsWith(U.CONST)&&s>2&&(s=3);const d=this._removePrefix(h);(d!==U.INT||!l)&&(l=d)}return s===100?l:`${Pi[s]} ${r||l}`}_returnTypesOtherHandle(n,r,s,l){if(!s.length||s[0].includes("<>")){const h=n.type;let d=h;if(!h||h===U.UNDETERMINED)return[U.UNDETERMINED];switch(r){case"series <type>":d=this._getArrayType(h),d||(d=this._removePrefix(h)),s=[this._typeAddSeries(d)];break;case"array<type>":case"matrix<type>":case"type[]":if(this._isMapType(h)){const v=this._getMapType(h)||[];l.includes("keys")?d=v[0]:d=v[1]}else d=this._getArrayType(h),d||(d=this._removePrefix(h));s=[this._typeReplace(r,d)];break;case"<matrix_type>":d=this._getArrayType(h),s=[this._typeAddSeries(d)];break;case"map<keyType, valueType>":s=[d];break;case"<value_type>":d=this._getMapType(h),s=[d[1]];break}}return s}_checkMethodThisType(n,r){if(!n||!n.length||n[0].includes("<>"))return!0;const s=r.replace("int","float");return n.some(l=>l===r||s===l||l.endsWith(r))}_priorityComparison(n,r){if(!n)return!1;if(this._isArrayType(n)||this._isMatrixType(n))return this._getArrayType(r)!==U.INT;{const s=this._getPrefix(n),l=this._getPrefix(r);return s===l?!!n.endsWith(U.INT):!(Pi.indexOf(s)<Pi.indexOf(l))}}_compareType(n,r){if(n===U.UNDETERMINED||r===U.UNDETERMINED)return!0;const s=[U.FLOAT,U.INT];if(this._isArrayType(n)||this._isMatrixType(n)){const l=this._getArrayType(n)||"",h=this._getArrayType(r)||"";return l===h||s.includes(l)&&s.includes(h)}else if(this._isMapType(n)){const l=this._getMapType(n)||[],h=this._getMapType(r)||[];return(l[0]===h[0]||s.includes(l[0])&&s.includes(h[0]))&&(l[1]===h[1]||s.includes(l[1])&&s.includes(h[1]))}else{const l=this._removePrefix(n),h=this._removePrefix(r);return l===U.NA||h===U.NA||l===h||s.includes(l)&&s.includes(h)}}_typeAddSeries(n){return this._buildinTypes.get(n)&&n!==U.CHART_POINT?`${U.SERIES} ${n}`:n}_typeAddConst(n){return lu.includes(n)?`${U.CONST} ${n}`:this._typeAddSeries(n)}_getOriginMethodName(n,r){let s="";return this._isArrayType(n)?s=`${U.ARRAY}.${r}`:this._isMatrixType(n)?s=`${U.MATRIX}.${r}`:this._isMapType(n)?s=`${U.MAP}.${r}`:s=`${this._removePrefix(n)}.${r}`,s}_returnedTypesParse(n){if(!n||!n.length)return[];const r=n[0];return/^\[.+\]$/.test(r)?r.replace(/[[\]]/g,"").split(",").map(s=>s.trim()):n}_removePrefix(n=""){return n.replace(/(series|simple|const|input)\s+([\w\d.]+)/,"$2")}_getPrefix(n){if(!n)return"";const r=n.replace(/(series|simple|const|input).+/,"$1");return Pi.includes(r)?r:""}_getArrayType(n){let r=/\w+<([\w\d.]+)>/.exec(n);return r||(r=/([\w\d.]+)\[\]/.exec(n)),r==null?void 0:r[1]}_getMapType(n){const r=/\w+<(\w+),\s*([\w\d.]+)>/.exec(n);return(r==null?void 0:r[1])&&(r==null?void 0:r[2])&&[r==null?void 0:r[1],r==null?void 0:r[2]]}_isMatrixType(n){return/^matrix<[\w\d.]+>$/.test(n)}_isArrayType(n){return/^array<[\w\d.]+>$/.test(n)||/^[\w\d.]+\[\]$/.test(n)}_isMapType(n){return/^map<\w+,\s*[\w\d.]+>$/.test(n)}_arrayTypeConvert(n){return!this._isArrayType(n)||!n.includes("<")?n:`${this._getArrayType(n)}[]`}_getMethodTypeName(n){return this._isArrayType(n)?U.ARRAY:this._isMapType(n)?U.MAP:this._isMatrixType(n)?U.MATRIX:this._removePrefix(n)}_typeReplace(n,r){return r===U.UNDETERMINED?r:(r=this._removePrefix(r),this._arrayTypeConvert(n.startsWith(U.SERIES)?n.replace("<type>",r):n.replace("type",r)))}}var Sn=(t=>(t[t.Hint=1]="Hint",t[t.Info=2]="Info",t[t.Warning=4]="Warning",t[t.Error=8]="Error",t))(Sn||{});class Mp extends j_{constructor(n,r,s){super(n);k(this,"_loopCount");k(this,"_errors");k(this,"_variables");k(this,"_functions");k(this,"_methods");k(this,"_types");k(this,"_enums");k(this,"_currentBlockVars");k(this,"_currentFuncParams");k(this,"_isNeedCalc");k(this,"_blockCount");k(this,"_isInFunc");k(this,"_currentExportFunc");k(this,"_onlyStatementsCount");k(this,"_blockRanges");k(this,"_overloadsFuncs");k(this,"_hasMemberIndex");k(this,"_isInLocalScop");k(this,"_comments");k(this,"_currentLine",0);k(this,"_hasDrawFunc",!1);k(this,"_hasCreateOrderFunc",!1);k(this,"_scriptType");k(this,"_exportFunctions");k(this,"_exportMethods");k(this,"_exportTypes");k(this,"_exportEnums");k(this,"_exportPositions");k(this,"_description","");k(this,"_endExport");k(this,"_importLibs");k(this,"_getImportLibraryFunc");k(this,"_isEndExpr");k(this,"_inputVarName");k(this,"_hasRequest");k(this,"_strategyFuncName");k(this,"_strategyVarName");k(this,"visitProgram",async n=>{const{children:r}=n;let s=0;const l=[];for(this._pushBlockRanges(n);s<r.length;s++){const h=r[s];h.ruleIndex===F.RULE_globalStmt&&l.push(await this.visit(h))}return this._onlyStatementsCount<=0?this._errors.push({startColumn:0,endColumn:0,startLineNumber:0,endLineNumber:0,type:Sn.Error,message:ye(de.onlyStatementErr,{count:this._onlyStatementsCount})}):this._scriptType===Ii.indicator&&(this._strategyFuncName?this._errorHandle(ye(de.indicatorUseStrategyFuncErr,{name:this._strategyFuncName.name,type:"functions"}),this._strategyFuncName.ctx):this._strategyVarName&&this._errorHandle(ye(de.indicatorUseStrategyFuncErr,{name:this._strategyVarName.name,type:"variables"}),this._strategyVarName.ctx)),l});k(this,"visitGlobalStmt",async n=>{const{children:r}=n;if(r&&r.length){const s=r[0],l=await this.visit(s);return s.ruleIndex===F.RULE_methodStmt&&Sl.includes(l.exprs[0].name)&&(this._onlyStatementsCount++,this._onlyStatementsCount>1?this._errorHandle(ye(de.onlyStatementErr,{count:this._onlyStatementsCount}),s):this._scriptType=l.exprs[0].name),l}return null});k(this,"visitBlockStmt",n=>{const{children:r}=n;let s=0;const l=[];for(;s<r.length;s++){const h=r[s];switch(h.ruleIndex){case F.RULE_variableDeclarationStmt:l.push(...this.visit(h));break;case F.RULE_varBlockStmt:l.push(this.visit(h));break;case F.RULE_blockExpression:l.push(this.visit(h));break}}return l});k(this,"visitStmt",n=>{const{children:r}=n;if(r&&r.length){const s=r[0];return this.visit(s)}return null});k(this,"visitSimpleStmt",n=>{const{children:r}=n;if(r&&r.length){const s=r[0];return this.visit(s)}return null});k(this,"visitFlowStmt",n=>{const{children:r}=n,{column:s,line:l,text:h}=r[0].symbol;if(this._currentLine=l,this._loopCount<=0){const d=s+1;this._errors.push({startColumn:d,endColumn:parseInt(d+h.length),startLineNumber:l,endLineNumber:l,message:ye(de.onlyInLoop,{text:h})})}return{ruleType:le.FlowStmt,value:h}});k(this,"visitBlock",n=>{const{children:r}=n;if(r&&r.length){const s=r[0];return s.ruleIndex===F.RULE_simpleStmt?this._inBlock(s):this.visit(s)}return null});k(this,"visitBlockLine",n=>{const{children:r}=n;if(!r)return null;let s=0;const l=[];this._blockCount++,this._pushBlockRanges(n);const h=this._isEndExpr;for(;s<r.length;s++){const d=r[s];d.ruleIndex===F.RULE_stmt&&(this._isInFunc&&(this._isEndExpr=r.length-2===s&&h),l.push(this.visit(d)))}return this._blockCount--,this._blockRanges.pop(),this._currentBlockVars.splice(this._blockCount+1),l});k(this,"visitDeclareAssign",n=>{var h;const{children:r}=n;let s=0;const l={ruleType:le.DeclareAssign};for(;s<r.length;s++){const d=r[s];switch(d.ruleIndex){case F.RULE_varArrayDeclaration:l.nameList=this.visit(d),this._inputVarName=(h=l.nameList)==null?void 0:h.name;break;case F.RULE_singleExpression:l.value=this.visit(d),this._inputVarName=void 0;break}}return this._variablesHandle(l,n),l});k(this,"visitAgainAssign",n=>{const{children:r,start:s}=n;if(this._currentLine=s.line,r.length>=3){const l=this.visit(r[0]);this._verifyGloablVar(l,r[0]);const h=this.visit(r[2]),d=this.visit(r[1]);return l.type?this._againAssignHandle([l,h],[r[0],r[2]],d):null}return null});k(this,"visitVarModifier",n=>{const{children:r}=n;return r[0].symbol.text});k(this,"visitExpressionSequence",n=>{const{children:r,start:s}=n;let l=0;const h=[];for(this._currentLine=s.line;l<r.length;l++){const d=r[l];if(d.ruleIndex===F.RULE_singleExpression){const v=this.visit(d);v&&(v.ctx=d,h.push(v))}}return h});k(this,"visitExpressionBlockSequence",n=>{const{children:r}=n;let s=0;const l=[];for(;s<r.length;s++){const h=r[s];switch(h.ruleIndex){case F.RULE_singleExpression:l.push(this.visit(h));break;case F.RULE_variableDeclarationList:l.push(this.visit(h));break;case F.RULE_blockExpression:l.push(this.visit(h));break;case F.RULE_varBlockStmt:l.push(this.visit(h));break}}return l});k(this,"visitBlockSequence",n=>{const{children:r}=n;let s=0;const l=[];for(;s<r.length;s++){const h=r[s];switch(h.ruleIndex){case F.RULE_variableDeclarationList:l.push(this.visit(h));break;case F.RULE_singleExpression:l.push(this.visit(h));break}}return l});k(this,"visitVariableDeclarationStmt",n=>{const{children:r}=n;let s=0;const l=[];for(;s<r.length;s++){const h=r[s];switch(h.ruleIndex){case F.RULE_variableDeclarationList:l.push(this.visit(h));break;case F.RULE_methodStmt:const d=this.visit(h);Sl.includes(d.exprs[0].name)&&(this._onlyStatementsCount++,this._onlyStatementsCount>1?this._errorHandle(ye(de.onlyStatementErr,{count:this._onlyStatementsCount}),h):this._scriptType=d.exprs[0].name),l.push(d);break}}return l});k(this,"visitVarBlockStmt",n=>{const{children:r}=n;let s=0;const l={ruleType:le.VarBlockStmt,ctx:n},h=[];for(;s<r.length;s++){const d=r[s];switch(d.ruleIndex){case F.RULE_varArrayDeclaration:l.nameList=this.visit(d);break;case F.RULE_assignmentOperator:l.operator=this.visit(d);break;case F.RULE_name:h.push(d),l.name=this.visit(d);break;case F.RULE_blockExpression:if(this._isNeedCalc=!0,l.value=this.visit(d),!l.value)break;h.push(d);const v=this._getBlockReturnTypes(l.value);v.length===1?l.value.type=v[0]:l.value.types=v,this._isNeedCalc=!1;break}}return l.name?this._againAssignHandle([l.name,l.value],h,l.operator):(this._variablesHandle(l,n),l)});k(this,"visitVarSingle",n=>{const{children:r,start:s}=n,l={ruleType:le.VarSingle};let h=0;const d=this._commentsParser(s.line,[Kt.variable]);l.desc=d==null?void 0:d[Kt.variable],this._currentLine=s.line;let v={lineNumber:0,column:0};for(;h<r.length;h++){const S=r[h];switch(S.ruleIndex){case F.RULE_varModifier:l.declare=this.visit(S);break;case F.RULE_typeGather:const C=this.visit(S);l.prefix=this._getPrefix(C),l.type=C&&this._typeAddConst(C);break;case F.RULE_identifier:const A=this.visit(S);v={lineNumber:S.start.line,column:S.start.column},this._repeatVarJudge(A,S,v),l.name=A,l.pos=v;break}}return l});k(this,"_commentsParser",(n,r,s=!1)=>{var S;const l=this._comments.filter(C=>C.line<n&&C.line>=this._currentLine),h={},d={line:0,key:"",secKey:""},v=[Kt.field,Kt.param];for(const C of l){const[A,R]=B_.exec(C.text)||[];if(R&&r.includes(R)){const B=C.text.replace(A,"").trim();if(Object.assign(d,{line:C.line,key:R}),v.includes(R)){const[M,...b]=B.split(" ");M&&(Object.assign(d,{secKey:M}),h[R]=Object.assign(h[R]||{},{[M]:b.join(" ").trim()}))}else h[R]=[B]}else if(s&&d.key){const B=C.text.replace("//","").trim();v.includes(d.key)?h[d.key][d.secKey]+=` ${B}`:(S=h[d.key])==null||S.push(B)}}return h});k(this,"visitVarMultiple",n=>{const{children:r,start:s}=n;let l=0;const h=[],d=[];for(this._currentLine=s.line;l<r.length;l++){const v=r[l];if(v.ruleIndex===F.RULE_identifier){const S=this.visit(v),C={lineNumber:v.start.line,column:v.start.column};this._repeatVarJudge(S,v,C,h),h.push(S),d.push(C)}}return{ruleType:le.VarMultiple,names:h,posList:d}});k(this,"visitBlockExpression",n=>{const{children:r,start:s}=n;if(this._currentLine=s.line,r&&r.length){const l=r[0];return this.visit(l)}return null});k(this,"visitParenthesizedExpression",n=>{const{children:r}=n,s=r[1],l=this.visit(s);return{ruleType:le.ParenthesizedExpression,type:l.type,ctx:n,exprs:l}});k(this,"visitAdditiveExpression",n=>{const{children:r}=n;let s=0,l="";const h=[];for(;s<r.length;s++){const v=r[s];v.ruleIndex===F.RULE_singleExpression?h.push(this.visit(v)):l=v.symbol.text}const d={ruleType:le.AdditiveExpression,operator:l,ctx:n,exprs:h};if(["+","-"].includes(l)){const v=[U.UNDETERMINED,U.INT,U.FLOAT];l==="+"&&v.push(U.STRING);const S=this._sameTypeJudge(h,[r[0],r[2]],l,v);d.type=this._typeHandle(S)}else{const v=this._calcTypeJudge(h[0],r[0],l),S=this._calcTypeJudge(h[1],r[2],l,1);d.type=this._typeHandle([v,S])}return d});k(this,"visitRelationalExpression",n=>{const{children:r}=n;let s=0,l="";const h=[];for(;s<r.length;s++){const S=r[s];S.ruleIndex===F.RULE_singleExpression?h.push(this.visit(S)):l=S.symbol.text}const d=this._calcTypeJudge(h[0],r[0],l),v=this._calcTypeJudge(h[1],r[2],l,1);return{ruleType:le.RelationalExpression,operator:l,ctx:n,type:this._typeHandle([d,v],U.BOOL),exprs:h}});k(this,"visitEqualityExpression",n=>{const{children:r}=n;let s=0,l="";const h=[];for(;s<r.length;s++){const v=r[s];v.ruleIndex===F.RULE_singleExpression?h.push(this.visit(v)):l=v.symbol.text}const d=this._sameTypeJudge(h,[r[0],r[2]],l,[]);return{ruleType:le.EqualityExpression,operator:l,ctx:n,type:this._typeHandle(d,U.BOOL),exprs:h}});k(this,"visitTernaryExpression",n=>{const{children:r}=n;let s=0;const l=[];for(;s<r.length;s++){const d=r[s];d.ruleIndex===F.RULE_singleExpression&&l.push(this.visit(d))}let h=U.UNDETERMINED;if(l.length>=3){this._boolTypeJudge(l[0],r[0],"?:");const d=this._sameTypeJudge(l.slice(1),[r[2],r[4]],"?:",[]),v=this._getPrefix(l[0].type);h=this._typeHandle(d),v&&this._getPrefix(h)&&(h=this._typeHandle([h,`${v} ${this._removePrefix(h)}`]))}return{ruleType:le.TernaryExpression,type:h,ctx:n,exprs:l}});k(this,"visitNameExpression",n=>{const{children:r}=n;if(r&&r.length){const s=r[0];return this.visit(s)}return null});k(this,"visitLiteralExpression",n=>{const{children:r}=n;if(r&&r.length){const s=r[0];return this.visit(s)}return null});k(this,"visitUnaryExpression",n=>{var S;const{children:r}=n,[s,l]=r,h=[this.visit(l)],d=s.symbol.text,v=this._calcTypeJudge(h[0],l,d);return((S=h[0])==null?void 0:S.ruleType)===le.UnaryExpression&&this._errors.push({message:ye(de.unaryErr,{sign:d}),startColumn:s.symbol.column+1,startLineNumber:s.symbol.line,endColumn:s.symbol.column+2,endLineNumber:s.symbol.line}),{ruleType:le.UnaryExpression,operator:d,type:v,ctx:n,exprs:h}});k(this,"visitNotExpression",n=>{const{children:r}=n,s=r[1],l=[this.visit(s)],h=this._boolTypeJudge(l[0],s,"not");return{ruleType:le.NotExpression,ctx:n,type:this._typeHandle([h],U.BOOL),exprs:l}});k(this,"visitMemberIndexExpression",n=>{var h,d;const{children:r}=n;let s=0;const l=[];for(;s<r.length;s++){const v=r[s];v.ruleIndex===F.RULE_singleExpression&&l.push(this.visit(v))}if(this._memberIndexVerify(l[0],n),this._hasMemberIndex=!0,((h=l[0])==null?void 0:h.ruleType)===le.MemberIndexExpression){const v=r[1];this._errors.push({message:ye(de.unaryErr,{sign:"["}),startColumn:v.symbol.column+1,startLineNumber:v.symbol.line,endColumn:v.symbol.column+2,endLineNumber:v.symbol.line}),this._hasMemberIndex=!1}return{ruleType:le.MemberIndexExpression,type:(d=l[0])==null?void 0:d.type,ctx:n,isInFunc:this._isInFunc,exprs:l}});k(this,"visitMethodStmt",n=>{var C;const{children:r,start:s}=n;let l=0;const h=[],d=[],v=this._commentsParser(s.line,[Kt.description],!0);this._currentLine=s.line;let S;for(;l<r.length;l++){const A=r[l];A.ruleIndex===F.RULE_methodElement&&(h.push(this.visit(A)),d.push(A))}return((C=h[0])==null?void 0:C.name)===Ii.library&&v.description&&(this._description=v.description.join(`
|
12
12
|
`)),S=this._getMethodTypes(h,d)||[],this._inputFuncTitleVerify(h,n),{ruleType:le.MethodExpression,types:S.length>1||S.isBrackethesized||S.isUnknown?S:void 0,ctx:n,type:S.length===1?S[0]:void 0,exprs:h}});k(this,"visitMethodExpression",n=>{const{children:r}=n;if(r&&r.length){const s=r[0];return this.visit(s)}return null});k(this,"visitLogicalAndExpression",n=>{const{children:r}=n;let s=0,l="";const h=[];for(;s<r.length;s++){const S=r[s];S.ruleIndex===F.RULE_singleExpression?h.push(this.visit(S)):l=S.symbol.text}const d=this._boolTypeJudge(h[0],r[0],l),v=this._boolTypeJudge(h[1],r[2],l,1);return{ruleType:le.LogicalAndExpression,type:this._typeHandle([d,v],U.BOOL),operator:l,ctx:n,exprs:h}});k(this,"visitLogicalOrExpression",n=>{const{children:r}=n;let s=0,l="";const h=[];for(;s<r.length;s++){const S=r[s];S.ruleIndex===F.RULE_singleExpression?h.push(this.visit(S)):l=S.symbol.text}const d=this._boolTypeJudge(h[0],r[0],l),v=this._boolTypeJudge(h[1],r[2],l,1);return{ruleType:le.LogicalOrExpression,operator:l,ctx:n,type:this._typeHandle([d,v],U.BOOL),exprs:h}});k(this,"visitMultiplicativeExpression",n=>{const{children:r}=n;let s=0,l="";const h=[];for(;s<r.length;s++){const S=r[s];S.ruleIndex===F.RULE_singleExpression?h.push(this.visit(S)):l=S.symbol.text}const d=this._calcTypeJudge(h[0],r[0],l),v=this._calcTypeJudge(h[1],r[2],l,1);return{ruleType:le.MultiplicativeExpression,operator:l,ctx:n,type:this._typeHandle([d,v]),exprs:h}});k(this,"visitBrackethesized",n=>{const{children:r,start:s}=n,l=r[1];return this._currentLine=s.line,{ruleType:le.Brackethesized,ctx:n,exprs:this.visit(l)}});k(this,"visitArguments",n=>{const{children:r}=n;let s=0;const l={params:[]};let h="";for(;s<r.length;s++){const d=r[s];if(d.ruleIndex===F.RULE_argument){const v=this.visit(d),S=v.paramKey;S?(h=S,l[S]?this._errorHandle(ye(sr.moreSameArg,{arg:S}),n.parentCtx,Sn.Warning):(l[S]=v.param,l[S].ctx=d)):h?this._errorHandle(ye(de.argsSyntaxErr,{argName:h}),d):(v.ctx=d,l.params.push(v))}}return l});k(this,"visitArgument",n=>{const{children:r}=n;return r.length===1?this.visit(r[0]):{paramKey:this.visit(r[0]),param:this.visit(r[2])}});k(this,"visitIfStatement",n=>{const{children:r}=n;let s=0;const l={ruleType:le.IfStatement,condition:[],block:[],ctx:n,typeList:[]};for(;s<r.length;s++){const h=r[s];switch(h.ruleIndex){case F.RULE_singleExpression:const d=this.visit(h);if(!d)break;d.ctx=h,l.condition.push(d);break;case F.RULE_blockLine:const v=this._isInLocalScop;this._isInLocalScop=!0;const S=this.visit(h);l.typeList.push(this._getBlockReturnTypes(S)),l.block.push(S),this._isInLocalScop=v;break}}return this._verifyIf(l),l});k(this,"visitForToStatement",n=>{const{children:r}=n;let s=0;const l={ruleType:le.ForToStatement,numerical:[],ctx:n,block:[]};for(;s<r.length;s++){const h=r[s];switch(h.ruleIndex){case F.RULE_varModifier:l.declare=this.visit(h);break;case F.RULE_typeGather:const d=this.visit(h);l.type=d&&this._typeAddSeries(d);break;case F.RULE_identifier:l.name=this.visit(h);break;case F.RULE_singleExpression:this._blockCount++,this._forToNameHandle(l,n);const v=this.visit(h);v&&(v.ctx=h,l.numerical.push(v)),this._blockCount--;break;case F.RULE_blockLine:this._loopCount++;const S=this._isInLocalScop;this._isInLocalScop=!0,l.block=this.visit(h),this._loopCount--,this._isInLocalScop=S,l.returnedTypes=this._getBlockReturnTypes(l.block);break}}return this._verifyForTo(l),l});k(this,"visitForInStatement",n=>{const{children:r}=n;let s=0;const l={ruleType:le.ForInStatement,ctx:n,names:[]};for(;s<r.length;s++){const h=r[s];switch(h.ruleIndex){case F.RULE_identifier:const d=this.visit(h);l.names.push(d);break;case F.RULE_singleExpression:this._blockCount++,l.array=this.visit(h);const v=l.array.type;this._forInNameHandle(l,n),this._isArrayType(v)||this._isMatrixType(v)||v===U.UNDETERMINED||this._errorHandle(ye(de.typeMismatch,{operator:"foreach",index:"id",typeE:v,typeR:"array<fun_arg>"}),h),this._blockCount--;break;case F.RULE_blockLine:this._loopCount++;const S=this._isInLocalScop;this._isInLocalScop=!0,l.block=this.visit(h),this._isInLocalScop=S,this._loopCount--,l.returnedTypes=this._getBlockReturnTypes(l.block);break}}return l});k(this,"visitSwitchStatement",n=>{const{children:r}=n;let s=0;const l={ruleType:le.SwitchStatement,condition:!0,ctx:n,cases:[],defaultCase:void 0};for(;s<r.length;s++){const h=r[s];switch(h.ruleIndex){case F.RULE_singleExpression:if(l.condition=this.visit(h),!h.children)break;l.condition.ctx=h;break;case F.RULE_caseClause:l.cases.push(this.visit(h));break;case F.RULE_defaultCaluse:l.defaultCase=this.visit(h);break}}return this._verifySwitch(l),l});k(this,"visitCaseClause",n=>{const{children:r}=n,s={ruleType:le.CaseClause},l=this._isInLocalScop;return this._isInLocalScop=!0,s.condition=this.visit(r[0]),s.condition&&(s.condition.ctx=r[0],s.block=this.visit(r[2]),this._isInLocalScop=l,s.returnedTypes=this._getBlockReturnTypes(s.block)),s});k(this,"visitDefaultCaluse",n=>{const{children:r}=n,s={ruleType:le.DefaultCaluse},l=this._isInLocalScop;return this._isInLocalScop=!0,s.block=this.visit(r[1]),this._isInLocalScop=l,s.returnedTypes=this._getBlockReturnTypes(s.block),s});k(this,"visitWhileStatement",n=>{const{children:r}=n,s={ruleType:le.WhileStatement,ctx:n};if(s.condition=this.visit(r[1]),!s.condition)return s;s.condition.ctx=r[1],this._loopCount++;const l=this._isInLocalScop;return this._isInLocalScop=!0,s.block=this.visit(r[2]),this._isInLocalScop=l,this._loopCount--,s.returnedTypes=this._getBlockReturnTypes(s.block),this._verifyWhile(s),s});k(this,"visitImportStmt",async n=>{const{children:r,start:s}=n;let l=0;const h=[];for(this._currentLine=s.line;l<r.length;l++){const d=r[l];if(d.ruleIndex===F.RULE_importElement){const v=await this.visit(d);v&&h.push(v)}}return h});k(this,"visitImportElement",async n=>{const{children:r}=n;if(!r||!r.length)return;let s=0;const l=[],h={ruleType:le.ImportElement,ctx:n};for(;s<r.length;s++){const d=r[s];d.ruleIndex===F.RULE_identifier?l.push(this.visit(d)):d.symbol&&d.symbol.type===F.IntegerLiteral&&(h.libraryVersion=d.symbol.text)}return h.username=l[0],h.libraryName=l[1],h.name=l[2],await this._importHandle(h,n),h});k(this,"visitLiteral",n=>{const{children:r}=n,s=r[0],{type:l,text:h}=s.symbol,d={ruleType:le.Literal,ctx:n,type:"",value:h};switch(l){case F.ColorLiteral:d.type=U.COLOR;break;case F.BooleanLiteral:d.type=U.BOOL;break;case F.StringLiteral:if(d.type=U.STRING,h.includes(`
|
13
|
-
`)){const v=h.replace(/\s*(\n|\r)\s*/g," ");d.value=`\`${v.substring(1,v.length-1)}\``}break;case F.IntegerLiteral:d.type=U.INT;break;case F.DecimalLiteral:d.type=U.FLOAT;break}return d.type&&(d.type=`${U.CONST} ${d.type}`),d});k(this,"visitMethodElement",n=>{const{children:r}=n,[s,l]=r,[h,d,v]=this.visit(s),S=this.visit(l);return h.startsWith("request.")&&this._isInFunc&&(this._currentExportFunc&&this._errorHandle(ye(de.exportFuncUseReqErr,{name:h}),n),this._hasRequest=!0),{name:h,type:d,args:S,expr:v}});k(this,"visitMethodName",n=>{const{children:r}=n,s=[],l=[];let h=0,d=null;for(;h<r.length;h++){const S=r[h],C=S.ruleIndex,A=S.symbol;switch(C){case F.RULE_identifier:s.push(this.visit(S));break;case F.RULE_singleExpression:d=this.visit(S);break;case F.RULE_typeName:const R=this.visit(S);l.push(R),this._typeCheck(R,F.RULE_typeName,S);break;default:A&&A.text==="."&&s.push(".")}}const v=s.join("");return L_.includes(v)?this._hasDrawFunc=!0:M_.includes(v)&&(this._hasCreateOrderFunc=!0),[v,l,d]});k(this,"visitArrowFunction",n=>{const{children:r,start:s,stop:l}=n,h={ruleType:le.ArrowFunction,returnedTypes:[]};let d=0,v={lineNumber:0,column:0};const S=this._commentsParser(s.line,[Kt.function,Kt.param,Kt.returns],!0);Object.assign(h,{desc:S[Kt.function],paramsDesc:S[Kt.param],returnsDesc:S[Kt.returns]}),this._currentLine=s.line;let C=null;for(;d<r.length;d++){const A=r[d],R=A.ruleIndex,B=A.symbol;switch(R){case F.RULE_identifier:v={lineNumber:A.start.line,column:A.start.column},h.name=this.visit(A);break;case F.RULE_arrowFunctionParameters:h.params=this.visit(A),h.isExport&&this._exportArgsTypeVerify(h.params),this._setFuncParams(h,{endColumn:l.column,endLineNumber:l.line-1,startColumn:s.column,startLineNumber:s.line}),C=A;break;case F.RULE_block:this._isInFunc=!0,h.isExport&&(this._currentExportFunc=h.name),this._hasMemberIndex=!1,this._hasRequest=!1,h.block=this.visit(A),h.hasMemberIndex=this._hasMemberIndex,h.returnedTypes=this._getBlockReturnTypes(h.block),this._isInFunc=!1,this._currentExportFunc="";break;default:B&&B.type===F.Export&&(h.isExport=!0,this._addExportPos(B,"functions"))}}return h.hasRequest=this._hasRequest,this._setFunc(h,v,C,l.line-1),this._hasRequest=!1,this._currentFuncParams.clear(),h});k(this,"visitArrowFunctionParameters",n=>{const{children:r}=n;let s=0,l=[];for(;s<r.length;s++){const h=r[s];h.ruleIndex===F.RULE_formalParameterList&&(l=this.visit(h))}return l});k(this,"visitFormalParameterList",n=>{const{children:r}=n;let s=0;const l=[];for(;s<r.length;s++){const h=r[s];h.ruleIndex===F.RULE_formalParameterArg&&l.push(this.visit(h))}return l});k(this,"visitFormalParameterArg",n=>{const{children:r}=n;let s=0;const l={};for(;s<r.length;s++){const h=r[s];switch(h.ruleIndex){case F.RULE_typeGather:const d=this.visit(h);l.type=d&&this._typeAddSeries(d);break;case F.RULE_identifier:l.name=this.visit(h);break;case F.RULE_singleExpression:l.defaultValue=this.visit(h),delete l.defaultValue.ctx}}return l.ctx=n,this._verifyArgsDefaultValue(l,n),l.type=l.type||U.UNDETERMINED,l});k(this,"visitArrowMethod",n=>{const{children:r,start:s,stop:l}=n;let h=0;const d={ruleType:le.ArrowMethod,returnedTypes:[]};let v={lineNumber:0,column:0};const S=this._commentsParser(s.line,[Kt.function,Kt.param,Kt.returns],!0);Object.assign(d,{desc:S[Kt.function],paramsDesc:S[Kt.param],returnsDesc:S[Kt.returns]}),this._currentLine=s.line;let C=null;for(;h<r.length;h++){const A=r[h];switch(A.ruleIndex){case F.RULE_identifier:v={lineNumber:A.start.line,column:A.start.column},d.name=this.visit(A);break;case F.RULE_arrowMethodParameters:d.params=this.visit(A),d.isExport&&this._exportArgsTypeVerify(d.params),this._setFuncParams(d,{endColumn:l.column,endLineNumber:l.line-1,startColumn:s.column,startLineNumber:s.line}),C=A;break;case F.RULE_block:this._isInFunc=!0,d.isExport&&(this._currentExportFunc=d.name),this._hasMemberIndex=!1,this._hasRequest=!1,d.block=this.visit(A),d.hasMemberIndex=this._hasMemberIndex,d.returnedTypes=this._getBlockReturnTypes(d.block),this._isInFunc=!1,this._currentExportFunc="";break;default:A.symbol&&A.symbol.type===F.Export&&(d.isExport=!0,this._addExportPos(A.symbol,"methods"));break}}return d.hasRequest=this._hasRequest,this._setFunc(d,v,C,l.line-1),this._setMethod(d,v),this._hasRequest=!1,this._currentFuncParams.clear(),d});k(this,"visitArrowMethodParameters",n=>{const{children:r}=n;let s=0;const l={};let h=[];for(;s<r.length;s++){const d=r[s];switch(d.ruleIndex){case F.RULE_typeGather:const v=this.visit(d);l.type=v&&this._typeAddSeries(v);break;case F.RULE_identifier:l.ctx=d,l.name=this.visit(d);break;case F.RULE_formalParameterList:h=this.visit(d);break}}return[l,...h]});k(this,"visitTypeStatement",n=>{const{children:r,start:s,stop:l}=n;let h=0;const d={ruleType:le.TypeStatement,fields:[]},v=this._commentsParser(s.line,[Kt.type,Kt.field]);Object.assign(d,{desc:v[Kt.type],fieldsDesc:v[Kt.field]}),this._currentLine=s.line;let S={lineNumber:0,column:0},C=null;for(;h<r.length;h++){const A=r[h];switch(A.ruleIndex){case F.RULE_identifier:S={lineNumber:A.start.line,column:A.start.column},C=A,d.name=this.visit(A),this._verifyTypeName(d.name,A);break;case F.RULE_typeElement:d.fields.push(this.visit(A));break;default:A.symbol&&A.symbol.type===F.Export&&(d.isExport=!0,this._addExportPos(A.symbol,"types"));break}}if(d.isExport){const A=l.line-1,{line:R=0}=this._endExport;A>R&&(this._endExport={line:A,name:d.name})}return this._setUserType(d,S,C),this._setNewFunc(d,S),this._setCopyFunc(d,S),this._setCopyMethod(d,S),d});k(this,"visitTypeElement",n=>{const{children:r,start:s}=n;let l=0;const h={};let d=null,v=null;for(this._currentLine=s.line;l<r.length;l++){const S=r[l];switch(S.ruleIndex){case F.RULE_typeGather:const C=this.visit(S);if(S.children[0].ruleIndex===F.RULE_typeSeries){const{column:A,line:R,text:B}=S.start,M=A+1;this._errors.push({startColumn:M,endColumn:parseInt(M+B.length),startLineNumber:R,endLineNumber:R,message:ye(this._buildinTypes.has(B)?de.typeUseError:de.notTypeKeyword,{text:B})}),h.type=U.UNDETERMINED}else h.type=C&&this._typeAddSeries(C);break;case F.RULE_identifier:h.name=this.visit(S),v=S;break;case F.RULE_singleExpression:d=S,h.value=this.visit(S);break;default:S.symbol&&S.symbol.type===F.Varip&&(h.isVarip=!0);break}}return this._typeElementVerify(h,d,v),h});k(this,"visitAssignmentOperator",n=>{const{children:r}=n;return r&&r[0].symbol.text});k(this,"visitTypeMap",n=>{const{children:r}=n;let s=0;const l=[];for(;s<r.length;s++){const h=r[s];if(h.ruleIndex===F.RULE_typeName){const d=this.visit(h);l.push(d),this._typeCheck(d,F.RULE_typeName,h)}}return`map<${l[0]},${l[1]}>`});k(this,"visitTypeSeries",n=>{const{children:r}=n,[s,l]=r,h=this.visit(s),d=this.visit(l);return this._typeCheck(h,F.RULE_typeSeries,s),this._typeCheck(d,F.RULE_typeName,l),`${h} ${d}`});k(this,"visitTypeArray",n=>{const{children:r}=n,s=r[0];let l=this.visit(s),h=l;if(r.length===3)l=U.ARRAY;else{this._typeCheck(l,F.RULE_typeArray,s);let d=1;for(;d<r.length;d++){const v=r[d];v.ruleIndex===F.RULE_typeName&&(h=this.visit(v),this._typeCheck(h,F.RULE_typeName,v))}}return this._arrayTypeConvert(`${l}<${h}>`)});k(this,"visitTypeGather",n=>{const{children:r}=n;if(r&&r.length){const s=r[0],l=this.visit(s);return s.ruleIndex===F.RULE_typeName&&this._typeCheck(l,F.RULE_typeName,s),l}return null});k(this,"visitIdentifier",n=>n.children&&n.children[0].symbol.text);k(this,"visitTypeName",n=>{const{children:r}=n;let s=0,l="";for(;s<r.length;s++){const h=r[s];h.ruleIndex===F.RULE_identifier?l=`${l}${this.visit(h)}`:l=`${l}.`}return l});k(this,"visitEnumStatement",n=>{const{children:r,start:s,stop:l}=n;let h=0;const d={ruleType:le.EnumStatement,fields:[]},v=this._commentsParser(s.line,[Kt.enum,Kt.field]);Object.assign(d,{desc:v[Kt.enum],fieldsDesc:v[Kt.field]}),this._currentLine=s.line;let S={lineNumber:0,column:0},C=null;for(;h<r.length;h++){const A=r[h];switch(A.ruleIndex){case F.RULE_identifier:S={lineNumber:A.start.line,column:A.start.column},C=A,d.name=this.visit(A),this._verifyEnumName(d.name,A);break;case F.RULE_enumElement:d.fields.push(this.visit(A));break;default:A.symbol&&A.symbol.type===F.Export&&(d.isExport=!0,this._addExportPos(A.symbol,"enums"));break}}if(d.isExport){const A=l.line-1,{line:R=0}=this._endExport;A>R&&(this._endExport={line:A,name:d.name})}return this._setUserEnum(d,S,C),d});k(this,"visitEnumElement",n=>{const{children:r,start:s}=n;let l=0;const h={};for(this._currentLine=s.line;l<r.length;l++){const d=r[l];switch(d.ruleIndex){case F.RULE_identifier:h.name=this.visit(d);break;default:d.symbol&&d.symbol.type===F.StringLiteral&&(h.value=d.symbol.text);break}}return h});k(this,"visitName",n=>{const{children:r}=n;let s=0,l=!1;const h=[];let d=null;for(;s<r.length;s++){const v=r[s];switch(v.ruleIndex){case F.RULE_identifier:h.push(this.visit(v));break;case F.RULE_singleExpression:d=this.visit(v);break;case F.RULE_methodElement:l=!0;const S=this.visit(v);S.ctx=v,h.push(S);break}}return this._nameHandle(l,h,d,n)});this._loopCount=0,this._errors=[],this._variables=new Map,this._functions=new Map,this._methods=new Map,this._currentFuncParams=new Map,this._types=new Map,this._enums=new Map,this._currentBlockVars=[new Map],this._blockCount=0,this._isInFunc=!1,this._isNeedCalc=!1,this._blockRanges=[],this._overloadsFuncs=[],this._hasMemberIndex=!1,this._isInLocalScop=!1,this._onlyStatementsCount=0,this._comments=r,this._exportFunctions=[],this._exportMethods=[],this._exportTypes=[],this._exportEnums=[],this._exportPositions=[],this._endExport={},this._importLibs=new Map,this._getImportLibraryFunc=s}get overloadsFuncs(){return this._overloadsFuncs}get errors(){return this._errors}get userEnums(){return this._enums}get userTypes(){return this._types}get userFunctions(){return this._functions}get userVariables(){return this._variables}get userMethods(){return this._methods}get hasUseDrawFunc(){return this._hasDrawFunc}get hasUseCreateOrderFunc(){return this._hasCreateOrderFunc}get scriptType(){return this._scriptType}get exportLibs(){return{functions:[...this._exportFunctions],methods:[...this._exportMethods],types:[...this._exportTypes],enums:[...this._exportEnums]}}get description(){return this._description}get exportPositions(){return this._exportPositions}get endExport(){return this._endExport}get imports(){return this._importLibs}_verifyGloablVar(n,r){const{name:s,varPos:l,isBuiltIn:h}=n;if(h&&this._errorHandle(ye(de.buidinAssignErr,{name:s}),r),!l)return;const d=this._currentBlockVars[0].get(s);if(!d)return;const{column:v,lineNumber:S}=d.pos||{};this._isInFunc&&v===l.column&&S===l.lineNumber?this._errorHandle(ye(de.modifyGlobalVarErr,{name:s}),r):d.hasAssigned=!0}_inputFuncTitleVerify(n,r){if(!(n!=null&&n.length)||n.length>1)return;const{name:s,args:l,isBuiltIn:h}=n[0];if(h&&!this._strategyFuncName&&s.startsWith(Ii.strategy))this._strategyFuncName={ctx:r,name:s};else if(!s.startsWith(U.INPUT))return;this._inputVarName&&!(l.params.some(d=>d.originName==="title")||l.title)&&(l.title={value:`"${this._inputVarName}"`,ruleType:le.Literal,type:`${U.CONST} ${U.STRING}`})}_verifyIf(n){const{condition:r}=n;if(r!=null&&r.length)for(const s of r){const{type:l,ctx:h}=s;if(l===U.UNDETERMINED)continue;const d=this._removePrefix(l);[U.INT,U.FLOAT].includes(d)?this._errorHandle(ye(sr.conditionWarning,{name:"if"}),h,Sn.Warning):d!==U.BOOL&&this._errorHandle(ye(de.conditionalErr,{name:"if"}),h)}}_forToNameHandle(n,r){if(n.name&&n.numerical.length===1){this._pushBlockRanges(r);const s=n.numerical[0].type;this._variablesHandle({nameList:{name:n.name,isForVar:!0,type:n.type},value:{type:s||`${U.SERIES} ${U.INT}`}},r),this._blockRanges.pop()}}_verifyForTo(n){const{numerical:r}=n;if(r!=null&&r.length)for(const s of r){const{type:l,ctx:h}=s;if(l===U.UNDETERMINED)continue;const d=this._removePrefix(l);[U.INT,U.FLOAT].includes(d)||this._errorHandle(de.fortoErr,h)}}_forInNameHandle(n,r){if(this._pushBlockRanges(r),n.names.length){let[s,l]=n.names;const h=n.array.type;l?this._variablesHandle({nameList:{name:s,isForVar:!0,type:`${U.SERIES} ${U.INT}`},value:{type:`${U.SERIES} ${U.INT}`}},r):l=s;const d=h===U.UNDETERMINED?h:this._isMatrixType(h)?`${this._getArrayType(h)}[]`:this._typeAddSeries(this._getArrayType(h));this._variablesHandle({nameList:{name:l,isForVar:!0,type:d},value:{type:d}},r)}this._blockRanges.pop()}_verifySwitch(n){var r;if(n.cases){const s=(r=n.condition)==null?void 0:r.type;if(s===U.UNDETERMINED)return;if(s&&this._types.has(s)){this._errorHandle(ye(de.typeMismatch,{operator:"switch",index:"expr0",typeE:s,typeR:`${U.SIMPLE} ${U.STRING}`}),n.condition.ctx);return}for(const l of n.cases){const{condition:{type:h,ctx:d}}=l;if(h!==U.UNDETERMINED)if(this._types.has(h))this._errorHandle(ye(de.typeMismatch,{operator:"case",index:"expr1",typeE:h,typeR:`${U.SIMPLE} ${U.STRING}`}),d);else if(s){if(!this._compareType(s,h)){const v=this._removePrefix(s),S=this._removePrefix(h);v===U.BOOL&&[U.INT,U.FLOAT].includes(S)?this._errorHandle(ye(sr.conditionWarning,{name:"switch"}),d,Sn.Warning):[U.INT,U.FLOAT].includes(v)&&S===U.BOOL?this._errorHandle(ye(sr.conditionWarning,{name:"switch"}),n.condition.ctx,Sn.Warning):this._errorHandle(ye(de.typeMismatch,{operator:"case",index:"expr1",typeE:h,typeR:`${s}`}),d)}}else{const v=this._removePrefix(h);[U.INT,U.FLOAT].includes(v)?this._errorHandle(ye(sr.conditionWarning,{name:"switch"}),d,Sn.Warning):v!==U.BOOL&&this._errorHandle(ye(de.conditionalErr,{name:"switch"}),d)}}}}_verifyWhile(n){const{condition:r}=n;if(r){const{type:s,ctx:l}=r;if(s===U.UNDETERMINED)return;const h=this._removePrefix(s);[U.INT,U.FLOAT].includes(h)?this._errorHandle(ye(sr.conditionWarning,{name:"while"}),l,Sn.Warning):h!==U.BOOL&&this._errorHandle(ye(de.conditionalErr,{name:"while"}),l)}}async _importHandle(n,r){const{stop:s,start:l}=r,{username:h,libraryName:d,libraryVersion:v,name:S}=n,C=`${h}/${d}/${v}`;if(this._importLibs.has(C))return this._errorHandle(de.importMultipleErr,r),n;for(const[B,M]of this._importLibs)if(M.name&&M.name===S||!M.name&&!S&&M.libraryName===d)return this._errorHandle(ye(de.importNameRepeatErr,{name:S,line:M.startLine}),r),n;let A=S||d;const R=await this._getImportLibraryFunc({...n,libraryId:C,ctx:void 0,startLine:l.line,endLine:s.line,startColumn:l.column,endColumn:s.column+s.text.length+1});if(R){const{codeStr:B,description:M}=R;this._importLibs.set(C,{...n,libraryId:C,startLine:l.line,endLine:s.line,ctx:void 0,desc:M}),this._importDataHandle(R,A),Rn.includes(A)&&(A=`$${A}`),n.code=B.replace("$name",A)}else this._errorHandle(ye(de.importNotExitErr,{username:h,libraryName:d}),r)}_importDataHandle(n,r){const{functions:s,methods:l,types:h}=n;for(const d of s){const{name:v}=d,S=`${r}.${v}`,C=this._functions.get(S)||[];C.push({...this._importTypeUpdate(d,h,r),name:S,isUser:void 0,isImport:!0}),this._functions.set(S,C)}for(const d of l){const v=this._importTypeUpdate(d,h,r),S=v.originalName||v.name,C=this._methods.get(S)||[];C.push({...v,isImport:!0,isUser:void 0}),this._methods.set(S,C)}for(const d of h){const v=`${r}.${d.name}`,S=this._types.get(v)||[];S.push({...this._importTypeUpdate(d,h,r),name:v,isImport:!0}),this._types.set(v,S)}}_importTypeUpdate(n,r,s){var B;let{args:l,returnedTypes:h,thisType:d,fields:v,name:S,originalName:C}=n,A="";if(l&&l.length&&(l=l.map(M=>{const{allowedTypeIDs:b,displayType:y,name:g}=M,O=y&&this._replaceTypeName(y,r,s);return A=A?`${A}, ${O} ${g}`:`${O} ${g}`,{...M,allowedTypeIDs:b==null?void 0:b.map(w=>this._replaceTypeName(w,r,s)),displayType:O}})),h!=null&&h.length&&(h=[this._replaceTypeName(h[0],r,s)]),d!=null&&d.length){const M=this._replaceTypeName(d[0],r,s);M!==d[0]&&(C=`${s}.${C||S}`),d=[M]}v!=null&&v.length&&(v=v.map(M=>{const{type:b}=M;return{...M,type:b&&this._replaceTypeName(b,r,s)}}));const R={...n,args:l,returnedTypes:h,thisType:d,fields:v,originalName:C};return(B=R.syntax)!=null&&B.length&&(R.syntax=[`${C||`${s}.${S}`}(${A}) → ${(h==null?void 0:h[0])||"void"}`]),R}_replaceTypeName(n,r,s){const l=r.find(h=>n.includes(h.name));return l?n.replace(l.name,`${s}.${l.name}`):n}_verifyArgsDefaultValue(n,r){const{defaultValue:s,type:l}=n;if(!s)return;const{ruleType:h,isBuiltIn:d,type:v}=s,S=this._removePrefix(v);if(h!==le.Literal&&!d)delete n.defaultValue,this._errorHandle(de.argDefaultErr,r);else if(l&&l!==U.UNDETERMINED&&v!==U.UNDETERMINED){const C=this._removePrefix(l);if(C===U.FLOAT&&S===U.INT)return;S!==C&&this._errorHandle(ye(de.defaultValueTypeErr,{typeE:v,typeR:l}),r)}else l||(n.type=this._typeAddSeries(S===U.INT?U.FLOAT:S))}_exportArgsTypeVerify(n){for(const r of n)(r.type===U.UNDETERMINED||!r.type)&&this._errorHandle(de.exportFuncArgErr,r.ctx)}_verifyTypeName(n,r){lu.includes(n)?this._errorHandle(ye(de.typeNameErr,{name:n}),r):Pp.includes(n)&&this._errorHandle(ye(de.enumVarNameBuiltinErr,{name:n}),r)}_addExportPos(n,r){const{line:s,column:l,text:h}=n;this._exportPositions.push({startLineNumber:s,startColumn:l,endLineNumber:s,endColumn:l+h.length+1,type:r})}_verifyEnumName(n,r){lu.includes(n)?this._errorHandle(ye(de.enumVarNameErr,{name:n}),r):Pp.includes(n)&&this._errorHandle(ye(de.enumVarNameBuiltinErr,{name:n}),r)}_nameHandle(n,r,s,l){var d,v;const h={ruleType:le.Name,hasMethod:n,exprs:r,expr:s};if(n){let S="";const C=[];for(const R of r)typeof R=="string"?S=S?`${S}.${R}`:R:(S&&(R.name=`${S}.${R.name}`),C.push(R),S="");h.exprs=[...C,S];const A=this._getMethodTypes(C,Array.from(C,()=>l));if(A&&A.length){const R=ye(de.noFiledErr,{name:S});A.length>1&&this._errorHandle(R,l),h.type=((v=this._nameCheck(this._getOriginMethodName(A[0],S),l,R))==null?void 0:v.type)||U.UNDETERMINED}}else{let S=r.join(".");if(s&&s.type&&s.type===U.UNDETERMINED)h.type=U.UNDETERMINED,S=`expr0.${S}`;else{s&&s.type&&(S=`${this._getMethodTypeName(s.type)}.${S}`);const C=this._nameCheck(S,l)||{};(d=C.title)!=null&&d.startsWith("built-in")&&(h.isBuiltIn=!0,h.isConst=C.isConst,!this._strategyVarName&&S.startsWith(Ii.strategy)&&(this._strategyVarName={ctx:l,name:S})),h.enumName=C.enumName,h.varPos=C.pos,h.varScope=C.scope,h.declare=C.declare,h.type=(C==null?void 0:C.type)||U.UNDETERMINED,C!=null&&C.isArg&&(h.arg=C),h.scope=this._blockCount,C.isEnum?this._errorHandle(ye(de.enumUseErr,{name:S}),l):this._isInFunc&&this._currentExportFunc&&(h.type.startsWith(U.INPUT)?this._errorHandle(ye(de.exportFuncHasInputErr,{name:S,func:this._currentExportFunc}),l):C.scope===0&&C.hasAssigned&&this._errorHandle(ye(de.exportFuncUseGlobalVarErr,{func:this._currentExportFunc}),l))}h.name=S}return h}_typeElementVerify(n,r,s){var v,S;const{type:l,value:h}=n;if(!h){l||this._errorHandle(de.typeFieldErr,s);return}if(![le.Literal,le.UnaryExpression].includes(h.ruleType)&&!h.isBuiltIn){this._errorHandle(de.defaultValueErr,r);return}else if(h.ruleType===le.UnaryExpression){const{exprs:C}=h;if(![le.Literal,le.UnaryExpression].includes((v=C[0])==null?void 0:v.ruleType)&&!((S=C[0])!=null&&S.isBuiltIn)){this._errorHandle(de.defaultValueErr,r);return}}if(!l){const C=h.type,A=this._getPrefix(C);n.type=A?this._typeAddSeries(this._removePrefix(C)):C;return}(!this._compareType(l,h.type)||l.endsWith(U.INT)&&h.type.endsWith(U.FLOAT))&&this._errorHandle(ye(de.defaultValueTypeErr,{typeE:h.type,typeR:l}),r)}_memberIndexVerify(n,r){if(n.ruleType===le.Name&&!n.hasMethod&&this._blockCount){const l=this._currentBlockVars[this._blockCount],h=l&&l.get(n.name);h&&(h.isForVar?this._errorHandle(ye(de.notHistoryErr,{name:n.name}),r):!(this._blockCount===1&&this._isInFunc)&&this._errorHandle(ye(sr.localScopeGetHistory,{name:n.name}),r,Sn.Warning))}const s=n&&n.type;if(s){const l=this._removePrefix(s);!this._types.has(l)&&!this._buildinTypes.has(l)&&!this._isArrayType(l)&&!this._isMatrixType(l)&&!this._isMapType(l)&&l!==U.UNDETERMINED&&this._errorHandle(ye(de.invalidType,{index:0}),r)}}_setFuncParams(n,r){var s;for(const l of n.params){const h=(s=this._types.get(l.type))==null?void 0:s[0];if(l.scope=this._blockCount+1,h&&h.fields)for(const d of h.fields){const v=`${l.name}.${d.name}`;this._currentFuncParams.set(v,{...d,originName:v,varScope:l.scope})}delete l.ctx,l.range=r,this._setVariablesMap(l,!0),this._currentFuncParams.set(l.name,l)}}_pushBlockRanges(n){!n||!n.start||!n.stop||this._blockRanges.push({startColumn:n.start.column,endColumn:n.stop.column,startLineNumber:n.start.line,endLineNumber:n.stop.line})}_setUserEnum(n,r,s){const{fields:l,name:h,desc:d,fieldsDesc:v}=n,S={members:l.map(C=>({name:C.name,value:C.value,enumName:h,isEnumMember:!0,desc:v==null?void 0:v[C.name],type:`${U.CONST} ${h}`})),name:h,desc:d,pos:r};if(this._enums.has(h)){this._errorHandle(ye(de.typeRepeatErr,{name:h,keyword:Kt.enum}),s);return}else if(this._types.has(h)){this._errorHandle(ye(de.typeRepeatErr,{name:h,keyword:Kt.type}),s);return}n.isExport&&this._exportEnums.push(S),this._enums.set(h,[{...S}]),this._addEnumToMap(h,h,r)}_setUserType(n,r,s){const{fields:l,name:h,desc:d,fieldsDesc:v}=n,S={fields:l.map(C=>({name:C.name,desc:v==null?void 0:v[C.name],type:C.type})),name:h,desc:d,pos:r};if(this._enums.has(h)){this._errorHandle(ye(de.typeRepeatErr,{name:h,keyword:Kt.enum}),s);return}else if(this._types.has(h)){this._errorHandle(ye(de.typeRepeatErr,{name:h,keyword:Kt.type}),s);return}n.isExport&&this._exportTypes.push(S),this._types.set(h,[{...S}]),this._addVarToMap(h,h,r,!1,!1)}_againAssignHandle(n,r,s){const l=s!==":="?s.replace("=",""):s,h=s!==":="?[U.UNDETERMINED,U.INT,U.FLOAT]:[];l==="+"&&h.push(U.STRING);const[d,v]=n;d.arg&&!d.name.includes(".")&&this._errorHandle(ye(de.funcArgAssignErr,{name:d.name}),r[0]);const S=this._sameTypeJudge(n,r,l,h);let C=this._typeHandle(S);return this._updateUserVar(d.name,C,v.type),d.type=C,{ruleType:le.AgainAssign,name:d,operator:s,type:C,value:v}}_typeCheck(n,r,s){const l=[U.SERIES,U.SIMPLE,U.CONST];switch(r){case F.RULE_typeName:const h=this._buildinTypes.get(n);h&&![...l,U.ARRAY,U.MATRIX,U.MAP].includes(h[0].name)||this._types.get(n)||this._errorHandle(ye(de.notTypeKeyword,{text:n}),s);break;case F.RULE_typeArray:[U.ARRAY,U.MATRIX].includes(n)||this._errorHandle(de.tempateTypeErr,s);break;case F.RULE_typeSeries:l.includes(n)||this._errorHandle(ye(de.qualifierErr,{name:n}),s);break}}_getBuildVar(n){const r=this._buildinVariables.get(n);if(r&&r[0])return r[0];const s=this._buildinConstants.get(n);return s&&s[0]?Object.assign(s[0],{isConst:!0}):this._specialTreatmentChartPoint(n)}_specialTreatmentChartPoint(n){var r,s;if(n.startsWith("chart.point")){const l=n.split("."),h=l.pop(),d=l.join(".");return(((s=(r=this._buildinTypes.get(d))==null?void 0:r[0])==null?void 0:s.fields)||[]).find(S=>S.name===h)}}_verifyName(n,r){var l,h;const s=this._getBuildVar(n);if(s)return s;if(n.includes(".")){const d=n.split("."),v=d.pop(),S=d.join(".");let C=this._blockCount;for(;C>=0;){if(!this._currentBlockVars[C]){C--;continue}const R=this._currentBlockVars[C].get(S);if(r&&this._judgeGatherValue(v||"",r,R==null?void 0:R.valueType,!0),(R==null?void 0:R.type)==="chart.point"){const M=(((h=(l=this._buildinTypes.get(R.type))==null?void 0:l[0])==null?void 0:h.fields)||[]).find(b=>b.name===v);if(M)return Object.assign(M,{pos:R.pos})}C--}const A=this._specialTreatmentChartPoint(n);if(A)return A}return this._getUserVar(n)}_judgeGatherValue(n,r,s,l){return s!==`${U.SIMPLE} ${U.NA}`?!0:(l&&this._errorHandle(ye(de.objectIsNaErr,{name:n,type:"field"}),r),!1)}_nameCheck(n,r,s=ye(de.undeclared,{name:n})){const l=this._verifyName(n,r);return l||this._errorHandle(s,r),l}_inBlock(n){this._blockCount++,this._pushBlockRanges(n);const r=this.visit(n);return this._blockCount--,this._blockRanges.pop(),this._currentBlockVars.splice(this._blockCount+1),r}_errorHandle(n,r,s=Sn.Error){this._errors.push({message:n,startColumn:r.start.column+1,startLineNumber:r.start.line,endColumn:r.start.column+2+r.stop.stop-r.start.start,endLineNumber:r.stop.line,type:s})}_boolTypeJudge(n,r,s,l=0){return this._typeJudge(n,r,s,U.BOOL,[U.UNDETERMINED,U.INT,U.FLOAT,U.BOOL],l)}_calcTypeJudge(n,r,s,l=0){return this._typeJudge(n,r,s,"int/float",[U.UNDETERMINED,U.INT,U.FLOAT],l)}_typeJudge(n,r,s,l,h,d=0){const v=n&&n.type;if(v){const S=this._removePrefix(v);if(!h.includes(S)&&S!==U.NA)return this._errorHandle(ye(de.typeMismatch,{operator:`operator ${s}`,index:`expr${d}`,typeE:S,typeR:l}),r),U.UNDETERMINED;l===U.BOOL&&[U.INT,U.FLOAT].includes(S)&&this._errorHandle(ye(sr.typeMismatch,{operator:`operator ${s}`,index:`expr${d}`,type:U.BOOL}),r,Sn.Warning)}return v||U.UNDETERMINED}_sameTypeJudge(n,r,s,l){let h="";const d=[],v=["plot_display","plot_simple_display"];["+","-","+=","-="].includes(s)&&(l=l.concat(v));for(const[S,C]of n.entries()){let A=C&&C.type||U.UNDETERMINED;const R=this._removePrefix(A);if(!l.includes(R)&&l.length&&R!==U.NA){this._errorHandle(ye(de.typeMismatch,{operator:`operator ${s}`,index:`expr${S}`,typeE:A,typeR:l.slice(1).join("/")}),r[S]),h=U.UNDETERMINED,d.push(h);continue}if(!h){h=R,d.push(A);continue}if(h===U.UNDETERMINED||R===U.UNDETERMINED)A=h=U.UNDETERMINED;else if(h!==R&&h!==U.NA&&R!==U.NA&&(![U.INT,U.FLOAT].includes(h)||![U.INT,U.FLOAT].includes(R)))if(s===":="){if(h===U.BOOL&&[U.INT,U.FLOAT].includes(R)){this._errorHandle(ye(sr.boolVarNumWarning,{name:n[0].name}),r[0],Sn.Warning),d.push(A);continue}this._errorHandle(ye(de.assignTypeMismatch,{typeE:R,name:n[0].name,typeR:h}),r[0]),A=h=U.UNDETERMINED}else if(["==","!=","?:"].includes(s)&&[U.INT,U.FLOAT,U.BOOL].includes(h)&&[U.INT,U.FLOAT,U.BOOL].includes(R))this._errorHandle(ye(sr.typeMismatch,{operator:`operator ${s}`,index:`expr${S}`,type:h}),r[S],Sn.Warning),A=h=U.UNDETERMINED;else if(v.includes(h)&&v.includes(R)){if(h!==R){const B=this._getPrefix(A);d[S-1]=`${this._getPrefix(d[S-1])} ${v[0]}`,A=h=`${B} ${v[0]}`}}else this._errorHandle(ye(de.typeMismatch,{operator:`operator ${s}`,index:`expr${S}`,typeE:R,typeR:h}),r[S]),A=h=U.UNDETERMINED;d.push(A)}return d}_getUserVar(n,r=!1){for(let s=this._blockCount;s>=0;s--){const l=this._currentBlockVars[s];if(s<=0){const h=this._currentFuncParams.get(n);if(h)return h.isArg=!0,h}if(l){const h=l.get(n);if(h)return h}}if(n.includes(".")&&!r){let s=!1,l=null;if(n.split(".").reduce((h,d)=>{let v=h?`${h}.${d}`:d;const S=this._getUserVar(v,!0);return S!=null&&S.type?S.type===U.UNDETERMINED?s=!0:(v=S.type,l=S):l=null,v},""),s)return{name:n,type:U.UNDETERMINED};if(l)return l}return null}_repeatVarJudge(n,r,s,l){this._getBuildVar(n)&&this._errorHandle(ye(de.buidinVarErr,{name:n}),r);for(let d=0;d<=this._blockCount;d++){const v=this._currentBlockVars[d];if(v&&v.get(n)){if(this._blockCount===d)return this._errorHandle(ye(de.repeatVar,{name:n}),r),!0;s.reName=`$_${n}__${this._blockCount}`,this._errorHandle(ye(sr.repeatVar,{name:n}),r,Sn.Warning)}}l!=null&&l.some(d=>d===n&&n!=="_")&&this._errorHandle(ye(de.repeatVar,{name:n}),r)}_judgeVarBuildIn(n){for(let r=0;r<=this._blockCount;r++){const s=this._currentBlockVars[r];if(s&&s.get(n))return!0}return!1}_updateUserVar(n,r,s){for(let l=0;l<=this._blockCount;l++){const h=this._currentBlockVars[l];if(h){const d=h.get(n);if(d){d.type=r,d.valueType=s;return}}}}_variablesHandle(n,r){var h,d,v,S;if(!(n&&n.nameList))return;const s=n.nameList;if(s.name==="_")return;const l=n.value;if(s.ruleType===le.VarMultiple){s.types=[],this._checkVarMultiple(s.names,l,r);for(const[C,A]of s.names.entries()){if(A==="_")continue;const R=this._varTypeJudge("",((h=l==null?void 0:l.types)==null?void 0:h[C])||U.UNDETERMINED,A,r);s.types.push(R),this._addVarToMap(A,R,s.posList[C],!0)}}else{const C=(l==null?void 0:l.type)||((d=l==null?void 0:l.returnedTypes)==null?void 0:d[0]);((v=l==null?void 0:l.types)!=null&&v.isBrackethesized||(S=l==null?void 0:l.returnedTypes)!=null&&S.isBrackethesized)&&this._errorHandle(ye(de.tupleLeftVarErr,{name:s.name}),r),!s.type&&C===`${U.SIMPLE} ${U.NA}`&&this._errorHandle(de.naVarErr,r),s.prefix&&Pi.indexOf(s.prefix)>Pi.indexOf(this._getPrefix(C))&&this._errorHandle(ye(de.declaredErr,{prefix:s.prefix,type:C}),r);const A=this._varTypeJudge(s.type,C||U.UNDETERMINED,s.name,r);s.type=A,this._addVarToMap(s.name,A,s.pos,!0,s.isForVar,s.declare,l==null?void 0:l.type,s.desc)}}_checkVarMultiple(n,r,s){var S,C,A,R;const l=n.length,h=((r==null?void 0:r.types)||(r==null?void 0:r.returnedTypes)||[]).length,d=((S=r==null?void 0:r.types)==null?void 0:S.isBrackethesized)||((C=r==null?void 0:r.returnedTypes)==null?void 0:C.isBrackethesized);(A=r==null?void 0:r.types)!=null&&A.isUnknown||(R=r==null?void 0:r.returnedTypes)!=null&&R.isUnknown||(h===1&&!d||!h?this._errorHandle(de.tupleRightVarErr,s):l!==h&&this._errorHandle(ye(de.tupleVarErr,{indexA:h,indexB:l}),s))}_addEnumToMap(n,r,s){var v;const l=this._currentBlockVars[this._blockCount]||new Map,h=(v=this._enums.get(n))==null?void 0:v[0];if(h&&h.members)for(const S of h.members)l.set(`${n}.${S.name}`,S);const d={name:n,isEnum:!0,type:`${U.CONST} ${r}`,pos:s};l.set(n,d),this._currentBlockVars[this._blockCount]=l}_addVarToMap(n,r,s,l=!0,h=!1,d,v,S){var B;const C=this._currentBlockVars[this._blockCount]||new Map,A=(B=this._types.get(r))==null?void 0:B[0];if(A&&A.fields)for(const M of A.fields)C.set(`${n}.${M.name}`,M);const R={name:n,type:r,pos:s,valueType:v,desc:S};l&&this._setVariablesMap(R),C.set(n,Object.assign(R,{isForVar:h,declare:d})),this._currentBlockVars[this._blockCount]=C}_setVariablesMap(n,r=!1){const s=this._blockRanges[this._blockCount];r||(n.range=s,n.scope=this._blockCount);const l=this._variables.get(n.name)||[];l.push(n),this._variables.set(n.name,l)}_varTypeJudge(n,r,s,l){if(r===U.VOID)return this._errorHandle(de.voidNotVar,l),U.UNDETERMINED;if(n&&r!==U.UNDETERMINED){const h=this._removePrefix(n),d=this._removePrefix(r);return d!==h&&d!==U.NA&&!(h===U.FLOAT&&d===U.INT)?h===U.BOOL&&[U.FLOAT,U.INT].includes(d)?(this._errorHandle(ye(sr.boolVarNumWarning,{name:s}),l,Sn.Warning),n):(this._errorHandle(ye(de.declareTypeErr,{type:n,valueType:r}),l),U.UNDETERMINED):this._typeHandle([n,r])}else if(r===U.UNDETERMINED)return U.UNDETERMINED;return n||r||U.UNDETERMINED}_getAllowTypes(n){const r=[];if(n===U.UNDETERMINED)return r;const s=this._getPrefix(n);if(s){const l=this._removePrefix(n);let h=-1;for(const[d,v]of Pi.entries())v===s&&(h=d),h>=0&&h<=d&&(l===U.FLOAT&&r.push(`${v} ${U.INT}`),r.push(`${v} ${l}`))}else n=this._arrayTypeConvert(n)||"",r.push(n),n.includes(U.FLOAT)&&r.push(n.replace(/float/,U.INT));return r}_setNewFunc(n,r){const s=`${n.name}.new`,l=[],h=[];for(const v of n.fields)l.push({name:v.name,required:!1,allowedTypeIDs:this._getAllowTypes(v.type),displayType:v.type}),h.push(`${v.type} ${v.name}`);const d={name:s,args:l,returnedTypes:[n.name],pos:r,syntax:[`${s}(${h.join(", ")}) → ${n.name}`]};n.isExport&&this._exportFunctions.push(d),this._functions.set(s,[{...d,isUser:!0}])}_setCopyFunc(n,r){const s=n.name,l=`${s}.copy`,h={name:l,args:[{name:"object",required:!0,allowedTypeIDs:[s],displayType:s}],returnedTypes:[s],pos:r,info:"The identifier of the object to be copied.",syntax:[`${l}(${s} object) → ${s}`]};n.isExport&&this._exportFunctions.push(h),this._functions.set(l,[{...h,isUser:!0}])}_setCopyMethod(n,r){const s=n.name,l=`${s}.copy`,h={name:l,originalName:l,args:[],returnedTypes:[s],thisType:[s],pos:r,syntax:[`${l}() → ${s}`]};n.isExport&&this._exportMethods.push(h),this._methods.set(l,[{...h,isUser:!0}])}_setFunc(n,r,s,l){const h=[],d=[],{desc:v,paramsDesc:S,returnsDesc:C,params:A,hasMemberIndex:R}=n;for(const O of A){const{type:w,name:D,defaultValue:H}=O;h.push({name:D,desc:S==null?void 0:S[D],required:!H,allowedTypeIDs:this._getAllowTypes(w),displayType:w}),d.push(`${w===U.UNDETERMINED?"":`${w} `}${D}`)}const{returnedTypes:B=[]}=n,M=n.name,b=B.length>1?`[${B.join(", ")}]`:B.toString(),y={name:M,desc:v,args:h,syntax:[`${M}(${d.join(", ")}) → ${b||"void"}`],hasMemberIndex:R,pos:r,isUser:!0,returnedTypes:B,returns:C,hasRequest:this._hasRequest};let g=this._functions.get(M);if(g){const O=g.length;y.index=O,n.index=O,this._verifyFuncRepeat(g,y,s),g.push(y),this._overloadsFuncs.push({name:M,index:O,line:r.lineNumber,startColumn:r.column+1,endColumn:r.column+M.length})}else g=[y];if(n.isExport){const{line:O=0}=this._endExport;l>O&&(this._endExport={line:l,name:M,index:y.index}),this._exportFunctions.push(y)}this._functions.set(M,g)}_setMethod(n,r){var w;const{name:s,returnedTypes:l,params:h,desc:d,paramsDesc:v,returnsDesc:S}=n,C=h[0].type,A=[],R=[];for(const D of h.slice(1)){const{type:H,name:X,defaultValue:ee}=D;A.push({name:X,desc:v==null?void 0:v[X],required:!ee,allowedTypeIDs:this._getAllowTypes(H),displayType:H}),R.push(`${H} ${X}`)}const B=l.length>1?`[${l.join(", ")}]`:l.toString(),M=this._getMethodTypeName(C),b=`${M}.${s}`;n.typeName=M;const y={name:s,args:A,desc:d,originalName:b,syntax:[`${s}(${R.join(", ")}) → ${B||"void"}`],returnedTypes:l,hasMemberIndex:n.hasMemberIndex,pos:r,thisType:[C],returns:S,hasRequest:this._hasRequest};let g=this._methods.get(b),O=this._functions.get(s);if(O){const D=O.filter(ee=>!ee.isImport).length,H=((w=g==null?void 0:g.filter(ee=>!ee.isImport))==null?void 0:w.length)||0;let X=D;D>H&&(X=D-1),y.index=X,n.index=X}g?g.push(y):g=[y],n.isExport&&this._exportMethods.push(y),this._methods.set(b,g)}_verifyFuncRepeat(n,r,s){const{args:l}=r;n.some(d=>{const{args:v}=d;return(v==null?void 0:v.length)!=(l==null?void 0:l.length)?!1:!(v!=null&&v.length)&&!(l!=null&&l.length)?!0:v==null?void 0:v.every((S,C)=>{var A;return S.displayType===((A=l==null?void 0:l[C])==null?void 0:A.displayType)})})&&this._errorHandle(ye(de.funcRepeatErr,{name:r.name}),s)}_getMethodTypes(n,r){let s;for(const[l,h]of n.entries()){const{type:d,expr:v,args:S}=h;let{name:C}=h;const A=r[l];if(v){if(v.type===U.UNDETERMINED)return[U.UNDETERMINED];C=`${this._getMethodTypeName(v.type)}${C}`,S.params.unshift(v)}if(s&&s.length>=1)if(s.length===1){const R=s[0];if(R===U.UNDETERMINED)return[U.UNDETERMINED];const B=this._getOriginMethodName(R,C);C.includes(".")?s=this._getOtherNamesMethodType(B,s,A,S,h):s=this._expandMethodHandle(B,A,S,{type:R},R,h)}else this._errorHandle(ye(de.noFiledErr,{name:C}),A);else{const[R,B]=this._tempFuncNameHandle(C,A,d);C=B;const M=this._buildinFunctions.get(R);if(M)this._globalFuncVerify(M[0],A),this._hasMemberIndexVerify(M[0],A,h),h.isBuiltIn=!0,s=this._getBuildInReturnTypes(M,S,C,A,void 0,d);else{const b=this._functions.get(C);if(b)if(b.length<=1){this._hasMemberIndexVerify(b[0],A,h),s=b[0].returnedTypes;const{hasErr:y}=this._checkArgs(S,b[0].args||[],C,A,s[0]);if(y)return[U.UNDETERMINED]}else{const y=this._overloadsFuncGetTypes(b,S,A,void 0,h);s=this._returnedTypesParse([y])}else s=this._getOtherNamesMethodType(C,s,A,S,h)}}h.returnTypes=s}return s===void 0&&this._errorHandle(ye(de.notFindFuncErr,{name:n[0].name}),r[0]),s}_globalFuncVerify(n,r){this._blockCount!==0&&F_.includes(n.name)&&this._errorHandle(ye(de.globalFuncErr,{name:n.name}),r)}_hasMemberIndexVerify(n,r,s){n.hasRequest&&(s.hasRequest=!0,this._hasRequest=!0),n.hasMemberIndex||n.name.startsWith("ta.")||n.name==="math.sum"?(this._hasMemberIndex=this._isInFunc,s.hasMemberIndex=!0,s.position=r.start.tokenIndex):n.name.startsWith("request.")&&this._isInLocalScop&&this._errorHandle(de.requestUserInLoopErr,r)}_tempFuncNameHandle(n,r,s){let l=n;if(s&&s.length>=1){const h=["array.new","matrix.new"].includes(n),d=n==="map.new";if(s.length===1)if(h)l=`${n}<type>`,n=`${n}<${s[0]}>`;else return d?this._errorHandle(ye(de.templateErr,{countA:2,countB:1}),r):this._errorHandle(ye(de.templateNoSupportErr,{name:n}),r),[U.UNDETERMINED];else{if(!d)return h?this._errorHandle(ye(de.templateErr,{countA:1,countB:2}),r):this._errorHandle(ye(de.templateNoSupportErr,{name:n}),r),[U.UNDETERMINED];if(!lu.includes(s[0]))return this._errorHandle(ye(de.mapKeyErr,{type:this._typeAddSeries(s[0])}),r),[U.UNDETERMINED];l=`${n}<type,type>`,n=`${n}<${s[0]},${s[1]}>`}}return[l,n]}_getOtherNamesMethodType(n,r,s,l,h){const d=n.split("."),v=d.length-1,S=d.slice(0,v).join("."),C=this._getUserVar(S);this._judgeGatherValue(d[v],s,C==null?void 0:C.valueType)||(h.name=`${S}?.${d[v]}`);const R=C==null?void 0:C.type;if(R){if(R===U.UNDETERMINED)return r=[U.UNDETERMINED],r.isUnknown=!0,r;const B=this._getOriginMethodName(R,d[v]);h.varScope=C.scope,r=this._expandMethodHandle(B,s,l,C,S,h)}else{let B="",M="",b="";for(const y of d.slice(0,v)){B?M=this._getOriginMethodName(B,y):M=M?`${M}.${y}`:y;const g=this._verifyName(M);if(g!=null&&g.type){if(B=g.type,b="",g.title.startsWith("built-in variable")){const O=this._getOriginMethodName(B,d[v]);r=this._expandMethodHandle(O,s,l,C,S,h),h.hasVarPrefix=!0}}else this._buildinTypes.get(M)?b=ye(de.methodNotExistErr,{name:M,methodName:d[v]}):b=ye(de.noFiledErr,{name:y})}b&&this._errorHandle(b,s)}return r}_expandMethodHandle(n,r,s,l,h,d){var C,A;let v;const S=this._buildinMethods.get(n);if(S)d.name=d.name.split(".").join("?."),v=this._getBuildInReturnTypes(S,s,n,r,l);else{const R=this._methods.get(n);if(R&&R.length)if(R.length<=1){const B=R[0],M=this._getMethodTypeName(((C=B.thisType)==null?void 0:C[0])||"");if(this._types.get(M))d.name=d.name.split(".").join("?.");else{const g=this._functions.get(B.name);g&&(d.selfArg=(A=g[B.index||0].args)==null?void 0:A[0])}d.funcName=B.name,d.index=B.index,this._hasMemberIndexVerify(B,r,d),v=B.returnedTypes;const{hasErr:y}=this._checkArgs(s,B.args||[],n,r,(v==null?void 0:v[0])||"");if(y)return[U.UNDETERMINED]}else{const B=this._overloadsFuncGetTypes(R,s,r,l,d);v=this._returnedTypesParse([B])}else this._errorHandle(ye(de.methodNotExistErr,{methodName:n.split(".").slice(-1)[0],name:h}),r)}return v}_getBuildInReturnTypes(n,r,s,l,h,d){var S;let v;if(n.length===1){const{returnedTypes:C,syntax:A,args:R=[],thisType:B}=n[0],M=A[0].split("→")[1].trim(),b=h||r.params[0]||((S=R[0])==null?void 0:S.name)&&r[R[0].name];b&&!this._checkMethodThisType(B,b.type)&&this._errorHandle(ye(de.typeMismatch,{operator:s,index:b.name||"id",typeE:b.type,typeR:B[0]}),l);const{hasErr:y,types:g}=this._checkArgs(r,R,s,l,M,b);if(y)return[U.UNDETERMINED];if(v=g.length&&g||this._returnedTypesParse(C),v.length>1)return v;(d==null?void 0:d.length)===1?v=[this._typeReplace(M,d[0])]:(d==null?void 0:d.length)===2&&(v=[`${U.MAP}<${d[0]},${d[1]}>`]),v=this._returnTypesOtherHandle(b,M,v,s)}else{const C=this._overloadsFuncGetTypes(n,r,l,h);v=this._returnedTypesParse([C])}return v}_overloadsFuncGetTypes(n,r,s,l,h){var M,b,y;let d="",v=[],S=[],C=0,A=0;for(const[g,O]of n.entries()){const{args:w,returnedTypes:D,name:H,thisType:X}=O,ee=l||r.params[0]||r[w[0].name],{errMsg:z,warnMsg:Y,matchCount:V}=this._overloadsCheckArgs(r,w,H,s,ee);V>A&&(C=g,A=V),ee&&!this._checkMethodThisType(X,ee.type)&&z.unshift({msg:ye(de.typeMismatch,{operator:H,index:ee.name||"id",typeE:ee.type,typeR:X[0]}),ctx:s}),g===0?(v=z,S=Y,!z.length&&(d=D[0])):z.length?((M=v[0])!=null&&M.isLenErr&&!((b=z[0])!=null&&b.isLenErr)||v.length>z.length)&&(v=z,S=Y,C=g):this._priorityComparison(d,D[0])||(D[0]===`${U.ARRAY}<>`?d=`${ee.type}[]`:d=D[0],v=z,S=Y,C=g)}for(const g of v)this._errorHandle(g.msg,g.ctx);for(const g of S)this._errorHandle(g.msg,g.ctx,Sn.Warning);const R=s.children[0],B=n[0].name;if(R&&this._overloadsFuncs.push({name:B,index:C,line:R.start.line,startColumn:R.start.column+1,endColumn:R.start.column+B.length}),h){const g=n[C],{thisType:O,name:w,index:D}=g;if(this._hasMemberIndexVerify(g,s,h),h.index=D||C,O){const H=this._getMethodTypeName((O==null?void 0:O[0])||"");if(this._types.get(H))h.name=h.name.split(".").join("?.");else{const ee=this._functions.get(w);ee&&(h.selfArg=(y=ee[0].args)==null?void 0:y[0])}}}return this._funcArgsAddOriginName(r,n[C].args,B),d||U.UNDETERMINED}_funcArgsAddOriginName(n,r,s){const l=n.params||[];for(const[h,d]of r.entries())h<l.length&&(l[h].originName=d.name);if(s==="input"){const h=l[0]||n.defval;Object.assign(n,{inputType:{name:`'${h!=null&&h.isSourceType?"source":this._removePrefix(h==null?void 0:h.type)}'`}})}}_overloadsCheckArgs(n,r,s,l,h){const d={...n},v=d.params;delete d.params;const S=Object.keys(d).length+v.length,C=r.length,A=[],R=[];let B=0;S>C&&(r.some(b=>["arg0, arg1, ...","number0, number1, ..."].includes(b.name))||A.push({msg:ye(de.argsLenErr,{name:s,lenA:S,lenB:C}),isLenErr:!0,ctx:l}));for(const[M,b]of r.entries()){let y=d[b.name];if(M<v.length&&(y&&A.push({msg:ye(sr.moreSameArg,{arg:b.name}),ctx:l}),y=v[M]),!y)b.required&&A.push({msg:ye(de.requiredParamErr,{name:s,argName:b.name}),ctx:l});else{const g=y.type!==`${U.SIMPLE} na`?this._checkArg(y,b,s,h,y.ctx,!0,R):"";g?A.push({msg:g,ctx:y.ctx}):B++,delete d[b.name]}if(["arg0, arg1, ...","number0, number1, ..."].includes(b.name)&&v.length>M+1){const g=v.slice(M+1);let O=v[M];for(const w of g){O.type===`${U.SIMPLE} ${U.NA}`&&(O=w);const D=w.type!==`${U.SIMPLE} ${U.NA}`?this._checkArg(w,b,s,O,w.ctx,!0,R):"";D&&A.push({msg:D,ctx:w.ctx})}}}if(Object.keys(d).length)for(const M of Object.keys(d))A.push({msg:ye(de.argsNameErr,{name:s,argName:M}),ctx:d[M].ctx});return{errMsg:A,warnMsg:R,matchCount:B}}_checkArgs(n,r,s,l,h,d){var M;const v={...n},S=v.params;delete v.params;const C=Object.keys(v).length+S.length,A=r.length;let R=!1,B=[];if(C>A&&!r.some(y=>["arg0, arg1, ...","number0, number1, ..."].includes(y.name)))return this._errorHandle(ye(de.argsLenErr,{name:s,lenA:C,lenB:A}),l),R=!0,{hasErr:R,types:B};for(const[b,y]of r.entries()){let g=v[y.name];if(b<S.length&&(g&&this._errorHandle(ye(sr.moreSameArg,{arg:y.name}),l,Sn.Warning),g=S[b],g.originName=y.name),!g)y.required&&(this._errorHandle(ye(de.requiredParamErr,{name:s,argName:y.name}),l),R=!0);else{const O=g.type!==`${U.SIMPLE} ${U.NA}`?this._checkArg(g,y,s,d,g.ctx):"";if(O)this._errorHandle(O,g.ctx),R=!0;else if(s.startsWith("request.")&&y.name==="expression")if(g.ruleType===le.Brackethesized)B=g.exprs.map(w=>this._typeReplace(h,w.type));else if((M=g.types||g.returnedTypes)!=null&&M.isBrackethesized)B=(g.types||g.returnedTypes).map(w=>this._typeReplace(h,w));else{const w=this._typeReplace(h,g.type);B.push(w)}else if(s==="input.enum"&&y.name==="defval"){const w=this._removePrefix(g.type);B.push(`${U.INPUT} ${w}`)}delete v[y.name]}}if(Object.keys(v).length)for(const b of Object.keys(v))this._errorHandle(ye(de.argsNameErr,{name:s,argName:b}),v[b].ctx),R=!0;return{hasErr:R,types:B}}_checkArg(n,r,s,l,h,d,v){var y,g;const{ruleType:S,exprs:C,name:A}=n;let R=n.type;S===le.Brackethesized&&(R=`[${C.map(O=>O.type).join(", ")}]`);const{allowedTypeIDs:B=[],displayType:M,name:b}=r;if(!(!R||R===U.UNDETERMINED||M===U.UNDETERMINED)){if(s==="input"&&b==="defval"&&!R.startsWith(U.CONST))if(Al.includes(A))n.isSourceType=!0;else return de.inputDefvalErr;if(!(this._checkMethodThisType(B,this._arrayTypeConvert(R))&&!(["input.source","input.enum"].includes(s)&&b==="defval"))){if(b==="condition"&&(M!=null&&M.endsWith(U.BOOL))){if(R.endsWith(U.INT)||R.endsWith(U.FLOAT)){const O=ye(sr.typeMismatch,{index:b,operator:s,type:U.BOOL});h&&(v?v.push({ctx:h,msg:O}):this._errorHandle(O,h,Sn.Warning));return}}else if(s==="str.tostring"&&b==="value"){const O=this._removePrefix(R);if(this._enums.get(O))return}switch(M){case"tuple of const string values: [val1, val2, ...]":return this._tupleToCheck(n,r,[`${U.CONST} ${U.STRING}`],s,R);case"tuple of const int/float values: [val1, val2, ...]":return this._tupleToCheck(n,r,[`${U.CONST} ${U.FLOAT}`,`${U.CONST} ${U.INT}`],s,R);case"tuple of const int values: [val1, val2, ...]":return this._tupleToCheck(n,r,[`${U.CONST} ${U.INT}`],s,R);case"open/high/low/close/hl2/hlc3/ohlc4/hlcc4":if(!A||!Al.includes(A))return ye(de.inputSourceErr,{name:b,funcName:s});if(this._judgeVarBuildIn(A))return ye(de.buildInUseErr,{name:A});n.isSourceType=!0;break;case"<matrix_type>":case"<array_type>":const O=this._getArrayType(s)||"";if(!R.endsWith(O)&&!(R.endsWith(U.INT)&&O===U.FLOAT))return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:this._typeAddSeries(O)});break;case"any matrix type":if(this._isMatrixType(R)){if(b==="id2"){const V=this._getArrayType(l==null?void 0:l.type);if(!V)return;const ne=this._getArrayType(R)||"";if(V!==ne)return ye(de.typeMismatch,{operator:s,index:b,typeE:ne,typeR:V})}}else return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:"matrix<fun_arg>"});break;case"any array type":if(this._isArrayType(R)){if(b==="id2"){const V=this._getArrayType(l==null?void 0:l.type);if(!V)return;const ne=this._getArrayType(R)||"";if(V!==ne)return ye(de.typeMismatch,{operator:s,index:b,typeE:ne,typeR:V})}}else return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:"array<fun_arg>"});break;case"series <type of the matrix's elements>":case"series <type of the array's elements>":const w=this._getArrayType(l==null?void 0:l.type)||"";if(!R.endsWith(w)&&!(R.endsWith(U.INT)&&w===U.FLOAT))return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:this._typeAddSeries(w)});break;case"any map type":if(this._isMapType(R)){if(b==="id2"){const V=this._getMapType(l==null?void 0:l.type);if(!V)return;const ne=this._getMapType(R)||[];if(V[0]!==ne[0]||V[1]!==ne[1])return ye(de.mapKeyValErr,{typeA:this._typeAddSeries(ne[0]),typeB:this._typeAddSeries(ne[1]),typeC:this._typeAddSeries(V[0]),typeD:this._typeAddSeries(V[1]),name:s})}}else return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:"map<type, type>"});break;case"series <type of the map's elements>":const D=this._getMapType(l==null?void 0:l.type);if(!D)return;const H=b==="key"?0:1;if(!R.endsWith(D[H])&&!(R.endsWith(U.INT)&&D[H]===U.FLOAT))return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:this._typeAddSeries(D[H])});break;case"<arg_expr_type>":if(S===le.Brackethesized)return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:M||""});break;case"<arg_type>":case"variable, function, object, array or matrix of series int/float/bool/string/color, or a tuple of these":const X=this._removePrefix(R);if([U.BOX,U.LABEL,U.LINE,U.LINEFILL,U.POLYLINE,U.TABLE].includes(X))return ye(de.requestExprErr,{type:X,name:s});break;case"variable, object or function of series int/float/bool/string/color, or a tuple of these":if(S===le.Brackethesized){for(const V of C)if(!B.includes(V.type))return ye(de.requestArgsErr,{name:s,argName:b,type:V.type})}break;case"const int/float/bool/string/color or source-type built-ins":if(Al.includes(n.name)&&B[0].endsWith(this._removePrefix(R)))n.isSourceType=!0;else return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:"const int/float/bool/string/color"});break;case"<arg..._type>":if(S===le.Brackethesized||this._isArrayType(R)||this._isMapType(R)||this._isMatrixType(R))return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:`${U.SERIES} ${U.INT}`});if(R!==(l==null?void 0:l.type))return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:l==null?void 0:l.type});break;case"simple enum":const ee=this._removePrefix(R);if(!this._enums.has(ee))return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:"const enum"});break;case"tuple of enum fields: [enumName.field1, enumName.field2, ...]":const z=l==null?void 0:l.enumName;if(z&&!((y=n.exprs)==null?void 0:y.every(ne=>ne.enumName===z)))return ye(de.typeMismatch,{operator:s,index:b,typeE:`${n.exprs?`[${(g=n.exprs)==null?void 0:g.map(ne=>ne.type).join(", ")}]`:n.type}`,typeR:`[const ${z}...]`});break;default:const Y=this._removePrefix(n.type);if(n.arg&&n.arg.isArg&&!d){const V=B.find(ne=>ne.endsWith(Y));if(V){n.type=V,n.arg.type=V;return}}if(B.length===1&&this._removePrefix(B[0])===Y){const V=this._getPrefix(n.type),ne=this._getPrefix(B[0]);if(Pi.indexOf(V)>=Pi.indexOf(ne))return}if(M)return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:M})}}}}_tupleToCheck(n,r,s,l,h){var d,v;if(s.push(`${U.SIMPLE} ${U.NA}`),n.ruleType===le.Brackethesized){const S=[];let C=!1;for(const A of n.exprs)S.push(A.type),s.includes(A.type)||(C=!0);if(C)return ye(de.typeMismatch,{operator:l,index:r.name,typeE:`[${S.join(", ")}]`,typeR:((d=r.allowedTypeIDs)==null?void 0:d[0])||""})}else return ye(de.typeMismatch,{operator:l,index:r.name,typeE:h,typeR:((v=r.allowedTypeIDs)==null?void 0:v[0])||""})}_getBlockReturnTypes(n){var R,B;let r=n;if(Array.isArray(n)&&(r=n.slice(-1)[0],Array.isArray(r)&&(r=r.slice(-1)[0])),!r)return[U.UNDETERMINED];const{ruleType:s,type:l,types:h,returnedTypes:d,exprs:v,nameList:S,typeList:C,block:A}=r;if(h&&h.length)return h;if(d&&d.length)return d;if(l)return[l];switch(s){case le.Brackethesized:const M=v.map(ee=>ee.type);return M.isBrackethesized=!0,M;case le.VarBlockStmt:case le.DeclareAssign:return S?S.ruleType===le.VarMultiple?S.types:[S.type]:[((R=r.name)==null?void 0:R.type)||U.UNDETERMINED];case le.SwitchStatement:if(!this._isNeedCalc&&this._isInFunc&&this._isEndExpr===!1)return[U.UNDETERMINED];const b=[...r.cases];r.defaultCase&&b.push(r.defaultCase);let y=((B=b[0])==null?void 0:B.returnedTypes)||[],g=y.length<=1?y[0]:`[${y.join(", ")}]`,O=null;for(const ee of b.slice(1)){const z=ee.returnedTypes||[U.UNDETERMINED];g+=z.length<=1?`; ${z[0]}`:`; [${z.join(", ")}]`;const Y=Array.isArray(ee.block)?ee.block.slice(-1)[0]:ee.block;if(z.length!==y.length)O=Y.ctx;else for(const[V,ne]of y.entries())if(this._compareType(z[V],ne))(z[V].includes(U.FLOAT)&&!ne.includes(U.FLOAT)||y[V]===`${U.SIMPLE} ${U.NA}`||y[V]===U.UNDETERMINED)&&(y[V]=z[V]);else{O=Y.ctx;break}}return O&&(this._errorHandle(ye(de.ifOrSwitchTypeErr,{keyword:"switch",types:g}),O),y=y.map(()=>U.UNDETERMINED)),r.returnedTypes=y,y;case le.IfStatement:if(!this._isNeedCalc&&!this._isInFunc)return[U.UNDETERMINED];if(!C.filter(ee=>ee&&ee.length).length)return[U.UNDETERMINED];let w=C[0]||[],D=w.length<=1?w[0]:`[${w.join(", ")}]`,H=0,X=0;for(const ee of C.slice(1))if(ee)if(H++,D+=ee.length<=1?`; ${ee[0]}`:`; [${ee.join(", ")}]`,ee.length!==w.length)X=H;else for(const[z,Y]of w.entries())if(this._compareType(ee[z],Y))(ee[z].includes(U.FLOAT)&&!Y.includes(U.FLOAT)||w[z]===`${U.SIMPLE} ${U.NA}`)&&(w[z]=ee[z]);else{X=H;break}if(X){const ee=A[X].slice(-1)[0],z=Array.isArray(ee)?ee.slice(-1)[0]:ee;this._errorHandle(ye(de.ifOrSwitchTypeErr,{keyword:"if",types:D}),z.ctx),w=w.map(()=>U.UNDETERMINED)}return r.returnedTypes=w,w}return[U.UNDETERMINED]}}class $_{constructor(e){k(this,"_nameMap");k(this,"_prefixNameVar");k(this,"_prefixNameFunc");k(this,"_prefixNameConst");k(this,"_userTypes");k(this,"_isInFunc");k(this,"_currentFuncName");k(this,"_varlist");k(this,"_memberIndexList");k(this,"_blockCount");k(this,"_inputCount");k(this,"_count");k(this,"_isSwitch",!1);k(this,"_isInLoop",!1);k(this,"_codesCol");k(this,"_dependsObj");k(this,"_enums");k(this,"_preRunMembers");k(this,"_isInConditionalStmt",!1);k(this,"_preRunMembersFuncs");k(this,"_preRunMemberFuncsCount",0);k(this,"__count",0);this._nameMap=new Map,this._prefixNameVar=`${e}_var`,this._prefixNameFunc=`${e}_func`,this._prefixNameConst=`${e}_const`,this._userTypes=[],this._isInFunc=!1,this._varlist=[{}],this._memberIndexList=[{}],this._blockCount=0,this._inputCount=0,this._count=0,this._codesCol=[[]],this._dependsObj={},this._enums=new Map,this._preRunMembers=[],this._preRunMembersFuncs=[]}preParser(e){var r,s;const n=[];for(const l of e){if(!l)return;if(Array.isArray(l)){for(const h of l)if(n.push(this._parserStmt(h)),Sl.includes((s=(r=h.exprs)==null?void 0:r[0])==null?void 0:s.name))return n.join(`;
|
13
|
+
`)){const v=h.replace(/\s*(\n|\r)\s*/g," ");d.value=`\`${v.substring(1,v.length-1)}\``}break;case F.IntegerLiteral:d.type=U.INT;break;case F.DecimalLiteral:d.type=U.FLOAT;break}return d.type&&(d.type=`${U.CONST} ${d.type}`),d});k(this,"visitMethodElement",n=>{const{children:r}=n,[s,l]=r,[h,d,v]=this.visit(s),S=this.visit(l);return h.startsWith("request.")&&this._isInFunc&&(this._currentExportFunc&&this._errorHandle(ye(de.exportFuncUseReqErr,{name:h}),n),this._hasRequest=!0),{name:h,type:d,args:S,expr:v}});k(this,"visitMethodName",n=>{const{children:r}=n,s=[],l=[];let h=0,d=null;for(;h<r.length;h++){const S=r[h],C=S.ruleIndex,A=S.symbol;switch(C){case F.RULE_identifier:s.push(this.visit(S));break;case F.RULE_singleExpression:d=this.visit(S);break;case F.RULE_typeName:const R=this.visit(S);l.push(R),this._typeCheck(R,F.RULE_typeName,S);break;default:A&&A.text==="."&&s.push(".")}}const v=s.join("");return L_.includes(v)?this._hasDrawFunc=!0:M_.includes(v)&&(this._hasCreateOrderFunc=!0),[v,l,d]});k(this,"visitArrowFunction",n=>{const{children:r,start:s,stop:l}=n,h={ruleType:le.ArrowFunction,returnedTypes:[]};let d=0,v={lineNumber:0,column:0};const S=this._commentsParser(s.line,[Kt.function,Kt.param,Kt.returns],!0);Object.assign(h,{desc:S[Kt.function],paramsDesc:S[Kt.param],returnsDesc:S[Kt.returns]}),this._currentLine=s.line;let C=null;for(;d<r.length;d++){const A=r[d],R=A.ruleIndex,B=A.symbol;switch(R){case F.RULE_identifier:v={lineNumber:A.start.line,column:A.start.column},h.name=this.visit(A);break;case F.RULE_arrowFunctionParameters:h.params=this.visit(A),h.isExport&&this._exportArgsTypeVerify(h.params),this._setFuncParams(h,{endColumn:l.column,endLineNumber:l.line-1,startColumn:s.column,startLineNumber:s.line}),C=A;break;case F.RULE_block:this._isInFunc=!0,h.isExport&&(this._currentExportFunc=h.name),this._hasMemberIndex=!1,this._hasRequest=!1,h.block=this.visit(A),h.hasMemberIndex=this._hasMemberIndex,h.returnedTypes=this._getBlockReturnTypes(h.block),this._isInFunc=!1,this._currentExportFunc="";break;default:B&&B.type===F.Export&&(h.isExport=!0,this._addExportPos(B,"functions"))}}return h.hasRequest=this._hasRequest,this._setFunc(h,v,C,l.line-1),this._hasRequest=!1,this._currentFuncParams.clear(),h});k(this,"visitArrowFunctionParameters",n=>{const{children:r}=n;let s=0,l=[];for(;s<r.length;s++){const h=r[s];h.ruleIndex===F.RULE_formalParameterList&&(l=this.visit(h))}return l});k(this,"visitFormalParameterList",n=>{const{children:r}=n;let s=0;const l=[];for(;s<r.length;s++){const h=r[s];h.ruleIndex===F.RULE_formalParameterArg&&l.push(this.visit(h))}return l});k(this,"visitFormalParameterArg",n=>{const{children:r}=n;let s=0;const l={};for(;s<r.length;s++){const h=r[s];switch(h.ruleIndex){case F.RULE_typeGather:const d=this.visit(h);l.type=d&&this._typeAddSeries(d);break;case F.RULE_identifier:l.name=this.visit(h);break;case F.RULE_singleExpression:l.defaultValue=this.visit(h),delete l.defaultValue.ctx}}return l.ctx=n,this._verifyArgsDefaultValue(l,n),l.type=l.type||U.UNDETERMINED,l});k(this,"visitArrowMethod",n=>{const{children:r,start:s,stop:l}=n;let h=0;const d={ruleType:le.ArrowMethod,returnedTypes:[]};let v={lineNumber:0,column:0};const S=this._commentsParser(s.line,[Kt.function,Kt.param,Kt.returns],!0);Object.assign(d,{desc:S[Kt.function],paramsDesc:S[Kt.param],returnsDesc:S[Kt.returns]}),this._currentLine=s.line;let C=null;for(;h<r.length;h++){const A=r[h];switch(A.ruleIndex){case F.RULE_identifier:v={lineNumber:A.start.line,column:A.start.column},d.name=this.visit(A);break;case F.RULE_arrowMethodParameters:d.params=this.visit(A),d.isExport&&this._exportArgsTypeVerify(d.params),this._setFuncParams(d,{endColumn:l.column,endLineNumber:l.line-1,startColumn:s.column,startLineNumber:s.line}),C=A;break;case F.RULE_block:this._isInFunc=!0,d.isExport&&(this._currentExportFunc=d.name),this._hasMemberIndex=!1,this._hasRequest=!1,d.block=this.visit(A),d.hasMemberIndex=this._hasMemberIndex,d.returnedTypes=this._getBlockReturnTypes(d.block),this._isInFunc=!1,this._currentExportFunc="";break;default:A.symbol&&A.symbol.type===F.Export&&(d.isExport=!0,this._addExportPos(A.symbol,"methods"));break}}return d.hasRequest=this._hasRequest,this._setFunc(d,v,C,l.line-1),this._setMethod(d,v),this._hasRequest=!1,this._currentFuncParams.clear(),d});k(this,"visitArrowMethodParameters",n=>{const{children:r}=n;let s=0;const l={};let h=[];for(;s<r.length;s++){const d=r[s];switch(d.ruleIndex){case F.RULE_typeGather:const v=this.visit(d);l.type=v&&this._typeAddSeries(v);break;case F.RULE_identifier:l.ctx=d,l.name=this.visit(d);break;case F.RULE_formalParameterList:h=this.visit(d);break}}return[l,...h]});k(this,"visitTypeStatement",n=>{const{children:r,start:s,stop:l}=n;let h=0;const d={ruleType:le.TypeStatement,fields:[]},v=this._commentsParser(s.line,[Kt.type,Kt.field]);Object.assign(d,{desc:v[Kt.type],fieldsDesc:v[Kt.field]}),this._currentLine=s.line;let S={lineNumber:0,column:0},C=null;for(;h<r.length;h++){const A=r[h];switch(A.ruleIndex){case F.RULE_identifier:S={lineNumber:A.start.line,column:A.start.column},C=A,d.name=this.visit(A),this._verifyTypeName(d.name,A);break;case F.RULE_typeElement:d.fields.push(this.visit(A));break;default:A.symbol&&A.symbol.type===F.Export&&(d.isExport=!0,this._addExportPos(A.symbol,"types"));break}}if(d.isExport){const A=l.line-1,{line:R=0}=this._endExport;A>R&&(this._endExport={line:A,name:d.name})}return this._setUserType(d,S,C),this._setNewFunc(d,S),this._setCopyFunc(d,S),this._setCopyMethod(d,S),d});k(this,"visitTypeElement",n=>{const{children:r,start:s}=n;let l=0;const h={};let d=null,v=null;for(this._currentLine=s.line;l<r.length;l++){const S=r[l];switch(S.ruleIndex){case F.RULE_typeGather:const C=this.visit(S);if(S.children[0].ruleIndex===F.RULE_typeSeries){const{column:A,line:R,text:B}=S.start,M=A+1;this._errors.push({startColumn:M,endColumn:parseInt(M+B.length),startLineNumber:R,endLineNumber:R,message:ye(this._buildinTypes.has(B)?de.typeUseError:de.notTypeKeyword,{text:B})}),h.type=U.UNDETERMINED}else h.type=C&&this._typeAddSeries(C);break;case F.RULE_identifier:h.name=this.visit(S),v=S;break;case F.RULE_singleExpression:d=S,h.value=this.visit(S);break;default:S.symbol&&S.symbol.type===F.Varip&&(h.isVarip=!0);break}}return this._typeElementVerify(h,d,v),h});k(this,"visitAssignmentOperator",n=>{const{children:r}=n;return r&&r[0].symbol.text});k(this,"visitTypeMap",n=>{const{children:r}=n;let s=0;const l=[];for(;s<r.length;s++){const h=r[s];if(h.ruleIndex===F.RULE_typeName){const d=this.visit(h);l.push(d),this._typeCheck(d,F.RULE_typeName,h)}}return`map<${l[0]},${l[1]}>`});k(this,"visitTypeSeries",n=>{const{children:r}=n,[s,l]=r,h=this.visit(s),d=this.visit(l);return this._typeCheck(h,F.RULE_typeSeries,s),this._typeCheck(d,F.RULE_typeName,l),`${h} ${d}`});k(this,"visitTypeArray",n=>{const{children:r}=n,s=r[0];let l=this.visit(s),h=l;if(r.length===3)l=U.ARRAY;else{this._typeCheck(l,F.RULE_typeArray,s);let d=1;for(;d<r.length;d++){const v=r[d];v.ruleIndex===F.RULE_typeName&&(h=this.visit(v),this._typeCheck(h,F.RULE_typeName,v))}}return this._arrayTypeConvert(`${l}<${h}>`)});k(this,"visitTypeGather",n=>{const{children:r}=n;if(r&&r.length){const s=r[0],l=this.visit(s);return s.ruleIndex===F.RULE_typeName&&this._typeCheck(l,F.RULE_typeName,s),l}return null});k(this,"visitIdentifier",n=>n.children&&n.children[0].symbol.text);k(this,"visitTypeName",n=>{const{children:r}=n;let s=0,l="";for(;s<r.length;s++){const h=r[s];h.ruleIndex===F.RULE_identifier?l=`${l}${this.visit(h)}`:l=`${l}.`}return l});k(this,"visitEnumStatement",n=>{const{children:r,start:s,stop:l}=n;let h=0;const d={ruleType:le.EnumStatement,fields:[]},v=this._commentsParser(s.line,[Kt.enum,Kt.field]);Object.assign(d,{desc:v[Kt.enum],fieldsDesc:v[Kt.field]}),this._currentLine=s.line;let S={lineNumber:0,column:0},C=null;for(;h<r.length;h++){const A=r[h];switch(A.ruleIndex){case F.RULE_identifier:S={lineNumber:A.start.line,column:A.start.column},C=A,d.name=this.visit(A),this._verifyEnumName(d.name,A);break;case F.RULE_enumElement:d.fields.push(this.visit(A));break;default:A.symbol&&A.symbol.type===F.Export&&(d.isExport=!0,this._addExportPos(A.symbol,"enums"));break}}if(d.isExport){const A=l.line-1,{line:R=0}=this._endExport;A>R&&(this._endExport={line:A,name:d.name})}return this._setUserEnum(d,S,C),d});k(this,"visitEnumElement",n=>{const{children:r,start:s}=n;let l=0;const h={};for(this._currentLine=s.line;l<r.length;l++){const d=r[l];switch(d.ruleIndex){case F.RULE_identifier:h.name=this.visit(d);break;default:d.symbol&&d.symbol.type===F.StringLiteral&&(h.value=d.symbol.text);break}}return h});k(this,"visitName",n=>{const{children:r}=n;let s=0,l=!1;const h=[];let d=null;for(;s<r.length;s++){const v=r[s];switch(v.ruleIndex){case F.RULE_identifier:h.push(this.visit(v));break;case F.RULE_singleExpression:d=this.visit(v);break;case F.RULE_methodElement:l=!0;const S=this.visit(v);S.ctx=v,h.push(S);break}}return this._nameHandle(l,h,d,n)});this._loopCount=0,this._errors=[],this._variables=new Map,this._functions=new Map,this._methods=new Map,this._currentFuncParams=new Map,this._types=new Map,this._enums=new Map,this._currentBlockVars=[new Map],this._blockCount=0,this._isInFunc=!1,this._isNeedCalc=!1,this._blockRanges=[],this._overloadsFuncs=[],this._hasMemberIndex=!1,this._isInLocalScop=!1,this._onlyStatementsCount=0,this._comments=r,this._exportFunctions=[],this._exportMethods=[],this._exportTypes=[],this._exportEnums=[],this._exportPositions=[],this._endExport={},this._importLibs=new Map,this._getImportLibraryFunc=s}get overloadsFuncs(){return this._overloadsFuncs}get errors(){return this._errors}get userEnums(){return this._enums}get userTypes(){return this._types}get userFunctions(){return this._functions}get userVariables(){return this._variables}get userMethods(){return this._methods}get hasUseDrawFunc(){return this._hasDrawFunc}get hasUseCreateOrderFunc(){return this._hasCreateOrderFunc}get scriptType(){return this._scriptType}get exportLibs(){return{functions:[...this._exportFunctions],methods:[...this._exportMethods],types:[...this._exportTypes],enums:[...this._exportEnums]}}get description(){return this._description}get exportPositions(){return this._exportPositions}get endExport(){return this._endExport}get imports(){return this._importLibs}_verifyGloablVar(n,r){const{name:s,varPos:l,isBuiltIn:h}=n;if(h&&this._errorHandle(ye(de.buidinAssignErr,{name:s}),r),!l)return;const d=this._currentBlockVars[0].get(s);if(!d)return;const{column:v,lineNumber:S}=d.pos||{};this._isInFunc&&v===l.column&&S===l.lineNumber?this._errorHandle(ye(de.modifyGlobalVarErr,{name:s}),r):d.hasAssigned=!0}_inputFuncTitleVerify(n,r){if(!(n!=null&&n.length)||n.length>1)return;const{name:s,args:l,isBuiltIn:h}=n[0];if(h&&!this._strategyFuncName&&s.startsWith(Ii.strategy))this._strategyFuncName={ctx:r,name:s};else if(!s.startsWith(U.INPUT))return;this._inputVarName&&!(l.params.some(d=>d.originName==="title")||l.title)&&(l.title={value:`"${this._inputVarName}"`,ruleType:le.Literal,type:`${U.CONST} ${U.STRING}`})}_verifyIf(n){const{condition:r}=n;if(r!=null&&r.length)for(const s of r){const{type:l,ctx:h}=s;if(l===U.UNDETERMINED)continue;const d=this._removePrefix(l);[U.INT,U.FLOAT].includes(d)?this._errorHandle(ye(sr.conditionWarning,{name:"if"}),h,Sn.Warning):d!==U.BOOL&&this._errorHandle(ye(de.conditionalErr,{name:"if"}),h)}}_forToNameHandle(n,r){if(n.name&&n.numerical.length===1){this._pushBlockRanges(r);const s=n.numerical[0].type;this._variablesHandle({nameList:{name:n.name,isForVar:!0,type:n.type},value:{type:s||`${U.SERIES} ${U.INT}`}},r),this._blockRanges.pop()}}_verifyForTo(n){const{numerical:r}=n;if(r!=null&&r.length)for(const s of r){const{type:l,ctx:h}=s;if(l===U.UNDETERMINED)continue;const d=this._removePrefix(l);[U.INT,U.FLOAT].includes(d)||this._errorHandle(de.fortoErr,h)}}_forInNameHandle(n,r){if(this._pushBlockRanges(r),n.names.length){let[s,l]=n.names;const h=n.array.type;l?this._variablesHandle({nameList:{name:s,isForVar:!0,type:`${U.SERIES} ${U.INT}`},value:{type:`${U.SERIES} ${U.INT}`}},r):l=s;const d=h===U.UNDETERMINED?h:this._isMatrixType(h)?`${this._getArrayType(h)}[]`:this._typeAddSeries(this._getArrayType(h));this._variablesHandle({nameList:{name:l,isForVar:!0,type:d},value:{type:d}},r)}this._blockRanges.pop()}_verifySwitch(n){var r;if(n.cases){const s=(r=n.condition)==null?void 0:r.type;if(s===U.UNDETERMINED)return;if(s&&this._types.has(s)){this._errorHandle(ye(de.typeMismatch,{operator:"switch",index:"expr0",typeE:s,typeR:`${U.SIMPLE} ${U.STRING}`}),n.condition.ctx);return}for(const l of n.cases){const{condition:{type:h,ctx:d}}=l;if(h!==U.UNDETERMINED)if(this._types.has(h))this._errorHandle(ye(de.typeMismatch,{operator:"case",index:"expr1",typeE:h,typeR:`${U.SIMPLE} ${U.STRING}`}),d);else if(s){if(!this._compareType(s,h)){const v=this._removePrefix(s),S=this._removePrefix(h);v===U.BOOL&&[U.INT,U.FLOAT].includes(S)?this._errorHandle(ye(sr.conditionWarning,{name:"switch"}),d,Sn.Warning):[U.INT,U.FLOAT].includes(v)&&S===U.BOOL?this._errorHandle(ye(sr.conditionWarning,{name:"switch"}),n.condition.ctx,Sn.Warning):this._errorHandle(ye(de.typeMismatch,{operator:"case",index:"expr1",typeE:h,typeR:`${s}`}),d)}}else{const v=this._removePrefix(h);[U.INT,U.FLOAT].includes(v)?this._errorHandle(ye(sr.conditionWarning,{name:"switch"}),d,Sn.Warning):v!==U.BOOL&&this._errorHandle(ye(de.conditionalErr,{name:"switch"}),d)}}}}_verifyWhile(n){const{condition:r}=n;if(r){const{type:s,ctx:l}=r;if(s===U.UNDETERMINED)return;const h=this._removePrefix(s);[U.INT,U.FLOAT].includes(h)?this._errorHandle(ye(sr.conditionWarning,{name:"while"}),l,Sn.Warning):h!==U.BOOL&&this._errorHandle(ye(de.conditionalErr,{name:"while"}),l)}}async _importHandle(n,r){const{stop:s,start:l}=r,{username:h,libraryName:d,libraryVersion:v,name:S}=n,C=`${h}/${d}/${v}`;if(this._importLibs.has(C))return this._errorHandle(de.importMultipleErr,r),n;for(const[B,M]of this._importLibs)if(M.name&&M.name===S||!M.name&&!S&&M.libraryName===d)return this._errorHandle(ye(de.importNameRepeatErr,{name:S,line:M.startLine}),r),n;let A=S||d;const R=await this._getImportLibraryFunc({...n,libraryId:C,ctx:void 0,startLine:l.line,endLine:s.line,startColumn:l.column,endColumn:s.column+s.text.length+1});if(R){const{codeStr:B,description:M}=R;this._importLibs.set(C,{...n,libraryId:C,startLine:l.line,endLine:s.line,ctx:void 0,desc:M}),this._importDataHandle(R,A),Rn.includes(A)&&(A=`$${A}`),n.code=B.replace("$name",A)}else this._errorHandle(ye(de.importNotExitErr,{username:h,libraryName:d}),r)}_importDataHandle(n,r){const{functions:s,methods:l,types:h}=n;for(const d of s){const{name:v}=d,S=`${r}.${v}`,C=this._functions.get(S)||[];C.push({...this._importTypeUpdate(d,h,r),name:S,isUser:void 0,isImport:!0}),this._functions.set(S,C)}for(const d of l){const v=this._importTypeUpdate(d,h,r),S=v.originalName||v.name,C=this._methods.get(S)||[];C.push({...v,isImport:!0,isUser:void 0}),this._methods.set(S,C)}for(const d of h){const v=`${r}.${d.name}`,S=this._types.get(v)||[];S.push({...this._importTypeUpdate(d,h,r),name:v,isImport:!0}),this._types.set(v,S)}}_importTypeUpdate(n,r,s){var B;let{args:l,returnedTypes:h,thisType:d,fields:v,name:S,originalName:C}=n,A="";if(l&&l.length&&(l=l.map(M=>{const{allowedTypeIDs:b,displayType:y,name:g}=M,O=y&&this._replaceTypeName(y,r,s);return A=A?`${A}, ${O} ${g}`:`${O} ${g}`,{...M,allowedTypeIDs:b==null?void 0:b.map(w=>this._replaceTypeName(w,r,s)),displayType:O}})),h!=null&&h.length&&(h=[this._replaceTypeName(h[0],r,s)]),d!=null&&d.length){const M=this._replaceTypeName(d[0],r,s);M!==d[0]&&(C=`${s}.${C||S}`),d=[M]}v!=null&&v.length&&(v=v.map(M=>{const{type:b}=M;return{...M,type:b&&this._replaceTypeName(b,r,s)}}));const R={...n,args:l,returnedTypes:h,thisType:d,fields:v,originalName:C};return(B=R.syntax)!=null&&B.length&&(R.syntax=[`${C||`${s}.${S}`}(${A}) → ${(h==null?void 0:h[0])||"void"}`]),R}_replaceTypeName(n,r,s){const l=r.find(h=>n.includes(h.name));return l?n.replace(l.name,`${s}.${l.name}`):n}_verifyArgsDefaultValue(n,r){const{defaultValue:s,type:l}=n;if(!s)return;const{ruleType:h,isBuiltIn:d,type:v}=s,S=this._removePrefix(v);if(h!==le.Literal&&!d)delete n.defaultValue,this._errorHandle(de.argDefaultErr,r);else if(l&&l!==U.UNDETERMINED&&v!==U.UNDETERMINED){const C=this._removePrefix(l);if(C===U.FLOAT&&S===U.INT)return;S!==C&&this._errorHandle(ye(de.defaultValueTypeErr,{typeE:v,typeR:l}),r)}else l||(n.type=this._typeAddSeries(S===U.INT?U.FLOAT:S))}_exportArgsTypeVerify(n){for(const r of n)(r.type===U.UNDETERMINED||!r.type)&&this._errorHandle(de.exportFuncArgErr,r.ctx)}_verifyTypeName(n,r){lu.includes(n)?this._errorHandle(ye(de.typeNameErr,{name:n}),r):Pp.includes(n)&&this._errorHandle(ye(de.enumVarNameBuiltinErr,{name:n}),r)}_addExportPos(n,r){const{line:s,column:l,text:h}=n;this._exportPositions.push({startLineNumber:s,startColumn:l,endLineNumber:s,endColumn:l+h.length+1,type:r})}_verifyEnumName(n,r){lu.includes(n)?this._errorHandle(ye(de.enumVarNameErr,{name:n}),r):Pp.includes(n)&&this._errorHandle(ye(de.enumVarNameBuiltinErr,{name:n}),r)}_nameHandle(n,r,s,l){var d,v;const h={ruleType:le.Name,hasMethod:n,exprs:r,expr:s};if(n){let S="";const C=[];for(const R of r)typeof R=="string"?S=S?`${S}.${R}`:R:(S&&(R.name=`${S}.${R.name}`),C.push(R),S="");h.exprs=[...C,S];const A=this._getMethodTypes(C,Array.from(C,()=>l));if(A&&A.length){const R=ye(de.noFiledErr,{name:S});A.length>1&&this._errorHandle(R,l),h.type=((v=this._nameCheck(this._getOriginMethodName(A[0],S),l,R))==null?void 0:v.type)||U.UNDETERMINED}}else{let S=r.join(".");if(s&&s.type&&s.type===U.UNDETERMINED)h.type=U.UNDETERMINED,S=`expr0.${S}`;else{s&&s.type&&(S=`${this._getMethodTypeName(s.type)}.${S}`);const C=this._nameCheck(S,l)||{};(d=C.title)!=null&&d.startsWith("built-in")&&(h.isBuiltIn=!0,h.isConst=C.isConst,!this._strategyVarName&&S.startsWith(Ii.strategy)&&(this._strategyVarName={ctx:l,name:S})),h.enumName=C.enumName,h.varPos=C.pos,h.varScope=C.scope,h.declare=C.declare,h.type=(C==null?void 0:C.type)||U.UNDETERMINED,C!=null&&C.isArg&&(h.arg=C),h.scope=this._blockCount,C.isEnum?this._errorHandle(ye(de.enumUseErr,{name:S}),l):this._isInFunc&&this._currentExportFunc&&(h.type.startsWith(U.INPUT)?this._errorHandle(ye(de.exportFuncHasInputErr,{name:S,func:this._currentExportFunc}),l):C.scope===0&&C.hasAssigned&&this._errorHandle(ye(de.exportFuncUseGlobalVarErr,{func:this._currentExportFunc}),l))}h.name=S}return h}_typeElementVerify(n,r,s){var v,S;const{type:l,value:h}=n;if(!h){l||this._errorHandle(de.typeFieldErr,s);return}if(![le.Literal,le.UnaryExpression].includes(h.ruleType)&&!h.isBuiltIn){this._errorHandle(de.defaultValueErr,r);return}else if(h.ruleType===le.UnaryExpression){const{exprs:C}=h;if(![le.Literal,le.UnaryExpression].includes((v=C[0])==null?void 0:v.ruleType)&&!((S=C[0])!=null&&S.isBuiltIn)){this._errorHandle(de.defaultValueErr,r);return}}if(!l){const C=h.type,A=this._getPrefix(C);n.type=A?this._typeAddSeries(this._removePrefix(C)):C;return}(!this._compareType(l,h.type)||l.endsWith(U.INT)&&h.type.endsWith(U.FLOAT))&&this._errorHandle(ye(de.defaultValueTypeErr,{typeE:h.type,typeR:l}),r)}_memberIndexVerify(n,r){if(n.ruleType===le.Name&&!n.hasMethod&&this._blockCount){const l=this._currentBlockVars[this._blockCount],h=l&&l.get(n.name);h&&(h.isForVar?this._errorHandle(ye(de.notHistoryErr,{name:n.name}),r):!(this._blockCount===1&&this._isInFunc)&&this._errorHandle(ye(sr.localScopeGetHistory,{name:n.name}),r,Sn.Warning))}const s=n&&n.type;if(s){const l=this._removePrefix(s);!this._types.has(l)&&!this._buildinTypes.has(l)&&!this._isArrayType(l)&&!this._isMatrixType(l)&&!this._isMapType(l)&&l!==U.UNDETERMINED&&this._errorHandle(ye(de.invalidType,{index:0}),r)}}_setFuncParams(n,r){var s;for(const l of n.params){const h=(s=this._types.get(l.type))==null?void 0:s[0];if(l.scope=this._blockCount+1,h&&h.fields)for(const d of h.fields){const v=`${l.name}.${d.name}`;this._currentFuncParams.set(v,{...d,originName:v,varScope:l.scope})}delete l.ctx,l.range=r,this._setVariablesMap(l,!0),this._currentFuncParams.set(l.name,l)}}_pushBlockRanges(n){!n||!n.start||!n.stop||this._blockRanges.push({startColumn:n.start.column,endColumn:n.stop.column,startLineNumber:n.start.line,endLineNumber:n.stop.line})}_setUserEnum(n,r,s){const{fields:l,name:h,desc:d,fieldsDesc:v}=n,S={members:l.map(C=>({name:C.name,value:C.value,enumName:h,isEnumMember:!0,desc:v==null?void 0:v[C.name],type:`${U.CONST} ${h}`})),name:h,desc:d,pos:r};if(this._enums.has(h)){this._errorHandle(ye(de.typeRepeatErr,{name:h,keyword:Kt.enum}),s);return}else if(this._types.has(h)){this._errorHandle(ye(de.typeRepeatErr,{name:h,keyword:Kt.type}),s);return}n.isExport&&this._exportEnums.push(S),this._enums.set(h,[{...S}]),this._addEnumToMap(h,h,r)}_setUserType(n,r,s){const{fields:l,name:h,desc:d,fieldsDesc:v}=n,S={fields:l.map(C=>({name:C.name,desc:v==null?void 0:v[C.name],type:C.type})),name:h,desc:d,pos:r};if(this._enums.has(h)){this._errorHandle(ye(de.typeRepeatErr,{name:h,keyword:Kt.enum}),s);return}else if(this._types.has(h)){this._errorHandle(ye(de.typeRepeatErr,{name:h,keyword:Kt.type}),s);return}n.isExport&&this._exportTypes.push(S),this._types.set(h,[{...S}]),this._addVarToMap(h,h,r,!1,!1)}_againAssignHandle(n,r,s){const l=s!==":="?s.replace("=",""):s,h=s!==":="?[U.UNDETERMINED,U.INT,U.FLOAT]:[];l==="+"&&h.push(U.STRING);const[d,v]=n;d.arg&&!d.name.includes(".")&&this._errorHandle(ye(de.funcArgAssignErr,{name:d.name}),r[0]);const S=this._sameTypeJudge(n,r,l,h);let C=this._typeHandle(S);return this._updateUserVar(d.name,C,v.type),d.type=C,{ruleType:le.AgainAssign,name:d,operator:s,type:C,value:v}}_typeCheck(n,r,s){const l=[U.SERIES,U.SIMPLE,U.CONST];switch(r){case F.RULE_typeName:const h=this._buildinTypes.get(n);h&&![...l,U.ARRAY,U.MATRIX,U.MAP].includes(h[0].name)||this._types.get(n)||this._errorHandle(ye(de.notTypeKeyword,{text:n}),s);break;case F.RULE_typeArray:[U.ARRAY,U.MATRIX].includes(n)||this._errorHandle(de.tempateTypeErr,s);break;case F.RULE_typeSeries:l.includes(n)||this._errorHandle(ye(de.qualifierErr,{name:n}),s);break}}_getBuildVar(n){const r=this._buildinVariables.get(n);if(r&&r[0])return r[0];const s=this._buildinConstants.get(n);return s&&s[0]?Object.assign(s[0],{isConst:!0}):this._specialTreatmentChartPoint(n)}_specialTreatmentChartPoint(n){var r,s;if(n.startsWith("chart.point")){const l=n.split("."),h=l.pop(),d=l.join(".");return(((s=(r=this._buildinTypes.get(d))==null?void 0:r[0])==null?void 0:s.fields)||[]).find(S=>S.name===h)}}_verifyName(n,r){var l,h;const s=this._getBuildVar(n);if(s)return s;if(n.includes(".")){const d=n.split("."),v=d.pop(),S=d.join(".");let C=this._blockCount;for(;C>=0;){if(!this._currentBlockVars[C]){C--;continue}const R=this._currentBlockVars[C].get(S);if(r&&this._judgeGatherValue(v||"",r,R==null?void 0:R.valueType,!0),(R==null?void 0:R.type)==="chart.point"){const M=(((h=(l=this._buildinTypes.get(R.type))==null?void 0:l[0])==null?void 0:h.fields)||[]).find(b=>b.name===v);if(M)return Object.assign(M,{pos:R.pos})}C--}const A=this._specialTreatmentChartPoint(n);if(A)return A}return this._getUserVar(n)}_judgeGatherValue(n,r,s,l){return s!==`${U.SIMPLE} ${U.NA}`?!0:(l&&this._errorHandle(ye(de.objectIsNaErr,{name:n,type:"field"}),r),!1)}_nameCheck(n,r,s=ye(de.undeclared,{name:n})){const l=this._verifyName(n,r);return l||this._errorHandle(s,r),l}_inBlock(n){this._blockCount++,this._pushBlockRanges(n);const r=this.visit(n);return this._blockCount--,this._blockRanges.pop(),this._currentBlockVars.splice(this._blockCount+1),r}_errorHandle(n,r,s=Sn.Error){this._errors.push({message:n,startColumn:r.start.column+1,startLineNumber:r.start.line,endColumn:r.start.column+2+r.stop.stop-r.start.start,endLineNumber:r.stop.line,type:s})}_boolTypeJudge(n,r,s,l=0){return this._typeJudge(n,r,s,U.BOOL,[U.UNDETERMINED,U.INT,U.FLOAT,U.BOOL],l)}_calcTypeJudge(n,r,s,l=0){return this._typeJudge(n,r,s,"int/float",[U.UNDETERMINED,U.INT,U.FLOAT],l)}_typeJudge(n,r,s,l,h,d=0){const v=n&&n.type;if(v){const S=this._removePrefix(v);if(!h.includes(S)&&S!==U.NA)return this._errorHandle(ye(de.typeMismatch,{operator:`operator ${s}`,index:`expr${d}`,typeE:S,typeR:l}),r),U.UNDETERMINED;l===U.BOOL&&[U.INT,U.FLOAT].includes(S)&&this._errorHandle(ye(sr.typeMismatch,{operator:`operator ${s}`,index:`expr${d}`,type:U.BOOL}),r,Sn.Warning)}return v||U.UNDETERMINED}_sameTypeJudge(n,r,s,l){let h="";const d=[],v=["plot_display","plot_simple_display"];["+","-","+=","-="].includes(s)&&(l=l.concat(v));for(const[S,C]of n.entries()){let A=C&&C.type||U.UNDETERMINED;const R=this._removePrefix(A);if(!l.includes(R)&&l.length&&R!==U.NA){this._errorHandle(ye(de.typeMismatch,{operator:`operator ${s}`,index:`expr${S}`,typeE:A,typeR:l.slice(1).join("/")}),r[S]),h=U.UNDETERMINED,d.push(h);continue}if(!h){h=R,d.push(A);continue}if(h===U.UNDETERMINED||R===U.UNDETERMINED)A=h=U.UNDETERMINED;else if(h!==R&&h!==U.NA&&R!==U.NA&&(![U.INT,U.FLOAT].includes(h)||![U.INT,U.FLOAT].includes(R)))if(s===":="){if(h===U.BOOL&&[U.INT,U.FLOAT].includes(R)){this._errorHandle(ye(sr.boolVarNumWarning,{name:n[0].name}),r[0],Sn.Warning),d.push(A);continue}this._errorHandle(ye(de.assignTypeMismatch,{typeE:R,name:n[0].name,typeR:h}),r[0]),A=h=U.UNDETERMINED}else if(["==","!=","?:"].includes(s)&&[U.INT,U.FLOAT,U.BOOL].includes(h)&&[U.INT,U.FLOAT,U.BOOL].includes(R))this._errorHandle(ye(sr.typeMismatch,{operator:`operator ${s}`,index:`expr${S}`,type:h}),r[S],Sn.Warning),A=h=U.UNDETERMINED;else if(v.includes(h)&&v.includes(R)){if(h!==R){const B=this._getPrefix(A);d[S-1]=`${this._getPrefix(d[S-1])} ${v[0]}`,A=h=`${B} ${v[0]}`}}else this._errorHandle(ye(de.typeMismatch,{operator:`operator ${s}`,index:`expr${S}`,typeE:R,typeR:h}),r[S]),A=h=U.UNDETERMINED;d.push(A)}return d}_getUserVar(n,r=!1){for(let s=this._blockCount;s>=0;s--){const l=this._currentBlockVars[s];if(s<=0){const h=this._currentFuncParams.get(n);if(h)return h.isArg=!0,h}if(l){const h=l.get(n);if(h)return h}}if(n.includes(".")&&!r){let s=!1,l=null;if(n.split(".").reduce((h,d)=>{let v=h?`${h}.${d}`:d;const S=this._getUserVar(v,!0);return S!=null&&S.type?S.type===U.UNDETERMINED?s=!0:(v=S.type,l=S):l=null,v},""),s)return{name:n,type:U.UNDETERMINED};if(l)return l}return null}_repeatVarJudge(n,r,s,l){this._getBuildVar(n)&&this._errorHandle(ye(de.buidinVarErr,{name:n}),r);for(let d=0;d<=this._blockCount;d++){const v=this._currentBlockVars[d];if(v&&v.get(n)){if(this._blockCount===d)return this._errorHandle(ye(de.repeatVar,{name:n}),r),!0;s.reName=`$_${n}__${this._blockCount}`,this._errorHandle(ye(sr.repeatVar,{name:n}),r,Sn.Warning)}}l!=null&&l.some(d=>d===n&&n!=="_")&&this._errorHandle(ye(de.repeatVar,{name:n}),r)}_judgeVarBuildIn(n){for(let r=0;r<=this._blockCount;r++){const s=this._currentBlockVars[r];if(s&&s.get(n))return!0}return!1}_updateUserVar(n,r,s){for(let l=0;l<=this._blockCount;l++){const h=this._currentBlockVars[l];if(h){const d=h.get(n);if(d){d.type=r,d.valueType=s;return}}}}_variablesHandle(n,r){var h,d,v,S;if(!(n&&n.nameList))return;const s=n.nameList;if(s.name==="_")return;const l=n.value;if(s.ruleType===le.VarMultiple){s.types=[],this._checkVarMultiple(s.names,l,r);for(const[C,A]of s.names.entries()){if(A==="_")continue;const R=this._varTypeJudge("",((h=l==null?void 0:l.types)==null?void 0:h[C])||U.UNDETERMINED,A,r);s.types.push(R),this._addVarToMap(A,R,s.posList[C],!0)}}else{const C=(l==null?void 0:l.type)||((d=l==null?void 0:l.returnedTypes)==null?void 0:d[0]);((v=l==null?void 0:l.types)!=null&&v.isBrackethesized||(S=l==null?void 0:l.returnedTypes)!=null&&S.isBrackethesized)&&this._errorHandle(ye(de.tupleLeftVarErr,{name:s.name}),r),!s.type&&C===`${U.SIMPLE} ${U.NA}`&&this._errorHandle(de.naVarErr,r),s.prefix&&Pi.indexOf(s.prefix)>Pi.indexOf(this._getPrefix(C))&&this._errorHandle(ye(de.declaredErr,{prefix:s.prefix,type:C}),r);const A=this._varTypeJudge(s.type,C||U.UNDETERMINED,s.name,r);s.type=A,this._addVarToMap(s.name,A,s.pos,!0,s.isForVar,s.declare,l==null?void 0:l.type,s.desc)}}_checkVarMultiple(n,r,s){var S,C,A,R;const l=n.length,h=((r==null?void 0:r.types)||(r==null?void 0:r.returnedTypes)||[]).length,d=((S=r==null?void 0:r.types)==null?void 0:S.isBrackethesized)||((C=r==null?void 0:r.returnedTypes)==null?void 0:C.isBrackethesized);(A=r==null?void 0:r.types)!=null&&A.isUnknown||(R=r==null?void 0:r.returnedTypes)!=null&&R.isUnknown||(h===1&&!d||!h?this._errorHandle(de.tupleRightVarErr,s):l!==h&&this._errorHandle(ye(de.tupleVarErr,{indexA:h,indexB:l}),s))}_addEnumToMap(n,r,s){var v;const l=this._currentBlockVars[this._blockCount]||new Map,h=(v=this._enums.get(n))==null?void 0:v[0];if(h&&h.members)for(const S of h.members)l.set(`${n}.${S.name}`,S);const d={name:n,isEnum:!0,type:`${U.CONST} ${r}`,pos:s};l.set(n,d),this._currentBlockVars[this._blockCount]=l}_addVarToMap(n,r,s,l=!0,h=!1,d,v,S){var B;const C=this._currentBlockVars[this._blockCount]||new Map,A=(B=this._types.get(r))==null?void 0:B[0];if(A&&A.fields)for(const M of A.fields)C.set(`${n}.${M.name}`,M);const R={name:n,type:r,pos:s,valueType:v,desc:S};l&&this._setVariablesMap(R),C.set(n,Object.assign(R,{isForVar:h,declare:d})),this._currentBlockVars[this._blockCount]=C}_setVariablesMap(n,r=!1){const s=this._blockRanges[this._blockCount];r||(n.range=s,n.scope=this._blockCount);const l=this._variables.get(n.name)||[];l.push(n),this._variables.set(n.name,l)}_varTypeJudge(n,r,s,l){if(r===U.VOID)return this._errorHandle(de.voidNotVar,l),U.UNDETERMINED;if(n&&r!==U.UNDETERMINED){const h=this._removePrefix(n),d=this._removePrefix(r);return d!==h&&d!==U.NA&&!(h===U.FLOAT&&d===U.INT)?h===U.BOOL&&[U.FLOAT,U.INT].includes(d)?(this._errorHandle(ye(sr.boolVarNumWarning,{name:s}),l,Sn.Warning),n):(this._errorHandle(ye(de.declareTypeErr,{type:n,valueType:r}),l),U.UNDETERMINED):this._typeHandle([n,r])}else if(r===U.UNDETERMINED)return U.UNDETERMINED;return n||r||U.UNDETERMINED}_getAllowTypes(n){const r=[];if(n===U.UNDETERMINED)return r;const s=this._getPrefix(n);if(s){const l=this._removePrefix(n);let h=-1;for(const[d,v]of Pi.entries())v===s&&(h=d),h>=0&&h<=d&&(l===U.FLOAT&&r.push(`${v} ${U.INT}`),r.push(`${v} ${l}`))}else n=this._arrayTypeConvert(n)||"",r.push(n),n.includes(U.FLOAT)&&r.push(n.replace(/float/,U.INT));return r}_setNewFunc(n,r){const s=`${n.name}.new`,l=[],h=[];for(const v of n.fields)l.push({name:v.name,required:!1,allowedTypeIDs:this._getAllowTypes(v.type),displayType:v.type}),h.push(`${v.type} ${v.name}`);const d={name:s,args:l,returnedTypes:[n.name],pos:r,syntax:[`${s}(${h.join(", ")}) → ${n.name}`]};n.isExport&&this._exportFunctions.push(d),this._functions.set(s,[{...d,isUser:!0}])}_setCopyFunc(n,r){const s=n.name,l=`${s}.copy`,h={name:l,args:[{name:"object",required:!0,allowedTypeIDs:[s],displayType:s}],returnedTypes:[s],pos:r,info:"The identifier of the object to be copied.",syntax:[`${l}(${s} object) → ${s}`]};n.isExport&&this._exportFunctions.push(h),this._functions.set(l,[{...h,isUser:!0}])}_setCopyMethod(n,r){const s=n.name,l=`${s}.copy`,h={name:l,originalName:l,args:[],returnedTypes:[s],thisType:[s],pos:r,syntax:[`${l}() → ${s}`]};n.isExport&&this._exportMethods.push(h),this._methods.set(l,[{...h,isUser:!0}])}_setFunc(n,r,s,l){const h=[],d=[],{desc:v,paramsDesc:S,returnsDesc:C,params:A,hasMemberIndex:R}=n;for(const O of A){const{type:w,name:D,defaultValue:H}=O;h.push({name:D,desc:S==null?void 0:S[D],required:!H,allowedTypeIDs:this._getAllowTypes(w),displayType:w}),d.push(`${w===U.UNDETERMINED?"":`${w} `}${D}`)}const{returnedTypes:B=[]}=n,M=n.name,b=B.length>1?`[${B.join(", ")}]`:B.toString(),y={name:M,desc:v,args:h,syntax:[`${M}(${d.join(", ")}) → ${b||"void"}`],hasMemberIndex:R,pos:r,isUser:!0,returnedTypes:B,returns:C,hasRequest:this._hasRequest};let g=this._functions.get(M);if(g){const O=g.length;y.index=O,n.index=O,this._verifyFuncRepeat(g,y,s),g.push(y),this._overloadsFuncs.push({name:M,index:O,line:r.lineNumber,startColumn:r.column+1,endColumn:r.column+M.length})}else g=[y];if(n.isExport){const{line:O=0}=this._endExport;l>O&&(this._endExport={line:l,name:M,index:y.index}),this._exportFunctions.push(y)}this._functions.set(M,g)}_setMethod(n,r){var w;const{name:s,returnedTypes:l,params:h,desc:d,paramsDesc:v,returnsDesc:S}=n,C=h[0].type,A=[],R=[];for(const D of h.slice(1)){const{type:H,name:X,defaultValue:ee}=D;A.push({name:X,desc:v==null?void 0:v[X],required:!ee,allowedTypeIDs:this._getAllowTypes(H),displayType:H}),R.push(`${H} ${X}`)}const B=l.length>1?`[${l.join(", ")}]`:l.toString(),M=this._getMethodTypeName(C),b=`${M}.${s}`;n.typeName=M;const y={name:s,args:A,desc:d,originalName:b,syntax:[`${s}(${R.join(", ")}) → ${B||"void"}`],returnedTypes:l,hasMemberIndex:n.hasMemberIndex,pos:r,thisType:[C],returns:S,hasRequest:this._hasRequest};let g=this._methods.get(b),O=this._functions.get(s);if(O){const D=O.filter(ee=>!ee.isImport).length,H=((w=g==null?void 0:g.filter(ee=>!ee.isImport))==null?void 0:w.length)||0;let X=D;D>H&&(X=D-1),y.index=X,n.index=X}g?g.push(y):g=[y],n.isExport&&this._exportMethods.push(y),this._methods.set(b,g)}_verifyFuncRepeat(n,r,s){const{args:l}=r;n.some(d=>{const{args:v}=d;return(v==null?void 0:v.length)!=(l==null?void 0:l.length)?!1:!(v!=null&&v.length)&&!(l!=null&&l.length)?!0:v==null?void 0:v.every((S,C)=>{var A;return S.displayType===((A=l==null?void 0:l[C])==null?void 0:A.displayType)})})&&this._errorHandle(ye(de.funcRepeatErr,{name:r.name}),s)}_getMethodTypes(n,r){let s;for(const[l,h]of n.entries()){const{type:d,expr:v,args:S}=h;let{name:C}=h;const A=r[l];if(v){if(v.type===U.UNDETERMINED)return[U.UNDETERMINED];C=`${this._getMethodTypeName(v.type)}${C}`,S.params.unshift(v)}if(s&&s.length>=1)if(s.length===1){const R=s[0];if(R===U.UNDETERMINED)return[U.UNDETERMINED];const B=this._getOriginMethodName(R,C);C.includes(".")?s=this._getOtherNamesMethodType(B,s,A,S,h):s=this._expandMethodHandle(B,A,S,{type:R},R,h)}else this._errorHandle(ye(de.noFiledErr,{name:C}),A);else{const[R,B]=this._tempFuncNameHandle(C,A,d);C=B;const M=this._buildinFunctions.get(R);if(M)this._globalFuncVerify(M[0],A),this._hasMemberIndexVerify(M[0],A,h),h.isBuiltIn=!0,s=this._getBuildInReturnTypes(M,S,C,A,void 0,d);else{const b=this._functions.get(C);if(b)if(b.length<=1){this._hasMemberIndexVerify(b[0],A,h),s=b[0].returnedTypes;const{hasErr:y}=this._checkArgs(S,b[0].args||[],C,A,s[0]);if(y)return[U.UNDETERMINED]}else{const y=this._overloadsFuncGetTypes(b,S,A,void 0,h);s=this._returnedTypesParse([y])}else s=this._getOtherNamesMethodType(C,s,A,S,h)}}h.returnTypes=s}return s===void 0&&this._errorHandle(ye(de.notFindFuncErr,{name:n[0].name}),r[0]),s}_globalFuncVerify(n,r){this._blockCount!==0&&F_.includes(n.name)&&this._errorHandle(ye(de.globalFuncErr,{name:n.name}),r)}_hasMemberIndexVerify(n,r,s){n.hasRequest&&(s.hasRequest=!0,this._hasRequest=!0),n.hasMemberIndex||n.name.startsWith("ta.")||n.name==="math.sum"?(this._hasMemberIndex=this._isInFunc,s.hasMemberIndex=!0,s.position=r.start.tokenIndex):n.name.startsWith("request.")&&this._isInLocalScop&&this._errorHandle(de.requestUserInLoopErr,r)}_tempFuncNameHandle(n,r,s){let l=n;if(s&&s.length>=1){const h=["array.new","matrix.new"].includes(n),d=n==="map.new";if(s.length===1)if(h)l=`${n}<type>`,n=`${n}<${s[0]}>`;else return d?this._errorHandle(ye(de.templateErr,{countA:2,countB:1}),r):this._errorHandle(ye(de.templateNoSupportErr,{name:n}),r),[U.UNDETERMINED];else{if(!d)return h?this._errorHandle(ye(de.templateErr,{countA:1,countB:2}),r):this._errorHandle(ye(de.templateNoSupportErr,{name:n}),r),[U.UNDETERMINED];if(!lu.includes(s[0]))return this._errorHandle(ye(de.mapKeyErr,{type:this._typeAddSeries(s[0])}),r),[U.UNDETERMINED];l=`${n}<type,type>`,n=`${n}<${s[0]},${s[1]}>`}}return[l,n]}_getOtherNamesMethodType(n,r,s,l,h){const d=n.split("."),v=d.length-1,S=d.slice(0,v).join("."),C=this._getUserVar(S);this._judgeGatherValue(d[v],s,C==null?void 0:C.valueType)||(h.name=`${S}?.${d[v]}`);const R=C==null?void 0:C.type;if(R){if(R===U.UNDETERMINED)return r=[U.UNDETERMINED],r.isUnknown=!0,r;const B=this._getOriginMethodName(R,d[v]);h.varScope=C.scope,r=this._expandMethodHandle(B,s,l,C,S,h)}else{let B="",M="",b="";for(const y of d.slice(0,v)){B?M=this._getOriginMethodName(B,y):M=M?`${M}.${y}`:y;const g=this._verifyName(M);if(g!=null&&g.type){if(B=g.type,b="",g.title.startsWith("built-in variable")){const O=this._getOriginMethodName(B,d[v]);r=this._expandMethodHandle(O,s,l,C,S,h),h.hasVarPrefix=!0}}else this._buildinTypes.get(M)?b=ye(de.methodNotExistErr,{name:M,methodName:d[v]}):b=ye(de.noFiledErr,{name:y})}b&&this._errorHandle(b,s)}return r}_expandMethodHandle(n,r,s,l,h,d){var C,A;let v;const S=this._buildinMethods.get(n);if(S)d.name=d.name.split(".").join("?.").replace("??","?"),v=this._getBuildInReturnTypes(S,s,n,r,l);else{const R=this._methods.get(n);if(R&&R.length)if(R.length<=1){const B=R[0],M=this._getMethodTypeName(((C=B.thisType)==null?void 0:C[0])||"");if(this._types.get(M))d.name=d.name.split(".").join("?.").replace("??","?");else{const g=this._functions.get(B.name);g&&(d.selfArg=(A=g[B.index||0].args)==null?void 0:A[0])}d.funcName=B.name,d.index=B.index,this._hasMemberIndexVerify(B,r,d),v=B.returnedTypes;const{hasErr:y}=this._checkArgs(s,B.args||[],n,r,(v==null?void 0:v[0])||"");if(y)return[U.UNDETERMINED]}else{const B=this._overloadsFuncGetTypes(R,s,r,l,d);v=this._returnedTypesParse([B])}else this._errorHandle(ye(de.methodNotExistErr,{methodName:n.split(".").slice(-1)[0],name:h}),r)}return v}_getBuildInReturnTypes(n,r,s,l,h,d){var S;let v;if(n.length===1){const{returnedTypes:C,syntax:A,args:R=[],thisType:B}=n[0],M=A[0].split("→")[1].trim(),b=h||r.params[0]||((S=R[0])==null?void 0:S.name)&&r[R[0].name];b&&!this._checkMethodThisType(B,b.type)&&this._errorHandle(ye(de.typeMismatch,{operator:s,index:b.name||"id",typeE:b.type,typeR:B[0]}),l);const{hasErr:y,types:g}=this._checkArgs(r,R,s,l,M,b);if(y)return[U.UNDETERMINED];if(v=g.length&&g||this._returnedTypesParse(C),v.length>1)return v;(d==null?void 0:d.length)===1?v=[this._typeReplace(M,d[0])]:(d==null?void 0:d.length)===2&&(v=[`${U.MAP}<${d[0]},${d[1]}>`]),v=this._returnTypesOtherHandle(b,M,v,s)}else{const C=this._overloadsFuncGetTypes(n,r,l,h);v=this._returnedTypesParse([C])}return v}_overloadsFuncGetTypes(n,r,s,l,h){var M,b,y;let d="",v=[],S=[],C=0,A=0;for(const[g,O]of n.entries()){const{args:w,returnedTypes:D,name:H,thisType:X}=O,ee=l||r.params[0]||r[w[0].name],{errMsg:z,warnMsg:Y,matchCount:V}=this._overloadsCheckArgs(r,w,H,s,ee);V>A&&(C=g,A=V),ee&&!this._checkMethodThisType(X,ee.type)&&z.unshift({msg:ye(de.typeMismatch,{operator:H,index:ee.name||"id",typeE:ee.type,typeR:X[0]}),ctx:s}),g===0?(v=z,S=Y,!z.length&&(d=D[0])):z.length?((M=v[0])!=null&&M.isLenErr&&!((b=z[0])!=null&&b.isLenErr)||v.length>z.length)&&(v=z,S=Y,C=g):this._priorityComparison(d,D[0])||(D[0]===`${U.ARRAY}<>`?d=`${ee.type}[]`:d=D[0],v=z,S=Y,C=g)}for(const g of v)this._errorHandle(g.msg,g.ctx);for(const g of S)this._errorHandle(g.msg,g.ctx,Sn.Warning);const R=s.children[0],B=n[0].name;if(R&&this._overloadsFuncs.push({name:B,index:C,line:R.start.line,startColumn:R.start.column+1,endColumn:R.start.column+B.length}),h){const g=n[C],{thisType:O,name:w,index:D}=g;if(this._hasMemberIndexVerify(g,s,h),h.index=D||C,O){const H=this._getMethodTypeName((O==null?void 0:O[0])||"");if(this._types.get(H))h.name=h.name.split(".").join("?.").replace("??","?");else{const ee=this._functions.get(w);ee&&(h.selfArg=(y=ee[0].args)==null?void 0:y[0])}}}return this._funcArgsAddOriginName(r,n[C].args,B),d||U.UNDETERMINED}_funcArgsAddOriginName(n,r,s){const l=n.params||[];for(const[h,d]of r.entries())h<l.length&&(l[h].originName=d.name);if(s==="input"){const h=l[0]||n.defval;Object.assign(n,{inputType:{name:`'${h!=null&&h.isSourceType?"source":this._removePrefix(h==null?void 0:h.type)}'`}})}}_overloadsCheckArgs(n,r,s,l,h){const d={...n},v=d.params;delete d.params;const S=Object.keys(d).length+v.length,C=r.length,A=[],R=[];let B=0;S>C&&(r.some(b=>["arg0, arg1, ...","number0, number1, ..."].includes(b.name))||A.push({msg:ye(de.argsLenErr,{name:s,lenA:S,lenB:C}),isLenErr:!0,ctx:l}));for(const[M,b]of r.entries()){let y=d[b.name];if(M<v.length&&(y&&A.push({msg:ye(sr.moreSameArg,{arg:b.name}),ctx:l}),y=v[M]),!y)b.required&&A.push({msg:ye(de.requiredParamErr,{name:s,argName:b.name}),ctx:l});else{const g=y.type!==`${U.SIMPLE} na`?this._checkArg(y,b,s,h,y.ctx,!0,R):"";g?A.push({msg:g,ctx:y.ctx}):B++,delete d[b.name]}if(["arg0, arg1, ...","number0, number1, ..."].includes(b.name)&&v.length>M+1){const g=v.slice(M+1);let O=v[M];for(const w of g){O.type===`${U.SIMPLE} ${U.NA}`&&(O=w);const D=w.type!==`${U.SIMPLE} ${U.NA}`?this._checkArg(w,b,s,O,w.ctx,!0,R):"";D&&A.push({msg:D,ctx:w.ctx})}}}if(Object.keys(d).length)for(const M of Object.keys(d))A.push({msg:ye(de.argsNameErr,{name:s,argName:M}),ctx:d[M].ctx});return{errMsg:A,warnMsg:R,matchCount:B}}_checkArgs(n,r,s,l,h,d){var M;const v={...n},S=v.params;delete v.params;const C=Object.keys(v).length+S.length,A=r.length;let R=!1,B=[];if(C>A&&!r.some(y=>["arg0, arg1, ...","number0, number1, ..."].includes(y.name)))return this._errorHandle(ye(de.argsLenErr,{name:s,lenA:C,lenB:A}),l),R=!0,{hasErr:R,types:B};for(const[b,y]of r.entries()){let g=v[y.name];if(b<S.length&&(g&&this._errorHandle(ye(sr.moreSameArg,{arg:y.name}),l,Sn.Warning),g=S[b],g.originName=y.name),!g)y.required&&(this._errorHandle(ye(de.requiredParamErr,{name:s,argName:y.name}),l),R=!0);else{const O=g.type!==`${U.SIMPLE} ${U.NA}`?this._checkArg(g,y,s,d,g.ctx):"";if(O)this._errorHandle(O,g.ctx),R=!0;else if(s.startsWith("request.")&&y.name==="expression")if(g.ruleType===le.Brackethesized)B=g.exprs.map(w=>this._typeReplace(h,w.type));else if((M=g.types||g.returnedTypes)!=null&&M.isBrackethesized)B=(g.types||g.returnedTypes).map(w=>this._typeReplace(h,w));else{const w=this._typeReplace(h,g.type);B.push(w)}else if(s==="input.enum"&&y.name==="defval"){const w=this._removePrefix(g.type);B.push(`${U.INPUT} ${w}`)}delete v[y.name]}}if(Object.keys(v).length)for(const b of Object.keys(v))this._errorHandle(ye(de.argsNameErr,{name:s,argName:b}),v[b].ctx),R=!0;return{hasErr:R,types:B}}_checkArg(n,r,s,l,h,d,v){var y,g;const{ruleType:S,exprs:C,name:A}=n;let R=n.type;S===le.Brackethesized&&(R=`[${C.map(O=>O.type).join(", ")}]`);const{allowedTypeIDs:B=[],displayType:M,name:b}=r;if(!(!R||R===U.UNDETERMINED||M===U.UNDETERMINED)){if(s==="input"&&b==="defval"&&!R.startsWith(U.CONST))if(Al.includes(A))n.isSourceType=!0;else return de.inputDefvalErr;if(!(this._checkMethodThisType(B,this._arrayTypeConvert(R))&&!(["input.source","input.enum"].includes(s)&&b==="defval"))){if(b==="condition"&&(M!=null&&M.endsWith(U.BOOL))){if(R.endsWith(U.INT)||R.endsWith(U.FLOAT)){const O=ye(sr.typeMismatch,{index:b,operator:s,type:U.BOOL});h&&(v?v.push({ctx:h,msg:O}):this._errorHandle(O,h,Sn.Warning));return}}else if(s==="str.tostring"&&b==="value"){const O=this._removePrefix(R);if(this._enums.get(O))return}switch(M){case"tuple of const string values: [val1, val2, ...]":return this._tupleToCheck(n,r,[`${U.CONST} ${U.STRING}`],s,R);case"tuple of const int/float values: [val1, val2, ...]":return this._tupleToCheck(n,r,[`${U.CONST} ${U.FLOAT}`,`${U.CONST} ${U.INT}`],s,R);case"tuple of const int values: [val1, val2, ...]":return this._tupleToCheck(n,r,[`${U.CONST} ${U.INT}`],s,R);case"open/high/low/close/hl2/hlc3/ohlc4/hlcc4":if(!A||!Al.includes(A))return ye(de.inputSourceErr,{name:b,funcName:s});if(this._judgeVarBuildIn(A))return ye(de.buildInUseErr,{name:A});n.isSourceType=!0;break;case"<matrix_type>":case"<array_type>":const O=this._getArrayType(s)||"";if(!R.endsWith(O)&&!(R.endsWith(U.INT)&&O===U.FLOAT))return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:this._typeAddSeries(O)});break;case"any matrix type":if(this._isMatrixType(R)){if(b==="id2"){const V=this._getArrayType(l==null?void 0:l.type);if(!V)return;const ne=this._getArrayType(R)||"";if(V!==ne)return ye(de.typeMismatch,{operator:s,index:b,typeE:ne,typeR:V})}}else return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:"matrix<fun_arg>"});break;case"any array type":if(this._isArrayType(R)){if(b==="id2"){const V=this._getArrayType(l==null?void 0:l.type);if(!V)return;const ne=this._getArrayType(R)||"";if(V!==ne)return ye(de.typeMismatch,{operator:s,index:b,typeE:ne,typeR:V})}}else return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:"array<fun_arg>"});break;case"series <type of the matrix's elements>":case"series <type of the array's elements>":const w=this._getArrayType(l==null?void 0:l.type)||"";if(!R.endsWith(w)&&!(R.endsWith(U.INT)&&w===U.FLOAT))return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:this._typeAddSeries(w)});break;case"any map type":if(this._isMapType(R)){if(b==="id2"){const V=this._getMapType(l==null?void 0:l.type);if(!V)return;const ne=this._getMapType(R)||[];if(V[0]!==ne[0]||V[1]!==ne[1])return ye(de.mapKeyValErr,{typeA:this._typeAddSeries(ne[0]),typeB:this._typeAddSeries(ne[1]),typeC:this._typeAddSeries(V[0]),typeD:this._typeAddSeries(V[1]),name:s})}}else return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:"map<type, type>"});break;case"series <type of the map's elements>":const D=this._getMapType(l==null?void 0:l.type);if(!D)return;const H=b==="key"?0:1;if(!R.endsWith(D[H])&&!(R.endsWith(U.INT)&&D[H]===U.FLOAT))return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:this._typeAddSeries(D[H])});break;case"<arg_expr_type>":if(S===le.Brackethesized)return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:M||""});break;case"<arg_type>":case"variable, function, object, array or matrix of series int/float/bool/string/color, or a tuple of these":const X=this._removePrefix(R);if([U.BOX,U.LABEL,U.LINE,U.LINEFILL,U.POLYLINE,U.TABLE].includes(X))return ye(de.requestExprErr,{type:X,name:s});break;case"variable, object or function of series int/float/bool/string/color, or a tuple of these":if(S===le.Brackethesized){for(const V of C)if(!B.includes(V.type))return ye(de.requestArgsErr,{name:s,argName:b,type:V.type})}break;case"const int/float/bool/string/color or source-type built-ins":if(Al.includes(n.name)&&B[0].endsWith(this._removePrefix(R)))n.isSourceType=!0;else return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:"const int/float/bool/string/color"});break;case"<arg..._type>":if(S===le.Brackethesized||this._isArrayType(R)||this._isMapType(R)||this._isMatrixType(R))return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:`${U.SERIES} ${U.INT}`});if(R!==(l==null?void 0:l.type))return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:l==null?void 0:l.type});break;case"simple enum":const ee=this._removePrefix(R);if(!this._enums.has(ee))return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:"const enum"});break;case"tuple of enum fields: [enumName.field1, enumName.field2, ...]":const z=l==null?void 0:l.enumName;if(z&&!((y=n.exprs)==null?void 0:y.every(ne=>ne.enumName===z)))return ye(de.typeMismatch,{operator:s,index:b,typeE:`${n.exprs?`[${(g=n.exprs)==null?void 0:g.map(ne=>ne.type).join(", ")}]`:n.type}`,typeR:`[const ${z}...]`});break;default:const Y=this._removePrefix(n.type);if(n.arg&&n.arg.isArg&&!d){const V=B.find(ne=>ne.endsWith(Y));if(V){n.type=V,n.arg.type=V;return}}if(B.length===1&&this._removePrefix(B[0])===Y){const V=this._getPrefix(n.type),ne=this._getPrefix(B[0]);if(Pi.indexOf(V)>=Pi.indexOf(ne))return}if(M)return ye(de.typeMismatch,{operator:s,index:b,typeE:R,typeR:M})}}}}_tupleToCheck(n,r,s,l,h){var d,v;if(s.push(`${U.SIMPLE} ${U.NA}`),n.ruleType===le.Brackethesized){const S=[];let C=!1;for(const A of n.exprs)S.push(A.type),s.includes(A.type)||(C=!0);if(C)return ye(de.typeMismatch,{operator:l,index:r.name,typeE:`[${S.join(", ")}]`,typeR:((d=r.allowedTypeIDs)==null?void 0:d[0])||""})}else return ye(de.typeMismatch,{operator:l,index:r.name,typeE:h,typeR:((v=r.allowedTypeIDs)==null?void 0:v[0])||""})}_getBlockReturnTypes(n){var R,B;let r=n;if(Array.isArray(n)&&(r=n.slice(-1)[0],Array.isArray(r)&&(r=r.slice(-1)[0])),!r)return[U.UNDETERMINED];const{ruleType:s,type:l,types:h,returnedTypes:d,exprs:v,nameList:S,typeList:C,block:A}=r;if(h&&h.length)return h;if(d&&d.length)return d;if(l)return[l];switch(s){case le.Brackethesized:const M=v.map(ee=>ee.type);return M.isBrackethesized=!0,M;case le.VarBlockStmt:case le.DeclareAssign:return S?S.ruleType===le.VarMultiple?S.types:[S.type]:[((R=r.name)==null?void 0:R.type)||U.UNDETERMINED];case le.SwitchStatement:if(!this._isNeedCalc&&this._isInFunc&&this._isEndExpr===!1)return[U.UNDETERMINED];const b=[...r.cases];r.defaultCase&&b.push(r.defaultCase);let y=((B=b[0])==null?void 0:B.returnedTypes)||[],g=y.length<=1?y[0]:`[${y.join(", ")}]`,O=null;for(const ee of b.slice(1)){const z=ee.returnedTypes||[U.UNDETERMINED];g+=z.length<=1?`; ${z[0]}`:`; [${z.join(", ")}]`;const Y=Array.isArray(ee.block)?ee.block.slice(-1)[0]:ee.block;if(z.length!==y.length)O=Y.ctx;else for(const[V,ne]of y.entries())if(this._compareType(z[V],ne))(z[V].includes(U.FLOAT)&&!ne.includes(U.FLOAT)||y[V]===`${U.SIMPLE} ${U.NA}`||y[V]===U.UNDETERMINED)&&(y[V]=z[V]);else{O=Y.ctx;break}}return O&&(this._errorHandle(ye(de.ifOrSwitchTypeErr,{keyword:"switch",types:g}),O),y=y.map(()=>U.UNDETERMINED)),r.returnedTypes=y,y;case le.IfStatement:if(!this._isNeedCalc&&!this._isInFunc)return[U.UNDETERMINED];if(!C.filter(ee=>ee&&ee.length).length)return[U.UNDETERMINED];let w=C[0]||[],D=w.length<=1?w[0]:`[${w.join(", ")}]`,H=0,X=0;for(const ee of C.slice(1))if(ee)if(H++,D+=ee.length<=1?`; ${ee[0]}`:`; [${ee.join(", ")}]`,ee.length!==w.length)X=H;else for(const[z,Y]of w.entries())if(this._compareType(ee[z],Y))(ee[z].includes(U.FLOAT)&&!Y.includes(U.FLOAT)||w[z]===`${U.SIMPLE} ${U.NA}`)&&(w[z]=ee[z]);else{X=H;break}if(X){const ee=A[X].slice(-1)[0],z=Array.isArray(ee)?ee.slice(-1)[0]:ee;this._errorHandle(ye(de.ifOrSwitchTypeErr,{keyword:"if",types:D}),z.ctx),w=w.map(()=>U.UNDETERMINED)}return r.returnedTypes=w,w}return[U.UNDETERMINED]}}class $_{constructor(e){k(this,"_nameMap");k(this,"_prefixNameVar");k(this,"_prefixNameFunc");k(this,"_prefixNameConst");k(this,"_userTypes");k(this,"_isInFunc");k(this,"_currentFuncName");k(this,"_varlist");k(this,"_memberIndexList");k(this,"_blockCount");k(this,"_inputCount");k(this,"_count");k(this,"_isSwitch",!1);k(this,"_isInLoop",!1);k(this,"_codesCol");k(this,"_dependsObj");k(this,"_enums");k(this,"_preRunMembers");k(this,"_isInConditionalStmt",!1);k(this,"_preRunMembersFuncs");k(this,"_preRunMemberFuncsCount",0);k(this,"__count",0);this._nameMap=new Map,this._prefixNameVar=`${e}_var`,this._prefixNameFunc=`${e}_func`,this._prefixNameConst=`${e}_const`,this._userTypes=[],this._isInFunc=!1,this._varlist=[{}],this._memberIndexList=[{}],this._blockCount=0,this._inputCount=0,this._count=0,this._codesCol=[[]],this._dependsObj={},this._enums=new Map,this._preRunMembers=[],this._preRunMembersFuncs=[]}preParser(e){var r,s;const n=[];for(const l of e){if(!l)return;if(Array.isArray(l)){for(const h of l)if(n.push(this._parserStmt(h)),Sl.includes((s=(r=h.exprs)==null?void 0:r[0])==null?void 0:s.name))return n.join(`;
|
14
14
|
`).replace(/;+/g,";")}else n.push(this._parserStmt(l))}return""}parser(e){const n=[];for(const s of e){if(!s)return;if(Array.isArray(s))for(const l of s)n.push(this._parserStmt(l));else n.push(this._parserStmt(s))}const r=this._memberIndexList[this._blockCount]||{};return n.push(...Object.values(r)),n.join(`;
|
15
15
|
`).replace(/;+/g,";")}_parserStmt(e,n=!1){let r="";switch(e==null?void 0:e.ruleType){case le.DeclareAssign:r=this._parserDeclareAssign(e);break;case le.MethodExpression:r=`${this._parserMethodExpression(e)}`;break;case le.ArrowFunction:r=this._parserArrowFunction(e);break;case le.ArrowMethod:r=this._parserArrowMethod(e);break;case le.IfStatement:r=this._parserIfStatement(e,n);break;case le.WhileStatement:r=this._parserWhileStatement(e,n);break;case le.SwitchStatement:r=this._parserSwitchStatement(e,n);break;case le.ForInStatement:r=this._parserForInStatement(e,n);break;case le.ForToStatement:r=this._parserForToStatement(e,n);break;case le.AgainAssign:r=this._parserAgainAssign(e);break;case le.ImportElement:r=e.code||"";break;case le.TypeStatement:r=this._parserTypeStatement(e);break;case le.VarBlockStmt:r=this._parserVarBlockStmt(e);break;case le.FlowStmt:if(this._isSwitch&&e.value==="break"){if(this._isInLoop){r="$$isBreak = true;";break}r="";break}r=`${e.value};`;break;case le.Brackethesized:r=this._parserBrackethesized(e);break;case le.EnumStatement:r=this._parserEnumStatement(e);break;default:r=this._parserSingleExpression(e);break}let s="";const l=this._preRunMembersFuncs[this._blockCount];l!=null&&l.length&&(s=l.join(`;
|
16
16
|
`),this._preRunMembersFuncs[this._blockCount]=[]);const h=this._preRunMembers[this._blockCount];if(h!=null&&h.length&&(s=`${s}
|
@@ -62,8 +62,8 @@ ${Pf}`)}function O1(s,t,e){return(s>=0&&e?` ${qf(s,t-1)}`:qf(s,t)).padEnd(t)}fun
|
|
62
62
|
`)}}if(typeof t=="string")return t;if(typeof t=="boolean")return String(t);if(typeof t=="number")return String(this._toStringFormat(t,e))}_arrToStr(t,e){return`[${t.map(n=>typeof n=="number"?this._toStringFormat(n,e):n).toString()}]`}substring({source:t="",begin_pos:e=0,end_pos:r}){return _t(e)&&(e=0),_t(r)&&(r=void 0),t==null?void 0:t.substring(e,r)}startswith({source:t="",str:e=""}){return t==null?void 0:t.startsWith(e)}format_time({time:t,format:e="yyyy-MM-dd'T'HH:mm:ssZ",timezone:r}){return _t(t)&&(t=0),qr(t,r).format(e)}replace_all({source:t="",target:e="",replacement:r=""}){return t==null?void 0:t.replace(new RegExp(e,"g"),r)}_toStringFormat(t,e){if(!e)return Number(t.toFixed(this._precision));switch(e){case Kt.mintick:return t.toFixed(this._precision);case Kt.percent:return`${t}%`;case Kt.volume:return this._intlNumberFormatter.format(Math.round(t));default:return this._formatOthers(t,e)}}_formatOthers(t,e){var l;let[r,n]=e.split(".");e.split("%").length===2&&(t=t*100);let[i,a=""]=String(t).split(".");if(r.includes("#")){if(r.includes(",")){const c=r.split(","),p=((l=c[c.length-1])==null?void 0:l.replace(/[^#]/g,"").length)||0;p&&(i=i.replace(new RegExp(`\\B(?=(\\d{${p}})+(?!\\d))`,"g"),",")),r=c.join("")}i=r.replace(/#/,i).replace(/#/g,"")}else i=`${r}${i}`;if(n&&n.includes("#")){const c=n.split("#").length-1;a=`${a.substring(0,c)}${n.replace(/#/g,"")}`}else a=n||"";return a?`${i}.${a}`:i}_formatNumber(t,e){if(!e)return Number(t.toFixed(this._precision));switch(e){case"integer":return String(Math.round(t));case"currency":return`$${t}`;case"percent":return`${t*100}%`;default:return this._formatOthers(t,e)}}_strFormat(t,e){let r=t;for(const[n,i]of e.entries()){if(i===void 0||typeof i=="number"&&isNaN(i)){r="NaN";continue}if(typeof i=="number"){const a=`\\{\\s*${n}\\s*,\\s*number\\s*,\\s*([^\\}]+)\\s*\\}`,l=t.match(new RegExp(a));if(l){const c=l[1];r=r.replace(new RegExp(a,"g"),String(this._formatNumber(i,c)))}else r=r.replace(new RegExp(`\\{${n}\\}`,"g"),String(i))}else r=r.replace(new RegExp(`\\{${n}\\}`,"g"),i)}return r}}class xy{constructor(t){$(this,"_errorListener");this._errorListener=t}new(){return new ka(this._errorListener)}copy({id:t}){return t==null?void 0:t.copy()}get({id:t,key:e}){return t==null?void 0:t.get({key:e})}put({id:t,key:e,value:r}){return t==null?void 0:t.put({key:e,value:r})}keys({id:t}){return t==null?void 0:t.keys()}size({id:t}){return t==null?void 0:t.size()}clear({id:t}){t==null||t.clear()}remove({id:t,key:e}){return t==null?void 0:t.remove({key:e})}values({id:t}){return t==null?void 0:t.values()}put_all({id:t,id2:e}){t==null||t.put_all({id2:e})}contains({id:t,key:e}){return t==null?void 0:t.contains({key:e})}}class ka{constructor(t){$(this,"_errorListener");$(this,"_mapInstance");this._errorListener=t,this._mapInstance=new Map}get isMap(){return!0}_copyMap(t){const e=new ka(this._errorListener);return e._mapInstance=new Map(t.entries()),e}copy(){return this._copyMap(this._mapInstance)}get({key:t}){return this._mapInstance.get(t)}put({key:t,value:e}){return this._mapInstance.set(t,e)}keys(){const t=new Qt(0,void 0,this._errorListener);return t._value=[...this._mapInstance.keys()],t}size(){return this._mapInstance.size}clear(){this._mapInstance.clear()}remove({key:t}){const e=this._mapInstance.get(t);return this._mapInstance.delete(t),e||void 0}values(){const t=new Qt(0,void 0,this._errorListener);return t._value=[...this._mapInstance.values()],t}put_all({id2:t}){this._mapInstance=new Map([...this._mapInstance,...t._mapInstance])}contains({key:t}){return this._mapInstance.has(t)}}class Ey{constructor(t){$(this,"_variables");this._variables=t}new({price:t,time:e,index:r}){return new Ai(t,r,e)}now({price:t}){const{time:e,bar_index:r}=this._variables;return new Ai(t,r,e)}copy({id:t}){return t==null?void 0:t.copy()}from_index({price:t,index:e}){return new Ai(t,e)}from_time({price:t,time:e}){return new Ai(t,void 0,e)}}class Ai{constructor(t,e,r){$(this,"_index");$(this,"_price");$(this,"_time");this._index=e,this._price=t,this._time=r}get index(){return this._index}get price(){return this._price}get time(){return this._time}copy(){return new Ai(this._price,this._index,this._time)}}class Ay{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultLabel",{text:"",xloc:we.bar_index,yloc:Wr.price,size:rr.normal,style:ge.styleLabelDown,textalign:Wt.alignCenter});this._variables=t,this._errorListener=e}new(t,e){const{time:r,high:n,low:i,bar_index:a}=this._variables,l=`label_${e}_${a}`;me(t,["color","textcolor"]);const c={...this._defaultLabel,...t,id:l,time:r,high:n,low:i,bar_index:a};t.point&&(c.x=c.xloc===we.bar_index?t.point.index:t.point.time,c.y=t.point.price),c.yloc===Wr.abovebar?c.y=n:c.yloc===Wr.belowbar&&(c.y=i),this._verfiyArgs(t,e);const p=new ao(l,this._variables,this._errorListener);return e.startsWith("export")||this._variables.label.add(l,c,p),p}_verfiyArgs(t,e){const{xloc:r,yloc:n,style:i,size:a,textalign:l,text_font_family:c}=t,p="label.new";this._paramVerfiy(i,e,p,Object.values(ge),"style"),this._paramVerfiy(r,e,p,Object.values(we),"xloc"),this._paramVerfiy(n,e,p,Object.values(Wr),"yloc"),this._paramVerfiy(a,e,p,Object.values(rr),"size"),this._paramVerfiy(l,e,p,[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"textalign"),this._paramVerfiy(c,e,p,Object.values(Zn),"text_font_family")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}label(t){return t.x}copy({id:t},e){return t==null?void 0:t.copy(e)}get_x({id:t},e){return t==null?void 0:t.get_x(e)}get_y({id:t},e){return t==null?void 0:t.get_y(e)}set_x({id:t,...e},r){t==null||t.set_x(e,r)}set_y({id:t,...e},r){t==null||t.set_y(e,r)}delete({id:t}){t==null||t.delete()}get_text({id:t},e){return t==null?void 0:t.get_text(e)}set_xy({id:t,...e},r){t==null||t.set_xy(e,r)}set_size({id:t,...e},r){t==null||t.set_size(e,r)}set_xloc({id:t,...e},r){t==null||t.set_xloc(e,r)}set_yloc({id:t,...e},r){t==null||t.set_yloc(e,r)}set_style({id:t,...e},r){t==null||t.set_style(e,r)}set_color({id:t,...e},r){t==null||t.set_color(e,r)}set_tooltip({id:t,...e},r){t==null||t.set_tooltip(e,r)}set_point({id:t,...e},r){t==null||t.set_point(e,r)}set_text({id:t,...e},r){t==null||t.set_text(e,r)}set_textcolor({id:t,...e},r){t==null||t.set_textcolor(e,r)}set_textalign({id:t,...e},r){t==null||t.set_textalign(e,r)}set_text_font_family({id:t,...e},r){t==null||t.set_text_font_family(e,r)}}class ao{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");this._id=t,this._variables=e,this._errorListener=r}get type(){return Fe.LABEL}get id(){return this._id}get data(){return this._variables.label.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`label_${t}_${e}`,n=this._getLabel(t),i=new ao(r,this._variables,this._errorListener);if(n){const a={...n,id:r,bar_index:e};this._variables.label.add(r,a,i)}return i}get_x(t){var e;return(e=this._getLabel(t))==null?void 0:e.x}get_y(t){var e;return(e=this._getLabel(t))==null?void 0:e.y}set_x({x:t},e){const r=this._getLabel(e);r&&(r.x=t)}set_y({y:t},e){const r=this._getLabel(e);r&&(r.y=t)}delete(){this._variables.label.delete(this._id)}set_xy({x:t,y:e},r){const n=this._getLabel(r);n&&(n.x=t,n.y=e)}get_text(t){var e;return(e=this._getLabel(t))==null?void 0:e.text}set_size({size:t},e){const r=this._getLabel(e);r&&(r.size=t),this._paramVerfiy(t,e,"label.set_size",Object.values(rr),"size")}set_text({text:t},e){const r=this._getLabel(e);r&&(r.text=t)}set_xloc({x:t,xloc:e},r){const n=this._getLabel(r);n&&(n.x=t,n.xloc=e,this._paramVerfiy(e,r,"label.set_xloc",Object.values(we),"xloc"))}set_yloc({yloc:t},e){const r=this._getLabel(e),{high:n,low:i}=this._variables;r&&(r.yloc=t,t===Wr.abovebar?r.y=n:t===Wr.belowbar&&(r.y=i),this._paramVerfiy(t,e,"label.set_yloc",Object.values(Wr),"yloc"))}set_color(t,e){const r=this._getLabel(e);me(t,["color"]),r&&(r.color=t.color)}set_point({point:t},e){const r=this._getLabel(e);r&&(r.x=r.xloc===we.bar_index?t==null?void 0:t.index:t==null?void 0:t.time,r.y=t==null?void 0:t.price)}set_style({style:t},e){const r=this._getLabel(e);r&&(r.style=t),this._paramVerfiy(t,e,"label.set_style",Object.values(ge),"style")}set_tooltip({tooltip:t},e){const r=this._getLabel(e);r&&(r.tooltip=t)}set_textalign({textalign:t},e){const r=this._getLabel(e);r&&(r.textalign=t),this._paramVerfiy(t,e,"label.set_textalign",[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"textalign")}set_textcolor(t,e){const r=this._getLabel(e);me(t,["textcolor"]),r&&(r.textcolor=t.textcolor)}set_text_font_family({text_font_family:t},e){const r=this._getLabel(e);r&&(r.text_font_family=t),this._paramVerfiy(t,e,"label.set_text_font_family",Object.values(Zn),"text_font_family")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getLabel(t){const e=this._variables.label.get(this._id);return e||console.log(`错误${t}: label 不存在`),e}}const Cy={freq_all:kr.freqAll,freq_once_per_bar:kr.freqOncePerBar,freq_once_per_bar_close:kr.freqOncePerBarClose},Fy={gaps_off:Vi.gapsOff,gaps_on:Vi.gapsOn,lookahead_off:Vi.lookaheadOff,lookahead_on:Vi.lookaheadOn},Ci={aqua:"#00BCD4",black:"#363A45",blue:"#2196F3",fuchsia:"#E040FB",gray:"#787B86",green:"#4CAF50",lime:"#00E676",maroon:"#880E4F",navy:"#311B92",olive:"#808000",orange:"#FF9800",purple:"#9C27B0",red:"#FF5252",silver:"#B2B5BE",teal:"#00897B",white:"#FFFFFF",yellow:"#FFEB3B"},Jf={AUD:"AUD",BTC:"BTC",CAD:"CAD",CHF:"CHF",ETH:"ETH",EUR:"EUR",GBP:"GBP",HKD:"HKD",INR:"INR",JPY:"JPY",KRW:"KRW",MYR:"MYR",NOK:"NOK",NONE:"NONE",NZD:"NZD",RUB:"RUB",SEK:"SEK",SGD:"SGD",TRY:"TRY",USD:"USD",USDT:"USDT",ZAR:"ZAR"},My={friday:6,monday:2,saturday:7,sunday:1,thursday:5,tuesday:3,wednesday:4},Xf={all:[Ve.dataWindow,Ve.pane,Ve.priceScale,Ve.statusLine],data_window:[Ve.dataWindow],none:[],pane:[Ve.pane],price_scale:[Ve.priceScale],status_line:[Ve.statusLine]},Ny={both:Ur.both,left:Ur.left,none:Ur.none,right:Ur.right},Sy={inherit:Kt.inherit,mintick:Kt.mintick,percent:Kt.percent,price:Kt.price,volume:Kt.volume},By={style_solid:Ds.styleSolid,style_dashed:Ds.styleDashed,style_dotted:Ds.styleDotted},Oy={style_arrowdown:ge.styleArrowdown,style_arrowup:ge.styleArrowup,style_circle:ge.styleCircle,style_cross:ge.styleCross,style_diamond:ge.styleDiamond,style_flag:ge.styleFlag,style_label_center:ge.styleLabelCenter,style_label_down:ge.styleLabelDown,style_label_left:ge.styleLabelLeft,style_label_lower_left:ge.styleLabelLowerLeft,style_label_lower_right:ge.styleLabelLowerRight,style_label_right:ge.styleLabelRight,style_label_up:ge.styleLabelUp,style_label_upper_left:ge.styleLabelUpperLeft,style_label_upper_right:ge.styleLabelUpperRight,style_none:ge.styleNone,style_square:ge.styleSquare,style_text_outline:ge.styleTextOutline,style_triangledown:ge.styleTriangledown,style_triangleup:ge.styleTriangleup,style_xcross:ge.styleXcross},Iy={style_arrow_both:Re.styleArrowBoth,style_arrow_left:Re.styleArrowLeft,style_arrow_right:Re.styleArrowRight,style_dashed:Re.styleDashed,style_dotted:Re.styleDotted,style_solid:Re.styleSolid},Ty={abovebar:an.abovebar,absolute:an.absolute,belowbar:an.belowbar,bottom:an.bottom,top:an.top},$y={e:2.718281828459045,phi:1.618033988749895,pi:3.141592653589793,rphi:.6180339887498948},Ly={style_area:Mr.styleArea,style_areabr:Mr.styleAreabr,style_circles:Mr.styleCircles,style_columns:Mr.styleColumns,style_cross:Mr.styleCross,style_histogram:Mr.styleHistogram,style_line:Mr.styleLine,style_linebr:Mr.styleLinebr,style_stepline:Mr.styleStepline,style_stepline_diamond:Mr.styleSteplineDiamond,style_steplinebr:Mr.styleSteplinebr},Ry={bottom_center:_r.bottomCenter,bottom_left:_r.bottomLeft,bottom_right:_r.bottomRight,middle_center:_r.middleCenter,middle_left:_r.middleLeft,middle_right:_r.middleRight,top_center:_r.topCenter,top_left:_r.topLeft,top_right:_r.topRight},Py={left:bs.left,none:bs.none,right:bs.right},zy={arrowdown:ur.arrowdown,arrowup:ur.arrowup,circle:ur.circle,cross:ur.cross,diamond:ur.diamond,flag:ur.flag,labeldown:ur.labeldown,labelup:ur.labelup,square:ur.square,triangledown:ur.triangledown,triangleup:ur.triangleup,xcross:ur.xcross},qy={auto:rr.auto,huge:rr.huge,large:rr.large,normal:rr.normal,small:rr.small,tiny:rr.tiny},ky={cash:Ie.cash,fixed:Ie.fixed,percent_of_equity:Ie.percentOfEquity,commission:{cash_per_contract:nr.cashPerContract,cash_per_order:nr.cashPerOrder,percent:nr.percent},direction:{all:ue.all,long:ue.long,short:ue.short},oca:{cancel:un.cancel,none:un.none,reduce:un.reduce}},Uy={align_bottom:Wt.alignBottom,align_center:Wt.alignCenter,align_left:Wt.alignLeft,align_right:Wt.alignRight,align_top:Wt.alignTop,wrap_auto:Wt.wrapAuto,wrap_none:Wt.wrapNone},Wy={bar_index:we.bar_index,bar_time:we.bar_time},jy={abovebar:Wr.abovebar,belowbar:Wr.belowbar,price:Wr.price},Yy={actual:xs.actual,estimate:xs.estimate,standardized:xs.standardized};class Qf{constructor(){$(this,"adjustment",{dividends:ws.dividends,none:ws.none,splits:ws.splits});$(this,"alert",Cy);$(this,"barmerge",Fy);$(this,"color",Ci);$(this,"currency",Jf);$(this,"dayofweek",My);$(this,"earnings",Yy);$(this,"display",Xf);$(this,"extend",Ny);$(this,"font",{family_default:Zn.familyDefault,family_monospace:Zn.familyMonospace});$(this,"format",Sy);$(this,"hline",By);$(this,"label",Oy);$(this,"line",Iy);$(this,"location",Ty);$(this,"math",$y);$(this,"order",{ascending:Vn.ascending,descending:Vn.descending});$(this,"plot",Ly);$(this,"position",Ry);$(this,"scale",Py);$(this,"session",{extended:fi.extended,regular:fi.regular});$(this,"shape",zy);$(this,"size",qy);$(this,"splits",{denominator:"denominator",numerator:"numerator"});$(this,"strategy",ky);$(this,"text",Uy);$(this,"xloc",Wy);$(this,"yloc",jy)}updateData(){}}class Vy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultPolyline",{curved:!1,closed:!1,xloc:we.bar_index,line_color:Ci.blue,line_style:Re.styleSolid,line_width:1});this._variables=t,this._errorListener=e}new(t,e){var l;const{bar_index:r}=this._variables,n=`polyline_${e}_${r}`,i=Object.assign({},this._defaultPolyline,t,{id:n,bar_index:r,points:(l=t.points)==null?void 0:l._value.map(c=>({time:c.time,index:c.index,price:c.price}))});me(i,["line_color","fill_color"]);const a=new th(n,this._variables);return this._verfiyArgs(t,e),e.startsWith("export")||this._variables.polyline.add(n,i,a),a}_verfiyArgs(t,e){const{line_style:r,xloc:n}=t,i="polyline.new";this._paramVerfiy(r,e,i,Object.values(Re),"line_style"),this._paramVerfiy(n,e,i,Object.values(we),"xloc")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}delete({id:t}){t&&t.delete()}}class th{constructor(t,e){$(this,"_id");$(this,"_variables");this._variables=e,this._id=t}get type(){return Fe.POLYLINE}get id(){return this._id}get data(){return this._variables.polyline.get(this._id)}delete(){this._variables.polyline.delete(this._id)}}class Zy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultLine",{xloc:we.bar_index,extend:Ur.none,style:Re.styleSolid});this._variables=t,this._errorListener=e}new({first_point:t,second_point:e,...r},n){const{bar_index:i}=this._variables,a=`line_${n}_${i}`;me(r,["color"]);const l={...this._defaultLine,...r,id:a,bar_index:i};if(t&&e){const p=l.xloc===we.bar_index?t==null?void 0:t.index:t==null?void 0:t.time,h=l.xloc===we.bar_index?e==null?void 0:e.index:e==null?void 0:e.time;Object.assign(l,{x1:p,y1:t==null?void 0:t.price,x2:h,y2:e==null?void 0:e.price})}this._verfiyArgs(r,n);const c=new uo(a,this._variables,this._errorListener);return n.startsWith("export")||this._variables.line.add(a,l,c),c}_verfiyArgs(t,e){const{extend:r,xloc:n,style:i}=t,a="line.new";this._paramVerfiy(i,e,a,Object.values(Re),"style"),this._paramVerfiy(r,e,a,Object.values(Ur),"extend"),this._paramVerfiy(n,e,a,Object.values(we),"xloc")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}line(t){return t.x}copy({id:t},e){return t==null?void 0:t.copy(e)}delete({id:t}){t==null||t.delete()}get_x1({id:t},e){return t==null?void 0:t.get_x1(e)}get_x2({id:t},e){return t==null?void 0:t.get_x2(e)}get_y1({id:t},e){return t==null?void 0:t.get_y1(e)}get_y2({id:t},e){return t==null?void 0:t.get_y2(e)}set_x1({id:t,...e},r){t==null||t.set_x1(e,r)}set_x2({id:t,...e},r){t==null||t.set_x2(e,r)}set_y1({id:t,...e},r){t==null||t.set_y1(e,r)}set_y2({id:t,...e},r){t==null||t.set_y2(e,r)}set_xy1({id:t,...e},r){t==null||t.set_xy1(e,r)}set_xy2({id:t,...e},r){t==null||t.set_xy2(e,r)}set_xloc({id:t,...e},r){t==null||t.set_xloc(e,r)}get_price({id:t,...e},r){return t==null?void 0:t.get_price(e,r)}set_color({id:t,...e},r){t==null||t.set_color(e,r)}set_style({id:t,...e},r){t==null||t.set_style(e,r)}set_width({id:t,...e},r){t==null||t.set_width(e,r)}set_extend({id:t,...e},r){t==null||t.set_extend(e,r)}set_first_point({id:t,...e},r){t==null||t.set_first_point(e,r)}set_second_point({id:t,...e},r){t==null||t.set_second_point(e,r)}}class uo{constructor(t,e,r){$(this,"_variables");$(this,"_id");$(this,"_errorListener");this._id=t,this._variables=e,this._errorListener=r}get id(){return this._id}get type(){return Fe.LINE}get data(){return this._variables.line.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`line_${t}_${e}`,n=this._getLine(t),i=new uo(r,this._variables,this._errorListener);return n&&this._variables.line.add(r,{...n,id:r,bar_index:e},i),i}delete(){this._variables.line.delete(this._id)}get_price({x:t},e){const r=this._getLine(e);if(t===void 0)return t;if(r&&r.xloc===we.bar_index){const{x1:n,y1:i,x2:a,y2:l}=r;return n===void 0||a===void 0||i===void 0||l===void 0?void 0:(l-i)/(a-n)*(t-n)+i}}get_x1(t){var e;return(e=this._getLine(t))==null?void 0:e.x1}get_x2(t){var e;return(e=this._getLine(t))==null?void 0:e.x2}get_y1(t){var e;return(e=this._getLine(t))==null?void 0:e.y1}get_y2(t){var e;return(e=this._getLine(t))==null?void 0:e.y2}set_x1({x:t},e){const r=this._getLine(e);r&&(r.x1=t)}set_x2({x:t},e){const r=this._getLine(e);r&&(r.x2=t)}set_y1({y:t},e){const r=this._getLine(e);r&&(r.y1=t)}set_y2({y:t},e){const r=this._getLine(e);r&&(r.y2=t)}set_xy1({x:t,y:e},r){const n=this._getLine(r);n&&(n.x1=t,n.y1=e)}set_xy2({x:t,y:e},r){const n=this._getLine(r);n&&(n.x2=t,n.y2=e)}set_xloc({xloc:t,x1:e,x2:r},n){const i=this._getLine(n);i&&(i.xloc=t,i.x1=e,i.x2=r,this._paramVerfiy(t,n,"line.set_xloc",Object.values(we),"xloc"))}set_color(t,e){const r=this._getLine(e);r&&(me(t,["color"]),r.color=t.color)}set_style({style:t},e){const r=this._getLine(e);r&&(r.style=t,this._paramVerfiy(t,e,"line.set_style",Object.values(Re),"style"))}set_width({width:t},e){const r=this._getLine(e);r&&(r.width=t)}set_extend({extend:t},e){const r=this._getLine(e);r&&(r.extend=t,this._paramVerfiy(t,e,"line.set_extend",Object.values(Ur),"extend"))}set_first_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:i,price:a}=t||{},l=r.xloc===we.bar_index?n:i,c=a;l&&(r.x1=l),c&&(r.y1=c)}}set_second_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:i,price:a}=t||{},l=r.xloc===we.bar_index?n:i,c=a;l&&(r.x2=l),c&&(r.y2=c)}}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getLine(t){const e=this._variables.line.get(this._id);return e||console.log(`${t}: line 不存在`),e}}class Ky{constructor(t){$(this,"_variables");this._variables=t}new(t,e){const{line1:r,line2:n}=t,{bar_index:i}=this._variables,a=`linefill_${e}_${i}`,l=r==null?void 0:r.data,c=n==null?void 0:n.data;l&&(l.linefills=l.linefills||[],l.linefills.push(a)),c&&(c.linefills=c.linefills||[],c.linefills.push(a)),me(t,["color"]);const p=new lo(this._variables,a,r,n);return e.startsWith("export")||(l||c)&&this._variables.linefill.add(a,{line1:l,line2:c,color:t.color,id:a,bar_index:i},p),p}delete({id:t}){t==null||t.delete()}get_line1({id:t}){return t==null?void 0:t.get_line1()}get_line2({id:t}){return t==null?void 0:t.get_line2()}set_color({id:t,...e}){t==null||t.set_color(e)}}class lo{constructor(t,e,r,n){$(this,"_id");$(this,"_line1");$(this,"_line2");$(this,"_variables");this._variables=t,this._id=e,this._line1=r,this._line2=n}get type(){return Fe.LINEFILL}get id(){return this._id}get data(){return this._variables.linefill.get(this._id)}linefill(t,e){return t.x?t.x:new lo(this._variables,e)}delete(){var e,r;const t=this._variables.linefill.get(this._id);if(t){const{line1:n,line2:i}=t;n&&(n.linefills=(e=n.linefills)==null?void 0:e.filter(a=>a!==this._id)),i&&(i.linefills=(r=i.linefills)==null?void 0:r.filter(a=>a!==this._id))}this._line1=void 0,this._line2=void 0,this._variables.linefill.delete(this._id)}get_line1(){return this._line1}get_line2(){return this._line2}set_color(t){const e=this._variables.linefill.get(this._id);e&&(me(t,["color"]),e.color=t.color)}}class Gy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultBox",{border_color:Ci.blue,border_width:1,bgcolor:Ci.blue,xloc:we.bar_index,extend:Ur.none,style:Re.styleSolid,text:"",text_size:rr.auto,text_color:Ci.black,text_halign:Wt.alignCenter,text_valign:Wt.alignCenter,text_wrap:Wt.wrapNone});this._variables=t,this._errorListener=e}box({x:t}){return t}new({top_left:t,bottom_right:e,...r},n){const{bar_index:i}=this._variables,a=`box_${n}_${i}`,l={...this._defaultBox,...r,id:a,bar_index:i};if(me(l,["border_color","bgcolor","text_color"]),t){const{price:p,time:h,index:f}=t;l.top=p,l.left=l.xloc===we.bar_index?f:h}if(e){const{price:p,time:h,index:f}=e;l.bottom=p,l.right=l.xloc===we.bar_index?f:h}this._verfiyArgs(r,n);const c=new co(this._variables,a,this._errorListener);return n.startsWith("export")||this._variables.box.add(a,l,c),c}_verfiyArgs(t,e){const{border_style:r,extend:n,xloc:i,text_size:a,text_halign:l,text_valign:c,text_wrap:p,text_font_family:h}=t,f="box.new";this._paramVerfiy(r,e,f,[Re.styleDashed,Re.styleDotted,Re.styleSolid],"border_style"),this._paramVerfiy(n,e,f,Object.values(Ur),"extend"),this._paramVerfiy(i,e,f,Object.values(we),"xloc"),this._paramVerfiy(a,e,f,Object.values(rr),"text_size"),this._paramVerfiy(l,e,f,[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"text_halign"),this._paramVerfiy(c,e,f,[Wt.alignBottom,Wt.alignCenter,Wt.alignTop],"text_valign"),this._paramVerfiy(p,e,f,[Wt.wrapAuto,Wt.wrapNone],"text_wrap"),this._paramVerfiy(h,e,f,Object.values(Zn),"text_font_family")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}copy({id:t},e){return t==null?void 0:t.copy(e)}delete({id:t}){t==null||t.delete()}get_top({id:t}){return t==null?void 0:t.get_top()}get_bottom({id:t}){return t==null?void 0:t.get_bottom()}get_left({id:t}){return t==null?void 0:t.get_left()}get_right({id:t}){return t==null?void 0:t.get_right()}set_top({id:t,...e}){t==null||t.set_top(e)}set_bottom({id:t,...e}){t==null||t.set_bottom(e)}set_left({id:t,...e}){t==null||t.set_left(e)}set_right({id:t,...e}){t==null||t.set_right(e)}set_extend({id:t,...e},r){t==null||t.set_extend(e,r)}set_bgcolor({id:t,...e}){t==null||t.set_bgcolor(e)}set_border_color({id:t,...e}){t==null||t.set_border_color(e)}set_border_width({id:t,...e}){t==null||t.set_border_width(e)}set_border_style({id:t,...e},r){t==null||t.set_border_style(e,r)}set_lefttop({id:t,...e}){t==null||t.set_lefttop(e)}set_rightbottom({id:t,...e}){t==null||t.set_rightbottom(e)}set_text_size({id:t,...e},r){t==null||t.set_text_size(e,r)}set_text_wrap({id:t,...e},r){t==null||t.set_text_wrap(e,r)}set_text_color({id:t,...e}){t==null||t.set_text_color(e)}set_text_halign({id:t,...e},r){t==null||t.set_text_halign(e,r)}set_text_valign({id:t,...e},r){t==null||t.set_text_valign(e,r)}set_top_left_point({id:t,...e}){t==null||t.set_top_left_point(e)}set_bottom_right_point({id:t,...e}){t==null||t.set_bottom_right_point(e)}set_text_font_family({id:t,...e},r){t==null||t.set_text_font_family(e,r)}}class co{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");this._variables=t,this._id=e,this._errorListener=r}get type(){return Fe.BOX}get id(){return this._id}get data(){return this._variables.box.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`box_${t}_${e}`,n=this._getBox(),i=new co(this._variables,r,this._errorListener);return n&&this._variables.box.add(r,{...n,id:r,bar_index:e},i),i}delete(){this._variables.box.delete(this._id)}get_top(){const t=this._getBox();return t&&t.top}set_top({top:t}){const e=this._getBox();e&&(e.top=t)}get_left(){const t=this._getBox();return t&&t.left}set_left({left:t}){const e=this._getBox();e&&(e.left=t)}set_text({text:t}){const e=this._getBox();e&&(e.text=t)}get_right(){const t=this._getBox();return t&&t.right}set_right({right:t}){const e=this._getBox();e&&(e.right=t)}get_bottom(){const t=this._getBox();return t&&t.bottom}set_bottom({bottom:t}){const e=this._getBox();e&&(e.bottom=t)}set_extend({extend:t},e){const r=this._getBox();r&&(r.extend=t,this._paramVerfiy(t,e,"box.set_extend",Object.values(Ur),"extend"))}set_bgcolor({color:t}){const e=this._getBox();e&&(e.bgcolor=t,me(e,["bgcolor"]))}set_lefttop({left:t,top:e}){const r=this._getBox();r&&(r.left=t,r.top=e)}set_text_size({text_size:t},e){const r=this._getBox();r&&(r.text_size=t,this._paramVerfiy(t,e,"box.set_text_size",Object.values(rr),"text_size"))}set_text_wrap({text_wrap:t},e){const r=this._getBox();r&&(r.text_wrap=t,this._paramVerfiy(t,e,"box.set_text_wrap",[Wt.wrapAuto,Wt.wrapNone],"text_wrap"))}set_text_color({text_color:t}){const e=this._getBox();e&&(e.text_color=t,me(e,["text_color"]))}set_rightbottom({right:t,bottom:e}){const r=this._getBox();r&&(r.right=t,r.bottom=e)}set_text_halign({text_halign:t},e){const r=this._getBox();r&&(r.text_halign=t,this._paramVerfiy(t,e,"box.set_text_halign",[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"text_halign"))}set_text_valign({text_valign:t},e){const r=this._getBox();r&&(r.text_valign=t,this._paramVerfiy(t,e,"box.set_text_valign",[Wt.alignBottom,Wt.alignCenter,Wt.alignTop],"text_valign"))}set_top_left_point({point:t}){const e=this._getBox();if(e){const{index:r,price:n,time:i}=t||{};e.top=n,e.left=e.xloc===we.bar_index?r:i}}set_border_color({color:t}){const e=this._getBox();e&&(e.border_color=t,me(e,["border_color"]))}set_border_style({style:t},e){const r=this._getBox();r&&(r.border_style=t,this._paramVerfiy(t,e,"box.set_border_style",[Re.styleDashed,Re.styleDotted,Re.styleSolid],"style"))}set_border_width({width:t}){const e=this._getBox();e&&(e.border_width=t)}set_bottom_right_point({point:t}){const e=this._getBox();if(e){const{index:r,price:n,time:i}=t||{};e.bottom=n,e.right=e.xloc===we.bar_index?r:i}}set_text_font_family({text_font_family:t},e){const r=this._getBox();r&&(r.text_font_family=t,this._paramVerfiy(t,e,"box.set_text_font_family",Object.values(Zn),"text_font_family"))}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getBox(){return this._variables.box.get(this._id)}}class Hy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultTable",{position:_r.topLeft,columns:0,rows:0,frame_width:0,border_width:0});this._variables=t,this._errorListener=e}table({x:t}){return t}new(t,e){const{bar_index:r}=this._variables,n=`table_${e}_${r}`,{columns:i,rows:a}=t;me(t,["text_color","bgcolor","border_color"]);const l=Array.from(Array(a),()=>Array.from(Array(i),()=>{})),c={...this._defaultTable,...t,cell:l,id:n,bar_index:r},p=new eh(this._variables,n,this._errorListener);return this._paramVerfiy(t.position,e,"table.new",Object.values(_r),"position"),e.startsWith("export")||this._variables.table.add(n,c,p),p}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}cell({table_id:t,...e}){t==null||t.cell(e)}cell_set_bgcolor({table_id:t,...e}){t==null||t.cell_set_bgcolor(e)}cell_set_height({table_id:t,...e}){t==null||t.cell_set_height(e)}cell_set_text({table_id:t,...e}){t==null||t.cell_set_text(e)}cell_set_text_color({table_id:t,...e}){t==null||t.cell_set_text_color(e)}cell_set_text_font_family({table_id:t,...e}){t==null||t.cell_set_text_font_family(e)}cell_set_text_halign({table_id:t,...e}){t==null||t.cell_set_text_halign(e)}cell_set_text_valign({table_id:t,...e}){t==null||t.cell_set_text_valign(e)}cell_set_text_size({table_id:t,...e}){t==null||t.cell_set_text_size(e)}cell_set_tooltip({table_id:t,...e}){t==null||t.cell_set_tooltip(e)}cell_set_width({table_id:t,...e}){t==null||t.cell_set_width(e)}clear({table_id:t,...e}){t==null||t.clear(e)}delete({table_id:t}){t==null||t.delete()}merge_cells({table_id:t,...e},r){t==null||t.merge_cells(e,r)}set_bgcolor({table_id:t,...e}){t==null||t.set_bgcolor(e)}set_border_color({table_id:t,...e}){t==null||t.set_border_color(e)}set_border_width({table_id:t,...e}){t==null||t.set_border_width(e)}set_frame_color({table_id:t,...e}){t==null||t.set_frame_color(e)}set_frame_width({table_id:t,...e}){t==null||t.set_frame_width(e)}set_position({table_id:t,...e},r){t==null||t.set_position(e,r)}}class eh{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");$(this,"_defaultCell",{column:0,row:0,text:"",text_color:Ci.black,text_halign:Wt.alignCenter,text_valign:Wt.alignCenter,text_size:rr.normal});this._variables=t,this._id=e,this._errorListener=r}get type(){return Fe.TABLE}get id(){return this._id}get data(){return this._variables.table.get(this._id)}cell(t){const e={...this._defaultCell,...t},{column:r=0,row:n=0}=e,i=this._variables.table.get(this._id);if(i){const a=i.cell||[],l=a[n]||[];l[r]=e,a[n]=l,i.cell=a}}cell_set_bgcolor({column:t=0,row:e=0,bgcolor:r}){const n=this._getTableItem(t,e);n&&(n.bgcolor=r)}cell_set_height({column:t=0,row:e=0,height:r}){const n=this._getTableItem(t,e);n&&(n.height=r)}cell_set_text({column:t=0,row:e=0,text:r}){const n=this._getTableItem(t,e);n&&(n.text=r)}cell_set_text_color({column:t=0,row:e=0,text_color:r}){const n=this._getTableItem(t,e);n&&(n.text_color=r,me(n,["text_color"]))}cell_set_text_font_family({column:t=0,row:e=0,text_font_family:r}){const n=this._getTableItem(t,e);n&&(n.text_font_family=r)}cell_set_text_halign({column:t=0,row:e=0,text_halign:r}){const n=this._getTableItem(t,e);n&&(n.text_halign=r)}cell_set_text_valign({column:t=0,row:e=0,text_valign:r}){const n=this._getTableItem(t,e);n&&(n.text_valign=r)}cell_set_text_size({column:t=0,row:e=0,text_size:r}){const n=this._getTableItem(t,e);n&&(n.text_size=r)}cell_set_tooltip({column:t=0,row:e=0,tooltip:r}){const n=this._getTableItem(t,e);n&&(n.tooltip=r)}cell_set_width({column:t=0,row:e=0,width:r}){const n=this._getTableItem(t,e);n&&(n.width=r)}clear({start_column:t=0,start_row:e=0,end_column:r=0,end_row:n=0}){const i=this._variables.table.get(this._id);if(i){const a=i.cell;if(a)for(let l=e;l<=n;l++)for(let c=t;c<=r;c++){const p=a[l];p&&(p[c]=void 0)}}}delete(){this._variables.table.delete(this._id)}merge_cells({start_column:t=0,start_row:e=0,end_column:r=0,end_row:n=0},i){if(t>r||e>n){this._errorListener.addError(le.mergeCellErr,i,zt.Error);return}const a=this._variables.table.get(this._id);if(!a)return;const l=a.merge_cells||[];l.push({start_column:t,start_row:e,end_column:r,end_row:n}),a.merge_cells=l}set_bgcolor({bgcolor:t}){const e=this._variables.table.get(this._id);e&&(e.bgcolor=t,me(e,["bgcolor"]))}set_border_color({border_color:t}){const e=this._variables.table.get(this._id);e&&(e.border_color=t,me(e,["border_color"]))}set_border_width({border_width:t}){const e=this._variables.table.get(this._id);e&&(e.border_width=t)}set_frame_color({frame_color:t}){const e=this._variables.table.get(this._id);e&&(e.frame_color=t)}set_frame_width({frame_width:t}){const e=this._variables.table.get(this._id);e&&(e.frame_width=t)}set_position({position:t},e){const r=this._variables.table.get(this._id);r&&(r.position=t,this._paramVerfiy(t,e,"table.set_position",Object.values(_r),"position"))}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getTableItem(t,e){const r=this._variables.table.get(this._id);if(r){const n=r.cell;return n?n[e][t]:void 0}}}class Jy{constructor(t){$(this,"_strategy");this._strategy=t}commission({trade_num:t}){return this._verifyTradeNum(t)&&this._strategy.historyOrders[t].commission||0}entry_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].in_index}entry_comment({trade_num:t}){if(!this._verifyTradeNum(t))return"";const{comment:e,id:r}=this._strategy.historyOrders[t];return e||r}entry_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].id:""}entry_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].in_price}entry_time({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].in_time}exit_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_index}exit_comment({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].out_comment:""}exit_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].out_id:""}exit_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_price}exit_time({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_time}max_drawdown({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].trading_loss:0}max_drawdown_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].trading_loss_percent:0}max_runup({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].max_profit:0}max_runup_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].max_profit_percent:0}profit({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].profit:0}profit_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].profit_percent:0}size({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{out_qty:e=0,direction:r}=this._strategy.historyOrders[t];return r===ue.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.historyOrders.length;return!(t>=e)}}class Xy{constructor(t){$(this,"_strategy");this._strategy=t}commission({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{qty:e=0,original_qty:r=0,commission:n=0}=this._strategy.orders[t];return n*e/r}entry_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.orders[t].in_index}entry_comment({trade_num:t}){if(!this._verifyTradeNum(t))return"";const{comment:e,id:r}=this._strategy.orders[t];return e||r}entry_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].id:""}entry_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.orders[t].in_price}entry_time({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.orders[t].in_time}max_drawdown({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].trading_loss:0}max_drawdown_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].trading_loss_percent:0}max_runup({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].max_profit:0}max_runup_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].max_profit_percent:0}profit({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].profit:0}profit_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].profit_percent:0}size({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{qty:e=0,direction:r}=this._strategy.orders[t];return r===ue.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.orders.length;return!(t>=e)}}class Qy{constructor(t,e){$(this,"_strategy");$(this,"_errorListener");this._strategy=t,this._errorListener=e}allow_entry_in({value:t},e){this._paramVerfiy(t,e,"strategy.risk.allow_entry_in",Object.values(ue),"value"),this._strategy.updateRisk({allow_entry_in:t})}max_cons_loss_days({count:t}){this._strategy.updateRisk({max_cons_loss_days:t})}max_drawdown({value:t,type:e},r){this._paramVerfiy(e,r,"strategy.risk.max_drawdown",[Ie.percentOfEquity,Ie.cash],"type"),e===Ie.percentOfEquity&&(t=t>100?100:t),this._strategy.updateRisk({max_drawdown:t,max_drawdown_type:e})}max_intraday_filled_orders({count:t}){this._strategy.updateRisk({max_intraday_filled_orders:t})}max_intraday_loss({value:t,type:e},r){this._paramVerfiy(e,r,"strategy.risk.max_intraday_loss",[Ie.percentOfEquity,Ie.cash],"type"),e===Ie.percentOfEquity&&(t=t>100?100:t),this._strategy.updateRisk({max_intraday_loss:t,max_intraday_loss_type:e})}max_position_size({contracts:t}){this._strategy.updateRisk({max_position_size:t})}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}}let tw=class{constructor(t,e,r,n,i){$(this,"_variables");$(this,"_options");$(this,"_totalChangeCapital");$(this,"_historyOrder");$(this,"_orders");$(this,"_pendingOrders");$(this,"_mintick");$(this,"_funcOptions");$(this,"_pendingCloseOrders");$(this,"_errorListener");$(this,"_risk");$(this,"_opentrades");$(this,"_closedtrades");$(this,"_riskNamespace");$(this,"_updateOptions",{});$(this,"_id");this._variables=t,this._errorListener=n,this._options={overlay:!1,format:Kt.inherit,pyramiding:0,calc_on_order_fills:!1,calc_on_every_tick:!1,max_bars_back:0,backtest_fill_limits_assumption:0,default_qty_type:Ie.fixed,default_qty_value:1,initial_capital:1e6,currency:Jf.NONE,slippage:0,commission_type:nr.percent,commission_value:0,process_orders_on_close:!1,close_entries_rule:"FIFO",margin_long:0,margin_short:0,explicit_plot_zorder:!1,max_lines_count:50,max_labels_count:50,max_boxes_count:50,calc_bars_count:0,risk_free_rate:2,use_bar_magnifier:!1,fill_orders_on_standard_ohlc:!1,max_polylines_count:50},this._funcOptions=e,this._totalChangeCapital=0,this._orders=[],this._pendingOrders=[],this._historyOrder=[],this._pendingCloseOrders=[],this._mintick=r,this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),this._variables.strategy.updateStrategyOptions(this._options),this._risk={intradayOrders:0},this._opentrades=new Xy(this),this._closedtrades=new Jy(this),this._riskNamespace=new Qy(this,n),this._id=`strategy_${i}`}get orders(){return[...this._orders]}get historyOrders(){return[...this._historyOrder]}get _freezeCapital(){const{close:t}=this._variables;return this._orders.reduce((e,r)=>e+t*(r.qty||0),0)}get opentrades(){return this._opentrades}get closedtrades(){return this._closedtrades}get risk(){return this._riskNamespace}updateOptions(t){this._updateOptions=t||{},Object.assign(this._options,this._updateOptions)}update(){this._maxConsLossDaysVerify(),this._pendingOrderHandle(),this._maxIntradayFilledOrdersVerify(),this._ordersHandle(),!this._options.process_orders_on_close&&this._calcLiquidate()}updateRisk(t){Object.assign(this._risk,t)}endExecution(){this._calcProfitAndLoss(),this._variables.strategy.update(),this._maxDrawdownVerify(),this._maxIntradayLoss(),this._pendingCloseOrderHandle(),this._options.process_orders_on_close&&this._calcLiquidate()}_maxIntradayLoss(){var g;const{max_intraday_loss:t,max_intraday_loss_type:e,isDisabledOpen:r}=this._risk;if(t===void 0||!e||r)return;const{high:n,low:i,time_tradingday:a,time:l,strategy:{netprofit:c,initial_capital:p}}=this._variables;let{preNetprofit:h=0}=this._risk;l===a&&(h=c,this._risk.preNetprofit=c,this._risk.isTemporaryBan=!1);let f=h-c;f+=this._orders.reduce((y,m)=>{const{in_price:w,direction:v,qty:x=0,commission:b=0,original_qty:N=0}=m,E=v===ue.long?1:-1,A=(n-w)*x,M=(i-w)*x,S=E===1?M:-A;return y+S+x/N*b},0);let d=!1;switch(e){case Ie.cash:d=t<f;break;case Ie.percentOfEquity:const y=f/(p+c)*100;d=t<y;break}if(d){this._risk.isTemporaryBan=!0;const y=(g=this._orders[0])==null?void 0:g.direction;this._closeOrders(this._orders,y===ue.long?i:n,"Close Position (Max intraday Loss)"),this._pendingOrders=[]}}_maxIntradayFilledOrdersVerify(){const{max_intraday_filled_orders:t,intradayOrders:e=0,isDisabledOpen:r}=this._risk;if(t===void 0||r)return;const{time:n,time_tradingday:i,open:a}=this._variables;n===i&&(this._risk.intradayOrders=0,this._risk.isTemporaryBan=!1),t<=e&&(this._risk.isTemporaryBan=!0,this._closeOrders(this._orders,a,"Close Position (Max number of filled orders in one day)"),this._pendingOrders=[])}_maxConsLossDaysVerify(){const{max_cons_loss_days:t,lossDays:e=0,isDisabledOpen:r,totalProfit:n=0}=this._risk;if(t===void 0||r)return;const{time:i,time_tradingday:a,strategy:l,open:c}=this._variables;let p=e;if(i===a){const h=l.netprofit+l.openprofit;h<n?p=0:p++,Object.assign(this._risk,{lossDays:p,totalProfit:h})}t<=p&&this._riskTouchOff(c,"Close Position (Max consecutive loss days)")}_maxDrawdownVerify(){var n;const{max_drawdown:t,max_drawdown_type:e,isDisabledOpen:r}=this._risk;if(!r&&t!==void 0&&e){const{max_drawdown:i,max_drawdown_percent:a}=this._variables.strategy;let l=!1;switch(e){case Ie.percentOfEquity:l=a<i;break;case Ie.cash:l=t<i;break}if(l){const{high:c,low:p}=this._variables,h=(n=this._orders[0])==null?void 0:n.direction;this._riskTouchOff(h===ue.long?c:p,"Close Position (Max Drawdown)")}}}_riskTouchOff(t,e){this._risk.isDisabledOpen=!0,this._closeOrders(this._orders,t,e),this._pendingOrders=[]}strategy(t,e){if(!this._variables.bar_index){this._paramVerfiy(t.format,e,"strategy",[Kt.inherit,Kt.price,Kt.percent,Kt.volume],"format"),this._paramVerfiy(t.default_qty_type,e,"strategy",Object.values(Ie),"default_qty_type"),this._paramVerfiy(t.commission_type,e,"strategy",Object.values(nr),"commission_type");const r=self==null?void 0:self.workerStorage.get(this._id),n={};if(r)for(const i of Object.keys(r)){const a=t[i];a!==r[i]&&(n[i]=a)}self==null||self.workerStorage.set(this._id,t),Object.assign(this._options,t,this._updateOptions,n),this._variables.updateMaxLength(t),Object.assign(this._funcOptions,{strategy:this._options,scriptType:"strategy"})}}order(t,e){this._risk.isDisabledOpen||(this._paramVerfiy(t.oca_type,e,"strategy.order",Object.values(un),"oca_type"),this._orderHandle(t))}entry(t,e){this._risk.isDisabledOpen||(this._paramVerfiy(t.oca_type,e,"strategy.entry",Object.values(un),"oca_type"),this._entryHandle(t))}close(t){if(!this._orders.length)return;const{immediately:e}=t;e||this._options.process_orders_on_close?this._pendingCloseOrders.push({...t,place_order_type:"close"}):this._pendingOrders.push({...t,place_order_type:"close"})}close_all(t){if(typeof t=="string"&&(t={}),!this._orders.length)return;const{immediately:e}=t;e||this._options.process_orders_on_close?this._pendingCloseOrders.push({...t,place_order_type:"close_all"}):this._pendingOrders.push({...t,place_order_type:"close_all"})}cancel({id:t}){this._pendingOrders=this._pendingOrders.filter(e=>!(e.id===t&&e.place_order_type!=="close"))}cancel_all(){this._pendingOrders=this._pendingOrders.filter(t=>t.place_order_type==="close_all")}exit(t,e){this._exit(t,e)}convert_to_account({value:t}){return t}convert_to_symbol({value:t}){return t}default_entry_qty({fill_price:t}){return t?this._calcDefaultQty(t):0}_calcDefaultQty(t){const{default_qty_type:e=Ie.fixed,default_qty_value:r=1,initial_capital:n}=this._options;switch(e){case Ie.fixed:return r;case Ie.cash:return r/t;case Ie.percentOfEquity:const i=this._getOrderProfit(t);return(n+i+this._totalChangeCapital)*r/100/t}}_getCapital(t,e){const{margin_long:r=0,margin_short:n=0}=this._options;return r<100&&r>0&&t===1?e=e*100/r:n<=100&&n>0&&t===-1&&(e=e*100/n),e}_calcProfitAndLoss(){const{close:t}=this._variables;for(const e of this._orders){const{in_price:r,qty:n=0,direction:i}=e,a=i===ue.long?1:-1,l=(t-r)*a*n,[c,p]=this._calcProfitAndLossHandle(r,n,a);this._calcOrderPercent(e,l,c,p)}}_calcProfitAndLossHandle(t,e,r){const{high:n,low:i}=this._variables,a=(n-t)*e,l=(i-t)*e;let c=r===1?a:-l,p=r===1?l:-a;return[c,p]}_calcOrderPercent(t,e,r,n){const{commission_value:i}=this._options,{close:a}=this._variables,{original_qty:l=0,qty:c=0,in_price:p,max_profit:h=0,trading_loss:f=0}=t;let{commission:d=0}=t,g=p*c;if(i){const y=this._getCommission(a,c);d=d*c/l,r-=d,n-=d,g+=d,e=e-y-d}r=Math.max(r,h,0),n=Math.min(n,f,0),Object.assign(t,{profit:e,total_profit:this._totalChangeCapital+e,total_profit_percent:e/(this._options.initial_capital+this._totalChangeCapital)*100,max_profit:r,trading_loss:n,profit_percent:e/g*100,max_profit_percent:r/g*100,trading_loss_percent:n/g*100})}_calcLiquidate(){if(!this._orders.length)return;const{high:t,low:e,time:r}=this._variables,{initial_capital:n,margin_long:i=0,margin_short:a=0}=this._options,l=this._orders[0].direction===ue.long?1:-1;let c=l===1?e:t;if(l===1&&i===100)return;const p=(l===1?i:a)/100;if(p<=0)return;let h=!1;const[f,d]=this._orders.reduce((w,v)=>{let[x,b]=w;const{in_price:N,qty:E=0,in_time:A}=v;A===r&&(h=!0);const M=N*E,S=c*E;return x+=M,b+=S,[x,b]},[0,0]);let g=0,y=0;const m=n+this._totalChangeCapital;if(h&&(g=m-f*p,g<0&&(c=this._orders[0].in_price,y=Math.abs(Math.trunc(g/p/c)*4),y=Math.max(y,1))),g>=0){const w=l*(d-f);if(g=m+w-d*p,g>=0)return;y=Math.abs(Math.trunc(g/p/c)*4)}y<=0||this._marginCallOrders(c,y,"Margin Call")}_marginCallOrders(t,e,r){const{close_entries_rule:n="FIFO"}=this._options;if(n==="FIFO"){this._processOrders(this._orders,t,e*this._orders.length,r,r,!0);return}for(const i of this.orders)this._processOrder(i,t,e,r,r,!0);this._orders=this._orders.filter(i=>!i.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_orderHandle(t){const{process_orders_on_close:e,slippage:r=0}=this._options,{orders:n,isMarketPrice:i,quantities:a,close:l,price:c,activePrice:p}=this._orderArgsParse(t),h=t.direction===ue.long?1:-1;if(a<=0)return;let f=a;if(i&&e){if(n.length){const m=this._processOrders(n,l,f,t.id,t.comment);if(m<=0)return;f=m}const g=l+h*r*this._mintick;if(!this._judgeCapitalEnough(f,g,h))return;this._ocaGroupVerify(f,t.oca_name,t.oca_type),this._calcCurrentOrder({...t,in_price:g,in_index:this._variables.bar_index,in_time:this._variables.time,qty:f,place_order_type:"order"});return}this._judgeCapitalEnough(a,c,h)&&this._addPendingOrders(t,c,f,i,p)}_judgeCapitalEnough(t,e,r){let n=this._freezeCapital;if(this._orders.some(h=>(h.direction===ue.long?1:-1)!==r)&&(n=0),t<=0)return!1;const{margin_long:i=0,margin_short:a=0}=this._options;if(i===0&&r===1||a===0&&r===-1)return!0;const l=this._getOrderProfit(e),p=this._getCapital(r,this._options.initial_capital+l+this._totalChangeCapital)-n;return t*e<=p}_getOrderProfit(t){return this._orders.reduce((e,r)=>{const{in_price:n,qty:i=0,direction:a}=r,l=a===ue.long?1:-1;return e+(t-n)*i*l},0)}_ocaGroupVerify(t,e,r){if(!e||!r||r===un.none)return!1;let n=!1;switch(r){case un.cancel:this._pendingOrders=this._pendingOrders.filter(i=>{if(i.oca_name===e)i.isCancel=!0,n=!0;else return!0});break;case un.reduce:this._pendingOrders=this._pendingOrders.filter(i=>{const{qty:a=0,oca_name:l}=i;if(e===l){const c=a-t;return n=!0,c<=0?(i.isCancel=!0,!1):(i.qty=c,!0)}else return!0});break}return n}_processOrders(t,e,r,n,i,a=!1){let l=r;for(const c of t)if(l=this._processOrder(c,e,l,n,i,a),l<=0)break;return this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),l}_addPendingOrders(t,e,r,n,i){const a=this._pendingOrders.find(l=>l.id===t.id&&!l.isMarketPrice);if(a)Object.assign(a,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:i});else{const l={...t,in_price:e,isMarketPrice:n,qty:r,active_price:i,place_order_type:"order"};this._pendingOrders.push(l)}}_orderArgsParse(t){const{direction:e,qty:r,stop:n}=t;let i=t.limit||0;const{close:a}=this._variables;let l=a,c=!1,p;const h=e===ue.long?1:-1,f=n&&(n-a)*h>0,{backtest_fill_limits_assumption:d=0}=this._options;d>0&&i&&(i-=d*this._mintick*h);const g=i&&(i-a)*h<0;f&&g?(p=n,l=i):f?l=n:g?l=i:c=!0;const y=r||this._calcDefaultQty(l)||1;return{orders:this._orders.filter(w=>w.direction!==e),isMarketPrice:c,activePrice:p,quantities:y,close:a,price:l}}_entryHandle(t){const{process_orders_on_close:e}=this._options,{orders:r,isMarketPrice:n,quantities:i,close:a,price:l,activePrice:c}=this._orderArgsParse(t);if(i<=0)return;if(r.length&&n&&e){this._entryOrder(r,a,i,t);return}this._judgeCapitalEnough(i,a,t.direction===ue.long?1:-1)&&this._addPendingEntry(t,l,i,n,c)}_entryOrder(t,e,r,n){const{time:i,bar_index:a}=this._variables,{slippage:l=0}=this._options,{oca_name:c,oca_type:p,direction:h,comment:f,isMarketPrice:d,id:g}=n,y=h===ue.long?1:-1;if(r=this._getAvailablePositionSize(r,h),r<=0||(e=e+l*this._mintick*y,!this._judgeCapitalEnough(r,e,y)))return;this._closeOrders(t,e,g,f);const w={...n,in_price:e,qty:r,in_index:a,in_time:i,place_order_type:"entry"};if(d){this._calcCurrentOrder(w);return}const{pendingOrders:v,orders:x}=this._getEntryOrders(h),b=v.length+x.length;b&&b>=(this._options.pyramiding||0)||(this._ocaGroupVerify(r,c,p),this._calcCurrentOrder(w))}_getAvailablePositionSize(t,e){const{max_position_size:r,allow_entry_in:n}=this._risk;if(n&&n!==ue.all&&n!==e)return 0;if(r===void 0)return t;const i=this._orders.reduce((a,l)=>a+(l.qty||0),0);return i?i+t>r?0:t:t>r?t-r:0}_getEntryOrders(t){const e=this._pendingOrders.filter(n=>["entry","order"].includes(n.place_order_type)&&n.direction===t),r=this._orders.filter(n=>n.direction===t);return{pendingOrders:e,orders:r}}_addPendingEntry(t,e,r,n,i){if(r=this._getAvailablePositionSize(r,t.direction),r<=0)return;const{pendingOrders:a,orders:l}=this._getEntryOrders(t.direction),c=a.length+l.length,p=a.find(h=>h.id===t.id&&h.place_order_type==="entry");if(p)Object.assign(p,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:i});else if(!c||c<(this._options.pyramiding||1)){const h={...t,in_price:e,isMarketPrice:n,qty:r,active_price:i,place_order_type:"entry"};this._pendingOrders.push(h)}}_closeAllOrders(t,e){const{comment:r}=t,{bar_index:n}=this._variables,i=this._orders.filter(a=>a.in_index!==n);i.length&&(this._closeOrders(i,e,"Close position order",r),this._orders=[],this._variables.strategy.updateOrders(this._orders))}_closeOrders(t,e,r,n){for(const i of t)this._closeOrder(i,e,r,n);this._orders=this._orders.filter(i=>!i.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_closeOrder(t,e,r,n){const{time:i,bar_index:a}=this._variables,{slippage:l=0}=this._options,{in_price:c,qty:p=0,direction:h}=t,f=h===ue.long?1:-1;e=e-f*l*this._mintick,t.isDeal=!0;const d=(e-c)*f*p,g={...t,out_price:e,out_id:r,out_index:a,out_time:i,out_comment:n,out_qty:p,profit:d};this._calcPercent(g)}_ordersHandle(){const t=this._orders.filter(a=>a.place_order_type==="exit"&&!a.hasExit);if(!t.length)return;const{open:e,low:r,high:n,close:i}=this._variables;for(const a of t){const{stop:l,limit:c,trail_stop_price:p,isMarketPriceLimit:h,isMarketPriceStop:f,direction:d,id:g,out_comment:y,active_price:m,trail_offset:w=0,out_qty:v,comment_loss:x,comment_profit:b,comment_trailing:N}=a;let E=p;const A=d===ue.long?1:-1;let M,S=y;if(h||f?M=e:(c&&r<=c&&n>=c&&(S=b||y,M=c),l&&r<=l&&n>=l&&(M=E?(l-E)*A>0?l:E:l,S=(E===M?N:x)||y)),M)this._processExitOnClose(a,M,{from_entry:g,comment:S,qty:v});else{let T=!1;if(m&&m<=n&&m>=r&&(E=m-w*A*this._mintick,(E-i)*A>=0&&(a.isMarketPriceStop=!0,this._options.process_orders_on_close&&(M=E)),T=!0,a.trail_stop_price=E),E)if((E-e)*A>=0&&!T)M=E;else{const F=(A===1?n:r)-w*A*this._mintick;A===1?E<e&&E>=r&&F>E&&F<i?M=E:F>E?(E=F,F>=i&&(M=F)):E<=n&&r<=E&&(M=E):E>e&&E<=n&&F<E&&F>i?M=E:F<E?(E=F,F<=i&&(M=F)):E<=n&&r<=E&&(M=E),a.trail_stop_price=E}M&&this._processExitOnClose(a,M,{from_entry:g,comment:N||y,qty:v})}}}_pendingOrderHandle(){if(!this._pendingOrders.length)return;const t=[],e=this._pendingOrders.filter(n=>n.place_order_type==="exit"),r=this._pendingOrders.filter(n=>["close","close_all"].includes(n.place_order_type||""));for(const n of r)switch(n.place_order_type){case"close":this._closeOrderHandle(n);break;case"close_all":this._closeAllOrders(n,this._variables.open);break}for(const n of this._pendingOrders){const{isCancel:i,place_order_type:a}=n;if(i)continue;let l;switch(a){case"entry":l=this._entryOrderHandle(n);break;case"order":l=this._orderOrderHandle(n);break}l&&t.push(l)}for(const n of e){const i=this._exitOrderHandle(n);i&&t.push(i)}this._pendingOrders=t}_pendingCloseOrderHandle(){if(!this._pendingCloseOrders.length)return;const t=this._pendingCloseOrders.filter(n=>n.place_order_type==="exit"),e=this._pendingCloseOrders.filter(n=>["close","close_all"].includes(n.place_order_type||"")),{close:r}=this._variables;for(const n of e)switch(n.place_order_type){case"close":this._closeOrderHandle(n,!0);break;case"close_all":this._closeAllOrders(n,r);break}for(const n of t){const{from_entry:i}=n,a=this._orders.filter(l=>!i||l.id===i&&(l.isMarketPriceLimit||l.isMarketPriceStop));for(const l of a)this._processExitOnClose(l,l.limit||l.stop||l.trail_stop_price||r,n)}this._pendingCloseOrders=[]}_entryOrderHandle(t){const{open:e,low:r,high:n}=this._variables,{isMarketPrice:i,qty:a=0,in_price:l,direction:c,active_price:p}=t;if(p&&n>=p&&r<=p)return delete t.active_price,t;let h=l;if(i&&(h=e),h<=n&&h>=r){const f=this._orders.filter(d=>d.direction!==c);this._entryOrder(f,h,a,t)}else return t}_orderOrderHandle(t){const{open:e,low:r,high:n,time:i,bar_index:a}=this._variables,{slippage:l=0}=this._options,{isMarketPrice:c,qty:p=0,in_price:h,direction:f,comment:d,oca_name:g,oca_type:y,active_price:m,id:w}=t;if(m&&n>=m&&r<=m)return delete t.active_price,t;let v=h,x=p;if(c&&(v=e),v<=n&&v>=r){const b=this._orders.filter(E=>E.direction!==f);if(b.length&&(x=this._processOrders(b,v,p,w,d),x<=0))return;const N=f===ue.long?1:-1;this._ocaGroupVerify(x,g,y),this._calcCurrentOrder({...t,in_price:v+N*l*this._mintick,in_index:a,in_time:i,qty:x});return}else return t}_closeOrderHandle(t,e){const{id:r,qty:n,qty_percent:i=100,comment:a}=t,{bar_index:l}=this._variables,c=this._orders.filter(g=>g.id===r&&g.in_index!==l&&(!g.close_qty||g.close_qty<(g.qty||0)));if(!c.length)return;let p=0;if(n?p=n:(p=c.reduce((g,y)=>g+(y.qty||0),p),p=i/100*p),p<=0)return;const{open:h,close:f}=this._variables;let d=p;for(const g of c){const{qty:y=0}=g;d<y?g.close_qty=d:(g.close_qty=y,d-=y)}this._processOrders(this._options.close_entries_rule==="ANY"?c:this._orders,e?f:h,p,`Close entry(s) order ${r}`,a)}_exitOrderHandle(t){const{from_entry:e}=t,r=this._orders.filter(n=>(!e||e===n.id)&&!n.hasExit);if(!(r.length&&!this._ordersToExit(r,t)))return t}_exit(t,e){const{profit:r,loss:n,stop:i,limit:a,trail_offset:l,trail_price:c,trail_points:p,from_entry:h="",id:f}=t;if(this._isNaN(r)&&this._isNaN(n)&&this._isNaN(i)&&this._isNaN(a)&&(this._isNaN(l)||this._isNaN(p)&&this._isNaN(c))){this._errorListener.addError(le.strategyExitErr,e,zt.Error);return}const d={...t,place_order_type:"exit"},g=this._orders.filter(w=>(!h||h===w.id)&&!w.hasExit),y=this._pendingOrders.filter(w=>!h||h===w.id);if(g.length){if(!this._ordersToExit(g,d))return}else if(!y.length)return;const m=this._pendingOrders.find(w=>w.id===f);m?Object.assign(m,{...t}):this._pendingOrders.push(d)}_ordersToExit(t,e){const{qty:r,qty_percent:n=100,id:i,comment:a,comment_loss:l,comment_profit:c,comment_trailing:p}=e;let h=r,f=!1;e.comment=a||i;for(const d of t){const{qty:g=0}=d,y=d.direction===ue.long?1:-1;h=r?r>=g?g:r:n/100*g,d.out_qty=h,h<g&&(f=!0),Object.assign(d,{out_comment:a||i,comment_loss:l,comment_profit:c,comment_trailing:p}),!(this._stopProfit(d,y,{...e,qty:h})||this._stopLoss(d,y,{...e,qty:h})||this._trailStopLoss(d,y,{...e,qty:h}))&&(d.place_order_type="exit")}return f}_addExitPendingCloseOrders(t){t.place_order_type="exit";const e=this._pendingCloseOrders.find(r=>r.id===t.id);e?Object.assign(e,{...t}):this._pendingCloseOrders.push(t)}_stopProfit(t,e,r){const{limit:n,profit:i,comment_profit:a,comment:l}=r;let c=n;const{close:p}=this._variables,{in_price:h}=t,{process_orders_on_close:f}=this._options;if(!this._isNaN(i)&&this._isNaN(n)&&(c=h+e*i*this._mintick),t.limit=c,c&&(c-p)*e<=0&&(t.isMarketPriceLimit=!0,r.comment=a||l,Object.assign(t,{out_comment:r.comment}),c=p,f))return this._addExitPendingCloseOrders(r),!0}_stopLoss(t,e,r){const{stop:n,loss:i,comment_loss:a,comment:l}=r;let c=n;const{close:p}=this._variables,{in_price:h}=t,{process_orders_on_close:f}=this._options;if(!this._isNaN(i)&&this._isNaN(n)&&(c=h-e*i*this._mintick),t.stop=c,c&&(c-p)*e>=0&&(t.isMarketPriceStop=!0,r.comment=a||l,Object.assign(t,{out_comment:r.comment}),c=p,f))return this._addExitPendingCloseOrders(r),!0}_trailStopLoss(t,e,r){const{trail_offset:n,trail_price:i,trail_points:a,comment_trailing:l,comment:c}=r;if(!this._isNaN(n)){const{close:p}=this._variables,{in_price:h}=t,{process_orders_on_close:f}=this._options;let d;if(this._isNaN(i)?this._isNaN(a)||(d=h+a*e*this._mintick):d=i,t.trail_offset=n,d&&(d-p)*e<=0){const g=p-n*e*this._mintick;if((g-p)*e>=0&&(t.trail_stop_price=p,t.isMarketPriceStop=!0,r.comment=l||c,Object.assign(t,{out_comment:r.comment}),f))return this._addExitPendingCloseOrders(r),!0;t.trail_stop_price=g}t.active_price=d}}_processExitOnClose(t,e,r){const{qty:n=0,comment:i,id:a}=r,{close_entries_rule:l="FIFO"}=this._options;if(l==="FIFO"){const c=this._processExitOrders(this._orders,e,n,a,i);c&&!c.hasExit?(c.hasExit=!0,Object.assign(t,{trail_stop_price:c.trail_stop_price,stop:c.stop,limit:c.limit,trail_offset:c.trail_offset,active_price:c.active_price})):c&&(t.hasExit=!0)}else t.hasExit=!0,this._processOrders([t],e,n,a,i)}_processExitOrders(t,e,r,n,i){let a=r,l;for(const c of t)if(l=c,a=this._processOrder(c,e,a,n,i),a<=0||!c.hasExit)break;return this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),l}_processOrder(t,e,r,n,i,a=!1){const{time:l,bar_index:c}=this._variables,{slippage:p=0}=this._options,{in_price:h,qty:f=0,max_profit:d,trading_loss:g,direction:y,commission:m=0,original_qty:w=0}=t,v=y===ue.long?1:-1;if(e=e-v*p*this._mintick,r<f){const x=f-r,b=(e-h)*v*r,N=d!==void 0?d/f*r:void 0,E=g!==void 0?g/f*r:void 0,A=m*x/w;this._calcPercent({...t,out_price:e,last_commission:A,out_id:n,out_index:c,out_time:l,out_comment:i,profit:b,out_qty:r,max_profit:N,trading_loss:E});const M=(e-h)*v*x-A;Object.assign(t,{qty:x,profit:M,max_profit:d!==void 0?d-(N||0):void 0,trading_loss:g!==void 0?g-(E||0):void 0,total_profit:this._totalChangeCapital+M}),r=0}else{t.isDeal=!0;const x=(e-h)*v*f;this._calcPercent({...t,out_price:e,out_id:n,out_index:c,out_time:l,out_comment:i,out_qty:f,profit:x}),r-=f}return a&&(v===1?this._variables.strategy.marginCallLong++:this._variables.strategy.marginCallShort++),r}_calcPercent(t){const{commission_value:e}=this._options,{in_price:r,out_qty:n=0,out_price:i=0,original_qty:a=0,direction:l,last_commission:c=0}=t;let{profit:p=0,max_profit:h,trading_loss:f,commission:d=0}=t,g=r*n,y=this._totalChangeCapital+this._options.initial_capital;if(this._totalChangeCapital+=p,e){const m=this._getCommission(i,n);this._totalChangeCapital-=m;let w=d*n/a;g+=w,w+=m,p=p-w,Object.assign(t,{commission:w,profit:p});const v=this._orders.reduce((x,b)=>{const{qty:N=0,original_qty:E=0,commission:A=0}=b;return x+A*N/E},0);y+=v-c}if(h===void 0||f===void 0){const m=l===ue.long?1:-1,w=this._calcProfitAndLossHandle(r,n,m);if(h=w[0],f=w[1],e){const v=d*n/a;h-=v,f-=v}h=Math.max(0,h),f=Math.min(0,f)}Object.assign(t,{max_profit:h,trading_loss:f,total_profit:this._totalChangeCapital,total_profit_percent:p/y*100,profit_percent:p/g*100,max_profit_percent:h/g*100,trading_loss_percent:f/g*100}),this._risk.intradayOrders+=1,this._historyOrder.push(t)}_getCommission(t,e){const{commission_value:r=0,commission_type:n}=this._options,i=t*e;let a=0;switch(n){case nr.percent:a=i*r/100;break;case nr.cashPerContract:a=e*r;break;case nr.cashPerOrder:a=r;break}return a}_calcCurrentOrder(t){const{commission_value:e}=this._options,{in_price:r,qty:n=0,max_profit:i=0,trading_loss:a=0}=t;let{profit:l=0}=t,c=r*n;const p=this._totalChangeCapital+this._options.initial_capital;if(e){const h=this._getCommission(r,n);this._totalChangeCapital-=h,l=l-h,c+=h,Object.assign(t,{commission:h,profit:l,total_profit:this._totalChangeCapital})}Object.assign(t,{original_qty:n,total_profit_percent:l/p*100,profit_percent:l/c*100,max_profit_percent:i/c*100,trading_loss_percent:a/c*100}),this._risk.intradayOrders+=1,this._orders.push(t),this._variables.strategy.updateOrders(this._orders),e&&this._variables.strategy.updateHistoryOrders(this._historyOrder)}_isNaN(t){return t===void 0||isNaN(t)}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}};var rh={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,function(){return function(e,r,n){r.prototype.isBetween=function(i,a,l,c){var p=n(i),h=n(a),f=(c=c||"()")[0]==="(",d=c[1]===")";return(f?this.isAfter(p,l):!this.isBefore(p,l))&&(d?this.isBefore(h,l):!this.isAfter(h,l))||(f?this.isBefore(p,l):!this.isAfter(p,l))&&(d?this.isAfter(h,l):!this.isBefore(h,l))}}})})(rh);var ew=rh.exports,rw=Gt(ew),nh={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,function(){return function(e,r,n){var i=r.prototype,a=function(d){var g,y=d.date,m=d.utc,w={};if(!((g=y)===null||g instanceof Date||g instanceof Array||i.$utils().u(g)||g.constructor.name!=="Object")){if(!Object.keys(y).length)return new Date;var v=m?n.utc():n();Object.keys(y).forEach(function(T){var F,O;w[F=T,O=i.$utils().p(F),O==="date"?"day":O]=y[T]});var x=w.day||(w.year||w.month>=0?1:v.date()),b=w.year||v.year(),N=w.month>=0?w.month:w.year||w.day?0:v.month(),E=w.hour||0,A=w.minute||0,M=w.second||0,S=w.millisecond||0;return m?new Date(Date.UTC(b,N,x,E,A,M,S)):new Date(b,N,x,E,A,M,S)}return y},l=i.parse;i.parse=function(d){d.date=a.bind(this)(d),l.bind(this)(d)};var c=i.set,p=i.add,h=i.subtract,f=function(d,g,y,m){m===void 0&&(m=1);var w=Object.keys(g),v=this;return w.forEach(function(x){v=d.bind(v)(g[x]*m,x)}),v};i.set=function(d,g){return g=g===void 0?d:g,d.constructor.name==="Object"?f.bind(this)(function(y,m){return c.bind(this)(m,y)},g,d):c.bind(this)(d,g)},i.add=function(d,g){return d.constructor.name==="Object"?f.bind(this)(p,d,g):p.bind(this)(d,g)},i.subtract=function(d,g){return d.constructor.name==="Object"?f.bind(this)(p,d,g,-1):h.bind(this)(d,g)}}})})(nh);var nw=nh.exports,iw=Gt(nw),ih={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,function(){var e,r,n=1e3,i=6e4,a=36e5,l=864e5,c=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,p=31536e6,h=2628e6,f=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,d={years:p,months:h,days:l,hours:a,minutes:i,seconds:n,milliseconds:1,weeks:6048e5},g=function(A){return A instanceof N},y=function(A,M,S){return new N(A,S,M.$l)},m=function(A){return r.p(A)+"s"},w=function(A){return A<0},v=function(A){return w(A)?Math.ceil(A):Math.floor(A)},x=function(A){return Math.abs(A)},b=function(A,M){return A?w(A)?{negative:!0,format:""+x(A)+M}:{negative:!1,format:""+A+M}:{negative:!1,format:""}},N=function(){function A(S,T,F){var O=this;if(this.$d={},this.$l=F,S===void 0&&(this.$ms=0,this.parseFromMilliseconds()),T)return y(S*d[m(T)],this);if(typeof S=="number")return this.$ms=S,this.parseFromMilliseconds(),this;if(typeof S=="object")return Object.keys(S).forEach(function(k){O.$d[m(k)]=S[k]}),this.calMilliseconds(),this;if(typeof S=="string"){var R=S.match(f);if(R){var U=R.slice(2).map(function(k){return k!=null?Number(k):0});return this.$d.years=U[0],this.$d.months=U[1],this.$d.weeks=U[2],this.$d.days=U[3],this.$d.hours=U[4],this.$d.minutes=U[5],this.$d.seconds=U[6],this.calMilliseconds(),this}}return this}var M=A.prototype;return M.calMilliseconds=function(){var S=this;this.$ms=Object.keys(this.$d).reduce(function(T,F){return T+(S.$d[F]||0)*d[F]},0)},M.parseFromMilliseconds=function(){var S=this.$ms;this.$d.years=v(S/p),S%=p,this.$d.months=v(S/h),S%=h,this.$d.days=v(S/l),S%=l,this.$d.hours=v(S/a),S%=a,this.$d.minutes=v(S/i),S%=i,this.$d.seconds=v(S/n),S%=n,this.$d.milliseconds=S},M.toISOString=function(){var S=b(this.$d.years,"Y"),T=b(this.$d.months,"M"),F=+this.$d.days||0;this.$d.weeks&&(F+=7*this.$d.weeks);var O=b(F,"D"),R=b(this.$d.hours,"H"),U=b(this.$d.minutes,"M"),k=this.$d.seconds||0;this.$d.milliseconds&&(k+=this.$d.milliseconds/1e3,k=Math.round(1e3*k)/1e3);var W=b(k,"S"),z=S.negative||T.negative||O.negative||R.negative||U.negative||W.negative,K=R.format||U.format||W.format?"T":"",Z=(z?"-":"")+"P"+S.format+T.format+O.format+K+R.format+U.format+W.format;return Z==="P"||Z==="-P"?"P0D":Z},M.toJSON=function(){return this.toISOString()},M.format=function(S){var T=S||"YYYY-MM-DDTHH:mm:ss",F={Y:this.$d.years,YY:r.s(this.$d.years,2,"0"),YYYY:r.s(this.$d.years,4,"0"),M:this.$d.months,MM:r.s(this.$d.months,2,"0"),D:this.$d.days,DD:r.s(this.$d.days,2,"0"),H:this.$d.hours,HH:r.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:r.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:r.s(this.$d.seconds,2,"0"),SSS:r.s(this.$d.milliseconds,3,"0")};return T.replace(c,function(O,R){return R||String(F[O])})},M.as=function(S){return this.$ms/d[m(S)]},M.get=function(S){var T=this.$ms,F=m(S);return F==="milliseconds"?T%=1e3:T=F==="weeks"?v(T/d[F]):this.$d[F],T||0},M.add=function(S,T,F){var O;return O=T?S*d[m(T)]:g(S)?S.$ms:y(S,this).$ms,y(this.$ms+O*(F?-1:1),this)},M.subtract=function(S,T){return this.add(S,T,!0)},M.locale=function(S){var T=this.clone();return T.$l=S,T},M.clone=function(){return y(this.$ms,this)},M.humanize=function(S){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!S)},M.valueOf=function(){return this.asMilliseconds()},M.milliseconds=function(){return this.get("milliseconds")},M.asMilliseconds=function(){return this.as("milliseconds")},M.seconds=function(){return this.get("seconds")},M.asSeconds=function(){return this.as("seconds")},M.minutes=function(){return this.get("minutes")},M.asMinutes=function(){return this.as("minutes")},M.hours=function(){return this.get("hours")},M.asHours=function(){return this.as("hours")},M.days=function(){return this.get("days")},M.asDays=function(){return this.as("days")},M.weeks=function(){return this.get("weeks")},M.asWeeks=function(){return this.as("weeks")},M.months=function(){return this.get("months")},M.asMonths=function(){return this.as("months")},M.years=function(){return this.get("years")},M.asYears=function(){return this.as("years")},A}(),E=function(A,M,S){return A.add(M.years()*S,"y").add(M.months()*S,"M").add(M.days()*S,"d").add(M.hours()*S,"h").add(M.minutes()*S,"m").add(M.seconds()*S,"s").add(M.milliseconds()*S,"ms")};return function(A,M,S){e=S,r=S().$utils(),S.duration=function(O,R){var U=S.locale();return y(O,{$l:U},R)},S.isDuration=g;var T=M.prototype.add,F=M.prototype.subtract;M.prototype.add=function(O,R){return g(O)?E(this,O,1):T.bind(this)(O,R)},M.prototype.subtract=function(O,R){return g(O)?E(this,O,-1):F.bind(this)(O,R)}}})})(ih);var sw=ih.exports,ow=Gt(sw);ee.extend(Sl),ee.extend(rw),ee.extend(iw),ee.extend(ow);class sh{constructor(t,e,r){$(this,"array");$(this,"color");$(this,"math");$(this,"str");$(this,"map");$(this,"matrix");$(this,"timeframe");$(this,"ta");$(this,"input");$(this,"_variables");$(this,"_cacheData");$(this,"_options");$(this,"_errorListener");$(this,"_plots");$(this,"_plotshapes");$(this,"_plotbars");$(this,"_plotchars");$(this,"_plotarrows");$(this,"_plotcandles");$(this,"_alerts");$(this,"_bgColors");$(this,"_hlines");$(this,"_fills");$(this,"chart");$(this,"line");$(this,"label");$(this,"polyline");$(this,"box");$(this,"table");$(this,"linefill");$(this,"log");$(this,"runtime");$(this,"strategy");$(this,"request");$(this,"syminfo");$(this,"_count",0);var i;const n=((i=t.toString().split(".")[1])==null?void 0:i.length)||5;this._variables=e,this._errorListener=new fw,this.array=new Gp(this._errorListener),this.math=new Hp(n,this._errorListener),this.color=new D1,this.str=new by(this._errorListener,n),this.map=new xy(this._errorListener),this.timeframe=new Dy(e),this.matrix=new wy(this._errorListener),this.ta=new y1(e,this.math,this.timeframe),this._cacheData={},this._options={},this._bgColors={},this._alerts=new Map,this._hlines=new Map,this._fills=new Map,this.input=new w1(e,this._errorListener,r),this._plots=new Map,this._plotshapes=new Map,this._plotbars=new Map,this._plotcandles=new Map,this._plotchars=new Map,this._plotarrows=new Map,this.chart={point:new Ey(e)},this.line=new Zy(e,this._errorListener),this.label=new Ay(e,this._errorListener),this.polyline=new Vy(e,this._errorListener),this.box=new Gy(e,this._errorListener),this.table=new Hy(e,this._errorListener),this.linefill=new Ky(e),this.log=new lw(e),this.runtime=new cw(this._errorListener),this.strategy=new tw(this._variables,this._options,t,this._errorListener,r),this.request=new aw(this._variables,r),this.syminfo=new uw}get errors(){return this._errorListener.errors}options(t){if(t.length)return this._getDataOfBarindex(t);const e=this.input.getInputs(),r=this._alerts.size?[...this._alerts.values()]:void 0;this._alerts.clear();const n=Object.keys(this._bgColors);let i;if(n.length){i={};for(const v of n)i[v]=[...this._bgColors[v].values()]}const a=this._hlines.size?[...this._hlines.values()]:void 0,l=this._fills.size?[...this._fills.values()]:void 0,c=this.log.logs.length?this.log.logs:void 0;this.log.clearLogs(),this._options.scriptType==="strategy"&&Object.assign(this._options,{orders:this.strategy.orders,historyOrders:this.strategy.historyOrders,strategySummary:this._variables.strategy.summaryData});const p=this._plots.size>0?[...this._plots.values()]:void 0,h=this._plotbars.size>0?[...this._plotbars.values()]:void 0,f=this._plotshapes.size>0?[...this._plotshapes.values()]:void 0,d=this._plotarrows.size>0?[...this._plotarrows.values()]:void 0,g=this._plotcandles.size>0?[...this._plotcandles.values()]:void 0,y=this._plotchars.size>0?[...this._plotchars.values()]:void 0,m=this._getDraws(),w=this._variables.chart.isUseBgColor;return Object.assign(this._options,{inputs:e,plots:p,draws:m,alerts:r,colors:i,hlines:a,fills:l,logs:c,plotshapes:f,plotarrows:d,plotcandles:g,plotchars:y,plotbars:h,isUseBgColor:w})}_getDataOfBarindex(t){const e=this._alerts.size?[...this._alerts.values()]:void 0;this._alerts.clear();const r=Object.keys(this._bgColors);let n;if(r.length){n={};for(const d of r)n[d]=[...this._bgColors[d].values()].map(g=>{const y=[];for(const m of t){const w=g.colors[m];w&&y.push(w)}return g.colors=y,g})}const i=this._hlines.size?[...this._hlines.values()]:void 0,a=this._fills.size?this._getDataFromBarindex(t,[...this._fills.values()]):void 0,l=this.log.logs.length?this.log.logs:void 0;this.log.clearLogs(),this._options.scriptType==="strategy"&&Object.assign(this._options,{orders:this.strategy.orders,historyOrders:this.strategy.historyOrders});const c=this._getDataFromBarindex(t,[...this._plots.values()]),p=this._plotshapes.size>0?this._getDataFromBarindex(t,[...this._plotshapes.values()]):void 0,h=this._getDrawsFromBarindex(t),f=this._variables.chart.isUseBgColor;return Object.assign(this._options,{plots:c,draws:h,alerts:e,colors:n,hlines:i,fills:a,logs:l,plotshapes:p,isUseBgColor:f})}_getDataFromBarindex(t,e){return e.map(r=>{const n=[];for(const i of t){const a=r.data[i];a&&n.push(a)}return r.data=n,{...r}})}_getDraws(){const{line:t,linefill:e,table:r,box:n,polyline:i,label:a}=this._variables,l={};return t.data.length&&(l.lines=t.data),e.data.length&&(l.linefills=e.data),r.data.length&&(l.tables=r.data),n.data.length&&(l.boxes=n.data),i.data.length&&(l.polylines=i.data),a.data.length&&(l.labels=a.data),Object.keys(l).length?l:void 0}_getDrawsFromBarindex(t){const{line:e,linefill:r,table:n,box:i,polyline:a,label:l}=this._variables,c={};return e.data.length&&(c.lines=e.getValOfBarIndex(t)),r.data.length&&(c.linefills=r.getValOfBarIndex(t)),n.data.length&&(c.tables=n.getValOfBarIndex(t)),i.data.length&&(c.boxes=i.getValOfBarIndex(t)),a.data.length&&(c.polylines=a.getValOfBarIndex(t)),l.data.length&&(c.labels=l.getValOfBarIndex(t)),Object.keys(c).length?c:void 0}updateOptions(t){const{inputs:e,strategy:r}=t;this.input.update(e),this.strategy.updateOptions(r)}update(t){const{barIndex:e}=t;this.strategy.update(),this.math.update(e)}endExecution(){this.strategy.endExecution()}library(t,e){if(!this._variables.bar_index){const r=/^[^\W\d\s][^\W\s]*$/,{title:n}=t;r.test(n)?(Kp.includes(n)||Zp.includes(n))&&this._errorListener.addError(Ye(le.libraryTitleIsKeywordErr,{name:n}),e,zt.Error):this._errorListener.addError(le.libraryTitleErr,e,zt.Error),this._options.scriptType="library",this._options.library=t}}indicator(t,e){if(!this._variables.bar_index){const{format:r}=t;this._paramVerfiy(r,e,"indicator",[Kt.inherit,Kt.percent,Kt.price,Kt.volume]),this._variables.updateMaxLength(t),this._options.scriptType="indicator",this._options.indicator=t}}_paramVerfiy(t="",e,r,n,i="format"){t&&!n.includes(t)&&this._errorListener.addError(Ye(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_lineWidthVerify(t,e){const{linewidth:r=1}=t;r<1&&(this._errorListener.addError(Yp.lineWidthWarning,e,zt.Warning),t.linewidth=1)}plot(t,e){const r=["color"];me(t,r);const{series:n,color:i,...a}=t,{bar_index:l,time:c}=this._variables,p=`plot_${e}`,h=this._plots.get(p),f=(h==null?void 0:h.data)||[],d=n!==void 0&&isNaN(n)?void 0:n;if(f[l]={value:[c,d],itemStyle:{color:i}},this._seriesColorHandle(t,r,h),!h){this._count++,this._lineWidthVerify(a,e),this._paramVerfiy(t.format,e,"plot",[Kt.percent,Kt.price,Kt.volume]);const g=i?[i]:void 0;this._plots.set(p,{editable:!0,...a,colors:g,data:f,id:p,zIndex:this._count})}return{type:"plot",key:p}}plotbar(t,e){const r=["color"];me(t,r);const{open:n,close:i,low:a,high:l,color:c,...p}=t,{bar_index:h,time:f}=this._variables,d=`plotbar_${e}`,g=this._plotbars.get(d),y=(g==null?void 0:g.data)||[],m=i!==void 0&&isNaN(i)?void 0:i,w=n!==void 0&&isNaN(n)?void 0:n,v=a!==void 0&&isNaN(a)?void 0:a,x=l!==void 0&&isNaN(l)?void 0:l,b=[f,w,m,v,x];if(y[h]={value:b,itemStyle:{color:c}},this._seriesColorHandle(t,r,g),!g){this._count++,this._paramVerfiy(t.format,e,"plotbar",[Kt.percent,Kt.price,Kt.volume]);const N=c?[c]:void 0;this._plotbars.set(d,{editable:!0,...p,colors:N,data:y,id:d,zIndex:this._count})}}_verfiyArgs(t,e,r){const{size:n,format:i,location:a,style:l}=t;this._paramVerfiy(l,r,e,Object.values(ur),"style"),this._paramVerfiy(a,r,e,Object.values(an),"location"),this._paramVerfiy(n,r,e,Object.values(rr),"size"),this._paramVerfiy(i,r,e,[Kt.percent,Kt.price,Kt.volume],"format")}plotchar(t,e){const r=["color","textcolor"];me(t,r);const{series:n,color:i,textcolor:a,location:l=an.abovebar,...c}=t,{bar_index:p,time:h,high:f,low:d}=this._variables,g=`plotchar_${e}`,y=this._plotchars.get(g),m=(y==null?void 0:y.data)||[],w={value:[h,n],itemStyle:{color:i,textcolor:a},low:d,high:f};m[p]=w,this._seriesColorHandle(t,r,y),y||(this._count++,this._verfiyArgs(t,"plotchar",e),this._plotchars.set(g,{editable:!0,...c,location:l,data:m,id:g,zIndex:this._count}))}plotarrow(t,e){const r=["colorup","colordown"];me(t,r);const{series:n,colorup:i,colordown:a,...l}=t,{bar_index:c,time:p}=this._variables,h=`plotarrow_${e}`,f=this._plotarrows.get(h),d=(f==null?void 0:f.data)||[];d[c]={value:[p,n!==void 0&&isNaN(n)?void 0:n],itemStyle:{colorup:i,colordown:a}},this._seriesColorHandle(t,r,f),f||(this._count++,this._paramVerfiy(t.format,e,"plotarrow",[Kt.percent,Kt.price,Kt.volume]),this._plotarrows.set(h,{editable:!0,...l,data:d,id:h,zIndex:this._count}))}plotshape(t,e){const r=["color","textcolor"];me(t,r);const{series:n,color:i,textcolor:a,location:l=an.abovebar,...c}=t,{bar_index:p,time:h,low:f,high:d}=this._variables,g=`plotshape_${e}`,y=this._plotshapes.get(g),m=(y==null?void 0:y.data)||[],w={value:n,color:i,textcolor:a,time:h,low:f,high:d};if(m[p]=w,this._seriesColorHandle(t,r,y),!y){this._count++;const v=i?[i]:void 0;this._verfiyArgs(t,"plotshape",e),this._plotshapes.set(g,{editable:!0,...c,data:m,location:l,id:g,colors:v,zIndex:this._count})}}plotcandle(t,e){const r=["wickcolor","bordercolor","color"];me(t,r);const{wickcolor:n,bordercolor:i,color:a,close:l,open:c,low:p,high:h,...f}=t,{bar_index:d,time:g}=this._variables,y=`plotcandle_${e}`,m=this._plotcandles.get(y),w=(m==null?void 0:m.data)||[],v=l!==void 0&&isNaN(l)?void 0:l,x=c!==void 0&&isNaN(c)?void 0:c,b=p!==void 0&&isNaN(p)?void 0:p,N=h!==void 0&&isNaN(h)?void 0:h,E=[g,x,v,b,N];w[d]={value:E,wickcolor:n,bordercolor:i,color:a},this._seriesColorHandle(t,r,m),m||(this._count++,this._paramVerfiy(t.format,e,"plotcandle",[Kt.percent,Kt.price,Kt.volume]),this._plotcandles.set(y,{editable:!0,...f,data:w,id:y,zIndex:this._count}))}hline(t,e){const r=`hline_${e}`;me(t,["color"]),this._verifyDisplay(t.display,"hline",e);const i=t.display&&!t.display.length?Ve.none:Ve.all;return this._hlines.has(r)||(this._count++,this._lineWidthVerify(t,e),this._hlines.set(r,{id:r,linewidth:1,editable:!0,display:i,...t,zIndex:this._count})),{type:"hline",key:r}}fill(t,e){var S,T,F,O,R,U,k,W,z,K;const r=["color","top_color","bottom_color"];me(t,r);const{color:n,top_color:i,bottom_color:a,seriesColors:l,hline1:c,hline2:p,plot1:h,plot2:f,top_value:d,bottom_value:g,...y}=t,{bar_index:m,time:w}=this._variables,v=`fill_${e}`,x=this._fills.get(v),b=(x==null?void 0:x.data)||[];this._verifyDisplay(t.display,"fill",e);const N=t.display&&!t.display.length?Ve.none:Ve.all;let E,A,M="plot";if(c&&p)E=(S=this._hlines.get(c==null?void 0:c.key))==null?void 0:S.price,A=(T=this._hlines.get(p==null?void 0:p.key))==null?void 0:T.price,M="hline";else{const Z=((F=this._plots.get(h==null?void 0:h.key))==null?void 0:F.data)||[],X=((O=this._plots.get(f==null?void 0:f.key))==null?void 0:O.data)||[];E=(U=(R=Z[m])==null?void 0:R.value)==null?void 0:U[1],A=(W=(k=X[m])==null?void 0:k.value)==null?void 0:W[1]}if(b[m]={time:w,color:n,top_color:i,bottom_color:a,plot1:E,plot2:A,top_value:d,bottom_value:g},this._seriesColorHandle(t,r,x),!x){this._count++;const Z=((z=this._options.indicator)==null?void 0:z.explicit_plot_zorder)||((K=this._options.strategy)==null?void 0:K.explicit_plot_zorder),X=n?[n]:void 0,Q=i?[i]:void 0,ct=a?[a]:void 0;this._fills.set(v,{id:v,colors:X,top_colors:Q,bottom_colors:ct,display:N,data:b,type:M,editable:!0,fillgaps:!1,hline1:c,hline2:p,plot1:h,plot2:f,...y,zIndex:Z?this._count:void 0})}}alert({message:t,freq:e=kr.freqOncePerBar},r){const{bar_index:n,_isRealTimeBar:i,last_bar_index:a}=this._variables,l=`alert_${r}`,c=this._cacheData[l]||{},p=c.barIndex;if(this._paramVerfiy(e,r,"alert",[kr.freqAll,kr.freqOncePerBar,kr.freqOncePerBarClose]),e===kr.freqOncePerBar&&n===p){this._alerts.delete(l);return}this._cacheData[l]=c;const h={message:t,freq:e,id:l,type:"alert"};if(i){e!==kr.freqOncePerBarClose&&this._alerts.set(l,h),c.barIndex=n;return}if(!i&&e===kr.freqOncePerBarClose&&n===p&&a===n-1){this._alerts.set(l,h),c.barIndex=n;return}this._alerts.delete(l)}alertcondition({condition:t,message:e,title:r},n){const{_isRealTimeBar:i}=this._variables,a=`alertcondition_${n}`;i&&t?this._alerts.set(a,{message:e,title:r,id:a,type:"alertcondition"}):this._alerts.delete(a)}barcolor(t,e){this._setColors(t,"barcolor",e)}bgcolor(t,e){this._setColors(t,"bgcolor",e)}_verifyDisplay(t=Xf.all,e,r){t.length&&t.length<4&&this._errorListener.addError(Ye(le.displayErr,{func:e,values:"[display.none, display.all]"}),r,zt.Error)}_setColors(t,e,r){me(t,["color"]);const{color:i,...a}=t;this._verifyDisplay(a.display,e,r);const l=t.display&&!t.display.length?Ve.none:Ve.all,{bar_index:c,time:p}=this._variables,h=`${e}_${r}`;this._bgColors[e]||(this._bgColors[e]=new Map);const f=this._bgColors[e].get(h),d=(f==null?void 0:f.colors)||[],g=(f==null?void 0:f.setColors)||[];i&&!g.includes(i)&&g.push(i),d[c]={color:i,time:p},f||this._bgColors[e].set(h,{...a,display:l,colors:d,setColors:g,id:h})}max_bars_back({var:t,num:e,var_name:r}){console.log(t,e,r)}float({x:t}){return t}bool({x:t}){return t||!1}string({x:t}){return t}int({x:t}){return t&&Math.trunc(t)}na({x:t}){return!!(t===void 0||typeof t=="number"&&isNaN(t))}fixnan({source:t},e){return t===void 0||typeof t=="number"&&isNaN(t)?this._cacheData[`fixnan_${e}`]:(this._cacheData[`fixnan_${e}`]=t,t)}nz({source:t,replacement:e}){return t!==void 0&&!(typeof t=="number"&&isNaN(t))?t:e||0}time({timeframe:t="",session:e,timezone:r,bars_back:n=0},i){return this._timeHandle(this._variables.time,i,t,e,r,n)}time_close({timeframe:t="",session:e,timezone:r,bars_back:n=0},i){return this._variables.time_close&&this._timeHandle(this._variables.time_close,i,t,e,r,n)}timestamp(t){const{dateString:e,timezone:r,year:n,month:i,day:a,hour:l=0,minute:c=0,second:p=0}=t;if(e)return ee(e).utc(!/GMT|UTC/.test(e)).valueOf();let h=i-1,f=n;if(h<0){const g=Math.ceil(Math.abs(h/12));h=12*g+h,f=n-g}let d=ee({year:f,month:h,day:a,hour:l,minute:c,second:p});return r&&(d=qr(d.utc(!0).valueOf(),r)),d.utc(!0).valueOf()}weekofyear({time:t,timezone:e}){return qr(t,e).week()}year({time:t,timezone:e}){return qr(t,e).year()}second({time:t,timezone:e}){return qr(t,e).second()}month({time:t,timezone:e}){return qr(t,e).month()+1}minute({time:t,timezone:e}){return qr(t,e).minute()}hour({time:t,timezone:e}){return qr(t,e).hour()}dayofweek({time:t,timezone:e}){return qr(t,e).day()+1}dayofmonth({time:t,timezone:e}){return qr(t,e).date()}_calcTimeOffset(t,e){const r=this._variables.getTimeTradingday(t,e),n=Qr(e)*1e3;return t-r-Math.floor((t-r)/n)*n}_timeHandle(t,e,r="",n,i,a=0){const l=r||this._variables.timeframe.period,c=Qr(l),p=Qr(this._variables.timeframe.period);let h;if(c<=p)h=t;else{const f=`time_${e}`,d=this._cacheData[f];if(d)d.currentTime+c*1e3-d.offset<=t?(h=t,this._cacheData[f]={currentTime:t,offset:0}):h=d;else{const g=this._calcTimeOffset(t,l);this._cacheData[f]={currentTime:t,offset:g},h=t}}if(n){const{timePeriods:f,weeks:d}=this._parserSession(n,e),g=ee(t).format("YYYY-MM-DD"),y=h;h=void 0;for(const w of f){const[v,x]=w;if(ee(t).isBetween(`${g} ${v}`,`${g} ${x}`,"hour")){ee(y).isBetween(`${g} ${v}`,`${g} ${x}`,"hour")?h=y:h=ee(`${g} ${v}`).valueOf();break}}const m=this._variables.dayofweek;h&&!d.includes(m)&&(h=void 0)}return i&&(h=h&&qr(h,i).valueOf()),h&&h-a*p*1e3}_seriesColorHandle(t,e,r){var n;if(r&&e!=null&&e.length)for(const i of e){if((n=r.gradientColorKeys)!=null&&n.includes(i))continue;const a=t[i];if(!a)continue;const l=r[`${i}s`]||[];l.includes(a)||(l.push(a),r[`${i}s`]=l,l.length>5&&(r[`${i}s`]=[],r.gradientColorKeys=r.gradientColorKeys||[],r.gradientColorKeys.push(i)))}}_parserSession(t,e){const r=t.split(":"),n=r[0],a=(r[1]||"1234567").split("").map(c=>{const p=parseInt(c,10);if(p<1||p>7){this._errorListener.addError(`Invalid day of week: ${c}`,e,zt.Error);return}return p});return{timePeriods:n.split(",").map(c=>{c===""||c===fi.regular?c="0930-1500":c===fi.extended&&(c="1500-1830");const p=c.split("-");return p.length!==2?(this._errorListener.addError(`Invalid time period: ${c}`,e,zt.Error),[]):[this._processTime(p[0],e),this._processTime(p[1],e)]}),weeks:a}}_processTime(t,e){const r=parseInt(t.slice(0,2),10),n=parseInt(t.slice(2),10);if(!(r>=0&&r<=23)&&n>=0&&n<=59){this._errorListener.addError("Invalid time: Time must be within 00:00 to 23:59",e,zt.Error);return}return`${r}:${n}`}}class aw{constructor(t,e){$(this,"_variables");$(this,"_scriptId");$(this,"_cacheData");this._variables=t,this._scriptId=e,this._cacheData=new Map}security(t,e){const r=self.workerStorage.get(`request_${this._scriptId}`),{paramsExpr:n=[]}=t,i=this._getRequestData(t,e);if(r!=null&&r.has(e)){const c=r.get(e);return this._runScripts(c,e,!1,n,i)}const a=this._parseExprCode(t),l=this._runScripts(a,e,!0,n,i);return r==null||r.set(e,a),l}_parseExprCode(t){let{expression:e,paramsExpr:r=[]}=t,n=[],i=1;e=Il(e);const a=JSON.parse(e),l=a.pop();let c=(l==null?void 0:l.memberCodes)||{},p=(l==null?void 0:l.depends)||[];if(!p.length)return`return ${l==null?void 0:l.code}`;let h=[],f=[];const d=[];if(this._getDependCodes(p,a,n,h,f,d),f.length){const m=r.length;let w=[];for(let v=m-1;v>=0;v--){const x=r[v];let b=JSON.parse(Il(x));const N=[];i!==0&&f.length&&(w.unshift("{"),i++),b=b.map(S=>{const{scope:T,code:F,varNames:O,dependSelf:R}=S;return T===2&&!N.includes(O)&&!R&&(S.code=`let ${F}`),O&&N.push(...O.split(", ")),S.memberCodes&&Object.assign(c,{...S.memberCodes}),S});const E=[],A=[];let M=f.map(S=>({...S,isArg:!1,isPreArg:!0}));f=[],this._getDependCodes(M,b,A,h,f,E),w.unshift(...A,...E),n=w.concat(n),w=[]}}for(n.push(`return ${l==null?void 0:l.code}`);i>1;)n.push("}"),i--;n=h.concat(n),n.push(...d);let g=n.join(`
|
63
63
|
`);const y=[];for(const m of Object.keys(c))g.includes(`$_var.getCacheData("${m}"`)&&y.push(c[m]);return y.length&&(g=`${y.join(`
|
64
64
|
`)}
|
65
|
-
${g}`),g}_getRequestData(t,e){let{symbol:r,timeframe:n,calc_bars_count:i}=t;const a=self.workerStorage.get(`request_${this._scriptId}_data`),l=`${r}--${n}`;if(a!=null&&a.has(l)){const{index:c=0,periodStamp:p=Qr(this._variables.__period)*1e3}=this._cacheData.get(e)||{},h=(a.get(l)||[]).slice(c),f=this._variables.time,d=p+f;for(const[g,y]of h.entries()){const{timestamp:m,close:w,open:v,high:x,low:b,volume:N}=y;let E=m*1e3;if(E>=d){this._cacheData.set(e,{index:g,periodStamp:p});return}if(E>=f)return this._cacheData.set(e,{index:g+1,periodStamp:p}),{close:Number(w),open:Number(v),high:Number(x),low:Number(b),timestamp:m,volume:N}}this._cacheData.set(e,{index:h.length,periodStamp:p})}else{const c=self.workerStorage.get(`request_${this._scriptId}_list`);(c==null?void 0:c.get(l))||c==null||c.set(l,{id:l,calc_bars_count:i,symbol:r,timeframe:n})}}_getDependCodes(t,e,r,n,i,a){for(const l of t){if(!l.isArg){const c=e.filter(h=>{var f;return(f=h==null?void 0:h.depends)==null?void 0:f.some(d=>d.name===l.name&&d.scope===l.scope&&d.isAgainAssign)});for(const h of c){const{code:f,depends:d}=h;if(!r.includes(f)&&(r.unshift(f),d!=null&&d.length)){for(const g of d)g.memberCode&&a.push(g.memberCode);this._getDependCodes(d,e,r,n,i,a)}}const p=e.find(h=>{var f;return((f=h.varNames)==null?void 0:f.split(", ").includes(l.name))&&(!l.isPreArg||l.isPreArg&&h.methodName===l.functionName)||h.funcName===l.name});if(p){const{code:h,depends:f}=p,d=r.findIndex(g=>g===h);if(d!==-1&&r.splice(d,1),r.unshift(h),f!=null&&f.length){for(const g of f)g.memberCode&&a.push(g.memberCode);this._getDependCodes(f,e,r,n,i,a)}continue}}i.some(c=>c.name===l.name)||i.push(l)}}_runScripts(t,e,r,n,i){const a=`${this._scriptId}_${e}`;let{builtInGather:l,buildinConstants:c,buildInFunctions:p,tradingvueFunc:h}=self.workerStorage.get(a)||{};return r&&(l=new oh(a),c=new Qf,p=new sh(this._variables.mintick||1e-5,l,this._scriptId),h=new Function("$_var","$_const","$_func","$paramsExpr","$posStr",t),self.workerStorage.set(a,{builtInGather:l,buildinConstants:c,buildInFunctions:p,tradingvueFunc:h})),h(l,c,p,n||[],e)}}let uw=class{constructor(){}prefix(t){var r;const{symbol:e}=t;return((r=e==null?void 0:e.split("."))==null?void 0:r[0])||""}ticker(t){var r;const{symbol:e}=t;return((r=e==null?void 0:e.split("."))==null?void 0:r[1])||""}};class lw{constructor(t){$(this,"_logs");$(this,"_variables");$(this,"_intlFormat");this._variables=t,this._logs=[],this._intlFormat=new Intl.NumberFormat("en-US")}get logs(){return this._logs}clearLogs(){this._logs=[]}info(t,e,r){this._addLog(t,e,"info",r)}error(t,e,r){this._addLog(t,e,"error",r)}warning(t,e,r){this._addLog(t,e,"warning",r)}_addLog(t,e,r,n){if(typeof e=="string"&&(n=e),n.startsWith("export"))return;const{message:i,formatString:a}=t,{time:l,bar_index:c}=this._variables;let p=i;a&&Array.isArray(e)&&e.length&&(p=a.replace(/{(\d+)}/g,(h,f)=>{let d=e[f];return typeof d=="number"&&(d=this._intlFormat.format(parseFloat(d.toFixed(3)))),typeof d=="object"&&(d.isArray?d=JSON.stringify(d._value):d=d.toString()),d!==void 0?d:h})),p&&this._logs.push({message:`[${ee(l).format()}]: ${p}`,time:l,barIndex:c,type:r})}}class cw{constructor(t){$(this,"_errorListener");this._errorListener=t}error({message:t},e){e.startsWith("export")||this._errorListener.addError(t,e,zt.Error)}}class fw{constructor(){$(this,"_errors");this._errors=new Map}clear(){this._errors.clear()}get errors(){return Xr.flatMap([...this._errors.values()])}addError(t,e,r,n=0){const[i,a]=e.split("_").slice(-2),l=this._errors.get(e),c={message:t,endLineNumber:Number(i),startColumn:Number(a)+1,endColumn:Number(a)+n+1,startLineNumber:Number(i),type:r};l?l.push(c):this._errors.set(e,[c])}}class hw{constructor(){$(this,"_isMarketOpen");$(this,"_currentBarIndex");$(this,"_totalBarIndex");$(this,"_isRealTimeBar");$(this,"_preBarIndex");this._currentBarIndex=0,this._totalBarIndex=0,this._isRealTimeBar=!1,this._preBarIndex=0,this._isMarketOpen=!0}update(t,e,r,n){this._preBarIndex=this._currentBarIndex,this._currentBarIndex=t,this._totalBarIndex=e,this._isRealTimeBar=r,this._isMarketOpen=n}get isnew(){return!this._isRealTimeBar||this._preBarIndex!==this._currentBarIndex}get islast(){return this._currentBarIndex===this._totalBarIndex}get isfirst(){return this._currentBarIndex===0}get ishistory(){return!this._isRealTimeBar}get isrealtime(){return this._isRealTimeBar}get isconfirmed(){return!this._isRealTimeBar}get islastconfirmedhistory(){return this._isMarketOpen?this._currentBarIndex===this._totalBarIndex-1:this._currentBarIndex===this._totalBarIndex}}class pw{constructor(t){$(this,"_variables");this._variables=t}get isfirstbar(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get isfirstbar_regular(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get islastbar(){if(this._variables.timeframe.isdwm)return!0;const t=Qr(this._variables.timeframe.period);return this._variables.time+t===this._variables.time_tradingday+24*60*60*1e3}get islastbar_regular(){if(this._variables.timeframe.isdwm)return!0;const t=Qr(this._variables.timeframe.period);return this._variables.time+t===this._variables.time_tradingday+24*60*60*1e3}get ismarket(){return!0}get ispostmarket(){return!1}get ispremarket(){return!1}}class dw{constructor(t){$(this,"_orders");$(this,"_historyOrders");$(this,"_options");$(this,"_max_contracts_held_all",0);$(this,"_max_contracts_held_long",0);$(this,"_max_contracts_held_short",0);$(this,"_max_drawdown",0);$(this,"_max_runup",0);$(this,"_max_runup_percent",0);$(this,"_max_drawdown_percent",0);$(this,"_variables");$(this,"_netprofit",0);$(this,"_eventrades",0);$(this,"_avg_trade_percent");$(this,"_closedtrades",0);$(this,"_losstrades",0);$(this,"_grossloss",0);$(this,"_grossloss_percent",0);$(this,"_grossprofit",0);$(this,"_grossprofit_percent",0);$(this,"_wintrades",0);$(this,"_opentrades_capital_held",0);$(this,"_position_avg_price",0);$(this,"_position_size",0);$(this,"_openprofit",0);$(this,"marginCallLong",0);$(this,"marginCallShort",0);this._orders=[],this._historyOrders=[],this._variables=t}update(){this._calcMaxDrawdownAndMaxRunup()}_calcMaxDrawdownAndMaxRunup(){let t=0,e=0;const{high:r,low:n,close:i}=this._variables;let a=0,l=this._netprofit;for(const g of this._orders){const{in_price:y,qty:m=0,commission:w=0,original_qty:v=0,direction:x,profit:b=0}=g,N=x===ue.long?1:-1,E=(r-y)*m,A=(n-y)*m,M=this._getCommission(i,m),S=w*m/v,T=N===1?E:-A,F=N===1?-A:E;a+=b+S+M,t+=F+S,e+=T,l+=S}this._openprofit=a;const c=this.initial_capital,[p,h]=this._historyOrders.reduce((g,y)=>{let[m,w]=g;const{profit:v=0,total_profit:x=0,last_commission:b=0}=y;return m+=v,w=Math.min(x+b+c,w),[m,w]},[0,c]);t-=p,e=c+l-h+e;const f=t/this.initial_capital*100;this._max_drawdown<t&&(this._max_drawdown=t),f>this._max_drawdown_percent&&(this._max_drawdown_percent=f);const d=e/this.initial_capital*100;e>this._max_runup&&(this._max_runup=e),d>this._max_runup_percent&&(this._max_runup_percent=d)}updateOrders(t){this._orders=t,this._calcMaxContracts()}_calcMaxContracts(){const t=this._orders.length;if(!t){this._position_size=0,this._position_avg_price=void 0,this._opentrades_capital_held=0;return}const[e,r,n,i,a,l,c]=this._orders.reduce(([p,h,f,d,g,y,m],w)=>{const{direction:v,qty:x=0,in_price:b,commission:N=0}=w;return v===ue.long?(p+=x,h+=x,y+=x):(p+=x,f+=x,y-=x),d+=x*b,g+=b,m+=N,[p,h,f,d,g,y,m]},[0,0,0,0,0,0,0]);this._historyOrders.length||(this._netprofit=-c,this._grossloss=-c),this._position_size=l,this._position_avg_price=a/t,this._opentrades_capital_held=i,this._max_contracts_held_all=Math.max(e,this._max_contracts_held_all),this._max_contracts_held_long=Math.max(r,this._max_contracts_held_long),this._max_contracts_held_short=Math.max(n,this._max_contracts_held_short)}updateHistoryOrders(t){this._historyOrders=t;const e=this._historyOrders.length;this._closedtrades=e;const[r,n,i,a,l,c]=this._historyOrders.reduce((h,f)=>{let[d,g,y,m,w,v]=h;const{profit:x=0,profit_percent:b=0}=f;return d+=x,g+=b,x<0?(y+=x,m+=b):(w+=x,v+=b),[d,g,y,m,w,v]},[0,0,0,0,0,0]),p=this._orders.reduce((h,f)=>{const{commission:d=0,qty:g=0,original_qty:y=0}=f,m=d*g/y;return h+m},0);this._avg_trade_percent=e?n/e:void 0,this._netprofit=r-p,this._grossloss=i-p,this._grossprofit=l,this._eventrades=this._historyOrders.filter(h=>h.profit===0).length,this._losstrades=this._historyOrders.filter(h=>(h.profit||0)<0).length,this._wintrades=this._historyOrders.filter(h=>(h.profit||0)>0).length}updateStrategyOptions(t){this._options=t}get long(){return"long"}get short(){return"short"}get account_currency(){return"USD"}get closedtrades(){return this._closedtrades}get opentrades(){return{opentrades:this._orders.length,capital_held:this._opentrades_capital_held}}get avg_losing_trade(){const t=this._losstrades;return t?Math.abs(this._grossloss/t):void 0}get avg_losing_trade_percent(){const t=this._losstrades;return t?Math.abs(this._grossloss_percent/t):void 0}get avg_trade(){if(this._closedtrades)return this._netprofit/this._closedtrades}get equity(){return this.initial_capital+this._netprofit+this._openprofit}get netprofit(){return this._netprofit}get eventrades(){return this._eventrades}get openprofit(){return this._openprofit}get avg_trade_percent(){return this._avg_trade_percent}get avg_winning_trade(){const t=this._wintrades;return t?Math.abs(this._grossprofit/t):void 0}get avg_winning_trade_percent(){const t=this._wintrades;return t?Math.abs(this._grossprofit_percent/t):void 0}get initial_capital(){var t;return((t=this._options)==null?void 0:t.initial_capital)||0}get losstrades(){return this._losstrades}get grossloss(){return this._grossloss}get grossloss_percent(){return this._grossloss/this.initial_capital*100}get grossprofit(){return this._grossprofit}get grossprofit_percent(){return this._grossprofit/this.initial_capital*100}get wintrades(){return this._wintrades}get margin_liquidation_price(){if(!this._options)return;const{initial_capital:t,margin_long:e=0,margin_short:r=0,commission_type:n,commission_value:i=0}=this._options,a=this._orders[0].direction===ue.long?1:-1,l=(a===1?e:r)/100;if(l<=0)return;const{close:c}=this._variables,[p,h]=this._orders.reduce((f,d)=>{let[g,y]=f;const{in_price:m,qty:w=0,original_qty:v=0}=d,x=m*w;if(g+=x,i){let b=0;switch(n){case nr.percent:b=(x+w*c)*i/100;break;case nr.cashPerContract:b=w*i*2;break;case nr.cashPerOrder:b=w/v*i+i;break}y+=b}return[g,y]},[0,0]);return(p-(t+this._netprofit-h))*a/this._position_size/(1-a*l)}get max_contracts_held_all(){return this._max_contracts_held_all}get max_contracts_held_long(){return this._max_contracts_held_long}get max_contracts_held_short(){return this._max_contracts_held_short}get max_drawdown(){return this._max_drawdown}get max_runup(){return this._max_runup}get max_runup_percent(){return this._max_runup_percent}get max_drawdown_percent(){return this._max_drawdown_percent}get netprofit_percent(){return this._netprofit/this.initial_capital*100}get openprofit_percent(){return this._openprofit/(this.initial_capital+this._netprofit)*100}get position_avg_price(){return this._position_avg_price}get position_entry_name(){if(this._orders.length)return this._orders[0].id}get position_size(){return this._position_size}get summaryData(){return{position_size:this.position_size,position_avg_price:this.position_avg_price,position_entry_name:this.position_entry_name,openprofit_percent:this.openprofit_percent,netprofit_percent:this.netprofit_percent,max_drawdown_percent:this.max_drawdown_percent,max_runup_percent:this.max_runup_percent,max_drawdown:this.max_drawdown,max_runup:this.max_runup,max_contracts_held_long:this.max_contracts_held_long,max_contracts_held_short:this.max_contracts_held_short,max_contracts_held_all:this.max_contracts_held_all,avg_winning_trade_percent:this.avg_winning_trade_percent,avg_winning_trade:this.avg_winning_trade,avg_trade_percent:this.avg_trade_percent,avg_trade:this.avg_trade,avg_losing_trade:this.avg_losing_trade,avg_losing_trade_percent:this.avg_losing_trade_percent,wintrades:this.wintrades,losstrades:this.losstrades,eventrades:this.eventrades,grossprofit:this.grossprofit,grossprofit_percent:this.grossprofit_percent,grossloss:this.grossloss,grossloss_percent:this.grossloss_percent,openprofit:this.openprofit,initial_capital:this.initial_capital,netprofit:this.netprofit,closedtrades:this.closedtrades,opentrades:this.opentrades,equity:this.equity,margin_call_long:this.marginCallLong,margin_call_short:this.marginCallShort}}_getCommission(t,e){if(!this._options)return 0;const{commission_value:r=0,commission_type:n}=this._options,i=t*e;let a=0;switch(n){case nr.percent:a=i*r/100;break;case nr.cashPerContract:a=e*r;break;case nr.cashPerOrder:a=r;break}return a}}class _w{constructor(t){$(this,"_preAccdist");$(this,"_preNvi");$(this,"_prePvi");$(this,"_preObv");$(this,"_prePvt");$(this,"_preWad");$(this,"_preVwap");$(this,"_preValue");$(this,"_currentData");$(this,"_preData");$(this,"_id");this._preAccdist=0,this._preNvi=0,this._prePvi=0,this._preObv=0,this._prePvt=0,this._preWad=0,this._preVwap={},this._preValue={},this._currentData={},this._preData={},this._id=t}update(t){this._preValue={},t.barIndex!==this._currentData.barIndex&&(this._preData={...this._currentData}),this._currentData={...t}}get isRealTime(){return this._preData.barIndex===this._currentData.barIndex}get accdist(){if(this._preValue.accdist)return this._preValue.accdist;const{close:t,low:e,high:r,volume:n}=this._currentData;if(r===e)return this._preAccdist;const i=(t-e-(r-t))/(r-e)*n+this._preAccdist;return!this.isRealTime&&(this._preAccdist=i),this._preValue.accdist=i,i}get iii(){if(this._preValue.iii)return this._preValue.iii;const{close:t,low:e,high:r,volume:n}=this._currentData,i=(2*t-r-e)/((r-e)*n);return this._preValue.iii=i,i}get nvi(){return this._preValue.nvi?this._preValue.nvi:this._getNvi()}get wvad(){if(this._preValue.wvad)return this._preValue.wvad;const{close:t,low:e,high:r,volume:n,open:i}=this._currentData,a=(t-i)/(r-e)*n;return this._preValue.wvad=a,a}get obv(){if(this._preValue.obv)return this._preValue.obv;const{close:t,volume:e}=this._currentData,{close:r}=this._preData;if(r===void 0){this._preObv=0;return}const n=Math.sign(t-r)*e+this._preObv;return!this.isRealTime&&(this._preObv=n),this._preValue.obv=n,n}get pvi(){return this._preValue.pvi?this._preValue.pvi:this._getPvi()}get tr(){if(this._preValue.tr)return this._preValue.tr;const{low:t,high:e}=this._currentData,{close:r}=this._preData;if(r===void 0)return;const n=Math.max(e-t,Math.abs(e-r),Math.abs(t-r));return this._preValue.tr=n,n}get pvt(){if(this._preValue.pvt)return this._preValue.pvt;const{close:t,volume:e}=this._currentData,{close:r}=this._preData;if(r===void 0){this._prePvt=0;return}const n=(t-r)/r*e+this._prePvt;return!this.isRealTime&&(this._prePvt=n),this._preValue.pvt=n,n}get wad(){if(this._preValue.wad)return this._preValue.wad;const{close:t,high:e,low:r}=this._currentData,{close:n}=this._preData;if(n===void 0)return this._preWad=0,0;const i=Math.max(e,n),a=Math.min(r,n),l=t-n,p=(l>0?t-a:l<0?t-i:0)+this._preWad;return!this.isRealTime&&(this._preWad=p),this._preValue.wad=p,p}get vwap(){var h,f;if(this._preValue.vwap)return this._preValue.vwap;const{hlc3:t,volume:e}=this._currentData;let{sum:r=0,sumV:n=0,isReset:i}=this._preVwap;if(((f=(h=self.workerStorage)==null?void 0:h.get(this._id))==null?void 0:f.buildInFunctions.timeframe.change({timeframe:"1D"},"vwap_buildin"))&&(i=!0,r=n=0),!i)return;const l=t*e+r,c=e+n;!this.isRealTime&&(this._preVwap={sum:l,sumV:c,isReset:i});const p=l/c;return this._preValue.vwap=p,p}_getNvi(){const t=this._preNvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:i}=this._currentData;let a=1;const l=t||1;return n&&e?a=i<r?l+(n-e)/e*l:l:a=l,!this.isRealTime&&(this._preNvi=a),this._preValue.nvi=a,a}_getPvi(){const t=this._prePvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:i}=this._currentData;let a=1;const l=t||1;return n&&e?a=i>r?l+(n-e)/e*l:l:a=l,!this.isRealTime&&(this._prePvi=a),this._preValue.pvi=a,a}}class mw{constructor(){$(this,"_period");$(this,"_multiplier");$(this,"_unit");this._period="1",this._multiplier=1,this._unit="m"}update(t){if(!t)return;this._period=t;const[e,r]=ys(t);this._multiplier=e,this._unit=r}get isdaily(){return this._unit==="d"}get isdwm(){return["d","w","M"].includes(this._unit)}get isintraday(){return["s","m","h"].includes(this._unit)}get isminutes(){return this._unit==="m"}get ismonthly(){return this._unit==="M"}get isseconds(){return this._unit==="s"}get isweekly(){return this._unit==="w"}get multiplier(){return this._multiplier}get period(){return this._period}}class gw{constructor(t){$(this,"_variables");$(this,"_bgColor");$(this,"_fgColor");$(this,"isUseBgColor",!1);this._variables=t}updateOptions(t){t!=null&&t.bg_color&&(this._bgColor=t.bg_color,this._fgColor=this._contrastColor(t.bg_color))}get bg_color(){return this.isUseBgColor=!0,this._bgColor}get fg_color(){return this.isUseBgColor=!0,this._fgColor}get is_heikinashi(){return!1}get is_kagi(){return!1}get is_linebreak(){return!1}get is_pnf(){return!1}get is_range(){return!1}get is_renko(){return!1}get is_standard(){return!0}get left_visible_bar_time(){return this._variables.time}get right_visible_bar_time(){return this._variables.time}_parseColor(t){let e,r,n,i;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const a=t.substring(7);a?i=parseInt(a,16)/255:i=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,i=a[3]||1}return{r:e,g:r,b:n,a:i}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}_contrastColor(t){const{r:e,g:r,b:n}=this._parseColor(t);return(299*e+587*r+114*n)/1e3>128?"#000000":"#ffffff"}}class vw{constructor(t){$(this,"_variables");this._variables=t}get basecurrency(){return""}get country(){}get currency(){return"CNY"}get description(){return""}get employees(){return 100}get expiration_date(){}get industry(){}get minmove(){}get mintick(){return this._variables.mintick}get pointvalue(){}get prefix(){}get pricescale(){}get recommendations_buy(){}get recommendations_buy_strong(){}get recommendations_date(){}get recommendations_hold(){}get recommendations_sell(){}get recommendations_sell_strong(){}get recommendations_total(){}get root(){return""}get sector(){}get session(){return fi.regular}get shareholders(){}get shares_outstanding_float(){}get shares_outstanding_total(){}get target_price_average(){}get target_price_date(){}get target_price_estimates(){}get target_price_high(){}get target_price_low(){}get target_price_median(){}get ticker(){}get tickerid(){}get timezone(){}get type(){}get volumetype(){return"n/a"}}class yw{constructor(t){$(this,"_variables");this._variables=t}get future_amount(){}get future_ex_date(){}get future_pay_date(){}}class ww{constructor(t){$(this,"_variables");this._variables=t}get future_eps(){}get future_period_end_time(){}get future_revenue(){}get future_time(){}}ee.extend(Wp),ee.extend(Sl),ee.extend(kp);class oh{constructor(t){$(this,"_cacheData");$(this,"_barIndex");$(this,"_isRealTimeBar");$(this,"_barstate");$(this,"_priceVariables");$(this,"_lastBarIndex");$(this,"_currentBarTime");$(this,"_lastBarTime");$(this,"_period");$(this,"_offsetTime");$(this,"_timeframe");$(this,"_ta");$(this,"_polyline");$(this,"_label");$(this,"_line");$(this,"_linefill");$(this,"_box");$(this,"_table");$(this,"_strategy");$(this,"_session");$(this,"syminfo");$(this,"chart");$(this,"earnings");$(this,"dividends");$(this,"_timeTradingday");$(this,"_mintick");$(this,"_cacheSpace");this._cacheData={varData:{},varNewData:{},varipData:{}},this._barIndex=0,this._lastBarIndex=0,this._currentBarTime=0,this._lastBarTime=0,this._offsetTime=0,this._period="",this._isRealTimeBar=!1,this._barstate=new hw,this._timeframe=new mw,this._priceVariables={close:0,open:0,low:0,high:0,volume:0},this._ta=new _w(t),this._polyline=new Fi,this._label=new Fi,this._line=new Fi,this._linefill=new Fi,this._box=new Fi,this._table=new Fi(1),this._strategy=new dw(this),this._session=new pw(this),this.syminfo=new vw(this),this.chart=new gw(this),this.earnings=new ww(this),this.dividends=new yw(this),this._cacheSpace=new Map}get table(){return this._table}get box(){return this._box}get linefill(){return this._linefill}get line(){return this._line}get polyline(){return this._polyline}get label(){return this._label}get ta(){return this._ta}get strategy(){return this._strategy}get session(){return this._session}get na(){}get last_bar_index(){return this._lastBarIndex}get bar_index(){return this._barIndex}get barstate(){return this._barstate}get close(){return this._priceVariables.close}get low(){return this._priceVariables.low}get open(){return this._priceVariables.open}get high(){return this._priceVariables.high}get volume(){return this._priceVariables.volume}get ohlc4(){const{close:t,open:e,high:r,low:n}=this._priceVariables;return(t+e+r+n)/4}get hl2(){const{high:t,low:e}=this._priceVariables;return(t+e)/2}get hlc3(){const{close:t,high:e,low:r}=this._priceVariables;return(t+e+r)/3}get hlcc4(){const{close:t,high:e,low:r}=this._priceVariables;return(t*2+e+r)/4}get hour(){return ee(this._currentBarTime).subtract(this._offsetTime,"hour").hour()}get minute(){return ee(this._currentBarTime).minute()}get second(){return ee(this._currentBarTime).second()}get month(){return ee(this._currentBarTime).month()+1}get year(){return ee(this._currentBarTime).year()}get dayofweek(){return ee(this._currentBarTime).day()+1}get dayofmonth(){return ee(this._currentBarTime).date()}get weekofyear(){return ee(this._currentBarTime).week()}get last_bar_time(){return this._lastBarTime}get time(){return this._currentBarTime}get time_close(){const[t,e]=ys(this._period);return this._isRealTimeBar?void 0:ee(this._currentBarTime).add(t,e).valueOf()}get timenow(){return Date.now()}get time_tradingday(){return this._timeTradingday||this.getTimeTradingday(this._currentBarTime,this._period)}get timeframe(){return this._timeframe}get mintick(){return this._mintick}get __period(){return this._period}updateMaxLength(t){const{max_lines_count:e,max_labels_count:r,max_boxes_count:n,max_polylines_count:i}=t;n&&this._box.setMaxLen(n),r&&this._label.setMaxLen(r),e&&this._line.setMaxLen(e),i&&this._polyline.setMaxLen(i)}getTimeTradingday(t,e){const[r,n]=ys(e),i=ee(t);return["M","w","y","d"].includes(n)?i.valueOf():(i.subtract(this._offsetTime,"h"),i.startOf("d").add(this._offsetTime,"h").valueOf())}updateOptions(t){const{interval:e="1D",offsetTime:r=5,mintick:n,chart:i}=t;this._period=e,this._mintick=n,this._offsetTime=r,this._timeframe.update(e),this.chart.updateOptions(i)}updateData(t){const{barIndex:e,c:r,o:n,h:i,l:a,volume:l,time:c,lastBarIndex:p,lastBarTime:h,complete:f,time_tradingday:d}=t;this._priceVariables={close:Number(r),open:Number(n),high:Number(i),low:Number(a),volume:Number(l)},this._isRealTimeBar=f,e>this._barIndex&&this._isRealTimeBar&&(this._cacheData.varData=this._cacheData.varNewData,this._cacheData.varNewData={}),this._timeTradingday=d,this._currentBarTime=c*1e3,this._lastBarIndex=p,this._barIndex=e,this._lastBarTime=h*1e3,this._barstate.update(e,p,f,!1),this.ta.update({...this._priceVariables,hlc3:this.hlc3,barIndex:e})}getCacheData(t,e,r){const n=this.setCacheData(t,r);return(this._cacheSpace.get(t)||0)<e&&this._cacheSpace.set(t,e),n[n.length-1-e]}setCacheData(t,e){let r=this._cacheData[t]||{barIndex:-1,data:[]};if(r.barIndex>this._barIndex)return r.data;r.barIndex===this._barIndex?r.data[r.data.length-1]=e:r.data.push(e);const n=this._cacheSpace.get(t);return n&&r.data.length>n+5&&r.data.shift(),r.barIndex=this._barIndex,this._cacheData[t]=r,r.data}getTypeInstance(t,e){return new Rp(t,e)}verifyVarAndVarip(t,e,r){const n=`${t}_${e}`;return r==="var"&&this._cacheData.varData.hasOwnProperty(n)?(this._upadteChartDraws(this._cacheData.varData[n]),!0):r==="varip"&&this._cacheData.varipData.hasOwnProperty(n)?(this._upadteChartDraws(this._cacheData.varipData[n]),!0):!1}getVarValue(t,e,r){const n=`${t}_${e}`;return r==="var"?this._cacheData.varData[n]:this._cacheData.varipData[n]}setVarValue(t,e,r,n){var l;const i=`${t}_${e}`;let a;switch(typeof r=="object"&&((l=r==null?void 0:r.varipKeys)!=null&&l.length)&&(n="var",a=r.varipKeys),this._chartDrawsHandle(r,this._cacheData.varData[i]||this._cacheData.varipData[i]),n){case"var":if(this._isRealTimeBar){if(this._cacheData.varNewData[i]=r,a&&a.length)for(const c of a)this._cacheData.varData[i][c]=r[c]}else this._cacheData.varData[i]=r;break;case"varip":this._cacheData.varipData[i]=r;break}return r}_upadteChartDraws(t){const e=t==null?void 0:t.id;if(e)switch(t==null?void 0:t.type){case Fe.BOX:this._setChartDraw(e,this._box);break;case Fe.LINE:this._setChartDraw(e,this._line);break;case Fe.POLYLINE:this._setChartDraw(e,this._polyline);break;case Fe.LABEL:this._setChartDraw(e,this._label);break;case Fe.LINEFILL:this._setChartDraw(e,this._linefill);break;case Fe.TABLE:this._setChartDraw(e,this._table);break}}_setChartDraw(t,e){const r=e.getInstance(t),n=e.get(t);e.delete(t),e.set(t,n,r)}_chartDrawsHandle(t,e){const r=e==null?void 0:e.id;let n=t==null?void 0:t.id;r!==n&&(n&&t.data&&(t.data.isVar=!0),r&&e.data&&(e.data.isVar=!1))}add(t,e){return Array.isArray(t)&&Array.isArray(e)?Xr.uniq([...t,...e]):typeof t=="number"||typeof e=="number"?Number(t)+Number(e):t+e}sub(t,e){return Array.isArray(t)&&Array.isArray(e)?t.filter(r=>!e.includes(r)):Number(t)-Number(e)}againAssignParse(t,e){var n;if(e)return;const r=(n=t==null?void 0:t.constructor)==null?void 0:n.name;if(r)switch(r){case ao.name:case th.name:case co.name:case eh.name:case uo.name:case lo.name:t==null||t.delete();break}}}class Fi{constructor(t=50){$(this,"_all");$(this,"_allInstance");$(this,"_pseudoArrayAll");$(this,"_maxLength");this._all=new Map,this._allInstance=new Map,this._pseudoArrayAll=new Qt,this._maxLength=t}setMaxLen(t){this._maxLength=t}get data(){return[...this._all.values()].slice(-this._maxLength)}get all(){return this._pseudoArrayAll._value=[...this._allInstance.values()],this._pseudoArrayAll}add(t,e,r){if(this.set(t,e,r),this._all.size>this._maxLength){const{bar_index:n}=e;for(const[i,a]of this._all){const{isVar:l,id:c,bar_index:p}=a;if(p===n)break;if(l)continue;this.delete(c);break}}}getValOfBarIndex(t){let e=[];const r=[...this._all.keys()];for(const n of t){const i=r.filter(a=>a.endsWith(`_${n}`));for(const a of i){const l=this._all.get(a);l&&e.push(l)}}return e.length?e:void 0}set(t,e,r){this._all.set(t,e),this._allInstance.set(t,r)}get(t){return this._all.get(t)}getInstance(t){return this._allInstance.get(t)}delete(t){this._all.delete(t),this._allInstance.delete(t)}}/**
|
65
|
+
${g}`),g}_getRequestData(t,e){let{symbol:r,timeframe:n,calc_bars_count:i}=t;const{__period:a,syminfo:{ticker:l,tickerid:c},mintick:p}=this._variables;if((n===a||n==="")&&(r===l||r===c)){const{close:g,open:y,high:m,low:w,bar_index:v,last_bar_index:x,last_bar_time:b,_isRealTimeBar:N,volume:E,time:A,time_tradingday:M}=this._variables;return{barIndex:v,c:g,o:y,h:m,l:w,volume:E,lastBarIndex:x,lastBarTime:b/1e3,complete:N,time_tradingday:M,time:A/1e3,interval:a,mintick:p}}const h=`${r}--${n||a}`,f=self.workerStorage.get(`request_${this._scriptId}_data`),d=self.workerStorage.get(`request_${this._scriptId}_list`);if(f!=null&&f.has(h)){d==null||d.delete(h);const{index:g=0,periodStamp:y=Qr(this._variables.__period)*1e3}=this._cacheData.get(e)||{},m=(f.get(h)||[]).slice(g),w=this._variables.time,v=y+w,x=m.length-1,b={lastBarIndex:m[x].barindex||x,lastBarTime:m[x].time,interval:a,mintick:p};for(const[N,E]of m.entries()){let{time:A,barindex:M}=E;if(A=A*1e3,A>=v){this._cacheData.set(e,{index:N,periodStamp:y});return}if(A>=w)return this._cacheData.set(e,{index:N+1,periodStamp:y}),{...E,barIndex:M||N,...b}}this._cacheData.set(e,{index:m.length,periodStamp:y})}else(d==null?void 0:d.get(h))||d==null||d.set(h,{id:h,calc_bars_count:i,symbol:r,timeframe:n||a})}_getDependCodes(t,e,r,n,i,a){for(const l of t){if(!l.isArg){const c=e.filter(h=>{var f;return(f=h==null?void 0:h.depends)==null?void 0:f.some(d=>d.name===l.name&&d.scope===l.scope&&d.isAgainAssign)});for(const h of c){const{code:f,depends:d}=h;if(!r.includes(f)&&(r.unshift(f),d!=null&&d.length)){for(const g of d)g.memberCode&&a.push(g.memberCode);this._getDependCodes(d,e,r,n,i,a)}}const p=e.find(h=>{var f;return((f=h.varNames)==null?void 0:f.split(", ").includes(l.name))&&(!l.isPreArg||l.isPreArg&&h.methodName===l.functionName)||h.funcName===l.name});if(p){const{code:h,depends:f}=p,d=r.findIndex(g=>g===h);if(d!==-1&&r.splice(d,1),r.unshift(h),f!=null&&f.length){for(const g of f)g.memberCode&&a.push(g.memberCode);this._getDependCodes(f,e,r,n,i,a)}continue}}i.some(c=>c.name===l.name)||i.push(l)}}_runScripts(t,e,r,n,i){const a=`${this._scriptId}_${e}`;let{builtInGather:l,buildinConstants:c,buildInFunctions:p,tradingvueFunc:h}=self.workerStorage.get(a)||{};const{interval:f,mintick:d,...g}=i||{};r&&(l=new oh(a),c=new Qf,p=new sh(this._variables.mintick||1e-5,l,this._scriptId),h=new Function("$_var","$_const","$_func","$paramsExpr","$posStr",t),l.updateOptions({interval:f,mintick:d||1e-5}),self.workerStorage.set(a,{builtInGather:l,buildinConstants:c,buildInFunctions:p,tradingvueFunc:h})),l.updateData(g),p.update({barIndex:(g==null?void 0:g.barindex)||0});const y=h(l,c,p,n||[],e);return p.endExecution(),y}}let uw=class{constructor(){}prefix(t){var r;const{symbol:e}=t;return((r=e==null?void 0:e.split("."))==null?void 0:r[0])||""}ticker(t){var r;const{symbol:e}=t;return((r=e==null?void 0:e.split("."))==null?void 0:r[1])||""}};class lw{constructor(t){$(this,"_logs");$(this,"_variables");$(this,"_intlFormat");this._variables=t,this._logs=[],this._intlFormat=new Intl.NumberFormat("en-US")}get logs(){return this._logs}clearLogs(){this._logs=[]}info(t,e,r){this._addLog(t,e,"info",r)}error(t,e,r){this._addLog(t,e,"error",r)}warning(t,e,r){this._addLog(t,e,"warning",r)}_addLog(t,e,r,n){if(typeof e=="string"&&(n=e),n.startsWith("export"))return;const{message:i,formatString:a}=t,{time:l,bar_index:c}=this._variables;let p=i;a&&Array.isArray(e)&&e.length&&(p=a.replace(/{(\d+)}/g,(h,f)=>{let d=e[f];return typeof d=="number"&&(d=this._intlFormat.format(parseFloat(d.toFixed(3)))),typeof d=="object"&&(d.isArray?d=JSON.stringify(d._value):d=d.toString()),d!==void 0?d:h})),p&&this._logs.push({message:`[${ee(l).format()}]: ${p}`,time:l,barIndex:c,type:r})}}class cw{constructor(t){$(this,"_errorListener");this._errorListener=t}error({message:t},e){e.startsWith("export")||this._errorListener.addError(t,e,zt.Error)}}class fw{constructor(){$(this,"_errors");this._errors=new Map}clear(){this._errors.clear()}get errors(){return Xr.flatMap([...this._errors.values()])}addError(t,e,r,n=0){const[i,a]=e.split("_").slice(-2),l=this._errors.get(e),c={message:t,endLineNumber:Number(i),startColumn:Number(a)+1,endColumn:Number(a)+n+1,startLineNumber:Number(i),type:r};l?l.push(c):this._errors.set(e,[c])}}class hw{constructor(){$(this,"_isMarketOpen");$(this,"_currentBarIndex");$(this,"_totalBarIndex");$(this,"_isRealTimeBar");$(this,"_preBarIndex");this._currentBarIndex=0,this._totalBarIndex=0,this._isRealTimeBar=!1,this._preBarIndex=0,this._isMarketOpen=!0}update(t,e,r,n){this._preBarIndex=this._currentBarIndex,this._currentBarIndex=t,this._totalBarIndex=e,this._isRealTimeBar=r,this._isMarketOpen=n}get isnew(){return!this._isRealTimeBar||this._preBarIndex!==this._currentBarIndex}get islast(){return this._currentBarIndex===this._totalBarIndex}get isfirst(){return this._currentBarIndex===0}get ishistory(){return!this._isRealTimeBar}get isrealtime(){return this._isRealTimeBar}get isconfirmed(){return!this._isRealTimeBar}get islastconfirmedhistory(){return this._isMarketOpen?this._currentBarIndex===this._totalBarIndex-1:this._currentBarIndex===this._totalBarIndex}}class pw{constructor(t){$(this,"_variables");this._variables=t}get isfirstbar(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get isfirstbar_regular(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get islastbar(){if(this._variables.timeframe.isdwm)return!0;const t=Qr(this._variables.timeframe.period);return this._variables.time+t===this._variables.time_tradingday+24*60*60*1e3}get islastbar_regular(){if(this._variables.timeframe.isdwm)return!0;const t=Qr(this._variables.timeframe.period);return this._variables.time+t===this._variables.time_tradingday+24*60*60*1e3}get ismarket(){return!0}get ispostmarket(){return!1}get ispremarket(){return!1}}class dw{constructor(t){$(this,"_orders");$(this,"_historyOrders");$(this,"_options");$(this,"_max_contracts_held_all",0);$(this,"_max_contracts_held_long",0);$(this,"_max_contracts_held_short",0);$(this,"_max_drawdown",0);$(this,"_max_runup",0);$(this,"_max_runup_percent",0);$(this,"_max_drawdown_percent",0);$(this,"_variables");$(this,"_netprofit",0);$(this,"_eventrades",0);$(this,"_avg_trade_percent");$(this,"_closedtrades",0);$(this,"_losstrades",0);$(this,"_grossloss",0);$(this,"_grossloss_percent",0);$(this,"_grossprofit",0);$(this,"_grossprofit_percent",0);$(this,"_wintrades",0);$(this,"_opentrades_capital_held",0);$(this,"_position_avg_price",0);$(this,"_position_size",0);$(this,"_openprofit",0);$(this,"marginCallLong",0);$(this,"marginCallShort",0);this._orders=[],this._historyOrders=[],this._variables=t}update(){this._calcMaxDrawdownAndMaxRunup()}_calcMaxDrawdownAndMaxRunup(){let t=0,e=0;const{high:r,low:n,close:i}=this._variables;let a=0,l=this._netprofit;for(const g of this._orders){const{in_price:y,qty:m=0,commission:w=0,original_qty:v=0,direction:x,profit:b=0}=g,N=x===ue.long?1:-1,E=(r-y)*m,A=(n-y)*m,M=this._getCommission(i,m),S=w*m/v,T=N===1?E:-A,F=N===1?-A:E;a+=b+S+M,t+=F+S,e+=T,l+=S}this._openprofit=a;const c=this.initial_capital,[p,h]=this._historyOrders.reduce((g,y)=>{let[m,w]=g;const{profit:v=0,total_profit:x=0,last_commission:b=0}=y;return m+=v,w=Math.min(x+b+c,w),[m,w]},[0,c]);t-=p,e=c+l-h+e;const f=t/this.initial_capital*100;this._max_drawdown<t&&(this._max_drawdown=t),f>this._max_drawdown_percent&&(this._max_drawdown_percent=f);const d=e/this.initial_capital*100;e>this._max_runup&&(this._max_runup=e),d>this._max_runup_percent&&(this._max_runup_percent=d)}updateOrders(t){this._orders=t,this._calcMaxContracts()}_calcMaxContracts(){const t=this._orders.length;if(!t){this._position_size=0,this._position_avg_price=void 0,this._opentrades_capital_held=0;return}const[e,r,n,i,a,l,c]=this._orders.reduce(([p,h,f,d,g,y,m],w)=>{const{direction:v,qty:x=0,in_price:b,commission:N=0}=w;return v===ue.long?(p+=x,h+=x,y+=x):(p+=x,f+=x,y-=x),d+=x*b,g+=b,m+=N,[p,h,f,d,g,y,m]},[0,0,0,0,0,0,0]);this._historyOrders.length||(this._netprofit=-c,this._grossloss=-c),this._position_size=l,this._position_avg_price=a/t,this._opentrades_capital_held=i,this._max_contracts_held_all=Math.max(e,this._max_contracts_held_all),this._max_contracts_held_long=Math.max(r,this._max_contracts_held_long),this._max_contracts_held_short=Math.max(n,this._max_contracts_held_short)}updateHistoryOrders(t){this._historyOrders=t;const e=this._historyOrders.length;this._closedtrades=e;const[r,n,i,a,l,c]=this._historyOrders.reduce((h,f)=>{let[d,g,y,m,w,v]=h;const{profit:x=0,profit_percent:b=0}=f;return d+=x,g+=b,x<0?(y+=x,m+=b):(w+=x,v+=b),[d,g,y,m,w,v]},[0,0,0,0,0,0]),p=this._orders.reduce((h,f)=>{const{commission:d=0,qty:g=0,original_qty:y=0}=f,m=d*g/y;return h+m},0);this._avg_trade_percent=e?n/e:void 0,this._netprofit=r-p,this._grossloss=i-p,this._grossprofit=l,this._eventrades=this._historyOrders.filter(h=>h.profit===0).length,this._losstrades=this._historyOrders.filter(h=>(h.profit||0)<0).length,this._wintrades=this._historyOrders.filter(h=>(h.profit||0)>0).length}updateStrategyOptions(t){this._options=t}get long(){return"long"}get short(){return"short"}get account_currency(){return"USD"}get closedtrades(){return this._closedtrades}get opentrades(){return{opentrades:this._orders.length,capital_held:this._opentrades_capital_held}}get avg_losing_trade(){const t=this._losstrades;return t?Math.abs(this._grossloss/t):void 0}get avg_losing_trade_percent(){const t=this._losstrades;return t?Math.abs(this._grossloss_percent/t):void 0}get avg_trade(){if(this._closedtrades)return this._netprofit/this._closedtrades}get equity(){return this.initial_capital+this._netprofit+this._openprofit}get netprofit(){return this._netprofit}get eventrades(){return this._eventrades}get openprofit(){return this._openprofit}get avg_trade_percent(){return this._avg_trade_percent}get avg_winning_trade(){const t=this._wintrades;return t?Math.abs(this._grossprofit/t):void 0}get avg_winning_trade_percent(){const t=this._wintrades;return t?Math.abs(this._grossprofit_percent/t):void 0}get initial_capital(){var t;return((t=this._options)==null?void 0:t.initial_capital)||0}get losstrades(){return this._losstrades}get grossloss(){return this._grossloss}get grossloss_percent(){return this._grossloss/this.initial_capital*100}get grossprofit(){return this._grossprofit}get grossprofit_percent(){return this._grossprofit/this.initial_capital*100}get wintrades(){return this._wintrades}get margin_liquidation_price(){if(!this._options)return;const{initial_capital:t,margin_long:e=0,margin_short:r=0,commission_type:n,commission_value:i=0}=this._options,a=this._orders[0].direction===ue.long?1:-1,l=(a===1?e:r)/100;if(l<=0)return;const{close:c}=this._variables,[p,h]=this._orders.reduce((f,d)=>{let[g,y]=f;const{in_price:m,qty:w=0,original_qty:v=0}=d,x=m*w;if(g+=x,i){let b=0;switch(n){case nr.percent:b=(x+w*c)*i/100;break;case nr.cashPerContract:b=w*i*2;break;case nr.cashPerOrder:b=w/v*i+i;break}y+=b}return[g,y]},[0,0]);return(p-(t+this._netprofit-h))*a/this._position_size/(1-a*l)}get max_contracts_held_all(){return this._max_contracts_held_all}get max_contracts_held_long(){return this._max_contracts_held_long}get max_contracts_held_short(){return this._max_contracts_held_short}get max_drawdown(){return this._max_drawdown}get max_runup(){return this._max_runup}get max_runup_percent(){return this._max_runup_percent}get max_drawdown_percent(){return this._max_drawdown_percent}get netprofit_percent(){return this._netprofit/this.initial_capital*100}get openprofit_percent(){return this._openprofit/(this.initial_capital+this._netprofit)*100}get position_avg_price(){return this._position_avg_price}get position_entry_name(){if(this._orders.length)return this._orders[0].id}get position_size(){return this._position_size}get summaryData(){return{position_size:this.position_size,position_avg_price:this.position_avg_price,position_entry_name:this.position_entry_name,openprofit_percent:this.openprofit_percent,netprofit_percent:this.netprofit_percent,max_drawdown_percent:this.max_drawdown_percent,max_runup_percent:this.max_runup_percent,max_drawdown:this.max_drawdown,max_runup:this.max_runup,max_contracts_held_long:this.max_contracts_held_long,max_contracts_held_short:this.max_contracts_held_short,max_contracts_held_all:this.max_contracts_held_all,avg_winning_trade_percent:this.avg_winning_trade_percent,avg_winning_trade:this.avg_winning_trade,avg_trade_percent:this.avg_trade_percent,avg_trade:this.avg_trade,avg_losing_trade:this.avg_losing_trade,avg_losing_trade_percent:this.avg_losing_trade_percent,wintrades:this.wintrades,losstrades:this.losstrades,eventrades:this.eventrades,grossprofit:this.grossprofit,grossprofit_percent:this.grossprofit_percent,grossloss:this.grossloss,grossloss_percent:this.grossloss_percent,openprofit:this.openprofit,initial_capital:this.initial_capital,netprofit:this.netprofit,closedtrades:this.closedtrades,opentrades:this.opentrades,equity:this.equity,margin_call_long:this.marginCallLong,margin_call_short:this.marginCallShort}}_getCommission(t,e){if(!this._options)return 0;const{commission_value:r=0,commission_type:n}=this._options,i=t*e;let a=0;switch(n){case nr.percent:a=i*r/100;break;case nr.cashPerContract:a=e*r;break;case nr.cashPerOrder:a=r;break}return a}}class _w{constructor(t){$(this,"_preAccdist");$(this,"_preNvi");$(this,"_prePvi");$(this,"_preObv");$(this,"_prePvt");$(this,"_preWad");$(this,"_preVwap");$(this,"_preValue");$(this,"_currentData");$(this,"_preData");$(this,"_id");this._preAccdist=0,this._preNvi=0,this._prePvi=0,this._preObv=0,this._prePvt=0,this._preWad=0,this._preVwap={},this._preValue={},this._currentData={},this._preData={},this._id=t}update(t){this._preValue={},t.barIndex!==this._currentData.barIndex&&(this._preData={...this._currentData}),this._currentData={...t}}get isRealTime(){return this._preData.barIndex===this._currentData.barIndex}get accdist(){if(this._preValue.accdist)return this._preValue.accdist;const{close:t,low:e,high:r,volume:n}=this._currentData;if(r===e)return this._preAccdist;const i=(t-e-(r-t))/(r-e)*n+this._preAccdist;return!this.isRealTime&&(this._preAccdist=i),this._preValue.accdist=i,i}get iii(){if(this._preValue.iii)return this._preValue.iii;const{close:t,low:e,high:r,volume:n}=this._currentData,i=(2*t-r-e)/((r-e)*n);return this._preValue.iii=i,i}get nvi(){return this._preValue.nvi?this._preValue.nvi:this._getNvi()}get wvad(){if(this._preValue.wvad)return this._preValue.wvad;const{close:t,low:e,high:r,volume:n,open:i}=this._currentData,a=(t-i)/(r-e)*n;return this._preValue.wvad=a,a}get obv(){if(this._preValue.obv)return this._preValue.obv;const{close:t,volume:e}=this._currentData,{close:r}=this._preData;if(r===void 0){this._preObv=0;return}const n=Math.sign(t-r)*e+this._preObv;return!this.isRealTime&&(this._preObv=n),this._preValue.obv=n,n}get pvi(){return this._preValue.pvi?this._preValue.pvi:this._getPvi()}get tr(){if(this._preValue.tr)return this._preValue.tr;const{low:t,high:e}=this._currentData,{close:r}=this._preData;if(r===void 0)return;const n=Math.max(e-t,Math.abs(e-r),Math.abs(t-r));return this._preValue.tr=n,n}get pvt(){if(this._preValue.pvt)return this._preValue.pvt;const{close:t,volume:e}=this._currentData,{close:r}=this._preData;if(r===void 0){this._prePvt=0;return}const n=(t-r)/r*e+this._prePvt;return!this.isRealTime&&(this._prePvt=n),this._preValue.pvt=n,n}get wad(){if(this._preValue.wad)return this._preValue.wad;const{close:t,high:e,low:r}=this._currentData,{close:n}=this._preData;if(n===void 0)return this._preWad=0,0;const i=Math.max(e,n),a=Math.min(r,n),l=t-n,p=(l>0?t-a:l<0?t-i:0)+this._preWad;return!this.isRealTime&&(this._preWad=p),this._preValue.wad=p,p}get vwap(){var h,f;if(this._preValue.vwap)return this._preValue.vwap;const{hlc3:t,volume:e}=this._currentData;let{sum:r=0,sumV:n=0,isReset:i}=this._preVwap;if(((f=(h=self.workerStorage)==null?void 0:h.get(this._id))==null?void 0:f.buildInFunctions.timeframe.change({timeframe:"1D"},"vwap_buildin"))&&(i=!0,r=n=0),!i)return;const l=t*e+r,c=e+n;!this.isRealTime&&(this._preVwap={sum:l,sumV:c,isReset:i});const p=l/c;return this._preValue.vwap=p,p}_getNvi(){const t=this._preNvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:i}=this._currentData;let a=1;const l=t||1;return n&&e?a=i<r?l+(n-e)/e*l:l:a=l,!this.isRealTime&&(this._preNvi=a),this._preValue.nvi=a,a}_getPvi(){const t=this._prePvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:i}=this._currentData;let a=1;const l=t||1;return n&&e?a=i>r?l+(n-e)/e*l:l:a=l,!this.isRealTime&&(this._prePvi=a),this._preValue.pvi=a,a}}class mw{constructor(){$(this,"_period");$(this,"_multiplier");$(this,"_unit");this._period="1",this._multiplier=1,this._unit="m"}update(t){if(!t)return;this._period=t;const[e,r]=ys(t);this._multiplier=e,this._unit=r}get isdaily(){return this._unit==="d"}get isdwm(){return["d","w","M"].includes(this._unit)}get isintraday(){return["s","m","h"].includes(this._unit)}get isminutes(){return this._unit==="m"}get ismonthly(){return this._unit==="M"}get isseconds(){return this._unit==="s"}get isweekly(){return this._unit==="w"}get multiplier(){return this._multiplier}get period(){return this._period}}class gw{constructor(t){$(this,"_variables");$(this,"_bgColor");$(this,"_fgColor");$(this,"isUseBgColor",!1);this._variables=t}updateOptions(t){t!=null&&t.bg_color&&(this._bgColor=t.bg_color,this._fgColor=this._contrastColor(t.bg_color))}get bg_color(){return this.isUseBgColor=!0,this._bgColor}get fg_color(){return this.isUseBgColor=!0,this._fgColor}get is_heikinashi(){return!1}get is_kagi(){return!1}get is_linebreak(){return!1}get is_pnf(){return!1}get is_range(){return!1}get is_renko(){return!1}get is_standard(){return!0}get left_visible_bar_time(){return this._variables.time}get right_visible_bar_time(){return this._variables.time}_parseColor(t){let e,r,n,i;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const a=t.substring(7);a?i=parseInt(a,16)/255:i=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,i=a[3]||1}return{r:e,g:r,b:n,a:i}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}_contrastColor(t){const{r:e,g:r,b:n}=this._parseColor(t);return(299*e+587*r+114*n)/1e3>128?"#000000":"#ffffff"}}class vw{constructor(t){$(this,"_variables");this._variables=t}get basecurrency(){return""}get country(){}get currency(){return"CNY"}get description(){return""}get employees(){return 100}get expiration_date(){}get industry(){}get minmove(){}get mintick(){return this._variables.mintick}get pointvalue(){}get prefix(){}get pricescale(){}get recommendations_buy(){}get recommendations_buy_strong(){}get recommendations_date(){}get recommendations_hold(){}get recommendations_sell(){}get recommendations_sell_strong(){}get recommendations_total(){}get root(){return""}get sector(){}get session(){return fi.regular}get shareholders(){}get shares_outstanding_float(){}get shares_outstanding_total(){}get target_price_average(){}get target_price_date(){}get target_price_estimates(){}get target_price_high(){}get target_price_low(){}get target_price_median(){}get ticker(){return""}get tickerid(){return""}get timezone(){}get type(){}get volumetype(){return"n/a"}}class yw{constructor(t){$(this,"_variables");this._variables=t}get future_amount(){}get future_ex_date(){}get future_pay_date(){}}class ww{constructor(t){$(this,"_variables");this._variables=t}get future_eps(){}get future_period_end_time(){}get future_revenue(){}get future_time(){}}ee.extend(Wp),ee.extend(Sl),ee.extend(kp);class oh{constructor(t){$(this,"_cacheData");$(this,"_barIndex");$(this,"_isRealTimeBar");$(this,"_barstate");$(this,"_priceVariables");$(this,"_lastBarIndex");$(this,"_currentBarTime");$(this,"_lastBarTime");$(this,"_period");$(this,"_offsetTime");$(this,"_timeframe");$(this,"_ta");$(this,"_polyline");$(this,"_label");$(this,"_line");$(this,"_linefill");$(this,"_box");$(this,"_table");$(this,"_strategy");$(this,"_session");$(this,"syminfo");$(this,"chart");$(this,"earnings");$(this,"dividends");$(this,"_timeTradingday");$(this,"_mintick");$(this,"_cacheSpace");this._cacheData={varData:{},varNewData:{},varipData:{}},this._barIndex=0,this._lastBarIndex=0,this._currentBarTime=0,this._lastBarTime=0,this._offsetTime=0,this._period="",this._isRealTimeBar=!1,this._barstate=new hw,this._timeframe=new mw,this._priceVariables={close:0,open:0,low:0,high:0,volume:0},this._ta=new _w(t),this._polyline=new Fi,this._label=new Fi,this._line=new Fi,this._linefill=new Fi,this._box=new Fi,this._table=new Fi(1),this._strategy=new dw(this),this._session=new pw(this),this.syminfo=new vw(this),this.chart=new gw(this),this.earnings=new ww(this),this.dividends=new yw(this),this._cacheSpace=new Map}get table(){return this._table}get box(){return this._box}get linefill(){return this._linefill}get line(){return this._line}get polyline(){return this._polyline}get label(){return this._label}get ta(){return this._ta}get strategy(){return this._strategy}get session(){return this._session}get na(){}get last_bar_index(){return this._lastBarIndex}get bar_index(){return this._barIndex}get barstate(){return this._barstate}get close(){return this._priceVariables.close}get low(){return this._priceVariables.low}get open(){return this._priceVariables.open}get high(){return this._priceVariables.high}get volume(){return this._priceVariables.volume}get ohlc4(){const{close:t,open:e,high:r,low:n}=this._priceVariables;return(t+e+r+n)/4}get hl2(){const{high:t,low:e}=this._priceVariables;return(t+e)/2}get hlc3(){const{close:t,high:e,low:r}=this._priceVariables;return(t+e+r)/3}get hlcc4(){const{close:t,high:e,low:r}=this._priceVariables;return(t*2+e+r)/4}get hour(){return ee(this._currentBarTime).subtract(this._offsetTime,"hour").hour()}get minute(){return ee(this._currentBarTime).minute()}get second(){return ee(this._currentBarTime).second()}get month(){return ee(this._currentBarTime).month()+1}get year(){return ee(this._currentBarTime).year()}get dayofweek(){return ee(this._currentBarTime).day()+1}get dayofmonth(){return ee(this._currentBarTime).date()}get weekofyear(){return ee(this._currentBarTime).week()}get last_bar_time(){return this._lastBarTime}get time(){return this._currentBarTime}get time_close(){const[t,e]=ys(this._period);return this._isRealTimeBar?void 0:ee(this._currentBarTime).add(t,e).valueOf()}get timenow(){return Date.now()}get time_tradingday(){return this._timeTradingday||this.getTimeTradingday(this._currentBarTime,this._period)}get timeframe(){return this._timeframe}get mintick(){return this._mintick}get __period(){return this._period}updateMaxLength(t){const{max_lines_count:e,max_labels_count:r,max_boxes_count:n,max_polylines_count:i}=t;n&&this._box.setMaxLen(n),r&&this._label.setMaxLen(r),e&&this._line.setMaxLen(e),i&&this._polyline.setMaxLen(i)}getTimeTradingday(t,e){const[r,n]=ys(e),i=ee(t);return["M","w","y","d"].includes(n)?i.valueOf():(i.subtract(this._offsetTime,"h"),i.startOf("d").add(this._offsetTime,"h").valueOf())}updateOptions(t){const{interval:e="1D",offsetTime:r=5,mintick:n,chart:i}=t;this._period=e,this._mintick=n,this._offsetTime=r,this._timeframe.update(e),this.chart.updateOptions(i)}updateData(t){const{barIndex:e,c:r,o:n,h:i,l:a,volume:l,time:c,lastBarIndex:p,lastBarTime:h,complete:f,time_tradingday:d}=t;this._priceVariables={close:Number(r),open:Number(n),high:Number(i),low:Number(a),volume:Number(l)},this._isRealTimeBar=f,e>this._barIndex&&this._isRealTimeBar&&(this._cacheData.varData=this._cacheData.varNewData,this._cacheData.varNewData={}),this._timeTradingday=d,this._currentBarTime=c*1e3,this._lastBarIndex=p,this._barIndex=e,this._lastBarTime=h*1e3,this._barstate.update(e,p,f,!1),this.ta.update({...this._priceVariables,hlc3:this.hlc3,barIndex:e})}getCacheData(t,e,r){const n=this.setCacheData(t,r);return(this._cacheSpace.get(t)||0)<e&&this._cacheSpace.set(t,e),n[n.length-1-e]}setCacheData(t,e){let r=this._cacheData[t]||{barIndex:-1,data:[]};if(r.barIndex>this._barIndex)return r.data;r.barIndex===this._barIndex?r.data[r.data.length-1]=e:r.data.push(e);const n=this._cacheSpace.get(t);return n&&r.data.length>n+5&&r.data.shift(),r.barIndex=this._barIndex,this._cacheData[t]=r,r.data}getTypeInstance(t,e){return new Rp(t,e)}verifyVarAndVarip(t,e,r){const n=`${t}_${e}`;return r==="var"&&this._cacheData.varData.hasOwnProperty(n)?(this._upadteChartDraws(this._cacheData.varData[n]),!0):r==="varip"&&this._cacheData.varipData.hasOwnProperty(n)?(this._upadteChartDraws(this._cacheData.varipData[n]),!0):!1}getVarValue(t,e,r){const n=`${t}_${e}`;return r==="var"?this._cacheData.varData[n]:this._cacheData.varipData[n]}setVarValue(t,e,r,n){var l;const i=`${t}_${e}`;let a;switch(typeof r=="object"&&((l=r==null?void 0:r.varipKeys)!=null&&l.length)&&(n="var",a=r.varipKeys),this._chartDrawsHandle(r,this._cacheData.varData[i]||this._cacheData.varipData[i]),n){case"var":if(this._isRealTimeBar){if(this._cacheData.varNewData[i]=r,a&&a.length)for(const c of a)this._cacheData.varData[i][c]=r[c]}else this._cacheData.varData[i]=r;break;case"varip":this._cacheData.varipData[i]=r;break}return r}_upadteChartDraws(t){const e=t==null?void 0:t.id;if(e)switch(t==null?void 0:t.type){case Fe.BOX:this._setChartDraw(e,this._box);break;case Fe.LINE:this._setChartDraw(e,this._line);break;case Fe.POLYLINE:this._setChartDraw(e,this._polyline);break;case Fe.LABEL:this._setChartDraw(e,this._label);break;case Fe.LINEFILL:this._setChartDraw(e,this._linefill);break;case Fe.TABLE:this._setChartDraw(e,this._table);break}}_setChartDraw(t,e){const r=e.getInstance(t),n=e.get(t);e.delete(t),e.set(t,n,r)}_chartDrawsHandle(t,e){const r=e==null?void 0:e.id;let n=t==null?void 0:t.id;r!==n&&(n&&t.data&&(t.data.isVar=!0),r&&e.data&&(e.data.isVar=!1))}add(t,e){return Array.isArray(t)&&Array.isArray(e)?Xr.uniq([...t,...e]):typeof t=="number"||typeof e=="number"?Number(t)+Number(e):t+e}sub(t,e){return Array.isArray(t)&&Array.isArray(e)?t.filter(r=>!e.includes(r)):Number(t)-Number(e)}againAssignParse(t,e){var n;if(e)return;const r=(n=t==null?void 0:t.constructor)==null?void 0:n.name;if(r)switch(r){case ao.name:case th.name:case co.name:case eh.name:case uo.name:case lo.name:t==null||t.delete();break}}}class Fi{constructor(t=50){$(this,"_all");$(this,"_allInstance");$(this,"_pseudoArrayAll");$(this,"_maxLength");this._all=new Map,this._allInstance=new Map,this._pseudoArrayAll=new Qt,this._maxLength=t}setMaxLen(t){this._maxLength=t}get data(){return[...this._all.values()].slice(-this._maxLength)}get all(){return this._pseudoArrayAll._value=[...this._allInstance.values()],this._pseudoArrayAll}add(t,e,r){if(this.set(t,e,r),this._all.size>this._maxLength){const{bar_index:n}=e;for(const[i,a]of this._all){const{isVar:l,id:c,bar_index:p}=a;if(p===n)break;if(l)continue;this.delete(c);break}}}getValOfBarIndex(t){let e=[];const r=[...this._all.keys()];for(const n of t){const i=r.filter(a=>a.endsWith(`_${n}`));for(const a of i){const l=this._all.get(a);l&&e.push(l)}}return e.length?e:void 0}set(t,e,r){this._all.set(t,e),this._allInstance.set(t,r)}get(t){return this._all.get(t)}getInstance(t){return this._allInstance.get(t)}delete(t){this._all.delete(t),this._allInstance.delete(t)}}/**
|
66
66
|
* @license
|
67
67
|
* Copyright 2019 Google LLC
|
68
68
|
* SPDX-License-Identifier: Apache-2.0
|
69
|
-
*/const ah=Symbol("Comlink.proxy"),Dw=Symbol("Comlink.endpoint"),bw=Symbol("Comlink.releaseProxy"),Ua=Symbol("Comlink.finalizer"),fo=Symbol("Comlink.thrown"),uh=s=>typeof s=="object"&&s!==null||typeof s=="function",xw={canHandle:s=>uh(s)&&s[ah],serialize(s){const{port1:t,port2:e}=new MessageChannel;return Wa(s,t),[e,[e]]},deserialize(s){return s.start(),Fw(s)}},Ew={canHandle:s=>uh(s)&&fo in s,serialize({value:s}){let t;return s instanceof Error?t={isError:!0,value:{message:s.message,name:s.name,stack:s.stack}}:t={isError:!1,value:s},[t,[]]},deserialize(s){throw s.isError?Object.assign(new Error(s.value.message),s.value):s.value}},lh=new Map([["proxy",xw],["throw",Ew]]);function Aw(s,t){for(const e of s)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function Wa(s,t=globalThis,e=["*"]){t.addEventListener("message",function r(n){if(!n||!n.data)return;if(!Aw(e,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:i,type:a,path:l}=Object.assign({path:[]},n.data),c=(n.data.argumentList||[]).map(Qn);let p;try{const h=l.slice(0,-1).reduce((d,g)=>d[g],s),f=l.reduce((d,g)=>d[g],s);switch(a){case"GET":p=f;break;case"SET":h[l.slice(-1)[0]]=Qn(n.data.value),p=!0;break;case"APPLY":p=f.apply(h,c);break;case"CONSTRUCT":{const d=new f(...c);p=Ow(d)}break;case"ENDPOINT":{const{port1:d,port2:g}=new MessageChannel;Wa(s,g),p=Bw(d,[d])}break;case"RELEASE":p=void 0;break;default:return}}catch(h){p={value:h,[fo]:0}}Promise.resolve(p).catch(h=>({value:h,[fo]:0})).then(h=>{const[f,d]=mo(h);t.postMessage(Object.assign(Object.assign({},f),{id:i}),d),a==="RELEASE"&&(t.removeEventListener("message",r),ch(t),Ua in s&&typeof s[Ua]=="function"&&s[Ua]())}).catch(h=>{const[f,d]=mo({value:new TypeError("Unserializable return value"),[fo]:0});t.postMessage(Object.assign(Object.assign({},f),{id:i}),d)})}),t.start&&t.start()}function Cw(s){return s.constructor.name==="MessagePort"}function ch(s){Cw(s)&&s.close()}function Fw(s,t){return ja(s,[],t)}function ho(s){if(s)throw new Error("Proxy has been released and is not useable")}function fh(s){return Mi(s,{type:"RELEASE"}).then(()=>{ch(s)})}const po=new WeakMap,_o="FinalizationRegistry"in globalThis&&new FinalizationRegistry(s=>{const t=(po.get(s)||0)-1;po.set(s,t),t===0&&fh(s)});function Mw(s,t){const e=(po.get(t)||0)+1;po.set(t,e),_o&&_o.register(s,t,s)}function Nw(s){_o&&_o.unregister(s)}function ja(s,t=[],e=function(){}){let r=!1;const n=new Proxy(e,{get(i,a){if(ho(r),a===bw)return()=>{Nw(n),fh(s),r=!0};if(a==="then"){if(t.length===0)return{then:()=>n};const l=Mi(s,{type:"GET",path:t.map(c=>c.toString())}).then(Qn);return l.then.bind(l)}return ja(s,[...t,a])},set(i,a,l){ho(r);const[c,p]=mo(l);return Mi(s,{type:"SET",path:[...t,a].map(h=>h.toString()),value:c},p).then(Qn)},apply(i,a,l){ho(r);const c=t[t.length-1];if(c===Dw)return Mi(s,{type:"ENDPOINT"}).then(Qn);if(c==="bind")return ja(s,t.slice(0,-1));const[p,h]=hh(l);return Mi(s,{type:"APPLY",path:t.map(f=>f.toString()),argumentList:p},h).then(Qn)},construct(i,a){ho(r);const[l,c]=hh(a);return Mi(s,{type:"CONSTRUCT",path:t.map(p=>p.toString()),argumentList:l},c).then(Qn)}});return Mw(n,s),n}function Sw(s){return Array.prototype.concat.apply([],s)}function hh(s){const t=s.map(mo);return[t.map(e=>e[0]),Sw(t.map(e=>e[1]))]}const ph=new WeakMap;function Bw(s,t){return ph.set(s,t),s}function Ow(s){return Object.assign(s,{[ah]:!0})}function mo(s){for(const[t,e]of lh)if(e.canHandle(s)){const[r,n]=e.serialize(s);return[{type:"HANDLER",name:t,value:r},n]}return[{type:"RAW",value:s},ph.get(s)||[]]}function Qn(s){switch(s.type){case"HANDLER":return lh.get(s.name).deserialize(s.value);case"RAW":return s.value}}function Mi(s,t,e){return new Promise(r=>{const n=Iw();s.addEventListener("message",function i(a){!a.data||!a.data.id||a.data.id!==n||(s.removeEventListener("message",i),r(a.data))}),s.start&&s.start(),s.postMessage(Object.assign({id:n},t),e)})}function Iw(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}class Tw{constructor(){$(this,"_cache");this._cache=new Map}set(t,e){this._cache.set(t,e)}setValue(t,e,r){const n=this._cache.get(t)||{};n[e]=r,this._cache.set(t,n)}updateValue(t,e,r){const n=this._cache.get(t)||{};this._cache.set(t,Object.assign(n[e]||{},r))}get(t){return this._cache.get(t)}has(t){return this._cache.has(t)}deleteStartwidthKey(t){for(const e of this._cache.keys())e.startsWith(t)&&this._cache.delete(e)}delete(t){this._cache.delete(t)}clear(){this._cache.clear()}}function $w(s,t,e){var x;const{data:r,isPreParser:n,id:i="default",syminfo:a,interval:l,inputs:c,chart:p,strategy:h}=t;self.workerStorage||(self.workerStorage=new Tw);let{builtInGather:f,buildinConstants:d,buildInFunctions:g,tradingvueFunc:y}=self.workerStorage.get(i)||{},m=[];e&&(f=new oh(i),d=new Qf,g=new sh((a==null?void 0:a.mintick)||1e-5,f,i),y=new Function("$_var","$_const","$_func",s),self.workerStorage.set(i,{builtInGather:f,buildinConstants:d,buildInFunctions:g,tradingvueFunc:y}),self.workerStorage.set(`request_${i}`,new Map),self.workerStorage.set(`request_${i}_data`,new Map),self.workerStorage.set(`request_${i}_list`,new Map));let w=[];if(n)y(f,d,g);else if(r&&r.length){const b=r.length-1;f.updateOptions({interval:l,mintick:(a==null?void 0:a.mintick)||1e-5,chart:p}),g.updateOptions({inputs:c,strategy:h});try{for(const[N,E]of r.entries()){const{barindex:A}=E;!e&&(A||A===0)&&(m.push(A),f.clearDrawCache(A)),f.updateData(Object.assign(E,{barIndex:A||N,lastBarIndex:r[b].
|
69
|
+
*/const ah=Symbol("Comlink.proxy"),Dw=Symbol("Comlink.endpoint"),bw=Symbol("Comlink.releaseProxy"),Ua=Symbol("Comlink.finalizer"),fo=Symbol("Comlink.thrown"),uh=s=>typeof s=="object"&&s!==null||typeof s=="function",xw={canHandle:s=>uh(s)&&s[ah],serialize(s){const{port1:t,port2:e}=new MessageChannel;return Wa(s,t),[e,[e]]},deserialize(s){return s.start(),Fw(s)}},Ew={canHandle:s=>uh(s)&&fo in s,serialize({value:s}){let t;return s instanceof Error?t={isError:!0,value:{message:s.message,name:s.name,stack:s.stack}}:t={isError:!1,value:s},[t,[]]},deserialize(s){throw s.isError?Object.assign(new Error(s.value.message),s.value):s.value}},lh=new Map([["proxy",xw],["throw",Ew]]);function Aw(s,t){for(const e of s)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function Wa(s,t=globalThis,e=["*"]){t.addEventListener("message",function r(n){if(!n||!n.data)return;if(!Aw(e,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:i,type:a,path:l}=Object.assign({path:[]},n.data),c=(n.data.argumentList||[]).map(Qn);let p;try{const h=l.slice(0,-1).reduce((d,g)=>d[g],s),f=l.reduce((d,g)=>d[g],s);switch(a){case"GET":p=f;break;case"SET":h[l.slice(-1)[0]]=Qn(n.data.value),p=!0;break;case"APPLY":p=f.apply(h,c);break;case"CONSTRUCT":{const d=new f(...c);p=Ow(d)}break;case"ENDPOINT":{const{port1:d,port2:g}=new MessageChannel;Wa(s,g),p=Bw(d,[d])}break;case"RELEASE":p=void 0;break;default:return}}catch(h){p={value:h,[fo]:0}}Promise.resolve(p).catch(h=>({value:h,[fo]:0})).then(h=>{const[f,d]=mo(h);t.postMessage(Object.assign(Object.assign({},f),{id:i}),d),a==="RELEASE"&&(t.removeEventListener("message",r),ch(t),Ua in s&&typeof s[Ua]=="function"&&s[Ua]())}).catch(h=>{const[f,d]=mo({value:new TypeError("Unserializable return value"),[fo]:0});t.postMessage(Object.assign(Object.assign({},f),{id:i}),d)})}),t.start&&t.start()}function Cw(s){return s.constructor.name==="MessagePort"}function ch(s){Cw(s)&&s.close()}function Fw(s,t){return ja(s,[],t)}function ho(s){if(s)throw new Error("Proxy has been released and is not useable")}function fh(s){return Mi(s,{type:"RELEASE"}).then(()=>{ch(s)})}const po=new WeakMap,_o="FinalizationRegistry"in globalThis&&new FinalizationRegistry(s=>{const t=(po.get(s)||0)-1;po.set(s,t),t===0&&fh(s)});function Mw(s,t){const e=(po.get(t)||0)+1;po.set(t,e),_o&&_o.register(s,t,s)}function Nw(s){_o&&_o.unregister(s)}function ja(s,t=[],e=function(){}){let r=!1;const n=new Proxy(e,{get(i,a){if(ho(r),a===bw)return()=>{Nw(n),fh(s),r=!0};if(a==="then"){if(t.length===0)return{then:()=>n};const l=Mi(s,{type:"GET",path:t.map(c=>c.toString())}).then(Qn);return l.then.bind(l)}return ja(s,[...t,a])},set(i,a,l){ho(r);const[c,p]=mo(l);return Mi(s,{type:"SET",path:[...t,a].map(h=>h.toString()),value:c},p).then(Qn)},apply(i,a,l){ho(r);const c=t[t.length-1];if(c===Dw)return Mi(s,{type:"ENDPOINT"}).then(Qn);if(c==="bind")return ja(s,t.slice(0,-1));const[p,h]=hh(l);return Mi(s,{type:"APPLY",path:t.map(f=>f.toString()),argumentList:p},h).then(Qn)},construct(i,a){ho(r);const[l,c]=hh(a);return Mi(s,{type:"CONSTRUCT",path:t.map(p=>p.toString()),argumentList:l},c).then(Qn)}});return Mw(n,s),n}function Sw(s){return Array.prototype.concat.apply([],s)}function hh(s){const t=s.map(mo);return[t.map(e=>e[0]),Sw(t.map(e=>e[1]))]}const ph=new WeakMap;function Bw(s,t){return ph.set(s,t),s}function Ow(s){return Object.assign(s,{[ah]:!0})}function mo(s){for(const[t,e]of lh)if(e.canHandle(s)){const[r,n]=e.serialize(s);return[{type:"HANDLER",name:t,value:r},n]}return[{type:"RAW",value:s},ph.get(s)||[]]}function Qn(s){switch(s.type){case"HANDLER":return lh.get(s.name).deserialize(s.value);case"RAW":return s.value}}function Mi(s,t,e){return new Promise(r=>{const n=Iw();s.addEventListener("message",function i(a){!a.data||!a.data.id||a.data.id!==n||(s.removeEventListener("message",i),r(a.data))}),s.start&&s.start(),s.postMessage(Object.assign({id:n},t),e)})}function Iw(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}class Tw{constructor(){$(this,"_cache");this._cache=new Map}set(t,e){this._cache.set(t,e)}setValue(t,e,r){const n=this._cache.get(t)||{};n[e]=r,this._cache.set(t,n)}updateValue(t,e,r){const n=this._cache.get(t)||{};this._cache.set(t,Object.assign(n[e]||{},r))}get(t){return this._cache.get(t)}has(t){return this._cache.has(t)}deleteStartwidthKey(t){for(const e of this._cache.keys())e.startsWith(t)&&this._cache.delete(e)}delete(t){this._cache.delete(t)}clear(){this._cache.clear()}}function $w(s,t,e){var x;const{data:r,isPreParser:n,id:i="default",syminfo:a,interval:l,inputs:c,chart:p,strategy:h}=t;self.workerStorage||(self.workerStorage=new Tw);let{builtInGather:f,buildinConstants:d,buildInFunctions:g,tradingvueFunc:y}=self.workerStorage.get(i)||{},m=[];e&&(f=new oh(i),d=new Qf,g=new sh((a==null?void 0:a.mintick)||1e-5,f,i),y=new Function("$_var","$_const","$_func",s),self.workerStorage.set(i,{builtInGather:f,buildinConstants:d,buildInFunctions:g,tradingvueFunc:y}),self.workerStorage.set(`request_${i}`,new Map),self.workerStorage.set(`request_${i}_data`,new Map),self.workerStorage.set(`request_${i}_list`,new Map));let w=[];if(n)y(f,d,g);else if(r&&r.length){const b=r.length-1;f.updateOptions({interval:l,mintick:(a==null?void 0:a.mintick)||1e-5,chart:p}),g.updateOptions({inputs:c,strategy:h});try{for(const[N,E]of r.entries()){const{barindex:A}=E;!e&&(A||A===0)&&(m.push(A),f.clearDrawCache(A)),f.updateData(Object.assign(E,{barIndex:A||N,lastBarIndex:r[b].barindex||b,lastBarTime:r[b].time})),g.update({barIndex:A||N}),y(f,d,g),g.endExecution();const M=g.errors;if(M.length&&M.some(S=>S.type===zt.Error))return{status:1,errors:M}}w=[...((x=self.workerStorage.get(`request_${i}_list`))==null?void 0:x.values())||[]],w.length&&self.workerStorage.delete(`request_${i}_list`)}catch(N){return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:N==null?void 0:N.message,type:zt.Error}]}}}const v=g.errors;return v.length&&v.some(b=>b.type===zt.Error)?{status:1,errors:v}:{status:0,requestList:w,errors:v,options:{...g.options(m),id:i}}}function Lw(s){self==null||self.workerStorage.deleteStartwidthKey(s),self==null||self.workerStorage.delete(`inputs_${s}`),self==null||self.workerStorage.delete(`strategy_${s}`),self==null||self.workerStorage.delete(`request_${s}`),self==null||self.workerStorage.delete(`request_${s}_data`),self==null||self.workerStorage.delete(`request_${s}_list`)}Wa({runScript:$w,removeScript:Lw})})();
|
@@ -34,8 +34,8 @@ export declare class Syminfo {
|
|
34
34
|
get target_price_high(): void;
|
35
35
|
get target_price_low(): void;
|
36
36
|
get target_price_median(): void;
|
37
|
-
get ticker():
|
38
|
-
get tickerid():
|
37
|
+
get ticker(): string;
|
38
|
+
get tickerid(): string;
|
39
39
|
get timezone(): void;
|
40
40
|
get type(): void;
|
41
41
|
get volumetype(): string;
|
@@ -67593,14 +67593,14 @@ function ir(a, n, r) {
|
|
67593
67593
|
function oh() {
|
67594
67594
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
67595
67595
|
}
|
67596
|
-
const Fp = new Worker(new URL("" + new URL("assets/scriptsRunWorker-
|
67596
|
+
const Fp = new Worker(new URL("" + new URL("assets/scriptsRunWorker-BD3Df3Mn.js", import.meta.url).href, import.meta.url), { type: "module", name: "Run TccScript Server" });
|
67597
67597
|
Fp.onerror = (a) => {
|
67598
67598
|
console.error(a);
|
67599
67599
|
};
|
67600
67600
|
async function Rp(a) {
|
67601
67601
|
return await Ja.setInlayHints(a);
|
67602
67602
|
}
|
67603
|
-
const Bp = ji(Fp), Kp = ji(new Worker(new URL("" + new URL("assets/parserTccWorker-
|
67603
|
+
const Bp = ji(Fp), Kp = ji(new Worker(new URL("" + new URL("assets/parserTccWorker-BRdbggcL.js", import.meta.url).href, import.meta.url), { type: "module", name: "Parser TccScript Server" }));
|
67604
67604
|
async function lh(a, n = !1) {
|
67605
67605
|
const { functions: r, types: o, constants: c, variables: l, methods: m } = ht;
|
67606
67606
|
return await Kp.parseTcc(a, n, Hi(Rp), { functions: Object.fromEntries(r), methods: Object.fromEntries(m), types: Object.fromEntries(o), constants: Object.fromEntries(c), variables: Object.fromEntries(l) });
|
@@ -141,7 +141,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
141
141
|
* @license
|
142
142
|
* Copyright 2019 Google LLC
|
143
143
|
* SPDX-License-Identifier: Apache-2.0
|
144
|
-
*/const _o=Symbol("Comlink.proxy"),sm=Symbol("Comlink.endpoint"),am=Symbol("Comlink.releaseProxy"),yn=Symbol("Comlink.finalizer"),Ys=Symbol("Comlink.thrown"),fo=a=>typeof a=="object"&&a!==null||typeof a=="function",nm={canHandle:a=>fo(a)&&a[_o],serialize(a){const{port1:n,port2:s}=new MessageChannel;return bo(a,n),[s,[s]]},deserialize(a){return a.start(),_n(a)}},im={canHandle:a=>fo(a)&&Ys in a,serialize({value:a}){let n;return a instanceof Error?n={isError:!0,value:{message:a.message,name:a.name,stack:a.stack}}:n={isError:!1,value:a},[n,[]]},deserialize(a){throw a.isError?Object.assign(new Error(a.value.message),a.value):a.value}},go=new Map([["proxy",nm],["throw",im]]);function om(a,n){for(const s of a)if(n===s||s==="*"||s instanceof RegExp&&s.test(n))return!0;return!1}function bo(a,n=globalThis,s=["*"]){n.addEventListener("message",function o(c){if(!c||!c.data)return;if(!om(s,c.origin)){console.warn(`Invalid origin '${c.origin}' for comlink proxy`);return}const{id:l,type:m,path:y}=Object.assign({path:[]},c.data),f=(c.data.argumentList||[]).map(xr);let b;try{const h=y.slice(0,-1).reduce((N,F)=>N[F],a),T=y.reduce((N,F)=>N[F],a);switch(m){case"GET":b=T;break;case"SET":h[y.slice(-1)[0]]=xr(c.data.value),b=!0;break;case"APPLY":b=T.apply(h,f);break;case"CONSTRUCT":{const N=new T(...f);b=gn(N)}break;case"ENDPOINT":{const{port1:N,port2:F}=new MessageChannel;bo(a,F),b=mm(N,[N])}break;case"RELEASE":b=void 0;break;default:return}}catch(h){b={value:h,[Ys]:0}}Promise.resolve(b).catch(h=>({value:h,[Ys]:0})).then(h=>{const[T,N]=ea(h);n.postMessage(Object.assign(Object.assign({},T),{id:l}),N),m==="RELEASE"&&(n.removeEventListener("message",o),xo(n),yn in a&&typeof a[yn]=="function"&&a[yn]())}).catch(h=>{const[T,N]=ea({value:new TypeError("Unserializable return value"),[Ys]:0});n.postMessage(Object.assign(Object.assign({},T),{id:l}),N)})}),n.start&&n.start()}function lm(a){return a.constructor.name==="MessagePort"}function xo(a){lm(a)&&a.close()}function _n(a,n){return fn(a,[],n)}function Qs(a){if(a)throw new Error("Proxy has been released and is not useable")}function ho(a){return Mr(a,{type:"RELEASE"}).then(()=>{xo(a)})}const Zs=new WeakMap,Js="FinalizationRegistry"in globalThis&&new FinalizationRegistry(a=>{const n=(Zs.get(a)||0)-1;Zs.set(a,n),n===0&&ho(a)});function cm(a,n){const s=(Zs.get(n)||0)+1;Zs.set(n,s),Js&&Js.register(a,n,a)}function pm(a){Js&&Js.unregister(a)}function fn(a,n=[],s=function(){}){let o=!1;const c=new Proxy(s,{get(l,m){if(Qs(o),m===am)return()=>{pm(c),ho(a),o=!0};if(m==="then"){if(n.length===0)return{then:()=>c};const y=Mr(a,{type:"GET",path:n.map(f=>f.toString())}).then(xr);return y.then.bind(y)}return fn(a,[...n,m])},set(l,m,y){Qs(o);const[f,b]=ea(y);return Mr(a,{type:"SET",path:[...n,m].map(h=>h.toString()),value:f},b).then(xr)},apply(l,m,y){Qs(o);const f=n[n.length-1];if(f===sm)return Mr(a,{type:"ENDPOINT"}).then(xr);if(f==="bind")return fn(a,n.slice(0,-1));const[b,h]=wo(y);return Mr(a,{type:"APPLY",path:n.map(T=>T.toString()),argumentList:b},h).then(xr)},construct(l,m){Qs(o);const[y,f]=wo(m);return Mr(a,{type:"CONSTRUCT",path:n.map(b=>b.toString()),argumentList:y},f).then(xr)}});return cm(c,a),c}function dm(a){return Array.prototype.concat.apply([],a)}function wo(a){const n=a.map(ea);return[n.map(s=>s[0]),dm(n.map(s=>s[1]))]}const vo=new WeakMap;function mm(a,n){return vo.set(a,n),a}function gn(a){return Object.assign(a,{[_o]:!0})}function ea(a){for(const[n,s]of go)if(s.canHandle(a)){const[o,c]=s.serialize(a);return[{type:"HANDLER",name:n,value:o},c]}return[{type:"RAW",value:a},vo.get(a)||[]]}function xr(a){switch(a.type){case"HANDLER":return go.get(a.name).deserialize(a.value);case"RAW":return a.value}}function Mr(a,n,s){return new Promise(o=>{const c=um();a.addEventListener("message",function l(m){!m.data||!m.data.id||m.data.id!==c||(a.removeEventListener("message",l),o(m.data))}),a.start&&a.start(),a.postMessage(Object.assign({id:c},n),s)})}function um(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const To=new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/scriptsRunWorker-
|
144
|
+
*/const _o=Symbol("Comlink.proxy"),sm=Symbol("Comlink.endpoint"),am=Symbol("Comlink.releaseProxy"),yn=Symbol("Comlink.finalizer"),Ys=Symbol("Comlink.thrown"),fo=a=>typeof a=="object"&&a!==null||typeof a=="function",nm={canHandle:a=>fo(a)&&a[_o],serialize(a){const{port1:n,port2:s}=new MessageChannel;return bo(a,n),[s,[s]]},deserialize(a){return a.start(),_n(a)}},im={canHandle:a=>fo(a)&&Ys in a,serialize({value:a}){let n;return a instanceof Error?n={isError:!0,value:{message:a.message,name:a.name,stack:a.stack}}:n={isError:!1,value:a},[n,[]]},deserialize(a){throw a.isError?Object.assign(new Error(a.value.message),a.value):a.value}},go=new Map([["proxy",nm],["throw",im]]);function om(a,n){for(const s of a)if(n===s||s==="*"||s instanceof RegExp&&s.test(n))return!0;return!1}function bo(a,n=globalThis,s=["*"]){n.addEventListener("message",function o(c){if(!c||!c.data)return;if(!om(s,c.origin)){console.warn(`Invalid origin '${c.origin}' for comlink proxy`);return}const{id:l,type:m,path:y}=Object.assign({path:[]},c.data),f=(c.data.argumentList||[]).map(xr);let b;try{const h=y.slice(0,-1).reduce((N,F)=>N[F],a),T=y.reduce((N,F)=>N[F],a);switch(m){case"GET":b=T;break;case"SET":h[y.slice(-1)[0]]=xr(c.data.value),b=!0;break;case"APPLY":b=T.apply(h,f);break;case"CONSTRUCT":{const N=new T(...f);b=gn(N)}break;case"ENDPOINT":{const{port1:N,port2:F}=new MessageChannel;bo(a,F),b=mm(N,[N])}break;case"RELEASE":b=void 0;break;default:return}}catch(h){b={value:h,[Ys]:0}}Promise.resolve(b).catch(h=>({value:h,[Ys]:0})).then(h=>{const[T,N]=ea(h);n.postMessage(Object.assign(Object.assign({},T),{id:l}),N),m==="RELEASE"&&(n.removeEventListener("message",o),xo(n),yn in a&&typeof a[yn]=="function"&&a[yn]())}).catch(h=>{const[T,N]=ea({value:new TypeError("Unserializable return value"),[Ys]:0});n.postMessage(Object.assign(Object.assign({},T),{id:l}),N)})}),n.start&&n.start()}function lm(a){return a.constructor.name==="MessagePort"}function xo(a){lm(a)&&a.close()}function _n(a,n){return fn(a,[],n)}function Qs(a){if(a)throw new Error("Proxy has been released and is not useable")}function ho(a){return Mr(a,{type:"RELEASE"}).then(()=>{xo(a)})}const Zs=new WeakMap,Js="FinalizationRegistry"in globalThis&&new FinalizationRegistry(a=>{const n=(Zs.get(a)||0)-1;Zs.set(a,n),n===0&&ho(a)});function cm(a,n){const s=(Zs.get(n)||0)+1;Zs.set(n,s),Js&&Js.register(a,n,a)}function pm(a){Js&&Js.unregister(a)}function fn(a,n=[],s=function(){}){let o=!1;const c=new Proxy(s,{get(l,m){if(Qs(o),m===am)return()=>{pm(c),ho(a),o=!0};if(m==="then"){if(n.length===0)return{then:()=>c};const y=Mr(a,{type:"GET",path:n.map(f=>f.toString())}).then(xr);return y.then.bind(y)}return fn(a,[...n,m])},set(l,m,y){Qs(o);const[f,b]=ea(y);return Mr(a,{type:"SET",path:[...n,m].map(h=>h.toString()),value:f},b).then(xr)},apply(l,m,y){Qs(o);const f=n[n.length-1];if(f===sm)return Mr(a,{type:"ENDPOINT"}).then(xr);if(f==="bind")return fn(a,n.slice(0,-1));const[b,h]=wo(y);return Mr(a,{type:"APPLY",path:n.map(T=>T.toString()),argumentList:b},h).then(xr)},construct(l,m){Qs(o);const[y,f]=wo(m);return Mr(a,{type:"CONSTRUCT",path:n.map(b=>b.toString()),argumentList:y},f).then(xr)}});return cm(c,a),c}function dm(a){return Array.prototype.concat.apply([],a)}function wo(a){const n=a.map(ea);return[n.map(s=>s[0]),dm(n.map(s=>s[1]))]}const vo=new WeakMap;function mm(a,n){return vo.set(a,n),a}function gn(a){return Object.assign(a,{[_o]:!0})}function ea(a){for(const[n,s]of go)if(s.canHandle(a)){const[o,c]=s.serialize(a);return[{type:"HANDLER",name:n,value:o},c]}return[{type:"RAW",value:a},vo.get(a)||[]]}function xr(a){switch(a.type){case"HANDLER":return go.get(a.name).deserialize(a.value);case"RAW":return a.value}}function Mr(a,n,s){return new Promise(o=>{const c=um();a.addEventListener("message",function l(m){!m.data||!m.data.id||m.data.id!==c||(a.removeEventListener("message",l),o(m.data))}),a.start&&a.start(),a.postMessage(Object.assign({id:c},n),s)})}function um(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const To=new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/scriptsRunWorker-BD3Df3Mn.js").href:new URL("assets/scriptsRunWorker-BD3Df3Mn.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Us&&Us.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Run TccScript Server"});To.onerror=a=>{console.error(a)};async function Do(a){return await Gs.setInlayHints(a)}const ko=_n(To),Io=_n(new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/parserTccWorker-BRdbggcL.js").href:new URL("assets/parserTccWorker-BRdbggcL.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Us&&Us.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Parser TccScript Server"}));async function Ao(a,n=!1){const{functions:s,types:o,constants:c,variables:l,methods:m}=pt;return await Io.parseTcc(a,n,gn(Do),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(c),variables:Object.fromEntries(l)})}async function ym(a,n){const{functions:s,types:o,constants:c,variables:l,methods:m}=pt;return await Io.parseLibraryCode(a,n,gn(Do),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(c),variables:Object.fromEntries(l)})}async function qo(a,n,s=!0){return await ko.runScript(a,n,s)}async function _m(a){return await ko.removeScript(a)}function fm(a){return new Worker(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/editor.worker-CT5Cb1wO.js").href:new URL("assets/editor.worker-CT5Cb1wO.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),{name:a==null?void 0:a.name})}self.MonacoEnvironment={getWorker(){return new fm({name:"Editor Worker"})}},sn.config({paths:{vs:"https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.45.0/min/vs"},"vs/nls":{availableLanguages:{"*":"zh-cn"}}});let Co={};const gm=(a,n)=>{const{height:s,width:o,theme:c,options:l,hasDiff:m,readOnly:y,defaultValue:f,onChange:b,onLinkOpen:h,onDeclareConfigChange:T,onCursorPositionChange:N,onActionTrigger:F,onEditorDidMount:O}=a,L=R.useRef(null),H=R.useRef(null),V=R.useRef(!1);R.useImperativeHandle(n,()=>({setOriginalScript(S){var W;(W=L.current)==null||W.setOriginalScript(S)},setScript(S){var W;(W=L.current)==null||W.setValue(S)},gotoLine(){var S;(S=L.current)==null||S.gotoLine()},getEditorLayout(){var S;return(S=L.current)==null?void 0:S.getEditorLayout()},setPosition(S,W){var Q;(Q=L.current)==null||Q.setPosition({column:S,lineNumber:W})},setModelMarkers(S){var W;(W=L.current)==null||W.setModelMarkers(S)},focus(){var S;(S=L.current)==null||S.focus()}})),R.useEffect(()=>{var S,W;m?(W=L.current)==null||W.addDiffDecorations():(S=L.current)==null||S.removeDiffDecorations()},[m]),R.useEffect(()=>{c&&ke.editor.setTheme(c)},[c]),R.useEffect(()=>{var S;(S=L.current)==null||S.updateActionTrigger(F)},[F]),R.useEffect(()=>{var S;h&&((S=L.current)==null||S.addLinkOpenFunc(h))},[h]);function Y(S,W){var ie,Ze;St.initBuiltinsTrees(),Gs.setEditor(S),L.current=new rm(S,W,F),h&&((ie=L.current)==null||ie.addLinkOpenFunc(h)),m&&((Ze=L.current)==null||Ze.addDiffDecorations()),qd(S),requestAnimationFrame(B);const Q=S.getValue();L.current.onChangeCursorPosition(N),b&&b(Q),!y&&U(Q),O&&O()}const U=R.useCallback(async S=>{var Lt;const W=Date.now();V.current=!1;const{errors:Q,functions:ie,methods:Ze,types:Et,variables:Ue,overloadsFuncs:Ke,imports:J,preParserCode:be,enums:Le}=await Ao(S),Me=new Map(Object.entries(ie)),dt=new Map(Object.entries(Ze)),wt=new Map(Object.entries(Et)),se=new Map(Object.entries(Ue)),he=new Map(Object.entries(J)),Pe=new Map(Object.entries(Le));br.setUserDefined({functions:Me,methods:dt,types:wt,variables:se,imports:he,enums:Pe},Ke),St.setUserDefind(Me,wt,se,dt,Pe);const Nt=Q.map(He=>({...He,severity:He.type||ke.MarkerSeverity.Error}));if(y)return;try{const He=await qo(be||"",{isPreParser:!0});(!io.isEqual(He,Co)||Q.length)&&(He.errors=He.errors.concat(Q),Co=He,T&&T(He))}catch(He){console.log(He),Q.push({message:He.message,startLineNumber:0,endLineNumber:0,startColumn:0,endColumn:0})}!V.current&&((Lt=L.current)==null||Lt.setModelMarkers(Nt));const je=Date.now();console.log((je-W)/1e3)},[T,y]),K=R.useMemo(()=>io.debounce(U,1500),[U]);function A(S){var W;if(y){U(S||"");return}V.current=!0,Gs.clearInlayHints(),(W=L.current)==null||W.setModelMarkers([]),S!==void 0&&(b&&b(S),K(S))}const B=R.useCallback(()=>{var W,Q;const S=(W=H.current)==null?void 0:W.getBoundingClientRect();(Q=L.current)==null||Q.setEditorLayout((S==null?void 0:S.height)||0,S==null?void 0:S.width)},[]);return R.useEffect(()=>{const S=()=>{window.requestAnimationFrame(B)},W=new ResizeObserver(S);return H.current&&W.observe(H.current),()=>{var Q;H.current&&W.unobserve(H.current),W.disconnect(),(Q=L.current)==null||Q.dispose()}},[]),M.jsx("div",{ref:H,children:M.jsx(gd,{height:s,width:o||"100%",defaultLanguage:Se,defaultValue:f||`indicator("我的脚本")
|
145
145
|
plot(close)
|
146
146
|
`,theme:c||"vs-dark",className:`tvue-script ${c||"vs-dark"}`,options:{colorDecorators:!0,useShadowDOM:!1,matchOnWordStartOnly:!0,automaticLayout:!1,unicodeHighlight:{allowedCharacters:{" ":!0}},suggest:{filterGraceful:!0},fontSize:13,...y?Pd:{},readOnlyMessage:{value:"该脚本是只读的。它无法被编辑。"},...l},onMount:Y,onChange:A})})},bm=R.forwardRef(gm),xm=a=>{const{theme:n,modified:s,original:o,height:c,width:l,renderSideBySide:m=!0}=a,y=R.useCallback((f,b)=>{b.languages.register({id:Se}),b.editor.defineTheme("vs-dark",cn),b.editor.defineTheme("vs",ln),b.languages.setMonarchTokensProvider(Se,Lr),b.languages.setLanguageConfiguration(Se,on)},[]);return M.jsx(md,{height:c||"90vh",width:l||"100%",theme:n||"vs-dark",options:{readOnly:!0,renderSideBySide:m,scrollBeyondLastLine:!1},language:Se,modified:s,original:o,onMount:y})};I.VMarkerSeverity=void 0,function(a){a[a.Hint=1]="Hint",a[a.Info=2]="Info",a[a.Warning=4]="Warning",a[a.Error=8]="Error"}(I.VMarkerSeverity||(I.VMarkerSeverity={}));var ta={},hm=function(){var a=document.getSelection();if(!a.rangeCount)return function(){};for(var n=document.activeElement,s=[],o=0;o<a.rangeCount;o++)s.push(a.getRangeAt(o));switch(n.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":n.blur();break;default:n=null;break}return a.removeAllRanges(),function(){a.type==="Caret"&&a.removeAllRanges(),a.rangeCount||s.forEach(function(c){a.addRange(c)}),n&&n.focus()}},wm=hm,zo={"text/plain":"Text","text/html":"Url",default:"Text"},vm="Copy to clipboard: #{key}, Enter";function Tm(a){var n=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return a.replace(/#{\s*key\s*}/g,n)}function Dm(a,n){var s,o,c,l,m,y,f=!1;n||(n={}),s=n.debug||!1;try{c=wm(),l=document.createRange(),m=document.getSelection(),y=document.createElement("span"),y.textContent=a,y.ariaHidden="true",y.style.all="unset",y.style.position="fixed",y.style.top=0,y.style.clip="rect(0, 0, 0, 0)",y.style.whiteSpace="pre",y.style.webkitUserSelect="text",y.style.MozUserSelect="text",y.style.msUserSelect="text",y.style.userSelect="text",y.addEventListener("copy",function(h){if(h.stopPropagation(),n.format)if(h.preventDefault(),typeof h.clipboardData>"u"){s&&console.warn("unable to use e.clipboardData"),s&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var T=zo[n.format]||zo.default;window.clipboardData.setData(T,a)}else h.clipboardData.clearData(),h.clipboardData.setData(n.format,a);n.onCopy&&(h.preventDefault(),n.onCopy(h.clipboardData))}),document.body.appendChild(y),l.selectNodeContents(y),m.addRange(l);var b=document.execCommand("copy");if(!b)throw new Error("copy command was unsuccessful");f=!0}catch(h){s&&console.error("unable to copy using execCommand: ",h),s&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(n.format||"text",a),n.onCopy&&n.onCopy(window.clipboardData),f=!0}catch(T){s&&console.error("unable to copy using clipboardData: ",T),s&&console.error("falling back to prompt"),o=Tm("message"in n?n.message:vm),window.prompt(o,a)}}finally{m&&(typeof m.removeRange=="function"?m.removeRange(l):m.removeAllRanges()),y&&document.body.removeChild(y),c()}return f}var km=Dm;function bn(a){"@babel/helpers - typeof";return bn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},bn(a)}Object.defineProperty(ta,"__esModule",{value:!0}),ta.CopyToClipboard=void 0;var ra=So(R),Im=So(km),Am=["text","onCopy","options","children"];function So(a){return a&&a.__esModule?a:{default:a}}function Eo(a,n){var s=Object.keys(a);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(a);n&&(o=o.filter(function(c){return Object.getOwnPropertyDescriptor(a,c).enumerable})),s.push.apply(s,o)}return s}function No(a){for(var n=1;n<arguments.length;n++){var s=arguments[n]!=null?arguments[n]:{};n%2?Eo(Object(s),!0).forEach(function(o){hn(a,o,s[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(s)):Eo(Object(s)).forEach(function(o){Object.defineProperty(a,o,Object.getOwnPropertyDescriptor(s,o))})}return a}function qm(a,n){if(a==null)return{};var s=Cm(a,n),o,c;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(a);for(c=0;c<l.length;c++)o=l[c],!(n.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(a,o)&&(s[o]=a[o])}return s}function Cm(a,n){if(a==null)return{};var s={},o=Object.keys(a),c,l;for(l=0;l<o.length;l++)c=o[l],!(n.indexOf(c)>=0)&&(s[c]=a[c]);return s}function zm(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function Lo(a,n){for(var s=0;s<n.length;s++){var o=n[s];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(a,o.key,o)}}function Sm(a,n,s){return n&&Lo(a.prototype,n),s&&Lo(a,s),Object.defineProperty(a,"prototype",{writable:!1}),a}function Em(a,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(n&&n.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),n&&xn(a,n)}function xn(a,n){return xn=Object.setPrototypeOf||function(o,c){return o.__proto__=c,o},xn(a,n)}function Nm(a){var n=Mm();return function(){var o=sa(a),c;if(n){var l=sa(this).constructor;c=Reflect.construct(o,arguments,l)}else c=o.apply(this,arguments);return Lm(this,c)}}function Lm(a,n){if(n&&(bn(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Mo(a)}function Mo(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function Mm(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function sa(a){return sa=Object.setPrototypeOf?Object.getPrototypeOf:function(s){return s.__proto__||Object.getPrototypeOf(s)},sa(a)}function hn(a,n,s){return n in a?Object.defineProperty(a,n,{value:s,enumerable:!0,configurable:!0,writable:!0}):a[n]=s,a}var Po=function(a){Em(s,a);var n=Nm(s);function s(){var o;zm(this,s);for(var c=arguments.length,l=new Array(c),m=0;m<c;m++)l[m]=arguments[m];return o=n.call.apply(n,[this].concat(l)),hn(Mo(o),"onClick",function(y){var f=o.props,b=f.text,h=f.onCopy,T=f.children,N=f.options,F=ra.default.Children.only(T),O=(0,Im.default)(b,N);h&&h(b,O),F&&F.props&&typeof F.props.onClick=="function"&&F.props.onClick(y)}),o}return Sm(s,[{key:"render",value:function(){var c=this.props;c.text,c.onCopy,c.options;var l=c.children,m=qm(c,Am),y=ra.default.Children.only(l);return ra.default.cloneElement(y,No(No({},m),{},{onClick:this.onClick}))}}]),s}(ra.default.PureComponent);ta.CopyToClipboard=Po,hn(Po,"defaultProps",{onCopy:void 0,options:void 0});var Pm=ta,wn=Pm.CopyToClipboard;wn.CopyToClipboard=wn;var Om=wn;const vn=cp(Om);async function Rm(a,n=0){const s=a[n];if(!s)return;const{name:o,args:c,type:l,desc:m,examples:y,remarks:f,seeAlso:b,syntax:h,detailedDesc:T,fields:N,returns:F}=s,O={name:o};if(a.length>1&&(O.overloads=`${a.length} overloads`),l&&(O.type=l),c&&(O.name=`${o}()`,O.args=c.map(L=>{const{name:H,desc:V,displayType:Y}=L;return{label:`${H} (${Y})`,desc:V&&hr(V)}})),m&&(O.desc=m.map(L=>hr(L))),y&&(O.originalExample=y.join(`
|
147
147
|
`),O.examples=await ke.editor.colorize(O.originalExample,Se,{tabSize:4})),T){O.detailedDesc=[];for(const L of T){const{desc:H,examples:V}=L;let Y=H.map(A=>hr(A)),U,K;V&&(K=V.join(`
|