pinets 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +146 -75
- package/dist/pinets.min.browser.es.js +117 -0
- package/dist/pinets.min.browser.es.js.map +1 -0
- package/dist/pinets.min.browser.js +96 -16
- package/dist/pinets.min.browser.js.map +1 -0
- package/dist/pinets.min.cjs +96 -15
- package/dist/pinets.min.cjs.map +1 -0
- package/dist/pinets.min.es.js +99 -5
- package/dist/pinets.min.es.js.map +1 -0
- package/dist/types/Context.class.d.ts +3 -25
- package/dist/types/namespaces/Core.d.ts +8 -3
- package/dist/types/namespaces/Plot.helper.d.ts +16 -0
- package/dist/types/namespaces/Plots.d.ts +16 -0
- package/dist/types/namespaces/Types.d.ts +1 -1
- package/dist/types/namespaces/input/utils.d.ts +2 -14
- package/dist/types/namespaces/ta/methods/pivothigh.d.ts +1 -1
- package/dist/types/namespaces/ta/methods/pivotlow.d.ts +1 -1
- package/dist/types/namespaces/utils.d.ts +12 -0
- package/dist/types/transpiler/index.d.ts +1 -1
- package/dist/types/transpiler/pineToJS/ast.d.ts +167 -0
- package/dist/types/transpiler/pineToJS/codegen.d.ts +53 -0
- package/dist/types/transpiler/pineToJS/lexer.d.ts +31 -0
- package/dist/types/transpiler/pineToJS/parser.d.ts +45 -0
- package/dist/types/transpiler/pineToJS/pineToJS.index.d.ts +32 -0
- package/dist/types/transpiler/pineToJS/tokens.d.ts +34 -0
- package/dist/types/transpiler/settings.d.ts +2 -0
- package/dist/types/transpiler/transformers/WrapperTransformer.d.ts +5 -3
- package/dist/types/transpiler/utils/ASTFactory.d.ts +1 -0
- package/dist/types/types/PineTypes.d.ts +19 -15
- package/package.json +24 -5
- package/dist/pinets.dev.browser.js +0 -16515
- package/dist/pinets.dev.cjs +0 -16765
- package/dist/pinets.dev.cjs.map +0 -1
- package/dist/pinets.dev.es.js +0 -9125
- package/dist/pinets.dev.es.js.map +0 -1
package/dist/pinets.min.es.js
CHANGED
|
@@ -15,9 +15,103 @@
|
|
|
15
15
|
* You should have received a copy of the GNU Affero General Public License
|
|
16
16
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
|
-
import*as St from"acorn";import*as et from"astring";import*as k from"acorn-walk";import*as Z from"fs";import*as nt from"path";import{fileURLToPath as Bt}from"url";var Dt=Object.defineProperty,Lt=(e,t,n)=>t in e?Dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,D=(e,t,n)=>Lt(e,typeof t!="symbol"?t+"":t,n);const Wt=new Set(["Infinity","NaN","undefined","null","true","false"]),Ot=new Set(["Math","Array","Object","String","Number","Boolean","Date","RegExp","Error","JSON","Promise","Set","Map","WeakSet","WeakMap","Symbol","BigInt","Proxy","Reflect","console","isNaN","isFinite","parseInt","parseFloat","encodeURI","decodeURI","encodeURIComponent","decodeURIComponent"]);class Rt{constructor(){D(this,"scopes",[]),D(this,"scopeTypes",[]),D(this,"scopeCounts",new Map),D(this,"contextBoundVars",new Set),D(this,"arrayPatternElements",new Set),D(this,"rootParams",new Set),D(this,"localSeriesVars",new Set),D(this,"varKinds",new Map),D(this,"loopVars",new Set),D(this,"loopVarNames",new Map),D(this,"paramIdCounter",0),D(this,"cacheIdCounter",0),D(this,"tempVarCounter",0),D(this,"taCallIdCounter",0),D(this,"hoistingStack",[]),D(this,"suppressHoisting",!1),this.pushScope("glb")}get nextParamIdArg(){return{type:"Identifier",name:`'p${this.paramIdCounter++}'`}}get nextCacheIdArg(){return{type:"Identifier",name:`'cache_${this.cacheIdCounter++}'`}}getNextTACallId(){return{type:"Literal",value:`_ta${this.taCallIdCounter++}`}}pushScope(t){this.scopes.push(new Map),this.scopeTypes.push(t),this.scopeCounts.set(t,(this.scopeCounts.get(t)||0)+1)}popScope(){this.scopes.pop(),this.scopeTypes.pop()}getCurrentScopeType(){return this.scopeTypes[this.scopeTypes.length-1]}getCurrentScopeCount(){return this.scopeCounts.get(this.getCurrentScopeType())||1}addLocalSeriesVar(t){this.localSeriesVars.add(t)}isLocalSeriesVar(t){return this.localSeriesVars.has(t)}addContextBoundVar(t,n=!1){this.contextBoundVars.add(t),n&&this.rootParams.add(t)}removeContextBoundVar(t){this.contextBoundVars.has(t)&&(this.contextBoundVars.delete(t),this.rootParams.has(t)&&this.rootParams.delete(t))}addArrayPatternElement(t){this.arrayPatternElements.add(t)}isContextBound(t){return Wt.has(t)||Ot.has(t)?!1:this.contextBoundVars.has(t)}isArrayPatternElement(t){return this.arrayPatternElements.has(t)}isRootParam(t){return this.rootParams.has(t)}addLoopVariable(t,n){this.loopVars.add(t),this.loopVarNames.set(t,n)}getLoopVariableName(t){return this.loopVarNames.get(t)}isLoopVariable(t){return this.loopVars.has(t)}addVariable(t,n){if(this.isContextBound(t))return t;const r=this.scopes[this.scopes.length-1],i=this.scopeTypes[this.scopeTypes.length-1],s=this.scopeCounts.get(i)||1,a=`${i}${s}_${t}`;return r.set(t,a),this.varKinds.set(a,n),a}getVariable(t){if(this.loopVars.has(t)){const n=this.loopVarNames.get(t);if(n)return[n,"let"]}if(this.isContextBound(t))return[t,"let"];for(let n=this.scopes.length-1;n>=0;n--){const r=this.scopes[n];if(r.has(t)){const i=r.get(t),s=this.varKinds.get(i)||"let";return[i,s]}}return[t,"let"]}generateTempVar(){return`temp_${++this.tempVarCounter}`}enterHoistingScope(){this.hoistingStack.push([])}exitHoistingScope(){return this.hoistingStack.pop()||[]}addHoistedStatement(t){this.hoistingStack.length>0&&!this.suppressHoisting&&this.hoistingStack[this.hoistingStack.length-1].push(t)}setSuppressHoisting(t){this.suppressHoisting=t}shouldSuppressHoisting(){return this.suppressHoisting}generateParamId(){return`p${this.paramIdCounter++}`}}const T="$",_={createIdentifier(e){return{type:"Identifier",name:e}},createLiteral(e){return{type:"Literal",value:e}},createMemberExpression(e,t,n=!1){return{type:"MemberExpression",object:e,property:t,computed:n}},createContextIdentifier(){return this.createIdentifier(T)},createContextVariableReference(e,t){const n=this.createContextIdentifier(),r=this.createIdentifier(e),i=this.createIdentifier(t);return this.createMemberExpression(this.createMemberExpression(n,r,!1),i,!1)},createContextVariableAccess0(e,t){const n=this.createContextVariableReference(e,t);return this.createGetCall(n,0)},createArrayAccess(e,t){const n=typeof t=="number"?this.createLiteral(t):t;return this.createMemberExpression(e,n,!0)},createCallExpression(e,t){return{type:"CallExpression",callee:e,arguments:t}},createAssignmentExpression(e,t,n="="){return{type:"AssignmentExpression",operator:n,left:e,right:t}},createExpressionStatement(e){return{type:"ExpressionStatement",expression:e}},createInitCall(e,t,n){const r=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("init"),!1),i=[e,t];return n&&i.push(n),this.createCallExpression(r,i)},createInitVarCall(e,t){const n=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("initVar"),!1),r=[e,t];return this.createCallExpression(n,r)},createGetCall(e,t){const n=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("get"),!1),r=typeof t=="number"?this.createLiteral(t):t;return this.createCallExpression(n,[e,r])},createSetCall(e,t){const n=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("set"),!1);return this.createCallExpression(n,[e,t])},createMathEqCall(e,t){const n=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("math"),!1),r=this.createMemberExpression(n,this.createIdentifier("__eq"),!1);return this.createCallExpression(r,[e,t])},createWrapperFunction(e){return{type:"FunctionDeclaration",id:null,params:[this.createIdentifier("context")],body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:e}]}}},createVariableDeclaration(e,t){return{type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:this.createIdentifier(e),init:t}]}}},lt=["ta","math","request","array","input"],Ct=["open","high","low","close","volume","hl2","hlc3","ohlc4","openTime","closeTime"],Et=["input","ta","math","request","array","na","plotchar","color","plot","nz","strategy","library","str","box","line","label","table","map","matrix","log","map","timeframe","syminfo","barstate","bar_index","last_bar_index","last_bar_time","order","currency","display","dayofweek"],Ft=["na","nz","plot","plotchar","color"];function zt(e){let t=null,n=T;if(e.type==="Program"&&e.body.length>0){const h=e.body[0];if(h.type==="ExpressionStatement"&&(h.expression.type==="ArrowFunctionExpression"||h.expression.type==="FunctionExpression")){const d=h.expression;d.body.type==="BlockStatement"&&(t=d.body.body,d.params.length>0&&d.params[0].type==="Identifier"&&(n=d.params[0].name))}}if(!t)return;const r=new Set,i=new Set,s=h=>{h.type==="Identifier"?r.add(h.name):h.type==="ObjectPattern"?h.properties.forEach(d=>s(d.value)):h.type==="ArrayPattern"&&h.elements.forEach(d=>{d&&s(d)})};k.recursive(e,{},{VariableDeclarator(h,d,g){s(h.id),h.init&&g(h.init,d)},FunctionDeclaration(h,d,g){s(h.id),g(h.body,d)},Identifier(h,d,g){i.add(h.name)},MemberExpression(h,d,g){g(h.object,d),h.computed&&g(h.property,d)},Property(h,d,g){h.computed&&g(h.key,d),g(h.value,d)}}),t.forEach(h=>{h.type==="VariableDeclaration"?h.declarations.forEach(d=>s(d.id)):h.type==="FunctionDeclaration"&&s(h.id)});const a=Ct,o=Et,c=a.filter(h=>!r.has(h)),l=o.filter(h=>!r.has(h)),u=c.filter(h=>i.has(h)),p=l.filter(h=>i.has(h)),f=[];u.length>0&&f.push({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"ObjectPattern",properties:u.map(h=>({type:"Property",key:{type:"Identifier",name:h},value:{type:"Identifier",name:h},kind:"init",shorthand:!0}))},init:{type:"MemberExpression",object:{type:"Identifier",name:n},property:{type:"Identifier",name:"data"},computed:!1}}]}),p.length>0&&f.push({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"ObjectPattern",properties:p.map(h=>({type:"Property",key:{type:"Identifier",name:h},value:{type:"Identifier",name:h},kind:"init",shorthand:!0}))},init:{type:"MemberExpression",object:{type:"Identifier",name:n},property:{type:"Identifier",name:"pine"},computed:!1}}]}),f.length>0&&t.unshift(...f)}function Ht(e){let t=null,n=T;if(e.type==="Program"&&e.body.length>0){const o=e.body[0];if(o.type==="ExpressionStatement"&&(o.expression.type==="ArrowFunctionExpression"||o.expression.type==="FunctionExpression")){const c=o.expression;c.body.type==="BlockStatement"&&(t=c.body.body,c.params.length>0&&c.params[0].type==="Identifier"&&(n=c.params[0].name))}}if(!t)return;const r=new Set(Ct),i=new Set(Et),s=new Set(Ft),a=new Map;t.forEach(o=>{o.type==="VariableDeclaration"&&o.declarations.forEach(c=>{if(c.init&&c.init.type==="MemberExpression"&&c.init.object.type==="Identifier"&&c.init.object.name===n&&c.init.property.type==="Identifier"){const l=c.init.property.name;let u=null;if(l==="data"?u=r:l==="pine"?u=i:l==="core"&&(u=s),u&&c.id.type==="ObjectPattern")c.id.properties.forEach(p=>{if(p.type==="Property"&&p.key.type==="Identifier"&&p.value.type==="Identifier"){const f=p.key.name,h=p.value.name;u.has(f)&&f!==h&&(a.set(h,f),p.value.name=f,p.shorthand=!0)}});else if(c.id.type==="Identifier"&<.includes(l)){const p=l,f=c.id.name;p!==f&&(a.set(f,p),c.id.name=p)}}})}),a.size>0&&k.recursive(e,{},{Identifier(o){a.has(o.name)&&(o.name=a.get(o.name))},MemberExpression(o,c,l){l(o.object,c),o.computed&&l(o.property,c)},Property(o,c,l){o.computed&&l(o.key,c),l(o.value,c)}})}function qt(e){try{const t=St.parse(e,{ecmaVersion:"latest",sourceType:"module"});if(t.type==="Program"&&t.body.length===1){const n=t.body[0];if(n.type==="ExpressionStatement"){const r=n.expression;if(r.type==="ArrowFunctionExpression"||r.type==="FunctionExpression")return!0}if(n.type==="FunctionDeclaration")return!0}return!1}catch{return!1}}function Ut(e){return e=e.trim(),qt(e)?e:`(context) => {
|
|
18
|
+
import*as Fe from"fs";import*as Xe from"path";import{fileURLToPath as br}from"url";var vr=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],Ei=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],_r="\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65",Ni="\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC",_t={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},St="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",Sr={5:St,"5module":St+" export import",6:St+" const class extends export import super"},Er=/^in(stanceof)?$/,Nr=new RegExp("["+Ni+"]"),Cr=new RegExp("["+Ni+_r+"]");function At(e,t){for(var i=65536,r=0;r<t.length;r+=2){if(i+=t[r],i>e)return!1;if(i+=t[r+1],i>=e)return!0}return!1}function _e(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Nr.test(String.fromCharCode(e)):t===!1?!1:At(e,Ei)}function We(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Cr.test(String.fromCharCode(e)):t===!1?!1:At(e,Ei)||At(e,vr)}var O=function(t,i){i===void 0&&(i={}),this.label=t,this.keyword=i.keyword,this.beforeExpr=!!i.beforeExpr,this.startsExpr=!!i.startsExpr,this.isLoop=!!i.isLoop,this.isAssign=!!i.isAssign,this.prefix=!!i.prefix,this.postfix=!!i.postfix,this.binop=i.binop||null,this.updateContext=null};function ne(e,t){return new O(e,{beforeExpr:!0,binop:t})}var ae={beforeExpr:!0},ee={startsExpr:!0},Ft={};function M(e,t){return t===void 0&&(t={}),t.keyword=e,Ft[e]=new O(e,t)}var u={num:new O("num",ee),regexp:new O("regexp",ee),string:new O("string",ee),name:new O("name",ee),privateId:new O("privateId",ee),eof:new O("eof"),bracketL:new O("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new O("]"),braceL:new O("{",{beforeExpr:!0,startsExpr:!0}),braceR:new O("}"),parenL:new O("(",{beforeExpr:!0,startsExpr:!0}),parenR:new O(")"),comma:new O(",",ae),semi:new O(";",ae),colon:new O(":",ae),dot:new O("."),question:new O("?",ae),questionDot:new O("?."),arrow:new O("=>",ae),template:new O("template"),invalidTemplate:new O("invalidTemplate"),ellipsis:new O("...",ae),backQuote:new O("`",ee),dollarBraceL:new O("${",{beforeExpr:!0,startsExpr:!0}),eq:new O("=",{beforeExpr:!0,isAssign:!0}),assign:new O("_=",{beforeExpr:!0,isAssign:!0}),incDec:new O("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new O("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:ne("||",1),logicalAND:ne("&&",2),bitwiseOR:ne("|",3),bitwiseXOR:ne("^",4),bitwiseAND:ne("&",5),equality:ne("==/!=/===/!==",6),relational:ne("</>/<=/>=",7),bitShift:ne("<</>>/>>>",8),plusMin:new O("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:ne("%",10),star:ne("*",10),slash:ne("/",10),starstar:new O("**",{beforeExpr:!0}),coalesce:ne("??",1),_break:M("break"),_case:M("case",ae),_catch:M("catch"),_continue:M("continue"),_debugger:M("debugger"),_default:M("default",ae),_do:M("do",{isLoop:!0,beforeExpr:!0}),_else:M("else",ae),_finally:M("finally"),_for:M("for",{isLoop:!0}),_function:M("function",ee),_if:M("if"),_return:M("return",ae),_switch:M("switch"),_throw:M("throw",ae),_try:M("try"),_var:M("var"),_const:M("const"),_while:M("while",{isLoop:!0}),_with:M("with"),_new:M("new",{beforeExpr:!0,startsExpr:!0}),_this:M("this",ee),_super:M("super",ee),_class:M("class",ee),_extends:M("extends",ae),_export:M("export"),_import:M("import",ee),_null:M("null",ee),_true:M("true",ee),_false:M("false",ee),_in:M("in",{beforeExpr:!0,binop:7}),_instanceof:M("instanceof",{beforeExpr:!0,binop:7}),_typeof:M("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:M("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:M("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},pe=/\r\n?|\n|\u2028|\u2029/,kr=new RegExp(pe.source,"g");function Ue(e){return e===10||e===13||e===8232||e===8233}function Ci(e,t,i){i===void 0&&(i=e.length);for(var r=t;r<i;r++){var s=e.charCodeAt(r);if(Ue(s))return r<i-1&&s===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var ki=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,he=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,Ii=Object.prototype,Ir=Ii.hasOwnProperty,Ar=Ii.toString,Ke=Object.hasOwn||function(e,t){return Ir.call(e,t)},Zt=Array.isArray||function(e){return Ar.call(e)==="[object Array]"},Jt=Object.create(null);function ke(e){return Jt[e]||(Jt[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function Se(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var Tr=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,et=function(t,i){this.line=t,this.column=i};et.prototype.offset=function(t){return new et(this.line,this.column+t)};var gt=function(t,i,r){this.start=i,this.end=r,t.sourceFile!==null&&(this.source=t.sourceFile)};function Ai(e,t){for(var i=1,r=0;;){var s=Ci(e,r,t);if(s<0)return new et(i,t-r);++i,r=s}}var Tt={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},ei=!1;function Pr(e){var t={};for(var i in Tt)t[i]=e&&Ke(e,i)?e[i]:Tt[i];if(t.ecmaVersion==="latest"?t.ecmaVersion=1e8:t.ecmaVersion==null?(!ei&&typeof console=="object"&&console.warn&&(ei=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
19
|
+
Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved==null&&(t.allowReserved=t.ecmaVersion<5),(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),Zt(t.onToken)){var r=t.onToken;t.onToken=function(s){return r.push(s)}}return Zt(t.onComment)&&(t.onComment=Rr(t,t.onComment)),t}function Rr(e,t){return function(i,r,s,n,a,o){var h={type:i?"Block":"Line",value:r,start:s,end:n};e.locations&&(h.loc=new gt(this,a,o)),e.ranges&&(h.range=[s,n]),t.push(h)}}var tt=1,ze=2,jt=4,Ti=8,Pi=16,Ri=32,$t=64,Di=128,it=256,Wt=tt|ze|it;function qt(e,t){return ze|(e?jt:0)|(t?Ti:0)}var ut=0,Ut=1,Ne=2,Mi=3,Oi=4,Vi=5,U=function(t,i,r){this.options=t=Pr(t),this.sourceFile=t.sourceFile,this.keywords=ke(Sr[t.ecmaVersion>=6?6:t.sourceType==="module"?"5module":5]);var s="";t.allowReserved!==!0&&(s=_t[t.ecmaVersion>=6?6:t.ecmaVersion===5?5:3],t.sourceType==="module"&&(s+=" await")),this.reservedWords=ke(s);var n=(s?s+" ":"")+_t.strict;this.reservedWordsStrict=ke(n),this.reservedWordsStrictBind=ke(n+" "+_t.strictBind),this.input=String(i),this.containsEsc=!1,r?(this.pos=r,this.lineStart=this.input.lastIndexOf(`
|
|
20
|
+
`,r-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(pe).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=u.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=t.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&t.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(tt),this.regexpState=null,this.privateNameStack=[]},we={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};U.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};we.inFunction.get=function(){return(this.currentVarScope().flags&ze)>0};we.inGenerator.get=function(){return(this.currentVarScope().flags&Ti)>0&&!this.currentVarScope().inClassFieldInit};we.inAsync.get=function(){return(this.currentVarScope().flags&jt)>0&&!this.currentVarScope().inClassFieldInit};we.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e];if(t.inClassFieldInit||t.flags&it)return!1;if(t.flags&ze)return(t.flags&jt)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};we.allowSuper.get=function(){var e=this.currentThisScope(),t=e.flags,i=e.inClassFieldInit;return(t&$t)>0||i||this.options.allowSuperOutsideMethod};we.allowDirectSuper.get=function(){return(this.currentThisScope().flags&Di)>0};we.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};we.allowNewDotTarget.get=function(){var e=this.currentThisScope(),t=e.flags,i=e.inClassFieldInit;return(t&(ze|it))>0||i};we.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&it)>0};U.extend=function(){for(var t=[],i=arguments.length;i--;)t[i]=arguments[i];for(var r=this,s=0;s<t.length;s++)r=t[s](r);return r};U.parse=function(t,i){return new this(i,t).parse()};U.parseExpressionAt=function(t,i,r){var s=new this(r,t,i);return s.nextToken(),s.parseExpression()};U.tokenizer=function(t,i){return new this(i,t)};Object.defineProperties(U.prototype,we);var J=U.prototype,Dr=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;J.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){he.lastIndex=e,e+=he.exec(this.input)[0].length;var t=Dr.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])==="use strict"){he.lastIndex=e+t[0].length;var i=he.exec(this.input),r=i.index+i[0].length,s=this.input.charAt(r);return s===";"||s==="}"||pe.test(i[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(s)||s==="!"&&this.input.charAt(r+1)==="=")}e+=t[0].length,he.lastIndex=e,e+=he.exec(this.input)[0].length,this.input[e]===";"&&e++}};J.eat=function(e){return this.type===e?(this.next(),!0):!1};J.isContextual=function(e){return this.type===u.name&&this.value===e&&!this.containsEsc};J.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1};J.expectContextual=function(e){this.eatContextual(e)||this.unexpected()};J.canInsertSemicolon=function(){return this.type===u.eof||this.type===u.braceR||pe.test(this.input.slice(this.lastTokEnd,this.start))};J.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};J.semicolon=function(){!this.eat(u.semi)&&!this.insertSemicolon()&&this.unexpected()};J.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0};J.expect=function(e){this.eat(e)||this.unexpected()};J.unexpected=function(e){this.raise(e??this.start,"Unexpected token")};var xt=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};J.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var i=t?e.parenthesizedAssign:e.parenthesizedBind;i>-1&&this.raiseRecoverable(i,t?"Assigning to rvalue":"Parenthesized pattern")}};J.checkExpressionErrors=function(e,t){if(!e)return!1;var i=e.shorthandAssign,r=e.doubleProto;if(!t)return i>=0||r>=0;i>=0&&this.raise(i,"Shorthand property assignments are valid only in destructuring patterns"),r>=0&&this.raiseRecoverable(r,"Redefinition of __proto__ property")};J.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")};J.isSimpleAssignTarget=function(e){return e.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(e.expression):e.type==="Identifier"||e.type==="MemberExpression"};var N=U.prototype;N.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==u.eof;){var i=this.parseStatement(null,!0,t);e.body.push(i)}if(this.inModule)for(var r=0,s=Object.keys(this.undefinedExports);r<s.length;r+=1){var n=s[r];this.raiseRecoverable(this.undefinedExports[n].start,"Export '"+n+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType,this.finishNode(e,"Program")};var Kt={kind:"loop"},Mr={kind:"switch"};N.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;he.lastIndex=this.pos;var t=he.exec(this.input),i=this.pos+t[0].length,r=this.input.charCodeAt(i);if(r===91||r===92)return!0;if(e)return!1;if(r===123||r>55295&&r<56320)return!0;if(_e(r,!0)){for(var s=i+1;We(r=this.input.charCodeAt(s),!0);)++s;if(r===92||r>55295&&r<56320)return!0;var n=this.input.slice(i,s);if(!Er.test(n))return!0}return!1};N.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;he.lastIndex=this.pos;var e=he.exec(this.input),t=this.pos+e[0].length,i;return!pe.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)==="function"&&(t+8===this.input.length||!(We(i=this.input.charCodeAt(t+8))||i>55295&&i<56320))};N.parseStatement=function(e,t,i){var r=this.type,s=this.startNode(),n;switch(this.isLet(e)&&(r=u._var,n="let"),r){case u._break:case u._continue:return this.parseBreakContinueStatement(s,r.keyword);case u._debugger:return this.parseDebuggerStatement(s);case u._do:return this.parseDoStatement(s);case u._for:return this.parseForStatement(s);case u._function:return e&&(this.strict||e!=="if"&&e!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(s,!1,!e);case u._class:return e&&this.unexpected(),this.parseClass(s,!0);case u._if:return this.parseIfStatement(s);case u._return:return this.parseReturnStatement(s);case u._switch:return this.parseSwitchStatement(s);case u._throw:return this.parseThrowStatement(s);case u._try:return this.parseTryStatement(s);case u._const:case u._var:return n=n||this.value,e&&n!=="var"&&this.unexpected(),this.parseVarStatement(s,n);case u._while:return this.parseWhileStatement(s);case u._with:return this.parseWithStatement(s);case u.braceL:return this.parseBlock(!0,s);case u.semi:return this.parseEmptyStatement(s);case u._export:case u._import:if(this.options.ecmaVersion>10&&r===u._import){he.lastIndex=this.pos;var a=he.exec(this.input),o=this.pos+a[0].length,h=this.input.charCodeAt(o);if(h===40||h===46)return this.parseExpressionStatement(s,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),r===u._import?this.parseImport(s):this.parseExport(s,i);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(s,!0,!e);var c=this.value,l=this.parseExpression();return r===u.name&&l.type==="Identifier"&&this.eat(u.colon)?this.parseLabeledStatement(s,c,l,e):this.parseExpressionStatement(s,l)}};N.parseBreakContinueStatement=function(e,t){var i=t==="break";this.next(),this.eat(u.semi)||this.insertSemicolon()?e.label=null:this.type!==u.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var r=0;r<this.labels.length;++r){var s=this.labels[r];if((e.label==null||s.name===e.label.name)&&(s.kind!=null&&(i||s.kind==="loop")||e.label&&i))break}return r===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,i?"BreakStatement":"ContinueStatement")};N.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")};N.parseDoStatement=function(e){return this.next(),this.labels.push(Kt),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(u._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(u.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")};N.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(Kt),this.enterScope(0),this.expect(u.parenL),this.type===u.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var i=this.isLet();if(this.type===u._var||this.type===u._const||i){var r=this.startNode(),s=i?"let":this.value;return this.next(),this.parseVar(r,!0,s),this.finishNode(r,"VariableDeclaration"),(this.type===u._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&r.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===u._in?t>-1&&this.unexpected(t):e.await=t>-1),this.parseForIn(e,r)):(t>-1&&this.unexpected(t),this.parseFor(e,r))}var n=this.isContextual("let"),a=!1,o=this.containsEsc,h=new xt,c=this.start,l=t>-1?this.parseExprSubscripts(h,"await"):this.parseExpression(!0,h);return this.type===u._in||(a=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===u._in&&this.unexpected(t),e.await=!0):a&&this.options.ecmaVersion>=8&&(l.start===c&&!o&&l.type==="Identifier"&&l.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),n&&a&&this.raise(l.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(l,!1,h),this.checkLValPattern(l),this.parseForIn(e,l)):(this.checkExpressionErrors(h,!0),t>-1&&this.unexpected(t),this.parseFor(e,l))};N.parseFunctionStatement=function(e,t,i){return this.next(),this.parseFunction(e,Ze|(i?0:Pt),!1,t)};N.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(u._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")};N.parseReturnStatement=function(e){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(u.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")};N.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(u.braceL),this.labels.push(Mr),this.enterScope(0);for(var t,i=!1;this.type!==u.braceR;)if(this.type===u._case||this.type===u._default){var r=this.type===u._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(i&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),i=!0,t.test=null),this.expect(u.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")};N.parseThrowStatement=function(e){return this.next(),pe.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var Or=[];N.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type==="Identifier";return this.enterScope(t?Ri:0),this.checkLValPattern(e,t?Oi:Ne),this.expect(u.parenR),e};N.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===u._catch){var t=this.startNode();this.next(),this.eat(u.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(u._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")};N.parseVarStatement=function(e,t,i){return this.next(),this.parseVar(e,!1,t,i),this.semicolon(),this.finishNode(e,"VariableDeclaration")};N.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Kt),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")};N.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement("with"),this.finishNode(e,"WithStatement")};N.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")};N.parseLabeledStatement=function(e,t,i,r){for(var s=0,n=this.labels;s<n.length;s+=1){var a=n[s];a.name===t&&this.raise(i.start,"Label '"+t+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===u._switch?"switch":null,h=this.labels.length-1;h>=0;h--){var c=this.labels[h];if(c.statementStart===e.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(r?r.indexOf("label")===-1?r+"label":r:"label"),this.labels.pop(),e.label=i,this.finishNode(e,"LabeledStatement")};N.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")};N.parseBlock=function(e,t,i){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(u.braceL),e&&this.enterScope(0);this.type!==u.braceR;){var r=this.parseStatement(null);t.body.push(r)}return i&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")};N.parseFor=function(e,t){return e.init=t,this.expect(u.semi),e.test=this.type===u.semi?null:this.parseExpression(),this.expect(u.semi),e.update=this.type===u.parenR?null:this.parseExpression(),this.expect(u.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")};N.parseForIn=function(e,t){var i=this.type===u._in;return this.next(),t.type==="VariableDeclaration"&&t.declarations[0].init!=null&&(!i||this.options.ecmaVersion<8||this.strict||t.kind!=="var"||t.declarations[0].id.type!=="Identifier")&&this.raise(t.start,(i?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=t,e.right=i?this.parseExpression():this.parseMaybeAssign(),this.expect(u.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,i?"ForInStatement":"ForOfStatement")};N.parseVar=function(e,t,i,r){for(e.declarations=[],e.kind=i;;){var s=this.startNode();if(this.parseVarId(s,i),this.eat(u.eq)?s.init=this.parseMaybeAssign(t):!r&&i==="const"&&!(this.type===u._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!r&&s.id.type!=="Identifier"&&!(t&&(this.type===u._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):s.init=null,e.declarations.push(this.finishNode(s,"VariableDeclarator")),!this.eat(u.comma))break}return e};N.parseVarId=function(e,t){e.id=this.parseBindingAtom(),this.checkLValPattern(e.id,t==="var"?Ut:Ne,!1)};var Ze=1,Pt=2,Li=4;N.parseFunction=function(e,t,i,r,s){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===u.star&&t&Pt&&this.unexpected(),e.generator=this.eat(u.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&Ze&&(e.id=t&Li&&this.type!==u.name?null:this.parseIdent(),e.id&&!(t&Pt)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?Ut:Ne:Mi));var n=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(qt(e.async,e.generator)),t&Ze||(e.id=this.type===u.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,i,!1,s),this.yieldPos=n,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(e,t&Ze?"FunctionDeclaration":"FunctionExpression")};N.parseFunctionParams=function(e){this.expect(u.parenL),e.params=this.parseBindingList(u.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};N.parseClass=function(e,t){this.next();var i=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),s=this.startNode(),n=!1;for(s.body=[],this.expect(u.braceL);this.type!==u.braceR;){var a=this.parseClassElement(e.superClass!==null);a&&(s.body.push(a),a.type==="MethodDefinition"&&a.kind==="constructor"?(n&&this.raiseRecoverable(a.start,"Duplicate constructor in the same class"),n=!0):a.key&&a.key.type==="PrivateIdentifier"&&Vr(r,a)&&this.raiseRecoverable(a.key.start,"Identifier '#"+a.key.name+"' has already been declared"))}return this.strict=i,this.next(),e.body=this.finishNode(s,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")};N.parseClassElement=function(e){if(this.eat(u.semi))return null;var t=this.options.ecmaVersion,i=this.startNode(),r="",s=!1,n=!1,a="method",o=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(u.braceL))return this.parseClassStaticBlock(i),i;this.isClassElementNameStart()||this.type===u.star?o=!0:r="static"}if(i.static=o,!r&&t>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===u.star)&&!this.canInsertSemicolon()?n=!0:r="async"),!r&&(t>=9||!n)&&this.eat(u.star)&&(s=!0),!r&&!n&&!s){var h=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?a=h:r=h)}if(r?(i.computed=!1,i.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),i.key.name=r,this.finishNode(i.key,"Identifier")):this.parseClassElementName(i),t<13||this.type===u.parenL||a!=="method"||s||n){var c=!i.static&<(i,"constructor"),l=c&&e;c&&a!=="method"&&this.raise(i.key.start,"Constructor can't have get/set modifier"),i.kind=c?"constructor":a,this.parseClassMethod(i,s,n,l)}else this.parseClassField(i);return i};N.isClassElementNameStart=function(){return this.type===u.name||this.type===u.privateId||this.type===u.num||this.type===u.string||this.type===u.bracketL||this.type.keyword};N.parseClassElementName=function(e){this.type===u.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)};N.parseClassMethod=function(e,t,i,r){var s=e.key;e.kind==="constructor"?(t&&this.raise(s.start,"Constructor can't be a generator"),i&&this.raise(s.start,"Constructor can't be an async method")):e.static&<(e,"prototype")&&this.raise(s.start,"Classes may not have a static property named prototype");var n=e.value=this.parseMethod(t,i,r);return e.kind==="get"&&n.params.length!==0&&this.raiseRecoverable(n.start,"getter should have no params"),e.kind==="set"&&n.params.length!==1&&this.raiseRecoverable(n.start,"setter should have exactly one param"),e.kind==="set"&&n.params[0].type==="RestElement"&&this.raiseRecoverable(n.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")};N.parseClassField=function(e){if(lt(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&<(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(u.eq)){var t=this.currentThisScope(),i=t.inClassFieldInit;t.inClassFieldInit=!0,e.value=this.parseMaybeAssign(),t.inClassFieldInit=i}else e.value=null;return this.semicolon(),this.finishNode(e,"PropertyDefinition")};N.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(it|$t);this.type!==u.braceR;){var i=this.parseStatement(null);e.body.push(i)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")};N.parseClassId=function(e,t){this.type===u.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,Ne,!1)):(t===!0&&this.unexpected(),e.id=null)};N.parseClassSuper=function(e){e.superClass=this.eat(u._extends)?this.parseExprSubscripts(null,!1):null};N.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared};N.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,i=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,s=r===0?null:this.privateNameStack[r-1],n=0;n<i.length;++n){var a=i[n];Ke(t,a.name)||(s?s.used.push(a):this.raiseRecoverable(a.start,"Private field '#"+a.name+"' must be declared in an enclosing class"))}};function Vr(e,t){var i=t.key.name,r=e[i],s="true";return t.type==="MethodDefinition"&&(t.kind==="get"||t.kind==="set")&&(s=(t.static?"s":"i")+t.kind),r==="iget"&&s==="iset"||r==="iset"&&s==="iget"||r==="sget"&&s==="sset"||r==="sset"&&s==="sget"?(e[i]="true",!1):r?!0:(e[i]=s,!1)}function lt(e,t){var i=e.computed,r=e.key;return!i&&(r.type==="Identifier"&&r.name===t||r.type==="Literal"&&r.value===t)}N.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual("from"),this.type!==u.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")};N.parseExport=function(e,t){if(this.next(),this.eat(u.star))return this.parseExportAllDeclaration(e,t);if(this.eat(u._default))return this.checkExport(t,"default",this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type==="VariableDeclaration"?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null;else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))this.type!==u.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var i=0,r=e.specifiers;i<r.length;i+=1){var s=r[i];this.checkUnreserved(s.local),this.checkLocalExport(s.local),s.local.type==="Literal"&&this.raise(s.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null}this.semicolon()}return this.finishNode(e,"ExportNamedDeclaration")};N.parseExportDeclaration=function(e){return this.parseStatement(null)};N.parseExportDefaultDeclaration=function(){var e;if(this.type===u._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,Ze|Li,!1,e)}else if(this.type===u._class){var i=this.startNode();return this.parseClass(i,"nullableID")}else{var r=this.parseMaybeAssign();return this.semicolon(),r}};N.checkExport=function(e,t,i){e&&(typeof t!="string"&&(t=t.type==="Identifier"?t.name:t.value),Ke(e,t)&&this.raiseRecoverable(i,"Duplicate export '"+t+"'"),e[t]=!0)};N.checkPatternExport=function(e,t){var i=t.type;if(i==="Identifier")this.checkExport(e,t,t.start);else if(i==="ObjectPattern")for(var r=0,s=t.properties;r<s.length;r+=1){var n=s[r];this.checkPatternExport(e,n)}else if(i==="ArrayPattern")for(var a=0,o=t.elements;a<o.length;a+=1){var h=o[a];h&&this.checkPatternExport(e,h)}else i==="Property"?this.checkPatternExport(e,t.value):i==="AssignmentPattern"?this.checkPatternExport(e,t.left):i==="RestElement"&&this.checkPatternExport(e,t.argument)};N.checkVariableExport=function(e,t){if(e)for(var i=0,r=t;i<r.length;i+=1){var s=r[i];this.checkPatternExport(e,s.id)}};N.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};N.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual("as")?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,"ExportSpecifier")};N.parseExportSpecifiers=function(e){var t=[],i=!0;for(this.expect(u.braceL);!this.eat(u.braceR);){if(i)i=!1;else if(this.expect(u.comma),this.afterTrailingComma(u.braceR))break;t.push(this.parseExportSpecifier(e))}return t};N.parseImport=function(e){return this.next(),this.type===u.string?(e.specifiers=Or,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===u.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")};N.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual("as")?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,Ne),this.finishNode(e,"ImportSpecifier")};N.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,Ne),this.finishNode(e,"ImportDefaultSpecifier")};N.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,Ne),this.finishNode(e,"ImportNamespaceSpecifier")};N.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===u.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(u.comma)))return e;if(this.type===u.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(u.braceL);!this.eat(u.braceR);){if(t)t=!1;else if(this.expect(u.comma),this.afterTrailingComma(u.braceR))break;e.push(this.parseImportSpecifier())}return e};N.parseWithClause=function(){var e=[];if(!this.eat(u._with))return e;this.expect(u.braceL);for(var t={},i=!0;!this.eat(u.braceR);){if(i)i=!1;else if(this.expect(u.comma),this.afterTrailingComma(u.braceR))break;var r=this.parseImportAttribute(),s=r.key.type==="Identifier"?r.key.name:r.key.value;Ke(t,s)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+s+"'"),t[s]=!0,e.push(r)}return e};N.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===u.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(u.colon),this.type!==u.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")};N.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===u.string){var e=this.parseLiteral(this.value);return Tr.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)};N.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)};N.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type==="ExpressionStatement"&&e.expression.type==="Literal"&&typeof e.expression.value=="string"&&(this.input[e.start]==='"'||this.input[e.start]==="'")};var fe=U.prototype;fe.toAssignable=function(e,t,i){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&e.name==="await"&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",i&&this.checkPatternErrors(i,!0);for(var r=0,s=e.properties;r<s.length;r+=1){var n=s[r];this.toAssignable(n,t),n.type==="RestElement"&&(n.argument.type==="ArrayPattern"||n.argument.type==="ObjectPattern")&&this.raise(n.argument.start,"Unexpected token")}break;case"Property":e.kind!=="init"&&this.raise(e.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(e.value,t);break;case"ArrayExpression":e.type="ArrayPattern",i&&this.checkPatternErrors(i,!0),this.toAssignableList(e.elements,t);break;case"SpreadElement":e.type="RestElement",this.toAssignable(e.argument,t),e.argument.type==="AssignmentPattern"&&this.raise(e.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":e.operator!=="="&&this.raise(e.left.end,"Only '=' operator can be used for specifying default value."),e.type="AssignmentPattern",delete e.operator,this.toAssignable(e.left,t);break;case"ParenthesizedExpression":this.toAssignable(e.expression,t,i);break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!t)break;default:this.raise(e.start,"Assigning to rvalue")}else i&&this.checkPatternErrors(i,!0);return e};fe.toAssignableList=function(e,t){for(var i=e.length,r=0;r<i;r++){var s=e[r];s&&this.toAssignable(s,t)}if(i){var n=e[i-1];this.options.ecmaVersion===6&&t&&n&&n.type==="RestElement"&&n.argument.type!=="Identifier"&&this.unexpected(n.argument.start)}return e};fe.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")};fe.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==u.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")};fe.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case u.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(u.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case u.braceL:return this.parseObj(!0)}return this.parseIdent()};fe.parseBindingList=function(e,t,i,r){for(var s=[],n=!0;!this.eat(e);)if(n?n=!1:this.expect(u.comma),t&&this.type===u.comma)s.push(null);else{if(i&&this.afterTrailingComma(e))break;if(this.type===u.ellipsis){var a=this.parseRestBinding();this.parseBindingListItem(a),s.push(a),this.type===u.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}else s.push(this.parseAssignableListItem(r))}return s};fe.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t};fe.parseBindingListItem=function(e){return e};fe.parseMaybeDefault=function(e,t,i){if(i=i||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(u.eq))return i;var r=this.startNodeAt(e,t);return r.left=i,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")};fe.checkLValSimple=function(e,t,i){t===void 0&&(t=ut);var r=t!==ut;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(r?"Binding ":"Assigning to ")+e.name+" in strict mode"),r&&(t===Ne&&e.name==="let"&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),i&&(Ke(i,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),i[e.name]=!0),t!==Vi&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":r&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return r&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,i);default:this.raise(e.start,(r?"Binding":"Assigning to")+" rvalue")}};fe.checkLValPattern=function(e,t,i){switch(t===void 0&&(t=ut),e.type){case"ObjectPattern":for(var r=0,s=e.properties;r<s.length;r+=1){var n=s[r];this.checkLValInnerPattern(n,t,i)}break;case"ArrayPattern":for(var a=0,o=e.elements;a<o.length;a+=1){var h=o[a];h&&this.checkLValInnerPattern(h,t,i)}break;default:this.checkLValSimple(e,t,i)}};fe.checkLValInnerPattern=function(e,t,i){switch(t===void 0&&(t=ut),e.type){case"Property":this.checkLValInnerPattern(e.value,t,i);break;case"AssignmentPattern":this.checkLValPattern(e.left,t,i);break;case"RestElement":this.checkLValPattern(e.argument,t,i);break;default:this.checkLValPattern(e,t,i)}};var de=function(t,i,r,s,n){this.token=t,this.isExpr=!!i,this.preserveSpace=!!r,this.override=s,this.generator=!!n},$={b_stat:new de("{",!1),b_expr:new de("{",!0),b_tmpl:new de("${",!1),p_stat:new de("(",!1),p_expr:new de("(",!0),q_tmpl:new de("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new de("function",!1),f_expr:new de("function",!0),f_expr_gen:new de("function",!0,!1,null,!0),f_gen:new de("function",!1,!1,null,!0)},He=U.prototype;He.initialContext=function(){return[$.b_stat]};He.curContext=function(){return this.context[this.context.length-1]};He.braceIsBlock=function(e){var t=this.curContext();return t===$.f_expr||t===$.f_stat?!0:e===u.colon&&(t===$.b_stat||t===$.b_expr)?!t.isExpr:e===u._return||e===u.name&&this.exprAllowed?pe.test(this.input.slice(this.lastTokEnd,this.start)):e===u._else||e===u.semi||e===u.eof||e===u.parenR||e===u.arrow?!0:e===u.braceL?t===$.b_stat:e===u._var||e===u._const||e===u.name?!1:!this.exprAllowed};He.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token==="function")return t.generator}return!1};He.updateContext=function(e){var t,i=this.type;i.keyword&&e===u.dot?this.exprAllowed=!1:(t=i.updateContext)?t.call(this,e):this.exprAllowed=i.beforeExpr};He.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)};u.parenR.updateContext=u.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===$.b_stat&&this.curContext().token==="function"&&(e=this.context.pop()),this.exprAllowed=!e.isExpr};u.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?$.b_stat:$.b_expr),this.exprAllowed=!0};u.dollarBraceL.updateContext=function(){this.context.push($.b_tmpl),this.exprAllowed=!0};u.parenL.updateContext=function(e){var t=e===u._if||e===u._for||e===u._with||e===u._while;this.context.push(t?$.p_stat:$.p_expr),this.exprAllowed=!0};u.incDec.updateContext=function(){};u._function.updateContext=u._class.updateContext=function(e){e.beforeExpr&&e!==u._else&&!(e===u.semi&&this.curContext()!==$.p_stat)&&!(e===u._return&&pe.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===u.colon||e===u.braceL)&&this.curContext()===$.b_stat)?this.context.push($.f_expr):this.context.push($.f_stat),this.exprAllowed=!1};u.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};u.backQuote.updateContext=function(){this.curContext()===$.q_tmpl?this.context.pop():this.context.push($.q_tmpl),this.exprAllowed=!1};u.star.updateContext=function(e){if(e===u._function){var t=this.context.length-1;this.context[t]===$.f_expr?this.context[t]=$.f_expr_gen:this.context[t]=$.f_gen}this.exprAllowed=!0};u.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==u.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var T=U.prototype;T.checkPropClash=function(e,t,i){if(!(this.options.ecmaVersion>=9&&e.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r=e.key,s;switch(r.type){case"Identifier":s=r.name;break;case"Literal":s=String(r.value);break;default:return}var n=e.kind;if(this.options.ecmaVersion>=6){s==="__proto__"&&n==="init"&&(t.proto&&(i?i.doubleProto<0&&(i.doubleProto=r.start):this.raiseRecoverable(r.start,"Redefinition of __proto__ property")),t.proto=!0);return}s="$"+s;var a=t[s];if(a){var o;n==="init"?o=this.strict&&a.init||a.get||a.set:o=a.init||a[n],o&&this.raiseRecoverable(r.start,"Redefinition of property")}else a=t[s]={init:!1,get:!1,set:!1};a[n]=!0}};T.parseExpression=function(e,t){var i=this.start,r=this.startLoc,s=this.parseMaybeAssign(e,t);if(this.type===u.comma){var n=this.startNodeAt(i,r);for(n.expressions=[s];this.eat(u.comma);)n.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(n,"SequenceExpression")}return s};T.parseMaybeAssign=function(e,t,i){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,s=-1,n=-1,a=-1;t?(s=t.parenthesizedAssign,n=t.trailingComma,a=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new xt,r=!0);var o=this.start,h=this.startLoc;(this.type===u.parenL||this.type===u.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e==="await");var c=this.parseMaybeConditional(e,t);if(i&&(c=i.call(this,c,o,h)),this.type.isAssign){var l=this.startNodeAt(o,h);return l.operator=this.value,this.type===u.eq&&(c=this.toAssignable(c,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=c.start&&(t.shorthandAssign=-1),this.type===u.eq?this.checkLValPattern(c):this.checkLValSimple(c),l.left=c,this.next(),l.right=this.parseMaybeAssign(e),a>-1&&(t.doubleProto=a),this.finishNode(l,"AssignmentExpression")}else r&&this.checkExpressionErrors(t,!0);return s>-1&&(t.parenthesizedAssign=s),n>-1&&(t.trailingComma=n),c};T.parseMaybeConditional=function(e,t){var i=this.start,r=this.startLoc,s=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return s;if(this.eat(u.question)){var n=this.startNodeAt(i,r);return n.test=s,n.consequent=this.parseMaybeAssign(),this.expect(u.colon),n.alternate=this.parseMaybeAssign(e),this.finishNode(n,"ConditionalExpression")}return s};T.parseExprOps=function(e,t){var i=this.start,r=this.startLoc,s=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||s.start===i&&s.type==="ArrowFunctionExpression"?s:this.parseExprOp(s,i,r,-1,e)};T.parseExprOp=function(e,t,i,r,s){var n=this.type.binop;if(n!=null&&(!s||this.type!==u._in)&&n>r){var a=this.type===u.logicalOR||this.type===u.logicalAND,o=this.type===u.coalesce;o&&(n=u.logicalAND.binop);var h=this.value;this.next();var c=this.start,l=this.startLoc,f=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,s),c,l,n,s),g=this.buildBinary(t,i,e,f,h,a||o);return(a&&this.type===u.coalesce||o&&(this.type===u.logicalOR||this.type===u.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(g,t,i,r,s)}return e};T.buildBinary=function(e,t,i,r,s,n){r.type==="PrivateIdentifier"&&this.raise(r.start,"Private identifier can only be left side of binary expression");var a=this.startNodeAt(e,t);return a.left=i,a.operator=s,a.right=r,this.finishNode(a,n?"LogicalExpression":"BinaryExpression")};T.parseMaybeUnary=function(e,t,i,r){var s=this.start,n=this.startLoc,a;if(this.isContextual("await")&&this.canAwait)a=this.parseAwait(r),t=!0;else if(this.type.prefix){var o=this.startNode(),h=this.type===u.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,h,r),this.checkExpressionErrors(e,!0),h?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&Bi(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&Rt(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):t=!0,a=this.finishNode(o,h?"UpdateExpression":"UnaryExpression")}else if(!t&&this.type===u.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),a=this.parsePrivateIdent(),this.type!==u._in&&this.unexpected();else{if(a=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return a;for(;this.type.postfix&&!this.canInsertSemicolon();){var c=this.startNodeAt(s,n);c.operator=this.value,c.prefix=!1,c.argument=a,this.checkLValSimple(a),this.next(),a=this.finishNode(c,"UpdateExpression")}}if(!i&&this.eat(u.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(s,n,a,this.parseMaybeUnary(null,!1,!1,r),"**",!1);else return a};function Bi(e){return e.type==="Identifier"||e.type==="ParenthesizedExpression"&&Bi(e.expression)}function Rt(e){return e.type==="MemberExpression"&&e.property.type==="PrivateIdentifier"||e.type==="ChainExpression"&&Rt(e.expression)||e.type==="ParenthesizedExpression"&&Rt(e.expression)}T.parseExprSubscripts=function(e,t){var i=this.start,r=this.startLoc,s=this.parseExprAtom(e,t);if(s.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return s;var n=this.parseSubscripts(s,i,r,!1,t);return e&&n.type==="MemberExpression"&&(e.parenthesizedAssign>=n.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=n.start&&(e.parenthesizedBind=-1),e.trailingComma>=n.start&&(e.trailingComma=-1)),n};T.parseSubscripts=function(e,t,i,r,s){for(var n=this.options.ecmaVersion>=8&&e.type==="Identifier"&&e.name==="async"&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,a=!1;;){var o=this.parseSubscript(e,t,i,r,n,a,s);if(o.optional&&(a=!0),o===e||o.type==="ArrowFunctionExpression"){if(a){var h=this.startNodeAt(t,i);h.expression=o,o=this.finishNode(h,"ChainExpression")}return o}e=o}};T.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(u.arrow)};T.parseSubscriptAsyncArrow=function(e,t,i,r){return this.parseArrowExpression(this.startNodeAt(e,t),i,!0,r)};T.parseSubscript=function(e,t,i,r,s,n,a){var o=this.options.ecmaVersion>=11,h=o&&this.eat(u.questionDot);r&&h&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var c=this.eat(u.bracketL);if(c||h&&this.type!==u.parenL&&this.type!==u.backQuote||this.eat(u.dot)){var l=this.startNodeAt(t,i);l.object=e,c?(l.property=this.parseExpression(),this.expect(u.bracketR)):this.type===u.privateId&&e.type!=="Super"?l.property=this.parsePrivateIdent():l.property=this.parseIdent(this.options.allowReserved!=="never"),l.computed=!!c,o&&(l.optional=h),e=this.finishNode(l,"MemberExpression")}else if(!r&&this.eat(u.parenL)){var f=new xt,g=this.yieldPos,p=this.awaitPos,x=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var y=this.parseExprList(u.parenR,this.options.ecmaVersion>=8,!1,f);if(s&&!h&&this.shouldParseAsyncArrow())return this.checkPatternErrors(f,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=g,this.awaitPos=p,this.awaitIdentPos=x,this.parseSubscriptAsyncArrow(t,i,y,a);this.checkExpressionErrors(f,!0),this.yieldPos=g||this.yieldPos,this.awaitPos=p||this.awaitPos,this.awaitIdentPos=x||this.awaitIdentPos;var w=this.startNodeAt(t,i);w.callee=e,w.arguments=y,o&&(w.optional=h),e=this.finishNode(w,"CallExpression")}else if(this.type===u.backQuote){(h||n)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var E=this.startNodeAt(t,i);E.tag=e,E.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(E,"TaggedTemplateExpression")}return e};T.parseExprAtom=function(e,t,i){this.type===u.slash&&this.readRegexp();var r,s=this.potentialArrowAt===this.start;switch(this.type){case u._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),r=this.startNode(),this.next(),this.type===u.parenL&&!this.allowDirectSuper&&this.raise(r.start,"super() call outside constructor of a subclass"),this.type!==u.dot&&this.type!==u.bracketL&&this.type!==u.parenL&&this.unexpected(),this.finishNode(r,"Super");case u._this:return r=this.startNode(),this.next(),this.finishNode(r,"ThisExpression");case u.name:var n=this.start,a=this.startLoc,o=this.containsEsc,h=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&h.name==="async"&&!this.canInsertSemicolon()&&this.eat(u._function))return this.overrideContext($.f_expr),this.parseFunction(this.startNodeAt(n,a),0,!1,!0,t);if(s&&!this.canInsertSemicolon()){if(this.eat(u.arrow))return this.parseArrowExpression(this.startNodeAt(n,a),[h],!1,t);if(this.options.ecmaVersion>=8&&h.name==="async"&&this.type===u.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return h=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(u.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(n,a),[h],!0,t)}return h;case u.regexp:var c=this.value;return r=this.parseLiteral(c.value),r.regex={pattern:c.pattern,flags:c.flags},r;case u.num:case u.string:return this.parseLiteral(this.value);case u._null:case u._true:case u._false:return r=this.startNode(),r.value=this.type===u._null?null:this.type===u._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,"Literal");case u.parenL:var l=this.start,f=this.parseParenAndDistinguishExpression(s,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(f)&&(e.parenthesizedAssign=l),e.parenthesizedBind<0&&(e.parenthesizedBind=l)),f;case u.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(u.bracketR,!0,!0,e),this.finishNode(r,"ArrayExpression");case u.braceL:return this.overrideContext($.b_expr),this.parseObj(!1,e);case u._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case u._class:return this.parseClass(this.startNode(),!1);case u._new:return this.parseNew();case u.backQuote:return this.parseTemplate();case u._import:return this.options.ecmaVersion>=11?this.parseExprImport(i):this.unexpected();default:return this.parseExprAtomDefault()}};T.parseExprAtomDefault=function(){this.unexpected()};T.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===u.parenL&&!e)return this.parseDynamicImport(t);if(this.type===u.dot){var i=this.startNodeAt(t.start,t.loc&&t.loc.start);return i.name="import",t.meta=this.finishNode(i,"Identifier"),this.parseImportMeta(t)}else this.unexpected()};T.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(u.parenR)?e.options=null:(this.expect(u.comma),this.afterTrailingComma(u.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(u.parenR)||(this.expect(u.comma),this.afterTrailingComma(u.parenR)||this.unexpected())));else if(!this.eat(u.parenR)){var t=this.start;this.eat(u.comma)&&this.eat(u.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")};T.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="meta"&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),t&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")};T.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(t,"Literal")};T.parseParenExpression=function(){this.expect(u.parenL);var e=this.parseExpression();return this.expect(u.parenR),e};T.shouldParseArrow=function(e){return!this.canInsertSemicolon()};T.parseParenAndDistinguishExpression=function(e,t){var i=this.start,r=this.startLoc,s,n=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a=this.start,o=this.startLoc,h=[],c=!0,l=!1,f=new xt,g=this.yieldPos,p=this.awaitPos,x;for(this.yieldPos=0,this.awaitPos=0;this.type!==u.parenR;)if(c?c=!1:this.expect(u.comma),n&&this.afterTrailingComma(u.parenR,!0)){l=!0;break}else if(this.type===u.ellipsis){x=this.start,h.push(this.parseParenItem(this.parseRestBinding())),this.type===u.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else h.push(this.parseMaybeAssign(!1,f,this.parseParenItem));var y=this.lastTokEnd,w=this.lastTokEndLoc;if(this.expect(u.parenR),e&&this.shouldParseArrow(h)&&this.eat(u.arrow))return this.checkPatternErrors(f,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=g,this.awaitPos=p,this.parseParenArrowList(i,r,h,t);(!h.length||l)&&this.unexpected(this.lastTokStart),x&&this.unexpected(x),this.checkExpressionErrors(f,!0),this.yieldPos=g||this.yieldPos,this.awaitPos=p||this.awaitPos,h.length>1?(s=this.startNodeAt(a,o),s.expressions=h,this.finishNodeAt(s,"SequenceExpression",y,w)):s=h[0]}else s=this.parseParenExpression();if(this.options.preserveParens){var E=this.startNodeAt(i,r);return E.expression=s,this.finishNode(E,"ParenthesizedExpression")}else return s};T.parseParenItem=function(e){return e};T.parseParenArrowList=function(e,t,i,r){return this.parseArrowExpression(this.startNodeAt(e,t),i,!1,r)};var Lr=[];T.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===u.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var i=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="target"&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),i&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var r=this.start,s=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,s,!0,!1),this.eat(u.parenL)?e.arguments=this.parseExprList(u.parenR,this.options.ecmaVersion>=8,!1):e.arguments=Lr,this.finishNode(e,"NewExpression")};T.parseTemplateElement=function(e){var t=e.isTagged,i=this.startNode();return this.type===u.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),i.value={raw:this.value.replace(/\r\n?/g,`
|
|
21
|
+
`),cooked:null}):i.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
|
|
22
|
+
`),cooked:this.value},this.next(),i.tail=this.type===u.backQuote,this.finishNode(i,"TemplateElement")};T.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var i=this.startNode();this.next(),i.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(i.quasis=[r];!r.tail;)this.type===u.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(u.dollarBraceL),i.expressions.push(this.parseExpression()),this.expect(u.braceR),i.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(i,"TemplateLiteral")};T.isAsyncProp=function(e){return!e.computed&&e.key.type==="Identifier"&&e.key.name==="async"&&(this.type===u.name||this.type===u.num||this.type===u.string||this.type===u.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===u.star)&&!pe.test(this.input.slice(this.lastTokEnd,this.start))};T.parseObj=function(e,t){var i=this.startNode(),r=!0,s={};for(i.properties=[],this.next();!this.eat(u.braceR);){if(r)r=!1;else if(this.expect(u.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(u.braceR))break;var n=this.parseProperty(e,t);e||this.checkPropClash(n,s,t),i.properties.push(n)}return this.finishNode(i,e?"ObjectPattern":"ObjectExpression")};T.parseProperty=function(e,t){var i=this.startNode(),r,s,n,a;if(this.options.ecmaVersion>=9&&this.eat(u.ellipsis))return e?(i.argument=this.parseIdent(!1),this.type===u.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(i,"RestElement")):(i.argument=this.parseMaybeAssign(!1,t),this.type===u.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(i,"SpreadElement"));this.options.ecmaVersion>=6&&(i.method=!1,i.shorthand=!1,(e||t)&&(n=this.start,a=this.startLoc),e||(r=this.eat(u.star)));var o=this.containsEsc;return this.parsePropertyName(i),!e&&!o&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(i)?(s=!0,r=this.options.ecmaVersion>=9&&this.eat(u.star),this.parsePropertyName(i)):s=!1,this.parsePropertyValue(i,e,r,s,n,a,t,o),this.finishNode(i,"Property")};T.parseGetterSetter=function(e){e.kind=e.key.name,this.parsePropertyName(e),e.value=this.parseMethod(!1);var t=e.kind==="get"?0:1;if(e.value.params.length!==t){var i=e.value.start;e.kind==="get"?this.raiseRecoverable(i,"getter should have no params"):this.raiseRecoverable(i,"setter should have exactly one param")}else e.kind==="set"&&e.value.params[0].type==="RestElement"&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")};T.parsePropertyValue=function(e,t,i,r,s,n,a,o){(i||r)&&this.type===u.colon&&this.unexpected(),this.eat(u.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),e.kind="init"):this.options.ecmaVersion>=6&&this.type===u.parenL?(t&&this.unexpected(),e.kind="init",e.method=!0,e.value=this.parseMethod(i,r)):!t&&!o&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type==="Identifier"&&(e.key.name==="get"||e.key.name==="set")&&this.type!==u.comma&&this.type!==u.braceR&&this.type!==u.eq?((i||r)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type==="Identifier"?((i||r)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=s),e.kind="init",t?e.value=this.parseMaybeDefault(s,n,this.copyNode(e.key)):this.type===u.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),e.value=this.parseMaybeDefault(s,n,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.shorthand=!0):this.unexpected()};T.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(u.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(u.bracketR),e.key;e.computed=!1}return e.key=this.type===u.num||this.type===u.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};T.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)};T.parseMethod=function(e,t,i){var r=this.startNode(),s=this.yieldPos,n=this.awaitPos,a=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(qt(t,r.generator)|$t|(i?Di:0)),this.expect(u.parenL),r.params=this.parseBindingList(u.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=s,this.awaitPos=n,this.awaitIdentPos=a,this.finishNode(r,"FunctionExpression")};T.parseArrowExpression=function(e,t,i,r){var s=this.yieldPos,n=this.awaitPos,a=this.awaitIdentPos;return this.enterScope(qt(i,!1)|Pi),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!i),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=s,this.awaitPos=n,this.awaitIdentPos=a,this.finishNode(e,"ArrowFunctionExpression")};T.parseFunctionBody=function(e,t,i,r){var s=t&&this.type!==u.braceL,n=this.strict,a=!1;if(s)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!n||o)&&(a=this.strictDirective(this.end),a&&o&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var h=this.labels;this.labels=[],a&&(this.strict=!0),this.checkParams(e,!n&&!a&&!t&&!i&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,Vi),e.body=this.parseBlock(!1,void 0,a&&!n),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=h}this.exitScope()};T.isSimpleParamList=function(e){for(var t=0,i=e;t<i.length;t+=1){var r=i[t];if(r.type!=="Identifier")return!1}return!0};T.checkParams=function(e,t){for(var i=Object.create(null),r=0,s=e.params;r<s.length;r+=1){var n=s[r];this.checkLValInnerPattern(n,Ut,t?null:i)}};T.parseExprList=function(e,t,i,r){for(var s=[],n=!0;!this.eat(e);){if(n)n=!1;else if(this.expect(u.comma),t&&this.afterTrailingComma(e))break;var a=void 0;i&&this.type===u.comma?a=null:this.type===u.ellipsis?(a=this.parseSpread(r),r&&this.type===u.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):a=this.parseMaybeAssign(!1,r),s.push(a)}return s};T.checkUnreserved=function(e){var t=e.start,i=e.end,r=e.name;if(this.inGenerator&&r==="yield"&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&r==="await"&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),this.currentThisScope().inClassFieldInit&&r==="arguments"&&this.raiseRecoverable(t,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(r==="arguments"||r==="await")&&this.raise(t,"Cannot use "+r+" in class static initialization block"),this.keywords.test(r)&&this.raise(t,"Unexpected keyword '"+r+"'"),!(this.options.ecmaVersion<6&&this.input.slice(t,i).indexOf("\\")!==-1)){var s=this.strict?this.reservedWordsStrict:this.reservedWords;s.test(r)&&(!this.inAsync&&r==="await"&&this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+r+"' is reserved"))}};T.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,"Identifier"),e||(this.checkUnreserved(t),t.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t};T.parseIdentNode=function(){var e=this.startNode();return this.type===u.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name==="class"||e.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=u.name):this.unexpected(),e};T.parsePrivateIdent=function(){var e=this.startNode();return this.type===u.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,"Private field '#"+e.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e};T.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===u.semi||this.canInsertSemicolon()||this.type!==u.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(u.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")};T.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,"AwaitExpression")};var pt=U.prototype;pt.raise=function(e,t){var i=Ai(this.input,e);t+=" ("+i.line+":"+i.column+")";var r=new SyntaxError(t);throw r.pos=e,r.loc=i,r.raisedAt=this.pos,r};pt.raiseRecoverable=pt.raise;pt.curPosition=function(){if(this.options.locations)return new et(this.curLine,this.pos-this.lineStart)};var Te=U.prototype,Br=function(t){this.flags=t,this.var=[],this.lexical=[],this.functions=[],this.inClassFieldInit=!1};Te.enterScope=function(e){this.scopeStack.push(new Br(e))};Te.exitScope=function(){this.scopeStack.pop()};Te.treatFunctionsAsVarInScope=function(e){return e.flags&ze||!this.inModule&&e.flags&tt};Te.declareName=function(e,t,i){var r=!1;if(t===Ne){var s=this.currentScope();r=s.lexical.indexOf(e)>-1||s.functions.indexOf(e)>-1||s.var.indexOf(e)>-1,s.lexical.push(e),this.inModule&&s.flags&tt&&delete this.undefinedExports[e]}else if(t===Oi){var n=this.currentScope();n.lexical.push(e)}else if(t===Mi){var a=this.currentScope();this.treatFunctionsAsVar?r=a.lexical.indexOf(e)>-1:r=a.lexical.indexOf(e)>-1||a.var.indexOf(e)>-1,a.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var h=this.scopeStack[o];if(h.lexical.indexOf(e)>-1&&!(h.flags&Ri&&h.lexical[0]===e)||!this.treatFunctionsAsVarInScope(h)&&h.functions.indexOf(e)>-1){r=!0;break}if(h.var.push(e),this.inModule&&h.flags&tt&&delete this.undefinedExports[e],h.flags&Wt)break}r&&this.raiseRecoverable(i,"Identifier '"+e+"' has already been declared")};Te.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)};Te.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};Te.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&Wt)return t}};Te.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&Wt&&!(t.flags&Pi))return t}};var yt=function(t,i,r){this.type="",this.start=i,this.end=0,t.options.locations&&(this.loc=new gt(t,r)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[i,0])},rt=U.prototype;rt.startNode=function(){return new yt(this,this.start,this.startLoc)};rt.startNodeAt=function(e,t){return new yt(this,e,t)};function Fi(e,t,i,r){return e.type=t,e.end=i,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=i),e}rt.finishNode=function(e,t){return Fi.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)};rt.finishNodeAt=function(e,t,i,r){return Fi.call(this,e,t,i,r)};rt.copyNode=function(e){var t=new yt(this,e.start,this.startLoc);for(var i in e)t[i]=e[i];return t};var Fr="Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz",ji="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",$i=ji+" Extended_Pictographic",Wi=$i,qi=Wi+" EBase EComp EMod EPres ExtPict",Ui=qi,jr=Ui,$r={9:ji,10:$i,11:Wi,12:qi,13:Ui,14:jr},Wr="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",qr={9:"",10:"",11:"",12:"",13:"",14:Wr},ti="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",Ki="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",zi=Ki+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",Hi=zi+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Gi=Hi+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Yi=Gi+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Ur=Yi+" "+Fr,Kr={9:Ki,10:zi,11:Hi,12:Gi,13:Yi,14:Ur},Qi={};function zr(e){var t=Qi[e]={binary:ke($r[e]+" "+ti),binaryOfStrings:ke(qr[e]),nonBinary:{General_Category:ke(ti),Script:ke(Kr[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(var Et=0,ii=[9,10,11,12,13,14];Et<ii.length;Et+=1){var Hr=ii[Et];zr(Hr)}var S=U.prototype,ft=function(t,i){this.parent=t,this.base=i||this};ft.prototype.separatedFrom=function(t){for(var i=this;i;i=i.parent)for(var r=t;r;r=r.parent)if(i.base===r.base&&i!==r)return!0;return!1};ft.prototype.sibling=function(){return new ft(this.parent,this.base)};var be=function(t){this.parser=t,this.validFlags="gim"+(t.options.ecmaVersion>=6?"uy":"")+(t.options.ecmaVersion>=9?"s":"")+(t.options.ecmaVersion>=13?"d":"")+(t.options.ecmaVersion>=15?"v":""),this.unicodeProperties=Qi[t.options.ecmaVersion>=14?14:t.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};be.prototype.reset=function(t,i,r){var s=r.indexOf("v")!==-1,n=r.indexOf("u")!==-1;this.start=t|0,this.source=i+"",this.flags=r,s&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=n&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=n&&this.parser.options.ecmaVersion>=9)};be.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)};be.prototype.at=function(t,i){i===void 0&&(i=!1);var r=this.source,s=r.length;if(t>=s)return-1;var n=r.charCodeAt(t);if(!(i||this.switchU)||n<=55295||n>=57344||t+1>=s)return n;var a=r.charCodeAt(t+1);return a>=56320&&a<=57343?(n<<10)+a-56613888:n};be.prototype.nextIndex=function(t,i){i===void 0&&(i=!1);var r=this.source,s=r.length;if(t>=s)return s;var n=r.charCodeAt(t),a;return!(i||this.switchU)||n<=55295||n>=57344||t+1>=s||(a=r.charCodeAt(t+1))<56320||a>57343?t+1:t+2};be.prototype.current=function(t){return t===void 0&&(t=!1),this.at(this.pos,t)};be.prototype.lookahead=function(t){return t===void 0&&(t=!1),this.at(this.nextIndex(this.pos,t),t)};be.prototype.advance=function(t){t===void 0&&(t=!1),this.pos=this.nextIndex(this.pos,t)};be.prototype.eat=function(t,i){return i===void 0&&(i=!1),this.current(i)===t?(this.advance(i),!0):!1};be.prototype.eatChars=function(t,i){i===void 0&&(i=!1);for(var r=this.pos,s=0,n=t;s<n.length;s+=1){var a=n[s],o=this.at(r,i);if(o===-1||o!==a)return!1;r=this.nextIndex(r,i)}return this.pos=r,!0};S.validateRegExpFlags=function(e){for(var t=e.validFlags,i=e.flags,r=!1,s=!1,n=0;n<i.length;n++){var a=i.charAt(n);t.indexOf(a)===-1&&this.raise(e.start,"Invalid regular expression flag"),i.indexOf(a,n+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),a==="u"&&(r=!0),a==="v"&&(s=!0)}this.options.ecmaVersion>=15&&r&&s&&this.raise(e.start,"Invalid regular expression flag")};function Gr(e){for(var t in e)return!0;return!1}S.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&Gr(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))};S.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var t=0,i=e.backReferenceNames;t<i.length;t+=1){var r=i[t];e.groupNames[r]||e.raise("Invalid named capture referenced")}};S.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new ft(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise("Nothing to repeat"),e.eat(123)&&e.raise("Lone quantifier brackets")};S.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););};S.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise("Invalid quantifier"),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1};S.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var i=!1;if(this.options.ecmaVersion>=9&&(i=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!i,!0}return e.pos=t,!1};S.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1};S.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)};S.regexp_eatBracedQuantifier=function(e,t){var i=e.pos;if(e.eat(123)){var r=0,s=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(s=e.lastIntValue),e.eat(125)))return s!==-1&&s<r&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=i}return!1};S.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)};S.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1};S.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var i=this.regexp_eatModifiers(e),r=e.eat(45);if(i||r){for(var s=0;s<i.length;s++){var n=i.charAt(s);i.indexOf(n,s+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(r){var a=this.regexp_eatModifiers(e);!i&&!a&&e.current()===58&&e.raise("Invalid regular expression modifiers");for(var o=0;o<a.length;o++){var h=a.charAt(o);(a.indexOf(h,o+1)>-1||i.indexOf(h)>-1)&&e.raise("Duplicate regular expression modifiers")}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise("Unterminated group")}}e.pos=t}return!1};S.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1};S.regexp_eatModifiers=function(e){for(var t="",i=0;(i=e.current())!==-1&&Yr(i);)t+=Se(i),e.advance();return t};function Yr(e){return e===105||e===109||e===115}S.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)};S.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1};S.regexp_eatSyntaxCharacter=function(e){var t=e.current();return Xi(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Xi(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}S.regexp_eatPatternCharacters=function(e){for(var t=e.pos,i=0;(i=e.current())!==-1&&!Xi(i);)e.advance();return e.pos!==t};S.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124?(e.advance(),!0):!1};S.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var t=this.options.ecmaVersion>=16,i=e.groupNames[e.lastStringValue];if(i)if(t)for(var r=0,s=i;r<s.length;r+=1){var n=s[r];n.separatedFrom(e.branchID)||e.raise("Duplicate capture group name")}else e.raise("Duplicate capture group name");t?(i||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}};S.regexp_eatGroupName=function(e){if(e.lastStringValue="",e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise("Invalid capture group name")}return!1};S.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=Se(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=Se(e.lastIntValue);return!0}return!1};S.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,i=this.options.ecmaVersion>=11,r=e.current(i);return e.advance(i),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,i)&&(r=e.lastIntValue),Qr(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Qr(e){return _e(e,!0)||e===36||e===95}S.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,i=this.options.ecmaVersion>=11,r=e.current(i);return e.advance(i),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,i)&&(r=e.lastIntValue),Xr(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Xr(e){return We(e,!0)||e===36||e===95||e===8204||e===8205}S.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)};S.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var i=e.lastIntValue;if(e.switchU)return i>e.maxBackReference&&(e.maxBackReference=i),!0;if(i<=e.numCapturingParens)return!0;e.pos=t}return!1};S.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1};S.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)};S.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1};S.regexp_eatZero=function(e){return e.current()===48&&!wt(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1};S.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114?(e.lastIntValue=13,e.advance(),!0):!1};S.regexp_eatControlLetter=function(e){var t=e.current();return Zi(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Zi(e){return e>=65&&e<=90||e>=97&&e<=122}S.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var i=e.pos,r=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var s=e.lastIntValue;if(r&&s>=55296&&s<=56319){var n=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var a=e.lastIntValue;if(a>=56320&&a<=57343)return e.lastIntValue=(s-55296)*1024+(a-56320)+65536,!0}e.pos=n,e.lastIntValue=s}return!0}if(r&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&Zr(e.lastIntValue))return!0;r&&e.raise("Invalid unicode escape"),e.pos=i}return!1};function Zr(e){return e>=0&&e<=1114111}S.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)?(e.lastIntValue=t,e.advance(),!0):!1};S.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var Ji=0,Ee=1,ce=2;S.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(Jr(t))return e.lastIntValue=-1,e.advance(),Ee;var i=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((i=t===80)||t===112)){e.lastIntValue=-1,e.advance();var r;if(e.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return i&&r===ce&&e.raise("Invalid property name"),r;e.raise("Invalid property name")}return Ji};function Jr(e){return e===100||e===68||e===115||e===83||e===119||e===87}S.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var i=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,i,r),Ee}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var s=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,s)}return Ji};S.regexp_validateUnicodePropertyNameAndValue=function(e,t,i){Ke(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(i)||e.raise("Invalid property value")};S.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return Ee;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return ce;e.raise("Invalid property name")};S.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";er(t=e.current());)e.lastStringValue+=Se(t),e.advance();return e.lastStringValue!==""};function er(e){return Zi(e)||e===95}S.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";es(t=e.current());)e.lastStringValue+=Se(t),e.advance();return e.lastStringValue!==""};function es(e){return er(e)||wt(e)}S.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)};S.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),i=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&i===ce&&e.raise("Negated character class may contain strings"),!0}return!1};S.regexp_classContents=function(e){return e.current()===93?Ee:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),Ee)};S.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var i=e.lastIntValue;e.switchU&&(t===-1||i===-1)&&e.raise("Invalid character class"),t!==-1&&i!==-1&&t>i&&e.raise("Range out of order in character class")}}};S.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var i=e.current();(i===99||rr(i))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var r=e.current();return r!==93?(e.lastIntValue=r,e.advance(),!0):!1};S.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)};S.regexp_classSetExpression=function(e){var t=Ee,i;if(!this.regexp_eatClassSetRange(e))if(i=this.regexp_eatClassSetOperand(e)){i===ce&&(t=ce);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(i=this.regexp_eatClassSetOperand(e))){i!==ce&&(t=Ee);continue}e.raise("Invalid character in character class")}if(r!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(r!==e.pos)return t}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(i=this.regexp_eatClassSetOperand(e),!i)return t;i===ce&&(t=ce)}};S.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var i=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;return i!==-1&&r!==-1&&i>r&&e.raise("Range out of order in character class"),!0}e.pos=t}return!1};S.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?Ee:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)};S.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var i=e.eat(94),r=this.regexp_classContents(e);if(e.eat(93))return i&&r===ce&&e.raise("Negated character class may contain strings"),r;e.pos=t}if(e.eat(92)){var s=this.regexp_eatCharacterClassEscape(e);if(s)return s;e.pos=t}return null};S.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var i=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return i}else e.raise("Invalid escape");e.pos=t}return null};S.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===ce&&(t=ce);return t};S.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?Ee:ce};S.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var i=e.current();return i<0||i===e.lookahead()&&ts(i)||is(i)?!1:(e.advance(),e.lastIntValue=i,!0)};function ts(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function is(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}S.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return rs(t)?(e.lastIntValue=t,e.advance(),!0):!1};function rs(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}S.regexp_eatClassControlLetter=function(e){var t=e.current();return wt(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1};S.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=t}return!1};S.regexp_eatDecimalDigits=function(e){var t=e.pos,i=0;for(e.lastIntValue=0;wt(i=e.current());)e.lastIntValue=10*e.lastIntValue+(i-48),e.advance();return e.pos!==t};function wt(e){return e>=48&&e<=57}S.regexp_eatHexDigits=function(e){var t=e.pos,i=0;for(e.lastIntValue=0;tr(i=e.current());)e.lastIntValue=16*e.lastIntValue+ir(i),e.advance();return e.pos!==t};function tr(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function ir(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}S.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var i=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=t*64+i*8+e.lastIntValue:e.lastIntValue=t*8+i}else e.lastIntValue=t;return!0}return!1};S.regexp_eatOctalDigit=function(e){var t=e.current();return rr(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function rr(e){return e>=48&&e<=55}S.regexp_eatFixedHexDigits=function(e,t){var i=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var s=e.current();if(!tr(s))return e.pos=i,!1;e.lastIntValue=16*e.lastIntValue+ir(s),e.advance()}return!0};var zt=function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new gt(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},D=U.prototype;D.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new zt(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};D.getToken=function(){return this.next(),new zt(this)};typeof Symbol<"u"&&(D[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===u.eof,value:t}}}});D.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(u.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())};D.readToken=function(e){return _e(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)};D.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=56320)return e;var t=this.input.charCodeAt(this.pos+1);return t<=56319||t>=57344?e:(e<<10)+t-56613888};D.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,i=this.input.indexOf("*/",this.pos+=2);if(i===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=i+2,this.options.locations)for(var r=void 0,s=t;(r=Ci(this.input,s,this.pos))>-1;)++this.curLine,s=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,i),t,this.pos,e,this.curPosition())};D.skipLineComment=function(e){for(var t=this.pos,i=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!Ue(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,i,this.curPosition())};D.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(e>8&&e<14||e>=5760&&ki.test(String.fromCharCode(e)))++this.pos;else break e}}};D.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var i=this.type;this.type=e,this.value=t,this.updateContext(i)};D.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(u.ellipsis)):(++this.pos,this.finishToken(u.dot))};D.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(u.assign,2):this.finishOp(u.slash,1)};D.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),i=1,r=e===42?u.star:u.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++i,r=u.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(u.assign,i+1):this.finishOp(r,i)};D.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);if(t===e){if(this.options.ecmaVersion>=12){var i=this.input.charCodeAt(this.pos+2);if(i===61)return this.finishOp(u.assign,3)}return this.finishOp(e===124?u.logicalOR:u.logicalAND,2)}return t===61?this.finishOp(u.assign,2):this.finishOp(e===124?u.bitwiseOR:u.bitwiseAND,1)};D.readToken_caret=function(){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(u.assign,2):this.finishOp(u.bitwiseXOR,1)};D.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||pe.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(u.incDec,2):t===61?this.finishOp(u.assign,2):this.finishOp(u.plusMin,1)};D.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),i=1;return t===e?(i=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+i)===61?this.finishOp(u.assign,i+1):this.finishOp(u.bitShift,i)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(i=2),this.finishOp(u.relational,i))};D.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(u.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(u.arrow)):this.finishOp(e===61?u.eq:u.prefix,1)};D.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var i=this.input.charCodeAt(this.pos+2);if(i<48||i>57)return this.finishOp(u.questionDot,2)}if(t===63){if(e>=12){var r=this.input.charCodeAt(this.pos+2);if(r===61)return this.finishOp(u.assign,3)}return this.finishOp(u.coalesce,2)}}return this.finishOp(u.question,1)};D.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),_e(t,!0)||t===92))return this.finishToken(u.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+Se(t)+"'")};D.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(u.parenL);case 41:return++this.pos,this.finishToken(u.parenR);case 59:return++this.pos,this.finishToken(u.semi);case 44:return++this.pos,this.finishToken(u.comma);case 91:return++this.pos,this.finishToken(u.bracketL);case 93:return++this.pos,this.finishToken(u.bracketR);case 123:return++this.pos,this.finishToken(u.braceL);case 125:return++this.pos,this.finishToken(u.braceR);case 58:return++this.pos,this.finishToken(u.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(u.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(u.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+Se(e)+"'")};D.finishOp=function(e,t){var i=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,i)};D.readRegexp=function(){for(var e,t,i=this.pos;;){this.pos>=this.input.length&&this.raise(i,"Unterminated regular expression");var r=this.input.charAt(this.pos);if(pe.test(r)&&this.raise(i,"Unterminated regular expression"),e)e=!1;else{if(r==="[")t=!0;else if(r==="]"&&t)t=!1;else if(r==="/"&&!t)break;e=r==="\\"}++this.pos}var s=this.input.slice(i,this.pos);++this.pos;var n=this.pos,a=this.readWord1();this.containsEsc&&this.unexpected(n);var o=this.regexpState||(this.regexpState=new be(this));o.reset(i,s,a),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var h=null;try{h=new RegExp(s,a)}catch{}return this.finishToken(u.regexp,{pattern:s,flags:a,value:h})};D.readInt=function(e,t,i){for(var r=this.options.ecmaVersion>=12&&t===void 0,s=i&&this.input.charCodeAt(this.pos)===48,n=this.pos,a=0,o=0,h=0,c=t??1/0;h<c;++h,++this.pos){var l=this.input.charCodeAt(this.pos),f=void 0;if(r&&l===95){s&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),o===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),h===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=l;continue}if(l>=97?f=l-97+10:l>=65?f=l-65+10:l>=48&&l<=57?f=l-48:f=1/0,f>=e)break;o=l,a=a*e+f}return r&&o===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===n||t!=null&&this.pos-n!==t?null:a};function ss(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}function sr(e){return typeof BigInt!="function"?null:BigInt(e.replace(/_/g,""))}D.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var i=this.readInt(e);return i==null&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(i=sr(this.input.slice(t,this.pos)),++this.pos):_e(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(u.num,i)};D.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,"Invalid number");var i=this.pos-t>=2&&this.input.charCodeAt(t)===48;i&&this.strict&&this.raise(t,"Invalid number");var r=this.input.charCodeAt(this.pos);if(!i&&!e&&this.options.ecmaVersion>=11&&r===110){var s=sr(this.input.slice(t,this.pos));return++this.pos,_e(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(u.num,s)}i&&/[89]/.test(this.input.slice(t,this.pos))&&(i=!1),r===46&&!i&&(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),(r===69||r===101)&&!i&&(r=this.input.charCodeAt(++this.pos),(r===43||r===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,"Invalid number")),_e(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var n=ss(this.input.slice(t,this.pos),i);return this.finishToken(u.num,n)};D.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var i=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(i,"Code point out of bounds")}else t=this.readHexChar(4);return t};D.readString=function(e){for(var t="",i=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(i,this.pos),t+=this.readEscapedChar(!1),i=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(Ue(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(i,this.pos++),this.finishToken(u.string,t)};var nr={};D.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===nr)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1};D.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw nr;this.raise(e,t)};D.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var i=this.input.charCodeAt(this.pos);if(i===96||i===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===u.template||this.type===u.invalidTemplate)?i===36?(this.pos+=2,this.finishToken(u.dollarBraceL)):(++this.pos,this.finishToken(u.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(u.template,e));if(i===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(Ue(i)){switch(e+=this.input.slice(t,this.pos),++this.pos,i){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`
|
|
23
|
+
`;break;default:e+=String.fromCharCode(i);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}};D.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(u.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
|
|
24
|
+
`&&++this.pos;case`
|
|
25
|
+
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};D.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
|
|
26
|
+
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return Se(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var i=this.pos-1;this.invalidStringToken(i,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],s=parseInt(r,8);return s>255&&(r=r.slice(0,-1),s=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(s)}return Ue(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}};D.readHexChar=function(e){var t=this.pos,i=this.readInt(16,e);return i===null&&this.invalidStringToken(t,"Bad character escape sequence"),i};D.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,i=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var s=this.fullCharCodeAtPos();if(We(s,r))this.pos+=s<=65535?1:2;else if(s===92){this.containsEsc=!0,e+=this.input.slice(i,this.pos);var n=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var a=this.readCodePoint();(t?_e:We)(a,r)||this.invalidStringToken(n,"Invalid Unicode escape"),e+=Se(a),i=this.pos}else break;t=!1}return e+this.input.slice(i,this.pos)};D.readWord=function(){var e=this.readWord1(),t=u.name;return this.keywords.test(e)&&(t=Ft[e]),this.finishToken(t,e)};var ns="8.14.0";U.acorn={Parser:U,version:ns,defaultOptions:Tt,Position:et,SourceLocation:gt,getLineInfo:Ai,Node:yt,TokenType:O,tokTypes:u,keywordTypes:Ft,TokContext:de,tokContexts:$,isIdentifierChar:We,isIdentifierStart:_e,Token:zt,isNewLine:Ue,lineBreak:pe,lineBreakG:kr,nonASCIIwhitespace:ki};function ar(e,t){return U.parse(e,t)}const{stringify:as}=JSON;if(!String.prototype.repeat)throw new Error("String.prototype.repeat is undefined, see https://github.com/davidbonnet/astring#installation");if(!String.prototype.endsWith)throw new Error("String.prototype.endsWith is undefined, see https://github.com/davidbonnet/astring#installation");const ot={"||":2,"??":3,"&&":4,"|":5,"^":6,"&":7,"==":8,"!=":8,"===":8,"!==":8,"<":9,">":9,"<=":9,">=":9,in:9,instanceof:9,"<<":10,">>":10,">>>":10,"+":11,"-":11,"*":12,"%":12,"/":12,"**":13},ge=17,os={ArrayExpression:20,TaggedTemplateExpression:20,ThisExpression:20,Identifier:20,PrivateIdentifier:20,Literal:18,TemplateLiteral:20,Super:20,SequenceExpression:20,MemberExpression:19,ChainExpression:19,CallExpression:19,NewExpression:19,ArrowFunctionExpression:ge,ClassExpression:ge,FunctionExpression:ge,ObjectExpression:ge,UpdateExpression:16,UnaryExpression:15,AwaitExpression:15,BinaryExpression:14,LogicalExpression:13,ConditionalExpression:4,AssignmentExpression:3,YieldExpression:2,RestElement:1};function je(e,t){const{generator:i}=e;if(e.write("("),t!=null&&t.length>0){i[t[0].type](t[0],e);const{length:r}=t;for(let s=1;s<r;s++){const n=t[s];e.write(", "),i[n.type](n,e)}}e.write(")")}function or(e,t,i,r){const s=e.expressionsPrecedence[t.type];if(s===ge)return!0;const n=e.expressionsPrecedence[i.type];return s!==n?!r&&s===15&&n===14&&i.operator==="**"||s<n:s!==13&&s!==14?!1:t.operator==="**"&&i.operator==="**"?!r:s===13&&n===13&&(t.operator==="??"||i.operator==="??")?!0:r?ot[t.operator]<=ot[i.operator]:ot[t.operator]<ot[i.operator]}function ht(e,t,i,r){const{generator:s}=e;or(e,t,i,r)?(e.write("("),s[t.type](t,e),e.write(")")):s[t.type](t,e)}function hs(e,t,i,r){const s=t.split(`
|
|
27
|
+
`),n=s.length-1;if(e.write(s[0].trim()),n>0){e.write(r);for(let a=1;a<n;a++)e.write(i+s[a].trim()+r);e.write(i+s[n].trim())}}function X(e,t,i,r){const{length:s}=t;for(let n=0;n<s;n++){const a=t[n];e.write(i),a.type[0]==="L"?e.write("// "+a.value.trim()+`
|
|
28
|
+
`,a):(e.write("/*"),hs(e,a.value,i,r),e.write("*/"+r))}}function cs(e){let t=e;for(;t!=null;){const{type:i}=t;if(i[0]==="C"&&i[1]==="a")return!0;if(i[0]==="M"&&i[1]==="e"&&i[2]==="m")t=t.object;else return!1}}function Nt(e,t){const{generator:i}=e,{declarations:r}=t;e.write(t.kind+" ");const{length:s}=r;if(s>0){i.VariableDeclarator(r[0],e);for(let n=1;n<s;n++)e.write(", "),i.VariableDeclarator(r[n],e)}}let ri,si,ni,ai,oi,hi;const Ht={Program(e,t){const i=t.indent.repeat(t.indentLevel),{lineEnd:r,writeComments:s}=t;s&&e.comments!=null&&X(t,e.comments,i,r);const n=e.body,{length:a}=n;for(let o=0;o<a;o++){const h=n[o];s&&h.comments!=null&&X(t,h.comments,i,r),t.write(i),this[h.type](h,t),t.write(r)}s&&e.trailingComments!=null&&X(t,e.trailingComments,i,r)},BlockStatement:hi=function(e,t){const i=t.indent.repeat(t.indentLevel++),{lineEnd:r,writeComments:s}=t,n=i+t.indent;t.write("{");const a=e.body;if(a!=null&&a.length>0){t.write(r),s&&e.comments!=null&&X(t,e.comments,n,r);const{length:o}=a;for(let h=0;h<o;h++){const c=a[h];s&&c.comments!=null&&X(t,c.comments,n,r),t.write(n),this[c.type](c,t),t.write(r)}t.write(i)}else s&&e.comments!=null&&(t.write(r),X(t,e.comments,n,r),t.write(i));s&&e.trailingComments!=null&&X(t,e.trailingComments,n,r),t.write("}"),t.indentLevel--},ClassBody:hi,StaticBlock(e,t){t.write("static "),this.BlockStatement(e,t)},EmptyStatement(e,t){t.write(";")},ExpressionStatement(e,t){const i=t.expressionsPrecedence[e.expression.type];i===ge||i===3&&e.expression.left.type[0]==="O"?(t.write("("),this[e.expression.type](e.expression,t),t.write(")")):this[e.expression.type](e.expression,t),t.write(";")},IfStatement(e,t){t.write("if ("),this[e.test.type](e.test,t),t.write(") "),this[e.consequent.type](e.consequent,t),e.alternate!=null&&(t.write(" else "),this[e.alternate.type](e.alternate,t))},LabeledStatement(e,t){this[e.label.type](e.label,t),t.write(": "),this[e.body.type](e.body,t)},BreakStatement(e,t){t.write("break"),e.label!=null&&(t.write(" "),this[e.label.type](e.label,t)),t.write(";")},ContinueStatement(e,t){t.write("continue"),e.label!=null&&(t.write(" "),this[e.label.type](e.label,t)),t.write(";")},WithStatement(e,t){t.write("with ("),this[e.object.type](e.object,t),t.write(") "),this[e.body.type](e.body,t)},SwitchStatement(e,t){const i=t.indent.repeat(t.indentLevel++),{lineEnd:r,writeComments:s}=t;t.indentLevel++;const n=i+t.indent,a=n+t.indent;t.write("switch ("),this[e.discriminant.type](e.discriminant,t),t.write(") {"+r);const{cases:o}=e,{length:h}=o;for(let c=0;c<h;c++){const l=o[c];s&&l.comments!=null&&X(t,l.comments,n,r),l.test?(t.write(n+"case "),this[l.test.type](l.test,t),t.write(":"+r)):t.write(n+"default:"+r);const{consequent:f}=l,{length:g}=f;for(let p=0;p<g;p++){const x=f[p];s&&x.comments!=null&&X(t,x.comments,a,r),t.write(a),this[x.type](x,t),t.write(r)}}t.indentLevel-=2,t.write(i+"}")},ReturnStatement(e,t){t.write("return"),e.argument&&(t.write(" "),this[e.argument.type](e.argument,t)),t.write(";")},ThrowStatement(e,t){t.write("throw "),this[e.argument.type](e.argument,t),t.write(";")},TryStatement(e,t){if(t.write("try "),this[e.block.type](e.block,t),e.handler){const{handler:i}=e;i.param==null?t.write(" catch "):(t.write(" catch ("),this[i.param.type](i.param,t),t.write(") ")),this[i.body.type](i.body,t)}e.finalizer&&(t.write(" finally "),this[e.finalizer.type](e.finalizer,t))},WhileStatement(e,t){t.write("while ("),this[e.test.type](e.test,t),t.write(") "),this[e.body.type](e.body,t)},DoWhileStatement(e,t){t.write("do "),this[e.body.type](e.body,t),t.write(" while ("),this[e.test.type](e.test,t),t.write(");")},ForStatement(e,t){if(t.write("for ("),e.init!=null){const{init:i}=e;i.type[0]==="V"?Nt(t,i):this[i.type](i,t)}t.write("; "),e.test&&this[e.test.type](e.test,t),t.write("; "),e.update&&this[e.update.type](e.update,t),t.write(") "),this[e.body.type](e.body,t)},ForInStatement:ri=function(e,t){t.write(`for ${e.await?"await ":""}(`);const{left:i}=e;i.type[0]==="V"?Nt(t,i):this[i.type](i,t),t.write(e.type[3]==="I"?" in ":" of "),this[e.right.type](e.right,t),t.write(") "),this[e.body.type](e.body,t)},ForOfStatement:ri,DebuggerStatement(e,t){t.write("debugger;",e)},FunctionDeclaration:si=function(e,t){t.write((e.async?"async ":"")+(e.generator?"function* ":"function ")+(e.id?e.id.name:""),e),je(t,e.params),t.write(" "),this[e.body.type](e.body,t)},FunctionExpression:si,VariableDeclaration(e,t){Nt(t,e),t.write(";")},VariableDeclarator(e,t){this[e.id.type](e.id,t),e.init!=null&&(t.write(" = "),this[e.init.type](e.init,t))},ClassDeclaration(e,t){if(t.write("class "+(e.id?`${e.id.name} `:""),e),e.superClass){t.write("extends ");const{superClass:i}=e,{type:r}=i,s=t.expressionsPrecedence[r];(r[0]!=="C"||r[1]!=="l"||r[5]!=="E")&&(s===ge||s<t.expressionsPrecedence.ClassExpression)?(t.write("("),this[e.superClass.type](i,t),t.write(")")):this[i.type](i,t),t.write(" ")}this.ClassBody(e.body,t)},ImportDeclaration(e,t){t.write("import ");const{specifiers:i,attributes:r}=e,{length:s}=i;let n=0;if(s>0){for(;n<s;){n>0&&t.write(", ");const a=i[n],o=a.type[6];if(o==="D")t.write(a.local.name,a),n++;else if(o==="N")t.write("* as "+a.local.name,a),n++;else break}if(n<s){for(t.write("{");;){const a=i[n],{name:o}=a.imported;if(t.write(o,a),o!==a.local.name&&t.write(" as "+a.local.name),++n<s)t.write(", ");else break}t.write("}")}t.write(" from ")}if(this.Literal(e.source,t),r&&r.length>0){t.write(" with { ");for(let a=0;a<r.length;a++)this.ImportAttribute(r[a],t),a<r.length-1&&t.write(", ");t.write(" }")}t.write(";")},ImportAttribute(e,t){this.Identifier(e.key,t),t.write(": "),this.Literal(e.value,t)},ImportExpression(e,t){t.write("import("),this[e.source.type](e.source,t),t.write(")")},ExportDefaultDeclaration(e,t){t.write("export default "),this[e.declaration.type](e.declaration,t),t.expressionsPrecedence[e.declaration.type]!=null&&e.declaration.type[0]!=="F"&&t.write(";")},ExportNamedDeclaration(e,t){if(t.write("export "),e.declaration)this[e.declaration.type](e.declaration,t);else{t.write("{");const{specifiers:i}=e,{length:r}=i;if(r>0)for(let s=0;;){const n=i[s],{name:a}=n.local;if(t.write(a,n),a!==n.exported.name&&t.write(" as "+n.exported.name),++s<r)t.write(", ");else break}if(t.write("}"),e.source&&(t.write(" from "),this.Literal(e.source,t)),e.attributes&&e.attributes.length>0){t.write(" with { ");for(let s=0;s<e.attributes.length;s++)this.ImportAttribute(e.attributes[s],t),s<e.attributes.length-1&&t.write(", ");t.write(" }")}t.write(";")}},ExportAllDeclaration(e,t){if(e.exported!=null?t.write("export * as "+e.exported.name+" from "):t.write("export * from "),this.Literal(e.source,t),e.attributes&&e.attributes.length>0){t.write(" with { ");for(let i=0;i<e.attributes.length;i++)this.ImportAttribute(e.attributes[i],t),i<e.attributes.length-1&&t.write(", ");t.write(" }")}t.write(";")},MethodDefinition(e,t){e.static&&t.write("static ");const i=e.kind[0];(i==="g"||i==="s")&&t.write(e.kind+" "),e.value.async&&t.write("async "),e.value.generator&&t.write("*"),e.computed?(t.write("["),this[e.key.type](e.key,t),t.write("]")):this[e.key.type](e.key,t),je(t,e.value.params),t.write(" "),this[e.value.body.type](e.value.body,t)},ClassExpression(e,t){this.ClassDeclaration(e,t)},ArrowFunctionExpression(e,t){t.write(e.async?"async ":"",e);const{params:i}=e;i!=null&&(i.length===1&&i[0].type[0]==="I"?t.write(i[0].name,i[0]):je(t,e.params)),t.write(" => "),e.body.type[0]==="O"?(t.write("("),this.ObjectExpression(e.body,t),t.write(")")):this[e.body.type](e.body,t)},ThisExpression(e,t){t.write("this",e)},Super(e,t){t.write("super",e)},RestElement:ni=function(e,t){t.write("..."),this[e.argument.type](e.argument,t)},SpreadElement:ni,YieldExpression(e,t){t.write(e.delegate?"yield*":"yield"),e.argument&&(t.write(" "),this[e.argument.type](e.argument,t))},AwaitExpression(e,t){t.write("await ",e),ht(t,e.argument,e)},TemplateLiteral(e,t){const{quasis:i,expressions:r}=e;t.write("`");const{length:s}=r;for(let a=0;a<s;a++){const o=r[a],h=i[a];t.write(h.value.raw,h),t.write("${"),this[o.type](o,t),t.write("}")}const n=i[i.length-1];t.write(n.value.raw,n),t.write("`")},TemplateElement(e,t){t.write(e.value.raw,e)},TaggedTemplateExpression(e,t){ht(t,e.tag,e),this[e.quasi.type](e.quasi,t)},ArrayExpression:oi=function(e,t){if(t.write("["),e.elements.length>0){const{elements:i}=e,{length:r}=i;for(let s=0;;){const n=i[s];if(n!=null&&this[n.type](n,t),++s<r)t.write(", ");else{n==null&&t.write(", ");break}}}t.write("]")},ArrayPattern:oi,ObjectExpression(e,t){const i=t.indent.repeat(t.indentLevel++),{lineEnd:r,writeComments:s}=t,n=i+t.indent;if(t.write("{"),e.properties.length>0){t.write(r),s&&e.comments!=null&&X(t,e.comments,n,r);const a=","+r,{properties:o}=e,{length:h}=o;for(let c=0;;){const l=o[c];if(s&&l.comments!=null&&X(t,l.comments,n,r),t.write(n),this[l.type](l,t),++c<h)t.write(a);else break}t.write(r),s&&e.trailingComments!=null&&X(t,e.trailingComments,n,r),t.write(i+"}")}else s?e.comments!=null?(t.write(r),X(t,e.comments,n,r),e.trailingComments!=null&&X(t,e.trailingComments,n,r),t.write(i+"}")):e.trailingComments!=null?(t.write(r),X(t,e.trailingComments,n,r),t.write(i+"}")):t.write("}"):t.write("}");t.indentLevel--},Property(e,t){e.method||e.kind[0]!=="i"?this.MethodDefinition(e,t):(e.shorthand||(e.computed?(t.write("["),this[e.key.type](e.key,t),t.write("]")):this[e.key.type](e.key,t),t.write(": ")),this[e.value.type](e.value,t))},PropertyDefinition(e,t){if(e.static&&t.write("static "),e.computed&&t.write("["),this[e.key.type](e.key,t),e.computed&&t.write("]"),e.value==null){e.key.type[0]!=="F"&&t.write(";");return}t.write(" = "),this[e.value.type](e.value,t),t.write(";")},ObjectPattern(e,t){if(t.write("{"),e.properties.length>0){const{properties:i}=e,{length:r}=i;for(let s=0;this[i[s].type](i[s],t),++s<r;)t.write(", ")}t.write("}")},SequenceExpression(e,t){je(t,e.expressions)},UnaryExpression(e,t){if(e.prefix){const{operator:i,argument:r,argument:{type:s}}=e;t.write(i);const n=or(t,r,e);!n&&(i.length>1||s[0]==="U"&&(s[1]==="n"||s[1]==="p")&&r.prefix&&r.operator[0]===i&&(i==="+"||i==="-"))&&t.write(" "),n?(t.write(i.length>1?" (":"("),this[s](r,t),t.write(")")):this[s](r,t)}else this[e.argument.type](e.argument,t),t.write(e.operator)},UpdateExpression(e,t){e.prefix?(t.write(e.operator),this[e.argument.type](e.argument,t)):(this[e.argument.type](e.argument,t),t.write(e.operator))},AssignmentExpression(e,t){this[e.left.type](e.left,t),t.write(" "+e.operator+" "),this[e.right.type](e.right,t)},AssignmentPattern(e,t){this[e.left.type](e.left,t),t.write(" = "),this[e.right.type](e.right,t)},BinaryExpression:ai=function(e,t){const i=e.operator==="in";i&&t.write("("),ht(t,e.left,e,!1),t.write(" "+e.operator+" "),ht(t,e.right,e,!0),i&&t.write(")")},LogicalExpression:ai,ConditionalExpression(e,t){const{test:i}=e,r=t.expressionsPrecedence[i.type];r===ge||r<=t.expressionsPrecedence.ConditionalExpression?(t.write("("),this[i.type](i,t),t.write(")")):this[i.type](i,t),t.write(" ? "),this[e.consequent.type](e.consequent,t),t.write(" : "),this[e.alternate.type](e.alternate,t)},NewExpression(e,t){t.write("new ");const i=t.expressionsPrecedence[e.callee.type];i===ge||i<t.expressionsPrecedence.CallExpression||cs(e.callee)?(t.write("("),this[e.callee.type](e.callee,t),t.write(")")):this[e.callee.type](e.callee,t),je(t,e.arguments)},CallExpression(e,t){const i=t.expressionsPrecedence[e.callee.type];i===ge||i<t.expressionsPrecedence.CallExpression?(t.write("("),this[e.callee.type](e.callee,t),t.write(")")):this[e.callee.type](e.callee,t),e.optional&&t.write("?."),je(t,e.arguments)},ChainExpression(e,t){this[e.expression.type](e.expression,t)},MemberExpression(e,t){const i=t.expressionsPrecedence[e.object.type];i===ge||i<t.expressionsPrecedence.MemberExpression?(t.write("("),this[e.object.type](e.object,t),t.write(")")):this[e.object.type](e.object,t),e.computed?(e.optional&&t.write("?."),t.write("["),this[e.property.type](e.property,t),t.write("]")):(e.optional?t.write("?."):t.write("."),this[e.property.type](e.property,t))},MetaProperty(e,t){t.write(e.meta.name+"."+e.property.name,e)},Identifier(e,t){t.write(e.name,e)},PrivateIdentifier(e,t){t.write(`#${e.name}`,e)},Literal(e,t){e.raw!=null?t.write(e.raw,e):e.regex!=null?this.RegExpLiteral(e,t):e.bigint!=null?t.write(e.bigint+"n",e):t.write(as(e.value),e)},RegExpLiteral(e,t){const{regex:i}=e;t.write(`/${i.pattern}/${i.flags}`,e)}},us={},ls=Ht;class ps{constructor(t){const i=t??us;this.output="",i.output!=null?(this.output=i.output,this.write=this.writeToStream):this.output="",this.generator=i.generator!=null?i.generator:Ht,this.expressionsPrecedence=i.expressionsPrecedence!=null?i.expressionsPrecedence:os,this.indent=i.indent!=null?i.indent:" ",this.lineEnd=i.lineEnd!=null?i.lineEnd:`
|
|
29
|
+
`,this.indentLevel=i.startingIndentLevel!=null?i.startingIndentLevel:0,this.writeComments=i.comments?i.comments:!1,i.sourceMap!=null&&(this.write=i.output==null?this.writeAndMap:this.writeToStreamAndMap,this.sourceMap=i.sourceMap,this.line=1,this.column=0,this.lineEndSize=this.lineEnd.split(`
|
|
30
|
+
`).length-1,this.mapping={original:null,generated:this,name:void 0,source:i.sourceMap.file||i.sourceMap._file})}write(t){this.output+=t}writeToStream(t){this.output.write(t)}writeAndMap(t,i){this.output+=t,this.map(t,i)}writeToStreamAndMap(t,i){this.output.write(t),this.map(t,i)}map(t,i){if(i!=null){const{type:n}=i;if(n[0]==="L"&&n[2]==="n"){this.column=0,this.line++;return}if(i.loc!=null){const{mapping:a}=this;a.original=i.loc.start,a.name=i.name,this.sourceMap.addMapping(a)}if(n[0]==="T"&&n[8]==="E"||n[0]==="L"&&n[1]==="i"&&typeof i.value=="string"){const{length:a}=t;let{column:o,line:h}=this;for(let c=0;c<a;c++)t[c]===`
|
|
31
|
+
`?(o=0,h++):o++;this.column=o,this.line=h;return}}const{length:r}=t,{lineEnd:s}=this;r>0&&(this.lineEndSize>0&&(s.length===1?t[r-1]===s:t.endsWith(s))?(this.line+=this.lineEndSize,this.column=0):this.column+=r)}toString(){return this.output}}function hr(e,t){const i=new ps(t);return i.generator[e.type](e,i),i.output}var fs=Object.defineProperty,ms=(e,t,i)=>t in e?fs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Y=(e,t,i)=>ms(e,typeof t!="symbol"?t+"":t,i);const ds=new Set(["Infinity","NaN","undefined","null","true","false"]),gs=new Set(["Math","Array","Object","String","Number","Boolean","Date","RegExp","Error","JSON","Promise","Set","Map","WeakSet","WeakMap","Symbol","BigInt","Proxy","Reflect","console","isNaN","isFinite","parseInt","parseFloat","encodeURI","decodeURI","encodeURIComponent","decodeURIComponent"]);class xs{constructor(){Y(this,"scopes",[]),Y(this,"scopeTypes",[]),Y(this,"scopeCounts",new Map),Y(this,"contextBoundVars",new Set),Y(this,"arrayPatternElements",new Set),Y(this,"rootParams",new Set),Y(this,"localSeriesVars",new Set),Y(this,"varKinds",new Map),Y(this,"loopVars",new Set),Y(this,"loopVarNames",new Map),Y(this,"paramIdCounter",0),Y(this,"cacheIdCounter",0),Y(this,"tempVarCounter",0),Y(this,"taCallIdCounter",0),Y(this,"hoistingStack",[]),Y(this,"suppressHoisting",!1),this.pushScope("glb")}get nextParamIdArg(){return{type:"Identifier",name:`'p${this.paramIdCounter++}'`}}get nextCacheIdArg(){return{type:"Identifier",name:`'cache_${this.cacheIdCounter++}'`}}getNextTACallId(){return{type:"Literal",value:`_ta${this.taCallIdCounter++}`}}pushScope(t){this.scopes.push(new Map),this.scopeTypes.push(t),this.scopeCounts.set(t,(this.scopeCounts.get(t)||0)+1)}popScope(){this.scopes.pop(),this.scopeTypes.pop()}getCurrentScopeType(){return this.scopeTypes[this.scopeTypes.length-1]}getCurrentScopeCount(){return this.scopeCounts.get(this.getCurrentScopeType())||1}addLocalSeriesVar(t){this.localSeriesVars.add(t)}isLocalSeriesVar(t){return this.localSeriesVars.has(t)}addContextBoundVar(t,i=!1){this.contextBoundVars.add(t),i&&this.rootParams.add(t)}removeContextBoundVar(t){this.contextBoundVars.has(t)&&(this.contextBoundVars.delete(t),this.rootParams.has(t)&&this.rootParams.delete(t))}addArrayPatternElement(t){this.arrayPatternElements.add(t)}isContextBound(t){return ds.has(t)||gs.has(t)?!1:this.contextBoundVars.has(t)}isArrayPatternElement(t){return this.arrayPatternElements.has(t)}isRootParam(t){return this.rootParams.has(t)}addLoopVariable(t,i){this.loopVars.add(t),this.loopVarNames.set(t,i)}getLoopVariableName(t){return this.loopVarNames.get(t)}isLoopVariable(t){return this.loopVars.has(t)}addVariable(t,i){if(this.isContextBound(t))return t;const r=this.scopes[this.scopes.length-1],s=this.scopeTypes[this.scopeTypes.length-1],n=this.scopeCounts.get(s)||1,a=`${s}${n}_${t}`;return r.set(t,a),this.varKinds.set(a,i),a}getVariable(t){if(this.loopVars.has(t)){const i=this.loopVarNames.get(t);if(i)return[i,"let"]}if(this.isContextBound(t))return[t,"let"];for(let i=this.scopes.length-1;i>=0;i--){const r=this.scopes[i];if(r.has(t)){const s=r.get(t),n=this.varKinds.get(s)||"let";return[s,n]}}return[t,"let"]}generateTempVar(){return`temp_${++this.tempVarCounter}`}enterHoistingScope(){this.hoistingStack.push([])}exitHoistingScope(){return this.hoistingStack.pop()||[]}addHoistedStatement(t){this.hoistingStack.length>0&&!this.suppressHoisting&&this.hoistingStack[this.hoistingStack.length-1].push(t)}setSuppressHoisting(t){this.suppressHoisting=t}shouldSuppressHoisting(){return this.suppressHoisting}generateParamId(){return`p${this.paramIdCounter++}`}}function Gt(e,t,i,r,s){i||(i=b),function n(a,o,h){var c=h||a.type;i[c](a,o,n),t[c]&&t[c](a,o)}(e,r,s)}function H(e,t,i,r,s){var n=i?ys(i,r||void 0):r;(function a(o,h,c){n[c||o.type](o,h,a)})(e,t,s)}function ys(e,t){var i=Object.create(t||b);for(var r in e)i[r]=e[r];return i}function Yt(e,t,i){i(e,t)}function Le(e,t,i){}var b={};b.Program=b.BlockStatement=b.StaticBlock=function(e,t,i){for(var r=0,s=e.body;r<s.length;r+=1){var n=s[r];i(n,t,"Statement")}};b.Statement=Yt;b.EmptyStatement=Le;b.ExpressionStatement=b.ParenthesizedExpression=b.ChainExpression=function(e,t,i){return i(e.expression,t,"Expression")};b.IfStatement=function(e,t,i){i(e.test,t,"Expression"),i(e.consequent,t,"Statement"),e.alternate&&i(e.alternate,t,"Statement")};b.LabeledStatement=function(e,t,i){return i(e.body,t,"Statement")};b.BreakStatement=b.ContinueStatement=Le;b.WithStatement=function(e,t,i){i(e.object,t,"Expression"),i(e.body,t,"Statement")};b.SwitchStatement=function(e,t,i){i(e.discriminant,t,"Expression");for(var r=0,s=e.cases;r<s.length;r+=1){var n=s[r];i(n,t)}};b.SwitchCase=function(e,t,i){e.test&&i(e.test,t,"Expression");for(var r=0,s=e.consequent;r<s.length;r+=1){var n=s[r];i(n,t,"Statement")}};b.ReturnStatement=b.YieldExpression=b.AwaitExpression=function(e,t,i){e.argument&&i(e.argument,t,"Expression")};b.ThrowStatement=b.SpreadElement=function(e,t,i){return i(e.argument,t,"Expression")};b.TryStatement=function(e,t,i){i(e.block,t,"Statement"),e.handler&&i(e.handler,t),e.finalizer&&i(e.finalizer,t,"Statement")};b.CatchClause=function(e,t,i){e.param&&i(e.param,t,"Pattern"),i(e.body,t,"Statement")};b.WhileStatement=b.DoWhileStatement=function(e,t,i){i(e.test,t,"Expression"),i(e.body,t,"Statement")};b.ForStatement=function(e,t,i){e.init&&i(e.init,t,"ForInit"),e.test&&i(e.test,t,"Expression"),e.update&&i(e.update,t,"Expression"),i(e.body,t,"Statement")};b.ForInStatement=b.ForOfStatement=function(e,t,i){i(e.left,t,"ForInit"),i(e.right,t,"Expression"),i(e.body,t,"Statement")};b.ForInit=function(e,t,i){e.type==="VariableDeclaration"?i(e,t):i(e,t,"Expression")};b.DebuggerStatement=Le;b.FunctionDeclaration=function(e,t,i){return i(e,t,"Function")};b.VariableDeclaration=function(e,t,i){for(var r=0,s=e.declarations;r<s.length;r+=1){var n=s[r];i(n,t)}};b.VariableDeclarator=function(e,t,i){i(e.id,t,"Pattern"),e.init&&i(e.init,t,"Expression")};b.Function=function(e,t,i){e.id&&i(e.id,t,"Pattern");for(var r=0,s=e.params;r<s.length;r+=1){var n=s[r];i(n,t,"Pattern")}i(e.body,t,e.expression?"Expression":"Statement")};b.Pattern=function(e,t,i){e.type==="Identifier"?i(e,t,"VariablePattern"):e.type==="MemberExpression"?i(e,t,"MemberPattern"):i(e,t)};b.VariablePattern=Le;b.MemberPattern=Yt;b.RestElement=function(e,t,i){return i(e.argument,t,"Pattern")};b.ArrayPattern=function(e,t,i){for(var r=0,s=e.elements;r<s.length;r+=1){var n=s[r];n&&i(n,t,"Pattern")}};b.ObjectPattern=function(e,t,i){for(var r=0,s=e.properties;r<s.length;r+=1){var n=s[r];n.type==="Property"?(n.computed&&i(n.key,t,"Expression"),i(n.value,t,"Pattern")):n.type==="RestElement"&&i(n.argument,t,"Pattern")}};b.Expression=Yt;b.ThisExpression=b.Super=b.MetaProperty=Le;b.ArrayExpression=function(e,t,i){for(var r=0,s=e.elements;r<s.length;r+=1){var n=s[r];n&&i(n,t,"Expression")}};b.ObjectExpression=function(e,t,i){for(var r=0,s=e.properties;r<s.length;r+=1){var n=s[r];i(n,t)}};b.FunctionExpression=b.ArrowFunctionExpression=b.FunctionDeclaration;b.SequenceExpression=function(e,t,i){for(var r=0,s=e.expressions;r<s.length;r+=1){var n=s[r];i(n,t,"Expression")}};b.TemplateLiteral=function(e,t,i){for(var r=0,s=e.quasis;r<s.length;r+=1){var n=s[r];i(n,t)}for(var a=0,o=e.expressions;a<o.length;a+=1){var h=o[a];i(h,t,"Expression")}};b.TemplateElement=Le;b.UnaryExpression=b.UpdateExpression=function(e,t,i){i(e.argument,t,"Expression")};b.BinaryExpression=b.LogicalExpression=function(e,t,i){i(e.left,t,"Expression"),i(e.right,t,"Expression")};b.AssignmentExpression=b.AssignmentPattern=function(e,t,i){i(e.left,t,"Pattern"),i(e.right,t,"Expression")};b.ConditionalExpression=function(e,t,i){i(e.test,t,"Expression"),i(e.consequent,t,"Expression"),i(e.alternate,t,"Expression")};b.NewExpression=b.CallExpression=function(e,t,i){if(i(e.callee,t,"Expression"),e.arguments)for(var r=0,s=e.arguments;r<s.length;r+=1){var n=s[r];i(n,t,"Expression")}};b.MemberExpression=function(e,t,i){i(e.object,t,"Expression"),e.computed&&i(e.property,t,"Expression")};b.ExportNamedDeclaration=b.ExportDefaultDeclaration=function(e,t,i){e.declaration&&i(e.declaration,t,e.type==="ExportNamedDeclaration"||e.declaration.id?"Statement":"Expression"),e.source&&i(e.source,t,"Expression")};b.ExportAllDeclaration=function(e,t,i){e.exported&&i(e.exported,t),i(e.source,t,"Expression")};b.ImportDeclaration=function(e,t,i){for(var r=0,s=e.specifiers;r<s.length;r+=1){var n=s[r];i(n,t)}i(e.source,t,"Expression")};b.ImportExpression=function(e,t,i){i(e.source,t,"Expression")};b.ImportSpecifier=b.ImportDefaultSpecifier=b.ImportNamespaceSpecifier=b.Identifier=b.PrivateIdentifier=b.Literal=Le;b.TaggedTemplateExpression=function(e,t,i){i(e.tag,t,"Expression"),i(e.quasi,t,"Expression")};b.ClassDeclaration=b.ClassExpression=function(e,t,i){return i(e,t,"Class")};b.Class=function(e,t,i){e.id&&i(e.id,t,"Pattern"),e.superClass&&i(e.superClass,t,"Expression"),i(e.body,t)};b.ClassBody=function(e,t,i){for(var r=0,s=e.body;r<s.length;r+=1){var n=s[r];i(n,t)}};b.MethodDefinition=b.PropertyDefinition=b.Property=function(e,t,i){e.computed&&i(e.key,t,"Expression"),e.value&&i(e.value,t,"Expression")};const q="$",v={createIdentifier(e){return{type:"Identifier",name:e}},createLiteral(e){return{type:"Literal",value:e}},createMemberExpression(e,t,i=!1){return{type:"MemberExpression",object:e,property:t,computed:i}},createContextIdentifier(){return this.createIdentifier(q)},createContextVariableReference(e,t){const i=this.createContextIdentifier(),r=this.createIdentifier(e),s=this.createIdentifier(t);return this.createMemberExpression(this.createMemberExpression(i,r,!1),s,!1)},createContextVariableAccess0(e,t){const i=this.createContextVariableReference(e,t);return this.createGetCall(i,0)},createArrayAccess(e,t){const i=typeof t=="number"?this.createLiteral(t):t;return this.createMemberExpression(e,i,!0)},createCallExpression(e,t){return{type:"CallExpression",callee:e,arguments:t}},createAssignmentExpression(e,t,i="="){return{type:"AssignmentExpression",operator:i,left:e,right:t}},createExpressionStatement(e){return{type:"ExpressionStatement",expression:e}},createInitCall(e,t,i){const r=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("init"),!1),s=[e,t];return i&&s.push(i),this.createCallExpression(r,s)},createInitVarCall(e,t){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("initVar"),!1),r=[e,t];return this.createCallExpression(i,r)},createGetCall(e,t){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("get"),!1),r=typeof t=="number"?this.createLiteral(t):t;return this.createCallExpression(i,[e,r])},createSetCall(e,t){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("set"),!1);return this.createCallExpression(i,[e,t])},createMathEqCall(e,t){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("math"),!1),r=this.createMemberExpression(i,this.createIdentifier("__eq"),!1);return this.createCallExpression(r,[e,t])},createWrapperFunction(e){return{type:"FunctionDeclaration",id:null,params:[this.createIdentifier("context")],body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:e}]}}},createVariableDeclaration(e,t){return{type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:this.createIdentifier(e),init:t}]}},createAwaitExpression(e){return{type:"AwaitExpression",argument:e}}},st=["ta","math","request","array","input"],ws=["hline"],bs=["request.security","request.security_lower_tf"],cr=["open","high","low","close","volume","hl2","hlc3","ohlc4","openTime","closeTime"],ur=[...st,"plotchar","plot","hline","indicator","strategy","library","alertcondition","fixnan","na","color","nz","str","box","line","label","table","map","matrix","log","map","bool","timeframe","syminfo","barstate","bar_index","last_bar_index","last_bar_time","order","currency","display","dayofweek"],vs=["na","nz","plot","plotchar","color","hline"];function _s(e){let t=null,i=q;if(e.type==="Program"&&e.body.length>0){const p=e.body[0];if(p.type==="ExpressionStatement"&&(p.expression.type==="ArrowFunctionExpression"||p.expression.type==="FunctionExpression")){const x=p.expression;x.body.type==="BlockStatement"&&(t=x.body.body,x.params.length>0&&x.params[0].type==="Identifier"&&(i=x.params[0].name))}}if(!t)return;const r=new Set,s=new Set,n=p=>{p.type==="Identifier"?r.add(p.name):p.type==="ObjectPattern"?p.properties.forEach(x=>n(x.value)):p.type==="ArrayPattern"&&p.elements.forEach(x=>{x&&n(x)})};H(e,{},{VariableDeclarator(p,x,y){n(p.id),p.init&&y(p.init,x)},FunctionDeclaration(p,x,y){n(p.id),y(p.body,x)},Identifier(p,x,y){s.add(p.name)},MemberExpression(p,x,y){y(p.object,x),p.computed&&y(p.property,x)},Property(p,x,y){p.computed&&y(p.key,x),y(p.value,x)}}),t.forEach(p=>{p.type==="VariableDeclaration"?p.declarations.forEach(x=>n(x.id)):p.type==="FunctionDeclaration"&&n(p.id)});const a=cr,o=ur,h=a.filter(p=>!r.has(p)),c=o.filter(p=>!r.has(p)),l=h.filter(p=>s.has(p)),f=c.filter(p=>s.has(p)),g=[];l.length>0&&g.push({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"ObjectPattern",properties:l.map(p=>({type:"Property",key:{type:"Identifier",name:p},value:{type:"Identifier",name:p},kind:"init",shorthand:!0}))},init:{type:"MemberExpression",object:{type:"Identifier",name:i},property:{type:"Identifier",name:"data"},computed:!1}}]}),f.length>0&&g.push({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"ObjectPattern",properties:f.map(p=>({type:"Property",key:{type:"Identifier",name:p},value:{type:"Identifier",name:p},kind:"init",shorthand:!0}))},init:{type:"MemberExpression",object:{type:"Identifier",name:i},property:{type:"Identifier",name:"pine"},computed:!1}}]}),g.length>0&&t.unshift(...g)}function Ss(e){let t=null,i=q;if(e.type==="Program"&&e.body.length>0){const o=e.body[0];if(o.type==="ExpressionStatement"&&(o.expression.type==="ArrowFunctionExpression"||o.expression.type==="FunctionExpression")){const h=o.expression;h.body.type==="BlockStatement"&&(t=h.body.body,h.params.length>0&&h.params[0].type==="Identifier"&&(i=h.params[0].name))}}if(!t)return;const r=new Set(cr),s=new Set(ur),n=new Set(vs),a=new Map;t.forEach(o=>{o.type==="VariableDeclaration"&&o.declarations.forEach(h=>{if(h.init&&h.init.type==="MemberExpression"&&h.init.object.type==="Identifier"&&h.init.object.name===i&&h.init.property.type==="Identifier"){const c=h.init.property.name;let l=null;if(c==="data"?l=r:c==="pine"?l=s:c==="core"&&(l=n),l&&h.id.type==="ObjectPattern")h.id.properties.forEach(f=>{if(f.type==="Property"&&f.key.type==="Identifier"&&f.value.type==="Identifier"){const g=f.key.name,p=f.value.name;l.has(g)&&g!==p&&(a.set(p,g),f.value.name=g,f.shorthand=!0)}});else if(h.id.type==="Identifier"&&st.includes(c)){const f=c,g=h.id.name;f!==g&&(a.set(g,f),h.id.name=f)}}})}),a.size>0&&H(e,{},{Identifier(o){a.has(o.name)&&(o.name=a.get(o.name))},MemberExpression(o,h,c){c(o.object,h),o.computed&&c(o.property,h)},Property(o,h,c){o.computed&&c(o.key,h),c(o.value,h)}})}function Es(e){try{const t=ar(e,{ecmaVersion:"latest",sourceType:"module"});if(t.type==="Program"&&t.body.length===1){const i=t.body[0];if(i.type==="ExpressionStatement"){const r=i.expression;if(r.type==="ArrowFunctionExpression"||r.type==="FunctionExpression")return{isWrapped:!0,isAsync:r.async||!1,functionNode:r}}if(i.type==="FunctionDeclaration")return{isWrapped:!0,isAsync:i.async||!1,functionNode:i}}return{isWrapped:!1,isAsync:!1}}catch{return{isWrapped:!1,isAsync:!1}}}function Ns(e){return e.async=!0,hr(e)}function Cs(e){e=e.trim();const{isWrapped:t,isAsync:i,functionNode:r}=Es(e);return t&&r?i?e:Ns(r):`async (context) => {
|
|
19
32
|
${e}
|
|
20
|
-
}`}function Gt(e){k.recursive(e,null,{VariableDeclaration(t,n,r){t.declarations&&t.declarations.length>0&&t.declarations.forEach(i=>{if(i.init&&i.init.type==="ArrowFunctionExpression"&&i.init.start!==0){const s={type:"FunctionDeclaration",id:i.id,params:i.init.params,body:i.init.body.type==="BlockStatement"?i.init.body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:i.init.body}]},async:i.init.async,generator:!1};Object.assign(t,s)}}),t.body&&t.body.body&&t.body.body.forEach(i=>r(i,n))}})}function Kt(e,t){k.simple(e,{VariableDeclaration(n){n.declarations.forEach(r=>{const i=r.init&&r.init.type==="MemberExpression"&&r.init.object&&(r.init.object.name==="context"||r.init.object.name===T||r.init.object.name==="context2"),s=r.init&&r.init.type==="MemberExpression"&&r.init.object?.object&&(r.init.object.object.name==="context"||r.init.object.object.name===T||r.init.object.object.name==="context2");(i||s)&&(r.id.name&&t.addContextBoundVar(r.id.name),r.id.properties&&r.id.properties.forEach(a=>{a.key.name&&t.addContextBoundVar(a.key.name)}))})}})}function Xt(e,t,n=!1){e.params.forEach(r=>{r.type==="Identifier"&&t.addContextBoundVar(r.name,n)})}function Yt(e,t){e.params.forEach(n=>{n.type==="Identifier"&&t.addContextBoundVar(n.name,!1)})}function Zt(e,t){let n;return k.simple(e,{FunctionDeclaration(r){Yt(r,t)},ArrowFunctionExpression(r){const i=r.start===0;i&&r.params&&r.params.length>0&&(n=r.params[0].name,r.params[0].name=T),Xt(r,t,i)},VariableDeclaration(r){r.declarations.forEach(i=>{if(i.id.type==="ArrayPattern"){const s=t.generateTempVar(),a={type:"VariableDeclaration",kind:r.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:s},init:i.init}]};i.id.elements?.forEach(c=>{c.type==="Identifier"&&t.addArrayPatternElement(c.name)});const o=i.id.elements.map((c,l)=>({type:"VariableDeclaration",kind:r.kind,declarations:[{type:"VariableDeclarator",id:c,init:{type:"MemberExpression",object:{type:"Identifier",name:s},property:{type:"Literal",value:l},computed:!0}}]}));Object.assign(r,{type:"BlockStatement",body:[a,...o]})}})},ForStatement(r){}}),n}const ft={type:"Identifier",name:"undefined"};function X(e,t){if(e.computed&&e.property.type==="Identifier"){if(t.isLoopVariable(e.property.name)){if(e.object.type==="Identifier"&&!t.isLoopVariable(e.object.name)&&!t.isContextBound(e.object.name)){const[n,r]=t.getVariable(e.object.name),i=_.createContextVariableReference(r,n),s=_.createGetCall(i,e.property);Object.assign(e,s),e._indexTransformed=!0}return}if(!t.isContextBound(e.property.name)){const[n,r]=t.getVariable(e.property.name);e.property=_.createContextVariableReference(r,n),e.property=_.createGetCall(e.property,0)}}if(e.computed&&e.object.type==="Identifier"){if(t.isLoopVariable(e.object.name))return;if(!t.isContextBound(e.object.name)){const[n,r]=t.getVariable(e.object.name);e.object=_.createContextVariableReference(r,n)}if(e.property.type==="MemberExpression"){const n=e.property;n._indexTransformed||(X(n,t),n._indexTransformed=!0)}}}function U(e,t){const n=_.createGetCall(_.createIdentifier(e.name),0);e.start!==void 0&&(n.start=e.start),e.end!==void 0&&(n.end=e.end),n._indexTransformed=!0,Object.assign(e,n)}function O(e,t){if(e.name!==T){if(e.name==="na"&&!(e.parent&&e.parent.type==="CallExpression"&&e.parent.callee===e)){e.name="NaN";return}if(e.name==="Math"||e.name==="NaN"||e.name==="undefined"||e.name==="Infinity"||e.name==="null"||e.name.startsWith("'")&&e.name.endsWith("'")||e.name.startsWith('"')&&e.name.endsWith('"')||e.name.startsWith("`")&&e.name.endsWith("`")||t.isLoopVariable(e.name))return;let n=!1;if(e.parent&&e.parent.type==="CallExpression"&&e.parent.arguments.includes(e)){const f=e.parent.callee;if(f.type==="MemberExpression"&&f.object&&f.object.name===T&&["get","set","init","param"].includes(f.property.name))e.parent.arguments.indexOf(e)===0&&(n=!0);else{const h=f.type==="MemberExpression"&&f.object&&f.object.type==="Identifier"&<.includes(f.object.name);f.type==="MemberExpression"&&!h?n=!1:n=!0}}const r=e.parent&&e.parent.type==="MemberExpression"&&e.parent.object===e&&t.isContextBound(e.name),i=e.parent&&e.parent.type==="CallExpression"&&e.parent.callee&&e.parent.callee.type==="MemberExpression"&&e.parent.callee.property.name==="param";e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left;const s=e.parent&&e.parent.type==="CallExpression"&&e.parent.callee===e,a=e.parent&&e.parent.type==="MemberExpression"&&e.parent.computed&&e.parent.object===e,o=e.parent&&e.parent.type==="MemberExpression"&&e.parent.computed&&e.parent.property===e&&e.parent.parent&&e.parent.parent.type==="CallExpression"&&e.parent.parent.callee&&e.parent.parent.callee.type==="MemberExpression"&&t.isContextBound(e.parent.parent.callee.object.name);if(r||i||n||o||s){if(s||t.isLocalSeriesVar(e.name)||t.isContextBound(e.name)&&!t.isRootParam(e.name))return;const[f,h]=t.getVariable(e.name),d=_.createContextVariableReference(h,f);Object.assign(e,d);return}const c=t.isContextBound(e.name)&&!t.isRootParam(e.name);if(c&&!(e.parent&&e.parent.type==="CallExpression"&&e.parent.arguments.includes(e)))return;if(t.isLocalSeriesVar(e.name)){if(!a){const f=_.createIdentifier(e.name),h=_.createGetCall(f,0);Object.assign(e,h)}return}const[l,u]=t.getVariable(e.name);let p;if(c)p=_.createIdentifier(e.name);else{if(l===e.name&&!t.isContextBound(e.name))return;p=_.createContextVariableReference(u,l)}if(a)Object.assign(e,p);else{const f=_.createGetCall(p,0);Object.assign(e,f)}}}function z(e,t,n){if(e.object&&e.object.type==="Identifier"&&e.object.name==="Math")return;if(e.object&&e.object.type==="Identifier"&<.includes(e.object.name)&&n.isContextBound(e.object.name)&&!e.computed){const c=e.parent&&e.parent.type==="CallExpression"&&e.parent.callee===e,l=e.parent&&(e.parent.type==="VariableDeclarator"||e.parent.type==="Property"||e.parent.type==="AssignmentExpression");if(!c&&!l){const u={type:"CallExpression",callee:{type:"MemberExpression",object:e.object,property:e.property,computed:!1},arguments:[],_transformed:!1};e.start!==void 0&&(u.start=e.start),e.end!==void 0&&(u.end=e.end),Object.assign(e,u);return}}const r=n.getCurrentScopeType()=="if",i=n.getCurrentScopeType()=="els",s=n.getCurrentScopeType()=="for";if(!r&&!i&&!s&&e.object&&e.object.type==="Identifier"&&n.isContextBound(e.object.name)&&!n.isRootParam(e.object.name)&&!e.computed)return;e._indexTransformed||(X(e,n),e._indexTransformed=!0);const a=e.object&&e.object.type==="MemberExpression"&&e.object.object&&e.object.object.type==="MemberExpression"&&e.object.object.object&&e.object.object.object.name===T,o=e.object&&e.object.type==="Identifier"&&n.isContextBound(e.object.name);if(e.computed&&(a||o)){if(e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e)return;const c=_.createGetCall(e.object,e.property);e.start&&(c.start=e.start),e.end&&(c.end=e.end),Object.assign(e,c),delete e.object,delete e.property,delete e.computed}}function rt(e,t){if(e.type==="Identifier"){if(e.name==="na")return e.name="NaN",e;if(t.isLoopVariable(e.name))return e;if(t.isRootParam(e.name)){const[i,s]=t.getVariable(e.name);return _.createContextVariableReference(s,i)}if(t.isContextBound(e.name)||t.isLocalSeriesVar(e.name))return e;const[n,r]=t.getVariable(e.name);return n===e.name&&!t.isContextBound(e.name)?e:_.createContextVariableReference(r,n)}return e}function K(e,t,n=""){switch(e.type){case"BinaryExpression":return It(e,t,n);case"MemberExpression":return{type:"MemberExpression",object:e.object.type==="Identifier"?rt(e.object,t):e.object,property:e.property,computed:e.computed};case"Identifier":{if(t.isLoopVariable(e.name)||e.parent&&e.parent.type==="MemberExpression"&&e.parent.property===e)return e;const r=rt(e,t);return r.type==="Identifier"&&(r.name==="NaN"||r.name==="undefined"||r.name==="Infinity"||r.name==="null"||r.name==="Math")?r:_.createGetCall(r,0)}case"UnaryExpression":return Mt(e,t,n);case"ConditionalExpression":{const r=K(e.test,t,n),i=K(e.consequent,t,n),s=K(e.alternate,t,n);return{type:"ConditionalExpression",test:r,consequent:i,alternate:s,start:e.start,end:e.end}}}return e}function It(e,t,n){const r=K(e.left,t,n),i=K(e.right,t,n),s={type:"BinaryExpression",operator:e.operator,left:r,right:i,start:e.start,end:e.end};return k.recursive(s,t,{CallExpression(a,o){a._transformed||H(a,o)},MemberExpression(a){z(a,"",t)}}),s}function Jt(e,t,n){const r=K(e.left,t,n),i=K(e.right,t,n),s={type:"LogicalExpression",operator:e.operator,left:r,right:i,start:e.start,end:e.end};return k.recursive(s,t,{CallExpression(a,o){a._transformed||H(a,o)}}),s}function Qt(e,t,n){k.recursive(e,{parent:e,inNamespaceCall:!1},{Identifier(a,o,c){if(a.name=="NaN")return;if(a.name=="na"){a.name="NaN";return}a.parent=o.parent,O(a,t);const l=a.parent&&a.parent.type==="BinaryExpression";(a.parent&&a.parent.type==="ConditionalExpression"||l)&&(a.type==="MemberExpression"?X(a,t):a.type==="Identifier"&&(a.parent&&a.parent.type==="CallExpression"&&a.parent.callee&&a.parent.callee.object&&a.parent.callee.object.name===T&&a.parent.callee.property.name==="get"||U(a)))},MemberExpression(a,o,c){X(a,t),a.object&&c(a.object,{parent:a,inNamespaceCall:o.inNamespaceCall})},ConditionalExpression(a,o,c){const l={...o,parent:a};a.test&&c(a.test,l),a.consequent&&c(a.consequent,l),a.alternate&&c(a.alternate,l)},BinaryExpression(a,o,c){const l={...o,parent:a};c(a.left,l),c(a.right,l)},LogicalExpression(a,o,c){const l={...o,parent:a};c(a.left,l),c(a.right,l)},UnaryExpression(a,o,c){const l={...o,parent:a};c(a.argument,l)},CallExpression(a,o,c){const l=a.callee&&a.callee.type==="MemberExpression"&&a.callee.object&&a.callee.object.type==="Identifier"&&t.isContextBound(a.callee.object.name);H(a,t),a.arguments.forEach(u=>c(u,{parent:a,inNamespaceCall:l||o.inNamespaceCall}))}});const r=_.createMemberExpression(_.createIdentifier(n),_.createIdentifier("param")),i=t.generateParamId(),s={type:"CallExpression",callee:r,arguments:[e,ft,{type:"Identifier",name:`'${i}'`}],_transformed:!0,_isParamCall:!0};if(!t.shouldSuppressHoisting()){const a=i;t.addLocalSeriesVar(a);const o=_.createVariableDeclaration(a,s);return t.addHoistedStatement(o),_.createIdentifier(a)}return s}function Mt(e,t,n){const r=K(e.argument,t,n);return{type:"UnaryExpression",operator:e.operator,prefix:e.prefix,argument:r,start:e.start,end:e.end}}function _t(e,t,n){switch(e?.type){case"BinaryExpression":e=It(e,n,t);break;case"LogicalExpression":e=Jt(e,n,t);break;case"ConditionalExpression":return Qt(e,n,t);case"UnaryExpression":e=Mt(e,n,t);break;case"ArrayExpression":e.elements=e.elements.map(o=>{if(o.type==="Identifier"){if(n.isContextBound(o.name)&&!n.isRootParam(o.name))return o;const[c,l]=n.getVariable(o.name);return _.createContextVariableAccess0(l,c)}return o});break}if(e.type==="MemberExpression"&&e.computed&&e.property){const o=e.object.type==="Identifier"&&n.isContextBound(e.object.name)&&!n.isRootParam(e.object.name)?e.object:rt(e.object,n),c=e.property.type==="Identifier"&&!n.isContextBound(e.property.name)&&!n.isLoopVariable(e.property.name)?rt(e.property,n):e.property,l=_.createMemberExpression(_.createIdentifier(t),_.createIdentifier("param")),u=n.generateParamId(),p={type:"CallExpression",callee:l,arguments:[o,c,{type:"Identifier",name:`'${u}'`}],_transformed:!0,_isParamCall:!0};if(!n.shouldSuppressHoisting()){const f=u;n.addLocalSeriesVar(f);const h=_.createVariableDeclaration(f,p);return n.addHoistedStatement(h),_.createIdentifier(f)}return p}if(e.type==="ObjectExpression"&&(e.properties=e.properties.map(o=>{if(o.value.name){if(n.isContextBound(o.value.name)&&!n.isRootParam(o.value.name))return{type:"Property",key:{type:"Identifier",name:o.key.name},value:_.createIdentifier(o.value.name),kind:"init",method:!1,shorthand:!1,computed:!1};const[c,l]=n.getVariable(o.value.name);return{type:"Property",key:{type:"Identifier",name:o.key.name},value:_.createContextVariableReference(l,c),kind:"init",method:!1,shorthand:!1,computed:!1}}return o})),e.type==="Identifier"){if(e.name==="na")return e.name="NaN",e;if(n.isContextBound(e.name)&&!n.isRootParam(e.name)){const o=_.createMemberExpression(_.createIdentifier(t),_.createIdentifier("param")),c=n.generateParamId(),l={type:"CallExpression",callee:o,arguments:[e,ft,{type:"Identifier",name:`'${c}'`}],_transformed:!0,_isParamCall:!0};if(!n.shouldSuppressHoisting()){const u=c;n.addLocalSeriesVar(u);const p=_.createVariableDeclaration(u,l);return n.addHoistedStatement(p),_.createIdentifier(u)}return l}}e?.type==="CallExpression"&&H(e,n);const r=_.createMemberExpression(_.createIdentifier(t),_.createIdentifier("param")),i=e.type==="Identifier"?rt(e,n):e,s=n.generateParamId(),a={type:"CallExpression",callee:r,arguments:[i,ft,{type:"Identifier",name:`'${s}'`}],_transformed:!0,_isParamCall:!0};if(!n.shouldSuppressHoisting()){const o=s;n.addLocalSeriesVar(o);const c=_.createVariableDeclaration(o,a);return n.addHoistedStatement(c),_.createIdentifier(o)}return a}function H(e,t,n){if(e._transformed)return;e.callee&&e.callee.type==="Identifier"&<.includes(e.callee.name)&&t.isContextBound(e.callee.name)&&(e.callee=_.createMemberExpression(e.callee,_.createIdentifier("any")));const r=e.callee&&e.callee.type==="MemberExpression"&&e.callee.object&&e.callee.object.type==="Identifier"&&(t.isContextBound(e.callee.object.name)||e.callee.object.name==="math"||e.callee.object.name==="ta");if(r){if(e.callee.object.name===T&&["get","init","param"].includes(e.callee.property.name))return;const i=e.callee.object.name,s=[];if(e.arguments.forEach(a=>{if(a._isParamCall){s.push(a);return}s.push(_t(a,i,t))}),e.arguments=s,i==="ta"&&e.arguments.push(t.getNextTACallId()),!t.shouldSuppressHoisting()){const a=t.generateTempVar();t.addLocalSeriesVar(a);const o=_.createVariableDeclaration(a,Object.assign({},e));t.addHoistedStatement(o),Object.assign(e,_.createIdentifier(a));return}e._transformed=!0}else e.callee&&e.callee.type==="Identifier"&&(e.arguments=e.arguments.map(i=>i._isParamCall?i:_t(i,T,t)),e._transformed=!0);!r&&e.callee&&e.callee.type==="MemberExpression"&&e.callee.object.type==="Identifier"&&O(e.callee.object,t),e.arguments.forEach(i=>{k.recursive(i,{parent:e},{Identifier(s,a,o){s.parent=a.parent,O(s,t);const c=s.parent&&s.parent.type==="BinaryExpression";(s.parent&&s.parent.type==="ConditionalExpression"||c)&&(s.type==="MemberExpression"?X(s,t):s.type==="Identifier"&&(s.parent&&s.parent.type==="CallExpression"&&s.parent.callee&&s.parent.callee.object&&s.parent.callee.object.name===T&&s.parent.callee.property.name==="get"||U(s)))},BinaryExpression(s,a,o){const c={...a,parent:s};o(s.left,c),o(s.right,c)},LogicalExpression(s,a,o){const c={...a,parent:s};o(s.left,c),o(s.right,c)},UnaryExpression(s,a,o){const c={...a,parent:s};o(s.argument,c)},CallExpression(s,a,o){s._transformed||H(s,t)},MemberExpression(s,a,o){z(s,"",t),s.object&&o(s.object,{parent:s})}})})}function $t(e,t){let n=null;if(e.left.type==="Identifier"){const[r,i]=t.getVariable(e.left.name);n=_.createContextVariableReference(i,r)}else if(e.left.type==="MemberExpression"&&e.left.computed&&e.left.object.type==="Identifier"){const r=e.left.object.name,[i,s]=t.getVariable(r),a=i!==r,o=t.isContextBound(r);(a||o)&&!t.isLoopVariable(r)&&e.left.property.type==="Literal"&&e.left.property.value===0&&(n=_.createContextVariableReference(s,i))}if(k.recursive(e.right,{parent:e.right,inNamespaceCall:!1},{Identifier(r,i,s){r.name=="na"&&(r.name="NaN"),r.parent=i.parent,O(r,t);const a=r.parent&&r.parent.type==="BinaryExpression",o=r.parent&&r.parent.type==="ConditionalExpression",c=t.isContextBound(r.name)&&!t.isRootParam(r.name),l=r.parent&&r.parent.type==="MemberExpression"&&r.parent.computed&&r.parent.object===r,u=r.parent&&r.parent._isParamCall,p=r.parent&&r.parent.type==="MemberExpression",f=r.name==="NaN",h=r.parent&&r.parent.type==="CallExpression"&&r.parent.callee&&r.parent.callee.object&&r.parent.callee.object.name===T&&r.parent.callee.property.name==="get";(c||o||a)&&(r.type==="MemberExpression"?X(r,t):r.type==="Identifier"&&!p&&!l&&!u&&!f&&!h&&U(r))},MemberExpression(r,i,s){z(r,"",t),r.type==="CallExpression"?r.arguments.forEach(a=>s(a,{parent:r,inNamespaceCall:i.inNamespaceCall})):r.object&&s(r.object,{parent:r,inNamespaceCall:i.inNamespaceCall})},CallExpression(r,i,s){const a=r.callee&&r.callee.type==="MemberExpression"&&r.callee.object&&r.callee.object.type==="Identifier"&&t.isContextBound(r.callee.object.name);H(r,t),r.type==="CallExpression"&&r.arguments.forEach(o=>s(o,{parent:r,inNamespaceCall:a||i.inNamespaceCall}))}}),n){let r=e.right;if(e.operator!=="="){const s=e.operator.replace("=",""),a=_.createGetCall(n,0);r={type:"BinaryExpression",operator:s,left:a,right:e.right,start:e.start,end:e.end}}const i=_.createSetCall(n,r);e.start&&(i.start=e.start),e.end&&(i.end=e.end),Object.assign(e,i)}}function jt(e,t){e.declarations.forEach(n=>{n.init.name=="na"&&(n.init.name="NaN");const r=n.init&&n.init.type==="MemberExpression"&&n.init.object&&(n.init.object.name==="context"||n.init.object.name===T||n.init.object.name==="context2"),i=n.init&&n.init.type==="MemberExpression"&&n.init.object?.object&&(n.init.object.object.name==="context"||n.init.object.object.name===T||n.init.object.object.name==="context2"),s=n.init&&n.init.type==="ArrowFunctionExpression";if(r){n.id.name&&t.addContextBoundVar(n.id.name),n.id.properties&&n.id.properties.forEach(h=>{h.key.name&&t.addContextBoundVar(h.key.name)}),n.init.object.name=T;return}if(i){n.id.name&&t.addContextBoundVar(n.id.name),n.id.properties&&n.id.properties.forEach(h=>{h.key.name&&t.addContextBoundVar(h.key.name)}),n.init.object.object.name=T;return}s&&n.init.params.forEach(h=>{h.type==="Identifier"&&t.addContextBoundVar(h.name)});const a=t.addVariable(n.id.name,e.kind),o=e.kind,c=t.isArrayPatternElement(n.id.name);n.init&&!s&&!c&&(n.init.type==="CallExpression"&&n.init.callee.type==="MemberExpression"&&n.init.callee.object&&n.init.callee.object.type==="Identifier"&&t.isContextBound(n.init.callee.object.name)?H(n.init,t):k.recursive(n.init,{parent:n.init},{Identifier(h,d){h.parent=d.parent,O(h,t);const g=h.parent&&h.parent.type==="BinaryExpression",y=h.parent&&h.parent.type==="UnaryExpression",w=h.parent&&h.parent.type==="ConditionalExpression",S=h.parent&&h.parent.type==="CallExpression"&&h.parent.callee&&h.parent.callee.object&&h.parent.callee.object.name===T&&h.parent.callee.property.name==="get";h.type==="Identifier"&&(g||y||w)&&!S&&U(h)},CallExpression(h,d,g){h.callee.type==="Identifier"&&(h.callee.parent=h),h.arguments.forEach(y=>{y.type==="Identifier"&&(y.parent=h)}),H(h,t),h.type==="CallExpression"&&h.arguments.forEach(y=>g(y,{parent:h}))},BinaryExpression(h,d,g){h.left.type==="Identifier"&&(h.left.parent=h),h.right.type==="Identifier"&&(h.right.parent=h),g(h.left,{parent:h}),g(h.right,{parent:h})},MemberExpression(h,d,g){h.object&&h.object.type==="Identifier"&&(h.object.parent=h),h.property&&h.property.type==="Identifier"&&(h.property.parent=h),z(h,"",t),h.type==="CallExpression"?h.arguments.forEach(y=>g(y,{parent:h})):h.object&&g(h.object,{parent:h})}}));const l=_.createContextVariableReference(o,a),u=!c&&n.init&&n.init.type==="MemberExpression"&&n.init.computed&&n.init.property&&(n.init.property.type==="Literal"||n.init.property.type==="MemberExpression");n.init?.property?.type==="MemberExpression"&&(n.init.property._indexTransformed||(X(n.init.property,t),n.init.property._indexTransformed=!0));let p;n.init?s||c?p=n.init:o==="var"?p=_.createInitVarCall(l,n.init):p=_.createInitCall(l,u?n.init.object:n.init,u?n.init.property:void 0):p=_.createIdentifier("undefined");const f=_.createExpressionStatement(_.createAssignmentExpression(l,p));if(c){const h=n.init.object.name,[d,g]=t.getVariable(h),y=_.createContextVariableReference(g,d),w=n.init.property.value,S={type:"MemberExpression",object:_.createGetCall(y,0),property:{type:"Literal",value:w},computed:!0};f.expression.right=_.createCallExpression(_.createMemberExpression(_.createContextIdentifier(),_.createIdentifier("init")),[l,S])}s&&(t.pushScope("fn"),k.recursive(n.init.body,t,{BlockStatement(h,d,g){h.body.forEach(y=>g(y,d))},IfStatement(h,d,g){d.pushScope("if"),g(h.consequent,d),h.alternate&&(d.pushScope("els"),g(h.alternate,d),d.popScope()),d.popScope()},VariableDeclaration(h,d){jt(h,d)},Identifier(h,d){O(h,d)},AssignmentExpression(h,d){$t(h,d)}}),t.popScope()),Object.assign(e,f)})}function te(e,t,n){if(t.setSuppressHoisting(!0),e.init&&e.init.type==="VariableDeclaration"){const r=e.init.declarations[0],i=r.id.name;t.addLoopVariable(i,i),e.init={type:"VariableDeclaration",kind:e.init.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:i},init:r.init}]},r.init&&k.recursive(r.init,t,{Identifier(s,a){t.isLoopVariable(s.name)||(t.pushScope("for"),O(s,a),t.popScope())},MemberExpression(s){t.pushScope("for"),z(s,"",t),t.popScope()}})}e.test&&k.recursive(e.test,t,{Identifier(r,i){!t.isLoopVariable(r.name)&&!r.computed&&(t.pushScope("for"),O(r,i),r.type==="Identifier"&&(r.computed=!0,U(r)),t.popScope())},MemberExpression(r){t.pushScope("for"),z(r,"",t),t.popScope()}}),e.update&&k.recursive(e.update,t,{Identifier(r,i){t.isLoopVariable(r.name)||(t.pushScope("for"),O(r,i),t.popScope())}}),t.setSuppressHoisting(!1),t.pushScope("for"),n(e.body,t),t.popScope()}function ee(e,t){k.recursive(e,t,{MemberExpression(n){z(n,"",t)},CallExpression(n,r){H(n,r)},Identifier(n,r){O(n,r);const i=t.getCurrentScopeType()==="if";t.isContextBound(n.name)&&!t.isRootParam(n.name)&&i&&U(n)}})}function ne(e,t,n){e.test&&(t.pushScope("if"),ee(e.test,t),t.popScope()),t.pushScope("if"),n(e.consequent,t),t.popScope(),e.alternate&&(t.pushScope("els"),n(e.alternate,t),t.popScope())}function re(e,t){const n=t.getCurrentScopeType();if(e.argument&&(e.argument.type==="ArrayExpression"?(e.argument.elements=e.argument.elements.map(r=>{if(r.type==="Identifier"){if(t.isContextBound(r.name)&&!t.isRootParam(r.name))return _.createGetCall(r,0);const[i,s]=t.getVariable(r.name);return _.createContextVariableAccess0(s,i)}else if(r.type==="MemberExpression")return r.object&&r.object.type==="MemberExpression"&&r.object.object&&r.object.object.type==="Identifier"&&r.object.object.name==="$"&&r.object.property&&["const","let","var","params"].includes(r.object.property.name)?_.createGetCall(r,0):(r.computed&&r.object.type==="Identifier"&&t.isContextBound(r.object.name)&&!t.isRootParam(r.object.name)||z(r,"",t),r);return r}),e.argument={type:"ArrayExpression",elements:[e.argument]}):e.argument.type==="BinaryExpression"?k.recursive(e.argument,t,{Identifier(r,i){O(r,i),r.type==="Identifier"&&U(r)},MemberExpression(r){z(r,"",t)}}):e.argument.type==="ObjectExpression"?e.argument.properties=e.argument.properties.map(r=>{if(r.shorthand){if(t.isContextBound(r.value.name))return r;const[i,s]=t.getVariable(r.value.name);return{type:"Property",key:_.createIdentifier(r.key.name),value:_.createContextVariableReference(s,i),kind:"init",method:!1,shorthand:!1,computed:!1}}if(r.value&&r.value.type==="Identifier"&&!(t.isContextBound(r.value.name)&&!t.isRootParam(r.value.name))&&!t.isContextBound(r.value.name)){const[i,s]=t.getVariable(r.value.name);r.value=_.createContextVariableReference(s,i)}return r}):e.argument.type==="Identifier"&&(O(e.argument,t),e.argument.type==="Identifier"&&U(e.argument)),n==="fn")){e.argument.type==="Identifier"&&t.isContextBound(e.argument.name)&&!t.isRootParam(e.argument.name)?e.argument=_.createArrayAccess(e.argument,0):e.argument.type==="MemberExpression"?e.argument.object.type==="Identifier"&&t.isContextBound(e.argument.object.name)&&!t.isRootParam(e.argument.object.name)&&(e.argument._indexTransformed||(X(e.argument,t),e.argument._indexTransformed=!0)):(e.argument.type==="BinaryExpression"||e.argument.type==="LogicalExpression"||e.argument.type==="ConditionalExpression"||e.argument.type==="CallExpression")&&k.recursive(e.argument,t,{Identifier(i,s){O(i,s),i.type==="Identifier"&&!i._arrayAccessed&&(U(i),i._arrayAccessed=!0)},MemberExpression(i){z(i,"",t)},CallExpression(i,s){H(i,s)}});const r=_.createCallExpression(_.createMemberExpression(_.createContextIdentifier(),_.createIdentifier("precision")),[e.argument]);e.argument=r}}function ie(e,t,n){e.body&&e.body.type==="BlockStatement"&&(t.pushScope("fn"),n(e.body,t),t.popScope())}function ae(e){const t={...k.base,LineComment:()=>{}};k.simple(e,{BinaryExpression(n){if(n.operator==="=="||n.operator==="==="){const r=n.left,i=n.right,s=_.createMathEqCall(r,i);s._transformed=!0,Object.assign(n,s)}}},t)}function se(e,t,n,r={debug:!1,ln:!1},i=[]){const s=a=>{if(!r.debug||!a.loc||!i.length)return null;const o=a.loc.start.line-1;if(o>=0&&o<i.length){const c=i[o].trim();if(c)return{type:"LineComment",value:`${r.ln?` [Line ${a.loc.start.line}]`:""} ${c}`}}return null};k.recursive(e,t,{Program(a,o,c){const l=[];a.body.forEach(u=>{o.enterHoistingScope(),c(u,o);const p=o.exitHoistingScope(),f=s(u);f&&l.push(f),l.push(...p),l.push(u)}),a.body=l},BlockStatement(a,o,c){const l=[];a.body.forEach(u=>{o.enterHoistingScope(),c(u,o);const p=o.exitHoistingScope(),f=s(u);f&&l.push(f),l.push(...p),l.push(u)}),a.body=l},ReturnStatement(a,o){re(a,o)},VariableDeclaration(a,o){jt(a,o)},Identifier(a,o){O(a,o)},CallExpression(a,o){H(a,o)},MemberExpression(a,o){z(a,n,o)},AssignmentExpression(a,o){$t(a,o)},FunctionDeclaration(a,o,c){ie(a,o,c)},ForStatement(a,o,c){te(a,o,c)},IfStatement(a,o,c){ne(a,o,c)}})}function oe(e,t={debug:!1,ln:!1}){typeof t=="boolean"&&(t={debug:t,ln:!0});const{debug:n}=t;let r=typeof e=="function"?e.toString():e;r=r.trim(),r=Ut(r);const i=n?r.split(`
|
|
21
|
-
`)
|
|
22
|
-
; return _r;`)(this)}function ce(e){return t=>new $(t.array.map(n=>Math.abs(n)),t.type,e)}function le(e){return t=>{let n=0,r=0;for(const i of t.array){const s=Number(i);isNaN(s)||(r++,n+=(s-n)/r)}return r===0?NaN:e.precision(n)}}function ue(e){return(t,n)=>{const r=t.array;let i=0,s=r.length-1;for(;i<=s;){const a=Math.floor((i+s)/2),o=r[a];if(o===n)return a;o<n?i=a+1:s=a-1}return-1}}function he(e){return(t,n)=>{const r=t.array;let i=0,s=r.length;for(;i<s;){const a=Math.floor((i+s)/2);r[a]<n?i=a+1:s=a}return i<r.length&&r[i]===n?i:i-1}}function pe(e){return(t,n)=>{const r=t.array;let i=0,s=r.length;for(;i<s;){const a=Math.floor((i+s)/2);r[a]<=n?i=a+1:s=a}return i>0&&r[i-1]===n?i-1:i}}function me(e){return t=>{t.array.length=0}}function fe(e){return(t,n)=>(t.array.push(...n.array),t)}function de(e){return t=>new $([...t.array],t.type,e)}function ge(e){return(t,n,r=!0)=>{const i=t.array,s=n.array;if(i.length!==s.length)return NaN;let a=0,o=0,c=0;const l=[];for(let d=0;d<i.length;d++){const g=Number(i[d]),y=Number(s[d]);!isNaN(g)&&g!==null&&g!==void 0&&!isNaN(y)&&y!==null&&y!==void 0&&(a+=g,o+=y,c++,l.push(d))}if(c===0)return NaN;const u=a/c,p=o/c;let f=0;for(const d of l){const g=Number(i[d]),y=Number(s[d]);f+=(g-u)*(y-p)}const h=r?c:c-1;return h<=0?NaN:e.precision(f/h)}}function ye(e){return t=>t.array.every(n=>!isNaN(n)&&n)}function _e(e){if(e.every(t=>typeof t=="number"))return e.every(t=>(t|0)===t)?A.int:A.float;if(e.every(t=>typeof t=="string"))return A.string;if(e.every(t=>typeof t=="boolean"))return A.bool;throw new Error("Cannot infer type from values")}function q(e){if(typeof e=="number")return(e|0)===e?A.int:A.float;if(typeof e=="string")return A.string;if(typeof e=="boolean")return A.bool;throw new Error("Cannot infer type from value")}function it(e,t){switch(t){case A.int:return typeof e=="number"&&(e|0)===e||isNaN(e);case A.float:return typeof e=="number"||isNaN(e);case A.string:return typeof e=="string";case A.bool:return typeof e=="boolean"}return!1}function xe(e){return(t,n,r=0,i)=>{const s=t.array.length,a=i!==void 0?Math.min(i,s):s;for(let o=r;o<a;o++){if(!it(n,t.type))throw new Error(`Cannot call 'array.fill' with argument 'value'='${n}'. An argument of 'literal ${typeof n}' type was used but a '${t.type}' is expected.`);t.array[o]=e.precision(n)}}}function Ne(e){return t=>t.array.length>0?t.array[0]:e.NA}function we(e){return(t,n)=>t.array[n]}function be(e){return(t,n)=>t.array.includes(n)}function ve(e){return(t,n)=>t.array.indexOf(n)}function Se(e){return(t,n,r)=>{if(!it(r,t.type))throw new Error(`Cannot call 'array.insert' with argument 'value'='${r}'. An argument of 'literal ${typeof r}' type was used but a '${t.type}' is expected.`);t.array.splice(n,0,r)}}function Ce(e){return(t,n=",")=>t.array.join(n)}function Ee(e){return t=>t.array.length>0?t.array[t.array.length-1]:e.NA}function Ie(e){return(t,n)=>t.array.lastIndexOf(n)}function Me(e){return(t,n=0)=>[...t.array].sort((r,i)=>i-r)[n]??e.NA}function $e(e){return t=>{if(t.array.length===0)return NaN;const n=[...t.array].sort((i,s)=>typeof i=="number"&&typeof s=="number"?i-s:0),r=Math.floor(n.length/2);return n.length%2!==0?n[r]:(n[r-1]+n[r])/2}}function je(e){return(t,n=0)=>[...t.array].sort((r,i)=>r-i)[n]??e.NA}function Ae(e){return t=>{if(t.array.length===0)return NaN;const n=new Map;let r=0;for(const s of t.array){const a=(n.get(s)||0)+1;n.set(s,a),a>r&&(r=a)}const i=[];for(const[s,a]of n)a===r&&i.push(s);return i.sort((s,a)=>typeof s=="number"&&typeof a=="number"?s-a:typeof s=="string"&&typeof a=="string"?s<a?-1:s>a?1:0:0),i[0]}}function ke(e){return(t,n)=>{const r=t.array;if(r.length===0)return NaN;const i=[];for(const c of r){const l=Number(c);if(isNaN(l)||l===null||l===void 0)return NaN;i.push(l)}i.sort((c,l)=>c-l),n<0&&(n=0),n>100&&(n=100);const s=n/100*i.length-.5;if(s<=0)return e.precision(i[0]);if(s>=i.length-1)return e.precision(i[i.length-1]);const a=Math.floor(s),o=s-a;return e.precision(i[a]*(1-o)+i[a+1]*o)}}function Te(e){return(t,n)=>{const r=t.array;if(r.length===0)return NaN;const i=[];for(const o of r){const c=Number(o);!isNaN(c)&&c!==null&&c!==void 0&&i.push(c)}if(i.length===0)return NaN;i.sort((o,c)=>o-c),n<0&&(n=0),n>100&&(n=100);const s=r.length,a=Math.ceil(n/100*s);return a<=0?i[0]:a>i.length?NaN:i[a-1]}}function Ve(e){return(t,n)=>{if(t.array.length===0)return NaN;const r=Math.floor(n);if(r<0||r>=t.array.length)return NaN;const i=Number(t.array[r]);if(isNaN(i)||i===null||i===void 0)return NaN;let s=0;for(const o of t.array){const c=Number(o);!isNaN(c)&&c!==null&&c!==void 0&&c<i&&s++}const a=t.array.length-1;return a<=0?NaN:s/a*100}}function Pe(e){return t=>t.array.pop()}function Be(e){return(t,n)=>{if(!it(n,t.type))throw new Error(`Cannot call 'array.push' with argument 'value'='${n}'. An argument of 'literal ${typeof n}' type was used but a '${t.type}' is expected.`);t.array.push(e.precision(n))}}function De(e){return t=>e.precision(e.pine.array.max(t)-e.pine.array.min(t))}function Le(e){return(t,n)=>n>=0&&n<t.array.length?t.array.splice(n,1)[0]:e.NA}function We(e){return t=>{t.array.reverse()}}function Oe(e){return(t,n,r)=>{if(!it(r,t.type))throw new Error(`Cannot call 'array.set' with argument 'value'='${r}'. An argument of 'literal ${typeof r}' type was used but a '${t.type}' is expected.`);t.array[n]=e.precision(r)}}function Re(e){return t=>t.array.shift()}function Fe(e){return t=>t.array.length}function ze(e){return(t,n,r)=>{const i=r!==void 0?r:void 0;return new $(t.array.slice(n,i),t.type,e)}}function He(e){return t=>t.array.some(n=>!isNaN(n)&&n)}var J=(e=>(e[e.ascending=1]="ascending",e[e.descending=0]="descending",e))(J||{}),At=(e=>(e.AED="AED",e.ARS="ARS",e.AUD="AUD",e.BDT="BDT",e.BHD="BHD",e.BRL="BRL",e.BTC="BTC",e.CAD="CAD",e.CHF="CHF",e.CLP="CLP",e.CNY="CNY",e.COP="COP",e.CZK="CZK",e.DKK="DKK",e.EGP="EGP",e.ETH="ETH",e.EUR="EUR",e.GBP="GBP",e.HKD="HKD",e.HUF="HUF",e.IDR="IDR",e.ILS="ILS",e.INR="INR",e.ISK="ISK",e.JPY="JPY",e.KES="KES",e.KRW="KRW",e.KWD="KWD",e.LKR="LKR",e.MAD="MAD",e.MXN="MXN",e.MYR="MYR",e.NGN="NGN",e.NOK="NOK",e.NONE="NONE",e.NZD="NZD",e.PEN="PEN",e.PHP="PHP",e.PKR="PKR",e.PLN="PLN",e.QAR="QAR",e.RON="RON",e.RSD="RSD",e.RUB="RUB",e.SAR="SAR",e.SEK="SEK",e.SGD="SGD",e.THB="THB",e.TND="TND",e.TRY="TRY",e.TWD="TWD",e.USD="USD",e.USDT="USDT",e.VES="VES",e.VND="VND",e.ZAR="ZAR",e))(At||{}),kt=(e=>(e[e.sunday=1]="sunday",e[e.monday=2]="monday",e[e.tuesday=3]="tuesday",e[e.wednesday=4]="wednesday",e[e.thursday=5]="thursday",e[e.friday=6]="friday",e[e.saturday=7]="saturday",e))(kt||{}),qe=(e=>(e.all="all",e.data_window="data_window",e.none="none",e.pane="pane",e.pine_screener="pine_screener",e.price_scale="price_scale",e.status_line="status_line",e))(qe||{});const Ue={order:J,currency:At,dayofweek:kt};function Ge(e){return(t,n=J.ascending)=>{t.array.sort((r,i)=>{let s=isNaN(r)?1/0:r,a=isNaN(i)?1/0:i;return n===J.ascending?s-a:a-s})}}function Ke(e){return(t,n=J.ascending)=>{const r=t.array.map((i,s)=>s);return r.sort((i,s)=>{const a=isNaN(t.array[i])?1/0:t.array[i],o=isNaN(t.array[s])?1/0:t.array[s];return n===J.ascending?a-o:o-a}),new $(r,A.int,e)}}function Xe(e){return t=>{const n=e.array.avg(t),r=e.array.stdev(t);return isNaN(r)?new $(t.array.map(()=>NaN),A.int,e):r===0?new $(t.array.map(()=>1),A.int,e):new $(t.array.map(i=>(i-n)/r),A.int,e)}}function Ye(e){return(t,n=!0)=>{const r=t.array,i=r.length;if(i===0)return NaN;let s=0,a=0,o=0;for(let u=0;u<i;u++){const p=Number(r[u]);!isNaN(p)&&p!==null&&p!==void 0&&(s+=p,a+=p*p,o++)}if(o===0)return NaN;const c=s/o;let l=a/o-c*c;return l<0?NaN:(!n&&o>1&&(l=l*o/(o-1)),!n&&o===1?0:e.precision(Math.sqrt(l)))}}function Ze(e){return t=>e.precision(t.array.reduce((n,r)=>{const i=Number(r);return isNaN(i)?n:n+i},0))}function Je(e){return(t,n)=>{if(!it(n,t.type))throw new Error(`Cannot call 'array.unshift' with argument 'value'='${n}'. An argument of 'literal ${typeof n}' type was used but a '${t.type}' is expected.`);t.array.unshift(e.precision(n))}}function Qe(e){return(t,n=!0)=>{let r=0,i=0;for(const c of t.array){const l=Number(c);!isNaN(l)&&l!==null&&l!==void 0&&(r+=l,i++)}if(i===0)return NaN;const s=r/i;let a=0;for(const c of t.array){const l=Number(c);!isNaN(l)&&l!==null&&l!==void 0&&(a+=(l-s)*(l-s))}const o=n?i:i-1;return o<=0?NaN:e.precision(a/o)}}var tn=Object.defineProperty,en=(e,t,n)=>t in e?tn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t,n)=>en(e,typeof t!="symbol"?t+"":t,n),A=(e=>(e.any="",e.box="box",e.bool="bool",e.color="color",e.float="float",e.int="int",e.label="label",e.line="line",e.linefill="linefill",e.string="string",e.table="table",e))(A||{});class ${constructor(t,n,r){this.array=t,this.type=n,this.context=r,E(this,"_abs"),E(this,"_avg"),E(this,"_binary_search"),E(this,"_binary_search_leftmost"),E(this,"_binary_search_rightmost"),E(this,"_clear"),E(this,"_concat"),E(this,"_copy"),E(this,"_covariance"),E(this,"_every"),E(this,"_fill"),E(this,"_first"),E(this,"_get"),E(this,"_includes"),E(this,"_indexof"),E(this,"_insert"),E(this,"_join"),E(this,"_last"),E(this,"_lastindexof"),E(this,"_max"),E(this,"_median"),E(this,"_min"),E(this,"_mode"),E(this,"_percentile_linear_interpolation"),E(this,"_percentile_nearest_rank"),E(this,"_percentrank"),E(this,"_pop"),E(this,"_push"),E(this,"_range"),E(this,"_remove"),E(this,"_reverse"),E(this,"_set"),E(this,"_shift"),E(this,"_size"),E(this,"_slice"),E(this,"_some"),E(this,"_sort"),E(this,"_sort_indices"),E(this,"_standardize"),E(this,"_stdev"),E(this,"_sum"),E(this,"_unshift"),E(this,"_variance"),this._abs=ce(this.context),this._avg=le(this.context),this._binary_search=ue(this.context),this._binary_search_leftmost=he(this.context),this._binary_search_rightmost=pe(this.context),this._clear=me(this.context),this._concat=fe(this.context),this._copy=de(this.context),this._covariance=ge(this.context),this._every=ye(this.context),this._fill=xe(this.context),this._first=Ne(this.context),this._get=we(this.context),this._includes=be(this.context),this._indexof=ve(this.context),this._insert=Se(this.context),this._join=Ce(this.context),this._last=Ee(this.context),this._lastindexof=Ie(this.context),this._max=Me(this.context),this._median=$e(this.context),this._min=je(this.context),this._mode=Ae(this.context),this._percentile_linear_interpolation=ke(this.context),this._percentile_nearest_rank=Te(this.context),this._percentrank=Ve(this.context),this._pop=Pe(this.context),this._push=Be(this.context),this._range=De(this.context),this._remove=Le(this.context),this._reverse=We(this.context),this._set=Oe(this.context),this._shift=Re(this.context),this._size=Fe(this.context),this._slice=ze(this.context),this._some=He(this.context),this._sort=Ge(this.context),this._sort_indices=Ke(this.context),this._standardize=Xe(this.context),this._stdev=Ye(this.context),this._sum=Ze(this.context),this._unshift=Je(this.context),this._variance=Qe(this.context)}toString(){return"["+this.array.toString().replace(/,/g,", ")+"]"}abs(...t){return this._abs(this,...t)}avg(...t){return this._avg(this,...t)}binary_search(...t){return this._binary_search(this,...t)}binary_search_leftmost(...t){return this._binary_search_leftmost(this,...t)}binary_search_rightmost(...t){return this._binary_search_rightmost(this,...t)}clear(...t){return this._clear(this,...t)}concat(...t){return this._concat(this,...t)}copy(...t){return this._copy(this,...t)}covariance(...t){return this._covariance(this,...t)}every(...t){return this._every(this,...t)}fill(...t){return this._fill(this,...t)}first(...t){return this._first(this,...t)}get(...t){return this._get(this,...t)}includes(...t){return this._includes(this,...t)}indexof(...t){return this._indexof(this,...t)}insert(...t){return this._insert(this,...t)}join(...t){return this._join(this,...t)}last(...t){return this._last(this,...t)}lastindexof(...t){return this._lastindexof(this,...t)}max(...t){return this._max(this,...t)}median(...t){return this._median(this,...t)}min(...t){return this._min(this,...t)}mode(...t){return this._mode(this,...t)}percentile_linear_interpolation(...t){return this._percentile_linear_interpolation(this,...t)}percentile_nearest_rank(...t){return this._percentile_nearest_rank(this,...t)}percentrank(...t){return this._percentrank(this,...t)}pop(...t){return this._pop(this,...t)}push(...t){return this._push(this,...t)}range(...t){return this._range(this,...t)}remove(...t){return this._remove(this,...t)}reverse(...t){return this._reverse(this,...t)}set(...t){return this._set(this,...t)}shift(...t){return this._shift(this,...t)}size(...t){return this._size(this,...t)}slice(...t){return this._slice(this,...t)}some(...t){return this._some(this,...t)}sort(...t){return this._sort(this,...t)}sort_indices(...t){return this._sort_indices(this,...t)}standardize(...t){return this._standardize(this,...t)}stdev(...t){return this._stdev(this,...t)}sum(...t){return this._sum(this,...t)}unshift(...t){return this._unshift(this,...t)}variance(...t){return this._variance(this,...t)}}function nn(e){return(...t)=>new $([...t],_e(t),e)}function rn(e){return(t,n)=>new $(Array(t).fill(e.precision(n||0)),q(n||0),e)}function an(e){return(t,n=!1)=>new $(Array(t).fill(n),A.bool,e)}function sn(e){return(t,n=NaN)=>new $(Array(t).fill(e.precision(n)),A.float,e)}function on(e){return(t,n=0)=>new $(Array(t).fill(e.precision(n)),A.int,e)}function cn(e){return(t,n="")=>new $(Array(t).fill(n),A.string,e)}class m{constructor(t,n=0){this.data=t,this.offset=n}get(t){const n=this.data.length-1-(this.offset+t);return n<0||n>=this.data.length?NaN:this.data[n]}set(t,n){const r=this.data.length-1-(this.offset+t);r>=0&&r<this.data.length&&(this.data[r]=n)}get length(){return this.data.length}toArray(){return this.data}static from(t){return t instanceof m?t:Array.isArray(t)?new m(t):new m([t])}}function ln(e){return(t,n=0)=>m.from(t).get(n)}class un{constructor(t){this.context=t,this.abs=(n,...r)=>n.abs(...r),this.avg=(n,...r)=>n.avg(...r),this.binary_search=(n,...r)=>n.binary_search(...r),this.binary_search_leftmost=(n,...r)=>n.binary_search_leftmost(...r),this.binary_search_rightmost=(n,...r)=>n.binary_search_rightmost(...r),this.clear=(n,...r)=>n.clear(...r),this.concat=(n,...r)=>n.concat(...r),this.copy=(n,...r)=>n.copy(...r),this.covariance=(n,...r)=>n.covariance(...r),this.every=(n,...r)=>n.every(...r),this.fill=(n,...r)=>n.fill(...r),this.first=(n,...r)=>n.first(...r),this.from=nn(t),this.get=(n,...r)=>n.get(...r),this.includes=(n,...r)=>n.includes(...r),this.indexof=(n,...r)=>n.indexof(...r),this.insert=(n,...r)=>n.insert(...r),this.join=(n,...r)=>n.join(...r),this.last=(n,...r)=>n.last(...r),this.lastindexof=(n,...r)=>n.lastindexof(...r),this.max=(n,...r)=>n.max(...r),this.median=(n,...r)=>n.median(...r),this.min=(n,...r)=>n.min(...r),this.mode=(n,...r)=>n.mode(...r),this.new=rn(t),this.new_bool=an(t),this.new_float=sn(t),this.new_int=on(t),this.new_string=cn(t),this.param=ln(),this.percentile_linear_interpolation=(n,...r)=>n.percentile_linear_interpolation(...r),this.percentile_nearest_rank=(n,...r)=>n.percentile_nearest_rank(...r),this.percentrank=(n,...r)=>n.percentrank(...r),this.pop=(n,...r)=>n.pop(...r),this.push=(n,...r)=>n.push(...r),this.range=(n,...r)=>n.range(...r),this.remove=(n,...r)=>n.remove(...r),this.reverse=(n,...r)=>n.reverse(...r),this.set=(n,...r)=>n.set(...r),this.shift=(n,...r)=>n.shift(...r),this.size=(n,...r)=>n.size(...r),this.slice=(n,...r)=>n.slice(...r),this.some=(n,...r)=>n.some(...r),this.sort=(n,...r)=>n.sort(...r),this.sort_indices=(n,...r)=>n.sort_indices(...r),this.standardize=(n,...r)=>n.standardize(...r),this.stdev=(n,...r)=>n.stdev(...r),this.sum=(n,...r)=>n.sum(...r),this.unshift=(n,...r)=>n.unshift(...r),this.variance=(n,...r)=>n.variance(...r)}}function hn(e){return t=>{t.map.clear()}}function pn(e){return(t,n)=>t.map.has(n)}function mn(e){return t=>{const n=new Tt(e);return n.map=new Map(t.map),n}}function fn(e){return(t,n)=>{const r=t.map.get(n);return r===void 0?NaN:r}}function dn(e){return t=>{const n=Array.from(t.map.keys()),r=q(n[0]);return new $(n,r,e)}}function gn(e){return(t,n,r)=>{const i=t.map.get(n);return t.map.set(n,r),i===void 0?NaN:i}}function yn(e){return(t,n)=>{for(const[r,i]of n.map)t.map.set(r,i)}}function _n(e){return(t,n)=>{const r=t.map.get(n);return t.map.delete(n)?r:NaN}}function xn(e){return t=>t.map.size}function Nn(e){return t=>{const n=Array.from(t.map.values()),r=q(n[0]);return new $(n,r,e)}}var wn=Object.defineProperty,bn=(e,t,n)=>t in e?wn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,F=(e,t,n)=>bn(e,typeof t!="symbol"?t+"":t,n);class Tt{constructor(t){this.context=t,F(this,"map"),F(this,"_clear"),F(this,"_contains"),F(this,"_copy"),F(this,"_get"),F(this,"_keys"),F(this,"_put"),F(this,"_put_all"),F(this,"_remove"),F(this,"_size"),F(this,"_values"),this.map=new Map,this._clear=hn(this.context),this._contains=pn(this.context),this._copy=mn(this.context),this._get=fn(this.context),this._keys=dn(this.context),this._put=gn(this.context),this._put_all=yn(this.context),this._remove=_n(this.context),this._size=xn(this.context),this._values=Nn(this.context)}toString(){return`PineMapObject(${this.map.size})`}clear(...t){return this._clear(this,...t)}contains(...t){return this._contains(this,...t)}copy(...t){return this._copy(this,...t)}get(...t){return this._get(this,...t)}keys(...t){return this._keys(this,...t)}put(...t){return this._put(this,...t)}put_all(...t){return this._put_all(this,...t)}remove(...t){return this._remove(this,...t)}size(...t){return this._size(this,...t)}values(...t){return this._values(this,...t)}}function vn(e){return()=>new Tt(e)}function Sn(e){return(t,n=0)=>m.from(t).get(n)}class Cn{constructor(t){this.context=t,this.clear=(n,...r)=>n.clear(...r),this.contains=(n,...r)=>n.contains(...r),this.copy=(n,...r)=>n.copy(...r),this.get=(n,...r)=>n.get(...r),this.keys=(n,...r)=>n.keys(...r),this.new=vn(t),this.param=Sn(),this.put=(n,...r)=>n.put(...r),this.put_all=(n,...r)=>n.put_all(...r),this.remove=(n,...r)=>n.remove(...r),this.size=(n,...r)=>n.size(...r),this.values=(n,...r)=>n.values(...r)}}function En(e){return(t,n,r)=>{const i=t.matrix.length;let s=[];if(r&&(r instanceof $?s=r.array:Array.isArray(r)?s=r:s=[r]),i===0){for(let c=0;c<s.length;c++){let l=s[c];l instanceof m&&(l=l.get(0)),t.matrix.push([l])}return}const a=t.matrix[0].length,o=n!==void 0?n:a;for(let c=0;c<i;c++){let l=c<s.length?s[c]:NaN;l instanceof m&&(l=l.get(0)),t.matrix[c].splice(o,0,l)}}}function In(e){return(t,n,r)=>{const i=t.matrix.length;let s=[];if(r)if(r instanceof $)s=r.array;else if(Array.isArray(r))s=r;else if(r instanceof m){const l=r.get(0);Array.isArray(l)?s=l:s=[l]}else s=[r];const a=i>0?t.matrix[0].length:s.length,o=n!==void 0?n:i,c=[];for(let l=0;l<a;l++)if(l<s.length){let u=s[l];u instanceof m&&(u=u.get(0)),c.push(u)}else c.push(NaN);t.matrix.splice(o,0,c)}}function Mn(e){return t=>{const n=t.matrix.length;if(n===0)return NaN;const r=t.matrix[0].length;if(r===0)return NaN;let i=0,s=0;for(let a=0;a<n;a++)for(let o=0;o<r;o++){const c=t.matrix[a][o];isNaN(c)||(i+=c,s++)}return s===0?NaN:i/s}}function $n(e){return(t,n)=>{const r=t.matrix.length,i=[];for(let a=0;a<r;a++)i.push(t.matrix[a][n]);const s=q(i[0]);return new $(i,s,e)}}function jn(e){return t=>t.matrix.length===0?0:t.matrix[0].length}function An(e){return(t,n)=>{const r=t.matrix.length,i=n.matrix.length;if(r===0){for(let o=0;o<i;o++)t.matrix.push([...n.matrix[o]]);return}const s=t.matrix[0].length,a=i>0?n.matrix[0].length:0;if(s!==a&&i>0){console.error(`matrix.concat: Column count mismatch ${s} vs ${a}`);return}for(let o=0;o<i;o++)t.matrix.push([...n.matrix[o]])}}function kn(e){return t=>{const n=t.matrix.length,r=n>0?t.matrix[0].length:0,i=new M(n,r,NaN,e);return i.matrix=t.matrix.map(s=>[...s]),i}}function Tn(e){const t=e.length;if(t===0)return 0;if(t===1)return e[0][0];if(t===2)return e[0][0]*e[1][1]-e[0][1]*e[1][0];const n=e.map(i=>[...i]);let r=1;for(let i=0;i<t;i++){let s=i;for(;s<t&&n[s][i]===0;)s++;if(s===t)return 0;s!==i&&([n[i],n[s]]=[n[s],n[i]],r*=-1),r*=n[i][i];for(let a=i+1;a<t;a++){const o=n[a][i]/n[i][i];for(let c=i;c<t;c++)n[a][c]-=o*n[i][c]}}return r}function Vn(e){return t=>{const n=t.matrix.length,r=n>0?t.matrix[0].length:0;return n!==r?NaN:Tn(t.matrix)}}function Pn(e){return(t,n)=>{const r=t.matrix.length;if(r===0)return new M(0,0,NaN,e);const i=t.matrix[0].length,s=new M(r,i,NaN,e);if(n instanceof M)for(let a=0;a<r;a++)for(let o=0;o<i;o++){const c=t.matrix[a][o],l=n.matrix[a]&&n.matrix[a][o]!==void 0?n.matrix[a][o]:NaN;s.matrix[a][o]=c-l}else{const a=n;for(let o=0;o<r;o++)for(let c=0;c<i;c++)s.matrix[o][c]=t.matrix[o][c]-a}return s}}function Bn(e){const t=e.length;if(t!==2)return Array(t).fill(NaN);const n=e[0][0],r=e[0][1],i=e[1][0],s=e[1][1],a=n+s,o=n*s-r*i,c=a*a-4*o;if(c<0)return[NaN,NaN];const l=(a+Math.sqrt(c))/2,u=(a-Math.sqrt(c))/2;return[l,u]}function Dn(e){return t=>{const n=t.matrix.length,r=n>0?t.matrix[0].length:0;if(n!==r){const a=q(t.matrix[0][0]);return new $([],a,e)}const i=Bn(t.matrix),s=q(i[0]);return new $(i,s,e)}}function Ln(e){return t=>{const n=t.matrix.length,r=n>0?t.matrix[0].length:0;if(n!==r)return new M(0,0,NaN,e);const i=new M(n,r,0,e);for(let s=0;s<n;s++)i.matrix[s][s]=1;return i}}function Wn(e){return t=>{const n=t.matrix.length;return n===0?0:n*t.matrix[0].length}}function On(e){return(t,n,r,i,s,a)=>{const o=t.matrix.length;if(o===0)return;const c=t.matrix[0].length,l=r!==void 0?r:0,u=i!==void 0?i:o,p=s!==void 0?s:0,f=a!==void 0?a:c;for(let h=l;h<u&&!(h>=o);h++)for(let d=p;d<f&&!(d>=c);d++)t.matrix[h][d]=n}}function Rn(e){return(t,n,r)=>{if(!t.matrix[n])return NaN;const i=t.matrix[n][r];return i===void 0?NaN:i}}function Fn(e){if(e.length!==2)return e.map(n=>n.map(()=>NaN));const t=e[0][0]*e[1][1]-e[0][1]*e[1][0];return t===0?[[NaN,NaN],[NaN,NaN]]:[[e[1][1]/t,-e[0][1]/t],[-e[1][0]/t,e[0][0]/t]]}function zn(e){return t=>{const n=t.matrix.length,r=n>0?t.matrix[0].length:0;if(n!==r)return new M(n,r,NaN,e);const i=Fn(t.matrix),s=new M(n,r,NaN,e);return s.matrix=i,s}}function Hn(e){return t=>{const n=t.matrix.length;if(n===0)return!1;const r=t.matrix[0].length;if(n!==r)return!1;for(let i=0;i<n;i++)for(let s=0;s<r;s++)if(i+s!==n-1&&t.matrix[i][s]!==0)return!1;return!0}}function qn(e){return t=>{const n=t.matrix.length;if(n===0)return!1;const r=t.matrix[0].length;if(n!==r)return!1;for(let i=0;i<n;i++)for(let s=0;s<r;s++)if(t.matrix[s][i]!==-t.matrix[i][s])return!1;return!0}}function Un(e){return t=>{const n=t.matrix.length;if(n===0)return!1;const r=t.matrix[0].length;for(let i=0;i<n;i++)for(let s=0;s<r;s++){const a=t.matrix[i][s];if(a!==0&&a!==1)return!1}return!0}}function Gn(e){return t=>{const n=t.matrix.length;if(n===0)return!1;const r=t.matrix[0].length;if(n!==r)return!1;for(let i=0;i<n;i++)for(let s=0;s<r;s++)if(i!==s&&t.matrix[i][s]!==0)return!1;return!0}}function Kn(e){return t=>{const n=t.matrix.length;if(n===0)return!1;const r=t.matrix[0].length;if(n!==r)return!1;for(let i=0;i<n;i++)for(let s=0;s<r;s++)if(i===s){if(t.matrix[i][s]!==1)return!1}else if(t.matrix[i][s]!==0)return!1;return!0}}function Xn(e){return t=>{const n=t.matrix.length;if(n===0)return!1;const r=t.matrix[0].length;return n===r}}function Yn(e){return t=>{const n=t.matrix.length;if(n===0)return!1;const r=t.matrix[0].length;for(let i=0;i<n;i++){let s=0;for(let a=0;a<r;a++){const o=t.matrix[i][a];if(o<0)return!1;s+=o}if(Math.abs(s-1)>1e-10)return!1}return!0}}function Zn(e){return t=>{const n=t.matrix.length;if(n===0)return!1;const r=t.matrix[0].length;if(n!==r)return!1;for(let i=0;i<n;i++)for(let s=0;s<i;s++)if(t.matrix[i][s]!==t.matrix[s][i])return!1;return!0}}function Jn(e){return t=>{const n=t.matrix.length;if(n===0)return!1;const r=t.matrix[0].length;if(n!==r)return!1;let i=!0,s=!0;for(let a=0;a<n;a++)for(let o=0;o<r;o++)a>o&&t.matrix[a][o]!==0&&(i=!1),a<o&&t.matrix[a][o]!==0&&(s=!1);return i||s}}function Qn(e){return t=>{const n=t.matrix.length;if(n===0)return!0;const r=t.matrix[0].length;for(let i=0;i<n;i++)for(let s=0;s<r;s++)if(t.matrix[i][s]!==0)return!1;return!0}}function tr(e){return(t,n)=>{const r=t.matrix.length,i=r>0?t.matrix[0].length:0,s=n.matrix.length,a=s>0?n.matrix[0].length:0,o=r*s,c=i*a,l=new M(o,c,NaN,e);for(let u=0;u<r;u++)for(let p=0;p<i;p++){const f=t.matrix[u][p];for(let h=0;h<s;h++)for(let d=0;d<a;d++){const g=n.matrix[h][d];l.matrix[u*s+h][p*a+d]=f*g}}return l}}function er(e){return t=>{const n=t.matrix.length;if(n===0)return NaN;const r=t.matrix[0].length;let i=-1/0,s=!1;for(let a=0;a<n;a++)for(let o=0;o<r;o++){const c=t.matrix[a][o];isNaN(c)||(c>i&&(i=c),s=!0)}return s?i:NaN}}function nr(e){return t=>{const n=t.matrix.length;if(n===0)return NaN;const r=t.matrix[0].length,i=[];for(let a=0;a<n;a++)for(let o=0;o<r;o++){const c=t.matrix[a][o];isNaN(c)||i.push(c)}if(i.length===0)return NaN;i.sort((a,o)=>a-o);const s=Math.floor(i.length/2);return i.length%2!==0?i[s]:(i[s-1]+i[s])/2}}function rr(e){return t=>{const n=t.matrix.length;if(n===0)return NaN;const r=t.matrix[0].length;let i=1/0,s=!1;for(let a=0;a<n;a++)for(let o=0;o<r;o++){const c=t.matrix[a][o];isNaN(c)||(c<i&&(i=c),s=!0)}return s?i:NaN}}function ir(e){return t=>{const n=t.matrix.length;if(n===0)return NaN;const r=t.matrix[0].length,i=new Map;let s=0,a=NaN;for(let o=0;o<n;o++)for(let c=0;c<r;c++){const l=t.matrix[o][c];if(!isNaN(l)){const u=(i.get(l)||0)+1;i.set(l,u),u>s?(s=u,a=l):u===s&&l<a&&(a=l)}}return a}}function ar(e){return(t,n)=>{const r=t.matrix.length,i=r>0?t.matrix[0].length:0;if(n instanceof M){const s=n.matrix.length,a=s>0?n.matrix[0].length:0;if(i!==s)return new M(0,0,NaN,e);const o=new M(r,a,0,e);for(let c=0;c<r;c++)for(let l=0;l<a;l++){let u=0;for(let p=0;p<i;p++)u+=t.matrix[c][p]*n.matrix[p][l];o.matrix[c][l]=u}return o}else if(n instanceof $||Array.isArray(n.array||n)){const s=n.array||n;if(i!==s.length)return new M(0,0,NaN,e);const a=new M(r,1,0,e);for(let o=0;o<r;o++){let c=0;for(let l=0;l<i;l++)c+=t.matrix[o][l]*s[l];a.matrix[o][0]=c}return a}else{const s=n,a=new M(r,i,NaN,e);for(let o=0;o<r;o++)for(let c=0;c<i;c++)a.matrix[o][c]=t.matrix[o][c]*s;return a}}}function sr(e){return t=>{const n=t.matrix.length,r=n>0?t.matrix[0].length:0;return n===r?new M(n,r,NaN,e):new M(r,n,NaN,e)}}function or(e){return(t,n)=>{const r=t.matrix.length,i=r>0?t.matrix[0].length:0;if(r!==i)return new M(0,0,NaN,e);let s=new M(r,i,0,e);for(let c=0;c<r;c++)s.matrix[c][c]=1;let a=new M(r,i,NaN,e);for(let c=0;c<r;c++)a.matrix[c]=[...t.matrix[c]];let o=Math.floor(n);if(o<0)return new M(r,i,NaN,e);for(;o>0;){if(o%2===1){const l=new M(r,i,0,e);for(let u=0;u<r;u++)for(let p=0;p<i;p++){let f=0;for(let h=0;h<r;h++)f+=s.matrix[u][h]*a.matrix[h][p];l.matrix[u][p]=f}s=l}const c=new M(r,i,0,e);for(let l=0;l<r;l++)for(let u=0;u<i;u++){let p=0;for(let f=0;f<r;f++)p+=a.matrix[l][f]*a.matrix[f][u];c.matrix[l][u]=p}a=c,o=Math.floor(o/2)}return s}}function cr(e){return t=>{const n=t.matrix.length;if(n===0)return 0;const r=t.matrix[0].length,i=t.matrix.map(a=>[...a]);let s=0;for(let a=0;a<r&&s<n;a++){let o=s;for(;o<n&&Math.abs(i[o][a])<1e-10;)o++;if(o<n){[i[s],i[o]]=[i[o],i[s]];const c=i[s][a];for(let l=a;l<r;l++)i[s][l]/=c;for(let l=0;l<n;l++)if(l!==s){const u=i[l][a];for(let p=a;p<r;p++)i[l][p]-=u*i[s][p]}s++}}return s}}function lr(e){return(t,n)=>{const r=t.matrix.length;if(r===0){const a=q(t.matrix[0][0]);return new $([],a,e)}const i=[];for(let a=0;a<r;a++){const o=t.matrix[a].splice(n,1);i.push(o[0])}const s=q(i[0]);return new $(i,s,e)}}function ur(e){return(t,n)=>{const r=t.matrix.splice(n,1),i=q(r[0][0]);return new $(r[0]||[],i,e)}}function hr(e){return(t,n,r)=>{const i=t.matrix.length,s=i>0?t.matrix[0].length:0,a=n*r,o=[];for(let u=0;u<i;u++)for(let p=0;p<s;p++)o.push(t.matrix[u][p]);for(;o.length<a;)o.push(NaN);o.length>a&&(o.length=a);const c=[];let l=0;for(let u=0;u<n;u++){const p=[];for(let f=0;f<r;f++)p.push(o[l++]);c.push(p)}t.matrix=c}}function pr(e){return t=>{t.matrix.reverse();for(const n of t.matrix)n.reverse()}}function mr(e){return(t,n)=>{if(!t.matrix[n]){const i=q(t.matrix[0][0]);return new $([],i,e)}const r=q(t.matrix[n][0]);return new $([...t.matrix[n]],r,e)}}function fr(e){return t=>t.matrix.length}function dr(e){return(t,n,r,i)=>{t.matrix[n]&&(t.matrix[n][r]=i)}}function gr(e){return(t,n=0,r="asc")=>{t.matrix.length!==0&&t.matrix.sort((i,s)=>{const a=i[n],o=s[n];return a<o?r==="asc"?-1:1:a>o?r==="asc"?1:-1:0})}}function yr(e){return(t,n,r,i,s)=>{const a=r-n,o=s-i,c=new M(a,o,NaN,e);for(let l=0;l<a;l++){const u=n+l;if(u>=t.matrix.length)break;for(let p=0;p<o;p++){const f=i+p;if(f>=t.matrix[u].length)break;c.matrix[l][p]=t.matrix[u][f]}}return c}}function _r(e){return(t,n)=>{const r=t.matrix.length;if(r===0)return new M(0,0,NaN,e);const i=t.matrix[0].length,s=new M(r,i,NaN,e);if(n instanceof M)for(let a=0;a<r;a++)for(let o=0;o<i;o++){const c=t.matrix[a][o],l=n.matrix[a]&&n.matrix[a][o]!==void 0?n.matrix[a][o]:NaN;s.matrix[a][o]=c+l}else{const a=n;for(let o=0;o<r;o++)for(let c=0;c<i;c++)s.matrix[o][c]=t.matrix[o][c]+a}return s}}function xr(e){return(t,n,r)=>{const i=t.matrix.length;for(let s=0;s<i;s++){const a=t.matrix[s][n];t.matrix[s][n]=t.matrix[s][r],t.matrix[s][r]=a}}}function Nr(e){return(t,n,r)=>{const i=t.matrix[n];t.matrix[n]=t.matrix[r],t.matrix[r]=i}}function wr(e){return t=>{const n=t.matrix.length;if(n===0)return 0;const r=t.matrix[0].length,i=Math.min(n,r);let s=0;for(let a=0;a<i;a++)s+=t.matrix[a][a];return s}}function br(e){return t=>{const n=t.matrix.length;if(n===0)return new M(0,0,NaN,e);const r=t.matrix[0].length,i=new M(r,n,NaN,e);for(let s=0;s<n;s++)for(let a=0;a<r;a++)i.matrix[a][s]=t.matrix[s][a];return i}}var vr=Object.defineProperty,Sr=(e,t,n)=>t in e?vr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t,n)=>Sr(e,typeof t!="symbol"?t+"":t,n);class M{constructor(t=0,n=0,r=NaN,i){if(this.context=i,v(this,"matrix"),v(this,"_add_col"),v(this,"_add_row"),v(this,"_avg"),v(this,"_col"),v(this,"_columns"),v(this,"_concat"),v(this,"_copy"),v(this,"_det"),v(this,"_diff"),v(this,"_eigenvalues"),v(this,"_eigenvectors"),v(this,"_elements_count"),v(this,"_fill"),v(this,"_get"),v(this,"_inv"),v(this,"_is_antidiagonal"),v(this,"_is_antisymmetric"),v(this,"_is_binary"),v(this,"_is_diagonal"),v(this,"_is_identity"),v(this,"_is_square"),v(this,"_is_stochastic"),v(this,"_is_symmetric"),v(this,"_is_triangular"),v(this,"_is_zero"),v(this,"_kron"),v(this,"_max"),v(this,"_median"),v(this,"_min"),v(this,"_mode"),v(this,"_mult"),v(this,"_pinv"),v(this,"_pow"),v(this,"_rank"),v(this,"_remove_col"),v(this,"_remove_row"),v(this,"_reshape"),v(this,"_reverse"),v(this,"_row"),v(this,"_rows"),v(this,"_set"),v(this,"_sort"),v(this,"_submatrix"),v(this,"_sum"),v(this,"_swap_columns"),v(this,"_swap_rows"),v(this,"_trace"),v(this,"_transpose"),this.matrix=[],t>0&&n>0)for(let s=0;s<t;s++)this.matrix.push(Array(n).fill(r));this._add_col=En(this.context),this._add_row=In(this.context),this._avg=Mn(this.context),this._col=$n(this.context),this._columns=jn(this.context),this._concat=An(this.context),this._copy=kn(this.context),this._det=Vn(this.context),this._diff=Pn(this.context),this._eigenvalues=Dn(this.context),this._eigenvectors=Ln(this.context),this._elements_count=Wn(this.context),this._fill=On(this.context),this._get=Rn(this.context),this._inv=zn(this.context),this._is_antidiagonal=Hn(this.context),this._is_antisymmetric=qn(this.context),this._is_binary=Un(this.context),this._is_diagonal=Gn(this.context),this._is_identity=Kn(this.context),this._is_square=Xn(this.context),this._is_stochastic=Yn(this.context),this._is_symmetric=Zn(this.context),this._is_triangular=Jn(this.context),this._is_zero=Qn(this.context),this._kron=tr(this.context),this._max=er(this.context),this._median=nr(this.context),this._min=rr(this.context),this._mode=ir(this.context),this._mult=ar(this.context),this._pinv=sr(this.context),this._pow=or(this.context),this._rank=cr(this.context),this._remove_col=lr(this.context),this._remove_row=ur(this.context),this._reshape=hr(this.context),this._reverse=pr(this.context),this._row=mr(this.context),this._rows=fr(this.context),this._set=dr(this.context),this._sort=gr(this.context),this._submatrix=yr(this.context),this._sum=_r(this.context),this._swap_columns=xr(this.context),this._swap_rows=Nr(this.context),this._trace=wr(this.context),this._transpose=br(this.context)}toString(){let t="";for(let n=0;n<this.matrix.length;n++)t+=t===""?"":`
|
|
23
|
-
`,t+="["+this.matrix[n].join(", ")+"]";return t}add_col(...t){return this._add_col(this,...t)}add_row(...t){return this._add_row(this,...t)}avg(...t){return this._avg(this,...t)}col(...t){return this._col(this,...t)}columns(...t){return this._columns(this,...t)}concat(...t){return this._concat(this,...t)}copy(...t){return this._copy(this,...t)}det(...t){return this._det(this,...t)}diff(...t){return this._diff(this,...t)}eigenvalues(...t){return this._eigenvalues(this,...t)}eigenvectors(...t){return this._eigenvectors(this,...t)}elements_count(...t){return this._elements_count(this,...t)}fill(...t){return this._fill(this,...t)}get(...t){return this._get(this,...t)}inv(...t){return this._inv(this,...t)}is_antidiagonal(...t){return this._is_antidiagonal(this,...t)}is_antisymmetric(...t){return this._is_antisymmetric(this,...t)}is_binary(...t){return this._is_binary(this,...t)}is_diagonal(...t){return this._is_diagonal(this,...t)}is_identity(...t){return this._is_identity(this,...t)}is_square(...t){return this._is_square(this,...t)}is_stochastic(...t){return this._is_stochastic(this,...t)}is_symmetric(...t){return this._is_symmetric(this,...t)}is_triangular(...t){return this._is_triangular(this,...t)}is_zero(...t){return this._is_zero(this,...t)}kron(...t){return this._kron(this,...t)}max(...t){return this._max(this,...t)}median(...t){return this._median(this,...t)}min(...t){return this._min(this,...t)}mode(...t){return this._mode(this,...t)}mult(...t){return this._mult(this,...t)}pinv(...t){return this._pinv(this,...t)}pow(...t){return this._pow(this,...t)}rank(...t){return this._rank(this,...t)}remove_col(...t){return this._remove_col(this,...t)}remove_row(...t){return this._remove_row(this,...t)}reshape(...t){return this._reshape(this,...t)}reverse(...t){return this._reverse(this,...t)}row(...t){return this._row(this,...t)}rows(...t){return this._rows(this,...t)}set(...t){return this._set(this,...t)}sort(...t){return this._sort(this,...t)}submatrix(...t){return this._submatrix(this,...t)}sum(...t){return this._sum(this,...t)}swap_columns(...t){return this._swap_columns(this,...t)}swap_rows(...t){return this._swap_rows(this,...t)}trace(...t){return this._trace(this,...t)}transpose(...t){return this._transpose(this,...t)}}function Cr(e){return(t,n,r)=>new M(t,n,r,e)}function Er(e){return(t,n=0)=>m.from(t).get(n)}class Ir{constructor(t){this.context=t,this.add_col=(n,...r)=>n.add_col(...r),this.add_row=(n,...r)=>n.add_row(...r),this.avg=(n,...r)=>n.avg(...r),this.col=(n,...r)=>n.col(...r),this.columns=(n,...r)=>n.columns(...r),this.concat=(n,...r)=>n.concat(...r),this.copy=(n,...r)=>n.copy(...r),this.det=(n,...r)=>n.det(...r),this.diff=(n,...r)=>n.diff(...r),this.eigenvalues=(n,...r)=>n.eigenvalues(...r),this.eigenvectors=(n,...r)=>n.eigenvectors(...r),this.elements_count=(n,...r)=>n.elements_count(...r),this.fill=(n,...r)=>n.fill(...r),this.get=(n,...r)=>n.get(...r),this.inv=(n,...r)=>n.inv(...r),this.is_antidiagonal=(n,...r)=>n.is_antidiagonal(...r),this.is_antisymmetric=(n,...r)=>n.is_antisymmetric(...r),this.is_binary=(n,...r)=>n.is_binary(...r),this.is_diagonal=(n,...r)=>n.is_diagonal(...r),this.is_identity=(n,...r)=>n.is_identity(...r),this.is_square=(n,...r)=>n.is_square(...r),this.is_stochastic=(n,...r)=>n.is_stochastic(...r),this.is_symmetric=(n,...r)=>n.is_symmetric(...r),this.is_triangular=(n,...r)=>n.is_triangular(...r),this.is_zero=(n,...r)=>n.is_zero(...r),this.kron=(n,...r)=>n.kron(...r),this.max=(n,...r)=>n.max(...r),this.median=(n,...r)=>n.median(...r),this.min=(n,...r)=>n.min(...r),this.mode=(n,...r)=>n.mode(...r),this.mult=(n,...r)=>n.mult(...r),this.new=Cr(t),this.param=Er(),this.pinv=(n,...r)=>n.pinv(...r),this.pow=(n,...r)=>n.pow(...r),this.rank=(n,...r)=>n.rank(...r),this.remove_col=(n,...r)=>n.remove_col(...r),this.remove_row=(n,...r)=>n.remove_row(...r),this.reshape=(n,...r)=>n.reshape(...r),this.reverse=(n,...r)=>n.reverse(...r),this.row=(n,...r)=>n.row(...r),this.rows=(n,...r)=>n.rows(...r),this.set=(n,...r)=>n.set(...r),this.sort=(n,...r)=>n.sort(...r),this.submatrix=(n,...r)=>n.submatrix(...r),this.sum=(n,...r)=>n.sum(...r),this.swap_columns=(n,...r)=>n.swap_columns(...r),this.swap_rows=(n,...r)=>n.swap_rows(...r),this.trace=(n,...r)=>n.trace(...r),this.transpose=(n,...r)=>n.transpose(...r)}}var Mr=Object.defineProperty,$r=(e,t,n)=>t in e?Mr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jr=(e,t,n)=>$r(e,typeof t!="symbol"?t+"":t,n);class Ar{constructor(t){this.context=t,jr(this,"_live",!1)}setLive(){this._live=!0}get isnew(){return!this._live}get islast(){return this.context.idx===this.context.data.close.data.length-1}get isfirst(){return this.context.idx===0}get ishistory(){return this.context.idx<this.context.data.close.data.length-1}get isrealtime(){return this.context.idx===this.context.data.close.data.length-1}get isconfirmed(){return this.context.data.closeTime[this.context.data.closeTime.length-1]<=new Date().getTime()}get islastconfirmedhistory(){return this.context.data.closeTime[this.context.data.closeTime.length-1]<=new Date().getTime()}}var kr=Object.defineProperty,Tr=(e,t,n)=>t in e?kr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Vr=(e,t,n)=>Tr(e,typeof t!="symbol"?t+"":t,n);class Pr{constructor(t){this.context=t,Vr(this,"color",{param:(n,r=0)=>m.from(n).get(r),rgb:(n,r,i,s)=>s?`rgba(${n}, ${r}, ${i}, ${s})`:`rgb(${n}, ${r}, ${i})`,new:(n,r)=>{if(n&&n.startsWith("#")){const i=n.slice(1),s=parseInt(i.slice(0,2),16),a=parseInt(i.slice(2,4),16),o=parseInt(i.slice(4,6),16);return r?`rgba(${s}, ${a}, ${o}, ${r})`:`rgb(${s}, ${a}, ${o})`}return r?`rgba(${n}, ${r})`:n},white:"white",lime:"lime",green:"green",red:"red",maroon:"maroon",black:"black",gray:"gray",blue:"blue",yellow:"yellow",orange:"orange",purple:"purple",pink:"pink",brown:"brown",teal:"teal",cyan:"cyan",navy:"navy",indigo:"indigo",violet:"violet",magenta:"magenta",rose:"rose",gold:"gold",silver:"silver",bronze:"bronze"})}extractPlotOptions(t){const n={};for(let r in t)n[r]=m.from(t[r]).get(0);return n}indicator(t,n,r){}plotchar(t,n,r){this.context.plots[n]||(this.context.plots[n]={data:[],options:this.extractPlotOptions(r),title:n});const i=m.from(t).get(0);this.context.plots[n].data.push({time:this.context.marketData[this.context.idx].openTime,value:i,options:{...this.extractPlotOptions(r),style:"char"}})}plot(t,n,r){this.context.plots[n]||(this.context.plots[n]={data:[],options:this.extractPlotOptions(r),title:n});const i=m.from(t).get(0);this.context.plots[n].data.push({time:this.context.marketData[this.context.idx].openTime,value:i,options:this.extractPlotOptions(r)})}get bar_index(){return this.context.idx}na(t){return isNaN(m.from(t).get(0))}nz(t,n=0){const r=m.from(t).get(0),i=m.from(n).get(0);return isNaN(r)?i:r}}const xt=[["defval","title","tooltip","inline","group","display"],["defval","title","tooltip","group","confirm","display"],["defval","title","tooltip","inline","group","confirm","display"],["defval","title","options","tooltip","inline","group","confirm","display"],["defval","title","minval","maxval","step","tooltip","inline","group","confirm","display"]],Br={defval:e=>typeof e!="object",title:e=>typeof e=="string",tooltip:e=>typeof e=="string",inline:e=>typeof e=="string",group:e=>typeof e=="string",display:e=>typeof e=="string",confirm:e=>typeof e=="boolean",options:e=>Array.isArray(e),minval:e=>typeof e=="number",maxval:e=>typeof e=="number",step:e=>typeof e=="number"};function R(e){const t={};let n={};const r=new Array(xt.length).fill(!0);for(let i=0;i<e.length;i++){const s=e[i];if(typeof s=="object"){n=s;break}const a=xt.map((o,c)=>r[c]?o[i]:void 0);for(let o=0;o<a.length;o++){const c=a[o];if(c===void 0){r[o]=!1;continue}Br[c](s)?t[c]=s:r[o]=!1}}return{...n,...t}}function Dr(e){return(...t)=>R(t).defval}function Lr(e){return(...t)=>R(t).defval}function Wr(e){return(...t)=>R(t).defval}function Or(e){return(...t)=>R(t).defval}function Rr(e){return(...t)=>R(t).defval}function Fr(e){return(...t)=>R(t).defval}function zr(e){return(t,n=0)=>m.from(t).get(n)}function Hr(e){return(...t)=>R(t).defval}function qr(e){return(...t)=>R(t).defval}function Ur(e){return(...t)=>R(t).defval}function Gr(e){return(...t)=>R(t).defval}function Kr(e){return(...t)=>R(t).defval}function Xr(e){return(...t)=>R(t).defval}function Yr(e){return(...t)=>R(t).defval}function Zr(e){return(...t)=>R(t).defval}var Jr=Object.defineProperty,Qr=(e,t,n)=>t in e?Jr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,W=(e,t,n)=>Qr(e,typeof t!="symbol"?t+"":t,n);const ti={any:Dr,bool:Lr,color:Wr,enum:Or,float:Rr,int:Fr,param:zr,price:Hr,session:qr,source:Ur,string:Gr,symbol:Kr,text_area:Xr,time:Yr,timeframe:Zr};class ei{constructor(t){this.context=t,W(this,"any"),W(this,"bool"),W(this,"color"),W(this,"enum"),W(this,"float"),W(this,"int"),W(this,"param"),W(this,"price"),W(this,"session"),W(this,"source"),W(this,"string"),W(this,"symbol"),W(this,"text_area"),W(this,"time"),W(this,"timeframe"),Object.entries(ti).forEach(([n,r])=>{this[n]=r(t)})}}function ni(e){return t=>Math.abs(m.from(t).get(0))}function ri(e){return t=>Math.acos(m.from(t).get(0))}function ii(e){return t=>Math.asin(m.from(t).get(0))}function ai(e){return t=>Math.atan(m.from(t).get(0))}function si(e){return(...t)=>{const n=t.map(r=>m.from(r).get(0));return n.reduce((r,i)=>r+i,0)/n.length}}function oi(e){return t=>Math.ceil(m.from(t).get(0))}function ci(e){return t=>Math.cos(m.from(t).get(0))}function li(e){return()=>Math.E}function ui(e){return t=>Math.exp(m.from(t).get(0))}function hi(e){return t=>Math.floor(m.from(t).get(0))}function pi(e){return t=>Math.log(m.from(t).get(0))}function mi(e){return t=>Math.log(m.from(t).get(0))}function fi(e){return t=>Math.log10(m.from(t).get(0))}function di(e){return(...t)=>{const n=t.map(r=>m.from(r).get(0));return Math.max(...n)}}function gi(e){return(...t)=>{const n=t.map(r=>m.from(r).get(0));return Math.min(...n)}}function yi(e){return(t,n,r)=>typeof t=="string"?t:t instanceof m?n?new m(t.data,t.offset+n):t:!Array.isArray(t)&&typeof t=="object"?t:(e.params[r]||(e.params[r]=[]),Array.isArray(t)?new m(t,n||0):(e.params[r].length===0?e.params[r].push(t):e.params[r][e.params[r].length-1]=t,new m(e.params[r],0)))}function _i(e){return()=>1.618033988749895}function xi(e){return()=>Math.PI}function Ni(e){return(t,n)=>Math.pow(m.from(t).get(0),m.from(n).get(0))}function wi(e){return()=>Math.random()}function bi(e){return t=>Math.round(m.from(t).get(0))}function vi(e){return t=>e.precision(Math.round(m.from(t).get(0)/e.pine.syminfo.mintick)*e.pine.syminfo.mintick)}function Si(e){return()=>.6180339887498948}function Ci(e){return t=>Math.sign(m.from(t).get(0))}function Ei(e){return t=>Math.sin(m.from(t).get(0))}function Ii(e){return t=>Math.sqrt(m.from(t).get(0))}function Mi(e){return(t,n)=>{const r=m.from(n).get(0),i=m.from(t);let s=0;for(let a=0;a<r;a++){const o=i.get(a);s+=o}return s}}function $i(e){return t=>Math.tan(m.from(t).get(0))}function ji(e){return(t,n)=>{const r=m.from(t).get(0),i=m.from(n).get(0);return isNaN(r)&&isNaN(i)?!0:isNaN(r)||isNaN(i)?!1:Math.abs(r-i)<1e-8}}var Ai=Object.defineProperty,ki=(e,t,n)=>t in e?Ai(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,I=(e,t,n)=>ki(e,typeof t!="symbol"?t+"":t,n);const Ti={abs:ni,acos:ri,asin:ii,atan:ai,avg:si,ceil:oi,cos:ci,e:li,exp:ui,floor:hi,ln:pi,log:mi,log10:fi,max:di,min:gi,param:yi,phi:_i,pi:xi,pow:Ni,random:wi,round:bi,round_to_mintick:vi,rphi:Si,sign:Ci,sin:Ei,sqrt:Ii,sum:Mi,tan:$i,__eq:ji};class Vi{constructor(t){this.context=t,I(this,"_cache",{}),I(this,"abs"),I(this,"acos"),I(this,"asin"),I(this,"atan"),I(this,"avg"),I(this,"ceil"),I(this,"cos"),I(this,"e"),I(this,"exp"),I(this,"floor"),I(this,"ln"),I(this,"log"),I(this,"log10"),I(this,"max"),I(this,"min"),I(this,"param"),I(this,"phi"),I(this,"pi"),I(this,"pow"),I(this,"random"),I(this,"round"),I(this,"round_to_mintick"),I(this,"rphi"),I(this,"sign"),I(this,"sin"),I(this,"sqrt"),I(this,"sum"),I(this,"tan"),I(this,"__eq"),Object.entries(Ti).forEach(([n,r])=>{this[n]=r(t)})}}function Pi(e){return(t,n,r)=>{e.params[r]||(e.params[r]=[]);let i;if(t instanceof m)i=t.get(n||0);else if(Array.isArray(t)){const s=t.every(o=>o instanceof m),a=t.every(o=>!(o instanceof m)&&!Array.isArray(o));(s||a)&&t.length>=1?s?i=t.map(o=>o.get(0)):i=t:i=m.from(t).get(n||0)}else i=t;return e.params[r].length===0?e.params[r].push(i):e.params[r][e.params[r].length-1]=i,[i,r]}}const ot=["1","3","5","15","30","45","60","120","180","240","D","W","M"];function Nt(e,t,n,r,i=!1){for(let s=0;s<n.length;s++)if(n[s]<=e&&t<=r[s])return i||t>=r[s]?s:s-1;return-1}function wt(e,t,n,r,i=!1,s,a=!1){for(let o=n.length-1;o>=0;o--){if(r[o]<=t&&n[o]>=e){const c=s&&t>s;if(a&&i)for(let l=0;l<n.length;l++){if(n[l]>=e&&n[l]<t)return l;if(n[l]>=t)break}if(c&&i&&!a)for(let l=0;l<n.length;l++){if(n[l]>=e&&n[l]<t)return l;if(n[l]>=t)break}return o}if(r[o]<e)break}return-1}function Bi(e){return async(t,n,r,i=!1,s=!1,a=!1,o=null,c=null)=>{const l=t[0],u=n[0],p=r[0],f=r[1],h=Array.isArray(i)?i[0]:i,d=Array.isArray(s)?s[0]:s;if(e.isSecondaryContext)return p;const g=ot.indexOf(e.timeframe),y=ot.indexOf(u);if(g==-1||y==-1)throw new Error("Invalid timeframe");if(g===y)return p;const w=g>y,S=m.from(e.data.openTime).get(0),b=m.from(e.data.closeTime).get(0),C=`${l}_${u}_${f}`,N=`${C}_prevIdx`;if(e.cache[C]){const tt=e.cache[C],at=w?wt(S,b,tt.data.openTime.data,tt.data.closeTime.data,d,e.eDate,h):Nt(S,b,tt.data.openTime.data,tt.data.closeTime.data,d);if(at==-1)return NaN;const Y=tt.params[f][at];if(!w&&h){const yt=e.cache[N];return yt!==void 0&&yt===at?NaN:(e.cache[N]=at,Array.isArray(Y)?[Y]:Y)}return Array.isArray(Y)?[Y]:Y}const L=1e3*60*60*24*30,B=e.sDate?e.sDate-L:void 0,P=e.sDate&&e.eDate?void 0:e.limit||1e3,Q=new Pt(e.source,l,u,P,B,void 0);Q.markAsSecondary();const G=await Q.run(e.pineTSCode);e.cache[C]=G;const ut=w?wt(S,b,G.data.openTime.data,G.data.closeTime.data,d,e.eDate,h):Nt(S,b,G.data.openTime.data,G.data.closeTime.data,d);if(ut==-1)return NaN;const ht=G.params[f][ut];return!w&&h?(e.cache[N]=ut,NaN):Array.isArray(ht)?[ht]:ht}}function Di(e){return async(t,n,r,i=!1,s=null,a=!1,o=0)=>{const c=t[0],l=n[0],u=r[0],p=r[1];Array.isArray(i)&&i[0];const f=Array.isArray(a)?a[0]:a;if(e.isSecondaryContext)return Array.isArray(u)?[u]:u;const h=ot.indexOf(e.timeframe),d=ot.indexOf(l);if(h===-1||d===-1){if(f)return NaN;throw new Error("Invalid timeframe")}if(d>h){if(f)return NaN;throw new Error(`Timeframe ${l} is not lower than or equal to chart timeframe ${e.timeframe}`)}if(d===h)return[[u]];const g=`${c}_${l}_${p}_lower`;if(!e.cache[g]){const B=e.sDate?e.sDate-2592e6:void 0,P=e.sDate&&e.eDate?void 0:e.limit||1e3,Q=new Pt(e.source,c,l,P,B,e.eDate);Q.markAsSecondary();const G=await Q.run(e.pineTSCode);e.cache[g]=G}const y=e.cache[g],w=m.from(e.data.openTime).get(0),S=m.from(e.data.closeTime).get(0),b=y.data.openTime.data,C=y.data.closeTime.data,N=y.params[p];if(!N)return[];const L=[];for(let B=0;B<b.length;B++){const P=b[B];if(!(C[B]<=w)){if(P>=S)break;P>=w&&P<S&&L.push(N[B])}}return[L]}}var Li=Object.defineProperty,Wi=(e,t,n)=>t in e?Li(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,st=(e,t,n)=>Wi(e,typeof t!="symbol"?t+"":t,n);const Oi={param:Pi,security:Bi,security_lower_tf:Di};class Ri{constructor(t){this.context=t,st(this,"_cache",{}),st(this,"param"),st(this,"security"),st(this,"security_lower_tf"),Object.entries(Oi).forEach(([n,r])=>{this[n]=r(t)})}}function Fi(e){return t=>{e.taState||(e.taState={});const n=t||"accdist";e.taState[n]||(e.taState[n]={cumulativeSum:0});const r=e.taState[n],i=e.get(e.data.close,0),s=e.get(e.data.high,0),a=e.get(e.data.low,0),o=e.get(e.data.volume,0);if(isNaN(i)||isNaN(s)||isNaN(a)||isNaN(o))return e.precision(r.cumulativeSum);const c=s-a;let l=0;return c!==0&&(l=(i-a-(s-i))/c*o),r.cumulativeSum+=l,e.precision(r.cumulativeSum)}}function zi(e){return(t,n,r,i,s)=>{const a=m.from(n).get(0),o=m.from(r).get(0),c=m.from(i).get(0);e.taState||(e.taState={});const l=s||`alma_${a}_${o}_${c}`;if(!e.taState[l]){const h=o*(a-1),d=a/c,g=[];let y=0;for(let w=0;w<a;w++){const S=Math.exp(-Math.pow(w-h,2)/(2*d*d));g.push(S),y+=S}for(let w=0;w<g.length;w++)g[w]/=y;e.taState[l]={window:[],weights:g}}const u=e.taState[l],p=m.from(t).get(0);if(u.window.unshift(p),u.window.length<a)return NaN;u.window.length>a&&u.window.pop();let f=0;for(let h=0;h<a;h++)f+=u.weights[h]*u.window[a-1-h];return e.precision(f)}}function Hi(e){return(t,n)=>{const r=m.from(t).get(0);e.taState||(e.taState={});const i=n||`atr_${r}`;e.taState[i]||(e.taState[i]={prevAtr:null,initSum:0,initCount:0,prevClose:null});const s=e.taState[i],a=e.get(e.data.high,0),o=e.get(e.data.low,0),c=e.get(e.data.close,0);let l;if(s.prevClose!==null){const p=a-o,f=Math.abs(a-s.prevClose),h=Math.abs(o-s.prevClose);l=Math.max(p,f,h)}else l=a-o;if(s.prevClose=c,s.initCount<r)return s.initSum+=l,s.initCount++,s.initCount===r?(s.prevAtr=s.initSum/r,e.precision(s.prevAtr)):NaN;const u=(s.prevAtr*(r-1)+l)/r;return s.prevAtr=u,e.precision(u)}}function qi(e){return(t,n)=>{e.taState||(e.taState={});const r=n||"barssince";e.taState[r]||(e.taState[r]={lastTrueIndex:null});const i=e.taState[r];return m.from(t).get(0)?(i.lastTrueIndex=e.idx,0):i.lastTrueIndex===null?NaN:e.idx-i.lastTrueIndex}}function Ui(e){return(t,n,r,i)=>{const s=m.from(n).get(0),a=m.from(r).get(0);e.taState||(e.taState={});const o=i||`bb_${s}_${a}`;e.taState[o]||(e.taState[o]={window:[],sum:0});const c=e.taState[o],l=m.from(t).get(0);if(isNaN(l))return[[NaN,NaN,NaN]];if(c.window.unshift(l),c.sum+=l,c.window.length<s)return[[NaN,NaN,NaN]];if(c.window.length>s){const g=c.window.pop();c.sum-=g}const u=c.sum/s;let p=0;for(let g=0;g<s;g++)p+=Math.pow(c.window[g]-u,2);const f=Math.sqrt(p/s),h=u+a*f,d=u-a*f;return[[e.precision(h),e.precision(u),e.precision(d)]]}}function Gi(e){return(t,n,r,i)=>{const s=m.from(n).get(0),a=m.from(r).get(0);e.taState||(e.taState={});const o=i||`bbw_${s}_${a}`;e.taState[o]||(e.taState[o]={window:[],sum:0});const c=e.taState[o],l=m.from(t).get(0);if(isNaN(l))return NaN;if(c.window.unshift(l),c.sum+=l,c.window.length<s)return NaN;if(c.window.length>s){const y=c.window.pop();c.sum-=y}const u=c.sum/s;let p=0;for(let y=0;y<s;y++){const w=c.window[y]-u;p+=w*w}const f=p/s,h=Math.sqrt(f),d=a*h;if(u===0)return e.precision(0);const g=2*d/u*100;return e.precision(g)}}function Ki(e){return(t,n,r)=>{const i=m.from(n).get(0);e.taState||(e.taState={});const s=r||`cci_${i}`;e.taState[s]||(e.taState[s]={window:[],sum:0});const a=e.taState[s],o=m.from(t).get(0);if(isNaN(o))return NaN;if(a.window.unshift(o),a.sum+=o,a.window.length<i)return NaN;if(a.window.length>i){const f=a.window.pop();a.sum-=f}const c=a.sum/i;let l=0;for(let f=0;f<i;f++)l+=Math.abs(a.window[f]-c);const u=l/i;if(u===0)return 0;const p=(o-c)/(.015*u);return e.precision(p)}}function Xi(e){return(t,n=1,r)=>{typeof n=="string"&&(r=n,n=1);const i=m.from(n).get(0);e.taState||(e.taState={});const s=r||`change_${i}`;e.taState[s]||(e.taState[s]={window:[]});const a=e.taState[s],o=m.from(t).get(0);if(a.window.unshift(o),a.window.length<=i)return NaN;a.window.length>i+1&&a.window.pop();const c=o-a.window[i];return e.precision(c)}}function Yi(e){return(t,n,r)=>{const i=m.from(n).get(0);e.taState||(e.taState={});const s=r||`cmo_${i}`;e.taState[s]||(e.taState[s]={gainsWindow:[],lossesWindow:[],gainsSum:0,lossesSum:0});const a=e.taState[s],o=m.from(t).get(0),c=m.from(t).get(1);if(isNaN(o)||isNaN(c))return NaN;const l=o-c,u=l>=0?l:0,p=l>=0?0:-l;if(a.gainsWindow.unshift(u),a.lossesWindow.unshift(p),a.gainsSum+=u,a.lossesSum+=p,a.gainsWindow.length<i)return NaN;if(a.gainsWindow.length>i){const d=a.gainsWindow.pop(),g=a.lossesWindow.pop();a.gainsSum-=d,a.lossesSum-=g}const f=a.gainsSum+a.lossesSum;if(f===0)return e.precision(0);const h=100*(a.gainsSum-a.lossesSum)/f;return e.precision(h)}}function Zi(e){return(t,n,r)=>{const i=m.from(n).get(0),s=m.from(t);let a=0,o=!1;for(let u=0;u<i;u++){const p=s.get(u);if(isNaN(p)){o=!0;break}a+=p}if(o)return NaN;let c=0;for(let u=0;u<i;u++){const p=s.get(u);c+=p*(u+1)}if(a===0)return NaN;const l=-c/a;return e.precision(l)}}function Ji(e){return(t,n,r,i)=>{const s=m.from(r).get(0),a=m.from(t),o=m.from(n);if(e.idx<s-1)return NaN;let c=0,l=0,u=0,p=0,f=0,h=0;for(let S=0;S<s;S++){const b=a.get(S),C=o.get(S);isNaN(b)||isNaN(C)||(c+=b,l+=C,u+=b*C,p+=b*b,f+=C*C,h++)}if(h<2)return NaN;const d=h*u-c*l,g=h*p-c*c,y=h*f-l*l;if(g<=0||y<=0)return e.precision(0);const w=d/Math.sqrt(g*y);return e.precision(w)}}function Qi(e){return(t,n,r)=>{const i=m.from(t),s=m.from(n),a=i.get(0),o=s.get(0),c=i.get(1),l=s.get(1);if(isNaN(a)||isNaN(o)||isNaN(c)||isNaN(l))return!1;const u=a>o&&c<=l,p=a<o&&c>=l;return u||p}}function ta(e){return(t,n)=>{const r=m.from(t),i=m.from(n),s=r.get(0),a=i.get(0),o=r.get(1),c=i.get(1);return o<c&&s>a}}function ea(e){return(t,n)=>{const r=m.from(t),i=m.from(n),s=r.get(0),a=i.get(0),o=r.get(1),c=i.get(1);return o>c&&s<a}}function na(e){return(t,n)=>{e.taState||(e.taState={});const r=n||"cum";e.taState[r]||(e.taState[r]={cumulativeSum:0});const i=e.taState[r],s=m.from(t).get(0);return isNaN(s)||(i.cumulativeSum+=s),e.precision(i.cumulativeSum)}}function ra(e){return(t,n,r)=>{const i=m.from(n).get(0);e.taState||(e.taState={});const s=r||`dev_${i}`;e.taState[s]||(e.taState[s]={window:[],sum:0});const a=e.taState[s],o=m.from(t).get(0)||0;if(a.window.unshift(o),a.sum+=o,a.window.length<i)return NaN;if(a.window.length>i){const p=a.window.pop();a.sum-=p}const c=a.sum/i;let l=0;for(let p=0;p<i;p++)l+=Math.abs(a.window[p]-c);const u=l/i;return e.precision(u)}}function ia(e){return(t,n,r)=>{const i=m.from(t).get(0),s=m.from(n).get(0);e.taState||(e.taState={});const a=r||`dmi_${i}_${s}`;e.taState[a]||(e.taState[a]={prevHigh:NaN,prevLow:NaN,prevClose:NaN,trInitSum:0,plusInitSum:0,minusInitSum:0,initCount:0,prevSmoothedTR:NaN,prevSmoothedPlus:NaN,prevSmoothedMinus:NaN,dxInitSum:0,adxInitCount:0,prevADX:NaN});const o=e.taState[a],c=e.get(e.data.high,0),l=e.get(e.data.low,0),u=e.get(e.data.close,0);if(isNaN(c)||isNaN(l)||isNaN(u))return[[NaN,NaN,NaN]];if(isNaN(o.prevHigh))return o.prevHigh=c,o.prevLow=l,o.prevClose=u,[[NaN,NaN,NaN]];const p=Math.max(c-l,Math.abs(c-o.prevClose),Math.abs(l-o.prevClose)),f=c-o.prevHigh,h=o.prevLow-l,d=f>h&&f>0?f:0,g=h>f&&h>0?h:0;o.prevHigh=c,o.prevLow=l,o.prevClose=u;let y,w,S;if(o.initCount++,o.initCount<=i)o.trInitSum+=p,o.plusInitSum+=d,o.minusInitSum+=g,o.initCount===i&&(o.prevSmoothedTR=o.trInitSum/i,o.prevSmoothedPlus=o.plusInitSum/i,o.prevSmoothedMinus=o.minusInitSum/i);else{const P=1/i;o.prevSmoothedTR=P*p+(1-P)*o.prevSmoothedTR,o.prevSmoothedPlus=P*d+(1-P)*o.prevSmoothedPlus,o.prevSmoothedMinus=P*g+(1-P)*o.prevSmoothedMinus}if(y=o.prevSmoothedTR,w=o.prevSmoothedPlus,S=o.prevSmoothedMinus,o.initCount<i)return[[NaN,NaN,NaN]];const b=y===0?0:100*w/y,C=y===0?0:100*S/y,N=b+C,L=N===0?0:100*Math.abs(b-C)/N;let B=NaN;if(o.adxInitCount++,o.adxInitCount<=s)o.dxInitSum+=L,o.adxInitCount===s&&(o.prevADX=o.dxInitSum/s,B=o.prevADX);else{const P=1/s;o.prevADX=P*L+(1-P)*o.prevADX,B=o.prevADX}return[[e.precision(b),e.precision(C),e.precision(B)]]}}function aa(e){return(t,n,r)=>{const i=m.from(n).get(0);e.taState||(e.taState={});const s=r||`ema_${i}`;e.taState[s]||(e.taState[s]={prevEma:null,initSum:0,initCount:0});const a=e.taState[s],o=m.from(t).get(0);if(a.initCount<i)return a.initSum+=o,a.initCount++,a.initCount===i?(a.prevEma=a.initSum/i,e.precision(a.prevEma)):NaN;const c=2/(i+1),l=o*c+a.prevEma*(1-c);return a.prevEma=l,e.precision(l)}}function sa(e){return(t,n,r)=>{const i=m.from(n).get(0),s=m.from(t);for(let a=0;a<i;a++){const o=s.get(a),c=s.get(a+1);if(isNaN(o)||isNaN(c)||o>=c)return!1}return!0}}function oa(e){return(t,n,r)=>{const i=m.from(n).get(0);e.taState||(e.taState={});const s=r||`highest_${i}`;e.taState[s]||(e.taState[s]={window:[]});const a=e.taState[s],o=m.from(t).get(0);if(a.window.unshift(o),a.window.length<i)return NaN;a.window.length>i&&a.window.pop();const c=Math.max(...a.window.filter(l=>!isNaN(l)));return e.precision(c)}}function ca(e){return(t,n,r)=>{const i=m.from(n).get(0),s=m.from(t);if(e.idx<i-1)return NaN;let a=-1/0,o=NaN;for(let c=0;c<i;c++){const l=s.get(c);isNaN(l)||(isNaN(o)||l>a)&&(a=l,o=-c)}return o}}function la(e){return(t,n,r)=>{const i=m.from(n).get(0),s=Math.floor(i/2),a=Math.floor(Math.sqrt(i)),o=e.ta.wma,c=o(t,s,r?`${r}_wma1`:void 0),l=o(t,i,r?`${r}_wma2`:void 0);if(isNaN(c)||isNaN(l))return NaN;e.taState||(e.taState={});const u=r||`hma_raw_${i}`;e.taState[u]||(e.taState[u]=[]);const p=2*c-l;e.taState[u].unshift(p);const f=r?`${r}_hma_final`:`hma_final_${i}`;e.taState[f]||(e.taState[f]={window:[]});const h=e.taState[f];if(h.window.unshift(p),h.window.length<a)return NaN;h.window.length>a&&h.window.pop();let d=0,g=0;for(let w=0;w<a;w++){const S=a-w;d+=h.window[w]*S,g+=S}const y=d/g;return e.precision(y)}}function ua(e){return t=>{const n=e.get(e.data.close,0),r=e.get(e.data.high,0),i=e.get(e.data.low,0),s=e.get(e.data.volume,0);if(isNaN(n)||isNaN(r)||isNaN(i)||isNaN(s))return NaN;const a=(r-i)*s;if(a===0)return e.precision(0);const o=(2*n-r-i)/a;return e.precision(o)}}function ha(e){return(t,n,r,i,s)=>{const a=m.from(n).get(0),o=m.from(r).get(0);let c=!0;typeof i=="string"?s=i:i!==void 0&&(c=m.from(i).get(0));let l;const u=e.get(e.data.high,0),p=e.get(e.data.low,0);if(c){const C=e.get(e.data.close,1);isNaN(C)?l=NaN:l=Math.max(u-p,Math.abs(u-C),Math.abs(p-C))}else l=u-p;const f=m.from(t).get(0);e.taState||(e.taState={});const h=s||`kc_${a}_${o}_${c}`;e.taState[h]||(e.taState[h]={basisState:{prevEma:null,initSum:0,initCount:0},rangeState:{prevEma:null,initSum:0,initCount:0}});const d=e.taState[h],g=(C,N,L)=>{if(isNaN(N))return NaN;if(C.initCount<L)return C.initSum+=N,C.initCount++,C.initCount===L?(C.prevEma=C.initSum/L,C.prevEma):NaN;const B=2/(L+1);return C.prevEma=N*B+C.prevEma*(1-B),C.prevEma},y=g(d.basisState,f,a),w=g(d.rangeState,l,a);if(isNaN(y)||isNaN(w))return[[NaN,NaN,NaN]];const S=y+w*o,b=y-w*o;return[[e.precision(y),e.precision(S),e.precision(b)]]}}function pa(e){return(t,n,r,i,s)=>{const a=m.from(n).get(0),o=m.from(r).get(0);let c=!0;typeof i=="string"?s=i:i!==void 0&&(c=m.from(i).get(0)),e.taState||(e.taState={});const l=s||`kcw_${a}_${o}_${c}`;e.taState[l]||(e.taState[l]={basisState:{prevEma:null,initSum:0,initCount:0},rangeState:{prevEma:null,initSum:0,initCount:0}});const u=e.taState[l],p=(b,C,N)=>{if(isNaN(C))return NaN;if(b.initCount<N)return b.initSum+=C,b.initCount++,b.initCount===N?(b.prevEma=b.initSum/N,b.prevEma):NaN;const L=2/(N+1);return b.prevEma=C*L+b.prevEma*(1-L),b.prevEma};let f;const h=e.get(e.data.high,0),d=e.get(e.data.low,0);if(c){const b=e.get(e.data.close,1);isNaN(b)?f=NaN:f=Math.max(h-d,Math.abs(h-b),Math.abs(d-b))}else f=h-d;const g=m.from(t).get(0),y=p(u.basisState,g,a),w=p(u.rangeState,f,a);if(isNaN(y)||isNaN(w))return NaN;if(y===0)return e.precision(0);const S=2*w*o/y;return e.precision(S)}}function ma(e){return(t,n,r,i)=>{const s=m.from(n).get(0),a=m.from(r).get(0);e.taState||(e.taState={});const o=i||`linreg_${s}_${a}`;e.taState[o]||(e.taState[o]={window:[]});const c=e.taState[o],l=m.from(t).get(0);if(c.window.unshift(l),c.window.length<s)return NaN;c.window.length>s&&c.window.pop();let u=0,p=0,f=0,h=0;const d=s;for(let S=0;S<s;S++){const b=s-1-S,C=c.window[S];u+=b,p+=C,f+=b*C,h+=b*b}const g=d*h-u*u;if(g===0)return NaN;const y=(d*f-u*p)/g,w=(p-y*u)/d+y*(s-1-a);return e.precision(w)}}function fa(e){return(t,n,r)=>{const i=m.from(n).get(0);e.taState||(e.taState={});const s=r||`lowest_${i}`;e.taState[s]||(e.taState[s]={window:[]});const a=e.taState[s],o=m.from(t).get(0);if(a.window.unshift(o),a.window.length<i)return NaN;a.window.length>i&&a.window.pop();const c=a.window.filter(u=>!isNaN(u)&&u!==void 0),l=c.length>0?Math.min(...c):NaN;return e.precision(l)}}function da(e){return(t,n,r)=>{const i=m.from(n).get(0),s=m.from(t);if(e.idx<i-1)return NaN;let a=1/0,o=NaN;for(let c=0;c<i;c++){const l=s.get(c);isNaN(l)||(isNaN(o)||l<a)&&(a=l,o=-c)}return o}}function ga(e){return(t,n,r,i,s)=>{const a=m.from(n).get(0),o=m.from(r).get(0),c=m.from(i).get(0),l=s||`macd_${a}_${o}_${c}`,u=`${l}_fast`,p=`${l}_slow`,f=`${l}_signal`,h=e.ta.ema(t,a,u),d=e.ta.ema(t,o,p);let g=NaN;!isNaN(h)&&!isNaN(d)&&(g=h-d);let y=NaN;isNaN(g)||(y=e.ta.ema(g,c,f));let w=NaN;return!isNaN(g)&&!isNaN(y)&&(w=g-y),[[e.precision(g),e.precision(y),e.precision(w)]]}}function ya(e){return(t,n,r)=>{const i=m.from(n).get(0);e.taState||(e.taState={});const s=r||`median_${i}`;e.taState[s]||(e.taState[s]={window:[]});const a=e.taState[s],o=m.from(t).get(0);if(a.window.unshift(o),a.window.length<i)return NaN;a.window.length>i&&a.window.pop();const c=a.window.slice().sort((p,f)=>p-f),l=Math.floor(i/2),u=i%2===0?(c[l-1]+c[l])/2:c[l];return e.precision(u)}}function _a(e){return(t,n,r)=>{const i=m.from(n).get(0);e.taState||(e.taState={});const s=r||`mfi_${i}`;e.taState[s]||(e.taState[s]={upperWindow:[],lowerWindow:[],upperSum:0,lowerSum:0});const a=e.taState[s],o=m.from(t).get(0),c=m.from(t).get(1),l=e.get(e.data.volume,0);if(isNaN(o)||isNaN(l))return NaN;const u=isNaN(c)?NaN:o-c;let p=0,f=0;if(p=l*(u<=0?0:o),f=l*(u>=0?0:o),a.upperWindow.unshift(p),a.lowerWindow.unshift(f),a.upperSum+=p,a.lowerSum+=f,a.upperWindow.length<i)return NaN;if(a.upperWindow.length>i){const d=a.upperWindow.pop(),g=a.lowerWindow.pop();a.upperSum-=d,a.lowerSum-=g}if(a.lowerSum===0)return a.upperSum,e.precision(100);if(a.upperSum===0)return e.precision(0);const h=100-100/(1+a.upperSum/a.lowerSum);return e.precision(h)}}function xa(e){return(t,n,r)=>{const i=m.from(n).get(0),s=m.from(t);if(e.idx<i-1)return NaN;const a=new Map;for(let l=0;l<i;l++){const u=s.get(l);isNaN(u)||a.set(u,(a.get(u)||0)+1)}if(a.size===0)return NaN;let o=NaN,c=-1;for(const[l,u]of a.entries())u>c?(c=u,o=l):u===c&&l<o&&(o=l);return o}}function Na(e){return(t,n,r)=>{const i=m.from(n).get(0);return e.ta.change(t,i)}}function wa(e){return t=>{e.taState||(e.taState={});const n=t||"nvi";e.taState[n]||(e.taState[n]={nvi:1});const r=e.taState[n],i=e.get(e.data.close,0),s=e.get(e.data.close,1),a=e.get(e.data.volume,0),o=e.get(e.data.volume,1),c=isNaN(i)?0:i,l=isNaN(s)?0:s,u=isNaN(a)?0:a,p=isNaN(o)?0:o;if(!(c===0||l===0)&&u<p){const f=(c-l)/l;r.nvi=r.nvi+f*r.nvi}return e.precision(r.nvi)}}function ba(e){return()=>{e.taState||(e.taState={});const t="obv";e.taState[t]||(e.taState[t]={prevOBV:0});const n=e.taState[t],r=e.get(e.data.close,0),i=e.get(e.data.volume,0),s=e.get(e.data.close,1);if(isNaN(s))return n.prevOBV=0,e.precision(0);let a;return r>s?a=n.prevOBV+i:r<s?a=n.prevOBV-i:a=n.prevOBV,n.prevOBV=a,e.precision(a)}}function va(e){return(t,n,r)=>t instanceof m?n?new m(t.data,t.offset+n):t:(e.params[r]||(e.params[r]=[]),Array.isArray(t)?new m(t,n||0):(e.params[r].length===0?e.params[r].push(t):e.params[r][e.params[r].length-1]=t,new m(e.params[r],0)))}function Sa(e){return(t,n,r,i)=>{const s=m.from(n).get(0),a=m.from(r).get(0),o=m.from(t);if(e.idx<s-1)return NaN;const c=[];for(let d=0;d<s;d++){const g=o.get(d);if(isNaN(g))return NaN;c.push(g)}c.sort((d,g)=>d-g);let l=a/100*s-.5;l<0&&(l=0),l>s-1&&(l=s-1);const u=Math.floor(l),p=Math.ceil(l);if(u===p)return e.precision(c[u]);const f=l-u,h=c[u]+f*(c[p]-c[u]);return e.precision(h)}}function Ca(e){return(t,n,r,i)=>{const s=m.from(n).get(0),a=m.from(r).get(0),o=m.from(t);if(e.idx<s-1)return NaN;const c=[];for(let u=0;u<s;u++){const p=o.get(u);isNaN(p)||c.push(p)}if(c.length===0)return NaN;c.sort((u,p)=>u-p);let l=Math.ceil(a/100*c.length)-1;return l<0&&(l=0),l>=c.length&&(l=c.length-1),e.precision(c[l])}}function Ea(e){return(t,n,r)=>{const i=m.from(n).get(0),s=m.from(t);if(e.idx<i)return NaN;const a=s.get(0);if(isNaN(a))return NaN;let o=0,c=0;for(let l=1;l<=i;l++){const u=s.get(l);isNaN(u)||(c++,u<=a&&o++)}return c===0?NaN:e.precision(o/c*100)}}function Ia(e,t,n){const r=new Array(e.length).fill(NaN);for(let i=t+n;i<e.length;i++){const s=e[i-n];let a=!0;for(let o=1;o<=t;o++)if(e[i-n-o]>=s){a=!1;break}if(a){for(let o=1;o<=n;o++)if(e[i-n+o]>=s){a=!1;break}}a&&(r[i]=s)}return r}function Ma(e){return(t,n,r)=>{r==null&&(r=n,n=t,t=e.data.high);const i=m.from(n).get(0),s=m.from(r).get(0),a=m.from(t).toArray(),o=Ia(a,i,s),c=e.idx;return e.precision(o[c])}}function $a(e,t,n){const r=new Array(e.length).fill(NaN);for(let i=t+n;i<e.length;i++){const s=e[i-n];let a=!0;for(let o=1;o<=t;o++)if(e[i-n-o]<=s){a=!1;break}if(a){for(let o=1;o<=n;o++)if(e[i-n+o]<=s){a=!1;break}}a&&(r[i]=s)}return r}function ja(e){return(t,n,r)=>{r==null&&(r=n,n=t,t=e.data.low);const i=m.from(n).get(0),s=m.from(r).get(0),a=m.from(t).toArray(),o=$a(a,i,s),c=e.idx;return e.precision(o[c])}}function Aa(e){return t=>{e.taState||(e.taState={});const n=t||"pvi";e.taState[n]||(e.taState[n]={pvi:1});const r=e.taState[n],i=e.get(e.data.close,0),s=e.get(e.data.close,1),a=e.get(e.data.volume,0),o=e.get(e.data.volume,1),c=isNaN(i)?0:i,l=isNaN(s)?0:s,u=isNaN(a)?0:a,p=isNaN(o)?0:o;if(!(c===0||l===0)&&u>p){const f=(c-l)/l;r.pvi=r.pvi+f*r.pvi}return e.precision(r.pvi)}}function ka(e){return t=>{e.taState||(e.taState={});const n=t||"pvt";e.taState[n]||(e.taState[n]={cumulativeSum:0});const r=e.taState[n],i=e.get(e.data.close,0),s=e.get(e.data.close,1),a=e.get(e.data.volume,0);if(!isNaN(i)&&!isNaN(s)&&!isNaN(a)&&s!==0){const o=(i-s)/s*a;r.cumulativeSum+=o}return e.precision(r.cumulativeSum)}}function Ta(e){return(t,n,r)=>{const i=e.pine.ta.highest(t,n,(r||"range")+"_h"),s=e.pine.ta.lowest(t,n,(r||"range")+"_l");return isNaN(i)||isNaN(s)?NaN:e.precision(i-s)}}function Va(e){return(t,n,r)=>{const i=m.from(n).get(0),s=m.from(t);for(let a=0;a<i;a++){const o=s.get(a),c=s.get(a+1);if(isNaN(o)||isNaN(c)||o<=c)return!1}return!0}}function Pa(e){return(t,n,r)=>{const i=m.from(n).get(0);e.taState||(e.taState={});const s=r||`rma_${i}`;e.taState[s]||(e.taState[s]={prevRma:null,initSum:0,initCount:0});const a=e.taState[s],o=m.from(t).get(0)||0;if(a.initCount<i)return a.initSum+=o,a.initCount++,a.initCount===i?(a.prevRma=a.initSum/i,e.precision(a.prevRma)):NaN;const c=1/i,l=o*c+a.prevRma*(1-c);return a.prevRma=l,e.precision(l)}}function Ba(e){return(t,n,r)=>{const i=m.from(n).get(0);e.taState||(e.taState={});const s=r||`roc_${i}`;e.taState[s]||(e.taState[s]={window:[]});const a=e.taState[s],o=m.from(t).get(0);if(a.window.unshift(o),a.window.length<=i)return NaN;a.window.length>i+1&&a.window.pop();const c=a.window[i],l=(o-c)/c*100;return e.precision(l)}}function Da(e){return(t,n,r)=>{const i=m.from(n).get(0);e.taState||(e.taState={});const s=r||`rsi_${i}`;e.taState[s]||(e.taState[s]={prevValue:null,avgGain:0,avgLoss:0,initGains:[],initLosses:[]});const a=e.taState[s],o=m.from(t).get(0);if(a.prevValue!==null){const c=o-a.prevValue,l=c>0?c:0,u=c<0?-c:0;if(a.initGains.length<i){if(a.initGains.push(l),a.initLosses.push(u),a.initGains.length===i){a.avgGain=a.initGains.reduce((h,d)=>h+d,0)/i,a.avgLoss=a.initLosses.reduce((h,d)=>h+d,0)/i,a.prevValue=o;const f=a.avgLoss===0?100:100-100/(1+a.avgGain/a.avgLoss);return e.precision(f)}return a.prevValue=o,NaN}a.avgGain=(a.avgGain*(i-1)+l)/i,a.avgLoss=(a.avgLoss*(i-1)+u)/i;const p=a.avgLoss===0?100:100-100/(1+a.avgGain/a.avgLoss);return a.prevValue=o,e.precision(p)}return a.prevValue=o,NaN}}function La(e){return(t,n,r,i)=>{const s=m.from(t).get(0),a=m.from(n).get(0),o=m.from(r).get(0);e.taState||(e.taState={});const c=i||`sar_${s}_${a}_${o}`;e.taState[c]||(e.taState[c]={result:NaN,maxMin:NaN,acceleration:NaN,isBelow:!1,barIndex:0});const l=e.taState[c],u=e.get(e.data.high,0),p=e.get(e.data.low,0),f=e.get(e.data.close,0),h=e.get(e.data.close,1),d=e.get(e.data.high,1),g=e.get(e.data.low,1),y=e.get(e.data.high,2),w=e.get(e.data.low,2);if(isNaN(u)||isNaN(p)||isNaN(f))return NaN;let S=!1;return l.barIndex===1&&(f>h?(l.isBelow=!0,l.maxMin=u,l.result=g):(l.isBelow=!1,l.maxMin=p,l.result=d),S=!0,l.acceleration=s),l.barIndex>=1&&(l.result=l.result+l.acceleration*(l.maxMin-l.result),l.isBelow?l.result>p&&(S=!0,l.isBelow=!1,l.result=Math.max(u,l.maxMin),l.maxMin=p,l.acceleration=s):l.result<u&&(S=!0,l.isBelow=!0,l.result=Math.min(p,l.maxMin),l.maxMin=u,l.acceleration=s),S||(l.isBelow?u>l.maxMin&&(l.maxMin=u,l.acceleration=Math.min(l.acceleration+a,o)):p<l.maxMin&&(l.maxMin=p,l.acceleration=Math.min(l.acceleration+a,o))),l.isBelow?(l.result=Math.min(l.result,g),l.barIndex>1&&(l.result=Math.min(l.result,w))):(l.result=Math.max(l.result,d),l.barIndex>1&&(l.result=Math.max(l.result,y)))),l.barIndex++,l.barIndex<=1?NaN:e.precision(l.result)}}function Wa(e){return(t,n,r)=>{const i=m.from(n).get(0);e.taState||(e.taState={});const s=r||`sma_${i}`;e.taState[s]||(e.taState[s]={window:[],sum:0});const a=e.taState[s],o=m.from(t).get(0)||0;if(a.window.unshift(o),a.sum+=o,a.window.length<i)return NaN;if(a.window.length>i){const l=a.window.pop();a.sum-=l}const c=a.sum/i;return e.precision(c)}}function Oa(e){return(t,n,r=!0,i)=>{const s=m.from(n).get(0),a=m.from(r).get(0);e.taState||(e.taState={});const o=i||`stdev_${s}_${a}`;e.taState[o]||(e.taState[o]={window:[],sum:0});const c=e.taState[o],l=m.from(t).get(0);if(c.window.unshift(l),c.sum+=l,c.window.length<s)return NaN;if(c.window.length>s){const d=c.window.pop();c.sum-=d}const u=c.sum/s;let p=0;for(let d=0;d<s;d++)p+=Math.pow(c.window[d]-u,2);const f=a?s:s-1,h=Math.sqrt(p/f);return e.precision(h)}}function Ra(e){return(t,n,r,i,s)=>{const a=m.from(i).get(0);e.taState||(e.taState={});const o=s||`stoch_${a}`;e.taState[o]||(e.taState[o]={highWindow:[],lowWindow:[]});const c=e.taState[o],l=m.from(t).get(0),u=m.from(n).get(0),p=m.from(r).get(0);if(isNaN(l)||isNaN(u)||isNaN(p))return NaN;if(c.highWindow.unshift(u),c.lowWindow.unshift(p),c.highWindow.length<a)return NaN;c.highWindow.length>a&&(c.highWindow.pop(),c.lowWindow.pop());let f=c.highWindow[0],h=c.lowWindow[0];for(let y=1;y<a;y++)c.highWindow[y]>f&&(f=c.highWindow[y]),c.lowWindow[y]<h&&(h=c.lowWindow[y]);const d=f-h;if(d===0)return NaN;const g=100*(l-h)/d;return e.precision(g)}}function Fa(e){return(t,n,r)=>{const i=m.from(t).get(0),s=m.from(n).get(0);e.taState||(e.taState={});const a=r||`supertrend_${i}_${s}`;e.taState[a]||(e.taState[a]={trWindow:[],trSum:0,atrValue:NaN,atrCount:0,prevLowerBand:NaN,prevUpperBand:NaN,prevSuperTrend:NaN,prevDirection:NaN,prevClose:NaN});const o=e.taState[a],c=e.get(e.data.high,0),l=e.get(e.data.low,0),u=e.get(e.data.close,0);if(isNaN(c)||isNaN(l)||isNaN(u))return[[NaN,NaN]];const p=(c+l)/2;let f;isNaN(o.prevClose)?f=c-l:f=Math.max(c-l,Math.abs(c-o.prevClose),Math.abs(l-o.prevClose)),o.atrCount++,o.atrCount<=s?(o.trWindow.push(f),o.trSum+=f,o.atrCount===s&&(o.atrValue=o.trSum/s)):o.atrValue=(o.atrValue*(s-1)+f)/s;const h=o.atrValue,d=o.prevClose;if(o.prevClose=u,isNaN(h))return[[NaN,NaN]];let g=p+i*h,y=p-i*h;const w=isNaN(o.prevLowerBand)?0:o.prevLowerBand,S=isNaN(o.prevUpperBand)?0:o.prevUpperBand;isNaN(o.prevLowerBand)||y>w||d<w||(y=w),isNaN(o.prevUpperBand)||g<S||d>S||(g=S);let b,C;const N=o.prevSuperTrend;return o.atrCount===s?b=1:N===o.prevUpperBand?b=u>g?-1:1:b=u<y?1:-1,C=b===-1?y:g,o.prevLowerBand=y,o.prevUpperBand=g,o.prevSuperTrend=C,o.prevDirection=b,[[e.precision(C),b]]}}function za(e){return(t,n)=>{const r=[1,2,2,1],i=6;e.taState||(e.taState={});const s=n||"swma";e.taState[s]||(e.taState[s]={window:[]});const a=e.taState[s],o=m.from(t).get(0);if(a.window.unshift(o),a.window.length<4)return NaN;a.window.length>4&&a.window.pop();let c=0;for(let l=0;l<4;l++)c+=r[l]*a.window[3-l];return c/=i,e.precision(c)}}function Ha(e){return(t,n)=>{let r=!0;typeof t=="string"||t!==void 0&&(r=m.from(t).get(0));const i=e.get(e.data.high,0),s=e.get(e.data.low,0),a=e.get(e.data.close,1);if(isNaN(a))return r?e.precision(i-s):NaN;const o=Math.max(i-s,Math.abs(i-a),Math.abs(s-a));return e.precision(o)}}function qa(e){return(t,n,r,i)=>{const s=m.from(n).get(0),a=m.from(r).get(0);e.taState||(e.taState={});const o=i||`tsi_${s}_${a}`;e.taState[o]||(e.taState[o]={prevSource:NaN,ema1_pc_multiplier:2/(a+1),ema1_pc_value:NaN,ema1_pc_count:0,ema1_pc_sum:0,ema2_pc_multiplier:2/(s+1),ema2_pc_value:NaN,ema2_pc_count:0,ema2_pc_sum:0,ema1_abs_multiplier:2/(a+1),ema1_abs_value:NaN,ema1_abs_count:0,ema1_abs_sum:0,ema2_abs_multiplier:2/(s+1),ema2_abs_value:NaN,ema2_abs_count:0,ema2_abs_sum:0});const c=e.taState[o],l=m.from(t).get(0);if(isNaN(l))return NaN;const u=isNaN(c.prevSource)?NaN:l-c.prevSource;if(c.prevSource=l,isNaN(u))return NaN;const p=Math.abs(u);if(c.ema1_pc_count++,c.ema1_pc_count<=a?(c.ema1_pc_sum+=u,c.ema1_pc_count===a&&(c.ema1_pc_value=c.ema1_pc_sum/a)):c.ema1_pc_value=u*c.ema1_pc_multiplier+c.ema1_pc_value*(1-c.ema1_pc_multiplier),c.ema1_abs_count++,c.ema1_abs_count<=a?(c.ema1_abs_sum+=p,c.ema1_abs_count===a&&(c.ema1_abs_value=c.ema1_abs_sum/a)):c.ema1_abs_value=p*c.ema1_abs_multiplier+c.ema1_abs_value*(1-c.ema1_abs_multiplier),isNaN(c.ema1_pc_value)||isNaN(c.ema1_abs_value))return NaN;if(c.ema2_pc_count++,c.ema2_pc_count<=s?(c.ema2_pc_sum+=c.ema1_pc_value,c.ema2_pc_count===s&&(c.ema2_pc_value=c.ema2_pc_sum/s)):c.ema2_pc_value=c.ema1_pc_value*c.ema2_pc_multiplier+c.ema2_pc_value*(1-c.ema2_pc_multiplier),c.ema2_abs_count++,c.ema2_abs_count<=s?(c.ema2_abs_sum+=c.ema1_abs_value,c.ema2_abs_count===s&&(c.ema2_abs_value=c.ema2_abs_sum/s)):c.ema2_abs_value=c.ema1_abs_value*c.ema2_abs_multiplier+c.ema2_abs_value*(1-c.ema2_abs_multiplier),isNaN(c.ema2_pc_value)||isNaN(c.ema2_abs_value))return NaN;if(c.ema2_abs_value===0)return e.precision(0);const f=c.ema2_pc_value/c.ema2_abs_value;return e.precision(f)}}function Ua(e){return(t,n,r,i)=>{e.taState||(e.taState={});const s=i||"valuewhen";e.taState[s]||(e.taState[s]={values:[]});const a=e.taState[s],o=m.from(t).get(0),c=m.from(n).get(0),l=m.from(r).get(0);if(o&&a.values.push(c),isNaN(l)||l<0)return NaN;const u=a.values.length-1-l;if(u<0)return NaN;const p=a.values[u];return typeof p=="number"?e.precision(p):p}}function Ga(e){return(t,n,r)=>{const i=m.from(n).get(0);e.taState||(e.taState={});const s=r||`variance_${i}`;e.taState[s]||(e.taState[s]={window:[]});const a=e.taState[s],o=m.from(t).get(0);if(a.window.unshift(o),a.window.length<i)return NaN;a.window.length>i&&a.window.pop();let c=0,l=0;for(let f=0;f<i;f++)c+=a.window[f],l+=a.window[f]*a.window[f];const u=c/i,p=l/i-u*u;return e.precision(p)}}function Ka(e){return(t,n)=>{e.taState||(e.taState={});const r=n||"vwap";e.taState[r]||(e.taState[r]={cumulativePV:0,cumulativeVolume:0,lastSessionDate:null});const i=e.taState[r],s=m.from(t).get(0),a=m.from(e.data.volume).get(0),o=m.from(e.data.openTime).get(0),c=new Date(o).toISOString().slice(0,10);if(i.lastSessionDate!==c&&(i.cumulativePV=0,i.cumulativeVolume=0,i.lastSessionDate=c),i.cumulativePV+=s*a,i.cumulativeVolume+=a,i.cumulativeVolume===0)return NaN;const l=i.cumulativePV/i.cumulativeVolume;return e.precision(l)}}function Xa(e){return(t,n,r)=>{const i=m.from(n).get(0);e.taState||(e.taState={});const s=r||`vwma_${i}`;e.taState[s]||(e.taState[s]={window:[],volumeWindow:[]});const a=e.taState[s],o=m.from(t).get(0),c=e.get(e.data.volume,0);if(a.window.unshift(o),a.volumeWindow.unshift(c),a.window.length<i)return NaN;a.window.length>i&&(a.window.pop(),a.volumeWindow.pop());let l=0,u=0;for(let f=0;f<i;f++)l+=a.window[f]*a.volumeWindow[f],u+=a.volumeWindow[f];const p=l/u;return e.precision(p)}}function Ya(e){return t=>{e.taState||(e.taState={});const n=t||"wad";e.taState[n]||(e.taState[n]={cumulativeSum:0});const r=e.taState[n],i=e.get(e.data.close,0),s=e.get(e.data.high,0),a=e.get(e.data.low,0),o=e.get(e.data.close,1);if(isNaN(i)||isNaN(s)||isNaN(a))return e.precision(r.cumulativeSum);let c=0;if(!isNaN(o)){const l=Math.max(s,o),u=Math.min(a,o),p=i-o;p>0?c=i-u:p<0&&(c=i-l)}return r.cumulativeSum+=c,e.precision(r.cumulativeSum)}}function Za(e){return(t,n,r)=>{const i=m.from(n).get(0);e.taState||(e.taState={});const s=r||`wma_${i}`;e.taState[s]||(e.taState[s]={window:[]});const a=e.taState[s],o=m.from(t).get(0);if(a.window.unshift(o),a.window.length<i)return NaN;a.window.length>i&&a.window.pop();let c=0,l=0;for(let p=0;p<i;p++){const f=i-p;c+=a.window[p]*f,l+=f}const u=c/l;return e.precision(u)}}function Ja(e){return(t,n)=>{const r=m.from(t).get(0);e.taState||(e.taState={});const i=n||`wpr_${r}`;e.taState[i]||(e.taState[i]={highWindow:[],lowWindow:[]});const s=e.taState[i],a=e.get(e.data.high,0),o=e.get(e.data.low,0),c=e.get(e.data.close,0);if(isNaN(a)||isNaN(o)||isNaN(c))return NaN;if(s.highWindow.unshift(a),s.lowWindow.unshift(o),s.highWindow.length<r)return NaN;s.highWindow.length>r&&(s.highWindow.pop(),s.lowWindow.pop());let l=s.highWindow[0],u=s.lowWindow[0];for(let h=1;h<r;h++)s.highWindow[h]>l&&(l=s.highWindow[h]),s.lowWindow[h]<u&&(u=s.lowWindow[h]);const p=l-u;if(p===0)return e.precision(0);const f=(l-c)/p*-100;return e.precision(f)}}function Qa(e){return t=>{const n=e.get(e.data.close,0),r=e.get(e.data.open,0),i=e.get(e.data.high,0),s=e.get(e.data.low,0),a=e.get(e.data.volume,0);if(isNaN(n)||isNaN(r)||isNaN(i)||isNaN(s)||isNaN(a))return NaN;const o=i-s;if(o===0)return e.precision(0);const c=(n-r)/o*a;return e.precision(c)}}var ts=Object.defineProperty,es=(e,t,n)=>t in e?ts(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t,n)=>es(e,typeof t!="symbol"?t+"":t,n);const ns={accdist:Fi,alma:zi,atr:Hi,barssince:qi,bb:Ui,bbw:Gi,cci:Ki,change:Xi,cmo:Yi,cog:Zi,correlation:Ji,cross:Qi,crossover:ta,crossunder:ea,cum:na,dev:ra,dmi:ia,ema:aa,falling:sa,highest:oa,highestbars:ca,hma:la,iii:ua,kc:ha,kcw:pa,linreg:ma,lowest:fa,lowestbars:da,macd:ga,median:ya,mfi:_a,mode:xa,mom:Na,nvi:wa,obv:ba,param:va,percentile_linear_interpolation:Sa,percentile_nearest_rank:Ca,percentrank:Ea,pivothigh:Ma,pivotlow:ja,pvi:Aa,pvt:ka,range:Ta,rising:Va,rma:Pa,roc:Ba,rsi:Da,sar:La,sma:Wa,stdev:Oa,stoch:Ra,supertrend:Fa,swma:za,tr:Ha,tsi:qa,valuewhen:Ua,variance:Ga,vwap:Ka,vwma:Xa,wad:Ya,wma:Za,wpr:Ja,wvad:Qa};class rs{constructor(t){this.context=t,x(this,"accdist"),x(this,"alma"),x(this,"atr"),x(this,"barssince"),x(this,"bb"),x(this,"bbw"),x(this,"cci"),x(this,"change"),x(this,"cmo"),x(this,"cog"),x(this,"correlation"),x(this,"cross"),x(this,"crossover"),x(this,"crossunder"),x(this,"cum"),x(this,"dev"),x(this,"dmi"),x(this,"ema"),x(this,"falling"),x(this,"highest"),x(this,"highestbars"),x(this,"hma"),x(this,"iii"),x(this,"kc"),x(this,"kcw"),x(this,"linreg"),x(this,"lowest"),x(this,"lowestbars"),x(this,"macd"),x(this,"median"),x(this,"mfi"),x(this,"mode"),x(this,"mom"),x(this,"nvi"),x(this,"obv"),x(this,"param"),x(this,"percentile_linear_interpolation"),x(this,"percentile_nearest_rank"),x(this,"percentrank"),x(this,"pivothigh"),x(this,"pivotlow"),x(this,"pvi"),x(this,"pvt"),x(this,"range"),x(this,"rising"),x(this,"rma"),x(this,"roc"),x(this,"rsi"),x(this,"sar"),x(this,"sma"),x(this,"stdev"),x(this,"stoch"),x(this,"supertrend"),x(this,"swma"),x(this,"tr"),x(this,"tsi"),x(this,"valuewhen"),x(this,"variance"),x(this,"vwap"),x(this,"vwma"),x(this,"wad"),x(this,"wma"),x(this,"wpr"),x(this,"wvad"),Object.entries(ns).forEach(([n,r])=>{this[n]=r(t)})}}class is{constructor(t){this.context=t}logFormat(t,...n){return t.replace(/{(\d+)}/g,(r,i)=>n[i])}param(t,n=0,r){return m.from(t).get(n)}warning(t,...n){console.warn(this.logFormat(t,...n))}error(t,...n){console.error(this.logFormat(t,...n))}info(t,...n){console.log(this.logFormat(t,...n))}}class as{constructor(t){this.context=t}param(t,n=0,r){return m.from(t).get(n)}tostring(t){return String(t)}tonumber(t){return Number(t)}lower(t){return String(t).toLowerCase()}upper(t){return String(t).toUpperCase()}trim(t){return String(t).trim()}repeat(t,n,r=""){return Array(n).fill(t).join(r||"")}replace_all(t,n,r){return String(t).replaceAll(n,r)}replace(t,n,r,i=0){const s=String(t),a=String(n),o=String(r),c=Math.floor(Number(i))||0;if(a==="")return s;let l=0,u=0;for(;;){const p=s.indexOf(a,l);if(p===-1)return s;if(u===c)return s.substring(0,p)+o+s.substring(p+a.length);u++,l=p+a.length}}contains(t,n){return String(t).includes(n)}endswith(t,n){return String(t).endsWith(n)}startswith(t,n){return String(t).startsWith(n)}pos(t,n){const r=String(t).indexOf(n);return r===-1?NaN:r}length(t){return String(t).length}match(t,n){return String(t).match(new RegExp(n))}split(t,n){return[String(t).split(n)]}substring(t,n,r){return String(t).substring(n,r)}format(t,...n){return t.replace(/{(\d+)}/g,(r,i)=>n[i])}}class ss{constructor(t){this.context=t}param(t,n=0,r){return m.from(t).get(n)}get main_period(){return this.context.timeframe}get period(){return this.context.timeframe}get multiplier(){const t=parseInt(this.context.timeframe);return isNaN(t)?1:t}get isdwm(){return["D","W","M"].includes(this.context.timeframe.slice(-1))}get isdaily(){return this.context.timeframe.slice(-1)==="D"}get isweekly(){return this.context.timeframe.slice(-1)==="W"}get ismonthly(){return this.context.timeframe.slice(-1)==="M"}get isseconds(){return this.context.timeframe.slice(-1)==="S"}get isminutes(){return parseInt(this.context.timeframe).toString()==this.context.timeframe.trim()}get isintraday(){return!this.isdwm}from_seconds(t){return t<60?Math.ceil(t/5)*5+"S":t<60*60*24?Math.ceil(t/60):t<=60*60*24*7*52?t%(60*60*24*7)===0?Math.ceil(t/604800)+"W":Math.ceil(t/(60*60*24))+"D":"12M"}in_seconds(t){const n=parseInt(t),r=t.slice(-1);return r==="S"?n:r==="D"?n*60*60*24:r==="W"?n*60*60*24*7:r==="M"?n*60*60*24*30:isNaN(n)?0:n*60}}var os=Object.defineProperty,cs=(e,t,n)=>t in e?os(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,j=(e,t,n)=>cs(e,typeof t!="symbol"?t+"":t,n);const Vt=class dt{constructor({marketData:t,source:n,tickerId:r,timeframe:i,limit:s,sDate:a,eDate:o,fullContext:c}){j(this,"data",{open:new m([]),high:new m([]),low:new m([]),close:new m([]),volume:new m([]),hl2:new m([]),hlc3:new m([]),ohlc4:new m([]),hlcc4:new m([])}),j(this,"cache",{}),j(this,"taState",{}),j(this,"isSecondaryContext",!1),j(this,"NA",NaN),j(this,"lang"),j(this,"pine"),j(this,"idx",0),j(this,"params",{}),j(this,"const",{}),j(this,"var",{}),j(this,"let",{}),j(this,"result"),j(this,"plots",{}),j(this,"marketData"),j(this,"source"),j(this,"tickerId"),j(this,"timeframe",""),j(this,"limit"),j(this,"sDate"),j(this,"eDate"),j(this,"fullContext"),j(this,"pineTSCode"),this.marketData=t,this.source=n,this.tickerId=r,this.timeframe=i,this.limit=s,this.sDate=a,this.eDate=o,this.fullContext=c||this;const l=new Pr(this),u={plotchar:l.plotchar.bind(l),na:l.na.bind(l),color:l.color,plot:l.plot.bind(l),nz:l.nz.bind(l)},p=this;this.pine={input:new ei(this),ta:new rs(this),math:new Vi(this),request:new Ri(this),array:new un(this),map:new Cn(this),matrix:new Ir(this),na:u.na,plotchar:u.plotchar,color:u.color,plot:u.plot,nz:u.nz,syminfo:null,timeframe:new ss(this),barstate:new Ar(this),get bar_index(){return p.idx},get last_bar_index(){return p.data.close.length-1},get last_bar_time(){return p.data.openTime.get(p.data.openTime.length-1)},get timenow(){return new Date().getTime()},log:new is(this),str:new as(this),...Ue}}init(t,n,r=0){let i;return n instanceof m?i=n.get(0):Array.isArray(n)?Array.isArray(n[0])?i=n[0]:i=n[n.length-1+r]:i=n,t?t instanceof m?(t.data[t.data.length-1]=i,t):Array.isArray(t)?(t[t.length-1]=i,new m(t)):new m([i]):new m([i])}initVar(t,n){if(t)return t;let r;return n instanceof m?r=n.get(0):Array.isArray(n)?Array.isArray(n[0])?r=n[0]:r=this.precision(n[n.length-1]):r=this.precision(n),new m([r])}precision(t,n=10){const r=10**n;return typeof t=="number"?Math.round(t*r)/r:t}param(t,n,r){return typeof t=="string"?t:t instanceof m?n?new m(t.data,t.offset+n):t:!Array.isArray(t)&&typeof t=="object"?t:(this.params[r]||(this.params[r]=[]),Array.isArray(t)?new m(t,n||0):(this.params[r].length===0?this.params[r].push(t):this.params[r][this.params[r].length-1]=t,new m(this.params[r],0)))}get(t,n){if(t instanceof m)return t.get(n);if(Array.isArray(t)){const r=t.length-1-n;return r<0||r>=t.length?NaN:t[r]}return t}set(t,n){if(t instanceof m){t.set(0,n);return}if(Array.isArray(t)){t.length>0?t[t.length-1]=n:t.push(n);return}}get math(){return this._showDeprecationWarning("const math = context.math","const { math, ta, input } = context.pine"),this.pine.math}get ta(){return this._showDeprecationWarning("const ta = context.ta","const { ta, math, input } = context.pine"),this.pine.ta}get input(){return this._showDeprecationWarning("const input = context.input","const { input, math, ta } = context.pine"),this.pine.input}get request(){return this._showDeprecationWarning("const request = context.request","const { request, math, ta } = context.pine"),this.pine.request}get array(){return this._showDeprecationWarning("const array = context.array","const { array, math, ta } = context.pine"),this.pine.array}get core(){return this._showDeprecationWarning("context.core.*","context.pine (e.g., const { na, plotchar, color, plot, nz } = context.pine)"),{na:this.pine.na,plotchar:this.pine.plotchar,color:this.pine.color,plot:this.pine.plot,nz:this.pine.nz}}_showDeprecationWarning(t,n){const r=`${t}->${n}`;dt._deprecationWarningsShown.has(r)||(dt._deprecationWarningsShown.add(r),typeof window<"u"?console.warn("%c[WARNING]%c %s syntax is deprecated. Use %s instead. This will be removed in a future version.","color: #FFA500; font-weight: bold;","color: #FFA500;",t,n):console.warn(`\x1B[33m[WARNING] ${t} syntax is deprecated. Use ${n} instead. This will be removed in a future version.\x1B[0m`))}};j(Vt,"_deprecationWarningsShown",new Set);let bt=Vt;var ls=Object.defineProperty,us=(e,t,n)=>t in e?ls(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,V=(e,t,n)=>us(e,typeof t!="symbol"?t+"":t,n);class Pt{constructor(t,n,r,i,s,a){this.source=t,this.tickerId=n,this.timeframe=r,this.limit=i,this.sDate=s,this.eDate=a,V(this,"data",[]),V(this,"open",[]),V(this,"high",[]),V(this,"low",[]),V(this,"close",[]),V(this,"volume",[]),V(this,"hl2",[]),V(this,"hlc3",[]),V(this,"ohlc4",[]),V(this,"hlcc4",[]),V(this,"openTime",[]),V(this,"closeTime",[]),V(this,"_readyPromise",null),V(this,"_ready",!1),V(this,"_debugSettings",{ln:!1,debug:!1}),V(this,"_transpiledCode",null),V(this,"_isSecondaryContext",!1),V(this,"_syminfo"),this._readyPromise=new Promise(o=>{this.loadMarketData(t,n,r,i,s,a).then(c=>{const l=c;this.data=l;const u=l.map(N=>N.open),p=l.map(N=>N.close),f=l.map(N=>N.high),h=l.map(N=>N.low),d=l.map(N=>N.volume),g=l.map(N=>(N.high+N.low+N.close)/3),y=l.map(N=>(N.high+N.low)/2),w=l.map(N=>(N.high+N.low+N.open+N.close)/4),S=l.map(N=>(N.high+N.low+N.close+N.close)/4),b=l.map(N=>N.openTime),C=l.map(N=>N.closeTime);this.open=u,this.close=p,this.high=f,this.low=h,this.volume=d,this.hl2=y,this.hlc3=g,this.ohlc4=w,this.hlcc4=S,this.openTime=b,this.closeTime=C,t&&t.getSymbolInfo?t.getSymbolInfo(n).then(N=>{this._syminfo=N,this._ready=!0,o(!0)}).catch(N=>{console.warn("Failed to get symbol info, using default values:",N),this._ready=!0,o(!0)}):(this._ready=!0,o(!0))})})}get transpiledCode(){return this._transpiledCode}markAsSecondary(){this._isSecondaryContext=!0}setDebugSettings({ln:t,debug:n}){this._debugSettings.ln=t,this._debugSettings.debug=n}async loadMarketData(t,n,r,i,s,a){return Array.isArray(t)?t:t.getMarketData(n,r,i,s,a)}async ready(){if(this._ready)return!0;if(!this._readyPromise)throw new Error("PineTS is not ready");return this._readyPromise}run(t,n,r){if(r&&r>0){const i=typeof this.eDate>"u"&&!Array.isArray(this.source);return this._runPaginated(t,n,r,i)}else return this._runComplete(t,n)}async _runComplete(t,n){await this.ready(),n||(n=this.data.length);const r=this._initializeContext(t,this._isSecondaryContext);return this._transpiledCode=this._transpileCode(t),await this._executeIterations(r,this._transpiledCode,this.data.length-n,this.data.length),r}async*_runPaginated(t,n,r,i=!1){await this.ready(),n||(n=this.data.length);const s=this._initializeContext(t,this._isSecondaryContext);this._transpiledCode=this._transpileCode(t);let a=this.data.length-n;for(;;){const o=this.data.length-a;if(o>0){const u=Math.min(o,r),p=this._getResultLength(s.result);await this._executeIterations(s,this._transpiledCode,a,a+u),a+=u,yield this._createPageContext(s,p);continue}if(!i||Array.isArray(this.source))break;const{newCandles:c,updatedLastCandle:l}=await this._updateMarketData();if(c===0&&!l){yield null;continue}this._removeLastResult(s),a=this.data.length-(c+1),s.pine.barstate.setLive()}}_getResultLength(t){if(Array.isArray(t))return t.length;if(typeof t=="object"&&t!==null){const n=Object.keys(t);if(n.length>0&&Array.isArray(t[n[0]]))return t[n[0]].length}return 0}_createPageContext(t,n){const r=new bt({marketData:this.data,source:this.source,tickerId:this.tickerId,timeframe:this.timeframe,limit:this.limit,sDate:this.sDate,eDate:this.eDate,fullContext:t});if(r.pineTSCode=t.pineTSCode,r.idx=t.idx,Array.isArray(t.result))r.result=t.result.slice(n);else if(typeof t.result=="object"&&t.result!==null){r.result={};for(let i in t.result)Array.isArray(t.result[i])?r.result[i]=t.result[i].slice(n):r.result[i]=t.result[i]}else r.result=t.result;return r.plots={...t.plots},r}async _updateMarketData(t){if(Array.isArray(this.source))return{newCandles:0,updatedLastCandle:!1};const n=this.source,r=this.data.length-1,i=this.data[r].openTime;try{const s=await n.getMarketData(this.tickerId,this.timeframe,void 0,i,t);if(!s||s.length===0)return{newCandles:0,updatedLastCandle:!1};let a=!1,o=0;for(let c=0;c<s.length;c++){const l=s[c];l.openTime===i?(this._replaceCandle(r,l),a=!0):l.openTime>i&&(this._appendCandle(l),o++)}return{newCandles:o,updatedLastCandle:a}}catch(s){return console.error("Error updating market data:",s),{newCandles:0,updatedLastCandle:!1}}}_replaceCandle(t,n){this.data[t]=n,this.open[t]=n.open,this.close[t]=n.close,this.high[t]=n.high,this.low[t]=n.low,this.volume[t]=n.volume,this.hl2[t]=(n.high+n.low)/2,this.hlc3[t]=(n.high+n.low+n.close)/3,this.ohlc4[t]=(n.high+n.low+n.open+n.close)/4,this.hlcc4[t]=(n.high+n.low+n.close+n.close)/4,this.openTime[t]=n.openTime,this.closeTime[t]=n.closeTime}_appendCandle(t){this.data.push(t),this.open.push(t.open),this.close.push(t.close),this.high.push(t.high),this.low.push(t.low),this.volume.push(t.volume),this.hl2.push((t.high+t.low)/2),this.hlc3.push((t.high+t.low+t.close)/3),this.ohlc4.push((t.high+t.low+t.open+t.close)/4),this.hlcc4.push((t.high+t.low+t.close+t.close)/4),this.openTime.push(t.openTime),this.closeTime.push(t.closeTime)}_removeLastResult(t){if(Array.isArray(t.result))t.result.pop();else if(typeof t.result=="object"&&t.result!==null)for(let n in t.result)Array.isArray(t.result[n])&&t.result[n].pop();t.data.close.data.pop(),t.data.open.data.pop(),t.data.high.data.pop(),t.data.low.data.pop(),t.data.volume.data.pop(),t.data.hl2.data.pop(),t.data.hlc3.data.pop(),t.data.ohlc4.data.pop(),t.data.hlcc4.data.pop(),t.data.openTime.data.pop(),t.data.closeTime&&t.data.closeTime.data.pop()}_initializeContext(t,n=!1){const r=new bt({marketData:this.data,source:this.source,tickerId:this.tickerId,timeframe:this.timeframe,limit:this.limit,sDate:this.sDate,eDate:this.eDate});return r.pine.syminfo=this._syminfo,r.pineTSCode=t,r.isSecondaryContext=n,r.data.close=new m([]),r.data.open=new m([]),r.data.high=new m([]),r.data.low=new m([]),r.data.volume=new m([]),r.data.hl2=new m([]),r.data.hlc3=new m([]),r.data.ohlc4=new m([]),r.data.hlcc4=new m([]),r.data.openTime=new m([]),r.data.closeTime=new m([]),r}_transpileCode(t){return oe.bind(this)(t,this._debugSettings)}async _executeIterations(t,n,r,i){const s=["const","var","let","params"];for(let a=r;a<i;a++){t.idx=a,t.data.close.data.push(this.close[a]),t.data.open.data.push(this.open[a]),t.data.high.data.push(this.high[a]),t.data.low.data.push(this.low[a]),t.data.volume.data.push(this.volume[a]),t.data.hl2.data.push(this.hl2[a]),t.data.hlc3.data.push(this.hlc3[a]),t.data.ohlc4.data.push(this.ohlc4[a]),t.data.hlcc4.data.push(this.hlcc4[a]),t.data.openTime.data.push(this.openTime[a]),t.data.closeTime.data.push(this.closeTime[a]);const o=await n(t);if(typeof o=="object"){typeof t.result!="object"&&(t.result={});for(let c in o){t.result[c]===void 0&&(t.result[c]=[]);let l;o[c]instanceof m?l=o[c].get(0):Array.isArray(o[c])?l=o[c][o[c].length-1]:l=o[c],t.result[c].push(l)}}else Array.isArray(t.result)||(t.result=[]),t.result.push(o);for(let c of s)for(let l in t[c]){const u=t[c][l];if(u instanceof m){const p=u.get(0);u.data.push(p)}else if(Array.isArray(u)){const p=u[u.length-1];u.push(p)}}}}}var hs=Object.defineProperty,ps=(e,t,n)=>t in e?hs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,gt=(e,t,n)=>ps(e,typeof t!="symbol"?t+"":t,n);const vt="https://api.binance.com/api/v3",pt={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",45:null,60:"1h",120:"2h",180:null,240:"4h","4H":"4h","1D":"1d",D:"1d","1W":"1w",W:"1w","1M":"1M",M:"1M"};class ms{constructor(t=5*60*1e3){gt(this,"cache"),gt(this,"cacheDuration"),this.cache=new Map,this.cacheDuration=t}generateKey(t){return Object.entries(t).filter(([n,r])=>r!==void 0).map(([n,r])=>`${n}:${r}`).join("|")}get(t){const n=this.generateKey(t),r=this.cache.get(n);return r?Date.now()-r.timestamp>this.cacheDuration?(this.cache.delete(n),null):r.data:null}set(t,n){const r=this.generateKey(t);this.cache.set(r,{data:n,timestamp:Date.now()})}clear(){this.cache.clear()}cleanup(){const t=Date.now();for(const[n,r]of this.cache.entries())t-r.timestamp>this.cacheDuration&&this.cache.delete(n)}}class fs{constructor(){gt(this,"cacheManager"),this.cacheManager=new ms(5*60*1e3)}async getMarketDataInterval(t,n,r,i){try{const s=pt[n.toUpperCase()];if(!s)return console.error(`Unsupported timeframe: ${n}`),[];const a={"1m":60*1e3,"3m":3*60*1e3,"5m":5*60*1e3,"15m":15*60*1e3,"30m":30*60*1e3,"1h":60*60*1e3,"2h":2*60*60*1e3,"4h":4*60*60*1e3,"1d":24*60*60*1e3,"1w":7*24*60*60*1e3,"1M":30*24*60*60*1e3};let o=[],c=r;const l=i,u=a[s];if(!u)return console.error(`Duration not defined for interval: ${s}`),[];for(;c<l;){const p=Math.min(c+1e3*u,l),f=await this.getMarketData(t,n,1e3,c,p);if(f.length===0)break;o=o.concat(f),c=f[f.length-1].closeTime+1}return o}catch(s){return console.error("Error in getMarketDataInterval:",s),[]}}async getMarketData(t,n,r,i,s){try{const a=s!==void 0,o={tickerId:t,timeframe:n,limit:r,sDate:i,eDate:s};if(a){const f=this.cacheManager.get(o);if(f)return f}const c=pt[n.toUpperCase()];if(!c)return console.error(`Unsupported timeframe: ${n}`),[];if(this.shouldPaginate(n,r,i,s)&&i&&s){const f=await this.getMarketDataInterval(t,n,i,s),h=r?f.slice(0,r):f;return this.cacheManager.set(o,h),h}let l=`${vt}/klines?symbol=${t}&interval=${c}`;r&&(l+=`&limit=${Math.min(r,1e3)}`),i&&(l+=`&startTime=${i}`),s&&(l+=`&endTime=${s}`);const u=await fetch(l);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);const p=(await u.json()).map(f=>({openTime:parseInt(f[0]),open:parseFloat(f[1]),high:parseFloat(f[2]),low:parseFloat(f[3]),close:parseFloat(f[4]),volume:parseFloat(f[5]),closeTime:parseInt(f[6]),quoteAssetVolume:parseFloat(f[7]),numberOfTrades:parseInt(f[8]),takerBuyBaseAssetVolume:parseFloat(f[9]),takerBuyQuoteAssetVolume:parseFloat(f[10]),ignore:f[11]}));return a&&this.cacheManager.set(o,p),p}catch(a){return console.error("Error in binance.klines:",a),[]}}shouldPaginate(t,n,r,i){if(n&&n>1e3)return!0;if(r&&i){const s=pt[t.toUpperCase()],a={"1m":60*1e3,"3m":3*60*1e3,"5m":5*60*1e3,"15m":15*60*1e3,"30m":30*60*1e3,"1h":60*60*1e3,"2h":2*60*60*1e3,"4h":4*60*60*1e3,"1d":24*60*60*1e3,"1w":7*24*60*60*1e3,"1M":30*24*60*60*1e3}[s];if(a)return Math.ceil((i-r)/a)>1e3}return!1}async getSymbolInfo(t){try{let n="crypto",r=vt,i=t,s="";t.endsWith(".P")?(n="futures",i=t.replace(".P",""),r="https://fapi.binance.com/fapi/v1",s="Perpetual"):t.includes("_")&&(n="futures",i=t,r="https://dapi.binance.com/dapi/v1",s="Delivery");const a=n==="crypto"?`${r}/exchangeInfo?symbol=${i}`:`${r}/exchangeInfo`,o=await fetch(a);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);const c=(await o.json()).symbols;if(!c||c.length===0)return console.error(`Symbol ${t} not found`),null;const l=n==="futures"?c.find(b=>b.symbol===i):c[0];if(!l)return console.error(`Symbol ${i} not found in exchange info`),null;const u=l.filters?.find(b=>b.filterType==="PRICE_FILTER"),p=l.filters?.find(b=>b.filterType==="LOT_SIZE"),f=u?parseFloat(u.tickSize):.01,h=p?parseFloat(p.minQty):0,d=Math.round(1/f),g=l.baseAsset,y=l.quoteAsset,w=s?` ${s}`:"",S=`${g} / ${y}${w}`;return{ticker:t,tickerid:`BINANCE:${t}`,prefix:"BINANCE",root:g,description:S,type:n,main_tickerid:`BINANCE:${t}`,current_contract:s,isin:"",basecurrency:g,currency:y,timezone:"Etc/UTC",country:"",mintick:f,pricescale:d,minmove:1,pointvalue:l.contractSize||1,mincontract:h,session:"24x7",volumetype:"base",expiration_date:l.deliveryDate||0,employees:0,industry:"",sector:"",shareholders:0,shares_outstanding_float:0,shares_outstanding_total:0,recommendations_buy:0,recommendations_buy_strong:0,recommendations_date:0,recommendations_hold:0,recommendations_sell:0,recommendations_sell_strong:0,recommendations_total:0,target_price_average:0,target_price_date:0,target_price_estimates:0,target_price_high:0,target_price_low:0,target_price_median:0}}catch(n){return console.error("Error in binance.exchangeInfo:",n),null}}}var ds=Object.defineProperty,gs=(e,t,n)=>t in e?ds(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mt=(e,t,n)=>gs(e,typeof t!="symbol"?t+"":t,n);const ys=Bt(import.meta.url),_s=nt.dirname(ys);class xs{constructor(t){if(mt(this,"dataCache",new Map),mt(this,"exchangeInfoCache",{}),mt(this,"dataDirectory"),t)this.dataDirectory=t;else{const n=nt.resolve(_s,"../../../");this.dataDirectory=nt.join(n,"tests","compatibility","_data")}}getDataFileName(t,n,r,i){return r&&i?`${t}-${n}-${r}-${i}.json`:null}loadDataFromFile(t){const n=`file:${t}`;if(this.dataCache.has(n))return this.dataCache.get(n);const r=nt.join(this.dataDirectory,t);if(!Z.existsSync(r))throw new Error(`Mock data file not found: ${r}`);const i=Z.readFileSync(r,"utf-8"),s=JSON.parse(i);return this.dataCache.set(n,s),s}findDataFile(t,n,r,i){if(!Z.existsSync(this.dataDirectory))return null;const s=Z.readdirSync(this.dataDirectory).filter(c=>c.endsWith(".json"));if(r&&i){const c=`${t}-${n}-${r}-${i}.json`;if(s.includes(c))return c}const a=new RegExp(`^${t}-${n}-(\\d+)-(\\d+)\\.json$`),o=s.filter(c=>a.test(c)).map(c=>{const l=c.match(a);return{file:c,startTime:parseInt(l[1]),endTime:parseInt(l[2])}}).sort((c,l)=>l.endTime-c.endTime);if(o.length===0)return null;if(r&&i){const c=o.find(l=>l.startTime<=r&&l.endTime>=i);if(c)return c.file}return o[0].file}filterData(t,n,r,i){let s=t;return(n||r)&&(s=t.filter(a=>{const o=!n||a.openTime>=n,c=!r||a.openTime<=r;return o&&c})),s.sort((a,o)=>a.openTime-o.openTime),i&&i>0&&(s=s.slice(0,i)),s}normalizeTimeframe(t){return{1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h","4H":"4h","1D":"1d",D:"1d","1W":"1w",W:"1w","1M":"1M",M:"1M"}[t.toUpperCase()]||t.toLowerCase()}async getMarketData(t,n,r,i,s){try{const a=this.normalizeTimeframe(n),o=this.findDataFile(t,a,i,s);if(!o)return console.warn(`No mock data file found for ${t} ${a}. Searched in: ${this.dataDirectory}`),[];const c=this.loadDataFromFile(o);return this.filterData(c,i,s,r)}catch(a){return console.error("Error in MockProvider.getMarketData:",a),[]}}loadExchangeInfo(t){if(this.exchangeInfoCache[t])return this.exchangeInfoCache[t];const n=t==="spot"?"api-exchangeInfo.json":"fapi-exchangeInfo.json",r=nt.join(this.dataDirectory,n);if(!Z.existsSync(r))return console.warn(`Exchange info file not found: ${r}`),null;try{const i=Z.readFileSync(r,"utf-8"),s=JSON.parse(i);return this.exchangeInfoCache[t]=s,s}catch(i){return console.error(`Error loading exchange info from ${n}:`,i),null}}async getSymbolInfo(t){try{let n="crypto",r=t,i="";t.endsWith(".P")?(n="futures",r=t.replace(".P",""),i="Perpetual"):t.includes("_")&&(n="futures",r=t,i="Delivery");const s=this.loadExchangeInfo(n==="futures"?"futures":"spot");if(!s||!s.symbols)return console.error(`Exchange info not available for ${n}`),null;const a=s.symbols.find(y=>y.symbol===r);if(!a)return console.error(`Symbol ${r} not found in ${n} exchange info`),null;const o=a.filters?.find(y=>y.filterType==="PRICE_FILTER"),c=a.filters?.find(y=>y.filterType==="LOT_SIZE"),l=o?parseFloat(o.tickSize):.01,u=c?parseFloat(c.minQty):0,p=Math.round(1/l),f=a.baseAsset,h=a.quoteAsset,d=i?` ${i}`:"",g=`${f} / ${h}${d}`;return{ticker:t,tickerid:`BINANCE:${t}`,prefix:"BINANCE",root:f,description:g,type:n,main_tickerid:`BINANCE:${t}`,current_contract:i,isin:"",basecurrency:f,currency:h,timezone:"Etc/UTC",country:"",mintick:l,pricescale:p,minmove:1,pointvalue:a.contractSize||1,mincontract:u,session:"24x7",volumetype:"base",expiration_date:a.deliveryDate||0,employees:0,industry:"",sector:"",shareholders:0,shares_outstanding_float:0,shares_outstanding_total:0,recommendations_buy:0,recommendations_buy_strong:0,recommendations_date:0,recommendations_hold:0,recommendations_sell:0,recommendations_sell_strong:0,recommendations_total:0,target_price_average:0,target_price_date:0,target_price_estimates:0,target_price_high:0,target_price_low:0,target_price_median:0}}catch(n){return console.error("Error in MockProvider.getSymbolInfo:",n),null}}clearCache(){this.dataCache.clear(),this.exchangeInfoCache={}}setDataDirectory(t){this.dataDirectory=t,this.clearCache()}}const Ns=typeof process<"u"&&process.versions&&process.versions.node;let ct=null;if(Ns)try{ct=new xs}catch{ct=null}const bs={Binance:new fs,...ct?{Mock:ct}:{}};export{bt as Context,Pt as PineTS,bs as Provider};
|
|
33
|
+
}`}function ks(e){H(e,null,{VariableDeclaration(t,i,r){t.declarations&&t.declarations.length>0&&t.declarations.forEach(s=>{if(s.init&&s.init.type==="ArrowFunctionExpression"&&s.init.start!==0){const n={type:"FunctionDeclaration",id:s.id,params:s.init.params,body:s.init.body.type==="BlockStatement"?s.init.body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:s.init.body}]},async:s.init.async,generator:!1};Object.assign(t,n)}}),t.body&&t.body.body&&t.body.body.forEach(s=>r(s,i))}})}function Is(e,t){Gt(e,{VariableDeclaration(i){i.declarations.forEach(r=>{const s=r.init&&r.init.type==="MemberExpression"&&r.init.object&&(r.init.object.name==="context"||r.init.object.name===q||r.init.object.name==="context2"),n=r.init&&r.init.type==="MemberExpression"&&r.init.object?.object&&(r.init.object.object.name==="context"||r.init.object.object.name===q||r.init.object.object.name==="context2");(s||n)&&(r.id.name&&t.addContextBoundVar(r.id.name),r.id.properties&&r.id.properties.forEach(a=>{a.key.name&&t.addContextBoundVar(a.key.name)}))})}})}function As(e,t,i=!1){e.params.forEach(r=>{r.type==="Identifier"&&t.addContextBoundVar(r.name,i)})}function Ts(e,t){e.params.forEach(i=>{i.type==="Identifier"&&t.addContextBoundVar(i.name,!1)})}function Ps(e,t){let i;return Gt(e,{FunctionDeclaration(r){Ts(r,t)},ArrowFunctionExpression(r){const s=r.start===0;s&&r.params&&r.params.length>0&&(i=r.params[0].name,r.params[0].name=q),As(r,t,s)},VariableDeclaration(r){r.declarations.forEach(s=>{if(s.id.type==="ArrayPattern"){const n=t.generateTempVar(),a={type:"VariableDeclaration",kind:r.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:n},init:s.init}]};s.id.elements?.forEach(h=>{h.type==="Identifier"&&t.addArrayPatternElement(h.name)});const o=s.id.elements.map((h,c)=>({type:"VariableDeclaration",kind:r.kind,declarations:[{type:"VariableDeclarator",id:h,init:{type:"MemberExpression",object:{type:"Identifier",name:n},property:{type:"Literal",value:c},computed:!0}}]}));Object.assign(r,{type:"BlockStatement",body:[a,...o]})}})},ForStatement(r){}}),i}const Dt={type:"Identifier",name:"undefined"};function Ae(e,t){if(e.computed&&e.property.type==="Identifier"){if(t.isLoopVariable(e.property.name)){if(e.object.type==="Identifier"&&!t.isLoopVariable(e.object.name)&&!t.isContextBound(e.object.name)){const[i,r]=t.getVariable(e.object.name),s=v.createContextVariableReference(r,i),n=v.createGetCall(s,e.property);Object.assign(e,n),e._indexTransformed=!0}return}if(!t.isContextBound(e.property.name)){const[i,r]=t.getVariable(e.property.name);e.property=v.createContextVariableReference(r,i),e.property=v.createGetCall(e.property,0)}}if(e.computed&&e.object.type==="Identifier"){if(t.isLoopVariable(e.object.name))return;if(!t.isContextBound(e.object.name)){const[i,r]=t.getVariable(e.object.name);e.object=v.createContextVariableReference(r,i)}if(e.property.type==="MemberExpression"){const i=e.property;i._indexTransformed||(Ae(i,t),i._indexTransformed=!0)}}}function ve(e,t){const i=v.createGetCall(v.createIdentifier(e.name),0);e.start!==void 0&&(i.start=e.start),e.end!==void 0&&(i.end=e.end),i._indexTransformed=!0,Object.assign(e,i)}function ie(e,t){if(e.name!==q){if(e.name==="na"&&!(e.parent&&e.parent.type==="CallExpression"&&e.parent.callee===e)){e.name="NaN";return}if(e.name==="Math"||e.name==="NaN"||e.name==="undefined"||e.name==="Infinity"||e.name==="null"||e.name.startsWith("'")&&e.name.endsWith("'")||e.name.startsWith('"')&&e.name.endsWith('"')||e.name.startsWith("`")&&e.name.endsWith("`")||t.isLoopVariable(e.name))return;let i=!1;if(e.parent&&e.parent.type==="CallExpression"&&e.parent.arguments.includes(e)){const g=e.parent.callee;if(g.type==="MemberExpression"&&g.object&&g.object.name===q&&["get","set","init","param"].includes(g.property.name))e.parent.arguments.indexOf(e)===0&&(i=!0);else{const p=g.type==="MemberExpression"&&g.object&&g.object.type==="Identifier"&&st.includes(g.object.name);g.type==="MemberExpression"&&!p?i=!1:i=!0}}const r=e.parent&&e.parent.type==="MemberExpression"&&e.parent.object===e&&t.isContextBound(e.name),s=e.parent&&e.parent.type==="CallExpression"&&e.parent.callee&&e.parent.callee.type==="MemberExpression"&&e.parent.callee.property.name==="param";e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left;const n=e.parent&&e.parent.type==="CallExpression"&&e.parent.callee===e,a=e.parent&&e.parent.type==="MemberExpression"&&e.parent.computed&&e.parent.object===e,o=e.parent&&e.parent.type==="MemberExpression"&&e.parent.computed&&e.parent.property===e&&e.parent.parent&&e.parent.parent.type==="CallExpression"&&e.parent.parent.callee&&e.parent.parent.callee.type==="MemberExpression"&&t.isContextBound(e.parent.parent.callee.object.name);if(r||s||i||o||n){if(n||t.isLocalSeriesVar(e.name)||t.isContextBound(e.name)&&!t.isRootParam(e.name))return;const[g,p]=t.getVariable(e.name),x=v.createContextVariableReference(p,g);Object.assign(e,x);return}const h=t.isContextBound(e.name)&&!t.isRootParam(e.name);if(h&&!(e.parent&&e.parent.type==="CallExpression"&&e.parent.arguments.includes(e)))return;if(t.isLocalSeriesVar(e.name)){if(!a){const g=v.createIdentifier(e.name),p=v.createGetCall(g,0);Object.assign(e,p)}return}const[c,l]=t.getVariable(e.name);let f;if(h)f=v.createIdentifier(e.name);else{if(c===e.name&&!t.isContextBound(e.name))return;f=v.createContextVariableReference(l,c)}if(a)Object.assign(e,f);else{const g=v.createGetCall(f,0);Object.assign(e,g)}}}function ue(e,t,i){if(e.object&&e.object.type==="Identifier"&&e.object.name==="Math")return;if(e.object&&e.object.type==="Identifier"&&st.includes(e.object.name)&&i.isContextBound(e.object.name)&&!e.computed){const h=e.parent&&e.parent.type==="CallExpression"&&e.parent.callee===e,c=e.parent&&(e.parent.type==="VariableDeclarator"||e.parent.type==="Property"||e.parent.type==="AssignmentExpression");if(!h&&!c){const l={type:"CallExpression",callee:{type:"MemberExpression",object:e.object,property:e.property,computed:!1},arguments:[],_transformed:!1};e.start!==void 0&&(l.start=e.start),e.end!==void 0&&(l.end=e.end),Object.assign(e,l);return}}const r=i.getCurrentScopeType()=="if",s=i.getCurrentScopeType()=="els",n=i.getCurrentScopeType()=="for";if(!r&&!s&&!n&&e.object&&e.object.type==="Identifier"&&i.isContextBound(e.object.name)&&!i.isRootParam(e.object.name)&&!e.computed)return;e._indexTransformed||(Ae(e,i),e._indexTransformed=!0);const a=e.object&&e.object.type==="MemberExpression"&&e.object.object&&e.object.object.type==="MemberExpression"&&e.object.object.object&&e.object.object.object.name===q,o=e.object&&e.object.type==="Identifier"&&i.isContextBound(e.object.name);if(e.computed&&(a||o)){if(e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e)return;const h=v.createGetCall(e.object,e.property);e.start&&(h.start=e.start),e.end&&(h.end=e.end),Object.assign(e,h),delete e.object,delete e.property,delete e.computed}}function Je(e,t){if(e.type==="Identifier"){if(e.name==="na")return e.name="NaN",e;if(t.isLoopVariable(e.name))return e;if(t.isRootParam(e.name)){const[s,n]=t.getVariable(e.name);return v.createContextVariableReference(n,s)}if(t.isContextBound(e.name)||t.isLocalSeriesVar(e.name))return e;const[i,r]=t.getVariable(e.name);return i===e.name&&!t.isContextBound(e.name)?e:v.createContextVariableReference(r,i)}return e}function Ie(e,t,i=""){switch(e.type){case"BinaryExpression":return Mt(e,t,i);case"MemberExpression":return{type:"MemberExpression",object:e.object.type==="Identifier"?Je(e.object,t):e.object,property:e.property,computed:e.computed};case"Identifier":{if(t.isLoopVariable(e.name)||e.parent&&e.parent.type==="MemberExpression"&&e.parent.property===e)return e;const r=Je(e,t);return r.type==="Identifier"&&(r.name==="NaN"||r.name==="undefined"||r.name==="Infinity"||r.name==="null"||r.name==="Math")?r:v.createGetCall(r,0)}case"UnaryExpression":return Ot(e,t,i);case"ConditionalExpression":{const r=Ie(e.test,t,i),s=Ie(e.consequent,t,i),n=Ie(e.alternate,t,i);return{type:"ConditionalExpression",test:r,consequent:s,alternate:n,start:e.start,end:e.end}}}return e}function Mt(e,t,i){const r=Ie(e.left,t,i),s=Ie(e.right,t,i),n={type:"BinaryExpression",operator:e.operator,left:r,right:s,start:e.start,end:e.end};return H(n,t,{CallExpression(a,o){a._transformed||le(a,o)},MemberExpression(a){ue(a,"",t)}}),n}function ci(e,t,i){const r=Ie(e.left,t,i),s=Ie(e.right,t,i),n={type:"LogicalExpression",operator:e.operator,left:r,right:s,start:e.start,end:e.end};return H(n,t,{CallExpression(a,o){a._transformed||le(a,o)}}),n}function ui(e,t,i){H(e,{parent:e,inNamespaceCall:!1},{Identifier(a,o,h){if(a.name=="NaN")return;if(a.name=="na"){a.name="NaN";return}a.parent=o.parent,ie(a,t);const c=a.parent&&a.parent.type==="BinaryExpression";(a.parent&&a.parent.type==="ConditionalExpression"||c)&&(a.type==="MemberExpression"?Ae(a,t):a.type==="Identifier"&&(a.parent&&a.parent.type==="CallExpression"&&a.parent.callee&&a.parent.callee.object&&a.parent.callee.object.name===q&&a.parent.callee.property.name==="get"||ve(a)))},MemberExpression(a,o,h){Ae(a,t),a.object&&h(a.object,{parent:a,inNamespaceCall:o.inNamespaceCall})},ConditionalExpression(a,o,h){const c={...o,parent:a};a.test&&h(a.test,c),a.consequent&&h(a.consequent,c),a.alternate&&h(a.alternate,c)},BinaryExpression(a,o,h){const c={...o,parent:a};h(a.left,c),h(a.right,c)},LogicalExpression(a,o,h){const c={...o,parent:a};h(a.left,c),h(a.right,c)},UnaryExpression(a,o,h){const c={...o,parent:a};h(a.argument,c)},CallExpression(a,o,h){const c=a.callee&&a.callee.type==="MemberExpression"&&a.callee.object&&a.callee.object.type==="Identifier"&&t.isContextBound(a.callee.object.name);le(a,t),a.arguments.forEach(l=>h(l,{parent:a,inNamespaceCall:c||o.inNamespaceCall}))}});const r=v.createMemberExpression(v.createIdentifier(i),v.createIdentifier("param")),s=t.generateParamId(),n={type:"CallExpression",callee:r,arguments:[e,Dt,{type:"Identifier",name:`'${s}'`}],_transformed:!0,_isParamCall:!0};if(!t.shouldSuppressHoisting()){const a=s;t.addLocalSeriesVar(a);const o=v.createVariableDeclaration(a,n);return t.addHoistedStatement(o),v.createIdentifier(a)}return n}function Ot(e,t,i){const r=Ie(e.argument,t,i);return{type:"UnaryExpression",operator:e.operator,prefix:e.prefix,argument:r,start:e.start,end:e.end}}function Vt(e,t,i){switch(e?.type){case"BinaryExpression":e=Mt(e,i,t);break;case"LogicalExpression":e=ci(e,i,t);break;case"ConditionalExpression":return ui(e,i,t);case"UnaryExpression":e=Ot(e,i,t);break;case"ArrayExpression":e.elements=e.elements.map(o=>{if(o.type==="Identifier"){if(i.isContextBound(o.name)&&!i.isRootParam(o.name))return o;const[h,c]=i.getVariable(o.name);return v.createContextVariableAccess0(c,h)}return o});break}if(e.type==="MemberExpression"&&e.computed&&e.property){e.object.type==="CallExpression"?le(e.object,i):e.object.type==="MemberExpression"?ue(e.object,"",i):e.object.type==="BinaryExpression"?e.object=Mt(e.object,i,t):e.object.type==="LogicalExpression"?e.object=ci(e.object,i,t):e.object.type==="ConditionalExpression"?e.object=ui(e.object,i,t):e.object.type==="UnaryExpression"&&(e.object=Ot(e.object,i,t));const o=e.object.type==="Identifier"&&i.isContextBound(e.object.name)&&!i.isRootParam(e.object.name)?e.object:Je(e.object,i),h=e.property.type==="Identifier"&&!i.isContextBound(e.property.name)&&!i.isLoopVariable(e.property.name)?Je(e.property,i):e.property,c=v.createMemberExpression(v.createIdentifier(t),v.createIdentifier("param")),l=i.generateParamId(),f={type:"CallExpression",callee:c,arguments:[o,h,{type:"Identifier",name:`'${l}'`}],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const g=l;i.addLocalSeriesVar(g);const p=v.createVariableDeclaration(g,f);return i.addHoistedStatement(p),v.createIdentifier(g)}return f}if(e.type==="ObjectExpression"&&(e.properties=e.properties.map(o=>{if(o.value.name){if(i.isContextBound(o.value.name)&&!i.isRootParam(o.value.name))return{type:"Property",key:{type:"Identifier",name:o.key.name},value:v.createIdentifier(o.value.name),kind:"init",method:!1,shorthand:!1,computed:!1};const[h,c]=i.getVariable(o.value.name);return{type:"Property",key:{type:"Identifier",name:o.key.name},value:v.createContextVariableReference(c,h),kind:"init",method:!1,shorthand:!1,computed:!1}}else o.value.type!=="Literal"&&(o.value=Vt(o.value,t,i));return o})),e.type==="Identifier"){if(e.name==="na")return e.name="NaN",e;if(i.isContextBound(e.name)&&!i.isRootParam(e.name)){const o=v.createMemberExpression(v.createIdentifier(t),v.createIdentifier("param")),h=i.generateParamId(),c={type:"CallExpression",callee:o,arguments:[e,Dt,{type:"Identifier",name:`'${h}'`}],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const l=h;i.addLocalSeriesVar(l);const f=v.createVariableDeclaration(l,c);return i.addHoistedStatement(f),v.createIdentifier(l)}return c}}e?.type==="CallExpression"&&le(e,i);const r=v.createMemberExpression(v.createIdentifier(t),v.createIdentifier("param")),s=e.type==="Identifier"?Je(e,i):e,n=i.generateParamId(),a={type:"CallExpression",callee:r,arguments:[s,Dt,{type:"Identifier",name:`'${n}'`}],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const o=n;i.addLocalSeriesVar(o);const h=v.createVariableDeclaration(o,a);return i.addHoistedStatement(h),v.createIdentifier(o)}return a}function le(e,t,i){if(e._transformed)return;e.callee&&e.callee.type==="Identifier"&&(st.includes(e.callee.name)||ws.includes(e.callee.name))&&t.isContextBound(e.callee.name)&&(e.callee=v.createMemberExpression(e.callee,v.createIdentifier("any")));const r=e.callee&&e.callee.type==="MemberExpression"&&e.callee.object&&e.callee.object.type==="Identifier"&&(t.isContextBound(e.callee.object.name)||e.callee.object.name==="math"||e.callee.object.name==="ta");if(r){if(e.callee.object.name===q&&["get","init","param"].includes(e.callee.property.name))return;const s=e.callee.object.name,n=[];e.arguments.forEach(l=>{if(l._isParamCall){n.push(l);return}n.push(Vt(l,s,t))}),e.arguments=n,s==="ta"&&e.arguments.push(t.getNextTACallId());const a=e.callee.property.name,o=`${s}.${a}`,h=bs.includes(o),c=e._insideAwait===!0;if(h&&!c){const l=Object.assign({},e),f=v.createAwaitExpression(l);Object.assign(e,f)}if(!t.shouldSuppressHoisting()){const l=t.generateTempVar();t.addLocalSeriesVar(l);const f=e._insideAwait===!0;let g=Object.assign({},e);f&&(g=v.createAwaitExpression(g));const p=v.createVariableDeclaration(l,g);t.addHoistedStatement(p);const x=v.createIdentifier(l);Object.assign(e,x),e._wasHoisted=!0,e._wasInsideAwait=f;return}e._transformed=!0}else e.callee&&e.callee.type==="Identifier"&&(e.arguments=e.arguments.map(s=>s._isParamCall?s:Vt(s,q,t)),e._transformed=!0);!r&&e.callee&&e.callee.type==="MemberExpression"&&e.callee.object.type==="Identifier"&&ie(e.callee.object,t),e.arguments.forEach(s=>{H(s,{parent:e},{Identifier(n,a,o){n.parent=a.parent,ie(n,t);const h=n.parent&&n.parent.type==="BinaryExpression";(n.parent&&n.parent.type==="ConditionalExpression"||h)&&(n.type==="MemberExpression"?Ae(n,t):n.type==="Identifier"&&(n.parent&&n.parent.type==="CallExpression"&&n.parent.callee&&n.parent.callee.object&&n.parent.callee.object.name===q&&n.parent.callee.property.name==="get"||ve(n)))},BinaryExpression(n,a,o){const h={...a,parent:n};o(n.left,h),o(n.right,h)},LogicalExpression(n,a,o){const h={...a,parent:n};o(n.left,h),o(n.right,h)},UnaryExpression(n,a,o){const h={...a,parent:n};o(n.argument,h)},CallExpression(n,a,o){n._transformed||le(n,t)},MemberExpression(n,a,o){ue(n,"",t),n.object&&o(n.object,{parent:n})}})})}function lr(e,t){let i=null;if(e.left.type==="Identifier"){const[r,s]=t.getVariable(e.left.name);i=v.createContextVariableReference(s,r)}else if(e.left.type==="MemberExpression"&&e.left.computed&&e.left.object.type==="Identifier"){const r=e.left.object.name,[s,n]=t.getVariable(r),a=s!==r,o=t.isContextBound(r);(a||o)&&!t.isLoopVariable(r)&&e.left.property.type==="Literal"&&e.left.property.value===0&&(i=v.createContextVariableReference(n,s))}if(H(e.right,{parent:e.right,inNamespaceCall:!1},{Identifier(r,s,n){r.name=="na"&&(r.name="NaN"),r.parent=s.parent,ie(r,t);const a=r.parent&&r.parent.type==="BinaryExpression",o=r.parent&&r.parent.type==="ConditionalExpression",h=t.isContextBound(r.name)&&!t.isRootParam(r.name),c=r.parent&&r.parent.type==="MemberExpression"&&r.parent.computed&&r.parent.object===r,l=r.parent&&r.parent._isParamCall,f=r.parent&&r.parent.type==="MemberExpression",g=r.name==="NaN",p=r.parent&&r.parent.type==="CallExpression"&&r.parent.callee&&r.parent.callee.object&&r.parent.callee.object.name===q&&r.parent.callee.property.name==="get";(h||o||a)&&(r.type==="MemberExpression"?Ae(r,t):r.type==="Identifier"&&!f&&!c&&!l&&!g&&!p&&ve(r))},MemberExpression(r,s,n){ue(r,"",t),r.type==="CallExpression"?r.arguments.forEach(a=>n(a,{parent:r,inNamespaceCall:s.inNamespaceCall})):r.object&&n(r.object,{parent:r,inNamespaceCall:s.inNamespaceCall})},CallExpression(r,s,n){const a=r.callee&&r.callee.type==="MemberExpression"&&r.callee.object&&r.callee.object.type==="Identifier"&&t.isContextBound(r.callee.object.name);le(r,t),r.type==="CallExpression"&&r.arguments.forEach(o=>n(o,{parent:r,inNamespaceCall:a||s.inNamespaceCall}))}}),i){let r=e.right;if(e.operator!=="="){const n=e.operator.replace("=",""),a=v.createGetCall(i,0);r={type:"BinaryExpression",operator:n,left:a,right:e.right,start:e.start,end:e.end}}const s=v.createSetCall(i,r);e.start&&(s.start=e.start),e.end&&(s.end=e.end),Object.assign(e,s)}}function pr(e,t){e.declarations.forEach(i=>{i.init.name=="na"&&(i.init.name="NaN");const r=i.init&&i.init.type==="MemberExpression"&&i.init.object&&(i.init.object.name==="context"||i.init.object.name===q||i.init.object.name==="context2"),s=i.init&&i.init.type==="MemberExpression"&&i.init.object?.object&&(i.init.object.object.name==="context"||i.init.object.object.name===q||i.init.object.object.name==="context2"),n=i.init&&i.init.type==="ArrowFunctionExpression";if(r){i.id.name&&t.addContextBoundVar(i.id.name),i.id.properties&&i.id.properties.forEach(p=>{p.key.name&&t.addContextBoundVar(p.key.name)}),i.init.object.name=q;return}if(s){i.id.name&&t.addContextBoundVar(i.id.name),i.id.properties&&i.id.properties.forEach(p=>{p.key.name&&t.addContextBoundVar(p.key.name)}),i.init.object.object.name=q;return}n&&i.init.params.forEach(p=>{p.type==="Identifier"&&t.addContextBoundVar(p.name)});const a=t.addVariable(i.id.name,e.kind),o=e.kind,h=t.isArrayPatternElement(i.id.name);i.init&&!n&&!h&&(i.init.type==="CallExpression"&&i.init.callee.type==="MemberExpression"&&i.init.callee.object&&i.init.callee.object.type==="Identifier"&&t.isContextBound(i.init.callee.object.name)?le(i.init,t):H(i.init,{parent:i.init},{Identifier(p,x){p.parent=x.parent,ie(p,t);const y=p.parent&&p.parent.type==="BinaryExpression",w=p.parent&&p.parent.type==="UnaryExpression",E=p.parent&&p.parent.type==="ConditionalExpression",A=p.parent&&p.parent.type==="CallExpression"&&p.parent.callee&&p.parent.callee.object&&p.parent.callee.object.name===q&&p.parent.callee.property.name==="get";p.type==="Identifier"&&(y||w||E)&&!A&&ve(p)},CallExpression(p,x,y){p.callee.type==="Identifier"&&(p.callee.parent=p),p.arguments.forEach(w=>{w.type==="Identifier"&&(w.parent=p)}),le(p,t),p.type==="CallExpression"&&p.arguments.forEach(w=>y(w,{parent:p}))},BinaryExpression(p,x,y){p.left.type==="Identifier"&&(p.left.parent=p),p.right.type==="Identifier"&&(p.right.parent=p),y(p.left,{parent:p}),y(p.right,{parent:p})},MemberExpression(p,x,y){p.object&&p.object.type==="Identifier"&&(p.object.parent=p),p.property&&p.property.type==="Identifier"&&(p.property.parent=p),ue(p,"",t),p.type==="CallExpression"?p.arguments.forEach(w=>y(w,{parent:p})):p.object&&y(p.object,{parent:p})},AwaitExpression(p,x,y){p.argument&&(p.argument._insideAwait=!0,y(p.argument,{parent:p}),p.argument.type==="Identifier"&&p.argument._wasInsideAwait&&Object.assign(p,p.argument))}}));const c=v.createContextVariableReference(o,a),l=!h&&i.init&&i.init.type==="MemberExpression"&&i.init.computed&&i.init.property&&(i.init.property.type==="Literal"||i.init.property.type==="MemberExpression");i.init?.property?.type==="MemberExpression"&&(i.init.property._indexTransformed||(Ae(i.init.property,t),i.init.property._indexTransformed=!0));let f;i.init?n||h?f=i.init:o==="var"?f=v.createInitVarCall(c,i.init):f=v.createInitCall(c,l?i.init.object:i.init,l?i.init.property:void 0):f=v.createIdentifier("undefined");const g=v.createExpressionStatement(v.createAssignmentExpression(c,f));if(h){const p=i.init.object.name,[x,y]=t.getVariable(p),w=v.createContextVariableReference(y,x),E=i.init.property.value,A={type:"MemberExpression",object:v.createGetCall(w,0),property:{type:"Literal",value:E},computed:!0};g.expression.right=v.createCallExpression(v.createMemberExpression(v.createContextIdentifier(),v.createIdentifier("init")),[c,A])}n&&(t.pushScope("fn"),H(i.init.body,t,{BlockStatement(p,x,y){p.body.forEach(w=>y(w,x))},IfStatement(p,x,y){x.pushScope("if"),y(p.consequent,x),p.alternate&&(x.pushScope("els"),y(p.alternate,x),x.popScope()),x.popScope()},VariableDeclaration(p,x){pr(p,x)},Identifier(p,x){ie(p,x)},AssignmentExpression(p,x){lr(p,x)}}),t.popScope()),Object.assign(e,g)})}function Rs(e,t,i){if(t.setSuppressHoisting(!0),e.init&&e.init.type==="VariableDeclaration"){const r=e.init.declarations[0],s=r.id.name;t.addLoopVariable(s,s),e.init={type:"VariableDeclaration",kind:e.init.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:s},init:r.init}]},r.init&&H(r.init,t,{Identifier(n,a){t.isLoopVariable(n.name)||(t.pushScope("for"),ie(n,a),t.popScope())},MemberExpression(n){t.pushScope("for"),ue(n,"",t),t.popScope()}})}e.test&&H(e.test,t,{Identifier(r,s){!t.isLoopVariable(r.name)&&!r.computed&&(t.pushScope("for"),ie(r,s),r.type==="Identifier"&&(r.computed=!0,ve(r)),t.popScope())},MemberExpression(r){t.pushScope("for"),ue(r,"",t),t.popScope()}}),e.update&&H(e.update,t,{Identifier(r,s){t.isLoopVariable(r.name)||(t.pushScope("for"),ie(r,s),t.popScope())}}),t.setSuppressHoisting(!1),t.pushScope("for"),i(e.body,t),t.popScope()}function Ds(e,t){H(e,t,{MemberExpression(i){ue(i,"",t)},CallExpression(i,r){le(i,r)},Identifier(i,r){ie(i,r);const s=t.getCurrentScopeType()==="if";t.isContextBound(i.name)&&!t.isRootParam(i.name)&&s&&ve(i)}})}function Ms(e,t,i){e.test&&(t.pushScope("if"),Ds(e.test,t),t.popScope()),t.pushScope("if"),i(e.consequent,t),t.popScope(),e.alternate&&(t.pushScope("els"),i(e.alternate,t),t.popScope())}function Os(e,t){const i=t.getCurrentScopeType();if(e.argument&&(e.argument.type==="ArrayExpression"?(e.argument.elements=e.argument.elements.map(r=>{if(r.type==="Identifier"){if(t.isContextBound(r.name)&&!t.isRootParam(r.name))return v.createGetCall(r,0);const[s,n]=t.getVariable(r.name);return v.createContextVariableAccess0(n,s)}else if(r.type==="MemberExpression")return r.object&&r.object.type==="MemberExpression"&&r.object.object&&r.object.object.type==="Identifier"&&r.object.object.name==="$"&&r.object.property&&["const","let","var","params"].includes(r.object.property.name)?v.createGetCall(r,0):(r.computed&&r.object.type==="Identifier"&&t.isContextBound(r.object.name)&&!t.isRootParam(r.object.name)||ue(r,"",t),r);return r}),e.argument={type:"ArrayExpression",elements:[e.argument]}):e.argument.type==="BinaryExpression"?H(e.argument,t,{Identifier(r,s){ie(r,s),r.type==="Identifier"&&ve(r)},MemberExpression(r){ue(r,"",t)}}):e.argument.type==="ObjectExpression"?e.argument.properties=e.argument.properties.map(r=>{if(r.shorthand){if(t.isContextBound(r.value.name))return r;const[s,n]=t.getVariable(r.value.name);return{type:"Property",key:v.createIdentifier(r.key.name),value:v.createContextVariableReference(n,s),kind:"init",method:!1,shorthand:!1,computed:!1}}if(r.value&&r.value.type==="Identifier"&&!(t.isContextBound(r.value.name)&&!t.isRootParam(r.value.name))&&!t.isContextBound(r.value.name)){const[s,n]=t.getVariable(r.value.name);r.value=v.createContextVariableReference(n,s)}return r}):e.argument.type==="Identifier"&&(ie(e.argument,t),e.argument.type==="Identifier"&&ve(e.argument)),i==="fn")){e.argument.type==="Identifier"&&t.isContextBound(e.argument.name)&&!t.isRootParam(e.argument.name)?e.argument=v.createArrayAccess(e.argument,0):e.argument.type==="MemberExpression"?e.argument.object.type==="Identifier"&&t.isContextBound(e.argument.object.name)&&!t.isRootParam(e.argument.object.name)&&(e.argument._indexTransformed||(Ae(e.argument,t),e.argument._indexTransformed=!0)):(e.argument.type==="BinaryExpression"||e.argument.type==="LogicalExpression"||e.argument.type==="ConditionalExpression"||e.argument.type==="CallExpression")&&H(e.argument,t,{Identifier(s,n){ie(s,n),s.type==="Identifier"&&!s._arrayAccessed&&(ve(s),s._arrayAccessed=!0)},MemberExpression(s){ue(s,"",t)},CallExpression(s,n){le(s,n)}});const r=v.createCallExpression(v.createMemberExpression(v.createContextIdentifier(),v.createIdentifier("precision")),[e.argument]);e.argument=r}}function Vs(e,t,i){e.body&&e.body.type==="BlockStatement"&&(t.pushScope("fn"),i(e.body,t),t.popScope())}function Ls(e){const t={...b,LineComment:()=>{}};Gt(e,{BinaryExpression(i){if(i.operator==="=="||i.operator==="==="){const r=i.left,s=i.right,n=v.createMathEqCall(r,s);n._transformed=!0,Object.assign(i,n)}}},t)}function Bs(e,t,i,r={debug:!1,ln:!1},s=[]){const n=a=>{if(!r.debug||!a.loc||!s.length)return null;const o=a.loc.start.line-1;if(o>=0&&o<s.length){const h=s[o].trim();if(h)return{type:"LineComment",value:`${r.ln?` [Line ${a.loc.start.line}]`:""} ${h}`}}return null};H(e,t,{Program(a,o,h){const c=[];a.body.forEach(l=>{o.enterHoistingScope(),h(l,o);const f=o.exitHoistingScope(),g=n(l);g&&c.push(g),c.push(...f),c.push(l)}),a.body=c},BlockStatement(a,o,h){const c=[];a.body.forEach(l=>{o.enterHoistingScope(),h(l,o);const f=o.exitHoistingScope(),g=n(l);g&&c.push(g),c.push(...f),c.push(l)}),a.body=c},ReturnStatement(a,o){Os(a,o)},VariableDeclaration(a,o){pr(a,o)},Identifier(a,o){ie(a,o)},CallExpression(a,o){le(a,o)},MemberExpression(a,o){ue(a,i,o)},AssignmentExpression(a,o){lr(a,o)},FunctionDeclaration(a,o,h){Vs(a,o,h)},ForStatement(a,o,h){Rs(a,o,h)},IfStatement(a,o,h){Ms(a,o,h)},AwaitExpression(a,o,h){a.argument&&(a.argument._insideAwait=!0,h(a.argument,o),a.argument.type==="Identifier"&&a.argument._wasInsideAwait===!0&&(a.type="Identifier",a.name=a.argument.name,a.argument._wasHoisted&&(a._wasHoisted=a.argument._wasHoisted),delete a.argument))}})}const m={NUMBER:"NUMBER",STRING:"STRING",BOOLEAN:"BOOLEAN",IDENTIFIER:"IDENTIFIER",KEYWORD:"KEYWORD",OPERATOR:"OPERATOR",LPAREN:"LPAREN",RPAREN:"RPAREN",LBRACKET:"LBRACKET",RBRACKET:"RBRACKET",LBRACE:"LBRACE",RBRACE:"RBRACE",COMMA:"COMMA",DOT:"DOT",COLON:"COLON",SEMICOLON:"SEMICOLON",INDENT:"INDENT",DEDENT:"DEDENT",NEWLINE:"NEWLINE",COMMENT:"COMMENT",EOF:"EOF"},Fs=new Set(["if","else","for","while","switch","break","continue","var","varip","type","and","or","not","to","by","in","import","export","method","extends"]),js=["==","!=","<=",">=",":=","+=","-=","*=","/=","%=","=>","//","and","or","not"];class $s{constructor(t,i,r,s,n=0){this.type=t,this.value=i,this.line=r,this.column=s,this.indent=n}toString(){return`Token(${this.type}, ${JSON.stringify(this.value)}, ${this.line}:${this.column}, indent=${this.indent})`}}var Ws=Object.defineProperty,qs=(e,t,i)=>t in e?Ws(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,ye=(e,t,i)=>qs(e,typeof t!="symbol"?t+"":t,i);class Us{constructor(t){ye(this,"source"),ye(this,"pos"),ye(this,"line"),ye(this,"column"),ye(this,"tokens"),ye(this,"indentStack"),ye(this,"atLineStart"),ye(this,"parenDepth"),ye(this,"bracketDepth"),ye(this,"braceDepth"),this.source=t,this.pos=0,this.line=1,this.column=1,this.tokens=[],this.indentStack=[0],this.atLineStart=!0,this.parenDepth=0,this.bracketDepth=0,this.braceDepth=0}tokenize(){for(;this.pos<this.source.length;){const t=this.peek();if(t==="\r"){this.advance();continue}if(t===`
|
|
34
|
+
`){this.handleNewline();continue}if(this.atLineStart&&t!==`
|
|
35
|
+
`){this.handleIndentation(),this.atLineStart=!1;continue}if(t===" "||t===" "){this.advance();continue}if(this.pos>=this.source.length)break;if(t==="/"&&this.peek(1)==="/"){this.readComment();continue}if(t==='"'||t==="'"){this.readString();continue}if(t==="#"){this.readColorLiteral();continue}if(this.isDigit(t)){this.readNumber();continue}if(this.isIdentifierStart(t)){this.readIdentifier();continue}if(!this.readOperatorOrPunctuation())throw new Error(`Unexpected character '${t}' at ${this.line}:${this.column}`)}for(;this.indentStack.length>1;)this.indentStack.pop(),this.addToken(m.DEDENT,"",this.getCurrentIndent());return this.addToken(m.EOF,""),this.tokens}handleNewline(){this.parenDepth===0&&this.bracketDepth===0&&this.braceDepth===0&&(this.addToken(m.NEWLINE,`
|
|
36
|
+
`),this.atLineStart=!0),this.advance(),this.line++,this.column=1}handleIndentation(){let t=0,i=0;for(this.pos;this.pos<this.source.length;){const s=this.peek();if(s===" ")i++,this.advance();else if(s===" ")t++,this.advance();else break}if(this.peek()===`
|
|
37
|
+
`||this.peek()==="\0")return;t+=Math.floor(i/4);const r=this.indentStack[this.indentStack.length-1];if(t>r)this.indentStack.push(t),this.addToken(m.INDENT,"",t);else if(t<r){for(;this.indentStack.length>1&&this.indentStack[this.indentStack.length-1]>t;)this.indentStack.pop(),this.addToken(m.DEDENT,"",this.indentStack[this.indentStack.length-1]);if(this.indentStack[this.indentStack.length-1]!==t)throw new Error(`Indentation error at ${this.line}:${this.column} - misaligned dedent`)}}readComment(){this.column;let t="";for(this.advance(),this.advance();this.pos<this.source.length&&this.peek()!==`
|
|
38
|
+
`;)t+=this.advance();this.addToken(m.COMMENT,t.trim())}readString(){const t=this.advance(),i=this.column-1;let r="";for(;this.pos<this.source.length&&this.peek()!==t;)if(this.peek()==="\\"){this.advance();const s=this.advance();switch(s){case"n":r+=`
|
|
39
|
+
`;break;case"t":r+=" ";break;case"r":r+="\r";break;case"\\":r+="\\";break;case t:r+=t;break;default:r+=s}}else r+=this.advance();if(this.peek()!==t)throw new Error(`Unterminated string at ${this.line}:${i}`);this.advance(),this.addToken(m.STRING,r)}readColorLiteral(){const t=this.column;let i="#";for(this.advance();this.pos<this.source.length&&i.length<9;){const r=this.peek();if(r>="0"&&r<="9"||r>="A"&&r<="F"||r>="a"&&r<="f")i+=this.advance();else break}if(i.length!==7&&i.length!==9)throw new Error(`Invalid color literal '${i}' at ${this.line}:${t}`);this.addToken(m.STRING,i)}readNumber(){this.column;let t="",i=!1;for(;this.pos<this.source.length;){const r=this.peek();if(this.isDigit(r))t+=this.advance();else if(r==="."&&!i){const s=this.peek(1);if(this.isDigit(s)||!this.isIdentifierStart(s)){if(i=!0,t+=this.advance(),!this.isDigit(this.peek()))break}else break}else break}this.addToken(m.NUMBER,parseFloat(t))}readIdentifier(){this.column;let t="";for(;this.pos<this.source.length&&this.isIdentifierChar(this.peek());)t+=this.advance();Fs.has(t)?this.addToken(m.KEYWORD,t):t==="true"||t==="false"?this.addToken(m.BOOLEAN,t==="true"):this.addToken(m.IDENTIFIER,t)}readOperatorOrPunctuation(){const t=this.peek(),i=this.peek(1),r=t+i;if(js.includes(r))return this.advance(),this.advance(),this.addToken(m.OPERATOR,r),!0;if("+-*/%<>=!?".includes(t))return this.advance(),this.addToken(m.OPERATOR,t),!0;switch(t){case"(":return this.parenDepth++,this.advance(),this.addToken(m.LPAREN,t),!0;case")":return this.parenDepth--,this.advance(),this.addToken(m.RPAREN,t),!0;case"[":return this.bracketDepth++,this.advance(),this.addToken(m.LBRACKET,t),!0;case"]":return this.bracketDepth--,this.advance(),this.addToken(m.RBRACKET,t),!0;case"{":return this.braceDepth++,this.advance(),this.addToken(m.LBRACE,t),!0;case"}":return this.braceDepth--,this.advance(),this.addToken(m.RBRACE,t),!0;case",":return this.advance(),this.addToken(m.COMMA,t),!0;case".":return this.advance(),this.addToken(m.DOT,t),!0;case":":return this.advance(),this.addToken(m.COLON,t),!0;case";":return this.advance(),this.addToken(m.SEMICOLON,t),!0}return!1}peek(t=0){const i=this.pos+t;return i<this.source.length?this.source[i]:"\0"}advance(){const t=this.source[this.pos++];return this.column++,t}skipWhitespaceInline(){if(!this.atLineStart)for(;this.pos<this.source.length&&(this.peek()===" "||this.peek()===" ");)this.advance()}isDigit(t){return t>="0"&&t<="9"}isIdentifierStart(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="_"}isIdentifierChar(t){return this.isIdentifierStart(t)||this.isDigit(t)}getCurrentIndent(){return this.indentStack[this.indentStack.length-1]}addToken(t,i,r=null){const s=new $s(t,i,this.line,this.column,r!==null?r:this.getCurrentIndent());this.tokens.push(s)}}var Ks=Object.defineProperty,zs=(e,t,i)=>t in e?Ks(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,se=(e,t,i)=>zs(e,typeof t!="symbol"?t+"":t,i);class B{constructor(t){this.type=t}}class Hs extends B{constructor(t){super("Program"),this.body=t}}class oe extends B{constructor(t){super("ExpressionStatement"),this.expression=t}}var Ve=(e=>(e.VAR="var",e.LET="let",e.CONST="const",e))(Ve||{});class Pe extends B{constructor(t,i="let"){super("VariableDeclaration"),this.declarations=t,this.kind=i}}class Re extends B{constructor(t,i,r=null){super("VariableDeclarator"),this.id=t,this.init=i,this.varType=r}}class li extends B{constructor(t,i,r,s=null){super("FunctionDeclaration"),this.id=t,this.params=i,this.body=r,this.returnType=s}}class Gs extends B{constructor(t,i){super("TypeDefinition"),this.name=t,this.fields=i}}class Ys extends B{constructor(t,i,r=null){super("IfStatement"),this.test=t,this.consequent=i,this.alternate=r,se(this,"_line")}}class pi extends B{constructor(t,i,r,s){super("ForStatement"),this.init=t,this.test=i,this.update=r,this.body=s,se(this,"isForIn")}}class Qs extends B{constructor(t,i){super("WhileStatement"),this.test=t,this.body=i}}class De extends B{constructor(t){super("BlockStatement"),this.body=t}}class fi extends B{constructor(t){super("ReturnStatement"),this.argument=t}}class te extends B{constructor(t){super("Identifier"),this.name=t,se(this,"varType"),se(this,"returnType"),se(this,"isMethod")}}class $e extends B{constructor(t,i=null){super("Literal"),this.value=t,this.raw=i}}class Me extends B{constructor(t,i,r){super("BinaryExpression"),this.operator=t,this.left=i,this.right=r}}class mi extends B{constructor(t,i,r=!0){super("UnaryExpression"),this.operator=t,this.argument=i,this.prefix=r}}class Ct extends B{constructor(t,i,r){super("AssignmentExpression"),this.operator=t,this.left=i,this.right=r}}class Xs extends B{constructor(t,i,r=!1){super("UpdateExpression"),this.operator=t,this.argument=i,this.prefix=r}}class Zs extends B{constructor(t,i){super("CallExpression"),this.callee=t,this.args=i,se(this,"arguments"),this.callee=t,this.arguments=i}}class di extends B{constructor(t,i,r=!1){super("MemberExpression"),this.object=t,this.property=i,this.computed=r}}class Qe extends B{constructor(t,i,r){super("ConditionalExpression"),this.test=t,this.consequent=i,this.alternate=r,se(this,"needsIIFE"),se(this,"consequentStmts"),se(this,"alternateStmts")}}class Js extends B{constructor(t){super("ArrayExpression"),this.elements=t}}class en extends B{constructor(t){super("ObjectExpression"),this.properties=t}}class tn extends B{constructor(t,i){super("Property"),this.key=t,this.value=i,se(this,"kind"),se(this,"method"),se(this,"shorthand"),se(this,"computed"),this.kind="init",this.method=!1,this.shorthand=!1,this.computed=!1}}class gi extends B{constructor(t){super("ArrayPattern"),this.elements=t}}class xi extends B{constructor(t,i){super("AssignmentPattern"),this.left=t,this.right=i}}class rn extends B{constructor(t,i){super("SwitchExpression"),this.discriminant=t,this.cases=i}}class sn extends B{constructor(t,i){super("SwitchCase"),this.test=t,this.consequent=i}}var nn=Object.defineProperty,an=(e,t,i)=>t in e?nn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,yi=(e,t,i)=>an(e,typeof t!="symbol"?t+"":t,i);class on{constructor(t){yi(this,"tokens"),yi(this,"pos"),this.tokens=t,this.pos=0}peek(t=0){return this.tokens[this.pos+t]||this.tokens[this.tokens.length-1]}advance(){return this.tokens[this.pos++]}match(t,i=null){const r=this.peek();return!(r.type!==t||i!==null&&r.value!==i)}expect(t,i=null){const r=this.peek();if(r.type!==t)throw new Error(`Expected ${t} but got ${r.type} at ${r.line}:${r.column}`);if(i!==null&&r.value!==i)throw new Error(`Expected '${i}' but got '${r.value}' at ${r.line}:${r.column}`);return this.advance()}skipNewlines(){for(;this.match(m.NEWLINE);)this.advance()}parse(){const t=[];for(;!this.match(m.EOF)&&(this.skipNewlines(),!this.match(m.EOF));){const i=this.parseStatement();i&&t.push(i),this.skipNewlines()}return new Hs(t)}parseStatement(){this.skipNewlines();const t=this.peek().line;if(this.match(m.COMMENT))return this.advance(),null;let i;if(this.match(m.KEYWORD,"type"))i=this.parseTypeDefinition();else if(this.match(m.KEYWORD,"var")||this.match(m.KEYWORD,"varip"))i=this.parseVarDeclaration();else if(this.match(m.KEYWORD,"method"))i=this.parseMethodDeclaration();else if(this.isFunctionDeclaration())i=this.parseFunctionDeclaration();else if(this.match(m.KEYWORD,"if"))i=this.parseIfStatement();else if(this.match(m.KEYWORD,"for"))i=this.parseForStatement();else if(this.match(m.KEYWORD,"while"))i=this.parseWhileStatement();else if(this.match(m.KEYWORD,"break")||this.match(m.KEYWORD,"continue")){const r=this.advance().value;i=new oe(new te(r))}else if(this.isTupleDestructuring())i=this.parseTupleDestructuring();else if(this.peek().type===m.IDENTIFIER&&this.peek(1).type===m.IDENTIFIER){let r=2;for(;this.peek(r).type===m.IDENTIFIER;)r++;this.peek(r).type===m.OPERATOR&&this.peek(r).value==="="&&(i=this.parseTypedVarDeclaration())}if(!i){const r=this.parseExpression();if(this.match(m.OPERATOR)){const s=this.peek().value;if(["=",":=","+=","-=","*=","/=","%="].includes(s)){this.advance(),this.skipNewlines();const n=this.parseExpression();s==="="&&r.type==="Identifier"?i=new Pe([new Re(r,n)],Ve.LET):i=new oe(new Ct(s===":="?"=":s,r,n))}else i=new oe(r)}else i=new oe(r)}return i&&(i._line=t),i}isFunctionDeclaration(){const t=this.pos;try{let i=0;if(this.peek(i).type===m.IDENTIFIER&&this.peek(i+1).type===m.IDENTIFIER&&i++,this.peek(i).type!==m.IDENTIFIER||(i++,this.peek(i).type!==m.LPAREN))return!1;i++;let r=1;for(;r>0&&this.peek(i).type!==m.EOF;)this.peek(i).type===m.LPAREN&&r++,this.peek(i).type===m.RPAREN&&r--,i++;for(;this.peek(i).type===m.NEWLINE;)i++;return this.peek(i).type===m.OPERATOR&&this.peek(i).value==="=>"}finally{this.pos=t}}parseTypeDefinition(){this.expect(m.KEYWORD,"type");const t=this.expect(m.IDENTIFIER).value;this.match(m.OPERATOR,"=>")&&this.advance(),this.skipNewlines(),this.expect(m.INDENT);const i=[];for(;!this.match(m.DEDENT)&&!this.match(m.EOF)&&(this.skipNewlines(),!this.match(m.DEDENT));){const r=this.expect(m.IDENTIFIER).value,s=this.expect(m.IDENTIFIER).value;let n=null;this.match(m.OPERATOR,"=")&&(this.advance(),this.skipNewlines(),n=this.parseExpression()),i.push({type:r,name:s,defaultValue:n}),this.skipNewlines()}return this.match(m.DEDENT)&&this.advance(),new Gs(t,i)}parseVarDeclaration(){const t=this.advance().value;let i=null,r=null;if(this.peek().type===m.IDENTIFIER&&this.peek(1).type===m.LBRACKET&&this.peek(2).type===m.RBRACKET)i=this.advance().value,this.advance(),i+="[]",this.advance(),r=this.expect(m.IDENTIFIER).value;else if(this.peek().type===m.IDENTIFIER&&(this.peek(1).type===m.IDENTIFIER||this.peek(1).type===m.OPERATOR&&this.peek(1).value==="<")){if(i=this.advance().value,this.match(m.OPERATOR,"<")){for(this.advance(),i+="<";!this.match(m.OPERATOR,">");)if(this.match(m.IDENTIFIER))i+=this.advance().value;else if(this.match(m.COMMA))i+=this.advance().value,this.skipNewlines();else break;this.match(m.OPERATOR,">")&&(i+=">",this.advance())}r=this.expect(m.IDENTIFIER).value}else if(this.peek().type===m.IDENTIFIER)r=this.advance().value;else throw new Error(`Expected identifier after ${t} at ${this.peek().line}:${this.peek().column}`);this.expect(m.OPERATOR,"="),this.skipNewlines();const s=this.parseExpression(),n=new te(r);return i&&(n.varType=i),new Pe([new Re(n,s,i)],t)}parseTypedVarDeclaration(){let t=this.advance().value;for(;this.peek().type===m.IDENTIFIER&&this.peek(1).type===m.IDENTIFIER;)t+=" "+this.advance().value;const i=this.expect(m.IDENTIFIER).value;this.expect(m.OPERATOR,"="),this.skipNewlines();const r=this.parseExpression(),s=new te(i);return s.varType=t,new Pe([new Re(s,r,t)],Ve.LET)}parseFunctionDeclaration(){let t=null;this.peek().type===m.IDENTIFIER&&this.peek(1).type===m.IDENTIFIER&&(t=this.advance().value);const i=this.expect(m.IDENTIFIER).value;this.expect(m.LPAREN);const r=[];for(;!this.match(m.RPAREN)&&(this.skipNewlines(),!this.match(m.RPAREN));){let a=null;for(;this.peek().type===m.IDENTIFIER&&this.peek(1).type===m.IDENTIFIER&&this.peek(2).type!==m.LPAREN;)a&&(a+=" "),a=(a||"")+this.advance().value;const o=this.expect(m.IDENTIFIER).value,h=new te(o);if(a&&(h.varType=a),this.match(m.OPERATOR,"=")){this.advance(),this.skipNewlines();const c=this.parseExpression();r.push(new xi(h,c))}else r.push(h);this.match(m.COMMA)&&this.advance()}this.expect(m.RPAREN),this.skipNewlines(),this.expect(m.OPERATOR,"=>"),this.skipNewlines();const s=this.parseFunctionBody(),n=new te(i);return t&&(n.returnType=t),new li(n,r,s,t)}parseMethodDeclaration(){this.expect(m.KEYWORD,"method");let t=null;this.peek().type===m.IDENTIFIER&&this.peek(1).type===m.IDENTIFIER&&this.peek(2).type===m.LPAREN&&(t=this.advance().value);const i=this.expect(m.IDENTIFIER).value;this.expect(m.LPAREN);const r=[];for(;!this.match(m.RPAREN)&&(this.skipNewlines(),!this.match(m.RPAREN));){let a=null;for(;this.peek().type===m.IDENTIFIER&&this.peek(1).type===m.IDENTIFIER&&this.peek(2).type!==m.LPAREN;)a&&(a+=" "),a=(a||"")+this.advance().value;const o=this.expect(m.IDENTIFIER).value,h=new te(o);if(a&&(h.varType=a),this.match(m.OPERATOR,"=")){this.advance(),this.skipNewlines();const c=this.parseExpression();r.push(new xi(h,c))}else r.push(h);this.match(m.COMMA)&&this.advance()}this.expect(m.RPAREN),this.skipNewlines(),this.expect(m.OPERATOR,"=>"),this.skipNewlines();const s=this.parseFunctionBody(),n=new te(i);return t&&(n.returnType=t),n.isMethod=!0,new li(n,r,s,t)}parseFunctionBody(){const t=[];if(!this.match(m.INDENT)){const i=this.parseExpression();return new De([new fi(i)])}for(this.advance();!this.match(m.DEDENT)&&!this.match(m.EOF)&&(this.skipNewlines(),!this.match(m.DEDENT));){const i=this.parseStatementOrSequence();Array.isArray(i)?t.push(...i):i&&t.push(i)}if(this.match(m.DEDENT)&&this.advance(),t.length>0){const i=t[t.length-1];i.type==="ExpressionStatement"&&(t[t.length-1]=new fi(i.expression))}return new De(t)}parseStatementOrSequence(){this.pos;const t=this.peek().line;if(this.match(m.KEYWORD,"if")){const r=this.parseIfStatement();return r&&(r._line=t),r}if(this.match(m.KEYWORD,"for"))return this.parseForStatement();if(this.match(m.KEYWORD,"while"))return this.parseWhileStatement();if(this.match(m.KEYWORD,"break")||this.match(m.KEYWORD,"continue")){const r=this.advance().value;return new oe(new te(r))}if(this.match(m.KEYWORD,"var")||this.match(m.KEYWORD,"varip"))return this.parseVarDeclaration();if(this.isTupleDestructuring())return this.parseTupleDestructuring();if(this.peek().type===m.IDENTIFIER&&this.peek(1).type===m.IDENTIFIER){let r=2;for(;this.peek(r).type===m.IDENTIFIER;)r++;if(this.peek(r).type===m.OPERATOR&&this.peek(r).value==="=")return this.parseTypedVarDeclaration()}const i=[];for(;;){const r=this.parseExpression();if(this.match(m.OPERATOR)){const s=this.peek().value;if(["=",":=","+=","-=","*=","/=","%="].includes(s)){this.advance(),this.skipNewlines();const n=this.parseExpression();if(s==="="&&r.type==="Identifier"?i.push(new Pe([new Re(r,n)],Ve.LET)):i.push(new oe(new Ct(s===":="?"=":s,r,n))),this.match(m.COMMA)){this.advance(),this.skipNewlines();continue}break}else{if(i.length>0)i.push(new oe(r));else return new oe(r);break}}else if(this.match(m.COMMA)){i.push(new oe(r)),this.advance(),this.skipNewlines();continue}else{if(i.length>0)i.push(new oe(r));else return new oe(r);break}}return i.length>1?i:i.length===1?i[0]:null}parseIfStatement(){this.expect(m.KEYWORD,"if");const t=this.parseExpression();this.skipNewlines();const i=this.parseBlock();let r=null;return this.match(m.KEYWORD,"else")&&(this.advance(),this.skipNewlines(),this.match(m.KEYWORD,"if")?r=this.parseIfStatement():r=this.parseBlock()),new Ys(t,i,r)}parseForStatement(){this.expect(m.KEYWORD,"for");let t=null,i=!1;if(this.match(m.LBRACKET)){this.advance();const r=[];for(;!this.match(m.RBRACKET);)this.skipNewlines(),r.push(new te(this.expect(m.IDENTIFIER).value)),this.match(m.COMMA)&&this.advance();this.expect(m.RBRACKET),t=new gi(r),i=!0}else{const r=this.expect(m.IDENTIFIER).value;t=new te(r)}if(this.match(m.KEYWORD,"in")){this.advance();const r=this.parseExpression();this.skipNewlines();const s=this.parseBlock(),n=new Pe([new Re(t,r)],Ve.CONST),a=new pi(n,null,null,s);return a.isForIn=!0,a}else{if(i)throw new Error(`Range-based for loops don't support destructuring at ${this.peek().line}:${this.peek().column}`);this.expect(m.OPERATOR,"=");const r=this.parseExpression();this.expect(m.KEYWORD,"to");const s=this.parseExpression();let n=null;this.match(m.KEYWORD,"by")&&(this.advance(),n=this.parseExpression()),this.skipNewlines();const a=this.parseBlock(),o=new Pe([new Re(t,r)],Ve.LET),h=new Me("<=",t,s),c=n?new Ct("+=",t,n):new Xs("++",t);return new pi(o,h,c,a)}}parseWhileStatement(){this.expect(m.KEYWORD,"while");const t=this.parseExpression();this.skipNewlines();const i=this.parseBlock();return new Qs(t,i)}parseBlock(){if(!this.match(m.INDENT)){const i=this.parseStatement();return new De(i?[i]:[])}this.advance();const t=[];for(;!this.match(m.DEDENT)&&!this.match(m.EOF)&&(this.skipNewlines(),!this.match(m.DEDENT));){const i=this.parseStatement();i&&t.push(i)}return this.match(m.DEDENT)&&this.advance(),new De(t)}isTupleDestructuring(){if(!this.match(m.LBRACKET))return!1;let t=1;for(;;){for(;this.peek(t).type===m.NEWLINE;)t++;if(this.peek(t).type!==m.IDENTIFIER)return!1;for(t++;this.peek(t).type===m.NEWLINE;)t++;if(this.peek(t).type===m.RBRACKET){t++;break}else if(this.peek(t).type===m.COMMA){t++;continue}else return!1}for(;this.peek(t).type===m.NEWLINE;)t++;return this.peek(t).type===m.OPERATOR&&this.peek(t).value==="="}parseTupleDestructuring(){this.expect(m.LBRACKET);const t=[];for(;!this.match(m.RBRACKET);)this.skipNewlines(),t.push(new te(this.expect(m.IDENTIFIER).value)),this.match(m.COMMA)&&this.advance();this.expect(m.RBRACKET),this.skipNewlines(),this.expect(m.OPERATOR,"="),this.skipNewlines();const i=this.parseExpression();return new Pe([new Re(new gi(t),i)],Ve.CONST)}parseExpression(){return this.parseTernary()}parseTernary(){let t=this.parseLogicalOr();if(this.match(m.OPERATOR,"?")){this.advance(),this.skipNewlines();const i=this.parseExpression();this.expect(m.COLON),this.skipNewlines();const r=this.parseExpression();return new Qe(t,i,r)}return t}parseLogicalOr(){let t=this.parseLogicalAnd();for(;this.match(m.KEYWORD,"or")||this.match(m.OPERATOR)&&this.peek().value==="||";){this.advance(),this.skipNewlines();const i=this.parseLogicalAnd();t=new Me("||",t,i)}return t}parseLogicalAnd(){let t=this.parseEquality();for(;this.match(m.KEYWORD,"and")||this.match(m.OPERATOR)&&this.peek().value==="&&";){this.advance(),this.skipNewlines();const i=this.parseEquality();t=new Me("&&",t,i)}return t}parseEquality(){let t=this.parseComparison();for(;this.match(m.OPERATOR);){const i=this.peek().value;if(!["==","!="].includes(i))break;this.advance(),this.skipNewlines();const r=this.parseComparison();t=new Me(i,t,r)}return t}parseComparison(){let t=this.parseAdditive();for(;this.match(m.OPERATOR);){const i=this.peek().value;if(!["<",">","<=",">="].includes(i))break;this.advance(),this.skipNewlines();const r=this.parseAdditive();t=new Me(i,t,r)}return t}parseAdditive(){let t=this.parseMultiplicative();for(;this.match(m.OPERATOR);){const i=this.peek().value;if(!["+","-"].includes(i))break;this.advance(),this.skipNewlines();const r=this.parseMultiplicative();t=new Me(i,t,r)}return t}parseMultiplicative(){let t=this.parseUnary();for(;this.match(m.OPERATOR);){const i=this.peek().value;if(!["*","/","%"].includes(i))break;this.advance(),this.skipNewlines();const r=this.parseUnary();t=new Me(i,t,r)}return t}parseUnary(){if(this.match(m.OPERATOR)){const t=this.peek().value;if(["+","-","!"].includes(t))return this.advance(),this.skipNewlines(),new mi(t,this.parseUnary())}return this.match(m.KEYWORD,"not")?(this.advance(),this.skipNewlines(),new mi("!",this.parseUnary())):this.parsePostfix()}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.match(m.OPERATOR,"<")){const i=this.pos;this.advance();let r=1,s=!0;for(;r>0&&!this.match(m.EOF);)if(this.match(m.OPERATOR,"<"))r++,this.advance();else if(this.match(m.OPERATOR,">"))r--,this.advance();else if(this.match(m.IDENTIFIER)||this.match(m.COMMA))this.advance();else{s=!1,this.pos=i;break}if(s&&this.match(m.LPAREN)){t=this.parseCallExpression(t);continue}else{if(s)continue;break}}else if(this.match(m.LPAREN))t=this.parseCallExpression(t);else if(this.match(m.DOT)){this.advance(),this.skipNewlines();const i=this.expect(m.IDENTIFIER).value;t=new di(t,new te(i),!1)}else if(this.match(m.LBRACKET)){this.advance(),this.skipNewlines();const i=this.parseExpression();this.expect(m.RBRACKET),t=new di(t,i,!0)}else break;return t}parseCallExpression(t){this.expect(m.LPAREN);const i=[],r=[];for(;!this.match(m.RPAREN)&&(this.skipNewlines(),!this.match(m.RPAREN));){if((this.peek().type===m.IDENTIFIER||this.peek().type===m.KEYWORD)&&this.peek(1).type===m.OPERATOR&&this.peek(1).value==="="){const s=this.advance().value;this.advance(),this.skipNewlines();const n=this.parseExpression();r.push(new tn(new te(s),n))}else i.push(this.parseExpression());this.match(m.COMMA)&&this.advance(),this.skipNewlines()}return this.expect(m.RPAREN),r.length>0&&i.push(new en(r)),new Zs(t,i)}parsePrimary(){const t=this.peek();if(this.match(m.NUMBER)){const i=this.advance();return new $e(i.value)}if(this.match(m.STRING)){const i=this.advance();return new $e(i.value)}if(this.match(m.BOOLEAN)){const i=this.advance();return new $e(i.value)}if(this.match(m.IDENTIFIER)){const i=this.advance();return new te(i.value)}if(this.match(m.LBRACKET))return this.parseArrayLiteral();if(this.match(m.LPAREN)){this.advance(),this.skipNewlines();const i=this.parseExpression();return this.skipNewlines(),this.expect(m.RPAREN),i}if(this.match(m.KEYWORD,"if"))return this.parseIfExpression();if(this.match(m.KEYWORD,"switch"))return this.parseSwitchExpression();throw new Error(`Unexpected token ${t.type} '${t.value}' at ${t.line}:${t.column}`)}parseArrayLiteral(){this.expect(m.LBRACKET);const t=[];for(;!this.match(m.RBRACKET)&&(this.skipNewlines(),!this.match(m.RBRACKET));)t.push(this.parseExpression()),this.match(m.COMMA)&&this.advance(),this.skipNewlines();return this.expect(m.RBRACKET),new Js(t)}parseIfExpression(){this.expect(m.KEYWORD,"if");const t=this.parseExpression();this.skipNewlines(),this.expect(m.INDENT);const i=[];for(;!this.match(m.DEDENT)&&!this.match(m.EOF)&&(this.skipNewlines(),!this.match(m.DEDENT));){const a=this.parseStatement();a&&i.push(a)}this.advance();let r=[];if(this.match(m.KEYWORD,"else"))if(this.advance(),this.skipNewlines(),this.match(m.KEYWORD,"if")){const a=this.parseIfExpression();if(this.needsIIFE(i,r)){const o=new Qe(t,new De(i),a);return o.needsIIFE=!0,o.consequentStmts=i,o.alternateExpr=a,o}else return new Qe(t,this.getBlockValue(i),a)}else{for(this.expect(m.INDENT);!this.match(m.DEDENT)&&!this.match(m.EOF)&&(this.skipNewlines(),!this.match(m.DEDENT));){const a=this.parseStatement();a&&r.push(a)}this.advance()}if(this.needsIIFE(i,r)){const a=new Qe(t,new De(i),new De(r));return a.needsIIFE=!0,a.consequentStmts=i,a.alternateStmts=r,a}const s=this.getBlockValue(i),n=r.length>0?this.getBlockValue(r):new $e(null);return new Qe(t,s,n)}needsIIFE(t,i){if(t.length>1||i.length>1)return!0;const r=s=>s.some(n=>n.type==="IfStatement"||n.type==="ForStatement"||n.type==="WhileStatement"||n.type==="BlockStatement");return r(t)||r(i)}parseSwitchExpression(){this.expect(m.KEYWORD,"switch");const t=this.parseExpression();this.skipNewlines(),this.expect(m.INDENT);const i=[];for(;!this.match(m.DEDENT)&&!this.match(m.EOF)&&(this.skipNewlines(),!this.match(m.DEDENT));){let r=null;this.match(m.OPERATOR,"=>")||(r=this.parseExpression()),this.expect(m.OPERATOR,"=>"),this.skipNewlines();const s=[];if(this.match(m.INDENT)){for(this.advance();!this.match(m.DEDENT)&&!this.match(m.EOF)&&(this.skipNewlines(),!this.match(m.DEDENT));){const a=this.parseStatement();a&&s.push(a)}this.advance()}else s.push(new oe(this.parseExpression()));const n=this.getBlockValue(s);i.push(new sn(r,n)),this.skipNewlines()}return this.advance(),new rn(t,i)}getBlockValue(t){if(t.length===0)return new $e(null);const i=t[t.length-1];return i.type==="ExpressionStatement"?i.expression:i.type==="VariableDeclaration"&&i.declarations.length>0?i.declarations[0].id:new $e(null)}}var hn=Object.defineProperty,cn=(e,t,i)=>t in e?hn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Oe=(e,t,i)=>cn(e,typeof t!="symbol"?t+"":t,i);class un{constructor(t={}){Oe(this,"indent"),Oe(this,"indentStr"),Oe(this,"output"),Oe(this,"sourceCode"),Oe(this,"sourceLines"),Oe(this,"lastCommentedLine"),Oe(this,"includeSourceComments"),this.indent=0,this.indentStr=t.indentStr||" ",this.output=[],this.sourceCode=t.sourceCode||null,this.sourceLines=this.sourceCode?this.sourceCode.split(`
|
|
40
|
+
`):[],this.lastCommentedLine=-1,this.includeSourceComments=t.includeSourceComments||!1}generate(t){if(this.output=[],this.indent=0,this.lastCommentedLine=-1,t.type==="Program")this.generateProgram(t);else throw new Error(`Expected Program node, got ${t.type}`);return this.output.join("")}writeSourceComment(t,i=null){if(!this.sourceLines.length)return;const r=i||t,s=[];for(let n=t-1;n<r&&n<this.sourceLines.length;n++)if(n>this.lastCommentedLine){const a=this.sourceLines[n].trim();a&&!a.startsWith("//@")&&!a.startsWith("//")&&s.push(this.sourceLines[n])}if(s.length>0){for(const n of s)this.write(this.indentStr.repeat(this.indent)),this.write("/// "),this.write(n.trimEnd()),this.write(`
|
|
41
|
+
`);this.lastCommentedLine=Math.max(this.lastCommentedLine,r-1)}}write(t){this.output.push(t)}writeLine(t=""){t?this.output.push(this.indentStr.repeat(this.indent)+t+`
|
|
42
|
+
`):this.output.push(`
|
|
43
|
+
`)}increaseIndent(){this.indent++}decreaseIndent(){this.indent--}generateProgram(t){for(let i=0;i<t.body.length;i++)if(this.generateStatement(t.body[i]),i<t.body.length-1){const r=t.body[i],s=t.body[i+1];(r.type==="FunctionDeclaration"||r.type==="TypeDefinition")&&(s.type==="FunctionDeclaration"||s.type==="TypeDefinition")&&this.writeLine()}}generateStatement(t){switch(this.includeSourceComments&&t._line&&this.sourceLines.length>0&&this.writeSourceComment(t._line),t.type){case"FunctionDeclaration":return this.generateFunctionDeclaration(t);case"VariableDeclaration":return this.generateVariableDeclaration(t);case"ExpressionStatement":return this.generateExpressionStatement(t);case"IfStatement":return this.generateIfStatement(t);case"ForStatement":return this.generateForStatement(t);case"WhileStatement":return this.generateWhileStatement(t);case"ReturnStatement":return this.generateReturnStatement(t);case"BlockStatement":return this.generateBlockStatement(t);case"TypeDefinition":return this.generateTypeDefinition(t);default:throw new Error(`Unknown statement type: ${t.type}`)}}generateTypeDefinition(t){this.write(this.indentStr.repeat(this.indent)),this.write(`class ${t.name} {
|
|
44
|
+
`),this.increaseIndent(),this.write(this.indentStr.repeat(this.indent)),this.write("constructor(");const i=t.fields.map(r=>r.name).join(", ");this.write(i),this.write(`) {
|
|
45
|
+
`),this.increaseIndent();for(const r of t.fields)this.write(this.indentStr.repeat(this.indent)),this.write(`this.${r.name} = ${r.name}`),r.defaultValue&&(this.write(" !== undefined ? "),this.write(r.name),this.write(" : "),this.generateExpression(r.defaultValue)),this.write(`;
|
|
46
|
+
`);this.decreaseIndent(),this.write(this.indentStr.repeat(this.indent)),this.write(`}
|
|
47
|
+
`),this.decreaseIndent(),this.write(this.indentStr.repeat(this.indent)),this.write(`}
|
|
48
|
+
`)}generateFunctionDeclaration(t){this.write(this.indentStr.repeat(this.indent));const i=t.id.isMethod;this.write("function "),this.write(t.id.name),this.write("(");const r=t.params,s=i&&r.length>0&&r[0].type==="Identifier"&&r[0].name==="this"?1:0;for(let n=s;n<r.length;n++){const a=r[n];if(a.type==="Identifier")this.write(a.name);else if(a.type==="AssignmentPattern"){const o=a.left.name==="this"&&i?"self":a.left.name;this.write(o),this.write(" = "),this.generateExpression(a.right)}n<r.length-1&&this.write(", ")}this.write(") "),this.generateBlockStatement(t.body,!1),this.write(`
|
|
49
|
+
`)}generateVariableDeclaration(t){const i=t.kind==="var"||t.kind==="varip"?"var":"let";for(let r=0;r<t.declarations.length;r++){const s=t.declarations[r];if(s.init&&s.init.type==="ConditionalExpression"&&s.init.needsIIFE){const n=s.id.type==="Identifier"?s.id.name:null;if(n){this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" "),this.write(n),this.write(`;
|
|
50
|
+
`),this.generateIfStatementWithAssignment(s.init,n);continue}}if(this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" "),s.id.type==="Identifier")this.write(s.id.name);else if(s.id.type==="ArrayPattern"){this.write("[");for(let n=0;n<s.id.elements.length;n++)this.write(s.id.elements[n].name),n<s.id.elements.length-1&&this.write(", ");this.write("]")}s.init&&(this.write(" = "),this.generateExpression(s.init)),this.write(`;
|
|
51
|
+
`)}}generateExpressionStatement(t){this.write(this.indentStr.repeat(this.indent)),this.generateExpression(t.expression),this.write(`;
|
|
52
|
+
`)}generateIfStatement(t){this.write(this.indentStr.repeat(this.indent)),this.write("if ("),this.generateExpression(t.test),this.write(") "),this.generateBlockStatement(t.consequent,!1),t.alternate?(this.write(" else "),t.alternate.type==="IfStatement"?this.generateIfStatement(t.alternate):this.generateBlockStatement(t.alternate,!1)):this.write(`
|
|
53
|
+
`)}generateIfStatementWithAssignment(t,i){if(this.write(this.indentStr.repeat(this.indent)),this.write("if ("),this.generateExpression(t.test),this.write(`) {
|
|
54
|
+
`),this.indent++,t.consequentStmts)for(let r=0;r<t.consequentStmts.length;r++){const s=t.consequentStmts[r];r===t.consequentStmts.length-1?s.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" = "),this.generateExpression(s.expression),this.write(`;
|
|
55
|
+
`)):s.type==="IfStatement"?this.generateNestedIfWithAssignments(s,i):this.generateStatement(s):this.generateStatement(s)}if(this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}"),t.alternateExpr)this.write(` else {
|
|
56
|
+
`),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" = "),this.generateExpression(t.alternateExpr),this.write(`;
|
|
57
|
+
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}");else if(t.alternateStmts&&t.alternateStmts.length>0){this.write(` else {
|
|
58
|
+
`),this.indent++;for(let r=0;r<t.alternateStmts.length;r++){const s=t.alternateStmts[r];r===t.alternateStmts.length-1?s.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" = "),this.generateExpression(s.expression),this.write(`;
|
|
59
|
+
`)):s.type==="IfStatement"?this.generateNestedIfWithAssignments(s,i):this.generateStatement(s):this.generateStatement(s)}this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}")}else this.write(` else {
|
|
60
|
+
`),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(` = false;
|
|
61
|
+
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}");this.write(`
|
|
62
|
+
`)}generateNestedIfWithAssignments(t,i){if(this.write(this.indentStr.repeat(this.indent)),this.write("if ("),this.generateExpression(t.test),this.write(`) {
|
|
63
|
+
`),this.indent++,t.consequent.type==="BlockStatement"&&t.consequent.body.length>0)for(let r=0;r<t.consequent.body.length;r++){const s=t.consequent.body[r];r===t.consequent.body.length-1?s.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" = "),this.generateExpression(s.expression),this.write(`;
|
|
64
|
+
`)):s.type==="IfStatement"?this.generateNestedIfWithAssignments(s,i):this.generateStatement(s):this.generateStatement(s)}if(this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}"),t.alternate)if(t.alternate.type==="IfStatement"){if(this.write(" else "),this.write("if ("),this.generateExpression(t.alternate.test),this.write(`) {
|
|
65
|
+
`),this.indent++,t.alternate.consequent.type==="BlockStatement"&&t.alternate.consequent.body.length>0)for(let r=0;r<t.alternate.consequent.body.length;r++){const s=t.alternate.consequent.body[r];r===t.alternate.consequent.body.length-1?s.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" = "),this.generateExpression(s.expression),this.write(`;
|
|
66
|
+
`)):s.type==="IfStatement"?this.generateNestedIfWithAssignments(s,i):this.generateStatement(s):this.generateStatement(s)}this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}"),this.generateNestedIfAlternatesWithAssignments(t.alternate.alternate,i)}else if(t.alternate.type==="BlockStatement"&&t.alternate.body.length>0){this.write(` else {
|
|
67
|
+
`),this.indent++;for(let r=0;r<t.alternate.body.length;r++){const s=t.alternate.body[r];r===t.alternate.body.length-1?s.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" = "),this.generateExpression(s.expression),this.write(`;
|
|
68
|
+
`)):s.type==="IfStatement"?this.generateNestedIfWithAssignments(s,i):this.generateStatement(s):this.generateStatement(s)}this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write(`}
|
|
69
|
+
`)}else this.write(` else {
|
|
70
|
+
`),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(` = false;
|
|
71
|
+
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write(`}
|
|
72
|
+
`);else this.write(`
|
|
73
|
+
`)}generateNestedIfAlternatesWithAssignments(t,i){if(t)if(t.type==="IfStatement"){if(this.write(" else "),this.write("if ("),this.generateExpression(t.test),this.write(`) {
|
|
74
|
+
`),this.indent++,t.consequent.type==="BlockStatement"&&t.consequent.body.length>0)for(let r=0;r<t.consequent.body.length;r++){const s=t.consequent.body[r];r===t.consequent.body.length-1?s.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" = "),this.generateExpression(s.expression),this.write(`;
|
|
75
|
+
`)):s.type==="IfStatement"?this.generateNestedIfWithAssignments(s,i):this.generateStatement(s):this.generateStatement(s)}this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}"),this.generateNestedIfAlternatesWithAssignments(t.alternate,i)}else if(t.type==="BlockStatement"&&t.body.length>0){this.write(` else {
|
|
76
|
+
`),this.indent++;for(let r=0;r<t.body.length;r++){const s=t.body[r];r===t.body.length-1?s.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" = "),this.generateExpression(s.expression),this.write(`;
|
|
77
|
+
`)):s.type==="IfStatement"?this.generateNestedIfWithAssignments(s,i):this.generateStatement(s):this.generateStatement(s)}this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write(`}
|
|
78
|
+
`)}else this.write(` else {
|
|
79
|
+
`),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(` = false;
|
|
80
|
+
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write(`}
|
|
81
|
+
`)}generateForStatement(t){if(this.write(this.indentStr.repeat(this.indent)),t.isForIn){if(this.write("for ("),t.init&&t.init.type==="VariableDeclaration"){const i=t.init.declarations[0];if(this.write(`${t.init.kind} `),i.id.type==="Identifier")this.write(i.id.name);else if(i.id.type==="ArrayPattern"){this.write("[");for(let r=0;r<i.id.elements.length;r++)this.write(i.id.elements[r].name),r<i.id.elements.length-1&&this.write(", ");this.write("]")}this.write(" of "),this.generateExpression(i.init)}this.write(") "),this.generateBlockStatement(t.body,!1);return}if(this.write("for ("),t.init)if(t.init.type==="VariableDeclaration"){const i=t.init.declarations[0];this.write(`${t.init.kind} ${i.id.name}`),i.init&&(this.write(" = "),this.generateExpression(i.init))}else this.generateExpression(t.init);this.write("; "),t.test&&this.generateExpression(t.test),this.write("; "),t.update&&(t.update.type==="AssignmentExpression"?(this.generateExpression(t.update.left),this.write(` ${t.update.operator} `),this.generateExpression(t.update.right)):this.generateExpression(t.update)),this.write(") "),this.generateBlockStatement(t.body,!1)}generateWhileStatement(t){this.write(this.indentStr.repeat(this.indent)),this.write("while ("),this.generateExpression(t.test),this.write(") "),this.generateBlockStatement(t.body,!1)}generateReturnStatement(t){this.write(this.indentStr.repeat(this.indent)),this.write("return"),t.argument&&(this.write(" "),this.generateExpression(t.argument)),this.write(`;
|
|
82
|
+
`)}generateBlockStatement(t,i=!0){this.write(`{
|
|
83
|
+
`),i?this.increaseIndent():this.indent++;for(const r of t.body)this.generateStatement(r);i?this.decreaseIndent():this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}"),i&&this.write(`
|
|
84
|
+
`)}generateExpression(t){switch(t.type){case"Identifier":return this.write(t.name);case"Literal":return this.generateLiteral(t);case"BinaryExpression":case"LogicalExpression":return this.generateBinaryExpression(t);case"UnaryExpression":return this.generateUnaryExpression(t);case"AssignmentExpression":return this.generateAssignmentExpression(t);case"UpdateExpression":return this.generateUpdateExpression(t);case"CallExpression":return this.generateCallExpression(t);case"MemberExpression":return this.generateMemberExpression(t);case"ConditionalExpression":return this.generateConditionalExpression(t);case"ArrayExpression":return this.generateArrayExpression(t);case"ObjectExpression":return this.generateObjectExpression(t);case"SwitchExpression":return this.generateSwitchExpression(t);case"SequenceExpression":return this.generateSequenceExpression(t);default:throw new Error(`Unknown expression type: ${t.type}`)}}generateLiteral(t){if(typeof t.value=="string"){const i=t.value.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");this.write(`'${i}'`)}else t.value===null?this.write("null"):this.write(String(t.value))}generateBinaryExpression(t){const i=this.needsParentheses(t);i&&this.write("("),this.generateExpression(t.left),this.write(" ");let r=t.operator;r==="and"?r="&&":r==="or"&&(r="||"),this.write(r),this.write(" "),this.generateExpression(t.right),i&&this.write(")")}generateUnaryExpression(t){let i=t.operator;i==="not"&&(i="!"),this.write(i),this.generateExpression(t.argument)}generateAssignmentExpression(t){this.generateExpression(t.left),this.write(" ");let i=t.operator;i===":="&&(i="="),this.write(i),this.write(" "),this.generateExpression(t.right)}generateUpdateExpression(t){t.prefix?(this.write(t.operator),this.generateExpression(t.argument)):(this.generateExpression(t.argument),this.write(t.operator))}generateCallExpression(t){this.generateExpression(t.callee),this.write("(");for(let i=0;i<t.arguments.length;i++){const r=t.arguments[i];r.type==="AssignmentExpression"&&r.operator==="="?this.generateExpression(r.right):this.generateExpression(r),i<t.arguments.length-1&&this.write(", ")}this.write(")")}generateMemberExpression(t){this.generateExpression(t.object),t.computed?(this.write("["),this.generateExpression(t.property),this.write("]")):(this.write("."),this.generateExpression(t.property))}generateConditionalExpression(t){if(t.needsIIFE){this.generateIIFEConditional(t);return}this.write("("),this.generateExpression(t.test),this.write(" ? "),this.generateExpression(t.consequent),this.write(" : "),this.generateExpression(t.alternate),this.write(")")}generateIIFEConditional(t){this.write(`(() => {
|
|
85
|
+
`),this.indent++,this.generateIIFEIfBlock(t),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("})()")}generateIIFEIfBlock(t){if(this.write(this.indentStr.repeat(this.indent)),this.write("if ("),this.generateExpression(t.test),this.write(`) {
|
|
86
|
+
`),this.indent++,t.consequentStmts)for(let i=0;i<t.consequentStmts.length;i++){const r=t.consequentStmts[i];i===t.consequentStmts.length-1?r.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write("return "),this.generateExpression(r.expression),this.write(`;
|
|
87
|
+
`)):r.type==="IfStatement"?this.generateNestedIfWithReturns(r):this.generateStatement(r):this.generateStatement(r)}if(this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}"),t.alternateExpr)this.write(` else {
|
|
88
|
+
`),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write("return "),this.generateExpression(t.alternateExpr),this.write(`;
|
|
89
|
+
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}");else if(t.alternateStmts&&t.alternateStmts.length>0){this.write(` else {
|
|
90
|
+
`),this.indent++;for(let i=0;i<t.alternateStmts.length;i++){const r=t.alternateStmts[i];i===t.alternateStmts.length-1?r.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write("return "),this.generateExpression(r.expression),this.write(`;
|
|
91
|
+
`)):r.type==="IfStatement"?this.generateNestedIfWithReturns(r):this.generateStatement(r):this.generateStatement(r)}this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}")}else this.write(` else {
|
|
92
|
+
`),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write(`return false;
|
|
93
|
+
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}");this.write(`
|
|
94
|
+
`)}generateNestedIfWithReturns(t){if(this.write(this.indentStr.repeat(this.indent)),this.write("if ("),this.generateExpression(t.test),this.write(`) {
|
|
95
|
+
`),this.indent++,t.consequent.type==="BlockStatement"&&t.consequent.body.length>0)for(let i=0;i<t.consequent.body.length;i++){const r=t.consequent.body[i];i===t.consequent.body.length-1?r.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write("return "),this.generateExpression(r.expression),this.write(`;
|
|
96
|
+
`)):r.type==="IfStatement"?this.generateNestedIfWithReturns(r):this.generateStatement(r):this.generateStatement(r)}if(this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}"),t.alternate)if(t.alternate.type==="IfStatement"){if(this.write(" else "),this.write("if ("),this.generateExpression(t.alternate.test),this.write(`) {
|
|
97
|
+
`),this.indent++,t.alternate.consequent.type==="BlockStatement"&&t.alternate.consequent.body.length>0)for(let i=0;i<t.alternate.consequent.body.length;i++){const r=t.alternate.consequent.body[i];i===t.alternate.consequent.body.length-1?r.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write("return "),this.generateExpression(r.expression),this.write(`;
|
|
98
|
+
`)):r.type==="IfStatement"?this.generateNestedIfWithReturns(r):this.generateStatement(r):this.generateStatement(r)}this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}"),this.generateNestedIfAlternates(t.alternate.alternate)}else if(t.alternate.type==="BlockStatement"&&t.alternate.body.length>0){this.write(` else {
|
|
99
|
+
`),this.indent++;for(let i=0;i<t.alternate.body.length;i++){const r=t.alternate.body[i];i===t.alternate.body.length-1?r.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write("return "),this.generateExpression(r.expression),this.write(`;
|
|
100
|
+
`)):r.type==="IfStatement"?this.generateNestedIfWithReturns(r):this.generateStatement(r):this.generateStatement(r)}this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write(`}
|
|
101
|
+
`)}else this.write(` else {
|
|
102
|
+
`),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write(`return false;
|
|
103
|
+
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write(`}
|
|
104
|
+
`);else this.write(`
|
|
105
|
+
`)}generateNestedIfAlternates(t){if(t)if(t.type==="IfStatement"){if(this.write(" else "),this.write("if ("),this.generateExpression(t.test),this.write(`) {
|
|
106
|
+
`),this.indent++,t.consequent.type==="BlockStatement"&&t.consequent.body.length>0)for(let i=0;i<t.consequent.body.length;i++){const r=t.consequent.body[i];i===t.consequent.body.length-1?r.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write("return "),this.generateExpression(r.expression),this.write(`;
|
|
107
|
+
`)):r.type==="IfStatement"?this.generateNestedIfWithReturns(r):this.generateStatement(r):this.generateStatement(r)}this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}"),this.generateNestedIfAlternates(t.alternate)}else if(t.type==="BlockStatement"&&t.body.length>0){this.write(` else {
|
|
108
|
+
`),this.indent++;for(let i=0;i<t.body.length;i++){const r=t.body[i];i===t.body.length-1?r.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write("return "),this.generateExpression(r.expression),this.write(`;
|
|
109
|
+
`)):r.type==="IfStatement"?this.generateNestedIfWithReturns(r):this.generateStatement(r):this.generateStatement(r)}this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write(`}
|
|
110
|
+
`)}else this.write(` else {
|
|
111
|
+
`),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write(`return false;
|
|
112
|
+
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write(`}
|
|
113
|
+
`)}generateNestedIfAsExpression(t){if(t.type==="IfStatement"){if(this.write("("),this.generateExpression(t.test),this.write(" ? "),t.consequent.type==="BlockStatement"&&t.consequent.body.length>0){const i=t.consequent.body[t.consequent.body.length-1];i.type==="ExpressionStatement"?this.generateExpression(i.expression):i.type==="IfStatement"&&this.generateNestedIfAsExpression(i)}if(this.write(" : "),t.alternate)if(t.alternate.type==="IfStatement")this.generateNestedIfAsExpression(t.alternate);else if(t.alternate.type==="BlockStatement"&&t.alternate.body.length>0){const i=t.alternate.body[t.alternate.body.length-1];i.type==="ExpressionStatement"&&this.generateExpression(i.expression)}else this.write("false");else this.write("false");this.write(")")}}generateArrayExpression(t){this.write("[");for(let i=0;i<t.elements.length;i++)this.generateExpression(t.elements[i]),i<t.elements.length-1&&this.write(", ");this.write("]")}generateObjectExpression(t){this.write("{");for(let i=0;i<t.properties.length;i++){const r=t.properties[i];r.key.type==="Identifier"?this.write(r.key.name):this.generateExpression(r.key),this.write(": "),this.generateExpression(r.value),i<t.properties.length-1&&this.write(", ")}this.write("}")}generateSwitchExpression(t){this.write("(");for(let i=0;i<t.cases.length;i++){const r=t.cases[i];r.test?(this.generateExpression(t.discriminant),this.write(" == "),this.generateExpression(r.test),this.write(" ? "),this.generateExpression(r.consequent),this.write(" : ")):this.generateExpression(r.consequent)}t.cases.some(i=>!i.test)||this.write("undefined"),this.write(")")}generateSequenceExpression(t){this.write("(");for(let i=0;i<t.expressions.length;i++)this.generateExpression(t.expressions[i]),i<t.expressions.length-1&&this.write(", ");this.write(")")}needsParentheses(t){return!1}}function fr(e){const t=/^\s*\/\/\s*@version\s*=\s*(\d+)\s*$/im,i=e.match(t);return i&&i[1]?parseInt(i[1],10):null}function ln(e,t={}){const i=fr(e);if(i===null)return{success:!1,version:null,error:"Pine Script version not found. Please add //@version=X comment to your script."};if(i<5)return{success:!1,version:i,error:`Pine Script version ${i} is not supported. Only version 5 and above are supported.`};try{const r=new Us(e).tokenize(),s=new on(r).parse(),n={...t,sourceCode:e},a=new un(n).generate(s);return{success:!0,version:i,code:a,ast:s,tokens:r}}catch(r){return{success:!1,version:i,error:r.message,stack:r.stack}}}function pn(e){if(typeof e=="function")return e.toString();{const t=fr(e);if(t===null)return e;if(t>=5){const i=ln(e);if(i.success)return i.code;throw new Error(`Failed to transpile Pine Script version ${t}: ${i.error}`)}else throw new Error(`Unsupported Pine Script version ${t}. Only version 5 and above are supported.`)}}function fn(e,t={debug:!1,ln:!1}){typeof t=="boolean"&&(t={debug:t,ln:!0});const{debug:i}=t;let r=pn(e);r=Cs(r);const s=i?r.split(`
|
|
114
|
+
`):[],n=ar(r,{ecmaVersion:"latest",sourceType:"module",locations:i});ks(n),Ss(n),_s(n);const a=new xs;Is(n,a);const o=Ps(n,a)||"";Bs(n,a,o,t,s),Ls(n);const h=ls||Ht||void 0,c=Object.assign({},h,{LineComment(f,g){g.write("//"+f.value)}}),l=hr(n,{generator:c,comments:i});return new Function("",`var _r = ${l}
|
|
115
|
+
; return _r;`)(this)}function mn(e){return t=>new F(t.array.map(i=>Math.abs(i)),t.type,e)}function dn(e){return t=>{let i=0,r=0;for(const s of t.array){const n=Number(s);isNaN(n)||(r++,i+=(n-i)/r)}return r===0?NaN:e.precision(i)}}function gn(e){return(t,i)=>{const r=t.array;let s=0,n=r.length-1;for(;s<=n;){const a=Math.floor((s+n)/2),o=r[a];if(o===i)return a;o<i?s=a+1:n=a-1}return-1}}function xn(e){return(t,i)=>{const r=t.array;let s=0,n=r.length;for(;s<n;){const a=Math.floor((s+n)/2);r[a]<i?s=a+1:n=a}return s<r.length&&r[s]===i?s:s-1}}function yn(e){return(t,i)=>{const r=t.array;let s=0,n=r.length;for(;s<n;){const a=Math.floor((s+n)/2);r[a]<=i?s=a+1:n=a}return s>0&&r[s-1]===i?s-1:s}}function wn(e){return t=>{t.array.length=0}}function bn(e){return(t,i)=>(t.array.push(...i.array),t)}function vn(e){return t=>new F([...t.array],t.type,e)}function _n(e){return(t,i,r=!0)=>{const s=t.array,n=i.array;if(s.length!==n.length)return NaN;let a=0,o=0,h=0;const c=[];for(let x=0;x<s.length;x++){const y=Number(s[x]),w=Number(n[x]);!isNaN(y)&&y!==null&&y!==void 0&&!isNaN(w)&&w!==null&&w!==void 0&&(a+=y,o+=w,h++,c.push(x))}if(h===0)return NaN;const l=a/h,f=o/h;let g=0;for(const x of c){const y=Number(s[x]),w=Number(n[x]);g+=(y-l)*(w-f)}const p=r?h:h-1;return p<=0?NaN:e.precision(g/p)}}function Sn(e){return t=>t.array.every(i=>!isNaN(i)&&i)}function En(e){if(e.every(t=>typeof t=="number"))return e.every(t=>(t|0)===t)?W.int:W.float;if(e.every(t=>typeof t=="string"))return W.string;if(e.every(t=>typeof t=="boolean"))return W.bool;throw new Error("Cannot infer type from values")}function xe(e){if(typeof e=="number")return(e|0)===e?W.int:W.float;if(typeof e=="string")return W.string;if(typeof e=="boolean")return W.bool;throw new Error("Cannot infer type from value")}function nt(e,t){switch(t){case W.int:return typeof e=="number"&&(e|0)===e||isNaN(e);case W.float:return typeof e=="number"||isNaN(e);case W.string:return typeof e=="string";case W.bool:return typeof e=="boolean"}return!1}function Nn(e){return(t,i,r=0,s)=>{const n=t.array.length,a=s!==void 0?Math.min(s,n):n;for(let o=r;o<a;o++){if(!nt(i,t.type))throw new Error(`Cannot call 'array.fill' with argument 'value'='${i}'. An argument of 'literal ${typeof i}' type was used but a '${t.type}' is expected.`);t.array[o]=e.precision(i)}}}function Cn(e){return t=>t.array.length>0?t.array[0]:e.NA}function kn(e){return(t,i)=>t.array[i]}function In(e){return(t,i)=>t.array.includes(i)}function An(e){return(t,i)=>t.array.indexOf(i)}function Tn(e){return(t,i,r)=>{if(!nt(r,t.type))throw new Error(`Cannot call 'array.insert' with argument 'value'='${r}'. An argument of 'literal ${typeof r}' type was used but a '${t.type}' is expected.`);t.array.splice(i,0,r)}}function Pn(e){return(t,i=",")=>t.array.join(i)}function Rn(e){return t=>t.array.length>0?t.array[t.array.length-1]:e.NA}function Dn(e){return(t,i)=>t.array.lastIndexOf(i)}function Mn(e){return(t,i=0)=>[...t.array].sort((r,s)=>s-r)[i]??e.NA}function On(e){return t=>{if(t.array.length===0)return NaN;const i=[...t.array].sort((s,n)=>typeof s=="number"&&typeof n=="number"?s-n:0),r=Math.floor(i.length/2);return i.length%2!==0?i[r]:(i[r-1]+i[r])/2}}function Vn(e){return(t,i=0)=>[...t.array].sort((r,s)=>r-s)[i]??e.NA}function Ln(e){return t=>{if(t.array.length===0)return NaN;const i=new Map;let r=0;for(const n of t.array){const a=(i.get(n)||0)+1;i.set(n,a),a>r&&(r=a)}const s=[];for(const[n,a]of i)a===r&&s.push(n);return s.sort((n,a)=>typeof n=="number"&&typeof a=="number"?n-a:typeof n=="string"&&typeof a=="string"?n<a?-1:n>a?1:0:0),s[0]}}function Bn(e){return(t,i)=>{const r=t.array;if(r.length===0)return NaN;const s=[];for(const h of r){const c=Number(h);if(isNaN(c)||c===null||c===void 0)return NaN;s.push(c)}s.sort((h,c)=>h-c),i<0&&(i=0),i>100&&(i=100);const n=i/100*s.length-.5;if(n<=0)return e.precision(s[0]);if(n>=s.length-1)return e.precision(s[s.length-1]);const a=Math.floor(n),o=n-a;return e.precision(s[a]*(1-o)+s[a+1]*o)}}function Fn(e){return(t,i)=>{const r=t.array;if(r.length===0)return NaN;const s=[];for(const o of r){const h=Number(o);!isNaN(h)&&h!==null&&h!==void 0&&s.push(h)}if(s.length===0)return NaN;s.sort((o,h)=>o-h),i<0&&(i=0),i>100&&(i=100);const n=r.length,a=Math.ceil(i/100*n);return a<=0?s[0]:a>s.length?NaN:s[a-1]}}function jn(e){return(t,i)=>{if(t.array.length===0)return NaN;const r=Math.floor(i);if(r<0||r>=t.array.length)return NaN;const s=Number(t.array[r]);if(isNaN(s)||s===null||s===void 0)return NaN;let n=0;for(const o of t.array){const h=Number(o);!isNaN(h)&&h!==null&&h!==void 0&&h<s&&n++}const a=t.array.length-1;return a<=0?NaN:n/a*100}}function $n(e){return t=>t.array.pop()}function Wn(e){return(t,i)=>{if(!nt(i,t.type))throw new Error(`Cannot call 'array.push' with argument 'value'='${i}'. An argument of 'literal ${typeof i}' type was used but a '${t.type}' is expected.`);t.array.push(e.precision(i))}}function qn(e){return t=>e.precision(e.pine.array.max(t)-e.pine.array.min(t))}function Un(e){return(t,i)=>i>=0&&i<t.array.length?t.array.splice(i,1)[0]:e.NA}function Kn(e){return t=>{t.array.reverse()}}function zn(e){return(t,i,r)=>{if(!nt(r,t.type))throw new Error(`Cannot call 'array.set' with argument 'value'='${r}'. An argument of 'literal ${typeof r}' type was used but a '${t.type}' is expected.`);t.array[i]=e.precision(r)}}function Hn(e){return t=>t.array.shift()}function Gn(e){return t=>t.array.length}function Yn(e){return(t,i,r)=>{const s=r!==void 0?r:void 0;return new F(t.array.slice(i,s),t.type,e)}}function Qn(e){return t=>t.array.some(i=>!isNaN(i)&&i)}var qe=(e=>(e[e.ascending=1]="ascending",e[e.descending=0]="descending",e))(qe||{}),mr=(e=>(e.AED="AED",e.ARS="ARS",e.AUD="AUD",e.BDT="BDT",e.BHD="BHD",e.BRL="BRL",e.BTC="BTC",e.CAD="CAD",e.CHF="CHF",e.CLP="CLP",e.CNY="CNY",e.COP="COP",e.CZK="CZK",e.DKK="DKK",e.EGP="EGP",e.ETH="ETH",e.EUR="EUR",e.GBP="GBP",e.HKD="HKD",e.HUF="HUF",e.IDR="IDR",e.ILS="ILS",e.INR="INR",e.ISK="ISK",e.JPY="JPY",e.KES="KES",e.KRW="KRW",e.KWD="KWD",e.LKR="LKR",e.MAD="MAD",e.MXN="MXN",e.MYR="MYR",e.NGN="NGN",e.NOK="NOK",e.NONE="NONE",e.NZD="NZD",e.PEN="PEN",e.PHP="PHP",e.PKR="PKR",e.PLN="PLN",e.QAR="QAR",e.RON="RON",e.RSD="RSD",e.RUB="RUB",e.SAR="SAR",e.SEK="SEK",e.SGD="SGD",e.THB="THB",e.TND="TND",e.TRY="TRY",e.TWD="TWD",e.USD="USD",e.USDT="USDT",e.VES="VES",e.VND="VND",e.ZAR="ZAR",e))(mr||{}),dr=(e=>(e[e.sunday=1]="sunday",e[e.monday=2]="monday",e[e.tuesday=3]="tuesday",e[e.wednesday=4]="wednesday",e[e.thursday=5]="thursday",e[e.friday=6]="friday",e[e.saturday=7]="saturday",e))(dr||{}),gr=(e=>(e.all="all",e.data_window="data_window",e.none="none",e.pane="pane",e.price_scale="price_scale",e.status_line="status_line",e))(gr||{});const Xn={order:qe,currency:mr,dayofweek:dr,display:gr};function Zn(e){return(t,i=qe.ascending)=>{t.array.sort((r,s)=>{let n=isNaN(r)?1/0:r,a=isNaN(s)?1/0:s;return i===qe.ascending?n-a:a-n})}}function Jn(e){return(t,i=qe.ascending)=>{const r=t.array.map((s,n)=>n);return r.sort((s,n)=>{const a=isNaN(t.array[s])?1/0:t.array[s],o=isNaN(t.array[n])?1/0:t.array[n];return i===qe.ascending?a-o:o-a}),new F(r,W.int,e)}}function ea(e){return t=>{const i=e.array.avg(t),r=e.array.stdev(t);return isNaN(r)?new F(t.array.map(()=>NaN),W.int,e):r===0?new F(t.array.map(()=>1),W.int,e):new F(t.array.map(s=>(s-i)/r),W.int,e)}}function ta(e){return(t,i=!0)=>{const r=t.array,s=r.length;if(s===0)return NaN;let n=0,a=0,o=0;for(let l=0;l<s;l++){const f=Number(r[l]);!isNaN(f)&&f!==null&&f!==void 0&&(n+=f,a+=f*f,o++)}if(o===0)return NaN;const h=n/o;let c=a/o-h*h;return c<0?NaN:(!i&&o>1&&(c=c*o/(o-1)),!i&&o===1?0:e.precision(Math.sqrt(c)))}}function ia(e){return t=>e.precision(t.array.reduce((i,r)=>{const s=Number(r);return isNaN(s)?i:i+s},0))}function ra(e){return(t,i)=>{if(!nt(i,t.type))throw new Error(`Cannot call 'array.unshift' with argument 'value'='${i}'. An argument of 'literal ${typeof i}' type was used but a '${t.type}' is expected.`);t.array.unshift(e.precision(i))}}function sa(e){return(t,i=!0)=>{let r=0,s=0;for(const h of t.array){const c=Number(h);!isNaN(c)&&c!==null&&c!==void 0&&(r+=c,s++)}if(s===0)return NaN;const n=r/s;let a=0;for(const h of t.array){const c=Number(h);!isNaN(c)&&c!==null&&c!==void 0&&(a+=(c-n)*(c-n))}const o=i?s:s-1;return o<=0?NaN:e.precision(a/o)}}var na=Object.defineProperty,aa=(e,t,i)=>t in e?na(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,R=(e,t,i)=>aa(e,typeof t!="symbol"?t+"":t,i),W=(e=>(e.any="",e.box="box",e.bool="bool",e.color="color",e.float="float",e.int="int",e.label="label",e.line="line",e.linefill="linefill",e.string="string",e.table="table",e))(W||{});class F{constructor(t,i,r){this.array=t,this.type=i,this.context=r,R(this,"_abs"),R(this,"_avg"),R(this,"_binary_search"),R(this,"_binary_search_leftmost"),R(this,"_binary_search_rightmost"),R(this,"_clear"),R(this,"_concat"),R(this,"_copy"),R(this,"_covariance"),R(this,"_every"),R(this,"_fill"),R(this,"_first"),R(this,"_get"),R(this,"_includes"),R(this,"_indexof"),R(this,"_insert"),R(this,"_join"),R(this,"_last"),R(this,"_lastindexof"),R(this,"_max"),R(this,"_median"),R(this,"_min"),R(this,"_mode"),R(this,"_percentile_linear_interpolation"),R(this,"_percentile_nearest_rank"),R(this,"_percentrank"),R(this,"_pop"),R(this,"_push"),R(this,"_range"),R(this,"_remove"),R(this,"_reverse"),R(this,"_set"),R(this,"_shift"),R(this,"_size"),R(this,"_slice"),R(this,"_some"),R(this,"_sort"),R(this,"_sort_indices"),R(this,"_standardize"),R(this,"_stdev"),R(this,"_sum"),R(this,"_unshift"),R(this,"_variance"),this._abs=mn(this.context),this._avg=dn(this.context),this._binary_search=gn(this.context),this._binary_search_leftmost=xn(this.context),this._binary_search_rightmost=yn(this.context),this._clear=wn(this.context),this._concat=bn(this.context),this._copy=vn(this.context),this._covariance=_n(this.context),this._every=Sn(this.context),this._fill=Nn(this.context),this._first=Cn(this.context),this._get=kn(this.context),this._includes=In(this.context),this._indexof=An(this.context),this._insert=Tn(this.context),this._join=Pn(this.context),this._last=Rn(this.context),this._lastindexof=Dn(this.context),this._max=Mn(this.context),this._median=On(this.context),this._min=Vn(this.context),this._mode=Ln(this.context),this._percentile_linear_interpolation=Bn(this.context),this._percentile_nearest_rank=Fn(this.context),this._percentrank=jn(this.context),this._pop=$n(this.context),this._push=Wn(this.context),this._range=qn(this.context),this._remove=Un(this.context),this._reverse=Kn(this.context),this._set=zn(this.context),this._shift=Hn(this.context),this._size=Gn(this.context),this._slice=Yn(this.context),this._some=Qn(this.context),this._sort=Zn(this.context),this._sort_indices=Jn(this.context),this._standardize=ea(this.context),this._stdev=ta(this.context),this._sum=ia(this.context),this._unshift=ra(this.context),this._variance=sa(this.context)}toString(){return"["+this.array.toString().replace(/,/g,", ")+"]"}abs(...t){return this._abs(this,...t)}avg(...t){return this._avg(this,...t)}binary_search(...t){return this._binary_search(this,...t)}binary_search_leftmost(...t){return this._binary_search_leftmost(this,...t)}binary_search_rightmost(...t){return this._binary_search_rightmost(this,...t)}clear(...t){return this._clear(this,...t)}concat(...t){return this._concat(this,...t)}copy(...t){return this._copy(this,...t)}covariance(...t){return this._covariance(this,...t)}every(...t){return this._every(this,...t)}fill(...t){return this._fill(this,...t)}first(...t){return this._first(this,...t)}get(...t){return this._get(this,...t)}includes(...t){return this._includes(this,...t)}indexof(...t){return this._indexof(this,...t)}insert(...t){return this._insert(this,...t)}join(...t){return this._join(this,...t)}last(...t){return this._last(this,...t)}lastindexof(...t){return this._lastindexof(this,...t)}max(...t){return this._max(this,...t)}median(...t){return this._median(this,...t)}min(...t){return this._min(this,...t)}mode(...t){return this._mode(this,...t)}percentile_linear_interpolation(...t){return this._percentile_linear_interpolation(this,...t)}percentile_nearest_rank(...t){return this._percentile_nearest_rank(this,...t)}percentrank(...t){return this._percentrank(this,...t)}pop(...t){return this._pop(this,...t)}push(...t){return this._push(this,...t)}range(...t){return this._range(this,...t)}remove(...t){return this._remove(this,...t)}reverse(...t){return this._reverse(this,...t)}set(...t){return this._set(this,...t)}shift(...t){return this._shift(this,...t)}size(...t){return this._size(this,...t)}slice(...t){return this._slice(this,...t)}some(...t){return this._some(this,...t)}sort(...t){return this._sort(this,...t)}sort_indices(...t){return this._sort_indices(this,...t)}standardize(...t){return this._standardize(this,...t)}stdev(...t){return this._stdev(this,...t)}sum(...t){return this._sum(this,...t)}unshift(...t){return this._unshift(this,...t)}variance(...t){return this._variance(this,...t)}}function oa(e){return(...t)=>new F([...t],En(t),e)}function ha(e){return(t,i)=>new F(Array(t).fill(e.precision(i||0)),xe(i||0),e)}function ca(e){return(t,i=!1)=>new F(Array(t).fill(i),W.bool,e)}function ua(e){return(t,i=NaN)=>new F(Array(t).fill(e.precision(i)),W.float,e)}function la(e){return(t,i=0)=>new F(Array(t).fill(e.precision(i)),W.int,e)}function pa(e){return(t,i="")=>new F(Array(t).fill(i),W.string,e)}class d{constructor(t,i=0){this.data=t,this.offset=i}get(t){const i=this.data.length-1-(this.offset+t);return i<0||i>=this.data.length?NaN:this.data[i]}set(t,i){const r=this.data.length-1-(this.offset+t);r>=0&&r<this.data.length&&(this.data[r]=i)}get length(){return this.data.length}toArray(){return this.data}static from(t){return t instanceof d?t:Array.isArray(t)?new d(t):new d([t])}}function fa(e){return(t,i=0)=>d.from(t).get(i)}class ma{constructor(t){this.context=t,this.abs=(i,...r)=>i.abs(...r),this.avg=(i,...r)=>i.avg(...r),this.binary_search=(i,...r)=>i.binary_search(...r),this.binary_search_leftmost=(i,...r)=>i.binary_search_leftmost(...r),this.binary_search_rightmost=(i,...r)=>i.binary_search_rightmost(...r),this.clear=(i,...r)=>i.clear(...r),this.concat=(i,...r)=>i.concat(...r),this.copy=(i,...r)=>i.copy(...r),this.covariance=(i,...r)=>i.covariance(...r),this.every=(i,...r)=>i.every(...r),this.fill=(i,...r)=>i.fill(...r),this.first=(i,...r)=>i.first(...r),this.from=oa(t),this.get=(i,...r)=>i.get(...r),this.includes=(i,...r)=>i.includes(...r),this.indexof=(i,...r)=>i.indexof(...r),this.insert=(i,...r)=>i.insert(...r),this.join=(i,...r)=>i.join(...r),this.last=(i,...r)=>i.last(...r),this.lastindexof=(i,...r)=>i.lastindexof(...r),this.max=(i,...r)=>i.max(...r),this.median=(i,...r)=>i.median(...r),this.min=(i,...r)=>i.min(...r),this.mode=(i,...r)=>i.mode(...r),this.new=ha(t),this.new_bool=ca(t),this.new_float=ua(t),this.new_int=la(t),this.new_string=pa(t),this.param=fa(),this.percentile_linear_interpolation=(i,...r)=>i.percentile_linear_interpolation(...r),this.percentile_nearest_rank=(i,...r)=>i.percentile_nearest_rank(...r),this.percentrank=(i,...r)=>i.percentrank(...r),this.pop=(i,...r)=>i.pop(...r),this.push=(i,...r)=>i.push(...r),this.range=(i,...r)=>i.range(...r),this.remove=(i,...r)=>i.remove(...r),this.reverse=(i,...r)=>i.reverse(...r),this.set=(i,...r)=>i.set(...r),this.shift=(i,...r)=>i.shift(...r),this.size=(i,...r)=>i.size(...r),this.slice=(i,...r)=>i.slice(...r),this.some=(i,...r)=>i.some(...r),this.sort=(i,...r)=>i.sort(...r),this.sort_indices=(i,...r)=>i.sort_indices(...r),this.standardize=(i,...r)=>i.standardize(...r),this.stdev=(i,...r)=>i.stdev(...r),this.sum=(i,...r)=>i.sum(...r),this.unshift=(i,...r)=>i.unshift(...r),this.variance=(i,...r)=>i.variance(...r)}}function da(e){return t=>{t.map.clear()}}function ga(e){return(t,i)=>t.map.has(i)}function xa(e){return t=>{const i=new xr(e);return i.map=new Map(t.map),i}}function ya(e){return(t,i)=>{const r=t.map.get(i);return r===void 0?NaN:r}}function wa(e){return t=>{const i=Array.from(t.map.keys()),r=xe(i[0]);return new F(i,r,e)}}function ba(e){return(t,i,r)=>{const s=t.map.get(i);return t.map.set(i,r),s===void 0?NaN:s}}function va(e){return(t,i)=>{for(const[r,s]of i.map)t.map.set(r,s)}}function _a(e){return(t,i)=>{const r=t.map.get(i);return t.map.delete(i)?r:NaN}}function Sa(e){return t=>t.map.size}function Ea(e){return t=>{const i=Array.from(t.map.values()),r=xe(i[0]);return new F(i,r,e)}}var Na=Object.defineProperty,Ca=(e,t,i)=>t in e?Na(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,me=(e,t,i)=>Ca(e,typeof t!="symbol"?t+"":t,i);class xr{constructor(t){this.context=t,me(this,"map"),me(this,"_clear"),me(this,"_contains"),me(this,"_copy"),me(this,"_get"),me(this,"_keys"),me(this,"_put"),me(this,"_put_all"),me(this,"_remove"),me(this,"_size"),me(this,"_values"),this.map=new Map,this._clear=da(this.context),this._contains=ga(this.context),this._copy=xa(this.context),this._get=ya(this.context),this._keys=wa(this.context),this._put=ba(this.context),this._put_all=va(this.context),this._remove=_a(this.context),this._size=Sa(this.context),this._values=Ea(this.context)}toString(){return`PineMapObject(${this.map.size})`}clear(...t){return this._clear(this,...t)}contains(...t){return this._contains(this,...t)}copy(...t){return this._copy(this,...t)}get(...t){return this._get(this,...t)}keys(...t){return this._keys(this,...t)}put(...t){return this._put(this,...t)}put_all(...t){return this._put_all(this,...t)}remove(...t){return this._remove(this,...t)}size(...t){return this._size(this,...t)}values(...t){return this._values(this,...t)}}function ka(e){return()=>new xr(e)}function Ia(e){return(t,i=0)=>d.from(t).get(i)}class Aa{constructor(t){this.context=t,this.clear=(i,...r)=>i.clear(...r),this.contains=(i,...r)=>i.contains(...r),this.copy=(i,...r)=>i.copy(...r),this.get=(i,...r)=>i.get(...r),this.keys=(i,...r)=>i.keys(...r),this.new=ka(t),this.param=Ia(),this.put=(i,...r)=>i.put(...r),this.put_all=(i,...r)=>i.put_all(...r),this.remove=(i,...r)=>i.remove(...r),this.size=(i,...r)=>i.size(...r),this.values=(i,...r)=>i.values(...r)}}function Ta(e){return(t,i,r)=>{const s=t.matrix.length;let n=[];if(r&&(r instanceof F?n=r.array:Array.isArray(r)?n=r:n=[r]),s===0){for(let h=0;h<n.length;h++){let c=n[h];c instanceof d&&(c=c.get(0)),t.matrix.push([c])}return}const a=t.matrix[0].length,o=i!==void 0?i:a;for(let h=0;h<s;h++){let c=h<n.length?n[h]:NaN;c instanceof d&&(c=c.get(0)),t.matrix[h].splice(o,0,c)}}}function Pa(e){return(t,i,r)=>{const s=t.matrix.length;let n=[];if(r)if(r instanceof F)n=r.array;else if(Array.isArray(r))n=r;else if(r instanceof d){const c=r.get(0);Array.isArray(c)?n=c:n=[c]}else n=[r];const a=s>0?t.matrix[0].length:n.length,o=i!==void 0?i:s,h=[];for(let c=0;c<a;c++)if(c<n.length){let l=n[c];l instanceof d&&(l=l.get(0)),h.push(l)}else h.push(NaN);t.matrix.splice(o,0,h)}}function Ra(e){return t=>{const i=t.matrix.length;if(i===0)return NaN;const r=t.matrix[0].length;if(r===0)return NaN;let s=0,n=0;for(let a=0;a<i;a++)for(let o=0;o<r;o++){const h=t.matrix[a][o];isNaN(h)||(s+=h,n++)}return n===0?NaN:s/n}}function Da(e){return(t,i)=>{const r=t.matrix.length,s=[];for(let a=0;a<r;a++)s.push(t.matrix[a][i]);const n=xe(s[0]);return new F(s,n,e)}}function Ma(e){return t=>t.matrix.length===0?0:t.matrix[0].length}function Oa(e){return(t,i)=>{const r=t.matrix.length,s=i.matrix.length;if(r===0){for(let o=0;o<s;o++)t.matrix.push([...i.matrix[o]]);return}const n=t.matrix[0].length,a=s>0?i.matrix[0].length:0;if(n!==a&&s>0){console.error(`matrix.concat: Column count mismatch ${n} vs ${a}`);return}for(let o=0;o<s;o++)t.matrix.push([...i.matrix[o]])}}function Va(e){return t=>{const i=t.matrix.length,r=i>0?t.matrix[0].length:0,s=new L(i,r,NaN,e);return s.matrix=t.matrix.map(n=>[...n]),s}}function La(e){const t=e.length;if(t===0)return 0;if(t===1)return e[0][0];if(t===2)return e[0][0]*e[1][1]-e[0][1]*e[1][0];const i=e.map(s=>[...s]);let r=1;for(let s=0;s<t;s++){let n=s;for(;n<t&&i[n][s]===0;)n++;if(n===t)return 0;n!==s&&([i[s],i[n]]=[i[n],i[s]],r*=-1),r*=i[s][s];for(let a=s+1;a<t;a++){const o=i[a][s]/i[s][s];for(let h=s;h<t;h++)i[a][h]-=o*i[s][h]}}return r}function Ba(e){return t=>{const i=t.matrix.length,r=i>0?t.matrix[0].length:0;return i!==r?NaN:La(t.matrix)}}function Fa(e){return(t,i)=>{const r=t.matrix.length;if(r===0)return new L(0,0,NaN,e);const s=t.matrix[0].length,n=new L(r,s,NaN,e);if(i instanceof L)for(let a=0;a<r;a++)for(let o=0;o<s;o++){const h=t.matrix[a][o],c=i.matrix[a]&&i.matrix[a][o]!==void 0?i.matrix[a][o]:NaN;n.matrix[a][o]=h-c}else{const a=i;for(let o=0;o<r;o++)for(let h=0;h<s;h++)n.matrix[o][h]=t.matrix[o][h]-a}return n}}function ja(e){const t=e.length;if(t!==2)return Array(t).fill(NaN);const i=e[0][0],r=e[0][1],s=e[1][0],n=e[1][1],a=i+n,o=i*n-r*s,h=a*a-4*o;if(h<0)return[NaN,NaN];const c=(a+Math.sqrt(h))/2,l=(a-Math.sqrt(h))/2;return[c,l]}function $a(e){return t=>{const i=t.matrix.length,r=i>0?t.matrix[0].length:0;if(i!==r){const a=xe(t.matrix[0][0]);return new F([],a,e)}const s=ja(t.matrix),n=xe(s[0]);return new F(s,n,e)}}function Wa(e){return t=>{const i=t.matrix.length,r=i>0?t.matrix[0].length:0;if(i!==r)return new L(0,0,NaN,e);const s=new L(i,r,0,e);for(let n=0;n<i;n++)s.matrix[n][n]=1;return s}}function qa(e){return t=>{const i=t.matrix.length;return i===0?0:i*t.matrix[0].length}}function Ua(e){return(t,i,r,s,n,a)=>{const o=t.matrix.length;if(o===0)return;const h=t.matrix[0].length,c=r!==void 0?r:0,l=s!==void 0?s:o,f=n!==void 0?n:0,g=a!==void 0?a:h;for(let p=c;p<l&&!(p>=o);p++)for(let x=f;x<g&&!(x>=h);x++)t.matrix[p][x]=i}}function Ka(e){return(t,i,r)=>{if(!t.matrix[i])return NaN;const s=t.matrix[i][r];return s===void 0?NaN:s}}function za(e){if(e.length!==2)return e.map(i=>i.map(()=>NaN));const t=e[0][0]*e[1][1]-e[0][1]*e[1][0];return t===0?[[NaN,NaN],[NaN,NaN]]:[[e[1][1]/t,-e[0][1]/t],[-e[1][0]/t,e[0][0]/t]]}function Ha(e){return t=>{const i=t.matrix.length,r=i>0?t.matrix[0].length:0;if(i!==r)return new L(i,r,NaN,e);const s=za(t.matrix),n=new L(i,r,NaN,e);return n.matrix=s,n}}function Ga(e){return t=>{const i=t.matrix.length;if(i===0)return!1;const r=t.matrix[0].length;if(i!==r)return!1;for(let s=0;s<i;s++)for(let n=0;n<r;n++)if(s+n!==i-1&&t.matrix[s][n]!==0)return!1;return!0}}function Ya(e){return t=>{const i=t.matrix.length;if(i===0)return!1;const r=t.matrix[0].length;if(i!==r)return!1;for(let s=0;s<i;s++)for(let n=0;n<r;n++)if(t.matrix[n][s]!==-t.matrix[s][n])return!1;return!0}}function Qa(e){return t=>{const i=t.matrix.length;if(i===0)return!1;const r=t.matrix[0].length;for(let s=0;s<i;s++)for(let n=0;n<r;n++){const a=t.matrix[s][n];if(a!==0&&a!==1)return!1}return!0}}function Xa(e){return t=>{const i=t.matrix.length;if(i===0)return!1;const r=t.matrix[0].length;if(i!==r)return!1;for(let s=0;s<i;s++)for(let n=0;n<r;n++)if(s!==n&&t.matrix[s][n]!==0)return!1;return!0}}function Za(e){return t=>{const i=t.matrix.length;if(i===0)return!1;const r=t.matrix[0].length;if(i!==r)return!1;for(let s=0;s<i;s++)for(let n=0;n<r;n++)if(s===n){if(t.matrix[s][n]!==1)return!1}else if(t.matrix[s][n]!==0)return!1;return!0}}function Ja(e){return t=>{const i=t.matrix.length;if(i===0)return!1;const r=t.matrix[0].length;return i===r}}function eo(e){return t=>{const i=t.matrix.length;if(i===0)return!1;const r=t.matrix[0].length;for(let s=0;s<i;s++){let n=0;for(let a=0;a<r;a++){const o=t.matrix[s][a];if(o<0)return!1;n+=o}if(Math.abs(n-1)>1e-10)return!1}return!0}}function to(e){return t=>{const i=t.matrix.length;if(i===0)return!1;const r=t.matrix[0].length;if(i!==r)return!1;for(let s=0;s<i;s++)for(let n=0;n<s;n++)if(t.matrix[s][n]!==t.matrix[n][s])return!1;return!0}}function io(e){return t=>{const i=t.matrix.length;if(i===0)return!1;const r=t.matrix[0].length;if(i!==r)return!1;let s=!0,n=!0;for(let a=0;a<i;a++)for(let o=0;o<r;o++)a>o&&t.matrix[a][o]!==0&&(s=!1),a<o&&t.matrix[a][o]!==0&&(n=!1);return s||n}}function ro(e){return t=>{const i=t.matrix.length;if(i===0)return!0;const r=t.matrix[0].length;for(let s=0;s<i;s++)for(let n=0;n<r;n++)if(t.matrix[s][n]!==0)return!1;return!0}}function so(e){return(t,i)=>{const r=t.matrix.length,s=r>0?t.matrix[0].length:0,n=i.matrix.length,a=n>0?i.matrix[0].length:0,o=r*n,h=s*a,c=new L(o,h,NaN,e);for(let l=0;l<r;l++)for(let f=0;f<s;f++){const g=t.matrix[l][f];for(let p=0;p<n;p++)for(let x=0;x<a;x++){const y=i.matrix[p][x];c.matrix[l*n+p][f*a+x]=g*y}}return c}}function no(e){return t=>{const i=t.matrix.length;if(i===0)return NaN;const r=t.matrix[0].length;let s=-1/0,n=!1;for(let a=0;a<i;a++)for(let o=0;o<r;o++){const h=t.matrix[a][o];isNaN(h)||(h>s&&(s=h),n=!0)}return n?s:NaN}}function ao(e){return t=>{const i=t.matrix.length;if(i===0)return NaN;const r=t.matrix[0].length,s=[];for(let a=0;a<i;a++)for(let o=0;o<r;o++){const h=t.matrix[a][o];isNaN(h)||s.push(h)}if(s.length===0)return NaN;s.sort((a,o)=>a-o);const n=Math.floor(s.length/2);return s.length%2!==0?s[n]:(s[n-1]+s[n])/2}}function oo(e){return t=>{const i=t.matrix.length;if(i===0)return NaN;const r=t.matrix[0].length;let s=1/0,n=!1;for(let a=0;a<i;a++)for(let o=0;o<r;o++){const h=t.matrix[a][o];isNaN(h)||(h<s&&(s=h),n=!0)}return n?s:NaN}}function ho(e){return t=>{const i=t.matrix.length;if(i===0)return NaN;const r=t.matrix[0].length,s=new Map;let n=0,a=NaN;for(let o=0;o<i;o++)for(let h=0;h<r;h++){const c=t.matrix[o][h];if(!isNaN(c)){const l=(s.get(c)||0)+1;s.set(c,l),l>n?(n=l,a=c):l===n&&c<a&&(a=c)}}return a}}function co(e){return(t,i)=>{const r=t.matrix.length,s=r>0?t.matrix[0].length:0;if(i instanceof L){const n=i.matrix.length,a=n>0?i.matrix[0].length:0;if(s!==n)return new L(0,0,NaN,e);const o=new L(r,a,0,e);for(let h=0;h<r;h++)for(let c=0;c<a;c++){let l=0;for(let f=0;f<s;f++)l+=t.matrix[h][f]*i.matrix[f][c];o.matrix[h][c]=l}return o}else if(i instanceof F||Array.isArray(i.array||i)){const n=i.array||i;if(s!==n.length)return new L(0,0,NaN,e);const a=new L(r,1,0,e);for(let o=0;o<r;o++){let h=0;for(let c=0;c<s;c++)h+=t.matrix[o][c]*n[c];a.matrix[o][0]=h}return a}else{const n=i,a=new L(r,s,NaN,e);for(let o=0;o<r;o++)for(let h=0;h<s;h++)a.matrix[o][h]=t.matrix[o][h]*n;return a}}}function uo(e){return t=>{const i=t.matrix.length,r=i>0?t.matrix[0].length:0;return i===r?new L(i,r,NaN,e):new L(r,i,NaN,e)}}function lo(e){return(t,i)=>{const r=t.matrix.length,s=r>0?t.matrix[0].length:0;if(r!==s)return new L(0,0,NaN,e);let n=new L(r,s,0,e);for(let h=0;h<r;h++)n.matrix[h][h]=1;let a=new L(r,s,NaN,e);for(let h=0;h<r;h++)a.matrix[h]=[...t.matrix[h]];let o=Math.floor(i);if(o<0)return new L(r,s,NaN,e);for(;o>0;){if(o%2===1){const c=new L(r,s,0,e);for(let l=0;l<r;l++)for(let f=0;f<s;f++){let g=0;for(let p=0;p<r;p++)g+=n.matrix[l][p]*a.matrix[p][f];c.matrix[l][f]=g}n=c}const h=new L(r,s,0,e);for(let c=0;c<r;c++)for(let l=0;l<s;l++){let f=0;for(let g=0;g<r;g++)f+=a.matrix[c][g]*a.matrix[g][l];h.matrix[c][l]=f}a=h,o=Math.floor(o/2)}return n}}function po(e){return t=>{const i=t.matrix.length;if(i===0)return 0;const r=t.matrix[0].length,s=t.matrix.map(a=>[...a]);let n=0;for(let a=0;a<r&&n<i;a++){let o=n;for(;o<i&&Math.abs(s[o][a])<1e-10;)o++;if(o<i){[s[n],s[o]]=[s[o],s[n]];const h=s[n][a];for(let c=a;c<r;c++)s[n][c]/=h;for(let c=0;c<i;c++)if(c!==n){const l=s[c][a];for(let f=a;f<r;f++)s[c][f]-=l*s[n][f]}n++}}return n}}function fo(e){return(t,i)=>{const r=t.matrix.length;if(r===0){const a=xe(t.matrix[0][0]);return new F([],a,e)}const s=[];for(let a=0;a<r;a++){const o=t.matrix[a].splice(i,1);s.push(o[0])}const n=xe(s[0]);return new F(s,n,e)}}function mo(e){return(t,i)=>{const r=t.matrix.splice(i,1),s=xe(r[0][0]);return new F(r[0]||[],s,e)}}function go(e){return(t,i,r)=>{const s=t.matrix.length,n=s>0?t.matrix[0].length:0,a=i*r,o=[];for(let l=0;l<s;l++)for(let f=0;f<n;f++)o.push(t.matrix[l][f]);for(;o.length<a;)o.push(NaN);o.length>a&&(o.length=a);const h=[];let c=0;for(let l=0;l<i;l++){const f=[];for(let g=0;g<r;g++)f.push(o[c++]);h.push(f)}t.matrix=h}}function xo(e){return t=>{t.matrix.reverse();for(const i of t.matrix)i.reverse()}}function yo(e){return(t,i)=>{if(!t.matrix[i]){const s=xe(t.matrix[0][0]);return new F([],s,e)}const r=xe(t.matrix[i][0]);return new F([...t.matrix[i]],r,e)}}function wo(e){return t=>t.matrix.length}function bo(e){return(t,i,r,s)=>{t.matrix[i]&&(t.matrix[i][r]=s)}}function vo(e){return(t,i=0,r="asc")=>{t.matrix.length!==0&&t.matrix.sort((s,n)=>{const a=s[i],o=n[i];return a<o?r==="asc"?-1:1:a>o?r==="asc"?1:-1:0})}}function _o(e){return(t,i,r,s,n)=>{const a=r-i,o=n-s,h=new L(a,o,NaN,e);for(let c=0;c<a;c++){const l=i+c;if(l>=t.matrix.length)break;for(let f=0;f<o;f++){const g=s+f;if(g>=t.matrix[l].length)break;h.matrix[c][f]=t.matrix[l][g]}}return h}}function So(e){return(t,i)=>{const r=t.matrix.length;if(r===0)return new L(0,0,NaN,e);const s=t.matrix[0].length,n=new L(r,s,NaN,e);if(i instanceof L)for(let a=0;a<r;a++)for(let o=0;o<s;o++){const h=t.matrix[a][o],c=i.matrix[a]&&i.matrix[a][o]!==void 0?i.matrix[a][o]:NaN;n.matrix[a][o]=h+c}else{const a=i;for(let o=0;o<r;o++)for(let h=0;h<s;h++)n.matrix[o][h]=t.matrix[o][h]+a}return n}}function Eo(e){return(t,i,r)=>{const s=t.matrix.length;for(let n=0;n<s;n++){const a=t.matrix[n][i];t.matrix[n][i]=t.matrix[n][r],t.matrix[n][r]=a}}}function No(e){return(t,i,r)=>{const s=t.matrix[i];t.matrix[i]=t.matrix[r],t.matrix[r]=s}}function Co(e){return t=>{const i=t.matrix.length;if(i===0)return 0;const r=t.matrix[0].length,s=Math.min(i,r);let n=0;for(let a=0;a<s;a++)n+=t.matrix[a][a];return n}}function ko(e){return t=>{const i=t.matrix.length;if(i===0)return new L(0,0,NaN,e);const r=t.matrix[0].length,s=new L(r,i,NaN,e);for(let n=0;n<i;n++)for(let a=0;a<r;a++)s.matrix[a][n]=t.matrix[n][a];return s}}var Io=Object.defineProperty,Ao=(e,t,i)=>t in e?Io(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,I=(e,t,i)=>Ao(e,typeof t!="symbol"?t+"":t,i);class L{constructor(t=0,i=0,r=NaN,s){if(this.context=s,I(this,"matrix"),I(this,"_add_col"),I(this,"_add_row"),I(this,"_avg"),I(this,"_col"),I(this,"_columns"),I(this,"_concat"),I(this,"_copy"),I(this,"_det"),I(this,"_diff"),I(this,"_eigenvalues"),I(this,"_eigenvectors"),I(this,"_elements_count"),I(this,"_fill"),I(this,"_get"),I(this,"_inv"),I(this,"_is_antidiagonal"),I(this,"_is_antisymmetric"),I(this,"_is_binary"),I(this,"_is_diagonal"),I(this,"_is_identity"),I(this,"_is_square"),I(this,"_is_stochastic"),I(this,"_is_symmetric"),I(this,"_is_triangular"),I(this,"_is_zero"),I(this,"_kron"),I(this,"_max"),I(this,"_median"),I(this,"_min"),I(this,"_mode"),I(this,"_mult"),I(this,"_pinv"),I(this,"_pow"),I(this,"_rank"),I(this,"_remove_col"),I(this,"_remove_row"),I(this,"_reshape"),I(this,"_reverse"),I(this,"_row"),I(this,"_rows"),I(this,"_set"),I(this,"_sort"),I(this,"_submatrix"),I(this,"_sum"),I(this,"_swap_columns"),I(this,"_swap_rows"),I(this,"_trace"),I(this,"_transpose"),this.matrix=[],t>0&&i>0)for(let n=0;n<t;n++)this.matrix.push(Array(i).fill(r));this._add_col=Ta(this.context),this._add_row=Pa(this.context),this._avg=Ra(this.context),this._col=Da(this.context),this._columns=Ma(this.context),this._concat=Oa(this.context),this._copy=Va(this.context),this._det=Ba(this.context),this._diff=Fa(this.context),this._eigenvalues=$a(this.context),this._eigenvectors=Wa(this.context),this._elements_count=qa(this.context),this._fill=Ua(this.context),this._get=Ka(this.context),this._inv=Ha(this.context),this._is_antidiagonal=Ga(this.context),this._is_antisymmetric=Ya(this.context),this._is_binary=Qa(this.context),this._is_diagonal=Xa(this.context),this._is_identity=Za(this.context),this._is_square=Ja(this.context),this._is_stochastic=eo(this.context),this._is_symmetric=to(this.context),this._is_triangular=io(this.context),this._is_zero=ro(this.context),this._kron=so(this.context),this._max=no(this.context),this._median=ao(this.context),this._min=oo(this.context),this._mode=ho(this.context),this._mult=co(this.context),this._pinv=uo(this.context),this._pow=lo(this.context),this._rank=po(this.context),this._remove_col=fo(this.context),this._remove_row=mo(this.context),this._reshape=go(this.context),this._reverse=xo(this.context),this._row=yo(this.context),this._rows=wo(this.context),this._set=bo(this.context),this._sort=vo(this.context),this._submatrix=_o(this.context),this._sum=So(this.context),this._swap_columns=Eo(this.context),this._swap_rows=No(this.context),this._trace=Co(this.context),this._transpose=ko(this.context)}toString(){let t="";for(let i=0;i<this.matrix.length;i++)t+=t===""?"":`
|
|
116
|
+
`,t+="["+this.matrix[i].join(", ")+"]";return t}add_col(...t){return this._add_col(this,...t)}add_row(...t){return this._add_row(this,...t)}avg(...t){return this._avg(this,...t)}col(...t){return this._col(this,...t)}columns(...t){return this._columns(this,...t)}concat(...t){return this._concat(this,...t)}copy(...t){return this._copy(this,...t)}det(...t){return this._det(this,...t)}diff(...t){return this._diff(this,...t)}eigenvalues(...t){return this._eigenvalues(this,...t)}eigenvectors(...t){return this._eigenvectors(this,...t)}elements_count(...t){return this._elements_count(this,...t)}fill(...t){return this._fill(this,...t)}get(...t){return this._get(this,...t)}inv(...t){return this._inv(this,...t)}is_antidiagonal(...t){return this._is_antidiagonal(this,...t)}is_antisymmetric(...t){return this._is_antisymmetric(this,...t)}is_binary(...t){return this._is_binary(this,...t)}is_diagonal(...t){return this._is_diagonal(this,...t)}is_identity(...t){return this._is_identity(this,...t)}is_square(...t){return this._is_square(this,...t)}is_stochastic(...t){return this._is_stochastic(this,...t)}is_symmetric(...t){return this._is_symmetric(this,...t)}is_triangular(...t){return this._is_triangular(this,...t)}is_zero(...t){return this._is_zero(this,...t)}kron(...t){return this._kron(this,...t)}max(...t){return this._max(this,...t)}median(...t){return this._median(this,...t)}min(...t){return this._min(this,...t)}mode(...t){return this._mode(this,...t)}mult(...t){return this._mult(this,...t)}pinv(...t){return this._pinv(this,...t)}pow(...t){return this._pow(this,...t)}rank(...t){return this._rank(this,...t)}remove_col(...t){return this._remove_col(this,...t)}remove_row(...t){return this._remove_row(this,...t)}reshape(...t){return this._reshape(this,...t)}reverse(...t){return this._reverse(this,...t)}row(...t){return this._row(this,...t)}rows(...t){return this._rows(this,...t)}set(...t){return this._set(this,...t)}sort(...t){return this._sort(this,...t)}submatrix(...t){return this._submatrix(this,...t)}sum(...t){return this._sum(this,...t)}swap_columns(...t){return this._swap_columns(this,...t)}swap_rows(...t){return this._swap_rows(this,...t)}trace(...t){return this._trace(this,...t)}transpose(...t){return this._transpose(this,...t)}}function To(e){return(t,i,r)=>new L(t,i,r,e)}function Po(e){return(t,i=0)=>d.from(t).get(i)}class Ro{constructor(t){this.context=t,this.add_col=(i,...r)=>i.add_col(...r),this.add_row=(i,...r)=>i.add_row(...r),this.avg=(i,...r)=>i.avg(...r),this.col=(i,...r)=>i.col(...r),this.columns=(i,...r)=>i.columns(...r),this.concat=(i,...r)=>i.concat(...r),this.copy=(i,...r)=>i.copy(...r),this.det=(i,...r)=>i.det(...r),this.diff=(i,...r)=>i.diff(...r),this.eigenvalues=(i,...r)=>i.eigenvalues(...r),this.eigenvectors=(i,...r)=>i.eigenvectors(...r),this.elements_count=(i,...r)=>i.elements_count(...r),this.fill=(i,...r)=>i.fill(...r),this.get=(i,...r)=>i.get(...r),this.inv=(i,...r)=>i.inv(...r),this.is_antidiagonal=(i,...r)=>i.is_antidiagonal(...r),this.is_antisymmetric=(i,...r)=>i.is_antisymmetric(...r),this.is_binary=(i,...r)=>i.is_binary(...r),this.is_diagonal=(i,...r)=>i.is_diagonal(...r),this.is_identity=(i,...r)=>i.is_identity(...r),this.is_square=(i,...r)=>i.is_square(...r),this.is_stochastic=(i,...r)=>i.is_stochastic(...r),this.is_symmetric=(i,...r)=>i.is_symmetric(...r),this.is_triangular=(i,...r)=>i.is_triangular(...r),this.is_zero=(i,...r)=>i.is_zero(...r),this.kron=(i,...r)=>i.kron(...r),this.max=(i,...r)=>i.max(...r),this.median=(i,...r)=>i.median(...r),this.min=(i,...r)=>i.min(...r),this.mode=(i,...r)=>i.mode(...r),this.mult=(i,...r)=>i.mult(...r),this.new=To(t),this.param=Po(),this.pinv=(i,...r)=>i.pinv(...r),this.pow=(i,...r)=>i.pow(...r),this.rank=(i,...r)=>i.rank(...r),this.remove_col=(i,...r)=>i.remove_col(...r),this.remove_row=(i,...r)=>i.remove_row(...r),this.reshape=(i,...r)=>i.reshape(...r),this.reverse=(i,...r)=>i.reverse(...r),this.row=(i,...r)=>i.row(...r),this.rows=(i,...r)=>i.rows(...r),this.set=(i,...r)=>i.set(...r),this.sort=(i,...r)=>i.sort(...r),this.submatrix=(i,...r)=>i.submatrix(...r),this.sum=(i,...r)=>i.sum(...r),this.swap_columns=(i,...r)=>i.swap_columns(...r),this.swap_rows=(i,...r)=>i.swap_rows(...r),this.trace=(i,...r)=>i.trace(...r),this.transpose=(i,...r)=>i.transpose(...r)}}var Do=Object.defineProperty,Mo=(e,t,i)=>t in e?Do(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Oo=(e,t,i)=>Mo(e,typeof t!="symbol"?t+"":t,i);class Vo{constructor(t){this.context=t,Oo(this,"_live",!1)}setLive(){this._live=!0}get isnew(){return!this._live}get islast(){return this.context.idx===this.context.data.close.data.length-1}get isfirst(){return this.context.idx===0}get ishistory(){return this.context.idx<this.context.data.close.data.length-1}get isrealtime(){return this.context.idx===this.context.data.close.data.length-1}get isconfirmed(){return this.context.data.closeTime[this.context.data.closeTime.length-1]<=new Date().getTime()}get islastconfirmedhistory(){return this.context.data.closeTime[this.context.data.closeTime.length-1]<=new Date().getTime()}}const wi={series:e=>e instanceof d||typeof e=="number",string:e=>typeof e=="string",number:e=>typeof e=="number",boolean:e=>typeof e=="boolean",array:e=>Array.isArray(e),object:e=>typeof e=="object",primitive:e=>typeof e===null||typeof e!="object"&&typeof e!="function",function:e=>typeof e=="function",undefined:e=>e===void 0,null:e=>e===null,NaN:e=>isNaN(e),remaining_options:e=>typeof e=="object"&&!(e instanceof d)};function Qt(e,t,i){Array.isArray(t)&&typeof t[0]=="string"&&(t=[t]);const r={};let s={};const n=new Array(t.length).fill(!0);for(let a=0;a<e.length;a++){const o=e[a];if(wi.remaining_options(o)){s=o;break}const h=t.map((c,l)=>n[l]?c[a]:void 0);for(let c=0;c<h.length;c++){const l=h[c];if(l===void 0){n[c]=!1;continue}const f=wi[i[l]];typeof f=="function"&&f(o)?r[l]=o:n[c]=!1}}return{...s,...r}}var Lo=Object.defineProperty,Bo=(e,t,i)=>t in e?Lo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Fo=(e,t,i)=>Bo(e,typeof t!="symbol"?t+"":t,i);const jo=["title","shorttitle","overlay","format","precision","scale","max_bars_back","timeframe","timeframe_gaps","explicit_plot_zorder","max_lines_count","max_labels_count","max_boxes_count","calc_bars_count","max_polylines_count","dynamic_requests","behind_chart"],$o={title:"string",shorttitle:"string",overlay:"boolean",format:"string",precision:"number",scale:"string",max_bars_back:"number",timeframe:"string",timeframe_gaps:"boolean",explicit_plot_zorder:"boolean",max_lines_count:"number",max_labels_count:"number",max_boxes_count:"number",calc_bars_count:"number",max_polylines_count:"number",dynamic_requests:"boolean",behind_chart:"boolean"};function Wo(e){return Qt(e,jo,$o)}class qo{constructor(t){this.context=t,Fo(this,"color",{param:(i,r=0)=>d.from(i).get(r),rgb:(i,r,s,n)=>n?`rgba(${i}, ${r}, ${s}, ${n})`:`rgb(${i}, ${r}, ${s})`,new:(i,r)=>{if(i&&i.startsWith("#")){const s=i.slice(1),n=parseInt(s.slice(0,2),16),a=parseInt(s.slice(2,4),16),o=parseInt(s.slice(4,6),16);return r?`rgba(${n}, ${a}, ${o}, ${r})`:`rgb(${n}, ${a}, ${o})`}return r?`rgba(${i}, ${r})`:i},white:"white",lime:"lime",green:"green",red:"red",maroon:"maroon",black:"black",gray:"gray",blue:"blue",yellow:"yellow",orange:"orange",purple:"purple",pink:"pink",brown:"brown",teal:"teal",cyan:"cyan",navy:"navy",indigo:"indigo",violet:"violet",magenta:"magenta",rose:"rose",gold:"gold",silver:"silver",bronze:"bronze"})}extractPlotOptions(t){const i={};for(let r in t)i[r]=d.from(t[r]).get(0);return i}indicator(...t){const i=Wo(t),r={title:"",shorttitle:"",overlay:!1,format:"inherit",precision:10,scale:"points",max_bars_back:0,timeframe:"",timeframe_gaps:!0,explicit_plot_zorder:!1,max_lines_count:50,max_labels_count:50,max_boxes_count:50,calc_bars_count:0,max_polylines_count:50,dynamic_requests:!1,behind_chart:!0};return this.context.indicator={...r,...i},this.context.indicator}get bar_index(){return this.context.idx}na(t){return isNaN(d.from(t).get(0))}nz(t,i=0){const r=d.from(t).get(0),s=d.from(i).get(0);return isNaN(r)?s:r}fixnan(t){const i=d.from(t);for(let r=0;r<i.length;r++){const s=i.get(r);if(!isNaN(s))return s}return NaN}alertcondition(t,i,r){}bool(t){const i=d.from(t).get(0);return!isNaN(i)&&i!==0}int(t){const i=d.from(t).get(0);if(typeof i!="number")throw new Error(`Cannot call "int" with argument "x"="${i}". An argument of "literal string" type was used but a "simple int" is expected.`);return Math.floor(i)}float(t){const i=d.from(t).get(0);if(typeof i!="number")throw new Error(`Cannot call "float" with argument "x"="${i}". An argument of "literal string" type was used but a "const float" is expected.`);return i}string(t){return d.from(t).get(0).toString()}}const Uo=[["defval","title","tooltip","inline","group","display"],["defval","title","tooltip","group","confirm","display"],["defval","title","tooltip","inline","group","confirm","display"],["defval","title","options","tooltip","inline","group","confirm","display"],["defval","title","minval","maxval","step","tooltip","inline","group","confirm","display"]],Ko={defval:"primitive",title:"string",tooltip:"string",inline:"string",group:"string",display:"string",confirm:"boolean",options:"array",minval:"number",maxval:"number",step:"number"};function re(e){return Qt(e,Uo,Ko)}function zo(e){return(...t)=>re(t).defval}function Ho(e){return(...t)=>re(t).defval}function Go(e){return(...t)=>re(t).defval}function Yo(e){return(...t)=>re(t).defval}function Qo(e){return(...t)=>re(t).defval}function Xo(e){return(...t)=>re(t).defval}function Zo(e){return(t,i=0)=>d.from(t).get(i)}function Jo(e){return(...t)=>re(t).defval}function eh(e){return(...t)=>re(t).defval}function th(e){return(...t)=>re(t).defval}function ih(e){return(...t)=>re(t).defval}function rh(e){return(...t)=>re(t).defval}function sh(e){return(...t)=>re(t).defval}function nh(e){return(...t)=>re(t).defval}function ah(e){return(...t)=>re(t).defval}var oh=Object.defineProperty,hh=(e,t,i)=>t in e?oh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Z=(e,t,i)=>hh(e,typeof t!="symbol"?t+"":t,i);const ch={any:zo,bool:Ho,color:Go,enum:Yo,float:Qo,int:Xo,param:Zo,price:Jo,session:eh,source:th,string:ih,symbol:rh,text_area:sh,time:nh,timeframe:ah};class uh{constructor(t){this.context=t,Z(this,"any"),Z(this,"bool"),Z(this,"color"),Z(this,"enum"),Z(this,"float"),Z(this,"int"),Z(this,"param"),Z(this,"price"),Z(this,"session"),Z(this,"source"),Z(this,"string"),Z(this,"symbol"),Z(this,"text_area"),Z(this,"time"),Z(this,"timeframe"),Object.entries(ch).forEach(([i,r])=>{this[i]=r(t)})}}function lh(e){return t=>Math.abs(d.from(t).get(0))}function ph(e){return t=>Math.acos(d.from(t).get(0))}function fh(e){return t=>Math.asin(d.from(t).get(0))}function mh(e){return t=>Math.atan(d.from(t).get(0))}function dh(e){return(...t)=>{const i=t.map(r=>d.from(r).get(0));return i.reduce((r,s)=>r+s,0)/i.length}}function gh(e){return t=>Math.ceil(d.from(t).get(0))}function xh(e){return t=>Math.cos(d.from(t).get(0))}function yh(e){return()=>Math.E}function wh(e){return t=>Math.exp(d.from(t).get(0))}function bh(e){return t=>Math.floor(d.from(t).get(0))}function vh(e){return t=>Math.log(d.from(t).get(0))}function _h(e){return t=>Math.log(d.from(t).get(0))}function Sh(e){return t=>Math.log10(d.from(t).get(0))}function Eh(e){return(...t)=>{const i=t.map(r=>d.from(r).get(0));return Math.max(...i)}}function Nh(e){return(...t)=>{const i=t.map(r=>d.from(r).get(0));return Math.min(...i)}}function Ch(e){return(t,i,r)=>typeof t=="string"?t:t instanceof d?i?new d(t.data,t.offset+i):t:!Array.isArray(t)&&typeof t=="object"?t:(e.params[r]||(e.params[r]=[]),Array.isArray(t)?new d(t,i||0):(e.params[r].length===0?e.params[r].push(t):e.params[r][e.params[r].length-1]=t,new d(e.params[r],0)))}function kh(e){return()=>1.618033988749895}function Ih(e){return()=>Math.PI}function Ah(e){return(t,i)=>Math.pow(d.from(t).get(0),d.from(i).get(0))}function Th(e){return()=>Math.random()}function Ph(e){return t=>Math.round(d.from(t).get(0))}function Rh(e){return t=>e.precision(Math.round(d.from(t).get(0)/e.pine.syminfo.mintick)*e.pine.syminfo.mintick)}function Dh(e){return()=>.6180339887498948}function Mh(e){return t=>Math.sign(d.from(t).get(0))}function Oh(e){return t=>Math.sin(d.from(t).get(0))}function Vh(e){return t=>Math.sqrt(d.from(t).get(0))}function Lh(e){return(t,i)=>{const r=d.from(i).get(0),s=d.from(t);let n=0;for(let a=0;a<r;a++){const o=s.get(a);n+=o}return n}}function Bh(e){return t=>Math.tan(d.from(t).get(0))}function Fh(e){return(t,i)=>{const r=d.from(t).get(0),s=d.from(i).get(0);return typeof r=="number"&&typeof s=="number"?isNaN(r)&&isNaN(s)?!0:isNaN(r)||isNaN(s)?!1:Math.abs(r-s)<1e-8:r===s}}var jh=Object.defineProperty,$h=(e,t,i)=>t in e?jh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,V=(e,t,i)=>$h(e,typeof t!="symbol"?t+"":t,i);const Wh={abs:lh,acos:ph,asin:fh,atan:mh,avg:dh,ceil:gh,cos:xh,e:yh,exp:wh,floor:bh,ln:vh,log:_h,log10:Sh,max:Eh,min:Nh,param:Ch,phi:kh,pi:Ih,pow:Ah,random:Th,round:Ph,round_to_mintick:Rh,rphi:Dh,sign:Mh,sin:Oh,sqrt:Vh,sum:Lh,tan:Bh,__eq:Fh};class qh{constructor(t){this.context=t,V(this,"_cache",{}),V(this,"abs"),V(this,"acos"),V(this,"asin"),V(this,"atan"),V(this,"avg"),V(this,"ceil"),V(this,"cos"),V(this,"e"),V(this,"exp"),V(this,"floor"),V(this,"ln"),V(this,"log"),V(this,"log10"),V(this,"max"),V(this,"min"),V(this,"param"),V(this,"phi"),V(this,"pi"),V(this,"pow"),V(this,"random"),V(this,"round"),V(this,"round_to_mintick"),V(this,"rphi"),V(this,"sign"),V(this,"sin"),V(this,"sqrt"),V(this,"sum"),V(this,"tan"),V(this,"__eq"),Object.entries(Wh).forEach(([i,r])=>{this[i]=r(t)})}}function Uh(e){return(t,i,r)=>{e.params[r]||(e.params[r]=[]);let s;if(t instanceof d)s=t.get(i||0);else if(Array.isArray(t)){const n=t.every(o=>o instanceof d),a=t.every(o=>!(o instanceof d)&&!Array.isArray(o));(n||a)&&t.length>=1?n?s=t.map(o=>o.get(0)):s=t:s=d.from(t).get(i||0)}else s=t;return e.params[r].length===0?e.params[r].push(s):e.params[r][e.params[r].length-1]=s,[s,r]}}const mt=["1","3","5","15","30","45","60","120","180","240","D","W","M"];function bi(e,t,i,r,s=!1){for(let n=0;n<i.length;n++)if(i[n]<=e&&t<=r[n])return s||t>=r[n]?n:n-1;return-1}function vi(e,t,i,r,s=!1,n,a=!1){for(let o=i.length-1;o>=0;o--){if(r[o]<=t&&i[o]>=e){const h=n&&t>n;if(a&&s)for(let c=0;c<i.length;c++){if(i[c]>=e&&i[c]<t)return c;if(i[c]>=t)break}if(h&&s&&!a)for(let c=0;c<i.length;c++){if(i[c]>=e&&i[c]<t)return c;if(i[c]>=t)break}return o}if(r[o]<e)break}return-1}function Kh(e){return async(t,i,r,s=!1,n=!1,a=!1,o=null,h=null)=>{const c=t[0],l=i[0],f=r[0],g=r[1],p=Array.isArray(s)?s[0]:s,x=Array.isArray(n)?n[0]:n;if(e.isSecondaryContext)return f;const y=mt.indexOf(e.timeframe),w=mt.indexOf(l);if(y==-1||w==-1)throw new Error("Invalid timeframe");if(y===w)return f;const E=y>w,A=d.from(e.data.openTime).get(0),k=d.from(e.data.closeTime).get(0),P=`${c}_${l}_${g}`,C=`${P}_prevIdx`;if(e.cache[P]){const Ye=e.cache[P],at=E?vi(A,k,Ye.data.openTime.data,Ye.data.closeTime.data,x,e.eDate,p):bi(A,k,Ye.data.openTime.data,Ye.data.closeTime.data,x);if(at==-1)return NaN;const Be=Ye.params[g][at];if(!E&&p){const Xt=e.cache[C];return Xt!==void 0&&Xt===at?NaN:(e.cache[C]=at,Array.isArray(Be)?[Be]:Be)}return Array.isArray(Be)?[Be]:Be}const Q=1e3*60*60*24*30,G=e.sDate?e.sDate-Q:void 0,z=e.sDate&&e.eDate?void 0:e.limit||1e3,Ge=new wr(e.source,c,l,z,G,void 0);Ge.markAsSecondary();const Ce=await Ge.run(e.pineTSCode);e.cache[P]=Ce;const bt=E?vi(A,k,Ce.data.openTime.data,Ce.data.closeTime.data,x,e.eDate,p):bi(A,k,Ce.data.openTime.data,Ce.data.closeTime.data,x);if(bt==-1)return NaN;const vt=Ce.params[g][bt];return!E&&p?(e.cache[C]=bt,NaN):Array.isArray(vt)?[vt]:vt}}function zh(e){return async(t,i,r,s=!1,n=null,a=!1,o=0)=>{const h=t[0],c=i[0],l=r[0],f=r[1];Array.isArray(s)&&s[0];const g=Array.isArray(a)?a[0]:a;if(e.isSecondaryContext)return Array.isArray(l)?[l]:l;const p=mt.indexOf(e.timeframe),x=mt.indexOf(c);if(p===-1||x===-1){if(g)return NaN;throw new Error("Invalid timeframe")}if(x>p){if(g)return NaN;throw new Error(`Timeframe ${c} is not lower than or equal to chart timeframe ${e.timeframe}`)}if(x===p)return[[l]];const y=`${h}_${c}_${f}_lower`;if(!e.cache[y]){const G=e.sDate?e.sDate-2592e6:void 0,z=e.sDate&&e.eDate?void 0:e.limit||1e3,Ge=new wr(e.source,h,c,z,G,e.eDate);Ge.markAsSecondary();const Ce=await Ge.run(e.pineTSCode);e.cache[y]=Ce}const w=e.cache[y],E=d.from(e.data.openTime).get(0),A=d.from(e.data.closeTime).get(0),k=w.data.openTime.data,P=w.data.closeTime.data,C=w.params[f];if(!C)return[];const Q=[];for(let G=0;G<k.length;G++){const z=k[G];if(!(P[G]<=E)){if(z>=A)break;z>=E&&z<A&&Q.push(C[G])}}return[Q]}}var Hh=Object.defineProperty,Gh=(e,t,i)=>t in e?Hh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,ct=(e,t,i)=>Gh(e,typeof t!="symbol"?t+"":t,i);const Yh={param:Uh,security:Kh,security_lower_tf:zh};class Qh{constructor(t){this.context=t,ct(this,"_cache",{}),ct(this,"param"),ct(this,"security"),ct(this,"security_lower_tf"),Object.entries(Yh).forEach(([i,r])=>{this[i]=r(t)})}}function Xh(e){return t=>{e.taState||(e.taState={});const i=t||"accdist";e.taState[i]||(e.taState[i]={cumulativeSum:0});const r=e.taState[i],s=e.get(e.data.close,0),n=e.get(e.data.high,0),a=e.get(e.data.low,0),o=e.get(e.data.volume,0);if(isNaN(s)||isNaN(n)||isNaN(a)||isNaN(o))return e.precision(r.cumulativeSum);const h=n-a;let c=0;return h!==0&&(c=(s-a-(n-s))/h*o),r.cumulativeSum+=c,e.precision(r.cumulativeSum)}}function Zh(e){return(t,i,r,s,n)=>{const a=d.from(i).get(0),o=d.from(r).get(0),h=d.from(s).get(0);e.taState||(e.taState={});const c=n||`alma_${a}_${o}_${h}`;if(!e.taState[c]){const p=o*(a-1),x=a/h,y=[];let w=0;for(let E=0;E<a;E++){const A=Math.exp(-Math.pow(E-p,2)/(2*x*x));y.push(A),w+=A}for(let E=0;E<y.length;E++)y[E]/=w;e.taState[c]={window:[],weights:y}}const l=e.taState[c],f=d.from(t).get(0);if(l.window.unshift(f),l.window.length<a)return NaN;l.window.length>a&&l.window.pop();let g=0;for(let p=0;p<a;p++)g+=l.weights[p]*l.window[a-1-p];return e.precision(g)}}function Jh(e){return(t,i)=>{const r=d.from(t).get(0);e.taState||(e.taState={});const s=i||`atr_${r}`;e.taState[s]||(e.taState[s]={prevAtr:null,initSum:0,initCount:0,prevClose:null});const n=e.taState[s],a=e.get(e.data.high,0),o=e.get(e.data.low,0),h=e.get(e.data.close,0);let c;if(n.prevClose!==null){const f=a-o,g=Math.abs(a-n.prevClose),p=Math.abs(o-n.prevClose);c=Math.max(f,g,p)}else c=a-o;if(n.prevClose=h,n.initCount<r)return n.initSum+=c,n.initCount++,n.initCount===r?(n.prevAtr=n.initSum/r,e.precision(n.prevAtr)):NaN;const l=(n.prevAtr*(r-1)+c)/r;return n.prevAtr=l,e.precision(l)}}function ec(e){return(t,i)=>{e.taState||(e.taState={});const r=i||"barssince";e.taState[r]||(e.taState[r]={lastTrueIndex:null});const s=e.taState[r];return d.from(t).get(0)?(s.lastTrueIndex=e.idx,0):s.lastTrueIndex===null?NaN:e.idx-s.lastTrueIndex}}function tc(e){return(t,i,r,s)=>{const n=d.from(i).get(0),a=d.from(r).get(0);e.taState||(e.taState={});const o=s||`bb_${n}_${a}`;e.taState[o]||(e.taState[o]={window:[],sum:0});const h=e.taState[o],c=d.from(t).get(0);if(isNaN(c))return[[NaN,NaN,NaN]];if(h.window.unshift(c),h.sum+=c,h.window.length<n)return[[NaN,NaN,NaN]];if(h.window.length>n){const y=h.window.pop();h.sum-=y}const l=h.sum/n;let f=0;for(let y=0;y<n;y++)f+=Math.pow(h.window[y]-l,2);const g=Math.sqrt(f/n),p=l+a*g,x=l-a*g;return[[e.precision(p),e.precision(l),e.precision(x)]]}}function ic(e){return(t,i,r,s)=>{const n=d.from(i).get(0),a=d.from(r).get(0);e.taState||(e.taState={});const o=s||`bbw_${n}_${a}`;e.taState[o]||(e.taState[o]={window:[],sum:0});const h=e.taState[o],c=d.from(t).get(0);if(isNaN(c))return NaN;if(h.window.unshift(c),h.sum+=c,h.window.length<n)return NaN;if(h.window.length>n){const w=h.window.pop();h.sum-=w}const l=h.sum/n;let f=0;for(let w=0;w<n;w++){const E=h.window[w]-l;f+=E*E}const g=f/n,p=Math.sqrt(g),x=a*p;if(l===0)return e.precision(0);const y=2*x/l*100;return e.precision(y)}}function rc(e){return(t,i,r)=>{const s=d.from(i).get(0);e.taState||(e.taState={});const n=r||`cci_${s}`;e.taState[n]||(e.taState[n]={window:[],sum:0});const a=e.taState[n],o=d.from(t).get(0);if(isNaN(o))return NaN;if(a.window.unshift(o),a.sum+=o,a.window.length<s)return NaN;if(a.window.length>s){const g=a.window.pop();a.sum-=g}const h=a.sum/s;let c=0;for(let g=0;g<s;g++)c+=Math.abs(a.window[g]-h);const l=c/s;if(l===0)return 0;const f=(o-h)/(.015*l);return e.precision(f)}}function sc(e){return(t,i=1,r)=>{typeof i=="string"&&(r=i,i=1);const s=d.from(i).get(0);e.taState||(e.taState={});const n=r||`change_${s}`;e.taState[n]||(e.taState[n]={window:[]});const a=e.taState[n],o=d.from(t).get(0);if(a.window.unshift(o),a.window.length<=s)return NaN;a.window.length>s+1&&a.window.pop();const h=o-a.window[s];return e.precision(h)}}function nc(e){return(t,i,r)=>{const s=d.from(i).get(0);e.taState||(e.taState={});const n=r||`cmo_${s}`;e.taState[n]||(e.taState[n]={gainsWindow:[],lossesWindow:[],gainsSum:0,lossesSum:0});const a=e.taState[n],o=d.from(t).get(0),h=d.from(t).get(1);if(isNaN(o)||isNaN(h))return NaN;const c=o-h,l=c>=0?c:0,f=c>=0?0:-c;if(a.gainsWindow.unshift(l),a.lossesWindow.unshift(f),a.gainsSum+=l,a.lossesSum+=f,a.gainsWindow.length<s)return NaN;if(a.gainsWindow.length>s){const x=a.gainsWindow.pop(),y=a.lossesWindow.pop();a.gainsSum-=x,a.lossesSum-=y}const g=a.gainsSum+a.lossesSum;if(g===0)return e.precision(0);const p=100*(a.gainsSum-a.lossesSum)/g;return e.precision(p)}}function ac(e){return(t,i,r)=>{const s=d.from(i).get(0),n=d.from(t);let a=0,o=!1;for(let l=0;l<s;l++){const f=n.get(l);if(isNaN(f)){o=!0;break}a+=f}if(o)return NaN;let h=0;for(let l=0;l<s;l++){const f=n.get(l);h+=f*(l+1)}if(a===0)return NaN;const c=-h/a;return e.precision(c)}}function oc(e){return(t,i,r,s)=>{const n=d.from(r).get(0),a=d.from(t),o=d.from(i);if(e.idx<n-1)return NaN;let h=0,c=0,l=0,f=0,g=0,p=0;for(let A=0;A<n;A++){const k=a.get(A),P=o.get(A);isNaN(k)||isNaN(P)||(h+=k,c+=P,l+=k*P,f+=k*k,g+=P*P,p++)}if(p<2)return NaN;const x=p*l-h*c,y=p*f-h*h,w=p*g-c*c;if(y<=0||w<=0)return e.precision(0);const E=x/Math.sqrt(y*w);return e.precision(E)}}function hc(e){return(t,i,r)=>{const s=d.from(t),n=d.from(i),a=s.get(0),o=n.get(0),h=s.get(1),c=n.get(1);if(isNaN(a)||isNaN(o)||isNaN(h)||isNaN(c))return!1;const l=a>o&&h<=c,f=a<o&&h>=c;return l||f}}function cc(e){return(t,i)=>{const r=d.from(t),s=d.from(i),n=r.get(0),a=s.get(0),o=r.get(1),h=s.get(1);return o<h&&n>a}}function uc(e){return(t,i)=>{const r=d.from(t),s=d.from(i),n=r.get(0),a=s.get(0),o=r.get(1),h=s.get(1);return o>h&&n<a}}function lc(e){return(t,i)=>{e.taState||(e.taState={});const r=i||"cum";e.taState[r]||(e.taState[r]={cumulativeSum:0});const s=e.taState[r],n=d.from(t).get(0);return isNaN(n)||(s.cumulativeSum+=n),e.precision(s.cumulativeSum)}}function pc(e){return(t,i,r)=>{const s=d.from(i).get(0);e.taState||(e.taState={});const n=r||`dev_${s}`;e.taState[n]||(e.taState[n]={window:[],sum:0});const a=e.taState[n],o=d.from(t).get(0)||0;if(a.window.unshift(o),a.sum+=o,a.window.length<s)return NaN;if(a.window.length>s){const f=a.window.pop();a.sum-=f}const h=a.sum/s;let c=0;for(let f=0;f<s;f++)c+=Math.abs(a.window[f]-h);const l=c/s;return e.precision(l)}}function fc(e){return(t,i,r)=>{const s=d.from(t).get(0),n=d.from(i).get(0);e.taState||(e.taState={});const a=r||`dmi_${s}_${n}`;e.taState[a]||(e.taState[a]={prevHigh:NaN,prevLow:NaN,prevClose:NaN,trInitSum:0,plusInitSum:0,minusInitSum:0,initCount:0,prevSmoothedTR:NaN,prevSmoothedPlus:NaN,prevSmoothedMinus:NaN,dxInitSum:0,adxInitCount:0,prevADX:NaN});const o=e.taState[a],h=e.get(e.data.high,0),c=e.get(e.data.low,0),l=e.get(e.data.close,0);if(isNaN(h)||isNaN(c)||isNaN(l))return[[NaN,NaN,NaN]];if(isNaN(o.prevHigh))return o.prevHigh=h,o.prevLow=c,o.prevClose=l,[[NaN,NaN,NaN]];const f=Math.max(h-c,Math.abs(h-o.prevClose),Math.abs(c-o.prevClose)),g=h-o.prevHigh,p=o.prevLow-c,x=g>p&&g>0?g:0,y=p>g&&p>0?p:0;o.prevHigh=h,o.prevLow=c,o.prevClose=l;let w,E,A;if(o.initCount++,o.initCount<=s)o.trInitSum+=f,o.plusInitSum+=x,o.minusInitSum+=y,o.initCount===s&&(o.prevSmoothedTR=o.trInitSum/s,o.prevSmoothedPlus=o.plusInitSum/s,o.prevSmoothedMinus=o.minusInitSum/s);else{const z=1/s;o.prevSmoothedTR=z*f+(1-z)*o.prevSmoothedTR,o.prevSmoothedPlus=z*x+(1-z)*o.prevSmoothedPlus,o.prevSmoothedMinus=z*y+(1-z)*o.prevSmoothedMinus}if(w=o.prevSmoothedTR,E=o.prevSmoothedPlus,A=o.prevSmoothedMinus,o.initCount<s)return[[NaN,NaN,NaN]];const k=w===0?0:100*E/w,P=w===0?0:100*A/w,C=k+P,Q=C===0?0:100*Math.abs(k-P)/C;let G=NaN;if(o.adxInitCount++,o.adxInitCount<=n)o.dxInitSum+=Q,o.adxInitCount===n&&(o.prevADX=o.dxInitSum/n,G=o.prevADX);else{const z=1/n;o.prevADX=z*Q+(1-z)*o.prevADX,G=o.prevADX}return[[e.precision(k),e.precision(P),e.precision(G)]]}}function mc(e){return(t,i,r)=>{const s=d.from(i).get(0);e.taState||(e.taState={});const n=r||`ema_${s}`;e.taState[n]||(e.taState[n]={prevEma:null,initSum:0,initCount:0});const a=e.taState[n],o=d.from(t).get(0);if(a.initCount<s)return a.initSum+=o,a.initCount++,a.initCount===s?(a.prevEma=a.initSum/s,e.precision(a.prevEma)):NaN;const h=2/(s+1),c=o*h+a.prevEma*(1-h);return a.prevEma=c,e.precision(c)}}function dc(e){return(t,i,r)=>{const s=d.from(i).get(0),n=d.from(t);for(let a=0;a<s;a++){const o=n.get(a),h=n.get(a+1);if(isNaN(o)||isNaN(h)||o>=h)return!1}return!0}}function gc(e){return(t,i,r)=>{const s=d.from(i).get(0);e.taState||(e.taState={});const n=r||`highest_${s}`;e.taState[n]||(e.taState[n]={window:[]});const a=e.taState[n],o=d.from(t).get(0);if(a.window.unshift(o),a.window.length<s)return NaN;a.window.length>s&&a.window.pop();const h=Math.max(...a.window.filter(c=>!isNaN(c)));return e.precision(h)}}function xc(e){return(t,i,r)=>{const s=d.from(i).get(0),n=d.from(t);if(e.idx<s-1)return NaN;let a=-1/0,o=NaN;for(let h=0;h<s;h++){const c=n.get(h);isNaN(c)||(isNaN(o)||c>a)&&(a=c,o=-h)}return o}}function yc(e){return(t,i,r)=>{const s=d.from(i).get(0),n=Math.floor(s/2),a=Math.floor(Math.sqrt(s)),o=e.ta.wma,h=o(t,n,r?`${r}_wma1`:void 0),c=o(t,s,r?`${r}_wma2`:void 0);if(isNaN(h)||isNaN(c))return NaN;e.taState||(e.taState={});const l=r||`hma_raw_${s}`;e.taState[l]||(e.taState[l]=[]);const f=2*h-c;e.taState[l].unshift(f);const g=r?`${r}_hma_final`:`hma_final_${s}`;e.taState[g]||(e.taState[g]={window:[]});const p=e.taState[g];if(p.window.unshift(f),p.window.length<a)return NaN;p.window.length>a&&p.window.pop();let x=0,y=0;for(let E=0;E<a;E++){const A=a-E;x+=p.window[E]*A,y+=A}const w=x/y;return e.precision(w)}}function wc(e){return t=>{const i=e.get(e.data.close,0),r=e.get(e.data.high,0),s=e.get(e.data.low,0),n=e.get(e.data.volume,0);if(isNaN(i)||isNaN(r)||isNaN(s)||isNaN(n))return NaN;const a=(r-s)*n;if(a===0)return e.precision(0);const o=(2*i-r-s)/a;return e.precision(o)}}function bc(e){return(t,i,r,s,n)=>{const a=d.from(i).get(0),o=d.from(r).get(0);let h=!0;typeof s=="string"?n=s:s!==void 0&&(h=d.from(s).get(0));let c;const l=e.get(e.data.high,0),f=e.get(e.data.low,0);if(h){const P=e.get(e.data.close,1);isNaN(P)?c=NaN:c=Math.max(l-f,Math.abs(l-P),Math.abs(f-P))}else c=l-f;const g=d.from(t).get(0);e.taState||(e.taState={});const p=n||`kc_${a}_${o}_${h}`;e.taState[p]||(e.taState[p]={basisState:{prevEma:null,initSum:0,initCount:0},rangeState:{prevEma:null,initSum:0,initCount:0}});const x=e.taState[p],y=(P,C,Q)=>{if(isNaN(C))return NaN;if(P.initCount<Q)return P.initSum+=C,P.initCount++,P.initCount===Q?(P.prevEma=P.initSum/Q,P.prevEma):NaN;const G=2/(Q+1);return P.prevEma=C*G+P.prevEma*(1-G),P.prevEma},w=y(x.basisState,g,a),E=y(x.rangeState,c,a);if(isNaN(w)||isNaN(E))return[[NaN,NaN,NaN]];const A=w+E*o,k=w-E*o;return[[e.precision(w),e.precision(A),e.precision(k)]]}}function vc(e){return(t,i,r,s,n)=>{const a=d.from(i).get(0),o=d.from(r).get(0);let h=!0;typeof s=="string"?n=s:s!==void 0&&(h=d.from(s).get(0)),e.taState||(e.taState={});const c=n||`kcw_${a}_${o}_${h}`;e.taState[c]||(e.taState[c]={basisState:{prevEma:null,initSum:0,initCount:0},rangeState:{prevEma:null,initSum:0,initCount:0}});const l=e.taState[c],f=(k,P,C)=>{if(isNaN(P))return NaN;if(k.initCount<C)return k.initSum+=P,k.initCount++,k.initCount===C?(k.prevEma=k.initSum/C,k.prevEma):NaN;const Q=2/(C+1);return k.prevEma=P*Q+k.prevEma*(1-Q),k.prevEma};let g;const p=e.get(e.data.high,0),x=e.get(e.data.low,0);if(h){const k=e.get(e.data.close,1);isNaN(k)?g=NaN:g=Math.max(p-x,Math.abs(p-k),Math.abs(x-k))}else g=p-x;const y=d.from(t).get(0),w=f(l.basisState,y,a),E=f(l.rangeState,g,a);if(isNaN(w)||isNaN(E))return NaN;if(w===0)return e.precision(0);const A=2*E*o/w;return e.precision(A)}}function _c(e){return(t,i,r,s)=>{const n=d.from(i).get(0),a=d.from(r).get(0);e.taState||(e.taState={});const o=s||`linreg_${n}_${a}`;e.taState[o]||(e.taState[o]={window:[]});const h=e.taState[o],c=d.from(t).get(0);if(h.window.unshift(c),h.window.length<n)return NaN;h.window.length>n&&h.window.pop();let l=0,f=0,g=0,p=0;const x=n;for(let A=0;A<n;A++){const k=n-1-A,P=h.window[A];l+=k,f+=P,g+=k*P,p+=k*k}const y=x*p-l*l;if(y===0)return NaN;const w=(x*g-l*f)/y,E=(f-w*l)/x+w*(n-1-a);return e.precision(E)}}function Sc(e){return(t,i,r)=>{const s=d.from(i).get(0);e.taState||(e.taState={});const n=r||`lowest_${s}`;e.taState[n]||(e.taState[n]={window:[]});const a=e.taState[n],o=d.from(t).get(0);if(a.window.unshift(o),a.window.length<s)return NaN;a.window.length>s&&a.window.pop();const h=a.window.filter(l=>!isNaN(l)&&l!==void 0),c=h.length>0?Math.min(...h):NaN;return e.precision(c)}}function Ec(e){return(t,i,r)=>{const s=d.from(i).get(0),n=d.from(t);if(e.idx<s-1)return NaN;let a=1/0,o=NaN;for(let h=0;h<s;h++){const c=n.get(h);isNaN(c)||(isNaN(o)||c<a)&&(a=c,o=-h)}return o}}function Nc(e){return(t,i,r,s,n)=>{const a=d.from(i).get(0),o=d.from(r).get(0),h=d.from(s).get(0),c=n||`macd_${a}_${o}_${h}`,l=`${c}_fast`,f=`${c}_slow`,g=`${c}_signal`,p=e.ta.ema(t,a,l),x=e.ta.ema(t,o,f);let y=NaN;!isNaN(p)&&!isNaN(x)&&(y=p-x);let w=NaN;isNaN(y)||(w=e.ta.ema(y,h,g));let E=NaN;return!isNaN(y)&&!isNaN(w)&&(E=y-w),[[e.precision(y),e.precision(w),e.precision(E)]]}}function Cc(e){return(t,i,r)=>{const s=d.from(i).get(0);e.taState||(e.taState={});const n=r||`median_${s}`;e.taState[n]||(e.taState[n]={window:[]});const a=e.taState[n],o=d.from(t).get(0);if(a.window.unshift(o),a.window.length<s)return NaN;a.window.length>s&&a.window.pop();const h=a.window.slice().sort((f,g)=>f-g),c=Math.floor(s/2),l=s%2===0?(h[c-1]+h[c])/2:h[c];return e.precision(l)}}function kc(e){return(t,i,r)=>{const s=d.from(i).get(0);e.taState||(e.taState={});const n=r||`mfi_${s}`;e.taState[n]||(e.taState[n]={upperWindow:[],lowerWindow:[],upperSum:0,lowerSum:0});const a=e.taState[n],o=d.from(t).get(0),h=d.from(t).get(1),c=e.get(e.data.volume,0);if(isNaN(o)||isNaN(c))return NaN;const l=isNaN(h)?NaN:o-h;let f=0,g=0;if(f=c*(l<=0?0:o),g=c*(l>=0?0:o),a.upperWindow.unshift(f),a.lowerWindow.unshift(g),a.upperSum+=f,a.lowerSum+=g,a.upperWindow.length<s)return NaN;if(a.upperWindow.length>s){const x=a.upperWindow.pop(),y=a.lowerWindow.pop();a.upperSum-=x,a.lowerSum-=y}if(a.lowerSum===0)return a.upperSum,e.precision(100);if(a.upperSum===0)return e.precision(0);const p=100-100/(1+a.upperSum/a.lowerSum);return e.precision(p)}}function Ic(e){return(t,i,r)=>{const s=d.from(i).get(0),n=d.from(t);if(e.idx<s-1)return NaN;const a=new Map;for(let c=0;c<s;c++){const l=n.get(c);isNaN(l)||a.set(l,(a.get(l)||0)+1)}if(a.size===0)return NaN;let o=NaN,h=-1;for(const[c,l]of a.entries())l>h?(h=l,o=c):l===h&&c<o&&(o=c);return o}}function Ac(e){return(t,i,r)=>{const s=d.from(i).get(0);return e.ta.change(t,s)}}function Tc(e){return t=>{e.taState||(e.taState={});const i=t||"nvi";e.taState[i]||(e.taState[i]={nvi:1});const r=e.taState[i],s=e.get(e.data.close,0),n=e.get(e.data.close,1),a=e.get(e.data.volume,0),o=e.get(e.data.volume,1),h=isNaN(s)?0:s,c=isNaN(n)?0:n,l=isNaN(a)?0:a,f=isNaN(o)?0:o;if(!(h===0||c===0)&&l<f){const g=(h-c)/c;r.nvi=r.nvi+g*r.nvi}return e.precision(r.nvi)}}function Pc(e){return()=>{e.taState||(e.taState={});const t="obv";e.taState[t]||(e.taState[t]={prevOBV:0});const i=e.taState[t],r=e.get(e.data.close,0),s=e.get(e.data.volume,0),n=e.get(e.data.close,1);if(isNaN(n))return i.prevOBV=0,e.precision(0);let a;return r>n?a=i.prevOBV+s:r<n?a=i.prevOBV-s:a=i.prevOBV,i.prevOBV=a,e.precision(a)}}function Rc(e){return(t,i,r)=>t instanceof d?i?new d(t.data,t.offset+i):t:(e.params[r]||(e.params[r]=[]),Array.isArray(t)?new d(t,i||0):(e.params[r].length===0?e.params[r].push(t):e.params[r][e.params[r].length-1]=t,new d(e.params[r],0)))}function Dc(e){return(t,i,r,s)=>{const n=d.from(i).get(0),a=d.from(r).get(0),o=d.from(t);if(e.idx<n-1)return NaN;const h=[];for(let x=0;x<n;x++){const y=o.get(x);if(isNaN(y))return NaN;h.push(y)}h.sort((x,y)=>x-y);let c=a/100*n-.5;c<0&&(c=0),c>n-1&&(c=n-1);const l=Math.floor(c),f=Math.ceil(c);if(l===f)return e.precision(h[l]);const g=c-l,p=h[l]+g*(h[f]-h[l]);return e.precision(p)}}function Mc(e){return(t,i,r,s)=>{const n=d.from(i).get(0),a=d.from(r).get(0),o=d.from(t);if(e.idx<n-1)return NaN;const h=[];for(let l=0;l<n;l++){const f=o.get(l);isNaN(f)||h.push(f)}if(h.length===0)return NaN;h.sort((l,f)=>l-f);let c=Math.ceil(a/100*h.length)-1;return c<0&&(c=0),c>=h.length&&(c=h.length-1),e.precision(h[c])}}function Oc(e){return(t,i,r)=>{const s=d.from(i).get(0),n=d.from(t);if(e.idx<s)return NaN;const a=n.get(0);if(isNaN(a))return NaN;let o=0,h=0;for(let c=1;c<=s;c++){const l=n.get(c);isNaN(l)||(h++,l<=a&&o++)}return h===0?NaN:e.precision(o/h*100)}}function Vc(e,t,i){const r=new Array(e.length).fill(NaN);for(let s=t+i;s<e.length;s++){const n=e[s-i];let a=!0;for(let o=1;o<=t;o++)if(e[s-i-o]>=n){a=!1;break}if(a){for(let o=1;o<=i;o++)if(e[s-i+o]>=n){a=!1;break}}a&&(r[s]=n)}return r}function Lc(e){return(t,i,r,s)=>{typeof r=="string"&&(r=i,i=t,t=e.data.high);const n=d.from(i).get(0),a=d.from(r).get(0),o=d.from(t).toArray(),h=Vc(o,n,a),c=e.idx;return e.precision(h[c])}}function Bc(e,t,i){const r=new Array(e.length).fill(NaN);for(let s=t+i;s<e.length;s++){const n=e[s-i];let a=!0;for(let o=1;o<=t;o++)if(e[s-i-o]<=n){a=!1;break}if(a){for(let o=1;o<=i;o++)if(e[s-i+o]<=n){a=!1;break}}a&&(r[s]=n)}return r}function Fc(e){return(t,i,r,s)=>{typeof r=="string"&&(r=i,i=t,t=e.data.low);const n=d.from(i).get(0),a=d.from(r).get(0),o=d.from(t).toArray(),h=Bc(o,n,a),c=e.idx;return e.precision(h[c])}}function jc(e){return t=>{e.taState||(e.taState={});const i=t||"pvi";e.taState[i]||(e.taState[i]={pvi:1});const r=e.taState[i],s=e.get(e.data.close,0),n=e.get(e.data.close,1),a=e.get(e.data.volume,0),o=e.get(e.data.volume,1),h=isNaN(s)?0:s,c=isNaN(n)?0:n,l=isNaN(a)?0:a,f=isNaN(o)?0:o;if(!(h===0||c===0)&&l>f){const g=(h-c)/c;r.pvi=r.pvi+g*r.pvi}return e.precision(r.pvi)}}function $c(e){return t=>{e.taState||(e.taState={});const i=t||"pvt";e.taState[i]||(e.taState[i]={cumulativeSum:0});const r=e.taState[i],s=e.get(e.data.close,0),n=e.get(e.data.close,1),a=e.get(e.data.volume,0);if(!isNaN(s)&&!isNaN(n)&&!isNaN(a)&&n!==0){const o=(s-n)/n*a;r.cumulativeSum+=o}return e.precision(r.cumulativeSum)}}function Wc(e){return(t,i,r)=>{const s=e.pine.ta.highest(t,i,(r||"range")+"_h"),n=e.pine.ta.lowest(t,i,(r||"range")+"_l");return isNaN(s)||isNaN(n)?NaN:e.precision(s-n)}}function qc(e){return(t,i,r)=>{const s=d.from(i).get(0),n=d.from(t);for(let a=0;a<s;a++){const o=n.get(a),h=n.get(a+1);if(isNaN(o)||isNaN(h)||o<=h)return!1}return!0}}function Uc(e){return(t,i,r)=>{const s=d.from(i).get(0);e.taState||(e.taState={});const n=r||`rma_${s}`;e.taState[n]||(e.taState[n]={prevRma:null,initSum:0,initCount:0});const a=e.taState[n],o=d.from(t).get(0)||0;if(a.initCount<s)return a.initSum+=o,a.initCount++,a.initCount===s?(a.prevRma=a.initSum/s,e.precision(a.prevRma)):NaN;const h=1/s,c=o*h+a.prevRma*(1-h);return a.prevRma=c,e.precision(c)}}function Kc(e){return(t,i,r)=>{const s=d.from(i).get(0);e.taState||(e.taState={});const n=r||`roc_${s}`;e.taState[n]||(e.taState[n]={window:[]});const a=e.taState[n],o=d.from(t).get(0);if(a.window.unshift(o),a.window.length<=s)return NaN;a.window.length>s+1&&a.window.pop();const h=a.window[s],c=(o-h)/h*100;return e.precision(c)}}function zc(e){return(t,i,r)=>{const s=d.from(i).get(0);e.taState||(e.taState={});const n=r||`rsi_${s}`;e.taState[n]||(e.taState[n]={prevValue:null,avgGain:0,avgLoss:0,initGains:[],initLosses:[]});const a=e.taState[n],o=d.from(t).get(0);if(a.prevValue!==null){const h=o-a.prevValue,c=h>0?h:0,l=h<0?-h:0;if(a.initGains.length<s){if(a.initGains.push(c),a.initLosses.push(l),a.initGains.length===s){a.avgGain=a.initGains.reduce((p,x)=>p+x,0)/s,a.avgLoss=a.initLosses.reduce((p,x)=>p+x,0)/s,a.prevValue=o;const g=a.avgLoss===0?100:100-100/(1+a.avgGain/a.avgLoss);return e.precision(g)}return a.prevValue=o,NaN}a.avgGain=(a.avgGain*(s-1)+c)/s,a.avgLoss=(a.avgLoss*(s-1)+l)/s;const f=a.avgLoss===0?100:100-100/(1+a.avgGain/a.avgLoss);return a.prevValue=o,e.precision(f)}return a.prevValue=o,NaN}}function Hc(e){return(t,i,r,s)=>{const n=d.from(t).get(0),a=d.from(i).get(0),o=d.from(r).get(0);e.taState||(e.taState={});const h=s||`sar_${n}_${a}_${o}`;e.taState[h]||(e.taState[h]={result:NaN,maxMin:NaN,acceleration:NaN,isBelow:!1,barIndex:0});const c=e.taState[h],l=e.get(e.data.high,0),f=e.get(e.data.low,0),g=e.get(e.data.close,0),p=e.get(e.data.close,1),x=e.get(e.data.high,1),y=e.get(e.data.low,1),w=e.get(e.data.high,2),E=e.get(e.data.low,2);if(isNaN(l)||isNaN(f)||isNaN(g))return NaN;let A=!1;return c.barIndex===1&&(g>p?(c.isBelow=!0,c.maxMin=l,c.result=y):(c.isBelow=!1,c.maxMin=f,c.result=x),A=!0,c.acceleration=n),c.barIndex>=1&&(c.result=c.result+c.acceleration*(c.maxMin-c.result),c.isBelow?c.result>f&&(A=!0,c.isBelow=!1,c.result=Math.max(l,c.maxMin),c.maxMin=f,c.acceleration=n):c.result<l&&(A=!0,c.isBelow=!0,c.result=Math.min(f,c.maxMin),c.maxMin=l,c.acceleration=n),A||(c.isBelow?l>c.maxMin&&(c.maxMin=l,c.acceleration=Math.min(c.acceleration+a,o)):f<c.maxMin&&(c.maxMin=f,c.acceleration=Math.min(c.acceleration+a,o))),c.isBelow?(c.result=Math.min(c.result,y),c.barIndex>1&&(c.result=Math.min(c.result,E))):(c.result=Math.max(c.result,x),c.barIndex>1&&(c.result=Math.max(c.result,w)))),c.barIndex++,c.barIndex<=1?NaN:e.precision(c.result)}}function Gc(e){return(t,i,r)=>{const s=d.from(i).get(0);e.taState||(e.taState={});const n=r||`sma_${s}`;e.taState[n]||(e.taState[n]={window:[],sum:0});const a=e.taState[n],o=d.from(t).get(0)||0;if(a.window.unshift(o),a.sum+=o,a.window.length<s)return NaN;if(a.window.length>s){const c=a.window.pop();a.sum-=c}const h=a.sum/s;return e.precision(h)}}function Yc(e){return(t,i,r=!0,s)=>{const n=d.from(i).get(0),a=d.from(r).get(0);e.taState||(e.taState={});const o=s||`stdev_${n}_${a}`;e.taState[o]||(e.taState[o]={window:[],sum:0});const h=e.taState[o],c=d.from(t).get(0);if(h.window.unshift(c),h.sum+=c,h.window.length<n)return NaN;if(h.window.length>n){const x=h.window.pop();h.sum-=x}const l=h.sum/n;let f=0;for(let x=0;x<n;x++)f+=Math.pow(h.window[x]-l,2);const g=a?n:n-1,p=Math.sqrt(f/g);return e.precision(p)}}function Qc(e){return(t,i,r,s,n)=>{const a=d.from(s).get(0);e.taState||(e.taState={});const o=n||`stoch_${a}`;e.taState[o]||(e.taState[o]={highWindow:[],lowWindow:[]});const h=e.taState[o],c=d.from(t).get(0),l=d.from(i).get(0),f=d.from(r).get(0);if(isNaN(c)||isNaN(l)||isNaN(f))return NaN;if(h.highWindow.unshift(l),h.lowWindow.unshift(f),h.highWindow.length<a)return NaN;h.highWindow.length>a&&(h.highWindow.pop(),h.lowWindow.pop());let g=h.highWindow[0],p=h.lowWindow[0];for(let w=1;w<a;w++)h.highWindow[w]>g&&(g=h.highWindow[w]),h.lowWindow[w]<p&&(p=h.lowWindow[w]);const x=g-p;if(x===0)return NaN;const y=100*(c-p)/x;return e.precision(y)}}function Xc(e){return(t,i,r)=>{const s=d.from(t).get(0),n=d.from(i).get(0);e.taState||(e.taState={});const a=r||`supertrend_${s}_${n}`;e.taState[a]||(e.taState[a]={trWindow:[],trSum:0,atrValue:NaN,atrCount:0,prevLowerBand:NaN,prevUpperBand:NaN,prevSuperTrend:NaN,prevDirection:NaN,prevClose:NaN});const o=e.taState[a],h=e.get(e.data.high,0),c=e.get(e.data.low,0),l=e.get(e.data.close,0);if(isNaN(h)||isNaN(c)||isNaN(l))return[[NaN,NaN]];const f=(h+c)/2;let g;isNaN(o.prevClose)?g=h-c:g=Math.max(h-c,Math.abs(h-o.prevClose),Math.abs(c-o.prevClose)),o.atrCount++,o.atrCount<=n?(o.trWindow.push(g),o.trSum+=g,o.atrCount===n&&(o.atrValue=o.trSum/n)):o.atrValue=(o.atrValue*(n-1)+g)/n;const p=o.atrValue,x=o.prevClose;if(o.prevClose=l,isNaN(p))return[[NaN,NaN]];let y=f+s*p,w=f-s*p;const E=isNaN(o.prevLowerBand)?0:o.prevLowerBand,A=isNaN(o.prevUpperBand)?0:o.prevUpperBand;isNaN(o.prevLowerBand)||w>E||x<E||(w=E),isNaN(o.prevUpperBand)||y<A||x>A||(y=A);let k,P;const C=o.prevSuperTrend;return o.atrCount===n?k=1:C===o.prevUpperBand?k=l>y?-1:1:k=l<w?1:-1,P=k===-1?w:y,o.prevLowerBand=w,o.prevUpperBand=y,o.prevSuperTrend=P,o.prevDirection=k,[[e.precision(P),k]]}}function Zc(e){return(t,i)=>{const r=[1,2,2,1],s=6;e.taState||(e.taState={});const n=i||"swma";e.taState[n]||(e.taState[n]={window:[]});const a=e.taState[n],o=d.from(t).get(0);if(a.window.unshift(o),a.window.length<4)return NaN;a.window.length>4&&a.window.pop();let h=0;for(let c=0;c<4;c++)h+=r[c]*a.window[3-c];return h/=s,e.precision(h)}}function Jc(e){return(t,i)=>{let r=!0;typeof t=="string"||t!==void 0&&(r=d.from(t).get(0));const s=e.get(e.data.high,0),n=e.get(e.data.low,0),a=e.get(e.data.close,1);if(isNaN(a))return r?e.precision(s-n):NaN;const o=Math.max(s-n,Math.abs(s-a),Math.abs(n-a));return e.precision(o)}}function eu(e){return(t,i,r,s)=>{const n=d.from(i).get(0),a=d.from(r).get(0);e.taState||(e.taState={});const o=s||`tsi_${n}_${a}`;e.taState[o]||(e.taState[o]={prevSource:NaN,ema1_pc_multiplier:2/(a+1),ema1_pc_value:NaN,ema1_pc_count:0,ema1_pc_sum:0,ema2_pc_multiplier:2/(n+1),ema2_pc_value:NaN,ema2_pc_count:0,ema2_pc_sum:0,ema1_abs_multiplier:2/(a+1),ema1_abs_value:NaN,ema1_abs_count:0,ema1_abs_sum:0,ema2_abs_multiplier:2/(n+1),ema2_abs_value:NaN,ema2_abs_count:0,ema2_abs_sum:0});const h=e.taState[o],c=d.from(t).get(0);if(isNaN(c))return NaN;const l=isNaN(h.prevSource)?NaN:c-h.prevSource;if(h.prevSource=c,isNaN(l))return NaN;const f=Math.abs(l);if(h.ema1_pc_count++,h.ema1_pc_count<=a?(h.ema1_pc_sum+=l,h.ema1_pc_count===a&&(h.ema1_pc_value=h.ema1_pc_sum/a)):h.ema1_pc_value=l*h.ema1_pc_multiplier+h.ema1_pc_value*(1-h.ema1_pc_multiplier),h.ema1_abs_count++,h.ema1_abs_count<=a?(h.ema1_abs_sum+=f,h.ema1_abs_count===a&&(h.ema1_abs_value=h.ema1_abs_sum/a)):h.ema1_abs_value=f*h.ema1_abs_multiplier+h.ema1_abs_value*(1-h.ema1_abs_multiplier),isNaN(h.ema1_pc_value)||isNaN(h.ema1_abs_value))return NaN;if(h.ema2_pc_count++,h.ema2_pc_count<=n?(h.ema2_pc_sum+=h.ema1_pc_value,h.ema2_pc_count===n&&(h.ema2_pc_value=h.ema2_pc_sum/n)):h.ema2_pc_value=h.ema1_pc_value*h.ema2_pc_multiplier+h.ema2_pc_value*(1-h.ema2_pc_multiplier),h.ema2_abs_count++,h.ema2_abs_count<=n?(h.ema2_abs_sum+=h.ema1_abs_value,h.ema2_abs_count===n&&(h.ema2_abs_value=h.ema2_abs_sum/n)):h.ema2_abs_value=h.ema1_abs_value*h.ema2_abs_multiplier+h.ema2_abs_value*(1-h.ema2_abs_multiplier),isNaN(h.ema2_pc_value)||isNaN(h.ema2_abs_value))return NaN;if(h.ema2_abs_value===0)return e.precision(0);const g=h.ema2_pc_value/h.ema2_abs_value;return e.precision(g)}}function tu(e){return(t,i,r,s)=>{e.taState||(e.taState={});const n=s||"valuewhen";e.taState[n]||(e.taState[n]={values:[]});const a=e.taState[n],o=d.from(t).get(0),h=d.from(i).get(0),c=d.from(r).get(0);if(o&&a.values.push(h),isNaN(c)||c<0)return NaN;const l=a.values.length-1-c;if(l<0)return NaN;const f=a.values[l];return typeof f=="number"?e.precision(f):f}}function iu(e){return(t,i,r)=>{const s=d.from(i).get(0);e.taState||(e.taState={});const n=r||`variance_${s}`;e.taState[n]||(e.taState[n]={window:[]});const a=e.taState[n],o=d.from(t).get(0);if(a.window.unshift(o),a.window.length<s)return NaN;a.window.length>s&&a.window.pop();let h=0,c=0;for(let g=0;g<s;g++)h+=a.window[g],c+=a.window[g]*a.window[g];const l=h/s,f=c/s-l*l;return e.precision(f)}}function ru(e){return(t,i)=>{e.taState||(e.taState={});const r=i||"vwap";e.taState[r]||(e.taState[r]={cumulativePV:0,cumulativeVolume:0,lastSessionDate:null});const s=e.taState[r],n=d.from(t).get(0),a=d.from(e.data.volume).get(0),o=d.from(e.data.openTime).get(0),h=new Date(o).toISOString().slice(0,10);if(s.lastSessionDate!==h&&(s.cumulativePV=0,s.cumulativeVolume=0,s.lastSessionDate=h),s.cumulativePV+=n*a,s.cumulativeVolume+=a,s.cumulativeVolume===0)return NaN;const c=s.cumulativePV/s.cumulativeVolume;return e.precision(c)}}function su(e){return(t,i,r)=>{const s=d.from(i).get(0);e.taState||(e.taState={});const n=r||`vwma_${s}`;e.taState[n]||(e.taState[n]={window:[],volumeWindow:[]});const a=e.taState[n],o=d.from(t).get(0),h=e.get(e.data.volume,0);if(a.window.unshift(o),a.volumeWindow.unshift(h),a.window.length<s)return NaN;a.window.length>s&&(a.window.pop(),a.volumeWindow.pop());let c=0,l=0;for(let g=0;g<s;g++)c+=a.window[g]*a.volumeWindow[g],l+=a.volumeWindow[g];const f=c/l;return e.precision(f)}}function nu(e){return t=>{e.taState||(e.taState={});const i=t||"wad";e.taState[i]||(e.taState[i]={cumulativeSum:0});const r=e.taState[i],s=e.get(e.data.close,0),n=e.get(e.data.high,0),a=e.get(e.data.low,0),o=e.get(e.data.close,1);if(isNaN(s)||isNaN(n)||isNaN(a))return e.precision(r.cumulativeSum);let h=0;if(!isNaN(o)){const c=Math.max(n,o),l=Math.min(a,o),f=s-o;f>0?h=s-l:f<0&&(h=s-c)}return r.cumulativeSum+=h,e.precision(r.cumulativeSum)}}function au(e){return(t,i,r)=>{const s=d.from(i).get(0);e.taState||(e.taState={});const n=r||`wma_${s}`;e.taState[n]||(e.taState[n]={window:[]});const a=e.taState[n],o=d.from(t).get(0);if(a.window.unshift(o),a.window.length<s)return NaN;a.window.length>s&&a.window.pop();let h=0,c=0;for(let f=0;f<s;f++){const g=s-f;h+=a.window[f]*g,c+=g}const l=h/c;return e.precision(l)}}function ou(e){return(t,i)=>{const r=d.from(t).get(0);e.taState||(e.taState={});const s=i||`wpr_${r}`;e.taState[s]||(e.taState[s]={highWindow:[],lowWindow:[]});const n=e.taState[s],a=e.get(e.data.high,0),o=e.get(e.data.low,0),h=e.get(e.data.close,0);if(isNaN(a)||isNaN(o)||isNaN(h))return NaN;if(n.highWindow.unshift(a),n.lowWindow.unshift(o),n.highWindow.length<r)return NaN;n.highWindow.length>r&&(n.highWindow.pop(),n.lowWindow.pop());let c=n.highWindow[0],l=n.lowWindow[0];for(let p=1;p<r;p++)n.highWindow[p]>c&&(c=n.highWindow[p]),n.lowWindow[p]<l&&(l=n.lowWindow[p]);const f=c-l;if(f===0)return e.precision(0);const g=(c-h)/f*-100;return e.precision(g)}}function hu(e){return t=>{const i=e.get(e.data.close,0),r=e.get(e.data.open,0),s=e.get(e.data.high,0),n=e.get(e.data.low,0),a=e.get(e.data.volume,0);if(isNaN(i)||isNaN(r)||isNaN(s)||isNaN(n)||isNaN(a))return NaN;const o=s-n;if(o===0)return e.precision(0);const h=(i-r)/o*a;return e.precision(h)}}var cu=Object.defineProperty,uu=(e,t,i)=>t in e?cu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,_=(e,t,i)=>uu(e,typeof t!="symbol"?t+"":t,i);const lu={accdist:Xh,alma:Zh,atr:Jh,barssince:ec,bb:tc,bbw:ic,cci:rc,change:sc,cmo:nc,cog:ac,correlation:oc,cross:hc,crossover:cc,crossunder:uc,cum:lc,dev:pc,dmi:fc,ema:mc,falling:dc,highest:gc,highestbars:xc,hma:yc,iii:wc,kc:bc,kcw:vc,linreg:_c,lowest:Sc,lowestbars:Ec,macd:Nc,median:Cc,mfi:kc,mode:Ic,mom:Ac,nvi:Tc,obv:Pc,param:Rc,percentile_linear_interpolation:Dc,percentile_nearest_rank:Mc,percentrank:Oc,pivothigh:Lc,pivotlow:Fc,pvi:jc,pvt:$c,range:Wc,rising:qc,rma:Uc,roc:Kc,rsi:zc,sar:Hc,sma:Gc,stdev:Yc,stoch:Qc,supertrend:Xc,swma:Zc,tr:Jc,tsi:eu,valuewhen:tu,variance:iu,vwap:ru,vwma:su,wad:nu,wma:au,wpr:ou,wvad:hu};class pu{constructor(t){this.context=t,_(this,"accdist"),_(this,"alma"),_(this,"atr"),_(this,"barssince"),_(this,"bb"),_(this,"bbw"),_(this,"cci"),_(this,"change"),_(this,"cmo"),_(this,"cog"),_(this,"correlation"),_(this,"cross"),_(this,"crossover"),_(this,"crossunder"),_(this,"cum"),_(this,"dev"),_(this,"dmi"),_(this,"ema"),_(this,"falling"),_(this,"highest"),_(this,"highestbars"),_(this,"hma"),_(this,"iii"),_(this,"kc"),_(this,"kcw"),_(this,"linreg"),_(this,"lowest"),_(this,"lowestbars"),_(this,"macd"),_(this,"median"),_(this,"mfi"),_(this,"mode"),_(this,"mom"),_(this,"nvi"),_(this,"obv"),_(this,"param"),_(this,"percentile_linear_interpolation"),_(this,"percentile_nearest_rank"),_(this,"percentrank"),_(this,"pivothigh"),_(this,"pivotlow"),_(this,"pvi"),_(this,"pvt"),_(this,"range"),_(this,"rising"),_(this,"rma"),_(this,"roc"),_(this,"rsi"),_(this,"sar"),_(this,"sma"),_(this,"stdev"),_(this,"stoch"),_(this,"supertrend"),_(this,"swma"),_(this,"tr"),_(this,"tsi"),_(this,"valuewhen"),_(this,"variance"),_(this,"vwap"),_(this,"vwma"),_(this,"wad"),_(this,"wma"),_(this,"wpr"),_(this,"wvad"),Object.entries(lu).forEach(([i,r])=>{this[i]=r(t)})}}class fu{constructor(t){this.context=t}logFormat(t,...i){return t.replace(/{(\d+)}/g,(r,s)=>i[s])}param(t,i=0,r){return d.from(t).get(i)}warning(t,...i){console.warn(this.logFormat(t,...i))}error(t,...i){console.error(this.logFormat(t,...i))}info(t,...i){console.log(this.logFormat(t,...i))}}class mu{constructor(t){this.context=t}param(t,i=0,r){return d.from(t).get(i)}tostring(t){return String(t)}tonumber(t){return Number(t)}lower(t){return String(t).toLowerCase()}upper(t){return String(t).toUpperCase()}trim(t){return String(t).trim()}repeat(t,i,r=""){return Array(i).fill(t).join(r||"")}replace_all(t,i,r){return String(t).replaceAll(i,r)}replace(t,i,r,s=0){const n=String(t),a=String(i),o=String(r),h=Math.floor(Number(s))||0;if(a==="")return n;let c=0,l=0;for(;;){const f=n.indexOf(a,c);if(f===-1)return n;if(l===h)return n.substring(0,f)+o+n.substring(f+a.length);l++,c=f+a.length}}contains(t,i){return String(t).includes(i)}endswith(t,i){return String(t).endsWith(i)}startswith(t,i){return String(t).startsWith(i)}pos(t,i){const r=String(t).indexOf(i);return r===-1?NaN:r}length(t){return String(t).length}match(t,i){return String(t).match(new RegExp(i))}split(t,i){return[String(t).split(i)]}substring(t,i,r){return String(t).substring(i,r)}format(t,...i){return t.replace(/{(\d+)}/g,(r,s)=>i[s])}}class du{constructor(t){this.context=t}param(t,i=0,r){return d.from(t).get(i)}get main_period(){return this.context.timeframe}get period(){return this.context.timeframe}get multiplier(){const t=parseInt(this.context.timeframe);return isNaN(t)?1:t}get isdwm(){return["D","W","M"].includes(this.context.timeframe.slice(-1))}get isdaily(){return this.context.timeframe.slice(-1)==="D"}get isweekly(){return this.context.timeframe.slice(-1)==="W"}get ismonthly(){return this.context.timeframe.slice(-1)==="M"}get isseconds(){return this.context.timeframe.slice(-1)==="S"}get isminutes(){return parseInt(this.context.timeframe).toString()==this.context.timeframe.trim()}get isintraday(){return!this.isdwm}from_seconds(t){return t<60?Math.ceil(t/5)*5+"S":t<60*60*24?Math.ceil(t/60):t<=60*60*24*7*52?t%(60*60*24*7)===0?Math.ceil(t/604800)+"W":Math.ceil(t/(60*60*24))+"D":"12M"}in_seconds(t){const i=parseInt(t),r=t.slice(-1);return r==="S"?i:r==="D"?i*60*60*24:r==="W"?i*60*60*24*7:r==="M"?i*60*60*24*30:isNaN(i)?0:i*60}}const gu=["series","title","color","linewidth","style","trackprice","histbase","offset","join","editable","show_last","display","format","precision","force_overlay"],xu={series:"series",title:"string",color:"string",linewidth:"number",style:"string",trackprice:"boolean",histbase:"number",offset:"number",join:"bool",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"};class yu{constructor(t){this.context=t}extractPlotOptions(t){const i={};for(let r in t)i[r]=d.from(t[r]).get(0);return i}plotchar(t,i,r){this.context.plots[i]||(this.context.plots[i]={data:[],options:this.extractPlotOptions(r),title:i});const s=d.from(t).get(0);this.context.plots[i].data.push({time:this.context.marketData[this.context.idx].openTime,value:s,options:{...this.extractPlotOptions(r),style:"char"}})}plot(...t){const i=Qt(t,gu,xu),{series:r,title:s,...n}=i,a=this.extractPlotOptions(n);this.context.plots[s]||(this.context.plots[s]={data:[],options:a,title:s});const o=d.from(r).get(0);this.context.plots[s].data.push({time:this.context.marketData[this.context.idx].openTime,value:o,options:{color:a.color,offset:a.offset}})}}class wu{constructor(t){this.context=t}get style_dashed(){return"dashed"}get style_solid(){return"solid"}get style_dotted(){return"dotted"}param(t,i=0,r){return d.from(t).get(i)}any(t,i,r,s,n,a,o){return this.context.pine.plot(t,{title:i,color:r,linestyle:s,linewidth:n,editable:a,display:o})}}var bu=Object.defineProperty,vu=(e,t,i)=>t in e?bu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,j=(e,t,i)=>vu(e,typeof t!="symbol"?t+"":t,i);const yr=class Lt{constructor({marketData:t,source:i,tickerId:r,timeframe:s,limit:n,sDate:a,eDate:o,fullContext:h}){j(this,"data",{open:new d([]),high:new d([]),low:new d([]),close:new d([]),volume:new d([]),hl2:new d([]),hlc3:new d([]),ohlc4:new d([]),hlcc4:new d([])}),j(this,"indicator"),j(this,"cache",{}),j(this,"taState",{}),j(this,"isSecondaryContext",!1),j(this,"NA",NaN),j(this,"lang"),j(this,"pine"),j(this,"idx",0),j(this,"params",{}),j(this,"const",{}),j(this,"var",{}),j(this,"let",{}),j(this,"result"),j(this,"plots",{}),j(this,"marketData"),j(this,"source"),j(this,"tickerId"),j(this,"timeframe",""),j(this,"limit"),j(this,"sDate"),j(this,"eDate"),j(this,"fullContext"),j(this,"pineTSCode"),this.marketData=t,this.source=i,this.tickerId=r,this.timeframe=s,this.limit=n,this.sDate=a,this.eDate=o,this.fullContext=h||this;const c=new qo(this),l={na:c.na.bind(c),color:c.color,nz:c.nz.bind(c),indicator:c.indicator.bind(c),fixnan:c.fixnan.bind(c),alertcondition:c.alertcondition.bind(c),bool:c.bool.bind(c)},f=this;this.pine={input:new uh(this),ta:new pu(this),math:new qh(this),request:new Qh(this),array:new ma(this),map:new Aa(this),matrix:new Ro(this),syminfo:null,timeframe:new du(this),barstate:new Vo(this),get bar_index(){return f.idx},get last_bar_index(){return f.data.close.length-1},get last_bar_time(){return f.data.openTime.get(f.data.openTime.length-1)},get timenow(){return new Date().getTime()},log:new fu(this),str:new mu(this),...l,...Xn};const g=new yu(this),p=new wu(this);this.bindContextObject(g,["plot","plotchar"]),this.bindContextObject(p,["any","style_dashed","style_solid","style_dotted","param"],"hline")}bindContextObject(t,i,r=""){r&&!this.pine[r]&&(this.pine[r]={});const s=r?this.pine[r]:this.pine;for(const n of i)typeof t[n]=="function"?s[n]=t[n].bind(t):s[n]=t[n]}init(t,i,r=0){let s;return i instanceof d?s=i.get(0):Array.isArray(i)?Array.isArray(i[0])?s=i[0]:s=i[i.length-1+r]:s=i,t?t instanceof d?(t.data[t.data.length-1]=s,t):Array.isArray(t)?(t[t.length-1]=s,new d(t)):new d([s]):new d([s])}initVar(t,i){if(t)return t;let r;return i instanceof d?r=i.get(0):Array.isArray(i)?Array.isArray(i[0])?r=i[0]:r=this.precision(i[i.length-1]):r=this.precision(i),new d([r])}precision(t,i=10){const r=10**i;return typeof t=="number"?Math.round(t*r)/r:t}param(t,i,r){return typeof t=="string"?t:t instanceof d?i?new d(t.data,t.offset+i):t:!Array.isArray(t)&&typeof t=="object"?t:(this.params[r]||(this.params[r]=[]),Array.isArray(t)?new d(t,i||0):(this.params[r].length===0?this.params[r].push(t):this.params[r][this.params[r].length-1]=t,new d(this.params[r],0)))}get(t,i){if(t instanceof d)return t.get(i);if(Array.isArray(t)){const r=t.length-1-i;return r<0||r>=t.length?NaN:t[r]}return t}set(t,i){if(t instanceof d){t.set(0,i);return}if(Array.isArray(t)){t.length>0?t[t.length-1]=i:t.push(i);return}}get math(){return this._showDeprecationWarning("const math = context.math","const { math, ta, input } = context.pine"),this.pine.math}get ta(){return this._showDeprecationWarning("const ta = context.ta","const { ta, math, input } = context.pine"),this.pine.ta}get input(){return this._showDeprecationWarning("const input = context.input","const { input, math, ta } = context.pine"),this.pine.input}get request(){return this._showDeprecationWarning("const request = context.request","const { request, math, ta } = context.pine"),this.pine.request}get array(){return this._showDeprecationWarning("const array = context.array","const { array, math, ta } = context.pine"),this.pine.array}get core(){return this._showDeprecationWarning("context.core.*","context.pine (e.g., const { na, plotchar, color, plot, nz } = context.pine)"),{na:this.pine.na,plotchar:this.pine.plotchar,color:this.pine.color,plot:this.pine.plot,nz:this.pine.nz}}_showDeprecationWarning(t,i){const r=`${t}->${i}`;Lt._deprecationWarningsShown.has(r)||(Lt._deprecationWarningsShown.add(r),typeof window<"u"?console.warn("%c[WARNING]%c %s syntax is deprecated. Use %s instead. This will be removed in a future version.","color: #FFA500; font-weight: bold;","color: #FFA500;",t,i):console.warn(`\x1B[33m[WARNING] ${t} syntax is deprecated. Use ${i} instead. This will be removed in a future version.\x1B[0m`))}};j(yr,"_deprecationWarningsShown",new Set);let _i=yr;var _u=Object.defineProperty,Su=(e,t,i)=>t in e?_u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,K=(e,t,i)=>Su(e,typeof t!="symbol"?t+"":t,i);class wr{constructor(t,i,r,s,n,a){this.source=t,this.tickerId=i,this.timeframe=r,this.limit=s,this.sDate=n,this.eDate=a,K(this,"data",[]),K(this,"open",[]),K(this,"high",[]),K(this,"low",[]),K(this,"close",[]),K(this,"volume",[]),K(this,"hl2",[]),K(this,"hlc3",[]),K(this,"ohlc4",[]),K(this,"hlcc4",[]),K(this,"openTime",[]),K(this,"closeTime",[]),K(this,"_readyPromise",null),K(this,"_ready",!1),K(this,"_debugSettings",{ln:!1,debug:!1}),K(this,"_transpiledCode",null),K(this,"_isSecondaryContext",!1),K(this,"_syminfo"),this._readyPromise=new Promise(o=>{this.loadMarketData(t,i,r,s,n,a).then(h=>{const c=h;this.data=c;const l=c.map(C=>C.open),f=c.map(C=>C.close),g=c.map(C=>C.high),p=c.map(C=>C.low),x=c.map(C=>C.volume),y=c.map(C=>(C.high+C.low+C.close)/3),w=c.map(C=>(C.high+C.low)/2),E=c.map(C=>(C.high+C.low+C.open+C.close)/4),A=c.map(C=>(C.high+C.low+C.close+C.close)/4),k=c.map(C=>C.openTime),P=c.map(C=>C.closeTime);this.open=l,this.close=f,this.high=g,this.low=p,this.volume=x,this.hl2=w,this.hlc3=y,this.ohlc4=E,this.hlcc4=A,this.openTime=k,this.closeTime=P,t&&t.getSymbolInfo?t.getSymbolInfo(i).then(C=>{this._syminfo=C,this._ready=!0,o(!0)}).catch(C=>{console.warn("Failed to get symbol info, using default values:",C),this._ready=!0,o(!0)}):(this._ready=!0,o(!0))})})}get transpiledCode(){return this._transpiledCode}markAsSecondary(){this._isSecondaryContext=!0}setDebugSettings({ln:t,debug:i}){this._debugSettings.ln=t,this._debugSettings.debug=i}async loadMarketData(t,i,r,s,n,a){return Array.isArray(t)?t:t.getMarketData(i,r,s,n,a)}async ready(){if(this._ready)return!0;if(!this._readyPromise)throw new Error("PineTS is not ready");return this._readyPromise}run(t,i,r){if(r&&r>0){const s=typeof this.eDate>"u"&&!Array.isArray(this.source);return this._runPaginated(t,i,r,s)}else return this._runComplete(t,i)}async _runComplete(t,i){await this.ready(),i||(i=this.data.length);const r=this._initializeContext(t,this._isSecondaryContext);return this._transpiledCode=this._transpileCode(t),await this._executeIterations(r,this._transpiledCode,this.data.length-i,this.data.length),r}async*_runPaginated(t,i,r,s=!1){await this.ready(),i||(i=this.data.length);const n=this._initializeContext(t,this._isSecondaryContext);this._transpiledCode=this._transpileCode(t);let a=this.data.length-i;for(;;){const o=this.data.length-a;if(o>0){const l=Math.min(o,r),f=this._getResultLength(n.result);await this._executeIterations(n,this._transpiledCode,a,a+l),a+=l,yield this._createPageContext(n,f);continue}if(!s||Array.isArray(this.source))break;const{newCandles:h,updatedLastCandle:c}=await this._updateMarketData();if(h===0&&!c){yield null;continue}this._removeLastResult(n),a=this.data.length-(h+1),n.pine.barstate.setLive()}}_getResultLength(t){if(Array.isArray(t))return t.length;if(typeof t=="object"&&t!==null){const i=Object.keys(t);if(i.length>0&&Array.isArray(t[i[0]]))return t[i[0]].length}return 0}_createPageContext(t,i){const r=new _i({marketData:this.data,source:this.source,tickerId:this.tickerId,timeframe:this.timeframe,limit:this.limit,sDate:this.sDate,eDate:this.eDate,fullContext:t});if(r.pineTSCode=t.pineTSCode,r.idx=t.idx,Array.isArray(t.result))r.result=t.result.slice(i);else if(typeof t.result=="object"&&t.result!==null){r.result={};for(let s in t.result)Array.isArray(t.result[s])?r.result[s]=t.result[s].slice(i):r.result[s]=t.result[s]}else r.result=t.result;return r.plots={...t.plots},r}async _updateMarketData(t){if(Array.isArray(this.source))return{newCandles:0,updatedLastCandle:!1};const i=this.source,r=this.data.length-1,s=this.data[r].openTime;try{const n=await i.getMarketData(this.tickerId,this.timeframe,void 0,s,t);if(!n||n.length===0)return{newCandles:0,updatedLastCandle:!1};let a=!1,o=0;for(let h=0;h<n.length;h++){const c=n[h];c.openTime===s?(this._replaceCandle(r,c),a=!0):c.openTime>s&&(this._appendCandle(c),o++)}return{newCandles:o,updatedLastCandle:a}}catch(n){return console.error("Error updating market data:",n),{newCandles:0,updatedLastCandle:!1}}}_replaceCandle(t,i){this.data[t]=i,this.open[t]=i.open,this.close[t]=i.close,this.high[t]=i.high,this.low[t]=i.low,this.volume[t]=i.volume,this.hl2[t]=(i.high+i.low)/2,this.hlc3[t]=(i.high+i.low+i.close)/3,this.ohlc4[t]=(i.high+i.low+i.open+i.close)/4,this.hlcc4[t]=(i.high+i.low+i.close+i.close)/4,this.openTime[t]=i.openTime,this.closeTime[t]=i.closeTime}_appendCandle(t){this.data.push(t),this.open.push(t.open),this.close.push(t.close),this.high.push(t.high),this.low.push(t.low),this.volume.push(t.volume),this.hl2.push((t.high+t.low)/2),this.hlc3.push((t.high+t.low+t.close)/3),this.ohlc4.push((t.high+t.low+t.open+t.close)/4),this.hlcc4.push((t.high+t.low+t.close+t.close)/4),this.openTime.push(t.openTime),this.closeTime.push(t.closeTime)}_removeLastResult(t){if(Array.isArray(t.result))t.result.pop();else if(typeof t.result=="object"&&t.result!==null)for(let i in t.result)Array.isArray(t.result[i])&&t.result[i].pop();t.data.close.data.pop(),t.data.open.data.pop(),t.data.high.data.pop(),t.data.low.data.pop(),t.data.volume.data.pop(),t.data.hl2.data.pop(),t.data.hlc3.data.pop(),t.data.ohlc4.data.pop(),t.data.hlcc4.data.pop(),t.data.openTime.data.pop(),t.data.closeTime&&t.data.closeTime.data.pop()}_initializeContext(t,i=!1){const r=new _i({marketData:this.data,source:this.source,tickerId:this.tickerId,timeframe:this.timeframe,limit:this.limit,sDate:this.sDate,eDate:this.eDate});return r.pine.syminfo=this._syminfo,r.pineTSCode=t,r.isSecondaryContext=i,r.data.close=new d([]),r.data.open=new d([]),r.data.high=new d([]),r.data.low=new d([]),r.data.volume=new d([]),r.data.hl2=new d([]),r.data.hlc3=new d([]),r.data.ohlc4=new d([]),r.data.hlcc4=new d([]),r.data.openTime=new d([]),r.data.closeTime=new d([]),r}_transpileCode(t){return fn.bind(this)(t,this._debugSettings)}async _executeIterations(t,i,r,s){const n=["const","var","let","params"];for(let a=r;a<s;a++){t.idx=a,t.data.close.data.push(this.close[a]),t.data.open.data.push(this.open[a]),t.data.high.data.push(this.high[a]),t.data.low.data.push(this.low[a]),t.data.volume.data.push(this.volume[a]),t.data.hl2.data.push(this.hl2[a]),t.data.hlc3.data.push(this.hlc3[a]),t.data.ohlc4.data.push(this.ohlc4[a]),t.data.hlcc4.data.push(this.hlcc4[a]),t.data.openTime.data.push(this.openTime[a]),t.data.closeTime.data.push(this.closeTime[a]);const o=await i(t);if(typeof o=="object"){typeof t.result!="object"&&(t.result={});for(let h in o){t.result[h]===void 0&&(t.result[h]=[]);let c;o[h]instanceof d?c=o[h].get(0):Array.isArray(o[h])?c=o[h][o[h].length-1]:c=o[h],t.result[h].push(c)}}else Array.isArray(t.result)||(t.result=[]),t.result.push(o);for(let h of n)for(let c in t[h]){const l=t[h][c];if(l instanceof d){const f=l.get(0);l.data.push(f)}else if(Array.isArray(l)){const f=l[l.length-1];l.push(f)}}}}}var Eu=Object.defineProperty,Nu=(e,t,i)=>t in e?Eu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Bt=(e,t,i)=>Nu(e,typeof t!="symbol"?t+"":t,i);const Si="https://api.binance.com/api/v3",kt={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",45:null,60:"1h",120:"2h",180:null,240:"4h","4H":"4h","1D":"1d",D:"1d","1W":"1w",W:"1w","1M":"1M",M:"1M"};class Cu{constructor(t=5*60*1e3){Bt(this,"cache"),Bt(this,"cacheDuration"),this.cache=new Map,this.cacheDuration=t}generateKey(t){return Object.entries(t).filter(([i,r])=>r!==void 0).map(([i,r])=>`${i}:${r}`).join("|")}get(t){const i=this.generateKey(t),r=this.cache.get(i);return r?Date.now()-r.timestamp>this.cacheDuration?(this.cache.delete(i),null):r.data:null}set(t,i){const r=this.generateKey(t);this.cache.set(r,{data:i,timestamp:Date.now()})}clear(){this.cache.clear()}cleanup(){const t=Date.now();for(const[i,r]of this.cache.entries())t-r.timestamp>this.cacheDuration&&this.cache.delete(i)}}class ku{constructor(){Bt(this,"cacheManager"),this.cacheManager=new Cu(5*60*1e3)}async getMarketDataInterval(t,i,r,s){try{const n=kt[i.toUpperCase()];if(!n)return console.error(`Unsupported timeframe: ${i}`),[];const a={"1m":60*1e3,"3m":3*60*1e3,"5m":5*60*1e3,"15m":15*60*1e3,"30m":30*60*1e3,"1h":60*60*1e3,"2h":2*60*60*1e3,"4h":4*60*60*1e3,"1d":24*60*60*1e3,"1w":7*24*60*60*1e3,"1M":30*24*60*60*1e3};let o=[],h=r;const c=s,l=a[n];if(!l)return console.error(`Duration not defined for interval: ${n}`),[];for(;h<c;){const f=Math.min(h+1e3*l,c),g=await this.getMarketData(t,i,1e3,h,f);if(g.length===0)break;o=o.concat(g),h=g[g.length-1].closeTime+1}return o}catch(n){return console.error("Error in getMarketDataInterval:",n),[]}}async getMarketData(t,i,r,s,n){try{const a=n!==void 0,o={tickerId:t,timeframe:i,limit:r,sDate:s,eDate:n};if(a){const g=this.cacheManager.get(o);if(g)return g}const h=kt[i.toUpperCase()];if(!h)return console.error(`Unsupported timeframe: ${i}`),[];if(this.shouldPaginate(i,r,s,n)&&s&&n){const g=await this.getMarketDataInterval(t,i,s,n),p=r?g.slice(0,r):g;return this.cacheManager.set(o,p),p}let c=`${Si}/klines?symbol=${t}&interval=${h}`;r&&(c+=`&limit=${Math.min(r,1e3)}`),s&&(c+=`&startTime=${s}`),n&&(c+=`&endTime=${n}`);const l=await fetch(c);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);const f=(await l.json()).map(g=>({openTime:parseInt(g[0]),open:parseFloat(g[1]),high:parseFloat(g[2]),low:parseFloat(g[3]),close:parseFloat(g[4]),volume:parseFloat(g[5]),closeTime:parseInt(g[6]),quoteAssetVolume:parseFloat(g[7]),numberOfTrades:parseInt(g[8]),takerBuyBaseAssetVolume:parseFloat(g[9]),takerBuyQuoteAssetVolume:parseFloat(g[10]),ignore:g[11]}));return a&&this.cacheManager.set(o,f),f}catch(a){return console.error("Error in binance.klines:",a),[]}}shouldPaginate(t,i,r,s){if(i&&i>1e3)return!0;if(r&&s){const n=kt[t.toUpperCase()],a={"1m":60*1e3,"3m":3*60*1e3,"5m":5*60*1e3,"15m":15*60*1e3,"30m":30*60*1e3,"1h":60*60*1e3,"2h":2*60*60*1e3,"4h":4*60*60*1e3,"1d":24*60*60*1e3,"1w":7*24*60*60*1e3,"1M":30*24*60*60*1e3}[n];if(a)return Math.ceil((s-r)/a)>1e3}return!1}async getSymbolInfo(t){try{let i="crypto",r=Si,s=t,n="";t.endsWith(".P")?(i="futures",s=t.replace(".P",""),r="https://fapi.binance.com/fapi/v1",n="Perpetual"):t.includes("_")&&(i="futures",s=t,r="https://dapi.binance.com/dapi/v1",n="Delivery");const a=i==="crypto"?`${r}/exchangeInfo?symbol=${s}`:`${r}/exchangeInfo`,o=await fetch(a);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);const h=(await o.json()).symbols;if(!h||h.length===0)return console.error(`Symbol ${t} not found`),null;const c=i==="futures"?h.find(k=>k.symbol===s):h[0];if(!c)return console.error(`Symbol ${s} not found in exchange info`),null;const l=c.filters?.find(k=>k.filterType==="PRICE_FILTER"),f=c.filters?.find(k=>k.filterType==="LOT_SIZE"),g=l?parseFloat(l.tickSize):.01,p=f?parseFloat(f.minQty):0,x=Math.round(1/g),y=c.baseAsset,w=c.quoteAsset,E=n?` ${n}`:"",A=`${y} / ${w}${E}`;return{ticker:t,tickerid:`BINANCE:${t}`,prefix:"BINANCE",root:y,description:A,type:i,main_tickerid:`BINANCE:${t}`,current_contract:n,isin:"",basecurrency:y,currency:w,timezone:"Etc/UTC",country:"",mintick:g,pricescale:x,minmove:1,pointvalue:c.contractSize||1,mincontract:p,session:"24x7",volumetype:"base",expiration_date:c.deliveryDate||0,employees:0,industry:"",sector:"",shareholders:0,shares_outstanding_float:0,shares_outstanding_total:0,recommendations_buy:0,recommendations_buy_strong:0,recommendations_date:0,recommendations_hold:0,recommendations_sell:0,recommendations_sell_strong:0,recommendations_total:0,target_price_average:0,target_price_date:0,target_price_estimates:0,target_price_high:0,target_price_low:0,target_price_median:0}}catch(i){return console.error("Error in binance.exchangeInfo:",i),null}}}var Iu=Object.defineProperty,Au=(e,t,i)=>t in e?Iu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,It=(e,t,i)=>Au(e,typeof t!="symbol"?t+"":t,i);const Tu=br(import.meta.url),Pu=Xe.dirname(Tu);class Ru{constructor(t){if(It(this,"dataCache",new Map),It(this,"exchangeInfoCache",{}),It(this,"dataDirectory"),t)this.dataDirectory=t;else{const i=Xe.resolve(Pu,"../../../");this.dataDirectory=Xe.join(i,"tests","compatibility","_data")}}getDataFileName(t,i,r,s){return r&&s?`${t}-${i}-${r}-${s}.json`:null}loadDataFromFile(t){const i=`file:${t}`;if(this.dataCache.has(i))return this.dataCache.get(i);const r=Xe.join(this.dataDirectory,t);if(!Fe.existsSync(r))throw new Error(`Mock data file not found: ${r}`);const s=Fe.readFileSync(r,"utf-8"),n=JSON.parse(s);return this.dataCache.set(i,n),n}findDataFile(t,i,r,s){if(!Fe.existsSync(this.dataDirectory))return null;const n=Fe.readdirSync(this.dataDirectory).filter(h=>h.endsWith(".json"));if(r&&s){const h=`${t}-${i}-${r}-${s}.json`;if(n.includes(h))return h}const a=new RegExp(`^${t}-${i}-(\\d+)-(\\d+)\\.json$`),o=n.filter(h=>a.test(h)).map(h=>{const c=h.match(a);return{file:h,startTime:parseInt(c[1]),endTime:parseInt(c[2])}}).sort((h,c)=>c.endTime-h.endTime);if(o.length===0)return null;if(r&&s){const h=o.find(c=>c.startTime<=r&&c.endTime>=s);if(h)return h.file}return o[0].file}filterData(t,i,r,s){let n=t;return(i||r)&&(n=t.filter(a=>{const o=!i||a.openTime>=i,h=!r||a.openTime<=r;return o&&h})),n.sort((a,o)=>a.openTime-o.openTime),s&&s>0&&(n=n.slice(0,s)),n}normalizeTimeframe(t){return{1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h","4H":"4h","1D":"1d",D:"1d","1W":"1w",W:"1w","1M":"1M",M:"1M"}[t.toUpperCase()]||t.toLowerCase()}async getMarketData(t,i,r,s,n){try{const a=this.normalizeTimeframe(i),o=this.findDataFile(t,a,s,n);if(!o)return console.warn(`No mock data file found for ${t} ${a}. Searched in: ${this.dataDirectory}`),[];const h=this.loadDataFromFile(o);return this.filterData(h,s,n,r)}catch(a){return console.error("Error in MockProvider.getMarketData:",a),[]}}loadExchangeInfo(t){if(this.exchangeInfoCache[t])return this.exchangeInfoCache[t];const i=t==="spot"?"api-exchangeInfo.json":"fapi-exchangeInfo.json",r=Xe.join(this.dataDirectory,i);if(!Fe.existsSync(r))return console.warn(`Exchange info file not found: ${r}`),null;try{const s=Fe.readFileSync(r,"utf-8"),n=JSON.parse(s);return this.exchangeInfoCache[t]=n,n}catch(s){return console.error(`Error loading exchange info from ${i}:`,s),null}}async getSymbolInfo(t){try{let i="crypto",r=t,s="";t.endsWith(".P")?(i="futures",r=t.replace(".P",""),s="Perpetual"):t.includes("_")&&(i="futures",r=t,s="Delivery");const n=this.loadExchangeInfo(i==="futures"?"futures":"spot");if(!n||!n.symbols)return console.error(`Exchange info not available for ${i}`),null;const a=n.symbols.find(w=>w.symbol===r);if(!a)return console.error(`Symbol ${r} not found in ${i} exchange info`),null;const o=a.filters?.find(w=>w.filterType==="PRICE_FILTER"),h=a.filters?.find(w=>w.filterType==="LOT_SIZE"),c=o?parseFloat(o.tickSize):.01,l=h?parseFloat(h.minQty):0,f=Math.round(1/c),g=a.baseAsset,p=a.quoteAsset,x=s?` ${s}`:"",y=`${g} / ${p}${x}`;return{ticker:t,tickerid:`BINANCE:${t}`,prefix:"BINANCE",root:g,description:y,type:i,main_tickerid:`BINANCE:${t}`,current_contract:s,isin:"",basecurrency:g,currency:p,timezone:"Etc/UTC",country:"",mintick:c,pricescale:f,minmove:1,pointvalue:a.contractSize||1,mincontract:l,session:"24x7",volumetype:"base",expiration_date:a.deliveryDate||0,employees:0,industry:"",sector:"",shareholders:0,shares_outstanding_float:0,shares_outstanding_total:0,recommendations_buy:0,recommendations_buy_strong:0,recommendations_date:0,recommendations_hold:0,recommendations_sell:0,recommendations_sell_strong:0,recommendations_total:0,target_price_average:0,target_price_date:0,target_price_estimates:0,target_price_high:0,target_price_low:0,target_price_median:0}}catch(i){return console.error("Error in MockProvider.getSymbolInfo:",i),null}}clearCache(){this.dataCache.clear(),this.exchangeInfoCache={}}setDataDirectory(t){this.dataDirectory=t,this.clearCache()}}const Du=typeof process<"u"&&process.versions&&process.versions.node;let dt=null;if(Du)try{dt=new Ru}catch{dt=null}const Ou={Binance:new ku,...dt?{Mock:dt}:{}};export{_i as Context,wr as PineTS,Ou as Provider};
|
|
117
|
+
//# sourceMappingURL=pinets.min.es.js.map
|