pinets-cli 0.1.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/LICENSE +661 -0
- package/README.md +316 -0
- package/dist/pinets-cli.dev.cjs +4713 -0
- package/dist/pinets-cli.dev.cjs.map +1 -0
- package/dist/pinets-cli.min.cjs +149 -0
- package/dist/pinets-cli.min.cjs.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* pinets-cli - CLI for PineTS
|
|
4
|
+
* Copyright (C) 2025 Alaa-eddine KADDOURI
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*/
|
|
11
|
+
"use strict";var ge=require("node:module"),Xt=require("fs"),re=require("path"),ls=require("url"),it=typeof document<"u"?document.currentScript:null;function nr(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(i){if(i!=="default"){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}}),e.default=t,Object.freeze(e)}var te=nr(Xt),le=nr(re);function ps(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ft={},be={},_e={},bi;function Ve(){if(bi)return _e;bi=1;class t extends Error{constructor(r,s,a){super(a),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=s,this.exitCode=r,this.nestedError=void 0}}class e extends t{constructor(r){super(1,"commander.invalidArgument",r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}return _e.CommanderError=t,_e.InvalidArgumentError=e,_e}var _i;function ui(){if(_i)return be;_i=1;const{InvalidArgumentError:t}=Ve();class e{constructor(s,a){switch(this.description=a||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,s[0]){case"<":this.required=!0,this._name=s.slice(1,-1);break;case"[":this.required=!1,this._name=s.slice(1,-1);break;default:this.required=!0,this._name=s;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(s,a){return a===this.defaultValue||!Array.isArray(a)?[s]:(a.push(s),a)}default(s,a){return this.defaultValue=s,this.defaultValueDescription=a,this}argParser(s){return this.parseArg=s,this}choices(s){return this.argChoices=s.slice(),this.parseArg=(a,n)=>{if(!this.argChoices.includes(a))throw new t(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(a,n):a},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function i(r){const s=r.name()+(r.variadic===!0?"...":"");return r.required?"<"+s+">":"["+s+"]"}return be.Argument=e,be.humanReadableArgName=i,be}var Ee={};const ds=ge.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:it&&it.tagName.toUpperCase()==="SCRIPT"&&it.src||new URL("pinets-cli.min.cjs",document.baseURI).href);function fs(){return ds("node:events")}const ms=ge.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:it&&it.tagName.toUpperCase()==="SCRIPT"&&it.src||new URL("pinets-cli.min.cjs",document.baseURI).href);function gs(){return ms("node:child_process")}const xs=ge.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:it&&it.tagName.toUpperCase()==="SCRIPT"&&it.src||new URL("pinets-cli.min.cjs",document.baseURI).href);function ys(){return xs("node:path")}const ws=ge.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:it&&it.tagName.toUpperCase()==="SCRIPT"&&it.src||new URL("pinets-cli.min.cjs",document.baseURI).href);function vs(){return ws("node:fs")}const bs=ge.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:it&&it.tagName.toUpperCase()==="SCRIPT"&&it.src||new URL("pinets-cli.min.cjs",document.baseURI).href);function _s(){return bs("node:process")}var Se={},Ei;function ar(){if(Ei)return Se;Ei=1;const{humanReadableArgName:t}=ui();class e{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(s){this.helpWidth=this.helpWidth??s.helpWidth??80}visibleCommands(s){const a=s.commands.filter(o=>!o._hidden),n=s._getHelpCommand();return n&&!n._hidden&&a.push(n),this.sortSubcommands&&a.sort((o,u)=>o.name().localeCompare(u.name())),a}compareOptions(s,a){const n=o=>o.short?o.short.replace(/^-/,""):o.long.replace(/^--/,"");return n(s).localeCompare(n(a))}visibleOptions(s){const a=s.options.filter(o=>!o.hidden),n=s._getHelpOption();if(n&&!n.hidden){const o=n.short&&s._findOption(n.short),u=n.long&&s._findOption(n.long);!o&&!u?a.push(n):n.long&&!u?a.push(s.createOption(n.long,n.description)):n.short&&!o&&a.push(s.createOption(n.short,n.description))}return this.sortOptions&&a.sort(this.compareOptions),a}visibleGlobalOptions(s){if(!this.showGlobalOptions)return[];const a=[];for(let n=s.parent;n;n=n.parent){const o=n.options.filter(u=>!u.hidden);a.push(...o)}return this.sortOptions&&a.sort(this.compareOptions),a}visibleArguments(s){return s._argsDescription&&s.registeredArguments.forEach(a=>{a.description=a.description||s._argsDescription[a.name()]||""}),s.registeredArguments.find(a=>a.description)?s.registeredArguments:[]}subcommandTerm(s){const a=s.registeredArguments.map(n=>t(n)).join(" ");return s._name+(s._aliases[0]?"|"+s._aliases[0]:"")+(s.options.length?" [options]":"")+(a?" "+a:"")}optionTerm(s){return s.flags}argumentTerm(s){return s.name()}longestSubcommandTermLength(s,a){return a.visibleCommands(s).reduce((n,o)=>Math.max(n,this.displayWidth(a.styleSubcommandTerm(a.subcommandTerm(o)))),0)}longestOptionTermLength(s,a){return a.visibleOptions(s).reduce((n,o)=>Math.max(n,this.displayWidth(a.styleOptionTerm(a.optionTerm(o)))),0)}longestGlobalOptionTermLength(s,a){return a.visibleGlobalOptions(s).reduce((n,o)=>Math.max(n,this.displayWidth(a.styleOptionTerm(a.optionTerm(o)))),0)}longestArgumentTermLength(s,a){return a.visibleArguments(s).reduce((n,o)=>Math.max(n,this.displayWidth(a.styleArgumentTerm(a.argumentTerm(o)))),0)}commandUsage(s){let a=s._name;s._aliases[0]&&(a=a+"|"+s._aliases[0]);let n="";for(let o=s.parent;o;o=o.parent)n=o.name()+" "+n;return n+a+" "+s.usage()}commandDescription(s){return s.description()}subcommandDescription(s){return s.summary()||s.description()}optionDescription(s){const a=[];if(s.argChoices&&a.push(`choices: ${s.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),s.defaultValue!==void 0&&(s.required||s.optional||s.isBoolean()&&typeof s.defaultValue=="boolean")&&a.push(`default: ${s.defaultValueDescription||JSON.stringify(s.defaultValue)}`),s.presetArg!==void 0&&s.optional&&a.push(`preset: ${JSON.stringify(s.presetArg)}`),s.envVar!==void 0&&a.push(`env: ${s.envVar}`),a.length>0){const n=`(${a.join(", ")})`;return s.description?`${s.description} ${n}`:n}return s.description}argumentDescription(s){const a=[];if(s.argChoices&&a.push(`choices: ${s.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),s.defaultValue!==void 0&&a.push(`default: ${s.defaultValueDescription||JSON.stringify(s.defaultValue)}`),a.length>0){const n=`(${a.join(", ")})`;return s.description?`${s.description} ${n}`:n}return s.description}formatItemList(s,a,n){return a.length===0?[]:[n.styleTitle(s),...a,""]}groupItems(s,a,n){const o=new Map;return s.forEach(u=>{const c=n(u);o.has(c)||o.set(c,[])}),a.forEach(u=>{const c=n(u);o.has(c)||o.set(c,[]),o.get(c).push(u)}),o}formatHelp(s,a){const n=a.padWidth(s,a),o=a.helpWidth??80;function u(x,E){return a.formatItem(x,n,E,a)}let c=[`${a.styleTitle("Usage:")} ${a.styleUsage(a.commandUsage(s))}`,""];const h=a.commandDescription(s);h.length>0&&(c=c.concat([a.boxWrap(a.styleCommandDescription(h),o),""]));const d=a.visibleArguments(s).map(x=>u(a.styleArgumentTerm(a.argumentTerm(x)),a.styleArgumentDescription(a.argumentDescription(x))));if(c=c.concat(this.formatItemList("Arguments:",d,a)),this.groupItems(s.options,a.visibleOptions(s),x=>x.helpGroupHeading??"Options:").forEach((x,E)=>{const S=x.map(p=>u(a.styleOptionTerm(a.optionTerm(p)),a.styleOptionDescription(a.optionDescription(p))));c=c.concat(this.formatItemList(E,S,a))}),a.showGlobalOptions){const x=a.visibleGlobalOptions(s).map(E=>u(a.styleOptionTerm(a.optionTerm(E)),a.styleOptionDescription(a.optionDescription(E))));c=c.concat(this.formatItemList("Global Options:",x,a))}return this.groupItems(s.commands,a.visibleCommands(s),x=>x.helpGroup()||"Commands:").forEach((x,E)=>{const S=x.map(p=>u(a.styleSubcommandTerm(a.subcommandTerm(p)),a.styleSubcommandDescription(a.subcommandDescription(p))));c=c.concat(this.formatItemList(E,S,a))}),c.join(`
|
|
12
|
+
`)}displayWidth(s){return i(s).length}styleTitle(s){return s}styleUsage(s){return s.split(" ").map(a=>a==="[options]"?this.styleOptionText(a):a==="[command]"?this.styleSubcommandText(a):a[0]==="["||a[0]==="<"?this.styleArgumentText(a):this.styleCommandText(a)).join(" ")}styleCommandDescription(s){return this.styleDescriptionText(s)}styleOptionDescription(s){return this.styleDescriptionText(s)}styleSubcommandDescription(s){return this.styleDescriptionText(s)}styleArgumentDescription(s){return this.styleDescriptionText(s)}styleDescriptionText(s){return s}styleOptionTerm(s){return this.styleOptionText(s)}styleSubcommandTerm(s){return s.split(" ").map(a=>a==="[options]"?this.styleOptionText(a):a[0]==="["||a[0]==="<"?this.styleArgumentText(a):this.styleSubcommandText(a)).join(" ")}styleArgumentTerm(s){return this.styleArgumentText(s)}styleOptionText(s){return s}styleArgumentText(s){return s}styleSubcommandText(s){return s}styleCommandText(s){return s}padWidth(s,a){return Math.max(a.longestOptionTermLength(s,a),a.longestGlobalOptionTermLength(s,a),a.longestSubcommandTermLength(s,a),a.longestArgumentTermLength(s,a))}preformatted(s){return/\n[^\S\r\n]/.test(s)}formatItem(s,a,n,o){const c=" ".repeat(2);if(!n)return c+s;const h=s.padEnd(a+s.length-o.displayWidth(s)),d=2,m=(this.helpWidth??80)-a-d-2;let x;return m<this.minWidthToWrap||o.preformatted(n)?x=n:x=o.boxWrap(n,m).replace(/\n/g,`
|
|
13
|
+
`+" ".repeat(a+d)),c+h+" ".repeat(d)+x.replace(/\n/g,`
|
|
14
|
+
${c}`)}boxWrap(s,a){if(a<this.minWidthToWrap)return s;const n=s.split(/\r\n|\n/),o=/[\s]*[^\s]+/g,u=[];return n.forEach(c=>{const h=c.match(o);if(h===null){u.push("");return}let d=[h.shift()],l=this.displayWidth(d[0]);h.forEach(m=>{const x=this.displayWidth(m);if(l+x<=a){d.push(m),l+=x;return}u.push(d.join(""));const E=m.trimStart();d=[E],l=this.displayWidth(E)}),u.push(d.join(""))}),u.join(`
|
|
15
|
+
`)}}function i(r){const s=/\x1b\[\d*(;\d*)*m/g;return r.replace(s,"")}return Se.Help=e,Se.stripColor=i,Se}var Ce={},Si;function or(){if(Si)return Ce;Si=1;const{InvalidArgumentError:t}=Ve();class e{constructor(n,o){this.flags=n,this.description=o||"",this.required=n.includes("<"),this.optional=n.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(n),this.mandatory=!1;const u=s(n);this.short=u.shortFlag,this.long=u.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(n,o){return this.defaultValue=n,this.defaultValueDescription=o,this}preset(n){return this.presetArg=n,this}conflicts(n){return this.conflictsWith=this.conflictsWith.concat(n),this}implies(n){let o=n;return typeof n=="string"&&(o={[n]:!0}),this.implied=Object.assign(this.implied||{},o),this}env(n){return this.envVar=n,this}argParser(n){return this.parseArg=n,this}makeOptionMandatory(n=!0){return this.mandatory=!!n,this}hideHelp(n=!0){return this.hidden=!!n,this}_collectValue(n,o){return o===this.defaultValue||!Array.isArray(o)?[n]:(o.push(n),o)}choices(n){return this.argChoices=n.slice(),this.parseArg=(o,u)=>{if(!this.argChoices.includes(o))throw new t(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(o,u):o},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?r(this.name().replace(/^no-/,"")):r(this.name())}helpGroup(n){return this.helpGroupHeading=n,this}is(n){return this.short===n||this.long===n}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class i{constructor(n){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,n.forEach(o=>{o.negate?this.negativeOptions.set(o.attributeName(),o):this.positiveOptions.set(o.attributeName(),o)}),this.negativeOptions.forEach((o,u)=>{this.positiveOptions.has(u)&&this.dualOptions.add(u)})}valueFromOption(n,o){const u=o.attributeName();if(!this.dualOptions.has(u))return!0;const c=this.negativeOptions.get(u).presetArg,h=c!==void 0?c:!1;return o.negate===(h===n)}}function r(a){return a.split("-").reduce((n,o)=>n+o[0].toUpperCase()+o.slice(1))}function s(a){let n,o;const u=/^-[^-]$/,c=/^--[^-]/,h=a.split(/[ |,]+/).concat("guard");if(u.test(h[0])&&(n=h.shift()),c.test(h[0])&&(o=h.shift()),!n&&u.test(h[0])&&(n=h.shift()),!n&&c.test(h[0])&&(n=o,o=h.shift()),h[0].startsWith("-")){const d=h[0],l=`option creation failed due to '${d}' in option flags '${a}'`;throw/^-[^-][^-]/.test(d)?new Error(`${l}
|
|
16
|
+
- a short flag is a single dash and a single character
|
|
17
|
+
- either use a single dash and a single character (for a short flag)
|
|
18
|
+
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):u.test(d)?new Error(`${l}
|
|
19
|
+
- too many short flags`):c.test(d)?new Error(`${l}
|
|
20
|
+
- too many long flags`):new Error(`${l}
|
|
21
|
+
- unrecognised flag format`)}if(n===void 0&&o===void 0)throw new Error(`option creation failed due to no flags found in '${a}'.`);return{shortFlag:n,longFlag:o}}return Ce.Option=e,Ce.DualOptions=i,Ce}var $e={},Ci;function Es(){if(Ci)return $e;Ci=1;const t=3;function e(r,s){if(Math.abs(r.length-s.length)>t)return Math.max(r.length,s.length);const a=[];for(let n=0;n<=r.length;n++)a[n]=[n];for(let n=0;n<=s.length;n++)a[0][n]=n;for(let n=1;n<=s.length;n++)for(let o=1;o<=r.length;o++){let u=1;r[o-1]===s[n-1]?u=0:u=1,a[o][n]=Math.min(a[o-1][n]+1,a[o][n-1]+1,a[o-1][n-1]+u),o>1&&n>1&&r[o-1]===s[n-2]&&r[o-2]===s[n-1]&&(a[o][n]=Math.min(a[o][n],a[o-2][n-2]+1))}return a[r.length][s.length]}function i(r,s){if(!s||s.length===0)return"";s=Array.from(new Set(s));const a=r.startsWith("--");a&&(r=r.slice(2),s=s.map(c=>c.slice(2)));let n=[],o=t;const u=.4;return s.forEach(c=>{if(c.length<=1)return;const h=e(r,c),d=Math.max(r.length,c.length);(d-h)/d>u&&(h<o?(o=h,n=[c]):h===o&&n.push(c))}),n.sort((c,h)=>c.localeCompare(h)),a&&(n=n.map(c=>`--${c}`)),n.length>1?`
|
|
22
|
+
(Did you mean one of ${n.join(", ")}?)`:n.length===1?`
|
|
23
|
+
(Did you mean ${n[0]}?)`:""}return $e.suggestSimilar=i,$e}var Ni;function Ss(){if(Ni)return Ee;Ni=1;const t=fs().EventEmitter,e=gs(),i=ys(),r=vs(),s=_s(),{Argument:a,humanReadableArgName:n}=ui(),{CommanderError:o}=Ve(),{Help:u,stripColor:c}=ar(),{Option:h,DualOptions:d}=or(),{suggestSimilar:l}=Es();class m extends t{constructor(p){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=p||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:g=>s.stdout.write(g),writeErr:g=>s.stderr.write(g),outputError:(g,v)=>v(g),getOutHelpWidth:()=>s.stdout.isTTY?s.stdout.columns:void 0,getErrHelpWidth:()=>s.stderr.isTTY?s.stderr.columns:void 0,getOutHasColors:()=>E()??(s.stdout.isTTY&&s.stdout.hasColors?.()),getErrHasColors:()=>E()??(s.stderr.isTTY&&s.stderr.hasColors?.()),stripColor:g=>c(g)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(p){return this._outputConfiguration=p._outputConfiguration,this._helpOption=p._helpOption,this._helpCommand=p._helpCommand,this._helpConfiguration=p._helpConfiguration,this._exitCallback=p._exitCallback,this._storeOptionsAsProperties=p._storeOptionsAsProperties,this._combineFlagAndOptionalValue=p._combineFlagAndOptionalValue,this._allowExcessArguments=p._allowExcessArguments,this._enablePositionalOptions=p._enablePositionalOptions,this._showHelpAfterError=p._showHelpAfterError,this._showSuggestionAfterError=p._showSuggestionAfterError,this}_getCommandAndAncestors(){const p=[];for(let g=this;g;g=g.parent)p.push(g);return p}command(p,g,v){let _=g,b=v;typeof _=="object"&&_!==null&&(b=_,_=null),b=b||{};const[,C,A]=p.match(/([^ ]+) *(.*)/),D=this.createCommand(C);return _&&(D.description(_),D._executableHandler=!0),b.isDefault&&(this._defaultCommandName=D._name),D._hidden=!!(b.noHelp||b.hidden),D._executableFile=b.executableFile||null,A&&D.arguments(A),this._registerCommand(D),D.parent=this,D.copyInheritedSettings(this),_?this:D}createCommand(p){return new m(p)}createHelp(){return Object.assign(new u,this.configureHelp())}configureHelp(p){return p===void 0?this._helpConfiguration:(this._helpConfiguration=p,this)}configureOutput(p){return p===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...p},this)}showHelpAfterError(p=!0){return typeof p!="string"&&(p=!!p),this._showHelpAfterError=p,this}showSuggestionAfterError(p=!0){return this._showSuggestionAfterError=!!p,this}addCommand(p,g){if(!p._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
24
|
+
- specify the name in Command constructor or using .name()`);return g=g||{},g.isDefault&&(this._defaultCommandName=p._name),(g.noHelp||g.hidden)&&(p._hidden=!0),this._registerCommand(p),p.parent=this,p._checkForBrokenPassThrough(),this}createArgument(p,g){return new a(p,g)}argument(p,g,v,_){const b=this.createArgument(p,g);return typeof v=="function"?b.default(_).argParser(v):b.default(v),this.addArgument(b),this}arguments(p){return p.trim().split(/ +/).forEach(g=>{this.argument(g)}),this}addArgument(p){const g=this.registeredArguments.slice(-1)[0];if(g?.variadic)throw new Error(`only the last argument can be variadic '${g.name()}'`);if(p.required&&p.defaultValue!==void 0&&p.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${p.name()}'`);return this.registeredArguments.push(p),this}helpCommand(p,g){if(typeof p=="boolean")return this._addImplicitHelpCommand=p,p&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;const v=p??"help [command]",[,_,b]=v.match(/([^ ]+) *(.*)/),C=g??"display help for command",A=this.createCommand(_);return A.helpOption(!1),b&&A.arguments(b),C&&A.description(C),this._addImplicitHelpCommand=!0,this._helpCommand=A,(p||g)&&this._initCommandGroup(A),this}addHelpCommand(p,g){return typeof p!="object"?(this.helpCommand(p,g),this):(this._addImplicitHelpCommand=!0,this._helpCommand=p,this._initCommandGroup(p),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(p,g){const v=["preSubcommand","preAction","postAction"];if(!v.includes(p))throw new Error(`Unexpected value for event passed to hook : '${p}'.
|
|
25
|
+
Expecting one of '${v.join("', '")}'`);return this._lifeCycleHooks[p]?this._lifeCycleHooks[p].push(g):this._lifeCycleHooks[p]=[g],this}exitOverride(p){return p?this._exitCallback=p:this._exitCallback=g=>{if(g.code!=="commander.executeSubCommandAsync")throw g},this}_exit(p,g,v){this._exitCallback&&this._exitCallback(new o(p,g,v)),s.exit(p)}action(p){const g=v=>{const _=this.registeredArguments.length,b=v.slice(0,_);return this._storeOptionsAsProperties?b[_]=this:b[_]=this.opts(),b.push(this),p.apply(this,b)};return this._actionHandler=g,this}createOption(p,g){return new h(p,g)}_callParseArg(p,g,v,_){try{return p.parseArg(g,v)}catch(b){if(b.code==="commander.invalidArgument"){const C=`${_} ${b.message}`;this.error(C,{exitCode:b.exitCode,code:b.code})}throw b}}_registerOption(p){const g=p.short&&this._findOption(p.short)||p.long&&this._findOption(p.long);if(g){const v=p.long&&this._findOption(p.long)?p.long:p.short;throw new Error(`Cannot add option '${p.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${v}'
|
|
26
|
+
- already used by option '${g.flags}'`)}this._initOptionGroup(p),this.options.push(p)}_registerCommand(p){const g=_=>[_.name()].concat(_.aliases()),v=g(p).find(_=>this._findCommand(_));if(v){const _=g(this._findCommand(v)).join("|"),b=g(p).join("|");throw new Error(`cannot add command '${b}' as already have command '${_}'`)}this._initCommandGroup(p),this.commands.push(p)}addOption(p){this._registerOption(p);const g=p.name(),v=p.attributeName();if(p.negate){const b=p.long.replace(/^--no-/,"--");this._findOption(b)||this.setOptionValueWithSource(v,p.defaultValue===void 0?!0:p.defaultValue,"default")}else p.defaultValue!==void 0&&this.setOptionValueWithSource(v,p.defaultValue,"default");const _=(b,C,A)=>{b==null&&p.presetArg!==void 0&&(b=p.presetArg);const D=this.getOptionValue(v);b!==null&&p.parseArg?b=this._callParseArg(p,b,D,C):b!==null&&p.variadic&&(b=p._collectValue(b,D)),b==null&&(p.negate?b=!1:p.isBoolean()||p.optional?b=!0:b=""),this.setOptionValueWithSource(v,b,A)};return this.on("option:"+g,b=>{const C=`error: option '${p.flags}' argument '${b}' is invalid.`;_(b,C,"cli")}),p.envVar&&this.on("optionEnv:"+g,b=>{const C=`error: option '${p.flags}' value '${b}' from env '${p.envVar}' is invalid.`;_(b,C,"env")}),this}_optionEx(p,g,v,_,b){if(typeof g=="object"&&g instanceof h)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const C=this.createOption(g,v);if(C.makeOptionMandatory(!!p.mandatory),typeof _=="function")C.default(b).argParser(_);else if(_ instanceof RegExp){const A=_;_=(D,B)=>{const k=A.exec(D);return k?k[0]:B},C.default(b).argParser(_)}else C.default(_);return this.addOption(C)}option(p,g,v,_){return this._optionEx({},p,g,v,_)}requiredOption(p,g,v,_){return this._optionEx({mandatory:!0},p,g,v,_)}combineFlagAndOptionalValue(p=!0){return this._combineFlagAndOptionalValue=!!p,this}allowUnknownOption(p=!0){return this._allowUnknownOption=!!p,this}allowExcessArguments(p=!0){return this._allowExcessArguments=!!p,this}enablePositionalOptions(p=!0){return this._enablePositionalOptions=!!p,this}passThroughOptions(p=!0){return this._passThroughOptions=!!p,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(p=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!p,this}getOptionValue(p){return this._storeOptionsAsProperties?this[p]:this._optionValues[p]}setOptionValue(p,g){return this.setOptionValueWithSource(p,g,void 0)}setOptionValueWithSource(p,g,v){return this._storeOptionsAsProperties?this[p]=g:this._optionValues[p]=g,this._optionValueSources[p]=v,this}getOptionValueSource(p){return this._optionValueSources[p]}getOptionValueSourceWithGlobals(p){let g;return this._getCommandAndAncestors().forEach(v=>{v.getOptionValueSource(p)!==void 0&&(g=v.getOptionValueSource(p))}),g}_prepareUserArgs(p,g){if(p!==void 0&&!Array.isArray(p))throw new Error("first parameter to parse must be array or undefined");if(g=g||{},p===void 0&&g.from===void 0){s.versions?.electron&&(g.from="electron");const _=s.execArgv??[];(_.includes("-e")||_.includes("--eval")||_.includes("-p")||_.includes("--print"))&&(g.from="eval")}p===void 0&&(p=s.argv),this.rawArgs=p.slice();let v;switch(g.from){case void 0:case"node":this._scriptPath=p[1],v=p.slice(2);break;case"electron":s.defaultApp?(this._scriptPath=p[1],v=p.slice(2)):v=p.slice(1);break;case"user":v=p.slice(0);break;case"eval":v=p.slice(1);break;default:throw new Error(`unexpected parse option { from: '${g.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",v}parse(p,g){this._prepareForParse();const v=this._prepareUserArgs(p,g);return this._parseCommand([],v),this}async parseAsync(p,g){this._prepareForParse();const v=this._prepareUserArgs(p,g);return await this._parseCommand([],v),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
27
|
+
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(p,g,v){if(r.existsSync(p))return;const _=g?`searched for local subcommand relative to directory '${g}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",b=`'${p}' does not exist
|
|
28
|
+
- if '${v}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
29
|
+
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
30
|
+
- ${_}`;throw new Error(b)}_executeSubCommand(p,g){g=g.slice();let v=!1;const _=[".js",".ts",".tsx",".mjs",".cjs"];function b(k,O){const W=i.resolve(k,O);if(r.existsSync(W))return W;if(_.includes(i.extname(O)))return;const Z=_.find(Dt=>r.existsSync(`${W}${Dt}`));if(Z)return`${W}${Z}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let C=p._executableFile||`${this._name}-${p._name}`,A=this._executableDir||"";if(this._scriptPath){let k;try{k=r.realpathSync(this._scriptPath)}catch{k=this._scriptPath}A=i.resolve(i.dirname(k),A)}if(A){let k=b(A,C);if(!k&&!p._executableFile&&this._scriptPath){const O=i.basename(this._scriptPath,i.extname(this._scriptPath));O!==this._name&&(k=b(A,`${O}-${p._name}`))}C=k||C}v=_.includes(i.extname(C));let D;s.platform!=="win32"?v?(g.unshift(C),g=x(s.execArgv).concat(g),D=e.spawn(s.argv[0],g,{stdio:"inherit"})):D=e.spawn(C,g,{stdio:"inherit"}):(this._checkForMissingExecutable(C,A,p._name),g.unshift(C),g=x(s.execArgv).concat(g),D=e.spawn(s.execPath,g,{stdio:"inherit"})),D.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(O=>{s.on(O,()=>{D.killed===!1&&D.exitCode===null&&D.kill(O)})});const B=this._exitCallback;D.on("close",k=>{k=k??1,B?B(new o(k,"commander.executeSubCommandAsync","(close)")):s.exit(k)}),D.on("error",k=>{if(k.code==="ENOENT")this._checkForMissingExecutable(C,A,p._name);else if(k.code==="EACCES")throw new Error(`'${C}' not executable`);if(!B)s.exit(1);else{const O=new o(1,"commander.executeSubCommandAsync","(error)");O.nestedError=k,B(O)}}),this.runningCommand=D}_dispatchSubcommand(p,g,v){const _=this._findCommand(p);_||this.help({error:!0}),_._prepareForParse();let b;return b=this._chainOrCallSubCommandHook(b,_,"preSubcommand"),b=this._chainOrCall(b,()=>{if(_._executableHandler)this._executeSubCommand(_,g.concat(v));else return _._parseCommand(g,v)}),b}_dispatchHelpCommand(p){p||this.help();const g=this._findCommand(p);return g&&!g._executableHandler&&g.help(),this._dispatchSubcommand(p,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((p,g)=>{p.required&&this.args[g]==null&&this.missingArgument(p.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){const p=(v,_,b)=>{let C=_;if(_!==null&&v.parseArg){const A=`error: command-argument value '${_}' is invalid for argument '${v.name()}'.`;C=this._callParseArg(v,_,b,A)}return C};this._checkNumberOfArguments();const g=[];this.registeredArguments.forEach((v,_)=>{let b=v.defaultValue;v.variadic?_<this.args.length?(b=this.args.slice(_),v.parseArg&&(b=b.reduce((C,A)=>p(v,A,C),v.defaultValue))):b===void 0&&(b=[]):_<this.args.length&&(b=this.args[_],v.parseArg&&(b=p(v,b,v.defaultValue))),g[_]=b}),this.processedArgs=g}_chainOrCall(p,g){return p?.then&&typeof p.then=="function"?p.then(()=>g()):g()}_chainOrCallHooks(p,g){let v=p;const _=[];return this._getCommandAndAncestors().reverse().filter(b=>b._lifeCycleHooks[g]!==void 0).forEach(b=>{b._lifeCycleHooks[g].forEach(C=>{_.push({hookedCommand:b,callback:C})})}),g==="postAction"&&_.reverse(),_.forEach(b=>{v=this._chainOrCall(v,()=>b.callback(b.hookedCommand,this))}),v}_chainOrCallSubCommandHook(p,g,v){let _=p;return this._lifeCycleHooks[v]!==void 0&&this._lifeCycleHooks[v].forEach(b=>{_=this._chainOrCall(_,()=>b(this,g))}),_}_parseCommand(p,g){const v=this.parseOptions(g);if(this._parseOptionsEnv(),this._parseOptionsImplied(),p=p.concat(v.operands),g=v.unknown,this.args=p.concat(g),p&&this._findCommand(p[0]))return this._dispatchSubcommand(p[0],p.slice(1),g);if(this._getHelpCommand()&&p[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(p[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(g),this._dispatchSubcommand(this._defaultCommandName,p,g);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(v.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const _=()=>{v.unknown.length>0&&this.unknownOption(v.unknown[0])},b=`command:${this.name()}`;if(this._actionHandler){_(),this._processArguments();let C;return C=this._chainOrCallHooks(C,"preAction"),C=this._chainOrCall(C,()=>this._actionHandler(this.processedArgs)),this.parent&&(C=this._chainOrCall(C,()=>{this.parent.emit(b,p,g)})),C=this._chainOrCallHooks(C,"postAction"),C}if(this.parent?.listenerCount(b))_(),this._processArguments(),this.parent.emit(b,p,g);else if(p.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",p,g);this.listenerCount("command:*")?this.emit("command:*",p,g):this.commands.length?this.unknownCommand():(_(),this._processArguments())}else this.commands.length?(_(),this.help({error:!0})):(_(),this._processArguments())}_findCommand(p){if(p)return this.commands.find(g=>g._name===p||g._aliases.includes(p))}_findOption(p){return this.options.find(g=>g.is(p))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(p=>{p.options.forEach(g=>{g.mandatory&&p.getOptionValue(g.attributeName())===void 0&&p.missingMandatoryOptionValue(g)})})}_checkForConflictingLocalOptions(){const p=this.options.filter(v=>{const _=v.attributeName();return this.getOptionValue(_)===void 0?!1:this.getOptionValueSource(_)!=="default"});p.filter(v=>v.conflictsWith.length>0).forEach(v=>{const _=p.find(b=>v.conflictsWith.includes(b.attributeName()));_&&this._conflictingOption(v,_)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(p=>{p._checkForConflictingLocalOptions()})}parseOptions(p){const g=[],v=[];let _=g;function b(k){return k.length>1&&k[0]==="-"}const C=k=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(k)?!this._getCommandAndAncestors().some(O=>O.options.map(W=>W.short).some(W=>/^-\d$/.test(W))):!1;let A=null,D=null,B=0;for(;B<p.length||D;){const k=D??p[B++];if(D=null,k==="--"){_===v&&_.push(k),_.push(...p.slice(B));break}if(A&&(!b(k)||C(k))){this.emit(`option:${A.name()}`,k);continue}if(A=null,b(k)){const O=this._findOption(k);if(O){if(O.required){const W=p[B++];W===void 0&&this.optionMissingArgument(O),this.emit(`option:${O.name()}`,W)}else if(O.optional){let W=null;B<p.length&&(!b(p[B])||C(p[B]))&&(W=p[B++]),this.emit(`option:${O.name()}`,W)}else this.emit(`option:${O.name()}`);A=O.variadic?O:null;continue}}if(k.length>2&&k[0]==="-"&&k[1]!=="-"){const O=this._findOption(`-${k[1]}`);if(O){O.required||O.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${O.name()}`,k.slice(2)):(this.emit(`option:${O.name()}`),D=`-${k.slice(2)}`);continue}}if(/^--[^=]+=/.test(k)){const O=k.indexOf("="),W=this._findOption(k.slice(0,O));if(W&&(W.required||W.optional)){this.emit(`option:${W.name()}`,k.slice(O+1));continue}}if(_===g&&b(k)&&!(this.commands.length===0&&C(k))&&(_=v),(this._enablePositionalOptions||this._passThroughOptions)&&g.length===0&&v.length===0){if(this._findCommand(k)){g.push(k),v.push(...p.slice(B));break}else if(this._getHelpCommand()&&k===this._getHelpCommand().name()){g.push(k,...p.slice(B));break}else if(this._defaultCommandName){v.push(k,...p.slice(B));break}}if(this._passThroughOptions){_.push(k,...p.slice(B));break}_.push(k)}return{operands:g,unknown:v}}opts(){if(this._storeOptionsAsProperties){const p={},g=this.options.length;for(let v=0;v<g;v++){const _=this.options[v].attributeName();p[_]=_===this._versionOptionName?this._version:this[_]}return p}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((p,g)=>Object.assign(p,g.opts()),{})}error(p,g){this._outputConfiguration.outputError(`${p}
|
|
31
|
+
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
32
|
+
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
33
|
+
`),this.outputHelp({error:!0}));const v=g||{},_=v.exitCode||1,b=v.code||"commander.error";this._exit(_,b,p)}_parseOptionsEnv(){this.options.forEach(p=>{if(p.envVar&&p.envVar in s.env){const g=p.attributeName();(this.getOptionValue(g)===void 0||["default","config","env"].includes(this.getOptionValueSource(g)))&&(p.required||p.optional?this.emit(`optionEnv:${p.name()}`,s.env[p.envVar]):this.emit(`optionEnv:${p.name()}`))}})}_parseOptionsImplied(){const p=new d(this.options),g=v=>this.getOptionValue(v)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(v));this.options.filter(v=>v.implied!==void 0&&g(v.attributeName())&&p.valueFromOption(this.getOptionValue(v.attributeName()),v)).forEach(v=>{Object.keys(v.implied).filter(_=>!g(_)).forEach(_=>{this.setOptionValueWithSource(_,v.implied[_],"implied")})})}missingArgument(p){const g=`error: missing required argument '${p}'`;this.error(g,{code:"commander.missingArgument"})}optionMissingArgument(p){const g=`error: option '${p.flags}' argument missing`;this.error(g,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(p){const g=`error: required option '${p.flags}' not specified`;this.error(g,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(p,g){const v=C=>{const A=C.attributeName(),D=this.getOptionValue(A),B=this.options.find(O=>O.negate&&A===O.attributeName()),k=this.options.find(O=>!O.negate&&A===O.attributeName());return B&&(B.presetArg===void 0&&D===!1||B.presetArg!==void 0&&D===B.presetArg)?B:k||C},_=C=>{const A=v(C),D=A.attributeName();return this.getOptionValueSource(D)==="env"?`environment variable '${A.envVar}'`:`option '${A.flags}'`},b=`error: ${_(p)} cannot be used with ${_(g)}`;this.error(b,{code:"commander.conflictingOption"})}unknownOption(p){if(this._allowUnknownOption)return;let g="";if(p.startsWith("--")&&this._showSuggestionAfterError){let _=[],b=this;do{const C=b.createHelp().visibleOptions(b).filter(A=>A.long).map(A=>A.long);_=_.concat(C),b=b.parent}while(b&&!b._enablePositionalOptions);g=l(p,_)}const v=`error: unknown option '${p}'${g}`;this.error(v,{code:"commander.unknownOption"})}_excessArguments(p){if(this._allowExcessArguments)return;const g=this.registeredArguments.length,v=g===1?"":"s",b=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${g} argument${v} but got ${p.length}.`;this.error(b,{code:"commander.excessArguments"})}unknownCommand(){const p=this.args[0];let g="";if(this._showSuggestionAfterError){const _=[];this.createHelp().visibleCommands(this).forEach(b=>{_.push(b.name()),b.alias()&&_.push(b.alias())}),g=l(p,_)}const v=`error: unknown command '${p}'${g}`;this.error(v,{code:"commander.unknownCommand"})}version(p,g,v){if(p===void 0)return this._version;this._version=p,g=g||"-V, --version",v=v||"output the version number";const _=this.createOption(g,v);return this._versionOptionName=_.attributeName(),this._registerOption(_),this.on("option:"+_.name(),()=>{this._outputConfiguration.writeOut(`${p}
|
|
34
|
+
`),this._exit(0,"commander.version",p)}),this}description(p,g){return p===void 0&&g===void 0?this._description:(this._description=p,g&&(this._argsDescription=g),this)}summary(p){return p===void 0?this._summary:(this._summary=p,this)}alias(p){if(p===void 0)return this._aliases[0];let g=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(g=this.commands[this.commands.length-1]),p===g._name)throw new Error("Command alias can't be the same as its name");const v=this.parent?._findCommand(p);if(v){const _=[v.name()].concat(v.aliases()).join("|");throw new Error(`cannot add alias '${p}' to command '${this.name()}' as already have command '${_}'`)}return g._aliases.push(p),this}aliases(p){return p===void 0?this._aliases:(p.forEach(g=>this.alias(g)),this)}usage(p){if(p===void 0){if(this._usage)return this._usage;const g=this.registeredArguments.map(v=>n(v));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?g:[]).join(" ")}return this._usage=p,this}name(p){return p===void 0?this._name:(this._name=p,this)}helpGroup(p){return p===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=p,this)}commandsGroup(p){return p===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=p,this)}optionsGroup(p){return p===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=p,this)}_initOptionGroup(p){this._defaultOptionGroup&&!p.helpGroupHeading&&p.helpGroup(this._defaultOptionGroup)}_initCommandGroup(p){this._defaultCommandGroup&&!p.helpGroup()&&p.helpGroup(this._defaultCommandGroup)}nameFromFilename(p){return this._name=i.basename(p,i.extname(p)),this}executableDir(p){return p===void 0?this._executableDir:(this._executableDir=p,this)}helpInformation(p){const g=this.createHelp(),v=this._getOutputContext(p);g.prepareContext({error:v.error,helpWidth:v.helpWidth,outputHasColors:v.hasColors});const _=g.formatHelp(this,g);return v.hasColors?_:this._outputConfiguration.stripColor(_)}_getOutputContext(p){p=p||{};const g=!!p.error;let v,_,b;return g?(v=A=>this._outputConfiguration.writeErr(A),_=this._outputConfiguration.getErrHasColors(),b=this._outputConfiguration.getErrHelpWidth()):(v=A=>this._outputConfiguration.writeOut(A),_=this._outputConfiguration.getOutHasColors(),b=this._outputConfiguration.getOutHelpWidth()),{error:g,write:A=>(_||(A=this._outputConfiguration.stripColor(A)),v(A)),hasColors:_,helpWidth:b}}outputHelp(p){let g;typeof p=="function"&&(g=p,p=void 0);const v=this._getOutputContext(p),_={error:v.error,write:v.write,command:this};this._getCommandAndAncestors().reverse().forEach(C=>C.emit("beforeAllHelp",_)),this.emit("beforeHelp",_);let b=this.helpInformation({error:v.error});if(g&&(b=g(b),typeof b!="string"&&!Buffer.isBuffer(b)))throw new Error("outputHelp callback must return a string or a Buffer");v.write(b),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",_),this._getCommandAndAncestors().forEach(C=>C.emit("afterAllHelp",_))}helpOption(p,g){return typeof p=="boolean"?(p?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(p??"-h, --help",g??"display help for command"),(p||g)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(p){return this._helpOption=p,this._initOptionGroup(p),this}help(p){this.outputHelp(p);let g=Number(s.exitCode??0);g===0&&p&&typeof p!="function"&&p.error&&(g=1),this._exit(g,"commander.help","(outputHelp)")}addHelpText(p,g){const v=["beforeAll","before","after","afterAll"];if(!v.includes(p))throw new Error(`Unexpected value for position to addHelpText.
|
|
35
|
+
Expecting one of '${v.join("', '")}'`);const _=`${p}Help`;return this.on(_,b=>{let C;typeof g=="function"?C=g({error:b.error,command:b.command}):C=g,C&&b.write(`${C}
|
|
36
|
+
`)}),this}_outputHelpIfRequested(p){const g=this._getHelpOption();g&&p.find(_=>g.is(_))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}}function x(S){return S.map(p=>{if(!p.startsWith("--inspect"))return p;let g,v="127.0.0.1",_="9229",b;return(b=p.match(/^(--inspect(-brk)?)$/))!==null?g=b[1]:(b=p.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(g=b[1],/^\d+$/.test(b[3])?_=b[3]:v=b[3]):(b=p.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(g=b[1],v=b[3],_=b[4]),g&&_!=="0"?`${g}=${v}:${parseInt(_)+1}`:p})}function E(){if(s.env.NO_COLOR||s.env.FORCE_COLOR==="0"||s.env.FORCE_COLOR==="false")return!1;if(s.env.FORCE_COLOR||s.env.CLICOLOR_FORCE!==void 0)return!0}return Ee.Command=m,Ee.useColor=E,Ee}var Ai;function Cs(){if(Ai)return ft;Ai=1;const{Argument:t}=ui(),{Command:e}=Ss(),{CommanderError:i,InvalidArgumentError:r}=Ve(),{Help:s}=ar(),{Option:a}=or();return ft.program=new e,ft.createCommand=n=>new e(n),ft.createOption=(n,o)=>new a(n,o),ft.createArgument=(n,o)=>new t(n,o),ft.Command=e,ft.Option=a,ft.Argument=t,ft.Help=s,ft.CommanderError=i,ft.InvalidArgumentError=r,ft.InvalidOptionArgumentError=r,ft}var Ns=Cs(),As=ps(Ns);const{program:qe,createCommand:lp,createArgument:pp,createOption:dp,CommanderError:fp,InvalidArgumentError:mp,InvalidOptionArgumentError:gp,Command:xp,Argument:yp,Option:wp,Help:vp}=As;var Is=[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],ur=[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],ks="\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",cr="\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",He={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"},Ue="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",Ds={5:Ue,"5module":Ue+" export import",6:Ue+" const class extends export import super"},Ts=/^in(stanceof)?$/,Ps=new RegExp("["+cr+"]"),Os=new RegExp("["+cr+ks+"]");function Ze(t,e){for(var i=65536,r=0;r<e.length;r+=2){if(i+=e[r],i>t)return!1;if(i+=e[r+1],i>=t)return!0}return!1}function Bt(t,e){return t<65?t===36:t<91?!0:t<97?t===95:t<123?!0:t<=65535?t>=170&&Ps.test(String.fromCharCode(t)):e===!1?!1:Ze(t,ur)}function se(t,e){return t<48?t===36:t<58?!0:t<65?!1:t<91?!0:t<97?t===95:t<123?!0:t<=65535?t>=170&&Os.test(String.fromCharCode(t)):e===!1?!1:Ze(t,ur)||Ze(t,Is)}var $=function(t,e){e===void 0&&(e={}),this.label=t,this.keyword=e.keyword,this.beforeExpr=!!e.beforeExpr,this.startsExpr=!!e.startsExpr,this.isLoop=!!e.isLoop,this.isAssign=!!e.isAssign,this.prefix=!!e.prefix,this.postfix=!!e.postfix,this.binop=e.binop||null,this.updateContext=null};function gt(t,e){return new $(t,{beforeExpr:!0,binop:e})}var xt={beforeExpr:!0},ht={startsExpr:!0},ci={};function j(t,e){return e===void 0&&(e={}),e.keyword=t,ci[t]=new $(t,e)}var f={num:new $("num",ht),regexp:new $("regexp",ht),string:new $("string",ht),name:new $("name",ht),privateId:new $("privateId",ht),eof:new $("eof"),bracketL:new $("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new $("]"),braceL:new $("{",{beforeExpr:!0,startsExpr:!0}),braceR:new $("}"),parenL:new $("(",{beforeExpr:!0,startsExpr:!0}),parenR:new $(")"),comma:new $(",",xt),semi:new $(";",xt),colon:new $(":",xt),dot:new $("."),question:new $("?",xt),questionDot:new $("?."),arrow:new $("=>",xt),template:new $("template"),invalidTemplate:new $("invalidTemplate"),ellipsis:new $("...",xt),backQuote:new $("`",ht),dollarBraceL:new $("${",{beforeExpr:!0,startsExpr:!0}),eq:new $("=",{beforeExpr:!0,isAssign:!0}),assign:new $("_=",{beforeExpr:!0,isAssign:!0}),incDec:new $("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new $("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:gt("||",1),logicalAND:gt("&&",2),bitwiseOR:gt("|",3),bitwiseXOR:gt("^",4),bitwiseAND:gt("&",5),equality:gt("==/!=/===/!==",6),relational:gt("</>/<=/>=",7),bitShift:gt("<</>>/>>>",8),plusMin:new $("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:gt("%",10),star:gt("*",10),slash:gt("/",10),starstar:new $("**",{beforeExpr:!0}),coalesce:gt("??",1),_break:j("break"),_case:j("case",xt),_catch:j("catch"),_continue:j("continue"),_debugger:j("debugger"),_default:j("default",xt),_do:j("do",{isLoop:!0,beforeExpr:!0}),_else:j("else",xt),_finally:j("finally"),_for:j("for",{isLoop:!0}),_function:j("function",ht),_if:j("if"),_return:j("return",xt),_switch:j("switch"),_throw:j("throw",xt),_try:j("try"),_var:j("var"),_const:j("const"),_while:j("while",{isLoop:!0}),_with:j("with"),_new:j("new",{beforeExpr:!0,startsExpr:!0}),_this:j("this",ht),_super:j("super",ht),_class:j("class",ht),_extends:j("extends",xt),_export:j("export"),_import:j("import",ht),_null:j("null",ht),_true:j("true",ht),_false:j("false",ht),_in:j("in",{beforeExpr:!0,binop:7}),_instanceof:j("instanceof",{beforeExpr:!0,binop:7}),_typeof:j("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:j("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:j("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},_t=/\r\n?|\n|\u2028|\u2029/,Fs=new RegExp(_t.source,"g");function ae(t){return t===10||t===13||t===8232||t===8233}function hr(t,e,i){i===void 0&&(i=t.length);for(var r=e;r<i;r++){var s=t.charCodeAt(r);if(ae(s))return r<i-1&&s===13&&t.charCodeAt(r+1)===10?r+2:r+1}return-1}var lr=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,wt=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,pr=Object.prototype,Rs=pr.hasOwnProperty,Bs=pr.toString,oe=Object.hasOwn||(function(t,e){return Rs.call(t,e)}),Ii=Array.isArray||(function(t){return Bs.call(t)==="[object Array]"}),ki=Object.create(null);function jt(t){return ki[t]||(ki[t]=new RegExp("^(?:"+t.replace(/ /g,"|")+")$"))}function Vt(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}var Vs=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,fe=function(t,e){this.line=t,this.column=e};fe.prototype.offset=function(t){return new fe(this.line,this.column+t)};var Le=function(t,e,i){this.start=e,this.end=i,t.sourceFile!==null&&(this.source=t.sourceFile)};function dr(t,e){for(var i=1,r=0;;){var s=hr(t,r,e);if(s<0)return new fe(i,e-r);++i,r=s}}var ti={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},Di=!1;function Ls(t){var e={};for(var i in ti)e[i]=t&&oe(t,i)?t[i]:ti[i];if(e.ecmaVersion==="latest"?e.ecmaVersion=1e8:e.ecmaVersion==null?(!Di&&typeof console=="object"&&console.warn&&(Di=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
37
|
+
Defaulting to 2020, but this will stop working in the future.`)),e.ecmaVersion=11):e.ecmaVersion>=2015&&(e.ecmaVersion-=2009),e.allowReserved==null&&(e.allowReserved=e.ecmaVersion<5),(!t||t.allowHashBang==null)&&(e.allowHashBang=e.ecmaVersion>=14),Ii(e.onToken)){var r=e.onToken;e.onToken=function(s){return r.push(s)}}return Ii(e.onComment)&&(e.onComment=Ms(e,e.onComment)),e}function Ms(t,e){return function(i,r,s,a,n,o){var u={type:i?"Block":"Line",value:r,start:s,end:a};t.locations&&(u.loc=new Le(this,n,o)),t.ranges&&(u.range=[s,a]),e.push(u)}}var me=1,ue=2,hi=4,fr=8,mr=16,gr=32,li=64,xr=128,xe=256,pi=me|ue|xe;function di(t,e){return ue|(t?hi:0)|(e?fr:0)}var ke=0,fi=1,Mt=2,yr=3,wr=4,vr=5,X=function(t,e,i){this.options=t=Ls(t),this.sourceFile=t.sourceFile,this.keywords=jt(Ds[t.ecmaVersion>=6?6:t.sourceType==="module"?"5module":5]);var r="";t.allowReserved!==!0&&(r=He[t.ecmaVersion>=6?6:t.ecmaVersion===5?5:3],t.sourceType==="module"&&(r+=" await")),this.reservedWords=jt(r);var s=(r?r+" ":"")+He.strict;this.reservedWordsStrict=jt(s),this.reservedWordsStrictBind=jt(s+" "+He.strictBind),this.input=String(e),this.containsEsc=!1,i?(this.pos=i,this.lineStart=this.input.lastIndexOf(`
|
|
38
|
+
`,i-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(_t).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=f.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(me),this.regexpState=null,this.privateNameStack=[]},Ft={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}};X.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};Ft.inFunction.get=function(){return(this.currentVarScope().flags&ue)>0};Ft.inGenerator.get=function(){return(this.currentVarScope().flags&fr)>0&&!this.currentVarScope().inClassFieldInit};Ft.inAsync.get=function(){return(this.currentVarScope().flags&hi)>0&&!this.currentVarScope().inClassFieldInit};Ft.canAwait.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var e=this.scopeStack[t];if(e.inClassFieldInit||e.flags&xe)return!1;if(e.flags&ue)return(e.flags&hi)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};Ft.allowSuper.get=function(){var t=this.currentThisScope(),e=t.flags,i=t.inClassFieldInit;return(e&li)>0||i||this.options.allowSuperOutsideMethod};Ft.allowDirectSuper.get=function(){return(this.currentThisScope().flags&xr)>0};Ft.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};Ft.allowNewDotTarget.get=function(){var t=this.currentThisScope(),e=t.flags,i=t.inClassFieldInit;return(e&(ue|xe))>0||i};Ft.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&xe)>0};X.extend=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];for(var i=this,r=0;r<t.length;r++)i=t[r](i);return i};X.parse=function(t,e){return new this(e,t).parse()};X.parseExpressionAt=function(t,e,i){var r=new this(i,t,e);return r.nextToken(),r.parseExpression()};X.tokenizer=function(t,e){return new this(e,t)};Object.defineProperties(X.prototype,Ft);var ct=X.prototype,Ws=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;ct.strictDirective=function(t){if(this.options.ecmaVersion<5)return!1;for(;;){wt.lastIndex=t,t+=wt.exec(this.input)[0].length;var e=Ws.exec(this.input.slice(t));if(!e)return!1;if((e[1]||e[2])==="use strict"){wt.lastIndex=t+e[0].length;var i=wt.exec(this.input),r=i.index+i[0].length,s=this.input.charAt(r);return s===";"||s==="}"||_t.test(i[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(s)||s==="!"&&this.input.charAt(r+1)==="=")}t+=e[0].length,wt.lastIndex=t,t+=wt.exec(this.input)[0].length,this.input[t]===";"&&t++}};ct.eat=function(t){return this.type===t?(this.next(),!0):!1};ct.isContextual=function(t){return this.type===f.name&&this.value===t&&!this.containsEsc};ct.eatContextual=function(t){return this.isContextual(t)?(this.next(),!0):!1};ct.expectContextual=function(t){this.eatContextual(t)||this.unexpected()};ct.canInsertSemicolon=function(){return this.type===f.eof||this.type===f.braceR||_t.test(this.input.slice(this.lastTokEnd,this.start))};ct.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};ct.semicolon=function(){!this.eat(f.semi)&&!this.insertSemicolon()&&this.unexpected()};ct.afterTrailingComma=function(t,e){if(this.type===t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0};ct.expect=function(t){this.eat(t)||this.unexpected()};ct.unexpected=function(t){this.raise(t??this.start,"Unexpected token")};var Me=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};ct.checkPatternErrors=function(t,e){if(t){t.trailingComma>-1&&this.raiseRecoverable(t.trailingComma,"Comma is not permitted after the rest element");var i=e?t.parenthesizedAssign:t.parenthesizedBind;i>-1&&this.raiseRecoverable(i,e?"Assigning to rvalue":"Parenthesized pattern")}};ct.checkExpressionErrors=function(t,e){if(!t)return!1;var i=t.shorthandAssign,r=t.doubleProto;if(!e)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")};ct.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")};ct.isSimpleAssignTarget=function(t){return t.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(t.expression):t.type==="Identifier"||t.type==="MemberExpression"};var F=X.prototype;F.parseTopLevel=function(t){var e=Object.create(null);for(t.body||(t.body=[]);this.type!==f.eof;){var i=this.parseStatement(null,!0,e);t.body.push(i)}if(this.inModule)for(var r=0,s=Object.keys(this.undefinedExports);r<s.length;r+=1){var a=s[r];this.raiseRecoverable(this.undefinedExports[a].start,"Export '"+a+"' is not defined")}return this.adaptDirectivePrologue(t.body),this.next(),t.sourceType=this.options.sourceType,this.finishNode(t,"Program")};var mi={kind:"loop"},js={kind:"switch"};F.isLet=function(t){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;wt.lastIndex=this.pos;var e=wt.exec(this.input),i=this.pos+e[0].length,r=this.input.charCodeAt(i);if(r===91||r===92)return!0;if(t)return!1;if(r===123||r>55295&&r<56320)return!0;if(Bt(r,!0)){for(var s=i+1;se(r=this.input.charCodeAt(s),!0);)++s;if(r===92||r>55295&&r<56320)return!0;var a=this.input.slice(i,s);if(!Ts.test(a))return!0}return!1};F.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;wt.lastIndex=this.pos;var t=wt.exec(this.input),e=this.pos+t[0].length,i;return!_t.test(this.input.slice(this.pos,e))&&this.input.slice(e,e+8)==="function"&&(e+8===this.input.length||!(se(i=this.input.charCodeAt(e+8))||i>55295&&i<56320))};F.parseStatement=function(t,e,i){var r=this.type,s=this.startNode(),a;switch(this.isLet(t)&&(r=f._var,a="let"),r){case f._break:case f._continue:return this.parseBreakContinueStatement(s,r.keyword);case f._debugger:return this.parseDebuggerStatement(s);case f._do:return this.parseDoStatement(s);case f._for:return this.parseForStatement(s);case f._function:return t&&(this.strict||t!=="if"&&t!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(s,!1,!t);case f._class:return t&&this.unexpected(),this.parseClass(s,!0);case f._if:return this.parseIfStatement(s);case f._return:return this.parseReturnStatement(s);case f._switch:return this.parseSwitchStatement(s);case f._throw:return this.parseThrowStatement(s);case f._try:return this.parseTryStatement(s);case f._const:case f._var:return a=a||this.value,t&&a!=="var"&&this.unexpected(),this.parseVarStatement(s,a);case f._while:return this.parseWhileStatement(s);case f._with:return this.parseWithStatement(s);case f.braceL:return this.parseBlock(!0,s);case f.semi:return this.parseEmptyStatement(s);case f._export:case f._import:if(this.options.ecmaVersion>10&&r===f._import){wt.lastIndex=this.pos;var n=wt.exec(this.input),o=this.pos+n[0].length,u=this.input.charCodeAt(o);if(u===40||u===46)return this.parseExpressionStatement(s,this.parseExpression())}return this.options.allowImportExportEverywhere||(e||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===f._import?this.parseImport(s):this.parseExport(s,i);default:if(this.isAsyncFunction())return t&&this.unexpected(),this.next(),this.parseFunctionStatement(s,!0,!t);var c=this.value,h=this.parseExpression();return r===f.name&&h.type==="Identifier"&&this.eat(f.colon)?this.parseLabeledStatement(s,c,h,t):this.parseExpressionStatement(s,h)}};F.parseBreakContinueStatement=function(t,e){var i=e==="break";this.next(),this.eat(f.semi)||this.insertSemicolon()?t.label=null:this.type!==f.name?this.unexpected():(t.label=this.parseIdent(),this.semicolon());for(var r=0;r<this.labels.length;++r){var s=this.labels[r];if((t.label==null||s.name===t.label.name)&&(s.kind!=null&&(i||s.kind==="loop")||t.label&&i))break}return r===this.labels.length&&this.raise(t.start,"Unsyntactic "+e),this.finishNode(t,i?"BreakStatement":"ContinueStatement")};F.parseDebuggerStatement=function(t){return this.next(),this.semicolon(),this.finishNode(t,"DebuggerStatement")};F.parseDoStatement=function(t){return this.next(),this.labels.push(mi),t.body=this.parseStatement("do"),this.labels.pop(),this.expect(f._while),t.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(f.semi):this.semicolon(),this.finishNode(t,"DoWhileStatement")};F.parseForStatement=function(t){this.next();var e=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(mi),this.enterScope(0),this.expect(f.parenL),this.type===f.semi)return e>-1&&this.unexpected(e),this.parseFor(t,null);var i=this.isLet();if(this.type===f._var||this.type===f._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===f._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&r.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===f._in?e>-1&&this.unexpected(e):t.await=e>-1),this.parseForIn(t,r)):(e>-1&&this.unexpected(e),this.parseFor(t,r))}var a=this.isContextual("let"),n=!1,o=this.containsEsc,u=new Me,c=this.start,h=e>-1?this.parseExprSubscripts(u,"await"):this.parseExpression(!0,u);return this.type===f._in||(n=this.options.ecmaVersion>=6&&this.isContextual("of"))?(e>-1?(this.type===f._in&&this.unexpected(e),t.await=!0):n&&this.options.ecmaVersion>=8&&(h.start===c&&!o&&h.type==="Identifier"&&h.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(t.await=!1)),a&&n&&this.raise(h.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(h,!1,u),this.checkLValPattern(h),this.parseForIn(t,h)):(this.checkExpressionErrors(u,!0),e>-1&&this.unexpected(e),this.parseFor(t,h))};F.parseFunctionStatement=function(t,e,i){return this.next(),this.parseFunction(t,pe|(i?0:ei),!1,e)};F.parseIfStatement=function(t){return this.next(),t.test=this.parseParenExpression(),t.consequent=this.parseStatement("if"),t.alternate=this.eat(f._else)?this.parseStatement("if"):null,this.finishNode(t,"IfStatement")};F.parseReturnStatement=function(t){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(f.semi)||this.insertSemicolon()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")};F.parseSwitchStatement=function(t){this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(f.braceL),this.labels.push(js),this.enterScope(0);for(var e,i=!1;this.type!==f.braceR;)if(this.type===f._case||this.type===f._default){var r=this.type===f._case;e&&this.finishNode(e,"SwitchCase"),t.cases.push(e=this.startNode()),e.consequent=[],this.next(),r?e.test=this.parseExpression():(i&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),i=!0,e.test=null),this.expect(f.colon)}else e||this.unexpected(),e.consequent.push(this.parseStatement(null));return this.exitScope(),e&&this.finishNode(e,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(t,"SwitchStatement")};F.parseThrowStatement=function(t){return this.next(),_t.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,"ThrowStatement")};var $s=[];F.parseCatchClauseParam=function(){var t=this.parseBindingAtom(),e=t.type==="Identifier";return this.enterScope(e?gr:0),this.checkLValPattern(t,e?wr:Mt),this.expect(f.parenR),t};F.parseTryStatement=function(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.type===f._catch){var e=this.startNode();this.next(),this.eat(f.parenL)?e.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),e.param=null,this.enterScope(0)),e.body=this.parseBlock(!1),this.exitScope(),t.handler=this.finishNode(e,"CatchClause")}return t.finalizer=this.eat(f._finally)?this.parseBlock():null,!t.handler&&!t.finalizer&&this.raise(t.start,"Missing catch or finally clause"),this.finishNode(t,"TryStatement")};F.parseVarStatement=function(t,e,i){return this.next(),this.parseVar(t,!1,e,i),this.semicolon(),this.finishNode(t,"VariableDeclaration")};F.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push(mi),t.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(t,"WhileStatement")};F.parseWithStatement=function(t){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),t.object=this.parseParenExpression(),t.body=this.parseStatement("with"),this.finishNode(t,"WithStatement")};F.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,"EmptyStatement")};F.parseLabeledStatement=function(t,e,i,r){for(var s=0,a=this.labels;s<a.length;s+=1){var n=a[s];n.name===e&&this.raise(i.start,"Label '"+e+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===f._switch?"switch":null,u=this.labels.length-1;u>=0;u--){var c=this.labels[u];if(c.statementStart===t.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:e,kind:o,statementStart:this.start}),t.body=this.parseStatement(r?r.indexOf("label")===-1?r+"label":r:"label"),this.labels.pop(),t.label=i,this.finishNode(t,"LabeledStatement")};F.parseExpressionStatement=function(t,e){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")};F.parseBlock=function(t,e,i){for(t===void 0&&(t=!0),e===void 0&&(e=this.startNode()),e.body=[],this.expect(f.braceL),t&&this.enterScope(0);this.type!==f.braceR;){var r=this.parseStatement(null);e.body.push(r)}return i&&(this.strict=!1),this.next(),t&&this.exitScope(),this.finishNode(e,"BlockStatement")};F.parseFor=function(t,e){return t.init=e,this.expect(f.semi),t.test=this.type===f.semi?null:this.parseExpression(),this.expect(f.semi),t.update=this.type===f.parenR?null:this.parseExpression(),this.expect(f.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,"ForStatement")};F.parseForIn=function(t,e){var i=this.type===f._in;return this.next(),e.type==="VariableDeclaration"&&e.declarations[0].init!=null&&(!i||this.options.ecmaVersion<8||this.strict||e.kind!=="var"||e.declarations[0].id.type!=="Identifier")&&this.raise(e.start,(i?"for-in":"for-of")+" loop variable declaration may not have an initializer"),t.left=e,t.right=i?this.parseExpression():this.parseMaybeAssign(),this.expect(f.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,i?"ForInStatement":"ForOfStatement")};F.parseVar=function(t,e,i,r){for(t.declarations=[],t.kind=i;;){var s=this.startNode();if(this.parseVarId(s,i),this.eat(f.eq)?s.init=this.parseMaybeAssign(e):!r&&i==="const"&&!(this.type===f._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!r&&s.id.type!=="Identifier"&&!(e&&(this.type===f._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):s.init=null,t.declarations.push(this.finishNode(s,"VariableDeclarator")),!this.eat(f.comma))break}return t};F.parseVarId=function(t,e){t.id=this.parseBindingAtom(),this.checkLValPattern(t.id,e==="var"?fi:Mt,!1)};var pe=1,ei=2,br=4;F.parseFunction=function(t,e,i,r,s){this.initFunction(t),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===f.star&&e&ei&&this.unexpected(),t.generator=this.eat(f.star)),this.options.ecmaVersion>=8&&(t.async=!!r),e&pe&&(t.id=e&br&&this.type!==f.name?null:this.parseIdent(),t.id&&!(e&ei)&&this.checkLValSimple(t.id,this.strict||t.generator||t.async?this.treatFunctionsAsVar?fi:Mt:yr));var a=this.yieldPos,n=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(di(t.async,t.generator)),e&pe||(t.id=this.type===f.name?this.parseIdent():null),this.parseFunctionParams(t),this.parseFunctionBody(t,i,!1,s),this.yieldPos=a,this.awaitPos=n,this.awaitIdentPos=o,this.finishNode(t,e&pe?"FunctionDeclaration":"FunctionExpression")};F.parseFunctionParams=function(t){this.expect(f.parenL),t.params=this.parseBindingList(f.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};F.parseClass=function(t,e){this.next();var i=this.strict;this.strict=!0,this.parseClassId(t,e),this.parseClassSuper(t);var r=this.enterClassBody(),s=this.startNode(),a=!1;for(s.body=[],this.expect(f.braceL);this.type!==f.braceR;){var n=this.parseClassElement(t.superClass!==null);n&&(s.body.push(n),n.type==="MethodDefinition"&&n.kind==="constructor"?(a&&this.raiseRecoverable(n.start,"Duplicate constructor in the same class"),a=!0):n.key&&n.key.type==="PrivateIdentifier"&&qs(r,n)&&this.raiseRecoverable(n.key.start,"Identifier '#"+n.key.name+"' has already been declared"))}return this.strict=i,this.next(),t.body=this.finishNode(s,"ClassBody"),this.exitClassBody(),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")};F.parseClassElement=function(t){if(this.eat(f.semi))return null;var e=this.options.ecmaVersion,i=this.startNode(),r="",s=!1,a=!1,n="method",o=!1;if(this.eatContextual("static")){if(e>=13&&this.eat(f.braceL))return this.parseClassStaticBlock(i),i;this.isClassElementNameStart()||this.type===f.star?o=!0:r="static"}if(i.static=o,!r&&e>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===f.star)&&!this.canInsertSemicolon()?a=!0:r="async"),!r&&(e>=9||!a)&&this.eat(f.star)&&(s=!0),!r&&!a&&!s){var u=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?n=u:r=u)}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),e<13||this.type===f.parenL||n!=="method"||s||a){var c=!i.static&&De(i,"constructor"),h=c&&t;c&&n!=="method"&&this.raise(i.key.start,"Constructor can't have get/set modifier"),i.kind=c?"constructor":n,this.parseClassMethod(i,s,a,h)}else this.parseClassField(i);return i};F.isClassElementNameStart=function(){return this.type===f.name||this.type===f.privateId||this.type===f.num||this.type===f.string||this.type===f.bracketL||this.type.keyword};F.parseClassElementName=function(t){this.type===f.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),t.computed=!1,t.key=this.parsePrivateIdent()):this.parsePropertyName(t)};F.parseClassMethod=function(t,e,i,r){var s=t.key;t.kind==="constructor"?(e&&this.raise(s.start,"Constructor can't be a generator"),i&&this.raise(s.start,"Constructor can't be an async method")):t.static&&De(t,"prototype")&&this.raise(s.start,"Classes may not have a static property named prototype");var a=t.value=this.parseMethod(e,i,r);return t.kind==="get"&&a.params.length!==0&&this.raiseRecoverable(a.start,"getter should have no params"),t.kind==="set"&&a.params.length!==1&&this.raiseRecoverable(a.start,"setter should have exactly one param"),t.kind==="set"&&a.params[0].type==="RestElement"&&this.raiseRecoverable(a.params[0].start,"Setter cannot use rest params"),this.finishNode(t,"MethodDefinition")};F.parseClassField=function(t){if(De(t,"constructor")?this.raise(t.key.start,"Classes can't have a field named 'constructor'"):t.static&&De(t,"prototype")&&this.raise(t.key.start,"Classes can't have a static field named 'prototype'"),this.eat(f.eq)){var e=this.currentThisScope(),i=e.inClassFieldInit;e.inClassFieldInit=!0,t.value=this.parseMaybeAssign(),e.inClassFieldInit=i}else t.value=null;return this.semicolon(),this.finishNode(t,"PropertyDefinition")};F.parseClassStaticBlock=function(t){t.body=[];var e=this.labels;for(this.labels=[],this.enterScope(xe|li);this.type!==f.braceR;){var i=this.parseStatement(null);t.body.push(i)}return this.next(),this.exitScope(),this.labels=e,this.finishNode(t,"StaticBlock")};F.parseClassId=function(t,e){this.type===f.name?(t.id=this.parseIdent(),e&&this.checkLValSimple(t.id,Mt,!1)):(e===!0&&this.unexpected(),t.id=null)};F.parseClassSuper=function(t){t.superClass=this.eat(f._extends)?this.parseExprSubscripts(null,!1):null};F.enterClassBody=function(){var t={declared:Object.create(null),used:[]};return this.privateNameStack.push(t),t.declared};F.exitClassBody=function(){var t=this.privateNameStack.pop(),e=t.declared,i=t.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,s=r===0?null:this.privateNameStack[r-1],a=0;a<i.length;++a){var n=i[a];oe(e,n.name)||(s?s.used.push(n):this.raiseRecoverable(n.start,"Private field '#"+n.name+"' must be declared in an enclosing class"))}};function qs(t,e){var i=e.key.name,r=t[i],s="true";return e.type==="MethodDefinition"&&(e.kind==="get"||e.kind==="set")&&(s=(e.static?"s":"i")+e.kind),r==="iget"&&s==="iset"||r==="iset"&&s==="iget"||r==="sget"&&s==="sset"||r==="sset"&&s==="sget"?(t[i]="true",!1):r?!0:(t[i]=s,!1)}function De(t,e){var i=t.computed,r=t.key;return!i&&(r.type==="Identifier"&&r.name===e||r.type==="Literal"&&r.value===e)}F.parseExportAllDeclaration=function(t,e){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(t.exported=this.parseModuleExportName(),this.checkExport(e,t.exported,this.lastTokStart)):t.exported=null),this.expectContextual("from"),this.type!==f.string&&this.unexpected(),t.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(t,"ExportAllDeclaration")};F.parseExport=function(t,e){if(this.next(),this.eat(f.star))return this.parseExportAllDeclaration(t,e);if(this.eat(f._default))return this.checkExport(e,"default",this.lastTokStart),t.declaration=this.parseExportDefaultDeclaration(),this.finishNode(t,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())t.declaration=this.parseExportDeclaration(t),t.declaration.type==="VariableDeclaration"?this.checkVariableExport(e,t.declaration.declarations):this.checkExport(e,t.declaration.id,t.declaration.id.start),t.specifiers=[],t.source=null;else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==f.string&&this.unexpected(),t.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause());else{for(var i=0,r=t.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`.")}t.source=null}this.semicolon()}return this.finishNode(t,"ExportNamedDeclaration")};F.parseExportDeclaration=function(t){return this.parseStatement(null)};F.parseExportDefaultDeclaration=function(){var t;if(this.type===f._function||(t=this.isAsyncFunction())){var e=this.startNode();return this.next(),t&&this.next(),this.parseFunction(e,pe|br,!1,t)}else if(this.type===f._class){var i=this.startNode();return this.parseClass(i,"nullableID")}else{var r=this.parseMaybeAssign();return this.semicolon(),r}};F.checkExport=function(t,e,i){t&&(typeof e!="string"&&(e=e.type==="Identifier"?e.name:e.value),oe(t,e)&&this.raiseRecoverable(i,"Duplicate export '"+e+"'"),t[e]=!0)};F.checkPatternExport=function(t,e){var i=e.type;if(i==="Identifier")this.checkExport(t,e,e.start);else if(i==="ObjectPattern")for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];this.checkPatternExport(t,a)}else if(i==="ArrayPattern")for(var n=0,o=e.elements;n<o.length;n+=1){var u=o[n];u&&this.checkPatternExport(t,u)}else i==="Property"?this.checkPatternExport(t,e.value):i==="AssignmentPattern"?this.checkPatternExport(t,e.left):i==="RestElement"&&this.checkPatternExport(t,e.argument)};F.checkVariableExport=function(t,e){if(t)for(var i=0,r=e;i<r.length;i+=1){var s=r[i];this.checkPatternExport(t,s.id)}};F.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};F.parseExportSpecifier=function(t){var e=this.startNode();return e.local=this.parseModuleExportName(),e.exported=this.eatContextual("as")?this.parseModuleExportName():e.local,this.checkExport(t,e.exported,e.exported.start),this.finishNode(e,"ExportSpecifier")};F.parseExportSpecifiers=function(t){var e=[],i=!0;for(this.expect(f.braceL);!this.eat(f.braceR);){if(i)i=!1;else if(this.expect(f.comma),this.afterTrailingComma(f.braceR))break;e.push(this.parseExportSpecifier(t))}return e};F.parseImport=function(t){return this.next(),this.type===f.string?(t.specifiers=$s,t.source=this.parseExprAtom()):(t.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),t.source=this.type===f.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(t,"ImportDeclaration")};F.parseImportSpecifier=function(){var t=this.startNode();return t.imported=this.parseModuleExportName(),this.eatContextual("as")?t.local=this.parseIdent():(this.checkUnreserved(t.imported),t.local=t.imported),this.checkLValSimple(t.local,Mt),this.finishNode(t,"ImportSpecifier")};F.parseImportDefaultSpecifier=function(){var t=this.startNode();return t.local=this.parseIdent(),this.checkLValSimple(t.local,Mt),this.finishNode(t,"ImportDefaultSpecifier")};F.parseImportNamespaceSpecifier=function(){var t=this.startNode();return this.next(),this.expectContextual("as"),t.local=this.parseIdent(),this.checkLValSimple(t.local,Mt),this.finishNode(t,"ImportNamespaceSpecifier")};F.parseImportSpecifiers=function(){var t=[],e=!0;if(this.type===f.name&&(t.push(this.parseImportDefaultSpecifier()),!this.eat(f.comma)))return t;if(this.type===f.star)return t.push(this.parseImportNamespaceSpecifier()),t;for(this.expect(f.braceL);!this.eat(f.braceR);){if(e)e=!1;else if(this.expect(f.comma),this.afterTrailingComma(f.braceR))break;t.push(this.parseImportSpecifier())}return t};F.parseWithClause=function(){var t=[];if(!this.eat(f._with))return t;this.expect(f.braceL);for(var e={},i=!0;!this.eat(f.braceR);){if(i)i=!1;else if(this.expect(f.comma),this.afterTrailingComma(f.braceR))break;var r=this.parseImportAttribute(),s=r.key.type==="Identifier"?r.key.name:r.key.value;oe(e,s)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+s+"'"),e[s]=!0,t.push(r)}return t};F.parseImportAttribute=function(){var t=this.startNode();return t.key=this.type===f.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(f.colon),this.type!==f.string&&this.unexpected(),t.value=this.parseExprAtom(),this.finishNode(t,"ImportAttribute")};F.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===f.string){var t=this.parseLiteral(this.value);return Vs.test(t.value)&&this.raise(t.start,"An export name cannot include a lone surrogate."),t}return this.parseIdent(!0)};F.adaptDirectivePrologue=function(t){for(var e=0;e<t.length&&this.isDirectiveCandidate(t[e]);++e)t[e].directive=t[e].expression.raw.slice(1,-1)};F.isDirectiveCandidate=function(t){return this.options.ecmaVersion>=5&&t.type==="ExpressionStatement"&&t.expression.type==="Literal"&&typeof t.expression.value=="string"&&(this.input[t.start]==='"'||this.input[t.start]==="'")};var Et=X.prototype;Et.toAssignable=function(t,e,i){if(this.options.ecmaVersion>=6&&t)switch(t.type){case"Identifier":this.inAsync&&t.name==="await"&&this.raise(t.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":t.type="ObjectPattern",i&&this.checkPatternErrors(i,!0);for(var r=0,s=t.properties;r<s.length;r+=1){var a=s[r];this.toAssignable(a,e),a.type==="RestElement"&&(a.argument.type==="ArrayPattern"||a.argument.type==="ObjectPattern")&&this.raise(a.argument.start,"Unexpected token")}break;case"Property":t.kind!=="init"&&this.raise(t.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(t.value,e);break;case"ArrayExpression":t.type="ArrayPattern",i&&this.checkPatternErrors(i,!0),this.toAssignableList(t.elements,e);break;case"SpreadElement":t.type="RestElement",this.toAssignable(t.argument,e),t.argument.type==="AssignmentPattern"&&this.raise(t.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":t.operator!=="="&&this.raise(t.left.end,"Only '=' operator can be used for specifying default value."),t.type="AssignmentPattern",delete t.operator,this.toAssignable(t.left,e);break;case"ParenthesizedExpression":this.toAssignable(t.expression,e,i);break;case"ChainExpression":this.raiseRecoverable(t.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!e)break;default:this.raise(t.start,"Assigning to rvalue")}else i&&this.checkPatternErrors(i,!0);return t};Et.toAssignableList=function(t,e){for(var i=t.length,r=0;r<i;r++){var s=t[r];s&&this.toAssignable(s,e)}if(i){var a=t[i-1];this.options.ecmaVersion===6&&e&&a&&a.type==="RestElement"&&a.argument.type!=="Identifier"&&this.unexpected(a.argument.start)}return t};Et.parseSpread=function(t){var e=this.startNode();return this.next(),e.argument=this.parseMaybeAssign(!1,t),this.finishNode(e,"SpreadElement")};Et.parseRestBinding=function(){var t=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==f.name&&this.unexpected(),t.argument=this.parseBindingAtom(),this.finishNode(t,"RestElement")};Et.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case f.bracketL:var t=this.startNode();return this.next(),t.elements=this.parseBindingList(f.bracketR,!0,!0),this.finishNode(t,"ArrayPattern");case f.braceL:return this.parseObj(!0)}return this.parseIdent()};Et.parseBindingList=function(t,e,i,r){for(var s=[],a=!0;!this.eat(t);)if(a?a=!1:this.expect(f.comma),e&&this.type===f.comma)s.push(null);else{if(i&&this.afterTrailingComma(t))break;if(this.type===f.ellipsis){var n=this.parseRestBinding();this.parseBindingListItem(n),s.push(n),this.type===f.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(t);break}else s.push(this.parseAssignableListItem(r))}return s};Et.parseAssignableListItem=function(t){var e=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(e),e};Et.parseBindingListItem=function(t){return t};Et.parseMaybeDefault=function(t,e,i){if(i=i||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(f.eq))return i;var r=this.startNodeAt(t,e);return r.left=i,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")};Et.checkLValSimple=function(t,e,i){e===void 0&&(e=ke);var r=e!==ke;switch(t.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(t.name)&&this.raiseRecoverable(t.start,(r?"Binding ":"Assigning to ")+t.name+" in strict mode"),r&&(e===Mt&&t.name==="let"&&this.raiseRecoverable(t.start,"let is disallowed as a lexically bound name"),i&&(oe(i,t.name)&&this.raiseRecoverable(t.start,"Argument name clash"),i[t.name]=!0),e!==vr&&this.declareName(t.name,e,t.start));break;case"ChainExpression":this.raiseRecoverable(t.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":r&&this.raiseRecoverable(t.start,"Binding member expression");break;case"ParenthesizedExpression":return r&&this.raiseRecoverable(t.start,"Binding parenthesized expression"),this.checkLValSimple(t.expression,e,i);default:this.raise(t.start,(r?"Binding":"Assigning to")+" rvalue")}};Et.checkLValPattern=function(t,e,i){switch(e===void 0&&(e=ke),t.type){case"ObjectPattern":for(var r=0,s=t.properties;r<s.length;r+=1){var a=s[r];this.checkLValInnerPattern(a,e,i)}break;case"ArrayPattern":for(var n=0,o=t.elements;n<o.length;n+=1){var u=o[n];u&&this.checkLValInnerPattern(u,e,i)}break;default:this.checkLValSimple(t,e,i)}};Et.checkLValInnerPattern=function(t,e,i){switch(e===void 0&&(e=ke),t.type){case"Property":this.checkLValInnerPattern(t.value,e,i);break;case"AssignmentPattern":this.checkLValPattern(t.left,e,i);break;case"RestElement":this.checkLValPattern(t.argument,e,i);break;default:this.checkLValPattern(t,e,i)}};var Nt=function(t,e,i,r,s){this.token=t,this.isExpr=!!e,this.preserveSpace=!!i,this.override=r,this.generator=!!s},z={b_stat:new Nt("{",!1),b_expr:new Nt("{",!0),b_tmpl:new Nt("${",!1),p_stat:new Nt("(",!1),p_expr:new Nt("(",!0),q_tmpl:new Nt("`",!0,!0,function(t){return t.tryReadTemplateToken()}),f_stat:new Nt("function",!1),f_expr:new Nt("function",!0),f_expr_gen:new Nt("function",!0,!1,null,!0),f_gen:new Nt("function",!1,!1,null,!0)},ce=X.prototype;ce.initialContext=function(){return[z.b_stat]};ce.curContext=function(){return this.context[this.context.length-1]};ce.braceIsBlock=function(t){var e=this.curContext();return e===z.f_expr||e===z.f_stat?!0:t===f.colon&&(e===z.b_stat||e===z.b_expr)?!e.isExpr:t===f._return||t===f.name&&this.exprAllowed?_t.test(this.input.slice(this.lastTokEnd,this.start)):t===f._else||t===f.semi||t===f.eof||t===f.parenR||t===f.arrow?!0:t===f.braceL?e===z.b_stat:t===f._var||t===f._const||t===f.name?!1:!this.exprAllowed};ce.inGeneratorContext=function(){for(var t=this.context.length-1;t>=1;t--){var e=this.context[t];if(e.token==="function")return e.generator}return!1};ce.updateContext=function(t){var e,i=this.type;i.keyword&&t===f.dot?this.exprAllowed=!1:(e=i.updateContext)?e.call(this,t):this.exprAllowed=i.beforeExpr};ce.overrideContext=function(t){this.curContext()!==t&&(this.context[this.context.length-1]=t)};f.parenR.updateContext=f.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var t=this.context.pop();t===z.b_stat&&this.curContext().token==="function"&&(t=this.context.pop()),this.exprAllowed=!t.isExpr};f.braceL.updateContext=function(t){this.context.push(this.braceIsBlock(t)?z.b_stat:z.b_expr),this.exprAllowed=!0};f.dollarBraceL.updateContext=function(){this.context.push(z.b_tmpl),this.exprAllowed=!0};f.parenL.updateContext=function(t){var e=t===f._if||t===f._for||t===f._with||t===f._while;this.context.push(e?z.p_stat:z.p_expr),this.exprAllowed=!0};f.incDec.updateContext=function(){};f._function.updateContext=f._class.updateContext=function(t){t.beforeExpr&&t!==f._else&&!(t===f.semi&&this.curContext()!==z.p_stat)&&!(t===f._return&&_t.test(this.input.slice(this.lastTokEnd,this.start)))&&!((t===f.colon||t===f.braceL)&&this.curContext()===z.b_stat)?this.context.push(z.f_expr):this.context.push(z.f_stat),this.exprAllowed=!1};f.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};f.backQuote.updateContext=function(){this.curContext()===z.q_tmpl?this.context.pop():this.context.push(z.q_tmpl),this.exprAllowed=!1};f.star.updateContext=function(t){if(t===f._function){var e=this.context.length-1;this.context[e]===z.f_expr?this.context[e]=z.f_expr_gen:this.context[e]=z.f_gen}this.exprAllowed=!0};f.name.updateContext=function(t){var e=!1;this.options.ecmaVersion>=6&&t!==f.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(e=!0),this.exprAllowed=e};var V=X.prototype;V.checkPropClash=function(t,e,i){if(!(this.options.ecmaVersion>=9&&t.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(t.computed||t.method||t.shorthand))){var r=t.key,s;switch(r.type){case"Identifier":s=r.name;break;case"Literal":s=String(r.value);break;default:return}var a=t.kind;if(this.options.ecmaVersion>=6){s==="__proto__"&&a==="init"&&(e.proto&&(i?i.doubleProto<0&&(i.doubleProto=r.start):this.raiseRecoverable(r.start,"Redefinition of __proto__ property")),e.proto=!0);return}s="$"+s;var n=e[s];if(n){var o;a==="init"?o=this.strict&&n.init||n.get||n.set:o=n.init||n[a],o&&this.raiseRecoverable(r.start,"Redefinition of property")}else n=e[s]={init:!1,get:!1,set:!1};n[a]=!0}};V.parseExpression=function(t,e){var i=this.start,r=this.startLoc,s=this.parseMaybeAssign(t,e);if(this.type===f.comma){var a=this.startNodeAt(i,r);for(a.expressions=[s];this.eat(f.comma);)a.expressions.push(this.parseMaybeAssign(t,e));return this.finishNode(a,"SequenceExpression")}return s};V.parseMaybeAssign=function(t,e,i){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(t);this.exprAllowed=!1}var r=!1,s=-1,a=-1,n=-1;e?(s=e.parenthesizedAssign,a=e.trailingComma,n=e.doubleProto,e.parenthesizedAssign=e.trailingComma=-1):(e=new Me,r=!0);var o=this.start,u=this.startLoc;(this.type===f.parenL||this.type===f.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=t==="await");var c=this.parseMaybeConditional(t,e);if(i&&(c=i.call(this,c,o,u)),this.type.isAssign){var h=this.startNodeAt(o,u);return h.operator=this.value,this.type===f.eq&&(c=this.toAssignable(c,!1,e)),r||(e.parenthesizedAssign=e.trailingComma=e.doubleProto=-1),e.shorthandAssign>=c.start&&(e.shorthandAssign=-1),this.type===f.eq?this.checkLValPattern(c):this.checkLValSimple(c),h.left=c,this.next(),h.right=this.parseMaybeAssign(t),n>-1&&(e.doubleProto=n),this.finishNode(h,"AssignmentExpression")}else r&&this.checkExpressionErrors(e,!0);return s>-1&&(e.parenthesizedAssign=s),a>-1&&(e.trailingComma=a),c};V.parseMaybeConditional=function(t,e){var i=this.start,r=this.startLoc,s=this.parseExprOps(t,e);if(this.checkExpressionErrors(e))return s;if(this.eat(f.question)){var a=this.startNodeAt(i,r);return a.test=s,a.consequent=this.parseMaybeAssign(),this.expect(f.colon),a.alternate=this.parseMaybeAssign(t),this.finishNode(a,"ConditionalExpression")}return s};V.parseExprOps=function(t,e){var i=this.start,r=this.startLoc,s=this.parseMaybeUnary(e,!1,!1,t);return this.checkExpressionErrors(e)||s.start===i&&s.type==="ArrowFunctionExpression"?s:this.parseExprOp(s,i,r,-1,t)};V.parseExprOp=function(t,e,i,r,s){var a=this.type.binop;if(a!=null&&(!s||this.type!==f._in)&&a>r){var n=this.type===f.logicalOR||this.type===f.logicalAND,o=this.type===f.coalesce;o&&(a=f.logicalAND.binop);var u=this.value;this.next();var c=this.start,h=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,s),c,h,a,s),l=this.buildBinary(e,i,t,d,u,n||o);return(n&&this.type===f.coalesce||o&&(this.type===f.logicalOR||this.type===f.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(l,e,i,r,s)}return t};V.buildBinary=function(t,e,i,r,s,a){r.type==="PrivateIdentifier"&&this.raise(r.start,"Private identifier can only be left side of binary expression");var n=this.startNodeAt(t,e);return n.left=i,n.operator=s,n.right=r,this.finishNode(n,a?"LogicalExpression":"BinaryExpression")};V.parseMaybeUnary=function(t,e,i,r){var s=this.start,a=this.startLoc,n;if(this.isContextual("await")&&this.canAwait)n=this.parseAwait(r),e=!0;else if(this.type.prefix){var o=this.startNode(),u=this.type===f.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,u,r),this.checkExpressionErrors(t,!0),u?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&_r(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&ii(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):e=!0,n=this.finishNode(o,u?"UpdateExpression":"UnaryExpression")}else if(!e&&this.type===f.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),n=this.parsePrivateIdent(),this.type!==f._in&&this.unexpected();else{if(n=this.parseExprSubscripts(t,r),this.checkExpressionErrors(t))return n;for(;this.type.postfix&&!this.canInsertSemicolon();){var c=this.startNodeAt(s,a);c.operator=this.value,c.prefix=!1,c.argument=n,this.checkLValSimple(n),this.next(),n=this.finishNode(c,"UpdateExpression")}}if(!i&&this.eat(f.starstar))if(e)this.unexpected(this.lastTokStart);else return this.buildBinary(s,a,n,this.parseMaybeUnary(null,!1,!1,r),"**",!1);else return n};function _r(t){return t.type==="Identifier"||t.type==="ParenthesizedExpression"&&_r(t.expression)}function ii(t){return t.type==="MemberExpression"&&t.property.type==="PrivateIdentifier"||t.type==="ChainExpression"&&ii(t.expression)||t.type==="ParenthesizedExpression"&&ii(t.expression)}V.parseExprSubscripts=function(t,e){var i=this.start,r=this.startLoc,s=this.parseExprAtom(t,e);if(s.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return s;var a=this.parseSubscripts(s,i,r,!1,e);return t&&a.type==="MemberExpression"&&(t.parenthesizedAssign>=a.start&&(t.parenthesizedAssign=-1),t.parenthesizedBind>=a.start&&(t.parenthesizedBind=-1),t.trailingComma>=a.start&&(t.trailingComma=-1)),a};V.parseSubscripts=function(t,e,i,r,s){for(var a=this.options.ecmaVersion>=8&&t.type==="Identifier"&&t.name==="async"&&this.lastTokEnd===t.end&&!this.canInsertSemicolon()&&t.end-t.start===5&&this.potentialArrowAt===t.start,n=!1;;){var o=this.parseSubscript(t,e,i,r,a,n,s);if(o.optional&&(n=!0),o===t||o.type==="ArrowFunctionExpression"){if(n){var u=this.startNodeAt(e,i);u.expression=o,o=this.finishNode(u,"ChainExpression")}return o}t=o}};V.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(f.arrow)};V.parseSubscriptAsyncArrow=function(t,e,i,r){return this.parseArrowExpression(this.startNodeAt(t,e),i,!0,r)};V.parseSubscript=function(t,e,i,r,s,a,n){var o=this.options.ecmaVersion>=11,u=o&&this.eat(f.questionDot);r&&u&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var c=this.eat(f.bracketL);if(c||u&&this.type!==f.parenL&&this.type!==f.backQuote||this.eat(f.dot)){var h=this.startNodeAt(e,i);h.object=t,c?(h.property=this.parseExpression(),this.expect(f.bracketR)):this.type===f.privateId&&t.type!=="Super"?h.property=this.parsePrivateIdent():h.property=this.parseIdent(this.options.allowReserved!=="never"),h.computed=!!c,o&&(h.optional=u),t=this.finishNode(h,"MemberExpression")}else if(!r&&this.eat(f.parenL)){var d=new Me,l=this.yieldPos,m=this.awaitPos,x=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var E=this.parseExprList(f.parenR,this.options.ecmaVersion>=8,!1,d);if(s&&!u&&this.shouldParseAsyncArrow())return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=l,this.awaitPos=m,this.awaitIdentPos=x,this.parseSubscriptAsyncArrow(e,i,E,n);this.checkExpressionErrors(d,!0),this.yieldPos=l||this.yieldPos,this.awaitPos=m||this.awaitPos,this.awaitIdentPos=x||this.awaitIdentPos;var S=this.startNodeAt(e,i);S.callee=t,S.arguments=E,o&&(S.optional=u),t=this.finishNode(S,"CallExpression")}else if(this.type===f.backQuote){(u||a)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var p=this.startNodeAt(e,i);p.tag=t,p.quasi=this.parseTemplate({isTagged:!0}),t=this.finishNode(p,"TaggedTemplateExpression")}return t};V.parseExprAtom=function(t,e,i){this.type===f.slash&&this.readRegexp();var r,s=this.potentialArrowAt===this.start;switch(this.type){case f._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),r=this.startNode(),this.next(),this.type===f.parenL&&!this.allowDirectSuper&&this.raise(r.start,"super() call outside constructor of a subclass"),this.type!==f.dot&&this.type!==f.bracketL&&this.type!==f.parenL&&this.unexpected(),this.finishNode(r,"Super");case f._this:return r=this.startNode(),this.next(),this.finishNode(r,"ThisExpression");case f.name:var a=this.start,n=this.startLoc,o=this.containsEsc,u=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&u.name==="async"&&!this.canInsertSemicolon()&&this.eat(f._function))return this.overrideContext(z.f_expr),this.parseFunction(this.startNodeAt(a,n),0,!1,!0,e);if(s&&!this.canInsertSemicolon()){if(this.eat(f.arrow))return this.parseArrowExpression(this.startNodeAt(a,n),[u],!1,e);if(this.options.ecmaVersion>=8&&u.name==="async"&&this.type===f.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return u=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(f.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,n),[u],!0,e)}return u;case f.regexp:var c=this.value;return r=this.parseLiteral(c.value),r.regex={pattern:c.pattern,flags:c.flags},r;case f.num:case f.string:return this.parseLiteral(this.value);case f._null:case f._true:case f._false:return r=this.startNode(),r.value=this.type===f._null?null:this.type===f._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,"Literal");case f.parenL:var h=this.start,d=this.parseParenAndDistinguishExpression(s,e);return t&&(t.parenthesizedAssign<0&&!this.isSimpleAssignTarget(d)&&(t.parenthesizedAssign=h),t.parenthesizedBind<0&&(t.parenthesizedBind=h)),d;case f.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(f.bracketR,!0,!0,t),this.finishNode(r,"ArrayExpression");case f.braceL:return this.overrideContext(z.b_expr),this.parseObj(!1,t);case f._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case f._class:return this.parseClass(this.startNode(),!1);case f._new:return this.parseNew();case f.backQuote:return this.parseTemplate();case f._import:return this.options.ecmaVersion>=11?this.parseExprImport(i):this.unexpected();default:return this.parseExprAtomDefault()}};V.parseExprAtomDefault=function(){this.unexpected()};V.parseExprImport=function(t){var e=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===f.parenL&&!t)return this.parseDynamicImport(e);if(this.type===f.dot){var i=this.startNodeAt(e.start,e.loc&&e.loc.start);return i.name="import",e.meta=this.finishNode(i,"Identifier"),this.parseImportMeta(e)}else this.unexpected()};V.parseDynamicImport=function(t){if(this.next(),t.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(f.parenR)?t.options=null:(this.expect(f.comma),this.afterTrailingComma(f.parenR)?t.options=null:(t.options=this.parseMaybeAssign(),this.eat(f.parenR)||(this.expect(f.comma),this.afterTrailingComma(f.parenR)||this.unexpected())));else if(!this.eat(f.parenR)){var e=this.start;this.eat(f.comma)&&this.eat(f.parenR)?this.raiseRecoverable(e,"Trailing comma is not allowed in import()"):this.unexpected(e)}return this.finishNode(t,"ImportExpression")};V.parseImportMeta=function(t){this.next();var e=this.containsEsc;return t.property=this.parseIdent(!0),t.property.name!=="meta"&&this.raiseRecoverable(t.property.start,"The only valid meta property for import is 'import.meta'"),e&&this.raiseRecoverable(t.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(t.start,"Cannot use 'import.meta' outside a module"),this.finishNode(t,"MetaProperty")};V.parseLiteral=function(t){var e=this.startNode();return e.value=t,e.raw=this.input.slice(this.start,this.end),e.raw.charCodeAt(e.raw.length-1)===110&&(e.bigint=e.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(e,"Literal")};V.parseParenExpression=function(){this.expect(f.parenL);var t=this.parseExpression();return this.expect(f.parenR),t};V.shouldParseArrow=function(t){return!this.canInsertSemicolon()};V.parseParenAndDistinguishExpression=function(t,e){var i=this.start,r=this.startLoc,s,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var n=this.start,o=this.startLoc,u=[],c=!0,h=!1,d=new Me,l=this.yieldPos,m=this.awaitPos,x;for(this.yieldPos=0,this.awaitPos=0;this.type!==f.parenR;)if(c?c=!1:this.expect(f.comma),a&&this.afterTrailingComma(f.parenR,!0)){h=!0;break}else if(this.type===f.ellipsis){x=this.start,u.push(this.parseParenItem(this.parseRestBinding())),this.type===f.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else u.push(this.parseMaybeAssign(!1,d,this.parseParenItem));var E=this.lastTokEnd,S=this.lastTokEndLoc;if(this.expect(f.parenR),t&&this.shouldParseArrow(u)&&this.eat(f.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=l,this.awaitPos=m,this.parseParenArrowList(i,r,u,e);(!u.length||h)&&this.unexpected(this.lastTokStart),x&&this.unexpected(x),this.checkExpressionErrors(d,!0),this.yieldPos=l||this.yieldPos,this.awaitPos=m||this.awaitPos,u.length>1?(s=this.startNodeAt(n,o),s.expressions=u,this.finishNodeAt(s,"SequenceExpression",E,S)):s=u[0]}else s=this.parseParenExpression();if(this.options.preserveParens){var p=this.startNodeAt(i,r);return p.expression=s,this.finishNode(p,"ParenthesizedExpression")}else return s};V.parseParenItem=function(t){return t};V.parseParenArrowList=function(t,e,i,r){return this.parseArrowExpression(this.startNodeAt(t,e),i,!1,r)};var Hs=[];V.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var t=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===f.dot){var e=this.startNodeAt(t.start,t.loc&&t.loc.start);e.name="new",t.meta=this.finishNode(e,"Identifier"),this.next();var i=this.containsEsc;return t.property=this.parseIdent(!0),t.property.name!=="target"&&this.raiseRecoverable(t.property.start,"The only valid meta property for new is 'new.target'"),i&&this.raiseRecoverable(t.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(t.start,"'new.target' can only be used in functions and class static block"),this.finishNode(t,"MetaProperty")}var r=this.start,s=this.startLoc;return t.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,s,!0,!1),this.eat(f.parenL)?t.arguments=this.parseExprList(f.parenR,this.options.ecmaVersion>=8,!1):t.arguments=Hs,this.finishNode(t,"NewExpression")};V.parseTemplateElement=function(t){var e=t.isTagged,i=this.startNode();return this.type===f.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),i.value={raw:this.value.replace(/\r\n?/g,`
|
|
39
|
+
`),cooked:null}):i.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
|
|
40
|
+
`),cooked:this.value},this.next(),i.tail=this.type===f.backQuote,this.finishNode(i,"TemplateElement")};V.parseTemplate=function(t){t===void 0&&(t={});var e=t.isTagged;e===void 0&&(e=!1);var i=this.startNode();this.next(),i.expressions=[];var r=this.parseTemplateElement({isTagged:e});for(i.quasis=[r];!r.tail;)this.type===f.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(f.dollarBraceL),i.expressions.push(this.parseExpression()),this.expect(f.braceR),i.quasis.push(r=this.parseTemplateElement({isTagged:e}));return this.next(),this.finishNode(i,"TemplateLiteral")};V.isAsyncProp=function(t){return!t.computed&&t.key.type==="Identifier"&&t.key.name==="async"&&(this.type===f.name||this.type===f.num||this.type===f.string||this.type===f.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===f.star)&&!_t.test(this.input.slice(this.lastTokEnd,this.start))};V.parseObj=function(t,e){var i=this.startNode(),r=!0,s={};for(i.properties=[],this.next();!this.eat(f.braceR);){if(r)r=!1;else if(this.expect(f.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(f.braceR))break;var a=this.parseProperty(t,e);t||this.checkPropClash(a,s,e),i.properties.push(a)}return this.finishNode(i,t?"ObjectPattern":"ObjectExpression")};V.parseProperty=function(t,e){var i=this.startNode(),r,s,a,n;if(this.options.ecmaVersion>=9&&this.eat(f.ellipsis))return t?(i.argument=this.parseIdent(!1),this.type===f.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(i,"RestElement")):(i.argument=this.parseMaybeAssign(!1,e),this.type===f.comma&&e&&e.trailingComma<0&&(e.trailingComma=this.start),this.finishNode(i,"SpreadElement"));this.options.ecmaVersion>=6&&(i.method=!1,i.shorthand=!1,(t||e)&&(a=this.start,n=this.startLoc),t||(r=this.eat(f.star)));var o=this.containsEsc;return this.parsePropertyName(i),!t&&!o&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(i)?(s=!0,r=this.options.ecmaVersion>=9&&this.eat(f.star),this.parsePropertyName(i)):s=!1,this.parsePropertyValue(i,t,r,s,a,n,e,o),this.finishNode(i,"Property")};V.parseGetterSetter=function(t){t.kind=t.key.name,this.parsePropertyName(t),t.value=this.parseMethod(!1);var e=t.kind==="get"?0:1;if(t.value.params.length!==e){var i=t.value.start;t.kind==="get"?this.raiseRecoverable(i,"getter should have no params"):this.raiseRecoverable(i,"setter should have exactly one param")}else t.kind==="set"&&t.value.params[0].type==="RestElement"&&this.raiseRecoverable(t.value.params[0].start,"Setter cannot use rest params")};V.parsePropertyValue=function(t,e,i,r,s,a,n,o){(i||r)&&this.type===f.colon&&this.unexpected(),this.eat(f.colon)?(t.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,n),t.kind="init"):this.options.ecmaVersion>=6&&this.type===f.parenL?(e&&this.unexpected(),t.kind="init",t.method=!0,t.value=this.parseMethod(i,r)):!e&&!o&&this.options.ecmaVersion>=5&&!t.computed&&t.key.type==="Identifier"&&(t.key.name==="get"||t.key.name==="set")&&this.type!==f.comma&&this.type!==f.braceR&&this.type!==f.eq?((i||r)&&this.unexpected(),this.parseGetterSetter(t)):this.options.ecmaVersion>=6&&!t.computed&&t.key.type==="Identifier"?((i||r)&&this.unexpected(),this.checkUnreserved(t.key),t.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=s),t.kind="init",e?t.value=this.parseMaybeDefault(s,a,this.copyNode(t.key)):this.type===f.eq&&n?(n.shorthandAssign<0&&(n.shorthandAssign=this.start),t.value=this.parseMaybeDefault(s,a,this.copyNode(t.key))):t.value=this.copyNode(t.key),t.shorthand=!0):this.unexpected()};V.parsePropertyName=function(t){if(this.options.ecmaVersion>=6){if(this.eat(f.bracketL))return t.computed=!0,t.key=this.parseMaybeAssign(),this.expect(f.bracketR),t.key;t.computed=!1}return t.key=this.type===f.num||this.type===f.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};V.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)};V.parseMethod=function(t,e,i){var r=this.startNode(),s=this.yieldPos,a=this.awaitPos,n=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=t),this.options.ecmaVersion>=8&&(r.async=!!e),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(di(e,r.generator)|li|(i?xr:0)),this.expect(f.parenL),r.params=this.parseBindingList(f.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=s,this.awaitPos=a,this.awaitIdentPos=n,this.finishNode(r,"FunctionExpression")};V.parseArrowExpression=function(t,e,i,r){var s=this.yieldPos,a=this.awaitPos,n=this.awaitIdentPos;return this.enterScope(di(i,!1)|mr),this.initFunction(t),this.options.ecmaVersion>=8&&(t.async=!!i),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,t.params=this.toAssignableList(e,!0),this.parseFunctionBody(t,!0,!1,r),this.yieldPos=s,this.awaitPos=a,this.awaitIdentPos=n,this.finishNode(t,"ArrowFunctionExpression")};V.parseFunctionBody=function(t,e,i,r){var s=e&&this.type!==f.braceL,a=this.strict,n=!1;if(s)t.body=this.parseMaybeAssign(r),t.expression=!0,this.checkParams(t,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(t.params);(!a||o)&&(n=this.strictDirective(this.end),n&&o&&this.raiseRecoverable(t.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var u=this.labels;this.labels=[],n&&(this.strict=!0),this.checkParams(t,!a&&!n&&!e&&!i&&this.isSimpleParamList(t.params)),this.strict&&t.id&&this.checkLValSimple(t.id,vr),t.body=this.parseBlock(!1,void 0,n&&!a),t.expression=!1,this.adaptDirectivePrologue(t.body.body),this.labels=u}this.exitScope()};V.isSimpleParamList=function(t){for(var e=0,i=t;e<i.length;e+=1){var r=i[e];if(r.type!=="Identifier")return!1}return!0};V.checkParams=function(t,e){for(var i=Object.create(null),r=0,s=t.params;r<s.length;r+=1){var a=s[r];this.checkLValInnerPattern(a,fi,e?null:i)}};V.parseExprList=function(t,e,i,r){for(var s=[],a=!0;!this.eat(t);){if(a)a=!1;else if(this.expect(f.comma),e&&this.afterTrailingComma(t))break;var n=void 0;i&&this.type===f.comma?n=null:this.type===f.ellipsis?(n=this.parseSpread(r),r&&this.type===f.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):n=this.parseMaybeAssign(!1,r),s.push(n)}return s};V.checkUnreserved=function(t){var e=t.start,i=t.end,r=t.name;if(this.inGenerator&&r==="yield"&&this.raiseRecoverable(e,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&r==="await"&&this.raiseRecoverable(e,"Cannot use 'await' as identifier inside an async function"),this.currentThisScope().inClassFieldInit&&r==="arguments"&&this.raiseRecoverable(e,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(r==="arguments"||r==="await")&&this.raise(e,"Cannot use "+r+" in class static initialization block"),this.keywords.test(r)&&this.raise(e,"Unexpected keyword '"+r+"'"),!(this.options.ecmaVersion<6&&this.input.slice(e,i).indexOf("\\")!==-1)){var s=this.strict?this.reservedWordsStrict:this.reservedWords;s.test(r)&&(!this.inAsync&&r==="await"&&this.raiseRecoverable(e,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(e,"The keyword '"+r+"' is reserved"))}};V.parseIdent=function(t){var e=this.parseIdentNode();return this.next(!!t),this.finishNode(e,"Identifier"),t||(this.checkUnreserved(e),e.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=e.start)),e};V.parseIdentNode=function(){var t=this.startNode();return this.type===f.name?t.name=this.value:this.type.keyword?(t.name=this.type.keyword,(t.name==="class"||t.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=f.name):this.unexpected(),t};V.parsePrivateIdent=function(){var t=this.startNode();return this.type===f.privateId?t.name=this.value:this.unexpected(),this.next(),this.finishNode(t,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(t.start,"Private field '#"+t.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(t)),t};V.parseYield=function(t){this.yieldPos||(this.yieldPos=this.start);var e=this.startNode();return this.next(),this.type===f.semi||this.canInsertSemicolon()||this.type!==f.star&&!this.type.startsExpr?(e.delegate=!1,e.argument=null):(e.delegate=this.eat(f.star),e.argument=this.parseMaybeAssign(t)),this.finishNode(e,"YieldExpression")};V.parseAwait=function(t){this.awaitPos||(this.awaitPos=this.start);var e=this.startNode();return this.next(),e.argument=this.parseMaybeUnary(null,!0,!1,t),this.finishNode(e,"AwaitExpression")};var Te=X.prototype;Te.raise=function(t,e){var i=dr(this.input,t);e+=" ("+i.line+":"+i.column+")";var r=new SyntaxError(e);throw r.pos=t,r.loc=i,r.raisedAt=this.pos,r};Te.raiseRecoverable=Te.raise;Te.curPosition=function(){if(this.options.locations)return new fe(this.curLine,this.pos-this.lineStart)};var Ht=X.prototype,Us=function(t){this.flags=t,this.var=[],this.lexical=[],this.functions=[],this.inClassFieldInit=!1};Ht.enterScope=function(t){this.scopeStack.push(new Us(t))};Ht.exitScope=function(){this.scopeStack.pop()};Ht.treatFunctionsAsVarInScope=function(t){return t.flags&ue||!this.inModule&&t.flags&me};Ht.declareName=function(t,e,i){var r=!1;if(e===Mt){var s=this.currentScope();r=s.lexical.indexOf(t)>-1||s.functions.indexOf(t)>-1||s.var.indexOf(t)>-1,s.lexical.push(t),this.inModule&&s.flags&me&&delete this.undefinedExports[t]}else if(e===wr){var a=this.currentScope();a.lexical.push(t)}else if(e===yr){var n=this.currentScope();this.treatFunctionsAsVar?r=n.lexical.indexOf(t)>-1:r=n.lexical.indexOf(t)>-1||n.var.indexOf(t)>-1,n.functions.push(t)}else for(var o=this.scopeStack.length-1;o>=0;--o){var u=this.scopeStack[o];if(u.lexical.indexOf(t)>-1&&!(u.flags&gr&&u.lexical[0]===t)||!this.treatFunctionsAsVarInScope(u)&&u.functions.indexOf(t)>-1){r=!0;break}if(u.var.push(t),this.inModule&&u.flags&me&&delete this.undefinedExports[t],u.flags&pi)break}r&&this.raiseRecoverable(i,"Identifier '"+t+"' has already been declared")};Ht.checkLocalExport=function(t){this.scopeStack[0].lexical.indexOf(t.name)===-1&&this.scopeStack[0].var.indexOf(t.name)===-1&&(this.undefinedExports[t.name]=t)};Ht.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};Ht.currentVarScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(e.flags&pi)return e}};Ht.currentThisScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(e.flags&pi&&!(e.flags&mr))return e}};var We=function(t,e,i){this.type="",this.start=e,this.end=0,t.options.locations&&(this.loc=new Le(t,i)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[e,0])},ye=X.prototype;ye.startNode=function(){return new We(this,this.start,this.startLoc)};ye.startNodeAt=function(t,e){return new We(this,t,e)};function Er(t,e,i,r){return t.type=e,t.end=i,this.options.locations&&(t.loc.end=r),this.options.ranges&&(t.range[1]=i),t}ye.finishNode=function(t,e){return Er.call(this,t,e,this.lastTokEnd,this.lastTokEndLoc)};ye.finishNodeAt=function(t,e,i,r){return Er.call(this,t,e,i,r)};ye.copyNode=function(t){var e=new We(this,t.start,this.startLoc);for(var i in t)e[i]=t[i];return e};var Gs="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",Sr="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",Cr=Sr+" Extended_Pictographic",Nr=Cr,Ar=Nr+" EBase EComp EMod EPres ExtPict",Ir=Ar,Ks=Ir,zs={9:Sr,10:Cr,11:Nr,12:Ar,13:Ir,14:Ks},Ys="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",Qs={9:"",10:"",11:"",12:"",13:"",14:Ys},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",kr="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",Dr=kr+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",Tr=Dr+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Pr=Tr+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Or=Pr+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Js=Or+" "+Gs,Xs={9:kr,10:Dr,11:Tr,12:Pr,13:Or,14:Js},Fr={};function Zs(t){var e=Fr[t]={binary:jt(zs[t]+" "+Ti),binaryOfStrings:jt(Qs[t]),nonBinary:{General_Category:jt(Ti),Script:jt(Xs[t])}};e.nonBinary.Script_Extensions=e.nonBinary.Script,e.nonBinary.gc=e.nonBinary.General_Category,e.nonBinary.sc=e.nonBinary.Script,e.nonBinary.scx=e.nonBinary.Script_Extensions}for(var Ge=0,Pi=[9,10,11,12,13,14];Ge<Pi.length;Ge+=1){var tn=Pi[Ge];Zs(tn)}var P=X.prototype,Pe=function(t,e){this.parent=t,this.base=e||this};Pe.prototype.separatedFrom=function(t){for(var e=this;e;e=e.parent)for(var i=t;i;i=i.parent)if(e.base===i.base&&e!==i)return!0;return!1};Pe.prototype.sibling=function(){return new Pe(this.parent,this.base)};var Rt=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=Fr[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};Rt.prototype.reset=function(t,e,i){var r=i.indexOf("v")!==-1,s=i.indexOf("u")!==-1;this.start=t|0,this.source=e+"",this.flags=i,r&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=s&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=s&&this.parser.options.ecmaVersion>=9)};Rt.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)};Rt.prototype.at=function(t,e){e===void 0&&(e=!1);var i=this.source,r=i.length;if(t>=r)return-1;var s=i.charCodeAt(t);if(!(e||this.switchU)||s<=55295||s>=57344||t+1>=r)return s;var a=i.charCodeAt(t+1);return a>=56320&&a<=57343?(s<<10)+a-56613888:s};Rt.prototype.nextIndex=function(t,e){e===void 0&&(e=!1);var i=this.source,r=i.length;if(t>=r)return r;var s=i.charCodeAt(t),a;return!(e||this.switchU)||s<=55295||s>=57344||t+1>=r||(a=i.charCodeAt(t+1))<56320||a>57343?t+1:t+2};Rt.prototype.current=function(t){return t===void 0&&(t=!1),this.at(this.pos,t)};Rt.prototype.lookahead=function(t){return t===void 0&&(t=!1),this.at(this.nextIndex(this.pos,t),t)};Rt.prototype.advance=function(t){t===void 0&&(t=!1),this.pos=this.nextIndex(this.pos,t)};Rt.prototype.eat=function(t,e){return e===void 0&&(e=!1),this.current(e)===t?(this.advance(e),!0):!1};Rt.prototype.eatChars=function(t,e){e===void 0&&(e=!1);for(var i=this.pos,r=0,s=t;r<s.length;r+=1){var a=s[r],n=this.at(i,e);if(n===-1||n!==a)return!1;i=this.nextIndex(i,e)}return this.pos=i,!0};P.validateRegExpFlags=function(t){for(var e=t.validFlags,i=t.flags,r=!1,s=!1,a=0;a<i.length;a++){var n=i.charAt(a);e.indexOf(n)===-1&&this.raise(t.start,"Invalid regular expression flag"),i.indexOf(n,a+1)>-1&&this.raise(t.start,"Duplicate regular expression flag"),n==="u"&&(r=!0),n==="v"&&(s=!0)}this.options.ecmaVersion>=15&&r&&s&&this.raise(t.start,"Invalid regular expression flag")};function en(t){for(var e in t)return!0;return!1}P.validateRegExpPattern=function(t){this.regexp_pattern(t),!t.switchN&&this.options.ecmaVersion>=9&&en(t.groupNames)&&(t.switchN=!0,this.regexp_pattern(t))};P.regexp_pattern=function(t){t.pos=0,t.lastIntValue=0,t.lastStringValue="",t.lastAssertionIsQuantifiable=!1,t.numCapturingParens=0,t.maxBackReference=0,t.groupNames=Object.create(null),t.backReferenceNames.length=0,t.branchID=null,this.regexp_disjunction(t),t.pos!==t.source.length&&(t.eat(41)&&t.raise("Unmatched ')'"),(t.eat(93)||t.eat(125))&&t.raise("Lone quantifier brackets")),t.maxBackReference>t.numCapturingParens&&t.raise("Invalid escape");for(var e=0,i=t.backReferenceNames;e<i.length;e+=1){var r=i[e];t.groupNames[r]||t.raise("Invalid named capture referenced")}};P.regexp_disjunction=function(t){var e=this.options.ecmaVersion>=16;for(e&&(t.branchID=new Pe(t.branchID,null)),this.regexp_alternative(t);t.eat(124);)e&&(t.branchID=t.branchID.sibling()),this.regexp_alternative(t);e&&(t.branchID=t.branchID.parent),this.regexp_eatQuantifier(t,!0)&&t.raise("Nothing to repeat"),t.eat(123)&&t.raise("Lone quantifier brackets")};P.regexp_alternative=function(t){for(;t.pos<t.source.length&&this.regexp_eatTerm(t););};P.regexp_eatTerm=function(t){return this.regexp_eatAssertion(t)?(t.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(t)&&t.switchU&&t.raise("Invalid quantifier"),!0):(t.switchU?this.regexp_eatAtom(t):this.regexp_eatExtendedAtom(t))?(this.regexp_eatQuantifier(t),!0):!1};P.regexp_eatAssertion=function(t){var e=t.pos;if(t.lastAssertionIsQuantifiable=!1,t.eat(94)||t.eat(36))return!0;if(t.eat(92)){if(t.eat(66)||t.eat(98))return!0;t.pos=e}if(t.eat(40)&&t.eat(63)){var i=!1;if(this.options.ecmaVersion>=9&&(i=t.eat(60)),t.eat(61)||t.eat(33))return this.regexp_disjunction(t),t.eat(41)||t.raise("Unterminated group"),t.lastAssertionIsQuantifiable=!i,!0}return t.pos=e,!1};P.regexp_eatQuantifier=function(t,e){return e===void 0&&(e=!1),this.regexp_eatQuantifierPrefix(t,e)?(t.eat(63),!0):!1};P.regexp_eatQuantifierPrefix=function(t,e){return t.eat(42)||t.eat(43)||t.eat(63)||this.regexp_eatBracedQuantifier(t,e)};P.regexp_eatBracedQuantifier=function(t,e){var i=t.pos;if(t.eat(123)){var r=0,s=-1;if(this.regexp_eatDecimalDigits(t)&&(r=t.lastIntValue,t.eat(44)&&this.regexp_eatDecimalDigits(t)&&(s=t.lastIntValue),t.eat(125)))return s!==-1&&s<r&&!e&&t.raise("numbers out of order in {} quantifier"),!0;t.switchU&&!e&&t.raise("Incomplete quantifier"),t.pos=i}return!1};P.regexp_eatAtom=function(t){return this.regexp_eatPatternCharacters(t)||t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)};P.regexp_eatReverseSolidusAtomEscape=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatAtomEscape(t))return!0;t.pos=e}return!1};P.regexp_eatUncapturingGroup=function(t){var e=t.pos;if(t.eat(40)){if(t.eat(63)){if(this.options.ecmaVersion>=16){var i=this.regexp_eatModifiers(t),r=t.eat(45);if(i||r){for(var s=0;s<i.length;s++){var a=i.charAt(s);i.indexOf(a,s+1)>-1&&t.raise("Duplicate regular expression modifiers")}if(r){var n=this.regexp_eatModifiers(t);!i&&!n&&t.current()===58&&t.raise("Invalid regular expression modifiers");for(var o=0;o<n.length;o++){var u=n.charAt(o);(n.indexOf(u,o+1)>-1||i.indexOf(u)>-1)&&t.raise("Duplicate regular expression modifiers")}}}}if(t.eat(58)){if(this.regexp_disjunction(t),t.eat(41))return!0;t.raise("Unterminated group")}}t.pos=e}return!1};P.regexp_eatCapturingGroup=function(t){if(t.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(t):t.current()===63&&t.raise("Invalid group"),this.regexp_disjunction(t),t.eat(41))return t.numCapturingParens+=1,!0;t.raise("Unterminated group")}return!1};P.regexp_eatModifiers=function(t){for(var e="",i=0;(i=t.current())!==-1&&rn(i);)e+=Vt(i),t.advance();return e};function rn(t){return t===105||t===109||t===115}P.regexp_eatExtendedAtom=function(t){return t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)||this.regexp_eatInvalidBracedQuantifier(t)||this.regexp_eatExtendedPatternCharacter(t)};P.regexp_eatInvalidBracedQuantifier=function(t){return this.regexp_eatBracedQuantifier(t,!0)&&t.raise("Nothing to repeat"),!1};P.regexp_eatSyntaxCharacter=function(t){var e=t.current();return Rr(e)?(t.lastIntValue=e,t.advance(),!0):!1};function Rr(t){return t===36||t>=40&&t<=43||t===46||t===63||t>=91&&t<=94||t>=123&&t<=125}P.regexp_eatPatternCharacters=function(t){for(var e=t.pos,i=0;(i=t.current())!==-1&&!Rr(i);)t.advance();return t.pos!==e};P.regexp_eatExtendedPatternCharacter=function(t){var e=t.current();return e!==-1&&e!==36&&!(e>=40&&e<=43)&&e!==46&&e!==63&&e!==91&&e!==94&&e!==124?(t.advance(),!0):!1};P.regexp_groupSpecifier=function(t){if(t.eat(63)){this.regexp_eatGroupName(t)||t.raise("Invalid group");var e=this.options.ecmaVersion>=16,i=t.groupNames[t.lastStringValue];if(i)if(e)for(var r=0,s=i;r<s.length;r+=1){var a=s[r];a.separatedFrom(t.branchID)||t.raise("Duplicate capture group name")}else t.raise("Duplicate capture group name");e?(i||(t.groupNames[t.lastStringValue]=[])).push(t.branchID):t.groupNames[t.lastStringValue]=!0}};P.regexp_eatGroupName=function(t){if(t.lastStringValue="",t.eat(60)){if(this.regexp_eatRegExpIdentifierName(t)&&t.eat(62))return!0;t.raise("Invalid capture group name")}return!1};P.regexp_eatRegExpIdentifierName=function(t){if(t.lastStringValue="",this.regexp_eatRegExpIdentifierStart(t)){for(t.lastStringValue+=Vt(t.lastIntValue);this.regexp_eatRegExpIdentifierPart(t);)t.lastStringValue+=Vt(t.lastIntValue);return!0}return!1};P.regexp_eatRegExpIdentifierStart=function(t){var e=t.pos,i=this.options.ecmaVersion>=11,r=t.current(i);return t.advance(i),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(t,i)&&(r=t.lastIntValue),sn(r)?(t.lastIntValue=r,!0):(t.pos=e,!1)};function sn(t){return Bt(t,!0)||t===36||t===95}P.regexp_eatRegExpIdentifierPart=function(t){var e=t.pos,i=this.options.ecmaVersion>=11,r=t.current(i);return t.advance(i),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(t,i)&&(r=t.lastIntValue),nn(r)?(t.lastIntValue=r,!0):(t.pos=e,!1)};function nn(t){return se(t,!0)||t===36||t===95||t===8204||t===8205}P.regexp_eatAtomEscape=function(t){return this.regexp_eatBackReference(t)||this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)||t.switchN&&this.regexp_eatKGroupName(t)?!0:(t.switchU&&(t.current()===99&&t.raise("Invalid unicode escape"),t.raise("Invalid escape")),!1)};P.regexp_eatBackReference=function(t){var e=t.pos;if(this.regexp_eatDecimalEscape(t)){var i=t.lastIntValue;if(t.switchU)return i>t.maxBackReference&&(t.maxBackReference=i),!0;if(i<=t.numCapturingParens)return!0;t.pos=e}return!1};P.regexp_eatKGroupName=function(t){if(t.eat(107)){if(this.regexp_eatGroupName(t))return t.backReferenceNames.push(t.lastStringValue),!0;t.raise("Invalid named reference")}return!1};P.regexp_eatCharacterEscape=function(t){return this.regexp_eatControlEscape(t)||this.regexp_eatCControlLetter(t)||this.regexp_eatZero(t)||this.regexp_eatHexEscapeSequence(t)||this.regexp_eatRegExpUnicodeEscapeSequence(t,!1)||!t.switchU&&this.regexp_eatLegacyOctalEscapeSequence(t)||this.regexp_eatIdentityEscape(t)};P.regexp_eatCControlLetter=function(t){var e=t.pos;if(t.eat(99)){if(this.regexp_eatControlLetter(t))return!0;t.pos=e}return!1};P.regexp_eatZero=function(t){return t.current()===48&&!je(t.lookahead())?(t.lastIntValue=0,t.advance(),!0):!1};P.regexp_eatControlEscape=function(t){var e=t.current();return e===116?(t.lastIntValue=9,t.advance(),!0):e===110?(t.lastIntValue=10,t.advance(),!0):e===118?(t.lastIntValue=11,t.advance(),!0):e===102?(t.lastIntValue=12,t.advance(),!0):e===114?(t.lastIntValue=13,t.advance(),!0):!1};P.regexp_eatControlLetter=function(t){var e=t.current();return Br(e)?(t.lastIntValue=e%32,t.advance(),!0):!1};function Br(t){return t>=65&&t<=90||t>=97&&t<=122}P.regexp_eatRegExpUnicodeEscapeSequence=function(t,e){e===void 0&&(e=!1);var i=t.pos,r=e||t.switchU;if(t.eat(117)){if(this.regexp_eatFixedHexDigits(t,4)){var s=t.lastIntValue;if(r&&s>=55296&&s<=56319){var a=t.pos;if(t.eat(92)&&t.eat(117)&&this.regexp_eatFixedHexDigits(t,4)){var n=t.lastIntValue;if(n>=56320&&n<=57343)return t.lastIntValue=(s-55296)*1024+(n-56320)+65536,!0}t.pos=a,t.lastIntValue=s}return!0}if(r&&t.eat(123)&&this.regexp_eatHexDigits(t)&&t.eat(125)&&an(t.lastIntValue))return!0;r&&t.raise("Invalid unicode escape"),t.pos=i}return!1};function an(t){return t>=0&&t<=1114111}P.regexp_eatIdentityEscape=function(t){if(t.switchU)return this.regexp_eatSyntaxCharacter(t)?!0:t.eat(47)?(t.lastIntValue=47,!0):!1;var e=t.current();return e!==99&&(!t.switchN||e!==107)?(t.lastIntValue=e,t.advance(),!0):!1};P.regexp_eatDecimalEscape=function(t){t.lastIntValue=0;var e=t.current();if(e>=49&&e<=57){do t.lastIntValue=10*t.lastIntValue+(e-48),t.advance();while((e=t.current())>=48&&e<=57);return!0}return!1};var Vr=0,Lt=1,vt=2;P.regexp_eatCharacterClassEscape=function(t){var e=t.current();if(on(e))return t.lastIntValue=-1,t.advance(),Lt;var i=!1;if(t.switchU&&this.options.ecmaVersion>=9&&((i=e===80)||e===112)){t.lastIntValue=-1,t.advance();var r;if(t.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(t))&&t.eat(125))return i&&r===vt&&t.raise("Invalid property name"),r;t.raise("Invalid property name")}return Vr};function on(t){return t===100||t===68||t===115||t===83||t===119||t===87}P.regexp_eatUnicodePropertyValueExpression=function(t){var e=t.pos;if(this.regexp_eatUnicodePropertyName(t)&&t.eat(61)){var i=t.lastStringValue;if(this.regexp_eatUnicodePropertyValue(t)){var r=t.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(t,i,r),Lt}}if(t.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(t)){var s=t.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(t,s)}return Vr};P.regexp_validateUnicodePropertyNameAndValue=function(t,e,i){oe(t.unicodeProperties.nonBinary,e)||t.raise("Invalid property name"),t.unicodeProperties.nonBinary[e].test(i)||t.raise("Invalid property value")};P.regexp_validateUnicodePropertyNameOrValue=function(t,e){if(t.unicodeProperties.binary.test(e))return Lt;if(t.switchV&&t.unicodeProperties.binaryOfStrings.test(e))return vt;t.raise("Invalid property name")};P.regexp_eatUnicodePropertyName=function(t){var e=0;for(t.lastStringValue="";Lr(e=t.current());)t.lastStringValue+=Vt(e),t.advance();return t.lastStringValue!==""};function Lr(t){return Br(t)||t===95}P.regexp_eatUnicodePropertyValue=function(t){var e=0;for(t.lastStringValue="";un(e=t.current());)t.lastStringValue+=Vt(e),t.advance();return t.lastStringValue!==""};function un(t){return Lr(t)||je(t)}P.regexp_eatLoneUnicodePropertyNameOrValue=function(t){return this.regexp_eatUnicodePropertyValue(t)};P.regexp_eatCharacterClass=function(t){if(t.eat(91)){var e=t.eat(94),i=this.regexp_classContents(t);return t.eat(93)||t.raise("Unterminated character class"),e&&i===vt&&t.raise("Negated character class may contain strings"),!0}return!1};P.regexp_classContents=function(t){return t.current()===93?Lt:t.switchV?this.regexp_classSetExpression(t):(this.regexp_nonEmptyClassRanges(t),Lt)};P.regexp_nonEmptyClassRanges=function(t){for(;this.regexp_eatClassAtom(t);){var e=t.lastIntValue;if(t.eat(45)&&this.regexp_eatClassAtom(t)){var i=t.lastIntValue;t.switchU&&(e===-1||i===-1)&&t.raise("Invalid character class"),e!==-1&&i!==-1&&e>i&&t.raise("Range out of order in character class")}}};P.regexp_eatClassAtom=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatClassEscape(t))return!0;if(t.switchU){var i=t.current();(i===99||jr(i))&&t.raise("Invalid class escape"),t.raise("Invalid escape")}t.pos=e}var r=t.current();return r!==93?(t.lastIntValue=r,t.advance(),!0):!1};P.regexp_eatClassEscape=function(t){var e=t.pos;if(t.eat(98))return t.lastIntValue=8,!0;if(t.switchU&&t.eat(45))return t.lastIntValue=45,!0;if(!t.switchU&&t.eat(99)){if(this.regexp_eatClassControlLetter(t))return!0;t.pos=e}return this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)};P.regexp_classSetExpression=function(t){var e=Lt,i;if(!this.regexp_eatClassSetRange(t))if(i=this.regexp_eatClassSetOperand(t)){i===vt&&(e=vt);for(var r=t.pos;t.eatChars([38,38]);){if(t.current()!==38&&(i=this.regexp_eatClassSetOperand(t))){i!==vt&&(e=Lt);continue}t.raise("Invalid character in character class")}if(r!==t.pos)return e;for(;t.eatChars([45,45]);)this.regexp_eatClassSetOperand(t)||t.raise("Invalid character in character class");if(r!==t.pos)return e}else t.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(t)){if(i=this.regexp_eatClassSetOperand(t),!i)return e;i===vt&&(e=vt)}};P.regexp_eatClassSetRange=function(t){var e=t.pos;if(this.regexp_eatClassSetCharacter(t)){var i=t.lastIntValue;if(t.eat(45)&&this.regexp_eatClassSetCharacter(t)){var r=t.lastIntValue;return i!==-1&&r!==-1&&i>r&&t.raise("Range out of order in character class"),!0}t.pos=e}return!1};P.regexp_eatClassSetOperand=function(t){return this.regexp_eatClassSetCharacter(t)?Lt:this.regexp_eatClassStringDisjunction(t)||this.regexp_eatNestedClass(t)};P.regexp_eatNestedClass=function(t){var e=t.pos;if(t.eat(91)){var i=t.eat(94),r=this.regexp_classContents(t);if(t.eat(93))return i&&r===vt&&t.raise("Negated character class may contain strings"),r;t.pos=e}if(t.eat(92)){var s=this.regexp_eatCharacterClassEscape(t);if(s)return s;t.pos=e}return null};P.regexp_eatClassStringDisjunction=function(t){var e=t.pos;if(t.eatChars([92,113])){if(t.eat(123)){var i=this.regexp_classStringDisjunctionContents(t);if(t.eat(125))return i}else t.raise("Invalid escape");t.pos=e}return null};P.regexp_classStringDisjunctionContents=function(t){for(var e=this.regexp_classString(t);t.eat(124);)this.regexp_classString(t)===vt&&(e=vt);return e};P.regexp_classString=function(t){for(var e=0;this.regexp_eatClassSetCharacter(t);)e++;return e===1?Lt:vt};P.regexp_eatClassSetCharacter=function(t){var e=t.pos;if(t.eat(92))return this.regexp_eatCharacterEscape(t)||this.regexp_eatClassSetReservedPunctuator(t)?!0:t.eat(98)?(t.lastIntValue=8,!0):(t.pos=e,!1);var i=t.current();return i<0||i===t.lookahead()&&cn(i)||hn(i)?!1:(t.advance(),t.lastIntValue=i,!0)};function cn(t){return t===33||t>=35&&t<=38||t>=42&&t<=44||t===46||t>=58&&t<=64||t===94||t===96||t===126}function hn(t){return t===40||t===41||t===45||t===47||t>=91&&t<=93||t>=123&&t<=125}P.regexp_eatClassSetReservedPunctuator=function(t){var e=t.current();return ln(e)?(t.lastIntValue=e,t.advance(),!0):!1};function ln(t){return t===33||t===35||t===37||t===38||t===44||t===45||t>=58&&t<=62||t===64||t===96||t===126}P.regexp_eatClassControlLetter=function(t){var e=t.current();return je(e)||e===95?(t.lastIntValue=e%32,t.advance(),!0):!1};P.regexp_eatHexEscapeSequence=function(t){var e=t.pos;if(t.eat(120)){if(this.regexp_eatFixedHexDigits(t,2))return!0;t.switchU&&t.raise("Invalid escape"),t.pos=e}return!1};P.regexp_eatDecimalDigits=function(t){var e=t.pos,i=0;for(t.lastIntValue=0;je(i=t.current());)t.lastIntValue=10*t.lastIntValue+(i-48),t.advance();return t.pos!==e};function je(t){return t>=48&&t<=57}P.regexp_eatHexDigits=function(t){var e=t.pos,i=0;for(t.lastIntValue=0;Mr(i=t.current());)t.lastIntValue=16*t.lastIntValue+Wr(i),t.advance();return t.pos!==e};function Mr(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function Wr(t){return t>=65&&t<=70?10+(t-65):t>=97&&t<=102?10+(t-97):t-48}P.regexp_eatLegacyOctalEscapeSequence=function(t){if(this.regexp_eatOctalDigit(t)){var e=t.lastIntValue;if(this.regexp_eatOctalDigit(t)){var i=t.lastIntValue;e<=3&&this.regexp_eatOctalDigit(t)?t.lastIntValue=e*64+i*8+t.lastIntValue:t.lastIntValue=e*8+i}else t.lastIntValue=e;return!0}return!1};P.regexp_eatOctalDigit=function(t){var e=t.current();return jr(e)?(t.lastIntValue=e-48,t.advance(),!0):(t.lastIntValue=0,!1)};function jr(t){return t>=48&&t<=55}P.regexp_eatFixedHexDigits=function(t,e){var i=t.pos;t.lastIntValue=0;for(var r=0;r<e;++r){var s=t.current();if(!Mr(s))return t.pos=i,!1;t.lastIntValue=16*t.lastIntValue+Wr(s),t.advance()}return!0};var gi=function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new Le(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},M=X.prototype;M.next=function(t){!t&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new gi(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};M.getToken=function(){return this.next(),new gi(this)};typeof Symbol<"u"&&(M[Symbol.iterator]=function(){var t=this;return{next:function(){var e=t.getToken();return{done:e.type===f.eof,value:e}}}});M.nextToken=function(){var t=this.curContext();if((!t||!t.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(f.eof);if(t.override)return t.override(this);this.readToken(this.fullCharCodeAtPos())};M.readToken=function(t){return Bt(t,this.options.ecmaVersion>=6)||t===92?this.readWord():this.getTokenFromCode(t)};M.fullCharCodeAtPos=function(){var t=this.input.charCodeAt(this.pos);if(t<=55295||t>=56320)return t;var e=this.input.charCodeAt(this.pos+1);return e<=56319||e>=57344?t:(t<<10)+e-56613888};M.skipBlockComment=function(){var t=this.options.onComment&&this.curPosition(),e=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=e;(r=hr(this.input,s,this.pos))>-1;)++this.curLine,s=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(e+2,i),e,this.pos,t,this.curPosition())};M.skipLineComment=function(t){for(var e=this.pos,i=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=t);this.pos<this.input.length&&!ae(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(e+t,this.pos),e,this.pos,i,this.curPosition())};M.skipSpace=function(){t:for(;this.pos<this.input.length;){var t=this.input.charCodeAt(this.pos);switch(t){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 t}break;default:if(t>8&&t<14||t>=5760&&lr.test(String.fromCharCode(t)))++this.pos;else break t}}};M.finishToken=function(t,e){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var i=this.type;this.type=t,this.value=e,this.updateContext(i)};M.readToken_dot=function(){var t=this.input.charCodeAt(this.pos+1);if(t>=48&&t<=57)return this.readNumber(!0);var e=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&t===46&&e===46?(this.pos+=3,this.finishToken(f.ellipsis)):(++this.pos,this.finishToken(f.dot))};M.readToken_slash=function(){var t=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):t===61?this.finishOp(f.assign,2):this.finishOp(f.slash,1)};M.readToken_mult_modulo_exp=function(t){var e=this.input.charCodeAt(this.pos+1),i=1,r=t===42?f.star:f.modulo;return this.options.ecmaVersion>=7&&t===42&&e===42&&(++i,r=f.starstar,e=this.input.charCodeAt(this.pos+2)),e===61?this.finishOp(f.assign,i+1):this.finishOp(r,i)};M.readToken_pipe_amp=function(t){var e=this.input.charCodeAt(this.pos+1);if(e===t){if(this.options.ecmaVersion>=12){var i=this.input.charCodeAt(this.pos+2);if(i===61)return this.finishOp(f.assign,3)}return this.finishOp(t===124?f.logicalOR:f.logicalAND,2)}return e===61?this.finishOp(f.assign,2):this.finishOp(t===124?f.bitwiseOR:f.bitwiseAND,1)};M.readToken_caret=function(){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(f.assign,2):this.finishOp(f.bitwiseXOR,1)};M.readToken_plus_min=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?e===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||_t.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(f.incDec,2):e===61?this.finishOp(f.assign,2):this.finishOp(f.plusMin,1)};M.readToken_lt_gt=function(t){var e=this.input.charCodeAt(this.pos+1),i=1;return e===t?(i=t===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+i)===61?this.finishOp(f.assign,i+1):this.finishOp(f.bitShift,i)):e===33&&t===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(e===61&&(i=2),this.finishOp(f.relational,i))};M.readToken_eq_excl=function(t){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(f.equality,this.input.charCodeAt(this.pos+2)===61?3:2):t===61&&e===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(f.arrow)):this.finishOp(t===61?f.eq:f.prefix,1)};M.readToken_question=function(){var t=this.options.ecmaVersion;if(t>=11){var e=this.input.charCodeAt(this.pos+1);if(e===46){var i=this.input.charCodeAt(this.pos+2);if(i<48||i>57)return this.finishOp(f.questionDot,2)}if(e===63){if(t>=12){var r=this.input.charCodeAt(this.pos+2);if(r===61)return this.finishOp(f.assign,3)}return this.finishOp(f.coalesce,2)}}return this.finishOp(f.question,1)};M.readToken_numberSign=function(){var t=this.options.ecmaVersion,e=35;if(t>=13&&(++this.pos,e=this.fullCharCodeAtPos(),Bt(e,!0)||e===92))return this.finishToken(f.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+Vt(e)+"'")};M.getTokenFromCode=function(t){switch(t){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(f.parenL);case 41:return++this.pos,this.finishToken(f.parenR);case 59:return++this.pos,this.finishToken(f.semi);case 44:return++this.pos,this.finishToken(f.comma);case 91:return++this.pos,this.finishToken(f.bracketL);case 93:return++this.pos,this.finishToken(f.bracketR);case 123:return++this.pos,this.finishToken(f.braceL);case 125:return++this.pos,this.finishToken(f.braceR);case 58:return++this.pos,this.finishToken(f.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(f.backQuote);case 48:var e=this.input.charCodeAt(this.pos+1);if(e===120||e===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(e===111||e===79)return this.readRadixNumber(8);if(e===98||e===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(t);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(t);case 124:case 38:return this.readToken_pipe_amp(t);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(t);case 60:case 62:return this.readToken_lt_gt(t);case 61:case 33:return this.readToken_eq_excl(t);case 63:return this.readToken_question();case 126:return this.finishOp(f.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+Vt(t)+"'")};M.finishOp=function(t,e){var i=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(t,i)};M.readRegexp=function(){for(var t,e,i=this.pos;;){this.pos>=this.input.length&&this.raise(i,"Unterminated regular expression");var r=this.input.charAt(this.pos);if(_t.test(r)&&this.raise(i,"Unterminated regular expression"),t)t=!1;else{if(r==="[")e=!0;else if(r==="]"&&e)e=!1;else if(r==="/"&&!e)break;t=r==="\\"}++this.pos}var s=this.input.slice(i,this.pos);++this.pos;var a=this.pos,n=this.readWord1();this.containsEsc&&this.unexpected(a);var o=this.regexpState||(this.regexpState=new Rt(this));o.reset(i,s,n),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var u=null;try{u=new RegExp(s,n)}catch{}return this.finishToken(f.regexp,{pattern:s,flags:n,value:u})};M.readInt=function(t,e,i){for(var r=this.options.ecmaVersion>=12&&e===void 0,s=i&&this.input.charCodeAt(this.pos)===48,a=this.pos,n=0,o=0,u=0,c=e??1/0;u<c;++u,++this.pos){var h=this.input.charCodeAt(this.pos),d=void 0;if(r&&h===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"),u===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=h;continue}if(h>=97?d=h-97+10:h>=65?d=h-65+10:h>=48&&h<=57?d=h-48:d=1/0,d>=t)break;o=h,n=n*t+d}return r&&o===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===a||e!=null&&this.pos-a!==e?null:n};function pn(t,e){return e?parseInt(t,8):parseFloat(t.replace(/_/g,""))}function $r(t){return typeof BigInt!="function"?null:BigInt(t.replace(/_/g,""))}M.readRadixNumber=function(t){var e=this.pos;this.pos+=2;var i=this.readInt(t);return i==null&&this.raise(this.start+2,"Expected number in radix "+t),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(i=$r(this.input.slice(e,this.pos)),++this.pos):Bt(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(f.num,i)};M.readNumber=function(t){var e=this.pos;!t&&this.readInt(10,void 0,!0)===null&&this.raise(e,"Invalid number");var i=this.pos-e>=2&&this.input.charCodeAt(e)===48;i&&this.strict&&this.raise(e,"Invalid number");var r=this.input.charCodeAt(this.pos);if(!i&&!t&&this.options.ecmaVersion>=11&&r===110){var s=$r(this.input.slice(e,this.pos));return++this.pos,Bt(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(f.num,s)}i&&/[89]/.test(this.input.slice(e,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(e,"Invalid number")),Bt(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var a=pn(this.input.slice(e,this.pos),i);return this.finishToken(f.num,a)};M.readCodePoint=function(){var t=this.input.charCodeAt(this.pos),e;if(t===123){this.options.ecmaVersion<6&&this.unexpected();var i=++this.pos;e=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,e>1114111&&this.invalidStringToken(i,"Code point out of bounds")}else e=this.readHexChar(4);return e};M.readString=function(t){for(var e="",i=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var r=this.input.charCodeAt(this.pos);if(r===t)break;r===92?(e+=this.input.slice(i,this.pos),e+=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)):(ae(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return e+=this.input.slice(i,this.pos++),this.finishToken(f.string,e)};var qr={};M.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t===qr)this.readInvalidTemplateToken();else throw t}this.inTemplateElement=!1};M.invalidStringToken=function(t,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw qr;this.raise(t,e)};M.readTmplToken=function(){for(var t="",e=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===f.template||this.type===f.invalidTemplate)?i===36?(this.pos+=2,this.finishToken(f.dollarBraceL)):(++this.pos,this.finishToken(f.backQuote)):(t+=this.input.slice(e,this.pos),this.finishToken(f.template,t));if(i===92)t+=this.input.slice(e,this.pos),t+=this.readEscapedChar(!0),e=this.pos;else if(ae(i)){switch(t+=this.input.slice(e,this.pos),++this.pos,i){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:t+=`
|
|
41
|
+
`;break;default:t+=String.fromCharCode(i);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),e=this.pos}else++this.pos}};M.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(f.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
|
|
42
|
+
`&&++this.pos;case`
|
|
43
|
+
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};M.readEscapedChar=function(t){var e=this.input.charCodeAt(++this.pos);switch(++this.pos,e){case 110:return`
|
|
44
|
+
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return Vt(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"),t){var i=this.pos-1;this.invalidStringToken(i,"Invalid escape sequence in template string")}default:if(e>=48&&e<=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,e=this.input.charCodeAt(this.pos),(r!=="0"||e===56||e===57)&&(this.strict||t)&&this.invalidStringToken(this.pos-1-r.length,t?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(s)}return ae(e)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(e)}};M.readHexChar=function(t){var e=this.pos,i=this.readInt(16,t);return i===null&&this.invalidStringToken(e,"Bad character escape sequence"),i};M.readWord1=function(){this.containsEsc=!1;for(var t="",e=!0,i=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var s=this.fullCharCodeAtPos();if(se(s,r))this.pos+=s<=65535?1:2;else if(s===92){this.containsEsc=!0,t+=this.input.slice(i,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var n=this.readCodePoint();(e?Bt:se)(n,r)||this.invalidStringToken(a,"Invalid Unicode escape"),t+=Vt(n),i=this.pos}else break;e=!1}return t+this.input.slice(i,this.pos)};M.readWord=function(){var t=this.readWord1(),e=f.name;return this.keywords.test(t)&&(e=ci[t]),this.finishToken(e,t)};var dn="8.14.0";X.acorn={Parser:X,version:dn,defaultOptions:ti,Position:fe,SourceLocation:Le,getLineInfo:dr,Node:We,TokenType:$,tokTypes:f,keywordTypes:ci,TokContext:Nt,tokContexts:z,isIdentifierChar:se,isIdentifierStart:Bt,Token:gi,isNewLine:ae,lineBreak:_t,lineBreakG:Fs,nonASCIIwhitespace:lr};function Hr(t,e){return X.parse(t,e)}const{stringify:fn}=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 Ne={"||":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},It=17,mn={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:It,ClassExpression:It,FunctionExpression:It,ObjectExpression:It,UpdateExpression:16,UnaryExpression:15,AwaitExpression:15,BinaryExpression:14,LogicalExpression:13,ConditionalExpression:4,AssignmentExpression:3,YieldExpression:2,RestElement:1};function ee(t,e){const{generator:i}=t;if(t.write("("),e!=null&&e.length>0){i[e[0].type](e[0],t);const{length:r}=e;for(let s=1;s<r;s++){const a=e[s];t.write(", "),i[a.type](a,t)}}t.write(")")}function Ur(t,e,i,r){const s=t.expressionsPrecedence[e.type];if(s===It)return!0;const a=t.expressionsPrecedence[i.type];return s!==a?!r&&s===15&&a===14&&i.operator==="**"||s<a:s!==13&&s!==14?!1:e.operator==="**"&&i.operator==="**"?!r:s===13&&a===13&&(e.operator==="??"||i.operator==="??")?!0:r?Ne[e.operator]<=Ne[i.operator]:Ne[e.operator]<Ne[i.operator]}function Ae(t,e,i,r){const{generator:s}=t;Ur(t,e,i,r)?(t.write("("),s[e.type](e,t),t.write(")")):s[e.type](e,t)}function gn(t,e,i,r){const s=e.split(`
|
|
45
|
+
`),a=s.length-1;if(t.write(s[0].trim()),a>0){t.write(r);for(let n=1;n<a;n++)t.write(i+s[n].trim()+r);t.write(i+s[a].trim())}}function at(t,e,i,r){const{length:s}=e;for(let a=0;a<s;a++){const n=e[a];t.write(i),n.type[0]==="L"?t.write("// "+n.value.trim()+`
|
|
46
|
+
`,n):(t.write("/*"),gn(t,n.value,i,r),t.write("*/"+r))}}function xn(t){let e=t;for(;e!=null;){const{type:i}=e;if(i[0]==="C"&&i[1]==="a")return!0;if(i[0]==="M"&&i[1]==="e"&&i[2]==="m")e=e.object;else return!1}}function Ke(t,e){const{generator:i}=t,{declarations:r}=e;t.write(e.kind+" ");const{length:s}=r;if(s>0){i.VariableDeclarator(r[0],t);for(let a=1;a<s;a++)t.write(", "),i.VariableDeclarator(r[a],t)}}let Oi,Fi,Ri,Bi,Vi,Li;const xi={Program(t,e){const i=e.indent.repeat(e.indentLevel),{lineEnd:r,writeComments:s}=e;s&&t.comments!=null&&at(e,t.comments,i,r);const a=t.body,{length:n}=a;for(let o=0;o<n;o++){const u=a[o];s&&u.comments!=null&&at(e,u.comments,i,r),e.write(i),this[u.type](u,e),e.write(r)}s&&t.trailingComments!=null&&at(e,t.trailingComments,i,r)},BlockStatement:Li=function(t,e){const i=e.indent.repeat(e.indentLevel++),{lineEnd:r,writeComments:s}=e,a=i+e.indent;e.write("{");const n=t.body;if(n!=null&&n.length>0){e.write(r),s&&t.comments!=null&&at(e,t.comments,a,r);const{length:o}=n;for(let u=0;u<o;u++){const c=n[u];s&&c.comments!=null&&at(e,c.comments,a,r),e.write(a),this[c.type](c,e),e.write(r)}e.write(i)}else s&&t.comments!=null&&(e.write(r),at(e,t.comments,a,r),e.write(i));s&&t.trailingComments!=null&&at(e,t.trailingComments,a,r),e.write("}"),e.indentLevel--},ClassBody:Li,StaticBlock(t,e){e.write("static "),this.BlockStatement(t,e)},EmptyStatement(t,e){e.write(";")},ExpressionStatement(t,e){const i=e.expressionsPrecedence[t.expression.type];i===It||i===3&&t.expression.left.type[0]==="O"?(e.write("("),this[t.expression.type](t.expression,e),e.write(")")):this[t.expression.type](t.expression,e),e.write(";")},IfStatement(t,e){e.write("if ("),this[t.test.type](t.test,e),e.write(") "),this[t.consequent.type](t.consequent,e),t.alternate!=null&&(e.write(" else "),this[t.alternate.type](t.alternate,e))},LabeledStatement(t,e){this[t.label.type](t.label,e),e.write(": "),this[t.body.type](t.body,e)},BreakStatement(t,e){e.write("break"),t.label!=null&&(e.write(" "),this[t.label.type](t.label,e)),e.write(";")},ContinueStatement(t,e){e.write("continue"),t.label!=null&&(e.write(" "),this[t.label.type](t.label,e)),e.write(";")},WithStatement(t,e){e.write("with ("),this[t.object.type](t.object,e),e.write(") "),this[t.body.type](t.body,e)},SwitchStatement(t,e){const i=e.indent.repeat(e.indentLevel++),{lineEnd:r,writeComments:s}=e;e.indentLevel++;const a=i+e.indent,n=a+e.indent;e.write("switch ("),this[t.discriminant.type](t.discriminant,e),e.write(") {"+r);const{cases:o}=t,{length:u}=o;for(let c=0;c<u;c++){const h=o[c];s&&h.comments!=null&&at(e,h.comments,a,r),h.test?(e.write(a+"case "),this[h.test.type](h.test,e),e.write(":"+r)):e.write(a+"default:"+r);const{consequent:d}=h,{length:l}=d;for(let m=0;m<l;m++){const x=d[m];s&&x.comments!=null&&at(e,x.comments,n,r),e.write(n),this[x.type](x,e),e.write(r)}}e.indentLevel-=2,e.write(i+"}")},ReturnStatement(t,e){e.write("return"),t.argument&&(e.write(" "),this[t.argument.type](t.argument,e)),e.write(";")},ThrowStatement(t,e){e.write("throw "),this[t.argument.type](t.argument,e),e.write(";")},TryStatement(t,e){if(e.write("try "),this[t.block.type](t.block,e),t.handler){const{handler:i}=t;i.param==null?e.write(" catch "):(e.write(" catch ("),this[i.param.type](i.param,e),e.write(") ")),this[i.body.type](i.body,e)}t.finalizer&&(e.write(" finally "),this[t.finalizer.type](t.finalizer,e))},WhileStatement(t,e){e.write("while ("),this[t.test.type](t.test,e),e.write(") "),this[t.body.type](t.body,e)},DoWhileStatement(t,e){e.write("do "),this[t.body.type](t.body,e),e.write(" while ("),this[t.test.type](t.test,e),e.write(");")},ForStatement(t,e){if(e.write("for ("),t.init!=null){const{init:i}=t;i.type[0]==="V"?Ke(e,i):this[i.type](i,e)}e.write("; "),t.test&&this[t.test.type](t.test,e),e.write("; "),t.update&&this[t.update.type](t.update,e),e.write(") "),this[t.body.type](t.body,e)},ForInStatement:Oi=function(t,e){e.write(`for ${t.await?"await ":""}(`);const{left:i}=t;i.type[0]==="V"?Ke(e,i):this[i.type](i,e),e.write(t.type[3]==="I"?" in ":" of "),this[t.right.type](t.right,e),e.write(") "),this[t.body.type](t.body,e)},ForOfStatement:Oi,DebuggerStatement(t,e){e.write("debugger;",t)},FunctionDeclaration:Fi=function(t,e){e.write((t.async?"async ":"")+(t.generator?"function* ":"function ")+(t.id?t.id.name:""),t),ee(e,t.params),e.write(" "),this[t.body.type](t.body,e)},FunctionExpression:Fi,VariableDeclaration(t,e){Ke(e,t),e.write(";")},VariableDeclarator(t,e){this[t.id.type](t.id,e),t.init!=null&&(e.write(" = "),this[t.init.type](t.init,e))},ClassDeclaration(t,e){if(e.write("class "+(t.id?`${t.id.name} `:""),t),t.superClass){e.write("extends ");const{superClass:i}=t,{type:r}=i,s=e.expressionsPrecedence[r];(r[0]!=="C"||r[1]!=="l"||r[5]!=="E")&&(s===It||s<e.expressionsPrecedence.ClassExpression)?(e.write("("),this[t.superClass.type](i,e),e.write(")")):this[i.type](i,e),e.write(" ")}this.ClassBody(t.body,e)},ImportDeclaration(t,e){e.write("import ");const{specifiers:i,attributes:r}=t,{length:s}=i;let a=0;if(s>0){for(;a<s;){a>0&&e.write(", ");const n=i[a],o=n.type[6];if(o==="D")e.write(n.local.name,n),a++;else if(o==="N")e.write("* as "+n.local.name,n),a++;else break}if(a<s){for(e.write("{");;){const n=i[a],{name:o}=n.imported;if(e.write(o,n),o!==n.local.name&&e.write(" as "+n.local.name),++a<s)e.write(", ");else break}e.write("}")}e.write(" from ")}if(this.Literal(t.source,e),r&&r.length>0){e.write(" with { ");for(let n=0;n<r.length;n++)this.ImportAttribute(r[n],e),n<r.length-1&&e.write(", ");e.write(" }")}e.write(";")},ImportAttribute(t,e){this.Identifier(t.key,e),e.write(": "),this.Literal(t.value,e)},ImportExpression(t,e){e.write("import("),this[t.source.type](t.source,e),e.write(")")},ExportDefaultDeclaration(t,e){e.write("export default "),this[t.declaration.type](t.declaration,e),e.expressionsPrecedence[t.declaration.type]!=null&&t.declaration.type[0]!=="F"&&e.write(";")},ExportNamedDeclaration(t,e){if(e.write("export "),t.declaration)this[t.declaration.type](t.declaration,e);else{e.write("{");const{specifiers:i}=t,{length:r}=i;if(r>0)for(let s=0;;){const a=i[s],{name:n}=a.local;if(e.write(n,a),n!==a.exported.name&&e.write(" as "+a.exported.name),++s<r)e.write(", ");else break}if(e.write("}"),t.source&&(e.write(" from "),this.Literal(t.source,e)),t.attributes&&t.attributes.length>0){e.write(" with { ");for(let s=0;s<t.attributes.length;s++)this.ImportAttribute(t.attributes[s],e),s<t.attributes.length-1&&e.write(", ");e.write(" }")}e.write(";")}},ExportAllDeclaration(t,e){if(t.exported!=null?e.write("export * as "+t.exported.name+" from "):e.write("export * from "),this.Literal(t.source,e),t.attributes&&t.attributes.length>0){e.write(" with { ");for(let i=0;i<t.attributes.length;i++)this.ImportAttribute(t.attributes[i],e),i<t.attributes.length-1&&e.write(", ");e.write(" }")}e.write(";")},MethodDefinition(t,e){t.static&&e.write("static ");const i=t.kind[0];(i==="g"||i==="s")&&e.write(t.kind+" "),t.value.async&&e.write("async "),t.value.generator&&e.write("*"),t.computed?(e.write("["),this[t.key.type](t.key,e),e.write("]")):this[t.key.type](t.key,e),ee(e,t.value.params),e.write(" "),this[t.value.body.type](t.value.body,e)},ClassExpression(t,e){this.ClassDeclaration(t,e)},ArrowFunctionExpression(t,e){e.write(t.async?"async ":"",t);const{params:i}=t;i!=null&&(i.length===1&&i[0].type[0]==="I"?e.write(i[0].name,i[0]):ee(e,t.params)),e.write(" => "),t.body.type[0]==="O"?(e.write("("),this.ObjectExpression(t.body,e),e.write(")")):this[t.body.type](t.body,e)},ThisExpression(t,e){e.write("this",t)},Super(t,e){e.write("super",t)},RestElement:Ri=function(t,e){e.write("..."),this[t.argument.type](t.argument,e)},SpreadElement:Ri,YieldExpression(t,e){e.write(t.delegate?"yield*":"yield"),t.argument&&(e.write(" "),this[t.argument.type](t.argument,e))},AwaitExpression(t,e){e.write("await ",t),Ae(e,t.argument,t)},TemplateLiteral(t,e){const{quasis:i,expressions:r}=t;e.write("`");const{length:s}=r;for(let n=0;n<s;n++){const o=r[n],u=i[n];e.write(u.value.raw,u),e.write("${"),this[o.type](o,e),e.write("}")}const a=i[i.length-1];e.write(a.value.raw,a),e.write("`")},TemplateElement(t,e){e.write(t.value.raw,t)},TaggedTemplateExpression(t,e){Ae(e,t.tag,t),this[t.quasi.type](t.quasi,e)},ArrayExpression:Vi=function(t,e){if(e.write("["),t.elements.length>0){const{elements:i}=t,{length:r}=i;for(let s=0;;){const a=i[s];if(a!=null&&this[a.type](a,e),++s<r)e.write(", ");else{a==null&&e.write(", ");break}}}e.write("]")},ArrayPattern:Vi,ObjectExpression(t,e){const i=e.indent.repeat(e.indentLevel++),{lineEnd:r,writeComments:s}=e,a=i+e.indent;if(e.write("{"),t.properties.length>0){e.write(r),s&&t.comments!=null&&at(e,t.comments,a,r);const n=","+r,{properties:o}=t,{length:u}=o;for(let c=0;;){const h=o[c];if(s&&h.comments!=null&&at(e,h.comments,a,r),e.write(a),this[h.type](h,e),++c<u)e.write(n);else break}e.write(r),s&&t.trailingComments!=null&&at(e,t.trailingComments,a,r),e.write(i+"}")}else s?t.comments!=null?(e.write(r),at(e,t.comments,a,r),t.trailingComments!=null&&at(e,t.trailingComments,a,r),e.write(i+"}")):t.trailingComments!=null?(e.write(r),at(e,t.trailingComments,a,r),e.write(i+"}")):e.write("}"):e.write("}");e.indentLevel--},Property(t,e){t.method||t.kind[0]!=="i"?this.MethodDefinition(t,e):(t.shorthand||(t.computed?(e.write("["),this[t.key.type](t.key,e),e.write("]")):this[t.key.type](t.key,e),e.write(": ")),this[t.value.type](t.value,e))},PropertyDefinition(t,e){if(t.static&&e.write("static "),t.computed&&e.write("["),this[t.key.type](t.key,e),t.computed&&e.write("]"),t.value==null){t.key.type[0]!=="F"&&e.write(";");return}e.write(" = "),this[t.value.type](t.value,e),e.write(";")},ObjectPattern(t,e){if(e.write("{"),t.properties.length>0){const{properties:i}=t,{length:r}=i;for(let s=0;this[i[s].type](i[s],e),++s<r;)e.write(", ")}e.write("}")},SequenceExpression(t,e){ee(e,t.expressions)},UnaryExpression(t,e){if(t.prefix){const{operator:i,argument:r,argument:{type:s}}=t;e.write(i);const a=Ur(e,r,t);!a&&(i.length>1||s[0]==="U"&&(s[1]==="n"||s[1]==="p")&&r.prefix&&r.operator[0]===i&&(i==="+"||i==="-"))&&e.write(" "),a?(e.write(i.length>1?" (":"("),this[s](r,e),e.write(")")):this[s](r,e)}else this[t.argument.type](t.argument,e),e.write(t.operator)},UpdateExpression(t,e){t.prefix?(e.write(t.operator),this[t.argument.type](t.argument,e)):(this[t.argument.type](t.argument,e),e.write(t.operator))},AssignmentExpression(t,e){this[t.left.type](t.left,e),e.write(" "+t.operator+" "),this[t.right.type](t.right,e)},AssignmentPattern(t,e){this[t.left.type](t.left,e),e.write(" = "),this[t.right.type](t.right,e)},BinaryExpression:Bi=function(t,e){const i=t.operator==="in";i&&e.write("("),Ae(e,t.left,t,!1),e.write(" "+t.operator+" "),Ae(e,t.right,t,!0),i&&e.write(")")},LogicalExpression:Bi,ConditionalExpression(t,e){const{test:i}=t,r=e.expressionsPrecedence[i.type];r===It||r<=e.expressionsPrecedence.ConditionalExpression?(e.write("("),this[i.type](i,e),e.write(")")):this[i.type](i,e),e.write(" ? "),this[t.consequent.type](t.consequent,e),e.write(" : "),this[t.alternate.type](t.alternate,e)},NewExpression(t,e){e.write("new ");const i=e.expressionsPrecedence[t.callee.type];i===It||i<e.expressionsPrecedence.CallExpression||xn(t.callee)?(e.write("("),this[t.callee.type](t.callee,e),e.write(")")):this[t.callee.type](t.callee,e),ee(e,t.arguments)},CallExpression(t,e){const i=e.expressionsPrecedence[t.callee.type];i===It||i<e.expressionsPrecedence.CallExpression?(e.write("("),this[t.callee.type](t.callee,e),e.write(")")):this[t.callee.type](t.callee,e),t.optional&&e.write("?."),ee(e,t.arguments)},ChainExpression(t,e){this[t.expression.type](t.expression,e)},MemberExpression(t,e){const i=e.expressionsPrecedence[t.object.type];i===It||i<e.expressionsPrecedence.MemberExpression?(e.write("("),this[t.object.type](t.object,e),e.write(")")):this[t.object.type](t.object,e),t.computed?(t.optional&&e.write("?."),e.write("["),this[t.property.type](t.property,e),e.write("]")):(t.optional?e.write("?."):e.write("."),this[t.property.type](t.property,e))},MetaProperty(t,e){e.write(t.meta.name+"."+t.property.name,t)},Identifier(t,e){e.write(t.name,t)},PrivateIdentifier(t,e){e.write(`#${t.name}`,t)},Literal(t,e){t.raw!=null?e.write(t.raw,t):t.regex!=null?this.RegExpLiteral(t,e):t.bigint!=null?e.write(t.bigint+"n",t):e.write(fn(t.value),t)},RegExpLiteral(t,e){const{regex:i}=t;e.write(`/${i.pattern}/${i.flags}`,t)}},yn={},wn=xi;class vn{constructor(e){const i=e??yn;this.output="",i.output!=null?(this.output=i.output,this.write=this.writeToStream):this.output="",this.generator=i.generator!=null?i.generator:xi,this.expressionsPrecedence=i.expressionsPrecedence!=null?i.expressionsPrecedence:mn,this.indent=i.indent!=null?i.indent:" ",this.lineEnd=i.lineEnd!=null?i.lineEnd:`
|
|
47
|
+
`,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(`
|
|
48
|
+
`).length-1,this.mapping={original:null,generated:this,name:void 0,source:i.sourceMap.file||i.sourceMap._file})}write(e){this.output+=e}writeToStream(e){this.output.write(e)}writeAndMap(e,i){this.output+=e,this.map(e,i)}writeToStreamAndMap(e,i){this.output.write(e),this.map(e,i)}map(e,i){if(i!=null){const{type:a}=i;if(a[0]==="L"&&a[2]==="n"){this.column=0,this.line++;return}if(i.loc!=null){const{mapping:n}=this;n.original=i.loc.start,n.name=i.name,this.sourceMap.addMapping(n)}if(a[0]==="T"&&a[8]==="E"||a[0]==="L"&&a[1]==="i"&&typeof i.value=="string"){const{length:n}=e;let{column:o,line:u}=this;for(let c=0;c<n;c++)e[c]===`
|
|
49
|
+
`?(o=0,u++):o++;this.column=o,this.line=u;return}}const{length:r}=e,{lineEnd:s}=this;r>0&&(this.lineEndSize>0&&(s.length===1?e[r-1]===s:e.endsWith(s))?(this.line+=this.lineEndSize,this.column=0):this.column+=r)}toString(){return this.output}}function Gr(t,e){const i=new vn(e);return i.generator[t.type](t,i),i.output}var bn=Object.defineProperty,_n=(t,e,i)=>e in t?bn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,J=(t,e,i)=>_n(t,typeof e!="symbol"?e+"":e,i);const En=new Set(["Infinity","NaN","undefined","null","true","false"]),Sn=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 Cn{constructor(){J(this,"scopes",[]),J(this,"scopeTypes",[]),J(this,"scopeCounts",new Map),J(this,"contextBoundVars",new Set),J(this,"arrayPatternElements",new Set),J(this,"rootParams",new Set),J(this,"localSeriesVars",new Set),J(this,"varKinds",new Map),J(this,"loopVars",new Set),J(this,"loopVarNames",new Map),J(this,"paramIdCounter",0),J(this,"cacheIdCounter",0),J(this,"tempVarCounter",0),J(this,"taCallIdCounter",0),J(this,"userCallIdCounter",0),J(this,"hoistingStack",[]),J(this,"suppressHoisting",!1),J(this,"reservedNames",new Set),J(this,"userFunctions",new Set),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++}`}}getNextUserCallId(){return{type:"Literal",value:`_fn${this.userCallIdCounter++}`}}pushScope(e){this.scopes.push(new Map),this.scopeTypes.push(e),this.scopeCounts.set(e,(this.scopeCounts.get(e)||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(e){this.localSeriesVars.add(e)}removeLocalSeriesVar(e){this.localSeriesVars.delete(e)}isLocalSeriesVar(e){return this.localSeriesVars.has(e)}addContextBoundVar(e,i=!1){this.contextBoundVars.add(e),i&&this.rootParams.add(e)}removeContextBoundVar(e){this.contextBoundVars.has(e)&&(this.contextBoundVars.delete(e),this.rootParams.has(e)&&this.rootParams.delete(e))}addArrayPatternElement(e){this.arrayPatternElements.add(e)}isContextBound(e){return En.has(e)||Sn.has(e)?!1:this.contextBoundVars.has(e)}isArrayPatternElement(e){return this.arrayPatternElements.has(e)}isRootParam(e){return this.rootParams.has(e)}addLoopVariable(e,i){this.loopVars.add(e),this.loopVarNames.set(e,i)}getLoopVariableName(e){return this.loopVarNames.get(e)}isLoopVariable(e){return this.loopVars.has(e)}addReservedName(e){this.reservedNames.add(e)}addUserFunction(e){this.userFunctions.add(e)}isUserFunction(e){return this.userFunctions.has(e)}addVariable(e,i){if(this.isContextBound(e))return e;const r=this.scopes[this.scopes.length-1],s=this.scopeTypes[this.scopeTypes.length-1],a=this.scopeCounts.get(s)||1,n=`${s}${a}_${e}`;return r.set(e,n),this.varKinds.set(n,i),n}getVariable(e){if(this.loopVars.has(e)){const i=this.loopVarNames.get(e);if(i)return[i,"let"]}if(this.isContextBound(e))return[e,"let"];for(let i=this.scopes.length-1;i>=0;i--){const r=this.scopes[i];if(r.has(e)){const s=r.get(e),a=this.varKinds.get(s)||"let";return[s,a]}}return[e,"let"]}generateTempVar(){return`temp_${++this.tempVarCounter}`}enterHoistingScope(){this.hoistingStack.push([])}exitHoistingScope(){return this.hoistingStack.pop()||[]}addHoistedStatement(e){this.hoistingStack.length>0&&!this.suppressHoisting&&this.hoistingStack[this.hoistingStack.length-1].push(e)}setSuppressHoisting(e){this.suppressHoisting=e}shouldSuppressHoisting(){return this.suppressHoisting}hasVariableInScope(e){if(this.reservedNames.has(e))return!0;for(let i=this.scopes.length-1;i>=0;i--)if(this.scopes[i].has(e))return!0;return!!(this.contextBoundVars.has(e)||this.loopVars.has(e)||this.localSeriesVars.has(e))}generateParamId(){let e=`p${this.paramIdCounter++}`;for(;this.hasVariableInScope(e);)e=`p${this.paramIdCounter++}`;const i=this.scopes[this.scopes.length-1];return i&&i.set(e,e),e}}function Kr(t,e,i,r,s){i||(i=I),(function a(n,o,u){var c=u||n.type;i[c](n,o,a),e[c]&&e[c](n,o)})(t,r,s)}function Nn(t,e,i,r,s){var a=[];i||(i=I),(function n(o,u,c){var h=c||o.type,d=o!==a[a.length-1];d&&a.push(o),i[h](o,u,n),e[h]&&e[h](o,u||a,a),d&&a.pop()})(t,r,s)}function rt(t,e,i,r,s){var a=i?An(i):r;(function n(o,u,c){a[c||o.type](o,u,n)})(t,e,s)}function An(t,e){var i=Object.create(I);for(var r in t)i[r]=t[r];return i}function yi(t,e,i){i(t,e)}function Zt(t,e,i){}var I={};I.Program=I.BlockStatement=I.StaticBlock=function(t,e,i){for(var r=0,s=t.body;r<s.length;r+=1){var a=s[r];i(a,e,"Statement")}};I.Statement=yi;I.EmptyStatement=Zt;I.ExpressionStatement=I.ParenthesizedExpression=I.ChainExpression=function(t,e,i){return i(t.expression,e,"Expression")};I.IfStatement=function(t,e,i){i(t.test,e,"Expression"),i(t.consequent,e,"Statement"),t.alternate&&i(t.alternate,e,"Statement")};I.LabeledStatement=function(t,e,i){return i(t.body,e,"Statement")};I.BreakStatement=I.ContinueStatement=Zt;I.WithStatement=function(t,e,i){i(t.object,e,"Expression"),i(t.body,e,"Statement")};I.SwitchStatement=function(t,e,i){i(t.discriminant,e,"Expression");for(var r=0,s=t.cases;r<s.length;r+=1){var a=s[r];i(a,e)}};I.SwitchCase=function(t,e,i){t.test&&i(t.test,e,"Expression");for(var r=0,s=t.consequent;r<s.length;r+=1){var a=s[r];i(a,e,"Statement")}};I.ReturnStatement=I.YieldExpression=I.AwaitExpression=function(t,e,i){t.argument&&i(t.argument,e,"Expression")};I.ThrowStatement=I.SpreadElement=function(t,e,i){return i(t.argument,e,"Expression")};I.TryStatement=function(t,e,i){i(t.block,e,"Statement"),t.handler&&i(t.handler,e),t.finalizer&&i(t.finalizer,e,"Statement")};I.CatchClause=function(t,e,i){t.param&&i(t.param,e,"Pattern"),i(t.body,e,"Statement")};I.WhileStatement=I.DoWhileStatement=function(t,e,i){i(t.test,e,"Expression"),i(t.body,e,"Statement")};I.ForStatement=function(t,e,i){t.init&&i(t.init,e,"ForInit"),t.test&&i(t.test,e,"Expression"),t.update&&i(t.update,e,"Expression"),i(t.body,e,"Statement")};I.ForInStatement=I.ForOfStatement=function(t,e,i){i(t.left,e,"ForInit"),i(t.right,e,"Expression"),i(t.body,e,"Statement")};I.ForInit=function(t,e,i){t.type==="VariableDeclaration"?i(t,e):i(t,e,"Expression")};I.DebuggerStatement=Zt;I.FunctionDeclaration=function(t,e,i){return i(t,e,"Function")};I.VariableDeclaration=function(t,e,i){for(var r=0,s=t.declarations;r<s.length;r+=1){var a=s[r];i(a,e)}};I.VariableDeclarator=function(t,e,i){i(t.id,e,"Pattern"),t.init&&i(t.init,e,"Expression")};I.Function=function(t,e,i){t.id&&i(t.id,e,"Pattern");for(var r=0,s=t.params;r<s.length;r+=1){var a=s[r];i(a,e,"Pattern")}i(t.body,e,t.expression?"Expression":"Statement")};I.Pattern=function(t,e,i){t.type==="Identifier"?i(t,e,"VariablePattern"):t.type==="MemberExpression"?i(t,e,"MemberPattern"):i(t,e)};I.VariablePattern=Zt;I.MemberPattern=yi;I.RestElement=function(t,e,i){return i(t.argument,e,"Pattern")};I.ArrayPattern=function(t,e,i){for(var r=0,s=t.elements;r<s.length;r+=1){var a=s[r];a&&i(a,e,"Pattern")}};I.ObjectPattern=function(t,e,i){for(var r=0,s=t.properties;r<s.length;r+=1){var a=s[r];a.type==="Property"?(a.computed&&i(a.key,e,"Expression"),i(a.value,e,"Pattern")):a.type==="RestElement"&&i(a.argument,e,"Pattern")}};I.Expression=yi;I.ThisExpression=I.Super=I.MetaProperty=Zt;I.ArrayExpression=function(t,e,i){for(var r=0,s=t.elements;r<s.length;r+=1){var a=s[r];a&&i(a,e,"Expression")}};I.ObjectExpression=function(t,e,i){for(var r=0,s=t.properties;r<s.length;r+=1){var a=s[r];i(a,e)}};I.FunctionExpression=I.ArrowFunctionExpression=I.FunctionDeclaration;I.SequenceExpression=function(t,e,i){for(var r=0,s=t.expressions;r<s.length;r+=1){var a=s[r];i(a,e,"Expression")}};I.TemplateLiteral=function(t,e,i){for(var r=0,s=t.quasis;r<s.length;r+=1){var a=s[r];i(a,e)}for(var n=0,o=t.expressions;n<o.length;n+=1){var u=o[n];i(u,e,"Expression")}};I.TemplateElement=Zt;I.UnaryExpression=I.UpdateExpression=function(t,e,i){i(t.argument,e,"Expression")};I.BinaryExpression=I.LogicalExpression=function(t,e,i){i(t.left,e,"Expression"),i(t.right,e,"Expression")};I.AssignmentExpression=I.AssignmentPattern=function(t,e,i){i(t.left,e,"Pattern"),i(t.right,e,"Expression")};I.ConditionalExpression=function(t,e,i){i(t.test,e,"Expression"),i(t.consequent,e,"Expression"),i(t.alternate,e,"Expression")};I.NewExpression=I.CallExpression=function(t,e,i){if(i(t.callee,e,"Expression"),t.arguments)for(var r=0,s=t.arguments;r<s.length;r+=1){var a=s[r];i(a,e,"Expression")}};I.MemberExpression=function(t,e,i){i(t.object,e,"Expression"),t.computed&&i(t.property,e,"Expression")};I.ExportNamedDeclaration=I.ExportDefaultDeclaration=function(t,e,i){t.declaration&&i(t.declaration,e,t.type==="ExportNamedDeclaration"||t.declaration.id?"Statement":"Expression"),t.source&&i(t.source,e,"Expression")};I.ExportAllDeclaration=function(t,e,i){t.exported&&i(t.exported,e),i(t.source,e,"Expression")};I.ImportDeclaration=function(t,e,i){for(var r=0,s=t.specifiers;r<s.length;r+=1){var a=s[r];i(a,e)}i(t.source,e,"Expression")};I.ImportExpression=function(t,e,i){i(t.source,e,"Expression")};I.ImportSpecifier=I.ImportDefaultSpecifier=I.ImportNamespaceSpecifier=I.Identifier=I.PrivateIdentifier=I.Literal=Zt;I.TaggedTemplateExpression=function(t,e,i){i(t.tag,e,"Expression"),i(t.quasi,e,"Expression")};I.ClassDeclaration=I.ClassExpression=function(t,e,i){return i(t,e,"Class")};I.Class=function(t,e,i){t.id&&i(t.id,e,"Pattern"),t.superClass&&i(t.superClass,e,"Expression"),i(t.body,e)};I.ClassBody=function(t,e,i){for(var r=0,s=t.body;r<s.length;r+=1){var a=s[r];i(a,e)}};I.MethodDefinition=I.PropertyDefinition=I.Property=function(t,e,i){t.computed&&i(t.key,e,"Expression"),t.value&&i(t.value,e,"Expression")};const Y="$",N={createIdentifier(t){return{type:"Identifier",name:t}},createLiteral(t){return{type:"Literal",value:t}},createMemberExpression(t,e,i=!1){return{type:"MemberExpression",object:t,property:e,computed:i}},createContextIdentifier(){return this.createIdentifier("$")},createLocalContextIdentifier(){return this.createIdentifier("$$")},createContextVariableReference(t,e){const i=this.createContextIdentifier(),r=this.createIdentifier(t),s=this.createIdentifier(e);return this.createMemberExpression(this.createMemberExpression(i,r,!1),s,!1)},createLocalContextVariableReference(t,e){const i=this.createLocalContextIdentifier(),r=this.createIdentifier(t),s=this.createIdentifier(e);return this.createMemberExpression(this.createMemberExpression(i,r,!1),s,!1)},createDynamicContextVariableReference(t,e){const i=this.createContextIdentifier(),r=this.createIdentifier(t);return this.createMemberExpression(this.createMemberExpression(i,r,!1),e,!0)},createContextVariableAccess0(t,e){const i=this.createContextVariableReference(t,e);return this.createGetCall(i,0)},createDynamicContextVariableAccess0(t,e){const i=this.createDynamicContextVariableReference(t,e);return this.createGetCall(i,0)},createArrayAccess(t,e){const i=typeof e=="number"?this.createLiteral(e):e;return this.createMemberExpression(t,i,!0)},createCallExpression(t,e){return{type:"CallExpression",callee:t,arguments:e}},createAssignmentExpression(t,e,i="="){return{type:"AssignmentExpression",operator:i,left:t,right:e}},createExpressionStatement(t){return{type:"ExpressionStatement",expression:t}},createInitCall(t,e,i){const r=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("init"),!1),s=[t,e];return i&&s.push(i),this.createCallExpression(r,s)},createInitVarCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("initVar"),!1),r=[t,e];return this.createCallExpression(i,r)},createGetCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("get"),!1),r=typeof e=="number"?this.createLiteral(e):e;return this.createCallExpression(i,[t,r])},createSetCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("set"),!1);return this.createCallExpression(i,[t,e])},createMathEqCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("pine"),!1),r=this.createMemberExpression(i,this.createIdentifier("math"),!1),s=this.createMemberExpression(r,this.createIdentifier("__eq"),!1);return this.createCallExpression(s,[t,e])},createWrapperFunction(t){return{type:"FunctionDeclaration",id:null,params:[this.createIdentifier("context")],body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:t}]}}},createVariableDeclaration(t,e){return{type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:this.createIdentifier(t),init:e}]}},createAwaitExpression(t){return{type:"AwaitExpression",argument:t}}},we=["ta","math","request","array","input"],In=["hline","plot","fill"],kn=["request.security","request.security_lower_tf"],zr=["open","high","low","close","volume","hl2","hlc3","ohlc4","openTime","closeTime"],Yr=[...we,"plotchar","plotshape","plotarrow","plotbar","plotcandle","plot","bgcolor","barcolor","hline","fill","indicator","strategy","library","alertcondition","fixnan","na","color","nz","str","box","line","label","table","map","matrix","log","map","Type","bool","timeframe","syminfo","barstate","bar_index","last_bar_index","last_bar_time","inputs","order","currency","display","shape","location","size","format","dayofweek"],Dn=["na","nz","plot","plotchar","color","hline","fill"];function Tn(t){let e=null,i=Y;if(t.type==="Program"&&t.body.length>0){const m=t.body[0];if(m.type==="ExpressionStatement"&&(m.expression.type==="ArrowFunctionExpression"||m.expression.type==="FunctionExpression")){const x=m.expression;x.body.type==="BlockStatement"&&(e=x.body.body,x.params.length>0&&x.params[0].type==="Identifier"&&(i=x.params[0].name))}}if(!e)return;const r=new Set,s=new Set,a=m=>{m.type==="Identifier"?r.add(m.name):m.type==="ObjectPattern"?m.properties.forEach(x=>a(x.value)):m.type==="ArrayPattern"&&m.elements.forEach(x=>{x&&a(x)})};rt(t,{},{VariableDeclarator(m,x,E){a(m.id),m.init&&E(m.init,x)},FunctionDeclaration(m,x,E){a(m.id),E(m.body,x)},Identifier(m,x,E){s.add(m.name)},MemberExpression(m,x,E){E(m.object,x),m.computed&&E(m.property,x)},Property(m,x,E){m.computed&&E(m.key,x),E(m.value,x)}}),e.forEach(m=>{m.type==="VariableDeclaration"?m.declarations.forEach(x=>a(x.id)):m.type==="FunctionDeclaration"&&a(m.id)});const n=zr,o=Yr,u=n.filter(m=>!r.has(m)),c=o.filter(m=>!r.has(m)),h=u.filter(m=>s.has(m)),d=c.filter(m=>s.has(m)),l=[];h.length>0&&l.push({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"ObjectPattern",properties:h.map(m=>({type:"Property",key:{type:"Identifier",name:m},value:{type:"Identifier",name:m},kind:"init",shorthand:!0}))},init:{type:"MemberExpression",object:{type:"Identifier",name:i},property:{type:"Identifier",name:"data"},computed:!1}}]}),d.length>0&&l.push({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"ObjectPattern",properties:d.map(m=>({type:"Property",key:{type:"Identifier",name:m},value:{type:"Identifier",name:m},kind:"init",shorthand:!0}))},init:{type:"MemberExpression",object:{type:"Identifier",name:i},property:{type:"Identifier",name:"pine"},computed:!1}}]}),l.length>0&&e.unshift(...l)}function Pn(t){let e=null,i=Y;if(t.type==="Program"&&t.body.length>0){const o=t.body[0];if(o.type==="ExpressionStatement"&&(o.expression.type==="ArrowFunctionExpression"||o.expression.type==="FunctionExpression")){const u=o.expression;u.body.type==="BlockStatement"&&(e=u.body.body,u.params.length>0&&u.params[0].type==="Identifier"&&(i=u.params[0].name))}}if(!e)return;const r=new Set(zr),s=new Set(Yr),a=new Set(Dn),n=new Map;e.forEach(o=>{o.type==="VariableDeclaration"&&o.declarations.forEach(u=>{if(u.init&&u.init.type==="MemberExpression"&&u.init.object.type==="Identifier"&&u.init.object.name===i&&u.init.property.type==="Identifier"){const c=u.init.property.name;let h=null;if(c==="data"?h=r:c==="pine"?h=s:c==="core"&&(h=a),h&&u.id.type==="ObjectPattern")u.id.properties.forEach(d=>{if(d.type==="Property"&&d.key.type==="Identifier"&&d.value.type==="Identifier"){const l=d.key.name,m=d.value.name;h.has(l)&&l!==m&&(n.set(m,l),d.value.name=l,d.shorthand=!0)}});else if(u.id.type==="Identifier"&&we.includes(c)){const d=c,l=u.id.name;d!==l&&(n.set(l,d),u.id.name=d)}}})}),n.size>0&&rt(t,{},{Identifier(o){n.has(o.name)&&(o.name=n.get(o.name))},MemberExpression(o,u,c){c(o.object,u),o.computed&&c(o.property,u)},Property(o,u,c){o.computed&&c(o.key,u),c(o.value,u)}})}function On(t){try{const e=Hr(t,{ecmaVersion:"latest",sourceType:"module"});if(e.type==="Program"&&e.body.length===1){const i=e.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 Fn(t){return t.async=!0,Gr(t)}function Rn(t){t=t.trim();const{isWrapped:e,isAsync:i,functionNode:r}=On(t);return e&&r?i?t:Fn(r):`async (context) => {
|
|
50
|
+
${t}
|
|
51
|
+
}`}function Bn(t){rt(t,null,{VariableDeclaration(e,i,r){e.declarations&&e.declarations.length>0&&e.declarations.forEach(s=>{if(s.init&&s.init.type==="ArrowFunctionExpression"&&s.init.start!==0){const a={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(e,a)}}),e.body&&e.body.body&&e.body.body.forEach(s=>r(s,i))}})}function Vn(t,e){Kr(t,{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===Y||r.init.object.name==="context2"),a=r.init&&r.init.type==="MemberExpression"&&r.init.object?.object&&(r.init.object.object.name==="context"||r.init.object.object.name===Y||r.init.object.object.name==="context2");(s||a)&&(r.id.name&&e.addContextBoundVar(r.id.name),r.id.properties&&r.id.properties.forEach(n=>{n.key.name&&e.addContextBoundVar(n.key.name)}))})}})}function Ln(t,e,i=!1){t.params.forEach(r=>{r.type==="Identifier"&&i&&e.addContextBoundVar(r.name,i)})}function Mn(t,e){let i;return Nn(t,{FunctionDeclaration(r){r.id&&r.id.name&&(e.addReservedName(r.id.name),e.addUserFunction(r.id.name))},ArrowFunctionExpression(r){const s=r.start===0;s&&r.params&&r.params.length>0&&(i=r.params[0].name,r.params[0].name=Y),Ln(r,e,s)},VariableDeclaration(r,s){const a=s.length>1?s[s.length-2]:null,n=a&&(a.type==="ForOfStatement"||a.type==="ForInStatement")&&a.left===r;r.declarations.forEach(o=>{if(o.id.type==="Identifier")e.addReservedName(o.id.name);else if(o.id.type==="ObjectPattern")o.id.properties.forEach(u=>{u.key&&u.key.type==="Identifier"&&e.addReservedName(u.key.name)});else if(o.id.type==="ArrayPattern"){if(o.id.elements?.forEach(d=>{d&&d.type==="Identifier"&&e.addReservedName(d.name)}),n)return;const u=e.generateTempVar(),c={type:"VariableDeclaration",kind:r.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:u},init:o.init}]};o.id.elements?.forEach(d=>{d.type==="Identifier"&&e.addArrayPatternElement(d.name)});const h=o.id.elements.map((d,l)=>({type:"VariableDeclaration",kind:r.kind,declarations:[{type:"VariableDeclarator",id:d,init:{type:"MemberExpression",object:{type:"Identifier",name:u},property:{type:"Literal",value:l},computed:!0}}]}));Object.assign(r,{type:"BlockStatement",body:[c,...h]})}})},ForStatement(r){}}),i}const ri={type:"Identifier",name:"undefined"};function nt(t,e){const[i,r]=e.getVariable(t);if(i.match(/^fn\d+_/)&&t!=="$$"){const[s]=e.getVariable("$$");if(s)return N.createLocalContextVariableReference(r,i)}return N.createContextVariableReference(r,i)}function Qr(t,e){const i=nt(t,e);return N.createGetCall(i,0)}function qt(t,e){if(t.computed&&t.property.type==="Identifier"){if(e.isLoopVariable(t.property.name)){if(t.object.type==="Identifier"&&!e.isLoopVariable(t.object.name)){if(e.isLocalSeriesVar(t.object.name)){const i=N.createIdentifier(t.object.name);i._skipTransformation=!0;const r=N.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0;return}if(!e.isContextBound(t.object.name)){const i=nt(t.object.name,e),r=N.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0}}return}e.isContextBound(t.property.name)||(t.property=nt(t.property.name,e),t.property=N.createGetCall(t.property,0))}if(t.computed&&t.object.type==="Identifier"){if(e.isLoopVariable(t.object.name))return;if(e.isLocalSeriesVar(t.object.name)){const i=N.createIdentifier(t.object.name);i._skipTransformation=!0;const r=N.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0;return}if(e.isContextBound(t.object.name)||(t.object=nt(t.object.name,e)),t.property.type==="MemberExpression"){const i=t.property;i._indexTransformed||(qt(i,e),i._indexTransformed=!0)}}}function Ot(t,e){const i=N.createGetCall(N.createIdentifier(t.name),0);t.start!==void 0&&(i.start=t.start),t.end!==void 0&&(i.end=t.end),i._indexTransformed=!0,Object.assign(t,i)}function ut(t,e){if(!t._skipTransformation&&t.name!==Y){if(t.name==="na"&&!(t.parent&&t.parent.type==="CallExpression"&&t.parent.callee===t)){t.name="NaN";return}if(t.name==="Math"||t.name==="NaN"||t.name==="undefined"||t.name==="Infinity"||t.name==="null"||t.name.startsWith("'")&&t.name.endsWith("'")||t.name.startsWith('"')&&t.name.endsWith('"')||t.name.startsWith("`")&&t.name.endsWith("`")||e.isLoopVariable(t.name))return;let i=!1;if(t.parent&&t.parent.type==="CallExpression"&&t.parent.arguments.includes(t)){const l=t.parent.callee;if(l.type==="MemberExpression"&&l.object&&l.object.name===Y&&["get","set","init","param","call"].includes(l.property.name)){const m=t.parent.arguments.indexOf(t);l.property.name==="call"?m>=2&&(i=!0):m===0&&(i=!0)}else{const m=l.type==="MemberExpression"&&l.object&&l.object.type==="Identifier"&&we.includes(l.object.name);l.type==="MemberExpression"&&!m?i=!1:i=!0}}const r=t.parent&&t.parent.type==="MemberExpression"&&t.parent.object===t&&e.isContextBound(t.name),s=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee&&t.parent.callee.type==="MemberExpression"&&t.parent.callee.property.name==="param";t.parent&&t.parent.type==="AssignmentExpression"&&t.parent.left;const a=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee===t,n=t.parent&&t.parent.type==="MemberExpression"&&t.parent.computed&&t.parent.object===t,o=t.parent&&t.parent.type==="MemberExpression"&&t.parent.computed&&t.parent.property===t&&t.parent.parent&&t.parent.parent.type==="CallExpression"&&t.parent.parent.callee&&t.parent.parent.callee.type==="MemberExpression"&&e.isContextBound(t.parent.parent.callee.object.name);if(r||s||i||o||a){if(a||t.parent&&t.parent.type==="CallExpression"&&t.parent.callee&&t.parent.callee.type==="MemberExpression"&&t.parent.callee.object&&t.parent.callee.object.name===Y&&t.parent.callee.property.name==="call"&&t.parent.arguments[0]===t||e.isLocalSeriesVar(t.name)||e.isContextBound(t.name)&&!e.isRootParam(t.name))return;const l=nt(t.name,e);Object.assign(t,l);return}const u=e.isContextBound(t.name)&&!e.isRootParam(t.name);if(u){const l=t.parent&&t.parent.type==="CallExpression"&&t.parent.arguments.includes(t),m=t.parent&&t.parent.type==="SwitchStatement"&&t.parent.discriminant===t,x=t.parent&&t.parent.type==="SwitchCase"&&t.parent.test===t;if(!l&&!m&&!x)return}if(e.isLocalSeriesVar(t.name)){if(!n){const l=N.createIdentifier(t.name),m=N.createGetCall(l,0);Object.assign(t,m)}return}const[c,h]=e.getVariable(t.name);let d;if(u)d=N.createIdentifier(t.name);else{if(c===t.name&&!e.isContextBound(t.name))return;d=nt(t.name,e)}if(n)Object.assign(t,d);else{const l=N.createGetCall(d,0);Object.assign(t,l)}}}function bt(t,e,i){if(t.object&&t.object.type==="Identifier"&&t.object.name==="Math")return;if(t.object&&t.object.type==="Identifier"&&we.includes(t.object.name)&&i.isContextBound(t.object.name)&&!t.computed){const u=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee===t,c=t.parent&&(t.parent.type==="VariableDeclarator"&&(t.parent.id.type==="ArrayPattern"||t.parent.id.type==="ObjectPattern")||t.parent.type==="AssignmentExpression"&&(t.parent.left.type==="ArrayPattern"||t.parent.left.type==="ObjectPattern")||t.parent.type==="Property");if(!u&&!c){const h={type:"CallExpression",callee:{type:"MemberExpression",object:t.object,property:t.property,computed:!1},arguments:[],_transformed:!1};t.start!==void 0&&(h.start=t.start),t.end!==void 0&&(h.end=t.end),Object.assign(t,h);return}}const r=i.getCurrentScopeType()=="if",s=i.getCurrentScopeType()=="els",a=i.getCurrentScopeType()=="for";if(!r&&!s&&!a&&t.object&&t.object.type==="Identifier"&&i.isContextBound(t.object.name)&&!i.isRootParam(t.object.name)&&!t.computed)return;t._indexTransformed||(qt(t,i),t._indexTransformed=!0);const n=t.object&&t.object.type==="MemberExpression"&&t.object.object&&t.object.object.type==="MemberExpression"&&t.object.object.object&&(t.object.object.object.name===Y||t.object.object.object.name==="$$"),o=t.object&&t.object.type==="Identifier"&&i.isContextBound(t.object.name);if(t.computed&&(n||o)){if(t.parent&&t.parent.type==="AssignmentExpression"&&t.parent.left===t)return;const u=N.createGetCall(t.object,t.property);t.start&&(u.start=t.start),t.end&&(u.end=t.end),Object.assign(t,u),delete t.object,delete t.property,delete t.computed}}function de(t,e){if(t.type==="Identifier"){if(t.name==="na")return t.name="NaN",t;if(e.isLoopVariable(t.name))return t;if(e.isRootParam(t.name)){const[a,n]=e.getVariable(t.name);return N.createContextVariableReference(n,a)}if(e.isContextBound(t.name))return t;const[i,r]=e.getVariable(t.name),s=i!==t.name;return e.isLocalSeriesVar(t.name)&&!s?t:s?nt(t.name,e):i===t.name&&!e.isContextBound(t.name)?t:nt(t.name,e)}return t}function $t(t,e,i=""){switch(t.type){case"BinaryExpression":return si(t,e,i);case"LogicalExpression":return ni(t,e,i);case"MemberExpression":return{type:"MemberExpression",object:t.object.type==="Identifier"?de(t.object,e):t.object,property:t.property,computed:t.computed};case"Identifier":{if(e.isLoopVariable(t.name)||t.parent&&t.parent.type==="MemberExpression"&&t.parent.property===t)return t;const r=de(t,e);return r.type==="Identifier"&&(r.name==="NaN"||r.name==="undefined"||r.name==="Infinity"||r.name==="null"||r.name==="Math")?r:N.createGetCall(r,0)}case"UnaryExpression":return ai(t,e,i);case"ConditionalExpression":{const r=$t(t.test,e,i),s=$t(t.consequent,e,i),a=$t(t.alternate,e,i);return{type:"ConditionalExpression",test:r,consequent:s,alternate:a,start:t.start,end:t.end}}}return t}function si(t,e,i){const r=$t(t.left,e,i),s=$t(t.right,e,i),a={type:"BinaryExpression",operator:t.operator,left:r,right:s,start:t.start,end:t.end};return rt(a,e,{CallExpression(n,o){n._transformed||pt(n,o)},MemberExpression(n){bt(n,"",e)}}),a}function ni(t,e,i){const r=$t(t.left,e,i),s=$t(t.right,e,i),a={type:"LogicalExpression",operator:t.operator,left:r,right:s,start:t.start,end:t.end};return rt(a,e,{CallExpression(n,o){n._transformed||pt(n,o)}}),a}function Mi(t,e,i){rt(t,{parent:t,inNamespaceCall:!1},{Identifier(n,o,u){if(n.name=="NaN")return;if(n.name=="na"){n.name="NaN";return}n.parent=o.parent,ut(n,e);const c=n.parent&&n.parent.type==="BinaryExpression";(n.parent&&n.parent.type==="ConditionalExpression"||c)&&(n.type==="MemberExpression"?qt(n,e):n.type==="Identifier"&&(n.parent&&n.parent.type==="CallExpression"&&n.parent.callee&&n.parent.callee.object&&n.parent.callee.object.name===Y&&n.parent.callee.property.name==="get"||Ot(n)))},MemberExpression(n,o,u){qt(n,e),n.object&&u(n.object,{parent:n,inNamespaceCall:o.inNamespaceCall})},ConditionalExpression(n,o,u){const c={...o,parent:n};n.test&&u(n.test,c),n.consequent&&u(n.consequent,c),n.alternate&&u(n.alternate,c)},BinaryExpression(n,o,u){const c={...o,parent:n};u(n.left,c),u(n.right,c)},LogicalExpression(n,o,u){const c={...o,parent:n};u(n.left,c),u(n.right,c)},UnaryExpression(n,o,u){const c={...o,parent:n};u(n.argument,c)},CallExpression(n,o,u){const c=n.callee&&n.callee.type==="MemberExpression"&&n.callee.object&&n.callee.object.type==="Identifier"&&e.isContextBound(n.callee.object.name);pt(n,e),n.arguments.forEach(h=>u(h,{parent:n,inNamespaceCall:c||o.inNamespaceCall}))}});const r=N.createMemberExpression(N.createIdentifier(i),N.createIdentifier("param")),s=e.generateParamId(),a={type:"CallExpression",callee:r,arguments:[t,ri,{type:"Identifier",name:`'${s}'`}],_transformed:!0,_isParamCall:!0};if(!e.shouldSuppressHoisting()){const n=s;e.addLocalSeriesVar(n);const o=N.createVariableDeclaration(n,a);return e.addHoistedStatement(o),N.createIdentifier(n)}return a}function ai(t,e,i){const r=$t(t.argument,e,i),s={type:"UnaryExpression",operator:t.operator,prefix:t.prefix,argument:r,start:t.start,end:t.end};return rt(s,e,{CallExpression(a,n){a._transformed||pt(a,n)},MemberExpression(a){bt(a,"",e)}}),s}function Jt(t,e,i){switch(t?.type){case"BinaryExpression":t=si(t,i,e);break;case"LogicalExpression":t=ni(t,i,e);break;case"ConditionalExpression":return Mi(t,i,e);case"UnaryExpression":t=ai(t,i,e);break;case"ArrayExpression":t.elements=t.elements.map(c=>c.type==="Identifier"?i.isContextBound(c.name)&&!i.isRootParam(c.name)?c:Qr(c.name,i):c);break}const r=t.type==="MemberExpression"&&t.computed&&t.property,s=t.type==="MemberExpression"&&!t.computed;if(r){t.object.type==="CallExpression"?pt(t.object,i):t.object.type==="MemberExpression"?bt(t.object,"",i):t.object.type==="BinaryExpression"?t.object=si(t.object,i,e):t.object.type==="LogicalExpression"?t.object=ni(t.object,i,e):t.object.type==="ConditionalExpression"?t.object=Mi(t.object,i,e):t.object.type==="UnaryExpression"&&(t.object=ai(t.object,i,e));const c=t.object.type==="Identifier"&&i.isContextBound(t.object.name)&&!i.isRootParam(t.object.name)?t.object:de(t.object,i),h=t.property.type==="Identifier"&&!i.isContextBound(t.property.name)&&!i.isLoopVariable(t.property.name)?de(t.property,i):t.property,d=N.createMemberExpression(N.createIdentifier(e),N.createIdentifier("param")),l=i.generateParamId(),m={type:"CallExpression",callee:d,arguments:[c,h,{type:"Identifier",name:`'${l}'`}],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const x=l;i.addLocalSeriesVar(x);const E=N.createVariableDeclaration(x,m);return i.addHoistedStatement(E),N.createIdentifier(x)}return m}if(s)if(t.object.type==="Identifier"){const c=t.object.name,[h,d]=i.getVariable(c);if(h!==c&&!i.isLoopVariable(c)){const l=N.createContextVariableReference(d,h),m=N.createGetCall(l,0);t.object=m}}else t.object.type==="MemberExpression"&&Jt(t.object,e,i);if(t.type==="ObjectExpression"&&(t.properties=t.properties.map(c=>c.value.name?i.isContextBound(c.value.name)&&!i.isRootParam(c.value.name)?{type:"Property",key:{type:"Identifier",name:c.key.name},value:N.createIdentifier(c.value.name),kind:"init",method:!1,shorthand:!1,computed:!1}:{type:"Property",key:{type:"Identifier",name:c.key.name},value:nt(c.value.name,i),kind:"init",method:!1,shorthand:!1,computed:!1}:(c.value.type!=="Literal"&&(c.value=Jt(c.value,e,i)),c))),t.type==="Identifier"){if(t.name==="na")return t.name="NaN",t;if(i.isContextBound(t.name)&&!i.isRootParam(t.name)){const c=N.createMemberExpression(N.createIdentifier(e),N.createIdentifier("param")),h=i.generateParamId(),d={type:"CallExpression",callee:c,arguments:[t,ri,{type:"Identifier",name:`'${h}'`}],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const l=h;i.addLocalSeriesVar(l);const m=N.createVariableDeclaration(l,d);return i.addHoistedStatement(m),N.createIdentifier(l)}return d}}t?.type==="CallExpression"&&pt(t,i);const a=N.createMemberExpression(N.createIdentifier(e),N.createIdentifier("param")),n=t.type==="Identifier"?de(t,i):t,o=i.generateParamId(),u={type:"CallExpression",callee:a,arguments:[n,ri,{type:"Identifier",name:`'${o}'`}],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const c=o;i.addLocalSeriesVar(c);const h=N.createVariableDeclaration(c,u);return i.addHoistedStatement(h),N.createIdentifier(c)}return u}function pt(t,e,i){if(t._transformed)return;t.callee&&t.callee.name,t.callee&&t.callee.type==="Identifier"&&(we.includes(t.callee.name)||In.includes(t.callee.name))&&e.isContextBound(t.callee.name)&&(t.callee=N.createMemberExpression(t.callee,N.createIdentifier("any")));const r=t.callee&&t.callee.type==="MemberExpression"&&t.callee.object&&t.callee.object.type==="Identifier"&&(e.isContextBound(t.callee.object.name)||t.callee.object.name==="math"||t.callee.object.name==="ta");if(r){if(t.callee.object.name===Y&&["get","init","param"].includes(t.callee.property.name))return;const s=t.callee.object.name,a=[];if(t.arguments.forEach(h=>{if(h._isParamCall){a.push(h);return}a.push(Jt(h,s,e))}),t.arguments=a,s==="ta")if(e.getCurrentScopeType()==="fn"){const h=e.getNextTACallId(),[d]=e.getVariable("$$");let l;d?l=N.createMemberExpression(N.createLocalContextIdentifier(),N.createIdentifier("id")):l=N.createLiteral("");const m={type:"BinaryExpression",operator:"+",left:l,right:h};t.arguments.push(m)}else t.arguments.push(e.getNextTACallId());const n=t.callee.property.name,o=`${s}.${n}`,u=kn.includes(o),c=t._insideAwait===!0;if(u&&!c){const h=Object.assign({},t),d=N.createAwaitExpression(h);Object.assign(t,d)}if(!e.shouldSuppressHoisting()){const h=e.generateTempVar();e.addLocalSeriesVar(h);const d=t._insideAwait===!0;let l=Object.assign({},t);d&&(l=N.createAwaitExpression(l));const m=N.createVariableDeclaration(h,l);e.addHoistedStatement(m);const x=N.createIdentifier(h);Object.assign(t,x),t._wasHoisted=!0,t._wasInsideAwait=d;return}t._transformed=!0}else if(t.callee&&t.callee.type==="Identifier"){if(t.arguments=t.arguments.map(s=>s._isParamCall?s:Jt(s,Y,e)),!e.isContextBound(t.callee.name)){const s=e.getNextUserCallId(),a=N.createMemberExpression(N.createContextIdentifier(),N.createIdentifier("call")),n=[t.callee,s,...t.arguments];t.callee=a,t.arguments=n}t._transformed=!0}if(!r&&t.callee&&t.callee.type==="MemberExpression"){const s=t.callee.property.name;if(e.isUserFunction(s)&&!e.isContextBound(s)){const a=t.callee.object;t.callee.property;const n=t.arguments.map(d=>d._isParamCall?d:Jt(d,Y,e));let o=a;a.type==="Identifier"?o=Jt(a,Y,e):a.type==="CallExpression"&&(pt(a,e),o=Jt(a,Y,e));const u=N.createMemberExpression(N.createContextIdentifier(),N.createIdentifier("call")),c=e.getNextUserCallId(),h=[N.createIdentifier(s),c,o,...n];t.callee=u,t.arguments=h,t._transformed=!0;return}t.callee.object.type==="Identifier"&&ut(t.callee.object,e)}t.arguments.forEach(s=>{rt(s,{parent:t},{Identifier(a,n,o){a.parent=n.parent,ut(a,e);const u=a.parent&&a.parent.type==="BinaryExpression";(a.parent&&a.parent.type==="ConditionalExpression"||u)&&(a.type==="MemberExpression"?qt(a,e):a.type==="Identifier"&&(a.parent&&a.parent.type==="CallExpression"&&a.parent.callee&&a.parent.callee.object&&a.parent.callee.object.name===Y&&a.parent.callee.property.name==="get"||Ot(a)))},BinaryExpression(a,n,o){const u={...n,parent:a};o(a.left,u),o(a.right,u)},LogicalExpression(a,n,o){const u={...n,parent:a};o(a.left,u),o(a.right,u)},UnaryExpression(a,n,o){const u={...n,parent:a};o(a.argument,u)},CallExpression(a,n,o){a._transformed||pt(a,e)},MemberExpression(a,n,o){bt(a,"",e),a.object&&o(a.object,{parent:a})}})})}function Jr(t,e){let i=null;if(t.left.type==="Identifier")i=nt(t.left.name,e);else if(t.left.type==="MemberExpression"&&t.left.computed){if(t.left.object.type==="Identifier"){const r=t.left.object.name,[s,a]=e.getVariable(r),n=s!==r,o=e.isContextBound(r);(n||o)&&!e.isLoopVariable(r)&&t.left.property.type==="Literal"&&t.left.property.value===0&&(i=nt(r,e))}}else if(t.left.type==="MemberExpression"&&!t.left.computed&&t.left.object.type==="Identifier"){const r=t.left.object.name,[s,a]=e.getVariable(r);if(s!==r&&!e.isLoopVariable(r)){const n=nt(r,e),o=N.createGetCall(n,0);t.left.object=o}}if(rt(t.right,{parent:t.right,inNamespaceCall:!1},{Identifier(r,s,a){r.name=="na"&&(r.name="NaN"),r.parent=s.parent,ut(r,e);const n=r.parent&&r.parent.type==="BinaryExpression",o=r.parent&&r.parent.type==="ConditionalExpression",u=e.isContextBound(r.name)&&!e.isRootParam(r.name),c=r.parent&&r.parent.type==="MemberExpression"&&r.parent.computed&&r.parent.object===r,h=r.parent&&r.parent._isParamCall,d=r.parent&&r.parent.type==="MemberExpression",l=r.name==="NaN",m=r.parent&&r.parent.type==="CallExpression"&&r.parent.callee&&r.parent.callee.object&&r.parent.callee.object.name===Y&&r.parent.callee.property.name==="get";(u||o||n)&&(r.type==="MemberExpression"?qt(r,e):r.type==="Identifier"&&!d&&!c&&!h&&!l&&!m&&Ot(r))},MemberExpression(r,s,a){bt(r,"",e),r.type==="CallExpression"?r.arguments.forEach(n=>a(n,{parent:r,inNamespaceCall:s.inNamespaceCall})):r.object&&a(r.object,{parent:r,inNamespaceCall:s.inNamespaceCall})},CallExpression(r,s,a){const n=r.callee&&r.callee.type==="MemberExpression"&&r.callee.object&&r.callee.object.type==="Identifier"&&e.isContextBound(r.callee.object.name);pt(r,e),r.type==="CallExpression"&&(r.callee.type==="MemberExpression"&&a(r.callee,{parent:r,inNamespaceCall:n||s.inNamespaceCall}),r.arguments.forEach(o=>a(o,{parent:r,inNamespaceCall:n||s.inNamespaceCall})))}}),i){let r=t.right;if(t.operator!=="="){const a=t.operator.replace("=",""),n=N.createGetCall(i,0);r={type:"BinaryExpression",operator:a,left:n,right:t.right,start:t.start,end:t.end}}const s=N.createSetCall(i,r);t.start&&(s.start=t.start),t.end&&(s.end=t.end),Object.assign(t,s)}}function Xr(t,e){t._skipTransformation||t.declarations.forEach(i=>{i.init&&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===Y||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===Y||i.init.object.object.name==="context2"),a=i.init&&i.init.type==="ArrowFunctionExpression";if(r){i.id.name&&e.addContextBoundVar(i.id.name),i.id.properties&&i.id.properties.forEach(l=>{l.key.name&&e.addContextBoundVar(l.key.name)}),i.init.object.name=Y;return}if(s){i.id.name&&e.addContextBoundVar(i.id.name),i.id.properties&&i.id.properties.forEach(l=>{l.key.name&&e.addContextBoundVar(l.key.name)}),i.init.object.object.name=Y;return}e.addVariable(i.id.name,t.kind);const n=t.kind,o=e.isArrayPatternElement(i.id.name);i.init&&!a&&!o&&(i.init.type==="CallExpression"&&i.init.callee.type==="MemberExpression"&&i.init.callee.object&&i.init.callee.object.type==="Identifier"&&e.isContextBound(i.init.callee.object.name)?pt(i.init,e):rt(i.init,{parent:i.init},{Identifier(l,m){l.parent=m.parent,ut(l,e);const x=l.parent&&l.parent.type==="BinaryExpression",E=l.parent&&l.parent.type==="UnaryExpression",S=l.parent&&l.parent.type==="ConditionalExpression",p=l.parent&&l.parent.type==="CallExpression"&&l.parent.callee&&l.parent.callee.object&&l.parent.callee.object.name===Y&&l.parent.callee.property.name==="get";l.type==="Identifier"&&(x||E||S)&&!p&&Ot(l)},CallExpression(l,m,x){l.callee.type==="Identifier"&&(l.callee.parent=l),l.arguments.forEach(E=>{E.type==="Identifier"&&(E.parent=l)}),(l.callee.type==="ArrowFunctionExpression"||l.callee.type==="FunctionExpression")&&x(l.callee,{parent:l}),pt(l,e),l.type==="CallExpression"&&(l.callee.type==="MemberExpression"&&x(l.callee,{parent:l}),l.arguments.forEach(E=>x(E,{parent:l})))},BinaryExpression(l,m,x){l.left.type==="Identifier"&&(l.left.parent=l),l.right.type==="Identifier"&&(l.right.parent=l),x(l.left,{parent:l}),x(l.right,{parent:l})},MemberExpression(l,m,x){l.object&&l.object.type==="Identifier"&&(l.object.parent=l),l.property&&l.property.type==="Identifier"&&(l.property.parent=l),bt(l,"",e),l.type==="CallExpression"?l.arguments.forEach(E=>x(E,{parent:l})):l.object&&x(l.object,{parent:l})},AwaitExpression(l,m,x){l.argument&&(l.argument._insideAwait=!0,x(l.argument,{parent:l}),l.argument.type==="Identifier"&&l.argument._wasInsideAwait&&Object.assign(l,l.argument))},ArrowFunctionExpression(l,m,x){if(l.body)if(l.body.type==="BlockStatement"){const E=[];l.body.body.forEach(S=>{e.enterHoistingScope(),x(S,{parent:l.body});const p=e.exitHoistingScope();E.push(...p),E.push(S)}),l.body.body=E}else x(l.body,{parent:l})},FunctionExpression(l,m,x){if(l.body&&l.body.type==="BlockStatement"){const E=[];l.body.body.forEach(S=>{e.enterHoistingScope(),x(S,{parent:l.body});const p=e.exitHoistingScope();E.push(...p),E.push(S)}),l.body.body=E}},SwitchStatement(l,m,x){l.discriminant&&(l.discriminant.parent=l,x(l.discriminant,{parent:l})),l.cases&&l.cases.forEach(E=>{E.parent=l,x(E,{parent:l})})},SwitchCase(l,m,x){if(l.test&&(l.test.parent=l,x(l.test,{parent:l})),l.consequent){const E=[];l.consequent.forEach(S=>{e.enterHoistingScope(),S.parent=l,x(S,{parent:l});const p=e.exitHoistingScope();E.push(...p),E.push(S)}),l.consequent=E}}}));const u=nt(i.id.name,e),c=!o&&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||(qt(i.init.property,e),i.init.property._indexTransformed=!0));let h;i.init?a||o?h=i.init:n==="var"?h=N.createInitVarCall(u,i.init):h=N.createInitCall(u,c?i.init.object:i.init,c?i.init.property:void 0):h=N.createIdentifier("undefined");const d=N.createExpressionStatement(N.createAssignmentExpression(u,h));if(o){const l=i.init.object.name,m=nt(l,e),x=i.init.property.value,E={type:"MemberExpression",object:N.createGetCall(m,0),property:{type:"Literal",value:x},computed:!0};d.expression.right=N.createCallExpression(N.createMemberExpression(N.createContextIdentifier(),N.createIdentifier("init")),[u,E])}a&&(e.pushScope("fn"),rt(i.init.body,e,{IfStatement(l,m,x){m.pushScope("if"),x(l.consequent,m),l.alternate&&(m.pushScope("els"),x(l.alternate,m),m.popScope()),m.popScope()},VariableDeclaration(l,m){Xr(l,m)},Identifier(l,m){ut(l,m)},AssignmentExpression(l,m){Jr(l,m)},SwitchStatement(l,m,x){l.discriminant.parent=l,x(l.discriminant,m),l.cases.forEach(E=>{E.parent=l,x(E,m)})},SwitchCase(l,m,x){l.test&&(l.test.parent=l,x(l.test,m));const E=[];l.consequent.forEach(S=>{m.enterHoistingScope(),x(S,m);const p=m.exitHoistingScope();E.push(...p),E.push(S)}),l.consequent=E},BlockStatement(l,m,x){const E=[];l.body.forEach(S=>{m.enterHoistingScope(),x(S,m);const p=m.exitHoistingScope();E.push(...p),E.push(S)}),l.body=E}}),e.popScope()),Object.assign(t,d)})}function Wn(t,e,i){if(e.setSuppressHoisting(!0),t.init&&t.init.type==="VariableDeclaration"){const r=t.init.declarations[0],s=r.id.name;e.addLoopVariable(s,s),t.init={type:"VariableDeclaration",kind:t.init.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:s},init:r.init}]},r.init&&rt(r.init,e,{Identifier(a,n){e.isLoopVariable(a.name)||(e.pushScope("for"),ut(a,n),e.popScope())},MemberExpression(a){e.pushScope("for"),bt(a,"",e),e.popScope()}})}t.test&&rt(t.test,e,{Identifier(r,s){!e.isLoopVariable(r.name)&&!r.computed&&(e.pushScope("for"),ut(r,s),r.type==="Identifier"&&(r.computed=!0,Ot(r)),e.popScope())},MemberExpression(r){e.pushScope("for"),bt(r,"",e),e.popScope()}}),t.update&&rt(t.update,e,{Identifier(r,s){e.isLoopVariable(r.name)||(e.pushScope("for"),ut(r,s),e.popScope())}}),e.setSuppressHoisting(!1),e.pushScope("for"),i(t.body,e),e.popScope()}function jn(t,e){rt(t,e,{MemberExpression(i){bt(i,"",e)},CallExpression(i,r){pt(i,r)},Identifier(i,r){ut(i,r);const s=e.getCurrentScopeType()==="if";e.isContextBound(i.name)&&!e.isRootParam(i.name)&&s&&Ot(i)}})}function $n(t,e,i){t.test&&(e.pushScope("if"),jn(t.test,e),e.popScope()),e.pushScope("if"),i(t.consequent,e),e.popScope(),t.alternate&&(e.pushScope("els"),i(t.alternate,e),e.popScope())}function qn(t,e){const i=e.getCurrentScopeType();if(t.argument&&(t.argument.type==="ArrayExpression"?(t.argument.elements=t.argument.elements.map(r=>r.type==="Identifier"?e.isContextBound(r.name)&&!e.isRootParam(r.name)?N.createGetCall(r,0):Qr(r.name,e):r.type==="MemberExpression"?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)?N.createGetCall(r,0):(r.computed&&r.object.type==="Identifier"&&e.isContextBound(r.object.name)&&!e.isRootParam(r.object.name)||bt(r,"",e),r):r),t.argument={type:"ArrayExpression",elements:[t.argument]}):t.argument.type==="ObjectExpression"?t.argument.properties=t.argument.properties.map(r=>r.shorthand?e.isContextBound(r.value.name)?r:(e.getVariable(r.value.name),{type:"Property",key:N.createIdentifier(r.key.name),value:nt(r.value.name,e),kind:"init",method:!1,shorthand:!1,computed:!1}):(r.value&&r.value.type==="Identifier"&&(e.isContextBound(r.value.name)&&!e.isRootParam(r.value.name)||e.isContextBound(r.value.name)||(r.value=nt(r.value.name,e))),r)):t.argument.type==="Identifier"&&(ut(t.argument,e),t.argument.type==="Identifier"&&Ot(t.argument)),i==="fn")){t.argument.type==="Identifier"&&e.isContextBound(t.argument.name)&&!e.isRootParam(t.argument.name)?t.argument=N.createArrayAccess(t.argument,0):t.argument.type==="MemberExpression"?t.argument.object.type==="Identifier"&&e.isContextBound(t.argument.object.name)&&!e.isRootParam(t.argument.object.name)&&(t.argument._indexTransformed||(qt(t.argument,e),t.argument._indexTransformed=!0)):(t.argument.type==="BinaryExpression"||t.argument.type==="LogicalExpression"||t.argument.type==="ConditionalExpression"||t.argument.type==="CallExpression")&&rt(t.argument,e,{Identifier(s,a){ut(s,a),s.type==="Identifier"&&!s._arrayAccessed&&(Ot(s),s._arrayAccessed=!0)},MemberExpression(s){bt(s,"",e)},CallExpression(s,a,n){(s.callee.type==="ArrowFunctionExpression"||s.callee.type==="FunctionExpression")&&n(s.callee,a),pt(s,a),s.type==="CallExpression"&&s.arguments.forEach(o=>n(o,a))},BinaryExpression(s,a,n){n(s.left,a),n(s.right,a)},ArrowFunctionExpression(s,a,n){if(s.body)if(s.body.type==="BlockStatement"){const o=[];s.body.body.forEach(u=>{e.enterHoistingScope(),n(u,a);const c=e.exitHoistingScope();o.push(...c),o.push(u)}),s.body.body=o}else n(s.body,a)},FunctionExpression(s,a,n){if(s.body&&s.body.type==="BlockStatement"){const o=[];s.body.body.forEach(u=>{e.enterHoistingScope(),n(u,a);const c=e.exitHoistingScope();o.push(...c),o.push(u)}),s.body.body=o}},SwitchStatement(s,a,n){s.discriminant.parent=s,n(s.discriminant,a),s.cases.forEach(o=>{o.parent=s,n(o,a)})},SwitchCase(s,a,n){s.test&&(s.test.parent=s,n(s.test,a));const o=[];s.consequent.forEach(u=>{e.enterHoistingScope(),n(u,a);const c=e.exitHoistingScope();o.push(...c),o.push(u)}),s.consequent=o},BlockStatement(s,a,n){const o=[];s.body.forEach(u=>{a.enterHoistingScope(),n(u,a);const c=a.exitHoistingScope();o.push(...c),o.push(u)}),s.body=o}});const r=N.createCallExpression(N.createMemberExpression(N.createContextIdentifier(),N.createIdentifier("precision")),[t.argument]);t.argument=r}}function Hn(t,e,i){const r=N.createVariableDeclaration("$$",N.createCallExpression(N.createMemberExpression(N.createContextIdentifier(),N.createIdentifier("peekCtx")),[]));r._skipTransformation=!0,e.addLoopVariable("$$","$$"),t.body&&t.body.type==="BlockStatement"&&(t.body.body.unshift(r),e.pushScope("fn"),t.params.forEach(s=>{s.type==="Identifier"&&e.addLocalSeriesVar(s.name)}),i(t.body,e),t.params.forEach(s=>{s.type==="Identifier"&&e.removeLocalSeriesVar(s.name)}),e.popScope())}function Un(t){const e={...I,LineComment:()=>{}};Kr(t,{BinaryExpression(i){if(i.operator==="=="||i.operator==="==="){const r=i.left,s=i.right,a=N.createMathEqCall(r,s);a._transformed=!0,Object.assign(i,a)}}},e)}function Gn(t,e,i,r={debug:!1,ln:!1},s=[]){const a=n=>{if(!r.debug||!n.loc||!s.length)return null;const o=n.loc.start.line-1;if(o>=0&&o<s.length){const u=s[o].trim();if(u)return{type:"LineComment",value:`${r.ln?` [Line ${n.loc.start.line}]`:""} ${u}`}}return null};rt(t,e,{Program(n,o,u){const c=[];n.body.forEach(h=>{o.enterHoistingScope(),u(h,o);const d=o.exitHoistingScope(),l=a(h);l&&c.push(l),c.push(...d),c.push(h)}),n.body=c},BlockStatement(n,o,u){const c=[];n.body.forEach(h=>{o.enterHoistingScope(),u(h,o);const d=o.exitHoistingScope(),l=a(h);l&&c.push(l),c.push(...d),c.push(h)}),n.body=c},ReturnStatement(n,o){qn(n,o)},VariableDeclaration(n,o){Xr(n,o)},Identifier(n,o){ut(n,o)},CallExpression(n,o,u){n.callee&&(n.callee.type==="ArrowFunctionExpression"||n.callee.type==="FunctionExpression")&&u(n.callee,o),pt(n,o)},ArrowFunctionExpression(n,o,u){n.body&&u(n.body,o)},FunctionExpression(n,o,u){n.body&&u(n.body,o)},ForOfStatement(n,o,u){if(n.left&&n.left.type==="VariableDeclaration"){n.left._skipTransformation=!0;const c=n.left.declarations[0];c.id.type==="Identifier"?o.addLoopVariable(c.id.name,c.id.name):c.id.type==="ArrayPattern"&&c.id.elements.forEach(h=>{h.type==="Identifier"&&o.addLoopVariable(h.name,h.name)})}if(n.right&&n.right.type==="Identifier"){ut(n.right,o),Ot(n.right);const c={...n.right};let h=N.createMemberExpression(c,N.createIdentifier("array"),!1);n.left&&n.left.type==="VariableDeclaration"&&n.left.declarations[0].id.type==="ArrayPattern"&&(h=N.createCallExpression(N.createMemberExpression(h,N.createIdentifier("entries"),!1),[])),Object.assign(n.right,h)}else n.right&&u(n.right,o);n.body&&u(n.body,o)},ForInStatement(n,o,u){n.left&&n.left.type==="VariableDeclaration"&&(n.left._skipTransformation=!0),n.right&&n.right.type==="Identifier"?(ut(n.right,o),Ot(n.right)):n.right&&u(n.right,o),n.body&&u(n.body,o)},MemberExpression(n,o){bt(n,i,o)},AssignmentExpression(n,o){Jr(n,o)},FunctionDeclaration(n,o,u){Hn(n,o,u)},ForStatement(n,o,u){Wn(n,o,u)},IfStatement(n,o,u){$n(n,o,u)},SwitchStatement(n,o,u){n.discriminant.parent=n,u(n.discriminant,o),n.cases.forEach(c=>{c.parent=n,u(c,o)})},SwitchCase(n,o,u){n.test&&(n.test.parent=n,u(n.test,o));const c=[];n.consequent.forEach(h=>{o.enterHoistingScope(),u(h,o);const d=o.exitHoistingScope();c.push(...d),c.push(h)}),n.consequent=c},AwaitExpression(n,o,u){n.argument&&(n.argument._insideAwait=!0,u(n.argument,o),n.argument.type==="Identifier"&&n.argument._wasInsideAwait===!0&&(n.type="Identifier",n.name=n.argument.name,n.argument._wasHoisted&&(n._wasHoisted=n.argument._wasHoisted),delete n.argument))}})}const y={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"},Kn=new Set(["if","else","for","while","switch","break","continue","var","varip","type","and","or","not","to","by","in","import","export","method","extends"]),zn=["==","!=","<=",">=",":=","+=","-=","*=","/=","%=","=>","//","and","or","not"];class Yn{constructor(e,i,r,s,a=0){this.type=e,this.value=i,this.line=r,this.column=s,this.indent=a}}var Qn=Object.defineProperty,Jn=(t,e,i)=>e in t?Qn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Tt=(t,e,i)=>Jn(t,typeof e!="symbol"?e+"":e,i);class Xn{constructor(e){Tt(this,"source"),Tt(this,"pos"),Tt(this,"line"),Tt(this,"column"),Tt(this,"tokens"),Tt(this,"indentStack"),Tt(this,"atLineStart"),Tt(this,"parenDepth"),Tt(this,"bracketDepth"),Tt(this,"braceDepth"),this.source=e,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 e=this.peek();if(e==="\r"){this.advance();continue}if(e===`
|
|
52
|
+
`){this.handleNewline();continue}if(this.atLineStart&&e!==`
|
|
53
|
+
`){this.handleIndentation(),this.atLineStart=!1;continue}if(e===" "||e===" "){this.advance();continue}if(this.pos>=this.source.length)break;if(e==="/"&&this.peek(1)==="/"){this.readComment();continue}if(e==='"'||e==="'"){this.readString();continue}if(e==="#"){this.readColorLiteral();continue}if(this.isDigit(e)){this.readNumber();continue}if(this.isIdentifierStart(e)){this.readIdentifier();continue}if(!this.readOperatorOrPunctuation())throw new Error(`Unexpected character '${e}' at ${this.line}:${this.column}`)}for(;this.indentStack.length>1;)this.indentStack.pop(),this.addToken(y.DEDENT,"",this.getCurrentIndent());return this.addToken(y.EOF,""),this.tokens}handleNewline(){this.parenDepth===0&&this.bracketDepth===0&&this.braceDepth===0&&(this.addToken(y.NEWLINE,`
|
|
54
|
+
`),this.atLineStart=!0),this.advance(),this.line++,this.column=1}handleIndentation(){let e=0,i=0;for(this.pos;this.pos<this.source.length;){const s=this.peek();if(s===" ")i++,this.advance();else if(s===" ")e++,this.advance();else break}if(this.peek()===`
|
|
55
|
+
`||this.peek()==="\r"||this.peek()==="\0")return;e+=Math.floor(i/4);const r=this.indentStack[this.indentStack.length-1];if(e>r)this.indentStack.push(e),this.addToken(y.INDENT,"",e);else if(e<r){for(;this.indentStack.length>1&&this.indentStack[this.indentStack.length-1]>e;)this.indentStack.pop(),this.addToken(y.DEDENT,"",this.indentStack[this.indentStack.length-1]);if(this.indentStack[this.indentStack.length-1]!==e)throw new Error(`Indentation error at ${this.line}:${this.column} - misaligned dedent`)}}readComment(){this.column;let e="";for(this.advance(),this.advance();this.pos<this.source.length&&this.peek()!==`
|
|
56
|
+
`;)e+=this.advance();this.addToken(y.COMMENT,e.trim())}readString(){const e=this.advance(),i=this.column-1;let r="";for(;this.pos<this.source.length&&this.peek()!==e;)if(this.peek()==="\\"){this.advance();const s=this.advance();switch(s){case"n":r+=`
|
|
57
|
+
`;break;case"t":r+=" ";break;case"r":r+="\r";break;case"\\":r+="\\";break;case e:r+=e;break;default:r+=s}}else r+=this.advance();if(this.peek()!==e)throw new Error(`Unterminated string at ${this.line}:${i}`);this.advance(),this.addToken(y.STRING,r)}readColorLiteral(){const e=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}:${e}`);this.addToken(y.STRING,i)}readNumber(){this.column;let e="",i=!1;for(this.peek()==="."&&this.isDigit(this.peek(1))&&(i=!0,e+=this.advance());this.pos<this.source.length;){const r=this.peek();if(this.isDigit(r))e+=this.advance();else if(r==="."&&!i){const s=this.peek(1);if(this.isDigit(s)||!this.isIdentifierStart(s)){if(i=!0,e+=this.advance(),!this.isDigit(this.peek()))break}else break}else break}if(this.pos<this.source.length){const r=this.peek();if(r==="e"||r==="E"){const s=this.peek(1);if(this.isDigit(s))for(e+=this.advance();this.pos<this.source.length&&this.isDigit(this.peek());)e+=this.advance();else if(s==="+"||s==="-"){const a=this.peek(2);if(this.isDigit(a))for(e+=this.advance(),e+=this.advance();this.pos<this.source.length&&this.isDigit(this.peek());)e+=this.advance()}}}this.addToken(y.NUMBER,parseFloat(e))}readIdentifier(){this.column;let e="";for(;this.pos<this.source.length&&this.isIdentifierChar(this.peek());)e+=this.advance();Kn.has(e)?this.addToken(y.KEYWORD,e):e==="true"||e==="false"?this.addToken(y.BOOLEAN,e==="true"):this.addToken(y.IDENTIFIER,e)}readOperatorOrPunctuation(){const e=this.peek(),i=this.peek(1),r=e+i;if(zn.includes(r))return this.advance(),this.advance(),this.addToken(y.OPERATOR,r),!0;if("+-*/%<>=!?".includes(e))return this.advance(),this.addToken(y.OPERATOR,e),!0;switch(e){case"(":return this.parenDepth++,this.advance(),this.addToken(y.LPAREN,e),!0;case")":return this.parenDepth--,this.advance(),this.addToken(y.RPAREN,e),!0;case"[":return this.bracketDepth++,this.advance(),this.addToken(y.LBRACKET,e),!0;case"]":return this.bracketDepth--,this.advance(),this.addToken(y.RBRACKET,e),!0;case"{":return this.braceDepth++,this.advance(),this.addToken(y.LBRACE,e),!0;case"}":return this.braceDepth--,this.advance(),this.addToken(y.RBRACE,e),!0;case",":return this.advance(),this.addToken(y.COMMA,e),!0;case".":return this.isDigit(this.peek(1))?(this.readNumber(),!0):(this.advance(),this.addToken(y.DOT,e),!0);case":":return this.advance(),this.addToken(y.COLON,e),!0;case";":return this.advance(),this.addToken(y.SEMICOLON,e),!0}return!1}peek(e=0){const i=this.pos+e;return i<this.source.length?this.source[i]:"\0"}advance(){const e=this.source[this.pos++];return this.column++,e}skipWhitespaceInline(){if(!this.atLineStart)for(;this.pos<this.source.length&&(this.peek()===" "||this.peek()===" ");)this.advance()}isDigit(e){return e>="0"&&e<="9"}isIdentifierStart(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}isIdentifierChar(e){return this.isIdentifierStart(e)||this.isDigit(e)}getCurrentIndent(){return this.indentStack[this.indentStack.length-1]}addToken(e,i,r=null){const s=new Yn(e,i,this.line,this.column,r!==null?r:this.getCurrentIndent());this.tokens.push(s)}}var Zn=Object.defineProperty,ta=(t,e,i)=>e in t?Zn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,mt=(t,e,i)=>ta(t,typeof e!="symbol"?e+"":e,i);class G{constructor(e){this.type=e}}class ea extends G{constructor(e){super("Program"),this.body=e}}class yt extends G{constructor(e){super("ExpressionStatement"),this.expression=e}}var Qt=(t=>(t.VAR="var",t.LET="let",t.CONST="const",t))(Qt||{});class Ut extends G{constructor(e,i="let"){super("VariableDeclaration"),this.declarations=e,this.kind=i}}class Gt extends G{constructor(e,i,r=null){super("VariableDeclarator"),this.id=e,this.init=i,this.varType=r}}class Wi extends G{constructor(e,i,r,s=null){super("FunctionDeclaration"),this.id=e,this.params=i,this.body=r,this.returnType=s}}class ia extends G{constructor(e,i){super("TypeDefinition"),this.name=e,this.fields=i}}class ra extends G{constructor(e,i,r=null){super("IfStatement"),this.test=e,this.consequent=i,this.alternate=r,mt(this,"_line")}}class ji extends G{constructor(e,i,r,s){super("ForStatement"),this.init=e,this.test=i,this.update=r,this.body=s,mt(this,"isForIn")}}class sa extends G{constructor(e,i){super("WhileStatement"),this.test=e,this.body=i}}class Wt extends G{constructor(e){super("BlockStatement"),this.body=e}}class $i extends G{constructor(e){super("ReturnStatement"),this.argument=e}}class lt extends G{constructor(e){super("Identifier"),this.name=e,mt(this,"varType"),mt(this,"returnType"),mt(this,"isMethod")}}class ie extends G{constructor(e,i=null){super("Literal"),this.value=e,this.raw=i}}class Kt extends G{constructor(e,i,r){super("BinaryExpression"),this.operator=e,this.left=i,this.right=r}}class qi extends G{constructor(e,i,r=!0){super("UnaryExpression"),this.operator=e,this.argument=i,this.prefix=r}}class ze extends G{constructor(e,i,r){super("AssignmentExpression"),this.operator=e,this.left=i,this.right=r}}class na extends G{constructor(e,i,r=!1){super("UpdateExpression"),this.operator=e,this.argument=i,this.prefix=r}}class aa extends G{constructor(e,i){super("CallExpression"),this.callee=e,this.args=i,mt(this,"arguments"),this.callee=e,this.arguments=i}}class Hi extends G{constructor(e,i,r=!1){super("MemberExpression"),this.object=e,this.property=i,this.computed=r}}class he extends G{constructor(e,i,r){super("ConditionalExpression"),this.test=e,this.consequent=i,this.alternate=r,mt(this,"needsIIFE"),mt(this,"consequentStmts"),mt(this,"alternateStmts")}}class oa extends G{constructor(e){super("ArrayExpression"),this.elements=e}}class ua extends G{constructor(e){super("ObjectExpression"),this.properties=e}}class ca extends G{constructor(e,i){super("Property"),this.key=e,this.value=i,mt(this,"kind"),mt(this,"method"),mt(this,"shorthand"),mt(this,"computed"),this.kind="init",this.method=!1,this.shorthand=!1,this.computed=!1}}class Ui extends G{constructor(e){super("ArrayPattern"),this.elements=e}}class Gi extends G{constructor(e,i){super("AssignmentPattern"),this.left=e,this.right=i}}class ha extends G{constructor(e,i){super("SwitchExpression"),this.discriminant=e,this.cases=i}}class la extends G{constructor(e,i,r){super("SwitchCase"),this.test=e,this.consequent=i,this.statements=r,this.statements=r}}var pa=Object.defineProperty,da=(t,e,i)=>e in t?pa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ye=(t,e,i)=>da(t,typeof e!="symbol"?e+"":e,i);class fa{constructor(e){Ye(this,"tokens"),Ye(this,"pos"),Ye(this,"functionNames",new Set),this.tokens=e,this.pos=0}peek(e=0){return this.tokens[this.pos+e]||this.tokens[this.tokens.length-1]}advance(){return this.tokens[this.pos++]}match(e,i=null){const r=this.peek();return!(r.type!==e||i!==null&&r.value!==i)}expect(e,i=null){const r=this.peek();if(r.type!==e)throw new Error(`Expected ${e} 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()}matchEx(e,i=null,r=!1){if(!r)return this.match(e,i);let s=0,a=this.peek(s);if(a.type===y.NEWLINE&&(s++,a=this.peek(s),a.type===y.INDENT&&(s++,a=this.peek(s))),a.type!==e||i!==null&&a.value!==i)return!1;for(let n=0;n<s;n++)this.advance();return!0}skipNewlines(e=!1){for(;this.match(y.NEWLINE)||this.match(y.COMMENT);)this.advance();e&&this.match(y.INDENT)&&this.advance()}parse(){const e=[];for(;!this.match(y.EOF);){if(this.skipNewlines(),this.match(y.DEDENT)){this.advance();continue}if(this.match(y.EOF))break;const i=this.parseStatement();i&&e.push(i),this.skipNewlines()}return new ea(e)}parseStatement(e=!0){this.skipNewlines();const i=this.peek().line;if(this.match(y.COMMENT))return this.advance(),null;let r;if(this.match(y.KEYWORD,"type"))r=this.parseTypeDefinition();else if(this.match(y.KEYWORD,"var")||this.match(y.KEYWORD,"varip"))r=this.parseVarDeclaration();else if(this.match(y.KEYWORD,"method"))r=this.parseMethodDeclaration();else if(this.isFunctionDeclaration())r=this.parseFunctionDeclaration();else if(this.match(y.KEYWORD,"if"))r=this.parseIfStatement();else if(this.match(y.KEYWORD,"for"))r=this.parseForStatement();else if(this.match(y.KEYWORD,"while"))r=this.parseWhileStatement();else if(this.match(y.KEYWORD,"break")||this.match(y.KEYWORD,"continue")){const s=this.advance().value;r=new yt(new lt(s))}else this.isTupleDestructuring()?r=this.parseTupleDestructuring():this.peek().type===y.IDENTIFIER&&this.isTypedVarDeclaration()&&(r=this.parseTypedVarDeclaration());if(!r){const s=this.parseExpression();if(this.match(y.OPERATOR)){const a=this.peek().value;if(["=",":=","+=","-=","*=","/=","%="].includes(a)){this.advance(),this.skipNewlines(!0);const n=this.parseExpression();a==="="&&s.type==="Identifier"?r=new Ut([new Gt(s,n)],Qt.LET):r=new yt(new ze(a===":="?"=":a,s,n))}else r=new yt(s)}else r=new yt(s)}if(r&&(r._line=i,e&&this.match(y.COMMA)&&this.peek().line===i)){const s=[r];for(;this.match(y.COMMA)&&this.peek().line===i;){this.advance(),this.skipNewlines(!0);const a=this.parseStatement(!1);a&&s.push(a)}return new Wt(s)}return r}isFunctionDeclaration(){const e=this.pos;try{let i=0;if(this.peek(i).type===y.IDENTIFIER&&this.peek(i+1).type===y.IDENTIFIER&&i++,this.peek(i).type!==y.IDENTIFIER||(i++,this.peek(i).type!==y.LPAREN))return!1;i++;let r=1;for(;r>0&&this.peek(i).type!==y.EOF;)this.peek(i).type===y.LPAREN&&r++,this.peek(i).type===y.RPAREN&&r--,i++;for(;this.peek(i).type===y.NEWLINE;)i++;return this.peek(i).type===y.OPERATOR&&this.peek(i).value==="=>"}finally{this.pos=e}}parseTypeExpression(){const e=this.expect(y.IDENTIFIER).value;if(this.match(y.OPERATOR,"<")){this.advance();const i=[];for(i.push(this.parseTypeExpression());this.match(y.COMMA);)this.advance(),this.skipNewlines(),i.push(this.parseTypeExpression());return this.expect(y.OPERATOR,">"),e+"<"+i.join(", ")+">"}return e}parseTypeDefinition(){this.expect(y.KEYWORD,"type");const e=this.expect(y.IDENTIFIER).value;this.match(y.OPERATOR,"=>")&&this.advance(),this.skipNewlines(),this.expect(y.INDENT);const i=[];for(;!this.match(y.DEDENT)&&!this.match(y.EOF)&&(this.skipNewlines(),!this.match(y.DEDENT));){const r=this.parseTypeExpression(),s=this.expect(y.IDENTIFIER).value;let a=null;this.match(y.OPERATOR,"=")&&(this.advance(),this.skipNewlines(),a=this.parseExpression()),i.push({type:r,name:s,defaultValue:a}),this.skipNewlines()}return this.match(y.DEDENT)&&this.advance(),new ia(e,i)}parseVarDeclaration(){const e=this.advance().value;let i=null,r=null;if(this.peek().type===y.IDENTIFIER&&this.peek(1).type===y.LBRACKET&&this.peek(2).type===y.RBRACKET)i=this.advance().value,this.advance(),i+="[]",this.advance(),r=this.expect(y.IDENTIFIER).value;else if(this.peek().type===y.IDENTIFIER&&(this.peek(1).type===y.IDENTIFIER||this.peek(1).type===y.OPERATOR&&this.peek(1).value==="<")){if(i=this.advance().value,this.match(y.OPERATOR,"<")){for(this.advance(),i+="<";!this.match(y.OPERATOR,">");)if(this.match(y.IDENTIFIER))i+=this.advance().value;else if(this.match(y.COMMA))i+=this.advance().value,this.skipNewlines();else break;this.match(y.OPERATOR,">")&&(i+=">",this.advance())}r=this.expect(y.IDENTIFIER).value}else if(this.peek().type===y.IDENTIFIER)r=this.advance().value;else throw new Error(`Expected identifier after ${e} at ${this.peek().line}:${this.peek().column}`);this.functionNames.has(r)&&(r=r+"_var"),this.expect(y.OPERATOR,"="),this.skipNewlines(!0);const s=this.parseExpression(),a=new lt(r);return i&&(a.varType=i),new Ut([new Gt(a,s,i)],e)}isTypedVarDeclaration(){let e=0;if(this.peek(e).type!==y.IDENTIFIER)return!1;if(e++,this.peek(e).type===y.LBRACKET&&this.peek(e+1).type===y.RBRACKET)return e+=2,this.peek(e).type!==y.IDENTIFIER?!1:(e++,this.peek(e).type===y.OPERATOR&&this.peek(e).value==="=");if(this.peek(e).type===y.OPERATOR&&this.peek(e).value==="<"){e++;let i=1;for(;i>0&&this.peek(e).type!==y.EOF;)this.peek(e).type===y.OPERATOR&&this.peek(e).value==="<"?i++:this.peek(e).type===y.OPERATOR&&this.peek(e).value===">"&&i--,e++;return this.peek(e).type!==y.IDENTIFIER?!1:(e++,this.peek(e).type===y.OPERATOR&&this.peek(e).value==="=")}if(this.peek(e).type!==y.IDENTIFIER)return!1;for(e++;this.peek(e).type===y.IDENTIFIER;)e++;return this.peek(e).type===y.OPERATOR&&this.peek(e).value==="="}parseTypedVarDeclaration(){let e=this.advance().value;if(this.match(y.LBRACKET)&&this.peek(1).type===y.RBRACKET)this.advance(),this.advance(),e+="[]";else if(this.match(y.OPERATOR,"<")){for(this.advance(),e+="<";!this.match(y.OPERATOR,">");)if(this.match(y.IDENTIFIER))e+=this.advance().value;else if(this.match(y.COMMA))e+=this.advance().value,this.skipNewlines();else break;this.match(y.OPERATOR,">")&&(e+=">",this.advance())}else for(;this.peek().type===y.IDENTIFIER&&this.peek(1).type===y.IDENTIFIER;)e+=" "+this.advance().value;let i=this.expect(y.IDENTIFIER).value;this.functionNames.has(i)&&(i=i+"_var"),this.expect(y.OPERATOR,"="),this.skipNewlines(!0);const r=this.parseExpression(),s=new lt(i);return s.varType=e,new Ut([new Gt(s,r,e)],Qt.LET)}parseFunctionDeclaration(){let e=null;this.peek().type===y.IDENTIFIER&&this.peek(1).type===y.IDENTIFIER&&(e=this.advance().value);const i=this.expect(y.IDENTIFIER).value;this.functionNames.add(i),this.expect(y.LPAREN);const r=[];for(;!this.match(y.RPAREN)&&(this.skipNewlines(),!this.match(y.RPAREN));){let n=null;for(;this.peek().type===y.IDENTIFIER&&this.peek(1).type===y.IDENTIFIER&&this.peek(2).type!==y.LPAREN;)n&&(n+=" "),n=(n||"")+this.advance().value;const o=this.expect(y.IDENTIFIER).value,u=new lt(o);if(n&&(u.varType=n),this.match(y.OPERATOR,"=")){this.advance(),this.skipNewlines();const c=this.parseExpression();r.push(new Gi(u,c))}else r.push(u);this.match(y.COMMA)&&this.advance()}this.expect(y.RPAREN),this.skipNewlines(),this.expect(y.OPERATOR,"=>"),this.skipNewlines();const s=this.parseFunctionBody(),a=new lt(i);return e&&(a.returnType=e),new Wi(a,r,s,e)}parseMethodDeclaration(){this.expect(y.KEYWORD,"method");let e=null;this.peek().type===y.IDENTIFIER&&this.peek(1).type===y.IDENTIFIER&&this.peek(2).type===y.LPAREN&&(e=this.advance().value);const i=this.expect(y.IDENTIFIER).value;this.expect(y.LPAREN);const r=[];for(;!this.match(y.RPAREN)&&(this.skipNewlines(),!this.match(y.RPAREN));){let n=null;for(;this.peek().type===y.IDENTIFIER&&this.peek(1).type===y.IDENTIFIER&&this.peek(2).type!==y.LPAREN;)n&&(n+=" "),n=(n||"")+this.advance().value;const o=this.expect(y.IDENTIFIER).value,u=new lt(o);if(n&&(u.varType=n),this.match(y.OPERATOR,"=")){this.advance(),this.skipNewlines();const c=this.parseExpression();r.push(new Gi(u,c))}else r.push(u);this.match(y.COMMA)&&this.advance()}this.expect(y.RPAREN),this.skipNewlines(),this.expect(y.OPERATOR,"=>"),this.skipNewlines();const s=this.parseFunctionBody(),a=new lt(i);return e&&(a.returnType=e),a.isMethod=!0,new Wi(a,r,s,e)}parseFunctionBody(){const e=[];if(!this.match(y.INDENT)){const i=this.parseExpression();return new Wt([new $i(i)])}for(this.advance();!this.match(y.DEDENT)&&!this.match(y.EOF)&&(this.skipNewlines(),!this.match(y.DEDENT));){const i=this.parseStatementOrSequence();Array.isArray(i)?e.push(...i):i&&e.push(i)}if(this.match(y.DEDENT)&&this.advance(),e.length>0){const i=e[e.length-1];i.type==="ExpressionStatement"&&(e[e.length-1]=new $i(i.expression))}return new Wt(e)}parseStatementOrSequence(){this.pos;const e=this.peek().line;if(this.match(y.KEYWORD,"if")){const r=this.parseIfStatement();return r&&(r._line=e),r}if(this.match(y.KEYWORD,"for"))return this.parseForStatement();if(this.match(y.KEYWORD,"while"))return this.parseWhileStatement();if(this.match(y.KEYWORD,"break")||this.match(y.KEYWORD,"continue")){const r=this.advance().value;return new yt(new lt(r))}if(this.match(y.KEYWORD,"var")||this.match(y.KEYWORD,"varip"))return this.parseVarDeclaration();if(this.isTupleDestructuring())return this.parseTupleDestructuring();if(this.peek().type===y.IDENTIFIER&&this.isTypedVarDeclaration())return this.parseTypedVarDeclaration();const i=[];for(;;){const r=this.parseExpression();if(this.match(y.OPERATOR)){const s=this.peek().value;if(["=",":=","+=","-=","*=","/=","%="].includes(s)){this.advance(),this.skipNewlines(!0);const a=this.parseExpression();if(s==="="&&r.type==="Identifier"?i.push(new Ut([new Gt(r,a)],Qt.LET)):i.push(new yt(new ze(s===":="?"=":s,r,a))),this.match(y.COMMA)){this.advance(),this.skipNewlines();continue}break}else{if(i.length>0)i.push(new yt(r));else return new yt(r);break}}else if(this.match(y.COMMA)){i.push(new yt(r)),this.advance(),this.skipNewlines();continue}else{if(i.length>0)i.push(new yt(r));else return new yt(r);break}}return i.length>1?i:i.length===1?i[0]:null}parseIfStatement(){this.expect(y.KEYWORD,"if");const e=this.parseExpression();this.skipNewlines();const i=this.parseBlock();let r=null;return this.skipNewlines(),this.match(y.KEYWORD,"else")&&(this.advance(),this.skipNewlines(),this.match(y.KEYWORD,"if")?r=this.parseIfStatement():r=this.parseBlock()),new ra(e,i,r)}parseForStatement(){this.expect(y.KEYWORD,"for");let e=null,i=!1;if(this.match(y.LBRACKET)){this.advance();const r=[];for(;!this.match(y.RBRACKET);)this.skipNewlines(),r.push(new lt(this.expect(y.IDENTIFIER).value)),this.match(y.COMMA)&&this.advance();this.expect(y.RBRACKET),e=new Ui(r),i=!0}else{const r=this.expect(y.IDENTIFIER).value;e=new lt(r)}if(this.match(y.KEYWORD,"in")){this.advance();const r=this.parseExpression();this.skipNewlines();const s=this.parseBlock(),a=new Ut([new Gt(e,r)],Qt.CONST),n=new ji(a,null,null,s);return n.isForIn=!0,n}else{if(i)throw new Error(`Range-based for loops don't support destructuring at ${this.peek().line}:${this.peek().column}`);this.expect(y.OPERATOR,"=");const r=this.parseExpression();this.expect(y.KEYWORD,"to");const s=this.parseExpression();let a=null;this.match(y.KEYWORD,"by")&&(this.advance(),a=this.parseExpression()),this.skipNewlines();const n=this.parseBlock(),o=new Ut([new Gt(e,r)],Qt.LET),u=new Kt("<=",e,s),c=a?new ze("+=",e,a):new na("++",e);return new ji(o,u,c,n)}}parseWhileStatement(){this.expect(y.KEYWORD,"while");const e=this.parseExpression();this.skipNewlines();const i=this.parseBlock();return new sa(e,i)}parseBlock(){if(!this.match(y.INDENT)){const r=this.parseStatement();return new Wt(r?[r]:[])}const e=this.peek().indent;this.advance();const i=[];for(;!this.match(y.EOF);){if(this.skipNewlines(),this.match(y.DEDENT)){if(this.peek().indent<e)break;this.advance();continue}if(this.match(y.EOF))break;const r=this.parseStatement();r&&i.push(r)}return this.match(y.DEDENT)&&this.peek().indent<e&&this.advance(),new Wt(i)}isTupleDestructuring(){if(!this.match(y.LBRACKET))return!1;let e=1;for(;;){for(;this.peek(e).type===y.NEWLINE;)e++;if(this.peek(e).type!==y.IDENTIFIER)return!1;for(e++;this.peek(e).type===y.NEWLINE;)e++;if(this.peek(e).type===y.RBRACKET){e++;break}else if(this.peek(e).type===y.COMMA){e++;continue}else return!1}for(;this.peek(e).type===y.NEWLINE;)e++;return this.peek(e).type===y.OPERATOR&&this.peek(e).value==="="}parseTupleDestructuring(){this.expect(y.LBRACKET);const e=[];for(;!this.match(y.RBRACKET);){this.skipNewlines();let r=this.expect(y.IDENTIFIER).value;this.functionNames.has(r)&&(r=r+"_var"),e.push(new lt(r)),this.match(y.COMMA)&&this.advance()}this.expect(y.RBRACKET),this.skipNewlines(),this.expect(y.OPERATOR,"="),this.skipNewlines(!0);const i=this.parseExpression();return new Ut([new Gt(new Ui(e),i)],Qt.CONST)}parseExpression(){return this.parseTernary()}parseTernary(){let e=this.parseLogicalOr();if(this.matchEx(y.OPERATOR,"?",!0)){this.advance(),this.skipNewlines(!0);const i=this.parseExpression();this.matchEx(y.COLON,null,!0)?this.advance():this.expect(y.COLON),this.skipNewlines(!0);const r=this.parseExpression();return new he(e,i,r)}return e}parseLogicalOr(){let e=this.parseLogicalAnd();for(;this.matchEx(y.KEYWORD,"or",!0)||this.matchEx(y.OPERATOR,null,!0)&&this.peek().value==="||";){this.advance(),this.skipNewlines(!0);const i=this.parseLogicalAnd();e=new Kt("||",e,i)}return e}parseLogicalAnd(){let e=this.parseEquality();for(;this.matchEx(y.KEYWORD,"and",!0)||this.matchEx(y.OPERATOR,null,!0)&&this.peek().value==="&&";){this.advance(),this.skipNewlines();const i=this.parseEquality();e=new Kt("&&",e,i)}return e}parseEquality(){let e=this.parseComparison();for(;this.matchEx(y.OPERATOR,null,!0);){const i=this.peek().value;if(!["==","!="].includes(i))break;this.advance(),this.skipNewlines(!0);const r=this.parseComparison();e=new Kt(i,e,r)}return e}parseComparison(){let e=this.parseAdditive();for(;this.matchEx(y.OPERATOR,null,!0);){const i=this.peek().value;if(!["<",">","<=",">="].includes(i))break;this.advance(),this.skipNewlines();const r=this.parseAdditive();e=new Kt(i,e,r)}return e}parseAdditive(){let e=this.parseMultiplicative();for(;this.matchEx(y.OPERATOR,null,!0);){const i=this.peek().value;if(!["+","-"].includes(i))break;this.advance(),this.skipNewlines(!0);const r=this.parseMultiplicative();e=new Kt(i,e,r)}return e}parseMultiplicative(){let e=this.parseUnary();for(;this.matchEx(y.OPERATOR,null,!0);){const i=this.peek().value;if(!["*","/","%"].includes(i))break;this.advance(),this.skipNewlines(!0);const r=this.parseUnary();e=new Kt(i,e,r)}return e}parseUnary(){if(this.match(y.OPERATOR)){const e=this.peek().value;if(["+","-","!"].includes(e))return this.advance(),this.skipNewlines(),new qi(e,this.parseUnary())}return this.match(y.KEYWORD,"not")?(this.advance(),this.skipNewlines(),new qi("!",this.parseUnary())):this.parsePostfix()}parsePostfix(){let e=this.parsePrimary();for(;;)if(this.match(y.OPERATOR,"<")){const i=this.pos;this.advance();let r=1,s=!0;for(;r>0&&!this.match(y.EOF);)if(this.match(y.OPERATOR,"<"))r++,this.advance();else if(this.match(y.OPERATOR,">"))r--,this.advance();else if(this.match(y.IDENTIFIER)||this.match(y.COMMA))this.advance();else{s=!1,this.pos=i;break}if(s&&this.match(y.LPAREN)){e=this.parseCallExpression(e);continue}else{if(s)continue;break}}else if(this.match(y.LPAREN))e=this.parseCallExpression(e);else if(this.match(y.DOT)){this.advance(),this.skipNewlines();const i=this.expect(y.IDENTIFIER).value;e=new Hi(e,new lt(i),!1)}else if(this.match(y.LBRACKET)){this.advance(),this.skipNewlines();const i=this.parseExpression();this.expect(y.RBRACKET),e=new Hi(e,i,!0)}else break;return e}parseCallExpression(e){this.expect(y.LPAREN);const i=[],r=[];for(;!this.match(y.RPAREN)&&(this.skipNewlines(),!this.match(y.RPAREN));){if((this.peek().type===y.IDENTIFIER||this.peek().type===y.KEYWORD)&&this.peek(1).type===y.OPERATOR&&this.peek(1).value==="="){const s=this.advance().value;this.advance(),this.skipNewlines();const a=this.parseExpression();r.push(new ca(new lt(s),a))}else i.push(this.parseExpression());this.match(y.COMMA)&&this.advance(),this.skipNewlines()}return this.expect(y.RPAREN),r.length>0&&i.push(new ua(r)),new aa(e,i)}parsePrimary(){const e=this.peek();if(this.match(y.NUMBER)){const i=this.advance();return new ie(i.value)}if(this.match(y.STRING)){const i=this.advance();return new ie(i.value)}if(this.match(y.BOOLEAN)){const i=this.advance();return new ie(i.value)}if(this.match(y.IDENTIFIER)){let i=this.advance().value;return this.functionNames.has(i)&&this.peek().type!==y.LPAREN&&(i=i+"_var"),new lt(i)}if(this.match(y.LBRACKET))return this.parseArrayLiteral();if(this.match(y.LPAREN)){this.advance(),this.skipNewlines();const i=this.parseExpression();return this.skipNewlines(),this.expect(y.RPAREN),i}if(this.match(y.KEYWORD,"if"))return this.parseIfExpression();if(this.match(y.KEYWORD,"switch"))return this.parseSwitchExpression();throw new Error(`Unexpected token ${e.type} '${e.value}' at ${e.line}:${e.column}`)}parseArrayLiteral(){this.expect(y.LBRACKET);const e=[];for(;!this.match(y.RBRACKET)&&(this.skipNewlines(),!this.match(y.RBRACKET));)e.push(this.parseExpression()),this.match(y.COMMA)&&this.advance(),this.skipNewlines();return this.expect(y.RBRACKET),new oa(e)}parseIfExpression(){this.expect(y.KEYWORD,"if");const e=this.parseExpression();this.skipNewlines(),this.expect(y.INDENT);const i=[];for(;!this.match(y.DEDENT)&&!this.match(y.EOF)&&(this.skipNewlines(),!this.match(y.DEDENT));){const n=this.parseStatement();n&&i.push(n)}this.advance();let r=[];if(this.match(y.KEYWORD,"else"))if(this.advance(),this.skipNewlines(),this.match(y.KEYWORD,"if")){const n=this.parseIfExpression();if(this.needsIIFE(i,r)){const o=new he(e,new Wt(i),n);return o.needsIIFE=!0,o.consequentStmts=i,o.alternateExpr=n,o}else return new he(e,this.getBlockValue(i),n)}else{for(this.expect(y.INDENT);!this.match(y.DEDENT)&&!this.match(y.EOF)&&(this.skipNewlines(),!this.match(y.DEDENT));){const n=this.parseStatement();n&&r.push(n)}this.advance()}if(this.needsIIFE(i,r)){const n=new he(e,new Wt(i),new Wt(r));return n.needsIIFE=!0,n.consequentStmts=i,n.alternateStmts=r,n}const s=this.getBlockValue(i),a=r.length>0?this.getBlockValue(r):new ie(null);return new he(e,s,a)}needsIIFE(e,i){if(e.length>1||i.length>1)return!0;const r=s=>s.some(a=>a.type==="IfStatement"||a.type==="ForStatement"||a.type==="WhileStatement"||a.type==="BlockStatement");return r(e)||r(i)}parseSwitchExpression(){this.expect(y.KEYWORD,"switch");let e=null;!this.match(y.NEWLINE)&&!this.match(y.INDENT)&&(e=this.parseExpression()),this.skipNewlines(),this.expect(y.INDENT);const i=[];for(;!this.match(y.DEDENT)&&!this.match(y.EOF)&&(this.skipNewlines(),!this.match(y.DEDENT));){let r=null;this.match(y.OPERATOR,"=>")||(r=this.parseExpression()),this.expect(y.OPERATOR,"=>"),this.skipNewlines();const s=[];if(this.match(y.INDENT)){for(this.advance();!this.match(y.DEDENT)&&!this.match(y.EOF)&&(this.skipNewlines(),!this.match(y.DEDENT));){const n=this.parseStatement();n&&s.push(n)}this.advance()}else s.push(new yt(this.parseExpression()));const a=this.getBlockValue(s);i.push(new la(r,a,s)),this.skipNewlines()}return this.advance(),new ha(e,i)}getBlockValue(e){if(e.length===0)return new ie(null);const i=e[e.length-1];return i.type==="ExpressionStatement"?i.expression:i.type==="VariableDeclaration"&&i.declarations.length>0?i.declarations[0].id:new ie(null)}}var ma=Object.defineProperty,ga=(t,e,i)=>e in t?ma(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,zt=(t,e,i)=>ga(t,typeof e!="symbol"?e+"":e,i);class xa{constructor(e={}){zt(this,"indent"),zt(this,"indentStr"),zt(this,"output"),zt(this,"sourceCode"),zt(this,"sourceLines"),zt(this,"lastCommentedLine"),zt(this,"includeSourceComments"),this.indent=0,this.indentStr=e.indentStr||" ",this.output=[],this.sourceCode=e.sourceCode||null,this.sourceLines=this.sourceCode?this.sourceCode.split(`
|
|
58
|
+
`):[],this.lastCommentedLine=-1,this.includeSourceComments=e.includeSourceComments||!1}generate(e){if(this.output=[],this.indent=0,this.lastCommentedLine=-1,e.type==="Program")this.generateProgram(e);else throw new Error(`Expected Program node, got ${e.type}`);return this.output.join("")}writeSourceComment(e,i=null){if(!this.sourceLines.length)return;const r=i||e,s=[];for(let a=e-1;a<r&&a<this.sourceLines.length;a++)if(a>this.lastCommentedLine){const n=this.sourceLines[a].trim();n&&!n.startsWith("//@")&&!n.startsWith("//")&&s.push(this.sourceLines[a])}if(s.length>0){for(const a of s)this.write(this.indentStr.repeat(this.indent)),this.write("/// "),this.write(a.trimEnd()),this.write(`
|
|
59
|
+
`);this.lastCommentedLine=Math.max(this.lastCommentedLine,r-1)}}write(e){this.output.push(e)}writeLine(e=""){e?this.output.push(this.indentStr.repeat(this.indent)+e+`
|
|
60
|
+
`):this.output.push(`
|
|
61
|
+
`)}increaseIndent(){this.indent++}decreaseIndent(){this.indent--}generateProgram(e){for(let i=0;i<e.body.length;i++)if(this.generateStatement(e.body[i]),i<e.body.length-1){const r=e.body[i],s=e.body[i+1];(r.type==="FunctionDeclaration"||r.type==="TypeDefinition")&&(s.type==="FunctionDeclaration"||s.type==="TypeDefinition")&&this.writeLine()}}generateStatement(e){switch(this.includeSourceComments&&e._line&&this.sourceLines.length>0&&this.writeSourceComment(e._line),e.type){case"FunctionDeclaration":return this.generateFunctionDeclaration(e);case"VariableDeclaration":return this.generateVariableDeclaration(e);case"ExpressionStatement":return this.generateExpressionStatement(e);case"IfStatement":return this.generateIfStatement(e);case"ForStatement":return this.generateForStatement(e);case"WhileStatement":return this.generateWhileStatement(e);case"ReturnStatement":return this.generateReturnStatement(e);case"BlockStatement":return this.generateBlockStatement(e);case"TypeDefinition":return this.generateTypeDefinition(e);default:throw new Error(`Unknown statement type: ${e.type}`)}}generateTypeDefinition(e){if(this.write(this.indentStr.repeat(this.indent)),this.write(`const ${e.name} = Type({`),e.fields.length>0){this.write(" ");for(let i=0;i<e.fields.length;i++){const r=e.fields[i];this.write(`${r.name}: '${r.type}'`),i<e.fields.length-1&&this.write(", ")}this.write(" ")}this.write(`});
|
|
62
|
+
`)}generateFunctionDeclaration(e){this.write(this.indentStr.repeat(this.indent));const i=e.id.isMethod;this.write("function "),this.write(e.id.name),this.write("(");const r=e.params,s=i&&r.length>0&&r[0].type==="Identifier"&&r[0].name==="this"?1:0;for(let a=s;a<r.length;a++){const n=r[a];if(n.type==="Identifier")this.write(n.name);else if(n.type==="AssignmentPattern"){const o=n.left.name==="this"&&i?"self":n.left.name;this.write(o),this.write(" = "),this.generateExpression(n.right)}a<r.length-1&&this.write(", ")}this.write(") "),this.generateBlockStatement(e.body,!1),this.write(`
|
|
63
|
+
`)}generateVariableDeclaration(e){const i=e.kind==="var"||e.kind==="varip"?"var":"let";for(let r=0;r<e.declarations.length;r++){const s=e.declarations[r];if(s.init&&s.init.type==="ConditionalExpression"&&s.init.needsIIFE){const a=s.id.type==="Identifier"?s.id.name:null;if(a){this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" "),this.write(a),this.write(`;
|
|
64
|
+
`),this.generateIfStatementWithAssignment(s.init,a);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 a=0;a<s.id.elements.length;a++)this.write(s.id.elements[a].name),a<s.id.elements.length-1&&this.write(", ");this.write("]")}s.init&&(this.write(" = "),this.generateExpression(s.init)),this.write(`;
|
|
65
|
+
`)}}generateExpressionStatement(e){this.write(this.indentStr.repeat(this.indent)),this.generateExpression(e.expression),this.write(`;
|
|
66
|
+
`)}generateIfStatement(e){this.write(this.indentStr.repeat(this.indent)),this.write("if ("),this.generateExpression(e.test),this.write(") "),this.generateBlockStatement(e.consequent,!1),e.alternate?(this.write(" else "),e.alternate.type==="IfStatement"?this.generateIfStatement(e.alternate):this.generateBlockStatement(e.alternate,!1)):this.write(`
|
|
67
|
+
`)}generateIfStatementWithAssignment(e,i){if(this.write(this.indentStr.repeat(this.indent)),this.write("if ("),this.generateExpression(e.test),this.write(`) {
|
|
68
|
+
`),this.indent++,e.consequentStmts)for(let r=0;r<e.consequentStmts.length;r++){const s=e.consequentStmts[r];r===e.consequentStmts.length-1?s.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" = "),this.generateExpression(s.expression),this.write(`;
|
|
69
|
+
`)):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("}"),e.alternateExpr)this.write(` else {
|
|
70
|
+
`),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" = "),this.generateExpression(e.alternateExpr),this.write(`;
|
|
71
|
+
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}");else if(e.alternateStmts&&e.alternateStmts.length>0){this.write(` else {
|
|
72
|
+
`),this.indent++;for(let r=0;r<e.alternateStmts.length;r++){const s=e.alternateStmts[r];r===e.alternateStmts.length-1?s.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" = "),this.generateExpression(s.expression),this.write(`;
|
|
73
|
+
`)):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 {
|
|
74
|
+
`),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(` = false;
|
|
75
|
+
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}");this.write(`
|
|
76
|
+
`)}generateNestedIfWithAssignments(e,i){if(this.write(this.indentStr.repeat(this.indent)),this.write("if ("),this.generateExpression(e.test),this.write(`) {
|
|
77
|
+
`),this.indent++,e.consequent.type==="BlockStatement"&&e.consequent.body.length>0)for(let r=0;r<e.consequent.body.length;r++){const s=e.consequent.body[r];r===e.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(`;
|
|
78
|
+
`)):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("}"),e.alternate)if(e.alternate.type==="IfStatement"){if(this.write(" else "),this.write("if ("),this.generateExpression(e.alternate.test),this.write(`) {
|
|
79
|
+
`),this.indent++,e.alternate.consequent.type==="BlockStatement"&&e.alternate.consequent.body.length>0)for(let r=0;r<e.alternate.consequent.body.length;r++){const s=e.alternate.consequent.body[r];r===e.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(`;
|
|
80
|
+
`)):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(e.alternate.alternate,i)}else if(e.alternate.type==="BlockStatement"&&e.alternate.body.length>0){this.write(` else {
|
|
81
|
+
`),this.indent++;for(let r=0;r<e.alternate.body.length;r++){const s=e.alternate.body[r];r===e.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(`;
|
|
82
|
+
`)):s.type==="IfStatement"?this.generateNestedIfWithAssignments(s,i):this.generateStatement(s):this.generateStatement(s)}this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write(`}
|
|
83
|
+
`)}else this.write(` else {
|
|
84
|
+
`),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(` = false;
|
|
85
|
+
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write(`}
|
|
86
|
+
`);else this.write(`
|
|
87
|
+
`)}generateNestedIfAlternatesWithAssignments(e,i){if(e)if(e.type==="IfStatement"){if(this.write(" else "),this.write("if ("),this.generateExpression(e.test),this.write(`) {
|
|
88
|
+
`),this.indent++,e.consequent.type==="BlockStatement"&&e.consequent.body.length>0)for(let r=0;r<e.consequent.body.length;r++){const s=e.consequent.body[r];r===e.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(`;
|
|
89
|
+
`)):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(e.alternate,i)}else if(e.type==="BlockStatement"&&e.body.length>0){this.write(` else {
|
|
90
|
+
`),this.indent++;for(let r=0;r<e.body.length;r++){const s=e.body[r];r===e.body.length-1?s.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" = "),this.generateExpression(s.expression),this.write(`;
|
|
91
|
+
`)):s.type==="IfStatement"?this.generateNestedIfWithAssignments(s,i):this.generateStatement(s):this.generateStatement(s)}this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write(`}
|
|
92
|
+
`)}else this.write(` else {
|
|
93
|
+
`),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(` = false;
|
|
94
|
+
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write(`}
|
|
95
|
+
`)}generateForStatement(e){if(this.write(this.indentStr.repeat(this.indent)),e.isForIn){if(this.write("for ("),e.init&&e.init.type==="VariableDeclaration"){const i=e.init.declarations[0];if(this.write(`${e.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(e.body,!1);return}if(this.write("for ("),e.init)if(e.init.type==="VariableDeclaration"){const i=e.init.declarations[0];this.write(`${e.init.kind} ${i.id.name}`),i.init&&(this.write(" = "),this.generateExpression(i.init))}else this.generateExpression(e.init);this.write("; "),e.test&&this.generateExpression(e.test),this.write("; "),e.update&&(e.update.type==="AssignmentExpression"?(this.generateExpression(e.update.left),this.write(` ${e.update.operator} `),this.generateExpression(e.update.right)):this.generateExpression(e.update)),this.write(") "),this.generateBlockStatement(e.body,!1)}generateWhileStatement(e){this.write(this.indentStr.repeat(this.indent)),this.write("while ("),this.generateExpression(e.test),this.write(") "),this.generateBlockStatement(e.body,!1)}generateReturnStatement(e){this.write(this.indentStr.repeat(this.indent)),this.write("return"),e.argument&&(this.write(" "),this.generateExpression(e.argument)),this.write(`;
|
|
96
|
+
`)}generateBlockStatement(e,i=!0){this.write(`{
|
|
97
|
+
`),i?this.increaseIndent():this.indent++;for(const r of e.body)this.generateStatement(r);i?this.decreaseIndent():this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}"),i&&this.write(`
|
|
98
|
+
`)}generateExpression(e){switch(e.type){case"Identifier":return this.write(e.name);case"Literal":return this.generateLiteral(e);case"BinaryExpression":case"LogicalExpression":return this.generateBinaryExpression(e);case"UnaryExpression":return this.generateUnaryExpression(e);case"AssignmentExpression":return this.generateAssignmentExpression(e);case"UpdateExpression":return this.generateUpdateExpression(e);case"CallExpression":return this.generateCallExpression(e);case"MemberExpression":return this.generateMemberExpression(e);case"ConditionalExpression":return this.generateConditionalExpression(e);case"ArrayExpression":return this.generateArrayExpression(e);case"ObjectExpression":return this.generateObjectExpression(e);case"SwitchExpression":return this.generateSwitchExpression(e);case"SequenceExpression":return this.generateSequenceExpression(e);default:throw new Error(`Unknown expression type: ${e.type}`)}}generateLiteral(e){if(typeof e.value=="string"){const i=e.value.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");this.write(`'${i}'`)}else e.value===null?this.write("null"):this.write(String(e.value))}generateBinaryExpression(e){const i=this.getPrecedence(e);this.getPrecedence(e.left)<i?(this.write("("),this.generateExpression(e.left),this.write(")")):this.generateExpression(e.left),this.write(" ");let r=e.operator;r==="and"?r="&&":r==="or"&&(r="||"),this.write(r),this.write(" ");const s=this.getPrecedence(e.right);let a=s<i;s===i&&(r==="-"||r==="/"||r==="%")&&(a=!0),a?(this.write("("),this.generateExpression(e.right),this.write(")")):this.generateExpression(e.right)}generateUnaryExpression(e){let i=e.operator;i==="not"&&(i="!"),this.write(i),this.getPrecedence(e.argument)<15?(this.write("("),this.generateExpression(e.argument),this.write(")")):this.generateExpression(e.argument)}generateAssignmentExpression(e){this.generateExpression(e.left),this.write(" ");let i=e.operator;i===":="&&(i="="),this.write(i),this.write(" "),this.generateExpression(e.right)}generateUpdateExpression(e){e.prefix?(this.write(e.operator),this.generateExpression(e.argument)):(this.generateExpression(e.argument),this.write(e.operator))}generateCallExpression(e){this.getPrecedence(e.callee)<19?(this.write("("),this.generateExpression(e.callee),this.write(")")):this.generateExpression(e.callee),this.write("(");for(let i=0;i<e.arguments.length;i++){const r=e.arguments[i];r.type==="AssignmentExpression"&&r.operator==="="?this.generateExpression(r.right):this.generateExpression(r),i<e.arguments.length-1&&this.write(", ")}this.write(")")}generateMemberExpression(e){this.getPrecedence(e.object)<19?(this.write("("),this.generateExpression(e.object),this.write(")")):this.generateExpression(e.object),e.computed?(this.write("["),this.generateExpression(e.property),this.write("]")):(this.write("."),this.generateExpression(e.property))}generateConditionalExpression(e){if(e.needsIIFE){this.generateIIFEConditional(e);return}this.write("("),this.generateExpression(e.test),this.write(" ? "),this.generateExpression(e.consequent),this.write(" : "),this.generateExpression(e.alternate),this.write(")")}generateIIFEConditional(e){this.write(`(() => {
|
|
99
|
+
`),this.indent++,this.generateIIFEIfBlock(e),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("})()")}generateIIFEIfBlock(e){if(this.write(this.indentStr.repeat(this.indent)),this.write("if ("),this.generateExpression(e.test),this.write(`) {
|
|
100
|
+
`),this.indent++,e.consequentStmts)for(let i=0;i<e.consequentStmts.length;i++){const r=e.consequentStmts[i];i===e.consequentStmts.length-1?r.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write("return "),this.generateExpression(r.expression),this.write(`;
|
|
101
|
+
`)):r.type==="IfStatement"?this.generateNestedIfWithReturns(r):this.generateStatement(r):this.generateStatement(r)}if(this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}"),e.alternateExpr)this.write(` else {
|
|
102
|
+
`),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write("return "),this.generateExpression(e.alternateExpr),this.write(`;
|
|
103
|
+
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}");else if(e.alternateStmts&&e.alternateStmts.length>0){this.write(` else {
|
|
104
|
+
`),this.indent++;for(let i=0;i<e.alternateStmts.length;i++){const r=e.alternateStmts[i];i===e.alternateStmts.length-1?r.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write("return "),this.generateExpression(r.expression),this.write(`;
|
|
105
|
+
`)):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 {
|
|
106
|
+
`),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write(`return false;
|
|
107
|
+
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}");this.write(`
|
|
108
|
+
`)}generateNestedIfWithReturns(e){if(this.write(this.indentStr.repeat(this.indent)),this.write("if ("),this.generateExpression(e.test),this.write(`) {
|
|
109
|
+
`),this.indent++,e.consequent.type==="BlockStatement"&&e.consequent.body.length>0)for(let i=0;i<e.consequent.body.length;i++){const r=e.consequent.body[i];i===e.consequent.body.length-1?r.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write("return "),this.generateExpression(r.expression),this.write(`;
|
|
110
|
+
`)):r.type==="IfStatement"?this.generateNestedIfWithReturns(r):this.generateStatement(r):this.generateStatement(r)}if(this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}"),e.alternate)if(e.alternate.type==="IfStatement"){if(this.write(" else "),this.write("if ("),this.generateExpression(e.alternate.test),this.write(`) {
|
|
111
|
+
`),this.indent++,e.alternate.consequent.type==="BlockStatement"&&e.alternate.consequent.body.length>0)for(let i=0;i<e.alternate.consequent.body.length;i++){const r=e.alternate.consequent.body[i];i===e.alternate.consequent.body.length-1?r.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write("return "),this.generateExpression(r.expression),this.write(`;
|
|
112
|
+
`)):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(e.alternate.alternate)}else if(e.alternate.type==="BlockStatement"&&e.alternate.body.length>0){this.write(` else {
|
|
113
|
+
`),this.indent++;for(let i=0;i<e.alternate.body.length;i++){const r=e.alternate.body[i];i===e.alternate.body.length-1?r.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write("return "),this.generateExpression(r.expression),this.write(`;
|
|
114
|
+
`)):r.type==="IfStatement"?this.generateNestedIfWithReturns(r):this.generateStatement(r):this.generateStatement(r)}this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write(`}
|
|
115
|
+
`)}else this.write(` else {
|
|
116
|
+
`),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write(`return false;
|
|
117
|
+
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write(`}
|
|
118
|
+
`);else this.write(`
|
|
119
|
+
`)}generateNestedIfAlternates(e){if(e)if(e.type==="IfStatement"){if(this.write(" else "),this.write("if ("),this.generateExpression(e.test),this.write(`) {
|
|
120
|
+
`),this.indent++,e.consequent.type==="BlockStatement"&&e.consequent.body.length>0)for(let i=0;i<e.consequent.body.length;i++){const r=e.consequent.body[i];i===e.consequent.body.length-1?r.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write("return "),this.generateExpression(r.expression),this.write(`;
|
|
121
|
+
`)):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(e.alternate)}else if(e.type==="BlockStatement"&&e.body.length>0){this.write(` else {
|
|
122
|
+
`),this.indent++;for(let i=0;i<e.body.length;i++){const r=e.body[i];i===e.body.length-1?r.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write("return "),this.generateExpression(r.expression),this.write(`;
|
|
123
|
+
`)):r.type==="IfStatement"?this.generateNestedIfWithReturns(r):this.generateStatement(r):this.generateStatement(r)}this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write(`}
|
|
124
|
+
`)}else this.write(` else {
|
|
125
|
+
`),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write(`return false;
|
|
126
|
+
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write(`}
|
|
127
|
+
`)}generateNestedIfAsExpression(e){if(e.type==="IfStatement"){if(this.write("("),this.generateExpression(e.test),this.write(" ? "),e.consequent.type==="BlockStatement"&&e.consequent.body.length>0){const i=e.consequent.body[e.consequent.body.length-1];i.type==="ExpressionStatement"?this.generateExpression(i.expression):i.type==="IfStatement"&&this.generateNestedIfAsExpression(i)}if(this.write(" : "),e.alternate)if(e.alternate.type==="IfStatement")this.generateNestedIfAsExpression(e.alternate);else if(e.alternate.type==="BlockStatement"&&e.alternate.body.length>0){const i=e.alternate.body[e.alternate.body.length-1];i.type==="ExpressionStatement"&&this.generateExpression(i.expression)}else this.write("false");else this.write("false");this.write(")")}}generateArrayExpression(e){this.write("[");for(let i=0;i<e.elements.length;i++)this.generateExpression(e.elements[i]),i<e.elements.length-1&&this.write(", ");this.write("]")}generateObjectExpression(e){this.write("{");for(let i=0;i<e.properties.length;i++){const r=e.properties[i];r.key.type==="Identifier"?this.write(r.key.name):this.generateExpression(r.key),this.write(": "),this.generateExpression(r.value),i<e.properties.length-1&&this.write(", ")}this.write("}")}generateSwitchExpression(e){if(e.discriminant===null){this.generateSwitchAsIfElse(e);return}this.write(`(() => {
|
|
128
|
+
`),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write("switch ("),this.generateExpression(e.discriminant),this.write(`) {
|
|
129
|
+
`),this.indent++;for(const i of e.cases){if(this.write(this.indentStr.repeat(this.indent)),i.test?(this.write("case "),this.generateExpression(i.test),this.write(`:
|
|
130
|
+
`)):this.write(`default:
|
|
131
|
+
`),this.indent++,i.statements&&i.statements.length>0){const r=i.statements[i.statements.length-1];if(r.type==="ExpressionStatement"||r.type==="VariableDeclaration"){for(let s=0;s<i.statements.length-1;s++)this.write(this.indentStr.repeat(this.indent)),this.generateStatement(i.statements[s]);this.write(this.indentStr.repeat(this.indent)),this.write("return "),r.type==="ExpressionStatement"?this.generateExpression(r.expression):this.generateExpression(i.consequent),this.write(`;
|
|
132
|
+
`)}else{for(let s=0;s<i.statements.length;s++)this.write(this.indentStr.repeat(this.indent)),this.generateStatement(i.statements[s]);this.write(this.indentStr.repeat(this.indent)),this.write(`return null;
|
|
133
|
+
`)}}else this.write(this.indentStr.repeat(this.indent)),this.write("return "),this.generateExpression(i.consequent),this.write(`;
|
|
134
|
+
`);this.indent--}this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write(`}
|
|
135
|
+
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("})()")}generateSwitchAsIfElse(e){for(let i=0;i<e.cases.length;i++){const r=e.cases[i];if(r.test?(i===0?this.write("if ("):this.write(" else if ("),this.generateExpression(r.test),this.write(`) {
|
|
136
|
+
`)):i>0?this.write(` else {
|
|
137
|
+
`):this.write(`{
|
|
138
|
+
`),this.indent++,r.statements&&r.statements.length>0)for(const s of r.statements)this.write(this.indentStr.repeat(this.indent)),this.generateStatement(s);else this.write(this.indentStr.repeat(this.indent)),this.generateExpression(r.consequent),this.write(`;
|
|
139
|
+
`);this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}"),i<e.cases.length-1||this.write(`
|
|
140
|
+
`)}}generateSequenceExpression(e){this.write("(");for(let i=0;i<e.expressions.length;i++)this.generateExpression(e.expressions[i]),i<e.expressions.length-1&&this.write(", ");this.write(")")}getPrecedence(e){switch(e.type){case"Literal":case"Identifier":case"ArrayExpression":case"ObjectExpression":return 20;case"CallExpression":case"MemberExpression":return 19;case"UnaryExpression":case"UpdateExpression":return 15;case"BinaryExpression":case"LogicalExpression":switch(e.operator){case"*":case"/":case"%":return 13;case"+":case"-":return 12;case"<":case"<=":case">":case">=":return 10;case"==":case"!=":return 9;case"and":case"&&":return 5;case"or":case"||":return 4;default:return 0}case"ConditionalExpression":return 3;case"AssignmentExpression":case"AssignmentPattern":return 2;case"SequenceExpression":return 1;default:return 0}}}function Zr(t){const e=/^\s*\/\/\s*@version\s*=\s*(\d+)\s*$/im,i=t.match(e);return i&&i[1]?parseInt(i[1],10):null}function ya(t,e={}){const i=Zr(t);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 Xn(t).tokenize(),s=new fa(r).parse(),a={...e,sourceCode:t},n=new xa(a).generate(s);return{success:!0,version:i,code:n,ast:s,tokens:r}}catch(r){return{success:!1,version:i,error:r.message,stack:r.stack}}}function wa(t){if(typeof t=="function")return t.toString();{const e=Zr(t);if(e===null)return t;if(e>=5){const i=ya(t);if(i.success)return i.code;throw new Error(`Failed to transpile Pine Script version ${e}: ${i.error}`)}else throw new Error(`Unsupported Pine Script version ${e}. Only version 5 and above are supported.`)}}function va(t,e={debug:!1,ln:!1}){typeof e=="boolean"&&(e={debug:e,ln:!0});const{debug:i}=e;let r=wa(t);r=Rn(r);const s=i?r.split(`
|
|
141
|
+
`):[],a=Hr(r,{ecmaVersion:"latest",sourceType:"module",locations:i});Bn(a),Pn(a),Tn(a);const n=new Cn;Vn(a,n);const o=Mn(a,n)||"";Gn(a,n,o,e,s),Un(a);const u=wn||xi||void 0,c=Object.assign({},u,{LineComment(d,l){l.write("//"+d.value)}}),h=Gr(a,{generator:c,comments:i});return new Function("",`var _r = ${h}
|
|
142
|
+
; return _r;`)(this)}function ba(t){return e=>new K(e.array.map(i=>Math.abs(i)),e.type,t)}function _a(t){return e=>{let i=0,r=0;for(const s of e.array){const a=Number(s);isNaN(a)||(r++,i+=(a-i)/r)}return r===0?NaN:t.precision(i)}}function Ea(t){return(e,i)=>{const r=e.array;let s=0,a=r.length-1;for(;s<=a;){const n=Math.floor((s+a)/2),o=r[n];if(o===i)return n;o<i?s=n+1:a=n-1}return-1}}function Sa(t){return(e,i)=>{const r=e.array;let s=0,a=r.length;for(;s<a;){const n=Math.floor((s+a)/2);r[n]<i?s=n+1:a=n}return s<r.length&&r[s]===i?s:s-1}}function Ca(t){return(e,i)=>{const r=e.array;let s=0,a=r.length;for(;s<a;){const n=Math.floor((s+a)/2);r[n]<=i?s=n+1:a=n}return s>0&&r[s-1]===i?s-1:s}}function Na(t){return e=>{e.array.length=0}}function Aa(t){return(e,i)=>(e.array.push(...i.array),e)}function Ia(t){return e=>new K([...e.array],e.type,t)}function ka(t){return(e,i,r=!0)=>{const s=e.array,a=i.array;if(s.length!==a.length)return NaN;let n=0,o=0,u=0;const c=[];for(let x=0;x<s.length;x++){const E=Number(s[x]),S=Number(a[x]);!isNaN(E)&&E!==null&&E!==void 0&&!isNaN(S)&&S!==null&&S!==void 0&&(n+=E,o+=S,u++,c.push(x))}if(u===0)return NaN;const h=n/u,d=o/u;let l=0;for(const x of c){const E=Number(s[x]),S=Number(a[x]);l+=(E-h)*(S-d)}const m=r?u:u-1;return m<=0?NaN:t.precision(l/m)}}function Da(t){return e=>e.array.every(i=>!isNaN(i)&&i)}function Ta(t){return t.every(e=>typeof e=="number")?t.every(e=>(e|0)===e)?Q.int:Q.float:t.every(e=>typeof e=="string")?Q.string:t.every(e=>typeof e=="boolean")?Q.bool:Q.any}function kt(t){if(typeof t=="number")return(t|0)===t?Q.int:Q.float;if(typeof t=="string")return Q.string;if(typeof t=="boolean")return Q.bool;throw new Error("Cannot infer type from value")}function ve(t,e){switch(e){case Q.int:return typeof t=="number"&&((t|0)===t||isNaN(t));case Q.float:return typeof t=="number";case Q.string:return typeof t=="string";case Q.bool:return typeof t=="boolean"}return!1}function Pa(t){return(e,i,r=0,s)=>{const a=e.array.length,n=s!==void 0?Math.min(s,a):a;for(let o=r;o<n;o++){if(!ve(i,e.type))throw new Error(`Cannot call 'array.fill' with argument 'value'='${i}'. An argument of 'literal ${typeof i}' type was used but a '${e.type}' is expected.`);e.array[o]=t.precision(i)}}}function Oa(t){return e=>e.array.length>0?e.array[0]:t.NA}function Fa(t){return(e,i)=>e.array[i]}function Ra(t){return(e,i)=>e.array.includes(i)}function Ba(t){return(e,i)=>e.array.indexOf(i)}function Va(t){return(e,i,r)=>{if(!ve(r,e.type))throw new Error(`Cannot call 'array.insert' with argument 'value'='${r}'. An argument of 'literal ${typeof r}' type was used but a '${e.type}' is expected.`);e.array.splice(i,0,r)}}function La(t){return(e,i=",")=>e.array.join(i)}function Ma(t){return e=>e.array.length>0?e.array[e.array.length-1]:t.NA}function Wa(t){return(e,i)=>e.array.lastIndexOf(i)}function ja(t){return(e,i=0)=>[...e.array].sort((r,s)=>s-r)[i]??t.NA}function $a(t){return e=>{if(e.array.length===0)return NaN;const i=[...e.array].sort((s,a)=>typeof s=="number"&&typeof a=="number"?s-a:0),r=Math.floor(i.length/2);return i.length%2!==0?i[r]:(i[r-1]+i[r])/2}}function qa(t){return(e,i=0)=>[...e.array].sort((r,s)=>r-s)[i]??t.NA}function Ha(t){return e=>{if(e.array.length===0)return NaN;const i=new Map;let r=0;for(const a of e.array){const n=(i.get(a)||0)+1;i.set(a,n),n>r&&(r=n)}const s=[];for(const[a,n]of i)n===r&&s.push(a);return s.sort((a,n)=>typeof a=="number"&&typeof n=="number"?a-n:typeof a=="string"&&typeof n=="string"?a<n?-1:a>n?1:0:0),s[0]}}function Ua(t){return(e,i)=>{const r=e.array;if(r.length===0)return NaN;const s=[];for(const u of r){const c=Number(u);if(isNaN(c)||c===null||c===void 0)return NaN;s.push(c)}s.sort((u,c)=>u-c),i<0&&(i=0),i>100&&(i=100);const a=i/100*s.length-.5;if(a<=0)return t.precision(s[0]);if(a>=s.length-1)return t.precision(s[s.length-1]);const n=Math.floor(a),o=a-n;return t.precision(s[n]*(1-o)+s[n+1]*o)}}function Ga(t){return(e,i)=>{const r=e.array;if(r.length===0)return NaN;const s=[];for(const o of r){const u=Number(o);!isNaN(u)&&u!==null&&u!==void 0&&s.push(u)}if(s.length===0)return NaN;s.sort((o,u)=>o-u),i<0&&(i=0),i>100&&(i=100);const a=r.length,n=Math.ceil(i/100*a);return n<=0?s[0]:n>s.length?NaN:s[n-1]}}function Ka(t){return(e,i)=>{if(e.array.length===0)return NaN;const r=Math.floor(i);if(r<0||r>=e.array.length)return NaN;const s=Number(e.array[r]);if(isNaN(s)||s===null||s===void 0)return NaN;let a=0;for(const o of e.array){const u=Number(o);!isNaN(u)&&u!==null&&u!==void 0&&u<s&&a++}const n=e.array.length-1;return n<=0?NaN:a/n*100}}function za(t){return e=>e.array.pop()}function Ya(t){return(e,i)=>{if(!ve(i,e.type))throw new Error(`Cannot call 'array.push' with argument 'value'='${i}'. An argument of 'literal ${typeof i}' type was used but a '${e.type}' is expected.`);e.array.push(t.precision(i))}}function Qa(t){return e=>t.precision(t.pine.array.max(e)-t.pine.array.min(e))}function Ja(t){return(e,i)=>i>=0&&i<e.array.length?e.array.splice(i,1)[0]:t.NA}function Xa(t){return e=>{e.array.reverse()}}function Za(t){return(e,i,r)=>{if(!ve(r,e.type))throw new Error(`Cannot call 'array.set' with argument 'value'='${r}'. An argument of 'literal ${typeof r}' type was used but a '${e.type}' is expected.`);e.array[i]=t.precision(r)}}function to(t){return e=>e.array.shift()}function eo(t){return e=>e.array.length}function io(t){return(e,i,r)=>{const s=r!==void 0?r:void 0;return new K(e.array.slice(i,s),e.type,t)}}function ro(t){return e=>e.array.some(i=>!isNaN(i)&&i)}var ne=(t=>(t[t.ascending=1]="ascending",t[t.descending=0]="descending",t))(ne||{}),ts=(t=>(t.AED="AED",t.ARS="ARS",t.AUD="AUD",t.BDT="BDT",t.BHD="BHD",t.BRL="BRL",t.BTC="BTC",t.CAD="CAD",t.CHF="CHF",t.CLP="CLP",t.CNY="CNY",t.COP="COP",t.CZK="CZK",t.DKK="DKK",t.EGP="EGP",t.ETH="ETH",t.EUR="EUR",t.GBP="GBP",t.HKD="HKD",t.HUF="HUF",t.IDR="IDR",t.ILS="ILS",t.INR="INR",t.ISK="ISK",t.JPY="JPY",t.KES="KES",t.KRW="KRW",t.KWD="KWD",t.LKR="LKR",t.MAD="MAD",t.MXN="MXN",t.MYR="MYR",t.NGN="NGN",t.NOK="NOK",t.NONE="NONE",t.NZD="NZD",t.PEN="PEN",t.PHP="PHP",t.PKR="PKR",t.PLN="PLN",t.QAR="QAR",t.RON="RON",t.RSD="RSD",t.RUB="RUB",t.SAR="SAR",t.SEK="SEK",t.SGD="SGD",t.THB="THB",t.TND="TND",t.TRY="TRY",t.TWD="TWD",t.USD="USD",t.USDT="USDT",t.VES="VES",t.VND="VND",t.ZAR="ZAR",t))(ts||{}),es=(t=>(t[t.sunday=1]="sunday",t[t.monday=2]="monday",t[t.tuesday=3]="tuesday",t[t.wednesday=4]="wednesday",t[t.thursday=5]="thursday",t[t.friday=6]="friday",t[t.saturday=7]="saturday",t))(es||{}),is=(t=>(t.all="all",t.data_window="data_window",t.none="none",t.pane="pane",t.price_scale="price_scale",t.status_line="status_line",t))(is||{}),rs=(t=>(t.flag="flag",t.arrowdown="arrowdown",t.arrowup="arrowup",t.circle="circle",t.cross="cross",t.diamond="diamond",t.labeldown="labeldown",t.labelup="labelup",t.square="square",t.triangledown="triangledown",t.triangleup="triangleup",t.xcross="xcross",t))(rs||{}),ss=(t=>(t.abovebar="abovebar",t.belowbar="belowbar",t.absolute="absolute",t.bottom="bottom",t.top="top",t))(ss||{}),ns=(t=>(t.auto="auto",t.tiny="tiny",t.small="small",t.normal="normal",t.large="large",t.huge="huge",t))(ns||{}),as=(t=>(t.inherit="inherit",t.mintick="mintick",t.percent="percent",t.price="price",t.volume="volume",t))(as||{}),so=(t=>(t.linestyle_dashed="linestyle_dashed",t.linestyle_dotted="linestyle_dotted",t.linestyle_solid="linestyle_solid",t.style_area="style_area",t.style_areabr="style_areabr",t.style_circles="style_circles",t.style_columns="style_columns",t.style_cross="style_cross",t.style_histogram="style_histogram",t.style_line="style_line",t.style_linebr="style_linebr",t.style_stepline="style_stepline",t.style_stepline_diamond="style_stepline_diamond",t.style_steplinebr="style_steplinebr",t))(so||{}),os=(t=>(t.gaps_on="gaps_on",t.gaps_off="gaps_off",t.lookahead_on="lookahead_on",t.lookahead_off="lookahead_off",t))(os||{});const no={order:ne,currency:ts,dayofweek:es,display:is,shape:rs,location:ss,size:ns,format:as,barmerge:os};function ao(t){return(e,i=ne.ascending)=>{e.array.sort((r,s)=>{let a=isNaN(r)?1/0:r,n=isNaN(s)?1/0:s;return i===ne.ascending?a-n:n-a})}}function oo(t){return(e,i=ne.ascending)=>{const r=e.array.map((s,a)=>a);return r.sort((s,a)=>{const n=isNaN(e.array[s])?1/0:e.array[s],o=isNaN(e.array[a])?1/0:e.array[a];return i===ne.ascending?n-o:o-n}),new K(r,Q.int,t)}}function uo(t){return e=>{const i=t.array.avg(e),r=t.array.stdev(e);return isNaN(r)?new K(e.array.map(()=>NaN),Q.int,t):r===0?new K(e.array.map(()=>1),Q.int,t):new K(e.array.map(s=>(s-i)/r),Q.int,t)}}function co(t){return(e,i=!0)=>{const r=e.array,s=r.length;if(s===0)return NaN;let a=0,n=0,o=0;for(let h=0;h<s;h++){const d=Number(r[h]);!isNaN(d)&&d!==null&&d!==void 0&&(a+=d,n+=d*d,o++)}if(o===0)return NaN;const u=a/o;let c=n/o-u*u;return c<0?NaN:(!i&&o>1&&(c=c*o/(o-1)),!i&&o===1?0:t.precision(Math.sqrt(c)))}}function ho(t){return e=>t.precision(e.array.reduce((i,r)=>{const s=Number(r);return isNaN(s)?i:i+s},0))}function lo(t){return(e,i)=>{if(!ve(i,e.type))throw new Error(`Cannot call 'array.unshift' with argument 'value'='${i}'. An argument of 'literal ${typeof i}' type was used but a '${e.type}' is expected.`);e.array.unshift(t.precision(i))}}function po(t){return(e,i=!0)=>{let r=0,s=0;for(const u of e.array){const c=Number(u);!isNaN(c)&&c!==null&&c!==void 0&&(r+=c,s++)}if(s===0)return NaN;const a=r/s;let n=0;for(const u of e.array){const c=Number(u);!isNaN(c)&&c!==null&&c!==void 0&&(n+=(c-a)*(c-a))}const o=i?s:s-1;return o<=0?NaN:t.precision(n/o)}}var fo=Object.defineProperty,mo=(t,e,i)=>e in t?fo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,L=(t,e,i)=>mo(t,typeof e!="symbol"?e+"":e,i),Q=(t=>(t.any="",t.box="box",t.bool="bool",t.color="color",t.float="float",t.int="int",t.label="label",t.line="line",t.linefill="linefill",t.string="string",t.table="table",t))(Q||{});class K{constructor(e,i,r){this.array=e,this.type=i,this.context=r,L(this,"_abs"),L(this,"_avg"),L(this,"_binary_search"),L(this,"_binary_search_leftmost"),L(this,"_binary_search_rightmost"),L(this,"_clear"),L(this,"_concat"),L(this,"_copy"),L(this,"_covariance"),L(this,"_every"),L(this,"_fill"),L(this,"_first"),L(this,"_get"),L(this,"_includes"),L(this,"_indexof"),L(this,"_insert"),L(this,"_join"),L(this,"_last"),L(this,"_lastindexof"),L(this,"_max"),L(this,"_median"),L(this,"_min"),L(this,"_mode"),L(this,"_percentile_linear_interpolation"),L(this,"_percentile_nearest_rank"),L(this,"_percentrank"),L(this,"_pop"),L(this,"_push"),L(this,"_range"),L(this,"_remove"),L(this,"_reverse"),L(this,"_set"),L(this,"_shift"),L(this,"_size"),L(this,"_slice"),L(this,"_some"),L(this,"_sort"),L(this,"_sort_indices"),L(this,"_standardize"),L(this,"_stdev"),L(this,"_sum"),L(this,"_unshift"),L(this,"_variance"),this._abs=ba(this.context),this._avg=_a(this.context),this._binary_search=Ea(this.context),this._binary_search_leftmost=Sa(this.context),this._binary_search_rightmost=Ca(this.context),this._clear=Na(this.context),this._concat=Aa(this.context),this._copy=Ia(this.context),this._covariance=ka(this.context),this._every=Da(this.context),this._fill=Pa(this.context),this._first=Oa(this.context),this._get=Fa(this.context),this._includes=Ra(this.context),this._indexof=Ba(this.context),this._insert=Va(this.context),this._join=La(this.context),this._last=Ma(this.context),this._lastindexof=Wa(this.context),this._max=ja(this.context),this._median=$a(this.context),this._min=qa(this.context),this._mode=Ha(this.context),this._percentile_linear_interpolation=Ua(this.context),this._percentile_nearest_rank=Ga(this.context),this._percentrank=Ka(this.context),this._pop=za(this.context),this._push=Ya(this.context),this._range=Qa(this.context),this._remove=Ja(this.context),this._reverse=Xa(this.context),this._set=Za(this.context),this._shift=to(this.context),this._size=eo(this.context),this._slice=io(this.context),this._some=ro(this.context),this._sort=ao(this.context),this._sort_indices=oo(this.context),this._standardize=uo(this.context),this._stdev=co(this.context),this._sum=ho(this.context),this._unshift=lo(this.context),this._variance=po(this.context)}toString(){return"["+this.array.toString().replace(/,/g,", ")+"]"}abs(...e){return this._abs(this,...e)}avg(...e){return this._avg(this,...e)}binary_search(...e){return this._binary_search(this,...e)}binary_search_leftmost(...e){return this._binary_search_leftmost(this,...e)}binary_search_rightmost(...e){return this._binary_search_rightmost(this,...e)}clear(...e){return this._clear(this,...e)}concat(...e){return this._concat(this,...e)}copy(...e){return this._copy(this,...e)}covariance(...e){return this._covariance(this,...e)}every(...e){return this._every(this,...e)}fill(...e){return this._fill(this,...e)}first(...e){return this._first(this,...e)}get(...e){return this._get(this,...e)}includes(...e){return this._includes(this,...e)}indexof(...e){return this._indexof(this,...e)}insert(...e){return this._insert(this,...e)}join(...e){return this._join(this,...e)}last(...e){return this._last(this,...e)}lastindexof(...e){return this._lastindexof(this,...e)}max(...e){return this._max(this,...e)}median(...e){return this._median(this,...e)}min(...e){return this._min(this,...e)}mode(...e){return this._mode(this,...e)}percentile_linear_interpolation(...e){return this._percentile_linear_interpolation(this,...e)}percentile_nearest_rank(...e){return this._percentile_nearest_rank(this,...e)}percentrank(...e){return this._percentrank(this,...e)}pop(...e){return this._pop(this,...e)}push(...e){return this._push(this,...e)}range(...e){return this._range(this,...e)}remove(...e){return this._remove(this,...e)}reverse(...e){return this._reverse(this,...e)}set(...e){return this._set(this,...e)}shift(...e){return this._shift(this,...e)}size(...e){return this._size(this,...e)}slice(...e){return this._slice(this,...e)}some(...e){return this._some(this,...e)}sort(...e){return this._sort(this,...e)}sort_indices(...e){return this._sort_indices(this,...e)}standardize(...e){return this._standardize(this,...e)}stdev(...e){return this._stdev(this,...e)}sum(...e){return this._sum(this,...e)}unshift(...e){return this._unshift(this,...e)}variance(...e){return this._variance(this,...e)}}function go(t){return(...e)=>new K([...e],Ta(e),t)}function xo(t){return(e,i)=>new K(Array(e).fill(t.precision(i||0)),kt(i||0),t)}function yo(t){return(e,i=!1)=>new K(Array(e).fill(i),Q.bool,t)}function wo(t){return(e,i=NaN)=>new K(Array(e).fill(t.precision(i)),Q.float,t)}function vo(t){return(e,i=0)=>new K(Array(e).fill(t.precision(i)),Q.int,t)}function bo(t){return(e,i="")=>new K(Array(e).fill(i),Q.string,t)}class w{constructor(e,i=0){this.data=e,this.offset=i}get(e){const i=this.data.length-1-(this.offset+e);return i<0||i>=this.data.length?NaN:this.data[i]}set(e,i){const r=this.data.length-1-(this.offset+e);r>=0&&r<this.data.length&&(this.data[r]=i)}get length(){return this.data.length}toArray(){return this.data}static from(e){return e instanceof w?e:Array.isArray(e)?new w(e):new w([e])}}function _o(t){return(e,i=0)=>w.from(e).get(i)}class Eo{constructor(e){this.context=e,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=go(e),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=xo(e),this.new_bool=yo(e),this.new_float=wo(e),this.new_int=vo(e),this.new_string=bo(e),this.param=_o(),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 So(t){return e=>{e.map.clear()}}function Co(t){return(e,i)=>e.map.has(i)}function No(t){return e=>{const i=new us(t);return i.map=new Map(e.map),i}}function Ao(t){return(e,i)=>{const r=e.map.get(i);return r===void 0?NaN:r}}function Io(t){return e=>{const i=Array.from(e.map.keys()),r=kt(i[0]);return new K(i,r,t)}}function ko(t){return(e,i,r)=>{const s=e.map.get(i);return e.map.set(i,r),s===void 0?NaN:s}}function Do(t){return(e,i)=>{for(const[r,s]of i.map)e.map.set(r,s)}}function To(t){return(e,i)=>{const r=e.map.get(i);return e.map.delete(i)?r:NaN}}function Po(t){return e=>e.map.size}function Oo(t){return e=>{const i=Array.from(e.map.values()),r=kt(i[0]);return new K(i,r,t)}}var Fo=Object.defineProperty,Ro=(t,e,i)=>e in t?Fo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ct=(t,e,i)=>Ro(t,typeof e!="symbol"?e+"":e,i);class us{constructor(e){this.context=e,Ct(this,"map"),Ct(this,"_clear"),Ct(this,"_contains"),Ct(this,"_copy"),Ct(this,"_get"),Ct(this,"_keys"),Ct(this,"_put"),Ct(this,"_put_all"),Ct(this,"_remove"),Ct(this,"_size"),Ct(this,"_values"),this.map=new Map,this._clear=So(this.context),this._contains=Co(this.context),this._copy=No(this.context),this._get=Ao(this.context),this._keys=Io(this.context),this._put=ko(this.context),this._put_all=Do(this.context),this._remove=To(this.context),this._size=Po(this.context),this._values=Oo(this.context)}toString(){return`PineMapObject(${this.map.size})`}clear(...e){return this._clear(this,...e)}contains(...e){return this._contains(this,...e)}copy(...e){return this._copy(this,...e)}get(...e){return this._get(this,...e)}keys(...e){return this._keys(this,...e)}put(...e){return this._put(this,...e)}put_all(...e){return this._put_all(this,...e)}remove(...e){return this._remove(this,...e)}size(...e){return this._size(this,...e)}values(...e){return this._values(this,...e)}}function Bo(t){return()=>new us(t)}function Vo(t){return(e,i=0)=>w.from(e).get(i)}class Lo{constructor(e){this.context=e,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=Bo(e),this.param=Vo(),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 Mo(t){return(e,i,r)=>{const s=e.matrix.length;let a=[];if(r&&(r instanceof K?a=r.array:Array.isArray(r)?a=r:a=[r]),s===0){for(let u=0;u<a.length;u++){let c=a[u];c instanceof w&&(c=c.get(0)),e.matrix.push([c])}return}const n=e.matrix[0].length,o=i!==void 0?i:n;for(let u=0;u<s;u++){let c=u<a.length?a[u]:NaN;c instanceof w&&(c=c.get(0)),e.matrix[u].splice(o,0,c)}}}function Wo(t){return(e,i,r)=>{const s=e.matrix.length;let a=[];if(r)if(r instanceof K)a=r.array;else if(Array.isArray(r))a=r;else if(r instanceof w){const c=r.get(0);Array.isArray(c)?a=c:a=[c]}else a=[r];const n=s>0?e.matrix[0].length:a.length,o=i!==void 0?i:s,u=[];for(let c=0;c<n;c++)if(c<a.length){let h=a[c];h instanceof w&&(h=h.get(0)),u.push(h)}else u.push(NaN);e.matrix.splice(o,0,u)}}function jo(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length;if(r===0)return NaN;let s=0,a=0;for(let n=0;n<i;n++)for(let o=0;o<r;o++){const u=e.matrix[n][o];isNaN(u)||(s+=u,a++)}return a===0?NaN:s/a}}function $o(t){return(e,i)=>{const r=e.matrix.length,s=[];for(let n=0;n<r;n++)s.push(e.matrix[n][i]);const a=kt(s[0]);return new K(s,a,t)}}function qo(t){return e=>e.matrix.length===0?0:e.matrix[0].length}function Ho(t){return(e,i)=>{const r=e.matrix.length,s=i.matrix.length;if(r===0){for(let o=0;o<s;o++)e.matrix.push([...i.matrix[o]]);return}const a=e.matrix[0].length,n=s>0?i.matrix[0].length:0;if(a!==n&&s>0){console.error(`matrix.concat: Column count mismatch ${a} vs ${n}`);return}for(let o=0;o<s;o++)e.matrix.push([...i.matrix[o]])}}function Uo(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0,s=new H(i,r,NaN,t);return s.matrix=e.matrix.map(a=>[...a]),s}}function Go(t){const e=t.length;if(e===0)return 0;if(e===1)return t[0][0];if(e===2)return t[0][0]*t[1][1]-t[0][1]*t[1][0];const i=t.map(s=>[...s]);let r=1;for(let s=0;s<e;s++){let a=s;for(;a<e&&i[a][s]===0;)a++;if(a===e)return 0;a!==s&&([i[s],i[a]]=[i[a],i[s]],r*=-1),r*=i[s][s];for(let n=s+1;n<e;n++){const o=i[n][s]/i[s][s];for(let u=s;u<e;u++)i[n][u]-=o*i[s][u]}}return r}function Ko(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;return i!==r?NaN:Go(e.matrix)}}function zo(t){return(e,i)=>{const r=e.matrix.length;if(r===0)return new H(0,0,NaN,t);const s=e.matrix[0].length,a=new H(r,s,NaN,t);if(i instanceof H)for(let n=0;n<r;n++)for(let o=0;o<s;o++){const u=e.matrix[n][o],c=i.matrix[n]&&i.matrix[n][o]!==void 0?i.matrix[n][o]:NaN;a.matrix[n][o]=u-c}else{const n=i;for(let o=0;o<r;o++)for(let u=0;u<s;u++)a.matrix[o][u]=e.matrix[o][u]-n}return a}}function Yo(t){const e=t.length;if(e!==2)return Array(e).fill(NaN);const i=t[0][0],r=t[0][1],s=t[1][0],a=t[1][1],n=i+a,o=i*a-r*s,u=n*n-4*o;if(u<0)return[NaN,NaN];const c=(n+Math.sqrt(u))/2,h=(n-Math.sqrt(u))/2;return[c,h]}function Qo(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r){const n=kt(e.matrix[0][0]);return new K([],n,t)}const s=Yo(e.matrix),a=kt(s[0]);return new K(s,a,t)}}function Jo(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r)return new H(0,0,NaN,t);const s=new H(i,r,0,t);for(let a=0;a<i;a++)s.matrix[a][a]=1;return s}}function Xo(t){return e=>{const i=e.matrix.length;return i===0?0:i*e.matrix[0].length}}function Zo(t){return(e,i,r,s,a,n)=>{const o=e.matrix.length;if(o===0)return;const u=e.matrix[0].length,c=r!==void 0?r:0,h=s!==void 0?s:o,d=a!==void 0?a:0,l=n!==void 0?n:u;for(let m=c;m<h&&!(m>=o);m++)for(let x=d;x<l&&!(x>=u);x++)e.matrix[m][x]=i}}function tu(t){return(e,i,r)=>{if(!e.matrix[i])return NaN;const s=e.matrix[i][r];return s===void 0?NaN:s}}function eu(t){if(t.length!==2)return t.map(i=>i.map(()=>NaN));const e=t[0][0]*t[1][1]-t[0][1]*t[1][0];return e===0?[[NaN,NaN],[NaN,NaN]]:[[t[1][1]/e,-t[0][1]/e],[-t[1][0]/e,t[0][0]/e]]}function iu(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r)return new H(i,r,NaN,t);const s=eu(e.matrix),a=new H(i,r,NaN,t);return a.matrix=s,a}}function ru(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let s=0;s<i;s++)for(let a=0;a<r;a++)if(s+a!==i-1&&e.matrix[s][a]!==0)return!1;return!0}}function su(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let s=0;s<i;s++)for(let a=0;a<r;a++)if(e.matrix[a][s]!==-e.matrix[s][a])return!1;return!0}}function nu(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;for(let s=0;s<i;s++)for(let a=0;a<r;a++){const n=e.matrix[s][a];if(n!==0&&n!==1)return!1}return!0}}function au(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let s=0;s<i;s++)for(let a=0;a<r;a++)if(s!==a&&e.matrix[s][a]!==0)return!1;return!0}}function ou(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let s=0;s<i;s++)for(let a=0;a<r;a++)if(s===a){if(e.matrix[s][a]!==1)return!1}else if(e.matrix[s][a]!==0)return!1;return!0}}function uu(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;return i===r}}function cu(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;for(let s=0;s<i;s++){let a=0;for(let n=0;n<r;n++){const o=e.matrix[s][n];if(o<0)return!1;a+=o}if(Math.abs(a-1)>1e-10)return!1}return!0}}function hu(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let s=0;s<i;s++)for(let a=0;a<s;a++)if(e.matrix[s][a]!==e.matrix[a][s])return!1;return!0}}function lu(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;let s=!0,a=!0;for(let n=0;n<i;n++)for(let o=0;o<r;o++)n>o&&e.matrix[n][o]!==0&&(s=!1),n<o&&e.matrix[n][o]!==0&&(a=!1);return s||a}}function pu(t){return e=>{const i=e.matrix.length;if(i===0)return!0;const r=e.matrix[0].length;for(let s=0;s<i;s++)for(let a=0;a<r;a++)if(e.matrix[s][a]!==0)return!1;return!0}}function du(t){return(e,i)=>{const r=e.matrix.length,s=r>0?e.matrix[0].length:0,a=i.matrix.length,n=a>0?i.matrix[0].length:0,o=r*a,u=s*n,c=new H(o,u,NaN,t);for(let h=0;h<r;h++)for(let d=0;d<s;d++){const l=e.matrix[h][d];for(let m=0;m<a;m++)for(let x=0;x<n;x++){const E=i.matrix[m][x];c.matrix[h*a+m][d*n+x]=l*E}}return c}}function fu(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length;let s=-1/0,a=!1;for(let n=0;n<i;n++)for(let o=0;o<r;o++){const u=e.matrix[n][o];isNaN(u)||(u>s&&(s=u),a=!0)}return a?s:NaN}}function mu(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length,s=[];for(let n=0;n<i;n++)for(let o=0;o<r;o++){const u=e.matrix[n][o];isNaN(u)||s.push(u)}if(s.length===0)return NaN;s.sort((n,o)=>n-o);const a=Math.floor(s.length/2);return s.length%2!==0?s[a]:(s[a-1]+s[a])/2}}function gu(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length;let s=1/0,a=!1;for(let n=0;n<i;n++)for(let o=0;o<r;o++){const u=e.matrix[n][o];isNaN(u)||(u<s&&(s=u),a=!0)}return a?s:NaN}}function xu(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length,s=new Map;let a=0,n=NaN;for(let o=0;o<i;o++)for(let u=0;u<r;u++){const c=e.matrix[o][u];if(!isNaN(c)){const h=(s.get(c)||0)+1;s.set(c,h),h>a?(a=h,n=c):h===a&&c<n&&(n=c)}}return n}}function yu(t){return(e,i)=>{const r=e.matrix.length,s=r>0?e.matrix[0].length:0;if(i instanceof H){const a=i.matrix.length,n=a>0?i.matrix[0].length:0;if(s!==a)return new H(0,0,NaN,t);const o=new H(r,n,0,t);for(let u=0;u<r;u++)for(let c=0;c<n;c++){let h=0;for(let d=0;d<s;d++)h+=e.matrix[u][d]*i.matrix[d][c];o.matrix[u][c]=h}return o}else if(i instanceof K||Array.isArray(i.array||i)){const a=i.array||i;if(s!==a.length)return new H(0,0,NaN,t);const n=new H(r,1,0,t);for(let o=0;o<r;o++){let u=0;for(let c=0;c<s;c++)u+=e.matrix[o][c]*a[c];n.matrix[o][0]=u}return n}else{const a=i,n=new H(r,s,NaN,t);for(let o=0;o<r;o++)for(let u=0;u<s;u++)n.matrix[o][u]=e.matrix[o][u]*a;return n}}}function wu(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;return i===r?new H(i,r,NaN,t):new H(r,i,NaN,t)}}function vu(t){return(e,i)=>{const r=e.matrix.length,s=r>0?e.matrix[0].length:0;if(r!==s)return new H(0,0,NaN,t);let a=new H(r,s,0,t);for(let u=0;u<r;u++)a.matrix[u][u]=1;let n=new H(r,s,NaN,t);for(let u=0;u<r;u++)n.matrix[u]=[...e.matrix[u]];let o=Math.floor(i);if(o<0)return new H(r,s,NaN,t);for(;o>0;){if(o%2===1){const c=new H(r,s,0,t);for(let h=0;h<r;h++)for(let d=0;d<s;d++){let l=0;for(let m=0;m<r;m++)l+=a.matrix[h][m]*n.matrix[m][d];c.matrix[h][d]=l}a=c}const u=new H(r,s,0,t);for(let c=0;c<r;c++)for(let h=0;h<s;h++){let d=0;for(let l=0;l<r;l++)d+=n.matrix[c][l]*n.matrix[l][h];u.matrix[c][h]=d}n=u,o=Math.floor(o/2)}return a}}function bu(t){return e=>{const i=e.matrix.length;if(i===0)return 0;const r=e.matrix[0].length,s=e.matrix.map(n=>[...n]);let a=0;for(let n=0;n<r&&a<i;n++){let o=a;for(;o<i&&Math.abs(s[o][n])<1e-10;)o++;if(o<i){[s[a],s[o]]=[s[o],s[a]];const u=s[a][n];for(let c=n;c<r;c++)s[a][c]/=u;for(let c=0;c<i;c++)if(c!==a){const h=s[c][n];for(let d=n;d<r;d++)s[c][d]-=h*s[a][d]}a++}}return a}}function _u(t){return(e,i)=>{const r=e.matrix.length;if(r===0){const n=kt(e.matrix[0][0]);return new K([],n,t)}const s=[];for(let n=0;n<r;n++){const o=e.matrix[n].splice(i,1);s.push(o[0])}const a=kt(s[0]);return new K(s,a,t)}}function Eu(t){return(e,i)=>{const r=e.matrix.splice(i,1),s=kt(r[0][0]);return new K(r[0]||[],s,t)}}function Su(t){return(e,i,r)=>{const s=e.matrix.length,a=s>0?e.matrix[0].length:0,n=i*r,o=[];for(let h=0;h<s;h++)for(let d=0;d<a;d++)o.push(e.matrix[h][d]);for(;o.length<n;)o.push(NaN);o.length>n&&(o.length=n);const u=[];let c=0;for(let h=0;h<i;h++){const d=[];for(let l=0;l<r;l++)d.push(o[c++]);u.push(d)}e.matrix=u}}function Cu(t){return e=>{e.matrix.reverse();for(const i of e.matrix)i.reverse()}}function Nu(t){return(e,i)=>{if(!e.matrix[i]){const s=kt(e.matrix[0][0]);return new K([],s,t)}const r=kt(e.matrix[i][0]);return new K([...e.matrix[i]],r,t)}}function Au(t){return e=>e.matrix.length}function Iu(t){return(e,i,r,s)=>{e.matrix[i]&&(e.matrix[i][r]=s)}}function ku(t){return(e,i=0,r="asc")=>{e.matrix.length!==0&&e.matrix.sort((s,a)=>{const n=s[i],o=a[i];return n<o?r==="asc"?-1:1:n>o?r==="asc"?1:-1:0})}}function Du(t){return(e,i,r,s,a)=>{const n=r-i,o=a-s,u=new H(n,o,NaN,t);for(let c=0;c<n;c++){const h=i+c;if(h>=e.matrix.length)break;for(let d=0;d<o;d++){const l=s+d;if(l>=e.matrix[h].length)break;u.matrix[c][d]=e.matrix[h][l]}}return u}}function Tu(t){return(e,i)=>{const r=e.matrix.length;if(r===0)return new H(0,0,NaN,t);const s=e.matrix[0].length,a=new H(r,s,NaN,t);if(i instanceof H)for(let n=0;n<r;n++)for(let o=0;o<s;o++){const u=e.matrix[n][o],c=i.matrix[n]&&i.matrix[n][o]!==void 0?i.matrix[n][o]:NaN;a.matrix[n][o]=u+c}else{const n=i;for(let o=0;o<r;o++)for(let u=0;u<s;u++)a.matrix[o][u]=e.matrix[o][u]+n}return a}}function Pu(t){return(e,i,r)=>{const s=e.matrix.length;for(let a=0;a<s;a++){const n=e.matrix[a][i];e.matrix[a][i]=e.matrix[a][r],e.matrix[a][r]=n}}}function Ou(t){return(e,i,r)=>{const s=e.matrix[i];e.matrix[i]=e.matrix[r],e.matrix[r]=s}}function Fu(t){return e=>{const i=e.matrix.length;if(i===0)return 0;const r=e.matrix[0].length,s=Math.min(i,r);let a=0;for(let n=0;n<s;n++)a+=e.matrix[n][n];return a}}function Ru(t){return e=>{const i=e.matrix.length;if(i===0)return new H(0,0,NaN,t);const r=e.matrix[0].length,s=new H(r,i,NaN,t);for(let a=0;a<i;a++)for(let n=0;n<r;n++)s.matrix[n][a]=e.matrix[a][n];return s}}var Bu=Object.defineProperty,Vu=(t,e,i)=>e in t?Bu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,R=(t,e,i)=>Vu(t,typeof e!="symbol"?e+"":e,i);class H{constructor(e=0,i=0,r=NaN,s){if(this.context=s,R(this,"matrix"),R(this,"_add_col"),R(this,"_add_row"),R(this,"_avg"),R(this,"_col"),R(this,"_columns"),R(this,"_concat"),R(this,"_copy"),R(this,"_det"),R(this,"_diff"),R(this,"_eigenvalues"),R(this,"_eigenvectors"),R(this,"_elements_count"),R(this,"_fill"),R(this,"_get"),R(this,"_inv"),R(this,"_is_antidiagonal"),R(this,"_is_antisymmetric"),R(this,"_is_binary"),R(this,"_is_diagonal"),R(this,"_is_identity"),R(this,"_is_square"),R(this,"_is_stochastic"),R(this,"_is_symmetric"),R(this,"_is_triangular"),R(this,"_is_zero"),R(this,"_kron"),R(this,"_max"),R(this,"_median"),R(this,"_min"),R(this,"_mode"),R(this,"_mult"),R(this,"_pinv"),R(this,"_pow"),R(this,"_rank"),R(this,"_remove_col"),R(this,"_remove_row"),R(this,"_reshape"),R(this,"_reverse"),R(this,"_row"),R(this,"_rows"),R(this,"_set"),R(this,"_sort"),R(this,"_submatrix"),R(this,"_sum"),R(this,"_swap_columns"),R(this,"_swap_rows"),R(this,"_trace"),R(this,"_transpose"),this.matrix=[],e>0&&i>0)for(let a=0;a<e;a++)this.matrix.push(Array(i).fill(r));this._add_col=Mo(this.context),this._add_row=Wo(this.context),this._avg=jo(this.context),this._col=$o(this.context),this._columns=qo(this.context),this._concat=Ho(this.context),this._copy=Uo(this.context),this._det=Ko(this.context),this._diff=zo(this.context),this._eigenvalues=Qo(this.context),this._eigenvectors=Jo(this.context),this._elements_count=Xo(this.context),this._fill=Zo(this.context),this._get=tu(this.context),this._inv=iu(this.context),this._is_antidiagonal=ru(this.context),this._is_antisymmetric=su(this.context),this._is_binary=nu(this.context),this._is_diagonal=au(this.context),this._is_identity=ou(this.context),this._is_square=uu(this.context),this._is_stochastic=cu(this.context),this._is_symmetric=hu(this.context),this._is_triangular=lu(this.context),this._is_zero=pu(this.context),this._kron=du(this.context),this._max=fu(this.context),this._median=mu(this.context),this._min=gu(this.context),this._mode=xu(this.context),this._mult=yu(this.context),this._pinv=wu(this.context),this._pow=vu(this.context),this._rank=bu(this.context),this._remove_col=_u(this.context),this._remove_row=Eu(this.context),this._reshape=Su(this.context),this._reverse=Cu(this.context),this._row=Nu(this.context),this._rows=Au(this.context),this._set=Iu(this.context),this._sort=ku(this.context),this._submatrix=Du(this.context),this._sum=Tu(this.context),this._swap_columns=Pu(this.context),this._swap_rows=Ou(this.context),this._trace=Fu(this.context),this._transpose=Ru(this.context)}toString(){let e="";for(let i=0;i<this.matrix.length;i++)e+=e===""?"":`
|
|
143
|
+
`,e+="["+this.matrix[i].join(", ")+"]";return e}add_col(...e){return this._add_col(this,...e)}add_row(...e){return this._add_row(this,...e)}avg(...e){return this._avg(this,...e)}col(...e){return this._col(this,...e)}columns(...e){return this._columns(this,...e)}concat(...e){return this._concat(this,...e)}copy(...e){return this._copy(this,...e)}det(...e){return this._det(this,...e)}diff(...e){return this._diff(this,...e)}eigenvalues(...e){return this._eigenvalues(this,...e)}eigenvectors(...e){return this._eigenvectors(this,...e)}elements_count(...e){return this._elements_count(this,...e)}fill(...e){return this._fill(this,...e)}get(...e){return this._get(this,...e)}inv(...e){return this._inv(this,...e)}is_antidiagonal(...e){return this._is_antidiagonal(this,...e)}is_antisymmetric(...e){return this._is_antisymmetric(this,...e)}is_binary(...e){return this._is_binary(this,...e)}is_diagonal(...e){return this._is_diagonal(this,...e)}is_identity(...e){return this._is_identity(this,...e)}is_square(...e){return this._is_square(this,...e)}is_stochastic(...e){return this._is_stochastic(this,...e)}is_symmetric(...e){return this._is_symmetric(this,...e)}is_triangular(...e){return this._is_triangular(this,...e)}is_zero(...e){return this._is_zero(this,...e)}kron(...e){return this._kron(this,...e)}max(...e){return this._max(this,...e)}median(...e){return this._median(this,...e)}min(...e){return this._min(this,...e)}mode(...e){return this._mode(this,...e)}mult(...e){return this._mult(this,...e)}pinv(...e){return this._pinv(this,...e)}pow(...e){return this._pow(this,...e)}rank(...e){return this._rank(this,...e)}remove_col(...e){return this._remove_col(this,...e)}remove_row(...e){return this._remove_row(this,...e)}reshape(...e){return this._reshape(this,...e)}reverse(...e){return this._reverse(this,...e)}row(...e){return this._row(this,...e)}rows(...e){return this._rows(this,...e)}set(...e){return this._set(this,...e)}sort(...e){return this._sort(this,...e)}submatrix(...e){return this._submatrix(this,...e)}sum(...e){return this._sum(this,...e)}swap_columns(...e){return this._swap_columns(this,...e)}swap_rows(...e){return this._swap_rows(this,...e)}trace(...e){return this._trace(this,...e)}transpose(...e){return this._transpose(this,...e)}}function Lu(t){return(e,i,r)=>new H(e,i,r,t)}function Mu(t){return(e,i=0)=>w.from(e).get(i)}class Wu{constructor(e){this.context=e,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=Lu(e),this.param=Mu(),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 ju=Object.defineProperty,$u=(t,e,i)=>e in t?ju(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,qu=(t,e,i)=>$u(t,e+"",i);class Hu{constructor(e){this.context=e,qu(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()}}class Oe{constructor(e,i){this._definition=e,this.context=i;for(let r in e)this[r]=e[r]}get __def__(){return this._definition}copy(){return new Oe(this.__def__,this.context)}toString(){const e={};for(let i in this.__def__)e[i]=this[i];return JSON.stringify(e)}}function Uu(t){return typeof t=="object"&&t.title!==void 0&&t.data!==void 0&&t.options!==void 0}const Ki={series:t=>t instanceof w||typeof t=="number"||typeof t=="string"||typeof t=="boolean",string:t=>typeof t=="string",number:t=>typeof t=="number",boolean:t=>typeof t=="boolean",array:t=>Array.isArray(t),object:t=>typeof t=="object",primitive:t=>typeof t===null||typeof t!="object"&&typeof t!="function",function:t=>typeof t=="function",undefined:t=>t===void 0,null:t=>t===null,NaN:t=>isNaN(t),remaining_options:t=>typeof t=="object"&&!(t instanceof w)&&!Uu(t)};function At(t,e,i,r){Array.isArray(e)&&typeof e[0]=="string"&&(e=[e]);const s={};let a={};const n=new Array(e.length).fill(!0);for(let o=0;o<t.length;o++){const u=t[o];if(Ki.remaining_options(u)){a=u;break}const c=e.map((h,d)=>n[d]?h[o]:void 0);for(let h=0;h<c.length;h++){const d=c[h];if(d===void 0){n[h]=!1;continue}const l=Ki[i[d]];typeof l=="function"&&l(u)?s[d]=u:n[h]=!1}}return{...a,...s,...r}}var Gu=Object.defineProperty,Ku=(t,e,i)=>e in t?Gu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,zu=(t,e,i)=>Ku(t,e+"",i);const Yu=["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"],Qu={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"},tt={aqua:"#00BCD4",black:"#363A45",blue:"#2196F3",fuchsia:"#E040FB",gray:"#787B86",green:"#4CAF50",lime:"#00E676",maroon:"#880E4F",navy:"#311B92",olive:"#808000",orange:"#FF9800",purple:"#9C27B0",red:"#F23645",silver:"#B2B5BE",teal:"#089981",white:"#FFFFFF",yellow:"#FDD835"};function Ju(t){return At(t,Yu,Qu)}class Xu{constructor(e){this.context=e,zu(this,"color",{param:(i,r=0)=>w.from(i).get(r),rgb:(i,r,s,a)=>a?`rgba(${i}, ${r}, ${s}, ${(100-a)/100})`:`rgb(${i}, ${r}, ${s})`,new:(i,r)=>{if(i&&i.startsWith("#")){const s=i.slice(1);return r?`#${s}${Math.round(255/100*(100-r)).toString(16).padStart(2,"0").toUpperCase()}`:`#${s}`}else{const s=tt[i];return s?r?`#${s}${Math.round(255/100*(100-r)).toString(16).padStart(2,"0").toUpperCase()}`:`#${s}`:r?`rgba(${i}, ${(100-r)/100})`:i}},aqua:tt.aqua,black:tt.black,blue:tt.blue,fuchsia:tt.fuchsia,gray:tt.gray,green:tt.green,lime:tt.lime,maroon:tt.maroon,navy:tt.navy,olive:tt.olive,orange:tt.orange,purple:tt.purple,red:tt.red,silver:tt.silver,teal:tt.teal,white:tt.white,yellow:tt.yellow})}extractPlotOptions(e){const i={};for(let r in e)i[r]=w.from(e[r]).get(0);return i}indicator(...e){const i=Ju(e),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(e){return isNaN(w.from(e).get(0))}nz(e,i=0){const r=w.from(e).get(0),s=w.from(i).get(0);return isNaN(r)?s:r}fixnan(e){const i=w.from(e);for(let r=0;r<i.length;r++){const s=i.get(r);if(!isNaN(s))return s}return NaN}alertcondition(e,i,r){}bool(e){const i=w.from(e).get(0);return!isNaN(i)&&i!==0}int(e){const i=w.from(e).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(e){const i=w.from(e).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(e){return w.from(e).get(0).toString()}Type(e){const i=Object.keys(e);return{new:function(...r){const s={};for(let a=0;a<r.length;a++)s[i[a]]=r[a];return new Oe(s,this.context)},copy:function(r){return new Oe(r.__def__,this.context)}}}}const Zu=[["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"]],tc={defval:"primitive",title:"string",tooltip:"string",inline:"string",group:"string",display:"string",confirm:"boolean",options:"array",minval:"number",maxval:"number",step:"number"};function dt(t){return At(t,Zu,tc)}function St(t,e){return e.title&&t.inputs&&t.inputs[e.title]!==void 0?t.inputs[e.title]:e.defval}function ec(t){return(...e)=>{const i=dt(e);return St(t,i)}}function ic(t){return(...e)=>dt(e).defval}function rc(t){return(...e)=>{const i=dt(e);return St(t,i)}}function sc(t){return(...e)=>{const i=dt(e);return St(t,i)}}function nc(t){return(...e)=>{const i=dt(e);return St(t,i)}}function ac(t){return(...e)=>{const i=dt(e);return St(t,i)}}function oc(t){return(e,i=0)=>w.from(e).get(i)}function uc(t){return(...e)=>{const i=dt(e);return St(t,i)}}function cc(t){return(...e)=>{const i=dt(e);return St(t,i)}}function hc(t){return(...e)=>{const i=dt(e);return St(t,i)}}function lc(t){return(...e)=>{const i=dt(e);return St(t,i)}}function pc(t){return(...e)=>{const i=dt(e);return St(t,i)}}function dc(t){return(...e)=>{const i=dt(e);return St(t,i)}}function fc(t){return(...e)=>{const i=dt(e);return St(t,i)}}function mc(t){return(...e)=>dt(e).defval}var gc=Object.defineProperty,xc=(t,e,i)=>e in t?gc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,ot=(t,e,i)=>xc(t,typeof e!="symbol"?e+"":e,i);const yc={any:ec,bool:ic,color:rc,enum:sc,float:nc,int:ac,param:oc,price:uc,session:cc,source:hc,string:lc,symbol:pc,text_area:dc,time:fc,timeframe:mc};class wc{constructor(e){this.context=e,ot(this,"any"),ot(this,"bool"),ot(this,"color"),ot(this,"enum"),ot(this,"float"),ot(this,"int"),ot(this,"param"),ot(this,"price"),ot(this,"session"),ot(this,"source"),ot(this,"string"),ot(this,"symbol"),ot(this,"text_area"),ot(this,"time"),ot(this,"timeframe"),Object.entries(yc).forEach(([i,r])=>{this[i]=r(e)})}}function vc(t){return e=>Math.abs(w.from(e).get(0))}function bc(t){return e=>Math.acos(w.from(e).get(0))}function _c(t){return e=>Math.asin(w.from(e).get(0))}function Ec(t){return e=>Math.atan(w.from(e).get(0))}function Sc(t){return(...e)=>{const i=e.map(r=>w.from(r).get(0));return i.reduce((r,s)=>r+s,0)/i.length}}function Cc(t){return e=>Math.ceil(w.from(e).get(0))}function Nc(t){return e=>Math.cos(w.from(e).get(0))}function Ac(t){return()=>Math.E}function Ic(t){return e=>Math.exp(w.from(e).get(0))}function kc(t){return e=>Math.floor(w.from(e).get(0))}function Dc(t){return e=>Math.log(w.from(e).get(0))}function Tc(t){return e=>Math.log(w.from(e).get(0))}function Pc(t){return e=>Math.log10(w.from(e).get(0))}function Oc(t){return(...e)=>{const i=e.map(r=>w.from(r).get(0));return Math.max(...i)}}function Fc(t){return(...e)=>{const i=e.map(r=>w.from(r).get(0));return Math.min(...i)}}function Rc(t){return(e,i,r)=>typeof e=="string"?e:e instanceof w?i?new w(e.data,e.offset+i):e:!Array.isArray(e)&&typeof e=="object"?e:(t.params[r]||(t.params[r]=[]),Array.isArray(e)?new w(e,i||0):(t.params[r].length===0?t.params[r].push(e):t.params[r][t.params[r].length-1]=e,new w(t.params[r],0)))}function Bc(t){return()=>1.618033988749895}function Vc(t){return()=>Math.PI}function Lc(t){return(e,i)=>Math.pow(w.from(e).get(0),w.from(i).get(0))}function Mc(t){return()=>Math.random()}function Wc(t){return(e,i)=>{const r=w.from(e).get(0);if(i==null)return Math.round(r);const s=w.from(i).get(0);if(s===0)return Math.round(r);const a=Math.pow(10,s);return Math.round(r*a)/a}}function jc(t){return e=>t.precision(Math.round(w.from(e).get(0)/t.pine.syminfo.mintick)*t.pine.syminfo.mintick)}function $c(t){return()=>.6180339887498948}function qc(t){return e=>Math.sign(w.from(e).get(0))}function Hc(t){return e=>Math.sin(w.from(e).get(0))}function Uc(t){return e=>Math.sqrt(w.from(e).get(0))}function Gc(t){return(e,i)=>{const r=w.from(i).get(0),s=w.from(e);let a=0;for(let n=0;n<r;n++){const o=s.get(n);a+=o}return a}}function Kc(t){return e=>Math.tan(w.from(e).get(0))}function zc(t){return e=>{const i=w.from(e).get(0);return i==null||Number.isNaN(i)?NaN:i*(180/Math.PI)}}function Yc(t){return e=>{const i=w.from(e).get(0);return i==null||Number.isNaN(i)?NaN:i*(Math.PI/180)}}function Qc(t){return(e,i)=>{const r=w.from(e).get(0),s=w.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 Jc=Object.defineProperty,Xc=(t,e,i)=>e in t?Jc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,q=(t,e,i)=>Xc(t,typeof e!="symbol"?e+"":e,i);const Zc={abs:vc,acos:bc,asin:_c,atan:Ec,avg:Sc,ceil:Cc,cos:Nc,e:Ac,exp:Ic,floor:kc,ln:Dc,log:Tc,log10:Pc,max:Oc,min:Fc,param:Rc,phi:Bc,pi:Vc,pow:Lc,random:Mc,round:Wc,round_to_mintick:jc,rphi:$c,sign:qc,sin:Hc,sqrt:Uc,sum:Gc,tan:Kc,todegrees:zc,toradians:Yc,__eq:Qc};class th{constructor(e){this.context=e,q(this,"_cache",{}),q(this,"abs"),q(this,"acos"),q(this,"asin"),q(this,"atan"),q(this,"avg"),q(this,"ceil"),q(this,"cos"),q(this,"e"),q(this,"exp"),q(this,"floor"),q(this,"ln"),q(this,"log"),q(this,"log10"),q(this,"max"),q(this,"min"),q(this,"param"),q(this,"phi"),q(this,"pi"),q(this,"pow"),q(this,"random"),q(this,"round"),q(this,"round_to_mintick"),q(this,"rphi"),q(this,"sign"),q(this,"sin"),q(this,"sqrt"),q(this,"sum"),q(this,"tan"),q(this,"todegrees"),q(this,"toradians"),q(this,"__eq"),Object.entries(Zc).forEach(([i,r])=>{this[i]=r(e)})}}function eh(t){return(e,i,r)=>{t.params[r]||(t.params[r]=[]);let s;if(e instanceof w)s=e.get(i||0);else if(Array.isArray(e)){const a=e.every(o=>o instanceof w),n=e.every(o=>!(o instanceof w)&&!Array.isArray(o));(a||n)&&e.length>=1?a?s=e.map(o=>o.get(0)):s=e:s=w.from(e).get(i||0)}else s=e;return t.params[r].length===0?t.params[r].push(s):t.params[r][t.params[r].length-1]=s,[s,r]}}const Fe=["1","3","5","15","30","45","60","120","180","240","D","W","M"];function zi(t,e,i,r,s=!1){for(let a=0;a<i.length;a++)if(i[a]<=t&&e<=r[a])return s||e>=r[a]?a:a-1;return-1}function Yi(t,e,i,r,s=!1,a,n=!1){for(let o=i.length-1;o>=0;o--){if(r[o]<=e&&i[o]>=t){const u=a&&e>a;if(n&&s)for(let c=0;c<i.length;c++){if(i[c]>=t&&i[c]<e)return c;if(i[c]>=e)break}if(u&&s&&!n)for(let c=0;c<i.length;c++){if(i[c]>=t&&i[c]<e)return c;if(i[c]>=e)break}return o}if(r[o]<t)break}return-1}function ih(t){return async(e,i,r,s=!1,a=!1,n=!1,o=null,u=null)=>{const c=e[0],h=i[0],d=r[0],l=r[1],m=Array.isArray(s)?s[0]:s,x=Array.isArray(a)?a[0]:a;if(t.isSecondaryContext)return d;const E=Fe.indexOf(t.timeframe),S=Fe.indexOf(h);if(E==-1||S==-1)throw new Error("Invalid timeframe");if(E===S)return d;const p=E>S,g=w.from(t.data.openTime).get(0),v=w.from(t.data.closeTime).get(0),_=`${c}_${h}_${l}`,b=`${_}_prevIdx`;if(t.cache[_]){const Z=t.cache[_],Dt=p?Yi(g,v,Z.data.openTime.data,Z.data.closeTime.data,x,t.eDate,m):zi(g,v,Z.data.openTime.data,Z.data.closeTime.data,x);if(Dt==-1)return NaN;const st=Z.params[l][Dt];if(!p&&m){const vi=t.cache[b];return vi!==void 0&&vi===Dt?NaN:(t.cache[b]=Dt,Array.isArray(st)?[st]:st)}return Array.isArray(st)?[st]:st}const C=1e3*60*60*24*30,A=t.sDate?t.sDate-C:void 0,D=t.sDate&&t.eDate?void 0:t.limit||1e3,B=new wi(t.source,c,h,D,A,void 0);B.markAsSecondary();const k=await B.run(t.pineTSCode);t.cache[_]=k;const O=p?Yi(g,v,k.data.openTime.data,k.data.closeTime.data,x,t.eDate,m):zi(g,v,k.data.openTime.data,k.data.closeTime.data,x);if(O==-1)return NaN;const W=k.params[l][O];return!p&&m?(t.cache[b]=O,NaN):Array.isArray(W)?[W]:W}}function rh(t){return async(e,i,r,s=!1,a=null,n=!1,o=0)=>{const u=e[0],c=i[0],h=r[0],d=r[1];Array.isArray(s)&&s[0];const l=Array.isArray(n)?n[0]:n;if(t.isSecondaryContext)return Array.isArray(h)?[h]:h;const m=Fe.indexOf(t.timeframe),x=Fe.indexOf(c);if(m===-1||x===-1){if(l)return NaN;throw new Error("Invalid timeframe")}if(x>m){if(l)return NaN;throw new Error(`Timeframe ${c} is not lower than or equal to chart timeframe ${t.timeframe}`)}if(x===m)return[[h]];const E=`${u}_${c}_${d}_lower`;if(!t.cache[E]){const A=t.sDate?t.sDate-2592e6:void 0,D=t.sDate&&t.eDate?void 0:t.limit||1e3,B=new wi(t.source,u,c,D,A,t.eDate);B.markAsSecondary();const k=await B.run(t.pineTSCode);t.cache[E]=k}const S=t.cache[E],p=w.from(t.data.openTime).get(0),g=w.from(t.data.closeTime).get(0),v=S.data.openTime.data,_=S.data.closeTime.data,b=S.params[d];if(!b)return[];const C=[];for(let A=0;A<v.length;A++){const D=v[A];if(!(_[A]<=p)){if(D>=g)break;D>=p&&D<g&&C.push(b[A])}}return[C]}}var sh=Object.defineProperty,nh=(t,e,i)=>e in t?sh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ie=(t,e,i)=>nh(t,typeof e!="symbol"?e+"":e,i);const ah={param:eh,security:ih,security_lower_tf:rh};class oh{constructor(e){this.context=e,Ie(this,"_cache",{}),Ie(this,"param"),Ie(this,"security"),Ie(this,"security_lower_tf"),Object.entries(ah).forEach(([i,r])=>{this[i]=r(e)})}}function uh(t){return e=>{t.taState||(t.taState={});const i=e||"accdist";t.taState[i]||(t.taState[i]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.prevCumulativeSum=r.currentCumulativeSum),r.lastIdx=t.idx);const s=t.get(t.data.close,0),a=t.get(t.data.high,0),n=t.get(t.data.low,0),o=t.get(t.data.volume,0);if(isNaN(s)||isNaN(a)||isNaN(n)||isNaN(o))return r.currentCumulativeSum=r.prevCumulativeSum,t.precision(r.prevCumulativeSum);const u=a-n;let c=0;u!==0&&(c=(s-n-(a-s))/u*o);const h=r.prevCumulativeSum+c;return r.currentCumulativeSum=h,t.precision(h)}}function ch(t){return(e,i,r,s,a)=>{const n=w.from(i).get(0),o=w.from(r).get(0),u=w.from(s).get(0);t.taState||(t.taState={});const c=a||`alma_${n}_${o}_${u}`;if(!t.taState[c]){const x=o*(n-1),E=n/u,S=[];let p=0;for(let g=0;g<n;g++){const v=Math.exp(-Math.pow(g-x,2)/(2*E*E));S.push(v),p+=v}for(let g=0;g<S.length;g++)S[g]/=p;t.taState[c]={lastIdx:-1,prevWindow:[],currentWindow:[],weights:S}}const h=t.taState[c];t.idx>h.lastIdx&&(h.lastIdx>=0&&(h.prevWindow=[...h.currentWindow]),h.lastIdx=t.idx);const d=w.from(e).get(0),l=[...h.prevWindow];if(l.unshift(d),l.length>n&&l.pop(),h.currentWindow=l,l.length<n)return NaN;let m=0;for(let x=0;x<n;x++)m+=h.weights[x]*l[n-1-x];return t.precision(m)}}function hh(t){return(e,i)=>{const r=w.from(e).get(0);t.taState||(t.taState={});const s=i||`atr_${r}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevAtr:null,prevInitSum:0,prevInitCount:0,prevPrevClose:null,currentAtr:null,currentInitSum:0,currentInitCount:0,currentPrevClose:null});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevAtr=a.currentAtr,a.prevInitSum=a.currentInitSum,a.prevInitCount=a.currentInitCount,a.prevPrevClose=a.currentPrevClose),a.lastIdx=t.idx);const n=t.get(t.data.high,0),o=t.get(t.data.low,0),u=t.get(t.data.close,0);if(isNaN(n)||isNaN(o)||isNaN(u))return NaN;const c=a.prevPrevClose;let h;if(c!==null){const E=n-o,S=Math.abs(n-c),p=Math.abs(o-c);h=Math.max(E,S,p)}else h=n-o;a.currentPrevClose=u;let d=a.prevInitCount,l=a.prevInitSum,m=a.prevAtr;if(d<r){if(l+=h,d++,a.currentInitSum=l,a.currentInitCount=d,d===r){const E=l/r;return a.currentAtr=E,t.precision(E)}return NaN}const x=(m*(r-1)+h)/r;return a.currentAtr=x,t.precision(x)}}function lh(t){return(e,i)=>{t.taState||(t.taState={});const r=i||"barssince";t.taState[r]||(t.taState[r]={lastIdx:-1,prevLastTrueIndex:null,currentLastTrueIndex:null});const s=t.taState[r];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevLastTrueIndex=s.currentLastTrueIndex),s.lastIdx=t.idx);const a=w.from(e).get(0);let n=s.prevLastTrueIndex;return a&&(n=t.idx),s.currentLastTrueIndex=n,n===null?NaN:t.idx-n}}function ph(t){return(e,i,r,s)=>{const a=w.from(i).get(0),n=w.from(r).get(0);t.taState||(t.taState={});const o=s||`bb_${a}_${n}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const u=t.taState[o];t.idx>u.lastIdx&&(u.lastIdx>=0&&(u.prevWindow=[...u.currentWindow],u.prevSum=u.currentSum),u.lastIdx=t.idx);const c=w.from(e).get(0);if(isNaN(c))return u.currentWindow=[...u.prevWindow],u.currentSum=u.prevSum,[[NaN,NaN,NaN]];const h=[...u.prevWindow];let d=u.prevSum;if(h.unshift(c),d+=c,h.length>a){const p=h.pop();d-=p}if(u.currentWindow=h,u.currentSum=d,h.length<a)return[[NaN,NaN,NaN]];const l=d/a;let m=0;for(let p=0;p<a;p++)m+=Math.pow(h[p]-l,2);const x=Math.sqrt(m/a),E=l+n*x,S=l-n*x;return[[t.precision(l),t.precision(E),t.precision(S)]]}}function dh(t){return(e,i,r,s)=>{const a=w.from(i).get(0),n=w.from(r).get(0);t.taState||(t.taState={});const o=s||`bbw_${a}_${n}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const u=t.taState[o];t.idx>u.lastIdx&&(u.lastIdx>=0&&(u.prevWindow=[...u.currentWindow],u.prevSum=u.currentSum),u.lastIdx=t.idx);const c=w.from(e).get(0);if(isNaN(c))return u.currentWindow=[...u.prevWindow],u.currentSum=u.prevSum,NaN;const h=[...u.prevWindow];let d=u.prevSum;if(h.unshift(c),d+=c,h.length>a){const g=h.pop();d-=g}if(u.currentWindow=h,u.currentSum=d,h.length<a)return NaN;const l=d/a;let m=0;for(let g=0;g<a;g++){const v=h[g]-l;m+=v*v}const x=m/a,E=Math.sqrt(x),S=n*E;if(l===0)return t.precision(0);const p=2*S/l*100;return t.precision(p)}}function fh(t){return(e,i,r)=>{const s=w.from(i).get(0);t.taState||(t.taState={});const a=r||`cci_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const n=t.taState[a];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevWindow=[...n.currentWindow],n.prevSum=n.currentSum),n.lastIdx=t.idx);const o=w.from(e).get(0);if(isNaN(o))return NaN;const u=[...n.prevWindow];let c=n.prevSum;if(u.unshift(o),c+=o,u.length<s)return n.currentWindow=u,n.currentSum=c,NaN;if(u.length>s){const x=u.pop();c-=x}n.currentWindow=u,n.currentSum=c;const h=c/s;let d=0;for(let x=0;x<s;x++)d+=Math.abs(u[x]-h);const l=d/s;if(l===0)return 0;const m=(o-h)/(.015*l);return t.precision(m)}}function mh(t){return(e,i=1,r)=>{typeof i=="string"&&(r=i,i=1);const s=w.from(i).get(0);t.taState||(t.taState={});const a=r||`change_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],currentWindow:[]});const n=t.taState[a];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevWindow=[...n.currentWindow]),n.lastIdx=t.idx);const o=w.from(e).get(0),u=[...n.prevWindow];if(u.unshift(o),u.length<=s)return n.currentWindow=u,NaN;u.length>s+1&&u.pop(),n.currentWindow=u;const c=o-u[s];return t.precision(c)}}function gh(t){return(e,i,r)=>{const s=w.from(i).get(0);t.taState||(t.taState={});const a=r||`cmo_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevGainsWindow:[],prevLossesWindow:[],prevGainsSum:0,prevLossesSum:0,currentGainsWindow:[],currentLossesWindow:[],currentGainsSum:0,currentLossesSum:0});const n=t.taState[a];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevGainsWindow=[...n.currentGainsWindow],n.prevLossesWindow=[...n.currentLossesWindow],n.prevGainsSum=n.currentGainsSum,n.prevLossesSum=n.currentLossesSum),n.lastIdx=t.idx);const o=w.from(e).get(0),u=w.from(e).get(1);if(isNaN(o)||isNaN(u))return NaN;const c=o-u,h=c>=0?c:0,d=c>=0?0:-c,l=[...n.prevGainsWindow],m=[...n.prevLossesWindow];let x=n.prevGainsSum,E=n.prevLossesSum;if(l.unshift(h),m.unshift(d),x+=h,E+=d,l.length<s)return n.currentGainsWindow=l,n.currentLossesWindow=m,n.currentGainsSum=x,n.currentLossesSum=E,NaN;if(l.length>s){const g=l.pop(),v=m.pop();x-=g,E-=v}n.currentGainsWindow=l,n.currentLossesWindow=m,n.currentGainsSum=x,n.currentLossesSum=E;const S=x+E;if(S===0)return t.precision(0);const p=100*(x-E)/S;return t.precision(p)}}function xh(t){return(e,i,r)=>{const s=w.from(i).get(0),a=w.from(e);let n=0,o=!1;for(let h=0;h<s;h++){const d=a.get(h);if(isNaN(d)){o=!0;break}n+=d}if(o)return NaN;let u=0;for(let h=0;h<s;h++){const d=a.get(h);u+=d*(h+1)}if(n===0)return NaN;const c=-u/n;return t.precision(c)}}function yh(t){return(e,i,r,s)=>{const a=w.from(r).get(0),n=w.from(e),o=w.from(i);if(t.idx<a-1)return NaN;let u=0,c=0,h=0,d=0,l=0,m=0;for(let g=0;g<a;g++){const v=n.get(g),_=o.get(g);isNaN(v)||isNaN(_)||(u+=v,c+=_,h+=v*_,d+=v*v,l+=_*_,m++)}if(m<2)return NaN;const x=m*h-u*c,E=m*d-u*u,S=m*l-c*c;if(E<=0||S<=0)return t.precision(0);const p=x/Math.sqrt(E*S);return t.precision(p)}}function wh(t){return(e,i,r)=>{const s=w.from(e),a=w.from(i),n=s.get(0),o=a.get(0),u=s.get(1),c=a.get(1);if(isNaN(n)||isNaN(o)||isNaN(u)||isNaN(c))return!1;const h=n>o&&u<=c,d=n<o&&u>=c;return h||d}}function vh(t){return(e,i)=>{const r=w.from(e),s=w.from(i),a=r.get(0),n=s.get(0),o=r.get(1),u=s.get(1);return o<u&&a>n}}function bh(t){return(e,i)=>{const r=w.from(e),s=w.from(i),a=r.get(0),n=s.get(0),o=r.get(1),u=s.get(1);return o>u&&a<n}}function _h(t){return(e,i)=>{t.taState||(t.taState={});const r=i||"cum";t.taState[r]||(t.taState[r]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const s=t.taState[r];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevCumulativeSum=s.currentCumulativeSum),s.lastIdx=t.idx);const a=w.from(e).get(0);if(isNaN(a))return s.currentCumulativeSum=s.prevCumulativeSum,t.precision(s.prevCumulativeSum);const n=s.prevCumulativeSum+a;return s.currentCumulativeSum=n,t.precision(n)}}function Eh(t){return(e,i,r)=>{const s=w.from(i).get(0);t.taState||(t.taState={});const a=r||`dev_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const n=t.taState[a];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevWindow=[...n.currentWindow],n.prevSum=n.currentSum),n.lastIdx=t.idx);const o=w.from(e).get(0)||0,u=[...n.prevWindow];let c=n.prevSum;if(u.unshift(o),c+=o,u.length>s){const m=u.pop();c-=m}if(n.currentWindow=u,n.currentSum=c,u.length<s)return NaN;const h=c/s;let d=0;for(let m=0;m<s;m++)d+=Math.abs(u[m]-h);const l=d/s;return t.precision(l)}}function Sh(t){return(e,i,r)=>{const s=w.from(e).get(0),a=w.from(i).get(0);t.taState||(t.taState={});const n=r||`dmi_${s}_${a}`;t.taState[n]||(t.taState[n]={lastIdx:-1,prevHigh:NaN,prevLow:NaN,prevClose:NaN,prevTrInitSum:0,prevPlusInitSum:0,prevMinusInitSum:0,prevInitCount:0,prevSmoothedTR:NaN,prevSmoothedPlus:NaN,prevSmoothedMinus:NaN,prevDxInitSum:0,prevAdxInitCount:0,prevADX:NaN,currentHigh:NaN,currentLow:NaN,currentClose:NaN,currentTrInitSum:0,currentPlusInitSum:0,currentMinusInitSum:0,currentInitCount:0,currentSmoothedTR:NaN,currentSmoothedPlus:NaN,currentSmoothedMinus:NaN,currentDxInitSum:0,currentAdxInitCount:0,currentADX:NaN});const o=t.taState[n];t.idx>o.lastIdx&&(o.lastIdx>=0&&(o.prevHigh=o.currentHigh,o.prevLow=o.currentLow,o.prevClose=o.currentClose,o.prevTrInitSum=o.currentTrInitSum,o.prevPlusInitSum=o.currentPlusInitSum,o.prevMinusInitSum=o.currentMinusInitSum,o.prevInitCount=o.currentInitCount,o.prevSmoothedTR=o.currentSmoothedTR,o.prevSmoothedPlus=o.currentSmoothedPlus,o.prevSmoothedMinus=o.currentSmoothedMinus,o.prevDxInitSum=o.currentDxInitSum,o.prevAdxInitCount=o.currentAdxInitCount,o.prevADX=o.currentADX),o.lastIdx=t.idx);const u=t.get(t.data.high,0),c=t.get(t.data.low,0),h=t.get(t.data.close,0);if(isNaN(u)||isNaN(c)||isNaN(h))return[[NaN,NaN,NaN]];if(o.currentHigh=u,o.currentLow=c,o.currentClose=h,isNaN(o.prevHigh))return[[NaN,NaN,NaN]];const d=Math.max(u-c,Math.abs(u-o.prevClose),Math.abs(c-o.prevClose)),l=u-o.prevHigh,m=o.prevLow-c,x=l>m&&l>0?l:0,E=m>l&&m>0?m:0;let S=o.prevInitCount,p=o.prevTrInitSum,g=o.prevPlusInitSum,v=o.prevMinusInitSum,_=o.prevSmoothedTR,b=o.prevSmoothedPlus,C=o.prevSmoothedMinus;if(S++,S<=s)p+=d,g+=x,v+=E,S===s&&(_=p/s,b=g/s,C=v/s);else{const st=1/s;_=st*d+(1-st)*_,b=st*x+(1-st)*b,C=st*E+(1-st)*C}if(o.currentInitCount=S,o.currentTrInitSum=p,o.currentPlusInitSum=g,o.currentMinusInitSum=v,o.currentSmoothedTR=_,o.currentSmoothedPlus=b,o.currentSmoothedMinus=C,S<s)return[[NaN,NaN,NaN]];const A=_===0?0:100*b/_,D=_===0?0:100*C/_,B=A+D,k=B===0?0:100*Math.abs(A-D)/B;let O=o.prevAdxInitCount,W=o.prevDxInitSum,Z=o.prevADX,Dt=NaN;if(O++,O<=a)W+=k,O===a&&(Z=W/a,Dt=Z);else{const st=1/a;Z=st*k+(1-st)*Z,Dt=Z}return o.currentAdxInitCount=O,o.currentDxInitSum=W,o.currentADX=Z,[[t.precision(A),t.precision(D),t.precision(Dt)]]}}function Ch(t){return(e,i,r)=>{const s=w.from(i).get(0);t.taState||(t.taState={});const a=r||`ema_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevEma:null,prevInitSum:0,prevInitCount:0,currentEma:null,currentInitSum:0,currentInitCount:0});const n=t.taState[a];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevEma=n.currentEma,n.prevInitSum=n.currentInitSum,n.prevInitCount=n.currentInitCount),n.lastIdx=t.idx);const o=w.from(e).get(0);if(o==null||isNaN(o))return NaN;let u=n.prevInitCount,c=n.prevInitSum,h=n.prevEma;if(u<s){if(c+=o,u++,n.currentInitSum=c,n.currentInitCount=u,u===s){const m=c/s;return n.currentEma=m,t.precision(m)}return NaN}const d=2/(s+1),l=o*d+h*(1-d);return n.currentEma=l,t.precision(l)}}function Nh(t){return(e,i,r)=>{const s=w.from(i).get(0),a=w.from(e);for(let n=0;n<s;n++){const o=a.get(n),u=a.get(n+1);if(isNaN(o)||isNaN(u)||o>=u)return!1}return!0}}function Ah(t){return(e,i,r)=>{typeof i=="string"&&r===void 0&&(r=i,i=e,e=t.data.high);const s=w.from(i).get(0);t.taState||(t.taState={});const a=r||`highest_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],currentWindow:[]});const n=t.taState[a];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevWindow=[...n.currentWindow]),n.lastIdx=t.idx);const o=w.from(e).get(0),u=[...n.prevWindow];if(u.unshift(o),u.length<s)return n.currentWindow=u,NaN;u.length>s&&u.pop(),n.currentWindow=u;const c=u.filter(d=>!isNaN(d)&&d!==void 0);if(c.length===0)return NaN;const h=Math.max(...c);return t.precision(h)}}function Ih(t){return(e,i,r)=>{const s=w.from(i).get(0),a=w.from(e);if(t.idx<s-1)return NaN;let n=-1/0,o=NaN;for(let u=0;u<s;u++){const c=a.get(u);isNaN(c)||(isNaN(o)||c>n)&&(n=c,o=-u)}return o}}function kh(t){return(e,i,r)=>{const s=w.from(i).get(0),a=Math.floor(s/2),n=Math.floor(Math.sqrt(s)),o=t.pine.ta.wma,u=o(e,a,r?`${r}_wma1`:void 0),c=o(e,s,r?`${r}_wma2`:void 0);if(isNaN(u)||isNaN(c))return NaN;t.taState||(t.taState={});const h=r||`hma_raw_${s}`;t.taState[h]||(t.taState[h]={lastIdx:-1,prevValues:[],currentValues:[]});const d=t.taState[h];t.idx>d.lastIdx&&(d.lastIdx>=0&&(d.prevValues=[...d.currentValues]),d.lastIdx=t.idx);const l=2*u-c,m=[...d.prevValues];m.unshift(l),m.length>n+1&&m.pop(),d.currentValues=m;const x=r?`${r}_hma_final`:`hma_final_${s}`;t.taState[x]||(t.taState[x]={lastIdx:-1,prevWindow:[],currentWindow:[]});const E=t.taState[x];t.idx>E.lastIdx&&(E.lastIdx>=0&&(E.prevWindow=[...E.currentWindow]),E.lastIdx=t.idx);const S=[...E.prevWindow];if(S.unshift(l),S.length<n)return E.currentWindow=S,NaN;S.length>n&&S.pop(),E.currentWindow=S;let p=0,g=0;for(let _=0;_<n;_++){const b=n-_;p+=S[_]*b,g+=b}const v=p/g;return t.precision(v)}}function Dh(t){return e=>{const i=t.get(t.data.close,0),r=t.get(t.data.high,0),s=t.get(t.data.low,0),a=t.get(t.data.volume,0);if(isNaN(i)||isNaN(r)||isNaN(s)||isNaN(a))return NaN;const n=(r-s)*a;if(n===0)return t.precision(0);const o=(2*i-r-s)/n;return t.precision(o)}}function Th(t){return(e,i,r,s,a)=>{const n=w.from(i).get(0),o=w.from(r).get(0);let u=!0;typeof s=="string"?a=s:s!==void 0&&(u=w.from(s).get(0));let c;const h=t.get(t.data.high,0),d=t.get(t.data.low,0);if(u){const _=t.get(t.data.close,1);isNaN(_)?c=NaN:c=Math.max(h-d,Math.abs(h-_),Math.abs(d-_))}else c=h-d;const l=w.from(e).get(0);t.taState||(t.taState={});const m=a||`kc_${n}_${o}_${u}`;t.taState[m]||(t.taState[m]={lastIdx:-1,basisState:{prevEma:null,initSum:0,initCount:0},rangeState:{prevEma:null,initSum:0,initCount:0},currentBasisState:{prevEma:null,initSum:0,initCount:0},currentRangeState:{prevEma:null,initSum:0,initCount:0}});const x=t.taState[m];t.idx>x.lastIdx&&(x.lastIdx>=0&&(x.basisState={...x.currentBasisState},x.rangeState={...x.currentRangeState}),x.lastIdx=t.idx);const E=(_,b,C,A)=>{if(isNaN(C))return Object.assign(b,_),b.prevEma!==null?b.prevEma:NaN;let D=_.initCount,B=_.initSum,k=_.prevEma;if(D<A){if(B+=C,D++,b.initSum=B,b.initCount=D,b.prevEma=k,D===A){const Z=B/A;return b.prevEma=Z,Z}return NaN}const O=2/(A+1),W=C*O+k*(1-O);return b.prevEma=W,b.initSum=B,b.initCount=D,W},S=E(x.basisState,x.currentBasisState,l,n),p=E(x.rangeState,x.currentRangeState,c,n);if(isNaN(S)||isNaN(p))return[[NaN,NaN,NaN]];const g=S+p*o,v=S-p*o;return[[t.precision(S),t.precision(g),t.precision(v)]]}}function Ph(t){return(e,i,r,s,a)=>{const n=w.from(i).get(0),o=w.from(r).get(0);let u=!0;typeof s=="string"?a=s:s!==void 0&&(u=w.from(s).get(0)),t.taState||(t.taState={});const c=a||`kcw_${n}_${o}_${u}`;t.taState[c]||(t.taState[c]={lastIdx:-1,basisState:{prevEma:null,initSum:0,initCount:0},rangeState:{prevEma:null,initSum:0,initCount:0},currentBasisState:{prevEma:null,initSum:0,initCount:0},currentRangeState:{prevEma:null,initSum:0,initCount:0}});const h=t.taState[c];t.idx>h.lastIdx&&(h.lastIdx>=0&&(h.basisState={...h.currentBasisState},h.rangeState={...h.currentRangeState}),h.lastIdx=t.idx);const d=(v,_,b,C)=>{if(isNaN(b))return Object.assign(_,v),_.prevEma!==null?_.prevEma:NaN;let A=v.initCount,D=v.initSum,B=v.prevEma;if(A<C){if(D+=b,A++,_.initSum=D,_.initCount=A,_.prevEma=B,A===C){const W=D/C;return _.prevEma=W,W}return NaN}const k=2/(C+1),O=b*k+B*(1-k);return _.prevEma=O,_.initSum=D,_.initCount=A,O};let l;const m=t.get(t.data.high,0),x=t.get(t.data.low,0);if(u){const v=t.get(t.data.close,1);isNaN(v)?l=NaN:l=Math.max(m-x,Math.abs(m-v),Math.abs(x-v))}else l=m-x;const E=w.from(e).get(0),S=d(h.basisState,h.currentBasisState,E,n),p=d(h.rangeState,h.currentRangeState,l,n);if(isNaN(S)||isNaN(p))return NaN;if(S===0)return t.precision(0);const g=2*p*o/S;return t.precision(g)}}function Oh(t){return(e,i,r,s)=>{const a=w.from(i).get(0),n=w.from(r).get(0);t.taState||(t.taState={});const o=s||`linreg_${a}_${n}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],currentWindow:[]});const u=t.taState[o];t.idx>u.lastIdx&&(u.lastIdx>=0&&(u.prevWindow=[...u.currentWindow]),u.lastIdx=t.idx);const c=w.from(e).get(0),h=[...u.prevWindow];if(h.unshift(c),h.length>a&&h.pop(),u.currentWindow=h,h.length<a)return NaN;let d=0,l=0,m=0,x=0;const E=a;for(let v=0;v<a;v++){const _=a-1-v,b=h[v];d+=_,l+=b,m+=_*b,x+=_*_}const S=E*x-d*d;if(S===0)return NaN;const p=(E*m-d*l)/S,g=(l-p*d)/E+p*(a-1-n);return t.precision(g)}}function Fh(t){return(e,i,r)=>{typeof i=="string"&&r===void 0&&(r=i,i=e,e=t.data.low);const s=w.from(i).get(0);t.taState||(t.taState={});const a=r||`lowest_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],currentWindow:[]});const n=t.taState[a];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevWindow=[...n.currentWindow]),n.lastIdx=t.idx);const o=w.from(e).get(0),u=[...n.prevWindow];if(u.unshift(o),u.length<s)return n.currentWindow=u,NaN;u.length>s&&u.pop(),n.currentWindow=u;const c=u.filter(d=>!isNaN(d)&&d!==void 0),h=c.length>0?Math.min(...c):NaN;return t.precision(h)}}function Rh(t){return(e,i,r)=>{const s=w.from(i).get(0),a=w.from(e);if(t.idx<s-1)return NaN;let n=1/0,o=NaN;for(let u=0;u<s;u++){const c=a.get(u);isNaN(c)||(isNaN(o)||c<n)&&(n=c,o=-u)}return o}}function Bh(t){return(e,i,r,s,a)=>{const n=w.from(i).get(0),o=w.from(r).get(0),u=w.from(s).get(0),c=a||`macd_${n}_${o}_${u}`,h=`${c}_fast`,d=`${c}_slow`,l=`${c}_signal`,m=t.pine.ta.ema(e,n,h),x=t.pine.ta.ema(e,o,d);let E=NaN;!isNaN(m)&&!isNaN(x)&&(E=m-x);let S=NaN;isNaN(E)||(S=t.pine.ta.ema(E,u,l));let p=NaN;return!isNaN(E)&&!isNaN(S)&&(p=E-S),[[t.precision(E),t.precision(S),t.precision(p)]]}}function Vh(t){return(e,i,r)=>{const s=w.from(i).get(0);t.taState||(t.taState={});const a=r||`median_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],currentWindow:[]});const n=t.taState[a];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevWindow=[...n.currentWindow]),n.lastIdx=t.idx);const o=w.from(e).get(0),u=[...n.prevWindow];if(u.unshift(o),u.length>s&&u.pop(),n.currentWindow=u,u.length<s)return NaN;const c=u.slice().sort((l,m)=>l-m),h=Math.floor(s/2),d=s%2===0?(c[h-1]+c[h])/2:c[h];return t.precision(d)}}function Lh(t){return(e,i,r)=>{const s=w.from(i).get(0);t.taState||(t.taState={});const a=r||`mfi_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevUpperWindow:[],prevLowerWindow:[],prevUpperSum:0,prevLowerSum:0,currentUpperWindow:[],currentLowerWindow:[],currentUpperSum:0,currentLowerSum:0});const n=t.taState[a];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevUpperWindow=[...n.currentUpperWindow],n.prevLowerWindow=[...n.currentLowerWindow],n.prevUpperSum=n.currentUpperSum,n.prevLowerSum=n.currentLowerSum),n.lastIdx=t.idx);const o=w.from(e).get(0),u=w.from(e).get(1),c=t.get(t.data.volume,0);if(isNaN(o)||isNaN(c))return NaN;const h=isNaN(u)?NaN:o-u,d=c*(h<=0?0:o),l=c*(h>=0?0:o),m=[...n.prevUpperWindow],x=[...n.prevLowerWindow];let E=n.prevUpperSum,S=n.prevLowerSum;if(m.unshift(d),x.unshift(l),E+=d,S+=l,m.length<s)return n.currentUpperWindow=m,n.currentLowerWindow=x,n.currentUpperSum=E,n.currentLowerSum=S,NaN;if(m.length>s){const g=m.pop(),v=x.pop();E-=g,S-=v}if(n.currentUpperWindow=m,n.currentLowerWindow=x,n.currentUpperSum=E,n.currentLowerSum=S,S===0)return t.precision(100);if(E===0)return t.precision(0);const p=100-100/(1+E/S);return t.precision(p)}}function Mh(t){return(e,i,r)=>{const s=w.from(i).get(0),a=w.from(e);if(t.idx<s-1)return NaN;const n=new Map;for(let c=0;c<s;c++){const h=a.get(c);isNaN(h)||n.set(h,(n.get(h)||0)+1)}if(n.size===0)return NaN;let o=NaN,u=-1;for(const[c,h]of n.entries())h>u?(u=h,o=c):h===u&&c<o&&(o=c);return o}}function Wh(t){return(e,i,r)=>{const s=w.from(i).get(0);return t.pine.ta.change(e,s,r)}}function jh(t){return e=>{t.taState||(t.taState={});const i=e||"nvi";t.taState[i]||(t.taState[i]={lastIdx:-1,committedNVI:1,tentativeNVI:1});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.committedNVI=r.tentativeNVI),r.lastIdx=t.idx);const s=t.get(t.data.close,0),a=t.get(t.data.close,1),n=t.get(t.data.volume,0),o=t.get(t.data.volume,1),u=isNaN(s)?0:s,c=isNaN(a)?0:a,h=isNaN(n)?0:n,d=isNaN(o)?0:o;let l=r.committedNVI;if(!(u===0||c===0)&&h<d){const m=(u-c)/c;l=l+m*l}return r.tentativeNVI=l,t.precision(l)}}function $h(t){return()=>{t.taState||(t.taState={});const e="obv";t.taState[e]||(t.taState[e]={lastIdx:-1,committedOBV:0,tentativeOBV:0});const i=t.taState[e];t.idx>i.lastIdx&&(i.lastIdx>=0&&(i.committedOBV=i.tentativeOBV),i.lastIdx=t.idx);const r=t.get(t.data.close,0),s=t.get(t.data.volume,0),a=t.get(t.data.close,1);if(isNaN(a))return i.tentativeOBV=0,t.precision(0);let n=i.committedOBV;return r>a?n+=s:r<a&&(n-=s),i.tentativeOBV=n,t.precision(n)}}function qh(t){return(e,i,r)=>e instanceof w?i?new w(e.data,e.offset+i):e:(t.params[r]||(t.params[r]=[]),Array.isArray(e)?new w(e,i||0):(t.params[r].length===0?t.params[r].push(e):t.params[r][t.params[r].length-1]=e,new w(t.params[r],0)))}function Hh(t){return(e,i,r,s)=>{const a=w.from(i).get(0),n=w.from(r).get(0),o=w.from(e);if(t.idx<a-1)return NaN;const u=[];for(let x=0;x<a;x++){const E=o.get(x);if(isNaN(E))return NaN;u.push(E)}u.sort((x,E)=>x-E);let c=n/100*a-.5;c<0&&(c=0),c>a-1&&(c=a-1);const h=Math.floor(c),d=Math.ceil(c);if(h===d)return t.precision(u[h]);const l=c-h,m=u[h]+l*(u[d]-u[h]);return t.precision(m)}}function Uh(t){return(e,i,r,s)=>{const a=w.from(i).get(0),n=w.from(r).get(0),o=w.from(e);if(t.idx<a-1)return NaN;const u=[];for(let h=0;h<a;h++){const d=o.get(h);isNaN(d)||u.push(d)}if(u.length===0)return NaN;u.sort((h,d)=>h-d);let c=Math.ceil(n/100*u.length)-1;return c<0&&(c=0),c>=u.length&&(c=u.length-1),t.precision(u[c])}}function Gh(t){return(e,i,r)=>{const s=w.from(i).get(0),a=w.from(e);if(t.idx<s)return NaN;const n=a.get(0);if(isNaN(n))return NaN;let o=0,u=0;for(let c=1;c<=s;c++){const h=a.get(c);isNaN(h)||(u++,h<=n&&o++)}return u===0?NaN:t.precision(o/u*100)}}function Kh(t,e,i){const r=new Array(t.length).fill(NaN);for(let s=e+i;s<t.length;s++){const a=t[s-i];let n=!0;for(let o=1;o<=e;o++)if(t[s-i-o]>=a){n=!1;break}if(n){for(let o=1;o<=i;o++)if(t[s-i+o]>=a){n=!1;break}}n&&(r[s]=a)}return r}function zh(t){return(e,i,r,s)=>{typeof r=="string"&&(r=i,i=e,e=t.data.high);const a=w.from(i).get(0),n=w.from(r).get(0),o=w.from(e).toArray(),u=Kh(o,a,n),c=t.idx;return t.precision(u[c])}}function Yh(t,e,i){const r=new Array(t.length).fill(NaN);for(let s=e+i;s<t.length;s++){const a=t[s-i];let n=!0;for(let o=1;o<=e;o++)if(t[s-i-o]<=a){n=!1;break}if(n){for(let o=1;o<=i;o++)if(t[s-i+o]<=a){n=!1;break}}n&&(r[s]=a)}return r}function Qh(t){return(e,i,r,s)=>{typeof r=="string"&&(r=i,i=e,e=t.data.low);const a=w.from(i).get(0),n=w.from(r).get(0),o=w.from(e).toArray(),u=Yh(o,a,n),c=t.idx;return t.precision(u[c])}}function Jh(t){return e=>{t.taState||(t.taState={});const i=e||"pvi";t.taState[i]||(t.taState[i]={lastIdx:-1,committedPVI:1,tentativePVI:1});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.committedPVI=r.tentativePVI),r.lastIdx=t.idx);const s=t.get(t.data.close,0),a=t.get(t.data.close,1),n=t.get(t.data.volume,0),o=t.get(t.data.volume,1),u=isNaN(s)?0:s,c=isNaN(a)?0:a,h=isNaN(n)?0:n,d=isNaN(o)?0:o;let l=r.committedPVI;if(!(u===0||c===0)&&h>d){const m=(u-c)/c;l=l+m*l}return r.tentativePVI=l,t.precision(l)}}function Xh(t){return e=>{t.taState||(t.taState={});const i=e||"pvt";t.taState[i]||(t.taState[i]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.prevCumulativeSum=r.currentCumulativeSum),r.lastIdx=t.idx);const s=t.get(t.data.close,0),a=t.get(t.data.close,1),n=t.get(t.data.volume,0);let o=r.prevCumulativeSum;if(!isNaN(s)&&!isNaN(a)&&!isNaN(n)&&a!==0){const u=(s-a)/a*n;o+=u}return r.currentCumulativeSum=o,t.precision(o)}}function Zh(t){return(e,i,r)=>{const s=t.pine.ta.highest(e,i,(r||"range")+"_h"),a=t.pine.ta.lowest(e,i,(r||"range")+"_l");return isNaN(s)||isNaN(a)?NaN:t.precision(s-a)}}function tl(t){return(e,i,r)=>{const s=w.from(i).get(0),a=w.from(e);for(let n=0;n<s;n++){const o=a.get(n),u=a.get(n+1);if(isNaN(o)||isNaN(u)||o<=u)return!1}return!0}}function el(t){return(e,i,r)=>{const s=w.from(i).get(0);t.taState||(t.taState={});const a=r||`rma_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevRma:null,prevInitSum:0,prevInitCount:0,currentRma:null,currentInitSum:0,currentInitCount:0});const n=t.taState[a];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevRma=n.currentRma,n.prevInitSum=n.currentInitSum,n.prevInitCount=n.currentInitCount),n.lastIdx=t.idx);const o=w.from(e).get(0)||0;let u=n.prevInitCount,c=n.prevInitSum,h=n.prevRma;if(u<s){if(c+=o,u++,n.currentInitSum=c,n.currentInitCount=u,u===s){const m=c/s;return n.currentRma=m,t.precision(m)}return NaN}const d=1/s,l=o*d+h*(1-d);return n.currentRma=l,t.precision(l)}}function il(t){return(e,i,r)=>{const s=w.from(i).get(0);t.taState||(t.taState={});const a=r||`roc_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],currentWindow:[]});const n=t.taState[a];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevWindow=[...n.currentWindow]),n.lastIdx=t.idx);const o=w.from(e).get(0),u=[...n.prevWindow];if(u.unshift(o),u.length<=s)return n.currentWindow=u,NaN;u.length>s+1&&u.pop(),n.currentWindow=u;const c=u[s],h=(o-c)/c*100;return t.precision(h)}}function rl(t){return(e,i,r)=>{const s=w.from(i).get(0);t.taState||(t.taState={});const a=r||`rsi_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevPrevValue:null,prevAvgGain:0,prevAvgLoss:0,prevInitGains:[],prevInitLosses:[],currentPrevValue:null,currentAvgGain:0,currentAvgLoss:0,currentInitGains:[],currentInitLosses:[]});const n=t.taState[a];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevPrevValue=n.currentPrevValue,n.prevAvgGain=n.currentAvgGain,n.prevAvgLoss=n.currentAvgLoss,n.prevInitGains=[...n.currentInitGains],n.prevInitLosses=[...n.currentInitLosses]),n.lastIdx=t.idx);const o=w.from(e).get(0),u=n.prevPrevValue;let c=n.prevAvgGain,h=n.prevAvgLoss;const d=[...n.prevInitGains],l=[...n.prevInitLosses];if(u!==null){const m=o-u,x=m>0?m:0,E=m<0?-m:0;if(d.length<s){if(d.push(x),l.push(E),n.currentInitGains=d,n.currentInitLosses=l,n.currentPrevValue=o,d.length===s){c=d.reduce((g,v)=>g+v,0)/s,h=l.reduce((g,v)=>g+v,0)/s,n.currentAvgGain=c,n.currentAvgLoss=h;const p=h===0?100:100-100/(1+c/h);return t.precision(p)}return NaN}c=(c*(s-1)+x)/s,h=(h*(s-1)+E)/s,n.currentAvgGain=c,n.currentAvgLoss=h,n.currentPrevValue=o;const S=h===0?100:100-100/(1+c/h);return t.precision(S)}return n.currentPrevValue=o,n.currentInitGains=[],n.currentInitLosses=[],NaN}}function sl(t){return(e,i,r,s)=>{const a=w.from(e).get(0),n=w.from(i).get(0),o=w.from(r).get(0);t.taState||(t.taState={});const u=s||`sar_${a}_${n}_${o}`;t.taState[u]||(t.taState[u]={lastIdx:-1,prevResult:NaN,prevMaxMin:NaN,prevAcceleration:NaN,prevIsBelow:!1,prevBarIndex:0,currentResult:NaN,currentMaxMin:NaN,currentAcceleration:NaN,currentIsBelow:!1,currentBarIndex:0});const c=t.taState[u];t.idx>c.lastIdx&&(c.lastIdx>=0&&(c.prevResult=c.currentResult,c.prevMaxMin=c.currentMaxMin,c.prevAcceleration=c.currentAcceleration,c.prevIsBelow=c.currentIsBelow,c.prevBarIndex=c.currentBarIndex),c.lastIdx=t.idx);let h=c.prevResult,d=c.prevMaxMin,l=c.prevAcceleration,m=c.prevIsBelow,x=c.prevBarIndex;const E=t.get(t.data.high,0),S=t.get(t.data.low,0),p=t.get(t.data.close,0),g=t.get(t.data.close,1),v=t.get(t.data.high,1),_=t.get(t.data.low,1),b=t.get(t.data.high,2),C=t.get(t.data.low,2);if(isNaN(E)||isNaN(S)||isNaN(p))return c.currentResult=h,c.currentMaxMin=d,c.currentAcceleration=l,c.currentIsBelow=m,c.currentBarIndex=x,NaN;let A=!1;return x===1&&(p>g?(m=!0,d=E,h=_):(m=!1,d=S,h=v),A=!0,l=a),x>=1&&(h=h+l*(d-h),m?h>S&&(A=!0,m=!1,h=Math.max(E,d),d=S,l=a):h<E&&(A=!0,m=!0,h=Math.min(S,d),d=E,l=a),A||(m?E>d&&(d=E,l=Math.min(l+n,o)):S<d&&(d=S,l=Math.min(l+n,o))),m?(h=Math.min(h,_),x>1&&(h=Math.min(h,C))):(h=Math.max(h,v),x>1&&(h=Math.max(h,b)))),x++,c.currentResult=h,c.currentMaxMin=d,c.currentAcceleration=l,c.currentIsBelow=m,c.currentBarIndex=x,x<=1?NaN:t.precision(h)}}function nl(t){return(e,i,r)=>{const s=w.from(i).get(0);t.taState||(t.taState={});const a=r||`sma_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const n=t.taState[a];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevWindow=[...n.currentWindow],n.prevSum=n.currentSum),n.lastIdx=t.idx);const o=w.from(e).get(0),u=[...n.prevWindow];u.unshift(o),u.length>s&&u.pop();let c;const h=o==null||Number.isNaN(o);let d=!Number.isNaN(n.prevSum)&&!h;if(d){let m=n.prevSum+o;if(n.prevWindow.length>=s){const x=n.prevWindow[n.prevWindow.length-1];x==null||Number.isNaN(x)?d=!1:m-=x}d&&(c=m)}if(!d){c=0;let m=!1;for(const x of u){if(x==null||Number.isNaN(x)){m=!0;break}c+=x}m&&(c=NaN)}if(n.currentWindow=u,n.currentSum=c,u.length<s)return NaN;const l=c/s;return t.precision(l)}}function al(t){return(e,i,r=!0,s)=>{const a=w.from(i).get(0),n=w.from(r).get(0);t.taState||(t.taState={});const o=s||`stdev_${a}_${n}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const u=t.taState[o];t.idx>u.lastIdx&&(u.lastIdx>=0&&(u.prevWindow=[...u.currentWindow],u.prevSum=u.currentSum),u.lastIdx=t.idx);const c=w.from(e).get(0);if(c==null||isNaN(c))return NaN;const h=[...u.prevWindow];let d=u.prevSum;if(h.unshift(c),d+=c,h.length<a)return u.currentWindow=h,u.currentSum=d,NaN;if(h.length>a){const S=h.pop();d-=S}u.currentWindow=h,u.currentSum=d;const l=d/a;let m=0;for(let S=0;S<a;S++)m+=Math.pow(h[S]-l,2);const x=n?a:a-1,E=Math.sqrt(m/x);return t.precision(E)}}function ol(t){return(e,i,r,s,a)=>{const n=w.from(s).get(0);t.taState||(t.taState={});const o=a||`stoch_${n}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevHighWindow:[],prevLowWindow:[],currentHighWindow:[],currentLowWindow:[]});const u=t.taState[o];t.idx>u.lastIdx&&(u.lastIdx>=0&&(u.prevHighWindow=[...u.currentHighWindow],u.prevLowWindow=[...u.currentLowWindow]),u.lastIdx=t.idx);const c=w.from(e).get(0),h=w.from(i).get(0),d=w.from(r).get(0);if(isNaN(c)||isNaN(h)||isNaN(d))return u.currentHighWindow=[...u.prevHighWindow],u.currentLowWindow=[...u.prevLowWindow],NaN;const l=[...u.prevHighWindow],m=[...u.prevLowWindow];if(l.unshift(h),m.unshift(d),l.length>n&&(l.pop(),m.pop()),u.currentHighWindow=l,u.currentLowWindow=m,l.length<n)return NaN;let x=l[0],E=m[0];for(let g=1;g<n;g++)l[g]>x&&(x=l[g]),m[g]<E&&(E=m[g]);const S=x-E;if(S===0)return NaN;const p=100*(c-E)/S;return t.precision(p)}}function ul(t){return(e,i,r)=>{const s=w.from(e).get(0),a=w.from(i).get(0);t.taState||(t.taState={});const n=r||`supertrend_${s}_${a}`;t.taState[n]||(t.taState[n]={lastIdx:-1,prevTrSum:0,prevAtrValue:NaN,prevAtrCount:0,prevLowerBand:NaN,prevUpperBand:NaN,prevSuperTrend:NaN,prevDirection:NaN,prevClose:NaN,currentTrSum:0,currentAtrValue:NaN,currentAtrCount:0,currentLowerBand:NaN,currentUpperBand:NaN,currentSuperTrend:NaN,currentDirection:NaN,currentClose:NaN});const o=t.taState[n];t.idx>o.lastIdx&&(o.lastIdx>=0&&(o.prevTrSum=o.currentTrSum,o.prevAtrValue=o.currentAtrValue,o.prevAtrCount=o.currentAtrCount,o.prevLowerBand=o.currentLowerBand,o.prevUpperBand=o.currentUpperBand,o.prevSuperTrend=o.currentSuperTrend,o.prevDirection=o.currentDirection,o.prevClose=o.currentClose),o.lastIdx=t.idx);const u=t.get(t.data.high,0),c=t.get(t.data.low,0),h=t.get(t.data.close,0);if(isNaN(u)||isNaN(c)||isNaN(h))return[[NaN,NaN]];const d=(u+c)/2,l=o.prevClose;let m;isNaN(l)?m=u-c:m=Math.max(u-c,Math.abs(u-l),Math.abs(c-l));let x=o.prevAtrCount,E=o.prevTrSum,S=o.prevAtrValue;x++,x<=a?(E+=m,x===a&&(S=E/a)):S=(S*(a-1)+m)/a;const p=S;if(o.currentAtrCount=x,o.currentTrSum=E,o.currentAtrValue=S,o.currentClose=h,isNaN(p))return[[NaN,NaN]];let g=d+s*p,v=d-s*p;const _=isNaN(o.prevLowerBand)?0:o.prevLowerBand,b=isNaN(o.prevUpperBand)?0:o.prevUpperBand;isNaN(o.prevLowerBand)||v>_||l<_||(v=_),isNaN(o.prevUpperBand)||g<b||l>b||(g=b);let C,A;const D=o.prevSuperTrend;return x===a?C=1:D===o.prevUpperBand?C=h>g?-1:1:C=h<v?1:-1,A=C===-1?v:g,o.currentLowerBand=v,o.currentUpperBand=g,o.currentSuperTrend=A,o.currentDirection=C,[[t.precision(A),C]]}}function cl(t){return(e,i)=>{const r=[1,2,2,1],s=6;t.taState||(t.taState={});const a=i||"swma";t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],currentWindow:[]});const n=t.taState[a];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevWindow=[...n.currentWindow]),n.lastIdx=t.idx);const o=w.from(e).get(0),u=[...n.prevWindow];if(u.unshift(o),u.length<4)return n.currentWindow=u,NaN;u.length>4&&u.pop(),n.currentWindow=u;let c=0;for(let h=0;h<4;h++)c+=r[h]*u[3-h];return c/=s,t.precision(c)}}function hl(t){return(e,i)=>{let r=!0;typeof e=="string"||e!==void 0&&(r=w.from(e).get(0));const s=t.get(t.data.high,0),a=t.get(t.data.low,0),n=t.get(t.data.close,1);if(isNaN(n))return r?t.precision(s-a):NaN;const o=Math.max(s-a,Math.abs(s-n),Math.abs(a-n));return t.precision(o)}}function ll(t){return(e,i,r,s)=>{const a=w.from(i).get(0),n=w.from(r).get(0);t.taState||(t.taState={});const o=s||`tsi_${a}_${n}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevSource:NaN,prevEma1PcValue:NaN,prevEma1PcCount:0,prevEma1PcSum:0,prevEma2PcValue:NaN,prevEma2PcCount:0,prevEma2PcSum:0,prevEma1AbsValue:NaN,prevEma1AbsCount:0,prevEma1AbsSum:0,prevEma2AbsValue:NaN,prevEma2AbsCount:0,prevEma2AbsSum:0,currentSource:NaN,currentEma1PcValue:NaN,currentEma1PcCount:0,currentEma1PcSum:0,currentEma2PcValue:NaN,currentEma2PcCount:0,currentEma2PcSum:0,currentEma1AbsValue:NaN,currentEma1AbsCount:0,currentEma1AbsSum:0,currentEma2AbsValue:NaN,currentEma2AbsCount:0,currentEma2AbsSum:0});const u=t.taState[o];t.idx>u.lastIdx&&(u.lastIdx>=0&&(u.prevSource=u.currentSource,u.prevEma1PcValue=u.currentEma1PcValue,u.prevEma1PcCount=u.currentEma1PcCount,u.prevEma1PcSum=u.currentEma1PcSum,u.prevEma2PcValue=u.currentEma2PcValue,u.prevEma2PcCount=u.currentEma2PcCount,u.prevEma2PcSum=u.currentEma2PcSum,u.prevEma1AbsValue=u.currentEma1AbsValue,u.prevEma1AbsCount=u.currentEma1AbsCount,u.prevEma1AbsSum=u.currentEma1AbsSum,u.prevEma2AbsValue=u.currentEma2AbsValue,u.prevEma2AbsCount=u.currentEma2AbsCount,u.prevEma2AbsSum=u.currentEma2AbsSum),u.lastIdx=t.idx);const c=w.from(e).get(0);if(isNaN(c))return NaN;const h=isNaN(u.prevSource)?NaN:c-u.prevSource;if(u.currentSource=c,isNaN(h))return NaN;const d=Math.abs(h),l=2/(n+1),m=2/(a+1),x=2/(n+1),E=2/(a+1);let S=u.prevEma1PcCount,p=u.prevEma1PcSum,g=u.prevEma1PcValue;S++,S<=n?(p+=h,S===n&&(g=p/n)):g=h*l+g*(1-l);let v=u.prevEma1AbsCount,_=u.prevEma1AbsSum,b=u.prevEma1AbsValue;if(v++,v<=n?(_+=d,v===n&&(b=_/n)):b=d*x+b*(1-x),isNaN(g)||isNaN(b))return u.currentEma1PcCount=S,u.currentEma1PcSum=p,u.currentEma1PcValue=g,u.currentEma1AbsCount=v,u.currentEma1AbsSum=_,u.currentEma1AbsValue=b,NaN;let C=u.prevEma2PcCount,A=u.prevEma2PcSum,D=u.prevEma2PcValue;C++,C<=a?(A+=g,C===a&&(D=A/a)):D=g*m+D*(1-m);let B=u.prevEma2AbsCount,k=u.prevEma2AbsSum,O=u.prevEma2AbsValue;if(B++,B<=a?(k+=b,B===a&&(O=k/a)):O=b*E+O*(1-E),u.currentEma1PcCount=S,u.currentEma1PcSum=p,u.currentEma1PcValue=g,u.currentEma1AbsCount=v,u.currentEma1AbsSum=_,u.currentEma1AbsValue=b,u.currentEma2PcCount=C,u.currentEma2PcSum=A,u.currentEma2PcValue=D,u.currentEma2AbsCount=B,u.currentEma2AbsSum=k,u.currentEma2AbsValue=O,isNaN(D)||isNaN(O))return NaN;if(O===0)return t.precision(0);const W=D/O;return t.precision(W)}}function pl(t){return(e,i,r,s)=>{t.taState||(t.taState={});const a=s||"valuewhen";t.taState[a]||(t.taState[a]={lastIdx:-1,prevValues:[],currentValues:[]});const n=t.taState[a];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevValues=[...n.currentValues]),n.lastIdx=t.idx);const o=w.from(e).get(0),u=w.from(i).get(0),c=w.from(r).get(0),h=[...n.prevValues];if(o&&h.push(u),n.currentValues=h,isNaN(c)||c<0)return NaN;const d=h.length-1-c;if(d<0)return NaN;const l=h[d];return typeof l=="number"?t.precision(l):l}}function dl(t){return(e,i,r)=>{const s=w.from(i).get(0);t.taState||(t.taState={});const a=r||`variance_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],currentWindow:[]});const n=t.taState[a];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevWindow=[...n.currentWindow]),n.lastIdx=t.idx);const o=w.from(e).get(0),u=[...n.prevWindow];if(u.unshift(o),u.length>s&&u.pop(),n.currentWindow=u,u.length<s)return NaN;let c=0,h=0;for(let m=0;m<s;m++)c+=u[m],h+=u[m]*u[m];const d=c/s,l=h/s-d*d;return t.precision(l)}}function fl(t){return(e,i)=>{t.taState||(t.taState={});const r=i||"vwap";t.taState[r]||(t.taState[r]={lastIdx:-1,prevCumulativePV:0,prevCumulativeVolume:0,prevLastSessionDate:null,currentCumulativePV:0,currentCumulativeVolume:0,currentLastSessionDate:null});const s=t.taState[r];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevCumulativePV=s.currentCumulativePV,s.prevCumulativeVolume=s.currentCumulativeVolume,s.prevLastSessionDate=s.currentLastSessionDate),s.lastIdx=t.idx);const a=w.from(e).get(0),n=w.from(t.data.volume).get(0),o=w.from(t.data.openTime).get(0),u=new Date(o).toISOString().slice(0,10);let c=s.prevCumulativePV,h=s.prevCumulativeVolume,d=s.prevLastSessionDate;if(d!==u&&(c=0,h=0,d=u),c+=a*n,h+=n,s.currentCumulativePV=c,s.currentCumulativeVolume=h,s.currentLastSessionDate=d,h===0)return NaN;const l=c/h;return t.precision(l)}}function ml(t){return(e,i,r)=>{const s=w.from(i).get(0);t.taState||(t.taState={});const a=r||`vwma_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevVolumeWindow:[],currentWindow:[],currentVolumeWindow:[]});const n=t.taState[a];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevWindow=[...n.currentWindow],n.prevVolumeWindow=[...n.currentVolumeWindow]),n.lastIdx=t.idx);const o=w.from(e).get(0),u=t.get(t.data.volume,0),c=[...n.prevWindow],h=[...n.prevVolumeWindow];if(c.unshift(o),h.unshift(u),c.length>s&&(c.pop(),h.pop()),n.currentWindow=c,n.currentVolumeWindow=h,c.length<s)return NaN;let d=0,l=0;for(let x=0;x<s;x++)d+=c[x]*h[x],l+=h[x];const m=d/l;return t.precision(m)}}function gl(t){return e=>{t.taState||(t.taState={});const i=e||"wad";t.taState[i]||(t.taState[i]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.prevCumulativeSum=r.currentCumulativeSum),r.lastIdx=t.idx);const s=t.get(t.data.close,0),a=t.get(t.data.high,0),n=t.get(t.data.low,0),o=t.get(t.data.close,1);if(isNaN(s)||isNaN(a)||isNaN(n))return r.currentCumulativeSum=r.prevCumulativeSum,t.precision(r.prevCumulativeSum);let u=0;if(!isNaN(o)){const h=Math.max(a,o),d=Math.min(n,o),l=s-o;l>0?u=s-d:l<0&&(u=s-h)}const c=r.prevCumulativeSum+u;return r.currentCumulativeSum=c,t.precision(c)}}function xl(t){return(e,i,r)=>{const s=w.from(i).get(0);t.taState||(t.taState={});const a=r||`wma_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],currentWindow:[]});const n=t.taState[a];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevWindow=[...n.currentWindow]),n.lastIdx=t.idx);const o=w.from(e).get(0),u=[...n.prevWindow];if(u.unshift(o),u.length<s)return n.currentWindow=u,NaN;u.length>s&&u.pop(),n.currentWindow=u;let c=0,h=0;for(let l=0;l<s;l++){const m=s-l;c+=u[l]*m,h+=m}const d=c/h;return t.precision(d)}}function yl(t){return(e,i)=>{const r=w.from(e).get(0);t.taState||(t.taState={});const s=i||`wpr_${r}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevHighWindow:[],prevLowWindow:[],currentHighWindow:[],currentLowWindow:[]});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevHighWindow=[...a.currentHighWindow],a.prevLowWindow=[...a.currentLowWindow]),a.lastIdx=t.idx);const n=t.get(t.data.high,0),o=t.get(t.data.low,0),u=t.get(t.data.close,0);if(isNaN(n)||isNaN(o)||isNaN(u))return a.currentHighWindow=[...a.prevHighWindow],a.currentLowWindow=[...a.prevLowWindow],NaN;const c=[...a.prevHighWindow],h=[...a.prevLowWindow];if(c.unshift(n),h.unshift(o),c.length>r&&(c.pop(),h.pop()),a.currentHighWindow=c,a.currentLowWindow=h,c.length<r)return NaN;let d=c[0],l=h[0];for(let E=1;E<r;E++)c[E]>d&&(d=c[E]),h[E]<l&&(l=h[E]);const m=d-l;if(m===0)return t.precision(0);const x=(d-u)/m*-100;return t.precision(x)}}function wl(t){return e=>{const i=t.get(t.data.close,0),r=t.get(t.data.open,0),s=t.get(t.data.high,0),a=t.get(t.data.low,0),n=t.get(t.data.volume,0);if(isNaN(i)||isNaN(r)||isNaN(s)||isNaN(a)||isNaN(n))return NaN;const o=s-a;if(o===0)return t.precision(0);const u=(i-r)/o*n;return t.precision(u)}}var vl=Object.defineProperty,bl=(t,e,i)=>e in t?vl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,T=(t,e,i)=>bl(t,typeof e!="symbol"?e+"":e,i);const _l={accdist:uh,alma:ch,atr:hh,barssince:lh,bb:ph,bbw:dh,cci:fh,change:mh,cmo:gh,cog:xh,correlation:yh,cross:wh,crossover:vh,crossunder:bh,cum:_h,dev:Eh,dmi:Sh,ema:Ch,falling:Nh,highest:Ah,highestbars:Ih,hma:kh,iii:Dh,kc:Th,kcw:Ph,linreg:Oh,lowest:Fh,lowestbars:Rh,macd:Bh,median:Vh,mfi:Lh,mode:Mh,mom:Wh,nvi:jh,obv:$h,param:qh,percentile_linear_interpolation:Hh,percentile_nearest_rank:Uh,percentrank:Gh,pivothigh:zh,pivotlow:Qh,pvi:Jh,pvt:Xh,range:Zh,rising:tl,rma:el,roc:il,rsi:rl,sar:sl,sma:nl,stdev:al,stoch:ol,supertrend:ul,swma:cl,tr:hl,tsi:ll,valuewhen:pl,variance:dl,vwap:fl,vwma:ml,wad:gl,wma:xl,wpr:yl,wvad:wl};class El{constructor(e){this.context=e,T(this,"accdist"),T(this,"alma"),T(this,"atr"),T(this,"barssince"),T(this,"bb"),T(this,"bbw"),T(this,"cci"),T(this,"change"),T(this,"cmo"),T(this,"cog"),T(this,"correlation"),T(this,"cross"),T(this,"crossover"),T(this,"crossunder"),T(this,"cum"),T(this,"dev"),T(this,"dmi"),T(this,"ema"),T(this,"falling"),T(this,"highest"),T(this,"highestbars"),T(this,"hma"),T(this,"iii"),T(this,"kc"),T(this,"kcw"),T(this,"linreg"),T(this,"lowest"),T(this,"lowestbars"),T(this,"macd"),T(this,"median"),T(this,"mfi"),T(this,"mode"),T(this,"mom"),T(this,"nvi"),T(this,"obv"),T(this,"param"),T(this,"percentile_linear_interpolation"),T(this,"percentile_nearest_rank"),T(this,"percentrank"),T(this,"pivothigh"),T(this,"pivotlow"),T(this,"pvi"),T(this,"pvt"),T(this,"range"),T(this,"rising"),T(this,"rma"),T(this,"roc"),T(this,"rsi"),T(this,"sar"),T(this,"sma"),T(this,"stdev"),T(this,"stoch"),T(this,"supertrend"),T(this,"swma"),T(this,"tr"),T(this,"tsi"),T(this,"valuewhen"),T(this,"variance"),T(this,"vwap"),T(this,"vwma"),T(this,"wad"),T(this,"wma"),T(this,"wpr"),T(this,"wvad"),Object.entries(_l).forEach(([i,r])=>{this[i]=r(e)})}}class Sl{constructor(e){this.context=e}logFormat(e,...i){return e.replace(/{(\d+)}/g,(r,s)=>i[s])}param(e,i=0,r){return w.from(e).get(i)}warning(e,...i){console.warn(this.logFormat(e,...i))}error(e,...i){console.error(this.logFormat(e,...i))}info(e,...i){console.log(this.logFormat(e,...i))}}class Cl{constructor(e){this.context=e}param(e,i=0,r){return w.from(e).get(i)}tostring(e){return String(e)}tonumber(e){return Number(e)}lower(e){return String(e).toLowerCase()}upper(e){return String(e).toUpperCase()}trim(e){return String(e).trim()}repeat(e,i,r=""){return Array(i).fill(e).join(r||"")}replace_all(e,i,r){return String(e).replaceAll(i,r)}replace(e,i,r,s=0){const a=String(e),n=String(i),o=String(r),u=Math.floor(Number(s))||0;if(n==="")return a;let c=0,h=0;for(;;){const d=a.indexOf(n,c);if(d===-1)return a;if(h===u)return a.substring(0,d)+o+a.substring(d+n.length);h++,c=d+n.length}}contains(e,i){return String(e).includes(i)}endswith(e,i){return String(e).endsWith(i)}startswith(e,i){return String(e).startsWith(i)}pos(e,i){const r=String(e).indexOf(i);return r===-1?NaN:r}length(e){return String(e).length}match(e,i){return String(e).match(new RegExp(i))}split(e,i){return[String(e).split(i)]}substring(e,i,r){return String(e).substring(i,r)}format(e,...i){return e.replace(/{(\d+)}/g,(r,s)=>i[s])}}class Nl{constructor(e){this.context=e}param(e,i=0,r){return w.from(e).get(i)}get main_period(){return this.context.timeframe}get period(){return this.context.timeframe}get multiplier(){const e=parseInt(this.context.timeframe);return isNaN(e)?1:e}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(e){return e<60?Math.ceil(e/5)*5+"S":e<3600*24?Math.ceil(e/60):e<=3600*24*7*52?e%(3600*24*7)===0?Math.ceil(e/604800)+"W":Math.ceil(e/(3600*24))+"D":"12M"}in_seconds(e){const i=parseInt(e),r=e.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 Qi=["series","title","color","linewidth","style","trackprice","histbase","offset","join","editable","show_last","display","format","precision","force_overlay"],Al=["series","title","style","location","color","offset","text","textcolor","editable","size","show_last","display","format","precision","force_overlay"],Il=["series","title","colorup","colordown","offset","minheight","maxheight","editable","show_last","display","format","precision","force_overlay"],kl=["open","high","low","close","title","color","editable","show_last","display","format","precision","force_overlay"],Dl=["open","high","low","close","title","color","wickcolor","editable","show_last","bordercolor","display","format","precision","force_overlay"],Ji=["color","offset","editable","show_last","title","display","force_overlay"],Tl=["plot1","plot2","color","title","editable","show_last","fillgaps","display"],Xi={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"},Pl={series:"series",title:"string",style:"string",location:"string",color:"string",offset:"number",text:"string",textcolor:"string",editable:"boolean",size:"string",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},Ol={series:"series",title:"string",colorup:"string",colordown:"string",offset:"number",minheight:"number",maxheight:"number",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},Fl={open:"series",high:"series",low:"series",close:"series",title:"string",color:"string",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},Rl={open:"series",high:"series",low:"series",close:"series",title:"string",color:"string",wickcolor:"string",bordercolor:"string",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},Zi={color:"string",offset:"number",editable:"boolean",show_last:"number",title:"string",display:"string",force_overlay:"boolean"},Bl={plot1:"object",plot2:"object",color:"string",title:"string",editable:"boolean",show_last:"number",fillgaps:"boolean",display:"string"};class Vl{constructor(e){this.context=e}extractPlotOptions(e){const i={};for(let r in e)i[r]=w.from(e[r]).get(0);return i}get linestyle_dashed(){return"linestyle_dashed"}get linestyle_dotted(){return"linestyle_dotted"}get linestyle_solid(){return"linestyle_solid"}get style_area(){return"style_area"}get style_areabr(){return"style_areabr"}get style_circles(){return"style_circles"}get style_columns(){return"style_columns"}get style_cross(){return"style_cross"}get style_histogram(){return"style_histogram"}get style_line(){return"style_line"}get style_linebr(){return"style_linebr"}get style_stepline(){return"style_stepline"}get style_stepline_diamond(){return"style_stepline_diamond"}get style_steplinebr(){return"style_steplinebr"}param(e,i=0,r){return w.from(e).get(i)}plotchar(...e){const i=At(e,Qi,Xi),{series:r,title:s,...a}=i,n=this.extractPlotOptions(a);this.context.plots[s]||(this.context.plots[s]={data:[],options:{...n,style:"char"},title:s});const o=w.from(r).get(0);return this.context.plots[s].data.push({title:s,time:this.context.marketData[this.context.idx].openTime,value:o}),this.context.plots[s]}any(...e){const i=At(e,Qi,Xi),{series:r,title:s,...a}=i,n=this.extractPlotOptions(a);if(!this.context.plots[s]){const u=n.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[s]={data:[],options:{...n,overlay:u},title:s}}const o=w.from(r).get(0);return this.context.plots[s].data.push({title:s,time:this.context.marketData[this.context.idx].openTime,value:o,options:{color:n.color,offset:n.offset}}),this.context.plots[s]}plotshape(...e){const i=At(e,Al,Pl),{series:r,title:s,...a}=i,n=this.extractPlotOptions(a);if(!this.context.plots[s]){const u=n.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[s]={data:[],options:{...n,style:"shape",shape:n.style,overlay:u},title:s}}const o=w.from(r).get(0);return this.context.plots[s].data.push({title:s,time:this.context.marketData[this.context.idx].openTime,value:o,options:n?.location==="absolute"||o?{text:n.text,textcolor:n.textcolor,color:n.color,offset:n.offset,shape:n.style,location:n.location,size:n.size}:void 0}),this.context.plots[s]}plotarrow(...e){const i=At(e,Il,Ol),{series:r,title:s,...a}=i,n=w.from(r).get(0),o=this.extractPlotOptions(a);if(!this.context.plots[s]){const u=o.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[s]={data:[],options:{...o,style:"shape",overlay:u},title:s}}return this.context.plots[s].data.push({title:s,time:this.context.marketData[this.context.idx].openTime,value:n,options:typeof n=="number"&&!isNaN(n)&&n!==0?{text:void 0,textcolor:void 0,color:n>0?o.colorup:o.colordown,offset:o.offset,shape:n>0?"arrowup":"arrowdown",location:n>0?"belowbar":"abovebar",height:o.maxheight}:void 0}),this.context.plots[s]}plotbar(...e){const i=At(e,kl,Fl),{open:r,high:s,low:a,close:n,title:o,...u}=i,c=this.extractPlotOptions(u);if(!this.context.plots[o]){const d=c.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[o]={data:[],options:{...c,style:"bar",overlay:d},title:o}}const h=[w.from(r).get(0),w.from(s).get(0),w.from(a).get(0),w.from(n).get(0)];this.context.plots[o].data.push({title:o,time:this.context.marketData[this.context.idx].openTime,value:h,options:{color:c.color}})}plotcandle(...e){const i=At(e,Dl,Rl),{open:r,high:s,low:a,close:n,title:o,...u}=i,c=this.extractPlotOptions(u);if(!this.context.plots[o]){const d=c.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[o]={data:[],options:{...c,style:"candle",overlay:d},title:o}}const h=[w.from(r).get(0),w.from(s).get(0),w.from(a).get(0),w.from(n).get(0)];return this.context.plots[o].data.push({title:o,time:this.context.marketData[this.context.idx].openTime,value:h,options:{color:c.color,wickcolor:c.wickcolor,bordercolor:c.bordercolor}}),this.context.plots[o]}bgcolor(...e){const i=At(e,Ji,Zi),{title:r,...s}=i,a=this.extractPlotOptions(s);if(!this.context.plots[r]){const n=a.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[r]={data:[],options:{...a,style:"background",overlay:n},title:r}}this.context.plots[r].data.push({title:r,time:this.context.marketData[this.context.idx].openTime,value:a.color&&a.color!=="na"&&a?.color.toString()!=="NaN",options:{color:a.color}})}barcolor(...e){const i=At(e,Ji,Zi),{title:r,...s}=i,a=this.extractPlotOptions(s);return this.context.plots[r]||(this.context.plots[r]={data:[],options:{...a,style:"barcolor"},title:r}),this.context.plots[r].data.push({title:r,time:this.context.marketData[this.context.idx].openTime,value:a.color&&a.color!=="na"&&a?.color.toString()!=="NaN",options:{color:a.color}}),this.context.plots[r]}}class Ll{constructor(e){this.context=e}get style_dashed(){return"dashed"}get style_solid(){return"solid"}get style_dotted(){return"dotted"}param(e,i=0,r){return w.from(e).get(i)}any(e,i,r,s,a,n,o){return this.context.pine.plot.any(e,{title:i,color:r,linestyle:s,linewidth:a,editable:n,display:o})}}class Ml{constructor(e){this.context=e}param(e,i=0,r){return w.from(e).get(i)}any(...e){const i=At(e,Tl,Bl),{plot1:r,plot2:s,color:a,title:n,editable:o,show_last:u,fillgaps:c,display:h}=i;this.context.plots[n]||(this.context.plots[n]={title:n,plot1:r.title,plot2:s.title,options:{color:a,editable:o,show_last:u,fillgaps:c,display:h,style:"fill"}})}}var Wl=Object.defineProperty,jl=(t,e,i)=>e in t?Wl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,U=(t,e,i)=>jl(t,typeof e!="symbol"?e+"":e,i);const cs=class oi{constructor({marketData:e,source:i,tickerId:r,timeframe:s,limit:a,sDate:n,eDate:o,fullContext:u,inputs:c}){U(this,"data",{open:new w([]),high:new w([]),low:new w([]),close:new w([]),volume:new w([]),hl2:new w([]),hlc3:new w([]),ohlc4:new w([]),hlcc4:new w([])}),U(this,"indicator"),U(this,"cache",{}),U(this,"taState",{}),U(this,"isSecondaryContext",!1),U(this,"NA",NaN),U(this,"lang"),U(this,"pine"),U(this,"idx",0),U(this,"params",{}),U(this,"const",{}),U(this,"var",{}),U(this,"let",{}),U(this,"lctx",new Map),U(this,"result"),U(this,"plots",{}),U(this,"marketData"),U(this,"source"),U(this,"tickerId"),U(this,"timeframe",""),U(this,"limit"),U(this,"sDate"),U(this,"eDate"),U(this,"fullContext"),U(this,"pineTSCode"),U(this,"inputs",{}),U(this,"_callStack",[]),this.marketData=e,this.source=i,this.tickerId=r,this.timeframe=s,this.limit=a,this.sDate=n,this.eDate=o,this.fullContext=u||this,this.inputs=c||{};const h=new Xu(this),d={Type:h.Type.bind(h),na:h.na.bind(h),color:h.color,nz:h.nz.bind(h),indicator:h.indicator.bind(h),fixnan:h.fixnan.bind(h),alertcondition:h.alertcondition.bind(h),bool:h.bool.bind(h)},l=this;this.pine={input:new wc(this),ta:new El(this),math:new th(this),request:new oh(this),array:new Eo(this),map:new Lo(this),matrix:new Wu(this),syminfo:null,timeframe:new Nl(this),barstate:new Hu(this),get bar_index(){return l.idx},get last_bar_index(){return l.data.close.length-1},get last_bar_time(){return l.data.openTime.get(l.data.openTime.length-1)},get timenow(){return new Date().getTime()},get inputs(){return l.inputs},log:new Sl(this),str:new Cl(this),...d,...no};const m=new Vl(this),x=new Ll(this),E=new Ml(this);this.bindContextObject(m,["plotchar","plotshape","plotarrow","plotbar","plotcandle","bgcolor","barcolor"]),this.bindContextObject(m,["any","param","linestyle_dashed","linestyle_dotted","linestyle_solid","style_area","style_areabr","style_circles","style_columns","style_cross","style_histogram","style_line","style_linebr","style_stepline","style_stepline_diamond","style_steplinebr"],"plot"),this.bindContextObject(x,["any","style_dashed","style_solid","style_dotted","param"],"hline"),this.bindContextObject(E,["any","param"],"fill")}bindContextObject(e,i,r=""){r&&!this.pine[r]&&(this.pine[r]={});const s=r?this.pine[r]:this.pine;for(const a of i)typeof e[a]=="function"?s[a]=e[a].bind(e):s[a]=e[a]}init(e,i,r=0){let s;return i instanceof w?s=i.get(0):Array.isArray(i)?Array.isArray(i[0])?s=i[0]:s=i[i.length-1+r]:s=i,e?e instanceof w?(e.data[e.data.length-1]=s,e):Array.isArray(e)?(e[e.length-1]=s,new w(e)):new w([s]):new w([s])}initVar(e,i){if(e)return e;let r;return i instanceof w?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 w([r])}precision(e,i=10){const r=10**i;return typeof e=="number"?Math.round(e*r)/r:e}param(e,i,r){return typeof e=="string"?e:e instanceof w?i?new w(e.data,e.offset+i):e:!Array.isArray(e)&&typeof e=="object"?e:(this.params[r]||(this.params[r]=[]),Array.isArray(e)?new w(e,i||0):(this.params[r].length===0?this.params[r].push(e):this.params[r][this.params[r].length-1]=e,new w(this.params[r],0)))}get(e,i){if(e instanceof w)return e.get(i);if(Array.isArray(e)){const r=e.length-1-i;return r<0||r>=e.length?NaN:e[r]}return e}set(e,i){if(e instanceof w){e.set(0,i);return}if(Array.isArray(e)){e.length>0?e[e.length-1]=i:e.push(i);return}}pushId(e){this._callStack.push(e)}popId(){this._callStack.pop()}peekId(){return this._callStack.length>0?this._callStack[this._callStack.length-1]:""}peekCtx(){const e=this.peekId();if(!e)return this;let i=this.lctx.get(e);return i||(i={id:e,let:{},const:{},var:{}},this.lctx.set(e,i)),i}call(e,i,...r){this.pushId(i);try{return e(...r)}finally{this.popId()}}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,fill:this.pine.fill,plotchar:this.pine.plotchar,plotshape:this.pine.plotshape,plotarrow:this.pine.plotarrow,color:this.pine.color,plot:this.pine.plot,nz:this.pine.nz}}_showDeprecationWarning(e,i){const r=`${e}->${i}`;oi._deprecationWarningsShown.has(r)||(oi._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;",e,i):console.warn(`\x1B[33m[WARNING] ${e} syntax is deprecated. Use ${i} instead. This will be removed in a future version.\x1B[0m`))}};U(cs,"_deprecationWarningsShown",new Set);let tr=cs;var $l=Object.defineProperty,ql=(t,e,i)=>e in t?$l(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,er=(t,e,i)=>ql(t,typeof e!="symbol"?e+"":e,i);class ir{constructor(e,i={}){er(this,"source"),er(this,"inputs"),this.source=e,this.inputs=i}}var Hl=Object.defineProperty,Ul=(t,e,i)=>e in t?Hl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,et=(t,e,i)=>Ul(t,typeof e!="symbol"?e+"":e,i);class wi{constructor(e,i,r,s,a,n){this.source=e,this.tickerId=i,this.timeframe=r,this.limit=s,this.sDate=a,this.eDate=n,et(this,"data",[]),et(this,"open",[]),et(this,"high",[]),et(this,"low",[]),et(this,"close",[]),et(this,"volume",[]),et(this,"hl2",[]),et(this,"hlc3",[]),et(this,"ohlc4",[]),et(this,"hlcc4",[]),et(this,"openTime",[]),et(this,"closeTime",[]),et(this,"_readyPromise",null),et(this,"_ready",!1),et(this,"_debugSettings",{ln:!1,debug:!1}),et(this,"_transpiledCode",null),et(this,"_isSecondaryContext",!1),et(this,"_syminfo"),this._readyPromise=new Promise(o=>{this.loadMarketData(e,i,r,s,a,n).then(u=>{const c=u;this.data=c;const h=c.map(b=>b.open),d=c.map(b=>b.close),l=c.map(b=>b.high),m=c.map(b=>b.low),x=c.map(b=>b.volume),E=c.map(b=>(b.high+b.low+b.close)/3),S=c.map(b=>(b.high+b.low)/2),p=c.map(b=>(b.high+b.low+b.open+b.close)/4),g=c.map(b=>(b.high+b.low+b.close+b.close)/4),v=c.map(b=>b.openTime),_=c.map(b=>b.closeTime);this.open=h,this.close=d,this.high=l,this.low=m,this.volume=x,this.hl2=S,this.hlc3=E,this.ohlc4=p,this.hlcc4=g,this.openTime=v,this.closeTime=_,e&&e.getSymbolInfo?e.getSymbolInfo(i).then(b=>{this._syminfo=b,this._ready=!0,o(!0)}).catch(b=>{console.warn("Failed to get symbol info, using default values:",b),this._ready=!0,o(!0)}):(this._ready=!0,o(!0))})})}get transpiledCode(){return this._transpiledCode}markAsSecondary(){this._isSecondaryContext=!0}setDebugSettings({ln:e,debug:i}){this._debugSettings.ln=e,this._debugSettings.debug=i}async loadMarketData(e,i,r,s,a,n){return Array.isArray(e)?e:e.getMarketData(i,r,s,a,n)}async ready(){if(this._ready)return!0;if(!this._readyPromise)throw new Error("PineTS is not ready");return this._readyPromise}run(e,i,r){let s,a={};if(e instanceof ir?(s=e.source,a=e.inputs||{}):s=e,r&&r>0){const n=typeof this.eDate>"u"&&!Array.isArray(this.source);return this._runPaginated(s,a,i,r,n)}else return this._runComplete(s,a,i)}stream(e,i={}){const{live:r=!0,interval:s=1e3}=i,a=i.pageSize||this.data.length;let n,o={};e instanceof ir?(n=e.source,o=e.inputs||{}):n=e;const u={data:[],error:[]};let c=!1;const h=(m,...x)=>{u[m]&&u[m].forEach(E=>E(...x))},d=(m,x)=>{u[m]||(u[m]=[]),u[m].push(x)},l=()=>{c=!0};return(async()=>{try{const m=typeof this.eDate>"u"&&!Array.isArray(this.source)&&r,x=this._runPaginated(n,o,void 0,a,m);for await(const E of x){if(c)break;if(E===null){await new Promise(S=>setTimeout(S,s));continue}if(h("data",E),m&&!c){const S=E.marketData[E.idx];S&&S.closeTime<Date.now()||await new Promise(p=>setTimeout(p,s))}}}catch(m){h("error",m)}})(),{on:d,stop:l}}async _runComplete(e,i,r){await this.ready(),r||(r=this.data.length);const s=this._initializeContext(e,i,this._isSecondaryContext);return this._transpiledCode=this._transpileCode(e),await this._executeIterations(s,this._transpiledCode,this.data.length-r,this.data.length),s}async*_runPaginated(e,i,r,s,a=!1){await this.ready(),r||(r=this.data.length);const n=this._initializeContext(e,i,this._isSecondaryContext);this._transpiledCode=this._transpileCode(e);let o=this.data.length-r;for(;;){const u=this.data.length-o;if(u>0){const d=Math.min(u,s),l=this._getResultLength(n.result);await this._executeIterations(n,this._transpiledCode,o,o+d),o+=d,yield this._createPageContext(n,l);continue}if(!a||Array.isArray(this.source))break;const{newCandles:c,updatedLastCandle:h}=await this._updateMarketData();if(c===0&&!h){yield null;continue}this._removeLastResult(n),o=this.data.length-(c+1),n.pine.barstate.setLive()}}_getResultLength(e){if(Array.isArray(e))return e.length;if(typeof e=="object"&&e!==null){const i=Object.keys(e);if(i.length>0&&Array.isArray(e[i[0]]))return e[i[0]].length}return 0}_createPageContext(e,i){const r=new tr({marketData:this.data,source:this.source,tickerId:this.tickerId,timeframe:this.timeframe,limit:this.limit,sDate:this.sDate,eDate:this.eDate,fullContext:e,inputs:e.inputs});if(r.pineTSCode=e.pineTSCode,r.idx=e.idx,Array.isArray(e.result))r.result=e.result.slice(i);else if(typeof e.result=="object"&&e.result!==null){r.result={};for(let s in e.result)Array.isArray(e.result[s])?r.result[s]=e.result[s].slice(i):r.result[s]=e.result[s]}else r.result=e.result;return r.plots={...e.plots},r}async _updateMarketData(e){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 a=await i.getMarketData(this.tickerId,this.timeframe,void 0,s,e);if(!a||a.length===0)return{newCandles:0,updatedLastCandle:!1};let n=!1,o=0;for(let u=0;u<a.length;u++){const c=a[u];c.openTime===s?(this._replaceCandle(r,c),n=!0):c.openTime>s&&(this._appendCandle(c),o++)}return{newCandles:o,updatedLastCandle:n}}catch(a){return console.error("Error updating market data:",a),{newCandles:0,updatedLastCandle:!1}}}_replaceCandle(e,i){this.data[e]=i,this.open[e]=i.open,this.close[e]=i.close,this.high[e]=i.high,this.low[e]=i.low,this.volume[e]=i.volume,this.hl2[e]=(i.high+i.low)/2,this.hlc3[e]=(i.high+i.low+i.close)/3,this.ohlc4[e]=(i.high+i.low+i.open+i.close)/4,this.hlcc4[e]=(i.high+i.low+i.close+i.close)/4,this.openTime[e]=i.openTime,this.closeTime[e]=i.closeTime}_appendCandle(e){this.data.push(e),this.open.push(e.open),this.close.push(e.close),this.high.push(e.high),this.low.push(e.low),this.volume.push(e.volume),this.hl2.push((e.high+e.low)/2),this.hlc3.push((e.high+e.low+e.close)/3),this.ohlc4.push((e.high+e.low+e.open+e.close)/4),this.hlcc4.push((e.high+e.low+e.close+e.close)/4),this.openTime.push(e.openTime),this.closeTime.push(e.closeTime)}_removeLastResult(e){if(Array.isArray(e.result))e.result.pop();else if(typeof e.result=="object"&&e.result!==null)for(let s in e.result)Array.isArray(e.result[s])&&e.result[s].pop();e.data.close.data.pop(),e.data.open.data.pop(),e.data.high.data.pop(),e.data.low.data.pop(),e.data.volume.data.pop(),e.data.hl2.data.pop(),e.data.hlc3.data.pop(),e.data.ohlc4.data.pop(),e.data.hlcc4.data.pop(),e.data.openTime.data.pop(),e.data.closeTime&&e.data.closeTime.data.pop();const i=["const","var","let","params"],r=s=>{for(let a of i)if(s[a])for(let n in s[a]){const o=s[a][n];o instanceof w?o.data.pop():Array.isArray(o)&&o.pop()}};r(e),e.lctx&&e.lctx.forEach(s=>r(s))}_initializeContext(e,i={},r=!1){const s=new tr({marketData:this.data,source:this.source,tickerId:this.tickerId,timeframe:this.timeframe,limit:this.limit,sDate:this.sDate,eDate:this.eDate,inputs:i});return s.pine.syminfo=this._syminfo,s.pineTSCode=e,s.isSecondaryContext=r,s.data.close=new w([]),s.data.open=new w([]),s.data.high=new w([]),s.data.low=new w([]),s.data.volume=new w([]),s.data.hl2=new w([]),s.data.hlc3=new w([]),s.data.ohlc4=new w([]),s.data.hlcc4=new w([]),s.data.openTime=new w([]),s.data.closeTime=new w([]),s}_transpileCode(e){return va.bind(this)(e,this._debugSettings)}async _executeIterations(e,i,r,s){const a=["const","var","let","params"];for(let n=r;n<s;n++){e.idx=n,e.data.close.data.push(this.close[n]),e.data.open.data.push(this.open[n]),e.data.high.data.push(this.high[n]),e.data.low.data.push(this.low[n]),e.data.volume.data.push(this.volume[n]),e.data.hl2.data.push(this.hl2[n]),e.data.hlc3.data.push(this.hlc3[n]),e.data.ohlc4.data.push(this.ohlc4[n]),e.data.hlcc4.data.push(this.hlcc4[n]),e.data.openTime.data.push(this.openTime[n]),e.data.closeTime.data.push(this.closeTime[n]);const o=await i(e);if(typeof o=="object"){typeof e.result!="object"&&(e.result={});for(let c in o){e.result[c]===void 0&&(e.result[c]=[]);let h;o[c]instanceof w?h=o[c].get(0):Array.isArray(o[c])?h=o[c][o[c].length-1]:h=o[c],e.result[c].push(h)}}else Array.isArray(e.result)||(e.result=[]),e.result.push(o);const u=c=>{for(let h of a)if(c[h])for(let d in c[h]){const l=c[h][d];if(l instanceof w){const m=l.get(0);l.data.push(m)}else if(Array.isArray(l)){const m=l[l.length-1];l.push(m)}}};u(e),e.lctx&&e.lctx.forEach(c=>u(c))}}}var Gl=Object.defineProperty,Kl=(t,e,i)=>e in t?Gl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Re=(t,e,i)=>Kl(t,typeof e!="symbol"?e+"":e,i);const Qe="https://api.binance.com/api/v3",rr="https://api.binance.us/api/v3",Je={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 zl{constructor(e=300*1e3){Re(this,"cache"),Re(this,"cacheDuration"),this.cache=new Map,this.cacheDuration=e}generateKey(e){return Object.entries(e).filter(([i,r])=>r!==void 0).map(([i,r])=>`${i}:${r}`).join("|")}get(e){const i=this.generateKey(e),r=this.cache.get(i);return r?Date.now()-r.timestamp>this.cacheDuration?(this.cache.delete(i),null):r.data:null}set(e,i){const r=this.generateKey(e);this.cache.set(r,{data:i,timestamp:Date.now()})}clear(){this.cache.clear()}cleanup(){const e=Date.now();for(const[i,r]of this.cache.entries())e-r.timestamp>this.cacheDuration&&this.cache.delete(i)}}class Yl{constructor(){Re(this,"cacheManager"),Re(this,"activeApiUrl",null),this.cacheManager=new zl(300*1e3)}async getBaseUrl(){if(this.activeApiUrl)return this.activeApiUrl;try{const e=new AbortController,i=setTimeout(()=>e.abort(),5e3),r=await fetch(`${Qe}/ping`,{signal:e.signal});if(clearTimeout(i),r.ok)return this.activeApiUrl=Qe,this.activeApiUrl}catch{}try{const e=new AbortController,i=setTimeout(()=>e.abort(),5e3),r=await fetch(`${rr}/ping`,{signal:e.signal});if(clearTimeout(i),r.ok)return this.activeApiUrl=rr,this.activeApiUrl}catch{}return Qe}async getMarketDataInterval(e,i,r,s){try{const a=Je[i.toUpperCase()];if(!a)return console.error(`Unsupported timeframe: ${i}`),[];const n={"1m":60*1e3,"3m":180*1e3,"5m":300*1e3,"15m":900*1e3,"30m":1800*1e3,"1h":3600*1e3,"2h":7200*1e3,"4h":14400*1e3,"1d":1440*60*1e3,"1w":10080*60*1e3,"1M":720*60*60*1e3};let o=[],u=r;const c=s,h=n[a];if(!h)return console.error(`Duration not defined for interval: ${a}`),[];for(;u<c;){const d=Math.min(u+1e3*h,c),l=await this.getMarketData(e,i,1e3,u,d);if(l.length===0)break;o=o.concat(l),u=l[l.length-1].closeTime+1}return o}catch(a){return console.error("Error in getMarketDataInterval:",a),[]}}async getMarketDataBackwards(e,i,r,s){let a=r,n=[],o=s,u=0;const c=Math.ceil(r/1e3)+5;for(;a>0&&u<c;){u++;const h=Math.min(a,1e3),d=await this.getMarketData(e,i,h,void 0,o);if(d.length===0||(n=d.concat(n),a-=d.length,o=d[0].openTime-1,d.length<h))break}return n}async getMarketData(e,i,r,s,a){try{const n=a!==void 0,o={tickerId:e,timeframe:i,limit:r,sDate:s,eDate:a};if(n){const l=this.cacheManager.get(o);if(l)return l}const u=Je[i.toUpperCase()];if(!u)return console.error(`Unsupported timeframe: ${i}`),[];if(this.shouldPaginate(i,r,s,a)){if(s&&a){const l=await this.getMarketDataInterval(e,i,s,a),m=r?l.slice(0,r):l;return this.cacheManager.set(o,m),m}else if(r&&r>1e3){const l=await this.getMarketDataBackwards(e,i,r,a);return this.cacheManager.set(o,l),l}}let c=`${await this.getBaseUrl()}/klines?symbol=${e}&interval=${u}`;r&&(c+=`&limit=${Math.min(r,1e3)}`),s&&(c+=`&startTime=${s}`),a&&(c+=`&endTime=${a}`);const h=await fetch(c);if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);const d=(await h.json()).map(l=>({openTime:parseInt(l[0]),open:parseFloat(l[1]),high:parseFloat(l[2]),low:parseFloat(l[3]),close:parseFloat(l[4]),volume:parseFloat(l[5]),closeTime:parseInt(l[6]),quoteAssetVolume:parseFloat(l[7]),numberOfTrades:parseInt(l[8]),takerBuyBaseAssetVolume:parseFloat(l[9]),takerBuyQuoteAssetVolume:parseFloat(l[10]),ignore:l[11]}));return n&&this.cacheManager.set(o,d),d}catch(n){return console.error("Error in binance.klines:",n),[]}}shouldPaginate(e,i,r,s){if(i&&i>1e3)return!0;if(r&&s){const a=Je[e.toUpperCase()],n={"1m":60*1e3,"3m":180*1e3,"5m":300*1e3,"15m":900*1e3,"30m":1800*1e3,"1h":3600*1e3,"2h":7200*1e3,"4h":14400*1e3,"1d":1440*60*1e3,"1w":10080*60*1e3,"1M":720*60*60*1e3}[a];if(n)return Math.ceil((s-r)/n)>1e3}return!1}async getSymbolInfo(e){try{let i="crypto",r=await this.getBaseUrl(),s=e,a="";e.endsWith(".P")?(i="futures",s=e.replace(".P",""),r="https://fapi.binance.com/fapi/v1",a="Perpetual"):e.includes("_")&&(i="futures",s=e,r="https://dapi.binance.com/dapi/v1",a="Delivery");const n=i==="crypto"?`${r}/exchangeInfo?symbol=${s}`:`${r}/exchangeInfo`,o=await fetch(n);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);const u=(await o.json()).symbols;if(!u||u.length===0)return console.error(`Symbol ${e} not found`),null;const c=i==="futures"?u.find(v=>v.symbol===s):u[0];if(!c)return console.error(`Symbol ${s} not found in exchange info`),null;const h=c.filters?.find(v=>v.filterType==="PRICE_FILTER"),d=c.filters?.find(v=>v.filterType==="LOT_SIZE"),l=h?parseFloat(h.tickSize):.01,m=d?parseFloat(d.minQty):0,x=Math.round(1/l),E=c.baseAsset,S=c.quoteAsset,p=a?` ${a}`:"",g=`${E} / ${S}${p}`;return{ticker:e,tickerid:`BINANCE:${e}`,prefix:"BINANCE",root:E,description:g,type:i,main_tickerid:`BINANCE:${e}`,current_contract:a,isin:"",basecurrency:E,currency:S,timezone:"Etc/UTC",country:"",mintick:l,pricescale:x,minmove:1,pointvalue:c.contractSize||1,mincontract:m,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 Ql=Object.defineProperty,Jl=(t,e,i)=>e in t?Ql(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Xe=(t,e,i)=>Jl(t,typeof e!="symbol"?e+"":e,i);const Xl=ls.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:it&&it.tagName.toUpperCase()==="SCRIPT"&&it.src||new URL("pinets-cli.min.cjs",document.baseURI).href),Zl=le.dirname(Xl);class tp{constructor(e){if(Xe(this,"dataCache",new Map),Xe(this,"exchangeInfoCache",{}),Xe(this,"dataDirectory"),e)this.dataDirectory=e;else{const i=le.resolve(Zl,"../../../");this.dataDirectory=le.join(i,"tests","compatibility","_data")}}getDataFileName(e,i,r,s){return r&&s?`${e}-${i}-${r}-${s}.json`:null}loadDataFromFile(e){const i=`file:${e}`;if(this.dataCache.has(i))return this.dataCache.get(i);const r=le.join(this.dataDirectory,e);if(!te.existsSync(r))throw new Error(`Mock data file not found: ${r}`);const s=te.readFileSync(r,"utf-8"),a=JSON.parse(s);return this.dataCache.set(i,a),a}findDataFile(e,i,r,s){if(!te.existsSync(this.dataDirectory))return null;const a=te.readdirSync(this.dataDirectory).filter(u=>u.endsWith(".json"));if(r&&s){const u=`${e}-${i}-${r}-${s}.json`;if(a.includes(u))return u}const n=new RegExp(`^${e}-${i}-(\\d+)-(\\d+)\\.json$`),o=a.filter(u=>n.test(u)).map(u=>{const c=u.match(n);return{file:u,startTime:parseInt(c[1]),endTime:parseInt(c[2])}}).sort((u,c)=>c.endTime-u.endTime);if(o.length===0)return null;if(r&&s){const u=o.find(c=>c.startTime<=r&&c.endTime>=s);if(u)return u.file}return o[0].file}filterData(e,i,r,s){let a=e;return(i||r)&&(a=e.filter(n=>{const o=!i||n.openTime>=i,u=!r||n.openTime<=r;return o&&u})),a.sort((n,o)=>n.openTime-o.openTime),s&&s>0&&(a=a.slice(0,s)),a}normalizeTimeframe(e){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"}[e.toUpperCase()]||e.toLowerCase()}async getMarketData(e,i,r,s,a){try{const n=this.normalizeTimeframe(i),o=this.findDataFile(e,n,s,a);if(!o)return console.warn(`No mock data file found for ${e} ${n}. Searched in: ${this.dataDirectory}`),[];const u=this.loadDataFromFile(o);return this.filterData(u,s,a,r)}catch(n){return console.error("Error in MockProvider.getMarketData:",n),[]}}loadExchangeInfo(e){if(this.exchangeInfoCache[e])return this.exchangeInfoCache[e];const i=e==="spot"?"api-exchangeInfo.json":"fapi-exchangeInfo.json",r=le.join(this.dataDirectory,i);if(!te.existsSync(r))return console.warn(`Exchange info file not found: ${r}`),null;try{const s=te.readFileSync(r,"utf-8"),a=JSON.parse(s);return this.exchangeInfoCache[e]=a,a}catch(s){return console.error(`Error loading exchange info from ${i}:`,s),null}}async getSymbolInfo(e){try{let i="crypto",r=e,s="";e.endsWith(".P")?(i="futures",r=e.replace(".P",""),s="Perpetual"):e.includes("_")&&(i="futures",r=e,s="Delivery");const a=this.loadExchangeInfo(i==="futures"?"futures":"spot");if(!a||!a.symbols)return console.error(`Exchange info not available for ${i}`),null;const n=a.symbols.find(S=>S.symbol===r);if(!n)return console.error(`Symbol ${r} not found in ${i} exchange info`),null;const o=n.filters?.find(S=>S.filterType==="PRICE_FILTER"),u=n.filters?.find(S=>S.filterType==="LOT_SIZE"),c=o?parseFloat(o.tickSize):.01,h=u?parseFloat(u.minQty):0,d=Math.round(1/c),l=n.baseAsset,m=n.quoteAsset,x=s?` ${s}`:"",E=`${l} / ${m}${x}`;return{ticker:e,tickerid:`BINANCE:${e}`,prefix:"BINANCE",root:l,description:E,type:i,main_tickerid:`BINANCE:${e}`,current_contract:s,isin:"",basecurrency:l,currency:m,timezone:"Etc/UTC",country:"",mintick:c,pricescale:d,minmove:1,pointvalue:n.contractSize||1,mincontract:h,session:"24x7",volumetype:"base",expiration_date:n.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(e){this.dataDirectory=e,this.clearCache()}}const ep=typeof process<"u"&&process.versions&&process.versions.node;let Be=null;if(ep)try{Be=new tp}catch{Be=null}const ip={Binance:new Yl,...Be?{Mock:Be}:{}};function rp(t=1e4){return new Promise((e,i)=>{let r="",s=!1;const a=o=>{s||(s=!0,clearTimeout(n),o())};process.stdin.setEncoding("utf-8"),process.stdin.on("data",o=>{r+=o}),process.stdin.on("end",()=>{a(()=>e(r))}),process.stdin.on("error",o=>{a(()=>i(o))});const n=setTimeout(()=>{r||a(()=>{process.stdin.destroy(),i(new Error("Timeout: No data received from stdin."))})},t)})}function sp(t,e,i){switch(e){case"full":return ap(t,i);case"default":default:return hs(t,i)}}function np(t,e,i,r){const s=i?JSON.stringify(t,null,2):JSON.stringify(t);if(e){const a=re.resolve(e);Xt.mkdirSync(re.dirname(a),{recursive:!0}),Xt.writeFileSync(a,s,"utf-8"),r||console.error(`Output written to: ${a}`)}else process.stdout.write(s+`
|
|
144
|
+
`)}function hs(t,e){const i={};for(const[r,s]of Object.entries(t.plots)){const a=s.data;i[r]={title:s.title,options:s.options,data:a.length>e?a.slice(-e):a}}return{indicator:t.indicator||{},plots:i}}function ap(t,e){const i=hs(t,e),r=t.marketData,s=r.length>e?r.slice(-e):r;let a=t.result;if(a!=null){if(Array.isArray(a))a=a.length>e?a.slice(-e):a;else if(typeof a=="object"){const n={};for(const[o,u]of Object.entries(a))Array.isArray(u)?n[o]=u.length>e?u.slice(-e):u:n[o]=u;a=n}}return{...i,result:a,marketData:s}}function Yt(t,...e){t||console.error(...e)}function Pt(t,e){console.error(`Error: ${t}`),e&&console.error(e),process.exit(1)}async function op(t,e){const i=parseInt(e.candles,10),r=parseInt(e.warmup,10),s=i+r,a=!!e.quiet;(isNaN(i)||i<=0)&&Pt("--candles must be a positive integer."),(isNaN(r)||r<0)&&Pt("--warmup must be a non-negative integer.");let n;if(t){const d=re.resolve(t);Xt.existsSync(d)||Pt(`File not found: ${d}`),n=Xt.readFileSync(d,"utf-8"),Yt(a,`Indicator: ${re.basename(d)}`)}else process.stdin.isTTY?Pt("No indicator provided. Pass a file argument or pipe via stdin.",`
|
|
145
|
+
Examples:
|
|
146
|
+
pinets run my_indicator.pine --symbol BTCUSDT
|
|
147
|
+
cat my_indicator.pine | pinets run --symbol BTCUSDT`):(Yt(a,"Reading indicator from stdin..."),n=await rp(),n.trim()||Pt("Empty input received from stdin."),Yt(a,`Indicator: <stdin> (${n.length} chars)`));let o,u,c,h;if(e.data){const d=re.resolve(e.data);Xt.existsSync(d)||Pt(`Data file not found: ${d}`);let l;try{const x=Xt.readFileSync(d,"utf-8");l=JSON.parse(x)}catch(x){Pt(`Failed to parse JSON data file: ${x.message}`)}(!Array.isArray(l)||l.length===0)&&Pt("JSON data must be a non-empty array of candle objects.","Expected: [{ openTime, open, high, low, close, volume, closeTime }, ...]");const m=["open","high","low","close","volume"].filter(x=>l[0][x]===void 0);m.length>0&&Pt(`JSON candle data is missing required fields: ${m.join(", ")}`),o=l,Yt(a,`Data source: JSON file (${l.length} candles)`)}else e.symbol?(o=ip.Binance,u=e.symbol.toUpperCase(),c=e.timeframe,h=s,Yt(a,`Data source: Binance | ${u} | ${c} | ${s} candles`)):Pt("No data source provided.","Use --symbol <ticker> for live data or --data <file.json> for a JSON file.");try{const d=new wi(o,u,c,h);e.debug&&d.setDebugSettings({ln:!1,debug:!0}),Yt(a,"Executing...");const l=await d.run(n);Yt(a,"Done.");const m=sp(l,e.format,i),x=e.pretty!==void 0?!0:e.output?!1:!!process.stdout.isTTY;np(m,e.output,x,a)}catch(d){console.error(`Execution failed: ${d.message||d}`),e.debug&&d.stack&&console.error(d.stack),process.exit(1)}}async function up(t,e){try{const i=new AbortController,r=setTimeout(()=>i.abort(),3e3),s=await fetch(`https://registry.npmjs.org/${e}/latest`,{signal:i.signal});if(clearTimeout(r),!s.ok)return null;const{version:a}=await s.json();return a&&a!==t?["",` Update available: ${t} \u2192 ${a}`,` Run: npm i -g ${e}`,""].join(`
|
|
148
|
+
`):null}catch{return null}}const sr="0.1.0",cp="pinets-cli";async function hp(){const t=up(sr,cp);qe.name("pinets").description("CLI for running Pine Script indicators via PineTS").version(sr,"-v, --version"),qe.command("run").description("Execute a Pine Script indicator").argument("[file]","Path to indicator file (.pine or any text file)").option("-s, --symbol <ticker>","Symbol to query (e.g., BTCUSDT, ETHUSDT.P)").option("-t, --timeframe <tf>","Timeframe: 1, 5, 15, 60, 240, 1D, 1W, 1M","60").option("-d, --data <path>","Path to JSON data file (alternative to --symbol)").option("-o, --output <path>","Write output to file (default: stdout)").option("-f, --format <type>","Output format: default | full","default").option("--pretty","Pretty-print JSON output").option("-n, --candles <count>","Number of output candles","500").option("-w, --warmup <count>","Extra warmup candles for indicator init","0").option("--debug","Show transpiled code").option("-q, --quiet","Suppress informational messages").action(op),await qe.parseAsync();const e=await Promise.race([t,new Promise(i=>setTimeout(()=>i(null),1e3))]);e&&console.error(e)}hp().catch(t=>{console.error(`Fatal: ${t.message||t}`),process.exit(1)});
|
|
149
|
+
//# sourceMappingURL=pinets-cli.min.cjs.map
|