pinets 0.8.12 → 0.9.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.
@@ -15,28 +15,28 @@
15
15
  * You should have received a copy of the GNU Affero General Public License
16
16
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
17
  */
18
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var Br=require("fs"),Fr=require("path"),jr=require("url");function Ti(t){if(t&&t.__esModule)return 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 ze=Ti(Br),tt=Ti(Fr),Wr=[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,78,5,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,199,7,137,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,55,9,266,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,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],Pi=[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,7,25,39,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,5,57,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,24,43,261,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,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7381,42,31,98,114,8702,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,208,30,2,2,2,1,2,6,3,4,10,1,225,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,4381,3,5773,3,7472,16,621,2467,541,1507,4938,6,8489],$r="\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ADD\u1AE0-\u1AEB\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",Di="\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-\u088F\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\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\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-\uA7DC\uA7F1-\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",It={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"},Ct="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",Ur={5:Ct,"5module":Ct+" export import",6:Ct+" const class extends export import super"},Ri=/^in(stanceof)?$/,qr=new RegExp("["+Di+"]"),Kr=new RegExp("["+Di+$r+"]");function Rt(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 be(t,e){return t<65?t===36:t<91?!0:t<97?t===95:t<123?!0:t<=65535?t>=170&&qr.test(String.fromCharCode(t)):e===!1?!1:Rt(t,Pi)}function Oe(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&&Kr.test(String.fromCharCode(t)):e===!1?!1:Rt(t,Pi)||Rt(t,Wr)}var M=function(e,i){i===void 0&&(i={}),this.label=e,this.keyword=i.keyword,this.beforeExpr=!!i.beforeExpr,this.startsExpr=!!i.startsExpr,this.isLoop=!!i.isLoop,this.isAssign=!!i.isAssign,this.prefix=!!i.prefix,this.postfix=!!i.postfix,this.binop=i.binop||null,this.updateContext=null};function ce(t,e){return new M(t,{beforeExpr:!0,binop:e})}var le={beforeExpr:!0},re={startsExpr:!0},$t={};function R(t,e){return e===void 0&&(e={}),e.keyword=t,$t[t]=new M(t,e)}var f={num:new M("num",re),regexp:new M("regexp",re),string:new M("string",re),name:new M("name",re),privateId:new M("privateId",re),eof:new M("eof"),bracketL:new M("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new M("]"),braceL:new M("{",{beforeExpr:!0,startsExpr:!0}),braceR:new M("}"),parenL:new M("(",{beforeExpr:!0,startsExpr:!0}),parenR:new M(")"),comma:new M(",",le),semi:new M(";",le),colon:new M(":",le),dot:new M("."),question:new M("?",le),questionDot:new M("?."),arrow:new M("=>",le),template:new M("template"),invalidTemplate:new M("invalidTemplate"),ellipsis:new M("...",le),backQuote:new M("`",re),dollarBraceL:new M("${",{beforeExpr:!0,startsExpr:!0}),eq:new M("=",{beforeExpr:!0,isAssign:!0}),assign:new M("_=",{beforeExpr:!0,isAssign:!0}),incDec:new M("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new M("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:ce("||",1),logicalAND:ce("&&",2),bitwiseOR:ce("|",3),bitwiseXOR:ce("^",4),bitwiseAND:ce("&",5),equality:ce("==/!=/===/!==",6),relational:ce("</>/<=/>=",7),bitShift:ce("<</>>/>>>",8),plusMin:new M("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:ce("%",10),star:ce("*",10),slash:ce("/",10),starstar:new M("**",{beforeExpr:!0}),coalesce:ce("??",1),_break:R("break"),_case:R("case",le),_catch:R("catch"),_continue:R("continue"),_debugger:R("debugger"),_default:R("default",le),_do:R("do",{isLoop:!0,beforeExpr:!0}),_else:R("else",le),_finally:R("finally"),_for:R("for",{isLoop:!0}),_function:R("function",re),_if:R("if"),_return:R("return",le),_switch:R("switch"),_throw:R("throw",le),_try:R("try"),_var:R("var"),_const:R("const"),_while:R("while",{isLoop:!0}),_with:R("with"),_new:R("new",{beforeExpr:!0,startsExpr:!0}),_this:R("this",re),_super:R("super",re),_class:R("class",re),_extends:R("extends",le),_export:R("export"),_import:R("import",re),_null:R("null",re),_true:R("true",re),_false:R("false",re),_in:R("in",{beforeExpr:!0,binop:7}),_instanceof:R("instanceof",{beforeExpr:!0,binop:7}),_typeof:R("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:R("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:R("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},se=/\r\n?|\n|\u2028|\u2029/,Hr=new RegExp(se.source,"g");function Ze(t){return t===10||t===13||t===8232||t===8233}function Mi(t,e,i){i===void 0&&(i=t.length);for(var r=e;r<i;r++){var n=t.charCodeAt(r);if(Ze(n))return r<i-1&&n===13&&t.charCodeAt(r+1)===10?r+2:r+1}return-1}var Oi=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,Q=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,Vi=Object.prototype,zr=Vi.hasOwnProperty,Gr=Vi.toString,Je=Object.hasOwn||(function(t,e){return zr.call(t,e)}),ti=Array.isArray||(function(t){return Gr.call(t)==="[object Array]"}),ii=Object.create(null);function Re(t){return ii[t]||(ii[t]=new RegExp("^(?:"+t.replace(/ /g,"|")+")$"))}function Ne(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}var Yr=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,nt=function(e,i){this.line=e,this.column=i};nt.prototype.offset=function(e){return new nt(this.line,this.column+e)};var wt=function(e,i,r){this.start=i,this.end=r,e.sourceFile!==null&&(this.source=e.sourceFile)};function Li(t,e){for(var i=1,r=0;;){var n=Mi(t,r,e);if(n<0)return new nt(i,e-r);++i,r=n}}var Mt={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},ri=!1;function Qr(t){var e={};for(var i in Mt)e[i]=t&&Je(t,i)?t[i]:Mt[i];if(e.ecmaVersion==="latest"?e.ecmaVersion=1e8:e.ecmaVersion==null?(!ri&&typeof console=="object"&&console.warn&&(ri=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
19
- 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),ti(e.onToken)){var r=e.onToken;e.onToken=function(n){return r.push(n)}}if(ti(e.onComment)&&(e.onComment=Xr(e,e.onComment)),e.sourceType==="commonjs"&&e.allowAwaitOutsideFunction)throw new Error("Cannot use allowAwaitOutsideFunction with sourceType: commonjs");return e}function Xr(t,e){return function(i,r,n,a,s,o){var c={type:i?"Block":"Line",value:r,start:n,end:a};t.locations&&(c.loc=new wt(this,s,o)),t.ranges&&(c.range=[n,a]),e.push(c)}}var Ue=1,qe=2,Ut=4,Bi=8,qt=16,Fi=32,bt=64,ji=128,Ke=256,st=512,Wi=1024,_t=Ue|qe|Ke;function Kt(t,e){return qe|(t?Ut:0)|(e?Bi:0)}var pt=0,Ht=1,Ce=2,$i=3,Ui=4,qi=5,K=function(e,i,r){this.options=e=Qr(e),this.sourceFile=e.sourceFile,this.keywords=Re(Ur[e.ecmaVersion>=6?6:e.sourceType==="module"?"5module":5]);var n="";e.allowReserved!==!0&&(n=It[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType==="module"&&(n+=" await")),this.reservedWords=Re(n);var a=(n?n+" ":"")+It.strict;this.reservedWordsStrict=Re(a),this.reservedWordsStrictBind=Re(a+" "+It.strictBind),this.input=String(i),this.containsEsc=!1,r?(this.pos=r,this.lineStart=this.input.lastIndexOf(`
20
- `,r-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(se).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=e.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&&e.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType==="commonjs"?qe:Ue),this.regexpState=null,this.privateNameStack=[]},fe={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};K.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)};fe.inFunction.get=function(){return(this.currentVarScope().flags&qe)>0};fe.inGenerator.get=function(){return(this.currentVarScope().flags&Bi)>0};fe.inAsync.get=function(){return(this.currentVarScope().flags&Ut)>0};fe.canAwait.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var e=this.scopeStack[t],i=e.flags;if(i&(Ke|st))return!1;if(i&qe)return(i&Ut)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};fe.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&Ue)};fe.allowSuper.get=function(){var t=this.currentThisScope(),e=t.flags;return(e&bt)>0||this.options.allowSuperOutsideMethod};fe.allowDirectSuper.get=function(){return(this.currentThisScope().flags&ji)>0};fe.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};fe.allowNewDotTarget.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var e=this.scopeStack[t],i=e.flags;if(i&(Ke|st)||i&qe&&!(i&qt))return!0}return!1};fe.allowUsing.get=function(){var t=this.currentScope(),e=t.flags;return!(e&Wi||!this.inModule&&e&Ue)};fe.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&Ke)>0};K.extend=function(){for(var e=[],i=arguments.length;i--;)e[i]=arguments[i];for(var r=this,n=0;n<e.length;n++)r=e[n](r);return r};K.parse=function(e,i){return new this(i,e).parse()};K.parseExpressionAt=function(e,i,r){var n=new this(r,e,i);return n.nextToken(),n.parseExpression()};K.tokenizer=function(e,i){return new this(i,e)};Object.defineProperties(K.prototype,fe);var ie=K.prototype,Zr=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;ie.strictDirective=function(t){if(this.options.ecmaVersion<5)return!1;for(;;){Q.lastIndex=t,t+=Q.exec(this.input)[0].length;var e=Zr.exec(this.input.slice(t));if(!e)return!1;if((e[1]||e[2])==="use strict"){Q.lastIndex=t+e[0].length;var i=Q.exec(this.input),r=i.index+i[0].length,n=this.input.charAt(r);return n===";"||n==="}"||se.test(i[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(n)||n==="!"&&this.input.charAt(r+1)==="=")}t+=e[0].length,Q.lastIndex=t,t+=Q.exec(this.input)[0].length,this.input[t]===";"&&t++}};ie.eat=function(t){return this.type===t?(this.next(),!0):!1};ie.isContextual=function(t){return this.type===f.name&&this.value===t&&!this.containsEsc};ie.eatContextual=function(t){return this.isContextual(t)?(this.next(),!0):!1};ie.expectContextual=function(t){this.eatContextual(t)||this.unexpected()};ie.canInsertSemicolon=function(){return this.type===f.eof||this.type===f.braceR||se.test(this.input.slice(this.lastTokEnd,this.start))};ie.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};ie.semicolon=function(){!this.eat(f.semi)&&!this.insertSemicolon()&&this.unexpected()};ie.afterTrailingComma=function(t,e){if(this.type===t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0};ie.expect=function(t){this.eat(t)||this.unexpected()};ie.unexpected=function(t){this.raise(t??this.start,"Unexpected token")};var St=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};ie.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")}};ie.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")};ie.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")};ie.isSimpleAssignTarget=function(t){return t.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(t.expression):t.type==="Identifier"||t.type==="MemberExpression"};var k=K.prototype;k.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,n=Object.keys(this.undefinedExports);r<n.length;r+=1){var a=n[r];this.raiseRecoverable(this.undefinedExports[a].start,"Export '"+a+"' is not defined")}return this.adaptDirectivePrologue(t.body),this.next(),t.sourceType=this.options.sourceType==="commonjs"?"script":this.options.sourceType,this.finishNode(t,"Program")};var zt={kind:"loop"},Jr={kind:"switch"};k.isLet=function(t){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;Q.lastIndex=this.pos;var e=Q.exec(this.input),i=this.pos+e[0].length,r=this.fullCharCodeAt(i);if(r===91||r===92)return!0;if(t)return!1;if(r===123)return!0;if(be(r)){var n=i;do i+=r<=65535?1:2;while(Oe(r=this.fullCharCodeAt(i)));if(r===92)return!0;var a=this.input.slice(n,i);if(!Ri.test(a))return!0}return!1};k.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;Q.lastIndex=this.pos;var t=Q.exec(this.input),e=this.pos+t[0].length,i;return!se.test(this.input.slice(this.pos,e))&&this.input.slice(e,e+8)==="function"&&(e+8===this.input.length||!(Oe(i=this.fullCharCodeAt(e+8))||i===92))};k.isUsingKeyword=function(t,e){if(this.options.ecmaVersion<17||!this.isContextual(t?"await":"using"))return!1;Q.lastIndex=this.pos;var i=Q.exec(this.input),r=this.pos+i[0].length;if(se.test(this.input.slice(this.pos,r)))return!1;if(t){var n=r+5,a;if(this.input.slice(r,n)!=="using"||n===this.input.length||Oe(a=this.fullCharCodeAt(n))||a===92)return!1;Q.lastIndex=n;var s=Q.exec(this.input);if(r=n+s[0].length,s&&se.test(this.input.slice(n,r)))return!1}var o=this.fullCharCodeAt(r);if(!be(o)&&o!==92)return!1;var c=r;do r+=o<=65535?1:2;while(Oe(o=this.fullCharCodeAt(r)));if(o===92)return!0;var l=this.input.slice(c,r);return!(Ri.test(l)||e&&l==="of")};k.isAwaitUsing=function(t){return this.isUsingKeyword(!0,t)};k.isUsing=function(t){return this.isUsingKeyword(!1,t)};k.parseStatement=function(t,e,i){var r=this.type,n=this.startNode(),a;switch(this.isLet(t)&&(r=f._var,a="let"),r){case f._break:case f._continue:return this.parseBreakContinueStatement(n,r.keyword);case f._debugger:return this.parseDebuggerStatement(n);case f._do:return this.parseDoStatement(n);case f._for:return this.parseForStatement(n);case f._function:return t&&(this.strict||t!=="if"&&t!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(n,!1,!t);case f._class:return t&&this.unexpected(),this.parseClass(n,!0);case f._if:return this.parseIfStatement(n);case f._return:return this.parseReturnStatement(n);case f._switch:return this.parseSwitchStatement(n);case f._throw:return this.parseThrowStatement(n);case f._try:return this.parseTryStatement(n);case f._const:case f._var:return a=a||this.value,t&&a!=="var"&&this.unexpected(),this.parseVarStatement(n,a);case f._while:return this.parseWhileStatement(n);case f._with:return this.parseWithStatement(n);case f.braceL:return this.parseBlock(!0,n);case f.semi:return this.parseEmptyStatement(n);case f._export:case f._import:if(this.options.ecmaVersion>10&&r===f._import){Q.lastIndex=this.pos;var s=Q.exec(this.input),o=this.pos+s[0].length,c=this.input.charCodeAt(o);if(c===40||c===46)return this.parseExpressionStatement(n,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(n):this.parseExport(n,i);default:if(this.isAsyncFunction())return t&&this.unexpected(),this.next(),this.parseFunctionStatement(n,!0,!t);var l=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(l)return this.allowUsing||this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"),l==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(n,!1,l),this.semicolon(),this.finishNode(n,"VariableDeclaration");var u=this.value,p=this.parseExpression();return r===f.name&&p.type==="Identifier"&&this.eat(f.colon)?this.parseLabeledStatement(n,u,p,t):this.parseExpressionStatement(n,p)}};k.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 n=this.labels[r];if((t.label==null||n.name===t.label.name)&&(n.kind!=null&&(i||n.kind==="loop")||t.label&&i))break}return r===this.labels.length&&this.raise(t.start,"Unsyntactic "+e),this.finishNode(t,i?"BreakStatement":"ContinueStatement")};k.parseDebuggerStatement=function(t){return this.next(),this.semicolon(),this.finishNode(t,"DebuggerStatement")};k.parseDoStatement=function(t){return this.next(),this.labels.push(zt),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")};k.parseForStatement=function(t){this.next();var e=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(zt),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(),n=i?"let":this.value;return this.next(),this.parseVar(r,!0,n),this.finishNode(r,"VariableDeclaration"),this.parseForAfterInit(t,r,e)}var a=this.isContextual("let"),s=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var c=this.startNode();return this.next(),o==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.parseVar(c,!0,o),this.finishNode(c,"VariableDeclaration"),this.parseForAfterInit(t,c,e)}var l=this.containsEsc,u=new St,p=this.start,h=e>-1?this.parseExprSubscripts(u,"await"):this.parseExpression(!0,u);return this.type===f._in||(s=this.options.ecmaVersion>=6&&this.isContextual("of"))?(e>-1?(this.type===f._in&&this.unexpected(e),t.await=!0):s&&this.options.ecmaVersion>=8&&(h.start===p&&!l&&h.type==="Identifier"&&h.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(t.await=!1)),a&&s&&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))};k.parseForAfterInit=function(t,e,i){return(this.type===f._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&e.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===f._in?i>-1&&this.unexpected(i):t.await=i>-1),this.parseForIn(t,e)):(i>-1&&this.unexpected(i),this.parseFor(t,e))};k.parseFunctionStatement=function(t,e,i){return this.next(),this.parseFunction(t,it|(i?0:Ot),!1,e)};k.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")};k.parseReturnStatement=function(t){return this.allowReturn||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")};k.parseSwitchStatement=function(t){this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(f.braceL),this.labels.push(Jr),this.enterScope(Wi);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")};k.parseThrowStatement=function(t){return this.next(),se.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 en=[];k.parseCatchClauseParam=function(){var t=this.parseBindingAtom(),e=t.type==="Identifier";return this.enterScope(e?Fi:0),this.checkLValPattern(t,e?Ui:Ce),this.expect(f.parenR),t};k.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")};k.parseVarStatement=function(t,e,i){return this.next(),this.parseVar(t,!1,e,i),this.semicolon(),this.finishNode(t,"VariableDeclaration")};k.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push(zt),t.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(t,"WhileStatement")};k.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")};k.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,"EmptyStatement")};k.parseLabeledStatement=function(t,e,i,r){for(var n=0,a=this.labels;n<a.length;n+=1){var s=a[n];s.name===e&&this.raise(i.start,"Label '"+e+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===f._switch?"switch":null,c=this.labels.length-1;c>=0;c--){var l=this.labels[c];if(l.statementStart===t.start)l.statementStart=this.start,l.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")};k.parseExpressionStatement=function(t,e){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")};k.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")};k.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")};k.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")};k.parseVar=function(t,e,i,r){for(t.declarations=[],t.kind=i;;){var n=this.startNode();if(this.parseVarId(n,i),this.eat(f.eq)?n.init=this.parseMaybeAssign(e):!r&&i==="const"&&!(this.type===f._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!r&&(i==="using"||i==="await using")&&this.options.ecmaVersion>=17&&this.type!==f._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+i+" declaration"):!r&&n.id.type!=="Identifier"&&!(e&&(this.type===f._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):n.init=null,t.declarations.push(this.finishNode(n,"VariableDeclarator")),!this.eat(f.comma))break}return t};k.parseVarId=function(t,e){t.id=e==="using"||e==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(t.id,e==="var"?Ht:Ce,!1)};var it=1,Ot=2,Ki=4;k.parseFunction=function(t,e,i,r,n){this.initFunction(t),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===f.star&&e&Ot&&this.unexpected(),t.generator=this.eat(f.star)),this.options.ecmaVersion>=8&&(t.async=!!r),e&it&&(t.id=e&Ki&&this.type!==f.name?null:this.parseIdent(),t.id&&!(e&Ot)&&this.checkLValSimple(t.id,this.strict||t.generator||t.async?this.treatFunctionsAsVar?Ht:Ce:$i));var a=this.yieldPos,s=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Kt(t.async,t.generator)),e&it||(t.id=this.type===f.name?this.parseIdent():null),this.parseFunctionParams(t),this.parseFunctionBody(t,i,!1,n),this.yieldPos=a,this.awaitPos=s,this.awaitIdentPos=o,this.finishNode(t,e&it?"FunctionDeclaration":"FunctionExpression")};k.parseFunctionParams=function(t){this.expect(f.parenL),t.params=this.parseBindingList(f.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};k.parseClass=function(t,e){this.next();var i=this.strict;this.strict=!0,this.parseClassId(t,e),this.parseClassSuper(t);var r=this.enterClassBody(),n=this.startNode(),a=!1;for(n.body=[],this.expect(f.braceL);this.type!==f.braceR;){var s=this.parseClassElement(t.superClass!==null);s&&(n.body.push(s),s.type==="MethodDefinition"&&s.kind==="constructor"?(a&&this.raiseRecoverable(s.start,"Duplicate constructor in the same class"),a=!0):s.key&&s.key.type==="PrivateIdentifier"&&tn(r,s)&&this.raiseRecoverable(s.key.start,"Identifier '#"+s.key.name+"' has already been declared"))}return this.strict=i,this.next(),t.body=this.finishNode(n,"ClassBody"),this.exitClassBody(),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")};k.parseClassElement=function(t){if(this.eat(f.semi))return null;var e=this.options.ecmaVersion,i=this.startNode(),r="",n=!1,a=!1,s="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)&&(n=!0),!r&&!a&&!n){var c=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?s=c:r=c)}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||s!=="method"||n||a){var l=!i.static&&ft(i,"constructor"),u=l&&t;l&&s!=="method"&&this.raise(i.key.start,"Constructor can't have get/set modifier"),i.kind=l?"constructor":s,this.parseClassMethod(i,n,a,u)}else this.parseClassField(i);return i};k.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};k.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)};k.parseClassMethod=function(t,e,i,r){var n=t.key;t.kind==="constructor"?(e&&this.raise(n.start,"Constructor can't be a generator"),i&&this.raise(n.start,"Constructor can't be an async method")):t.static&&ft(t,"prototype")&&this.raise(n.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")};k.parseClassField=function(t){return ft(t,"constructor")?this.raise(t.key.start,"Classes can't have a field named 'constructor'"):t.static&&ft(t,"prototype")&&this.raise(t.key.start,"Classes can't have a static field named 'prototype'"),this.eat(f.eq)?(this.enterScope(st|bt),t.value=this.parseMaybeAssign(),this.exitScope()):t.value=null,this.semicolon(),this.finishNode(t,"PropertyDefinition")};k.parseClassStaticBlock=function(t){t.body=[];var e=this.labels;for(this.labels=[],this.enterScope(Ke|bt);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")};k.parseClassId=function(t,e){this.type===f.name?(t.id=this.parseIdent(),e&&this.checkLValSimple(t.id,Ce,!1)):(e===!0&&this.unexpected(),t.id=null)};k.parseClassSuper=function(t){t.superClass=this.eat(f._extends)?this.parseExprSubscripts(null,!1):null};k.enterClassBody=function(){var t={declared:Object.create(null),used:[]};return this.privateNameStack.push(t),t.declared};k.exitClassBody=function(){var t=this.privateNameStack.pop(),e=t.declared,i=t.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,n=r===0?null:this.privateNameStack[r-1],a=0;a<i.length;++a){var s=i[a];Je(e,s.name)||(n?n.used.push(s):this.raiseRecoverable(s.start,"Private field '#"+s.name+"' must be declared in an enclosing class"))}};function tn(t,e){var i=e.key.name,r=t[i],n="true";return e.type==="MethodDefinition"&&(e.kind==="get"||e.kind==="set")&&(n=(e.static?"s":"i")+e.kind),r==="iget"&&n==="iset"||r==="iset"&&n==="iget"||r==="sget"&&n==="sset"||r==="sset"&&n==="sget"?(t[i]="true",!1):r?!0:(t[i]=n,!1)}function ft(t,e){var i=t.computed,r=t.key;return!i&&(r.type==="Identifier"&&r.name===e||r.type==="Literal"&&r.value===e)}k.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")};k.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,this.options.ecmaVersion>=16&&(t.attributes=[]);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 n=r[i];this.checkUnreserved(n.local),this.checkLocalExport(n.local),n.local.type==="Literal"&&this.raise(n.local.start,"A string literal cannot be used as an exported binding without `from`.")}t.source=null,this.options.ecmaVersion>=16&&(t.attributes=[])}this.semicolon()}return this.finishNode(t,"ExportNamedDeclaration")};k.parseExportDeclaration=function(t){return this.parseStatement(null)};k.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,it|Ki,!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}};k.checkExport=function(t,e,i){t&&(typeof e!="string"&&(e=e.type==="Identifier"?e.name:e.value),Je(t,e)&&this.raiseRecoverable(i,"Duplicate export '"+e+"'"),t[e]=!0)};k.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,n=e.properties;r<n.length;r+=1){var a=n[r];this.checkPatternExport(t,a)}else if(i==="ArrayPattern")for(var s=0,o=e.elements;s<o.length;s+=1){var c=o[s];c&&this.checkPatternExport(t,c)}else i==="Property"?this.checkPatternExport(t,e.value):i==="AssignmentPattern"?this.checkPatternExport(t,e.left):i==="RestElement"&&this.checkPatternExport(t,e.argument)};k.checkVariableExport=function(t,e){if(t)for(var i=0,r=e;i<r.length;i+=1){var n=r[i];this.checkPatternExport(t,n.id)}};k.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};k.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")};k.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};k.parseImport=function(t){return this.next(),this.type===f.string?(t.specifiers=en,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")};k.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,Ce),this.finishNode(t,"ImportSpecifier")};k.parseImportDefaultSpecifier=function(){var t=this.startNode();return t.local=this.parseIdent(),this.checkLValSimple(t.local,Ce),this.finishNode(t,"ImportDefaultSpecifier")};k.parseImportNamespaceSpecifier=function(){var t=this.startNode();return this.next(),this.expectContextual("as"),t.local=this.parseIdent(),this.checkLValSimple(t.local,Ce),this.finishNode(t,"ImportNamespaceSpecifier")};k.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};k.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(),n=r.key.type==="Identifier"?r.key.name:r.key.value;Je(e,n)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+n+"'"),e[n]=!0,t.push(r)}return t};k.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")};k.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===f.string){var t=this.parseLiteral(this.value);return Yr.test(t.value)&&this.raise(t.start,"An export name cannot include a lone surrogate."),t}return this.parseIdent(!0)};k.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)};k.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 de=K.prototype;de.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,n=t.properties;r<n.length;r+=1){var a=n[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};de.toAssignableList=function(t,e){for(var i=t.length,r=0;r<i;r++){var n=t[r];n&&this.toAssignable(n,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};de.parseSpread=function(t){var e=this.startNode();return this.next(),e.argument=this.parseMaybeAssign(!1,t),this.finishNode(e,"SpreadElement")};de.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")};de.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()};de.parseBindingList=function(t,e,i,r){for(var n=[],a=!0;!this.eat(t);)if(a?a=!1:this.expect(f.comma),e&&this.type===f.comma)n.push(null);else{if(i&&this.afterTrailingComma(t))break;if(this.type===f.ellipsis){var s=this.parseRestBinding();this.parseBindingListItem(s),n.push(s),this.type===f.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(t);break}else n.push(this.parseAssignableListItem(r))}return n};de.parseAssignableListItem=function(t){var e=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(e),e};de.parseBindingListItem=function(t){return t};de.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")};de.checkLValSimple=function(t,e,i){e===void 0&&(e=pt);var r=e!==pt;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===Ce&&t.name==="let"&&this.raiseRecoverable(t.start,"let is disallowed as a lexically bound name"),i&&(Je(i,t.name)&&this.raiseRecoverable(t.start,"Argument name clash"),i[t.name]=!0),e!==qi&&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")}};de.checkLValPattern=function(t,e,i){switch(e===void 0&&(e=pt),t.type){case"ObjectPattern":for(var r=0,n=t.properties;r<n.length;r+=1){var a=n[r];this.checkLValInnerPattern(a,e,i)}break;case"ArrayPattern":for(var s=0,o=t.elements;s<o.length;s+=1){var c=o[s];c&&this.checkLValInnerPattern(c,e,i)}break;default:this.checkLValSimple(t,e,i)}};de.checkLValInnerPattern=function(t,e,i){switch(e===void 0&&(e=pt),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 xe=function(e,i,r,n,a){this.token=e,this.isExpr=!!i,this.preserveSpace=!!r,this.override=n,this.generator=!!a},F={b_stat:new xe("{",!1),b_expr:new xe("{",!0),b_tmpl:new xe("${",!1),p_stat:new xe("(",!1),p_expr:new xe("(",!0),q_tmpl:new xe("`",!0,!0,function(t){return t.tryReadTemplateToken()}),f_stat:new xe("function",!1),f_expr:new xe("function",!0),f_expr_gen:new xe("function",!0,!1,null,!0),f_gen:new xe("function",!1,!1,null,!0)},et=K.prototype;et.initialContext=function(){return[F.b_stat]};et.curContext=function(){return this.context[this.context.length-1]};et.braceIsBlock=function(t){var e=this.curContext();return e===F.f_expr||e===F.f_stat?!0:t===f.colon&&(e===F.b_stat||e===F.b_expr)?!e.isExpr:t===f._return||t===f.name&&this.exprAllowed?se.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===F.b_stat:t===f._var||t===f._const||t===f.name?!1:!this.exprAllowed};et.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};et.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};et.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===F.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)?F.b_stat:F.b_expr),this.exprAllowed=!0};f.dollarBraceL.updateContext=function(){this.context.push(F.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?F.p_stat:F.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()!==F.p_stat)&&!(t===f._return&&se.test(this.input.slice(this.lastTokEnd,this.start)))&&!((t===f.colon||t===f.braceL)&&this.curContext()===F.b_stat)?this.context.push(F.f_expr):this.context.push(F.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()===F.q_tmpl?this.context.pop():this.context.push(F.q_tmpl),this.exprAllowed=!1};f.star.updateContext=function(t){if(t===f._function){var e=this.context.length-1;this.context[e]===F.f_expr?this.context[e]=F.f_expr_gen:this.context[e]=F.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 A=K.prototype;A.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,n;switch(r.type){case"Identifier":n=r.name;break;case"Literal":n=String(r.value);break;default:return}var a=t.kind;if(this.options.ecmaVersion>=6){n==="__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}n="$"+n;var s=e[n];if(s){var o;a==="init"?o=this.strict&&s.init||s.get||s.set:o=s.init||s[a],o&&this.raiseRecoverable(r.start,"Redefinition of property")}else s=e[n]={init:!1,get:!1,set:!1};s[a]=!0}};A.parseExpression=function(t,e){var i=this.start,r=this.startLoc,n=this.parseMaybeAssign(t,e);if(this.type===f.comma){var a=this.startNodeAt(i,r);for(a.expressions=[n];this.eat(f.comma);)a.expressions.push(this.parseMaybeAssign(t,e));return this.finishNode(a,"SequenceExpression")}return n};A.parseMaybeAssign=function(t,e,i){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(t);this.exprAllowed=!1}var r=!1,n=-1,a=-1,s=-1;e?(n=e.parenthesizedAssign,a=e.trailingComma,s=e.doubleProto,e.parenthesizedAssign=e.trailingComma=-1):(e=new St,r=!0);var o=this.start,c=this.startLoc;(this.type===f.parenL||this.type===f.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=t==="await");var l=this.parseMaybeConditional(t,e);if(i&&(l=i.call(this,l,o,c)),this.type.isAssign){var u=this.startNodeAt(o,c);return u.operator=this.value,this.type===f.eq&&(l=this.toAssignable(l,!1,e)),r||(e.parenthesizedAssign=e.trailingComma=e.doubleProto=-1),e.shorthandAssign>=l.start&&(e.shorthandAssign=-1),this.type===f.eq?this.checkLValPattern(l):this.checkLValSimple(l),u.left=l,this.next(),u.right=this.parseMaybeAssign(t),s>-1&&(e.doubleProto=s),this.finishNode(u,"AssignmentExpression")}else r&&this.checkExpressionErrors(e,!0);return n>-1&&(e.parenthesizedAssign=n),a>-1&&(e.trailingComma=a),l};A.parseMaybeConditional=function(t,e){var i=this.start,r=this.startLoc,n=this.parseExprOps(t,e);if(this.checkExpressionErrors(e))return n;if(this.eat(f.question)){var a=this.startNodeAt(i,r);return a.test=n,a.consequent=this.parseMaybeAssign(),this.expect(f.colon),a.alternate=this.parseMaybeAssign(t),this.finishNode(a,"ConditionalExpression")}return n};A.parseExprOps=function(t,e){var i=this.start,r=this.startLoc,n=this.parseMaybeUnary(e,!1,!1,t);return this.checkExpressionErrors(e)||n.start===i&&n.type==="ArrowFunctionExpression"?n:this.parseExprOp(n,i,r,-1,t)};A.parseExprOp=function(t,e,i,r,n){var a=this.type.binop;if(a!=null&&(!n||this.type!==f._in)&&a>r){var s=this.type===f.logicalOR||this.type===f.logicalAND,o=this.type===f.coalesce;o&&(a=f.logicalAND.binop);var c=this.value;this.next();var l=this.start,u=this.startLoc,p=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,n),l,u,a,n),h=this.buildBinary(e,i,t,p,c,s||o);return(s&&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(h,e,i,r,n)}return t};A.buildBinary=function(t,e,i,r,n,a){r.type==="PrivateIdentifier"&&this.raise(r.start,"Private identifier can only be left side of binary expression");var s=this.startNodeAt(t,e);return s.left=i,s.operator=n,s.right=r,this.finishNode(s,a?"LogicalExpression":"BinaryExpression")};A.parseMaybeUnary=function(t,e,i,r){var n=this.start,a=this.startLoc,s;if(this.isContextual("await")&&this.canAwait)s=this.parseAwait(r),e=!0;else if(this.type.prefix){var o=this.startNode(),c=this.type===f.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,c,r),this.checkExpressionErrors(t,!0),c?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&Hi(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&Vt(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):e=!0,s=this.finishNode(o,c?"UpdateExpression":"UnaryExpression")}else if(!e&&this.type===f.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),s=this.parsePrivateIdent(),this.type!==f._in&&this.unexpected();else{if(s=this.parseExprSubscripts(t,r),this.checkExpressionErrors(t))return s;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(n,a);l.operator=this.value,l.prefix=!1,l.argument=s,this.checkLValSimple(s),this.next(),s=this.finishNode(l,"UpdateExpression")}}if(!i&&this.eat(f.starstar))if(e)this.unexpected(this.lastTokStart);else return this.buildBinary(n,a,s,this.parseMaybeUnary(null,!1,!1,r),"**",!1);else return s};function Hi(t){return t.type==="Identifier"||t.type==="ParenthesizedExpression"&&Hi(t.expression)}function Vt(t){return t.type==="MemberExpression"&&t.property.type==="PrivateIdentifier"||t.type==="ChainExpression"&&Vt(t.expression)||t.type==="ParenthesizedExpression"&&Vt(t.expression)}A.parseExprSubscripts=function(t,e){var i=this.start,r=this.startLoc,n=this.parseExprAtom(t,e);if(n.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return n;var a=this.parseSubscripts(n,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};A.parseSubscripts=function(t,e,i,r,n){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,s=!1;;){var o=this.parseSubscript(t,e,i,r,a,s,n);if(o.optional&&(s=!0),o===t||o.type==="ArrowFunctionExpression"){if(s){var c=this.startNodeAt(e,i);c.expression=o,o=this.finishNode(c,"ChainExpression")}return o}t=o}};A.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(f.arrow)};A.parseSubscriptAsyncArrow=function(t,e,i,r){return this.parseArrowExpression(this.startNodeAt(t,e),i,!0,r)};A.parseSubscript=function(t,e,i,r,n,a,s){var o=this.options.ecmaVersion>=11,c=o&&this.eat(f.questionDot);r&&c&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var l=this.eat(f.bracketL);if(l||c&&this.type!==f.parenL&&this.type!==f.backQuote||this.eat(f.dot)){var u=this.startNodeAt(e,i);u.object=t,l?(u.property=this.parseExpression(),this.expect(f.bracketR)):this.type===f.privateId&&t.type!=="Super"?u.property=this.parsePrivateIdent():u.property=this.parseIdent(this.options.allowReserved!=="never"),u.computed=!!l,o&&(u.optional=c),t=this.finishNode(u,"MemberExpression")}else if(!r&&this.eat(f.parenL)){var p=new St,h=this.yieldPos,d=this.awaitPos,g=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var y=this.parseExprList(f.parenR,this.options.ecmaVersion>=8,!1,p);if(n&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=h,this.awaitPos=d,this.awaitIdentPos=g,this.parseSubscriptAsyncArrow(e,i,y,s);this.checkExpressionErrors(p,!0),this.yieldPos=h||this.yieldPos,this.awaitPos=d||this.awaitPos,this.awaitIdentPos=g||this.awaitIdentPos;var v=this.startNodeAt(e,i);v.callee=t,v.arguments=y,o&&(v.optional=c),t=this.finishNode(v,"CallExpression")}else if(this.type===f.backQuote){(c||a)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var w=this.startNodeAt(e,i);w.tag=t,w.quasi=this.parseTemplate({isTagged:!0}),t=this.finishNode(w,"TaggedTemplateExpression")}return t};A.parseExprAtom=function(t,e,i){this.type===f.slash&&this.readRegexp();var r,n=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,s=this.startLoc,o=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&c.name==="async"&&!this.canInsertSemicolon()&&this.eat(f._function))return this.overrideContext(F.f_expr),this.parseFunction(this.startNodeAt(a,s),0,!1,!0,e);if(n&&!this.canInsertSemicolon()){if(this.eat(f.arrow))return this.parseArrowExpression(this.startNodeAt(a,s),[c],!1,e);if(this.options.ecmaVersion>=8&&c.name==="async"&&this.type===f.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(f.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,s),[c],!0,e)}return c;case f.regexp:var l=this.value;return r=this.parseLiteral(l.value),r.regex={pattern:l.pattern,flags:l.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 u=this.start,p=this.parseParenAndDistinguishExpression(n,e);return t&&(t.parenthesizedAssign<0&&!this.isSimpleAssignTarget(p)&&(t.parenthesizedAssign=u),t.parenthesizedBind<0&&(t.parenthesizedBind=u)),p;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(F.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()}};A.parseExprAtomDefault=function(){this.unexpected()};A.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()};A.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")};A.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")};A.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.value!=null?e.value.toString():e.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(e,"Literal")};A.parseParenExpression=function(){this.expect(f.parenL);var t=this.parseExpression();return this.expect(f.parenR),t};A.shouldParseArrow=function(t){return!this.canInsertSemicolon()};A.parseParenAndDistinguishExpression=function(t,e){var i=this.start,r=this.startLoc,n,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var s=this.start,o=this.startLoc,c=[],l=!0,u=!1,p=new St,h=this.yieldPos,d=this.awaitPos,g;for(this.yieldPos=0,this.awaitPos=0;this.type!==f.parenR;)if(l?l=!1:this.expect(f.comma),a&&this.afterTrailingComma(f.parenR,!0)){u=!0;break}else if(this.type===f.ellipsis){g=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===f.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else c.push(this.parseMaybeAssign(!1,p,this.parseParenItem));var y=this.lastTokEnd,v=this.lastTokEndLoc;if(this.expect(f.parenR),t&&this.shouldParseArrow(c)&&this.eat(f.arrow))return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=h,this.awaitPos=d,this.parseParenArrowList(i,r,c,e);(!c.length||u)&&this.unexpected(this.lastTokStart),g&&this.unexpected(g),this.checkExpressionErrors(p,!0),this.yieldPos=h||this.yieldPos,this.awaitPos=d||this.awaitPos,c.length>1?(n=this.startNodeAt(s,o),n.expressions=c,this.finishNodeAt(n,"SequenceExpression",y,v)):n=c[0]}else n=this.parseParenExpression();if(this.options.preserveParens){var w=this.startNodeAt(i,r);return w.expression=n,this.finishNode(w,"ParenthesizedExpression")}else return n};A.parseParenItem=function(t){return t};A.parseParenArrowList=function(t,e,i,r){return this.parseArrowExpression(this.startNodeAt(t,e),i,!1,r)};var rn=[];A.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,n=this.startLoc;return t.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,n,!0,!1),this.eat(f.parenL)?t.arguments=this.parseExprList(f.parenR,this.options.ecmaVersion>=8,!1):t.arguments=rn,this.finishNode(t,"NewExpression")};A.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,`
18
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var Xr=require("fs"),Zr=require("path"),Jr=require("url");function Vi(t){if(t&&t.__esModule)return 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 Ye=Vi(Xr),rt=Vi(Zr),en=[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,78,5,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,199,7,137,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,55,9,266,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,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],Bi=[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,7,25,39,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,5,57,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,24,43,261,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,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7381,42,31,98,114,8702,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,208,30,2,2,2,1,2,6,3,4,10,1,225,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,4381,3,5773,3,7472,16,621,2467,541,1507,4938,6,8489],tn="\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-\u1ADD\u1AE0-\u1AEB\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",Fi="\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-\u088F\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\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\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-\uA7DC\uA7F1-\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",It={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"},kt="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",rn={5:kt,"5module":kt+" export import",6:kt+" const class extends export import super"},ji=/^in(stanceof)?$/,nn=new RegExp("["+Fi+"]"),sn=new RegExp("["+Fi+tn+"]");function Ot(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 be(t,e){return t<65?t===36:t<91?!0:t<97?t===95:t<123?!0:t<=65535?t>=170&&nn.test(String.fromCharCode(t)):e===!1?!1:Ot(t,Bi)}function Be(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&&sn.test(String.fromCharCode(t)):e===!1?!1:Ot(t,Bi)||Ot(t,en)}var O=function(e,i){i===void 0&&(i={}),this.label=e,this.keyword=i.keyword,this.beforeExpr=!!i.beforeExpr,this.startsExpr=!!i.startsExpr,this.isLoop=!!i.isLoop,this.isAssign=!!i.isAssign,this.prefix=!!i.prefix,this.postfix=!!i.postfix,this.binop=i.binop||null,this.updateContext=null};function ce(t,e){return new O(t,{beforeExpr:!0,binop:e})}var ue={beforeExpr:!0},re={startsExpr:!0},Ht={};function R(t,e){return e===void 0&&(e={}),e.keyword=t,Ht[t]=new O(t,e)}var d={num:new O("num",re),regexp:new O("regexp",re),string:new O("string",re),name:new O("name",re),privateId:new O("privateId",re),eof:new O("eof"),bracketL:new O("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new O("]"),braceL:new O("{",{beforeExpr:!0,startsExpr:!0}),braceR:new O("}"),parenL:new O("(",{beforeExpr:!0,startsExpr:!0}),parenR:new O(")"),comma:new O(",",ue),semi:new O(";",ue),colon:new O(":",ue),dot:new O("."),question:new O("?",ue),questionDot:new O("?."),arrow:new O("=>",ue),template:new O("template"),invalidTemplate:new O("invalidTemplate"),ellipsis:new O("...",ue),backQuote:new O("`",re),dollarBraceL:new O("${",{beforeExpr:!0,startsExpr:!0}),eq:new O("=",{beforeExpr:!0,isAssign:!0}),assign:new O("_=",{beforeExpr:!0,isAssign:!0}),incDec:new O("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new O("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:ce("||",1),logicalAND:ce("&&",2),bitwiseOR:ce("|",3),bitwiseXOR:ce("^",4),bitwiseAND:ce("&",5),equality:ce("==/!=/===/!==",6),relational:ce("</>/<=/>=",7),bitShift:ce("<</>>/>>>",8),plusMin:new O("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:ce("%",10),star:ce("*",10),slash:ce("/",10),starstar:new O("**",{beforeExpr:!0}),coalesce:ce("??",1),_break:R("break"),_case:R("case",ue),_catch:R("catch"),_continue:R("continue"),_debugger:R("debugger"),_default:R("default",ue),_do:R("do",{isLoop:!0,beforeExpr:!0}),_else:R("else",ue),_finally:R("finally"),_for:R("for",{isLoop:!0}),_function:R("function",re),_if:R("if"),_return:R("return",ue),_switch:R("switch"),_throw:R("throw",ue),_try:R("try"),_var:R("var"),_const:R("const"),_while:R("while",{isLoop:!0}),_with:R("with"),_new:R("new",{beforeExpr:!0,startsExpr:!0}),_this:R("this",re),_super:R("super",re),_class:R("class",re),_extends:R("extends",ue),_export:R("export"),_import:R("import",re),_null:R("null",re),_true:R("true",re),_false:R("false",re),_in:R("in",{beforeExpr:!0,binop:7}),_instanceof:R("instanceof",{beforeExpr:!0,binop:7}),_typeof:R("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:R("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:R("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},se=/\r\n?|\n|\u2028|\u2029/,an=new RegExp(se.source,"g");function Je(t){return t===10||t===13||t===8232||t===8233}function Wi(t,e,i){i===void 0&&(i=t.length);for(var r=e;r<i;r++){var n=t.charCodeAt(r);if(Je(n))return r<i-1&&n===13&&t.charCodeAt(r+1)===10?r+2:r+1}return-1}var $i=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,Q=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,Ui=Object.prototype,on=Ui.hasOwnProperty,ln=Ui.toString,et=Object.hasOwn||(function(t,e){return on.call(t,e)}),si=Array.isArray||(function(t){return ln.call(t)==="[object Array]"}),ai=Object.create(null);function Le(t){return ai[t]||(ai[t]=new RegExp("^(?:"+t.replace(/ /g,"|")+")$"))}function Ce(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}var cn=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,at=function(e,i){this.line=e,this.column=i};at.prototype.offset=function(e){return new at(this.line,this.column+e)};var bt=function(e,i,r){this.start=i,this.end=r,e.sourceFile!==null&&(this.source=e.sourceFile)};function qi(t,e){for(var i=1,r=0;;){var n=Wi(t,r,e);if(n<0)return new at(i,e-r);++i,r=n}}var Lt={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},oi=!1;function un(t){var e={};for(var i in Lt)e[i]=t&&et(t,i)?t[i]:Lt[i];if(e.ecmaVersion==="latest"?e.ecmaVersion=1e8:e.ecmaVersion==null?(!oi&&typeof console=="object"&&console.warn&&(oi=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
19
+ 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),si(e.onToken)){var r=e.onToken;e.onToken=function(n){return r.push(n)}}if(si(e.onComment)&&(e.onComment=hn(e,e.onComment)),e.sourceType==="commonjs"&&e.allowAwaitOutsideFunction)throw new Error("Cannot use allowAwaitOutsideFunction with sourceType: commonjs");return e}function hn(t,e){return function(i,r,n,a,s,o){var l={type:i?"Block":"Line",value:r,start:n,end:a};t.locations&&(l.loc=new bt(this,s,o)),t.ranges&&(l.range=[n,a]),e.push(l)}}var qe=1,He=2,Kt=4,Hi=8,zt=16,Ki=32,wt=64,zi=128,Ke=256,ot=512,Gi=1024,St=qe|He|Ke;function Gt(t,e){return He|(t?Kt:0)|(e?Hi:0)}var ft=0,Yt=1,ke=2,Yi=3,Qi=4,Xi=5,H=function(e,i,r){this.options=e=un(e),this.sourceFile=e.sourceFile,this.keywords=Le(rn[e.ecmaVersion>=6?6:e.sourceType==="module"?"5module":5]);var n="";e.allowReserved!==!0&&(n=It[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType==="module"&&(n+=" await")),this.reservedWords=Le(n);var a=(n?n+" ":"")+It.strict;this.reservedWordsStrict=Le(a),this.reservedWordsStrictBind=Le(a+" "+It.strictBind),this.input=String(i),this.containsEsc=!1,r?(this.pos=r,this.lineStart=this.input.lastIndexOf(`
20
+ `,r-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(se).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=d.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=e.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&&e.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType==="commonjs"?He:qe),this.regexpState=null,this.privateNameStack=[]},de={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};H.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)};de.inFunction.get=function(){return(this.currentVarScope().flags&He)>0};de.inGenerator.get=function(){return(this.currentVarScope().flags&Hi)>0};de.inAsync.get=function(){return(this.currentVarScope().flags&Kt)>0};de.canAwait.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var e=this.scopeStack[t],i=e.flags;if(i&(Ke|ot))return!1;if(i&He)return(i&Kt)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};de.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&qe)};de.allowSuper.get=function(){var t=this.currentThisScope(),e=t.flags;return(e&wt)>0||this.options.allowSuperOutsideMethod};de.allowDirectSuper.get=function(){return(this.currentThisScope().flags&zi)>0};de.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};de.allowNewDotTarget.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var e=this.scopeStack[t],i=e.flags;if(i&(Ke|ot)||i&He&&!(i&zt))return!0}return!1};de.allowUsing.get=function(){var t=this.currentScope(),e=t.flags;return!(e&Gi||!this.inModule&&e&qe)};de.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&Ke)>0};H.extend=function(){for(var e=[],i=arguments.length;i--;)e[i]=arguments[i];for(var r=this,n=0;n<e.length;n++)r=e[n](r);return r};H.parse=function(e,i){return new this(i,e).parse()};H.parseExpressionAt=function(e,i,r){var n=new this(r,e,i);return n.nextToken(),n.parseExpression()};H.tokenizer=function(e,i){return new this(i,e)};Object.defineProperties(H.prototype,de);var te=H.prototype,pn=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;te.strictDirective=function(t){if(this.options.ecmaVersion<5)return!1;for(;;){Q.lastIndex=t,t+=Q.exec(this.input)[0].length;var e=pn.exec(this.input.slice(t));if(!e)return!1;if((e[1]||e[2])==="use strict"){Q.lastIndex=t+e[0].length;var i=Q.exec(this.input),r=i.index+i[0].length,n=this.input.charAt(r);return n===";"||n==="}"||se.test(i[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(n)||n==="!"&&this.input.charAt(r+1)==="=")}t+=e[0].length,Q.lastIndex=t,t+=Q.exec(this.input)[0].length,this.input[t]===";"&&t++}};te.eat=function(t){return this.type===t?(this.next(),!0):!1};te.isContextual=function(t){return this.type===d.name&&this.value===t&&!this.containsEsc};te.eatContextual=function(t){return this.isContextual(t)?(this.next(),!0):!1};te.expectContextual=function(t){this.eatContextual(t)||this.unexpected()};te.canInsertSemicolon=function(){return this.type===d.eof||this.type===d.braceR||se.test(this.input.slice(this.lastTokEnd,this.start))};te.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};te.semicolon=function(){!this.eat(d.semi)&&!this.insertSemicolon()&&this.unexpected()};te.afterTrailingComma=function(t,e){if(this.type===t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0};te.expect=function(t){this.eat(t)||this.unexpected()};te.unexpected=function(t){this.raise(t??this.start,"Unexpected token")};var Et=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};te.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")}};te.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")};te.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")};te.isSimpleAssignTarget=function(t){return t.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(t.expression):t.type==="Identifier"||t.type==="MemberExpression"};var k=H.prototype;k.parseTopLevel=function(t){var e=Object.create(null);for(t.body||(t.body=[]);this.type!==d.eof;){var i=this.parseStatement(null,!0,e);t.body.push(i)}if(this.inModule)for(var r=0,n=Object.keys(this.undefinedExports);r<n.length;r+=1){var a=n[r];this.raiseRecoverable(this.undefinedExports[a].start,"Export '"+a+"' is not defined")}return this.adaptDirectivePrologue(t.body),this.next(),t.sourceType=this.options.sourceType==="commonjs"?"script":this.options.sourceType,this.finishNode(t,"Program")};var Qt={kind:"loop"},fn={kind:"switch"};k.isLet=function(t){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;Q.lastIndex=this.pos;var e=Q.exec(this.input),i=this.pos+e[0].length,r=this.fullCharCodeAt(i);if(r===91||r===92)return!0;if(t)return!1;if(r===123)return!0;if(be(r)){var n=i;do i+=r<=65535?1:2;while(Be(r=this.fullCharCodeAt(i)));if(r===92)return!0;var a=this.input.slice(n,i);if(!ji.test(a))return!0}return!1};k.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;Q.lastIndex=this.pos;var t=Q.exec(this.input),e=this.pos+t[0].length,i;return!se.test(this.input.slice(this.pos,e))&&this.input.slice(e,e+8)==="function"&&(e+8===this.input.length||!(Be(i=this.fullCharCodeAt(e+8))||i===92))};k.isUsingKeyword=function(t,e){if(this.options.ecmaVersion<17||!this.isContextual(t?"await":"using"))return!1;Q.lastIndex=this.pos;var i=Q.exec(this.input),r=this.pos+i[0].length;if(se.test(this.input.slice(this.pos,r)))return!1;if(t){var n=r+5,a;if(this.input.slice(r,n)!=="using"||n===this.input.length||Be(a=this.fullCharCodeAt(n))||a===92)return!1;Q.lastIndex=n;var s=Q.exec(this.input);if(r=n+s[0].length,s&&se.test(this.input.slice(n,r)))return!1}var o=this.fullCharCodeAt(r);if(!be(o)&&o!==92)return!1;var l=r;do r+=o<=65535?1:2;while(Be(o=this.fullCharCodeAt(r)));if(o===92)return!0;var c=this.input.slice(l,r);return!(ji.test(c)||e&&c==="of")};k.isAwaitUsing=function(t){return this.isUsingKeyword(!0,t)};k.isUsing=function(t){return this.isUsingKeyword(!1,t)};k.parseStatement=function(t,e,i){var r=this.type,n=this.startNode(),a;switch(this.isLet(t)&&(r=d._var,a="let"),r){case d._break:case d._continue:return this.parseBreakContinueStatement(n,r.keyword);case d._debugger:return this.parseDebuggerStatement(n);case d._do:return this.parseDoStatement(n);case d._for:return this.parseForStatement(n);case d._function:return t&&(this.strict||t!=="if"&&t!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(n,!1,!t);case d._class:return t&&this.unexpected(),this.parseClass(n,!0);case d._if:return this.parseIfStatement(n);case d._return:return this.parseReturnStatement(n);case d._switch:return this.parseSwitchStatement(n);case d._throw:return this.parseThrowStatement(n);case d._try:return this.parseTryStatement(n);case d._const:case d._var:return a=a||this.value,t&&a!=="var"&&this.unexpected(),this.parseVarStatement(n,a);case d._while:return this.parseWhileStatement(n);case d._with:return this.parseWithStatement(n);case d.braceL:return this.parseBlock(!0,n);case d.semi:return this.parseEmptyStatement(n);case d._export:case d._import:if(this.options.ecmaVersion>10&&r===d._import){Q.lastIndex=this.pos;var s=Q.exec(this.input),o=this.pos+s[0].length,l=this.input.charCodeAt(o);if(l===40||l===46)return this.parseExpressionStatement(n,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===d._import?this.parseImport(n):this.parseExport(n,i);default:if(this.isAsyncFunction())return t&&this.unexpected(),this.next(),this.parseFunctionStatement(n,!0,!t);var c=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(c)return this.allowUsing||this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"),c==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(n,!1,c),this.semicolon(),this.finishNode(n,"VariableDeclaration");var u=this.value,p=this.parseExpression();return r===d.name&&p.type==="Identifier"&&this.eat(d.colon)?this.parseLabeledStatement(n,u,p,t):this.parseExpressionStatement(n,p)}};k.parseBreakContinueStatement=function(t,e){var i=e==="break";this.next(),this.eat(d.semi)||this.insertSemicolon()?t.label=null:this.type!==d.name?this.unexpected():(t.label=this.parseIdent(),this.semicolon());for(var r=0;r<this.labels.length;++r){var n=this.labels[r];if((t.label==null||n.name===t.label.name)&&(n.kind!=null&&(i||n.kind==="loop")||t.label&&i))break}return r===this.labels.length&&this.raise(t.start,"Unsyntactic "+e),this.finishNode(t,i?"BreakStatement":"ContinueStatement")};k.parseDebuggerStatement=function(t){return this.next(),this.semicolon(),this.finishNode(t,"DebuggerStatement")};k.parseDoStatement=function(t){return this.next(),this.labels.push(Qt),t.body=this.parseStatement("do"),this.labels.pop(),this.expect(d._while),t.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(d.semi):this.semicolon(),this.finishNode(t,"DoWhileStatement")};k.parseForStatement=function(t){this.next();var e=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(Qt),this.enterScope(0),this.expect(d.parenL),this.type===d.semi)return e>-1&&this.unexpected(e),this.parseFor(t,null);var i=this.isLet();if(this.type===d._var||this.type===d._const||i){var r=this.startNode(),n=i?"let":this.value;return this.next(),this.parseVar(r,!0,n),this.finishNode(r,"VariableDeclaration"),this.parseForAfterInit(t,r,e)}var a=this.isContextual("let"),s=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var l=this.startNode();return this.next(),o==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.parseVar(l,!0,o),this.finishNode(l,"VariableDeclaration"),this.parseForAfterInit(t,l,e)}var c=this.containsEsc,u=new Et,p=this.start,h=e>-1?this.parseExprSubscripts(u,"await"):this.parseExpression(!0,u);return this.type===d._in||(s=this.options.ecmaVersion>=6&&this.isContextual("of"))?(e>-1?(this.type===d._in&&this.unexpected(e),t.await=!0):s&&this.options.ecmaVersion>=8&&(h.start===p&&!c&&h.type==="Identifier"&&h.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(t.await=!1)),a&&s&&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))};k.parseForAfterInit=function(t,e,i){return(this.type===d._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&e.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===d._in?i>-1&&this.unexpected(i):t.await=i>-1),this.parseForIn(t,e)):(i>-1&&this.unexpected(i),this.parseFor(t,e))};k.parseFunctionStatement=function(t,e,i){return this.next(),this.parseFunction(t,nt|(i?0:Vt),!1,e)};k.parseIfStatement=function(t){return this.next(),t.test=this.parseParenExpression(),t.consequent=this.parseStatement("if"),t.alternate=this.eat(d._else)?this.parseStatement("if"):null,this.finishNode(t,"IfStatement")};k.parseReturnStatement=function(t){return this.allowReturn||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(d.semi)||this.insertSemicolon()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")};k.parseSwitchStatement=function(t){this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(d.braceL),this.labels.push(fn),this.enterScope(Gi);for(var e,i=!1;this.type!==d.braceR;)if(this.type===d._case||this.type===d._default){var r=this.type===d._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(d.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")};k.parseThrowStatement=function(t){return this.next(),se.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 dn=[];k.parseCatchClauseParam=function(){var t=this.parseBindingAtom(),e=t.type==="Identifier";return this.enterScope(e?Ki:0),this.checkLValPattern(t,e?Qi:ke),this.expect(d.parenR),t};k.parseTryStatement=function(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.type===d._catch){var e=this.startNode();this.next(),this.eat(d.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(d._finally)?this.parseBlock():null,!t.handler&&!t.finalizer&&this.raise(t.start,"Missing catch or finally clause"),this.finishNode(t,"TryStatement")};k.parseVarStatement=function(t,e,i){return this.next(),this.parseVar(t,!1,e,i),this.semicolon(),this.finishNode(t,"VariableDeclaration")};k.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push(Qt),t.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(t,"WhileStatement")};k.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")};k.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,"EmptyStatement")};k.parseLabeledStatement=function(t,e,i,r){for(var n=0,a=this.labels;n<a.length;n+=1){var s=a[n];s.name===e&&this.raise(i.start,"Label '"+e+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===d._switch?"switch":null,l=this.labels.length-1;l>=0;l--){var c=this.labels[l];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")};k.parseExpressionStatement=function(t,e){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")};k.parseBlock=function(t,e,i){for(t===void 0&&(t=!0),e===void 0&&(e=this.startNode()),e.body=[],this.expect(d.braceL),t&&this.enterScope(0);this.type!==d.braceR;){var r=this.parseStatement(null);e.body.push(r)}return i&&(this.strict=!1),this.next(),t&&this.exitScope(),this.finishNode(e,"BlockStatement")};k.parseFor=function(t,e){return t.init=e,this.expect(d.semi),t.test=this.type===d.semi?null:this.parseExpression(),this.expect(d.semi),t.update=this.type===d.parenR?null:this.parseExpression(),this.expect(d.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,"ForStatement")};k.parseForIn=function(t,e){var i=this.type===d._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(d.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,i?"ForInStatement":"ForOfStatement")};k.parseVar=function(t,e,i,r){for(t.declarations=[],t.kind=i;;){var n=this.startNode();if(this.parseVarId(n,i),this.eat(d.eq)?n.init=this.parseMaybeAssign(e):!r&&i==="const"&&!(this.type===d._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!r&&(i==="using"||i==="await using")&&this.options.ecmaVersion>=17&&this.type!==d._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+i+" declaration"):!r&&n.id.type!=="Identifier"&&!(e&&(this.type===d._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):n.init=null,t.declarations.push(this.finishNode(n,"VariableDeclarator")),!this.eat(d.comma))break}return t};k.parseVarId=function(t,e){t.id=e==="using"||e==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(t.id,e==="var"?Yt:ke,!1)};var nt=1,Vt=2,Zi=4;k.parseFunction=function(t,e,i,r,n){this.initFunction(t),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===d.star&&e&Vt&&this.unexpected(),t.generator=this.eat(d.star)),this.options.ecmaVersion>=8&&(t.async=!!r),e&nt&&(t.id=e&Zi&&this.type!==d.name?null:this.parseIdent(),t.id&&!(e&Vt)&&this.checkLValSimple(t.id,this.strict||t.generator||t.async?this.treatFunctionsAsVar?Yt:ke:Yi));var a=this.yieldPos,s=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Gt(t.async,t.generator)),e&nt||(t.id=this.type===d.name?this.parseIdent():null),this.parseFunctionParams(t),this.parseFunctionBody(t,i,!1,n),this.yieldPos=a,this.awaitPos=s,this.awaitIdentPos=o,this.finishNode(t,e&nt?"FunctionDeclaration":"FunctionExpression")};k.parseFunctionParams=function(t){this.expect(d.parenL),t.params=this.parseBindingList(d.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};k.parseClass=function(t,e){this.next();var i=this.strict;this.strict=!0,this.parseClassId(t,e),this.parseClassSuper(t);var r=this.enterClassBody(),n=this.startNode(),a=!1;for(n.body=[],this.expect(d.braceL);this.type!==d.braceR;){var s=this.parseClassElement(t.superClass!==null);s&&(n.body.push(s),s.type==="MethodDefinition"&&s.kind==="constructor"?(a&&this.raiseRecoverable(s.start,"Duplicate constructor in the same class"),a=!0):s.key&&s.key.type==="PrivateIdentifier"&&mn(r,s)&&this.raiseRecoverable(s.key.start,"Identifier '#"+s.key.name+"' has already been declared"))}return this.strict=i,this.next(),t.body=this.finishNode(n,"ClassBody"),this.exitClassBody(),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")};k.parseClassElement=function(t){if(this.eat(d.semi))return null;var e=this.options.ecmaVersion,i=this.startNode(),r="",n=!1,a=!1,s="method",o=!1;if(this.eatContextual("static")){if(e>=13&&this.eat(d.braceL))return this.parseClassStaticBlock(i),i;this.isClassElementNameStart()||this.type===d.star?o=!0:r="static"}if(i.static=o,!r&&e>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===d.star)&&!this.canInsertSemicolon()?a=!0:r="async"),!r&&(e>=9||!a)&&this.eat(d.star)&&(n=!0),!r&&!a&&!n){var l=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?s=l:r=l)}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===d.parenL||s!=="method"||n||a){var c=!i.static&&dt(i,"constructor"),u=c&&t;c&&s!=="method"&&this.raise(i.key.start,"Constructor can't have get/set modifier"),i.kind=c?"constructor":s,this.parseClassMethod(i,n,a,u)}else this.parseClassField(i);return i};k.isClassElementNameStart=function(){return this.type===d.name||this.type===d.privateId||this.type===d.num||this.type===d.string||this.type===d.bracketL||this.type.keyword};k.parseClassElementName=function(t){this.type===d.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)};k.parseClassMethod=function(t,e,i,r){var n=t.key;t.kind==="constructor"?(e&&this.raise(n.start,"Constructor can't be a generator"),i&&this.raise(n.start,"Constructor can't be an async method")):t.static&&dt(t,"prototype")&&this.raise(n.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")};k.parseClassField=function(t){return dt(t,"constructor")?this.raise(t.key.start,"Classes can't have a field named 'constructor'"):t.static&&dt(t,"prototype")&&this.raise(t.key.start,"Classes can't have a static field named 'prototype'"),this.eat(d.eq)?(this.enterScope(ot|wt),t.value=this.parseMaybeAssign(),this.exitScope()):t.value=null,this.semicolon(),this.finishNode(t,"PropertyDefinition")};k.parseClassStaticBlock=function(t){t.body=[];var e=this.labels;for(this.labels=[],this.enterScope(Ke|wt);this.type!==d.braceR;){var i=this.parseStatement(null);t.body.push(i)}return this.next(),this.exitScope(),this.labels=e,this.finishNode(t,"StaticBlock")};k.parseClassId=function(t,e){this.type===d.name?(t.id=this.parseIdent(),e&&this.checkLValSimple(t.id,ke,!1)):(e===!0&&this.unexpected(),t.id=null)};k.parseClassSuper=function(t){t.superClass=this.eat(d._extends)?this.parseExprSubscripts(null,!1):null};k.enterClassBody=function(){var t={declared:Object.create(null),used:[]};return this.privateNameStack.push(t),t.declared};k.exitClassBody=function(){var t=this.privateNameStack.pop(),e=t.declared,i=t.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,n=r===0?null:this.privateNameStack[r-1],a=0;a<i.length;++a){var s=i[a];et(e,s.name)||(n?n.used.push(s):this.raiseRecoverable(s.start,"Private field '#"+s.name+"' must be declared in an enclosing class"))}};function mn(t,e){var i=e.key.name,r=t[i],n="true";return e.type==="MethodDefinition"&&(e.kind==="get"||e.kind==="set")&&(n=(e.static?"s":"i")+e.kind),r==="iget"&&n==="iset"||r==="iset"&&n==="iget"||r==="sget"&&n==="sset"||r==="sset"&&n==="sget"?(t[i]="true",!1):r?!0:(t[i]=n,!1)}function dt(t,e){var i=t.computed,r=t.key;return!i&&(r.type==="Identifier"&&r.name===e||r.type==="Literal"&&r.value===e)}k.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!==d.string&&this.unexpected(),t.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(t,"ExportAllDeclaration")};k.parseExport=function(t,e){if(this.next(),this.eat(d.star))return this.parseExportAllDeclaration(t,e);if(this.eat(d._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,this.options.ecmaVersion>=16&&(t.attributes=[]);else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==d.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 n=r[i];this.checkUnreserved(n.local),this.checkLocalExport(n.local),n.local.type==="Literal"&&this.raise(n.local.start,"A string literal cannot be used as an exported binding without `from`.")}t.source=null,this.options.ecmaVersion>=16&&(t.attributes=[])}this.semicolon()}return this.finishNode(t,"ExportNamedDeclaration")};k.parseExportDeclaration=function(t){return this.parseStatement(null)};k.parseExportDefaultDeclaration=function(){var t;if(this.type===d._function||(t=this.isAsyncFunction())){var e=this.startNode();return this.next(),t&&this.next(),this.parseFunction(e,nt|Zi,!1,t)}else if(this.type===d._class){var i=this.startNode();return this.parseClass(i,"nullableID")}else{var r=this.parseMaybeAssign();return this.semicolon(),r}};k.checkExport=function(t,e,i){t&&(typeof e!="string"&&(e=e.type==="Identifier"?e.name:e.value),et(t,e)&&this.raiseRecoverable(i,"Duplicate export '"+e+"'"),t[e]=!0)};k.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,n=e.properties;r<n.length;r+=1){var a=n[r];this.checkPatternExport(t,a)}else if(i==="ArrayPattern")for(var s=0,o=e.elements;s<o.length;s+=1){var l=o[s];l&&this.checkPatternExport(t,l)}else i==="Property"?this.checkPatternExport(t,e.value):i==="AssignmentPattern"?this.checkPatternExport(t,e.left):i==="RestElement"&&this.checkPatternExport(t,e.argument)};k.checkVariableExport=function(t,e){if(t)for(var i=0,r=e;i<r.length;i+=1){var n=r[i];this.checkPatternExport(t,n.id)}};k.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};k.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")};k.parseExportSpecifiers=function(t){var e=[],i=!0;for(this.expect(d.braceL);!this.eat(d.braceR);){if(i)i=!1;else if(this.expect(d.comma),this.afterTrailingComma(d.braceR))break;e.push(this.parseExportSpecifier(t))}return e};k.parseImport=function(t){return this.next(),this.type===d.string?(t.specifiers=dn,t.source=this.parseExprAtom()):(t.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),t.source=this.type===d.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(t,"ImportDeclaration")};k.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,ke),this.finishNode(t,"ImportSpecifier")};k.parseImportDefaultSpecifier=function(){var t=this.startNode();return t.local=this.parseIdent(),this.checkLValSimple(t.local,ke),this.finishNode(t,"ImportDefaultSpecifier")};k.parseImportNamespaceSpecifier=function(){var t=this.startNode();return this.next(),this.expectContextual("as"),t.local=this.parseIdent(),this.checkLValSimple(t.local,ke),this.finishNode(t,"ImportNamespaceSpecifier")};k.parseImportSpecifiers=function(){var t=[],e=!0;if(this.type===d.name&&(t.push(this.parseImportDefaultSpecifier()),!this.eat(d.comma)))return t;if(this.type===d.star)return t.push(this.parseImportNamespaceSpecifier()),t;for(this.expect(d.braceL);!this.eat(d.braceR);){if(e)e=!1;else if(this.expect(d.comma),this.afterTrailingComma(d.braceR))break;t.push(this.parseImportSpecifier())}return t};k.parseWithClause=function(){var t=[];if(!this.eat(d._with))return t;this.expect(d.braceL);for(var e={},i=!0;!this.eat(d.braceR);){if(i)i=!1;else if(this.expect(d.comma),this.afterTrailingComma(d.braceR))break;var r=this.parseImportAttribute(),n=r.key.type==="Identifier"?r.key.name:r.key.value;et(e,n)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+n+"'"),e[n]=!0,t.push(r)}return t};k.parseImportAttribute=function(){var t=this.startNode();return t.key=this.type===d.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(d.colon),this.type!==d.string&&this.unexpected(),t.value=this.parseExprAtom(),this.finishNode(t,"ImportAttribute")};k.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===d.string){var t=this.parseLiteral(this.value);return cn.test(t.value)&&this.raise(t.start,"An export name cannot include a lone surrogate."),t}return this.parseIdent(!0)};k.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)};k.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 me=H.prototype;me.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,n=t.properties;r<n.length;r+=1){var a=n[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};me.toAssignableList=function(t,e){for(var i=t.length,r=0;r<i;r++){var n=t[r];n&&this.toAssignable(n,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};me.parseSpread=function(t){var e=this.startNode();return this.next(),e.argument=this.parseMaybeAssign(!1,t),this.finishNode(e,"SpreadElement")};me.parseRestBinding=function(){var t=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==d.name&&this.unexpected(),t.argument=this.parseBindingAtom(),this.finishNode(t,"RestElement")};me.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case d.bracketL:var t=this.startNode();return this.next(),t.elements=this.parseBindingList(d.bracketR,!0,!0),this.finishNode(t,"ArrayPattern");case d.braceL:return this.parseObj(!0)}return this.parseIdent()};me.parseBindingList=function(t,e,i,r){for(var n=[],a=!0;!this.eat(t);)if(a?a=!1:this.expect(d.comma),e&&this.type===d.comma)n.push(null);else{if(i&&this.afterTrailingComma(t))break;if(this.type===d.ellipsis){var s=this.parseRestBinding();this.parseBindingListItem(s),n.push(s),this.type===d.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(t);break}else n.push(this.parseAssignableListItem(r))}return n};me.parseAssignableListItem=function(t){var e=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(e),e};me.parseBindingListItem=function(t){return t};me.parseMaybeDefault=function(t,e,i){if(i=i||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(d.eq))return i;var r=this.startNodeAt(t,e);return r.left=i,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")};me.checkLValSimple=function(t,e,i){e===void 0&&(e=ft);var r=e!==ft;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===ke&&t.name==="let"&&this.raiseRecoverable(t.start,"let is disallowed as a lexically bound name"),i&&(et(i,t.name)&&this.raiseRecoverable(t.start,"Argument name clash"),i[t.name]=!0),e!==Xi&&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")}};me.checkLValPattern=function(t,e,i){switch(e===void 0&&(e=ft),t.type){case"ObjectPattern":for(var r=0,n=t.properties;r<n.length;r+=1){var a=n[r];this.checkLValInnerPattern(a,e,i)}break;case"ArrayPattern":for(var s=0,o=t.elements;s<o.length;s+=1){var l=o[s];l&&this.checkLValInnerPattern(l,e,i)}break;default:this.checkLValSimple(t,e,i)}};me.checkLValInnerPattern=function(t,e,i){switch(e===void 0&&(e=ft),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 xe=function(e,i,r,n,a){this.token=e,this.isExpr=!!i,this.preserveSpace=!!r,this.override=n,this.generator=!!a},j={b_stat:new xe("{",!1),b_expr:new xe("{",!0),b_tmpl:new xe("${",!1),p_stat:new xe("(",!1),p_expr:new xe("(",!0),q_tmpl:new xe("`",!0,!0,function(t){return t.tryReadTemplateToken()}),f_stat:new xe("function",!1),f_expr:new xe("function",!0),f_expr_gen:new xe("function",!0,!1,null,!0),f_gen:new xe("function",!1,!1,null,!0)},tt=H.prototype;tt.initialContext=function(){return[j.b_stat]};tt.curContext=function(){return this.context[this.context.length-1]};tt.braceIsBlock=function(t){var e=this.curContext();return e===j.f_expr||e===j.f_stat?!0:t===d.colon&&(e===j.b_stat||e===j.b_expr)?!e.isExpr:t===d._return||t===d.name&&this.exprAllowed?se.test(this.input.slice(this.lastTokEnd,this.start)):t===d._else||t===d.semi||t===d.eof||t===d.parenR||t===d.arrow?!0:t===d.braceL?e===j.b_stat:t===d._var||t===d._const||t===d.name?!1:!this.exprAllowed};tt.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};tt.updateContext=function(t){var e,i=this.type;i.keyword&&t===d.dot?this.exprAllowed=!1:(e=i.updateContext)?e.call(this,t):this.exprAllowed=i.beforeExpr};tt.overrideContext=function(t){this.curContext()!==t&&(this.context[this.context.length-1]=t)};d.parenR.updateContext=d.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var t=this.context.pop();t===j.b_stat&&this.curContext().token==="function"&&(t=this.context.pop()),this.exprAllowed=!t.isExpr};d.braceL.updateContext=function(t){this.context.push(this.braceIsBlock(t)?j.b_stat:j.b_expr),this.exprAllowed=!0};d.dollarBraceL.updateContext=function(){this.context.push(j.b_tmpl),this.exprAllowed=!0};d.parenL.updateContext=function(t){var e=t===d._if||t===d._for||t===d._with||t===d._while;this.context.push(e?j.p_stat:j.p_expr),this.exprAllowed=!0};d.incDec.updateContext=function(){};d._function.updateContext=d._class.updateContext=function(t){t.beforeExpr&&t!==d._else&&!(t===d.semi&&this.curContext()!==j.p_stat)&&!(t===d._return&&se.test(this.input.slice(this.lastTokEnd,this.start)))&&!((t===d.colon||t===d.braceL)&&this.curContext()===j.b_stat)?this.context.push(j.f_expr):this.context.push(j.f_stat),this.exprAllowed=!1};d.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};d.backQuote.updateContext=function(){this.curContext()===j.q_tmpl?this.context.pop():this.context.push(j.q_tmpl),this.exprAllowed=!1};d.star.updateContext=function(t){if(t===d._function){var e=this.context.length-1;this.context[e]===j.f_expr?this.context[e]=j.f_expr_gen:this.context[e]=j.f_gen}this.exprAllowed=!0};d.name.updateContext=function(t){var e=!1;this.options.ecmaVersion>=6&&t!==d.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(e=!0),this.exprAllowed=e};var A=H.prototype;A.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,n;switch(r.type){case"Identifier":n=r.name;break;case"Literal":n=String(r.value);break;default:return}var a=t.kind;if(this.options.ecmaVersion>=6){n==="__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}n="$"+n;var s=e[n];if(s){var o;a==="init"?o=this.strict&&s.init||s.get||s.set:o=s.init||s[a],o&&this.raiseRecoverable(r.start,"Redefinition of property")}else s=e[n]={init:!1,get:!1,set:!1};s[a]=!0}};A.parseExpression=function(t,e){var i=this.start,r=this.startLoc,n=this.parseMaybeAssign(t,e);if(this.type===d.comma){var a=this.startNodeAt(i,r);for(a.expressions=[n];this.eat(d.comma);)a.expressions.push(this.parseMaybeAssign(t,e));return this.finishNode(a,"SequenceExpression")}return n};A.parseMaybeAssign=function(t,e,i){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(t);this.exprAllowed=!1}var r=!1,n=-1,a=-1,s=-1;e?(n=e.parenthesizedAssign,a=e.trailingComma,s=e.doubleProto,e.parenthesizedAssign=e.trailingComma=-1):(e=new Et,r=!0);var o=this.start,l=this.startLoc;(this.type===d.parenL||this.type===d.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=t==="await");var c=this.parseMaybeConditional(t,e);if(i&&(c=i.call(this,c,o,l)),this.type.isAssign){var u=this.startNodeAt(o,l);return u.operator=this.value,this.type===d.eq&&(c=this.toAssignable(c,!1,e)),r||(e.parenthesizedAssign=e.trailingComma=e.doubleProto=-1),e.shorthandAssign>=c.start&&(e.shorthandAssign=-1),this.type===d.eq?this.checkLValPattern(c):this.checkLValSimple(c),u.left=c,this.next(),u.right=this.parseMaybeAssign(t),s>-1&&(e.doubleProto=s),this.finishNode(u,"AssignmentExpression")}else r&&this.checkExpressionErrors(e,!0);return n>-1&&(e.parenthesizedAssign=n),a>-1&&(e.trailingComma=a),c};A.parseMaybeConditional=function(t,e){var i=this.start,r=this.startLoc,n=this.parseExprOps(t,e);if(this.checkExpressionErrors(e))return n;if(this.eat(d.question)){var a=this.startNodeAt(i,r);return a.test=n,a.consequent=this.parseMaybeAssign(),this.expect(d.colon),a.alternate=this.parseMaybeAssign(t),this.finishNode(a,"ConditionalExpression")}return n};A.parseExprOps=function(t,e){var i=this.start,r=this.startLoc,n=this.parseMaybeUnary(e,!1,!1,t);return this.checkExpressionErrors(e)||n.start===i&&n.type==="ArrowFunctionExpression"?n:this.parseExprOp(n,i,r,-1,t)};A.parseExprOp=function(t,e,i,r,n){var a=this.type.binop;if(a!=null&&(!n||this.type!==d._in)&&a>r){var s=this.type===d.logicalOR||this.type===d.logicalAND,o=this.type===d.coalesce;o&&(a=d.logicalAND.binop);var l=this.value;this.next();var c=this.start,u=this.startLoc,p=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,n),c,u,a,n),h=this.buildBinary(e,i,t,p,l,s||o);return(s&&this.type===d.coalesce||o&&(this.type===d.logicalOR||this.type===d.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(h,e,i,r,n)}return t};A.buildBinary=function(t,e,i,r,n,a){r.type==="PrivateIdentifier"&&this.raise(r.start,"Private identifier can only be left side of binary expression");var s=this.startNodeAt(t,e);return s.left=i,s.operator=n,s.right=r,this.finishNode(s,a?"LogicalExpression":"BinaryExpression")};A.parseMaybeUnary=function(t,e,i,r){var n=this.start,a=this.startLoc,s;if(this.isContextual("await")&&this.canAwait)s=this.parseAwait(r),e=!0;else if(this.type.prefix){var o=this.startNode(),l=this.type===d.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,l,r),this.checkExpressionErrors(t,!0),l?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&Ji(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&Bt(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):e=!0,s=this.finishNode(o,l?"UpdateExpression":"UnaryExpression")}else if(!e&&this.type===d.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),s=this.parsePrivateIdent(),this.type!==d._in&&this.unexpected();else{if(s=this.parseExprSubscripts(t,r),this.checkExpressionErrors(t))return s;for(;this.type.postfix&&!this.canInsertSemicolon();){var c=this.startNodeAt(n,a);c.operator=this.value,c.prefix=!1,c.argument=s,this.checkLValSimple(s),this.next(),s=this.finishNode(c,"UpdateExpression")}}if(!i&&this.eat(d.starstar))if(e)this.unexpected(this.lastTokStart);else return this.buildBinary(n,a,s,this.parseMaybeUnary(null,!1,!1,r),"**",!1);else return s};function Ji(t){return t.type==="Identifier"||t.type==="ParenthesizedExpression"&&Ji(t.expression)}function Bt(t){return t.type==="MemberExpression"&&t.property.type==="PrivateIdentifier"||t.type==="ChainExpression"&&Bt(t.expression)||t.type==="ParenthesizedExpression"&&Bt(t.expression)}A.parseExprSubscripts=function(t,e){var i=this.start,r=this.startLoc,n=this.parseExprAtom(t,e);if(n.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return n;var a=this.parseSubscripts(n,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};A.parseSubscripts=function(t,e,i,r,n){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,s=!1;;){var o=this.parseSubscript(t,e,i,r,a,s,n);if(o.optional&&(s=!0),o===t||o.type==="ArrowFunctionExpression"){if(s){var l=this.startNodeAt(e,i);l.expression=o,o=this.finishNode(l,"ChainExpression")}return o}t=o}};A.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(d.arrow)};A.parseSubscriptAsyncArrow=function(t,e,i,r){return this.parseArrowExpression(this.startNodeAt(t,e),i,!0,r)};A.parseSubscript=function(t,e,i,r,n,a,s){var o=this.options.ecmaVersion>=11,l=o&&this.eat(d.questionDot);r&&l&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var c=this.eat(d.bracketL);if(c||l&&this.type!==d.parenL&&this.type!==d.backQuote||this.eat(d.dot)){var u=this.startNodeAt(e,i);u.object=t,c?(u.property=this.parseExpression(),this.expect(d.bracketR)):this.type===d.privateId&&t.type!=="Super"?u.property=this.parsePrivateIdent():u.property=this.parseIdent(this.options.allowReserved!=="never"),u.computed=!!c,o&&(u.optional=l),t=this.finishNode(u,"MemberExpression")}else if(!r&&this.eat(d.parenL)){var p=new Et,h=this.yieldPos,f=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var y=this.parseExprList(d.parenR,this.options.ecmaVersion>=8,!1,p);if(n&&!l&&this.shouldParseAsyncArrow())return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=h,this.awaitPos=f,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(e,i,y,s);this.checkExpressionErrors(p,!0),this.yieldPos=h||this.yieldPos,this.awaitPos=f||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var _=this.startNodeAt(e,i);_.callee=t,_.arguments=y,o&&(_.optional=l),t=this.finishNode(_,"CallExpression")}else if(this.type===d.backQuote){(l||a)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var v=this.startNodeAt(e,i);v.tag=t,v.quasi=this.parseTemplate({isTagged:!0}),t=this.finishNode(v,"TaggedTemplateExpression")}return t};A.parseExprAtom=function(t,e,i){this.type===d.slash&&this.readRegexp();var r,n=this.potentialArrowAt===this.start;switch(this.type){case d._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),r=this.startNode(),this.next(),this.type===d.parenL&&!this.allowDirectSuper&&this.raise(r.start,"super() call outside constructor of a subclass"),this.type!==d.dot&&this.type!==d.bracketL&&this.type!==d.parenL&&this.unexpected(),this.finishNode(r,"Super");case d._this:return r=this.startNode(),this.next(),this.finishNode(r,"ThisExpression");case d.name:var a=this.start,s=this.startLoc,o=this.containsEsc,l=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&l.name==="async"&&!this.canInsertSemicolon()&&this.eat(d._function))return this.overrideContext(j.f_expr),this.parseFunction(this.startNodeAt(a,s),0,!1,!0,e);if(n&&!this.canInsertSemicolon()){if(this.eat(d.arrow))return this.parseArrowExpression(this.startNodeAt(a,s),[l],!1,e);if(this.options.ecmaVersion>=8&&l.name==="async"&&this.type===d.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return l=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(d.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,s),[l],!0,e)}return l;case d.regexp:var c=this.value;return r=this.parseLiteral(c.value),r.regex={pattern:c.pattern,flags:c.flags},r;case d.num:case d.string:return this.parseLiteral(this.value);case d._null:case d._true:case d._false:return r=this.startNode(),r.value=this.type===d._null?null:this.type===d._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,"Literal");case d.parenL:var u=this.start,p=this.parseParenAndDistinguishExpression(n,e);return t&&(t.parenthesizedAssign<0&&!this.isSimpleAssignTarget(p)&&(t.parenthesizedAssign=u),t.parenthesizedBind<0&&(t.parenthesizedBind=u)),p;case d.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(d.bracketR,!0,!0,t),this.finishNode(r,"ArrayExpression");case d.braceL:return this.overrideContext(j.b_expr),this.parseObj(!1,t);case d._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case d._class:return this.parseClass(this.startNode(),!1);case d._new:return this.parseNew();case d.backQuote:return this.parseTemplate();case d._import:return this.options.ecmaVersion>=11?this.parseExprImport(i):this.unexpected();default:return this.parseExprAtomDefault()}};A.parseExprAtomDefault=function(){this.unexpected()};A.parseExprImport=function(t){var e=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===d.parenL&&!t)return this.parseDynamicImport(e);if(this.type===d.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()};A.parseDynamicImport=function(t){if(this.next(),t.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(d.parenR)?t.options=null:(this.expect(d.comma),this.afterTrailingComma(d.parenR)?t.options=null:(t.options=this.parseMaybeAssign(),this.eat(d.parenR)||(this.expect(d.comma),this.afterTrailingComma(d.parenR)||this.unexpected())));else if(!this.eat(d.parenR)){var e=this.start;this.eat(d.comma)&&this.eat(d.parenR)?this.raiseRecoverable(e,"Trailing comma is not allowed in import()"):this.unexpected(e)}return this.finishNode(t,"ImportExpression")};A.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")};A.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.value!=null?e.value.toString():e.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(e,"Literal")};A.parseParenExpression=function(){this.expect(d.parenL);var t=this.parseExpression();return this.expect(d.parenR),t};A.shouldParseArrow=function(t){return!this.canInsertSemicolon()};A.parseParenAndDistinguishExpression=function(t,e){var i=this.start,r=this.startLoc,n,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var s=this.start,o=this.startLoc,l=[],c=!0,u=!1,p=new Et,h=this.yieldPos,f=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==d.parenR;)if(c?c=!1:this.expect(d.comma),a&&this.afterTrailingComma(d.parenR,!0)){u=!0;break}else if(this.type===d.ellipsis){m=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===d.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else l.push(this.parseMaybeAssign(!1,p,this.parseParenItem));var y=this.lastTokEnd,_=this.lastTokEndLoc;if(this.expect(d.parenR),t&&this.shouldParseArrow(l)&&this.eat(d.arrow))return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=h,this.awaitPos=f,this.parseParenArrowList(i,r,l,e);(!l.length||u)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(p,!0),this.yieldPos=h||this.yieldPos,this.awaitPos=f||this.awaitPos,l.length>1?(n=this.startNodeAt(s,o),n.expressions=l,this.finishNodeAt(n,"SequenceExpression",y,_)):n=l[0]}else n=this.parseParenExpression();if(this.options.preserveParens){var v=this.startNodeAt(i,r);return v.expression=n,this.finishNode(v,"ParenthesizedExpression")}else return n};A.parseParenItem=function(t){return t};A.parseParenArrowList=function(t,e,i,r){return this.parseArrowExpression(this.startNodeAt(t,e),i,!1,r)};var gn=[];A.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===d.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,n=this.startLoc;return t.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,n,!0,!1),this.eat(d.parenL)?t.arguments=this.parseExprList(d.parenR,this.options.ecmaVersion>=8,!1):t.arguments=gn,this.finishNode(t,"NewExpression")};A.parseTemplateElement=function(t){var e=t.isTagged,i=this.startNode();return this.type===d.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),i.value={raw:this.value.replace(/\r\n?/g,`
21
21
  `),cooked:null}):i.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
22
- `),cooked:this.value},this.next(),i.tail=this.type===f.backQuote,this.finishNode(i,"TemplateElement")};A.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")};A.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)&&!se.test(this.input.slice(this.lastTokEnd,this.start))};A.parseObj=function(t,e){var i=this.startNode(),r=!0,n={};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,n,e),i.properties.push(a)}return this.finishNode(i,t?"ObjectPattern":"ObjectExpression")};A.parseProperty=function(t,e){var i=this.startNode(),r,n,a,s;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,s=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)?(n=!0,r=this.options.ecmaVersion>=9&&this.eat(f.star),this.parsePropertyName(i)):n=!1,this.parsePropertyValue(i,t,r,n,a,s,e,o),this.finishNode(i,"Property")};A.parseGetterSetter=function(t){var e=t.key.name;this.parsePropertyName(t),t.value=this.parseMethod(!1),t.kind=e;var i=t.kind==="get"?0:1;if(t.value.params.length!==i){var r=t.value.start;t.kind==="get"?this.raiseRecoverable(r,"getter should have no params"):this.raiseRecoverable(r,"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")};A.parsePropertyValue=function(t,e,i,r,n,a,s,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,s),t.kind="init"):this.options.ecmaVersion>=6&&this.type===f.parenL?(e&&this.unexpected(),t.method=!0,t.value=this.parseMethod(i,r),t.kind="init"):!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=n),e?t.value=this.parseMaybeDefault(n,a,this.copyNode(t.key)):this.type===f.eq&&s?(s.shorthandAssign<0&&(s.shorthandAssign=this.start),t.value=this.parseMaybeDefault(n,a,this.copyNode(t.key))):t.value=this.copyNode(t.key),t.kind="init",t.shorthand=!0):this.unexpected()};A.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")};A.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)};A.parseMethod=function(t,e,i){var r=this.startNode(),n=this.yieldPos,a=this.awaitPos,s=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(Kt(e,r.generator)|bt|(i?ji: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=n,this.awaitPos=a,this.awaitIdentPos=s,this.finishNode(r,"FunctionExpression")};A.parseArrowExpression=function(t,e,i,r){var n=this.yieldPos,a=this.awaitPos,s=this.awaitIdentPos;return this.enterScope(Kt(i,!1)|qt),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=n,this.awaitPos=a,this.awaitIdentPos=s,this.finishNode(t,"ArrowFunctionExpression")};A.parseFunctionBody=function(t,e,i,r){var n=e&&this.type!==f.braceL,a=this.strict,s=!1;if(n)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)&&(s=this.strictDirective(this.end),s&&o&&this.raiseRecoverable(t.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var c=this.labels;this.labels=[],s&&(this.strict=!0),this.checkParams(t,!a&&!s&&!e&&!i&&this.isSimpleParamList(t.params)),this.strict&&t.id&&this.checkLValSimple(t.id,qi),t.body=this.parseBlock(!1,void 0,s&&!a),t.expression=!1,this.adaptDirectivePrologue(t.body.body),this.labels=c}this.exitScope()};A.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};A.checkParams=function(t,e){for(var i=Object.create(null),r=0,n=t.params;r<n.length;r+=1){var a=n[r];this.checkLValInnerPattern(a,Ht,e?null:i)}};A.parseExprList=function(t,e,i,r){for(var n=[],a=!0;!this.eat(t);){if(a)a=!1;else if(this.expect(f.comma),e&&this.afterTrailingComma(t))break;var s=void 0;i&&this.type===f.comma?s=null:this.type===f.ellipsis?(s=this.parseSpread(r),r&&this.type===f.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):s=this.parseMaybeAssign(!1,r),n.push(s)}return n};A.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().flags&_t)&&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 n=this.strict?this.reservedWordsStrict:this.reservedWords;n.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"))}};A.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};A.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};A.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};A.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")};A.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 dt=K.prototype;dt.raise=function(t,e){var i=Li(this.input,t);e+=" ("+i.line+":"+i.column+")",this.sourceFile&&(e+=" in "+this.sourceFile);var r=new SyntaxError(e);throw r.pos=t,r.loc=i,r.raisedAt=this.pos,r};dt.raiseRecoverable=dt.raise;dt.curPosition=function(){if(this.options.locations)return new nt(this.curLine,this.pos-this.lineStart)};var Le=K.prototype,nn=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};Le.enterScope=function(t){this.scopeStack.push(new nn(t))};Le.exitScope=function(){this.scopeStack.pop()};Le.treatFunctionsAsVarInScope=function(t){return t.flags&qe||!this.inModule&&t.flags&Ue};Le.declareName=function(t,e,i){var r=!1;if(e===Ce){var n=this.currentScope();r=n.lexical.indexOf(t)>-1||n.functions.indexOf(t)>-1||n.var.indexOf(t)>-1,n.lexical.push(t),this.inModule&&n.flags&Ue&&delete this.undefinedExports[t]}else if(e===Ui){var a=this.currentScope();a.lexical.push(t)}else if(e===$i){var s=this.currentScope();this.treatFunctionsAsVar?r=s.lexical.indexOf(t)>-1:r=s.lexical.indexOf(t)>-1||s.var.indexOf(t)>-1,s.functions.push(t)}else for(var o=this.scopeStack.length-1;o>=0;--o){var c=this.scopeStack[o];if(c.lexical.indexOf(t)>-1&&!(c.flags&Fi&&c.lexical[0]===t)||!this.treatFunctionsAsVarInScope(c)&&c.functions.indexOf(t)>-1){r=!0;break}if(c.var.push(t),this.inModule&&c.flags&Ue&&delete this.undefinedExports[t],c.flags&_t)break}r&&this.raiseRecoverable(i,"Identifier '"+t+"' has already been declared")};Le.checkLocalExport=function(t){this.scopeStack[0].lexical.indexOf(t.name)===-1&&this.scopeStack[0].var.indexOf(t.name)===-1&&(this.undefinedExports[t.name]=t)};Le.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};Le.currentVarScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(e.flags&(_t|st|Ke))return e}};Le.currentThisScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(e.flags&(_t|st|Ke)&&!(e.flags&qt))return e}};var Et=function(e,i,r){this.type="",this.start=i,this.end=0,e.options.locations&&(this.loc=new wt(e,r)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[i,0])},at=K.prototype;at.startNode=function(){return new Et(this,this.start,this.startLoc)};at.startNodeAt=function(t,e){return new Et(this,t,e)};function zi(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}at.finishNode=function(t,e){return zi.call(this,t,e,this.lastTokEnd,this.lastTokEndLoc)};at.finishNodeAt=function(t,e,i,r){return zi.call(this,t,e,i,r)};at.copyNode=function(t){var e=new Et(this,t.start,this.startLoc);for(var i in t)e[i]=t[i];return e};var sn="Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz",Gi="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",Yi=Gi+" Extended_Pictographic",Qi=Yi,Xi=Qi+" EBase EComp EMod EPres ExtPict",Zi=Xi,an=Zi,on={9:Gi,10:Yi,11:Qi,12:Xi,13:Zi,14:an},cn="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",ln={9:"",10:"",11:"",12:"",13:"",14:cn},ni="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",Ji="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",er=Ji+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",tr=er+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",ir=tr+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",rr=ir+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",un=rr+" "+sn,hn={9:Ji,10:er,11:tr,12:ir,13:rr,14:un},nr={};function pn(t){var e=nr[t]={binary:Re(on[t]+" "+ni),binaryOfStrings:Re(ln[t]),nonBinary:{General_Category:Re(ni),Script:Re(hn[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 kt=0,si=[9,10,11,12,13,14];kt<si.length;kt+=1){var fn=si[kt];pn(fn)}var C=K.prototype,mt=function(e,i){this.parent=e,this.base=i||this};mt.prototype.separatedFrom=function(e){for(var i=this;i;i=i.parent)for(var r=e;r;r=r.parent)if(i.base===r.base&&i!==r)return!0;return!1};mt.prototype.sibling=function(){return new mt(this.parent,this.base)};var Se=function(e){this.parser=e,this.validFlags="gim"+(e.options.ecmaVersion>=6?"uy":"")+(e.options.ecmaVersion>=9?"s":"")+(e.options.ecmaVersion>=13?"d":"")+(e.options.ecmaVersion>=15?"v":""),this.unicodeProperties=nr[e.options.ecmaVersion>=14?14:e.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};Se.prototype.reset=function(e,i,r){var n=r.indexOf("v")!==-1,a=r.indexOf("u")!==-1;this.start=e|0,this.source=i+"",this.flags=r,n&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=a&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=a&&this.parser.options.ecmaVersion>=9)};Se.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)};Se.prototype.at=function(e,i){i===void 0&&(i=!1);var r=this.source,n=r.length;if(e>=n)return-1;var a=r.charCodeAt(e);if(!(i||this.switchU)||a<=55295||a>=57344||e+1>=n)return a;var s=r.charCodeAt(e+1);return s>=56320&&s<=57343?(a<<10)+s-56613888:a};Se.prototype.nextIndex=function(e,i){i===void 0&&(i=!1);var r=this.source,n=r.length;if(e>=n)return n;var a=r.charCodeAt(e),s;return!(i||this.switchU)||a<=55295||a>=57344||e+1>=n||(s=r.charCodeAt(e+1))<56320||s>57343?e+1:e+2};Se.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)};Se.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)};Se.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)};Se.prototype.eat=function(e,i){return i===void 0&&(i=!1),this.current(i)===e?(this.advance(i),!0):!1};Se.prototype.eatChars=function(e,i){i===void 0&&(i=!1);for(var r=this.pos,n=0,a=e;n<a.length;n+=1){var s=a[n],o=this.at(r,i);if(o===-1||o!==s)return!1;r=this.nextIndex(r,i)}return this.pos=r,!0};C.validateRegExpFlags=function(t){for(var e=t.validFlags,i=t.flags,r=!1,n=!1,a=0;a<i.length;a++){var s=i.charAt(a);e.indexOf(s)===-1&&this.raise(t.start,"Invalid regular expression flag"),i.indexOf(s,a+1)>-1&&this.raise(t.start,"Duplicate regular expression flag"),s==="u"&&(r=!0),s==="v"&&(n=!0)}this.options.ecmaVersion>=15&&r&&n&&this.raise(t.start,"Invalid regular expression flag")};function dn(t){for(var e in t)return!0;return!1}C.validateRegExpPattern=function(t){this.regexp_pattern(t),!t.switchN&&this.options.ecmaVersion>=9&&dn(t.groupNames)&&(t.switchN=!0,this.regexp_pattern(t))};C.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")}};C.regexp_disjunction=function(t){var e=this.options.ecmaVersion>=16;for(e&&(t.branchID=new mt(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")};C.regexp_alternative=function(t){for(;t.pos<t.source.length&&this.regexp_eatTerm(t););};C.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};C.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};C.regexp_eatQuantifier=function(t,e){return e===void 0&&(e=!1),this.regexp_eatQuantifierPrefix(t,e)?(t.eat(63),!0):!1};C.regexp_eatQuantifierPrefix=function(t,e){return t.eat(42)||t.eat(43)||t.eat(63)||this.regexp_eatBracedQuantifier(t,e)};C.regexp_eatBracedQuantifier=function(t,e){var i=t.pos;if(t.eat(123)){var r=0,n=-1;if(this.regexp_eatDecimalDigits(t)&&(r=t.lastIntValue,t.eat(44)&&this.regexp_eatDecimalDigits(t)&&(n=t.lastIntValue),t.eat(125)))return n!==-1&&n<r&&!e&&t.raise("numbers out of order in {} quantifier"),!0;t.switchU&&!e&&t.raise("Incomplete quantifier"),t.pos=i}return!1};C.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)};C.regexp_eatReverseSolidusAtomEscape=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatAtomEscape(t))return!0;t.pos=e}return!1};C.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 n=0;n<i.length;n++){var a=i.charAt(n);i.indexOf(a,n+1)>-1&&t.raise("Duplicate regular expression modifiers")}if(r){var s=this.regexp_eatModifiers(t);!i&&!s&&t.current()===58&&t.raise("Invalid regular expression modifiers");for(var o=0;o<s.length;o++){var c=s.charAt(o);(s.indexOf(c,o+1)>-1||i.indexOf(c)>-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};C.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};C.regexp_eatModifiers=function(t){for(var e="",i=0;(i=t.current())!==-1&&mn(i);)e+=Ne(i),t.advance();return e};function mn(t){return t===105||t===109||t===115}C.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)};C.regexp_eatInvalidBracedQuantifier=function(t){return this.regexp_eatBracedQuantifier(t,!0)&&t.raise("Nothing to repeat"),!1};C.regexp_eatSyntaxCharacter=function(t){var e=t.current();return sr(e)?(t.lastIntValue=e,t.advance(),!0):!1};function sr(t){return t===36||t>=40&&t<=43||t===46||t===63||t>=91&&t<=94||t>=123&&t<=125}C.regexp_eatPatternCharacters=function(t){for(var e=t.pos,i=0;(i=t.current())!==-1&&!sr(i);)t.advance();return t.pos!==e};C.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};C.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,n=i;r<n.length;r+=1){var a=n[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}};C.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};C.regexp_eatRegExpIdentifierName=function(t){if(t.lastStringValue="",this.regexp_eatRegExpIdentifierStart(t)){for(t.lastStringValue+=Ne(t.lastIntValue);this.regexp_eatRegExpIdentifierPart(t);)t.lastStringValue+=Ne(t.lastIntValue);return!0}return!1};C.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),xn(r)?(t.lastIntValue=r,!0):(t.pos=e,!1)};function xn(t){return be(t,!0)||t===36||t===95}C.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),gn(r)?(t.lastIntValue=r,!0):(t.pos=e,!1)};function gn(t){return Oe(t,!0)||t===36||t===95||t===8204||t===8205}C.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)};C.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};C.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};C.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)};C.regexp_eatCControlLetter=function(t){var e=t.pos;if(t.eat(99)){if(this.regexp_eatControlLetter(t))return!0;t.pos=e}return!1};C.regexp_eatZero=function(t){return t.current()===48&&!Nt(t.lookahead())?(t.lastIntValue=0,t.advance(),!0):!1};C.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};C.regexp_eatControlLetter=function(t){var e=t.current();return ar(e)?(t.lastIntValue=e%32,t.advance(),!0):!1};function ar(t){return t>=65&&t<=90||t>=97&&t<=122}C.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 n=t.lastIntValue;if(r&&n>=55296&&n<=56319){var a=t.pos;if(t.eat(92)&&t.eat(117)&&this.regexp_eatFixedHexDigits(t,4)){var s=t.lastIntValue;if(s>=56320&&s<=57343)return t.lastIntValue=(n-55296)*1024+(s-56320)+65536,!0}t.pos=a,t.lastIntValue=n}return!0}if(r&&t.eat(123)&&this.regexp_eatHexDigits(t)&&t.eat(125)&&yn(t.lastIntValue))return!0;r&&t.raise("Invalid unicode escape"),t.pos=i}return!1};function yn(t){return t>=0&&t<=1114111}C.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};C.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 or=0,Ie=1,he=2;C.regexp_eatCharacterClassEscape=function(t){var e=t.current();if(vn(e))return t.lastIntValue=-1,t.advance(),Ie;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===he&&t.raise("Invalid property name"),r;t.raise("Invalid property name")}return or};function vn(t){return t===100||t===68||t===115||t===83||t===119||t===87}C.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),Ie}}if(t.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(t)){var n=t.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(t,n)}return or};C.regexp_validateUnicodePropertyNameAndValue=function(t,e,i){Je(t.unicodeProperties.nonBinary,e)||t.raise("Invalid property name"),t.unicodeProperties.nonBinary[e].test(i)||t.raise("Invalid property value")};C.regexp_validateUnicodePropertyNameOrValue=function(t,e){if(t.unicodeProperties.binary.test(e))return Ie;if(t.switchV&&t.unicodeProperties.binaryOfStrings.test(e))return he;t.raise("Invalid property name")};C.regexp_eatUnicodePropertyName=function(t){var e=0;for(t.lastStringValue="";cr(e=t.current());)t.lastStringValue+=Ne(e),t.advance();return t.lastStringValue!==""};function cr(t){return ar(t)||t===95}C.regexp_eatUnicodePropertyValue=function(t){var e=0;for(t.lastStringValue="";wn(e=t.current());)t.lastStringValue+=Ne(e),t.advance();return t.lastStringValue!==""};function wn(t){return cr(t)||Nt(t)}C.regexp_eatLoneUnicodePropertyNameOrValue=function(t){return this.regexp_eatUnicodePropertyValue(t)};C.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===he&&t.raise("Negated character class may contain strings"),!0}return!1};C.regexp_classContents=function(t){return t.current()===93?Ie:t.switchV?this.regexp_classSetExpression(t):(this.regexp_nonEmptyClassRanges(t),Ie)};C.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")}}};C.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||hr(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};C.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)};C.regexp_classSetExpression=function(t){var e=Ie,i;if(!this.regexp_eatClassSetRange(t))if(i=this.regexp_eatClassSetOperand(t)){i===he&&(e=he);for(var r=t.pos;t.eatChars([38,38]);){if(t.current()!==38&&(i=this.regexp_eatClassSetOperand(t))){i!==he&&(e=Ie);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===he&&(e=he)}};C.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};C.regexp_eatClassSetOperand=function(t){return this.regexp_eatClassSetCharacter(t)?Ie:this.regexp_eatClassStringDisjunction(t)||this.regexp_eatNestedClass(t)};C.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===he&&t.raise("Negated character class may contain strings"),r;t.pos=e}if(t.eat(92)){var n=this.regexp_eatCharacterClassEscape(t);if(n)return n;t.pos=e}return null};C.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};C.regexp_classStringDisjunctionContents=function(t){for(var e=this.regexp_classString(t);t.eat(124);)this.regexp_classString(t)===he&&(e=he);return e};C.regexp_classString=function(t){for(var e=0;this.regexp_eatClassSetCharacter(t);)e++;return e===1?Ie:he};C.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()&&bn(i)||_n(i)?!1:(t.advance(),t.lastIntValue=i,!0)};function bn(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 _n(t){return t===40||t===41||t===45||t===47||t>=91&&t<=93||t>=123&&t<=125}C.regexp_eatClassSetReservedPunctuator=function(t){var e=t.current();return Sn(e)?(t.lastIntValue=e,t.advance(),!0):!1};function Sn(t){return t===33||t===35||t===37||t===38||t===44||t===45||t>=58&&t<=62||t===64||t===96||t===126}C.regexp_eatClassControlLetter=function(t){var e=t.current();return Nt(e)||e===95?(t.lastIntValue=e%32,t.advance(),!0):!1};C.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};C.regexp_eatDecimalDigits=function(t){var e=t.pos,i=0;for(t.lastIntValue=0;Nt(i=t.current());)t.lastIntValue=10*t.lastIntValue+(i-48),t.advance();return t.pos!==e};function Nt(t){return t>=48&&t<=57}C.regexp_eatHexDigits=function(t){var e=t.pos,i=0;for(t.lastIntValue=0;lr(i=t.current());)t.lastIntValue=16*t.lastIntValue+ur(i),t.advance();return t.pos!==e};function lr(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function ur(t){return t>=65&&t<=70?10+(t-65):t>=97&&t<=102?10+(t-97):t-48}C.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};C.regexp_eatOctalDigit=function(t){var e=t.current();return hr(e)?(t.lastIntValue=e-48,t.advance(),!0):(t.lastIntValue=0,!1)};function hr(t){return t>=48&&t<=55}C.regexp_eatFixedHexDigits=function(t,e){var i=t.pos;t.lastIntValue=0;for(var r=0;r<e;++r){var n=t.current();if(!lr(n))return t.pos=i,!1;t.lastIntValue=16*t.lastIntValue+ur(n),t.advance()}return!0};var Gt=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new wt(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},P=K.prototype;P.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 Gt(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};P.getToken=function(){return this.next(),new Gt(this)};typeof Symbol<"u"&&(P[Symbol.iterator]=function(){var t=this;return{next:function(){var e=t.getToken();return{done:e.type===f.eof,value:e}}}});P.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())};P.readToken=function(t){return be(t,this.options.ecmaVersion>=6)||t===92?this.readWord():this.getTokenFromCode(t)};P.fullCharCodeAt=function(t){var e=this.input.charCodeAt(t);if(e<=55295||e>=56320)return e;var i=this.input.charCodeAt(t+1);return i<=56319||i>=57344?e:(e<<10)+i-56613888};P.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)};P.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,n=e;(r=Mi(this.input,n,this.pos))>-1;)++this.curLine,n=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(e+2,i),e,this.pos,t,this.curPosition())};P.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&&!Ze(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())};P.skipSpace=function(){e: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 e}break;default:if(t>8&&t<14||t>=5760&&Oi.test(String.fromCharCode(t)))++this.pos;else break e}}};P.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)};P.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))};P.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)};P.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)};P.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)};P.readToken_caret=function(){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(f.assign,2):this.finishOp(f.bitwiseXOR,1)};P.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||se.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)};P.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))};P.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)};P.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)};P.readToken_numberSign=function(){var t=this.options.ecmaVersion,e=35;if(t>=13&&(++this.pos,e=this.fullCharCodeAtPos(),be(e,!0)||e===92))return this.finishToken(f.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+Ne(e)+"'")};P.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 '"+Ne(t)+"'")};P.finishOp=function(t,e){var i=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(t,i)};P.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(se.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 n=this.input.slice(i,this.pos);++this.pos;var a=this.pos,s=this.readWord1();this.containsEsc&&this.unexpected(a);var o=this.regexpState||(this.regexpState=new Se(this));o.reset(i,n,s),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var c=null;try{c=new RegExp(n,s)}catch{}return this.finishToken(f.regexp,{pattern:n,flags:s,value:c})};P.readInt=function(t,e,i){for(var r=this.options.ecmaVersion>=12&&e===void 0,n=i&&this.input.charCodeAt(this.pos)===48,a=this.pos,s=0,o=0,c=0,l=e??1/0;c<l;++c,++this.pos){var u=this.input.charCodeAt(this.pos),p=void 0;if(r&&u===95){n&&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"),c===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=u;continue}if(u>=97?p=u-97+10:u>=65?p=u-65+10:u>=48&&u<=57?p=u-48:p=1/0,p>=t)break;o=u,s=s*t+p}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:s};function En(t,e){return e?parseInt(t,8):parseFloat(t.replace(/_/g,""))}function pr(t){return typeof BigInt!="function"?null:BigInt(t.replace(/_/g,""))}P.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=pr(this.input.slice(e,this.pos)),++this.pos):be(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(f.num,i)};P.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 n=pr(this.input.slice(e,this.pos));return++this.pos,be(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(f.num,n)}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")),be(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var a=En(this.input.slice(e,this.pos),i);return this.finishToken(f.num,a)};P.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};P.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)):(Ze(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return e+=this.input.slice(i,this.pos++),this.finishToken(f.string,e)};var fr={};P.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t===fr)this.readInvalidTemplateToken();else throw t}this.inTemplateElement=!1};P.invalidStringToken=function(t,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw fr;this.raise(t,e)};P.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(Ze(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+=`
23
- `;break;default:t+=String.fromCharCode(i);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),e=this.pos}else++this.pos}};P.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]===`
22
+ `),cooked:this.value},this.next(),i.tail=this.type===d.backQuote,this.finishNode(i,"TemplateElement")};A.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===d.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(d.dollarBraceL),i.expressions.push(this.parseExpression()),this.expect(d.braceR),i.quasis.push(r=this.parseTemplateElement({isTagged:e}));return this.next(),this.finishNode(i,"TemplateLiteral")};A.isAsyncProp=function(t){return!t.computed&&t.key.type==="Identifier"&&t.key.name==="async"&&(this.type===d.name||this.type===d.num||this.type===d.string||this.type===d.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===d.star)&&!se.test(this.input.slice(this.lastTokEnd,this.start))};A.parseObj=function(t,e){var i=this.startNode(),r=!0,n={};for(i.properties=[],this.next();!this.eat(d.braceR);){if(r)r=!1;else if(this.expect(d.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(d.braceR))break;var a=this.parseProperty(t,e);t||this.checkPropClash(a,n,e),i.properties.push(a)}return this.finishNode(i,t?"ObjectPattern":"ObjectExpression")};A.parseProperty=function(t,e){var i=this.startNode(),r,n,a,s;if(this.options.ecmaVersion>=9&&this.eat(d.ellipsis))return t?(i.argument=this.parseIdent(!1),this.type===d.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===d.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,s=this.startLoc),t||(r=this.eat(d.star)));var o=this.containsEsc;return this.parsePropertyName(i),!t&&!o&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(i)?(n=!0,r=this.options.ecmaVersion>=9&&this.eat(d.star),this.parsePropertyName(i)):n=!1,this.parsePropertyValue(i,t,r,n,a,s,e,o),this.finishNode(i,"Property")};A.parseGetterSetter=function(t){var e=t.key.name;this.parsePropertyName(t),t.value=this.parseMethod(!1),t.kind=e;var i=t.kind==="get"?0:1;if(t.value.params.length!==i){var r=t.value.start;t.kind==="get"?this.raiseRecoverable(r,"getter should have no params"):this.raiseRecoverable(r,"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")};A.parsePropertyValue=function(t,e,i,r,n,a,s,o){(i||r)&&this.type===d.colon&&this.unexpected(),this.eat(d.colon)?(t.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,s),t.kind="init"):this.options.ecmaVersion>=6&&this.type===d.parenL?(e&&this.unexpected(),t.method=!0,t.value=this.parseMethod(i,r),t.kind="init"):!e&&!o&&this.options.ecmaVersion>=5&&!t.computed&&t.key.type==="Identifier"&&(t.key.name==="get"||t.key.name==="set")&&this.type!==d.comma&&this.type!==d.braceR&&this.type!==d.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=n),e?t.value=this.parseMaybeDefault(n,a,this.copyNode(t.key)):this.type===d.eq&&s?(s.shorthandAssign<0&&(s.shorthandAssign=this.start),t.value=this.parseMaybeDefault(n,a,this.copyNode(t.key))):t.value=this.copyNode(t.key),t.kind="init",t.shorthand=!0):this.unexpected()};A.parsePropertyName=function(t){if(this.options.ecmaVersion>=6){if(this.eat(d.bracketL))return t.computed=!0,t.key=this.parseMaybeAssign(),this.expect(d.bracketR),t.key;t.computed=!1}return t.key=this.type===d.num||this.type===d.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};A.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)};A.parseMethod=function(t,e,i){var r=this.startNode(),n=this.yieldPos,a=this.awaitPos,s=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(Gt(e,r.generator)|wt|(i?zi:0)),this.expect(d.parenL),r.params=this.parseBindingList(d.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=n,this.awaitPos=a,this.awaitIdentPos=s,this.finishNode(r,"FunctionExpression")};A.parseArrowExpression=function(t,e,i,r){var n=this.yieldPos,a=this.awaitPos,s=this.awaitIdentPos;return this.enterScope(Gt(i,!1)|zt),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=n,this.awaitPos=a,this.awaitIdentPos=s,this.finishNode(t,"ArrowFunctionExpression")};A.parseFunctionBody=function(t,e,i,r){var n=e&&this.type!==d.braceL,a=this.strict,s=!1;if(n)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)&&(s=this.strictDirective(this.end),s&&o&&this.raiseRecoverable(t.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var l=this.labels;this.labels=[],s&&(this.strict=!0),this.checkParams(t,!a&&!s&&!e&&!i&&this.isSimpleParamList(t.params)),this.strict&&t.id&&this.checkLValSimple(t.id,Xi),t.body=this.parseBlock(!1,void 0,s&&!a),t.expression=!1,this.adaptDirectivePrologue(t.body.body),this.labels=l}this.exitScope()};A.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};A.checkParams=function(t,e){for(var i=Object.create(null),r=0,n=t.params;r<n.length;r+=1){var a=n[r];this.checkLValInnerPattern(a,Yt,e?null:i)}};A.parseExprList=function(t,e,i,r){for(var n=[],a=!0;!this.eat(t);){if(a)a=!1;else if(this.expect(d.comma),e&&this.afterTrailingComma(t))break;var s=void 0;i&&this.type===d.comma?s=null:this.type===d.ellipsis?(s=this.parseSpread(r),r&&this.type===d.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):s=this.parseMaybeAssign(!1,r),n.push(s)}return n};A.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().flags&St)&&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 n=this.strict?this.reservedWordsStrict:this.reservedWords;n.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"))}};A.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};A.parseIdentNode=function(){var t=this.startNode();return this.type===d.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=d.name):this.unexpected(),t};A.parsePrivateIdent=function(){var t=this.startNode();return this.type===d.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};A.parseYield=function(t){this.yieldPos||(this.yieldPos=this.start);var e=this.startNode();return this.next(),this.type===d.semi||this.canInsertSemicolon()||this.type!==d.star&&!this.type.startsExpr?(e.delegate=!1,e.argument=null):(e.delegate=this.eat(d.star),e.argument=this.parseMaybeAssign(t)),this.finishNode(e,"YieldExpression")};A.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 mt=H.prototype;mt.raise=function(t,e){var i=qi(this.input,t);e+=" ("+i.line+":"+i.column+")",this.sourceFile&&(e+=" in "+this.sourceFile);var r=new SyntaxError(e);throw r.pos=t,r.loc=i,r.raisedAt=this.pos,r};mt.raiseRecoverable=mt.raise;mt.curPosition=function(){if(this.options.locations)return new at(this.curLine,this.pos-this.lineStart)};var je=H.prototype,xn=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};je.enterScope=function(t){this.scopeStack.push(new xn(t))};je.exitScope=function(){this.scopeStack.pop()};je.treatFunctionsAsVarInScope=function(t){return t.flags&He||!this.inModule&&t.flags&qe};je.declareName=function(t,e,i){var r=!1;if(e===ke){var n=this.currentScope();r=n.lexical.indexOf(t)>-1||n.functions.indexOf(t)>-1||n.var.indexOf(t)>-1,n.lexical.push(t),this.inModule&&n.flags&qe&&delete this.undefinedExports[t]}else if(e===Qi){var a=this.currentScope();a.lexical.push(t)}else if(e===Yi){var s=this.currentScope();this.treatFunctionsAsVar?r=s.lexical.indexOf(t)>-1:r=s.lexical.indexOf(t)>-1||s.var.indexOf(t)>-1,s.functions.push(t)}else for(var o=this.scopeStack.length-1;o>=0;--o){var l=this.scopeStack[o];if(l.lexical.indexOf(t)>-1&&!(l.flags&Ki&&l.lexical[0]===t)||!this.treatFunctionsAsVarInScope(l)&&l.functions.indexOf(t)>-1){r=!0;break}if(l.var.push(t),this.inModule&&l.flags&qe&&delete this.undefinedExports[t],l.flags&St)break}r&&this.raiseRecoverable(i,"Identifier '"+t+"' has already been declared")};je.checkLocalExport=function(t){this.scopeStack[0].lexical.indexOf(t.name)===-1&&this.scopeStack[0].var.indexOf(t.name)===-1&&(this.undefinedExports[t.name]=t)};je.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};je.currentVarScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(e.flags&(St|ot|Ke))return e}};je.currentThisScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(e.flags&(St|ot|Ke)&&!(e.flags&zt))return e}};var Nt=function(e,i,r){this.type="",this.start=i,this.end=0,e.options.locations&&(this.loc=new bt(e,r)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[i,0])},lt=H.prototype;lt.startNode=function(){return new Nt(this,this.start,this.startLoc)};lt.startNodeAt=function(t,e){return new Nt(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}lt.finishNode=function(t,e){return er.call(this,t,e,this.lastTokEnd,this.lastTokEndLoc)};lt.finishNodeAt=function(t,e,i,r){return er.call(this,t,e,i,r)};lt.copyNode=function(t){var e=new Nt(this,t.start,this.startLoc);for(var i in t)e[i]=t[i];return e};var yn="Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz",tr="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",ir=tr+" Extended_Pictographic",rr=ir,nr=rr+" EBase EComp EMod EPres ExtPict",sr=nr,_n=sr,vn={9:tr,10:ir,11:rr,12:nr,13:sr,14:_n},bn="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",wn={9:"",10:"",11:"",12:"",13:"",14:bn},li="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",ar="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",or=ar+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",lr=or+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",cr=lr+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",ur=cr+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Sn=ur+" "+yn,En={9:ar,10:or,11:lr,12:cr,13:ur,14:Sn},hr={};function Nn(t){var e=hr[t]={binary:Le(vn[t]+" "+li),binaryOfStrings:Le(wn[t]),nonBinary:{General_Category:Le(li),Script:Le(En[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 At=0,ci=[9,10,11,12,13,14];At<ci.length;At+=1){var Cn=ci[At];Nn(Cn)}var I=H.prototype,gt=function(e,i){this.parent=e,this.base=i||this};gt.prototype.separatedFrom=function(e){for(var i=this;i;i=i.parent)for(var r=e;r;r=r.parent)if(i.base===r.base&&i!==r)return!0;return!1};gt.prototype.sibling=function(){return new gt(this.parent,this.base)};var Se=function(e){this.parser=e,this.validFlags="gim"+(e.options.ecmaVersion>=6?"uy":"")+(e.options.ecmaVersion>=9?"s":"")+(e.options.ecmaVersion>=13?"d":"")+(e.options.ecmaVersion>=15?"v":""),this.unicodeProperties=hr[e.options.ecmaVersion>=14?14:e.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};Se.prototype.reset=function(e,i,r){var n=r.indexOf("v")!==-1,a=r.indexOf("u")!==-1;this.start=e|0,this.source=i+"",this.flags=r,n&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=a&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=a&&this.parser.options.ecmaVersion>=9)};Se.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)};Se.prototype.at=function(e,i){i===void 0&&(i=!1);var r=this.source,n=r.length;if(e>=n)return-1;var a=r.charCodeAt(e);if(!(i||this.switchU)||a<=55295||a>=57344||e+1>=n)return a;var s=r.charCodeAt(e+1);return s>=56320&&s<=57343?(a<<10)+s-56613888:a};Se.prototype.nextIndex=function(e,i){i===void 0&&(i=!1);var r=this.source,n=r.length;if(e>=n)return n;var a=r.charCodeAt(e),s;return!(i||this.switchU)||a<=55295||a>=57344||e+1>=n||(s=r.charCodeAt(e+1))<56320||s>57343?e+1:e+2};Se.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)};Se.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)};Se.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)};Se.prototype.eat=function(e,i){return i===void 0&&(i=!1),this.current(i)===e?(this.advance(i),!0):!1};Se.prototype.eatChars=function(e,i){i===void 0&&(i=!1);for(var r=this.pos,n=0,a=e;n<a.length;n+=1){var s=a[n],o=this.at(r,i);if(o===-1||o!==s)return!1;r=this.nextIndex(r,i)}return this.pos=r,!0};I.validateRegExpFlags=function(t){for(var e=t.validFlags,i=t.flags,r=!1,n=!1,a=0;a<i.length;a++){var s=i.charAt(a);e.indexOf(s)===-1&&this.raise(t.start,"Invalid regular expression flag"),i.indexOf(s,a+1)>-1&&this.raise(t.start,"Duplicate regular expression flag"),s==="u"&&(r=!0),s==="v"&&(n=!0)}this.options.ecmaVersion>=15&&r&&n&&this.raise(t.start,"Invalid regular expression flag")};function In(t){for(var e in t)return!0;return!1}I.validateRegExpPattern=function(t){this.regexp_pattern(t),!t.switchN&&this.options.ecmaVersion>=9&&In(t.groupNames)&&(t.switchN=!0,this.regexp_pattern(t))};I.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")}};I.regexp_disjunction=function(t){var e=this.options.ecmaVersion>=16;for(e&&(t.branchID=new gt(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")};I.regexp_alternative=function(t){for(;t.pos<t.source.length&&this.regexp_eatTerm(t););};I.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};I.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};I.regexp_eatQuantifier=function(t,e){return e===void 0&&(e=!1),this.regexp_eatQuantifierPrefix(t,e)?(t.eat(63),!0):!1};I.regexp_eatQuantifierPrefix=function(t,e){return t.eat(42)||t.eat(43)||t.eat(63)||this.regexp_eatBracedQuantifier(t,e)};I.regexp_eatBracedQuantifier=function(t,e){var i=t.pos;if(t.eat(123)){var r=0,n=-1;if(this.regexp_eatDecimalDigits(t)&&(r=t.lastIntValue,t.eat(44)&&this.regexp_eatDecimalDigits(t)&&(n=t.lastIntValue),t.eat(125)))return n!==-1&&n<r&&!e&&t.raise("numbers out of order in {} quantifier"),!0;t.switchU&&!e&&t.raise("Incomplete quantifier"),t.pos=i}return!1};I.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)};I.regexp_eatReverseSolidusAtomEscape=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatAtomEscape(t))return!0;t.pos=e}return!1};I.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 n=0;n<i.length;n++){var a=i.charAt(n);i.indexOf(a,n+1)>-1&&t.raise("Duplicate regular expression modifiers")}if(r){var s=this.regexp_eatModifiers(t);!i&&!s&&t.current()===58&&t.raise("Invalid regular expression modifiers");for(var o=0;o<s.length;o++){var l=s.charAt(o);(s.indexOf(l,o+1)>-1||i.indexOf(l)>-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};I.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};I.regexp_eatModifiers=function(t){for(var e="",i=0;(i=t.current())!==-1&&kn(i);)e+=Ce(i),t.advance();return e};function kn(t){return t===105||t===109||t===115}I.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)};I.regexp_eatInvalidBracedQuantifier=function(t){return this.regexp_eatBracedQuantifier(t,!0)&&t.raise("Nothing to repeat"),!1};I.regexp_eatSyntaxCharacter=function(t){var e=t.current();return pr(e)?(t.lastIntValue=e,t.advance(),!0):!1};function pr(t){return t===36||t>=40&&t<=43||t===46||t===63||t>=91&&t<=94||t>=123&&t<=125}I.regexp_eatPatternCharacters=function(t){for(var e=t.pos,i=0;(i=t.current())!==-1&&!pr(i);)t.advance();return t.pos!==e};I.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};I.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,n=i;r<n.length;r+=1){var a=n[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}};I.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};I.regexp_eatRegExpIdentifierName=function(t){if(t.lastStringValue="",this.regexp_eatRegExpIdentifierStart(t)){for(t.lastStringValue+=Ce(t.lastIntValue);this.regexp_eatRegExpIdentifierPart(t);)t.lastStringValue+=Ce(t.lastIntValue);return!0}return!1};I.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),An(r)?(t.lastIntValue=r,!0):(t.pos=e,!1)};function An(t){return be(t,!0)||t===36||t===95}I.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),Tn(r)?(t.lastIntValue=r,!0):(t.pos=e,!1)};function Tn(t){return Be(t,!0)||t===36||t===95||t===8204||t===8205}I.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)};I.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};I.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};I.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)};I.regexp_eatCControlLetter=function(t){var e=t.pos;if(t.eat(99)){if(this.regexp_eatControlLetter(t))return!0;t.pos=e}return!1};I.regexp_eatZero=function(t){return t.current()===48&&!Ct(t.lookahead())?(t.lastIntValue=0,t.advance(),!0):!1};I.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};I.regexp_eatControlLetter=function(t){var e=t.current();return fr(e)?(t.lastIntValue=e%32,t.advance(),!0):!1};function fr(t){return t>=65&&t<=90||t>=97&&t<=122}I.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 n=t.lastIntValue;if(r&&n>=55296&&n<=56319){var a=t.pos;if(t.eat(92)&&t.eat(117)&&this.regexp_eatFixedHexDigits(t,4)){var s=t.lastIntValue;if(s>=56320&&s<=57343)return t.lastIntValue=(n-55296)*1024+(s-56320)+65536,!0}t.pos=a,t.lastIntValue=n}return!0}if(r&&t.eat(123)&&this.regexp_eatHexDigits(t)&&t.eat(125)&&Pn(t.lastIntValue))return!0;r&&t.raise("Invalid unicode escape"),t.pos=i}return!1};function Pn(t){return t>=0&&t<=1114111}I.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};I.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 dr=0,Ie=1,pe=2;I.regexp_eatCharacterClassEscape=function(t){var e=t.current();if(Dn(e))return t.lastIntValue=-1,t.advance(),Ie;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===pe&&t.raise("Invalid property name"),r;t.raise("Invalid property name")}return dr};function Dn(t){return t===100||t===68||t===115||t===83||t===119||t===87}I.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),Ie}}if(t.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(t)){var n=t.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(t,n)}return dr};I.regexp_validateUnicodePropertyNameAndValue=function(t,e,i){et(t.unicodeProperties.nonBinary,e)||t.raise("Invalid property name"),t.unicodeProperties.nonBinary[e].test(i)||t.raise("Invalid property value")};I.regexp_validateUnicodePropertyNameOrValue=function(t,e){if(t.unicodeProperties.binary.test(e))return Ie;if(t.switchV&&t.unicodeProperties.binaryOfStrings.test(e))return pe;t.raise("Invalid property name")};I.regexp_eatUnicodePropertyName=function(t){var e=0;for(t.lastStringValue="";mr(e=t.current());)t.lastStringValue+=Ce(e),t.advance();return t.lastStringValue!==""};function mr(t){return fr(t)||t===95}I.regexp_eatUnicodePropertyValue=function(t){var e=0;for(t.lastStringValue="";Rn(e=t.current());)t.lastStringValue+=Ce(e),t.advance();return t.lastStringValue!==""};function Rn(t){return mr(t)||Ct(t)}I.regexp_eatLoneUnicodePropertyNameOrValue=function(t){return this.regexp_eatUnicodePropertyValue(t)};I.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===pe&&t.raise("Negated character class may contain strings"),!0}return!1};I.regexp_classContents=function(t){return t.current()===93?Ie:t.switchV?this.regexp_classSetExpression(t):(this.regexp_nonEmptyClassRanges(t),Ie)};I.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")}}};I.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||yr(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};I.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)};I.regexp_classSetExpression=function(t){var e=Ie,i;if(!this.regexp_eatClassSetRange(t))if(i=this.regexp_eatClassSetOperand(t)){i===pe&&(e=pe);for(var r=t.pos;t.eatChars([38,38]);){if(t.current()!==38&&(i=this.regexp_eatClassSetOperand(t))){i!==pe&&(e=Ie);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===pe&&(e=pe)}};I.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};I.regexp_eatClassSetOperand=function(t){return this.regexp_eatClassSetCharacter(t)?Ie:this.regexp_eatClassStringDisjunction(t)||this.regexp_eatNestedClass(t)};I.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===pe&&t.raise("Negated character class may contain strings"),r;t.pos=e}if(t.eat(92)){var n=this.regexp_eatCharacterClassEscape(t);if(n)return n;t.pos=e}return null};I.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};I.regexp_classStringDisjunctionContents=function(t){for(var e=this.regexp_classString(t);t.eat(124);)this.regexp_classString(t)===pe&&(e=pe);return e};I.regexp_classString=function(t){for(var e=0;this.regexp_eatClassSetCharacter(t);)e++;return e===1?Ie:pe};I.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()&&Mn(i)||On(i)?!1:(t.advance(),t.lastIntValue=i,!0)};function Mn(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 On(t){return t===40||t===41||t===45||t===47||t>=91&&t<=93||t>=123&&t<=125}I.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}I.regexp_eatClassControlLetter=function(t){var e=t.current();return Ct(e)||e===95?(t.lastIntValue=e%32,t.advance(),!0):!1};I.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};I.regexp_eatDecimalDigits=function(t){var e=t.pos,i=0;for(t.lastIntValue=0;Ct(i=t.current());)t.lastIntValue=10*t.lastIntValue+(i-48),t.advance();return t.pos!==e};function Ct(t){return t>=48&&t<=57}I.regexp_eatHexDigits=function(t){var e=t.pos,i=0;for(t.lastIntValue=0;gr(i=t.current());)t.lastIntValue=16*t.lastIntValue+xr(i),t.advance();return t.pos!==e};function gr(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function xr(t){return t>=65&&t<=70?10+(t-65):t>=97&&t<=102?10+(t-97):t-48}I.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};I.regexp_eatOctalDigit=function(t){var e=t.current();return yr(e)?(t.lastIntValue=e-48,t.advance(),!0):(t.lastIntValue=0,!1)};function yr(t){return t>=48&&t<=55}I.regexp_eatFixedHexDigits=function(t,e){var i=t.pos;t.lastIntValue=0;for(var r=0;r<e;++r){var n=t.current();if(!gr(n))return t.pos=i,!1;t.lastIntValue=16*t.lastIntValue+xr(n),t.advance()}return!0};var Xt=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new bt(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},D=H.prototype;D.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 Xt(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};D.getToken=function(){return this.next(),new Xt(this)};typeof Symbol<"u"&&(D[Symbol.iterator]=function(){var t=this;return{next:function(){var e=t.getToken();return{done:e.type===d.eof,value:e}}}});D.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(d.eof);if(t.override)return t.override(this);this.readToken(this.fullCharCodeAtPos())};D.readToken=function(t){return be(t,this.options.ecmaVersion>=6)||t===92?this.readWord():this.getTokenFromCode(t)};D.fullCharCodeAt=function(t){var e=this.input.charCodeAt(t);if(e<=55295||e>=56320)return e;var i=this.input.charCodeAt(t+1);return i<=56319||i>=57344?e:(e<<10)+i-56613888};D.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)};D.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,n=e;(r=Wi(this.input,n,this.pos))>-1;)++this.curLine,n=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(e+2,i),e,this.pos,t,this.curPosition())};D.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&&!Je(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())};D.skipSpace=function(){e: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 e}break;default:if(t>8&&t<14||t>=5760&&$i.test(String.fromCharCode(t)))++this.pos;else break e}}};D.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)};D.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(d.ellipsis)):(++this.pos,this.finishToken(d.dot))};D.readToken_slash=function(){var t=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):t===61?this.finishOp(d.assign,2):this.finishOp(d.slash,1)};D.readToken_mult_modulo_exp=function(t){var e=this.input.charCodeAt(this.pos+1),i=1,r=t===42?d.star:d.modulo;return this.options.ecmaVersion>=7&&t===42&&e===42&&(++i,r=d.starstar,e=this.input.charCodeAt(this.pos+2)),e===61?this.finishOp(d.assign,i+1):this.finishOp(r,i)};D.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(d.assign,3)}return this.finishOp(t===124?d.logicalOR:d.logicalAND,2)}return e===61?this.finishOp(d.assign,2):this.finishOp(t===124?d.bitwiseOR:d.bitwiseAND,1)};D.readToken_caret=function(){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(d.assign,2):this.finishOp(d.bitwiseXOR,1)};D.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||se.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(d.incDec,2):e===61?this.finishOp(d.assign,2):this.finishOp(d.plusMin,1)};D.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(d.assign,i+1):this.finishOp(d.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(d.relational,i))};D.readToken_eq_excl=function(t){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(d.equality,this.input.charCodeAt(this.pos+2)===61?3:2):t===61&&e===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(d.arrow)):this.finishOp(t===61?d.eq:d.prefix,1)};D.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(d.questionDot,2)}if(e===63){if(t>=12){var r=this.input.charCodeAt(this.pos+2);if(r===61)return this.finishOp(d.assign,3)}return this.finishOp(d.coalesce,2)}}return this.finishOp(d.question,1)};D.readToken_numberSign=function(){var t=this.options.ecmaVersion,e=35;if(t>=13&&(++this.pos,e=this.fullCharCodeAtPos(),be(e,!0)||e===92))return this.finishToken(d.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+Ce(e)+"'")};D.getTokenFromCode=function(t){switch(t){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(d.parenL);case 41:return++this.pos,this.finishToken(d.parenR);case 59:return++this.pos,this.finishToken(d.semi);case 44:return++this.pos,this.finishToken(d.comma);case 91:return++this.pos,this.finishToken(d.bracketL);case 93:return++this.pos,this.finishToken(d.bracketR);case 123:return++this.pos,this.finishToken(d.braceL);case 125:return++this.pos,this.finishToken(d.braceR);case 58:return++this.pos,this.finishToken(d.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(d.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(d.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+Ce(t)+"'")};D.finishOp=function(t,e){var i=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(t,i)};D.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(se.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 n=this.input.slice(i,this.pos);++this.pos;var a=this.pos,s=this.readWord1();this.containsEsc&&this.unexpected(a);var o=this.regexpState||(this.regexpState=new Se(this));o.reset(i,n,s),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var l=null;try{l=new RegExp(n,s)}catch{}return this.finishToken(d.regexp,{pattern:n,flags:s,value:l})};D.readInt=function(t,e,i){for(var r=this.options.ecmaVersion>=12&&e===void 0,n=i&&this.input.charCodeAt(this.pos)===48,a=this.pos,s=0,o=0,l=0,c=e??1/0;l<c;++l,++this.pos){var u=this.input.charCodeAt(this.pos),p=void 0;if(r&&u===95){n&&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"),l===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=u;continue}if(u>=97?p=u-97+10:u>=65?p=u-65+10:u>=48&&u<=57?p=u-48:p=1/0,p>=t)break;o=u,s=s*t+p}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:s};function Vn(t,e){return e?parseInt(t,8):parseFloat(t.replace(/_/g,""))}function _r(t){return typeof BigInt!="function"?null:BigInt(t.replace(/_/g,""))}D.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):be(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(d.num,i)};D.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 n=_r(this.input.slice(e,this.pos));return++this.pos,be(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(d.num,n)}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")),be(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var a=Vn(this.input.slice(e,this.pos),i);return this.finishToken(d.num,a)};D.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};D.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)):(Je(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return e+=this.input.slice(i,this.pos++),this.finishToken(d.string,e)};var vr={};D.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t===vr)this.readInvalidTemplateToken();else throw t}this.inTemplateElement=!1};D.invalidStringToken=function(t,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw vr;this.raise(t,e)};D.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===d.template||this.type===d.invalidTemplate)?i===36?(this.pos+=2,this.finishToken(d.dollarBraceL)):(++this.pos,this.finishToken(d.backQuote)):(t+=this.input.slice(e,this.pos),this.finishToken(d.template,t));if(i===92)t+=this.input.slice(e,this.pos),t+=this.readEscapedChar(!0),e=this.pos;else if(Je(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+=`
23
+ `;break;default:t+=String.fromCharCode(i);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),e=this.pos}else++this.pos}};D.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(d.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
24
24
  `&&++this.pos;case`
25
- `:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};P.readEscapedChar=function(t){var e=this.input.charCodeAt(++this.pos);switch(++this.pos,e){case 110:return`
26
- `;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return Ne(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],n=parseInt(r,8);return n>255&&(r=r.slice(0,-1),n=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(n)}return Ze(e)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(e)}};P.readHexChar=function(t){var e=this.pos,i=this.readInt(16,t);return i===null&&this.invalidStringToken(e,"Bad character escape sequence"),i};P.readWord1=function(){this.containsEsc=!1;for(var t="",e=!0,i=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var n=this.fullCharCodeAtPos();if(Oe(n,r))this.pos+=n<=65535?1:2;else if(n===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 s=this.readCodePoint();(e?be:Oe)(s,r)||this.invalidStringToken(a,"Invalid Unicode escape"),t+=Ne(s),i=this.pos}else break;e=!1}return t+this.input.slice(i,this.pos)};P.readWord=function(){var t=this.readWord1(),e=f.name;return this.keywords.test(t)&&(e=$t[t]),this.finishToken(e,t)};var Nn="8.16.0";K.acorn={Parser:K,version:Nn,defaultOptions:Mt,Position:nt,SourceLocation:wt,getLineInfo:Li,Node:Et,TokenType:M,tokTypes:f,keywordTypes:$t,TokContext:xe,tokContexts:F,isIdentifierChar:Oe,isIdentifierStart:be,Token:Gt,isNewLine:Ze,lineBreak:se,lineBreakG:Hr,nonASCIIwhitespace:Oi};function dr(t,e){return K.parse(t,e)}const{stringify:In}=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 lt={"||":2,"??":3,"&&":4,"|":5,"^":6,"&":7,"==":8,"!=":8,"===":8,"!==":8,"<":9,">":9,"<=":9,">=":9,in:9,instanceof:9,"<<":10,">>":10,">>>":10,"+":11,"-":11,"*":12,"%":12,"/":12,"**":13},ge=17,Cn={ArrayExpression:20,TaggedTemplateExpression:20,ThisExpression:20,Identifier:20,PrivateIdentifier:20,Literal:18,TemplateLiteral:20,Super:20,SequenceExpression:20,MemberExpression:19,ChainExpression:19,CallExpression:19,NewExpression:19,ArrowFunctionExpression:ge,ClassExpression:ge,FunctionExpression:ge,ObjectExpression:ge,UpdateExpression:16,UnaryExpression:15,AwaitExpression:15,BinaryExpression:14,LogicalExpression:13,ConditionalExpression:4,AssignmentExpression:3,YieldExpression:2,RestElement:1};function Ge(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 n=1;n<r;n++){const a=e[n];t.write(", "),i[a.type](a,t)}}t.write(")")}function mr(t,e,i,r){const n=t.expressionsPrecedence[e.type];if(n===ge)return!0;const a=t.expressionsPrecedence[i.type];return n!==a?!r&&n===15&&a===14&&i.operator==="**"||n<a:n!==13&&n!==14?!1:e.operator==="**"&&i.operator==="**"?!r:n===13&&a===13&&(e.operator==="??"||i.operator==="??")?!0:r?lt[e.operator]<=lt[i.operator]:lt[e.operator]<lt[i.operator]}function ut(t,e,i,r){const{generator:n}=t;mr(t,e,i,r)?(t.write("("),n[e.type](e,t),t.write(")")):n[e.type](e,t)}function kn(t,e,i,r){const n=e.split(`
27
- `),a=n.length-1;if(t.write(n[0].trim()),a>0){t.write(r);for(let s=1;s<a;s++)t.write(i+n[s].trim()+r);t.write(i+n[a].trim())}}function ee(t,e,i,r){const{length:n}=e;for(let a=0;a<n;a++){const s=e[a];t.write(i),s.type[0]==="L"?t.write("// "+s.value.trim()+`
28
- `,s):(t.write("/*"),kn(t,s.value,i,r),t.write("*/"+r))}}function An(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 At(t,e){const{generator:i}=t,{declarations:r}=e;t.write(e.kind+" ");const{length:n}=r;if(n>0){i.VariableDeclarator(r[0],t);for(let a=1;a<n;a++)t.write(", "),i.VariableDeclarator(r[a],t)}}let ai,oi,ci,li,ui,hi;const Yt={Program(t,e){const i=e.indent.repeat(e.indentLevel),{lineEnd:r,writeComments:n}=e;n&&t.comments!=null&&ee(e,t.comments,i,r);const a=t.body,{length:s}=a;for(let o=0;o<s;o++){const c=a[o];n&&c.comments!=null&&ee(e,c.comments,i,r),e.write(i),this[c.type](c,e),e.write(r)}n&&t.trailingComments!=null&&ee(e,t.trailingComments,i,r)},BlockStatement:hi=function(t,e){const i=e.indent.repeat(e.indentLevel++),{lineEnd:r,writeComments:n}=e,a=i+e.indent;e.write("{");const s=t.body;if(s!=null&&s.length>0){e.write(r),n&&t.comments!=null&&ee(e,t.comments,a,r);const{length:o}=s;for(let c=0;c<o;c++){const l=s[c];n&&l.comments!=null&&ee(e,l.comments,a,r),e.write(a),this[l.type](l,e),e.write(r)}e.write(i)}else n&&t.comments!=null&&(e.write(r),ee(e,t.comments,a,r),e.write(i));n&&t.trailingComments!=null&&ee(e,t.trailingComments,a,r),e.write("}"),e.indentLevel--},ClassBody:hi,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===ge||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:n}=e;e.indentLevel++;const a=i+e.indent,s=a+e.indent;e.write("switch ("),this[t.discriminant.type](t.discriminant,e),e.write(") {"+r);const{cases:o}=t,{length:c}=o;for(let l=0;l<c;l++){const u=o[l];n&&u.comments!=null&&ee(e,u.comments,a,r),u.test?(e.write(a+"case "),this[u.test.type](u.test,e),e.write(":"+r)):e.write(a+"default:"+r);const{consequent:p}=u,{length:h}=p;for(let d=0;d<h;d++){const g=p[d];n&&g.comments!=null&&ee(e,g.comments,s,r),e.write(s),this[g.type](g,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"?At(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:ai=function(t,e){e.write(`for ${t.await?"await ":""}(`);const{left:i}=t;i.type[0]==="V"?At(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:ai,DebuggerStatement(t,e){e.write("debugger;",t)},FunctionDeclaration:oi=function(t,e){e.write((t.async?"async ":"")+(t.generator?"function* ":"function ")+(t.id?t.id.name:""),t),Ge(e,t.params),e.write(" "),this[t.body.type](t.body,e)},FunctionExpression:oi,VariableDeclaration(t,e){At(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,n=e.expressionsPrecedence[r];(r[0]!=="C"||r[1]!=="l"||r[5]!=="E")&&(n===ge||n<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:n}=i;let a=0;if(n>0){for(;a<n;){a>0&&e.write(", ");const s=i[a],o=s.type[6];if(o==="D")e.write(s.local.name,s),a++;else if(o==="N")e.write("* as "+s.local.name,s),a++;else break}if(a<n){for(e.write("{");;){const s=i[a],{name:o}=s.imported;if(e.write(o,s),o!==s.local.name&&e.write(" as "+s.local.name),++a<n)e.write(", ");else break}e.write("}")}e.write(" from ")}if(this.Literal(t.source,e),r&&r.length>0){e.write(" with { ");for(let s=0;s<r.length;s++)this.ImportAttribute(r[s],e),s<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 n=0;;){const a=i[n],{name:s}=a.local;if(e.write(s,a),s!==a.exported.name&&e.write(" as "+a.exported.name),++n<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 n=0;n<t.attributes.length;n++)this.ImportAttribute(t.attributes[n],e),n<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),Ge(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]):Ge(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:ci=function(t,e){e.write("..."),this[t.argument.type](t.argument,e)},SpreadElement:ci,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),ut(e,t.argument,t)},TemplateLiteral(t,e){const{quasis:i,expressions:r}=t;e.write("`");const{length:n}=r;for(let s=0;s<n;s++){const o=r[s],c=i[s];e.write(c.value.raw,c),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){ut(e,t.tag,t),this[t.quasi.type](t.quasi,e)},ArrayExpression:ui=function(t,e){if(e.write("["),t.elements.length>0){const{elements:i}=t,{length:r}=i;for(let n=0;;){const a=i[n];if(a!=null&&this[a.type](a,e),++n<r)e.write(", ");else{a==null&&e.write(", ");break}}}e.write("]")},ArrayPattern:ui,ObjectExpression(t,e){const i=e.indent.repeat(e.indentLevel++),{lineEnd:r,writeComments:n}=e,a=i+e.indent;if(e.write("{"),t.properties.length>0){e.write(r),n&&t.comments!=null&&ee(e,t.comments,a,r);const s=","+r,{properties:o}=t,{length:c}=o;for(let l=0;;){const u=o[l];if(n&&u.comments!=null&&ee(e,u.comments,a,r),e.write(a),this[u.type](u,e),++l<c)e.write(s);else break}e.write(r),n&&t.trailingComments!=null&&ee(e,t.trailingComments,a,r),e.write(i+"}")}else n?t.comments!=null?(e.write(r),ee(e,t.comments,a,r),t.trailingComments!=null&&ee(e,t.trailingComments,a,r),e.write(i+"}")):t.trailingComments!=null?(e.write(r),ee(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 n=0;this[i[n].type](i[n],e),++n<r;)e.write(", ")}e.write("}")},SequenceExpression(t,e){Ge(e,t.expressions)},UnaryExpression(t,e){if(t.prefix){const{operator:i,argument:r,argument:{type:n}}=t;e.write(i);const a=mr(e,r,t);!a&&(i.length>1||n[0]==="U"&&(n[1]==="n"||n[1]==="p")&&r.prefix&&r.operator[0]===i&&(i==="+"||i==="-"))&&e.write(" "),a?(e.write(i.length>1?" (":"("),this[n](r,e),e.write(")")):this[n](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:li=function(t,e){const i=t.operator==="in";i&&e.write("("),ut(e,t.left,t,!1),e.write(" "+t.operator+" "),ut(e,t.right,t,!0),i&&e.write(")")},LogicalExpression:li,ConditionalExpression(t,e){const{test:i}=t,r=e.expressionsPrecedence[i.type];r===ge||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===ge||i<e.expressionsPrecedence.CallExpression||An(t.callee)?(e.write("("),this[t.callee.type](t.callee,e),e.write(")")):this[t.callee.type](t.callee,e),Ge(e,t.arguments)},CallExpression(t,e){const i=e.expressionsPrecedence[t.callee.type];i===ge||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("?."),Ge(e,t.arguments)},ChainExpression(t,e){this[t.expression.type](t.expression,e)},MemberExpression(t,e){const i=e.expressionsPrecedence[t.object.type];i===ge||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(In(t.value),t)},RegExpLiteral(t,e){const{regex:i}=t;e.write(`/${i.pattern}/${i.flags}`,t)}},Tn={},Pn=Yt;class Dn{constructor(e){const i=e??Tn;this.output="",i.output!=null?(this.output=i.output,this.write=this.writeToStream):this.output="",this.generator=i.generator!=null?i.generator:Yt,this.expressionsPrecedence=i.expressionsPrecedence!=null?i.expressionsPrecedence:Cn,this.indent=i.indent!=null?i.indent:" ",this.lineEnd=i.lineEnd!=null?i.lineEnd:`
25
+ `:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};D.readEscapedChar=function(t){var e=this.input.charCodeAt(++this.pos);switch(++this.pos,e){case 110:return`
26
+ `;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return Ce(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],n=parseInt(r,8);return n>255&&(r=r.slice(0,-1),n=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(n)}return Je(e)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(e)}};D.readHexChar=function(t){var e=this.pos,i=this.readInt(16,t);return i===null&&this.invalidStringToken(e,"Bad character escape sequence"),i};D.readWord1=function(){this.containsEsc=!1;for(var t="",e=!0,i=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var n=this.fullCharCodeAtPos();if(Be(n,r))this.pos+=n<=65535?1:2;else if(n===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 s=this.readCodePoint();(e?be:Be)(s,r)||this.invalidStringToken(a,"Invalid Unicode escape"),t+=Ce(s),i=this.pos}else break;e=!1}return t+this.input.slice(i,this.pos)};D.readWord=function(){var t=this.readWord1(),e=d.name;return this.keywords.test(t)&&(e=Ht[t]),this.finishToken(e,t)};var Bn="8.16.0";H.acorn={Parser:H,version:Bn,defaultOptions:Lt,Position:at,SourceLocation:bt,getLineInfo:qi,Node:Nt,TokenType:O,tokTypes:d,keywordTypes:Ht,TokContext:xe,tokContexts:j,isIdentifierChar:Be,isIdentifierStart:be,Token:Xt,isNewLine:Je,lineBreak:se,lineBreakG:an,nonASCIIwhitespace:$i};function br(t,e){return H.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 ut={"||":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},ye=17,jn={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:ye,ClassExpression:ye,FunctionExpression:ye,ObjectExpression:ye,UpdateExpression:16,UnaryExpression:15,AwaitExpression:15,BinaryExpression:14,LogicalExpression:13,ConditionalExpression:4,AssignmentExpression:3,YieldExpression:2,RestElement:1};function Qe(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 n=1;n<r;n++){const a=e[n];t.write(", "),i[a.type](a,t)}}t.write(")")}function wr(t,e,i,r){const n=t.expressionsPrecedence[e.type];if(n===ye)return!0;const a=t.expressionsPrecedence[i.type];return n!==a?!r&&n===15&&a===14&&i.operator==="**"||n<a:n!==13&&n!==14?!1:e.operator==="**"&&i.operator==="**"?!r:n===13&&a===13&&(e.operator==="??"||i.operator==="??")?!0:r?ut[e.operator]<=ut[i.operator]:ut[e.operator]<ut[i.operator]}function ht(t,e,i,r){const{generator:n}=t;wr(t,e,i,r)?(t.write("("),n[e.type](e,t),t.write(")")):n[e.type](e,t)}function Wn(t,e,i,r){const n=e.split(`
27
+ `),a=n.length-1;if(t.write(n[0].trim()),a>0){t.write(r);for(let s=1;s<a;s++)t.write(i+n[s].trim()+r);t.write(i+n[a].trim())}}function J(t,e,i,r){const{length:n}=e;for(let a=0;a<n;a++){const s=e[a];t.write(i),s.type[0]==="L"?t.write("// "+s.value.trim()+`
28
+ `,s):(t.write("/*"),Wn(t,s.value,i,r),t.write("*/"+r))}}function $n(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 Tt(t,e){const{generator:i}=t,{declarations:r}=e;t.write(e.kind+" ");const{length:n}=r;if(n>0){i.VariableDeclarator(r[0],t);for(let a=1;a<n;a++)t.write(", "),i.VariableDeclarator(r[a],t)}}let ui,hi,pi,fi,di,mi;const Zt={Program(t,e){const i=e.indent.repeat(e.indentLevel),{lineEnd:r,writeComments:n}=e;n&&t.comments!=null&&J(e,t.comments,i,r);const a=t.body,{length:s}=a;for(let o=0;o<s;o++){const l=a[o];n&&l.comments!=null&&J(e,l.comments,i,r),e.write(i),this[l.type](l,e),e.write(r)}n&&t.trailingComments!=null&&J(e,t.trailingComments,i,r)},BlockStatement:mi=function(t,e){const i=e.indent.repeat(e.indentLevel++),{lineEnd:r,writeComments:n}=e,a=i+e.indent;e.write("{");const s=t.body;if(s!=null&&s.length>0){e.write(r),n&&t.comments!=null&&J(e,t.comments,a,r);const{length:o}=s;for(let l=0;l<o;l++){const c=s[l];n&&c.comments!=null&&J(e,c.comments,a,r),e.write(a),this[c.type](c,e),e.write(r)}e.write(i)}else n&&t.comments!=null&&(e.write(r),J(e,t.comments,a,r),e.write(i));n&&t.trailingComments!=null&&J(e,t.trailingComments,a,r),e.write("}"),e.indentLevel--},ClassBody:mi,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===ye||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:n}=e;e.indentLevel++;const a=i+e.indent,s=a+e.indent;e.write("switch ("),this[t.discriminant.type](t.discriminant,e),e.write(") {"+r);const{cases:o}=t,{length:l}=o;for(let c=0;c<l;c++){const u=o[c];n&&u.comments!=null&&J(e,u.comments,a,r),u.test?(e.write(a+"case "),this[u.test.type](u.test,e),e.write(":"+r)):e.write(a+"default:"+r);const{consequent:p}=u,{length:h}=p;for(let f=0;f<h;f++){const m=p[f];n&&m.comments!=null&&J(e,m.comments,s,r),e.write(s),this[m.type](m,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"?Tt(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:ui=function(t,e){e.write(`for ${t.await?"await ":""}(`);const{left:i}=t;i.type[0]==="V"?Tt(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:ui,DebuggerStatement(t,e){e.write("debugger;",t)},FunctionDeclaration:hi=function(t,e){e.write((t.async?"async ":"")+(t.generator?"function* ":"function ")+(t.id?t.id.name:""),t),Qe(e,t.params),e.write(" "),this[t.body.type](t.body,e)},FunctionExpression:hi,VariableDeclaration(t,e){Tt(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,n=e.expressionsPrecedence[r];(r[0]!=="C"||r[1]!=="l"||r[5]!=="E")&&(n===ye||n<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:n}=i;let a=0;if(n>0){for(;a<n;){a>0&&e.write(", ");const s=i[a],o=s.type[6];if(o==="D")e.write(s.local.name,s),a++;else if(o==="N")e.write("* as "+s.local.name,s),a++;else break}if(a<n){for(e.write("{");;){const s=i[a],{name:o}=s.imported;if(e.write(o,s),o!==s.local.name&&e.write(" as "+s.local.name),++a<n)e.write(", ");else break}e.write("}")}e.write(" from ")}if(this.Literal(t.source,e),r&&r.length>0){e.write(" with { ");for(let s=0;s<r.length;s++)this.ImportAttribute(r[s],e),s<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 n=0;;){const a=i[n],{name:s}=a.local;if(e.write(s,a),s!==a.exported.name&&e.write(" as "+a.exported.name),++n<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 n=0;n<t.attributes.length;n++)this.ImportAttribute(t.attributes[n],e),n<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),Qe(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]):Qe(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:pi=function(t,e){e.write("..."),this[t.argument.type](t.argument,e)},SpreadElement:pi,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),ht(e,t.argument,t)},TemplateLiteral(t,e){const{quasis:i,expressions:r}=t;e.write("`");const{length:n}=r;for(let s=0;s<n;s++){const o=r[s],l=i[s];e.write(l.value.raw,l),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){ht(e,t.tag,t),this[t.quasi.type](t.quasi,e)},ArrayExpression:di=function(t,e){if(e.write("["),t.elements.length>0){const{elements:i}=t,{length:r}=i;for(let n=0;;){const a=i[n];if(a!=null&&this[a.type](a,e),++n<r)e.write(", ");else{a==null&&e.write(", ");break}}}e.write("]")},ArrayPattern:di,ObjectExpression(t,e){const i=e.indent.repeat(e.indentLevel++),{lineEnd:r,writeComments:n}=e,a=i+e.indent;if(e.write("{"),t.properties.length>0){e.write(r),n&&t.comments!=null&&J(e,t.comments,a,r);const s=","+r,{properties:o}=t,{length:l}=o;for(let c=0;;){const u=o[c];if(n&&u.comments!=null&&J(e,u.comments,a,r),e.write(a),this[u.type](u,e),++c<l)e.write(s);else break}e.write(r),n&&t.trailingComments!=null&&J(e,t.trailingComments,a,r),e.write(i+"}")}else n?t.comments!=null?(e.write(r),J(e,t.comments,a,r),t.trailingComments!=null&&J(e,t.trailingComments,a,r),e.write(i+"}")):t.trailingComments!=null?(e.write(r),J(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 n=0;this[i[n].type](i[n],e),++n<r;)e.write(", ")}e.write("}")},SequenceExpression(t,e){Qe(e,t.expressions)},UnaryExpression(t,e){if(t.prefix){const{operator:i,argument:r,argument:{type:n}}=t;e.write(i);const a=wr(e,r,t);!a&&(i.length>1||n[0]==="U"&&(n[1]==="n"||n[1]==="p")&&r.prefix&&r.operator[0]===i&&(i==="+"||i==="-"))&&e.write(" "),a?(e.write(i.length>1?" (":"("),this[n](r,e),e.write(")")):this[n](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:fi=function(t,e){const i=t.operator==="in";i&&e.write("("),ht(e,t.left,t,!1),e.write(" "+t.operator+" "),ht(e,t.right,t,!0),i&&e.write(")")},LogicalExpression:fi,ConditionalExpression(t,e){const{test:i}=t,r=e.expressionsPrecedence[i.type];r===ye||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===ye||i<e.expressionsPrecedence.CallExpression||$n(t.callee)?(e.write("("),this[t.callee.type](t.callee,e),e.write(")")):this[t.callee.type](t.callee,e),Qe(e,t.arguments)},CallExpression(t,e){const i=e.expressionsPrecedence[t.callee.type];i===ye||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("?."),Qe(e,t.arguments)},ChainExpression(t,e){this[t.expression.type](t.expression,e)},MemberExpression(t,e){const i=e.expressionsPrecedence[t.object.type];i===ye||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)}},Un={},qn=Zt;class Hn{constructor(e){const i=e??Un;this.output="",i.output!=null?(this.output=i.output,this.write=this.writeToStream):this.output="",this.generator=i.generator!=null?i.generator:Zt,this.expressionsPrecedence=i.expressionsPrecedence!=null?i.expressionsPrecedence:jn,this.indent=i.indent!=null?i.indent:" ",this.lineEnd=i.lineEnd!=null?i.lineEnd:`
29
29
  `,this.indentLevel=i.startingIndentLevel!=null?i.startingIndentLevel:0,this.writeComments=i.comments?i.comments:!1,i.sourceMap!=null&&(this.write=i.output==null?this.writeAndMap:this.writeToStreamAndMap,this.sourceMap=i.sourceMap,this.line=1,this.column=0,this.lineEndSize=this.lineEnd.split(`
30
- `).length-1,this.mapping={original:null,generated:this,name:void 0,source:i.sourceMap.file||i.sourceMap._file})}write(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:s}=this;s.original=i.loc.start,s.name=i.name,this.sourceMap.addMapping(s)}if(a[0]==="T"&&a[8]==="E"||a[0]==="L"&&a[1]==="i"&&typeof i.value=="string"){const{length:s}=e;let{column:o,line:c}=this;for(let l=0;l<s;l++)e[l]===`
31
- `?(o=0,c++):o++;this.column=o,this.line=c;return}}const{length:r}=e,{lineEnd:n}=this;r>0&&(this.lineEndSize>0&&(n.length===1?e[r-1]===n:e.endsWith(n))?(this.line+=this.lineEndSize,this.column=0):this.column+=r)}toString(){return this.output}}function xr(t,e){const i=new Dn(e);return i.generator[t.type](t,i),i.output}const Rn=new Set(["Infinity","NaN","undefined","null","true","false"]),Mn=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 On{scopes=[];scopeTypes=[];scopeCounts=new Map;contextBoundVars=new Set;arrayPatternElements=new Set;rootParams=new Set;localSeriesVars=new Set;varKinds=new Map;loopVars=new Set;loopVarNames=new Map;paramIdCounter=0;cacheIdCounter=0;tempVarCounter=0;taCallIdCounter=0;userCallIdCounter=0;plotCallIdCounter=0;hoistingStack=[];suppressHoisting=!1;reservedNames=new Set;userFunctions=new Set;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++}`}}getNextPlotCallId(){return{type:"Literal",value:`#${this.plotCallIdCounter++}`}}constructor(){this.pushScope("glb")}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 Rn.has(e)||Mn.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],n=this.scopeTypes[this.scopeTypes.length-1],a=this.scopeCounts.get(n)||1,s=`${n}${a}_${e}`;return r.set(e,s),this.varKinds.set(s,i),s}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 n=r.get(e),a=this.varKinds.get(n)||"let";return[n,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)}getCurrentHoistingScope(){return this.hoistingStack.length===0?null:this.hoistingStack[this.hoistingStack.length-1]}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 gr(t,e,i,r,n){i||(i=E),(function a(s,o,c){var l=c||s.type;yr(i,l,s,o,a),e[l]&&e[l](s,o)})(t,r,n)}function Vn(t,e,i,r,n){var a=[];i||(i=E),(function s(o,c,l){var u=l||o.type,p=o!==a[a.length-1];p&&a.push(o),yr(i,u,o,c,s),e[u]&&e[u](o,c||a,a),p&&a.pop()})(t,r,n)}function z(t,e,i,r,n){var a=i?Ln(i,r||void 0):r;(function s(o,c,l){a[l||o.type](o,c,s)})(t,e,n)}function Ln(t,e){var i=Object.create(e||E);for(var r in t)i[r]=t[r];return i}function Qt(t,e,i){i(t,e)}function He(t,e,i){}function yr(t,e,i,r,n){if(t[e]==null)throw new Error("No walker function defined for node type "+e);t[e](i,r,n)}var E={};E.Program=E.BlockStatement=E.StaticBlock=function(t,e,i){for(var r=0,n=t.body;r<n.length;r+=1){var a=n[r];i(a,e,"Statement")}};E.Statement=Qt;E.EmptyStatement=He;E.ExpressionStatement=E.ParenthesizedExpression=E.ChainExpression=function(t,e,i){return i(t.expression,e,"Expression")};E.IfStatement=function(t,e,i){i(t.test,e,"Expression"),i(t.consequent,e,"Statement"),t.alternate&&i(t.alternate,e,"Statement")};E.LabeledStatement=function(t,e,i){return i(t.body,e,"Statement")};E.BreakStatement=E.ContinueStatement=He;E.WithStatement=function(t,e,i){i(t.object,e,"Expression"),i(t.body,e,"Statement")};E.SwitchStatement=function(t,e,i){i(t.discriminant,e,"Expression");for(var r=0,n=t.cases;r<n.length;r+=1){var a=n[r];i(a,e)}};E.SwitchCase=function(t,e,i){t.test&&i(t.test,e,"Expression");for(var r=0,n=t.consequent;r<n.length;r+=1){var a=n[r];i(a,e,"Statement")}};E.ReturnStatement=E.YieldExpression=E.AwaitExpression=function(t,e,i){t.argument&&i(t.argument,e,"Expression")};E.ThrowStatement=E.SpreadElement=function(t,e,i){return i(t.argument,e,"Expression")};E.TryStatement=function(t,e,i){i(t.block,e,"Statement"),t.handler&&i(t.handler,e),t.finalizer&&i(t.finalizer,e,"Statement")};E.CatchClause=function(t,e,i){t.param&&i(t.param,e,"Pattern"),i(t.body,e,"Statement")};E.WhileStatement=E.DoWhileStatement=function(t,e,i){i(t.test,e,"Expression"),i(t.body,e,"Statement")};E.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")};E.ForInStatement=E.ForOfStatement=function(t,e,i){i(t.left,e,"ForInit"),i(t.right,e,"Expression"),i(t.body,e,"Statement")};E.ForInit=function(t,e,i){t.type==="VariableDeclaration"?i(t,e):i(t,e,"Expression")};E.DebuggerStatement=He;E.FunctionDeclaration=function(t,e,i){return i(t,e,"Function")};E.VariableDeclaration=function(t,e,i){for(var r=0,n=t.declarations;r<n.length;r+=1){var a=n[r];i(a,e)}};E.VariableDeclarator=function(t,e,i){i(t.id,e,"Pattern"),t.init&&i(t.init,e,"Expression")};E.Function=function(t,e,i){t.id&&i(t.id,e,"Pattern");for(var r=0,n=t.params;r<n.length;r+=1){var a=n[r];i(a,e,"Pattern")}i(t.body,e,t.expression?"Expression":"Statement")};E.Pattern=function(t,e,i){t.type==="Identifier"?i(t,e,"VariablePattern"):t.type==="MemberExpression"?i(t,e,"MemberPattern"):i(t,e)};E.VariablePattern=He;E.MemberPattern=Qt;E.RestElement=function(t,e,i){return i(t.argument,e,"Pattern")};E.ArrayPattern=function(t,e,i){for(var r=0,n=t.elements;r<n.length;r+=1){var a=n[r];a&&i(a,e,"Pattern")}};E.ObjectPattern=function(t,e,i){for(var r=0,n=t.properties;r<n.length;r+=1){var a=n[r];a.type==="Property"?(a.computed&&i(a.key,e,"Expression"),i(a.value,e,"Pattern")):a.type==="RestElement"&&i(a.argument,e,"Pattern")}};E.Expression=Qt;E.ThisExpression=E.Super=E.MetaProperty=He;E.ArrayExpression=function(t,e,i){for(var r=0,n=t.elements;r<n.length;r+=1){var a=n[r];a&&i(a,e,"Expression")}};E.ObjectExpression=function(t,e,i){for(var r=0,n=t.properties;r<n.length;r+=1){var a=n[r];i(a,e)}};E.FunctionExpression=E.ArrowFunctionExpression=E.FunctionDeclaration;E.SequenceExpression=function(t,e,i){for(var r=0,n=t.expressions;r<n.length;r+=1){var a=n[r];i(a,e,"Expression")}};E.TemplateLiteral=function(t,e,i){for(var r=0,n=t.quasis;r<n.length;r+=1){var a=n[r];i(a,e)}for(var s=0,o=t.expressions;s<o.length;s+=1){var c=o[s];i(c,e,"Expression")}};E.TemplateElement=He;E.UnaryExpression=E.UpdateExpression=function(t,e,i){i(t.argument,e,"Expression")};E.BinaryExpression=E.LogicalExpression=function(t,e,i){i(t.left,e,"Expression"),i(t.right,e,"Expression")};E.AssignmentExpression=E.AssignmentPattern=function(t,e,i){i(t.left,e,"Pattern"),i(t.right,e,"Expression")};E.ConditionalExpression=function(t,e,i){i(t.test,e,"Expression"),i(t.consequent,e,"Expression"),i(t.alternate,e,"Expression")};E.NewExpression=E.CallExpression=function(t,e,i){if(i(t.callee,e,"Expression"),t.arguments)for(var r=0,n=t.arguments;r<n.length;r+=1){var a=n[r];i(a,e,"Expression")}};E.MemberExpression=function(t,e,i){i(t.object,e,"Expression"),t.computed&&i(t.property,e,"Expression")};E.ExportNamedDeclaration=E.ExportDefaultDeclaration=function(t,e,i){if(t.declaration&&i(t.declaration,e,t.type==="ExportNamedDeclaration"||t.declaration.id?"Statement":"Expression"),t.source&&i(t.source,e,"Expression"),t.attributes)for(var r=0,n=t.attributes;r<n.length;r+=1){var a=n[r];i(a,e)}};E.ExportAllDeclaration=function(t,e,i){if(t.exported&&i(t.exported,e),i(t.source,e,"Expression"),t.attributes)for(var r=0,n=t.attributes;r<n.length;r+=1){var a=n[r];i(a,e)}};E.ImportAttribute=function(t,e,i){i(t.value,e,"Expression")};E.ImportDeclaration=function(t,e,i){for(var r=0,n=t.specifiers;r<n.length;r+=1){var a=n[r];i(a,e)}if(i(t.source,e,"Expression"),t.attributes)for(var s=0,o=t.attributes;s<o.length;s+=1){var c=o[s];i(c,e)}};E.ImportExpression=function(t,e,i){i(t.source,e,"Expression"),t.options&&i(t.options,e,"Expression")};E.ImportSpecifier=E.ImportDefaultSpecifier=E.ImportNamespaceSpecifier=E.Identifier=E.PrivateIdentifier=E.Literal=He;E.TaggedTemplateExpression=function(t,e,i){i(t.tag,e,"Expression"),i(t.quasi,e,"Expression")};E.ClassDeclaration=E.ClassExpression=function(t,e,i){return i(t,e,"Class")};E.Class=function(t,e,i){t.id&&i(t.id,e,"Pattern"),t.superClass&&i(t.superClass,e,"Expression"),i(t.body,e)};E.ClassBody=function(t,e,i){for(var r=0,n=t.body;r<n.length;r+=1){var a=n[r];i(a,e)}};E.MethodDefinition=E.PropertyDefinition=E.Property=function(t,e,i){t.computed&&i(t.key,e,"Expression"),t.value&&i(t.value,e,"Expression")};const $="$",b={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),n=this.createIdentifier(e);return this.createMemberExpression(this.createMemberExpression(i,r,!1),n,!1)},createLocalContextVariableReference(t,e){const i=this.createLocalContextIdentifier(),r=this.createIdentifier(t),n=this.createIdentifier(e);return this.createMemberExpression(this.createMemberExpression(i,r,!1),n,!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),n=[t,e];return i&&n.push(i),this.createCallExpression(r,n)},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),n=this.createMemberExpression(r,this.createIdentifier("__eq"),!1);return this.createCallExpression(n,[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}}},ot=["ta","math","request","array","input"],Be=["hline","plot","fill","label","line","na","time","time_close","dayofmonth","dayofweek","hour","minute","month","second","weekofyear","year"],Bn=["request.security","request.security_lower_tf"],Fn=["line.new","line.copy","label.new","label.copy"],vr=["open","high","low","close","volume","hl2","hlc3","ohlc4","openTime","closeTime"],wr=[...ot,"plotchar","plotshape","plotarrow","plotbar","plotcandle","plot","bgcolor","barcolor","hline","fill","indicator","strategy","library","alertcondition","fixnan","na","color","nz","timestamp","str","box","line","label","table","chart","linefill","map","matrix","log","map","Type","bool","timeframe","syminfo","barstate","bar_index","last_bar_index","last_bar_time","inputs","time","time_close","time_tradingday","dayofmonth","hour","minute","month","second","weekofyear","year","order","currency","display","shape","location","size","format","dayofweek","xloc","yloc","text","font"],jn=["na","nz","plot","plotchar","color","hline","fill"];function Wn(t){let e=null,i=$;if(t.type==="Program"&&t.body.length>0){const d=t.body[0];if(d.type==="ExpressionStatement"&&(d.expression.type==="ArrowFunctionExpression"||d.expression.type==="FunctionExpression")){const g=d.expression;g.body.type==="BlockStatement"&&(e=g.body.body,g.params.length>0&&g.params[0].type==="Identifier"&&(i=g.params[0].name))}}if(!e)return;const r=new Set,n=new Set,a=d=>{d.type==="Identifier"?r.add(d.name):d.type==="ObjectPattern"?d.properties.forEach(g=>a(g.value)):d.type==="ArrayPattern"&&d.elements.forEach(g=>{g&&a(g)})};z(t,{},{VariableDeclarator(d,g,y){a(d.id),d.init&&y(d.init,g)},FunctionDeclaration(d,g,y){a(d.id),y(d.body,g)},Identifier(d,g,y){n.add(d.name)},MemberExpression(d,g,y){y(d.object,g),d.computed&&y(d.property,g)},Property(d,g,y){d.computed&&y(d.key,g),y(d.value,g)}}),e.forEach(d=>{d.type==="VariableDeclaration"?d.declarations.forEach(g=>a(g.id)):d.type==="FunctionDeclaration"&&a(d.id)});const s=vr,o=wr,c=s.filter(d=>!r.has(d)),l=o.filter(d=>!r.has(d)),u=c.filter(d=>n.has(d)),p=l.filter(d=>n.has(d)),h=[];u.length>0&&h.push({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"ObjectPattern",properties:u.map(d=>({type:"Property",key:{type:"Identifier",name:d},value:{type:"Identifier",name:d},kind:"init",shorthand:!0}))},init:{type:"MemberExpression",object:{type:"Identifier",name:i},property:{type:"Identifier",name:"data"},computed:!1}}]}),p.length>0&&h.push({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"ObjectPattern",properties:p.map(d=>({type:"Property",key:{type:"Identifier",name:d},value:{type:"Identifier",name:d},kind:"init",shorthand:!0}))},init:{type:"MemberExpression",object:{type:"Identifier",name:i},property:{type:"Identifier",name:"pine"},computed:!1}}]}),h.length>0&&e.unshift(...h)}function $n(t){let e=null,i=$;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 c=o.expression;c.body.type==="BlockStatement"&&(e=c.body.body,c.params.length>0&&c.params[0].type==="Identifier"&&(i=c.params[0].name))}}if(!e)return;const r=new Set(vr),n=new Set(wr),a=new Set(jn),s=new Map;e.forEach(o=>{o.type==="VariableDeclaration"&&o.declarations.forEach(c=>{if(c.init&&c.init.type==="MemberExpression"&&c.init.object.type==="Identifier"&&c.init.object.name===i&&c.init.property.type==="Identifier"){const l=c.init.property.name;let u=null;if(l==="data"?u=r:l==="pine"?u=n:l==="core"&&(u=a),u&&c.id.type==="ObjectPattern")c.id.properties.forEach(p=>{if(p.type==="Property"&&p.key.type==="Identifier"&&p.value.type==="Identifier"){const h=p.key.name,d=p.value.name;u.has(h)&&h!==d&&(s.set(d,h),p.value.name=h,p.shorthand=!0)}});else if(c.id.type==="Identifier"&&ot.includes(l)){const p=l,h=c.id.name;p!==h&&(s.set(h,p),c.id.name=p)}}})}),s.size>0&&z(t,{},{Identifier(o){s.has(o.name)&&(o.name=s.get(o.name))},MemberExpression(o,c,l){l(o.object,c),o.computed&&l(o.property,c)},Property(o,c,l){o.computed&&l(o.key,c),l(o.value,c)}})}function Un(t){try{const e=dr(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 qn(t){return t.async=!0,xr(t)}function Kn(t){t=t.trim();const{isWrapped:e,isAsync:i,functionNode:r}=Un(t);return e&&r?i?t:qn(r):`async (context) => {
30
+ `).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:s}=this;s.original=i.loc.start,s.name=i.name,this.sourceMap.addMapping(s)}if(a[0]==="T"&&a[8]==="E"||a[0]==="L"&&a[1]==="i"&&typeof i.value=="string"){const{length:s}=e;let{column:o,line:l}=this;for(let c=0;c<s;c++)e[c]===`
31
+ `?(o=0,l++):o++;this.column=o,this.line=l;return}}const{length:r}=e,{lineEnd:n}=this;r>0&&(this.lineEndSize>0&&(n.length===1?e[r-1]===n:e.endsWith(n))?(this.line+=this.lineEndSize,this.column=0):this.column+=r)}toString(){return this.output}}function Sr(t,e){const i=new Hn(e);return i.generator[t.type](t,i),i.output}const Kn=new Set(["Infinity","NaN","undefined","null","true","false"]),zn=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 Gn{scopes=[];scopeTypes=[];scopeCounts=new Map;contextBoundVars=new Set;arrayPatternElements=new Set;rootParams=new Set;localSeriesVars=new Set;varKinds=new Map;loopVars=new Set;loopVarNames=new Map;paramIdCounter=0;cacheIdCounter=0;tempVarCounter=0;taCallIdCounter=0;userCallIdCounter=0;plotCallIdCounter=0;hoistingStack=[];suppressHoisting=!1;reservedNames=new Set;userFunctions=new Set;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++}`}}getNextPlotCallId(){return{type:"Literal",value:`#${this.plotCallIdCounter++}`}}constructor(){this.pushScope("glb")}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 Kn.has(e)||zn.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],n=this.scopeTypes[this.scopeTypes.length-1],a=this.scopeCounts.get(n)||1,s=`${n}${a}_${e}`;return r.set(e,s),this.varKinds.set(s,i),s}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 n=r.get(e),a=this.varKinds.get(n)||"let";return[n,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)}addOuterHoistedStatement(e){if(this.hoistingStack.length>0&&!this.suppressHoisting){const i=Math.min(1,this.hoistingStack.length-1);this.hoistingStack[i].push(e)}}getCurrentHoistingScope(){return this.hoistingStack.length===0?null:this.hoistingStack[this.hoistingStack.length-1]}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 Er(t,e,i,r,n){i||(i=C),(function a(s,o,l){var c=l||s.type;Nr(i,c,s,o,a),e[c]&&e[c](s,o)})(t,r,n)}function Yn(t,e,i,r,n){var a=[];i||(i=C),(function s(o,l,c){var u=c||o.type,p=o!==a[a.length-1];p&&a.push(o),Nr(i,u,o,l,s),e[u]&&e[u](o,l||a,a),p&&a.pop()})(t,r,n)}function G(t,e,i,r,n){var a=i?Qn(i,r||void 0):r;(function s(o,l,c){a[c||o.type](o,l,s)})(t,e,n)}function Qn(t,e){var i=Object.create(e||C);for(var r in t)i[r]=t[r];return i}function Jt(t,e,i){i(t,e)}function ze(t,e,i){}function Nr(t,e,i,r,n){if(t[e]==null)throw new Error("No walker function defined for node type "+e);t[e](i,r,n)}var C={};C.Program=C.BlockStatement=C.StaticBlock=function(t,e,i){for(var r=0,n=t.body;r<n.length;r+=1){var a=n[r];i(a,e,"Statement")}};C.Statement=Jt;C.EmptyStatement=ze;C.ExpressionStatement=C.ParenthesizedExpression=C.ChainExpression=function(t,e,i){return i(t.expression,e,"Expression")};C.IfStatement=function(t,e,i){i(t.test,e,"Expression"),i(t.consequent,e,"Statement"),t.alternate&&i(t.alternate,e,"Statement")};C.LabeledStatement=function(t,e,i){return i(t.body,e,"Statement")};C.BreakStatement=C.ContinueStatement=ze;C.WithStatement=function(t,e,i){i(t.object,e,"Expression"),i(t.body,e,"Statement")};C.SwitchStatement=function(t,e,i){i(t.discriminant,e,"Expression");for(var r=0,n=t.cases;r<n.length;r+=1){var a=n[r];i(a,e)}};C.SwitchCase=function(t,e,i){t.test&&i(t.test,e,"Expression");for(var r=0,n=t.consequent;r<n.length;r+=1){var a=n[r];i(a,e,"Statement")}};C.ReturnStatement=C.YieldExpression=C.AwaitExpression=function(t,e,i){t.argument&&i(t.argument,e,"Expression")};C.ThrowStatement=C.SpreadElement=function(t,e,i){return i(t.argument,e,"Expression")};C.TryStatement=function(t,e,i){i(t.block,e,"Statement"),t.handler&&i(t.handler,e),t.finalizer&&i(t.finalizer,e,"Statement")};C.CatchClause=function(t,e,i){t.param&&i(t.param,e,"Pattern"),i(t.body,e,"Statement")};C.WhileStatement=C.DoWhileStatement=function(t,e,i){i(t.test,e,"Expression"),i(t.body,e,"Statement")};C.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")};C.ForInStatement=C.ForOfStatement=function(t,e,i){i(t.left,e,"ForInit"),i(t.right,e,"Expression"),i(t.body,e,"Statement")};C.ForInit=function(t,e,i){t.type==="VariableDeclaration"?i(t,e):i(t,e,"Expression")};C.DebuggerStatement=ze;C.FunctionDeclaration=function(t,e,i){return i(t,e,"Function")};C.VariableDeclaration=function(t,e,i){for(var r=0,n=t.declarations;r<n.length;r+=1){var a=n[r];i(a,e)}};C.VariableDeclarator=function(t,e,i){i(t.id,e,"Pattern"),t.init&&i(t.init,e,"Expression")};C.Function=function(t,e,i){t.id&&i(t.id,e,"Pattern");for(var r=0,n=t.params;r<n.length;r+=1){var a=n[r];i(a,e,"Pattern")}i(t.body,e,t.expression?"Expression":"Statement")};C.Pattern=function(t,e,i){t.type==="Identifier"?i(t,e,"VariablePattern"):t.type==="MemberExpression"?i(t,e,"MemberPattern"):i(t,e)};C.VariablePattern=ze;C.MemberPattern=Jt;C.RestElement=function(t,e,i){return i(t.argument,e,"Pattern")};C.ArrayPattern=function(t,e,i){for(var r=0,n=t.elements;r<n.length;r+=1){var a=n[r];a&&i(a,e,"Pattern")}};C.ObjectPattern=function(t,e,i){for(var r=0,n=t.properties;r<n.length;r+=1){var a=n[r];a.type==="Property"?(a.computed&&i(a.key,e,"Expression"),i(a.value,e,"Pattern")):a.type==="RestElement"&&i(a.argument,e,"Pattern")}};C.Expression=Jt;C.ThisExpression=C.Super=C.MetaProperty=ze;C.ArrayExpression=function(t,e,i){for(var r=0,n=t.elements;r<n.length;r+=1){var a=n[r];a&&i(a,e,"Expression")}};C.ObjectExpression=function(t,e,i){for(var r=0,n=t.properties;r<n.length;r+=1){var a=n[r];i(a,e)}};C.FunctionExpression=C.ArrowFunctionExpression=C.FunctionDeclaration;C.SequenceExpression=function(t,e,i){for(var r=0,n=t.expressions;r<n.length;r+=1){var a=n[r];i(a,e,"Expression")}};C.TemplateLiteral=function(t,e,i){for(var r=0,n=t.quasis;r<n.length;r+=1){var a=n[r];i(a,e)}for(var s=0,o=t.expressions;s<o.length;s+=1){var l=o[s];i(l,e,"Expression")}};C.TemplateElement=ze;C.UnaryExpression=C.UpdateExpression=function(t,e,i){i(t.argument,e,"Expression")};C.BinaryExpression=C.LogicalExpression=function(t,e,i){i(t.left,e,"Expression"),i(t.right,e,"Expression")};C.AssignmentExpression=C.AssignmentPattern=function(t,e,i){i(t.left,e,"Pattern"),i(t.right,e,"Expression")};C.ConditionalExpression=function(t,e,i){i(t.test,e,"Expression"),i(t.consequent,e,"Expression"),i(t.alternate,e,"Expression")};C.NewExpression=C.CallExpression=function(t,e,i){if(i(t.callee,e,"Expression"),t.arguments)for(var r=0,n=t.arguments;r<n.length;r+=1){var a=n[r];i(a,e,"Expression")}};C.MemberExpression=function(t,e,i){i(t.object,e,"Expression"),t.computed&&i(t.property,e,"Expression")};C.ExportNamedDeclaration=C.ExportDefaultDeclaration=function(t,e,i){if(t.declaration&&i(t.declaration,e,t.type==="ExportNamedDeclaration"||t.declaration.id?"Statement":"Expression"),t.source&&i(t.source,e,"Expression"),t.attributes)for(var r=0,n=t.attributes;r<n.length;r+=1){var a=n[r];i(a,e)}};C.ExportAllDeclaration=function(t,e,i){if(t.exported&&i(t.exported,e),i(t.source,e,"Expression"),t.attributes)for(var r=0,n=t.attributes;r<n.length;r+=1){var a=n[r];i(a,e)}};C.ImportAttribute=function(t,e,i){i(t.value,e,"Expression")};C.ImportDeclaration=function(t,e,i){for(var r=0,n=t.specifiers;r<n.length;r+=1){var a=n[r];i(a,e)}if(i(t.source,e,"Expression"),t.attributes)for(var s=0,o=t.attributes;s<o.length;s+=1){var l=o[s];i(l,e)}};C.ImportExpression=function(t,e,i){i(t.source,e,"Expression"),t.options&&i(t.options,e,"Expression")};C.ImportSpecifier=C.ImportDefaultSpecifier=C.ImportNamespaceSpecifier=C.Identifier=C.PrivateIdentifier=C.Literal=ze;C.TaggedTemplateExpression=function(t,e,i){i(t.tag,e,"Expression"),i(t.quasi,e,"Expression")};C.ClassDeclaration=C.ClassExpression=function(t,e,i){return i(t,e,"Class")};C.Class=function(t,e,i){t.id&&i(t.id,e,"Pattern"),t.superClass&&i(t.superClass,e,"Expression"),i(t.body,e)};C.ClassBody=function(t,e,i){for(var r=0,n=t.body;r<n.length;r+=1){var a=n[r];i(a,e)}};C.MethodDefinition=C.PropertyDefinition=C.Property=function(t,e,i){t.computed&&i(t.key,e,"Expression"),t.value&&i(t.value,e,"Expression")};const U="$",w={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),n=this.createIdentifier(e);return this.createMemberExpression(this.createMemberExpression(i,r,!1),n,!1)},createLocalContextVariableReference(t,e){const i=this.createLocalContextIdentifier(),r=this.createIdentifier(t),n=this.createIdentifier(e);return this.createMemberExpression(this.createMemberExpression(i,r,!1),n,!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),n=[t,e];return i&&n.push(i),this.createCallExpression(r,n)},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),n=this.createMemberExpression(r,this.createIdentifier("__eq"),!1);return this.createCallExpression(n,[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}}},it=["ta","math","request","array","input"],We=["hline","plot","fill","label","line","na","time","time_close","dayofmonth","dayofweek","hour","minute","month","second","weekofyear","year"],Xn=["request.security","request.security_lower_tf"],Zn=["line.new","line.copy","label.new","label.copy","polyline.new","box.new","box.copy","table.new"],Cr=["open","high","low","close","volume","hl2","hlc3","ohlc4","hlcc4","openTime","closeTime"],Ir=[...it,"plotchar","plotshape","plotarrow","plotbar","plotcandle","plot","bgcolor","barcolor","hline","fill","indicator","strategy","library","alertcondition","fixnan","na","color","nz","timestamp","str","box","line","label","table","chart","linefill","polyline","map","matrix","log","map","Type","bool","int","float","string","timeframe","syminfo","barstate","bar_index","last_bar_index","last_bar_time","inputs","time","time_close","time_tradingday","dayofmonth","hour","minute","month","second","weekofyear","year","order","currency","display","shape","location","size","format","dayofweek","xloc","yloc","text","font","extend","position","adjustment","backadjustment","earnings","dividends","splits"],Jn=["na","nz","plot","plotchar","color","hline","fill"];function es(t){let e=null,i=U;if(t.type==="Program"&&t.body.length>0){const f=t.body[0];if(f.type==="ExpressionStatement"&&(f.expression.type==="ArrowFunctionExpression"||f.expression.type==="FunctionExpression")){const m=f.expression;m.body.type==="BlockStatement"&&(e=m.body.body,m.params.length>0&&m.params[0].type==="Identifier"&&(i=m.params[0].name))}}if(!e)return;const r=new Set,n=new Set,a=f=>{f.type==="Identifier"?r.add(f.name):f.type==="ObjectPattern"?f.properties.forEach(m=>a(m.value)):f.type==="ArrayPattern"&&f.elements.forEach(m=>{m&&a(m)})};G(t,{},{VariableDeclarator(f,m,y){a(f.id),f.init&&y(f.init,m)},FunctionDeclaration(f,m,y){a(f.id),y(f.body,m)},Identifier(f,m,y){n.add(f.name)},MemberExpression(f,m,y){y(f.object,m),f.computed&&y(f.property,m)},Property(f,m,y){f.computed&&y(f.key,m),y(f.value,m)}}),e.forEach(f=>{f.type==="VariableDeclaration"?f.declarations.forEach(m=>a(m.id)):f.type==="FunctionDeclaration"&&a(f.id)});const s=Cr,o=Ir,l=s.filter(f=>!r.has(f)),c=o.filter(f=>!r.has(f)),u=l.filter(f=>n.has(f)),p=c.filter(f=>n.has(f)),h=[];u.length>0&&h.push({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"ObjectPattern",properties:u.map(f=>({type:"Property",key:{type:"Identifier",name:f},value:{type:"Identifier",name:f},kind:"init",shorthand:!0}))},init:{type:"MemberExpression",object:{type:"Identifier",name:i},property:{type:"Identifier",name:"data"},computed:!1}}]}),p.length>0&&h.push({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"ObjectPattern",properties:p.map(f=>({type:"Property",key:{type:"Identifier",name:f},value:{type:"Identifier",name:f},kind:"init",shorthand:!0}))},init:{type:"MemberExpression",object:{type:"Identifier",name:i},property:{type:"Identifier",name:"pine"},computed:!1}}]}),h.length>0&&e.unshift(...h)}function ts(t){let e=null,i=U;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 l=o.expression;l.body.type==="BlockStatement"&&(e=l.body.body,l.params.length>0&&l.params[0].type==="Identifier"&&(i=l.params[0].name))}}if(!e)return;const r=new Set(Cr),n=new Set(Ir),a=new Set(Jn),s=new Map;e.forEach(o=>{o.type==="VariableDeclaration"&&o.declarations.forEach(l=>{if(l.init&&l.init.type==="MemberExpression"&&l.init.object.type==="Identifier"&&l.init.object.name===i&&l.init.property.type==="Identifier"){const c=l.init.property.name;let u=null;if(c==="data"?u=r:c==="pine"?u=n:c==="core"&&(u=a),u&&l.id.type==="ObjectPattern")l.id.properties.forEach(p=>{if(p.type==="Property"&&p.key.type==="Identifier"&&p.value.type==="Identifier"){const h=p.key.name,f=p.value.name;u.has(h)&&h!==f&&(s.set(f,h),p.value.name=h,p.shorthand=!0)}});else if(l.id.type==="Identifier"&&it.includes(c)){const p=c,h=l.id.name;p!==h&&(s.set(h,p),l.id.name=p)}}})}),s.size>0&&G(t,{},{Identifier(o){s.has(o.name)&&(o.name=s.get(o.name))},MemberExpression(o,l,c){c(o.object,l),o.computed&&c(o.property,l)},Property(o,l,c){o.computed&&c(o.key,l),c(o.value,l)}})}function is(t){try{const e=br(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 rs(t){return t.async=!0,Sr(t)}function ns(t){t=t.trim();const{isWrapped:e,isAsync:i,functionNode:r}=is(t);return e&&r?i?t:rs(r):`async (context) => {
32
32
  ${t}
33
- }`}function Hn(t){z(t,null,{VariableDeclaration(e,i,r){e.declarations&&e.declarations.length>0&&e.declarations.forEach(n=>{if(n.init&&n.init.type==="ArrowFunctionExpression"&&n.init.start!==0){const a={type:"FunctionDeclaration",id:n.id,params:n.init.params,body:n.init.body.type==="BlockStatement"?n.init.body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:n.init.body}]},async:n.init.async,generator:!1};Object.assign(e,a)}}),e.body&&e.body.body&&e.body.body.forEach(n=>r(n,i))}})}function zn(t,e){gr(t,{VariableDeclaration(i){i.declarations.forEach(r=>{const n=r.init&&r.init.type==="MemberExpression"&&r.init.object&&(r.init.object.name==="context"||r.init.object.name===$||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===$||r.init.object.object.name==="context2");(n||a)&&(r.id.name&&e.addContextBoundVar(r.id.name),r.id.properties&&r.id.properties.forEach(s=>{s.key.name&&e.addContextBoundVar(s.key.name)}))})}})}function Gn(t,e,i=!1){t.params.forEach(r=>{r.type==="Identifier"&&i&&e.addContextBoundVar(r.name,i)})}function Yn(t,e){let i;return Vn(t,{FunctionDeclaration(r){r.id&&r.id.name&&(e.addReservedName(r.id.name),e.addUserFunction(r.id.name))},ArrowFunctionExpression(r){const n=r.start===0;n&&r.params&&r.params.length>0&&(i=r.params[0].name,r.params[0].name=$),Gn(r,e,n)},VariableDeclaration(r,n){const a=n.length>1?n[n.length-2]:null,s=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(c=>{c.key&&c.key.type==="Identifier"&&e.addReservedName(c.key.name)});else if(o.id.type==="ArrayPattern"){if(o.id.elements?.forEach(p=>{p&&p.type==="Identifier"&&e.addReservedName(p.name)}),s)return;const c=e.generateTempVar(),l={type:"VariableDeclaration",kind:r.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:c},init:o.init}]};o.id.elements?.forEach(p=>{p.type==="Identifier"&&e.addArrayPatternElement(p.name)});const u=o.id.elements.map((p,h)=>({type:"VariableDeclaration",kind:r.kind,declarations:[{type:"VariableDeclarator",id:p,init:{type:"MemberExpression",object:{type:"Identifier",name:c},property:{type:"Literal",value:h},computed:!0}}]}));Object.assign(r,{type:"BlockStatement",body:[l,...u]})}})},ForStatement(r){}}),i}const Lt={type:"Identifier",name:"undefined"};function X(t,e){const[i,r]=e.getVariable(t);if(i.match(/^fn\d+_/)&&t!=="$$"){const[n]=e.getVariable("$$");if(n)return b.createLocalContextVariableReference(r,i)}return b.createContextVariableReference(r,i)}function br(t,e){const i=X(t,e);return b.createGetCall(i,0)}function Ve(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=b.createIdentifier(t.object.name);i._skipTransformation=!0;const r=b.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0;return}if(!e.isContextBound(t.object.name)){const i=X(t.object.name,e),r=b.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0}}return}e.isContextBound(t.property.name)||(t.property=X(t.property.name,e),t.property=b.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=b.createIdentifier(t.object.name);i._skipTransformation=!0;const r=b.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0;return}if(e.isContextBound(t.object.name)||(t.object=X(t.object.name,e)),t.property.type==="MemberExpression"){const i=t.property;i._indexTransformed||(Ve(i,e),i._indexTransformed=!0)}}}function _e(t,e){const i=b.createGetCall(b.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 te(t,e){if(!t._skipTransformation&&t.name!==$){if(Be.includes(t.name)&&e.isContextBound(t.name)){const h=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee===t,d=t.parent&&t.parent.type==="MemberExpression"&&t.parent.object===t&&!t.parent.computed;if(!h&&!d){const g={type:"MemberExpression",object:{type:"Identifier",name:t.name},property:{type:"Identifier",name:"__value"},computed:!1},y=b.createGetCall(g,0);Object.assign(t,y),delete t.name;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 h=t.parent.callee;if(h.type==="MemberExpression"&&h.object&&h.object.name===$&&["get","set","init","param","call"].includes(h.property.name)){const d=t.parent.arguments.indexOf(t);h.property.name==="call"?d>=2&&(i=!0):d===0&&(i=!0)}else{const d=h.type==="MemberExpression"&&h.object&&h.object.type==="Identifier"&&ot.includes(h.object.name);h.type==="MemberExpression"&&!d?i=!1:i=!0}}const r=t.parent&&t.parent.type==="MemberExpression"&&t.parent.object===t&&e.isContextBound(t.name),n=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,s=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||n||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===$&&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 h=X(t.name,e);Object.assign(t,h);return}const c=e.isContextBound(t.name)&&!e.isRootParam(t.name);if(c){const h=t.parent&&t.parent.type==="CallExpression"&&t.parent.arguments.includes(t),d=t.parent&&t.parent.type==="SwitchStatement"&&t.parent.discriminant===t,g=t.parent&&t.parent.type==="SwitchCase"&&t.parent.test===t;if(!h&&!d&&!g)return}if(e.isLocalSeriesVar(t.name)){if(!s){const h=b.createIdentifier(t.name),d=b.createGetCall(h,0);Object.assign(t,d)}return}const[l,u]=e.getVariable(t.name);let p;if(c)p=b.createIdentifier(t.name);else{if(l===t.name&&!e.isContextBound(t.name))return;p=X(t.name,e)}if(s)Object.assign(t,p);else{const h=b.createGetCall(p,0);Object.assign(t,h)}}}function pe(t,e,i){if(t.object&&t.object.type==="Identifier"&&t.object.name==="Math")return;if(t.object&&t.object.type==="Identifier"&&ot.includes(t.object.name)&&i.isContextBound(t.object.name)&&!t.computed){const c=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee===t,l=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(!c&&!l){const u={type:"CallExpression",callee:{type:"MemberExpression",object:t.object,property:t.property,computed:!1},arguments:[],_transformed:!1};t.start!==void 0&&(u.start=t.start),t.end!==void 0&&(u.end=t.end),Object.assign(t,u);return}}const r=i.getCurrentScopeType()=="if",n=i.getCurrentScopeType()=="els",a=i.getCurrentScopeType()=="for";if(!r&&!n&&!a&&t.object&&t.object.type==="Identifier"&&i.isContextBound(t.object.name)&&!i.isRootParam(t.object.name)&&!t.computed)return;t._indexTransformed||(Ve(t,i),t._indexTransformed=!0);const s=t.object&&t.object.type==="MemberExpression"&&t.object.object&&t.object.object.type==="MemberExpression"&&t.object.object.object&&(t.object.object.object.name===$||t.object.object.object.name==="$$"),o=t.object&&t.object.type==="Identifier"&&i.isContextBound(t.object.name);if(t.computed&&(s||o)){if(t.parent&&t.parent.type==="AssignmentExpression"&&t.parent.left===t)return;t.object.type==="Identifier"&&Be.includes(t.object.name)&&i.isContextBound(t.object.name)&&(t.object={type:"MemberExpression",object:{type:"Identifier",name:t.object.name},property:{type:"Identifier",name:"__value"},computed:!1});const c=b.createGetCall(t.object,t.property);t.start&&(c.start=t.start),t.end&&(c.end=t.end),Object.assign(t,c),delete t.object,delete t.property,delete t.computed}}function rt(t,e){if(t.type==="Identifier"){if(Be.includes(t.name)&&e.isContextBound(t.name)){const a=t.name;return Object.assign(t,{type:"MemberExpression",object:{type:"Identifier",name:a},property:{type:"Identifier",name:"__value"},computed:!1}),delete t.name,t}if(e.isLoopVariable(t.name))return t;if(e.isRootParam(t.name)){const[a,s]=e.getVariable(t.name);return b.createContextVariableReference(s,a)}if(e.isContextBound(t.name))return t;const[i,r]=e.getVariable(t.name),n=i!==t.name;return e.isLocalSeriesVar(t.name)&&!n?t:n?X(t.name,e):i===t.name&&!e.isContextBound(t.name)?t:X(t.name,e)}return t}function Me(t,e,i=""){switch(t.type){case"BinaryExpression":return Bt(t,e,i);case"LogicalExpression":return Ft(t,e,i);case"MemberExpression":return{type:"MemberExpression",object:t.object.type==="Identifier"?rt(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=rt(t,e);return r.type==="Identifier"&&(r.name==="NaN"||r.name==="undefined"||r.name==="Infinity"||r.name==="null"||r.name==="Math")?r:b.createGetCall(r,0)}case"UnaryExpression":return jt(t,e,i);case"ConditionalExpression":{const r=Me(t.test,e,i),n=Me(t.consequent,e,i),a=Me(t.alternate,e,i);return{type:"ConditionalExpression",test:r,consequent:n,alternate:a,start:t.start,end:t.end}}}return t}function Bt(t,e,i){const r=Me(t.left,e,i),n=Me(t.right,e,i),a={type:"BinaryExpression",operator:t.operator,left:r,right:n,start:t.start,end:t.end};return z(a,e,{CallExpression(s,o){s._transformed||ae(s,o)},MemberExpression(s){pe(s,"",e)}}),a}function Ft(t,e,i){const r=Me(t.left,e,i),n=Me(t.right,e,i),a={type:"LogicalExpression",operator:t.operator,left:r,right:n,start:t.start,end:t.end};return z(a,e,{CallExpression(s,o){s._transformed||ae(s,o)}}),a}function pi(t,e,i){z(t,{parent:t,inNamespaceCall:!1},{Identifier(s,o,c){if(s.name=="NaN")return;if(Be.includes(s.name)&&e.isContextBound(s.name)){const u={type:"MemberExpression",object:{type:"Identifier",name:s.name},property:{type:"Identifier",name:"__value"},computed:!1},p=b.createGetCall(u,0);Object.assign(s,p),delete s.name;return}s.parent=o.parent,te(s,e);const l=s.parent&&s.parent.type==="BinaryExpression";(s.parent&&s.parent.type==="ConditionalExpression"||l)&&(s.type==="MemberExpression"?Ve(s,e):s.type==="Identifier"&&(s.parent&&s.parent.type==="CallExpression"&&s.parent.callee&&s.parent.callee.object&&s.parent.callee.object.name===$&&s.parent.callee.property.name==="get"||_e(s)))},MemberExpression(s,o,c){Ve(s,e),s.object&&c(s.object,{parent:s,inNamespaceCall:o.inNamespaceCall})},ConditionalExpression(s,o,c){const l={...o,parent:s};s.test&&c(s.test,l),s.consequent&&c(s.consequent,l),s.alternate&&c(s.alternate,l)},BinaryExpression(s,o,c){const l={...o,parent:s};c(s.left,l),c(s.right,l)},LogicalExpression(s,o,c){const l={...o,parent:s};c(s.left,l),c(s.right,l)},UnaryExpression(s,o,c){const l={...o,parent:s};c(s.argument,l)},CallExpression(s,o,c){const l=s.callee&&s.callee.type==="MemberExpression"&&s.callee.object&&s.callee.object.type==="Identifier"&&e.isContextBound(s.callee.object.name);ae(s,e),s.arguments.forEach(u=>c(u,{parent:s,inNamespaceCall:l||o.inNamespaceCall}))}});const r=b.createMemberExpression(b.createIdentifier(i),b.createIdentifier("param")),n=e.generateParamId(),a={type:"CallExpression",callee:r,arguments:[t,Lt,{type:"Identifier",name:`'${n}'`}],_transformed:!0,_isParamCall:!0};if(!e.shouldSuppressHoisting()){const s=n;e.addLocalSeriesVar(s);const o=b.createVariableDeclaration(s,a);return e.addHoistedStatement(o),b.createIdentifier(s)}return a}function jt(t,e,i){const r=Me(t.argument,e,i),n={type:"UnaryExpression",operator:t.operator,prefix:t.prefix,argument:r,start:t.start,end:t.end};return z(n,e,{CallExpression(a,s){a._transformed||ae(a,s)},MemberExpression(a){pe(a,"",e)}}),n}function $e(t,e,i){switch(t?.type){case"BinaryExpression":t=Bt(t,i,e);break;case"LogicalExpression":t=Ft(t,i,e);break;case"ConditionalExpression":return pi(t,i,e);case"UnaryExpression":t=jt(t,i,e);break;case"ArrayExpression":t.elements=t.elements.map(l=>l.type==="Identifier"?i.isContextBound(l.name)&&!i.isRootParam(l.name)?l:br(l.name,i):l);break}const r=t.type==="MemberExpression"&&t.computed&&t.property,n=t.type==="MemberExpression"&&!t.computed;if(r){t.object.type==="CallExpression"?ae(t.object,i):t.object.type==="MemberExpression"?pe(t.object,"",i):t.object.type==="BinaryExpression"?t.object=Bt(t.object,i,e):t.object.type==="LogicalExpression"?t.object=Ft(t.object,i,e):t.object.type==="ConditionalExpression"?t.object=pi(t.object,i,e):t.object.type==="UnaryExpression"&&(t.object=jt(t.object,i,e));const l=t.object.type==="Identifier"&&i.isContextBound(t.object.name)&&!i.isRootParam(t.object.name)?t.object:rt(t.object,i),u=t.property.type==="Identifier"&&!i.isContextBound(t.property.name)&&!i.isLoopVariable(t.property.name)?b.createGetCall(rt(t.property,i),0):t.property,p=b.createMemberExpression(b.createIdentifier(e),b.createIdentifier("param")),h=i.generateParamId(),d={type:"CallExpression",callee:p,arguments:[l,u,{type:"Identifier",name:`'${h}'`}],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const g=h;i.addLocalSeriesVar(g);const y=b.createVariableDeclaration(g,d);return i.addHoistedStatement(y),b.createIdentifier(g)}return d}if(n)if(t.object.type==="Identifier"){const l=t.object.name,[u,p]=i.getVariable(l);if(u!==l&&!i.isLoopVariable(l)){const h=b.createContextVariableReference(p,u),d=b.createGetCall(h,0);t.object=d}}else t.object.type==="MemberExpression"&&$e(t.object,e,i);if(t.type==="ObjectExpression"&&(t.properties=t.properties.map(l=>l.value.name?i.isContextBound(l.value.name)&&!i.isRootParam(l.value.name)?{type:"Property",key:{type:"Identifier",name:l.key.name},value:b.createIdentifier(l.value.name),kind:"init",method:!1,shorthand:!1,computed:!1}:{type:"Property",key:{type:"Identifier",name:l.key.name},value:X(l.value.name,i),kind:"init",method:!1,shorthand:!1,computed:!1}:(l.value.type!=="Literal"&&(l.value=$e(l.value,e,i)),l))),t.type==="Identifier"){if(Be.includes(t.name)&&i.isContextBound(t.name)){const l=t.name;Object.assign(t,{type:"MemberExpression",object:{type:"Identifier",name:l},property:{type:"Identifier",name:"__value"},computed:!1}),delete t.name}else if(i.isContextBound(t.name)&&!i.isRootParam(t.name)){const l=b.createMemberExpression(b.createIdentifier(e),b.createIdentifier("param")),u=i.generateParamId(),p={type:"CallExpression",callee:l,arguments:[t,Lt,{type:"Identifier",name:`'${u}'`}],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const h=u;i.addLocalSeriesVar(h);const d=b.createVariableDeclaration(h,p);return i.addHoistedStatement(d),b.createIdentifier(h)}return p}}t?.type==="CallExpression"&&ae(t,i);const a=b.createMemberExpression(b.createIdentifier(e),b.createIdentifier("param")),s=t.type==="Identifier"?rt(t,i):t,o=i.generateParamId(),c={type:"CallExpression",callee:a,arguments:[s,Lt,{type:"Identifier",name:`'${o}'`}],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const l=o;i.addLocalSeriesVar(l);const u=b.createVariableDeclaration(l,c);return i.addHoistedStatement(u),b.createIdentifier(l)}return c}function ae(t,e,i){if(t._transformed)return;t.callee&&t.callee.name,t.callee&&t.callee.type==="Identifier"&&(ot.includes(t.callee.name)||Be.includes(t.callee.name))&&e.isContextBound(t.callee.name)&&(t.callee=b.createMemberExpression(t.callee,b.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===$&&["get","init","param"].includes(t.callee.property.name))return;const n=t.callee.object.name,a=[];if(t.arguments.forEach(u=>{if(u._isParamCall){a.push(u);return}a.push($e(u,n,e))}),t.arguments=a,["plot","hline","fill"].includes(n)){const u=e.getNextPlotCallId();t.arguments.push({type:"ObjectExpression",properties:[{type:"Property",key:{type:"Identifier",name:"__callsiteId"},value:u,kind:"init",computed:!1,shorthand:!1}]})}if(n==="ta")if(e.getCurrentScopeType()==="fn"){const u=e.getNextTACallId(),[p]=e.getVariable("$$");let h;p?h=b.createMemberExpression(b.createLocalContextIdentifier(),b.createIdentifier("id")):h=b.createLiteral("");const d={type:"BinaryExpression",operator:"+",left:h,right:u};t.arguments.push(d)}else t.arguments.push(e.getNextTACallId());const s=t.callee.property.name,o=`${n}.${s}`,c=Bn.includes(o),l=t._insideAwait===!0;if(c&&!l){const u=Object.assign({},t),p=b.createAwaitExpression(u);Object.assign(t,p)}if(!e.shouldSuppressHoisting()){const u=e.generateTempVar();e.addLocalSeriesVar(u);const p=t._insideAwait===!0;let h=Object.assign({},t);p&&(h=b.createAwaitExpression(h));const d=b.createVariableDeclaration(u,h);e.addHoistedStatement(d);const g=b.createIdentifier(u);Object.assign(t,g),t._wasHoisted=!0,t._wasInsideAwait=p;return}t._transformed=!0}else if(t.callee&&t.callee.type==="Identifier"){if(t.arguments=t.arguments.map(n=>n._isParamCall?n:$e(n,$,e)),!e.isContextBound(t.callee.name)){const n=e.getNextUserCallId(),a=b.createMemberExpression(b.createContextIdentifier(),b.createIdentifier("call")),s=[t.callee,n,...t.arguments];t.callee=a,t.arguments=s}t._transformed=!0}if(!r&&t.callee&&t.callee.type==="MemberExpression"){const n=t.callee.property.name;if(e.isUserFunction(n)&&!e.isContextBound(n)){const a=t.callee.object;t.callee.property;const s=t.arguments.map(p=>p._isParamCall?p:$e(p,$,e));let o=a;a.type==="Identifier"?o=$e(a,$,e):a.type==="CallExpression"&&(ae(a,e),o=$e(a,$,e));const c=b.createMemberExpression(b.createContextIdentifier(),b.createIdentifier("call")),l=e.getNextUserCallId(),u=[b.createIdentifier(n),l,o,...s];t.callee=c,t.arguments=u,t._transformed=!0;return}t.callee.object.type==="Identifier"&&te(t.callee.object,e)}t.arguments.forEach(n=>{z(n,{parent:t},{Identifier(a,s,o){a.parent=s.parent,te(a,e);const c=a.parent&&a.parent.type==="BinaryExpression";(a.parent&&a.parent.type==="ConditionalExpression"||c)&&(a.type==="MemberExpression"?Ve(a,e):a.type==="Identifier"&&(a.parent&&a.parent.type==="CallExpression"&&a.parent.callee&&a.parent.callee.object&&a.parent.callee.object.name===$&&a.parent.callee.property.name==="get"||_e(a)))},BinaryExpression(a,s,o){const c={...s,parent:a};o(a.left,c),o(a.right,c)},LogicalExpression(a,s,o){const c={...s,parent:a};o(a.left,c),o(a.right,c)},UnaryExpression(a,s,o){const c={...s,parent:a};o(a.argument,c)},CallExpression(a,s,o){a._transformed||ae(a,e)},MemberExpression(a,s,o){pe(a,"",e),a.object&&o(a.object,{parent:a})}})})}function _r(t,e){let i=null;if(t.left.type==="Identifier")i=X(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,[n,a]=e.getVariable(r),s=n!==r,o=e.isContextBound(r);(s||o)&&!e.isLoopVariable(r)&&t.left.property.type==="Literal"&&t.left.property.value===0&&(i=X(r,e))}}else if(t.left.type==="MemberExpression"&&!t.left.computed&&t.left.object.type==="Identifier"){const r=t.left.object.name,[n,a]=e.getVariable(r);if(n!==r&&!e.isLoopVariable(r)){const s=X(r,e),o=b.createGetCall(s,0);t.left.object=o}}if(z(t.right,{parent:t.right,inNamespaceCall:!1},{Identifier(r,n,a){if(Be.includes(r.name)&&e.isContextBound(r.name)){const g={type:"MemberExpression",object:{type:"Identifier",name:r.name},property:{type:"Identifier",name:"__value"},computed:!1},y=b.createGetCall(g,0);Object.assign(r,y),delete r.name;return}r.parent=n.parent,te(r,e);const s=r.parent&&r.parent.type==="BinaryExpression",o=r.parent&&r.parent.type==="ConditionalExpression",c=e.isContextBound(r.name)&&!e.isRootParam(r.name),l=r.parent&&r.parent.type==="MemberExpression"&&r.parent.computed&&r.parent.object===r,u=r.parent&&r.parent._isParamCall,p=r.parent&&r.parent.type==="MemberExpression",h=r.name==="NaN",d=r.parent&&r.parent.type==="CallExpression"&&r.parent.callee&&r.parent.callee.object&&r.parent.callee.object.name===$&&r.parent.callee.property.name==="get";(c||o||s)&&(r.type==="MemberExpression"?Ve(r,e):r.type==="Identifier"&&!p&&!l&&!u&&!h&&!d&&_e(r))},MemberExpression(r,n,a){pe(r,"",e),r.type==="CallExpression"?r.arguments.forEach(s=>a(s,{parent:r,inNamespaceCall:n.inNamespaceCall})):r.object&&a(r.object,{parent:r,inNamespaceCall:n.inNamespaceCall})},CallExpression(r,n,a){const s=r.callee&&r.callee.type==="MemberExpression"&&r.callee.object&&r.callee.object.type==="Identifier"&&e.isContextBound(r.callee.object.name);ae(r,e),r.type==="CallExpression"&&(r.callee.type==="MemberExpression"&&a(r.callee,{parent:r,inNamespaceCall:s||n.inNamespaceCall}),r.arguments.forEach(o=>a(o,{parent:r,inNamespaceCall:s||n.inNamespaceCall})))}}),i){let r=t.right;if(t.operator!=="="){const a=t.operator.replace("=",""),s=b.createGetCall(i,0);r={type:"BinaryExpression",operator:a,left:s,right:t.right,start:t.start,end:t.end}}const n=b.createSetCall(i,r);t.start&&(n.start=t.start),t.end&&(n.end=t.end),Object.assign(t,n)}}function Sr(t,e){t._skipTransformation||t.declarations.forEach(i=>{if(i.init&&i.init.type==="Identifier"&&Be.includes(i.init.name)&&e.isContextBound(i.init.name)){const h=i.init.name;Object.assign(i.init,{type:"MemberExpression",object:{type:"Identifier",name:h},property:{type:"Identifier",name:"__value"},computed:!1}),delete i.init.name}const r=i.init&&i.init.type==="MemberExpression"&&i.init.object&&(i.init.object.name==="context"||i.init.object.name===$||i.init.object.name==="context2"),n=i.init&&i.init.type==="MemberExpression"&&i.init.object?.object&&(i.init.object.object.name==="context"||i.init.object.object.name===$||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(h=>{h.key.name&&e.addContextBoundVar(h.key.name)}),i.init.object.name=$;return}if(n){i.id.name&&e.addContextBoundVar(i.id.name),i.id.properties&&i.id.properties.forEach(h=>{h.key.name&&e.addContextBoundVar(h.key.name)}),i.init.object.object.name=$;return}e.addVariable(i.id.name,t.kind);const s=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)?ae(i.init,e):z(i.init,{parent:i.init},{Identifier(h,d){h.parent=d.parent,te(h,e);const g=h.parent&&h.parent.type==="BinaryExpression",y=h.parent&&h.parent.type==="UnaryExpression",v=h.parent&&h.parent.type==="ConditionalExpression",w=h.parent&&h.parent.type==="CallExpression"&&h.parent.callee&&h.parent.callee.object&&h.parent.callee.object.name===$&&h.parent.callee.property.name==="get";h.type==="Identifier"&&(g||y||v)&&!w&&_e(h)},CallExpression(h,d,g){h.callee.type==="Identifier"&&(h.callee.parent=h),h.arguments.forEach(y=>{y.type==="Identifier"&&(y.parent=h)}),(h.callee.type==="ArrowFunctionExpression"||h.callee.type==="FunctionExpression")&&g(h.callee,{parent:h}),ae(h,e),h.type==="CallExpression"&&(h.callee.type==="MemberExpression"&&g(h.callee,{parent:h}),h.arguments.forEach(y=>g(y,{parent:h})))},BinaryExpression(h,d,g){h.left.type==="Identifier"&&(h.left.parent=h),h.right.type==="Identifier"&&(h.right.parent=h),g(h.left,{parent:h}),g(h.right,{parent:h})},MemberExpression(h,d,g){h.object&&h.object.type==="Identifier"&&(h.object.parent=h),h.property&&h.property.type==="Identifier"&&(h.property.parent=h),pe(h,"",e),h.type==="CallExpression"?h.arguments.forEach(y=>g(y,{parent:h})):h.object&&g(h.object,{parent:h})},AwaitExpression(h,d,g){h.argument&&(h.argument._insideAwait=!0,g(h.argument,{parent:h}),h.argument.type==="Identifier"&&h.argument._wasInsideAwait&&Object.assign(h,h.argument))},ArrowFunctionExpression(h,d,g){if(h.body)if(h.body.type==="BlockStatement"){const y=[];h.body.body.forEach(v=>{e.enterHoistingScope(),g(v,{parent:h.body});const w=e.exitHoistingScope();y.push(...w),y.push(v)}),h.body.body=y}else g(h.body,{parent:h})},FunctionExpression(h,d,g){if(h.body&&h.body.type==="BlockStatement"){const y=[];h.body.body.forEach(v=>{e.enterHoistingScope(),g(v,{parent:h.body});const w=e.exitHoistingScope();y.push(...w),y.push(v)}),h.body.body=y}},SwitchStatement(h,d,g){h.discriminant&&(h.discriminant.parent=h,g(h.discriminant,{parent:h})),h.cases&&h.cases.forEach(y=>{y.parent=h,g(y,{parent:h})})},SwitchCase(h,d,g){if(h.test&&(h.test.parent=h,g(h.test,{parent:h})),h.consequent){const y=[];h.consequent.forEach(v=>{e.enterHoistingScope(),v.parent=h,g(v,{parent:h});const w=e.exitHoistingScope();y.push(...w),y.push(v)}),h.consequent=y}}}));const c=X(i.id.name,e),l=!o&&i.init&&i.init.type==="MemberExpression"&&i.init.computed&&i.init.property&&(i.init.property.type==="Literal"||i.init.property.type==="MemberExpression");if(i.init?.property?.type==="MemberExpression"&&(i.init.property._indexTransformed||(Ve(i.init.property,e),i.init.property._indexTransformed=!0)),s==="var"){const h=e.getCurrentHoistingScope();if(h){for(const d of h)if(d.type==="VariableDeclaration")for(const g of d.declarations){if(!g.init||g.init.type!=="CallExpression")continue;const y=g.init.callee;if(y?.type!=="MemberExpression")continue;let v;const w=y.property?.name;if(y.object?.type==="Identifier"?v=y.object.name:y.object?.type==="MemberExpression"&&y.object.property?.name&&(v=y.object.property.name),v&&w){const _=`${v}.${w}`;Fn.includes(_)&&(g.init={type:"ArrowFunctionExpression",params:[],body:g.init,expression:!0,async:!1})}}}}let u;i.init?a||o?u=i.init:s==="var"?u=b.createInitVarCall(c,i.init):u=b.createInitCall(c,l?i.init.object:i.init,l?i.init.property:void 0):u=b.createIdentifier("undefined");const p=b.createExpressionStatement(b.createAssignmentExpression(c,u));if(o){const h=i.init.object.name,d=X(h,e),g=i.init.property.value,y={type:"MemberExpression",object:b.createGetCall(d,0),property:{type:"Literal",value:g},computed:!0};p.expression.right=b.createCallExpression(b.createMemberExpression(b.createContextIdentifier(),b.createIdentifier("init")),[c,y])}a&&(e.pushScope("fn"),z(i.init.body,e,{IfStatement(h,d,g){d.pushScope("if"),g(h.consequent,d),h.alternate&&(d.pushScope("els"),g(h.alternate,d),d.popScope()),d.popScope()},VariableDeclaration(h,d){Sr(h,d)},Identifier(h,d){te(h,d)},AssignmentExpression(h,d){_r(h,d)},SwitchStatement(h,d,g){h.discriminant.parent=h,g(h.discriminant,d),h.cases.forEach(y=>{y.parent=h,g(y,d)})},SwitchCase(h,d,g){h.test&&(h.test.parent=h,g(h.test,d));const y=[];h.consequent.forEach(v=>{d.enterHoistingScope(),g(v,d);const w=d.exitHoistingScope();y.push(...w),y.push(v)}),h.consequent=y},BlockStatement(h,d,g){const y=[];h.body.forEach(v=>{d.enterHoistingScope(),g(v,d);const w=d.exitHoistingScope();y.push(...w),y.push(v)}),h.body=y}}),e.popScope()),Object.assign(t,p)})}function Qn(t,e,i){if(e.setSuppressHoisting(!0),t.init&&t.init.type==="VariableDeclaration"){const r=t.init.declarations[0],n=r.id.name;e.addLoopVariable(n,n),t.init={type:"VariableDeclaration",kind:t.init.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:n},init:r.init}]},r.init&&z(r.init,e,{Identifier(a,s){e.isLoopVariable(a.name)||(e.pushScope("for"),te(a,s),e.popScope())},MemberExpression(a){e.pushScope("for"),pe(a,"",e),e.popScope()},CallExpression(a,s,o){a.callee.parent=a,o(a.callee,s);for(const c of a.arguments)o(c,s)}})}t.test&&z(t.test,e,{Identifier(r,n){!e.isLoopVariable(r.name)&&!r.computed&&(e.pushScope("for"),te(r,n),r.type==="Identifier"&&(r.computed=!0,_e(r)),e.popScope())},MemberExpression(r){e.pushScope("for"),pe(r,"",e),e.popScope()},CallExpression(r,n,a){r.callee.parent=r,a(r.callee,n);for(const s of r.arguments)a(s,n)}}),t.update&&z(t.update,e,{Identifier(r,n){e.isLoopVariable(r.name)||(e.pushScope("for"),te(r,n),e.popScope())}}),e.setSuppressHoisting(!1),e.pushScope("for"),i(t.body,e),e.popScope()}function Xn(t,e){z(t,e,{MemberExpression(i){pe(i,"",e)},CallExpression(i,r){ae(i,r)},Identifier(i,r){te(i,r);const n=e.getCurrentScopeType()==="if";e.isContextBound(i.name)&&!e.isRootParam(i.name)&&n&&_e(i)}})}function Zn(t,e,i){t.test&&(e.pushScope("if"),Xn(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 Jn(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)?b.createGetCall(r,0):br(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)?b.createGetCall(r,0):(r.computed&&r.object.type==="Identifier"&&e.isContextBound(r.object.name)&&!e.isRootParam(r.object.name)||pe(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:b.createIdentifier(r.key.name),value:X(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=X(r.value.name,e))),r)):t.argument.type==="Identifier"&&(te(t.argument,e),t.argument.type==="Identifier"&&_e(t.argument)),i==="fn")){t.argument.type==="Identifier"&&e.isContextBound(t.argument.name)&&!e.isRootParam(t.argument.name)?t.argument=b.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||(Ve(t.argument,e),t.argument._indexTransformed=!0)):(t.argument.type==="BinaryExpression"||t.argument.type==="LogicalExpression"||t.argument.type==="ConditionalExpression"||t.argument.type==="CallExpression")&&z(t.argument,e,{Identifier(n,a){te(n,a),n.type==="Identifier"&&!n._arrayAccessed&&(_e(n),n._arrayAccessed=!0)},MemberExpression(n){pe(n,"",e)},CallExpression(n,a,s){(n.callee.type==="ArrowFunctionExpression"||n.callee.type==="FunctionExpression")&&s(n.callee,a),ae(n,a),n.type==="CallExpression"&&n.arguments.forEach(o=>s(o,a))},BinaryExpression(n,a,s){s(n.left,a),s(n.right,a)},ArrowFunctionExpression(n,a,s){if(n.body)if(n.body.type==="BlockStatement"){const o=[];n.body.body.forEach(c=>{e.enterHoistingScope(),s(c,a);const l=e.exitHoistingScope();o.push(...l),o.push(c)}),n.body.body=o}else s(n.body,a)},FunctionExpression(n,a,s){if(n.body&&n.body.type==="BlockStatement"){const o=[];n.body.body.forEach(c=>{e.enterHoistingScope(),s(c,a);const l=e.exitHoistingScope();o.push(...l),o.push(c)}),n.body.body=o}},SwitchStatement(n,a,s){n.discriminant.parent=n,s(n.discriminant,a),n.cases.forEach(o=>{o.parent=n,s(o,a)})},SwitchCase(n,a,s){n.test&&(n.test.parent=n,s(n.test,a));const o=[];n.consequent.forEach(c=>{e.enterHoistingScope(),s(c,a);const l=e.exitHoistingScope();o.push(...l),o.push(c)}),n.consequent=o},BlockStatement(n,a,s){const o=[];n.body.forEach(c=>{a.enterHoistingScope(),s(c,a);const l=a.exitHoistingScope();o.push(...l),o.push(c)}),n.body=o}});const r=b.createCallExpression(b.createMemberExpression(b.createContextIdentifier(),b.createIdentifier("precision")),[t.argument]);t.argument=r}}function es(t,e,i){const r=b.createVariableDeclaration("$$",b.createCallExpression(b.createMemberExpression(b.createContextIdentifier(),b.createIdentifier("peekCtx")),[]));r._skipTransformation=!0,e.addLoopVariable("$$","$$"),t.body&&t.body.type==="BlockStatement"&&(t.body.body.unshift(r),e.pushScope("fn"),t.params.forEach(n=>{n.type==="Identifier"&&e.addLocalSeriesVar(n.name)}),i(t.body,e),t.params.forEach(n=>{n.type==="Identifier"&&e.removeLocalSeriesVar(n.name)}),e.popScope())}function ts(t){const e={...E,LineComment:()=>{}};gr(t,{BinaryExpression(i){if(i.operator==="=="||i.operator==="==="){const r=i.left,n=i.right,a=b.createMathEqCall(r,n);a._transformed=!0,Object.assign(i,a)}}},e)}function is(t,e,i,r={debug:!1,ln:!1},n=[]){const a=s=>{if(!r.debug||!s.loc||!n.length)return null;const o=s.loc.start.line-1;if(o>=0&&o<n.length){const c=n[o].trim();if(c)return{type:"LineComment",value:`${r.ln?` [Line ${s.loc.start.line}]`:""} ${c}`}}return null};z(t,e,{Program(s,o,c){const l=[];s.body.forEach(u=>{o.enterHoistingScope(),c(u,o);const p=o.exitHoistingScope(),h=a(u);h&&l.push(h),l.push(...p),l.push(u)}),s.body=l},BlockStatement(s,o,c){const l=[];s.body.forEach(u=>{o.enterHoistingScope(),c(u,o);const p=o.exitHoistingScope(),h=a(u);h&&l.push(h),l.push(...p),l.push(u)}),s.body=l},ReturnStatement(s,o){Jn(s,o)},VariableDeclaration(s,o){Sr(s,o)},Identifier(s,o){te(s,o)},CallExpression(s,o,c){s.callee&&(s.callee.type==="ArrowFunctionExpression"||s.callee.type==="FunctionExpression")&&c(s.callee,o),ae(s,o)},ArrowFunctionExpression(s,o,c){s.body&&c(s.body,o)},FunctionExpression(s,o,c){s.body&&c(s.body,o)},ForOfStatement(s,o,c){if(s.left&&s.left.type==="VariableDeclaration"){s.left._skipTransformation=!0;const l=s.left.declarations[0];l.id.type==="Identifier"?o.addLoopVariable(l.id.name,l.id.name):l.id.type==="ArrayPattern"&&l.id.elements.forEach(u=>{u.type==="Identifier"&&o.addLoopVariable(u.name,u.name)})}if(s.right&&s.right.type==="Identifier"){te(s.right,o),_e(s.right);const l={...s.right};let u=b.createMemberExpression(l,b.createIdentifier("array"),!1);s.left&&s.left.type==="VariableDeclaration"&&s.left.declarations[0].id.type==="ArrayPattern"&&(u=b.createCallExpression(b.createMemberExpression(u,b.createIdentifier("entries"),!1),[])),Object.assign(s.right,u)}else s.right&&c(s.right,o);s.body&&c(s.body,o)},ForInStatement(s,o,c){s.left&&s.left.type==="VariableDeclaration"&&(s.left._skipTransformation=!0),s.right&&s.right.type==="Identifier"?(te(s.right,o),_e(s.right)):s.right&&c(s.right,o),s.body&&c(s.body,o)},MemberExpression(s,o){pe(s,i,o)},AssignmentExpression(s,o){_r(s,o)},FunctionDeclaration(s,o,c){es(s,o,c)},ForStatement(s,o,c){Qn(s,o,c)},IfStatement(s,o,c){Zn(s,o,c)},SwitchStatement(s,o,c){s.discriminant.parent=s,c(s.discriminant,o),s.cases.forEach(l=>{l.parent=s,c(l,o)})},SwitchCase(s,o,c){s.test&&(s.test.parent=s,c(s.test,o));const l=[];s.consequent.forEach(u=>{o.enterHoistingScope(),c(u,o);const p=o.exitHoistingScope();l.push(...p),l.push(u)}),s.consequent=l},AwaitExpression(s,o,c){s.argument&&(s.argument._insideAwait=!0,c(s.argument,o),s.argument.type==="Identifier"&&s.argument._wasInsideAwait===!0&&(s.type="Identifier",s.name=s.argument.name,s.argument._wasHoisted&&(s._wasHoisted=s.argument._wasHoisted),delete s.argument))}})}const x={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"},rs=new Set(["if","else","for","while","switch","break","continue","var","varip","type","and","or","not","to","by","in","import","export","method","extends"]),ns=["==","!=","<=",">=",":=","+=","-=","*=","/=","%=","=>","//","and","or","not"];class ss{constructor(e,i,r,n,a=0){this.type=e,this.value=i,this.line=r,this.column=n,this.indent=a}}class as{source;pos;line;column;tokens;indentStack;atLineStart;parenDepth;bracketDepth;braceDepth;constructor(e){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===`
33
+ }`}function ss(t){G(t,null,{VariableDeclaration(e,i,r){e.declarations&&e.declarations.length>0&&e.declarations.forEach(n=>{if(n.init&&n.init.type==="ArrowFunctionExpression"&&n.init.start!==0){const a={type:"FunctionDeclaration",id:n.id,params:n.init.params,body:n.init.body.type==="BlockStatement"?n.init.body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:n.init.body}]},async:n.init.async,generator:!1};Object.assign(e,a)}}),e.body&&e.body.body&&e.body.body.forEach(n=>r(n,i))}})}function as(t,e){Er(t,{VariableDeclaration(i){i.declarations.forEach(r=>{const n=r.init&&r.init.type==="MemberExpression"&&r.init.object&&(r.init.object.name==="context"||r.init.object.name===U||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===U||r.init.object.object.name==="context2");(n||a)&&(r.id.name&&e.addContextBoundVar(r.id.name),r.id.properties&&r.id.properties.forEach(s=>{s.key.name&&e.addContextBoundVar(s.key.name)}))})}})}function os(t,e,i=!1){t.params.forEach(r=>{r.type==="Identifier"&&i&&e.addContextBoundVar(r.name,i)})}function ls(t,e){let i;return Yn(t,{FunctionDeclaration(r){r.id&&r.id.name&&(e.addReservedName(r.id.name),e.addUserFunction(r.id.name))},ArrowFunctionExpression(r){const n=r.start===0;n&&r.params&&r.params.length>0&&(i=r.params[0].name,r.params[0].name=U),os(r,e,n)},VariableDeclaration(r,n){const a=n.length>1?n[n.length-2]:null,s=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(l=>{l.key&&l.key.type==="Identifier"&&e.addReservedName(l.key.name)});else if(o.id.type==="ArrayPattern"){if(o.id.elements?.forEach(p=>{p&&p.type==="Identifier"&&e.addReservedName(p.name)}),s)return;const l=e.generateTempVar(),c={type:"VariableDeclaration",kind:r.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:l},init:o.init}]};o.id.elements?.forEach(p=>{p.type==="Identifier"&&e.addArrayPatternElement(p.name)});const u=o.id.elements.map((p,h)=>({type:"VariableDeclaration",kind:r.kind,declarations:[{type:"VariableDeclarator",id:p,init:{type:"MemberExpression",object:{type:"Identifier",name:l},property:{type:"Literal",value:h},computed:!0}}]}));Object.assign(r,{type:"BlockStatement",body:[c,...u]})}})},ForStatement(r){}}),i}const Ft={type:"Identifier",name:"undefined"};function X(t,e){const[i,r]=e.getVariable(t);if(i.match(/^fn\d+_/)&&t!=="$$"){const[n]=e.getVariable("$$");if(n)return w.createLocalContextVariableReference(r,i)}return w.createContextVariableReference(r,i)}function kr(t,e){const i=X(t,e);return w.createGetCall(i,0)}function Fe(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=w.createIdentifier(t.object.name);i._skipTransformation=!0;const r=w.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0;return}if(!e.isContextBound(t.object.name)){const i=X(t.object.name,e),r=w.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0}}return}e.isContextBound(t.property.name)||(t.property=X(t.property.name,e),t.property=w.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=w.createIdentifier(t.object.name);i._skipTransformation=!0;const r=w.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0;return}if(e.isContextBound(t.object.name)||(t.object=X(t.object.name,e)),t.property.type==="MemberExpression"){const i=t.property;i._indexTransformed||(Fe(i,e),i._indexTransformed=!0)}}}function we(t,e){const i=w.createGetCall(w.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 ee(t,e){if(!t._skipTransformation&&t.name!==U){if(We.includes(t.name)&&e.isContextBound(t.name)){const h=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee===t,f=t.parent&&t.parent.type==="MemberExpression"&&t.parent.object===t&&!t.parent.computed;if(!h&&!f){const m={type:"MemberExpression",object:{type:"Identifier",name:t.name},property:{type:"Identifier",name:"__value"},computed:!1},y=w.createGetCall(m,0);Object.assign(t,y),delete t.name;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 h=t.parent.callee;if(h.type==="MemberExpression"&&h.object&&h.object.name===U&&["get","set","init","param","call"].includes(h.property.name)){const f=t.parent.arguments.indexOf(t);h.property.name==="call"?f>=2&&(i=!0):f===0&&(i=!0)}else{const f=h.type==="MemberExpression"&&h.object&&h.object.type==="Identifier"&&it.includes(h.object.name);h.type==="MemberExpression"&&!f?i=!1:i=!0}}const r=t.parent&&t.parent.type==="MemberExpression"&&t.parent.object===t&&e.isContextBound(t.name),n=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,s=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||n||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===U&&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 h=X(t.name,e);Object.assign(t,h);return}const l=e.isContextBound(t.name)&&!e.isRootParam(t.name);if(l){const h=t.parent&&t.parent.type==="CallExpression"&&t.parent.arguments.includes(t),f=t.parent&&t.parent.type==="SwitchStatement"&&t.parent.discriminant===t,m=t.parent&&t.parent.type==="SwitchCase"&&t.parent.test===t;if(!h&&!f&&!m)return}if(e.isLocalSeriesVar(t.name)){if(!s){const h=w.createIdentifier(t.name),f=w.createGetCall(h,0);Object.assign(t,f)}return}const[c,u]=e.getVariable(t.name);let p;if(l)p=w.createIdentifier(t.name);else{if(c===t.name&&!e.isContextBound(t.name))return;p=X(t.name,e)}if(s)Object.assign(t,p);else{const h=w.createGetCall(p,0);Object.assign(t,h)}}}function fe(t,e,i){if(t.object&&t.object.type==="Identifier"&&t.object.name==="Math")return;if(t.object&&t.object.type==="Identifier"&&it.includes(t.object.name)&&i.isContextBound(t.object.name)&&!t.computed){const l=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(!l&&!c){const u={type:"CallExpression",callee:{type:"MemberExpression",object:t.object,property:t.property,computed:!1},arguments:[],_transformed:!1};t.start!==void 0&&(u.start=t.start),t.end!==void 0&&(u.end=t.end),Object.assign(t,u);return}}const r=i.getCurrentScopeType()=="if",n=i.getCurrentScopeType()=="els",a=i.getCurrentScopeType()=="for";if(!r&&!n&&!a&&t.object&&t.object.type==="Identifier"&&i.isContextBound(t.object.name)&&!i.isRootParam(t.object.name)&&!t.computed)return;t._indexTransformed||(Fe(t,i),t._indexTransformed=!0);const s=t.object&&t.object.type==="MemberExpression"&&t.object.object&&t.object.object.type==="MemberExpression"&&t.object.object.object&&(t.object.object.object.name===U||t.object.object.object.name==="$$"),o=t.object&&t.object.type==="Identifier"&&i.isContextBound(t.object.name);if(t.computed&&(s||o)){if(t.parent&&t.parent.type==="AssignmentExpression"&&t.parent.left===t)return;t.object.type==="Identifier"&&We.includes(t.object.name)&&i.isContextBound(t.object.name)&&(t.object={type:"MemberExpression",object:{type:"Identifier",name:t.object.name},property:{type:"Identifier",name:"__value"},computed:!1});const l=w.createGetCall(t.object,t.property);t.start&&(l.start=t.start),t.end&&(l.end=t.end),Object.assign(t,l),delete t.object,delete t.property,delete t.computed}}function st(t,e){if(t.type==="Identifier"){if(We.includes(t.name)&&e.isContextBound(t.name)){const a=t.name;return Object.assign(t,{type:"MemberExpression",object:{type:"Identifier",name:a},property:{type:"Identifier",name:"__value"},computed:!1}),delete t.name,t}if(e.isLoopVariable(t.name))return t;if(e.isRootParam(t.name)){const[a,s]=e.getVariable(t.name);return w.createContextVariableReference(s,a)}if(e.isContextBound(t.name))return t;const[i,r]=e.getVariable(t.name),n=i!==t.name;return e.isLocalSeriesVar(t.name)&&!n?t:n?X(t.name,e):i===t.name&&!e.isContextBound(t.name)?t:X(t.name,e)}return t}function Ve(t,e,i=""){switch(t.type){case"BinaryExpression":return jt(t,e,i);case"LogicalExpression":return Wt(t,e,i);case"MemberExpression":return{type:"MemberExpression",object:t.object.type==="Identifier"?st(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=st(t,e);return r.type==="Identifier"&&(r.name==="NaN"||r.name==="undefined"||r.name==="Infinity"||r.name==="null"||r.name==="Math")?r:w.createGetCall(r,0)}case"UnaryExpression":return $t(t,e,i);case"ConditionalExpression":{const r=Ve(t.test,e,i),n=Ve(t.consequent,e,i),a=Ve(t.alternate,e,i);return{type:"ConditionalExpression",test:r,consequent:n,alternate:a,start:t.start,end:t.end}}}return t}function jt(t,e,i){const r=Ve(t.left,e,i),n=Ve(t.right,e,i),a={type:"BinaryExpression",operator:t.operator,left:r,right:n,start:t.start,end:t.end};return G(a,e,{CallExpression(s,o){s._transformed||ae(s,o)},MemberExpression(s){fe(s,"",e)}}),a}function Wt(t,e,i){const r=Ve(t.left,e,i),n=Ve(t.right,e,i),a={type:"LogicalExpression",operator:t.operator,left:r,right:n,start:t.start,end:t.end};return G(a,e,{CallExpression(s,o){s._transformed||ae(s,o)}}),a}function gi(t,e,i){G(t,{parent:t,inNamespaceCall:!1},{Identifier(s,o,l){if(s.name=="NaN")return;if(We.includes(s.name)&&e.isContextBound(s.name)){const u={type:"MemberExpression",object:{type:"Identifier",name:s.name},property:{type:"Identifier",name:"__value"},computed:!1},p=w.createGetCall(u,0);Object.assign(s,p),delete s.name;return}s.parent=o.parent,ee(s,e);const c=s.parent&&s.parent.type==="BinaryExpression";(s.parent&&s.parent.type==="ConditionalExpression"||c)&&(s.type==="MemberExpression"?Fe(s,e):s.type==="Identifier"&&(s.parent&&s.parent.type==="CallExpression"&&s.parent.callee&&s.parent.callee.object&&s.parent.callee.object.name===U&&s.parent.callee.property.name==="get"||we(s)))},MemberExpression(s,o,l){Fe(s,e),s.object&&l(s.object,{parent:s,inNamespaceCall:o.inNamespaceCall})},ConditionalExpression(s,o,l){const c={...o,parent:s};s.test&&l(s.test,c),s.consequent&&l(s.consequent,c),s.alternate&&l(s.alternate,c)},BinaryExpression(s,o,l){const c={...o,parent:s};l(s.left,c),l(s.right,c)},LogicalExpression(s,o,l){const c={...o,parent:s};l(s.left,c),l(s.right,c)},UnaryExpression(s,o,l){const c={...o,parent:s};l(s.argument,c)},CallExpression(s,o,l){const c=s.callee&&s.callee.type==="MemberExpression"&&s.callee.object&&s.callee.object.type==="Identifier"&&e.isContextBound(s.callee.object.name);ae(s,e),s.arguments.forEach(u=>l(u,{parent:s,inNamespaceCall:c||o.inNamespaceCall}))}});const r=w.createMemberExpression(w.createIdentifier(i),w.createIdentifier("param")),n=e.generateParamId(),a={type:"CallExpression",callee:r,arguments:[t,Ft,{type:"Identifier",name:`'${n}'`}],_transformed:!0,_isParamCall:!0};if(!e.shouldSuppressHoisting()){const s=n;e.addLocalSeriesVar(s);const o=w.createVariableDeclaration(s,a);return e.addHoistedStatement(o),w.createIdentifier(s)}return a}function $t(t,e,i){const r=Ve(t.argument,e,i),n={type:"UnaryExpression",operator:t.operator,prefix:t.prefix,argument:r,start:t.start,end:t.end};return G(n,e,{CallExpression(a,s){a._transformed||ae(a,s)},MemberExpression(a){fe(a,"",e)}}),n}function Ue(t,e,i){switch(t?.type){case"BinaryExpression":t=jt(t,i,e);break;case"LogicalExpression":t=Wt(t,i,e);break;case"ConditionalExpression":return gi(t,i,e);case"UnaryExpression":t=$t(t,i,e);break;case"ArrayExpression":t.elements=t.elements.map(c=>c.type==="Identifier"?i.isContextBound(c.name)&&!i.isRootParam(c.name)?c:kr(c.name,i):c);break}const r=t.type==="MemberExpression"&&t.computed&&t.property,n=t.type==="MemberExpression"&&!t.computed;if(r){t.object.type==="CallExpression"?ae(t.object,i):t.object.type==="MemberExpression"?fe(t.object,"",i):t.object.type==="BinaryExpression"?t.object=jt(t.object,i,e):t.object.type==="LogicalExpression"?t.object=Wt(t.object,i,e):t.object.type==="ConditionalExpression"?t.object=gi(t.object,i,e):t.object.type==="UnaryExpression"&&(t.object=$t(t.object,i,e));const c=t.object.type==="Identifier"&&i.isContextBound(t.object.name)&&!i.isRootParam(t.object.name)?t.object:st(t.object,i),u=t.property.type==="Identifier"&&!i.isContextBound(t.property.name)&&!i.isLoopVariable(t.property.name)?w.createGetCall(st(t.property,i),0):t.property,p=w.createMemberExpression(w.createIdentifier(e),w.createIdentifier("param")),h=i.generateParamId(),f={type:"CallExpression",callee:p,arguments:[c,u,{type:"Identifier",name:`'${h}'`}],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const m=h;i.addLocalSeriesVar(m);const y=w.createVariableDeclaration(m,f);return i.addHoistedStatement(y),w.createIdentifier(m)}return f}if(n){if(t.object.type==="Identifier"&&it.includes(t.object.name)&&i.isContextBound(t.object.name)&&!t.computed){const c=t.object.name,u={type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:c},property:{type:"Identifier",name:t.property.name},computed:!1},arguments:[],_transformed:!0};c==="ta"&&u.arguments.push(i.getNextTACallId());const p=i.generateTempVar();i.addLocalSeriesVar(p);const h=w.createVariableDeclaration(p,u);return i.addOuterHoistedStatement(h),Object.assign(t,w.createIdentifier(p)),t}if(t.object.type==="Identifier"){const c=t.object.name,[u,p]=i.getVariable(c);if(u!==c&&!i.isLoopVariable(c)){const h=w.createContextVariableReference(p,u),f=w.createGetCall(h,0);t.object=f}}else t.object.type==="MemberExpression"&&Ue(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:w.createIdentifier(c.value.name),kind:"init",method:!1,shorthand:!1,computed:!1}:{type:"Property",key:{type:"Identifier",name:c.key.name},value:X(c.value.name,i),kind:"init",method:!1,shorthand:!1,computed:!1}:(c.value.type!=="Literal"&&(c.value=Ue(c.value,e,i)),c))),t.type==="Identifier"){if(We.includes(t.name)&&i.isContextBound(t.name)){const c=t.name;Object.assign(t,{type:"MemberExpression",object:{type:"Identifier",name:c},property:{type:"Identifier",name:"__value"},computed:!1}),delete t.name}else if(i.isContextBound(t.name)&&!i.isRootParam(t.name)){const c=w.createMemberExpression(w.createIdentifier(e),w.createIdentifier("param")),u=i.generateParamId(),p={type:"CallExpression",callee:c,arguments:[t,Ft,{type:"Identifier",name:`'${u}'`}],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const h=u;i.addLocalSeriesVar(h);const f=w.createVariableDeclaration(h,p);return i.addHoistedStatement(f),w.createIdentifier(h)}return p}}t?.type==="CallExpression"&&ae(t,i);const a=w.createMemberExpression(w.createIdentifier(e),w.createIdentifier("param")),s=t.type==="Identifier"?st(t,i):t,o=i.generateParamId(),l={type:"CallExpression",callee:a,arguments:[s,Ft,{type:"Identifier",name:`'${o}'`}],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const c=o;i.addLocalSeriesVar(c);const u=w.createVariableDeclaration(c,l);return i.addHoistedStatement(u),w.createIdentifier(c)}return l}function ae(t,e,i){if(t._transformed)return;t.callee&&t.callee.name,t.callee&&t.callee.type==="Identifier"&&(it.includes(t.callee.name)||We.includes(t.callee.name))&&e.isContextBound(t.callee.name)&&(t.callee=w.createMemberExpression(t.callee,w.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===U&&["get","init","param"].includes(t.callee.property.name))return;const n=t.callee.object.name,a=[];if(t.arguments.forEach(u=>{if(u._isParamCall){a.push(u);return}a.push(Ue(u,n,e))}),t.arguments=a,["plot","hline","fill"].includes(n)){const u=e.getNextPlotCallId();t.arguments.push({type:"ObjectExpression",properties:[{type:"Property",key:{type:"Identifier",name:"__callsiteId"},value:u,kind:"init",computed:!1,shorthand:!1}]})}if(n==="ta")if(e.getCurrentScopeType()==="fn"){const u=e.getNextTACallId(),[p]=e.getVariable("$$");let h;p?h=w.createMemberExpression(w.createLocalContextIdentifier(),w.createIdentifier("id")):h=w.createLiteral("");const f={type:"BinaryExpression",operator:"+",left:h,right:u};t.arguments.push(f)}else t.arguments.push(e.getNextTACallId());const s=t.callee.property.name,o=`${n}.${s}`,l=Xn.includes(o),c=t._insideAwait===!0;if(l&&!c){const u=Object.assign({},t),p=w.createAwaitExpression(u);Object.assign(t,p)}if(!e.shouldSuppressHoisting()){const u=e.generateTempVar();e.addLocalSeriesVar(u);const p=t._insideAwait===!0;let h=Object.assign({},t);p&&(h=w.createAwaitExpression(h));const f=w.createVariableDeclaration(u,h);e.addHoistedStatement(f);const m=w.createIdentifier(u);Object.assign(t,m),t._wasHoisted=!0,t._wasInsideAwait=p;return}t._transformed=!0}else if(t.callee&&t.callee.type==="Identifier"){if(t.arguments=t.arguments.map(n=>n._isParamCall?n:Ue(n,U,e)),!e.isContextBound(t.callee.name)){const n=e.getNextUserCallId(),a=w.createMemberExpression(w.createContextIdentifier(),w.createIdentifier("call")),s=[t.callee,n,...t.arguments];t.callee=a,t.arguments=s}t._transformed=!0}if(!r&&t.callee&&t.callee.type==="MemberExpression"){const n=t.callee.property.name;if(e.isUserFunction(n)&&!e.isContextBound(n)){const a=t.callee.object;t.callee.property;const s=t.arguments.map(p=>p._isParamCall?p:Ue(p,U,e));let o=a;a.type==="Identifier"?o=Ue(a,U,e):a.type==="CallExpression"&&(ae(a,e),o=Ue(a,U,e));const l=w.createMemberExpression(w.createContextIdentifier(),w.createIdentifier("call")),c=e.getNextUserCallId(),u=[w.createIdentifier(n),c,o,...s];t.callee=l,t.arguments=u,t._transformed=!0;return}t.callee.object.type==="Identifier"&&ee(t.callee.object,e)}t.arguments.forEach(n=>{G(n,{parent:t},{Identifier(a,s,o){a.parent=s.parent,ee(a,e);const l=a.parent&&a.parent.type==="BinaryExpression";(a.parent&&a.parent.type==="ConditionalExpression"||l)&&(a.type==="MemberExpression"?Fe(a,e):a.type==="Identifier"&&(a.parent&&a.parent.type==="CallExpression"&&a.parent.callee&&a.parent.callee.object&&a.parent.callee.object.name===U&&a.parent.callee.property.name==="get"||we(a)))},BinaryExpression(a,s,o){const l={...s,parent:a};o(a.left,l),o(a.right,l)},LogicalExpression(a,s,o){const l={...s,parent:a};o(a.left,l),o(a.right,l)},UnaryExpression(a,s,o){const l={...s,parent:a};o(a.argument,l)},CallExpression(a,s,o){a._transformed||ae(a,e)},MemberExpression(a,s,o){fe(a,"",e),a.object&&o(a.object,{parent:a})}})})}function Ut(t,e){let i=null;if(t.left.type==="Identifier")i=X(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,[n,a]=e.getVariable(r),s=n!==r,o=e.isContextBound(r);(s||o)&&!e.isLoopVariable(r)&&t.left.property.type==="Literal"&&t.left.property.value===0&&(i=X(r,e))}}else if(t.left.type==="MemberExpression"&&!t.left.computed&&t.left.object.type==="Identifier"){const r=t.left.object.name,[n,a]=e.getVariable(r);if(n!==r&&!e.isLoopVariable(r)){const s=X(r,e),o=w.createGetCall(s,0);t.left.object=o}}if(G(t.right,{parent:t.right,inNamespaceCall:!1},{Identifier(r,n,a){if(We.includes(r.name)&&e.isContextBound(r.name)){const m={type:"MemberExpression",object:{type:"Identifier",name:r.name},property:{type:"Identifier",name:"__value"},computed:!1},y=w.createGetCall(m,0);Object.assign(r,y),delete r.name;return}r.parent=n.parent,ee(r,e);const s=r.parent&&r.parent.type==="BinaryExpression",o=r.parent&&r.parent.type==="ConditionalExpression",l=e.isContextBound(r.name)&&!e.isRootParam(r.name),c=r.parent&&r.parent.type==="MemberExpression"&&r.parent.computed&&r.parent.object===r,u=r.parent&&r.parent._isParamCall,p=r.parent&&r.parent.type==="MemberExpression",h=r.name==="NaN",f=r.parent&&r.parent.type==="CallExpression"&&r.parent.callee&&r.parent.callee.object&&r.parent.callee.object.name===U&&r.parent.callee.property.name==="get";(l||o||s)&&(r.type==="MemberExpression"?Fe(r,e):r.type==="Identifier"&&!p&&!c&&!u&&!h&&!f&&we(r))},MemberExpression(r,n,a){fe(r,"",e),r.type==="CallExpression"?r.arguments.forEach(s=>a(s,{parent:r,inNamespaceCall:n.inNamespaceCall})):r.object&&a(r.object,{parent:r,inNamespaceCall:n.inNamespaceCall})},CallExpression(r,n,a){const s=r.callee&&r.callee.type==="MemberExpression"&&r.callee.object&&r.callee.object.type==="Identifier"&&e.isContextBound(r.callee.object.name);ae(r,e),r.type==="CallExpression"&&(r.callee.type==="MemberExpression"&&a(r.callee,{parent:r,inNamespaceCall:s||n.inNamespaceCall}),r.arguments.forEach(o=>a(o,{parent:r,inNamespaceCall:s||n.inNamespaceCall})))}}),i){let r=t.right;if(t.operator!=="="){const a=t.operator.replace("=",""),s=w.createGetCall(i,0);r={type:"BinaryExpression",operator:a,left:s,right:t.right,start:t.start,end:t.end}}const n=w.createSetCall(i,r);t.start&&(n.start=t.start),t.end&&(n.end=t.end),Object.assign(t,n)}}function Ar(t,e){t._skipTransformation||t.declarations.forEach(i=>{if(i.init&&i.init.type==="Identifier"&&We.includes(i.init.name)&&e.isContextBound(i.init.name)){const h=i.init.name;Object.assign(i.init,{type:"MemberExpression",object:{type:"Identifier",name:h},property:{type:"Identifier",name:"__value"},computed:!1}),delete i.init.name}const r=i.init&&i.init.type==="MemberExpression"&&i.init.object&&(i.init.object.name==="context"||i.init.object.name===U||i.init.object.name==="context2"),n=i.init&&i.init.type==="MemberExpression"&&i.init.object?.object&&(i.init.object.object.name==="context"||i.init.object.object.name===U||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(h=>{h.key.name&&e.addContextBoundVar(h.key.name)}),i.init.object.name=U;return}if(n){i.id.name&&e.addContextBoundVar(i.id.name),i.id.properties&&i.id.properties.forEach(h=>{h.key.name&&e.addContextBoundVar(h.key.name)}),i.init.object.object.name=U;return}e.addVariable(i.id.name,t.kind);const s=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)?ae(i.init,e):G(i.init,{parent:i.init},{Identifier(h,f){h.parent=f.parent,ee(h,e);const m=h.parent&&h.parent.type==="BinaryExpression",y=h.parent&&h.parent.type==="UnaryExpression",_=h.parent&&h.parent.type==="ConditionalExpression",v=h.parent&&h.parent.type==="CallExpression"&&h.parent.callee&&h.parent.callee.object&&h.parent.callee.object.name===U&&h.parent.callee.property.name==="get";h.type==="Identifier"&&(m||y||_)&&!v&&we(h)},CallExpression(h,f,m){h.callee.type==="Identifier"&&(h.callee.parent=h),h.arguments.forEach(y=>{y.type==="Identifier"&&(y.parent=h)}),(h.callee.type==="ArrowFunctionExpression"||h.callee.type==="FunctionExpression")&&m(h.callee,{parent:h}),ae(h,e),h.type==="CallExpression"&&(h.callee.type==="MemberExpression"&&m(h.callee,{parent:h}),h.arguments.forEach(y=>m(y,{parent:h})))},BinaryExpression(h,f,m){h.left.type==="Identifier"&&(h.left.parent=h),h.right.type==="Identifier"&&(h.right.parent=h),m(h.left,{parent:h}),m(h.right,{parent:h})},MemberExpression(h,f,m){h.object&&h.object.type==="Identifier"&&(h.object.parent=h),h.property&&h.property.type==="Identifier"&&(h.property.parent=h),fe(h,"",e),h.type==="CallExpression"?h.arguments.forEach(y=>m(y,{parent:h})):h.object&&m(h.object,{parent:h})},AwaitExpression(h,f,m){h.argument&&(h.argument._insideAwait=!0,m(h.argument,{parent:h}),h.argument.type==="Identifier"&&h.argument._wasInsideAwait&&Object.assign(h,h.argument))},ArrowFunctionExpression(h,f,m){if(h.body)if(h.body.type==="BlockStatement"){const y=[];h.body.body.forEach(_=>{e.enterHoistingScope(),m(_,{parent:h.body,insideIIFE:!0});const v=e.exitHoistingScope();y.push(...v),y.push(_)}),h.body.body=y}else m(h.body,{parent:h,insideIIFE:!0})},FunctionExpression(h,f,m){if(h.body&&h.body.type==="BlockStatement"){const y=[];h.body.body.forEach(_=>{e.enterHoistingScope(),m(_,{parent:h.body,insideIIFE:!0});const v=e.exitHoistingScope();y.push(...v),y.push(_)}),h.body.body=y}},SwitchStatement(h,f,m){h.discriminant&&(h.discriminant.parent=h,m(h.discriminant,{parent:h})),h.cases&&h.cases.forEach(y=>{y.parent=h,m(y,{parent:h})})},SwitchCase(h,f,m){if(h.test&&(h.test.parent=h,m(h.test,{parent:h})),h.consequent){const y=[];h.consequent.forEach(_=>{e.enterHoistingScope(),_.parent=h,m(_,{parent:h});const v=e.exitHoistingScope();y.push(...v),y.push(_)}),h.consequent=y}},AssignmentExpression(h,f,m){if(f.insideIIFE){if(h.left.type==="Identifier"){const[y]=e.getVariable(h.left.name);if(y===h.left.name&&!e.isContextBound(h.left.name)){m(h.right,{parent:h});return}}Ut(h,e)}}}));const l=X(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");if(i.init?.property?.type==="MemberExpression"&&(i.init.property._indexTransformed||(Fe(i.init.property,e),i.init.property._indexTransformed=!0)),s==="var"){const h=e.getCurrentHoistingScope();if(h){for(const f of h)if(f.type==="VariableDeclaration")for(const m of f.declarations){if(!m.init||m.init.type!=="CallExpression")continue;const y=m.init.callee;if(y?.type!=="MemberExpression")continue;let _;const v=y.property?.name;if(y.object?.type==="Identifier"?_=y.object.name:y.object?.type==="MemberExpression"&&y.object.property?.name&&(_=y.object.property.name),_&&v){const S=`${_}.${v}`;Zn.includes(S)&&(m.init={type:"ArrowFunctionExpression",params:[],body:m.init,expression:!0,async:!1})}}}}let u;i.init?a||o?u=i.init:s==="var"?u=w.createInitVarCall(l,i.init):u=w.createInitCall(l,c?i.init.object:i.init,c?i.init.property:void 0):u=w.createIdentifier("undefined");const p=w.createExpressionStatement(w.createAssignmentExpression(l,u));if(o){const h=i.init.object.name,f=X(h,e),m=i.init.property.value,y={type:"MemberExpression",object:w.createGetCall(f,0),property:{type:"Literal",value:m},computed:!0};p.expression.right=w.createCallExpression(w.createMemberExpression(w.createContextIdentifier(),w.createIdentifier("init")),[l,y])}a&&(e.pushScope("fn"),G(i.init.body,e,{IfStatement(h,f,m){f.pushScope("if"),m(h.consequent,f),h.alternate&&(f.pushScope("els"),m(h.alternate,f),f.popScope()),f.popScope()},VariableDeclaration(h,f){Ar(h,f)},Identifier(h,f){ee(h,f)},AssignmentExpression(h,f){Ut(h,f)},SwitchStatement(h,f,m){h.discriminant.parent=h,m(h.discriminant,f),h.cases.forEach(y=>{y.parent=h,m(y,f)})},SwitchCase(h,f,m){h.test&&(h.test.parent=h,m(h.test,f));const y=[];h.consequent.forEach(_=>{f.enterHoistingScope(),m(_,f);const v=f.exitHoistingScope();y.push(...v),y.push(_)}),h.consequent=y},BlockStatement(h,f,m){const y=[];h.body.forEach(_=>{f.enterHoistingScope(),m(_,f);const v=f.exitHoistingScope();y.push(...v),y.push(_)}),h.body=y}}),e.popScope()),Object.assign(t,p)})}function cs(t,e,i){if(e.setSuppressHoisting(!0),t.init&&t.init.type==="VariableDeclaration"){const r=t.init.declarations[0],n=r.id.name;e.addLoopVariable(n,n),t.init={type:"VariableDeclaration",kind:t.init.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:n},init:r.init}]},r.init&&G(r.init,e,{Identifier(a,s){e.isLoopVariable(a.name)||(e.pushScope("for"),ee(a,s),e.popScope())},MemberExpression(a){e.pushScope("for"),fe(a,"",e),e.popScope()},CallExpression(a,s,o){a.callee.parent=a,o(a.callee,s);for(const l of a.arguments)o(l,s)}})}t.test&&G(t.test,e,{Identifier(r,n){!e.isLoopVariable(r.name)&&!r.computed&&(e.pushScope("for"),ee(r,n),r.type==="Identifier"&&(r.computed=!0,we(r)),e.popScope())},MemberExpression(r){e.pushScope("for"),fe(r,"",e),e.popScope()},CallExpression(r,n,a){r.callee.parent=r,a(r.callee,n);for(const s of r.arguments)a(s,n)}}),t.update&&G(t.update,e,{Identifier(r,n){e.isLoopVariable(r.name)||(e.pushScope("for"),ee(r,n),e.popScope())}}),e.setSuppressHoisting(!1),e.pushScope("for"),i(t.body,e),e.popScope()}function us(t,e){G(t,e,{MemberExpression(i){fe(i,"",e)},CallExpression(i,r){ae(i,r)},Identifier(i,r){ee(i,r);const n=e.getCurrentScopeType()==="if";e.isContextBound(i.name)&&!e.isRootParam(i.name)&&n&&we(i)}})}function hs(t,e,i){t.test&&(e.pushScope("if"),us(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 ps(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)?w.createGetCall(r,0):kr(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)?w.createGetCall(r,0):(r.computed&&r.object.type==="Identifier"&&e.isContextBound(r.object.name)&&!e.isRootParam(r.object.name)||fe(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:w.createIdentifier(r.key.name),value:X(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=X(r.value.name,e))),r)):t.argument.type==="Identifier"&&(ee(t.argument,e),t.argument.type==="Identifier"&&we(t.argument)),i==="fn")){t.argument.type==="Identifier"&&e.isContextBound(t.argument.name)&&!e.isRootParam(t.argument.name)?t.argument=w.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||(Fe(t.argument,e),t.argument._indexTransformed=!0)):(t.argument.type==="BinaryExpression"||t.argument.type==="LogicalExpression"||t.argument.type==="ConditionalExpression"||t.argument.type==="CallExpression")&&G(t.argument,e,{Identifier(n,a){ee(n,a),n.type==="Identifier"&&!n._arrayAccessed&&(we(n),n._arrayAccessed=!0)},MemberExpression(n){fe(n,"",e)},CallExpression(n,a,s){(n.callee.type==="ArrowFunctionExpression"||n.callee.type==="FunctionExpression")&&s(n.callee,a),ae(n,a),n.type==="CallExpression"&&n.arguments.forEach(o=>s(o,a))},BinaryExpression(n,a,s){s(n.left,a),s(n.right,a)},ArrowFunctionExpression(n,a,s){if(n.body)if(n.body.type==="BlockStatement"){const o=[];n.body.body.forEach(l=>{e.enterHoistingScope(),s(l,a);const c=e.exitHoistingScope();o.push(...c),o.push(l)}),n.body.body=o}else s(n.body,a)},FunctionExpression(n,a,s){if(n.body&&n.body.type==="BlockStatement"){const o=[];n.body.body.forEach(l=>{e.enterHoistingScope(),s(l,a);const c=e.exitHoistingScope();o.push(...c),o.push(l)}),n.body.body=o}},SwitchStatement(n,a,s){n.discriminant.parent=n,s(n.discriminant,a),n.cases.forEach(o=>{o.parent=n,s(o,a)})},SwitchCase(n,a,s){n.test&&(n.test.parent=n,s(n.test,a));const o=[];n.consequent.forEach(l=>{e.enterHoistingScope(),s(l,a);const c=e.exitHoistingScope();o.push(...c),o.push(l)}),n.consequent=o},BlockStatement(n,a,s){const o=[];n.body.forEach(l=>{a.enterHoistingScope(),s(l,a);const c=a.exitHoistingScope();o.push(...c),o.push(l)}),n.body=o}});const r=w.createCallExpression(w.createMemberExpression(w.createContextIdentifier(),w.createIdentifier("precision")),[t.argument]);t.argument=r}}function fs(t,e,i){const r=w.createVariableDeclaration("$$",w.createCallExpression(w.createMemberExpression(w.createContextIdentifier(),w.createIdentifier("peekCtx")),[]));r._skipTransformation=!0,e.addLoopVariable("$$","$$"),t.body&&t.body.type==="BlockStatement"&&(t.body.body.unshift(r),e.pushScope("fn"),t.params.forEach(n=>{n.type==="Identifier"&&e.addLocalSeriesVar(n.name)}),i(t.body,e),t.params.forEach(n=>{n.type==="Identifier"&&e.removeLocalSeriesVar(n.name)}),e.popScope())}function ds(t){const e={...C,LineComment:()=>{}};Er(t,{BinaryExpression(i){if(i.operator==="=="||i.operator==="==="){const r=i.left,n=i.right,a=w.createMathEqCall(r,n);a._transformed=!0,Object.assign(i,a)}}},e)}function ms(t,e,i,r={debug:!1,ln:!1},n=[]){const a=s=>{if(!r.debug||!s.loc||!n.length)return null;const o=s.loc.start.line-1;if(o>=0&&o<n.length){const l=n[o].trim();if(l)return{type:"LineComment",value:`${r.ln?` [Line ${s.loc.start.line}]`:""} ${l}`}}return null};G(t,e,{Program(s,o,l){const c=[];s.body.forEach(u=>{o.enterHoistingScope(),l(u,o);const p=o.exitHoistingScope(),h=a(u);h&&c.push(h),c.push(...p),c.push(u)}),s.body=c},BlockStatement(s,o,l){const c=[];s.body.forEach(u=>{o.enterHoistingScope(),l(u,o);const p=o.exitHoistingScope(),h=a(u);h&&c.push(h),c.push(...p),c.push(u)}),s.body=c},ReturnStatement(s,o){ps(s,o)},VariableDeclaration(s,o){Ar(s,o)},Identifier(s,o){ee(s,o)},CallExpression(s,o,l){s.callee&&(s.callee.type==="ArrowFunctionExpression"||s.callee.type==="FunctionExpression")&&l(s.callee,o),ae(s,o)},ArrowFunctionExpression(s,o,l){s.body&&l(s.body,o)},FunctionExpression(s,o,l){s.body&&l(s.body,o)},ForOfStatement(s,o,l){if(s.left&&s.left.type==="VariableDeclaration"){s.left._skipTransformation=!0;const c=s.left.declarations[0];c.id.type==="Identifier"?o.addLoopVariable(c.id.name,c.id.name):c.id.type==="ArrayPattern"&&c.id.elements.forEach(u=>{u.type==="Identifier"&&o.addLoopVariable(u.name,u.name)})}if(s.right&&s.right.type==="Identifier"){ee(s.right,o),we(s.right);const c={...s.right};let u=w.createMemberExpression(c,w.createIdentifier("array"),!1);s.left&&s.left.type==="VariableDeclaration"&&s.left.declarations[0].id.type==="ArrayPattern"&&(u=w.createCallExpression(w.createMemberExpression(u,w.createIdentifier("entries"),!1),[])),Object.assign(s.right,u)}else s.right&&l(s.right,o);s.body&&l(s.body,o)},ForInStatement(s,o,l){s.left&&s.left.type==="VariableDeclaration"&&(s.left._skipTransformation=!0),s.right&&s.right.type==="Identifier"?(ee(s.right,o),we(s.right)):s.right&&l(s.right,o),s.body&&l(s.body,o)},MemberExpression(s,o){fe(s,i,o)},AssignmentExpression(s,o){Ut(s,o)},FunctionDeclaration(s,o,l){fs(s,o,l)},ForStatement(s,o,l){cs(s,o,l)},IfStatement(s,o,l){hs(s,o,l)},SwitchStatement(s,o,l){s.discriminant.parent=s,l(s.discriminant,o),s.cases.forEach(c=>{c.parent=s,l(c,o)})},SwitchCase(s,o,l){s.test&&(s.test.parent=s,l(s.test,o));const c=[];s.consequent.forEach(u=>{o.enterHoistingScope(),l(u,o);const p=o.exitHoistingScope();c.push(...p),c.push(u)}),s.consequent=c},AwaitExpression(s,o,l){s.argument&&(s.argument._insideAwait=!0,l(s.argument,o),s.argument.type==="Identifier"&&s.argument._wasInsideAwait===!0&&(s.type="Identifier",s.name=s.argument.name,s.argument._wasHoisted&&(s._wasHoisted=s.argument._wasHoisted),delete s.argument))}})}const g={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"},gs=new Set(["if","else","for","while","switch","break","continue","var","varip","type","and","or","not","to","by","in","import","export","method","extends","enum"]),xs=["==","!=","<=",">=",":=","+=","-=","*=","/=","%=","=>","//","and","or","not"];class ys{constructor(e,i,r,n,a=0){this.type=e,this.value=i,this.line=r,this.column=n,this.indent=a}}class _s{source;pos;line;column;tokens;indentStack;atLineStart;parenDepth;bracketDepth;braceDepth;constructor(e){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===`
34
34
  `){this.handleNewline();continue}if(this.atLineStart&&e!==`
35
- `){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(x.DEDENT,"",this.getCurrentIndent());return this.addToken(x.EOF,""),this.tokens}handleNewline(){this.parenDepth===0&&this.bracketDepth===0&&this.braceDepth===0&&(this.addToken(x.NEWLINE,`
35
+ `){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(g.DEDENT,"",this.getCurrentIndent());return this.addToken(g.EOF,""),this.tokens}handleNewline(){this.parenDepth===0&&this.bracketDepth===0&&this.braceDepth===0&&(this.addToken(g.NEWLINE,`
36
36
  `),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 n=this.peek();if(n===" ")i++,this.advance();else if(n===" ")e++,this.advance();else break}if(this.peek()===`
37
- `||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(x.INDENT,"",e);else if(e<r){for(;this.indentStack.length>1&&this.indentStack[this.indentStack.length-1]>e;)this.indentStack.pop(),this.addToken(x.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()!==`
38
- `;)e+=this.advance();this.addToken(x.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 n=this.advance();switch(n){case"n":r+=`
39
- `;break;case"t":r+=" ";break;case"r":r+="\r";break;case"\\":r+="\\";break;case e:r+=e;break;default:r+=n}}else r+=this.advance();if(this.peek()!==e)throw new Error(`Unterminated string at ${this.line}:${i}`);this.advance(),this.addToken(x.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(x.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 n=this.peek(1);if(this.isDigit(n)||!this.isIdentifierStart(n)){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 n=this.peek(1);if(this.isDigit(n))for(e+=this.advance();this.pos<this.source.length&&this.isDigit(this.peek());)e+=this.advance();else if(n==="+"||n==="-"){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(x.NUMBER,parseFloat(e))}readIdentifier(){this.column;let e="";for(;this.pos<this.source.length&&this.isIdentifierChar(this.peek());)e+=this.advance();rs.has(e)?this.addToken(x.KEYWORD,e):e==="true"||e==="false"?this.addToken(x.BOOLEAN,e==="true"):this.addToken(x.IDENTIFIER,e)}readOperatorOrPunctuation(){const e=this.peek(),i=this.peek(1),r=e+i;if(ns.includes(r))return this.advance(),this.advance(),this.addToken(x.OPERATOR,r),!0;if("+-*/%<>=!?".includes(e))return this.advance(),this.addToken(x.OPERATOR,e),!0;switch(e){case"(":return this.parenDepth++,this.advance(),this.addToken(x.LPAREN,e),!0;case")":return this.parenDepth--,this.advance(),this.addToken(x.RPAREN,e),!0;case"[":return this.bracketDepth++,this.advance(),this.addToken(x.LBRACKET,e),!0;case"]":return this.bracketDepth--,this.advance(),this.addToken(x.RBRACKET,e),!0;case"{":return this.braceDepth++,this.advance(),this.addToken(x.LBRACE,e),!0;case"}":return this.braceDepth--,this.advance(),this.addToken(x.RBRACE,e),!0;case",":return this.advance(),this.addToken(x.COMMA,e),!0;case".":return this.isDigit(this.peek(1))?(this.readNumber(),!0):(this.advance(),this.addToken(x.DOT,e),!0);case":":return this.advance(),this.addToken(x.COLON,e),!0;case";":return this.advance(),this.addToken(x.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 n=new ss(e,i,this.line,this.column,r!==null?r:this.getCurrentIndent());this.tokens.push(n)}}class B{constructor(e){this.type=e}}class os extends B{constructor(e){super("Program"),this.body=e}}class ue extends B{constructor(e){super("ExpressionStatement"),this.expression=e}}var We=(t=>(t.VAR="var",t.LET="let",t.CONST="const",t))(We||{});class Fe extends B{constructor(e,i="let"){super("VariableDeclaration"),this.declarations=e,this.kind=i}}class je extends B{constructor(e,i,r=null){super("VariableDeclarator"),this.id=e,this.init=i,this.varType=r}}class fi extends B{constructor(e,i,r,n=null){super("FunctionDeclaration"),this.id=e,this.params=i,this.body=r,this.returnType=n}}class cs extends B{constructor(e,i){super("TypeDefinition"),this.name=e,this.fields=i}}class ls extends B{constructor(e,i,r=null){super("IfStatement"),this.test=e,this.consequent=i,this.alternate=r}_line}class di extends B{constructor(e,i,r,n){super("ForStatement"),this.init=e,this.test=i,this.update=r,this.body=n}isForIn}class us extends B{constructor(e,i){super("WhileStatement"),this.test=e,this.body=i}}class Ae extends B{constructor(e){super("BlockStatement"),this.body=e}}class mi extends B{constructor(e){super("ReturnStatement"),this.argument=e}}class ne extends B{constructor(e){super("Identifier"),this.name=e}varType;returnType;isMethod}class Ye extends B{constructor(e,i=null){super("Literal"),this.value=e,this.raw=i}}class Ee extends B{constructor(e,i,r){super("BinaryExpression"),this.operator=e,this.left=i,this.right=r}}class xi extends B{constructor(e,i,r=!0){super("UnaryExpression"),this.operator=e,this.argument=i,this.prefix=r}}class ht extends B{constructor(e,i,r){super("AssignmentExpression"),this.operator=e,this.left=i,this.right=r}}class gi extends B{constructor(e,i,r=!1){super("UpdateExpression"),this.operator=e,this.argument=i,this.prefix=r}}class hs extends B{constructor(e,i){super("CallExpression"),this.callee=e,this.args=i,this.callee=e,this.arguments=i}arguments}class yi extends B{constructor(e,i,r=!1){super("MemberExpression"),this.object=e,this.property=i,this.computed=r}}class Te extends B{constructor(e,i,r){super("ConditionalExpression"),this.test=e,this.consequent=i,this.alternate=r}needsIIFE;consequentStmts;alternateStmts}class ps extends B{constructor(e){super("ArrayExpression"),this.elements=e}}class fs extends B{constructor(e){super("ObjectExpression"),this.properties=e}}class ds extends B{constructor(e,i){super("Property"),this.key=e,this.value=i,this.kind="init",this.method=!1,this.shorthand=!1,this.computed=!1}kind;method;shorthand;computed}class vi extends B{constructor(e){super("ArrayPattern"),this.elements=e}}class wi extends B{constructor(e,i){super("AssignmentPattern"),this.left=e,this.right=i}}class ms extends B{constructor(e,i){super("SwitchExpression"),this.discriminant=e,this.cases=i}}class xs extends B{constructor(e,i,r){super("SwitchCase"),this.test=e,this.consequent=i,this.statements=r,this.statements=r}}class gs{tokens;pos;functionNames=new Set;constructor(e){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 n=0,a=this.peek(n);if(a.type===x.NEWLINE&&(n++,a=this.peek(n),a.type===x.INDENT&&(n++,a=this.peek(n))),a.type!==e||i!==null&&a.value!==i)return!1;for(let s=0;s<n;s++)this.advance();return!0}skipNewlines(e=!1){for(;this.match(x.NEWLINE)||this.match(x.COMMENT);)this.advance();e&&this.match(x.INDENT)&&this.advance()}parse(){const e=[];for(;!this.match(x.EOF);){if(this.skipNewlines(),this.match(x.DEDENT)){this.advance();continue}if(this.match(x.EOF))break;const i=this.parseStatement();i&&e.push(i),this.skipNewlines()}return new os(e)}parseStatement(e=!0){this.skipNewlines();const i=this.peek().line;if(this.match(x.COMMENT))return this.advance(),null;let r;if(this.match(x.KEYWORD,"type"))r=this.parseTypeDefinition();else if(this.match(x.KEYWORD,"var")||this.match(x.KEYWORD,"varip"))r=this.parseVarDeclaration();else if(this.match(x.KEYWORD,"method"))r=this.parseMethodDeclaration();else if(this.isFunctionDeclaration())r=this.parseFunctionDeclaration();else if(this.match(x.KEYWORD,"if"))r=this.parseIfStatement();else if(this.match(x.KEYWORD,"for"))r=this.parseForStatement();else if(this.match(x.KEYWORD,"while"))r=this.parseWhileStatement();else if(this.match(x.KEYWORD,"break")||this.match(x.KEYWORD,"continue")){const n=this.advance().value;r=new ue(new ne(n))}else this.isTupleDestructuring()?r=this.parseTupleDestructuring():this.peek().type===x.IDENTIFIER&&this.isTypedVarDeclaration()&&(r=this.parseTypedVarDeclaration());if(!r){const n=this.parseExpression();if(this.match(x.OPERATOR)){const a=this.peek().value;if(["=",":=","+=","-=","*=","/=","%="].includes(a)){this.advance(),this.skipNewlines(!0);const s=this.parseExpression();a==="="&&n.type==="Identifier"?r=new Fe([new je(n,s)],We.LET):r=new ue(new ht(a===":="?"=":a,n,s))}else r=new ue(n)}else r=new ue(n)}if(r&&(r._line=i,e&&this.match(x.COMMA)&&this.peek().line===i)){const n=[r];for(;this.match(x.COMMA)&&this.peek().line===i;){this.advance(),this.skipNewlines(!0);const a=this.parseStatement(!1);a&&n.push(a)}return new Ae(n)}return r}isFunctionDeclaration(){const e=this.pos;try{let i=0;if(this.peek(i).type===x.IDENTIFIER&&this.peek(i+1).type===x.IDENTIFIER&&i++,this.peek(i).type!==x.IDENTIFIER||(i++,this.peek(i).type!==x.LPAREN))return!1;i++;let r=1;for(;r>0&&this.peek(i).type!==x.EOF;)this.peek(i).type===x.LPAREN&&r++,this.peek(i).type===x.RPAREN&&r--,i++;for(;this.peek(i).type===x.NEWLINE;)i++;return this.peek(i).type===x.OPERATOR&&this.peek(i).value==="=>"}finally{this.pos=e}}parseTypeExpression(){let e=this.expect(x.IDENTIFIER).value;for(;this.match(x.DOT)&&this.peek(1).type===x.IDENTIFIER;)this.advance(),e+="."+this.advance().value;if(this.match(x.OPERATOR,"<")){this.advance();const i=[];for(i.push(this.parseTypeExpression());this.match(x.COMMA);)this.advance(),this.skipNewlines(),i.push(this.parseTypeExpression());return this.expect(x.OPERATOR,">"),e+"<"+i.join(", ")+">"}return e}parseTypeDefinition(){this.expect(x.KEYWORD,"type");const e=this.expect(x.IDENTIFIER).value;this.match(x.OPERATOR,"=>")&&this.advance(),this.skipNewlines(),this.expect(x.INDENT);const i=[];for(;!this.match(x.DEDENT)&&!this.match(x.EOF)&&(this.skipNewlines(),!this.match(x.DEDENT));){const r=this.parseTypeExpression(),n=this.expect(x.IDENTIFIER).value;let a=null;this.match(x.OPERATOR,"=")&&(this.advance(),this.skipNewlines(),a=this.parseExpression()),i.push({type:r,name:n,defaultValue:a}),this.skipNewlines()}return this.match(x.DEDENT)&&this.advance(),new cs(e,i)}parseVarDeclaration(){const e=this.advance().value;let i=null,r=null;if(this.peek().type===x.IDENTIFIER&&this.peek(1).type===x.LBRACKET&&this.peek(2).type===x.RBRACKET)i=this.advance().value,this.advance(),i+="[]",this.advance(),r=this.expect(x.IDENTIFIER).value;else if(this.peek().type===x.IDENTIFIER&&(this.peek(1).type===x.DOT||this.peek(1).type===x.IDENTIFIER||this.peek(1).type===x.OPERATOR&&this.peek(1).value==="<")){for(i=this.advance().value;this.match(x.DOT)&&this.peek(1).type===x.IDENTIFIER;)this.advance(),i+="."+this.advance().value;if(this.match(x.LBRACKET)&&this.peek(1).type===x.RBRACKET)this.advance(),this.advance(),i+="[]",r=this.expect(x.IDENTIFIER).value;else if(this.match(x.OPERATOR,"<")){for(this.advance(),i+="<";!this.match(x.OPERATOR,">");)if(this.match(x.IDENTIFIER))for(i+=this.advance().value;this.match(x.DOT)&&this.peek(1).type===x.IDENTIFIER;)i+=".",this.advance(),i+=this.advance().value;else if(this.match(x.COMMA))i+=this.advance().value,this.skipNewlines();else break;this.match(x.OPERATOR,">")&&(i+=">",this.advance()),r=this.expect(x.IDENTIFIER).value}else r=this.expect(x.IDENTIFIER).value}else if(this.peek().type===x.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(x.OPERATOR,"="),this.skipNewlines(!0);const n=this.parseExpression(),a=new ne(r);return i&&(a.varType=i),new Fe([new je(a,n,i)],e)}isTypedVarDeclaration(){let e=0;if(this.peek(e).type!==x.IDENTIFIER)return!1;for(e++;this.peek(e).type===x.DOT&&this.peek(e+1).type===x.IDENTIFIER;)e+=2;if(this.peek(e).type===x.LBRACKET&&this.peek(e+1).type===x.RBRACKET)return e+=2,this.peek(e).type!==x.IDENTIFIER?!1:(e++,this.peek(e).type===x.OPERATOR&&this.peek(e).value==="=");if(this.peek(e).type===x.OPERATOR&&this.peek(e).value==="<"){e++;let i=1;for(;i>0&&this.peek(e).type!==x.EOF;)this.peek(e).type===x.OPERATOR&&this.peek(e).value==="<"?i++:this.peek(e).type===x.OPERATOR&&this.peek(e).value===">"&&i--,e++;return this.peek(e).type!==x.IDENTIFIER?!1:(e++,this.peek(e).type===x.OPERATOR&&this.peek(e).value==="=")}if(this.peek(e).type!==x.IDENTIFIER)return!1;for(e++;this.peek(e).type===x.IDENTIFIER;)e++;return this.peek(e).type===x.OPERATOR&&this.peek(e).value==="="}parseTypedVarDeclaration(){let e=this.advance().value;for(;this.match(x.DOT)&&this.peek(1).type===x.IDENTIFIER;)this.advance(),e+="."+this.advance().value;if(this.match(x.LBRACKET)&&this.peek(1).type===x.RBRACKET)this.advance(),this.advance(),e+="[]";else if(this.match(x.OPERATOR,"<")){for(this.advance(),e+="<";!this.match(x.OPERATOR,">");)if(this.match(x.IDENTIFIER))for(e+=this.advance().value;this.match(x.DOT)&&this.peek(1).type===x.IDENTIFIER;)e+=".",this.advance(),e+=this.advance().value;else if(this.match(x.COMMA))e+=this.advance().value,this.skipNewlines();else break;this.match(x.OPERATOR,">")&&(e+=">",this.advance())}else for(;this.peek().type===x.IDENTIFIER&&this.peek(1).type===x.IDENTIFIER;)e+=" "+this.advance().value;let i=this.expect(x.IDENTIFIER).value;this.functionNames.has(i)&&(i=i+"_var"),this.expect(x.OPERATOR,"="),this.skipNewlines(!0);const r=this.parseExpression(),n=new ne(i);return n.varType=e,new Fe([new je(n,r,e)],We.LET)}parseFunctionDeclaration(){let e=null;this.peek().type===x.IDENTIFIER&&this.peek(1).type===x.IDENTIFIER&&(e=this.advance().value);const i=this.expect(x.IDENTIFIER).value;this.functionNames.add(i),this.expect(x.LPAREN);const r=[];for(;!this.match(x.RPAREN)&&(this.skipNewlines(),!this.match(x.RPAREN));){let s=null;for(;this.peek().type===x.IDENTIFIER&&this.peek(1).type===x.IDENTIFIER&&this.peek(2).type!==x.LPAREN;)s&&(s+=" "),s=(s||"")+this.advance().value;const o=this.expect(x.IDENTIFIER).value,c=new ne(o);if(s&&(c.varType=s),this.match(x.OPERATOR,"=")){this.advance(),this.skipNewlines();const l=this.parseExpression();r.push(new wi(c,l))}else r.push(c);this.match(x.COMMA)&&this.advance()}this.expect(x.RPAREN),this.skipNewlines(),this.expect(x.OPERATOR,"=>"),this.skipNewlines();const n=this.parseFunctionBody(),a=new ne(i);return e&&(a.returnType=e),new fi(a,r,n,e)}parseMethodDeclaration(){this.expect(x.KEYWORD,"method");let e=null;this.peek().type===x.IDENTIFIER&&this.peek(1).type===x.IDENTIFIER&&this.peek(2).type===x.LPAREN&&(e=this.advance().value);const i=this.expect(x.IDENTIFIER).value;this.expect(x.LPAREN);const r=[];for(;!this.match(x.RPAREN)&&(this.skipNewlines(),!this.match(x.RPAREN));){let s=null;for(;this.peek().type===x.IDENTIFIER&&this.peek(1).type===x.IDENTIFIER&&this.peek(2).type!==x.LPAREN;)s&&(s+=" "),s=(s||"")+this.advance().value;const o=this.expect(x.IDENTIFIER).value,c=new ne(o);if(s&&(c.varType=s),this.match(x.OPERATOR,"=")){this.advance(),this.skipNewlines();const l=this.parseExpression();r.push(new wi(c,l))}else r.push(c);this.match(x.COMMA)&&this.advance()}this.expect(x.RPAREN),this.skipNewlines(),this.expect(x.OPERATOR,"=>"),this.skipNewlines();const n=this.parseFunctionBody(),a=new ne(i);return e&&(a.returnType=e),a.isMethod=!0,new fi(a,r,n,e)}parseFunctionBody(){const e=[];if(!this.match(x.INDENT)){const i=this.parseExpression();return new Ae([new mi(i)])}for(this.advance();!this.match(x.DEDENT)&&!this.match(x.EOF)&&(this.skipNewlines(),!this.match(x.DEDENT));){const i=this.parseStatementOrSequence();Array.isArray(i)?e.push(...i):i&&e.push(i)}if(this.match(x.DEDENT)&&this.advance(),e.length>0){const i=e[e.length-1];i.type==="ExpressionStatement"&&(e[e.length-1]=new mi(i.expression))}return new Ae(e)}parseStatementOrSequence(){this.pos;const e=this.peek().line;if(this.match(x.KEYWORD,"if")){const r=this.parseIfStatement();return r&&(r._line=e),r}if(this.match(x.KEYWORD,"for"))return this.parseForStatement();if(this.match(x.KEYWORD,"while"))return this.parseWhileStatement();if(this.match(x.KEYWORD,"break")||this.match(x.KEYWORD,"continue")){const r=this.advance().value;return new ue(new ne(r))}if(this.match(x.KEYWORD,"var")||this.match(x.KEYWORD,"varip"))return this.parseVarDeclaration();if(this.isTupleDestructuring())return this.parseTupleDestructuring();if(this.peek().type===x.IDENTIFIER&&this.isTypedVarDeclaration())return this.parseTypedVarDeclaration();const i=[];for(;;){const r=this.parseExpression();if(this.match(x.OPERATOR)){const n=this.peek().value;if(["=",":=","+=","-=","*=","/=","%="].includes(n)){this.advance(),this.skipNewlines(!0);const a=this.parseExpression();if(n==="="&&r.type==="Identifier"?i.push(new Fe([new je(r,a)],We.LET)):i.push(new ue(new ht(n===":="?"=":n,r,a))),this.match(x.COMMA)){this.advance(),this.skipNewlines();continue}break}else{if(i.length>0)i.push(new ue(r));else return new ue(r);break}}else if(this.match(x.COMMA)){i.push(new ue(r)),this.advance(),this.skipNewlines();continue}else{if(i.length>0)i.push(new ue(r));else return new ue(r);break}}return i.length>1?i:i.length===1?i[0]:null}parseIfStatement(){this.expect(x.KEYWORD,"if");const e=this.parseExpression();this.skipNewlines();const i=this.parseBlock();let r=null;return this.skipNewlines(),this.match(x.KEYWORD,"else")&&(this.advance(),this.skipNewlines(),this.match(x.KEYWORD,"if")?r=this.parseIfStatement():r=this.parseBlock()),new ls(e,i,r)}parseForStatement(){this.expect(x.KEYWORD,"for");let e=null,i=!1;if(this.match(x.LBRACKET)){this.advance();const r=[];for(;!this.match(x.RBRACKET);)this.skipNewlines(),r.push(new ne(this.expect(x.IDENTIFIER).value)),this.match(x.COMMA)&&this.advance();this.expect(x.RBRACKET),e=new vi(r),i=!0}else{const r=this.expect(x.IDENTIFIER).value;e=new ne(r)}if(this.match(x.KEYWORD,"in")){this.advance();const r=this.parseExpression();this.skipNewlines();const n=this.parseBlock(),a=new Fe([new je(e,r)],We.CONST),s=new di(a,null,null,n);return s.isForIn=!0,s}else{if(i)throw new Error(`Range-based for loops don't support destructuring at ${this.peek().line}:${this.peek().column}`);this.expect(x.OPERATOR,"=");const r=this.parseExpression();this.expect(x.KEYWORD,"to");const n=this.parseExpression();let a=null;this.match(x.KEYWORD,"by")&&(this.advance(),a=this.parseExpression()),this.skipNewlines();const s=this.parseBlock(),o=new Fe([new je(e,r)],We.LET),c=new Ee("<=",r,n),l=new Te(c,new Ee("<=",e,n),new Ee(">=",e,n));let u;return a?u=new Te(c,new ht("+=",e,a),new ht("-=",e,a)):u=new Te(c,new gi("++",e),new gi("--",e)),new di(o,l,u,s)}}parseWhileStatement(){this.expect(x.KEYWORD,"while");const e=this.parseExpression();this.skipNewlines();const i=this.parseBlock();return new us(e,i)}parseBlock(){if(!this.match(x.INDENT)){const r=this.parseStatement();return new Ae(r?[r]:[])}const e=this.peek().indent;this.advance();const i=[];for(;!this.match(x.EOF);){if(this.skipNewlines(),this.match(x.DEDENT)){if(this.peek().indent<e)break;this.advance();continue}if(this.match(x.EOF))break;const r=this.parseStatement();r&&i.push(r)}return this.match(x.DEDENT)&&this.peek().indent<e&&this.advance(),new Ae(i)}isTupleDestructuring(){if(!this.match(x.LBRACKET))return!1;let e=1;for(;;){for(;this.peek(e).type===x.NEWLINE;)e++;if(this.peek(e).type!==x.IDENTIFIER)return!1;for(e++;this.peek(e).type===x.NEWLINE;)e++;if(this.peek(e).type===x.RBRACKET){e++;break}else if(this.peek(e).type===x.COMMA){e++;continue}else return!1}for(;this.peek(e).type===x.NEWLINE;)e++;return this.peek(e).type===x.OPERATOR&&this.peek(e).value==="="}parseTupleDestructuring(){this.expect(x.LBRACKET);const e=[];for(;!this.match(x.RBRACKET);){this.skipNewlines();let r=this.expect(x.IDENTIFIER).value;this.functionNames.has(r)&&(r=r+"_var"),e.push(new ne(r)),this.match(x.COMMA)&&this.advance()}this.expect(x.RBRACKET),this.skipNewlines(),this.expect(x.OPERATOR,"="),this.skipNewlines(!0);const i=this.parseExpression();return new Fe([new je(new vi(e),i)],We.CONST)}parseExpression(){return this.parseTernary()}parseTernary(){let e=this.parseLogicalOr();if(this.matchEx(x.OPERATOR,"?",!0)){this.advance(),this.skipNewlines(!0);const i=this.parseExpression();this.matchEx(x.COLON,null,!0)?this.advance():this.expect(x.COLON),this.skipNewlines(!0);const r=this.parseExpression();return new Te(e,i,r)}return e}parseLogicalOr(){let e=this.parseLogicalAnd();for(;this.matchEx(x.KEYWORD,"or",!0)||this.matchEx(x.OPERATOR,null,!0)&&this.peek().value==="||";){this.advance(),this.skipNewlines(!0);const i=this.parseLogicalAnd();e=new Ee("||",e,i)}return e}parseLogicalAnd(){let e=this.parseEquality();for(;this.matchEx(x.KEYWORD,"and",!0)||this.matchEx(x.OPERATOR,null,!0)&&this.peek().value==="&&";){this.advance(),this.skipNewlines();const i=this.parseEquality();e=new Ee("&&",e,i)}return e}parseEquality(){let e=this.parseComparison();for(;this.matchEx(x.OPERATOR,null,!0);){const i=this.peek().value;if(!["==","!="].includes(i))break;this.advance(),this.skipNewlines(!0);const r=this.parseComparison();e=new Ee(i,e,r)}return e}parseComparison(){let e=this.parseAdditive();for(;this.matchEx(x.OPERATOR,null,!0);){const i=this.peek().value;if(!["<",">","<=",">="].includes(i))break;this.advance(),this.skipNewlines();const r=this.parseAdditive();e=new Ee(i,e,r)}return e}parseAdditive(){let e=this.parseMultiplicative();for(;this.matchEx(x.OPERATOR,null,!0);){const i=this.peek().value;if(!["+","-"].includes(i))break;this.advance(),this.skipNewlines(!0);const r=this.parseMultiplicative();e=new Ee(i,e,r)}return e}parseMultiplicative(){let e=this.parseUnary();for(;this.matchEx(x.OPERATOR,null,!0);){const i=this.peek().value;if(!["*","/","%"].includes(i))break;this.advance(),this.skipNewlines(!0);const r=this.parseUnary();e=new Ee(i,e,r)}return e}parseUnary(){if(this.match(x.OPERATOR)){const e=this.peek().value;if(["+","-","!"].includes(e))return this.advance(),this.skipNewlines(),new xi(e,this.parseUnary())}return this.match(x.KEYWORD,"not")?(this.advance(),this.skipNewlines(),new xi("!",this.parseUnary())):this.parsePostfix()}parsePostfix(){let e=this.parsePrimary();for(;;)if(this.match(x.OPERATOR,"<")){const i=this.pos;this.advance();let r=1,n=!0;for(;r>0&&!this.match(x.EOF);)if(this.match(x.OPERATOR,"<"))r++,this.advance();else if(this.match(x.OPERATOR,">"))r--,this.advance();else if(this.match(x.IDENTIFIER)||this.match(x.COMMA)||this.match(x.DOT))this.advance();else{n=!1,this.pos=i;break}if(n&&this.match(x.LPAREN)){e=this.parseCallExpression(e);continue}else{if(n)continue;break}}else if(this.match(x.LPAREN))e=this.parseCallExpression(e);else if(this.match(x.DOT)){this.advance(),this.skipNewlines();const i=this.expect(x.IDENTIFIER).value;e=new yi(e,new ne(i),!1)}else if(this.match(x.LBRACKET)){this.advance(),this.skipNewlines();const i=this.parseExpression();this.expect(x.RBRACKET),e=new yi(e,i,!0)}else break;return e}parseCallExpression(e){this.expect(x.LPAREN);const i=[],r=[];for(;!this.match(x.RPAREN)&&(this.skipNewlines(),!this.match(x.RPAREN));){if((this.peek().type===x.IDENTIFIER||this.peek().type===x.KEYWORD)&&this.peek(1).type===x.OPERATOR&&this.peek(1).value==="="){const n=this.advance().value;this.advance(),this.skipNewlines();const a=this.parseExpression();r.push(new ds(new ne(n),a))}else i.push(this.parseExpression());this.match(x.COMMA)&&this.advance(),this.skipNewlines()}return this.expect(x.RPAREN),r.length>0&&i.push(new fs(r)),new hs(e,i)}parsePrimary(){const e=this.peek();if(this.match(x.NUMBER)){const i=this.advance();return new Ye(i.value)}if(this.match(x.STRING)){const i=this.advance();return new Ye(i.value)}if(this.match(x.BOOLEAN)){const i=this.advance();return new Ye(i.value)}if(this.match(x.IDENTIFIER)){let i=this.advance().value;return this.functionNames.has(i)&&this.peek().type!==x.LPAREN&&(i=i+"_var"),new ne(i)}if(this.match(x.LBRACKET))return this.parseArrayLiteral();if(this.match(x.LPAREN)){this.advance(),this.skipNewlines();const i=this.parseExpression();return this.skipNewlines(),this.expect(x.RPAREN),i}if(this.match(x.KEYWORD,"if"))return this.parseIfExpression();if(this.match(x.KEYWORD,"switch"))return this.parseSwitchExpression();throw new Error(`Unexpected token ${e.type} '${e.value}' at ${e.line}:${e.column}`)}parseArrayLiteral(){this.expect(x.LBRACKET);const e=[];for(;!this.match(x.RBRACKET)&&(this.skipNewlines(),!this.match(x.RBRACKET));)e.push(this.parseExpression()),this.match(x.COMMA)&&this.advance(),this.skipNewlines();return this.expect(x.RBRACKET),new ps(e)}parseIfExpression(){this.expect(x.KEYWORD,"if");const e=this.parseExpression();this.skipNewlines(),this.expect(x.INDENT);const i=[];for(;!this.match(x.DEDENT)&&!this.match(x.EOF)&&(this.skipNewlines(),!this.match(x.DEDENT));){const s=this.parseStatement();s&&i.push(s)}this.advance();let r=[];if(this.match(x.KEYWORD,"else"))if(this.advance(),this.skipNewlines(),this.match(x.KEYWORD,"if")){const s=this.parseIfExpression();if(this.needsIIFE(i,r)){const o=new Te(e,new Ae(i),s);return o.needsIIFE=!0,o.consequentStmts=i,o.alternateExpr=s,o}else return new Te(e,this.getBlockValue(i),s)}else{for(this.expect(x.INDENT);!this.match(x.DEDENT)&&!this.match(x.EOF)&&(this.skipNewlines(),!this.match(x.DEDENT));){const s=this.parseStatement();s&&r.push(s)}this.advance()}if(this.needsIIFE(i,r)){const s=new Te(e,new Ae(i),new Ae(r));return s.needsIIFE=!0,s.consequentStmts=i,s.alternateStmts=r,s}const n=this.getBlockValue(i),a=r.length>0?this.getBlockValue(r):new Ye(null);return new Te(e,n,a)}needsIIFE(e,i){if(e.length>1||i.length>1)return!0;const r=n=>n.some(a=>a.type==="IfStatement"||a.type==="ForStatement"||a.type==="WhileStatement"||a.type==="BlockStatement");return r(e)||r(i)}parseSwitchExpression(){this.expect(x.KEYWORD,"switch");let e=null;!this.match(x.NEWLINE)&&!this.match(x.INDENT)&&(e=this.parseExpression()),this.skipNewlines(),this.expect(x.INDENT);const i=[];for(;!this.match(x.DEDENT)&&!this.match(x.EOF)&&(this.skipNewlines(),!this.match(x.DEDENT));){let r=null;this.match(x.OPERATOR,"=>")||(r=this.parseExpression()),this.expect(x.OPERATOR,"=>"),this.skipNewlines();const n=[];if(this.match(x.INDENT)){for(this.advance();!this.match(x.DEDENT)&&!this.match(x.EOF)&&(this.skipNewlines(),!this.match(x.DEDENT));){const s=this.parseStatement();s&&n.push(s)}this.advance()}else n.push(new ue(this.parseExpression()));const a=this.getBlockValue(n);i.push(new xs(r,a,n)),this.skipNewlines()}return this.advance(),new ms(e,i)}getBlockValue(e){if(e.length===0)return new Ye(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 Ye(null)}}class ys{indent;indentStr;output;sourceCode;sourceLines;lastCommentedLine;includeSourceComments;constructor(e={}){this.indent=0,this.indentStr=e.indentStr||" ",this.output=[],this.sourceCode=e.sourceCode||null,this.sourceLines=this.sourceCode?this.sourceCode.split(`
37
+ `||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(g.INDENT,"",e);else if(e<r){for(;this.indentStack.length>1&&this.indentStack[this.indentStack.length-1]>e;)this.indentStack.pop(),this.addToken(g.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()!==`
38
+ `;)e+=this.advance();this.addToken(g.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 n=this.advance();switch(n){case"n":r+=`
39
+ `;break;case"t":r+=" ";break;case"r":r+="\r";break;case"\\":r+="\\";break;case e:r+=e;break;default:r+=n}}else r+=this.advance();if(this.peek()!==e)throw new Error(`Unterminated string at ${this.line}:${i}`);this.advance(),this.addToken(g.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(g.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 n=this.peek(1);if(this.isDigit(n)||!this.isIdentifierStart(n)){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 n=this.peek(1);if(this.isDigit(n))for(e+=this.advance();this.pos<this.source.length&&this.isDigit(this.peek());)e+=this.advance();else if(n==="+"||n==="-"){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(g.NUMBER,parseFloat(e))}readIdentifier(){this.column;let e="";for(;this.pos<this.source.length&&this.isIdentifierChar(this.peek());)e+=this.advance();gs.has(e)?this.addToken(g.KEYWORD,e):e==="true"||e==="false"?this.addToken(g.BOOLEAN,e==="true"):this.addToken(g.IDENTIFIER,e)}readOperatorOrPunctuation(){const e=this.peek(),i=this.peek(1),r=e+i;if(xs.includes(r))return this.advance(),this.advance(),this.addToken(g.OPERATOR,r),!0;if("+-*/%<>=!?".includes(e))return this.advance(),this.addToken(g.OPERATOR,e),!0;switch(e){case"(":return this.parenDepth++,this.advance(),this.addToken(g.LPAREN,e),!0;case")":return this.parenDepth--,this.advance(),this.addToken(g.RPAREN,e),!0;case"[":return this.bracketDepth++,this.advance(),this.addToken(g.LBRACKET,e),!0;case"]":return this.bracketDepth--,this.advance(),this.addToken(g.RBRACKET,e),!0;case"{":return this.braceDepth++,this.advance(),this.addToken(g.LBRACE,e),!0;case"}":return this.braceDepth--,this.advance(),this.addToken(g.RBRACE,e),!0;case",":return this.advance(),this.addToken(g.COMMA,e),!0;case".":return this.isDigit(this.peek(1))?(this.readNumber(),!0):(this.advance(),this.addToken(g.DOT,e),!0);case":":return this.advance(),this.addToken(g.COLON,e),!0;case";":return this.advance(),this.addToken(g.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 n=new ys(e,i,this.line,this.column,r!==null?r:this.getCurrentIndent());this.tokens.push(n)}}class B{constructor(e){this.type=e}}class vs extends B{constructor(e){super("Program"),this.body=e}}class he extends B{constructor(e){super("ExpressionStatement"),this.expression=e}}var Oe=(t=>(t.VAR="var",t.LET="let",t.CONST="const",t))(Oe||{});class Ae extends B{constructor(e,i="let"){super("VariableDeclaration"),this.declarations=e,this.kind=i}}class Te extends B{constructor(e,i,r=null){super("VariableDeclarator"),this.id=e,this.init=i,this.varType=r}}class xi extends B{constructor(e,i,r,n=null){super("FunctionDeclaration"),this.id=e,this.params=i,this.body=r,this.returnType=n}}class bs extends B{constructor(e,i){super("TypeDefinition"),this.name=e,this.fields=i}}class ws extends B{constructor(e,i,r=null){super("IfStatement"),this.test=e,this.consequent=i,this.alternate=r}_line}class yi extends B{constructor(e,i,r,n){super("ForStatement"),this.init=e,this.test=i,this.update=r,this.body=n}isForIn}class Ss extends B{constructor(e,i){super("WhileStatement"),this.test=e,this.body=i}}class Pe extends B{constructor(e){super("BlockStatement"),this.body=e}}class _i extends B{constructor(e){super("ReturnStatement"),this.argument=e}}class Y extends B{constructor(e){super("Identifier"),this.name=e}varType;returnType;isMethod}class $e extends B{constructor(e,i=null){super("Literal"),this.value=e,this.raw=i}}class Ne extends B{constructor(e,i,r){super("BinaryExpression"),this.operator=e,this.left=i,this.right=r}}class vi extends B{constructor(e,i,r=!0){super("UnaryExpression"),this.operator=e,this.argument=i,this.prefix=r}}class pt extends B{constructor(e,i,r){super("AssignmentExpression"),this.operator=e,this.left=i,this.right=r}}class bi extends B{constructor(e,i,r=!1){super("UpdateExpression"),this.operator=e,this.argument=i,this.prefix=r}}class Es extends B{constructor(e,i){super("CallExpression"),this.callee=e,this.args=i,this.callee=e,this.arguments=i}arguments}class wi extends B{constructor(e,i,r=!1){super("MemberExpression"),this.object=e,this.property=i,this.computed=r}}class De extends B{constructor(e,i,r){super("ConditionalExpression"),this.test=e,this.consequent=i,this.alternate=r}needsIIFE;consequentStmts;alternateStmts}class Ns extends B{constructor(e){super("ArrayExpression"),this.elements=e}}class Si extends B{constructor(e){super("ObjectExpression"),this.properties=e}}class Ei extends B{constructor(e,i){super("Property"),this.key=e,this.value=i,this.kind="init",this.method=!1,this.shorthand=!1,this.computed=!1}kind;method;shorthand;computed}class Ni extends B{constructor(e){super("ArrayPattern"),this.elements=e}}class Ci extends B{constructor(e,i){super("AssignmentPattern"),this.left=e,this.right=i}}class Cs extends B{constructor(e,i){super("SwitchExpression"),this.discriminant=e,this.cases=i}}class Is extends B{constructor(e,i,r){super("SwitchCase"),this.test=e,this.consequent=i,this.statements=r,this.statements=r}}class ks{tokens;pos;functionNames=new Set;constructor(e){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 n=0,a=this.peek(n);if(a.type===g.NEWLINE&&(n++,a=this.peek(n),a.type===g.INDENT&&(n++,a=this.peek(n))),a.type!==e||i!==null&&a.value!==i)return!1;for(let s=0;s<n;s++)this.advance();return!0}peekOperatorEx(e){let i=0,r=this.peek(i),n=!1;if(r.type===g.NEWLINE&&(i++,r=this.peek(i),r.type===g.INDENT&&(n=!0,i++,r=this.peek(i))),r.type!==g.OPERATOR||!e.includes(r.value)||n&&(r.value==="+"||r.value==="-"))return null;for(let a=0;a<i;a++)this.advance();return r.value}skipNewlines(e=!1){for(;this.match(g.NEWLINE)||this.match(g.COMMENT);)this.advance();e&&this.match(g.INDENT)&&this.advance()}parse(){const e=[];for(;!this.match(g.EOF);){if(this.skipNewlines(),this.match(g.DEDENT)){this.advance();continue}if(this.match(g.EOF))break;const i=this.parseStatement();i&&e.push(i),this.skipNewlines()}return new vs(e)}parseStatement(e=!0){this.skipNewlines();const i=this.peek().line;if(this.match(g.COMMENT))return this.advance(),null;let r;if(this.match(g.KEYWORD,"enum"))r=this.parseEnumDefinition();else if(this.match(g.KEYWORD,"type"))r=this.parseTypeDefinition();else if(this.match(g.KEYWORD,"var")||this.match(g.KEYWORD,"varip"))r=this.parseVarDeclaration();else if(this.match(g.KEYWORD,"method"))r=this.parseMethodDeclaration();else if(this.isFunctionDeclaration())r=this.parseFunctionDeclaration();else if(this.match(g.KEYWORD,"if"))r=this.parseIfStatement();else if(this.match(g.KEYWORD,"for"))r=this.parseForStatement();else if(this.match(g.KEYWORD,"while"))r=this.parseWhileStatement();else if(this.match(g.KEYWORD,"break")||this.match(g.KEYWORD,"continue")){const n=this.advance().value;r=new he(new Y(n))}else this.isTupleDestructuring()?r=this.parseTupleDestructuring():this.peek().type===g.IDENTIFIER&&this.isTypedVarDeclaration()&&(r=this.parseTypedVarDeclaration());if(!r){const n=this.parseExpression();if(this.match(g.OPERATOR)){const a=this.peek().value;if(["=",":=","+=","-=","*=","/=","%="].includes(a)){this.advance(),this.skipNewlines(!0);const s=this.parseExpression();a==="="&&n.type==="Identifier"?r=new Ae([new Te(n,s)],Oe.LET):r=new he(new pt(a===":="?"=":a,n,s))}else r=new he(n)}else r=new he(n)}if(r&&(r._line=i,e&&this.match(g.COMMA)&&this.peek().line===i)){const n=[r];for(;this.match(g.COMMA)&&this.peek().line===i;){this.advance(),this.skipNewlines(!0);const a=this.parseStatement(!1);a&&n.push(a)}return new Pe(n)}return r}isFunctionDeclaration(){const e=this.pos;try{let i=0;if(this.peek(i).type===g.IDENTIFIER&&this.peek(i+1).type===g.IDENTIFIER&&i++,this.peek(i).type!==g.IDENTIFIER||(i++,this.peek(i).type!==g.LPAREN))return!1;i++;let r=1;for(;r>0&&this.peek(i).type!==g.EOF;)this.peek(i).type===g.LPAREN&&r++,this.peek(i).type===g.RPAREN&&r--,i++;for(;this.peek(i).type===g.NEWLINE;)i++;return this.peek(i).type===g.OPERATOR&&this.peek(i).value==="=>"}finally{this.pos=e}}parseTypeExpression(){let e=this.expect(g.IDENTIFIER).value;for(;this.match(g.DOT)&&this.peek(1).type===g.IDENTIFIER;)this.advance(),e+="."+this.advance().value;if(this.match(g.OPERATOR,"<")){this.advance();const i=[];for(i.push(this.parseTypeExpression());this.match(g.COMMA);)this.advance(),this.skipNewlines(),i.push(this.parseTypeExpression());return this.expect(g.OPERATOR,">"),e+"<"+i.join(", ")+">"}return e}parseEnumDefinition(){this.expect(g.KEYWORD,"enum");const e=this.expect(g.IDENTIFIER).value;this.skipNewlines(),this.expect(g.INDENT);const i=[];for(;!this.match(g.DEDENT)&&!this.match(g.EOF)&&(this.skipNewlines(),!this.match(g.DEDENT));){if(this.match(g.COMMENT)){this.advance();continue}const a=this.expect(g.IDENTIFIER).value;i.push(a),this.skipNewlines()}this.match(g.DEDENT)&&this.advance();const r=i.map(a=>new Ei(new Y(a),new $e(`${e}.${a}`))),n=new Si(r);return new Ae([new Te(new Y(e),n)],Oe.CONST)}parseTypeDefinition(){this.expect(g.KEYWORD,"type");const e=this.expect(g.IDENTIFIER).value;this.match(g.OPERATOR,"=>")&&this.advance(),this.skipNewlines(),this.expect(g.INDENT);const i=[];for(;!this.match(g.DEDENT)&&!this.match(g.EOF)&&(this.skipNewlines(),!this.match(g.DEDENT));){const r=this.parseTypeExpression(),n=this.expect(g.IDENTIFIER).value;let a=null;this.match(g.OPERATOR,"=")&&(this.advance(),this.skipNewlines(),a=this.parseExpression()),i.push({type:r,name:n,defaultValue:a}),this.skipNewlines()}return this.match(g.DEDENT)&&this.advance(),new bs(e,i)}parseVarDeclaration(){const e=this.advance().value;let i=null,r=null;if(this.peek().type===g.IDENTIFIER&&this.peek(1).type===g.LBRACKET&&this.peek(2).type===g.RBRACKET)i=this.advance().value,this.advance(),i+="[]",this.advance(),r=this.expect(g.IDENTIFIER).value;else if(this.peek().type===g.IDENTIFIER&&(this.peek(1).type===g.DOT||this.peek(1).type===g.IDENTIFIER||this.peek(1).type===g.OPERATOR&&this.peek(1).value==="<")){for(i=this.advance().value;this.match(g.DOT)&&this.peek(1).type===g.IDENTIFIER;)this.advance(),i+="."+this.advance().value;if(this.match(g.LBRACKET)&&this.peek(1).type===g.RBRACKET)this.advance(),this.advance(),i+="[]",r=this.expect(g.IDENTIFIER).value;else if(this.match(g.OPERATOR,"<")){for(this.advance(),i+="<";!this.match(g.OPERATOR,">");)if(this.match(g.IDENTIFIER))for(i+=this.advance().value;this.match(g.DOT)&&this.peek(1).type===g.IDENTIFIER;)i+=".",this.advance(),i+=this.advance().value;else if(this.match(g.COMMA))i+=this.advance().value,this.skipNewlines();else break;this.match(g.OPERATOR,">")&&(i+=">",this.advance()),r=this.expect(g.IDENTIFIER).value}else r=this.expect(g.IDENTIFIER).value}else if(this.peek().type===g.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(g.OPERATOR,"="),this.skipNewlines(!0);const n=this.parseExpression(),a=new Y(r);return i&&(a.varType=i),new Ae([new Te(a,n,i)],e)}isTypedVarDeclaration(){let e=0;if(this.peek(e).type!==g.IDENTIFIER)return!1;for(e++;this.peek(e).type===g.DOT&&this.peek(e+1).type===g.IDENTIFIER;)e+=2;if(this.peek(e).type===g.LBRACKET&&this.peek(e+1).type===g.RBRACKET)return e+=2,this.peek(e).type!==g.IDENTIFIER?!1:(e++,this.peek(e).type===g.OPERATOR&&this.peek(e).value==="=");if(this.peek(e).type===g.OPERATOR&&this.peek(e).value==="<"){e++;let i=1;for(;i>0&&this.peek(e).type!==g.EOF;)this.peek(e).type===g.OPERATOR&&this.peek(e).value==="<"?i++:this.peek(e).type===g.OPERATOR&&this.peek(e).value===">"&&i--,e++;return this.peek(e).type!==g.IDENTIFIER?!1:(e++,this.peek(e).type===g.OPERATOR&&this.peek(e).value==="=")}if(this.peek(e).type!==g.IDENTIFIER)return!1;for(e++;this.peek(e).type===g.IDENTIFIER;)e++;return this.peek(e).type===g.OPERATOR&&this.peek(e).value==="="}parseTypedVarDeclaration(){let e=this.advance().value;for(;this.match(g.DOT)&&this.peek(1).type===g.IDENTIFIER;)this.advance(),e+="."+this.advance().value;if(this.match(g.LBRACKET)&&this.peek(1).type===g.RBRACKET)this.advance(),this.advance(),e+="[]";else if(this.match(g.OPERATOR,"<")){for(this.advance(),e+="<";!this.match(g.OPERATOR,">");)if(this.match(g.IDENTIFIER))for(e+=this.advance().value;this.match(g.DOT)&&this.peek(1).type===g.IDENTIFIER;)e+=".",this.advance(),e+=this.advance().value;else if(this.match(g.COMMA))e+=this.advance().value,this.skipNewlines();else break;this.match(g.OPERATOR,">")&&(e+=">",this.advance())}else for(;this.peek().type===g.IDENTIFIER&&this.peek(1).type===g.IDENTIFIER;)e+=" "+this.advance().value;let i=this.expect(g.IDENTIFIER).value;this.functionNames.has(i)&&(i=i+"_var"),this.expect(g.OPERATOR,"="),this.skipNewlines(!0);const r=this.parseExpression(),n=new Y(i);return n.varType=e,new Ae([new Te(n,r,e)],Oe.LET)}parseFunctionDeclaration(){let e=null;this.peek().type===g.IDENTIFIER&&this.peek(1).type===g.IDENTIFIER&&(e=this.advance().value);const i=this.expect(g.IDENTIFIER).value;this.functionNames.add(i),this.expect(g.LPAREN);const r=[];for(;!this.match(g.RPAREN)&&(this.skipNewlines(),!this.match(g.RPAREN));){let s=null;for(;this.peek().type===g.IDENTIFIER&&this.peek(1).type===g.IDENTIFIER&&this.peek(2).type!==g.LPAREN;)s&&(s+=" "),s=(s||"")+this.advance().value;const o=this.expect(g.IDENTIFIER).value,l=new Y(o);if(s&&(l.varType=s),this.match(g.OPERATOR,"=")){this.advance(),this.skipNewlines();const c=this.parseExpression();r.push(new Ci(l,c))}else r.push(l);this.match(g.COMMA)&&this.advance()}this.expect(g.RPAREN),this.skipNewlines(),this.expect(g.OPERATOR,"=>"),this.skipNewlines();const n=this.parseFunctionBody(),a=new Y(i);return e&&(a.returnType=e),new xi(a,r,n,e)}parseMethodDeclaration(){this.expect(g.KEYWORD,"method");let e=null;this.peek().type===g.IDENTIFIER&&this.peek(1).type===g.IDENTIFIER&&this.peek(2).type===g.LPAREN&&(e=this.advance().value);const i=this.expect(g.IDENTIFIER).value;this.expect(g.LPAREN);const r=[];for(;!this.match(g.RPAREN)&&(this.skipNewlines(),!this.match(g.RPAREN));){let s=null;for(;this.peek().type===g.IDENTIFIER&&this.peek(1).type===g.IDENTIFIER&&this.peek(2).type!==g.LPAREN;)s&&(s+=" "),s=(s||"")+this.advance().value;const o=this.expect(g.IDENTIFIER).value,l=new Y(o);if(s&&(l.varType=s),this.match(g.OPERATOR,"=")){this.advance(),this.skipNewlines();const c=this.parseExpression();r.push(new Ci(l,c))}else r.push(l);this.match(g.COMMA)&&this.advance()}this.expect(g.RPAREN),this.skipNewlines(),this.expect(g.OPERATOR,"=>"),this.skipNewlines();const n=this.parseFunctionBody(),a=new Y(i);return e&&(a.returnType=e),a.isMethod=!0,new xi(a,r,n,e)}parseFunctionBody(){const e=[];if(!this.match(g.INDENT)){const i=this.parseExpression();return new Pe([new _i(i)])}for(this.advance();!this.match(g.DEDENT)&&!this.match(g.EOF)&&(this.skipNewlines(),!this.match(g.DEDENT));){const i=this.parseStatementOrSequence();Array.isArray(i)?e.push(...i):i&&e.push(i)}if(this.match(g.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 Pe(e)}parseStatementOrSequence(){this.pos;const e=this.peek().line;if(this.match(g.KEYWORD,"if")){const r=this.parseIfStatement();return r&&(r._line=e),r}if(this.match(g.KEYWORD,"for"))return this.parseForStatement();if(this.match(g.KEYWORD,"while"))return this.parseWhileStatement();if(this.match(g.KEYWORD,"break")||this.match(g.KEYWORD,"continue")){const r=this.advance().value;return new he(new Y(r))}if(this.match(g.KEYWORD,"var")||this.match(g.KEYWORD,"varip"))return this.parseVarDeclaration();if(this.isTupleDestructuring())return this.parseTupleDestructuring();if(this.peek().type===g.IDENTIFIER&&this.isTypedVarDeclaration())return this.parseTypedVarDeclaration();const i=[];for(;;){const r=this.parseExpression();if(this.match(g.OPERATOR)){const n=this.peek().value;if(["=",":=","+=","-=","*=","/=","%="].includes(n)){this.advance(),this.skipNewlines(!0);const a=this.parseExpression();if(n==="="&&r.type==="Identifier"?i.push(new Ae([new Te(r,a)],Oe.LET)):i.push(new he(new pt(n===":="?"=":n,r,a))),this.match(g.COMMA)){this.advance(),this.skipNewlines();continue}break}else{if(i.length>0)i.push(new he(r));else return new he(r);break}}else if(this.match(g.COMMA)){i.push(new he(r)),this.advance(),this.skipNewlines();continue}else{if(i.length>0)i.push(new he(r));else return new he(r);break}}return i.length>1?i:i.length===1?i[0]:null}parseIfStatement(){this.expect(g.KEYWORD,"if");const e=this.parseExpression();this.skipNewlines();const i=this.parseBlock();let r=null;return this.skipNewlines(),this.match(g.KEYWORD,"else")&&(this.advance(),this.skipNewlines(),this.match(g.KEYWORD,"if")?r=this.parseIfStatement():r=this.parseBlock()),new ws(e,i,r)}parseForStatement(){this.expect(g.KEYWORD,"for");let e=null,i=!1;if(this.match(g.LBRACKET)){this.advance();const r=[];for(;!this.match(g.RBRACKET);)this.skipNewlines(),r.push(new Y(this.expect(g.IDENTIFIER).value)),this.match(g.COMMA)&&this.advance();this.expect(g.RBRACKET),e=new Ni(r),i=!0}else{const r=this.expect(g.IDENTIFIER).value;e=new Y(r)}if(this.match(g.KEYWORD,"in")){this.advance();const r=this.parseExpression();this.skipNewlines();const n=this.parseBlock(),a=new Ae([new Te(e,r)],Oe.CONST),s=new yi(a,null,null,n);return s.isForIn=!0,s}else{if(i)throw new Error(`Range-based for loops don't support destructuring at ${this.peek().line}:${this.peek().column}`);this.expect(g.OPERATOR,"=");const r=this.parseExpression();this.expect(g.KEYWORD,"to");const n=this.parseExpression();let a=null;this.match(g.KEYWORD,"by")&&(this.advance(),a=this.parseExpression()),this.skipNewlines();const s=this.parseBlock(),o=new Ae([new Te(e,r)],Oe.LET),l=new Ne("<=",r,n),c=new De(l,new Ne("<=",e,n),new Ne(">=",e,n));let u;return a?u=new De(l,new pt("+=",e,a),new pt("-=",e,a)):u=new De(l,new bi("++",e),new bi("--",e)),new yi(o,c,u,s)}}parseWhileStatement(){this.expect(g.KEYWORD,"while");const e=this.parseExpression();this.skipNewlines();const i=this.parseBlock();return new Ss(e,i)}parseBlock(){if(!this.match(g.INDENT)){const r=this.parseStatement();return new Pe(r?[r]:[])}const e=this.peek().indent;this.advance();const i=[];for(;!this.match(g.EOF);){if(this.skipNewlines(),this.match(g.DEDENT)){if(this.peek().indent<e)break;this.advance();continue}if(this.match(g.EOF))break;const r=this.parseStatement();r&&i.push(r)}return this.match(g.DEDENT)&&this.peek().indent<e&&this.advance(),new Pe(i)}isTupleDestructuring(){if(!this.match(g.LBRACKET))return!1;let e=1;for(;;){for(;this.peek(e).type===g.NEWLINE;)e++;if(this.peek(e).type!==g.IDENTIFIER)return!1;for(e++;this.peek(e).type===g.NEWLINE;)e++;if(this.peek(e).type===g.RBRACKET){e++;break}else if(this.peek(e).type===g.COMMA){e++;continue}else return!1}for(;this.peek(e).type===g.NEWLINE;)e++;return this.peek(e).type===g.OPERATOR&&this.peek(e).value==="="}parseTupleDestructuring(){this.expect(g.LBRACKET);const e=[];for(;!this.match(g.RBRACKET);){this.skipNewlines();let r=this.expect(g.IDENTIFIER).value;this.functionNames.has(r)&&(r=r+"_var"),e.push(new Y(r)),this.match(g.COMMA)&&this.advance()}this.expect(g.RBRACKET),this.skipNewlines(),this.expect(g.OPERATOR,"="),this.skipNewlines(!0);const i=this.parseExpression();return new Ae([new Te(new Ni(e),i)],Oe.CONST)}parseExpression(){return this.parseTernary()}parseTernary(){let e=this.parseLogicalOr();if(this.matchEx(g.OPERATOR,"?",!0)){this.advance(),this.skipNewlines(!0);const i=this.parseExpression();this.matchEx(g.COLON,null,!0)?this.advance():this.expect(g.COLON),this.skipNewlines(!0);const r=this.parseExpression();return new De(e,i,r)}return e}parseLogicalOr(){let e=this.parseLogicalAnd();for(;this.matchEx(g.KEYWORD,"or",!0)||this.peekOperatorEx(["||"]);){this.advance(),this.skipNewlines(!0);const i=this.parseLogicalAnd();e=new Ne("||",e,i)}return e}parseLogicalAnd(){let e=this.parseEquality();for(;this.matchEx(g.KEYWORD,"and",!0)||this.peekOperatorEx(["&&"]);){this.advance(),this.skipNewlines();const i=this.parseEquality();e=new Ne("&&",e,i)}return e}parseEquality(){let e=this.parseComparison();for(;this.peekOperatorEx(["==","!="]);){const i=this.advance().value;this.skipNewlines(!0);const r=this.parseComparison();e=new Ne(i,e,r)}return e}parseComparison(){let e=this.parseAdditive();for(;this.peekOperatorEx(["<",">","<=",">="]);){const i=this.advance().value;this.skipNewlines();const r=this.parseAdditive();e=new Ne(i,e,r)}return e}parseAdditive(){let e=this.parseMultiplicative();for(;this.peekOperatorEx(["+","-"]);){const i=this.advance().value;this.skipNewlines(!0);const r=this.parseMultiplicative();e=new Ne(i,e,r)}return e}parseMultiplicative(){let e=this.parseUnary();for(;this.peekOperatorEx(["*","/","%"]);){const i=this.advance().value;this.skipNewlines(!0);const r=this.parseUnary();e=new Ne(i,e,r)}return e}parseUnary(){if(this.match(g.OPERATOR)){const e=this.peek().value;if(["+","-","!"].includes(e))return this.advance(),this.skipNewlines(),new vi(e,this.parseUnary())}return this.match(g.KEYWORD,"not")?(this.advance(),this.skipNewlines(),new vi("!",this.parseUnary())):this.parsePostfix()}parsePostfix(){let e=this.parsePrimary();for(;;)if(this.match(g.OPERATOR,"<")){const i=this.pos;this.advance();let r=1,n=!0;for(;r>0&&!this.match(g.EOF);)if(this.match(g.OPERATOR,"<"))r++,this.advance();else if(this.match(g.OPERATOR,">"))r--,this.advance();else if(this.match(g.IDENTIFIER)||this.match(g.COMMA)||this.match(g.DOT))this.advance();else{n=!1,this.pos=i;break}if(n&&this.match(g.LPAREN)){e=this.parseCallExpression(e);continue}else{if(n)continue;break}}else if(this.match(g.LPAREN))e=this.parseCallExpression(e);else if(this.match(g.DOT)){this.advance(),this.skipNewlines();const i=this.expect(g.IDENTIFIER).value;e=new wi(e,new Y(i),!1)}else if(this.match(g.LBRACKET)){this.advance(),this.skipNewlines();const i=this.parseExpression();this.expect(g.RBRACKET),e=new wi(e,i,!0)}else break;return e}parseCallExpression(e){this.expect(g.LPAREN);const i=[],r=[];for(;!this.match(g.RPAREN)&&(this.skipNewlines(),!this.match(g.RPAREN));){if((this.peek().type===g.IDENTIFIER||this.peek().type===g.KEYWORD)&&this.peek(1).type===g.OPERATOR&&this.peek(1).value==="="){const n=this.advance().value;this.advance(),this.skipNewlines();const a=this.parseExpression();r.push(new Ei(new Y(n),a))}else i.push(this.parseExpression());this.match(g.COMMA)&&this.advance(),this.skipNewlines()}return this.expect(g.RPAREN),r.length>0&&i.push(new Si(r)),new Es(e,i)}parsePrimary(){const e=this.peek();if(this.match(g.NUMBER)){const i=this.advance();return new $e(i.value)}if(this.match(g.STRING)){const i=this.advance();return new $e(i.value)}if(this.match(g.BOOLEAN)){const i=this.advance();return new $e(i.value)}if(this.match(g.IDENTIFIER)){let i=this.advance().value;return this.functionNames.has(i)&&this.peek().type!==g.LPAREN&&(i=i+"_var"),new Y(i)}if(this.match(g.LBRACKET))return this.parseArrayLiteral();if(this.match(g.LPAREN)){this.advance(),this.skipNewlines();const i=this.parseExpression();return this.skipNewlines(),this.expect(g.RPAREN),i}if(this.match(g.KEYWORD,"if"))return this.parseIfExpression();if(this.match(g.KEYWORD,"switch"))return this.parseSwitchExpression();if(this.match(g.KEYWORD,"for"))return this.parseForExpression();if(this.match(g.KEYWORD,"while"))return this.parseWhileExpression();throw new Error(`Unexpected token ${e.type} '${e.value}' at ${e.line}:${e.column}`)}parseArrayLiteral(){this.expect(g.LBRACKET);const e=[];for(;!this.match(g.RBRACKET)&&(this.skipNewlines(),!this.match(g.RBRACKET));)e.push(this.parseExpression()),this.match(g.COMMA)&&this.advance(),this.skipNewlines();return this.expect(g.RBRACKET),new Ns(e)}parseIfExpression(){this.expect(g.KEYWORD,"if");const e=this.parseExpression();this.skipNewlines(),this.expect(g.INDENT);const i=[];for(;!this.match(g.DEDENT)&&!this.match(g.EOF)&&(this.skipNewlines(),!this.match(g.DEDENT));){const s=this.parseStatement();s&&i.push(s)}this.advance();let r=[];if(this.match(g.KEYWORD,"else"))if(this.advance(),this.skipNewlines(),this.match(g.KEYWORD,"if")){const s=this.parseIfExpression();if(this.needsIIFE(i,r)){const o=new De(e,new Pe(i),s);return o.needsIIFE=!0,o.consequentStmts=i,o.alternateExpr=s,o}else return new De(e,this.getBlockValue(i),s)}else{for(this.expect(g.INDENT);!this.match(g.DEDENT)&&!this.match(g.EOF)&&(this.skipNewlines(),!this.match(g.DEDENT));){const s=this.parseStatement();s&&r.push(s)}this.advance()}if(this.needsIIFE(i,r)){const s=new De(e,new Pe(i),new Pe(r));return s.needsIIFE=!0,s.consequentStmts=i,s.alternateStmts=r,s}const n=this.getBlockValue(i),a=r.length>0?this.getBlockValue(r):new $e(null);return new De(e,n,a)}needsIIFE(e,i){if(e.length>1||i.length>1)return!0;const r=n=>n.some(a=>a.type==="IfStatement"||a.type==="ForStatement"||a.type==="WhileStatement"||a.type==="BlockStatement");return r(e)||r(i)}parseSwitchExpression(){this.expect(g.KEYWORD,"switch");let e=null;!this.match(g.NEWLINE)&&!this.match(g.INDENT)&&(e=this.parseExpression()),this.skipNewlines(),this.expect(g.INDENT);const i=[];for(;!this.match(g.DEDENT)&&!this.match(g.EOF)&&(this.skipNewlines(),!this.match(g.DEDENT));){let r=null;this.match(g.OPERATOR,"=>")||(r=this.parseExpression()),this.expect(g.OPERATOR,"=>"),this.skipNewlines();const n=[];if(this.match(g.INDENT)){for(this.advance();!this.match(g.DEDENT)&&!this.match(g.EOF)&&(this.skipNewlines(),!this.match(g.DEDENT));){const s=this.parseStatement();s&&n.push(s)}this.advance()}else n.push(new he(this.parseExpression()));const a=this.getBlockValue(n);i.push(new Is(r,a,n)),this.skipNewlines()}return this.advance(),new Cs(e,i)}parseForExpression(){const e=this.parseForStatement();return e.isExpression=!0,e}parseWhileExpression(){const e=this.parseWhileStatement();return e.isExpression=!0,e}getBlockValue(e){if(e.length===0)return new $e(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 $e(null)}}class As{indent;indentStr;output;sourceCode;sourceLines;lastCommentedLine;includeSourceComments;constructor(e={}){this.indent=0,this.indentStr=e.indentStr||" ",this.output=[],this.sourceCode=e.sourceCode||null,this.sourceLines=this.sourceCode?this.sourceCode.split(`
40
40
  `):[],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,n=[];for(let a=e-1;a<r&&a<this.sourceLines.length;a++)if(a>this.lastCommentedLine){const s=this.sourceLines[a].trim();s&&!s.startsWith("//@")&&!s.startsWith("//")&&n.push(this.sourceLines[a])}if(n.length>0){for(const a of n)this.write(this.indentStr.repeat(this.indent)),this.write("/// "),this.write(a.trimEnd()),this.write(`
41
41
  `);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+`
42
42
  `):this.output.push(`
@@ -44,7 +44,8 @@ ${t}
44
44
  `)}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,n=i&&r.length>0&&r[0].type==="Identifier"&&r[0].name==="this"?1:0;for(let a=n;a<r.length;a++){const s=r[a];if(s.type==="Identifier")this.write(s.name);else if(s.type==="AssignmentPattern"){const o=s.left.name==="this"&&i?"self":s.left.name;this.write(o),this.write(" = "),this.generateExpression(s.right)}a<r.length-1&&this.write(", ")}this.write(") "),this.generateBlockStatement(e.body,!1),this.write(`
45
45
  `)}generateVariableDeclaration(e){const i=e.kind==="var"||e.kind==="varip"?"var":"let";for(let r=0;r<e.declarations.length;r++){const n=e.declarations[r];if(n.init&&n.init.type==="ConditionalExpression"&&n.init.needsIIFE){const a=n.id.type==="Identifier"?n.id.name:null;if(a){this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" "),this.write(a),this.write(`;
46
46
  `),this.generateIfStatementWithAssignment(n.init,a);continue}}if(this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" "),n.id.type==="Identifier")this.write(n.id.name);else if(n.id.type==="ArrayPattern"){this.write("[");for(let a=0;a<n.id.elements.length;a++)this.write(n.id.elements[a].name),a<n.id.elements.length-1&&this.write(", ");this.write("]")}n.init&&(this.write(" = "),this.generateExpression(n.init)),this.write(`;
47
- `)}}generateExpressionStatement(e){this.write(this.indentStr.repeat(this.indent)),this.generateExpression(e.expression),this.write(`;
47
+ `)}}generateExpressionStatement(e){if(e.expression.type==="SwitchExpression"&&e.expression.discriminant===null){this.write(this.indentStr.repeat(this.indent)),this.generateSwitchAsIfElse(e.expression),this.write(`
48
+ `);return}this.write(this.indentStr.repeat(this.indent)),this.generateExpression(e.expression),this.write(`;
48
49
  `)}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(`
49
50
  `)}generateIfStatementWithAssignment(e,i){if(this.write(this.indentStr.repeat(this.indent)),this.write("if ("),this.generateExpression(e.test),this.write(`) {
50
51
  `),this.indent++,e.consequentStmts)for(let r=0;r<e.consequentStmts.length;r++){const n=e.consequentStmts[r];r===e.consequentStmts.length-1?n.type==="ExpressionStatement"?(this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" = "),this.generateExpression(n.expression),this.write(`;
@@ -77,7 +78,7 @@ ${t}
77
78
  `)}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(`;
78
79
  `)}generateBlockStatement(e,i=!0){this.write(`{
79
80
  `),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(`
80
- `)}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 n=this.getPrecedence(e.right);let a=n<i;n===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(`(() => {
81
+ `)}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);case"ForStatement":return this.generateLoopAsExpression(e,"for");case"WhileStatement":return this.generateLoopAsExpression(e,"while");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 n=this.getPrecedence(e.right);let a=n<i;n===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||e.argument.type==="UnaryExpression"&&(i==="-"||i==="+")&&(e.argument.operator==="-"||e.argument.operator==="+")?(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(`(() => {
81
82
  `),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(`) {
82
83
  `),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(`;
83
84
  `)):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 {
@@ -106,7 +107,7 @@ ${t}
106
107
  `)}else this.write(` else {
107
108
  `),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write(`return false;
108
109
  `),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write(`}
109
- `)}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(`(() => {
110
+ `)}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.generateSwitchAsIfElseIIFE(e);return}this.write(`(() => {
110
111
  `),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write("switch ("),this.generateExpression(e.discriminant),this.write(`) {
111
112
  `),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(`:
112
113
  `)):this.write(`default:
@@ -114,13 +115,24 @@ ${t}
114
115
  `)}else{for(let n=0;n<i.statements.length;n++)this.write(this.indentStr.repeat(this.indent)),this.generateStatement(i.statements[n]);this.write(this.indentStr.repeat(this.indent)),this.write(`return null;
115
116
  `)}}else this.write(this.indentStr.repeat(this.indent)),this.write("return "),this.generateExpression(i.consequent),this.write(`;
116
117
  `);this.indent--}this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write(`}
117
- `),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(`) {
118
+ `),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("})()")}generateSwitchAsIfElseIIFE(e){this.write(`(() => {
119
+ `),this.indent++,this.write(this.indentStr.repeat(this.indent));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(`) {
120
+ `)):i>0?this.write(` else {
121
+ `):this.write(`{
122
+ `),this.indent++,r.statements&&r.statements.length>0){const n=r.statements[r.statements.length-1];if(n.type==="ExpressionStatement"||n.type==="VariableDeclaration"){for(let a=0;a<r.statements.length-1;a++)this.write(this.indentStr.repeat(this.indent)),this.generateStatement(r.statements[a]);this.write(this.indentStr.repeat(this.indent)),this.write("return "),n.type==="ExpressionStatement"?this.generateExpression(n.expression):this.generateExpression(r.consequent),this.write(`;
123
+ `)}else{for(const a of r.statements)this.write(this.indentStr.repeat(this.indent)),this.generateStatement(a);this.write(this.indentStr.repeat(this.indent)),this.write(`return null;
124
+ `)}}else this.write(this.indentStr.repeat(this.indent)),this.write("return "),this.generateExpression(r.consequent),this.write(`;
125
+ `);this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}"),i>=e.cases.length-1&&this.write(`
126
+ `)}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(`) {
118
127
  `)):i>0?this.write(` else {
119
128
  `):this.write(`{
120
129
  `),this.indent++,r.statements&&r.statements.length>0)for(const n of r.statements)this.write(this.indentStr.repeat(this.indent)),this.generateStatement(n);else this.write(this.indentStr.repeat(this.indent)),this.generateExpression(r.consequent),this.write(`;
121
130
  `);this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("}"),i<e.cases.length-1||this.write(`
122
- `)}}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 Er(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 vs(t,e={}){const i=Er(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 as(t).tokenize(),n=new gs(r).parse(),a={...e,sourceCode:t},s=new ys(a).generate(n);return{success:!0,version:i,code:s,ast:n,tokens:r}}catch(r){return{success:!1,version:i,error:r.message,stack:r.stack}}}function ws(t){if(typeof t=="function")return t.toString();{const e=Er(t);if(e===null)return t;if(e>=5){const i=vs(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 bs(t,e={debug:!1,ln:!1}){typeof e=="boolean"&&(e={debug:e,ln:!0});const{debug:i}=e;let r=ws(t);r=Kn(r);const n=i?r.split(`
123
- `):[],a=dr(r,{ecmaVersion:"latest",sourceType:"module",locations:i});Hn(a),$n(a),Wn(a);const s=new On;zn(a,s);const o=Yn(a,s)||"";is(a,s,o,e,n),ts(a);const c=Pn||Yt||void 0,l=Object.assign({},c,{LineComment(p,h){h.write("//"+p.value)}}),u=xr(a,{generator:l,comments:i});return new Function("",`var _r = ${u}
124
- ; return _r;`)(this)}function _s(t){return e=>new L(e.array.map(i=>Math.abs(i)),e.type,t)}function Ss(t){return e=>{let i=0,r=0;for(const n of e.array){const a=Number(n);isNaN(a)||(r++,i+=(a-i)/r)}return r===0?NaN:t.precision(i)}}function Es(t){return(e,i)=>{const r=e.array;let n=0,a=r.length-1;for(;n<=a;){const s=Math.floor((n+a)/2),o=r[s];if(o===i)return s;o<i?n=s+1:a=s-1}return-1}}function Ns(t){return(e,i)=>{const r=e.array;let n=0,a=r.length;for(;n<a;){const s=Math.floor((n+a)/2);r[s]<i?n=s+1:a=s}return n<r.length&&r[n]===i?n:n-1}}function Is(t){return(e,i)=>{const r=e.array;let n=0,a=r.length;for(;n<a;){const s=Math.floor((n+a)/2);r[s]<=i?n=s+1:a=s}return n>0&&r[n-1]===i?n-1:n}}function Cs(t){return e=>{e.array.length=0}}function ks(t){return(e,i)=>(e.array.push(...i.array),e)}function As(t){return e=>new L([...e.array],e.type,t)}function Ts(t){return(e,i,r=!0)=>{const n=e.array,a=i.array;if(n.length!==a.length)return NaN;let s=0,o=0,c=0;const l=[];for(let g=0;g<n.length;g++){const y=Number(n[g]),v=Number(a[g]);!isNaN(y)&&y!==null&&y!==void 0&&!isNaN(v)&&v!==null&&v!==void 0&&(s+=y,o+=v,c++,l.push(g))}if(c===0)return NaN;const u=s/c,p=o/c;let h=0;for(const g of l){const y=Number(n[g]),v=Number(a[g]);h+=(y-u)*(v-p)}const d=r?c:c-1;return d<=0?NaN:t.precision(h/d)}}function Ps(t){return e=>e.array.every(i=>!isNaN(i)&&i)}function Ds(t){return t.every(e=>typeof e=="number")?t.every(e=>(e|0)===e)?j.int:j.float:t.every(e=>typeof e=="string")?j.string:t.every(e=>typeof e=="boolean")?j.bool:j.any}function ve(t){if(typeof t=="number")return(t|0)===t?j.int:j.float;if(typeof t=="string")return j.string;if(typeof t=="boolean")return j.bool;throw new Error("Cannot infer type from value")}function ct(t,e){if(e===j.any)return!0;switch(e){case j.int:return typeof t=="number"&&((t|0)===t||isNaN(t));case j.float:return typeof t=="number";case j.string:return typeof t=="string";case j.bool:return typeof t=="boolean"}return!1}function Rs(t){return(e,i,r=0,n)=>{const a=e.array.length,s=n!==void 0?Math.min(n,a):a;for(let o=r;o<s;o++){if(!ct(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 Ms(t){return e=>e.array.length>0?e.array[0]:t.NA}function Os(t){return(e,i)=>e.array[i]}function Vs(t){return(e,i)=>e.array.includes(i)}function Ls(t){return(e,i)=>e.array.indexOf(i)}function Bs(t){return(e,i,r)=>{if(!ct(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 Fs(t){return(e,i=",")=>e.array.join(i)}function js(t){return e=>e.array.length>0?e.array[e.array.length-1]:t.NA}function Ws(t){return(e,i)=>e.array.lastIndexOf(i)}function $s(t){return(e,i=0)=>[...e.array].sort((r,n)=>n-r)[i]??t.NA}function Us(t){return e=>{if(e.array.length===0)return NaN;const i=[...e.array].sort((n,a)=>typeof n=="number"&&typeof a=="number"?n-a:0),r=Math.floor(i.length/2);return i.length%2!==0?i[r]:(i[r-1]+i[r])/2}}function qs(t){return(e,i=0)=>[...e.array].sort((r,n)=>r-n)[i]??t.NA}function Ks(t){return e=>{if(e.array.length===0)return NaN;const i=new Map;let r=0;for(const a of e.array){const s=(i.get(a)||0)+1;i.set(a,s),s>r&&(r=s)}const n=[];for(const[a,s]of i)s===r&&n.push(a);return n.sort((a,s)=>typeof a=="number"&&typeof s=="number"?a-s:typeof a=="string"&&typeof s=="string"?a<s?-1:a>s?1:0:0),n[0]}}function Hs(t){return(e,i)=>{const r=e.array;if(r.length===0)return NaN;const n=[];for(const c of r){const l=Number(c);if(isNaN(l)||l===null||l===void 0)return NaN;n.push(l)}n.sort((c,l)=>c-l),i<0&&(i=0),i>100&&(i=100);const a=i/100*n.length-.5;if(a<=0)return t.precision(n[0]);if(a>=n.length-1)return t.precision(n[n.length-1]);const s=Math.floor(a),o=a-s;return t.precision(n[s]*(1-o)+n[s+1]*o)}}function zs(t){return(e,i)=>{const r=e.array;if(r.length===0)return NaN;const n=[];for(const o of r){const c=Number(o);!isNaN(c)&&c!==null&&c!==void 0&&n.push(c)}if(n.length===0)return NaN;n.sort((o,c)=>o-c),i<0&&(i=0),i>100&&(i=100);const a=r.length,s=Math.ceil(i/100*a);return s<=0?n[0]:s>n.length?NaN:n[s-1]}}function Gs(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 n=Number(e.array[r]);if(isNaN(n)||n===null||n===void 0)return NaN;let a=0;for(const o of e.array){const c=Number(o);!isNaN(c)&&c!==null&&c!==void 0&&c<n&&a++}const s=e.array.length-1;return s<=0?NaN:a/s*100}}function Ys(t){return e=>e.array.pop()}function Qs(t){return(e,i)=>{if(!ct(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 Xs(t){return e=>t.precision(t.pine.array.max(e)-t.pine.array.min(e))}function Zs(t){return(e,i)=>i>=0&&i<e.array.length?e.array.splice(i,1)[0]:t.NA}function Js(t){return e=>{e.array.reverse()}}function ea(t){return(e,i,r)=>{if(!ct(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 ta(t){return e=>e.array.shift()}function ia(t){return e=>e.array.length}function ra(t){return(e,i,r)=>{const n=r!==void 0?r:void 0;return new L(e.array.slice(i,n),e.type,t)}}function na(t){return e=>e.array.some(i=>!isNaN(i)&&i)}var Qe=(t=>(t[t.ascending=1]="ascending",t[t.descending=0]="descending",t))(Qe||{}),Nr=(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))(Nr||{}),Ir=(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))(Ir||{}),Cr=(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))(Cr||{}),kr=(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))(kr||{}),Ar=(t=>(t.abovebar="abovebar",t.belowbar="belowbar",t.absolute="absolute",t.bottom="bottom",t.top="top",t))(Ar||{}),Tr=(t=>(t.auto="auto",t.tiny="tiny",t.small="small",t.normal="normal",t.large="large",t.huge="huge",t))(Tr||{}),Pr=(t=>(t.inherit="inherit",t.mintick="mintick",t.percent="percent",t.price="price",t.volume="volume",t))(Pr||{}),sa=(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))(sa||{}),Dr=(t=>(t.gaps_on="gaps_on",t.gaps_off="gaps_off",t.lookahead_on="lookahead_on",t.lookahead_off="lookahead_off",t))(Dr||{}),Rr=(t=>(t.bar_index="bar_index",t.bar_time="bar_time",t))(Rr||{}),Mr=(t=>(t.price="price",t.abovebar="abovebar",t.belowbar="belowbar",t))(Mr||{}),Or=(t=>(t.align_left="align_left",t.align_center="align_center",t.align_right="align_right",t.wrap_auto="wrap_auto",t.wrap_none="wrap_none",t))(Or||{}),Vr=(t=>(t.family_default="family_default",t.family_monospace="family_monospace",t))(Vr||{});const aa={order:Qe,currency:Nr,dayofweek:Ir,display:Cr,shape:kr,location:Ar,size:Tr,format:Pr,barmerge:Dr,xloc:Rr,yloc:Mr,text:Or,font:Vr};function oa(t){return(e,i=Qe.ascending)=>{e.array.sort((r,n)=>{let a=isNaN(r)?1/0:r,s=isNaN(n)?1/0:n;return i===Qe.ascending?a-s:s-a})}}function ca(t){return(e,i=Qe.ascending)=>{const r=e.array.map((n,a)=>a);return r.sort((n,a)=>{const s=isNaN(e.array[n])?1/0:e.array[n],o=isNaN(e.array[a])?1/0:e.array[a];return i===Qe.ascending?s-o:o-s}),new L(r,j.int,t)}}function la(t){return e=>{const i=t.array.avg(e),r=t.array.stdev(e);return isNaN(r)?new L(e.array.map(()=>NaN),j.int,t):r===0?new L(e.array.map(()=>1),j.int,t):new L(e.array.map(n=>(n-i)/r),j.int,t)}}function ua(t){return(e,i=!0)=>{const r=e.array,n=r.length;if(n===0)return NaN;let a=0,s=0,o=0;for(let u=0;u<n;u++){const p=Number(r[u]);!isNaN(p)&&p!==null&&p!==void 0&&(a+=p,s+=p*p,o++)}if(o===0)return NaN;const c=a/o;let l=s/o-c*c;return l<0?NaN:(!i&&o>1&&(l=l*o/(o-1)),!i&&o===1?0:t.precision(Math.sqrt(l)))}}function ha(t){return e=>t.precision(e.array.reduce((i,r)=>{const n=Number(r);return isNaN(n)?i:i+n},0))}function pa(t){return(e,i)=>{if(!ct(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 fa(t){return(e,i=!0)=>{let r=0,n=0;for(const c of e.array){const l=Number(c);!isNaN(l)&&l!==null&&l!==void 0&&(r+=l,n++)}if(n===0)return NaN;const a=r/n;let s=0;for(const c of e.array){const l=Number(c);!isNaN(l)&&l!==null&&l!==void 0&&(s+=(l-a)*(l-a))}const o=i?n:n-1;return o<=0?NaN:t.precision(s/o)}}var j=(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))(j||{});class L{constructor(e,i,r){this.array=e,this.type=i,this.context=r,this._abs=_s(this.context),this._avg=Ss(this.context),this._binary_search=Es(this.context),this._binary_search_leftmost=Ns(this.context),this._binary_search_rightmost=Is(this.context),this._clear=Cs(this.context),this._concat=ks(this.context),this._copy=As(this.context),this._covariance=Ts(this.context),this._every=Ps(this.context),this._fill=Rs(this.context),this._first=Ms(this.context),this._get=Os(this.context),this._includes=Vs(this.context),this._indexof=Ls(this.context),this._insert=Bs(this.context),this._join=Fs(this.context),this._last=js(this.context),this._lastindexof=Ws(this.context),this._max=$s(this.context),this._median=Us(this.context),this._min=qs(this.context),this._mode=Ks(this.context),this._percentile_linear_interpolation=Hs(this.context),this._percentile_nearest_rank=zs(this.context),this._percentrank=Gs(this.context),this._pop=Ys(this.context),this._push=Qs(this.context),this._range=Xs(this.context),this._remove=Zs(this.context),this._reverse=Js(this.context),this._set=ea(this.context),this._shift=ta(this.context),this._size=ia(this.context),this._slice=ra(this.context),this._some=na(this.context),this._sort=oa(this.context),this._sort_indices=ca(this.context),this._standardize=la(this.context),this._stdev=ua(this.context),this._sum=ha(this.context),this._unshift=pa(this.context),this._variance=fa(this.context)}_abs;_avg;_binary_search;_binary_search_leftmost;_binary_search_rightmost;_clear;_concat;_copy;_covariance;_every;_fill;_first;_get;_includes;_indexof;_insert;_join;_last;_lastindexof;_max;_median;_min;_mode;_percentile_linear_interpolation;_percentile_nearest_rank;_percentrank;_pop;_push;_range;_remove;_reverse;_set;_shift;_size;_slice;_some;_sort;_sort_indices;_standardize;_stdev;_sum;_unshift;_variance;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 da(t){return(...e)=>new L([...e],Ds(e),t)}function ma(t){return(e,i)=>e===void 0&&i===void 0?new L([],j.any,t):new L(Array(e).fill(t.precision(i||0)),ve(i||0),t)}function xa(t){return(e,i=!1)=>new L(Array(e).fill(i),j.bool,t)}function ga(t){return(e,i=NaN)=>new L(Array(e).fill(t.precision(i)),j.float,t)}function ya(t){return(e,i=0)=>new L(Array(e).fill(t.precision(i)),j.int,t)}function va(t){return(e,i="")=>new L(Array(e).fill(i),j.string,t)}class m{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 m?e:Array.isArray(e)?new m(e):new m([e])}}function wa(t){return(e,i=0)=>m.from(e).get(i)}class ba{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=da(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=ma(e),this.new_bool=xa(e),this.new_float=ga(e),this.new_int=ya(e),this.new_string=va(e),this.param=wa(),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 _a(t){return e=>{e.map.clear()}}function Sa(t){return(e,i)=>e.map.has(i)}function Ea(t){return e=>{const i=new Lr(t);return i.map=new Map(e.map),i}}function Na(t){return(e,i)=>{const r=e.map.get(i);return r===void 0?NaN:r}}function Ia(t){return e=>{const i=Array.from(e.map.keys()),r=ve(i[0]);return new L(i,r,t)}}function Ca(t){return(e,i,r)=>{const n=e.map.get(i);return e.map.set(i,r),n===void 0?NaN:n}}function ka(t){return(e,i)=>{for(const[r,n]of i.map)e.map.set(r,n)}}function Aa(t){return(e,i)=>{const r=e.map.get(i);return e.map.delete(i)?r:NaN}}function Ta(t){return e=>e.map.size}function Pa(t){return e=>{const i=Array.from(e.map.values()),r=ve(i[0]);return new L(i,r,t)}}class Lr{constructor(e){this.context=e,this.map=new Map,this._clear=_a(this.context),this._contains=Sa(this.context),this._copy=Ea(this.context),this._get=Na(this.context),this._keys=Ia(this.context),this._put=Ca(this.context),this._put_all=ka(this.context),this._remove=Aa(this.context),this._size=Ta(this.context),this._values=Pa(this.context)}map;_clear;_contains;_copy;_get;_keys;_put;_put_all;_remove;_size;_values;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 Da(t){return()=>new Lr(t)}function Ra(t){return(e,i=0)=>m.from(e).get(i)}class Ma{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=Da(e),this.param=Ra(),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 Oa(t){return(e,i,r)=>{const n=e.matrix.length;let a=[];if(r&&(r instanceof L?a=r.array:Array.isArray(r)?a=r:a=[r]),n===0){for(let c=0;c<a.length;c++){let l=a[c];l instanceof m&&(l=l.get(0)),e.matrix.push([l])}return}const s=e.matrix[0].length,o=i!==void 0?i:s;for(let c=0;c<n;c++){let l=c<a.length?a[c]:NaN;l instanceof m&&(l=l.get(0)),e.matrix[c].splice(o,0,l)}}}function Va(t){return(e,i,r)=>{const n=e.matrix.length;let a=[];if(r)if(r instanceof L)a=r.array;else if(Array.isArray(r))a=r;else if(r instanceof m){const l=r.get(0);Array.isArray(l)?a=l:a=[l]}else a=[r];const s=n>0?e.matrix[0].length:a.length,o=i!==void 0?i:n,c=[];for(let l=0;l<s;l++)if(l<a.length){let u=a[l];u instanceof m&&(u=u.get(0)),c.push(u)}else c.push(NaN);e.matrix.splice(o,0,c)}}function La(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 n=0,a=0;for(let s=0;s<i;s++)for(let o=0;o<r;o++){const c=e.matrix[s][o];isNaN(c)||(n+=c,a++)}return a===0?NaN:n/a}}function Ba(t){return(e,i)=>{const r=e.matrix.length,n=[];for(let s=0;s<r;s++)n.push(e.matrix[s][i]);const a=ve(n[0]);return new L(n,a,t)}}function Fa(t){return e=>e.matrix.length===0?0:e.matrix[0].length}function ja(t){return(e,i)=>{const r=e.matrix.length,n=i.matrix.length;if(r===0){for(let o=0;o<n;o++)e.matrix.push([...i.matrix[o]]);return}const a=e.matrix[0].length,s=n>0?i.matrix[0].length:0;if(a!==s&&n>0){console.error(`matrix.concat: Column count mismatch ${a} vs ${s}`);return}for(let o=0;o<n;o++)e.matrix.push([...i.matrix[o]])}}function Wa(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0,n=new V(i,r,NaN,t);return n.matrix=e.matrix.map(a=>[...a]),n}}function $a(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(n=>[...n]);let r=1;for(let n=0;n<e;n++){let a=n;for(;a<e&&i[a][n]===0;)a++;if(a===e)return 0;a!==n&&([i[n],i[a]]=[i[a],i[n]],r*=-1),r*=i[n][n];for(let s=n+1;s<e;s++){const o=i[s][n]/i[n][n];for(let c=n;c<e;c++)i[s][c]-=o*i[n][c]}}return r}function Ua(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;return i!==r?NaN:$a(e.matrix)}}function qa(t){return(e,i)=>{const r=e.matrix.length;if(r===0)return new V(0,0,NaN,t);const n=e.matrix[0].length,a=new V(r,n,NaN,t);if(i instanceof V)for(let s=0;s<r;s++)for(let o=0;o<n;o++){const c=e.matrix[s][o],l=i.matrix[s]&&i.matrix[s][o]!==void 0?i.matrix[s][o]:NaN;a.matrix[s][o]=c-l}else{const s=i;for(let o=0;o<r;o++)for(let c=0;c<n;c++)a.matrix[o][c]=e.matrix[o][c]-s}return a}}function Ka(t){const e=t.length;if(e!==2)return Array(e).fill(NaN);const i=t[0][0],r=t[0][1],n=t[1][0],a=t[1][1],s=i+a,o=i*a-r*n,c=s*s-4*o;if(c<0)return[NaN,NaN];const l=(s+Math.sqrt(c))/2,u=(s-Math.sqrt(c))/2;return[l,u]}function Ha(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r){const s=ve(e.matrix[0][0]);return new L([],s,t)}const n=Ka(e.matrix),a=ve(n[0]);return new L(n,a,t)}}function za(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r)return new V(0,0,NaN,t);const n=new V(i,r,0,t);for(let a=0;a<i;a++)n.matrix[a][a]=1;return n}}function Ga(t){return e=>{const i=e.matrix.length;return i===0?0:i*e.matrix[0].length}}function Ya(t){return(e,i,r,n,a,s)=>{const o=e.matrix.length;if(o===0)return;const c=e.matrix[0].length,l=r!==void 0?r:0,u=n!==void 0?n:o,p=a!==void 0?a:0,h=s!==void 0?s:c;for(let d=l;d<u&&!(d>=o);d++)for(let g=p;g<h&&!(g>=c);g++)e.matrix[d][g]=i}}function Qa(t){return(e,i,r)=>{if(!e.matrix[i])return NaN;const n=e.matrix[i][r];return n===void 0?NaN:n}}function Xa(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 Za(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r)return new V(i,r,NaN,t);const n=Xa(e.matrix),a=new V(i,r,NaN,t);return a.matrix=n,a}}function Ja(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 n=0;n<i;n++)for(let a=0;a<r;a++)if(n+a!==i-1&&e.matrix[n][a]!==0)return!1;return!0}}function eo(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 n=0;n<i;n++)for(let a=0;a<r;a++)if(e.matrix[a][n]!==-e.matrix[n][a])return!1;return!0}}function to(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;for(let n=0;n<i;n++)for(let a=0;a<r;a++){const s=e.matrix[n][a];if(s!==0&&s!==1)return!1}return!0}}function io(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 n=0;n<i;n++)for(let a=0;a<r;a++)if(n!==a&&e.matrix[n][a]!==0)return!1;return!0}}function ro(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 n=0;n<i;n++)for(let a=0;a<r;a++)if(n===a){if(e.matrix[n][a]!==1)return!1}else if(e.matrix[n][a]!==0)return!1;return!0}}function no(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;return i===r}}function so(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;for(let n=0;n<i;n++){let a=0;for(let s=0;s<r;s++){const o=e.matrix[n][s];if(o<0)return!1;a+=o}if(Math.abs(a-1)>1e-10)return!1}return!0}}function ao(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 n=0;n<i;n++)for(let a=0;a<n;a++)if(e.matrix[n][a]!==e.matrix[a][n])return!1;return!0}}function oo(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 n=!0,a=!0;for(let s=0;s<i;s++)for(let o=0;o<r;o++)s>o&&e.matrix[s][o]!==0&&(n=!1),s<o&&e.matrix[s][o]!==0&&(a=!1);return n||a}}function co(t){return e=>{const i=e.matrix.length;if(i===0)return!0;const r=e.matrix[0].length;for(let n=0;n<i;n++)for(let a=0;a<r;a++)if(e.matrix[n][a]!==0)return!1;return!0}}function lo(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0,a=i.matrix.length,s=a>0?i.matrix[0].length:0,o=r*a,c=n*s,l=new V(o,c,NaN,t);for(let u=0;u<r;u++)for(let p=0;p<n;p++){const h=e.matrix[u][p];for(let d=0;d<a;d++)for(let g=0;g<s;g++){const y=i.matrix[d][g];l.matrix[u*a+d][p*s+g]=h*y}}return l}}function uo(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length;let n=-1/0,a=!1;for(let s=0;s<i;s++)for(let o=0;o<r;o++){const c=e.matrix[s][o];isNaN(c)||(c>n&&(n=c),a=!0)}return a?n:NaN}}function ho(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length,n=[];for(let s=0;s<i;s++)for(let o=0;o<r;o++){const c=e.matrix[s][o];isNaN(c)||n.push(c)}if(n.length===0)return NaN;n.sort((s,o)=>s-o);const a=Math.floor(n.length/2);return n.length%2!==0?n[a]:(n[a-1]+n[a])/2}}function po(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length;let n=1/0,a=!1;for(let s=0;s<i;s++)for(let o=0;o<r;o++){const c=e.matrix[s][o];isNaN(c)||(c<n&&(n=c),a=!0)}return a?n:NaN}}function fo(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length,n=new Map;let a=0,s=NaN;for(let o=0;o<i;o++)for(let c=0;c<r;c++){const l=e.matrix[o][c];if(!isNaN(l)){const u=(n.get(l)||0)+1;n.set(l,u),u>a?(a=u,s=l):u===a&&l<s&&(s=l)}}return s}}function mo(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0;if(i instanceof V){const a=i.matrix.length,s=a>0?i.matrix[0].length:0;if(n!==a)return new V(0,0,NaN,t);const o=new V(r,s,0,t);for(let c=0;c<r;c++)for(let l=0;l<s;l++){let u=0;for(let p=0;p<n;p++)u+=e.matrix[c][p]*i.matrix[p][l];o.matrix[c][l]=u}return o}else if(i instanceof L||Array.isArray(i.array||i)){const a=i.array||i;if(n!==a.length)return new V(0,0,NaN,t);const s=new V(r,1,0,t);for(let o=0;o<r;o++){let c=0;for(let l=0;l<n;l++)c+=e.matrix[o][l]*a[l];s.matrix[o][0]=c}return s}else{const a=i,s=new V(r,n,NaN,t);for(let o=0;o<r;o++)for(let c=0;c<n;c++)s.matrix[o][c]=e.matrix[o][c]*a;return s}}}function xo(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;return i===r?new V(i,r,NaN,t):new V(r,i,NaN,t)}}function go(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0;if(r!==n)return new V(0,0,NaN,t);let a=new V(r,n,0,t);for(let c=0;c<r;c++)a.matrix[c][c]=1;let s=new V(r,n,NaN,t);for(let c=0;c<r;c++)s.matrix[c]=[...e.matrix[c]];let o=Math.floor(i);if(o<0)return new V(r,n,NaN,t);for(;o>0;){if(o%2===1){const l=new V(r,n,0,t);for(let u=0;u<r;u++)for(let p=0;p<n;p++){let h=0;for(let d=0;d<r;d++)h+=a.matrix[u][d]*s.matrix[d][p];l.matrix[u][p]=h}a=l}const c=new V(r,n,0,t);for(let l=0;l<r;l++)for(let u=0;u<n;u++){let p=0;for(let h=0;h<r;h++)p+=s.matrix[l][h]*s.matrix[h][u];c.matrix[l][u]=p}s=c,o=Math.floor(o/2)}return a}}function yo(t){return e=>{const i=e.matrix.length;if(i===0)return 0;const r=e.matrix[0].length,n=e.matrix.map(s=>[...s]);let a=0;for(let s=0;s<r&&a<i;s++){let o=a;for(;o<i&&Math.abs(n[o][s])<1e-10;)o++;if(o<i){[n[a],n[o]]=[n[o],n[a]];const c=n[a][s];for(let l=s;l<r;l++)n[a][l]/=c;for(let l=0;l<i;l++)if(l!==a){const u=n[l][s];for(let p=s;p<r;p++)n[l][p]-=u*n[a][p]}a++}}return a}}function vo(t){return(e,i)=>{const r=e.matrix.length;if(r===0){const s=ve(e.matrix[0][0]);return new L([],s,t)}const n=[];for(let s=0;s<r;s++){const o=e.matrix[s].splice(i,1);n.push(o[0])}const a=ve(n[0]);return new L(n,a,t)}}function wo(t){return(e,i)=>{const r=e.matrix.splice(i,1),n=ve(r[0][0]);return new L(r[0]||[],n,t)}}function bo(t){return(e,i,r)=>{const n=e.matrix.length,a=n>0?e.matrix[0].length:0,s=i*r,o=[];for(let u=0;u<n;u++)for(let p=0;p<a;p++)o.push(e.matrix[u][p]);for(;o.length<s;)o.push(NaN);o.length>s&&(o.length=s);const c=[];let l=0;for(let u=0;u<i;u++){const p=[];for(let h=0;h<r;h++)p.push(o[l++]);c.push(p)}e.matrix=c}}function _o(t){return e=>{e.matrix.reverse();for(const i of e.matrix)i.reverse()}}function So(t){return(e,i)=>{if(!e.matrix[i]){const n=ve(e.matrix[0][0]);return new L([],n,t)}const r=ve(e.matrix[i][0]);return new L([...e.matrix[i]],r,t)}}function Eo(t){return e=>e.matrix.length}function No(t){return(e,i,r,n)=>{e.matrix[i]&&(e.matrix[i][r]=n)}}function Io(t){return(e,i=0,r="asc")=>{e.matrix.length!==0&&e.matrix.sort((n,a)=>{const s=n[i],o=a[i];return s<o?r==="asc"?-1:1:s>o?r==="asc"?1:-1:0})}}function Co(t){return(e,i,r,n,a)=>{const s=r-i,o=a-n,c=new V(s,o,NaN,t);for(let l=0;l<s;l++){const u=i+l;if(u>=e.matrix.length)break;for(let p=0;p<o;p++){const h=n+p;if(h>=e.matrix[u].length)break;c.matrix[l][p]=e.matrix[u][h]}}return c}}function ko(t){return(e,i)=>{const r=e.matrix.length;if(r===0)return new V(0,0,NaN,t);const n=e.matrix[0].length,a=new V(r,n,NaN,t);if(i instanceof V)for(let s=0;s<r;s++)for(let o=0;o<n;o++){const c=e.matrix[s][o],l=i.matrix[s]&&i.matrix[s][o]!==void 0?i.matrix[s][o]:NaN;a.matrix[s][o]=c+l}else{const s=i;for(let o=0;o<r;o++)for(let c=0;c<n;c++)a.matrix[o][c]=e.matrix[o][c]+s}return a}}function Ao(t){return(e,i,r)=>{const n=e.matrix.length;for(let a=0;a<n;a++){const s=e.matrix[a][i];e.matrix[a][i]=e.matrix[a][r],e.matrix[a][r]=s}}}function To(t){return(e,i,r)=>{const n=e.matrix[i];e.matrix[i]=e.matrix[r],e.matrix[r]=n}}function Po(t){return e=>{const i=e.matrix.length;if(i===0)return 0;const r=e.matrix[0].length,n=Math.min(i,r);let a=0;for(let s=0;s<n;s++)a+=e.matrix[s][s];return a}}function Do(t){return e=>{const i=e.matrix.length;if(i===0)return new V(0,0,NaN,t);const r=e.matrix[0].length,n=new V(r,i,NaN,t);for(let a=0;a<i;a++)for(let s=0;s<r;s++)n.matrix[s][a]=e.matrix[a][s];return n}}class V{constructor(e=0,i=0,r=NaN,n){if(this.context=n,this.matrix=[],e>0&&i>0)for(let a=0;a<e;a++)this.matrix.push(Array(i).fill(r));this._add_col=Oa(this.context),this._add_row=Va(this.context),this._avg=La(this.context),this._col=Ba(this.context),this._columns=Fa(this.context),this._concat=ja(this.context),this._copy=Wa(this.context),this._det=Ua(this.context),this._diff=qa(this.context),this._eigenvalues=Ha(this.context),this._eigenvectors=za(this.context),this._elements_count=Ga(this.context),this._fill=Ya(this.context),this._get=Qa(this.context),this._inv=Za(this.context),this._is_antidiagonal=Ja(this.context),this._is_antisymmetric=eo(this.context),this._is_binary=to(this.context),this._is_diagonal=io(this.context),this._is_identity=ro(this.context),this._is_square=no(this.context),this._is_stochastic=so(this.context),this._is_symmetric=ao(this.context),this._is_triangular=oo(this.context),this._is_zero=co(this.context),this._kron=lo(this.context),this._max=uo(this.context),this._median=ho(this.context),this._min=po(this.context),this._mode=fo(this.context),this._mult=mo(this.context),this._pinv=xo(this.context),this._pow=go(this.context),this._rank=yo(this.context),this._remove_col=vo(this.context),this._remove_row=wo(this.context),this._reshape=bo(this.context),this._reverse=_o(this.context),this._row=So(this.context),this._rows=Eo(this.context),this._set=No(this.context),this._sort=Io(this.context),this._submatrix=Co(this.context),this._sum=ko(this.context),this._swap_columns=Ao(this.context),this._swap_rows=To(this.context),this._trace=Po(this.context),this._transpose=Do(this.context)}matrix;_add_col;_add_row;_avg;_col;_columns;_concat;_copy;_det;_diff;_eigenvalues;_eigenvectors;_elements_count;_fill;_get;_inv;_is_antidiagonal;_is_antisymmetric;_is_binary;_is_diagonal;_is_identity;_is_square;_is_stochastic;_is_symmetric;_is_triangular;_is_zero;_kron;_max;_median;_min;_mode;_mult;_pinv;_pow;_rank;_remove_col;_remove_row;_reshape;_reverse;_row;_rows;_set;_sort;_submatrix;_sum;_swap_columns;_swap_rows;_trace;_transpose;toString(){let e="";for(let i=0;i<this.matrix.length;i++)e+=e===""?"":`
125
- `,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 Ro(t){return(e,i,r)=>new V(e,i,r,t)}function Mo(t){return(e,i=0)=>m.from(e).get(i)}class Oo{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=Ro(e),this.param=Mo(),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)}}class Vo{constructor(e){this.context=e}_live=!1;setLive(){this._live=!0}get isnew(){return!this._live}get islast(){return this.context.idx===this.context.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 xt{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 xt(this.__def__,this.context)}toString(){const e={};for(let i in this.__def__)e[i]=this[i];return JSON.stringify(e)}}class ye{time;index;price;constructor(e,i,r){this.time=e,this.index=i,this.price=r}copy(){return new ye(this.time,this.index,this.price)}toString(){return JSON.stringify({time:this.time,index:this.index,price:this.price})}}function Lo(t){return typeof t=="object"&&t.title!==void 0&&t.data!==void 0&&t.options!==void 0}const bi={series:t=>t instanceof m||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",point:t=>t instanceof ye,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 m)&&!(t instanceof ye)&&!Lo(t)};function we(t){const e=t[t.length-1];if(e&&typeof e=="object"&&"__callsiteId"in e)return t.pop().__callsiteId}function Y(t,e,i,r){Array.isArray(e)&&typeof e[0]=="string"&&(e=[e]);const n={};let a={};const s=new Array(e.length).fill(!0);for(let o=0;o<t.length;o++){const c=t[o];if(bi.remaining_options(c)){a=c;break}const l=e.map((u,p)=>s[p]?u[o]:void 0);for(let u=0;u<l.length;u++){const p=l[u];if(p===void 0){s[u]=!1;continue}const h=bi[i[p]];typeof h=="function"&&h(c)?n[p]=c:s[u]=!1}}return{...a,...n,...r}}const Bo=[["dateString"],["year","month","day","hour","minute","second"],["timezone","year","month","day","hour","minute","second"]],Fo={dateString:"string",timezone:"string",year:"number",month:"number",day:"number",hour:"number",minute:"number",second:"number"},jo=["title","shorttitle","overlay","format","precision","scale","max_bars_back","timeframe","timeframe_gaps","explicit_plot_zorder","max_lines_count","max_labels_count","max_boxes_count","calc_bars_count","max_polylines_count","dynamic_requests","behind_chart"],Wo={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"},H={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 $o(t){return Y(t,jo,Wo)}class Uo{get __value(){return NaN}param(e,i=0){return m.from(e).get(i)}any(e){return isNaN(m.from(e).get(0))}}class qo{constructor(e){this.context=e}color={param:(e,i=0)=>m.from(e).get(i),rgb:(e,i,r,n)=>n?`rgba(${e}, ${i}, ${r}, ${(100-n)/100})`:`rgb(${e}, ${i}, ${r})`,new:(e,i)=>{if(e&&e.startsWith("#")){const r=e.slice(1);return i?`#${r}${Math.round(255/100*(100-i)).toString(16).padStart(2,"0").toUpperCase()}`:`#${r}`}else{const r=H[e];return r?i?`#${r}${Math.round(255/100*(100-i)).toString(16).padStart(2,"0").toUpperCase()}`:`#${r}`:i?`rgba(${e}, ${(100-i)/100})`:e}},aqua:H.aqua,black:H.black,blue:H.blue,fuchsia:H.fuchsia,gray:H.gray,green:H.green,lime:H.lime,maroon:H.maroon,navy:H.navy,olive:H.olive,orange:H.orange,purple:H.purple,red:H.red,silver:H.silver,teal:H.teal,white:H.white,yellow:H.yellow};extractPlotOptions(e){const i={};for(let r in e)i[r]=m.from(e[r]).get(0);return i}indicator(...e){const i=$o(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(m.from(e).get(0))}nz(e,i=0){const r=m.from(e).get(0),n=m.from(i).get(0);return isNaN(r)?n:r}fixnan(e){const i=m.from(e);for(let r=0;r<i.length;r++){const n=i.get(r);if(!isNaN(n))return n}return NaN}alertcondition(e,i,r){}timestamp(...e){const i=e.map(n=>n instanceof m?n.get(0):n),r=Y(i,Bo,Fo);if(r.year!==void 0){const n=r.year,a=r.month,s=r.day,o=r.hour||0,c=r.minute||0,l=r.second||0,u=r.timezone||this.context.pine?.syminfo?.timezone||"UTC";return this._timestampFromComponents(u,n,a,s,o,c,l)}return r.dateString!==void 0?new Date(r.dateString).getTime():NaN}_timestampFromComponents(e,i,r,n,a,s,o){const c=new Date(Date.UTC(i,r-1,n,a,s,o));i>=0&&i<100&&c.setUTCFullYear(i);const l=e.trim();if(l==="UTC"||l==="GMT")return c.getTime();const u=l.match(/^(?:UTC|GMT)([+-])(\d{1,2})(?::(\d{2}))?$/i);if(u){const p=u[1]==="+"?1:-1,h=parseInt(u[2],10),d=parseInt(u[3]||"0",10),g=p*(h*60+d)*60*1e3;return c.getTime()-g}try{return this._timestampFromIANA(e,i,r,n,a,s,o)}catch{return c.getTime()}}_timestampFromIANA(e,i,r,n,a,s,o){const c=new Date(Date.UTC(i,r-1,n,a,s,o));i>=0&&i<100&&c.setUTCFullYear(i);const l=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(c),u=N=>parseInt(l.find(I=>I.type===N)?.value||"0",10),p=u("year"),h=u("month"),d=u("day");let g=u("hour");g===24&&(g=0);const y=u("minute"),v=u("second"),w=new Date(Date.UTC(p,h-1,d,g,y,v));p>=0&&p<100&&w.setUTCFullYear(p);const _=w.getTime()-c.getTime();return c.getTime()-_}bool(e){const i=m.from(e).get(0);return!isNaN(i)&&i!==0}int(e){const i=m.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=m.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 m.from(e).get(0).toString()}Type(e){const i=Object.keys(e);return{new:function(...r){const n={};for(let a=0;a<r.length;a++)n[i[a]]=r[a];return new xt(n,this.context)},copy:function(r){return new xt(r.__def__,this.context)}}}}function gt(t,e){const i=e.trim();if(i==="UTC"||i==="GMT"){const n=new Date(t);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),dayOfWeek:n.getUTCDay()}}const r=i.match(/^(?:UTC|GMT)([+-])(\d{1,2})(?::(\d{2}))?$/i);if(r){const n=r[1]==="+"?1:-1,a=parseInt(r[2],10),s=parseInt(r[3]||"0",10),o=n*(a*60+s)*60*1e3,c=new Date(t+o);return{year:c.getUTCFullYear(),month:c.getUTCMonth()+1,day:c.getUTCDate(),hour:c.getUTCHours(),minute:c.getUTCMinutes(),second:c.getUTCSeconds(),dayOfWeek:c.getUTCDay()}}try{const n=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",weekday:"short",hour12:!1}).formatToParts(new Date(t)),a=l=>parseInt(n.find(u=>u.type===l)?.value||"0",10);let s=a("hour");s===24&&(s=0);const o=n.find(l=>l.type==="weekday")?.value||"Sun",c={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return{year:a("year"),month:a("month"),day:a("day"),hour:s,minute:a("minute"),second:a("second"),dayOfWeek:c[o]??0}}catch{const n=new Date(t);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),dayOfWeek:n.getUTCDay()}}}function Ko(t,e,i){const r=new Date(Date.UTC(t,e-1,i)),n=r.getUTCDay()||7;r.setUTCDate(r.getUTCDate()+4-n);const a=new Date(Date.UTC(r.getUTCFullYear(),0,1));return Math.ceil(((r.getTime()-a.getTime())/864e5+1)/7)}const Ho=[["timeframe"],["timeframe","bars_back"],["timeframe","session","bars_back"],["timeframe","session","bars_back","timeframe_bars_back"],["timeframe","session","timezone","bars_back","timeframe_bars_back"]],zo={timeframe:"string",session:"string",timezone:"string",bars_back:"number",timeframe_bars_back:"number"};class _i{context;dataField;constructor(e,i="openTime"){this.context=e,this.dataField=i}get __value(){return this.context.data[this.dataField]}param(e,i=0){return m.from(e).get(i)}any(...e){const i=e.map(l=>l instanceof m?l.get(0):l),r=Y(i,Ho,zo),n=r.bars_back??0,a=r.timeframe_bars_back??0,s=n+a,o=this.context.data[this.dataField],c=m.from(o).get(s);if(r.session!==void 0){const l=r.timezone||this.context.pine?.syminfo?.timezone||"UTC";return this._isInSession(c,r.session,l)?c:NaN}return c}_isInSession(e,i,r){const n=i.match(/^(\d{2})(\d{2})-(\d{2})(\d{2})$/);if(!n)return!0;const a=parseInt(n[1],10),s=parseInt(n[2],10),o=parseInt(n[3],10),c=parseInt(n[4],10),l=gt(e,r),u=l.hour,p=l.minute,h=u*60+p,d=a*60+s,g=o*60+c;return d<=g?h>=d&&h<g:h>=d||h<g}}const Go=[[],["time"],["time","timezone"]],Yo={time:"number",timezone:"string"};class Pe{context;extractor;constructor(e,i){this.context=e,this.extractor=i}get __value(){const e=m.from(this.context.data.openTime).get(0);if(isNaN(e))return NaN;const i=this.context.pine?.syminfo?.timezone||"UTC",r=gt(e,i);return this.extractor(r)}param(e,i=0){return m.from(e).get(i)}any(...e){const i=e.map(o=>o instanceof m?o.get(0):o);if(i.length===0)return this.__value;const r=Y(i,Go,Yo),n=r.time;if(n===void 0||isNaN(n))return NaN;const a=r.timezone||this.context.pine?.syminfo?.timezone||"UTC",s=gt(n,a);return this.extractor(s)}}const De={dayofmonth:t=>t.day,dayofweek:t=>t.dayOfWeek===0?1:t.dayOfWeek+1,hour:t=>t.hour,minute:t=>t.minute,month:t=>t.month,second:t=>t.second,weekofyear:t=>Ko(t.year,t.month,t.day),year:t=>t.year},Qo=[["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"]],Xo={defval:"primitive",title:"string",tooltip:"string",inline:"string",group:"string",display:"string",confirm:"boolean",options:"array",minval:"number",maxval:"number",step:"number"};function oe(t){return Y(t,Qo,Xo)}function me(t,e){return e.title&&t.inputs&&t.inputs[e.title]!==void 0?t.inputs[e.title]:e.defval}function Zo(t){return(...e)=>{const i=oe(e);return me(t,i)}}function Jo(t){return(...e)=>oe(e).defval}function ec(t){return(...e)=>{const i=oe(e);return me(t,i)}}function tc(t){return(...e)=>{const i=oe(e);return me(t,i)}}function ic(t){return(...e)=>{const i=oe(e);return me(t,i)}}function rc(t){return(...e)=>{const i=oe(e);return me(t,i)}}function nc(t){return(e,i=0)=>m.from(e).get(i)}function sc(t){return(...e)=>{const i=oe(e);return me(t,i)}}function ac(t){return(...e)=>{const i=oe(e);return me(t,i)}}function oc(t){return(...e)=>{const i=oe(e);return me(t,i)}}function cc(t){return(...e)=>{const i=oe(e);return me(t,i)}}function lc(t){return(...e)=>{const i=oe(e);return me(t,i)}}function uc(t){return(...e)=>{const i=oe(e);return me(t,i)}}function hc(t){return(...e)=>{const i=oe(e);return me(t,i)}}function pc(t){return(...e)=>oe(e).defval}const fc={any:Zo,bool:Jo,color:ec,enum:tc,float:ic,int:rc,param:nc,price:sc,session:ac,source:oc,string:cc,symbol:lc,text_area:uc,time:hc,timeframe:pc};class dc{constructor(e){this.context=e,Object.entries(fc).forEach(([i,r])=>{this[i]=r(e)})}any;bool;color;enum;float;int;param;price;session;source;string;symbol;text_area;time;timeframe}function mc(t){return e=>Math.abs(m.from(e).get(0))}function xc(t){return e=>Math.acos(m.from(e).get(0))}function gc(t){return e=>Math.asin(m.from(e).get(0))}function yc(t){return e=>Math.atan(m.from(e).get(0))}function vc(t){return(...e)=>{const i=e.map(r=>m.from(r).get(0));return i.reduce((r,n)=>r+n,0)/i.length}}function wc(t){return e=>Math.ceil(m.from(e).get(0))}function bc(t){return e=>Math.cos(m.from(e).get(0))}function _c(t){return()=>Math.E}function Sc(t){return e=>Math.exp(m.from(e).get(0))}function Ec(t){return e=>Math.floor(m.from(e).get(0))}function Nc(t){return e=>Math.log(m.from(e).get(0))}function Ic(t){return e=>Math.log(m.from(e).get(0))}function Cc(t){return e=>Math.log10(m.from(e).get(0))}function kc(t){return(...e)=>{const i=e.map(r=>m.from(r).get(0));return Math.max(...i)}}function Ac(t){return(...e)=>{const i=e.map(r=>m.from(r).get(0));return Math.min(...i)}}function Tc(t){return(e,i,r)=>typeof e=="string"?e:e instanceof m?i?new m(e.data,e.offset+i):e:!Array.isArray(e)&&typeof e=="object"?e:(t.params[r]||(t.params[r]=[]),Array.isArray(e)?new m(e,i||0):(t.params[r].length===0?t.params[r].push(e):t.params[r][t.params[r].length-1]=e,new m(t.params[r],0)))}function Pc(t){return()=>1.618033988749895}function Dc(t){return()=>Math.PI}function Rc(t){return(e,i)=>Math.pow(m.from(e).get(0),m.from(i).get(0))}function Mc(t){return()=>Math.random()}function Oc(t){return(e,i)=>{const r=m.from(e).get(0);if(i==null)return Math.round(r);const n=m.from(i).get(0);if(n===0)return Math.round(r);const a=Math.pow(10,n);return Math.round(r*a)/a}}function Vc(t){return e=>t.precision(Math.round(m.from(e).get(0)/t.pine.syminfo.mintick)*t.pine.syminfo.mintick)}function Lc(t){return()=>.6180339887498948}function Bc(t){return e=>Math.sign(m.from(e).get(0))}function Fc(t){return e=>Math.sin(m.from(e).get(0))}function jc(t){return e=>Math.sqrt(m.from(e).get(0))}function Wc(t){return(e,i)=>{const r=m.from(i).get(0),n=m.from(e);let a=0;for(let s=0;s<r;s++){const o=n.get(s);a+=o}return a}}function $c(t){return e=>Math.tan(m.from(e).get(0))}function Uc(t){return e=>{const i=m.from(e).get(0);return i==null||Number.isNaN(i)?NaN:i*(180/Math.PI)}}function qc(t){return e=>{const i=m.from(e).get(0);return i==null||Number.isNaN(i)?NaN:i*(Math.PI/180)}}function Kc(t){return(e,i)=>{const r=m.from(e).get(0),n=m.from(i).get(0);return typeof r=="number"&&typeof n=="number"?isNaN(r)&&isNaN(n)?!0:isNaN(r)||isNaN(n)?!1:Math.abs(r-n)<1e-8:r===n}}const Hc={abs:mc,acos:xc,asin:gc,atan:yc,avg:vc,ceil:wc,cos:bc,e:_c,exp:Sc,floor:Ec,ln:Nc,log:Ic,log10:Cc,max:kc,min:Ac,param:Tc,phi:Pc,pi:Dc,pow:Rc,random:Mc,round:Oc,round_to_mintick:Vc,rphi:Lc,sign:Bc,sin:Fc,sqrt:jc,sum:Wc,tan:$c,todegrees:Uc,toradians:qc,__eq:Kc};class zc{constructor(e){this.context=e,Object.entries(Hc).forEach(([i,r])=>{this[i]=r(e)})}_cache={};abs;acos;asin;atan;avg;ceil;cos;e;exp;floor;ln;log;log10;max;min;param;phi;pi;pow;random;round;round_to_mintick;rphi;sign;sin;sqrt;sum;tan;todegrees;toradians;__eq}function Gc(t){return(e,i,r)=>{t.params[r]||(t.params[r]=[]);let n;if(e instanceof m)n=e.get(i||0);else if(Array.isArray(e)){const a=e.every(o=>o instanceof m),s=e.every(o=>!(o instanceof m)&&!Array.isArray(o));(a||s)&&e.length>=1?a?n=e.map(o=>o.get(0)):n=e:n=m.from(e).get(i||0)}else n=e;return t.params[r].length===0?t.params[r].push(n):t.params[r][t.params[r].length-1]=n,[n,r]}}const yt=["1","3","5","15","30","45","60","120","180","240","D","W","M"];function Si(t,e,i,r,n=!1){for(let a=0;a<i.length;a++)if(i[a]<=t&&e<=r[a])return n||e>=r[a]?a:a-1;return-1}function Ei(t,e,i,r,n=!1,a,s=!1){for(let o=i.length-1;o>=0;o--){if(r[o]<=e&&i[o]>=t){const c=a&&e>a;if(s&&n)for(let l=0;l<i.length;l++){if(i[l]>=t&&i[l]<e)return l;if(i[l]>=e)break}if(c&&n&&!s)for(let l=0;l<i.length;l++){if(i[l]>=t&&i[l]<e)return l;if(i[l]>=e)break}return o}if(r[o]<t)break}return-1}function Yc(t){return async(e,i,r,n=!1,a=!1,s=!1,o=null,c=null)=>{const l=e[0],u=i[0],p=r[0],h=r[1],d=Array.isArray(n)?n[0]:n,g=Array.isArray(a)?a[0]:a;if(t.isSecondaryContext)return p;const y=yt.indexOf(t.timeframe),v=yt.indexOf(u);if(y==-1||v==-1)throw new Error("Invalid timeframe");if(y===v)return p;const w=y>v,_=m.from(t.data.openTime).get(0),N=m.from(t.data.closeTime).get(0),I=`${l}_${u}_${h}`,S=`${I}_prevIdx`;if(t.cache[I]){const J=t.cache[I],ke=w?Ei(_,N,J.data.openTime.data,J.data.closeTime.data,g,t.eDate,d):Si(_,N,J.data.openTime.data,J.data.closeTime.data,g);if(ke==-1)return NaN;const G=J.params[h][ke];if(!w&&d){const ei=t.cache[S];return ei!==void 0&&ei===ke?NaN:(t.cache[S]=ke,Array.isArray(G)?[G]:G)}return Array.isArray(G)?[G]:G}const D=1e3*60*60*24*30,T=t.sDate?t.sDate-D:void 0,O=t.sDate&&t.eDate?void 0:t.limit||1e3,U=new Jt(t.source,l,u,O,T,void 0);U.markAsSecondary();const q=await U.run(t.pineTSCode);t.cache[I]=q;const W=w?Ei(_,N,q.data.openTime.data,q.data.closeTime.data,g,t.eDate,d):Si(_,N,q.data.openTime.data,q.data.closeTime.data,g);if(W==-1)return NaN;const Z=q.params[h][W];return!w&&d?(t.cache[S]=W,NaN):Array.isArray(Z)?[Z]:Z}}function Qc(t){return async(e,i,r,n=!1,a=null,s=!1,o=0)=>{const c=e[0],l=i[0],u=r[0],p=r[1];Array.isArray(n)&&n[0];const h=Array.isArray(s)?s[0]:s;if(t.isSecondaryContext)return Array.isArray(u)?[u]:u;const d=yt.indexOf(t.timeframe),g=yt.indexOf(l);if(d===-1||g===-1){if(h)return NaN;throw new Error("Invalid timeframe")}if(g>d){if(h)return NaN;throw new Error(`Timeframe ${l} is not lower than or equal to chart timeframe ${t.timeframe}`)}if(g===d)return[[u]];const y=`${c}_${l}_${p}_lower`;if(!t.cache[y]){const T=t.sDate?t.sDate-2592e6:void 0,O=t.sDate&&t.eDate?void 0:t.limit||1e3,U=new Jt(t.source,c,l,O,T,t.eDate);U.markAsSecondary();const q=await U.run(t.pineTSCode);t.cache[y]=q}const v=t.cache[y],w=m.from(t.data.openTime).get(0),_=m.from(t.data.closeTime).get(0),N=v.data.openTime.data,I=v.data.closeTime.data,S=v.params[p];if(!S)return[];const D=[];for(let T=0;T<N.length;T++){const O=N[T];if(!(I[T]<=w)){if(O>=_)break;O>=w&&O<_&&D.push(S[T])}}return[D]}}const Xc={param:Gc,security:Yc,security_lower_tf:Qc};class Zc{constructor(e){this.context=e,Object.entries(Xc).forEach(([i,r])=>{this[i]=r(e)})}_cache={};param;security;security_lower_tf}function Jc(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 n=t.get(t.data.close,0),a=t.get(t.data.high,0),s=t.get(t.data.low,0),o=t.get(t.data.volume,0);if(isNaN(n)||isNaN(a)||isNaN(s)||isNaN(o))return r.currentCumulativeSum=r.prevCumulativeSum,t.precision(r.prevCumulativeSum);const c=a-s;let l=0;c!==0&&(l=(n-s-(a-n))/c*o);const u=r.prevCumulativeSum+l;return r.currentCumulativeSum=u,t.precision(u)}}function el(t){return(e,i,r,n,a)=>{const s=m.from(i).get(0),o=m.from(r).get(0),c=m.from(n).get(0);t.taState||(t.taState={});const l=a||`alma_${s}_${o}_${c}`;if(!t.taState[l]){const g=o*(s-1),y=s/c,v=[];let w=0;for(let _=0;_<s;_++){const N=Math.exp(-Math.pow(_-g,2)/(2*y*y));v.push(N),w+=N}for(let _=0;_<v.length;_++)v[_]/=w;t.taState[l]={lastIdx:-1,prevWindow:[],currentWindow:[],weights:v}}const u=t.taState[l];t.idx>u.lastIdx&&(u.lastIdx>=0&&(u.prevWindow=[...u.currentWindow]),u.lastIdx=t.idx);const p=m.from(e).get(0),h=[...u.prevWindow];for(h.unshift(p);h.length>s;)h.pop();if(h.length<s&&t.idx>=s-1){const g=m.from(e);for(;h.length<s;)h.push(g.get(h.length))}if(u.currentWindow=h,h.length<s)return NaN;let d=0;for(let g=0;g<s;g++)d+=u.weights[g]*h[s-1-g];return t.precision(d)}}function tl(t){return(e,i)=>{const r=m.from(e).get(0);t.taState||(t.taState={});const n=i||`atr_${r}`;t.taState[n]||(t.taState[n]={lastIdx:-1,prevAtr:null,prevInitSum:0,prevInitCount:0,prevPrevClose:null,currentAtr:null,currentInitSum:0,currentInitCount:0,currentPrevClose:null});const a=t.taState[n];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 s=t.get(t.data.high,0),o=t.get(t.data.low,0),c=t.get(t.data.close,0);if(isNaN(s)||isNaN(o)||isNaN(c))return NaN;const l=a.prevPrevClose;let u;if(l!==null){const y=s-o,v=Math.abs(s-l),w=Math.abs(o-l);u=Math.max(y,v,w)}else u=s-o;a.currentPrevClose=c;let p=a.prevInitCount,h=a.prevInitSum,d=a.prevAtr;if(p<r){if(h+=u,p++,a.currentInitSum=h,a.currentInitCount=p,p===r){const y=h/r;return a.currentAtr=y,t.precision(y)}return NaN}const g=(d*(r-1)+u)/r;return a.currentAtr=g,t.precision(g)}}function il(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 n=t.taState[r];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevLastTrueIndex=n.currentLastTrueIndex),n.lastIdx=t.idx);const a=m.from(e).get(0);let s=n.prevLastTrueIndex;return a&&(s=t.idx),n.currentLastTrueIndex=s,s===null?NaN:t.idx-s}}function rl(t){return(e,i,r,n)=>{const a=m.from(i).get(0),s=m.from(r).get(0);t.taState||(t.taState={});const o=n||`bb_${a}_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const c=t.taState[o];t.idx>c.lastIdx&&(c.lastIdx>=0&&(c.prevWindow=[...c.currentWindow],c.prevSum=c.currentSum),c.lastIdx=t.idx);const l=m.from(e).get(0);if(isNaN(l))return c.currentWindow=[...c.prevWindow],c.currentSum=c.prevSum,[[NaN,NaN,NaN]];const u=[...c.prevWindow];let p=c.prevSum;for(u.unshift(l),p+=l;u.length>a;){const w=u.pop();p-=w}if(u.length<a&&t.idx>=a-1){const w=m.from(e);for(;u.length<a;){const _=w.get(u.length);if(isNaN(_))break;u.push(_),p+=_}}if(c.currentWindow=u,c.currentSum=p,u.length<a)return[[NaN,NaN,NaN]];const h=p/a;let d=0;for(let w=0;w<a;w++)d+=Math.pow(u[w]-h,2);const g=Math.sqrt(d/a),y=h+s*g,v=h-s*g;return[[t.precision(h),t.precision(y),t.precision(v)]]}}function nl(t){return(e,i,r,n)=>{const a=m.from(i).get(0),s=m.from(r).get(0);t.taState||(t.taState={});const o=n||`bbw_${a}_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const c=t.taState[o];t.idx>c.lastIdx&&(c.lastIdx>=0&&(c.prevWindow=[...c.currentWindow],c.prevSum=c.currentSum),c.lastIdx=t.idx);const l=m.from(e).get(0);if(isNaN(l))return c.currentWindow=[...c.prevWindow],c.currentSum=c.prevSum,NaN;const u=[...c.prevWindow];let p=c.prevSum;for(u.unshift(l),p+=l;u.length>a;){const _=u.pop();p-=_}if(u.length<a&&t.idx>=a-1){const _=m.from(e);for(;u.length<a;){const N=_.get(u.length);if(isNaN(N))break;u.push(N),p+=N}}if(c.currentWindow=u,c.currentSum=p,u.length<a)return NaN;const h=p/a;let d=0;for(let _=0;_<a;_++){const N=u[_]-h;d+=N*N}const g=d/a,y=Math.sqrt(g),v=s*y;if(h===0)return t.precision(0);const w=2*v/h*100;return t.precision(w)}}function sl(t){return(e,i,r)=>{const n=m.from(i).get(0);t.taState||(t.taState={});const a=r||`cci_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevSum=s.currentSum),s.lastIdx=t.idx);const o=m.from(e).get(0);if(isNaN(o))return NaN;const c=[...s.prevWindow];let l=s.prevSum;for(c.unshift(o),l+=o;c.length>n;){const g=c.pop();l-=g}if(c.length<n&&t.idx>=n-1){const g=m.from(e);for(;c.length<n;){const y=g.get(c.length);if(isNaN(y))break;c.push(y),l+=y}}if(s.currentWindow=c,s.currentSum=l,c.length<n)return NaN;const u=l/n;let p=0;for(let g=0;g<n;g++)p+=Math.abs(c[g]-u);const h=p/n;if(h===0)return 0;const d=(o-u)/(.015*h);return t.precision(d)}}function al(t){return(e,i=1,r)=>{typeof i=="string"&&(r=i,i=1);const n=m.from(i).get(0);t.taState||(t.taState={});const a=r||`change_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],currentWindow:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow]),s.lastIdx=t.idx);const o=m.from(e).get(0),c=[...s.prevWindow];for(c.unshift(o);c.length>n+1;)c.pop();if(c.length<n+1&&t.idx>=n){const u=m.from(e);for(;c.length<n+1;)c.push(u.get(c.length))}if(s.currentWindow=c,c.length<=n)return NaN;const l=o-c[n];return t.precision(l)}}function ol(t){return(e,i,r)=>{const n=m.from(i).get(0);t.taState||(t.taState={});const a=r||`cmo_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevGainsWindow:[],prevLossesWindow:[],prevGainsSum:0,prevLossesSum:0,currentGainsWindow:[],currentLossesWindow:[],currentGainsSum:0,currentLossesSum:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevGainsWindow=[...s.currentGainsWindow],s.prevLossesWindow=[...s.currentLossesWindow],s.prevGainsSum=s.currentGainsSum,s.prevLossesSum=s.currentLossesSum),s.lastIdx=t.idx);const o=m.from(e).get(0),c=m.from(e).get(1);if(isNaN(o)||isNaN(c))return NaN;const l=o-c,u=l>=0?l:0,p=l>=0?0:-l,h=[...s.prevGainsWindow],d=[...s.prevLossesWindow];let g=s.prevGainsSum,y=s.prevLossesSum;if(h.unshift(u),d.unshift(p),g+=u,y+=p,h.length<n)return s.currentGainsWindow=h,s.currentLossesWindow=d,s.currentGainsSum=g,s.currentLossesSum=y,NaN;if(h.length>n){const _=h.pop(),N=d.pop();g-=_,y-=N}s.currentGainsWindow=h,s.currentLossesWindow=d,s.currentGainsSum=g,s.currentLossesSum=y;const v=g+y;if(v===0)return t.precision(0);const w=100*(g-y)/v;return t.precision(w)}}function cl(t){return(e,i,r)=>{const n=m.from(i).get(0),a=m.from(e);let s=0,o=!1;for(let u=0;u<n;u++){const p=a.get(u);if(isNaN(p)){o=!0;break}s+=p}if(o)return NaN;let c=0;for(let u=0;u<n;u++){const p=a.get(u);c+=p*(u+1)}if(s===0)return NaN;const l=-c/s;return t.precision(l)}}function ll(t){return(e,i,r,n)=>{const a=m.from(r).get(0),s=m.from(e),o=m.from(i);if(t.idx<a-1)return NaN;let c=0,l=0,u=0,p=0,h=0,d=0;for(let _=0;_<a;_++){const N=s.get(_),I=o.get(_);isNaN(N)||isNaN(I)||(c+=N,l+=I,u+=N*I,p+=N*N,h+=I*I,d++)}if(d<2)return NaN;const g=d*u-c*l,y=d*p-c*c,v=d*h-l*l;if(y<=0||v<=0)return t.precision(0);const w=g/Math.sqrt(y*v);return t.precision(w)}}function ul(t){return(e,i,r)=>{const n=m.from(e),a=m.from(i),s=n.get(0),o=a.get(0),c=n.get(1),l=a.get(1);if(isNaN(s)||isNaN(o)||isNaN(c)||isNaN(l))return!1;const u=s>o&&c<=l,p=s<o&&c>=l;return u||p}}function hl(t){return(e,i)=>{const r=m.from(e),n=m.from(i),a=r.get(0),s=n.get(0),o=r.get(1),c=n.get(1);return o<c&&a>s}}function pl(t){return(e,i)=>{const r=m.from(e),n=m.from(i),a=r.get(0),s=n.get(0),o=r.get(1),c=n.get(1);return o>c&&a<s}}function fl(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 n=t.taState[r];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevCumulativeSum=n.currentCumulativeSum),n.lastIdx=t.idx);const a=m.from(e).get(0);if(isNaN(a))return n.currentCumulativeSum=n.prevCumulativeSum,t.precision(n.prevCumulativeSum);const s=n.prevCumulativeSum+a;return n.currentCumulativeSum=s,t.precision(s)}}function dl(t){return(e,i,r)=>{const n=m.from(i).get(0);t.taState||(t.taState={});const a=r||`dev_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevSum=s.currentSum),s.lastIdx=t.idx);const o=m.from(e).get(0)||0,c=[...s.prevWindow];let l=s.prevSum;for(c.unshift(o),l+=o;c.length>n;){const d=c.pop();l-=d}if(c.length<n&&t.idx>=n-1){const d=m.from(e);for(;c.length<n;){const g=d.get(c.length);c.push(g),l+=g}}if(s.currentWindow=c,s.currentSum=l,c.length<n)return NaN;const u=l/n;let p=0;for(let d=0;d<n;d++)p+=Math.abs(c[d]-u);const h=p/n;return t.precision(h)}}function ml(t){return(e,i,r)=>{const n=m.from(e).get(0),a=m.from(i).get(0);t.taState||(t.taState={});const s=r||`dmi_${n}_${a}`;t.taState[s]||(t.taState[s]={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[s];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 c=t.get(t.data.high,0),l=t.get(t.data.low,0),u=t.get(t.data.close,0);if(isNaN(c)||isNaN(l)||isNaN(u))return[[NaN,NaN,NaN]];if(o.currentHigh=c,o.currentLow=l,o.currentClose=u,isNaN(o.prevHigh))return[[NaN,NaN,NaN]];const p=Math.max(c-l,Math.abs(c-o.prevClose),Math.abs(l-o.prevClose)),h=c-o.prevHigh,d=o.prevLow-l,g=h>d&&h>0?h:0,y=d>h&&d>0?d:0;let v=o.prevInitCount,w=o.prevTrInitSum,_=o.prevPlusInitSum,N=o.prevMinusInitSum,I=o.prevSmoothedTR,S=o.prevSmoothedPlus,D=o.prevSmoothedMinus;if(v++,v<=n)w+=p,_+=g,N+=y,v===n&&(I=w/n,S=_/n,D=N/n);else{const G=1/n;I=G*p+(1-G)*I,S=G*g+(1-G)*S,D=G*y+(1-G)*D}if(o.currentInitCount=v,o.currentTrInitSum=w,o.currentPlusInitSum=_,o.currentMinusInitSum=N,o.currentSmoothedTR=I,o.currentSmoothedPlus=S,o.currentSmoothedMinus=D,v<n)return[[NaN,NaN,NaN]];const T=I===0?0:100*S/I,O=I===0?0:100*D/I,U=T+O,q=U===0?0:100*Math.abs(T-O)/U;let W=o.prevAdxInitCount,Z=o.prevDxInitSum,J=o.prevADX,ke=NaN;if(W++,W<=a)Z+=q,W===a&&(J=Z/a,ke=J);else{const G=1/a;J=G*q+(1-G)*J,ke=J}return o.currentAdxInitCount=W,o.currentDxInitSum=Z,o.currentADX=J,[[t.precision(T),t.precision(O),t.precision(ke)]]}}function xl(t){return(e,i,r)=>{const n=m.from(i).get(0);t.taState||(t.taState={});const a=r||`ema_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevEma:null,prevInitSum:0,prevInitCount:0,currentEma:null,currentInitSum:0,currentInitCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevEma=s.currentEma,s.prevInitSum=s.currentInitSum,s.prevInitCount=s.currentInitCount),s.lastIdx=t.idx);const o=m.from(e).get(0);if(o==null||isNaN(o))return NaN;let c=s.prevInitCount,l=s.prevInitSum,u=s.prevEma;if(c<n){if(l+=o,c++,s.currentInitSum=l,s.currentInitCount=c,c===n){const d=l/n;return s.currentEma=d,t.precision(d)}return NaN}const p=2/(n+1),h=o*p+u*(1-p);return s.currentEma=h,t.precision(h)}}function gl(t){return(e,i,r)=>{const n=m.from(i).get(0),a=m.from(e);for(let s=0;s<n;s++){const o=a.get(s),c=a.get(s+1);if(isNaN(o)||isNaN(c)||o>=c)return!1}return!0}}function yl(t){return(e,i,r)=>{typeof i=="string"&&r===void 0&&(r=i,i=e,e=t.data.high);const n=m.from(i).get(0);t.taState||(t.taState={});const a=r||`highest_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],currentWindow:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow]),s.lastIdx=t.idx);const o=m.from(e).get(0),c=[...s.prevWindow];for(c.unshift(o);c.length>n;)c.pop();if(c.length<n&&t.idx>=n-1){const p=m.from(e);for(;c.length<n;)c.push(p.get(c.length))}if(s.currentWindow=c,c.length<n)return NaN;const l=c.filter(p=>!isNaN(p)&&p!==void 0);if(l.length===0)return NaN;const u=Math.max(...l);return t.precision(u)}}function vl(t){return(e,i,r)=>{const n=m.from(i).get(0),a=m.from(e);if(t.idx<n-1)return NaN;let s=-1/0,o=NaN;for(let c=0;c<n;c++){const l=a.get(c);isNaN(l)||(isNaN(o)||l>s)&&(s=l,o=-c)}return o}}function wl(t){return(e,i,r)=>{const n=m.from(i).get(0),a=Math.floor(n/2),s=Math.floor(Math.sqrt(n)),o=t.pine.ta.wma,c=o(e,a,r?`${r}_wma1`:void 0),l=o(e,n,r?`${r}_wma2`:void 0);if(isNaN(c)||isNaN(l))return NaN;t.taState||(t.taState={});const u=r||`hma_raw_${n}`;t.taState[u]||(t.taState[u]={lastIdx:-1,prevValues:[],currentValues:[]});const p=t.taState[u];t.idx>p.lastIdx&&(p.lastIdx>=0&&(p.prevValues=[...p.currentValues]),p.lastIdx=t.idx);const h=2*c-l,d=[...p.prevValues];d.unshift(h),d.length>s+1&&d.pop(),p.currentValues=d;const g=r?`${r}_hma_final`:`hma_final_${n}`;t.taState[g]||(t.taState[g]={lastIdx:-1,prevWindow:[],currentWindow:[]});const y=t.taState[g];t.idx>y.lastIdx&&(y.lastIdx>=0&&(y.prevWindow=[...y.currentWindow]),y.lastIdx=t.idx);const v=[...y.prevWindow];if(v.unshift(h),v.length<s)return y.currentWindow=v,NaN;for(;v.length>s;)v.pop();y.currentWindow=v;let w=0,_=0;for(let I=0;I<s;I++){const S=s-I;w+=v[I]*S,_+=S}const N=w/_;return t.precision(N)}}function bl(t){return e=>{const i=t.get(t.data.close,0),r=t.get(t.data.high,0),n=t.get(t.data.low,0),a=t.get(t.data.volume,0);if(isNaN(i)||isNaN(r)||isNaN(n)||isNaN(a))return NaN;const s=(r-n)*a;if(s===0)return t.precision(0);const o=(2*i-r-n)/s;return t.precision(o)}}function _l(t){return(e,i,r,n,a)=>{const s=m.from(i).get(0),o=m.from(r).get(0);let c=!0;typeof n=="string"?a=n:n!==void 0&&(c=m.from(n).get(0));let l;const u=t.get(t.data.high,0),p=t.get(t.data.low,0);if(c){const I=t.get(t.data.close,1);isNaN(I)?l=NaN:l=Math.max(u-p,Math.abs(u-I),Math.abs(p-I))}else l=u-p;const h=m.from(e).get(0);t.taState||(t.taState={});const d=a||`kc_${s}_${o}_${c}`;t.taState[d]||(t.taState[d]={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 g=t.taState[d];t.idx>g.lastIdx&&(g.lastIdx>=0&&(g.basisState={...g.currentBasisState},g.rangeState={...g.currentRangeState}),g.lastIdx=t.idx);const y=(I,S,D,T)=>{if(isNaN(D))return Object.assign(S,I),S.prevEma!==null?S.prevEma:NaN;let O=I.initCount,U=I.initSum,q=I.prevEma;if(O<T){if(U+=D,O++,S.initSum=U,S.initCount=O,S.prevEma=q,O===T){const J=U/T;return S.prevEma=J,J}return NaN}const W=2/(T+1),Z=D*W+q*(1-W);return S.prevEma=Z,S.initSum=U,S.initCount=O,Z},v=y(g.basisState,g.currentBasisState,h,s),w=y(g.rangeState,g.currentRangeState,l,s);if(isNaN(v)||isNaN(w))return[[NaN,NaN,NaN]];const _=v+w*o,N=v-w*o;return[[t.precision(v),t.precision(_),t.precision(N)]]}}function Sl(t){return(e,i,r,n,a)=>{const s=m.from(i).get(0),o=m.from(r).get(0);let c=!0;typeof n=="string"?a=n:n!==void 0&&(c=m.from(n).get(0)),t.taState||(t.taState={});const l=a||`kcw_${s}_${o}_${c}`;t.taState[l]||(t.taState[l]={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 u=t.taState[l];t.idx>u.lastIdx&&(u.lastIdx>=0&&(u.basisState={...u.currentBasisState},u.rangeState={...u.currentRangeState}),u.lastIdx=t.idx);const p=(N,I,S,D)=>{if(isNaN(S))return Object.assign(I,N),I.prevEma!==null?I.prevEma:NaN;let T=N.initCount,O=N.initSum,U=N.prevEma;if(T<D){if(O+=S,T++,I.initSum=O,I.initCount=T,I.prevEma=U,T===D){const Z=O/D;return I.prevEma=Z,Z}return NaN}const q=2/(D+1),W=S*q+U*(1-q);return I.prevEma=W,I.initSum=O,I.initCount=T,W};let h;const d=t.get(t.data.high,0),g=t.get(t.data.low,0);if(c){const N=t.get(t.data.close,1);isNaN(N)?h=NaN:h=Math.max(d-g,Math.abs(d-N),Math.abs(g-N))}else h=d-g;const y=m.from(e).get(0),v=p(u.basisState,u.currentBasisState,y,s),w=p(u.rangeState,u.currentRangeState,h,s);if(isNaN(v)||isNaN(w))return NaN;if(v===0)return t.precision(0);const _=2*w*o/v;return t.precision(_)}}function El(t){return(e,i,r,n)=>{const a=m.from(i).get(0),s=m.from(r).get(0);t.taState||(t.taState={});const o=n||`linreg_${a}_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],currentWindow:[]});const c=t.taState[o];t.idx>c.lastIdx&&(c.lastIdx>=0&&(c.prevWindow=[...c.currentWindow]),c.lastIdx=t.idx);const l=m.from(e).get(0),u=[...c.prevWindow];for(u.unshift(l);u.length>a;)u.pop();if(u.length<a&&t.idx>=a-1){const N=m.from(e);for(;u.length<a;)u.push(N.get(u.length))}if(c.currentWindow=u,u.length<a)return NaN;let p=0,h=0,d=0,g=0;const y=a;for(let N=0;N<a;N++){const I=a-1-N,S=u[N];p+=I,h+=S,d+=I*S,g+=I*I}const v=y*g-p*p;if(v===0)return NaN;const w=(y*d-p*h)/v,_=(h-w*p)/y+w*(a-1-s);return t.precision(_)}}function Nl(t){return(e,i,r)=>{typeof i=="string"&&r===void 0&&(r=i,i=e,e=t.data.low);const n=m.from(i).get(0);t.taState||(t.taState={});const a=r||`lowest_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],currentWindow:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow]),s.lastIdx=t.idx);const o=m.from(e).get(0),c=[...s.prevWindow];for(c.unshift(o);c.length>n;)c.pop();if(c.length<n&&t.idx>=n-1){const p=m.from(e);for(;c.length<n;)c.push(p.get(c.length))}if(s.currentWindow=c,c.length<n)return NaN;const l=c.filter(p=>!isNaN(p)&&p!==void 0),u=l.length>0?Math.min(...l):NaN;return t.precision(u)}}function Il(t){return(e,i,r)=>{const n=m.from(i).get(0),a=m.from(e);if(t.idx<n-1)return NaN;let s=1/0,o=NaN;for(let c=0;c<n;c++){const l=a.get(c);isNaN(l)||(isNaN(o)||l<s)&&(s=l,o=-c)}return o}}function Cl(t){return(e,i,r,n,a)=>{const s=m.from(i).get(0),o=m.from(r).get(0),c=m.from(n).get(0),l=a||`macd_${s}_${o}_${c}`,u=`${l}_fast`,p=`${l}_slow`,h=`${l}_signal`,d=t.pine.ta.ema(e,s,u),g=t.pine.ta.ema(e,o,p);let y=NaN;!isNaN(d)&&!isNaN(g)&&(y=d-g);let v=NaN;isNaN(y)||(v=t.pine.ta.ema(y,c,h));let w=NaN;return!isNaN(y)&&!isNaN(v)&&(w=y-v),[[t.precision(y),t.precision(v),t.precision(w)]]}}function kl(t){return(e,i,r)=>{const n=m.from(i).get(0);t.taState||(t.taState={});const a=r||`median_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],currentWindow:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow]),s.lastIdx=t.idx);const o=m.from(e).get(0),c=[...s.prevWindow];for(c.unshift(o);c.length>n;)c.pop();if(c.length<n&&t.idx>=n-1){const h=m.from(e);for(;c.length<n;)c.push(h.get(c.length))}if(s.currentWindow=c,c.length<n)return NaN;const l=c.slice().sort((h,d)=>h-d),u=Math.floor(n/2),p=n%2===0?(l[u-1]+l[u])/2:l[u];return t.precision(p)}}function Al(t){return(e,i,r)=>{const n=m.from(i).get(0);t.taState||(t.taState={});const a=r||`mfi_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevUpperWindow:[],prevLowerWindow:[],prevUpperSum:0,prevLowerSum:0,currentUpperWindow:[],currentLowerWindow:[],currentUpperSum:0,currentLowerSum:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevUpperWindow=[...s.currentUpperWindow],s.prevLowerWindow=[...s.currentLowerWindow],s.prevUpperSum=s.currentUpperSum,s.prevLowerSum=s.currentLowerSum),s.lastIdx=t.idx);const o=m.from(e).get(0),c=m.from(e).get(1),l=t.get(t.data.volume,0);if(isNaN(o)||isNaN(l))return NaN;const u=isNaN(c)?NaN:o-c,p=l*(u<=0?0:o),h=l*(u>=0?0:o),d=[...s.prevUpperWindow],g=[...s.prevLowerWindow];let y=s.prevUpperSum,v=s.prevLowerSum;if(d.unshift(p),g.unshift(h),y+=p,v+=h,d.length<n)return s.currentUpperWindow=d,s.currentLowerWindow=g,s.currentUpperSum=y,s.currentLowerSum=v,NaN;if(d.length>n){const _=d.pop(),N=g.pop();y-=_,v-=N}if(s.currentUpperWindow=d,s.currentLowerWindow=g,s.currentUpperSum=y,s.currentLowerSum=v,v===0)return t.precision(100);if(y===0)return t.precision(0);const w=100-100/(1+y/v);return t.precision(w)}}function Tl(t){return(e,i,r)=>{const n=m.from(i).get(0),a=m.from(e);if(t.idx<n-1)return NaN;const s=new Map;for(let l=0;l<n;l++){const u=a.get(l);isNaN(u)||s.set(u,(s.get(u)||0)+1)}if(s.size===0)return NaN;let o=NaN,c=-1;for(const[l,u]of s.entries())u>c?(c=u,o=l):u===c&&l<o&&(o=l);return o}}function Pl(t){return(e,i,r)=>{const n=m.from(i).get(0);return t.pine.ta.change(e,n,r)}}function Dl(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 n=t.get(t.data.close,0),a=t.get(t.data.close,1),s=t.get(t.data.volume,0),o=t.get(t.data.volume,1),c=isNaN(n)?0:n,l=isNaN(a)?0:a,u=isNaN(s)?0:s,p=isNaN(o)?0:o;let h=r.committedNVI;if(!(c===0||l===0)&&u<p){const d=(c-l)/l;h=h+d*h}return r.tentativeNVI=h,t.precision(h)}}function Rl(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),n=t.get(t.data.volume,0),a=t.get(t.data.close,1);if(isNaN(a))return i.tentativeOBV=0,t.precision(0);let s=i.committedOBV;return r>a?s+=n:r<a&&(s-=n),i.tentativeOBV=s,t.precision(s)}}function Ml(t){return(e,i,r)=>e instanceof m?i?new m(e.data,e.offset+i):e:(t.params[r]||(t.params[r]=[]),Array.isArray(e)?new m(e,i||0):(t.params[r].length===0?t.params[r].push(e):t.params[r][t.params[r].length-1]=e,new m(t.params[r],0)))}function Ol(t){return(e,i,r,n)=>{const a=m.from(i).get(0),s=m.from(r).get(0),o=m.from(e);if(t.idx<a-1)return NaN;const c=[];for(let g=0;g<a;g++){const y=o.get(g);if(isNaN(y))return NaN;c.push(y)}c.sort((g,y)=>g-y);let l=s/100*a-.5;l<0&&(l=0),l>a-1&&(l=a-1);const u=Math.floor(l),p=Math.ceil(l);if(u===p)return t.precision(c[u]);const h=l-u,d=c[u]+h*(c[p]-c[u]);return t.precision(d)}}function Vl(t){return(e,i,r,n)=>{const a=m.from(i).get(0),s=m.from(r).get(0),o=m.from(e);if(t.idx<a-1)return NaN;const c=[];for(let u=0;u<a;u++){const p=o.get(u);isNaN(p)||c.push(p)}if(c.length===0)return NaN;c.sort((u,p)=>u-p);let l=Math.ceil(s/100*c.length)-1;return l<0&&(l=0),l>=c.length&&(l=c.length-1),t.precision(c[l])}}function Ll(t){return(e,i,r)=>{const n=m.from(i).get(0),a=m.from(e);if(t.idx<n)return NaN;const s=a.get(0);if(isNaN(s))return NaN;let o=0,c=0;for(let l=1;l<=n;l++){const u=a.get(l);isNaN(u)||(c++,u<=s&&o++)}return c===0?NaN:t.precision(o/c*100)}}function Bl(t,e,i){const r=new Array(t.length).fill(NaN);for(let n=e+i;n<t.length;n++){const a=t[n-i];let s=!0;for(let o=1;o<=e;o++)if(t[n-i-o]>=a){s=!1;break}if(s){for(let o=1;o<=i;o++)if(t[n-i+o]>=a){s=!1;break}}s&&(r[n]=a)}return r}function Fl(t){return(e,i,r,n)=>{typeof r=="string"&&(r=i,i=e,e=t.data.high);const a=m.from(i).get(0),s=m.from(r).get(0),o=m.from(e).toArray(),c=Bl(o,a,s),l=t.idx;return t.precision(c[l])}}function jl(t,e,i){const r=new Array(t.length).fill(NaN);for(let n=e+i;n<t.length;n++){const a=t[n-i];let s=!0;for(let o=1;o<=e;o++)if(t[n-i-o]<=a){s=!1;break}if(s){for(let o=1;o<=i;o++)if(t[n-i+o]<=a){s=!1;break}}s&&(r[n]=a)}return r}function Wl(t){return(e,i,r,n)=>{typeof r=="string"&&(r=i,i=e,e=t.data.low);const a=m.from(i).get(0),s=m.from(r).get(0),o=m.from(e).toArray(),c=jl(o,a,s),l=t.idx;return t.precision(c[l])}}function $l(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 n=t.get(t.data.close,0),a=t.get(t.data.close,1),s=t.get(t.data.volume,0),o=t.get(t.data.volume,1),c=isNaN(n)?0:n,l=isNaN(a)?0:a,u=isNaN(s)?0:s,p=isNaN(o)?0:o;let h=r.committedPVI;if(!(c===0||l===0)&&u>p){const d=(c-l)/l;h=h+d*h}return r.tentativePVI=h,t.precision(h)}}function Ul(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 n=t.get(t.data.close,0),a=t.get(t.data.close,1),s=t.get(t.data.volume,0);let o=r.prevCumulativeSum;if(!isNaN(n)&&!isNaN(a)&&!isNaN(s)&&a!==0){const c=(n-a)/a*s;o+=c}return r.currentCumulativeSum=o,t.precision(o)}}function ql(t){return(e,i,r)=>{const n=t.pine.ta.highest(e,i,(r||"range")+"_h"),a=t.pine.ta.lowest(e,i,(r||"range")+"_l");return isNaN(n)||isNaN(a)?NaN:t.precision(n-a)}}function Kl(t){return(e,i,r)=>{const n=m.from(i).get(0),a=m.from(e);for(let s=0;s<n;s++){const o=a.get(s),c=a.get(s+1);if(isNaN(o)||isNaN(c)||o<=c)return!1}return!0}}function Hl(t){return(e,i,r)=>{const n=m.from(i).get(0);t.taState||(t.taState={});const a=r||`rma_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevRma:null,prevInitSum:0,prevInitCount:0,currentRma:null,currentInitSum:0,currentInitCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevRma=s.currentRma,s.prevInitSum=s.currentInitSum,s.prevInitCount=s.currentInitCount),s.lastIdx=t.idx);const o=m.from(e).get(0)||0;let c=s.prevInitCount,l=s.prevInitSum,u=s.prevRma;if(c<n){if(l+=o,c++,s.currentInitSum=l,s.currentInitCount=c,c===n){const d=l/n;return s.currentRma=d,t.precision(d)}return NaN}const p=1/n,h=o*p+u*(1-p);return s.currentRma=h,t.precision(h)}}function zl(t){return(e,i,r)=>{const n=m.from(i).get(0);t.taState||(t.taState={});const a=r||`roc_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],currentWindow:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow]),s.lastIdx=t.idx);const o=m.from(e).get(0),c=[...s.prevWindow];for(c.unshift(o);c.length>n+1;)c.pop();if(c.length<n+1&&t.idx>=n){const p=m.from(e);for(;c.length<n+1;)c.push(p.get(c.length))}if(s.currentWindow=c,c.length<=n)return NaN;const l=c[n],u=(o-l)/l*100;return t.precision(u)}}function Gl(t){return(e,i,r)=>{const n=m.from(i).get(0);t.taState||(t.taState={});const a=r||`rsi_${n}`;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 s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevPrevValue=s.currentPrevValue,s.prevAvgGain=s.currentAvgGain,s.prevAvgLoss=s.currentAvgLoss,s.prevInitGains=[...s.currentInitGains],s.prevInitLosses=[...s.currentInitLosses]),s.lastIdx=t.idx);const o=m.from(e).get(0),c=s.prevPrevValue;let l=s.prevAvgGain,u=s.prevAvgLoss;const p=[...s.prevInitGains],h=[...s.prevInitLosses];if(c!==null){const d=o-c,g=d>0?d:0,y=d<0?-d:0;if(p.length<n){if(p.push(g),h.push(y),s.currentInitGains=p,s.currentInitLosses=h,s.currentPrevValue=o,p.length===n){l=p.reduce((_,N)=>_+N,0)/n,u=h.reduce((_,N)=>_+N,0)/n,s.currentAvgGain=l,s.currentAvgLoss=u;const w=u===0?100:100-100/(1+l/u);return t.precision(w)}return NaN}l=(l*(n-1)+g)/n,u=(u*(n-1)+y)/n,s.currentAvgGain=l,s.currentAvgLoss=u,s.currentPrevValue=o;const v=u===0?100:100-100/(1+l/u);return t.precision(v)}return s.currentPrevValue=o,s.currentInitGains=[],s.currentInitLosses=[],NaN}}function Yl(t){return(e,i,r,n)=>{const a=m.from(e).get(0),s=m.from(i).get(0),o=m.from(r).get(0);t.taState||(t.taState={});const c=n||`sar_${a}_${s}_${o}`;t.taState[c]||(t.taState[c]={lastIdx:-1,prevResult:NaN,prevMaxMin:NaN,prevAcceleration:NaN,prevIsBelow:!1,prevBarIndex:0,currentResult:NaN,currentMaxMin:NaN,currentAcceleration:NaN,currentIsBelow:!1,currentBarIndex:0});const l=t.taState[c];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevResult=l.currentResult,l.prevMaxMin=l.currentMaxMin,l.prevAcceleration=l.currentAcceleration,l.prevIsBelow=l.currentIsBelow,l.prevBarIndex=l.currentBarIndex),l.lastIdx=t.idx);let u=l.prevResult,p=l.prevMaxMin,h=l.prevAcceleration,d=l.prevIsBelow,g=l.prevBarIndex;const y=t.get(t.data.high,0),v=t.get(t.data.low,0),w=t.get(t.data.close,0),_=t.get(t.data.close,1),N=t.get(t.data.high,1),I=t.get(t.data.low,1),S=t.get(t.data.high,2),D=t.get(t.data.low,2);if(isNaN(y)||isNaN(v)||isNaN(w))return l.currentResult=u,l.currentMaxMin=p,l.currentAcceleration=h,l.currentIsBelow=d,l.currentBarIndex=g,NaN;let T=!1;return g===1&&(w>_?(d=!0,p=y,u=I):(d=!1,p=v,u=N),T=!0,h=a),g>=1&&(u=u+h*(p-u),d?u>v&&(T=!0,d=!1,u=Math.max(y,p),p=v,h=a):u<y&&(T=!0,d=!0,u=Math.min(v,p),p=y,h=a),T||(d?y>p&&(p=y,h=Math.min(h+s,o)):v<p&&(p=v,h=Math.min(h+s,o))),d?(u=Math.min(u,I),g>1&&(u=Math.min(u,D))):(u=Math.max(u,N),g>1&&(u=Math.max(u,S)))),g++,l.currentResult=u,l.currentMaxMin=p,l.currentAcceleration=h,l.currentIsBelow=d,l.currentBarIndex=g,g<=1?NaN:t.precision(u)}}function Ql(t){return(e,i,r)=>{const n=m.from(i).get(0);t.taState||(t.taState={});const a=r||`sma_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevSum=s.currentSum),s.lastIdx=t.idx);const o=m.from(e).get(0),c=[...s.prevWindow];for(c.unshift(o);c.length>n;)c.pop();let l=!1;if(c.length<n&&t.idx>=n-1){const g=m.from(e);for(;c.length<n;)c.push(g.get(c.length));l=!0}let u;const p=o==null||Number.isNaN(o);let h=!Number.isNaN(s.prevSum)&&!p&&!l;if(h){let g=s.prevSum+o;if(s.prevWindow.length>=n){const y=s.prevWindow[s.prevWindow.length-1];y==null||Number.isNaN(y)?h=!1:g-=y}h&&(u=g)}if(!h){u=0;let g=!1;for(const y of c){if(y==null||Number.isNaN(y)){g=!0;break}u+=y}g&&(u=NaN)}if(s.currentWindow=c,s.currentSum=u,c.length<n)return NaN;const d=u/n;return t.precision(d)}}function Xl(t){return(e,i,r=!0,n)=>{const a=m.from(i).get(0),s=m.from(r).get(0);t.taState||(t.taState={});const o=n||`stdev_${a}_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const c=t.taState[o];t.idx>c.lastIdx&&(c.lastIdx>=0&&(c.prevWindow=[...c.currentWindow],c.prevSum=c.currentSum),c.lastIdx=t.idx);const l=m.from(e).get(0);if(l==null||isNaN(l))return NaN;const u=[...c.prevWindow];let p=c.prevSum;for(u.unshift(l),p+=l;u.length>a;){const v=u.pop();p-=v}if(u.length<a&&t.idx>=a-1){const v=m.from(e);for(;u.length<a;){const w=v.get(u.length);if(w==null||isNaN(w))break;u.push(w),p+=w}}if(c.currentWindow=u,c.currentSum=p,u.length<a)return NaN;const h=p/a;let d=0;for(let v=0;v<a;v++)d+=Math.pow(u[v]-h,2);const g=s?a:a-1,y=Math.sqrt(d/g);return t.precision(y)}}function Zl(t){return(e,i,r,n,a)=>{const s=m.from(n).get(0);t.taState||(t.taState={});const o=a||`stoch_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevHighWindow:[],prevLowWindow:[],currentHighWindow:[],currentLowWindow:[]});const c=t.taState[o];t.idx>c.lastIdx&&(c.lastIdx>=0&&(c.prevHighWindow=[...c.currentHighWindow],c.prevLowWindow=[...c.currentLowWindow]),c.lastIdx=t.idx);const l=m.from(e).get(0),u=m.from(i).get(0),p=m.from(r).get(0);if(isNaN(l)||isNaN(u)||isNaN(p))return c.currentHighWindow=[...c.prevHighWindow],c.currentLowWindow=[...c.prevLowWindow],NaN;const h=[...c.prevHighWindow],d=[...c.prevLowWindow];if(h.unshift(u),d.unshift(p),h.length>s&&(h.pop(),d.pop()),c.currentHighWindow=h,c.currentLowWindow=d,h.length<s)return NaN;let g=h[0],y=d[0];for(let _=1;_<s;_++)h[_]>g&&(g=h[_]),d[_]<y&&(y=d[_]);const v=g-y;if(v===0)return NaN;const w=100*(l-y)/v;return t.precision(w)}}function Jl(t){return(e,i,r)=>{const n=m.from(e).get(0),a=m.from(i).get(0);t.taState||(t.taState={});const s=r||`supertrend_${n}_${a}`;t.taState[s]||(t.taState[s]={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[s];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 c=t.get(t.data.high,0),l=t.get(t.data.low,0),u=t.get(t.data.close,0);if(isNaN(c)||isNaN(l)||isNaN(u))return[[NaN,NaN]];const p=(c+l)/2,h=o.prevClose;let d;isNaN(h)?d=c-l:d=Math.max(c-l,Math.abs(c-h),Math.abs(l-h));let g=o.prevAtrCount,y=o.prevTrSum,v=o.prevAtrValue;g++,g<=a?(y+=d,g===a&&(v=y/a)):v=(v*(a-1)+d)/a;const w=v;if(o.currentAtrCount=g,o.currentTrSum=y,o.currentAtrValue=v,o.currentClose=u,isNaN(w))return[[NaN,NaN]];let _=p+n*w,N=p-n*w;const I=isNaN(o.prevLowerBand)?0:o.prevLowerBand,S=isNaN(o.prevUpperBand)?0:o.prevUpperBand;isNaN(o.prevLowerBand)||N>I||h<I||(N=I),isNaN(o.prevUpperBand)||_<S||h>S||(_=S);let D,T;const O=o.prevSuperTrend;return g===a?D=1:O===o.prevUpperBand?D=u>_?-1:1:D=u<N?1:-1,T=D===-1?N:_,o.currentLowerBand=N,o.currentUpperBand=_,o.currentSuperTrend=T,o.currentDirection=D,[[t.precision(T),D]]}}function eu(t){return(e,i)=>{const r=[1,2,2,1],n=6;t.taState||(t.taState={});const a=i||"swma";t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],currentWindow:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow]),s.lastIdx=t.idx);const o=m.from(e).get(0),c=[...s.prevWindow];for(c.unshift(o);c.length>4;)c.pop();if(c.length<4&&t.idx>=3){const u=m.from(e);for(;c.length<4;)c.push(u.get(c.length))}if(s.currentWindow=c,c.length<4)return NaN;let l=0;for(let u=0;u<4;u++)l+=r[u]*c[3-u];return l/=n,t.precision(l)}}function tu(t){return(e,i)=>{let r=!0;typeof e=="string"||e!==void 0&&(r=m.from(e).get(0));const n=t.get(t.data.high,0),a=t.get(t.data.low,0),s=t.get(t.data.close,1);if(isNaN(s))return r?t.precision(n-a):NaN;const o=Math.max(n-a,Math.abs(n-s),Math.abs(a-s));return t.precision(o)}}function iu(t){return(e,i,r,n)=>{const a=m.from(i).get(0),s=m.from(r).get(0);t.taState||(t.taState={});const o=n||`tsi_${a}_${s}`;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 c=t.taState[o];t.idx>c.lastIdx&&(c.lastIdx>=0&&(c.prevSource=c.currentSource,c.prevEma1PcValue=c.currentEma1PcValue,c.prevEma1PcCount=c.currentEma1PcCount,c.prevEma1PcSum=c.currentEma1PcSum,c.prevEma2PcValue=c.currentEma2PcValue,c.prevEma2PcCount=c.currentEma2PcCount,c.prevEma2PcSum=c.currentEma2PcSum,c.prevEma1AbsValue=c.currentEma1AbsValue,c.prevEma1AbsCount=c.currentEma1AbsCount,c.prevEma1AbsSum=c.currentEma1AbsSum,c.prevEma2AbsValue=c.currentEma2AbsValue,c.prevEma2AbsCount=c.currentEma2AbsCount,c.prevEma2AbsSum=c.currentEma2AbsSum),c.lastIdx=t.idx);const l=m.from(e).get(0);if(isNaN(l))return NaN;const u=isNaN(c.prevSource)?NaN:l-c.prevSource;if(c.currentSource=l,isNaN(u))return NaN;const p=Math.abs(u),h=2/(s+1),d=2/(a+1),g=2/(s+1),y=2/(a+1);let v=c.prevEma1PcCount,w=c.prevEma1PcSum,_=c.prevEma1PcValue;v++,v<=s?(w+=u,v===s&&(_=w/s)):_=u*h+_*(1-h);let N=c.prevEma1AbsCount,I=c.prevEma1AbsSum,S=c.prevEma1AbsValue;if(N++,N<=s?(I+=p,N===s&&(S=I/s)):S=p*g+S*(1-g),isNaN(_)||isNaN(S))return c.currentEma1PcCount=v,c.currentEma1PcSum=w,c.currentEma1PcValue=_,c.currentEma1AbsCount=N,c.currentEma1AbsSum=I,c.currentEma1AbsValue=S,NaN;let D=c.prevEma2PcCount,T=c.prevEma2PcSum,O=c.prevEma2PcValue;D++,D<=a?(T+=_,D===a&&(O=T/a)):O=_*d+O*(1-d);let U=c.prevEma2AbsCount,q=c.prevEma2AbsSum,W=c.prevEma2AbsValue;if(U++,U<=a?(q+=S,U===a&&(W=q/a)):W=S*y+W*(1-y),c.currentEma1PcCount=v,c.currentEma1PcSum=w,c.currentEma1PcValue=_,c.currentEma1AbsCount=N,c.currentEma1AbsSum=I,c.currentEma1AbsValue=S,c.currentEma2PcCount=D,c.currentEma2PcSum=T,c.currentEma2PcValue=O,c.currentEma2AbsCount=U,c.currentEma2AbsSum=q,c.currentEma2AbsValue=W,isNaN(O)||isNaN(W))return NaN;if(W===0)return t.precision(0);const Z=O/W;return t.precision(Z)}}function ru(t){return(e,i,r,n)=>{t.taState||(t.taState={});const a=n||"valuewhen";t.taState[a]||(t.taState[a]={lastIdx:-1,prevValues:[],currentValues:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevValues=[...s.currentValues]),s.lastIdx=t.idx);const o=m.from(e).get(0),c=m.from(i).get(0),l=m.from(r).get(0),u=[...s.prevValues];if(o&&u.push(c),s.currentValues=u,isNaN(l)||l<0)return NaN;const p=u.length-1-l;if(p<0)return NaN;const h=u[p];return typeof h=="number"?t.precision(h):h}}function nu(t){return(e,i,r)=>{const n=m.from(i).get(0);t.taState||(t.taState={});const a=r||`variance_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],currentWindow:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow]),s.lastIdx=t.idx);const o=m.from(e).get(0),c=[...s.prevWindow];for(c.unshift(o);c.length>n;)c.pop();if(c.length<n&&t.idx>=n-1){const d=m.from(e);for(;c.length<n;)c.push(d.get(c.length))}if(s.currentWindow=c,c.length<n)return NaN;let l=0,u=0;for(let d=0;d<n;d++)l+=c[d],u+=c[d]*c[d];const p=l/n,h=u/n-p*p;return t.precision(h)}}function su(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 n=t.taState[r];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevCumulativePV=n.currentCumulativePV,n.prevCumulativeVolume=n.currentCumulativeVolume,n.prevLastSessionDate=n.currentLastSessionDate),n.lastIdx=t.idx);const a=m.from(e).get(0),s=m.from(t.data.volume).get(0),o=m.from(t.data.openTime).get(0),c=new Date(o).toISOString().slice(0,10);let l=n.prevCumulativePV,u=n.prevCumulativeVolume,p=n.prevLastSessionDate;if(p!==c&&(l=0,u=0,p=c),l+=a*s,u+=s,n.currentCumulativePV=l,n.currentCumulativeVolume=u,n.currentLastSessionDate=p,u===0)return NaN;const h=l/u;return t.precision(h)}}function au(t){return(e,i,r)=>{const n=m.from(i).get(0);t.taState||(t.taState={});const a=r||`vwma_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevVolumeWindow:[],currentWindow:[],currentVolumeWindow:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevVolumeWindow=[...s.currentVolumeWindow]),s.lastIdx=t.idx);const o=m.from(e).get(0),c=t.get(t.data.volume,0),l=[...s.prevWindow],u=[...s.prevVolumeWindow];for(l.unshift(o),u.unshift(c);l.length>n;)l.pop(),u.pop();if(l.length<n&&t.idx>=n-1){const g=m.from(e),y=m.from(t.data.volume);for(;l.length<n;)l.push(g.get(l.length)),u.push(y.get(u.length))}if(s.currentWindow=l,s.currentVolumeWindow=u,l.length<n)return NaN;let p=0,h=0;for(let g=0;g<n;g++)p+=l[g]*u[g],h+=u[g];const d=p/h;return t.precision(d)}}function ou(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 n=t.get(t.data.close,0),a=t.get(t.data.high,0),s=t.get(t.data.low,0),o=t.get(t.data.close,1);if(isNaN(n)||isNaN(a)||isNaN(s))return r.currentCumulativeSum=r.prevCumulativeSum,t.precision(r.prevCumulativeSum);let c=0;if(!isNaN(o)){const u=Math.max(a,o),p=Math.min(s,o),h=n-o;h>0?c=n-p:h<0&&(c=n-u)}const l=r.prevCumulativeSum+c;return r.currentCumulativeSum=l,t.precision(l)}}function cu(t){return(e,i,r)=>{const n=m.from(i).get(0);t.taState||(t.taState={});const a=r||`wma_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],currentWindow:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow]),s.lastIdx=t.idx);const o=m.from(e).get(0),c=[...s.prevWindow];for(c.unshift(o);c.length>n;)c.pop();if(c.length<n&&t.idx>=n-1){const h=m.from(e);for(;c.length<n;)c.push(h.get(c.length))}if(s.currentWindow=c,c.length<n)return NaN;let l=0,u=0;for(let h=0;h<n;h++){const d=n-h;l+=c[h]*d,u+=d}const p=l/u;return t.precision(p)}}function lu(t){return(e,i)=>{const r=m.from(e).get(0);t.taState||(t.taState={});const n=i||`wpr_${r}`;t.taState[n]||(t.taState[n]={lastIdx:-1,prevHighWindow:[],prevLowWindow:[],currentHighWindow:[],currentLowWindow:[]});const a=t.taState[n];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevHighWindow=[...a.currentHighWindow],a.prevLowWindow=[...a.currentLowWindow]),a.lastIdx=t.idx);const s=t.get(t.data.high,0),o=t.get(t.data.low,0),c=t.get(t.data.close,0);if(isNaN(s)||isNaN(o)||isNaN(c))return a.currentHighWindow=[...a.prevHighWindow],a.currentLowWindow=[...a.prevLowWindow],NaN;const l=[...a.prevHighWindow],u=[...a.prevLowWindow];if(l.unshift(s),u.unshift(o),l.length>r&&(l.pop(),u.pop()),a.currentHighWindow=l,a.currentLowWindow=u,l.length<r)return NaN;let p=l[0],h=u[0];for(let y=1;y<r;y++)l[y]>p&&(p=l[y]),u[y]<h&&(h=u[y]);const d=p-h;if(d===0)return t.precision(0);const g=(p-c)/d*-100;return t.precision(g)}}function uu(t){return e=>{const i=t.get(t.data.close,0),r=t.get(t.data.open,0),n=t.get(t.data.high,0),a=t.get(t.data.low,0),s=t.get(t.data.volume,0);if(isNaN(i)||isNaN(r)||isNaN(n)||isNaN(a)||isNaN(s))return NaN;const o=n-a;if(o===0)return t.precision(0);const c=(i-r)/o*s;return t.precision(c)}}const hu={accdist:Jc,alma:el,atr:tl,barssince:il,bb:rl,bbw:nl,cci:sl,change:al,cmo:ol,cog:cl,correlation:ll,cross:ul,crossover:hl,crossunder:pl,cum:fl,dev:dl,dmi:ml,ema:xl,falling:gl,highest:yl,highestbars:vl,hma:wl,iii:bl,kc:_l,kcw:Sl,linreg:El,lowest:Nl,lowestbars:Il,macd:Cl,median:kl,mfi:Al,mode:Tl,mom:Pl,nvi:Dl,obv:Rl,param:Ml,percentile_linear_interpolation:Ol,percentile_nearest_rank:Vl,percentrank:Ll,pivothigh:Fl,pivotlow:Wl,pvi:$l,pvt:Ul,range:ql,rising:Kl,rma:Hl,roc:zl,rsi:Gl,sar:Yl,sma:Ql,stdev:Xl,stoch:Zl,supertrend:Jl,swma:eu,tr:tu,tsi:iu,valuewhen:ru,variance:nu,vwap:su,vwma:au,wad:ou,wma:cu,wpr:lu,wvad:uu};class pu{constructor(e){this.context=e,Object.entries(hu).forEach(([i,r])=>{this[i]=r(e)})}accdist;alma;atr;barssince;bb;bbw;cci;change;cmo;cog;correlation;cross;crossover;crossunder;cum;dev;dmi;ema;falling;highest;highestbars;hma;iii;kc;kcw;linreg;lowest;lowestbars;macd;median;mfi;mode;mom;nvi;obv;param;percentile_linear_interpolation;percentile_nearest_rank;percentrank;pivothigh;pivotlow;pvi;pvt;range;rising;rma;roc;rsi;sar;sma;stdev;stoch;supertrend;swma;tr;tsi;valuewhen;variance;vwap;vwma;wad;wma;wpr;wvad}function Tt(t=new Date,e){const i=e??-t.getTimezoneOffset(),r=i>=0?"+":"-",n=s=>String(Math.floor(Math.abs(s))).padStart(2,"0"),a=r+n(i/60)+":"+n(i%60);return`[${t.toISOString().slice(0,-1)}${a}]`}class fu{constructor(e){this.context=e}logFormat(e,...i){return e.replace(/{(\d+)}/g,(r,n)=>i[n])}param(e,i=0,r){return m.from(e).get(i)}warning(e,...i){const r=this.context.data.openTime.data[this.context.idx],n=Tt(new Date(r),0);console.warn(`${n} ${this.logFormat(e,...i)}`)}error(e,...i){const r=this.context.data.openTime.data[this.context.idx],n=Tt(new Date(r),0);console.error(`${n} ${this.logFormat(e,...i)}`)}info(e,...i){const r=this.context.data.openTime.data[this.context.idx],n=Tt(new Date(r),0);console.log(`${n} ${this.logFormat(e,...i)}`)}}class du{constructor(e){this.context=e}param(e,i=0,r){return m.from(e).get(i)}tostring(e,i){if(i==="mintick"&&typeof e=="number"){const r=this.context.pine?.syminfo?.mintick||.01,n=Math.max(0,-Math.floor(Math.log10(r)));return e.toFixed(n)}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,n=0){const a=String(e),s=String(i),o=String(r),c=Math.floor(Number(n))||0;if(s==="")return a;let l=0,u=0;for(;;){const p=a.indexOf(s,l);if(p===-1)return a;if(u===c)return a.substring(0,p)+o+a.substring(p+s.length);u++,l=p+s.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,n)=>i[n])}}class mu{constructor(e){this.context=e}param(e,i=0,r){return m.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 Ni=["series","title","color","linewidth","style","trackprice","histbase","offset","join","editable","show_last","display","format","precision","force_overlay"],xu=["series","title","style","location","color","offset","text","textcolor","editable","size","show_last","display","format","precision","force_overlay"],gu=["series","title","colorup","colordown","offset","minheight","maxheight","editable","show_last","display","format","precision","force_overlay"],yu=["open","high","low","close","title","color","editable","show_last","display","format","precision","force_overlay"],vu=["open","high","low","close","title","color","wickcolor","editable","show_last","bordercolor","display","format","precision","force_overlay"],Ii=["color","offset","editable","show_last","title","display","force_overlay"],wu=["plot1","plot2","color","title","editable","show_last","fillgaps","display"],Ci={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"},bu={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"},_u={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"},Su={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"},Eu={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"},ki={color:"string",offset:"number",editable:"boolean",show_last:"number",title:"string",display:"string",force_overlay:"boolean"},Nu={plot1:"object",plot2:"object",color:"string",title:"string",editable:"boolean",show_last:"number",fillgaps:"boolean",display:"string"};class Iu{constructor(e){this.context=e}_resolvePlotKey(e,i){if(e){const r=this.context.plots[e];return!r||!i||r._callsiteId===i?e:e+i}return i||"plot"}extractPlotOptions(e){const i={};for(let r in e)i[r]=m.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 m.from(e).get(i)}plotchar(...e){const i=we(e),r=Y(e,Ni,Ci),{series:n,title:a,...s}=r,o=this.extractPlotOptions(s),c=this._resolvePlotKey(a,i);this.context.plots[c]||(this.context.plots[c]={data:[],options:{...o,style:"char"},title:a,_plotKey:c,_callsiteId:i});const l=m.from(n).get(0);return this.context.plots[c].data.push({title:a,time:this.context.marketData[this.context.idx].openTime,value:l}),this.context.plots[c]}any(...e){const i=we(e),r=Y(e,Ni,Ci),{series:n,title:a,...s}=r,o=this.extractPlotOptions(s),c=this._resolvePlotKey(a,i);if(!this.context.plots[c]){const u=o.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[c]={data:[],options:{...o,overlay:u},title:a,_plotKey:c,_callsiteId:i}}const l=m.from(n).get(0);return this.context.plots[c].data.push({title:a,time:this.context.marketData[this.context.idx].openTime,value:l,options:{color:o.color,offset:o.offset}}),this.context.plots[c]}plotshape(...e){const i=we(e),r=Y(e,xu,bu),{series:n,title:a,...s}=r,o=this.extractPlotOptions(s),c=this._resolvePlotKey(a,i);if(!this.context.plots[c]){const u=o.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[c]={data:[],options:{...o,style:"shape",shape:o.style,overlay:u},title:a,_plotKey:c,_callsiteId:i}}const l=m.from(n).get(0);return this.context.plots[c].data.push({title:a,time:this.context.marketData[this.context.idx].openTime,value:l,options:o?.location==="absolute"||l?{text:o.text,textcolor:o.textcolor,color:o.color,offset:o.offset,shape:o.style,location:o.location,size:o.size}:void 0}),this.context.plots[c]}plotarrow(...e){const i=we(e),r=Y(e,gu,_u),{series:n,title:a,...s}=r,o=m.from(n).get(0),c=this.extractPlotOptions(s),l=this._resolvePlotKey(a,i);if(!this.context.plots[l]){const u=c.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[l]={data:[],options:{...c,style:"shape",overlay:u},title:a,_plotKey:l,_callsiteId:i}}return this.context.plots[l].data.push({title:a,time:this.context.marketData[this.context.idx].openTime,value:o,options:typeof o=="number"&&!isNaN(o)&&o!==0?{text:void 0,textcolor:void 0,color:o>0?c.colorup:c.colordown,offset:c.offset,shape:o>0?"arrowup":"arrowdown",location:o>0?"belowbar":"abovebar",height:c.maxheight}:void 0}),this.context.plots[l]}plotbar(...e){const i=we(e),r=Y(e,yu,Su),{open:n,high:a,low:s,close:o,title:c,...l}=r,u=this.extractPlotOptions(l),p=this._resolvePlotKey(c,i);if(!this.context.plots[p]){const d=u.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[p]={data:[],options:{...u,style:"bar",overlay:d},title:c,_plotKey:p,_callsiteId:i}}const h=[m.from(n).get(0),m.from(a).get(0),m.from(s).get(0),m.from(o).get(0)];this.context.plots[p].data.push({title:c,time:this.context.marketData[this.context.idx].openTime,value:h,options:{color:u.color}})}plotcandle(...e){const i=we(e),r=Y(e,vu,Eu),{open:n,high:a,low:s,close:o,title:c,...l}=r,u=this.extractPlotOptions(l),p=this._resolvePlotKey(c,i);if(!this.context.plots[p]){const d=u.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[p]={data:[],options:{...u,style:"candle",overlay:d},title:c,_plotKey:p,_callsiteId:i}}const h=[m.from(n).get(0),m.from(a).get(0),m.from(s).get(0),m.from(o).get(0)];return this.context.plots[p].data.push({title:c,time:this.context.marketData[this.context.idx].openTime,value:h,options:{color:u.color,wickcolor:u.wickcolor,bordercolor:u.bordercolor}}),this.context.plots[p]}bgcolor(...e){const i=we(e),r=Y(e,Ii,ki),{title:n,...a}=r,s=this.extractPlotOptions(a),o=this._resolvePlotKey(n,i);if(!this.context.plots[o]){const c=s.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[o]={data:[],options:{...s,style:"background",overlay:c},title:n,_plotKey:o,_callsiteId:i}}this.context.plots[o].data.push({title:n,time:this.context.marketData[this.context.idx].openTime,value:s.color&&s.color!=="na"&&s?.color.toString()!=="NaN",options:{color:s.color}})}barcolor(...e){const i=we(e),r=Y(e,Ii,ki),{title:n,...a}=r,s=this.extractPlotOptions(a),o=this._resolvePlotKey(n,i);return this.context.plots[o]||(this.context.plots[o]={data:[],options:{...s,style:"barcolor"},title:n,_plotKey:o,_callsiteId:i}),this.context.plots[o].data.push({title:n,time:this.context.marketData[this.context.idx].openTime,value:s.color&&s.color!=="na"&&s?.color.toString()!=="NaN",options:{color:s.color}}),this.context.plots[o]}}class Cu{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 m.from(e).get(i)}any(...e){const i=we(e),[r,n,a,s,o,c,l]=e,u=[r,{title:n,color:a,linestyle:s,linewidth:o,editable:c,display:l}];return i&&u.push({__callsiteId:i}),this.context.pine.plot.any(...u)}}class ku{constructor(e){this.context=e}param(e,i=0,r){return m.from(e).get(i)}any(...e){const i=we(e),r=Y(e,wu,Nu),{plot1:n,plot2:a,color:s,title:o,editable:c,show_last:l,fillgaps:u,display:p}=r;let h=o||"fill";const d=this.context.plots[h];if(d&&i&&d._callsiteId!==i&&(h=i),!this.context.plots[h]){const g=n?._plotKey||n?.title,y=a?._plotKey||a?.title;this.context.plots[h]={title:o||"Fill",plot1:g,plot2:y,options:{plot1:g,plot2:y,color:s,editable:c,show_last:l,fillgaps:u,display:p,style:"fill"},_plotKey:h,_callsiteId:i}}}}class Au{constructor(e){this.context=e;const i=this.context;this.point={new(r,n,a){return new ye(r,n,a??NaN)},from_index(r,n){return new ye(void 0,r,n)},from_time(r,n){return new ye(r,void 0,n)},copy(r){return r.copy()},now(r){const n=i.idx,a=i.marketData[n]?.openTime;return new ye(a,n,r)}}}point;param(e,i=0,r){return m.from(e).get(i)}bg_color(){return"#1e293b"}fg_color(){return"#ffffff"}is_standard(){return!0}is_heikinashi(){return!1}is_kagi(){return!1}is_linebreak(){return!1}is_pnf(){return!1}is_range(){return!1}is_renko(){return!1}}let Tu=0;class Xt{id;x;y;text;xloc;yloc;color;style;textcolor;size;textalign;tooltip;text_font_family;force_overlay;_deleted;constructor(e,i,r="",n="bar_index",a="price",s="",o="style_label_down",c="",l="normal",u="align_center",p="",h="family_default",d=!1){this.id=Tu++,this.x=e,this.y=i,this.text=r,this.xloc=n,this.yloc=a,this.color=s,this.style=o,this.textcolor=c,this.size=l,this.textalign=u,this.tooltip=p,this.text_font_family=h,this.force_overlay=d,this._deleted=!1}copy(){return new Xt(this.x,this.y,this.text,this.xloc,this.yloc,this.color,this.style,this.textcolor,this.size,this.textalign,this.tooltip,this.text_font_family,this.force_overlay)}toPlotData(){return{id:this.id,x:this.x,y:this.y,text:this.text,xloc:this.xloc,yloc:this.yloc,color:this.color,style:this.style,textcolor:this.textcolor,size:this.size,textalign:this.textalign,tooltip:this.tooltip,text_font_family:this.text_font_family,force_overlay:this.force_overlay}}}const Pu=[["x","y","text","xloc","yloc","color","style","textcolor","size","textalign","tooltip","text_font_family","force_overlay"],["point","text","xloc","yloc","color","style","textcolor","size","textalign","tooltip","text_font_family","force_overlay"]],Du={x:"number",y:"number",text:"string",xloc:"string",yloc:"string",color:"string",style:"string",textcolor:"string",size:"string",textalign:"string",tooltip:"string",text_font_family:"string",force_overlay:"boolean",point:"point"};class Ru{constructor(e){this.context=e}_labels=[];param(e,i=0,r){return m.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__labels__||(this.context.plots.__labels__={title:"__labels__",data:[],options:{style:"label",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__labels__.data=[{time:e,value:this._labels,options:{style:"label"}}]}_resolve(e){return e==null?e:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_createLabel(e,i,r="",n="bar_index",a="price",s="",o="style_label_down",c="",l="normal",u="align_center",p="",h="family_default",d=!1){const g=new Xt(e,i,this._resolve(r),this._resolve(n),this._resolve(a),this._resolve(s),this._resolve(o),this._resolve(c),this._resolve(l),this._resolve(u),this._resolve(p),this._resolve(h),d);return this._labels.push(g),this._syncToPlot(),g}new(...e){const i=Y(e,Pu,Du);let r,n,a=i.xloc;if(i.point instanceof ye){const s=i.point;s.index!==void 0?(r=s.index,a=a||"bar_index"):s.time!==void 0?(r=s.time,a=a||"bar_time"):(r=0,a=a||"bar_index"),n=s.price}else r=i.x,n=i.y;return this._createLabel(r,n,i.text,a,i.yloc,i.color,i.style,i.textcolor,i.size,i.textalign,i.tooltip,i.text_font_family,i.force_overlay)}any(...e){return this.new(...e)}set_x(e,i){e&&!e._deleted&&(e.x=i)}set_y(e,i){e&&!e._deleted&&(e.y=i)}set_xy(e,i,r){e&&!e._deleted&&(e.x=i,e.y=r)}set_text(e,i){e&&!e._deleted&&(e.text=i)}set_color(e,i){e&&!e._deleted&&(e.color=i)}set_textcolor(e,i){e&&!e._deleted&&(e.textcolor=i)}set_size(e,i){e&&!e._deleted&&(e.size=i)}set_style(e,i){e&&!e._deleted&&(e.style=i)}set_textalign(e,i){e&&!e._deleted&&(e.textalign=i)}set_tooltip(e,i){e&&!e._deleted&&(e.tooltip=i)}set_xloc(e,i){e&&!e._deleted&&(e.xloc=i)}set_yloc(e,i){e&&!e._deleted&&(e.yloc=i)}set_point(e,i){e&&!e._deleted&&i&&(i.index!==void 0?(e.x=i.index,e.xloc="bar_index"):i.time!==void 0&&(e.x=i.time,e.xloc="bar_time"),e.y=i.price)}get_x(e){return e?e.x:NaN}get_y(e){return e?e.y:NaN}get_text(e){return e?e.text:""}copy(e){if(!e)return;const i=e.copy();return this._labels.push(i),this._syncToPlot(),i}delete(e){e&&(e._deleted=!0)}get all(){return this._labels.filter(e=>!e._deleted)}get style_label_down(){return"style_label_down"}get style_label_up(){return"style_label_up"}get style_label_left(){return"style_label_left"}get style_label_right(){return"style_label_right"}get style_label_lower_left(){return"style_label_lower_left"}get style_label_lower_right(){return"style_label_lower_right"}get style_label_upper_left(){return"style_label_upper_left"}get style_label_upper_right(){return"style_label_upper_right"}get style_label_center(){return"style_label_center"}get style_circle(){return"style_circle"}get style_square(){return"style_square"}get style_diamond(){return"style_diamond"}get style_flag(){return"style_flag"}get style_arrowup(){return"style_arrowup"}get style_arrowdown(){return"style_arrowdown"}get style_cross(){return"style_cross"}get style_xcross(){return"style_xcross"}get style_triangleup(){return"style_triangleup"}get style_triangledown(){return"style_triangledown"}get style_none(){return"style_none"}get style_text_outline(){return"style_text_outline"}}let Mu=0;class Zt{id;x1;y1;x2;y2;xloc;extend;color;style;width;force_overlay;_deleted;constructor(e,i,r,n,a="bar_index",s="none",o="",c="style_solid",l=1,u=!1){this.id=Mu++,this.x1=e,this.y1=i,this.x2=r,this.y2=n,this.xloc=a,this.extend=s,this.color=o,this.style=c,this.width=l,this.force_overlay=u,this._deleted=!1}copy(){return new Zt(this.x1,this.y1,this.x2,this.y2,this.xloc,this.extend,this.color,this.style,this.width,this.force_overlay)}toPlotData(){return{id:this.id,x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2,xloc:this.xloc,extend:this.extend,color:this.color,style:this.style,width:this.width,force_overlay:this.force_overlay}}}const Ou=[["x1","y1","x2","y2","xloc","extend","color","style","width","force_overlay"],["first_point","second_point","xloc","extend","color","style","width","force_overlay"]],Vu={x1:"number",y1:"number",x2:"number",y2:"number",xloc:"string",extend:"string",color:"string",style:"string",width:"number",force_overlay:"boolean",first_point:"point",second_point:"point"};class Lu{constructor(e){this.context=e}_lines=[];param(e,i=0,r){return m.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__lines__||(this.context.plots.__lines__={title:"__lines__",data:[],options:{style:"drawing_line",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__lines__.data=[{time:e,value:this._lines,options:{style:"drawing_line"}}]}_resolvePoint(e){return e.index!==void 0?{x:e.index,xloc:"bar_index"}:e.time!==void 0?{x:e.time,xloc:"bar_time"}:{x:0,xloc:"bar_index"}}_resolve(e){return e==null?e:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_createLine(e,i,r,n,a="bar_index",s="none",o="",c="style_solid",l=1,u=!1){const p=new Zt(e,i,r,n,a,this._resolve(s),this._resolve(o),this._resolve(c),this._resolve(l)||1,u);return this._lines.push(p),this._syncToPlot(),p}new(...e){const i=Y(e,Ou,Vu);let r,n,a,s,o=i.xloc;if(i.first_point instanceof ye){const c=i.first_point,l=i.second_point,u=this._resolvePoint(c);r=u.x,n=c.price,o=o||u.xloc,l instanceof ye?(a=this._resolvePoint(l).x,s=l.price):(a=0,s=NaN)}else r=i.x1,n=i.y1,a=i.x2,s=i.y2;return this._createLine(r,n,a,s,o,i.extend,i.color,i.style,i.width,i.force_overlay)}any(...e){return this.new(...e)}set_x1(e,i){e&&!e._deleted&&(e.x1=i)}set_y1(e,i){e&&!e._deleted&&(e.y1=i)}set_x2(e,i){e&&!e._deleted&&(e.x2=i)}set_y2(e,i){e&&!e._deleted&&(e.y2=i)}set_xy1(e,i,r){e&&!e._deleted&&(e.x1=i,e.y1=r)}set_xy2(e,i,r){e&&!e._deleted&&(e.x2=i,e.y2=r)}set_color(e,i){e&&!e._deleted&&(e.color=this._resolve(i))}set_width(e,i){e&&!e._deleted&&(e.width=this._resolve(i)||1)}set_style(e,i){e&&!e._deleted&&(e.style=this._resolve(i))}set_extend(e,i){e&&!e._deleted&&(e.extend=this._resolve(i))}set_xloc(e,i,r,n){e&&!e._deleted&&(e.x1=i,e.x2=r,e.xloc=n)}set_first_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.x1=r.x,e.y1=i.price,e.xloc=r.xloc}}set_second_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.x2=r.x,e.y2=i.price,e.xloc=r.xloc}}get_x1(e){return e?e.x1:NaN}get_y1(e){return e?e.y1:NaN}get_x2(e){return e?e.x2:NaN}get_y2(e){return e?e.y2:NaN}get_price(e,i){if(!e||e._deleted)return NaN;if(e.xloc!=="bar_index")return NaN;const r=e.x2-e.x1;return r===0?e.y1:e.y1+(i-e.x1)/r*(e.y2-e.y1)}copy(e){if(!e)return;const i=e.copy();return this._lines.push(i),this._syncToPlot(),i}delete(e){e&&(e._deleted=!0)}get all(){return this._lines.filter(e=>!e._deleted)}get style_solid(){return"style_solid"}get style_dotted(){return"style_dotted"}get style_dashed(){return"style_dashed"}get style_arrow_left(){return"style_arrow_left"}get style_arrow_right(){return"style_arrow_right"}get style_arrow_both(){return"style_arrow_both"}}let Bu=0;class Fu{id;line1;line2;color;_deleted;constructor(e,i,r){this.id=Bu++,this.line1=e,this.line2=i,this.color=r,this._deleted=!1}}class ju{constructor(e){this.context=e}_linefills=[];param(e,i=0,r){return m.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__linefills__||(this.context.plots.__linefills__={title:"__linefills__",data:[],options:{style:"linefill",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__linefills__.data=[{time:e,value:this._linefills,options:{style:"linefill"}}]}_resolve(e){return e==null?e:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}new(e,i,r){const n=this._resolve(r)||"",a=new Fu(e,i,n);return this._linefills.push(a),this._syncToPlot(),a}any(...e){return this.new(e[0],e[1],e[2])}set_color(e,i){e&&!e._deleted&&(e.color=this._resolve(i)||"")}get_line1(e){return e?e.line1:void 0}get_line2(e){return e?e.line2:void 0}delete(e){e&&(e._deleted=!0)}get all(){return this._linefills.filter(e=>!e._deleted)}}class Xe{data={open:new m([]),high:new m([]),low:new m([]),close:new m([]),volume:new m([]),hl2:new m([]),hlc3:new m([]),ohlc4:new m([]),hlcc4:new m([])};indicator;cache={};taState={};isSecondaryContext=!1;NA=NaN;lang;length=0;pine;static _deprecationWarningsShown=new Set;idx=0;params={};const={};var={};let={};lctx=new Map;result=void 0;plots={};marketData;source;tickerId;timeframe="";limit;sDate;eDate;fullContext;pineTSCode;inputs={};constructor({marketData:e,source:i,tickerId:r,timeframe:n,limit:a,sDate:s,eDate:o,fullContext:c,inputs:l}){this.marketData=e,this.source=i,this.tickerId=r,this.timeframe=n,this.limit=a,this.sDate=s,this.eDate=o,this.fullContext=c||this,this.inputs=l||{};const u=new qo(this),p={Type:u.Type.bind(u),na:new Uo,color:u.color,nz:u.nz.bind(u),indicator:u.indicator.bind(u),fixnan:u.fixnan.bind(u),alertcondition:u.alertcondition.bind(u),timestamp:u.timestamp.bind(u),time:new _i(this,"openTime"),time_close:new _i(this,"closeTime"),dayofmonth:new Pe(this,De.dayofmonth),dayofweek:new Pe(this,De.dayofweek),hour:new Pe(this,De.hour),minute:new Pe(this,De.minute),month:new Pe(this,De.month),second:new Pe(this,De.second),weekofyear:new Pe(this,De.weekofyear),year:new Pe(this,De.year),bool:u.bool.bind(u)},h=this;this.pine={input:new dc(this),ta:new pu(this),math:new zc(this),request:new Zc(this),array:new ba(this),map:new Ma(this),matrix:new Oo(this),syminfo:null,timeframe:new mu(this),barstate:new Vo(this),get bar_index(){return h.idx},get last_bar_index(){return h.data.close.length-1},get last_bar_time(){return h.data.openTime.get(h.data.openTime.length-1)},get timenow(){return new Date().getTime()},get time_tradingday(){const S=m.from(h.data.openTime).get(0);if(isNaN(S))return NaN;const D=h.pine?.syminfo?.timezone||"UTC",T=gt(S,D);return Date.UTC(T.year,T.month-1,T.day,0,0,0)},get inputs(){return h.inputs},log:new fu(this),str:new du(this),...p,...aa};const d=p.dayofweek;Object.assign(d,{sunday:1,monday:2,tuesday:3,wednesday:4,thursday:5,friday:6,saturday:7}),this.pine.dayofweek=d;const g=new Iu(this),y=new Cu(this),v=new ku(this);this.bindContextObject(g,["plotchar","plotshape","plotarrow","plotbar","plotcandle","bgcolor","barcolor"]),this.bindContextObject(g,["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(y,["any","style_dashed","style_solid","style_dotted","param"],"hline"),this.bindContextObject(v,["any","param"],"fill");const w=new Au(this);this.pine.chart={param:w.param.bind(w),bg_color:w.bg_color.bind(w),fg_color:w.fg_color.bind(w),is_standard:w.is_standard.bind(w),is_heikinashi:w.is_heikinashi.bind(w),is_kagi:w.is_kagi.bind(w),is_linebreak:w.is_linebreak.bind(w),is_pnf:w.is_pnf.bind(w),is_range:w.is_range.bind(w),is_renko:w.is_renko.bind(w),point:w.point};const _=new Ru(this);this.bindContextObject(_,["any","new","param","set_x","set_y","set_xy","set_text","set_color","set_textcolor","set_size","set_style","set_textalign","set_tooltip","set_point","set_xloc","set_yloc","get_x","get_y","get_text","copy","delete","style_label_down","style_label_up","style_label_left","style_label_right","style_label_lower_left","style_label_lower_right","style_label_upper_left","style_label_upper_right","style_label_center","style_circle","style_square","style_diamond","style_flag","style_arrowup","style_arrowdown","style_cross","style_xcross","style_triangleup","style_triangledown","style_none","style_text_outline"],"label"),Object.defineProperty(this.pine.label,"all",{get:()=>_.all});const N=new Lu(this);this.bindContextObject(N,["any","new","param","set_x1","set_y1","set_x2","set_y2","set_xy1","set_xy2","set_color","set_width","set_style","set_extend","set_xloc","set_first_point","set_second_point","get_x1","get_y1","get_x2","get_y2","get_price","copy","delete","style_solid","style_dotted","style_dashed","style_arrow_left","style_arrow_right","style_arrow_both"],"line"),Object.defineProperty(this.pine.line,"all",{get:()=>N.all});const I=new ju(this);this.bindContextObject(I,["any","new","param","set_color","get_line1","get_line2","delete"],"linefill"),Object.defineProperty(this.pine.linefill,"all",{get:()=>I.all})}bindContextObject(e,i,r=""){r&&!this.pine[r]&&(this.pine[r]={});const n=r?this.pine[r]:this.pine;for(const a of i)typeof e[a]=="function"?n[a]=e[a].bind(e):n[a]=e[a]}init(e,i,r=0){let n;return i instanceof m?n=i.get(0):Array.isArray(i)?Array.isArray(i[0])?n=i[0]:n=i[i.length-1+r]:n=i,e?e instanceof m?(e.data[e.data.length-1]=n,e):Array.isArray(e)?(e[e.length-1]=n,new m(e)):new m([n]):new m([n])}initVar(e,i){if(e)return e;typeof i=="function"&&(i=i());let r;return i instanceof m?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 m([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 m?i?new m(e.data,e.offset+i):e:!Array.isArray(e)&&typeof e=="object"?e:(this.params[r]||(this.params[r]=[]),Array.isArray(e)?new m(e,i||0):(this.params[r].length===0?this.params[r].push(e):this.params[r][this.params[r].length-1]=e,new m(this.params[r],0)))}get(e,i){if(e instanceof m)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 m){e.set(0,i);return}if(Array.isArray(e)){e.length>0?e[e.length-1]=i:e.push(i);return}}_callStack=[];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}`;Xe._deprecationWarningsShown.has(r)||(Xe._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`))}}class Wt{source;inputs;constructor(e,i={}){this.source=e,this.inputs=i}}class Jt{constructor(e,i,r,n,a,s){this.source=e,this.tickerId=i,this.timeframe=r,this.limit=n,this.sDate=a,this.eDate=s,this._readyPromise=new Promise(o=>{this.loadMarketData(e,i,r,n,a,s).then(c=>{const l=c;this.data=l;const u=l.map(S=>S.open),p=l.map(S=>S.close),h=l.map(S=>S.high),d=l.map(S=>S.low),g=l.map(S=>S.volume),y=l.map(S=>(S.high+S.low+S.close)/3),v=l.map(S=>(S.high+S.low)/2),w=l.map(S=>(S.high+S.low+S.open+S.close)/4),_=l.map(S=>(S.high+S.low+S.close+S.close)/4),N=l.map(S=>S.openTime),I=l.map(S=>S.closeTime);this.open=u,this.close=p,this.high=h,this.low=d,this.volume=g,this.hl2=v,this.hlc3=y,this.ohlc4=w,this.hlcc4=_,this.openTime=N,this.closeTime=I,e&&e.getSymbolInfo?e.getSymbolInfo(i).then(S=>{this._syminfo=S,this._ready=!0,o(!0)}).catch(S=>{console.warn("Failed to get symbol info, using default values:",S),this._ready=!0,o(!0)}):(this._ready=!0,o(!0))})})}data=[];open=[];high=[];low=[];close=[];volume=[];hl2=[];hlc3=[];ohlc4=[];hlcc4=[];openTime=[];closeTime=[];_readyPromise=null;_ready=!1;_debugSettings={ln:!1,debug:!1};_transpiledCode=null;get transpiledCode(){return this._transpiledCode}_isSecondaryContext=!1;markAsSecondary(){this._isSecondaryContext=!0}_syminfo;setDebugSettings({ln:e,debug:i}){this._debugSettings.ln=e,this._debugSettings.debug=i}async loadMarketData(e,i,r,n,a,s){return Array.isArray(e)?e:e.getMarketData(i,r,n,a,s)}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 n,a={};if(e instanceof Wt?(n=e.source,a=e.inputs||{}):n=e,r&&r>0){const s=typeof this.eDate>"u"&&!Array.isArray(this.source);return this._runPaginated(n,a,i,r,s)}else return this._runComplete(n,a,i)}stream(e,i={}){const{live:r=!0,interval:n=1e3}=i,a=i.pageSize||this.data.length;let s,o={};e instanceof Wt?(s=e.source,o=e.inputs||{}):s=e;const c={data:[],error:[]};let l=!1;const u=(d,...g)=>{c[d]&&c[d].forEach(y=>y(...g))},p=(d,g)=>{c[d]||(c[d]=[]),c[d].push(g)},h=()=>{l=!0};return(async()=>{try{const d=typeof this.eDate>"u"&&!Array.isArray(this.source)&&r,g=this._runPaginated(s,o,void 0,a,d);for await(const y of g){if(l)break;if(y===null){await new Promise(v=>setTimeout(v,n));continue}if(u("data",y),d&&!l){const v=y.marketData[y.idx];v&&v.closeTime<Date.now()||await new Promise(w=>setTimeout(w,n))}}}catch(d){u("error",d)}})(),{on:p,stop:h}}async _runComplete(e,i,r){await this.ready(),r||(r=this.data.length);const n=this._initializeContext(e,i,this._isSecondaryContext);return this._transpiledCode=this._transpileCode(e),await this._executeIterations(n,this._transpiledCode,this.data.length-r,this.data.length),n}async*_runPaginated(e,i,r,n,a=!1){await this.ready(),r||(r=this.data.length);const s=this._initializeContext(e,i,this._isSecondaryContext);this._transpiledCode=this._transpileCode(e);let o=this.data.length-r;for(;;){const c=this.data.length-o;if(c>0){const p=Math.min(c,n),h=this._getResultLength(s.result);await this._executeIterations(s,this._transpiledCode,o,o+p),o+=p,yield this._createPageContext(s,h);continue}if(!a||Array.isArray(this.source))break;const{newCandles:l,updatedLastCandle:u}=await this._updateMarketData();if(l===0&&!u){yield null;continue}this._removeLastResult(s),o=this.data.length-(l+1),s.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 Xe({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 n in e.result)Array.isArray(e.result[n])?r.result[n]=e.result[n].slice(i):r.result[n]=e.result[n]}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,n=this.data[r].openTime;try{const a=await i.getMarketData(this.tickerId,this.timeframe,void 0,n,e);if(!a||a.length===0)return{newCandles:0,updatedLastCandle:!1};let s=!1,o=0;for(let c=0;c<a.length;c++){const l=a[c];l.openTime===n?(this._replaceCandle(r,l),s=!0):l.openTime>n&&(this._appendCandle(l),o++)}return{newCandles:o,updatedLastCandle:s}}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 n in e.result)Array.isArray(e.result[n])&&e.result[n].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=n=>{for(let a of i)if(n[a])for(let s in n[a]){const o=n[a][s];o instanceof m?o.data.pop():Array.isArray(o)&&o.pop()}};r(e),e.lctx&&e.lctx.forEach(n=>r(n))}_initializeContext(e,i={},r=!1){const n=new Xe({marketData:this.data,source:this.source,tickerId:this.tickerId,timeframe:this.timeframe,limit:this.limit,sDate:this.sDate,eDate:this.eDate,inputs:i});return n.pine.syminfo=this._syminfo,n.pineTSCode=e,n.isSecondaryContext=r,n.data.close=new m([]),n.data.open=new m([]),n.data.high=new m([]),n.data.low=new m([]),n.data.volume=new m([]),n.data.hl2=new m([]),n.data.hlc3=new m([]),n.data.ohlc4=new m([]),n.data.hlcc4=new m([]),n.data.openTime=new m([]),n.data.closeTime=new m([]),n.length=this.data.length,n}_transpileCode(e){return bs.bind(this)(e,this._debugSettings)}async _executeIterations(e,i,r,n){const a=["const","var","let","params"];for(let s=r;s<n;s++){e.idx=s,e.data.close.data.push(this.close[s]),e.data.open.data.push(this.open[s]),e.data.high.data.push(this.high[s]),e.data.low.data.push(this.low[s]),e.data.volume.data.push(this.volume[s]),e.data.hl2.data.push(this.hl2[s]),e.data.hlc3.data.push(this.hlc3[s]),e.data.ohlc4.data.push(this.ohlc4[s]),e.data.hlcc4.data.push(this.hlcc4[s]),e.data.openTime.data.push(this.openTime[s]),e.data.closeTime.data.push(this.closeTime[s]);const o=await i(e);if(typeof o=="object"){typeof e.result!="object"&&(e.result={});for(let l in o){e.result[l]===void 0&&(e.result[l]=[]);let u;o[l]instanceof m?u=o[l].get(0):Array.isArray(o[l])?u=o[l][o[l].length-1]:u=o[l],e.result[l].push(u)}}else Array.isArray(e.result)||(e.result=[]),e.result.push(o);const c=l=>{for(let u of a)if(l[u])for(let p in l[u]){const h=l[u][p];if(h instanceof m){const d=h.get(0);h.data.push(d)}else if(Array.isArray(h)){const d=h[h.length-1];h.push(d)}}};c(e),e.lctx&&e.lctx.forEach(l=>c(l))}}}const Pt="https://api.binance.com/api/v3",Ai="https://api.binance.us/api/v3",Dt={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 Wu{cache;cacheDuration;constructor(e=300*1e3){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 $u{cacheManager;activeApiUrl=null;constructor(){this.cacheManager=new Wu(300*1e3)}async getBaseUrl(){if(this.activeApiUrl)return this.activeApiUrl;try{const e=new AbortController,i=setTimeout(()=>e.abort(),5e3),r=await fetch(`${Pt}/ping`,{signal:e.signal});if(clearTimeout(i),r.ok)return this.activeApiUrl=Pt,this.activeApiUrl}catch{}try{const e=new AbortController,i=setTimeout(()=>e.abort(),5e3),r=await fetch(`${Ai}/ping`,{signal:e.signal});if(clearTimeout(i),r.ok)return this.activeApiUrl=Ai,this.activeApiUrl}catch{}return Pt}async getMarketDataInterval(e,i,r,n){try{const a=Dt[i.toUpperCase()];if(!a)return console.error(`Unsupported timeframe: ${i}`),[];const s={"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=[],c=r;const l=n,u=s[a];if(!u)return console.error(`Duration not defined for interval: ${a}`),[];for(;c<l;){const p=Math.min(c+1e3*u,l),h=await this.getMarketData(e,i,1e3,c,p);if(h.length===0)break;o=o.concat(h),c=h[h.length-1].closeTime+1}return o}catch(a){return console.error("Error in getMarketDataInterval:",a),[]}}async getMarketDataBackwards(e,i,r,n){let a=r,s=[],o=n,c=0;const l=Math.ceil(r/1e3)+5;for(;a>0&&c<l;){c++;const u=Math.min(a,1e3),p=await this.getMarketData(e,i,u,void 0,o);if(p.length===0||(s=p.concat(s),a-=p.length,o=p[0].openTime-1,p.length<u))break}return s}async getMarketData(e,i,r,n,a){try{const s=a!==void 0,o={tickerId:e,timeframe:i,limit:r,sDate:n,eDate:a};if(s){const h=this.cacheManager.get(o);if(h)return h}const c=Dt[i.toUpperCase()];if(!c)return console.error(`Unsupported timeframe: ${i}`),[];if(this.shouldPaginate(i,r,n,a)){if(n&&a){const h=await this.getMarketDataInterval(e,i,n,a),d=r?h.slice(0,r):h;return this.cacheManager.set(o,d),d}else if(r&&r>1e3){const h=await this.getMarketDataBackwards(e,i,r,a);return this.cacheManager.set(o,h),h}}let l=`${await this.getBaseUrl()}/klines?symbol=${e}&interval=${c}`;r&&(l+=`&limit=${Math.min(r,1e3)}`),n&&(l+=`&startTime=${n}`),a&&(l+=`&endTime=${a}`);const u=await fetch(l);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);const p=(await u.json()).map(h=>({openTime:parseInt(h[0]),open:parseFloat(h[1]),high:parseFloat(h[2]),low:parseFloat(h[3]),close:parseFloat(h[4]),volume:parseFloat(h[5]),closeTime:parseInt(h[6]),quoteAssetVolume:parseFloat(h[7]),numberOfTrades:parseInt(h[8]),takerBuyBaseAssetVolume:parseFloat(h[9]),takerBuyQuoteAssetVolume:parseFloat(h[10]),ignore:h[11]}));return s&&this.cacheManager.set(o,p),p}catch(s){return console.error("Error in binance.klines:",s),[]}}shouldPaginate(e,i,r,n){if(i&&i>1e3)return!0;if(r&&n){const a=Dt[e.toUpperCase()],s={"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(s)return Math.ceil((n-r)/s)>1e3}return!1}async getSymbolInfo(e){try{let i="crypto",r=await this.getBaseUrl(),n=e,a="";e.endsWith(".P")?(i="futures",n=e.replace(".P",""),r="https://fapi.binance.com/fapi/v1",a="Perpetual"):e.includes("_")&&(i="futures",n=e,r="https://dapi.binance.com/dapi/v1",a="Delivery");const s=i==="crypto"?`${r}/exchangeInfo?symbol=${n}`:`${r}/exchangeInfo`,o=await fetch(s);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);const c=(await o.json()).symbols;if(!c||c.length===0)return console.error(`Symbol ${e} not found`),null;const l=i==="futures"?c.find(N=>N.symbol===n):c[0];if(!l)return console.error(`Symbol ${n} not found in exchange info`),null;const u=l.filters?.find(N=>N.filterType==="PRICE_FILTER"),p=l.filters?.find(N=>N.filterType==="LOT_SIZE"),h=u?parseFloat(u.tickSize):.01,d=p?parseFloat(p.minQty):0,g=Math.round(1/h),y=l.baseAsset,v=l.quoteAsset,w=a?` ${a}`:"",_=`${y} / ${v}${w}`;return{ticker:e,tickerid:`BINANCE:${e}`,prefix:"BINANCE",root:y,description:_,type:i,main_tickerid:`BINANCE:${e}`,current_contract:a,isin:"",basecurrency:y,currency:v,timezone:"Etc/UTC",country:"",mintick:h,pricescale:g,minmove:1,pointvalue:l.contractSize||1,mincontract:d,session:"24x7",volumetype:"base",expiration_date:l.deliveryDate||0,employees:0,industry:"",sector:"",shareholders:0,shares_outstanding_float:0,shares_outstanding_total:0,recommendations_buy:0,recommendations_buy_strong:0,recommendations_date:0,recommendations_hold:0,recommendations_sell:0,recommendations_sell_strong:0,recommendations_total:0,target_price_average:0,target_price_date:0,target_price_estimates:0,target_price_high:0,target_price_low:0,target_price_median:0}}catch(i){return console.error("Error in binance.exchangeInfo:",i),null}}configure(e){}}const Uu=jr.fileURLToPath(typeof document>"u"?new(require("url")).URL("file:"+__filename).href:document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||new URL("pinets.min.cjs",document.baseURI).href),qu=tt.dirname(Uu);class Ku{dataCache=new Map;exchangeInfoCache={};dataDirectory;constructor(e){if(e)this.dataDirectory=e;else{const i=tt.resolve(qu,"../../../");this.dataDirectory=tt.join(i,"tests","compatibility","_data")}}configure({dataDirectory:e}){e&&(this.dataDirectory=e)}getDataFileName(e,i,r,n){return r&&n?`${e}-${i}-${r}-${n}.json`:null}loadDataFromFile(e){const i=`file:${e}`;if(this.dataCache.has(i))return this.dataCache.get(i);const r=tt.join(this.dataDirectory,e);if(!ze.existsSync(r))throw new Error(`Mock data file not found: ${r}`);const n=ze.readFileSync(r,"utf-8"),a=JSON.parse(n);return this.dataCache.set(i,a),a}findDataFile(e,i,r,n){if(!ze.existsSync(this.dataDirectory))return null;const a=ze.readdirSync(this.dataDirectory).filter(c=>c.endsWith(".json"));if(r&&n){const c=`${e}-${i}-${r}-${n}.json`;if(a.includes(c))return c}const s=new RegExp(`^${e}-${i}-(\\d+)-(\\d+)\\.json$`),o=a.filter(c=>s.test(c)).map(c=>{const l=c.match(s);return{file:c,startTime:parseInt(l[1]),endTime:parseInt(l[2])}}).sort((c,l)=>l.endTime-c.endTime);if(o.length===0)return null;if(r&&n){const c=o.find(l=>l.startTime<=r&&l.endTime>=n);if(c)return c.file}return o[0].file}filterData(e,i,r,n){let a=e;return(i||r)&&(a=e.filter(s=>{const o=!i||s.openTime>=i,c=!r||s.openTime<=r;return o&&c})),a.sort((s,o)=>s.openTime-o.openTime),n&&n>0&&(a=a.slice(0,n)),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,n,a){try{const s=this.normalizeTimeframe(i),o=this.findDataFile(e,s,n,a);if(!o)return console.warn(`No mock data file found for ${e} ${s}. Searched in: ${this.dataDirectory}`),[];const c=this.loadDataFromFile(o);return this.filterData(c,n,a,r)}catch(s){return console.error("Error in MockProvider.getMarketData:",s),[]}}loadExchangeInfo(e){if(this.exchangeInfoCache[e])return this.exchangeInfoCache[e];const i=e==="spot"?"api-exchangeInfo.json":"fapi-exchangeInfo.json",r=tt.join(this.dataDirectory,i);if(!ze.existsSync(r))return console.warn(`Exchange info file not found: ${r}`),null;try{const n=ze.readFileSync(r,"utf-8"),a=JSON.parse(n);return this.exchangeInfoCache[e]=a,a}catch(n){return console.error(`Error loading exchange info from ${i}:`,n),null}}async getSymbolInfo(e){try{let i="crypto",r=e,n="";e.endsWith(".P")?(i="futures",r=e.replace(".P",""),n="Perpetual"):e.includes("_")&&(i="futures",r=e,n="Delivery");const a=this.loadExchangeInfo(i==="futures"?"futures":"spot");if(!a||!a.symbols)return console.error(`Exchange info not available for ${i}`),null;const s=a.symbols.find(v=>v.symbol===r);if(!s)return console.error(`Symbol ${r} not found in ${i} exchange info`),null;const o=s.filters?.find(v=>v.filterType==="PRICE_FILTER"),c=s.filters?.find(v=>v.filterType==="LOT_SIZE"),l=o?parseFloat(o.tickSize):.01,u=c?parseFloat(c.minQty):0,p=Math.round(1/l),h=s.baseAsset,d=s.quoteAsset,g=n?` ${n}`:"",y=`${h} / ${d}${g}`;return{ticker:e,tickerid:`BINANCE:${e}`,prefix:"BINANCE",root:h,description:y,type:i,main_tickerid:`BINANCE:${e}`,current_contract:n,isin:"",basecurrency:h,currency:d,timezone:"Etc/UTC",country:"",mintick:l,pricescale:p,minmove:1,pointvalue:s.contractSize||1,mincontract:u,session:"24x7",volumetype:"base",expiration_date:s.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 Hu=typeof process<"u"&&process.versions&&process.versions.node;let vt=null;if(Hu)try{vt=new Ku}catch{vt=null}const zu={Binance:new $u,...vt?{Mock:vt}:{}};exports.Context=Xe;exports.Indicator=Wt;exports.PineTS=Jt;exports.Provider=zu;
131
+ `)}}generateLoopAsExpression(e,i){this.write(`(() => {
132
+ `),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write(`let __result;
133
+ `);const r=e.body;if(r&&r.body&&r.body.length>0){const n=r.body.length-1,a=r.body[n];a.type==="ExpressionStatement"&&(r.body[n]={type:"ExpressionStatement",expression:{type:"AssignmentExpression",operator:"=",left:{type:"Identifier",name:"__result"},right:a.expression},_line:a._line})}i==="for"?this.generateForStatement(e):this.generateWhileStatement(e),this.write(this.indentStr.repeat(this.indent)),this.write(`return __result;
134
+ `),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("})()")}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 Tr(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 Ts(t,e={}){const i=Tr(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 _s(t).tokenize(),n=new ks(r).parse(),a={...e,sourceCode:t},s=new As(a).generate(n);return{success:!0,version:i,code:s,ast:n,tokens:r}}catch(r){return{success:!1,version:i,error:r.message,stack:r.stack}}}function Ps(t){if(typeof t=="function")return t.toString();{const e=Tr(t);if(e===null)return t;if(e>=5){const i=Ts(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 Ds(t,e={debug:!1,ln:!1}){typeof e=="boolean"&&(e={debug:e,ln:!0});const{debug:i}=e;let r=Ps(t);r=ns(r);const n=i?r.split(`
135
+ `):[],a=br(r,{ecmaVersion:"latest",sourceType:"module",locations:i});ss(a),ts(a),es(a);const s=new Gn;as(a,s);const o=ls(a,s)||"";ms(a,s,o,e,n),ds(a);const l=qn||Zt||void 0,c=Object.assign({},l,{LineComment(p,h){h.write("//"+p.value)}}),u=Sr(a,{generator:c,comments:i});return new Function("",`var _r = ${u}
136
+ ; return _r;`)(this)}function Rs(t){return e=>new V(e.array.map(i=>Math.abs(i)),e.type,t)}function Ms(t){return e=>{let i=0,r=0;for(const n of e.array){const a=Number(n);isNaN(a)||(r++,i+=(a-i)/r)}return r===0?NaN:t.precision(i)}}function Os(t){return(e,i)=>{const r=e.array;let n=0,a=r.length-1;for(;n<=a;){const s=Math.floor((n+a)/2),o=r[s];if(o===i)return s;o<i?n=s+1:a=s-1}return-1}}function Ls(t){return(e,i)=>{const r=e.array;let n=0,a=r.length;for(;n<a;){const s=Math.floor((n+a)/2);r[s]<i?n=s+1:a=s}return n<r.length&&r[n]===i?n:n-1}}function Vs(t){return(e,i)=>{const r=e.array;let n=0,a=r.length;for(;n<a;){const s=Math.floor((n+a)/2);r[s]<=i?n=s+1:a=s}return n>0&&r[n-1]===i?n-1:n}}function Bs(t){return e=>{e.array.length=0}}function Fs(t){return(e,i)=>(e.array.push(...i.array),e)}function js(t){return e=>new V([...e.array],e.type,t)}function Ws(t){return(e,i,r=!0)=>{const n=e.array,a=i.array;if(n.length!==a.length)return NaN;let s=0,o=0,l=0;const c=[];for(let m=0;m<n.length;m++){const y=Number(n[m]),_=Number(a[m]);!isNaN(y)&&y!==null&&y!==void 0&&!isNaN(_)&&_!==null&&_!==void 0&&(s+=y,o+=_,l++,c.push(m))}if(l===0)return NaN;const u=s/l,p=o/l;let h=0;for(const m of c){const y=Number(n[m]),_=Number(a[m]);h+=(y-u)*(_-p)}const f=r?l:l-1;return f<=0?NaN:t.precision(h/f)}}function $s(t){return e=>e.array.every(i=>!isNaN(i)&&i)}function Us(t){return t.every(e=>typeof e=="number")?t.every(e=>(e|0)===e)?W.int:W.float:t.every(e=>typeof e=="string")?W.string:t.every(e=>typeof e=="boolean")?W.bool:W.any}function _e(t){if(typeof t=="number")return(t|0)===t?W.int:W.float;if(typeof t=="string")return W.string;if(typeof t=="boolean")return W.bool;throw new Error("Cannot infer type from value")}function ct(t,e){if(e===W.any)return!0;switch(e){case W.int:return typeof t=="number"&&((t|0)===t||isNaN(t));case W.float:return typeof t=="number";case W.string:return typeof t=="string";case W.bool:return typeof t=="boolean"}return!1}function qs(t){return(e,i,r=0,n)=>{const a=e.array.length,s=n!==void 0?Math.min(n,a):a;for(let o=r;o<s;o++){if(!ct(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 Hs(t){return e=>e.array.length>0?e.array[0]:t.NA}function Ks(t){return(e,i)=>e.array[i]}function zs(t){return(e,i)=>e.array.includes(i)}function Gs(t){return(e,i)=>e.array.indexOf(i)}function Ys(t){return(e,i,r)=>{if(!ct(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 Qs(t){return(e,i=",")=>e.array.join(i)}function Xs(t){return e=>e.array.length>0?e.array[e.array.length-1]:t.NA}function Zs(t){return(e,i)=>e.array.lastIndexOf(i)}function Js(t){return(e,i=0)=>[...e.array].sort((r,n)=>n-r)[i]??t.NA}function ea(t){return e=>{if(e.array.length===0)return NaN;const i=[...e.array].sort((n,a)=>typeof n=="number"&&typeof a=="number"?n-a:0),r=Math.floor(i.length/2);return i.length%2!==0?i[r]:(i[r-1]+i[r])/2}}function ta(t){return(e,i=0)=>[...e.array].sort((r,n)=>r-n)[i]??t.NA}function ia(t){return e=>{if(e.array.length===0)return NaN;const i=new Map;let r=0;for(const a of e.array){const s=(i.get(a)||0)+1;i.set(a,s),s>r&&(r=s)}const n=[];for(const[a,s]of i)s===r&&n.push(a);return n.sort((a,s)=>typeof a=="number"&&typeof s=="number"?a-s:typeof a=="string"&&typeof s=="string"?a<s?-1:a>s?1:0:0),n[0]}}function ra(t){return(e,i)=>{const r=e.array;if(r.length===0)return NaN;const n=[];for(const l of r){const c=Number(l);if(isNaN(c)||c===null||c===void 0)return NaN;n.push(c)}n.sort((l,c)=>l-c),i<0&&(i=0),i>100&&(i=100);const a=i/100*n.length-.5;if(a<=0)return t.precision(n[0]);if(a>=n.length-1)return t.precision(n[n.length-1]);const s=Math.floor(a),o=a-s;return t.precision(n[s]*(1-o)+n[s+1]*o)}}function na(t){return(e,i)=>{const r=e.array;if(r.length===0)return NaN;const n=[];for(const o of r){const l=Number(o);!isNaN(l)&&l!==null&&l!==void 0&&n.push(l)}if(n.length===0)return NaN;n.sort((o,l)=>o-l),i<0&&(i=0),i>100&&(i=100);const a=r.length,s=Math.ceil(i/100*a);return s<=0?n[0]:s>n.length?NaN:n[s-1]}}function sa(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 n=Number(e.array[r]);if(isNaN(n)||n===null||n===void 0)return NaN;let a=0;for(const o of e.array){const l=Number(o);!isNaN(l)&&l!==null&&l!==void 0&&l<n&&a++}const s=e.array.length-1;return s<=0?NaN:a/s*100}}function aa(t){return e=>e.array.pop()}function oa(t){return(e,i)=>{if(!ct(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 la(t){return e=>t.precision(t.pine.array.max(e)-t.pine.array.min(e))}function ca(t){return(e,i)=>i>=0&&i<e.array.length?e.array.splice(i,1)[0]:t.NA}function ua(t){return e=>{e.array.reverse()}}function ha(t){return(e,i,r)=>{if(!ct(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 pa(t){return e=>e.array.shift()}function fa(t){return e=>e.array.length}function da(t){return(e,i,r)=>{const n=r!==void 0?r:void 0;return new V(e.array.slice(i,n),e.type,t)}}function ma(t){return e=>e.array.some(i=>!isNaN(i)&&i)}var Xe=(t=>(t[t.ascending=1]="ascending",t[t.descending=0]="descending",t))(Xe||{}),Pr=(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))(Pr||{}),Dr=(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))(Dr||{}),Rr=(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))(Rr||{}),Mr=(t=>(t.flag="shape_flag",t.arrowdown="shape_arrow_down",t.arrowup="shape_arrow_up",t.circle="shape_circle",t.cross="shape_cross",t.diamond="shape_diamond",t.labeldown="shape_label_down",t.labelup="shape_label_up",t.square="shape_square",t.triangledown="shape_triangle_down",t.triangleup="shape_triangle_up",t.xcross="shape_xcross",t))(Mr||{}),Or=(t=>(t.abovebar="AboveBar",t.belowbar="BelowBar",t.absolute="Absolute",t.bottom="Bottom",t.top="Top",t))(Or||{}),Lr=(t=>(t.auto="auto",t.tiny="tiny",t.small="small",t.normal="normal",t.large="large",t.huge="huge",t))(Lr||{}),Vr=(t=>(t.inherit="inherit",t.mintick="mintick",t.percent="percent",t.price="price",t.volume="volume",t))(Vr||{}),ga=(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))(ga||{}),Br=(t=>(t.gaps_on="gaps_on",t.gaps_off="gaps_off",t.lookahead_on="lookahead_on",t.lookahead_off="lookahead_off",t))(Br||{}),Fr=(t=>(t.bar_index="bi",t.bar_time="bt",t))(Fr||{}),jr=(t=>(t.price="pr",t.abovebar="ab",t.belowbar="bl",t))(jr||{}),Wr=(t=>(t.left="l",t.right="r",t.both="b",t.none="n",t))(Wr||{}),$r=(t=>(t.align_left="left",t.align_center="center",t.align_right="right",t.wrap_auto="auto",t.wrap_none="none",t))($r||{}),Ur=(t=>(t.family_default="default",t.family_monospace="monospace",t))(Ur||{}),qr=(t=>(t.none="none",t.splits="splits",t.dividends="dividends",t))(qr||{}),Hr=(t=>(t.inherit="inherit",t.off="off",t.on="on",t))(Hr||{}),Kr=(t=>(t.actual="earnings_actual",t.estimate="earnings_estimate",t.standardized="earnings_standardized",t.future_eps="earnings_future_eps",t.future_period_end_time="earnings_future_period_end_time",t.future_revenue="earnings_future_revenue",t.future_time="earnings_future_time",t))(Kr||{}),zr=(t=>(t.gross="dividends_gross",t.net="dividends_net",t.future_amount="dividends_future_amount",t.future_ex_date="dividends_future_ex_date",t.future_pay_date="dividends_future_pay_date",t))(zr||{}),Gr=(t=>(t.denominator="splits_denominator",t.numerator="splits_numerator",t))(Gr||{}),Yr=(t=>(t.top_left="top_left",t.top_center="top_center",t.top_right="top_right",t.middle_left="middle_left",t.middle_center="middle_center",t.middle_right="middle_right",t.bottom_left="bottom_left",t.bottom_center="bottom_center",t.bottom_right="bottom_right",t))(Yr||{});const xa={order:Xe,currency:Pr,dayofweek:Dr,display:Rr,shape:Mr,location:Or,size:Lr,format:Vr,barmerge:Br,xloc:Fr,yloc:jr,extend:Wr,text:$r,font:Ur,adjustment:qr,backadjustment:Hr,earnings:Kr,dividends:zr,splits:Gr,position:Yr};function ya(t){return(e,i=Xe.ascending)=>{e.array.sort((r,n)=>{let a=isNaN(r)?1/0:r,s=isNaN(n)?1/0:n;return i===Xe.ascending?a-s:s-a})}}function _a(t){return(e,i=Xe.ascending)=>{const r=e.array.map((n,a)=>a);return r.sort((n,a)=>{const s=isNaN(e.array[n])?1/0:e.array[n],o=isNaN(e.array[a])?1/0:e.array[a];return i===Xe.ascending?s-o:o-s}),new V(r,W.int,t)}}function va(t){return e=>{const i=t.array.avg(e),r=t.array.stdev(e);return isNaN(r)?new V(e.array.map(()=>NaN),W.int,t):r===0?new V(e.array.map(()=>1),W.int,t):new V(e.array.map(n=>(n-i)/r),W.int,t)}}function ba(t){return(e,i=!0)=>{const r=e.array,n=r.length;if(n===0)return NaN;let a=0,s=0,o=0;for(let u=0;u<n;u++){const p=Number(r[u]);!isNaN(p)&&p!==null&&p!==void 0&&(a+=p,s+=p*p,o++)}if(o===0)return NaN;const l=a/o;let c=s/o-l*l;return c<0?NaN:(!i&&o>1&&(c=c*o/(o-1)),!i&&o===1?0:t.precision(Math.sqrt(c)))}}function wa(t){return e=>t.precision(e.array.reduce((i,r)=>{const n=Number(r);return isNaN(n)?i:i+n},0))}function Sa(t){return(e,i)=>{if(!ct(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 Ea(t){return(e,i=!0)=>{let r=0,n=0;for(const l of e.array){const c=Number(l);!isNaN(c)&&c!==null&&c!==void 0&&(r+=c,n++)}if(n===0)return NaN;const a=r/n;let s=0;for(const l of e.array){const c=Number(l);!isNaN(c)&&c!==null&&c!==void 0&&(s+=(c-a)*(c-a))}const o=i?n:n-1;return o<=0?NaN:t.precision(s/o)}}var W=(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))(W||{});class V{constructor(e,i,r){this.array=e,this.type=i,this.context=r,this._abs=Rs(this.context),this._avg=Ms(this.context),this._binary_search=Os(this.context),this._binary_search_leftmost=Ls(this.context),this._binary_search_rightmost=Vs(this.context),this._clear=Bs(this.context),this._concat=Fs(this.context),this._copy=js(this.context),this._covariance=Ws(this.context),this._every=$s(this.context),this._fill=qs(this.context),this._first=Hs(this.context),this._get=Ks(this.context),this._includes=zs(this.context),this._indexof=Gs(this.context),this._insert=Ys(this.context),this._join=Qs(this.context),this._last=Xs(this.context),this._lastindexof=Zs(this.context),this._max=Js(this.context),this._median=ea(this.context),this._min=ta(this.context),this._mode=ia(this.context),this._percentile_linear_interpolation=ra(this.context),this._percentile_nearest_rank=na(this.context),this._percentrank=sa(this.context),this._pop=aa(this.context),this._push=oa(this.context),this._range=la(this.context),this._remove=ca(this.context),this._reverse=ua(this.context),this._set=ha(this.context),this._shift=pa(this.context),this._size=fa(this.context),this._slice=da(this.context),this._some=ma(this.context),this._sort=ya(this.context),this._sort_indices=_a(this.context),this._standardize=va(this.context),this._stdev=ba(this.context),this._sum=wa(this.context),this._unshift=Sa(this.context),this._variance=Ea(this.context)}_abs;_avg;_binary_search;_binary_search_leftmost;_binary_search_rightmost;_clear;_concat;_copy;_covariance;_every;_fill;_first;_get;_includes;_indexof;_insert;_join;_last;_lastindexof;_max;_median;_min;_mode;_percentile_linear_interpolation;_percentile_nearest_rank;_percentrank;_pop;_push;_range;_remove;_reverse;_set;_shift;_size;_slice;_some;_sort;_sort_indices;_standardize;_stdev;_sum;_unshift;_variance;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 Na(t){return(...e)=>new V([...e],Us(e),t)}function Ca(t){return(e,i)=>e===void 0&&i===void 0?new V([],W.any,t):new V(Array(e).fill(t.precision(i||0)),_e(i||0),t)}function Ia(t){return(e,i=!1)=>new V(Array(e).fill(i),W.bool,t)}function ka(t){return(e,i=NaN)=>new V(Array(e).fill(t.precision(i)),W.float,t)}function Aa(t){return(e,i=0)=>new V(Array(e).fill(t.precision(i)),W.int,t)}function Ta(t){return(e,i="")=>new V(Array(e).fill(i),W.string,t)}class x{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 x?e:Array.isArray(e)?new x(e):new x([e])}}function Pa(t){return(e,i=0)=>x.from(e).get(i)}class Da{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=Na(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=Ca(e),this.new_bool=Ia(e),this.new_float=ka(e),this.new_int=Aa(e),this.new_string=Ta(e),this.param=Pa(),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 Ra(t){return e=>{e.map.clear()}}function Ma(t){return(e,i)=>e.map.has(i)}function Oa(t){return e=>{const i=new Qr(t);return i.map=new Map(e.map),i}}function La(t){return(e,i)=>{const r=e.map.get(i);return r===void 0?NaN:r}}function Va(t){return e=>{const i=Array.from(e.map.keys()),r=_e(i[0]);return new V(i,r,t)}}function Ba(t){return(e,i,r)=>{const n=e.map.get(i);return e.map.set(i,r),n===void 0?NaN:n}}function Fa(t){return(e,i)=>{for(const[r,n]of i.map)e.map.set(r,n)}}function ja(t){return(e,i)=>{const r=e.map.get(i);return e.map.delete(i)?r:NaN}}function Wa(t){return e=>e.map.size}function $a(t){return e=>{const i=Array.from(e.map.values()),r=_e(i[0]);return new V(i,r,t)}}class Qr{constructor(e){this.context=e,this.map=new Map,this._clear=Ra(this.context),this._contains=Ma(this.context),this._copy=Oa(this.context),this._get=La(this.context),this._keys=Va(this.context),this._put=Ba(this.context),this._put_all=Fa(this.context),this._remove=ja(this.context),this._size=Wa(this.context),this._values=$a(this.context)}map;_clear;_contains;_copy;_get;_keys;_put;_put_all;_remove;_size;_values;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 Ua(t){return()=>new Qr(t)}function qa(t){return(e,i=0)=>x.from(e).get(i)}class Ha{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=Ua(e),this.param=qa(),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 Ka(t){return(e,i,r)=>{const n=e.matrix.length;let a=[];if(r&&(r instanceof V?a=r.array:Array.isArray(r)?a=r:a=[r]),n===0){for(let l=0;l<a.length;l++){let c=a[l];c instanceof x&&(c=c.get(0)),e.matrix.push([c])}return}const s=e.matrix[0].length,o=i!==void 0?i:s;for(let l=0;l<n;l++){let c=l<a.length?a[l]:NaN;c instanceof x&&(c=c.get(0)),e.matrix[l].splice(o,0,c)}}}function za(t){return(e,i,r)=>{const n=e.matrix.length;let a=[];if(r)if(r instanceof V)a=r.array;else if(Array.isArray(r))a=r;else if(r instanceof x){const c=r.get(0);Array.isArray(c)?a=c:a=[c]}else a=[r];const s=n>0?e.matrix[0].length:a.length,o=i!==void 0?i:n,l=[];for(let c=0;c<s;c++)if(c<a.length){let u=a[c];u instanceof x&&(u=u.get(0)),l.push(u)}else l.push(NaN);e.matrix.splice(o,0,l)}}function Ga(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 n=0,a=0;for(let s=0;s<i;s++)for(let o=0;o<r;o++){const l=e.matrix[s][o];isNaN(l)||(n+=l,a++)}return a===0?NaN:n/a}}function Ya(t){return(e,i)=>{const r=e.matrix.length,n=[];for(let s=0;s<r;s++)n.push(e.matrix[s][i]);const a=_e(n[0]);return new V(n,a,t)}}function Qa(t){return e=>e.matrix.length===0?0:e.matrix[0].length}function Xa(t){return(e,i)=>{const r=e.matrix.length,n=i.matrix.length;if(r===0){for(let o=0;o<n;o++)e.matrix.push([...i.matrix[o]]);return}const a=e.matrix[0].length,s=n>0?i.matrix[0].length:0;if(a!==s&&n>0){console.error(`matrix.concat: Column count mismatch ${a} vs ${s}`);return}for(let o=0;o<n;o++)e.matrix.push([...i.matrix[o]])}}function Za(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0,n=new L(i,r,NaN,t);return n.matrix=e.matrix.map(a=>[...a]),n}}function Ja(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(n=>[...n]);let r=1;for(let n=0;n<e;n++){let a=n;for(;a<e&&i[a][n]===0;)a++;if(a===e)return 0;a!==n&&([i[n],i[a]]=[i[a],i[n]],r*=-1),r*=i[n][n];for(let s=n+1;s<e;s++){const o=i[s][n]/i[n][n];for(let l=n;l<e;l++)i[s][l]-=o*i[n][l]}}return r}function eo(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;return i!==r?NaN:Ja(e.matrix)}}function to(t){return(e,i)=>{const r=e.matrix.length;if(r===0)return new L(0,0,NaN,t);const n=e.matrix[0].length,a=new L(r,n,NaN,t);if(i instanceof L)for(let s=0;s<r;s++)for(let o=0;o<n;o++){const l=e.matrix[s][o],c=i.matrix[s]&&i.matrix[s][o]!==void 0?i.matrix[s][o]:NaN;a.matrix[s][o]=l-c}else{const s=i;for(let o=0;o<r;o++)for(let l=0;l<n;l++)a.matrix[o][l]=e.matrix[o][l]-s}return a}}function io(t){const e=t.length;if(e!==2)return Array(e).fill(NaN);const i=t[0][0],r=t[0][1],n=t[1][0],a=t[1][1],s=i+a,o=i*a-r*n,l=s*s-4*o;if(l<0)return[NaN,NaN];const c=(s+Math.sqrt(l))/2,u=(s-Math.sqrt(l))/2;return[c,u]}function ro(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r){const s=_e(e.matrix[0][0]);return new V([],s,t)}const n=io(e.matrix),a=_e(n[0]);return new V(n,a,t)}}function no(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r)return new L(0,0,NaN,t);const n=new L(i,r,0,t);for(let a=0;a<i;a++)n.matrix[a][a]=1;return n}}function so(t){return e=>{const i=e.matrix.length;return i===0?0:i*e.matrix[0].length}}function ao(t){return(e,i,r,n,a,s)=>{const o=e.matrix.length;if(o===0)return;const l=e.matrix[0].length,c=r!==void 0?r:0,u=n!==void 0?n:o,p=a!==void 0?a:0,h=s!==void 0?s:l;for(let f=c;f<u&&!(f>=o);f++)for(let m=p;m<h&&!(m>=l);m++)e.matrix[f][m]=i}}function oo(t){return(e,i,r)=>{if(!e.matrix[i])return NaN;const n=e.matrix[i][r];return n===void 0?NaN:n}}function lo(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 co(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r)return new L(i,r,NaN,t);const n=lo(e.matrix),a=new L(i,r,NaN,t);return a.matrix=n,a}}function uo(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 n=0;n<i;n++)for(let a=0;a<r;a++)if(n+a!==i-1&&e.matrix[n][a]!==0)return!1;return!0}}function ho(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 n=0;n<i;n++)for(let a=0;a<r;a++)if(e.matrix[a][n]!==-e.matrix[n][a])return!1;return!0}}function po(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;for(let n=0;n<i;n++)for(let a=0;a<r;a++){const s=e.matrix[n][a];if(s!==0&&s!==1)return!1}return!0}}function fo(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 n=0;n<i;n++)for(let a=0;a<r;a++)if(n!==a&&e.matrix[n][a]!==0)return!1;return!0}}function mo(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 n=0;n<i;n++)for(let a=0;a<r;a++)if(n===a){if(e.matrix[n][a]!==1)return!1}else if(e.matrix[n][a]!==0)return!1;return!0}}function go(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;return i===r}}function xo(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;for(let n=0;n<i;n++){let a=0;for(let s=0;s<r;s++){const o=e.matrix[n][s];if(o<0)return!1;a+=o}if(Math.abs(a-1)>1e-10)return!1}return!0}}function yo(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 n=0;n<i;n++)for(let a=0;a<n;a++)if(e.matrix[n][a]!==e.matrix[a][n])return!1;return!0}}function _o(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 n=!0,a=!0;for(let s=0;s<i;s++)for(let o=0;o<r;o++)s>o&&e.matrix[s][o]!==0&&(n=!1),s<o&&e.matrix[s][o]!==0&&(a=!1);return n||a}}function vo(t){return e=>{const i=e.matrix.length;if(i===0)return!0;const r=e.matrix[0].length;for(let n=0;n<i;n++)for(let a=0;a<r;a++)if(e.matrix[n][a]!==0)return!1;return!0}}function bo(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0,a=i.matrix.length,s=a>0?i.matrix[0].length:0,o=r*a,l=n*s,c=new L(o,l,NaN,t);for(let u=0;u<r;u++)for(let p=0;p<n;p++){const h=e.matrix[u][p];for(let f=0;f<a;f++)for(let m=0;m<s;m++){const y=i.matrix[f][m];c.matrix[u*a+f][p*s+m]=h*y}}return c}}function wo(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length;let n=-1/0,a=!1;for(let s=0;s<i;s++)for(let o=0;o<r;o++){const l=e.matrix[s][o];isNaN(l)||(l>n&&(n=l),a=!0)}return a?n:NaN}}function So(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length,n=[];for(let s=0;s<i;s++)for(let o=0;o<r;o++){const l=e.matrix[s][o];isNaN(l)||n.push(l)}if(n.length===0)return NaN;n.sort((s,o)=>s-o);const a=Math.floor(n.length/2);return n.length%2!==0?n[a]:(n[a-1]+n[a])/2}}function Eo(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length;let n=1/0,a=!1;for(let s=0;s<i;s++)for(let o=0;o<r;o++){const l=e.matrix[s][o];isNaN(l)||(l<n&&(n=l),a=!0)}return a?n:NaN}}function No(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length,n=new Map;let a=0,s=NaN;for(let o=0;o<i;o++)for(let l=0;l<r;l++){const c=e.matrix[o][l];if(!isNaN(c)){const u=(n.get(c)||0)+1;n.set(c,u),u>a?(a=u,s=c):u===a&&c<s&&(s=c)}}return s}}function Co(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0;if(i instanceof L){const a=i.matrix.length,s=a>0?i.matrix[0].length:0;if(n!==a)return new L(0,0,NaN,t);const o=new L(r,s,0,t);for(let l=0;l<r;l++)for(let c=0;c<s;c++){let u=0;for(let p=0;p<n;p++)u+=e.matrix[l][p]*i.matrix[p][c];o.matrix[l][c]=u}return o}else if(i instanceof V||Array.isArray(i.array||i)){const a=i.array||i;if(n!==a.length)return new L(0,0,NaN,t);const s=new L(r,1,0,t);for(let o=0;o<r;o++){let l=0;for(let c=0;c<n;c++)l+=e.matrix[o][c]*a[c];s.matrix[o][0]=l}return s}else{const a=i,s=new L(r,n,NaN,t);for(let o=0;o<r;o++)for(let l=0;l<n;l++)s.matrix[o][l]=e.matrix[o][l]*a;return s}}}function Io(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;return i===r?new L(i,r,NaN,t):new L(r,i,NaN,t)}}function ko(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0;if(r!==n)return new L(0,0,NaN,t);let a=new L(r,n,0,t);for(let l=0;l<r;l++)a.matrix[l][l]=1;let s=new L(r,n,NaN,t);for(let l=0;l<r;l++)s.matrix[l]=[...e.matrix[l]];let o=Math.floor(i);if(o<0)return new L(r,n,NaN,t);for(;o>0;){if(o%2===1){const c=new L(r,n,0,t);for(let u=0;u<r;u++)for(let p=0;p<n;p++){let h=0;for(let f=0;f<r;f++)h+=a.matrix[u][f]*s.matrix[f][p];c.matrix[u][p]=h}a=c}const l=new L(r,n,0,t);for(let c=0;c<r;c++)for(let u=0;u<n;u++){let p=0;for(let h=0;h<r;h++)p+=s.matrix[c][h]*s.matrix[h][u];l.matrix[c][u]=p}s=l,o=Math.floor(o/2)}return a}}function Ao(t){return e=>{const i=e.matrix.length;if(i===0)return 0;const r=e.matrix[0].length,n=e.matrix.map(s=>[...s]);let a=0;for(let s=0;s<r&&a<i;s++){let o=a;for(;o<i&&Math.abs(n[o][s])<1e-10;)o++;if(o<i){[n[a],n[o]]=[n[o],n[a]];const l=n[a][s];for(let c=s;c<r;c++)n[a][c]/=l;for(let c=0;c<i;c++)if(c!==a){const u=n[c][s];for(let p=s;p<r;p++)n[c][p]-=u*n[a][p]}a++}}return a}}function To(t){return(e,i)=>{const r=e.matrix.length;if(r===0){const s=_e(e.matrix[0][0]);return new V([],s,t)}const n=[];for(let s=0;s<r;s++){const o=e.matrix[s].splice(i,1);n.push(o[0])}const a=_e(n[0]);return new V(n,a,t)}}function Po(t){return(e,i)=>{const r=e.matrix.splice(i,1),n=_e(r[0][0]);return new V(r[0]||[],n,t)}}function Do(t){return(e,i,r)=>{const n=e.matrix.length,a=n>0?e.matrix[0].length:0,s=i*r,o=[];for(let u=0;u<n;u++)for(let p=0;p<a;p++)o.push(e.matrix[u][p]);for(;o.length<s;)o.push(NaN);o.length>s&&(o.length=s);const l=[];let c=0;for(let u=0;u<i;u++){const p=[];for(let h=0;h<r;h++)p.push(o[c++]);l.push(p)}e.matrix=l}}function Ro(t){return e=>{e.matrix.reverse();for(const i of e.matrix)i.reverse()}}function Mo(t){return(e,i)=>{if(!e.matrix[i]){const n=_e(e.matrix[0][0]);return new V([],n,t)}const r=_e(e.matrix[i][0]);return new V([...e.matrix[i]],r,t)}}function Oo(t){return e=>e.matrix.length}function Lo(t){return(e,i,r,n)=>{e.matrix[i]&&(e.matrix[i][r]=n)}}function Vo(t){return(e,i=0,r="asc")=>{e.matrix.length!==0&&e.matrix.sort((n,a)=>{const s=n[i],o=a[i];return s<o?r==="asc"?-1:1:s>o?r==="asc"?1:-1:0})}}function Bo(t){return(e,i,r,n,a)=>{const s=r-i,o=a-n,l=new L(s,o,NaN,t);for(let c=0;c<s;c++){const u=i+c;if(u>=e.matrix.length)break;for(let p=0;p<o;p++){const h=n+p;if(h>=e.matrix[u].length)break;l.matrix[c][p]=e.matrix[u][h]}}return l}}function Fo(t){return(e,i)=>{const r=e.matrix.length;if(r===0)return new L(0,0,NaN,t);const n=e.matrix[0].length,a=new L(r,n,NaN,t);if(i instanceof L)for(let s=0;s<r;s++)for(let o=0;o<n;o++){const l=e.matrix[s][o],c=i.matrix[s]&&i.matrix[s][o]!==void 0?i.matrix[s][o]:NaN;a.matrix[s][o]=l+c}else{const s=i;for(let o=0;o<r;o++)for(let l=0;l<n;l++)a.matrix[o][l]=e.matrix[o][l]+s}return a}}function jo(t){return(e,i,r)=>{const n=e.matrix.length;for(let a=0;a<n;a++){const s=e.matrix[a][i];e.matrix[a][i]=e.matrix[a][r],e.matrix[a][r]=s}}}function Wo(t){return(e,i,r)=>{const n=e.matrix[i];e.matrix[i]=e.matrix[r],e.matrix[r]=n}}function $o(t){return e=>{const i=e.matrix.length;if(i===0)return 0;const r=e.matrix[0].length,n=Math.min(i,r);let a=0;for(let s=0;s<n;s++)a+=e.matrix[s][s];return a}}function Uo(t){return e=>{const i=e.matrix.length;if(i===0)return new L(0,0,NaN,t);const r=e.matrix[0].length,n=new L(r,i,NaN,t);for(let a=0;a<i;a++)for(let s=0;s<r;s++)n.matrix[s][a]=e.matrix[a][s];return n}}class L{constructor(e=0,i=0,r=NaN,n){if(this.context=n,this.matrix=[],e>0&&i>0)for(let a=0;a<e;a++)this.matrix.push(Array(i).fill(r));this._add_col=Ka(this.context),this._add_row=za(this.context),this._avg=Ga(this.context),this._col=Ya(this.context),this._columns=Qa(this.context),this._concat=Xa(this.context),this._copy=Za(this.context),this._det=eo(this.context),this._diff=to(this.context),this._eigenvalues=ro(this.context),this._eigenvectors=no(this.context),this._elements_count=so(this.context),this._fill=ao(this.context),this._get=oo(this.context),this._inv=co(this.context),this._is_antidiagonal=uo(this.context),this._is_antisymmetric=ho(this.context),this._is_binary=po(this.context),this._is_diagonal=fo(this.context),this._is_identity=mo(this.context),this._is_square=go(this.context),this._is_stochastic=xo(this.context),this._is_symmetric=yo(this.context),this._is_triangular=_o(this.context),this._is_zero=vo(this.context),this._kron=bo(this.context),this._max=wo(this.context),this._median=So(this.context),this._min=Eo(this.context),this._mode=No(this.context),this._mult=Co(this.context),this._pinv=Io(this.context),this._pow=ko(this.context),this._rank=Ao(this.context),this._remove_col=To(this.context),this._remove_row=Po(this.context),this._reshape=Do(this.context),this._reverse=Ro(this.context),this._row=Mo(this.context),this._rows=Oo(this.context),this._set=Lo(this.context),this._sort=Vo(this.context),this._submatrix=Bo(this.context),this._sum=Fo(this.context),this._swap_columns=jo(this.context),this._swap_rows=Wo(this.context),this._trace=$o(this.context),this._transpose=Uo(this.context)}matrix;_add_col;_add_row;_avg;_col;_columns;_concat;_copy;_det;_diff;_eigenvalues;_eigenvectors;_elements_count;_fill;_get;_inv;_is_antidiagonal;_is_antisymmetric;_is_binary;_is_diagonal;_is_identity;_is_square;_is_stochastic;_is_symmetric;_is_triangular;_is_zero;_kron;_max;_median;_min;_mode;_mult;_pinv;_pow;_rank;_remove_col;_remove_row;_reshape;_reverse;_row;_rows;_set;_sort;_submatrix;_sum;_swap_columns;_swap_rows;_trace;_transpose;toString(){let e="";for(let i=0;i<this.matrix.length;i++)e+=e===""?"":`
137
+ `,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 qo(t){return(e,i,r)=>new L(e,i,r,t)}function Ho(t){return(e,i=0)=>x.from(e).get(i)}class Ko{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=qo(e),this.param=Ho(),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)}}class zo{constructor(e){this.context=e}_live=!1;setLive(){this._live=!0}get isnew(){return!this._live}get islast(){return this.context.idx===this.context.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 xt{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 xt(this.__def__,this.context)}toString(){const e={};for(let i in this.__def__)e[i]=this[i];return JSON.stringify(e)}}class ne{time;index;price;constructor(e,i,r){this.time=e,this.index=i,this.price=r}copy(){return new ne(this.time,this.index,this.price)}toString(){return JSON.stringify({time:this.time,index:this.index,price:this.price})}}function Go(t){return typeof t=="object"&&t.title!==void 0&&t.data!==void 0&&t.options!==void 0}const Ii={series:t=>t instanceof x||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",point:t=>t instanceof ne,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 x)&&!(t instanceof ne)&&!Go(t)};function ve(t){const e=t[t.length-1];if(e&&typeof e=="object"&&"__callsiteId"in e)return t.pop().__callsiteId}function z(t,e,i,r){Array.isArray(e)&&typeof e[0]=="string"&&(e=[e]);const n={};let a={};const s=new Array(e.length).fill(!0);for(let o=0;o<t.length;o++){const l=t[o];if(Ii.remaining_options(l)){a=l;break}const c=e.map((u,p)=>s[p]?u[o]:void 0);for(let u=0;u<c.length;u++){const p=c[u];if(p===void 0){s[u]=!1;continue}const h=Ii[i[p]];typeof h=="function"&&h(l)?n[p]=l:s[u]=!1}}return{...a,...n,...r}}const Yo=[["dateString"],["year","month","day","hour","minute","second"],["timezone","year","month","day","hour","minute","second"]],Qo={dateString:"string",timezone:"string",year:"number",month:"number",day:"number",hour:"number",minute:"number",second:"number"},Xo=["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"],Zo={title:"string",shorttitle:"string",overlay:"boolean",format:"string",precision:"number",scale:"string",max_bars_back:"number",timeframe:"string",timeframe_gaps:"boolean",explicit_plot_zorder:"boolean",max_lines_count:"number",max_labels_count:"number",max_boxes_count:"number",calc_bars_count:"number",max_polylines_count:"number",dynamic_requests:"boolean",behind_chart:"boolean"};function ki(t){if(!t||typeof t!="string")return null;if(t.startsWith("#")){const i=t.slice(1);return i.length===6?[parseInt(i.slice(0,2),16),parseInt(i.slice(2,4),16),parseInt(i.slice(4,6),16),1]:i.length===8?[parseInt(i.slice(0,2),16),parseInt(i.slice(2,4),16),parseInt(i.slice(4,6),16),parseInt(i.slice(6,8),16)/255]:null}const e=t.match(/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\s*\)/);return e?[parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),e[4]?parseFloat(e[4]):1]:null}function Jo(t,e,i,r){const n=Math.round(Math.max(0,Math.min(255,t))).toString(16).padStart(2,"0"),a=Math.round(Math.max(0,Math.min(255,e))).toString(16).padStart(2,"0"),s=Math.round(Math.max(0,Math.min(255,i))).toString(16).padStart(2,"0");if(r>=1)return`#${n}${a}${s}`.toUpperCase();const o=Math.round(Math.max(0,Math.min(255,r*255))).toString(16).padStart(2,"0");return`#${n}${a}${s}${o}`.toUpperCase()}const K={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 el(t){return z(t,Xo,Zo)}class tl{get __value(){return NaN}param(e,i=0){return x.from(e).get(i)}any(e){return isNaN(x.from(e).get(0))}}class il{constructor(e){this.context=e}color={param:(e,i=0)=>x.from(e).get(i),rgb:(e,i,r,n)=>n?`rgba(${e}, ${i}, ${r}, ${(100-n)/100})`:`rgb(${e}, ${i}, ${r})`,new:(e,i)=>{if(typeof e=="function"&&(e=e()),e&&typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"&&(e=e.get(0)),!e||typeof e!="string")return e;if(e.startsWith("#")){const r=e.slice(1);return i?`#${r}${Math.round(255/100*(100-i)).toString(16).padStart(2,"0").toUpperCase()}`:`#${r}`}else{const r=K[e];return r?i?`#${r}${Math.round(255/100*(100-i)).toString(16).padStart(2,"0").toUpperCase()}`:`#${r}`:i?`rgba(${e}, ${(100-i)/100})`:e}},from_gradient:(e,i,r,n,a)=>{typeof e=="function"&&(e=e()),typeof i=="function"&&(i=i()),typeof r=="function"&&(r=r()),typeof n=="function"&&(n=n()),typeof a=="function"&&(a=a()),e&&typeof e=="object"&&typeof e.get=="function"&&(e=e.get(0)),i&&typeof i=="object"&&typeof i.get=="function"&&(i=i.get(0)),r&&typeof r=="object"&&typeof r.get=="function"&&(r=r.get(0)),n&&typeof n=="object"&&typeof n.get=="function"&&(n=n.get(0)),a&&typeof a=="object"&&typeof a.get=="function"&&(a=a.get(0));let s=0;r!==i&&(s=(e-i)/(r-i)),s=Math.max(0,Math.min(1,s));const o=ki(typeof n=="string"?n:"#000000")||[0,0,0,1],l=ki(typeof a=="string"?a:"#FFFFFF")||[255,255,255,1],c=o[0]+(l[0]-o[0])*s,u=o[1]+(l[1]-o[1])*s,p=o[2]+(l[2]-o[2])*s,h=o[3]+(l[3]-o[3])*s;return Jo(c,u,p,h)},aqua:K.aqua,black:K.black,blue:K.blue,fuchsia:K.fuchsia,gray:K.gray,green:K.green,lime:K.lime,maroon:K.maroon,navy:K.navy,olive:K.olive,orange:K.orange,purple:K.purple,red:K.red,silver:K.silver,teal:K.teal,white:K.white,yellow:K.yellow};extractPlotOptions(e){const i={};for(let r in e)i[r]=x.from(e[r]).get(0);return i}indicator(...e){const i=el(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(x.from(e).get(0))}nz(e,i=0){const r=x.from(e).get(0),n=x.from(i).get(0);return isNaN(r)?n:r}fixnan(e){const i=x.from(e);for(let r=0;r<i.length;r++){const n=i.get(r);if(!isNaN(n))return n}return NaN}alertcondition(e,i,r){}timestamp(...e){const i=e.map(n=>n instanceof x?n.get(0):n),r=z(i,Yo,Qo);if(r.year!==void 0){const n=r.year,a=r.month,s=r.day,o=r.hour||0,l=r.minute||0,c=r.second||0,u=r.timezone||this.context.pine?.syminfo?.timezone||"UTC";return this._timestampFromComponents(u,n,a,s,o,l,c)}return r.dateString!==void 0?new Date(r.dateString).getTime():NaN}_timestampFromComponents(e,i,r,n,a,s,o){const l=new Date(Date.UTC(i,r-1,n,a,s,o));i>=0&&i<100&&l.setUTCFullYear(i);const c=e.trim();if(c==="UTC"||c==="GMT")return l.getTime();const u=c.match(/^(?:UTC|GMT)([+-])(\d{1,2})(?::(\d{2}))?$/i);if(u){const p=u[1]==="+"?1:-1,h=parseInt(u[2],10),f=parseInt(u[3]||"0",10),m=p*(h*60+f)*60*1e3;return l.getTime()-m}try{return this._timestampFromIANA(e,i,r,n,a,s,o)}catch{return l.getTime()}}_timestampFromIANA(e,i,r,n,a,s,o){const l=new Date(Date.UTC(i,r-1,n,a,s,o));i>=0&&i<100&&l.setUTCFullYear(i);const c=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(l),u=b=>parseInt(c.find(E=>E.type===b)?.value||"0",10),p=u("year"),h=u("month"),f=u("day");let m=u("hour");m===24&&(m=0);const y=u("minute"),_=u("second"),v=new Date(Date.UTC(p,h-1,f,m,y,_));p>=0&&p<100&&v.setUTCFullYear(p);const S=v.getTime()-l.getTime();return l.getTime()-S}bool(e){const i=x.from(e).get(0);return!isNaN(i)&&i!==0}int(e){const i=x.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.trunc(i)}float(e){const i=x.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 x.from(e).get(0).toString()}Type(e){const i=Object.keys(e);return{new:function(...r){const n={};for(let a=0;a<r.length;a++)n[i[a]]=r[a];return new xt(n,this.context)},copy:function(r){return new xt(r.__def__,this.context)}}}}function yt(t,e){const i=e.trim();if(i==="UTC"||i==="GMT"){const n=new Date(t);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),dayOfWeek:n.getUTCDay()}}const r=i.match(/^(?:UTC|GMT)([+-])(\d{1,2})(?::(\d{2}))?$/i);if(r){const n=r[1]==="+"?1:-1,a=parseInt(r[2],10),s=parseInt(r[3]||"0",10),o=n*(a*60+s)*60*1e3,l=new Date(t+o);return{year:l.getUTCFullYear(),month:l.getUTCMonth()+1,day:l.getUTCDate(),hour:l.getUTCHours(),minute:l.getUTCMinutes(),second:l.getUTCSeconds(),dayOfWeek:l.getUTCDay()}}try{const n=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",weekday:"short",hour12:!1}).formatToParts(new Date(t)),a=c=>parseInt(n.find(u=>u.type===c)?.value||"0",10);let s=a("hour");s===24&&(s=0);const o=n.find(c=>c.type==="weekday")?.value||"Sun",l={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return{year:a("year"),month:a("month"),day:a("day"),hour:s,minute:a("minute"),second:a("second"),dayOfWeek:l[o]??0}}catch{const n=new Date(t);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),dayOfWeek:n.getUTCDay()}}}function rl(t,e,i){const r=new Date(Date.UTC(t,e-1,i)),n=r.getUTCDay()||7;r.setUTCDate(r.getUTCDate()+4-n);const a=new Date(Date.UTC(r.getUTCFullYear(),0,1));return Math.ceil(((r.getTime()-a.getTime())/864e5+1)/7)}const nl=[["timeframe"],["timeframe","bars_back"],["timeframe","session","bars_back"],["timeframe","session","bars_back","timeframe_bars_back"],["timeframe","session","timezone","bars_back","timeframe_bars_back"]],sl={timeframe:"string",session:"string",timezone:"string",bars_back:"number",timeframe_bars_back:"number"};class Ai{context;dataField;constructor(e,i="openTime"){this.context=e,this.dataField=i}get __value(){return this.context.data[this.dataField]}param(e,i=0){return x.from(e).get(i)}any(...e){const i=e.map(c=>c instanceof x?c.get(0):c),r=z(i,nl,sl),n=r.bars_back??0,a=r.timeframe_bars_back??0,s=n+a,o=this.context.data[this.dataField],l=x.from(o).get(s);if(r.session!==void 0){const c=r.timezone||this.context.pine?.syminfo?.timezone||"UTC";return this._isInSession(l,r.session,c)?l:NaN}return l}_isInSession(e,i,r){const n=i.match(/^(\d{2})(\d{2})-(\d{2})(\d{2})$/);if(!n)return!0;const a=parseInt(n[1],10),s=parseInt(n[2],10),o=parseInt(n[3],10),l=parseInt(n[4],10),c=yt(e,r),u=c.hour,p=c.minute,h=u*60+p,f=a*60+s,m=o*60+l;return f<=m?h>=f&&h<m:h>=f||h<m}}const al=[[],["time"],["time","timezone"]],ol={time:"number",timezone:"string"};class Re{context;extractor;constructor(e,i){this.context=e,this.extractor=i}get __value(){const e=x.from(this.context.data.openTime).get(0);if(isNaN(e))return NaN;const i=this.context.pine?.syminfo?.timezone||"UTC",r=yt(e,i);return this.extractor(r)}param(e,i=0){return x.from(e).get(i)}any(...e){const i=e.map(o=>o instanceof x?o.get(0):o);if(i.length===0)return this.__value;const r=z(i,al,ol),n=r.time;if(n===void 0||isNaN(n))return NaN;const a=r.timezone||this.context.pine?.syminfo?.timezone||"UTC",s=yt(n,a);return this.extractor(s)}}const Me={dayofmonth:t=>t.day,dayofweek:t=>t.dayOfWeek===0?1:t.dayOfWeek+1,hour:t=>t.hour,minute:t=>t.minute,month:t=>t.month,second:t=>t.second,weekofyear:t=>rl(t.year,t.month,t.day),year:t=>t.year},ll=[["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"]],cl={defval:"primitive",title:"string",tooltip:"string",inline:"string",group:"string",display:"string",confirm:"boolean",options:"array",minval:"number",maxval:"number",step:"number"};function oe(t){return z(t,ll,cl)}function ge(t,e){return e.title&&t.inputs&&t.inputs[e.title]!==void 0?t.inputs[e.title]:e.defval}function ul(t){return(...e)=>{const i=oe(e);return ge(t,i)}}function hl(t){return(...e)=>oe(e).defval}function pl(t){return(...e)=>{const i=oe(e);return ge(t,i)}}function fl(t){return(...e)=>{const i=oe(e);return ge(t,i)}}function dl(t){return(...e)=>{const i=oe(e);return ge(t,i)}}function ml(t){return(...e)=>{const i=oe(e);return ge(t,i)}}function gl(t){return(e,i=0)=>x.from(e).get(i)}function xl(t){return(...e)=>{const i=oe(e);return ge(t,i)}}function yl(t){return(...e)=>{const i=oe(e);return ge(t,i)}}function _l(t){return(...e)=>{const i=oe(e);return ge(t,i)}}function vl(t){return(...e)=>{const i=oe(e);return ge(t,i)}}function bl(t){return(...e)=>{const i=oe(e);return ge(t,i)}}function wl(t){return(...e)=>{const i=oe(e);return ge(t,i)}}function Sl(t){return(...e)=>{const i=oe(e);return ge(t,i)}}function El(t){return(...e)=>oe(e).defval}const Nl={any:ul,bool:hl,color:pl,enum:fl,float:dl,int:ml,param:gl,price:xl,session:yl,source:_l,string:vl,symbol:bl,text_area:wl,time:Sl,timeframe:El};class Cl{constructor(e){this.context=e,Object.entries(Nl).forEach(([i,r])=>{this[i]=r(e)})}any;bool;color;enum;float;int;param;price;session;source;string;symbol;text_area;time;timeframe}function Il(t){return e=>Math.abs(x.from(e).get(0))}function kl(t){return e=>Math.acos(x.from(e).get(0))}function Al(t){return e=>Math.asin(x.from(e).get(0))}function Tl(t){return e=>Math.atan(x.from(e).get(0))}function Pl(t){return(...e)=>{const i=e.map(r=>x.from(r).get(0));return i.reduce((r,n)=>r+n,0)/i.length}}function Dl(t){return e=>Math.ceil(x.from(e).get(0))}function Rl(t){return e=>Math.cos(x.from(e).get(0))}function Ml(t){return()=>Math.E}function Ol(t){return e=>Math.exp(x.from(e).get(0))}function Ll(t){return e=>Math.floor(x.from(e).get(0))}function Vl(t){return e=>Math.log(x.from(e).get(0))}function Bl(t){return e=>Math.log(x.from(e).get(0))}function Fl(t){return e=>Math.log10(x.from(e).get(0))}function jl(t){return(...e)=>{const i=e.map(r=>x.from(r).get(0));return Math.max(...i)}}function Wl(t){return(...e)=>{const i=e.map(r=>x.from(r).get(0));return Math.min(...i)}}function $l(t){return(e,i,r)=>typeof e=="string"?e:e instanceof x?i?new x(e.data,e.offset+i):e:!Array.isArray(e)&&typeof e=="object"?e:(t.params[r]||(t.params[r]=[]),Array.isArray(e)?new x(e,i||0):(t.params[r].length===0?t.params[r].push(e):t.params[r][t.params[r].length-1]=e,new x(t.params[r],0)))}function Ul(t){return()=>1.618033988749895}function ql(t){return()=>Math.PI}function Hl(t){return(e,i)=>Math.pow(x.from(e).get(0),x.from(i).get(0))}function Kl(t){return()=>Math.random()}function Pt(t){return t!==t?NaN:Math.sign(t)*Math.round(Math.abs(t))}function zl(t){return(e,i)=>{const r=x.from(e).get(0);if(i==null)return Pt(r);const n=x.from(i).get(0);if(n===0)return Pt(r);const a=Math.pow(10,n);return Pt(r*a)/a}}function Gl(t){return e=>t.precision(Math.round(x.from(e).get(0)/t.pine.syminfo.mintick)*t.pine.syminfo.mintick)}function Yl(t){return()=>.6180339887498948}function Ql(t){return e=>Math.sign(x.from(e).get(0))}function Xl(t){return e=>Math.sin(x.from(e).get(0))}function Zl(t){return e=>Math.sqrt(x.from(e).get(0))}function Jl(t){return(e,i)=>{const r=x.from(i).get(0),n=x.from(e);let a=0;for(let s=0;s<r;s++){const o=n.get(s);a+=o}return a}}function ec(t){return e=>Math.tan(x.from(e).get(0))}function tc(t){return e=>{const i=x.from(e).get(0);return i==null||Number.isNaN(i)?NaN:i*(180/Math.PI)}}function ic(t){return e=>{const i=x.from(e).get(0);return i==null||Number.isNaN(i)?NaN:i*(Math.PI/180)}}function rc(t){return(e,i)=>{const r=x.from(e).get(0),n=x.from(i).get(0);return typeof r=="number"&&typeof n=="number"?isNaN(r)||isNaN(n)?!1:Math.abs(r-n)<1e-8:r===n}}const nc={abs:Il,acos:kl,asin:Al,atan:Tl,avg:Pl,ceil:Dl,cos:Rl,e:Ml,exp:Ol,floor:Ll,ln:Vl,log:Bl,log10:Fl,max:jl,min:Wl,param:$l,phi:Ul,pi:ql,pow:Hl,random:Kl,round:zl,round_to_mintick:Gl,rphi:Yl,sign:Ql,sin:Xl,sqrt:Zl,sum:Jl,tan:ec,todegrees:tc,toradians:ic,__eq:rc};class sc{constructor(e){this.context=e,Object.entries(nc).forEach(([i,r])=>{this[i]=r(e)})}_cache={};abs;acos;asin;atan;avg;ceil;cos;e;exp;floor;ln;log;log10;max;min;param;phi;pi;pow;random;round;round_to_mintick;rphi;sign;sin;sqrt;sum;tan;todegrees;toradians;__eq}function ac(t){return(e,i,r)=>{t.params[r]||(t.params[r]=[]);let n;if(e instanceof x)n=e.get(i||0);else if(Array.isArray(e)){const a=e.every(o=>o instanceof x),s=e.every(o=>!(o instanceof x)&&!Array.isArray(o));(a||s)&&e.length>=1?a?n=e.map(o=>o.get(0)):n=e:n=x.from(e).get(i||0)}else n=e;return t.params[r].length===0?t.params[r].push(n):t.params[r][t.params[r].length-1]=n,[n,r]}}const _t=["1","3","5","15","30","45","60","120","180","240","D","W","M"];function Ti(t,e,i,r,n=!1){for(let a=0;a<i.length;a++)if(i[a]<=t&&t<r[a])return n||e>=r[a]?a:a-1;return-1}function Pi(t,e,i,r,n=!1,a,s=!1){for(let o=i.length-1;o>=0;o--){if(r[o]<=e&&i[o]>=t){const l=a&&e>a;if(s&&n)for(let c=0;c<i.length;c++){if(i[c]>=t&&i[c]<e)return c;if(i[c]>=e)break}if(l&&n&&!s)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 oc(t){return async(e,i,r,n=!1,a=!1,s=!1,o=null,l=null)=>{const c=e[0],u=typeof c=="string"&&c.includes(":")?c.split(":")[1]:c,p=i[0],h=r[0],f=r[1],m=Array.isArray(n)?n[0]:n,y=Array.isArray(a)?a[0]:a;if(t.isSecondaryContext)return Array.isArray(h)?[h]:h;const _=_t.indexOf(t.timeframe),v=_t.indexOf(p);if(_==-1||v==-1)throw new Error("Invalid timeframe");if(_===v)return Array.isArray(h)?[h]:h;const S=_>v,b=x.from(t.data.openTime).get(0),E=x.from(t.data.closeTime).get(0),N=`${u}_${p}_${f}`,T=`${N}_prevIdx`;if(t.cache[N]){const Ee=t.cache[N],ie=S?Pi(b,E,Ee.data.openTime.data,Ee.data.closeTime.data,y,t.eDate,m):Ti(b,E,Ee.data.openTime.data,Ee.data.closeTime.data,y);if(ie==-1)return NaN;const Ge=Ee.params[f][ie];if(!S&&m){const ni=t.cache[T];return ni!==void 0&&ni===ie?NaN:(t.cache[T]=ie,Array.isArray(Ge)?[Ge]:Ge)}return Array.isArray(Ge)?[Ge]:Ge}const P=1e3*60*60*24*30,M=t.sDate?t.sDate-P:void 0,$=t.sDate&&t.eDate?void 0:t.limit||1e3,q=new ri(t.source,u,p,$,M,void 0);q.markAsSecondary();const F=await q.run(t.pineTSCode);t.cache[N]=F;const Z=S?Pi(b,E,F.data.openTime.data,F.data.closeTime.data,y,t.eDate,m):Ti(b,E,F.data.openTime.data,F.data.closeTime.data,y);if(Z==-1)return NaN;const le=F.params[f][Z];return!S&&m?(t.cache[T]=Z,NaN):Array.isArray(le)?[le]:le}}function lc(t){return async(e,i,r,n=!1,a=null,s=!1,o=0)=>{const l=e[0],c=i[0],u=r[0],p=r[1];Array.isArray(n)&&n[0];const h=Array.isArray(s)?s[0]:s;if(t.isSecondaryContext)return Array.isArray(u)?[u]:u;const f=_t.indexOf(t.timeframe),m=_t.indexOf(c);if(f===-1||m===-1){if(h)return NaN;throw new Error("Invalid timeframe")}if(m>f){if(h)return NaN;throw new Error(`Timeframe ${c} is not lower than or equal to chart timeframe ${t.timeframe}`)}if(m===f)return[[u]];const y=`${l}_${c}_${p}_lower`;if(!t.cache[y]){const P=t.sDate?t.sDate-2592e6:void 0,M=t.sDate&&t.eDate?void 0:t.limit||1e3,$=new ri(t.source,l,c,M,P,t.eDate);$.markAsSecondary();const q=await $.run(t.pineTSCode);t.cache[y]=q}const _=t.cache[y],v=x.from(t.data.openTime).get(0),S=x.from(t.data.closeTime).get(0),b=_.data.openTime.data,E=_.data.closeTime.data,N=_.params[p];if(!N)return[];const T=[];for(let P=0;P<b.length;P++){const M=b[P];if(!(E[P]<=v)){if(M>=S)break;M>=v&&M<S&&T.push(N[P])}}return[T]}}const cc={param:ac,security:oc,security_lower_tf:lc};class uc{constructor(e){this.context=e,Object.entries(cc).forEach(([i,r])=>{this[i]=r(e)})}_cache={};param;security;security_lower_tf}function hc(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 n=t.get(t.data.close,0),a=t.get(t.data.high,0),s=t.get(t.data.low,0),o=t.get(t.data.volume,0);if(isNaN(n)||isNaN(a)||isNaN(s)||isNaN(o))return r.currentCumulativeSum=r.prevCumulativeSum,t.precision(r.prevCumulativeSum);const l=a-s;let c=0;l!==0&&(c=(n-s-(a-n))/l*o);const u=r.prevCumulativeSum+c;return r.currentCumulativeSum=u,t.precision(u)}}function pc(t){return(e,i,r,n,a)=>{const s=x.from(i).get(0),o=x.from(r).get(0),l=x.from(n).get(0);t.taState||(t.taState={});const c=a||`alma_${s}_${o}_${l}`;if(!t.taState[c]){const y=o*(s-1),_=s/l,v=[];let S=0;for(let b=0;b<s;b++){const E=Math.exp(-Math.pow(b-y,2)/(2*_*_));v.push(E),S+=E}for(let b=0;b<v.length;b++)v[b]/=S;t.taState[c]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0,weights:v}}const u=t.taState[c];t.idx>u.lastIdx&&(u.lastIdx>=0&&(u.prevWindow=[...u.currentWindow],u.prevCallCount=u.currentCallCount),u.lastIdx=t.idx);const p=x.from(e).get(0),h=[...u.prevWindow];for(h.unshift(p);h.length>s;)h.pop();const f=u.prevCallCount+1;if(h.length<s&&(f>=s||t.idx>=s-1)){const y=x.from(e);for(;h.length<s;)h.push(y.get(h.length))}if(u.currentWindow=h,u.currentCallCount=f,h.length<s)return NaN;let m=0;for(let y=0;y<s;y++)m+=u.weights[y]*h[s-1-y];return t.precision(m)}}function fc(t){return(e,i)=>{const r=x.from(e).get(0);t.taState||(t.taState={});const n=i||`atr_${r}`;t.taState[n]||(t.taState[n]={lastIdx:-1,prevAtr:null,prevInitSum:0,prevInitCount:0,prevPrevClose:null,currentAtr:null,currentInitSum:0,currentInitCount:0,currentPrevClose:null});const a=t.taState[n];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 s=t.get(t.data.high,0),o=t.get(t.data.low,0),l=t.get(t.data.close,0);if(isNaN(s)||isNaN(o)||isNaN(l))return NaN;const c=a.prevPrevClose;let u;if(c!==null){const y=s-o,_=Math.abs(s-c),v=Math.abs(o-c);u=Math.max(y,_,v)}else u=s-o;a.currentPrevClose=l;let p=a.prevInitCount,h=a.prevInitSum,f=a.prevAtr;if(p<r){if(h+=u,p++,a.currentInitSum=h,a.currentInitCount=p,p===r){const y=h/r;return a.currentAtr=y,t.precision(y)}return NaN}const m=(f*(r-1)+u)/r;return a.currentAtr=m,t.precision(m)}}function dc(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 n=t.taState[r];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevLastTrueIndex=n.currentLastTrueIndex),n.lastIdx=t.idx);const a=x.from(e).get(0);let s=n.prevLastTrueIndex;return a&&(s=t.idx),n.currentLastTrueIndex=s,s===null?NaN:t.idx-s}}function mc(t){return(e,i,r,n)=>{const a=x.from(i).get(0),s=x.from(r).get(0);t.taState||(t.taState={});const o=n||`bb_${a}_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevSum=l.currentSum),l.lastIdx=t.idx);const c=x.from(e).get(0);if(isNaN(c))return l.currentWindow=[...l.prevWindow],l.currentSum=l.prevSum,[[NaN,NaN,NaN]];const u=[...l.prevWindow];let p=l.prevSum;for(u.unshift(c),p+=c;u.length>a;){const v=u.pop();p-=v}if(u.length<a&&t.idx>=a-1){const v=x.from(e);for(;u.length<a;){const S=v.get(u.length);if(isNaN(S))break;u.push(S),p+=S}}if(l.currentWindow=u,l.currentSum=p,u.length<a)return[[NaN,NaN,NaN]];const h=p/a;let f=0;for(let v=0;v<a;v++)f+=Math.pow(u[v]-h,2);const m=Math.sqrt(f/a),y=h+s*m,_=h-s*m;return[[t.precision(h),t.precision(y),t.precision(_)]]}}function gc(t){return(e,i,r,n)=>{const a=x.from(i).get(0),s=x.from(r).get(0);t.taState||(t.taState={});const o=n||`bbw_${a}_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevSum=l.currentSum),l.lastIdx=t.idx);const c=x.from(e).get(0);if(isNaN(c))return l.currentWindow=[...l.prevWindow],l.currentSum=l.prevSum,NaN;const u=[...l.prevWindow];let p=l.prevSum;for(u.unshift(c),p+=c;u.length>a;){const S=u.pop();p-=S}if(u.length<a&&t.idx>=a-1){const S=x.from(e);for(;u.length<a;){const b=S.get(u.length);if(isNaN(b))break;u.push(b),p+=b}}if(l.currentWindow=u,l.currentSum=p,u.length<a)return NaN;const h=p/a;let f=0;for(let S=0;S<a;S++){const b=u[S]-h;f+=b*b}const m=f/a,y=Math.sqrt(m),_=s*y;if(h===0)return t.precision(0);const v=2*_/h*100;return t.precision(v)}}function xc(t){return(e,i,r)=>{const n=x.from(i).get(0);t.taState||(t.taState={});const a=r||`cci_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevSum=s.currentSum,s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=x.from(e).get(0);if(isNaN(o))return NaN;const l=[...s.prevWindow];let c=s.prevSum;for(l.unshift(o),c+=o;l.length>n;){const y=l.pop();c-=y}const u=s.prevCallCount+1;if(l.length<n&&(u>=n||t.idx>=n-1)){const y=x.from(e);for(;l.length<n;){const _=y.get(l.length);if(isNaN(_))break;l.push(_),c+=_}}if(s.currentWindow=l,s.currentSum=c,s.currentCallCount=u,l.length<n)return NaN;const p=c/n;let h=0;for(let y=0;y<n;y++)h+=Math.abs(l[y]-p);const f=h/n;if(f===0)return 0;const m=(o-p)/(.015*f);return t.precision(m)}}function yc(t){return(e,i=1,r)=>{typeof i=="string"&&(r=i,i=1);const n=x.from(i).get(0);t.taState||(t.taState={});const a=r||`change_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=x.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n+1;)l.pop();const c=s.prevCallCount+1;if(l.length<n+1&&(c>=n+1||t.idx>=n)){const p=x.from(e);for(;l.length<n+1;)l.push(p.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<=n)return NaN;const u=o-l[n];return t.precision(u)}}function _c(t){return(e,i,r)=>{const n=x.from(i).get(0);t.taState||(t.taState={});const a=r||`cmo_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevGainsWindow:[],prevLossesWindow:[],prevGainsSum:0,prevLossesSum:0,currentGainsWindow:[],currentLossesWindow:[],currentGainsSum:0,currentLossesSum:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevGainsWindow=[...s.currentGainsWindow],s.prevLossesWindow=[...s.currentLossesWindow],s.prevGainsSum=s.currentGainsSum,s.prevLossesSum=s.currentLossesSum),s.lastIdx=t.idx);const o=x.from(e).get(0),l=x.from(e).get(1);if(isNaN(o)||isNaN(l))return NaN;const c=o-l,u=c>=0?c:0,p=c>=0?0:-c,h=[...s.prevGainsWindow],f=[...s.prevLossesWindow];let m=s.prevGainsSum,y=s.prevLossesSum;if(h.unshift(u),f.unshift(p),m+=u,y+=p,h.length<n)return s.currentGainsWindow=h,s.currentLossesWindow=f,s.currentGainsSum=m,s.currentLossesSum=y,NaN;if(h.length>n){const S=h.pop(),b=f.pop();m-=S,y-=b}s.currentGainsWindow=h,s.currentLossesWindow=f,s.currentGainsSum=m,s.currentLossesSum=y;const _=m+y;if(_===0)return t.precision(0);const v=100*(m-y)/_;return t.precision(v)}}function vc(t){return(e,i,r)=>{const n=x.from(i).get(0),a=x.from(e);let s=0,o=!1;for(let u=0;u<n;u++){const p=a.get(u);if(isNaN(p)){o=!0;break}s+=p}if(o)return NaN;let l=0;for(let u=0;u<n;u++){const p=a.get(u);l+=p*(u+1)}if(s===0)return NaN;const c=-l/s;return t.precision(c)}}function bc(t){return(e,i,r,n)=>{const a=x.from(r).get(0),s=x.from(e),o=x.from(i);if(t.idx<a-1)return NaN;let l=0,c=0,u=0,p=0,h=0,f=0;for(let S=0;S<a;S++){const b=s.get(S),E=o.get(S);isNaN(b)||isNaN(E)||(l+=b,c+=E,u+=b*E,p+=b*b,h+=E*E,f++)}if(f<2)return NaN;const m=f*u-l*c,y=f*p-l*l,_=f*h-c*c;if(y<=0||_<=0)return t.precision(0);const v=m/Math.sqrt(y*_);return t.precision(v)}}function wc(t){return(e,i,r)=>{const n=x.from(e),a=x.from(i),s=n.get(0),o=a.get(0),l=n.get(1),c=a.get(1);if(isNaN(s)||isNaN(o)||isNaN(l)||isNaN(c))return!1;const u=s>o&&l<=c,p=s<o&&l>=c;return u||p}}function Sc(t){return(e,i)=>{const r=x.from(e),n=x.from(i),a=r.get(0),s=n.get(0),o=r.get(1),l=n.get(1);return o<l&&a>s}}function Ec(t){return(e,i)=>{const r=x.from(e),n=x.from(i),a=r.get(0),s=n.get(0),o=r.get(1),l=n.get(1);return o>l&&a<s}}function Nc(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 n=t.taState[r];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevCumulativeSum=n.currentCumulativeSum),n.lastIdx=t.idx);const a=x.from(e).get(0);if(isNaN(a))return n.currentCumulativeSum=n.prevCumulativeSum,t.precision(n.prevCumulativeSum);const s=n.prevCumulativeSum+a;return n.currentCumulativeSum=s,t.precision(s)}}function Cc(t){return(e,i,r)=>{const n=x.from(i).get(0);t.taState||(t.taState={});const a=r||`dev_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevSum=s.currentSum,s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=x.from(e).get(0)||0,l=[...s.prevWindow];let c=s.prevSum;for(l.unshift(o),c+=o;l.length>n;){const m=l.pop();c-=m}const u=s.prevCallCount+1;if(l.length<n&&(u>=n||t.idx>=n-1)){const m=x.from(e);for(;l.length<n;){const y=m.get(l.length);l.push(y),c+=y}}if(s.currentWindow=l,s.currentSum=c,s.currentCallCount=u,l.length<n)return NaN;const p=c/n;let h=0;for(let m=0;m<n;m++)h+=Math.abs(l[m]-p);const f=h/n;return t.precision(f)}}function Ic(t){return(e,i,r)=>{const n=x.from(e).get(0),a=x.from(i).get(0);t.taState||(t.taState={});const s=r||`dmi_${n}_${a}`;t.taState[s]||(t.taState[s]={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[s];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 l=t.get(t.data.high,0),c=t.get(t.data.low,0),u=t.get(t.data.close,0);if(isNaN(l)||isNaN(c)||isNaN(u))return[[NaN,NaN,NaN]];if(o.currentHigh=l,o.currentLow=c,o.currentClose=u,isNaN(o.prevHigh))return[[NaN,NaN,NaN]];const p=Math.max(l-c,Math.abs(l-o.prevClose),Math.abs(c-o.prevClose)),h=l-o.prevHigh,f=o.prevLow-c,m=h>f&&h>0?h:0,y=f>h&&f>0?f:0;let _=o.prevInitCount,v=o.prevTrInitSum,S=o.prevPlusInitSum,b=o.prevMinusInitSum,E=o.prevSmoothedTR,N=o.prevSmoothedPlus,T=o.prevSmoothedMinus;if(_++,_<=n)v+=p,S+=m,b+=y,_===n&&(E=v/n,N=S/n,T=b/n);else{const ie=1/n;E=ie*p+(1-ie)*E,N=ie*m+(1-ie)*N,T=ie*y+(1-ie)*T}if(o.currentInitCount=_,o.currentTrInitSum=v,o.currentPlusInitSum=S,o.currentMinusInitSum=b,o.currentSmoothedTR=E,o.currentSmoothedPlus=N,o.currentSmoothedMinus=T,_<n)return[[NaN,NaN,NaN]];const P=E===0?0:100*N/E,M=E===0?0:100*T/E,$=P+M,q=$===0?0:100*Math.abs(P-M)/$;let F=o.prevAdxInitCount,Z=o.prevDxInitSum,le=o.prevADX,Ee=NaN;if(F++,F<=a)Z+=q,F===a&&(le=Z/a,Ee=le);else{const ie=1/a;le=ie*q+(1-ie)*le,Ee=le}return o.currentAdxInitCount=F,o.currentDxInitSum=Z,o.currentADX=le,[[t.precision(P),t.precision(M),t.precision(Ee)]]}}function kc(t){return(e,i,r)=>{const n=x.from(i).get(0);t.taState||(t.taState={});const a=r||`ema_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevEma:null,prevInitSum:0,prevInitCount:0,currentEma:null,currentInitSum:0,currentInitCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevEma=s.currentEma,s.prevInitSum=s.currentInitSum,s.prevInitCount=s.currentInitCount),s.lastIdx=t.idx);const o=x.from(e).get(0);if(o==null||isNaN(o))return NaN;let l=s.prevInitCount,c=s.prevInitSum,u=s.prevEma;if(l<n){if(c+=o,l++,s.currentInitSum=c,s.currentInitCount=l,l===n){const f=c/n;return s.currentEma=f,t.precision(f)}return NaN}const p=2/(n+1),h=o*p+u*(1-p);return s.currentEma=h,t.precision(h)}}function Ac(t){return(e,i,r)=>{const n=x.from(i).get(0),a=x.from(e);for(let s=0;s<n;s++){const o=a.get(s),l=a.get(s+1);if(isNaN(o)||isNaN(l)||o>=l)return!1}return!0}}function Tc(t){return(e,i,r)=>{typeof i=="string"&&r===void 0&&(r=i,i=e,e=t.data.high);const n=x.from(i).get(0);t.taState||(t.taState={});const a=r||`highest_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=x.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=s.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const h=x.from(e);for(;l.length<n;)l.push(h.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<n)return NaN;const u=l.filter(h=>!isNaN(h)&&h!==void 0);if(u.length===0)return NaN;const p=Math.max(...u);return t.precision(p)}}function Pc(t){return(e,i,r)=>{const n=x.from(i).get(0),a=x.from(e);if(t.idx<n-1)return NaN;let s=-1/0,o=NaN;for(let l=0;l<n;l++){const c=a.get(l);isNaN(c)||(isNaN(o)||c>s)&&(s=c,o=-l)}return o}}function Dc(t){return(e,i,r)=>{const n=x.from(i).get(0),a=Math.floor(n/2),s=Math.floor(Math.sqrt(n)),o=t.pine.ta.wma,l=o(e,a,r?`${r}_wma1`:void 0),c=o(e,n,r?`${r}_wma2`:void 0);if(isNaN(l)||isNaN(c))return NaN;t.taState||(t.taState={});const u=r||`hma_raw_${n}`;t.taState[u]||(t.taState[u]={lastIdx:-1,prevValues:[],currentValues:[]});const p=t.taState[u];t.idx>p.lastIdx&&(p.lastIdx>=0&&(p.prevValues=[...p.currentValues]),p.lastIdx=t.idx);const h=2*l-c,f=[...p.prevValues];f.unshift(h),f.length>s+1&&f.pop(),p.currentValues=f;const m=r?`${r}_hma_final`:`hma_final_${n}`;t.taState[m]||(t.taState[m]={lastIdx:-1,prevWindow:[],currentWindow:[]});const y=t.taState[m];t.idx>y.lastIdx&&(y.lastIdx>=0&&(y.prevWindow=[...y.currentWindow]),y.lastIdx=t.idx);const _=[...y.prevWindow];if(_.unshift(h),_.length<s)return y.currentWindow=_,NaN;for(;_.length>s;)_.pop();y.currentWindow=_;let v=0,S=0;for(let E=0;E<s;E++){const N=s-E;v+=_[E]*N,S+=N}const b=v/S;return t.precision(b)}}function Rc(t){return e=>{const i=t.get(t.data.close,0),r=t.get(t.data.high,0),n=t.get(t.data.low,0),a=t.get(t.data.volume,0);if(isNaN(i)||isNaN(r)||isNaN(n)||isNaN(a))return NaN;const s=(r-n)*a;if(s===0)return t.precision(0);const o=(2*i-r-n)/s;return t.precision(o)}}function Mc(t){return(e,i,r,n,a)=>{const s=x.from(i).get(0),o=x.from(r).get(0);let l=!0;typeof n=="string"?a=n:n!==void 0&&(l=x.from(n).get(0));let c;const u=t.get(t.data.high,0),p=t.get(t.data.low,0);if(l){const E=t.get(t.data.close,1);isNaN(E)?c=NaN:c=Math.max(u-p,Math.abs(u-E),Math.abs(p-E))}else c=u-p;const h=x.from(e).get(0);t.taState||(t.taState={});const f=a||`kc_${s}_${o}_${l}`;t.taState[f]||(t.taState[f]={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 m=t.taState[f];t.idx>m.lastIdx&&(m.lastIdx>=0&&(m.basisState={...m.currentBasisState},m.rangeState={...m.currentRangeState}),m.lastIdx=t.idx);const y=(E,N,T,P)=>{if(isNaN(T))return Object.assign(N,E),N.prevEma!==null?N.prevEma:NaN;let M=E.initCount,$=E.initSum,q=E.prevEma;if(M<P){if($+=T,M++,N.initSum=$,N.initCount=M,N.prevEma=q,M===P){const le=$/P;return N.prevEma=le,le}return NaN}const F=2/(P+1),Z=T*F+q*(1-F);return N.prevEma=Z,N.initSum=$,N.initCount=M,Z},_=y(m.basisState,m.currentBasisState,h,s),v=y(m.rangeState,m.currentRangeState,c,s);if(isNaN(_)||isNaN(v))return[[NaN,NaN,NaN]];const S=_+v*o,b=_-v*o;return[[t.precision(_),t.precision(S),t.precision(b)]]}}function Oc(t){return(e,i,r,n,a)=>{const s=x.from(i).get(0),o=x.from(r).get(0);let l=!0;typeof n=="string"?a=n:n!==void 0&&(l=x.from(n).get(0)),t.taState||(t.taState={});const c=a||`kcw_${s}_${o}_${l}`;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 u=t.taState[c];t.idx>u.lastIdx&&(u.lastIdx>=0&&(u.basisState={...u.currentBasisState},u.rangeState={...u.currentRangeState}),u.lastIdx=t.idx);const p=(b,E,N,T)=>{if(isNaN(N))return Object.assign(E,b),E.prevEma!==null?E.prevEma:NaN;let P=b.initCount,M=b.initSum,$=b.prevEma;if(P<T){if(M+=N,P++,E.initSum=M,E.initCount=P,E.prevEma=$,P===T){const Z=M/T;return E.prevEma=Z,Z}return NaN}const q=2/(T+1),F=N*q+$*(1-q);return E.prevEma=F,E.initSum=M,E.initCount=P,F};let h;const f=t.get(t.data.high,0),m=t.get(t.data.low,0);if(l){const b=t.get(t.data.close,1);isNaN(b)?h=NaN:h=Math.max(f-m,Math.abs(f-b),Math.abs(m-b))}else h=f-m;const y=x.from(e).get(0),_=p(u.basisState,u.currentBasisState,y,s),v=p(u.rangeState,u.currentRangeState,h,s);if(isNaN(_)||isNaN(v))return NaN;if(_===0)return t.precision(0);const S=2*v*o/_;return t.precision(S)}}function Lc(t){return(e,i,r,n)=>{const a=x.from(i).get(0),s=x.from(r).get(0);t.taState||(t.taState={});const o=n||`linreg_${a}_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevCallCount=l.currentCallCount),l.lastIdx=t.idx);const c=x.from(e).get(0),u=[...l.prevWindow];for(u.unshift(c);u.length>a;)u.pop();const p=l.prevCallCount+1;if(u.length<a&&(p>=a||t.idx>=a-1)){const E=x.from(e);for(;u.length<a;)u.push(E.get(u.length))}if(l.currentWindow=u,l.currentCallCount=p,u.length<a)return NaN;let h=0,f=0,m=0,y=0;const _=a;for(let E=0;E<a;E++){const N=a-1-E,T=u[E];h+=N,f+=T,m+=N*T,y+=N*N}const v=_*y-h*h;if(v===0)return NaN;const S=(_*m-h*f)/v,b=(f-S*h)/_+S*(a-1-s);return t.precision(b)}}function Vc(t){return(e,i,r)=>{typeof i=="string"&&r===void 0&&(r=i,i=e,e=t.data.low);const n=x.from(i).get(0);t.taState||(t.taState={});const a=r||`lowest_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=x.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=s.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const h=x.from(e);for(;l.length<n;)l.push(h.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<n)return NaN;const u=l.filter(h=>!isNaN(h)&&h!==void 0);if(u.length===0)return NaN;const p=Math.min(...u);return t.precision(p)}}function Bc(t){return(e,i,r)=>{const n=x.from(i).get(0),a=x.from(e);if(t.idx<n-1)return NaN;let s=1/0,o=NaN;for(let l=0;l<n;l++){const c=a.get(l);isNaN(c)||(isNaN(o)||c<s)&&(s=c,o=-l)}return o}}function Fc(t){return(e,i,r,n,a)=>{const s=x.from(i).get(0),o=x.from(r).get(0),l=x.from(n).get(0),c=a||`macd_${s}_${o}_${l}`,u=`${c}_fast`,p=`${c}_slow`,h=`${c}_signal`,f=t.pine.ta.ema(e,s,u),m=t.pine.ta.ema(e,o,p);let y=NaN;!isNaN(f)&&!isNaN(m)&&(y=f-m);let _=NaN;isNaN(y)||(_=t.pine.ta.ema(y,l,h));let v=NaN;return!isNaN(y)&&!isNaN(_)&&(v=y-_),[[t.precision(y),t.precision(_),t.precision(v)]]}}function jc(t){return(e,i,r)=>{const n=x.from(i).get(0);t.taState||(t.taState={});const a=r||`median_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=x.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=s.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const f=x.from(e);for(;l.length<n;)l.push(f.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<n)return NaN;const u=l.slice().sort((f,m)=>f-m),p=Math.floor(n/2),h=n%2===0?(u[p-1]+u[p])/2:u[p];return t.precision(h)}}function Wc(t){return(e,i,r)=>{const n=x.from(i).get(0);t.taState||(t.taState={});const a=r||`mfi_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevUpperWindow:[],prevLowerWindow:[],prevUpperSum:0,prevLowerSum:0,currentUpperWindow:[],currentLowerWindow:[],currentUpperSum:0,currentLowerSum:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevUpperWindow=[...s.currentUpperWindow],s.prevLowerWindow=[...s.currentLowerWindow],s.prevUpperSum=s.currentUpperSum,s.prevLowerSum=s.currentLowerSum),s.lastIdx=t.idx);const o=x.from(e).get(0),l=x.from(e).get(1),c=t.get(t.data.volume,0);if(isNaN(o)||isNaN(c))return NaN;const u=isNaN(l)?NaN:o-l,p=c*(u<=0?0:o),h=c*(u>=0?0:o),f=[...s.prevUpperWindow],m=[...s.prevLowerWindow];let y=s.prevUpperSum,_=s.prevLowerSum;if(f.unshift(p),m.unshift(h),y+=p,_+=h,f.length<n)return s.currentUpperWindow=f,s.currentLowerWindow=m,s.currentUpperSum=y,s.currentLowerSum=_,NaN;if(f.length>n){const S=f.pop(),b=m.pop();y-=S,_-=b}if(s.currentUpperWindow=f,s.currentLowerWindow=m,s.currentUpperSum=y,s.currentLowerSum=_,_===0)return t.precision(100);if(y===0)return t.precision(0);const v=100-100/(1+y/_);return t.precision(v)}}function $c(t){return(e,i,r)=>{const n=x.from(i).get(0),a=x.from(e);if(t.idx<n-1)return NaN;const s=new Map;for(let c=0;c<n;c++){const u=a.get(c);isNaN(u)||s.set(u,(s.get(u)||0)+1)}if(s.size===0)return NaN;let o=NaN,l=-1;for(const[c,u]of s.entries())u>l?(l=u,o=c):u===l&&c<o&&(o=c);return o}}function Uc(t){return(e,i,r)=>{const n=x.from(i).get(0);return t.pine.ta.change(e,n,r)}}function qc(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 n=t.get(t.data.close,0),a=t.get(t.data.close,1),s=t.get(t.data.volume,0),o=t.get(t.data.volume,1),l=isNaN(n)?0:n,c=isNaN(a)?0:a,u=isNaN(s)?0:s,p=isNaN(o)?0:o;let h=r.committedNVI;if(!(l===0||c===0)&&u<p){const f=(l-c)/c;h=h+f*h}return r.tentativeNVI=h,t.precision(h)}}function Hc(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),n=t.get(t.data.volume,0),a=t.get(t.data.close,1);if(isNaN(a))return i.tentativeOBV=0,t.precision(0);let s=i.committedOBV;return r>a?s+=n:r<a&&(s-=n),i.tentativeOBV=s,t.precision(s)}}function Kc(t){return(e,i,r)=>e instanceof x?i?new x(e.data,e.offset+i):e:(t.params[r]||(t.params[r]=[]),Array.isArray(e)?new x(e,i||0):(t.params[r].length===0?t.params[r].push(e):t.params[r][t.params[r].length-1]=e,new x(t.params[r],0)))}function zc(t){return(e,i,r,n)=>{const a=x.from(i).get(0),s=x.from(r).get(0),o=x.from(e);if(t.idx<a-1)return NaN;const l=[];for(let m=0;m<a;m++){const y=o.get(m);if(isNaN(y))return NaN;l.push(y)}l.sort((m,y)=>m-y);let c=s/100*a-.5;c<0&&(c=0),c>a-1&&(c=a-1);const u=Math.floor(c),p=Math.ceil(c);if(u===p)return t.precision(l[u]);const h=c-u,f=l[u]+h*(l[p]-l[u]);return t.precision(f)}}function Gc(t){return(e,i,r,n)=>{const a=x.from(i).get(0),s=x.from(r).get(0),o=x.from(e);if(t.idx<a-1)return NaN;const l=[];for(let u=0;u<a;u++){const p=o.get(u);isNaN(p)||l.push(p)}if(l.length===0)return NaN;l.sort((u,p)=>u-p);let c=Math.ceil(s/100*l.length)-1;return c<0&&(c=0),c>=l.length&&(c=l.length-1),t.precision(l[c])}}function Yc(t){return(e,i,r)=>{const n=x.from(i).get(0),a=x.from(e);if(t.idx<n)return NaN;const s=a.get(0);if(isNaN(s))return NaN;let o=0,l=0;for(let c=1;c<=n;c++){const u=a.get(c);isNaN(u)||(l++,u<=s&&o++)}return l===0?NaN:t.precision(o/l*100)}}function Qc(t,e,i){const r=new Array(t.length).fill(NaN);for(let n=e+i;n<t.length;n++){const a=t[n-i];let s=!0;for(let o=1;o<=e;o++)if(t[n-i-o]>=a){s=!1;break}if(s){for(let o=1;o<=i;o++)if(t[n-i+o]>=a){s=!1;break}}s&&(r[n]=a)}return r}function Xc(t){return(e,i,r,n)=>{typeof r=="string"&&(r=i,i=e,e=t.data.high);const a=x.from(i).get(0),s=x.from(r).get(0),o=x.from(e).toArray(),l=Qc(o,a,s),c=t.idx;return t.precision(l[c])}}function Zc(t,e,i){const r=new Array(t.length).fill(NaN);for(let n=e+i;n<t.length;n++){const a=t[n-i];let s=!0;for(let o=1;o<=e;o++)if(t[n-i-o]<=a){s=!1;break}if(s){for(let o=1;o<=i;o++)if(t[n-i+o]<=a){s=!1;break}}s&&(r[n]=a)}return r}function Jc(t){return(e,i,r,n)=>{typeof r=="string"&&(r=i,i=e,e=t.data.low);const a=x.from(i).get(0),s=x.from(r).get(0),o=x.from(e).toArray(),l=Zc(o,a,s),c=t.idx;return t.precision(l[c])}}function eu(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 n=t.get(t.data.close,0),a=t.get(t.data.close,1),s=t.get(t.data.volume,0),o=t.get(t.data.volume,1),l=isNaN(n)?0:n,c=isNaN(a)?0:a,u=isNaN(s)?0:s,p=isNaN(o)?0:o;let h=r.committedPVI;if(!(l===0||c===0)&&u>p){const f=(l-c)/c;h=h+f*h}return r.tentativePVI=h,t.precision(h)}}function tu(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 n=t.get(t.data.close,0),a=t.get(t.data.close,1),s=t.get(t.data.volume,0);let o=r.prevCumulativeSum;if(!isNaN(n)&&!isNaN(a)&&!isNaN(s)&&a!==0){const l=(n-a)/a*s;o+=l}return r.currentCumulativeSum=o,t.precision(o)}}function iu(t){return(e,i,r)=>{const n=t.pine.ta.highest(e,i,(r||"range")+"_h"),a=t.pine.ta.lowest(e,i,(r||"range")+"_l");return isNaN(n)||isNaN(a)?NaN:t.precision(n-a)}}function ru(t){return(e,i,r)=>{const n=x.from(i).get(0),a=x.from(e);for(let s=0;s<n;s++){const o=a.get(s),l=a.get(s+1);if(isNaN(o)||isNaN(l)||o<=l)return!1}return!0}}function nu(t){return(e,i,r)=>{const n=x.from(i).get(0);t.taState||(t.taState={});const a=r||`rma_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevRma:null,prevInitSum:0,prevInitCount:0,currentRma:null,currentInitSum:0,currentInitCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevRma=s.currentRma,s.prevInitSum=s.currentInitSum,s.prevInitCount=s.currentInitCount),s.lastIdx=t.idx);const o=x.from(e).get(0)||0;let l=s.prevInitCount,c=s.prevInitSum,u=s.prevRma;if(l<n){if(c+=o,l++,s.currentInitSum=c,s.currentInitCount=l,l===n){const f=c/n;return s.currentRma=f,t.precision(f)}return NaN}const p=1/n,h=o*p+u*(1-p);return s.currentRma=h,t.precision(h)}}function su(t){return(e,i,r)=>{const n=x.from(i).get(0);t.taState||(t.taState={});const a=r||`roc_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=x.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n+1;)l.pop();const c=s.prevCallCount+1;if(l.length<n+1&&(c>=n+1||t.idx>=n)){const h=x.from(e);for(;l.length<n+1;)l.push(h.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<=n)return NaN;const u=l[n],p=(o-u)/u*100;return t.precision(p)}}function au(t){return(e,i,r)=>{const n=x.from(i).get(0);t.taState||(t.taState={});const a=r||`rsi_${n}`;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 s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevPrevValue=s.currentPrevValue,s.prevAvgGain=s.currentAvgGain,s.prevAvgLoss=s.currentAvgLoss,s.prevInitGains=[...s.currentInitGains],s.prevInitLosses=[...s.currentInitLosses]),s.lastIdx=t.idx);const o=x.from(e).get(0);if(o==null||isNaN(o))return NaN;const l=s.prevPrevValue;if(l===null||isNaN(l))return s.currentPrevValue=o,s.currentInitGains=[...s.prevInitGains],s.currentInitLosses=[...s.prevInitLosses],s.currentAvgGain=s.prevAvgGain,s.currentAvgLoss=s.prevAvgLoss,NaN;let c=s.prevAvgGain,u=s.prevAvgLoss;const p=[...s.prevInitGains],h=[...s.prevInitLosses],f=o-l,m=f>0?f:0,y=f<0?-f:0;if(p.length<n){if(p.push(m),h.push(y),s.currentInitGains=p,s.currentInitLosses=h,s.currentPrevValue=o,p.length===n){c=p.reduce((S,b)=>S+b,0)/n,u=h.reduce((S,b)=>S+b,0)/n,s.currentAvgGain=c,s.currentAvgLoss=u;const v=u===0?100:100-100/(1+c/u);return t.precision(v)}return NaN}c=(c*(n-1)+m)/n,u=(u*(n-1)+y)/n,s.currentAvgGain=c,s.currentAvgLoss=u,s.currentPrevValue=o;const _=u===0?100:100-100/(1+c/u);return t.precision(_)}}function ou(t){return(e,i,r,n)=>{const a=x.from(e).get(0),s=x.from(i).get(0),o=x.from(r).get(0);t.taState||(t.taState={});const l=n||`sar_${a}_${s}_${o}`;t.taState[l]||(t.taState[l]={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[l];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 u=c.prevResult,p=c.prevMaxMin,h=c.prevAcceleration,f=c.prevIsBelow,m=c.prevBarIndex;const y=t.get(t.data.high,0),_=t.get(t.data.low,0),v=t.get(t.data.close,0),S=t.get(t.data.close,1),b=t.get(t.data.high,1),E=t.get(t.data.low,1),N=t.get(t.data.high,2),T=t.get(t.data.low,2);if(isNaN(y)||isNaN(_)||isNaN(v))return c.currentResult=u,c.currentMaxMin=p,c.currentAcceleration=h,c.currentIsBelow=f,c.currentBarIndex=m,NaN;let P=!1;return m===1&&(v>S?(f=!0,p=y,u=E):(f=!1,p=_,u=b),P=!0,h=a),m>=1&&(u=u+h*(p-u),f?u>_&&(P=!0,f=!1,u=Math.max(y,p),p=_,h=a):u<y&&(P=!0,f=!0,u=Math.min(_,p),p=y,h=a),P||(f?y>p&&(p=y,h=Math.min(h+s,o)):_<p&&(p=_,h=Math.min(h+s,o))),f?(u=Math.min(u,E),m>1&&(u=Math.min(u,T))):(u=Math.max(u,b),m>1&&(u=Math.max(u,N)))),m++,c.currentResult=u,c.currentMaxMin=p,c.currentAcceleration=h,c.currentIsBelow=f,c.currentBarIndex=m,m<=1?NaN:t.precision(u)}}function lu(t){return(e,i,r)=>{const n=x.from(i).get(0);t.taState||(t.taState={});const a=r||`sma_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevSum=s.currentSum,s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=x.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=s.prevCallCount+1;let u=!1;if(l.length<n&&(c>=n||t.idx>=n-1)){const y=x.from(e);for(;l.length<n;)l.push(y.get(l.length));u=!0}let p;const h=o==null||Number.isNaN(o);let f=!Number.isNaN(s.prevSum)&&!h&&!u;if(f){let y=s.prevSum+o;if(s.prevWindow.length>=n){const _=s.prevWindow[s.prevWindow.length-1];_==null||Number.isNaN(_)?f=!1:y-=_}f&&(p=y)}if(!f){p=0;let y=!1;for(const _ of l){if(_==null||Number.isNaN(_)){y=!0;break}p+=_}y&&(p=NaN)}if(s.currentWindow=l,s.currentSum=p,s.currentCallCount=c,l.length<n)return NaN;const m=p/n;return t.precision(m)}}function cu(t){return(e,i,r=!0,n)=>{const a=x.from(i).get(0),s=x.from(r).get(0);t.taState||(t.taState={});const o=n||`stdev_${a}_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevSum=l.currentSum,l.prevCallCount=l.currentCallCount),l.lastIdx=t.idx);const c=x.from(e).get(0);if(c==null||isNaN(c))return NaN;const u=[...l.prevWindow];let p=l.prevSum;for(u.unshift(c),p+=c;u.length>a;){const v=u.pop();p-=v}const h=l.prevCallCount+1;if(u.length<a&&(h>=a||t.idx>=a-1)){const v=x.from(e);for(;u.length<a;){const S=v.get(u.length);if(S==null||isNaN(S))break;u.push(S),p+=S}}if(l.currentWindow=u,l.currentSum=p,l.currentCallCount=h,u.length<a)return NaN;const f=p/a;let m=0;for(let v=0;v<a;v++)m+=Math.pow(u[v]-f,2);const y=s?a:a-1,_=Math.sqrt(m/y);return t.precision(_)}}function uu(t){return(e,i,r,n,a)=>{const s=x.from(n).get(0);t.taState||(t.taState={});const o=a||`stoch_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevHighWindow:[],prevLowWindow:[],currentHighWindow:[],currentLowWindow:[]});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevHighWindow=[...l.currentHighWindow],l.prevLowWindow=[...l.currentLowWindow]),l.lastIdx=t.idx);const c=x.from(e).get(0),u=x.from(i).get(0),p=x.from(r).get(0);if(isNaN(c)||isNaN(u)||isNaN(p))return l.currentHighWindow=[...l.prevHighWindow],l.currentLowWindow=[...l.prevLowWindow],NaN;const h=[...l.prevHighWindow],f=[...l.prevLowWindow];if(h.unshift(u),f.unshift(p),h.length>s&&(h.pop(),f.pop()),l.currentHighWindow=h,l.currentLowWindow=f,h.length<s)return NaN;let m=h[0],y=f[0];for(let S=1;S<s;S++)h[S]>m&&(m=h[S]),f[S]<y&&(y=f[S]);const _=m-y;if(_===0)return NaN;const v=100*(c-y)/_;return t.precision(v)}}function hu(t){return(e,i,r)=>{const n=x.from(e).get(0),a=x.from(i).get(0);t.taState||(t.taState={});const s=r||`supertrend_${n}_${a}`;t.taState[s]||(t.taState[s]={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[s];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 l=t.get(t.data.high,0),c=t.get(t.data.low,0),u=t.get(t.data.close,0);if(isNaN(l)||isNaN(c)||isNaN(u))return[[NaN,NaN]];const p=(l+c)/2,h=o.prevClose;let f;isNaN(h)?f=l-c:f=Math.max(l-c,Math.abs(l-h),Math.abs(c-h));let m=o.prevAtrCount,y=o.prevTrSum,_=o.prevAtrValue;m++,m<=a?(y+=f,m===a&&(_=y/a)):_=(_*(a-1)+f)/a;const v=_;if(o.currentAtrCount=m,o.currentTrSum=y,o.currentAtrValue=_,o.currentClose=u,isNaN(v))return[[NaN,NaN]];let S=p+n*v,b=p-n*v;const E=isNaN(o.prevLowerBand)?0:o.prevLowerBand,N=isNaN(o.prevUpperBand)?0:o.prevUpperBand;isNaN(o.prevLowerBand)||b>E||h<E||(b=E),isNaN(o.prevUpperBand)||S<N||h>N||(S=N);let T,P;const M=o.prevSuperTrend;return m===a?T=1:M===o.prevUpperBand?T=u>S?-1:1:T=u<b?1:-1,P=T===-1?b:S,o.currentLowerBand=b,o.currentUpperBand=S,o.currentSuperTrend=P,o.currentDirection=T,[[t.precision(P),T]]}}function pu(t){return(e,i)=>{const r=[1,2,2,1],n=6;t.taState||(t.taState={});const a=i||"swma";t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],currentWindow:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow]),s.lastIdx=t.idx);const o=x.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>4;)l.pop();if(l.length<4&&t.idx>=3){const u=x.from(e);for(;l.length<4;)l.push(u.get(l.length))}if(s.currentWindow=l,l.length<4)return NaN;let c=0;for(let u=0;u<4;u++)c+=r[u]*l[3-u];return c/=n,t.precision(c)}}function fu(t){return(e,i)=>{let r=!0;typeof e=="string"||e!==void 0&&(r=x.from(e).get(0));const n=t.get(t.data.high,0),a=t.get(t.data.low,0),s=t.get(t.data.close,1);if(isNaN(s))return r?t.precision(n-a):NaN;const o=Math.max(n-a,Math.abs(n-s),Math.abs(a-s));return t.precision(o)}}function du(t){return(e,i,r,n)=>{const a=x.from(i).get(0),s=x.from(r).get(0);t.taState||(t.taState={});const o=n||`tsi_${a}_${s}`;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 l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevSource=l.currentSource,l.prevEma1PcValue=l.currentEma1PcValue,l.prevEma1PcCount=l.currentEma1PcCount,l.prevEma1PcSum=l.currentEma1PcSum,l.prevEma2PcValue=l.currentEma2PcValue,l.prevEma2PcCount=l.currentEma2PcCount,l.prevEma2PcSum=l.currentEma2PcSum,l.prevEma1AbsValue=l.currentEma1AbsValue,l.prevEma1AbsCount=l.currentEma1AbsCount,l.prevEma1AbsSum=l.currentEma1AbsSum,l.prevEma2AbsValue=l.currentEma2AbsValue,l.prevEma2AbsCount=l.currentEma2AbsCount,l.prevEma2AbsSum=l.currentEma2AbsSum),l.lastIdx=t.idx);const c=x.from(e).get(0);if(isNaN(c))return NaN;const u=isNaN(l.prevSource)?NaN:c-l.prevSource;if(l.currentSource=c,isNaN(u))return NaN;const p=Math.abs(u),h=2/(s+1),f=2/(a+1),m=2/(s+1),y=2/(a+1);let _=l.prevEma1PcCount,v=l.prevEma1PcSum,S=l.prevEma1PcValue;_++,_<=s?(v+=u,_===s&&(S=v/s)):S=u*h+S*(1-h);let b=l.prevEma1AbsCount,E=l.prevEma1AbsSum,N=l.prevEma1AbsValue;if(b++,b<=s?(E+=p,b===s&&(N=E/s)):N=p*m+N*(1-m),isNaN(S)||isNaN(N))return l.currentEma1PcCount=_,l.currentEma1PcSum=v,l.currentEma1PcValue=S,l.currentEma1AbsCount=b,l.currentEma1AbsSum=E,l.currentEma1AbsValue=N,NaN;let T=l.prevEma2PcCount,P=l.prevEma2PcSum,M=l.prevEma2PcValue;T++,T<=a?(P+=S,T===a&&(M=P/a)):M=S*f+M*(1-f);let $=l.prevEma2AbsCount,q=l.prevEma2AbsSum,F=l.prevEma2AbsValue;if($++,$<=a?(q+=N,$===a&&(F=q/a)):F=N*y+F*(1-y),l.currentEma1PcCount=_,l.currentEma1PcSum=v,l.currentEma1PcValue=S,l.currentEma1AbsCount=b,l.currentEma1AbsSum=E,l.currentEma1AbsValue=N,l.currentEma2PcCount=T,l.currentEma2PcSum=P,l.currentEma2PcValue=M,l.currentEma2AbsCount=$,l.currentEma2AbsSum=q,l.currentEma2AbsValue=F,isNaN(M)||isNaN(F))return NaN;if(F===0)return t.precision(0);const Z=M/F;return t.precision(Z)}}function mu(t){return(e,i,r,n)=>{t.taState||(t.taState={});const a=n||"valuewhen";t.taState[a]||(t.taState[a]={lastIdx:-1,prevValues:[],currentValues:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevValues=[...s.currentValues]),s.lastIdx=t.idx);const o=x.from(e).get(0),l=x.from(i).get(0),c=x.from(r).get(0),u=[...s.prevValues];if(o&&u.push(l),s.currentValues=u,isNaN(c)||c<0)return NaN;const p=u.length-1-c;if(p<0)return NaN;const h=u[p];return typeof h=="number"?t.precision(h):h}}function gu(t){return(e,i,r)=>{const n=x.from(i).get(0);t.taState||(t.taState={});const a=r||`variance_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=x.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=s.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const m=x.from(e);for(;l.length<n;)l.push(m.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<n)return NaN;let u=0,p=0;for(let m=0;m<n;m++)u+=l[m],p+=l[m]*l[m];const h=u/n,f=p/n-h*h;return t.precision(f)}}function xu(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 n=t.taState[r];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevCumulativePV=n.currentCumulativePV,n.prevCumulativeVolume=n.currentCumulativeVolume,n.prevLastSessionDate=n.currentLastSessionDate),n.lastIdx=t.idx);const a=x.from(e).get(0),s=x.from(t.data.volume).get(0),o=x.from(t.data.openTime).get(0),l=new Date(o).toISOString().slice(0,10);let c=n.prevCumulativePV,u=n.prevCumulativeVolume,p=n.prevLastSessionDate;if(p!==l&&(c=0,u=0,p=l),c+=a*s,u+=s,n.currentCumulativePV=c,n.currentCumulativeVolume=u,n.currentLastSessionDate=p,u===0)return NaN;const h=c/u;return t.precision(h)}}function yu(t){return(e,i,r)=>{const n=x.from(i).get(0);t.taState||(t.taState={});const a=r||`vwma_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevVolumeWindow:[],currentWindow:[],currentVolumeWindow:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevVolumeWindow=[...s.currentVolumeWindow]),s.lastIdx=t.idx);const o=x.from(e).get(0),l=t.get(t.data.volume,0),c=[...s.prevWindow],u=[...s.prevVolumeWindow];for(c.unshift(o),u.unshift(l);c.length>n;)c.pop(),u.pop();if(c.length<n&&t.idx>=n-1){const m=x.from(e),y=x.from(t.data.volume);for(;c.length<n;)c.push(m.get(c.length)),u.push(y.get(u.length))}if(s.currentWindow=c,s.currentVolumeWindow=u,c.length<n)return NaN;let p=0,h=0;for(let m=0;m<n;m++)p+=c[m]*u[m],h+=u[m];const f=p/h;return t.precision(f)}}function _u(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 n=t.get(t.data.close,0),a=t.get(t.data.high,0),s=t.get(t.data.low,0),o=t.get(t.data.close,1);if(isNaN(n)||isNaN(a)||isNaN(s))return r.currentCumulativeSum=r.prevCumulativeSum,t.precision(r.prevCumulativeSum);let l=0;if(!isNaN(o)){const u=Math.max(a,o),p=Math.min(s,o),h=n-o;h>0?l=n-p:h<0&&(l=n-u)}const c=r.prevCumulativeSum+l;return r.currentCumulativeSum=c,t.precision(c)}}function vu(t){return(e,i,r)=>{const n=x.from(i).get(0);t.taState||(t.taState={});const a=r||`wma_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=x.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=s.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const f=x.from(e);for(;l.length<n;)l.push(f.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<n)return NaN;let u=0,p=0;for(let f=0;f<n;f++){const m=n-f;u+=l[f]*m,p+=m}const h=u/p;return t.precision(h)}}function bu(t){return(e,i)=>{const r=x.from(e).get(0);t.taState||(t.taState={});const n=i||`wpr_${r}`;t.taState[n]||(t.taState[n]={lastIdx:-1,prevHighWindow:[],prevLowWindow:[],currentHighWindow:[],currentLowWindow:[]});const a=t.taState[n];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevHighWindow=[...a.currentHighWindow],a.prevLowWindow=[...a.currentLowWindow]),a.lastIdx=t.idx);const s=t.get(t.data.high,0),o=t.get(t.data.low,0),l=t.get(t.data.close,0);if(isNaN(s)||isNaN(o)||isNaN(l))return a.currentHighWindow=[...a.prevHighWindow],a.currentLowWindow=[...a.prevLowWindow],NaN;const c=[...a.prevHighWindow],u=[...a.prevLowWindow];if(c.unshift(s),u.unshift(o),c.length>r&&(c.pop(),u.pop()),a.currentHighWindow=c,a.currentLowWindow=u,c.length<r)return NaN;let p=c[0],h=u[0];for(let y=1;y<r;y++)c[y]>p&&(p=c[y]),u[y]<h&&(h=u[y]);const f=p-h;if(f===0)return t.precision(0);const m=(p-l)/f*-100;return t.precision(m)}}function wu(t){return e=>{const i=t.get(t.data.close,0),r=t.get(t.data.open,0),n=t.get(t.data.high,0),a=t.get(t.data.low,0),s=t.get(t.data.volume,0);if(isNaN(i)||isNaN(r)||isNaN(n)||isNaN(a)||isNaN(s))return NaN;const o=n-a;if(o===0)return t.precision(0);const l=(i-r)/o*s;return t.precision(l)}}const Su={accdist:hc,alma:pc,atr:fc,barssince:dc,bb:mc,bbw:gc,cci:xc,change:yc,cmo:_c,cog:vc,correlation:bc,cross:wc,crossover:Sc,crossunder:Ec,cum:Nc,dev:Cc,dmi:Ic,ema:kc,falling:Ac,highest:Tc,highestbars:Pc,hma:Dc,iii:Rc,kc:Mc,kcw:Oc,linreg:Lc,lowest:Vc,lowestbars:Bc,macd:Fc,median:jc,mfi:Wc,mode:$c,mom:Uc,nvi:qc,obv:Hc,param:Kc,percentile_linear_interpolation:zc,percentile_nearest_rank:Gc,percentrank:Yc,pivothigh:Xc,pivotlow:Jc,pvi:eu,pvt:tu,range:iu,rising:ru,rma:nu,roc:su,rsi:au,sar:ou,sma:lu,stdev:cu,stoch:uu,supertrend:hu,swma:pu,tr:fu,tsi:du,valuewhen:mu,variance:gu,vwap:xu,vwma:yu,wad:_u,wma:vu,wpr:bu,wvad:wu};class Eu{constructor(e){this.context=e,Object.entries(Su).forEach(([i,r])=>{this[i]=r(e)})}accdist;alma;atr;barssince;bb;bbw;cci;change;cmo;cog;correlation;cross;crossover;crossunder;cum;dev;dmi;ema;falling;highest;highestbars;hma;iii;kc;kcw;linreg;lowest;lowestbars;macd;median;mfi;mode;mom;nvi;obv;param;percentile_linear_interpolation;percentile_nearest_rank;percentrank;pivothigh;pivotlow;pvi;pvt;range;rising;rma;roc;rsi;sar;sma;stdev;stoch;supertrend;swma;tr;tsi;valuewhen;variance;vwap;vwma;wad;wma;wpr;wvad}function Dt(t=new Date,e){const i=e??-t.getTimezoneOffset(),r=i>=0?"+":"-",n=s=>String(Math.floor(Math.abs(s))).padStart(2,"0"),a=r+n(i/60)+":"+n(i%60);return`[${t.toISOString().slice(0,-1)}${a}]`}class Nu{constructor(e){this.context=e}logFormat(e,...i){return e.replace(/{(\d+)}/g,(r,n)=>i[n])}param(e,i=0,r){return x.from(e).get(i)}warning(e,...i){if(this.context.isSecondaryContext)return;const r=this.context.data.openTime.data[this.context.idx],n=Dt(new Date(r),0);console.warn(`${n} ${this.logFormat(e,...i)}`)}error(e,...i){if(this.context.isSecondaryContext)return;const r=this.context.data.openTime.data[this.context.idx],n=Dt(new Date(r),0);console.error(`${n} ${this.logFormat(e,...i)}`)}info(e,...i){if(this.context.isSecondaryContext)return;const r=this.context.data.openTime.data[this.context.idx],n=Dt(new Date(r),0);console.log(`${n} ${this.logFormat(e,...i)}`)}}class Cu{constructor(e){this.context=e}param(e,i=0,r){return x.from(e).get(i)}tostring(e,i){if(i==="mintick"&&typeof e=="number"){const r=this.context.pine?.syminfo?.mintick||.01,n=Math.max(0,-Math.floor(Math.log10(r)));return e.toFixed(n)}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,n=0){const a=String(e),s=String(i),o=String(r),l=Math.floor(Number(n))||0;if(s==="")return a;let c=0,u=0;for(;;){const p=a.indexOf(s,c);if(p===-1)return a;if(u===l)return a.substring(0,p)+o+a.substring(p+s.length);u++,c=p+s.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,n)=>i[n])}}class Iu{constructor(e){this.context=e}param(e,i=0,r){return x.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 Di=["series","title","color","linewidth","style","trackprice","histbase","offset","join","editable","show_last","display","format","precision","force_overlay"],ku=["series","title","style","location","color","offset","text","textcolor","editable","size","show_last","display","format","precision","force_overlay"],Au=["series","title","colorup","colordown","offset","minheight","maxheight","editable","show_last","display","format","precision","force_overlay"],Tu=["open","high","low","close","title","color","editable","show_last","display","format","precision","force_overlay"],Pu=["open","high","low","close","title","color","wickcolor","editable","show_last","bordercolor","display","format","precision","force_overlay"],Ri=["color","offset","editable","show_last","title","display","force_overlay"],Du=["price","title","color","linestyle","linewidth","editable","display"],Ru=["plot1","plot2","color","title","editable","show_last","fillgaps","display"],Mi={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"},Mu={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"},Ou={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"},Lu={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"},Vu={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"},Oi={color:"string",offset:"number",editable:"boolean",show_last:"number",title:"string",display:"string",force_overlay:"boolean"},Bu={price:"series",title:"string",color:"string",linestyle:"string",linewidth:"number",editable:"boolean",display:"string"},Fu={plot1:"object",plot2:"object",color:"string",title:"string",editable:"boolean",show_last:"number",fillgaps:"boolean",display:"string"};class ju{constructor(e){this.context=e}_resolvePlotKey(e,i){if(e){const r=this.context.plots[e];return!r||!i||r._callsiteId===i?e:e+i}return i||"plot"}extractPlotOptions(e){const i={};for(let r in e)i[r]=x.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 x.from(e).get(i)}plotchar(...e){const i=ve(e),r=z(e,Di,Mi),{series:n,title:a,...s}=r,o=this.extractPlotOptions(s),l=this._resolvePlotKey(a,i);this.context.plots[l]||(this.context.plots[l]={data:[],options:{...o,style:"char"},title:a,_plotKey:l,_callsiteId:i});const c=x.from(n).get(0);return this.context.plots[l].data.push({title:a,time:this.context.marketData[this.context.idx].openTime,value:c}),this.context.plots[l]}any(...e){const i=ve(e),r=z(e,Di,Mi),{series:n,title:a,...s}=r,o=this.extractPlotOptions(s),l=this._resolvePlotKey(a,i);if(!this.context.plots[l]){const u=o.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[l]={data:[],options:{...o,overlay:u},title:a,_plotKey:l,_callsiteId:i}}const c=x.from(n).get(0);return this.context.plots[l].data.push({title:a,time:this.context.marketData[this.context.idx].openTime,value:c,options:{color:o.color,offset:o.offset}}),this.context.plots[l]}plotshape(...e){const i=ve(e),r=z(e,ku,Mu),{series:n,title:a,...s}=r,o=this.extractPlotOptions(s),l=this._resolvePlotKey(a,i);if(!this.context.plots[l]){const u=o.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[l]={data:[],options:{...o,style:"shape",shape:o.style,overlay:u},title:a,_plotKey:l,_callsiteId:i}}const c=x.from(n).get(0);return this.context.plots[l].data.push({title:a,time:this.context.marketData[this.context.idx].openTime,value:c,options:o?.location==="absolute"||c?{text:o.text,textcolor:o.textcolor,color:o.color,offset:o.offset,shape:o.style,location:o.location,size:o.size}:void 0}),this.context.plots[l]}plotarrow(...e){const i=ve(e),r=z(e,Au,Ou),{series:n,title:a,...s}=r,o=x.from(n).get(0),l=this.extractPlotOptions(s),c=this._resolvePlotKey(a,i);if(!this.context.plots[c]){const u=l.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[c]={data:[],options:{...l,style:"shape",overlay:u},title:a,_plotKey:c,_callsiteId:i}}return this.context.plots[c].data.push({title:a,time:this.context.marketData[this.context.idx].openTime,value:o,options:typeof o=="number"&&!isNaN(o)&&o!==0?{text:void 0,textcolor:void 0,color:o>0?l.colorup:l.colordown,offset:l.offset,shape:o>0?"shape_arrow_up":"shape_arrow_down",location:o>0?"BelowBar":"AboveBar",height:l.maxheight}:void 0}),this.context.plots[c]}plotbar(...e){const i=ve(e),r=z(e,Tu,Lu),{open:n,high:a,low:s,close:o,title:l,...c}=r,u=this.extractPlotOptions(c),p=this._resolvePlotKey(l,i);if(!this.context.plots[p]){const f=u.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[p]={data:[],options:{...u,style:"bar",overlay:f},title:l,_plotKey:p,_callsiteId:i}}const h=[x.from(n).get(0),x.from(a).get(0),x.from(s).get(0),x.from(o).get(0)];this.context.plots[p].data.push({title:l,time:this.context.marketData[this.context.idx].openTime,value:h,options:{color:u.color}})}plotcandle(...e){const i=ve(e),r=z(e,Pu,Vu),{open:n,high:a,low:s,close:o,title:l,...c}=r,u=this.extractPlotOptions(c),p=this._resolvePlotKey(l,i);if(!this.context.plots[p]){const f=u.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[p]={data:[],options:{...u,style:"candle",overlay:f},title:l,_plotKey:p,_callsiteId:i}}const h=[x.from(n).get(0),x.from(a).get(0),x.from(s).get(0),x.from(o).get(0)];return this.context.plots[p].data.push({title:l,time:this.context.marketData[this.context.idx].openTime,value:h,options:{color:u.color,wickcolor:u.wickcolor,bordercolor:u.bordercolor}}),this.context.plots[p]}bgcolor(...e){const i=ve(e),r=z(e,Ri,Oi),{title:n,...a}=r,s=this.extractPlotOptions(a),o=this._resolvePlotKey(n,i);if(!this.context.plots[o]){const l=s.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[o]={data:[],options:{...s,style:"background",overlay:l},title:n,_plotKey:o,_callsiteId:i}}this.context.plots[o].data.push({title:n,time:this.context.marketData[this.context.idx].openTime,value:s.color&&s.color!=="na"&&s?.color.toString()!=="NaN",options:{color:s.color}})}barcolor(...e){const i=ve(e),r=z(e,Ri,Oi),{title:n,...a}=r,s=this.extractPlotOptions(a),o=this._resolvePlotKey(n,i);return this.context.plots[o]||(this.context.plots[o]={data:[],options:{...s,style:"barcolor"},title:n,_plotKey:o,_callsiteId:i}),this.context.plots[o].data.push({title:n,time:this.context.marketData[this.context.idx].openTime,value:s.color&&s.color!=="na"&&s?.color.toString()!=="NaN",options:{color:s.color}}),this.context.plots[o]}}class Wu{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 x.from(e).get(i)}any(...e){const i=ve(e),r=z(e,Du,Bu),{price:n,title:a,color:s,linestyle:o,linewidth:l,editable:c,display:u}=r,p=[n,{title:a,color:s,linestyle:o,linewidth:l,editable:c,display:u,style:"hline"}];return i&&p.push({__callsiteId:i}),this.context.pine.plot.any(...p)}}class $u{constructor(e){this.context=e}param(e,i=0,r){return x.from(e).get(i)}any(...e){const i=ve(e),r=z(e,Ru,Fu),{plot1:n,plot2:a,color:s,title:o,editable:l,show_last:c,fillgaps:u,display:p}=r;let h=o||"fill";const f=this.context.plots[h];if(f&&i&&f._callsiteId!==i&&(h=i),!this.context.plots[h]){const m=n?._plotKey||n?.title,y=a?._plotKey||a?.title;this.context.plots[h]={title:o||"Fill",plot1:m,plot2:y,options:{plot1:m,plot2:y,color:s,editable:l,show_last:c,fillgaps:u,display:p,style:"fill"},_plotKey:h,_callsiteId:i}}}}class Uu{constructor(e){this.context=e;const i=this.context;this.point={new(r,n,a){return new ne(r,n,a??NaN)},from_index(r,n){return new ne(void 0,r,n)},from_time(r,n){return new ne(r,void 0,n)},copy(r){return r.copy()},now(r){const n=i.idx,a=i.marketData[n]?.openTime;return new ne(a,n,r)}}}point;param(e,i=0,r){return x.from(e).get(i)}bg_color(){return"#1e293b"}fg_color(){return"#ffffff"}is_standard(){return!0}is_heikinashi(){return!1}is_kagi(){return!1}is_linebreak(){return!1}is_pnf(){return!1}is_range(){return!1}is_renko(){return!1}}let qu=0;class ei{id;x;y;text;xloc;yloc;color;style;textcolor;size;textalign;tooltip;text_font_family;force_overlay;_deleted;constructor(e,i,r="",n="bi",a="pr",s="",o="style_label_down",l="",c="normal",u="center",p="",h="default",f=!1){this.id=qu++,this.x=e,this.y=i,this.text=r,this.xloc=n,this.yloc=a,this.color=s,this.style=o,this.textcolor=l,this.size=c,this.textalign=u,this.tooltip=p,this.text_font_family=h,this.force_overlay=f,this._deleted=!1}delete(){this._deleted=!0}copy(){return new ei(this.x,this.y,this.text,this.xloc,this.yloc,this.color,this.style,this.textcolor,this.size,this.textalign,this.tooltip,this.text_font_family,this.force_overlay)}toPlotData(){return{id:this.id,x:this.x,y:this.y,text:this.text,xloc:this.xloc,yloc:this.yloc,color:this.color,style:this.style,textcolor:this.textcolor,size:this.size,textalign:this.textalign,tooltip:this.tooltip,text_font_family:this.text_font_family,force_overlay:this.force_overlay}}}const Hu=[["x","y","text","xloc","yloc","color","style","textcolor","size","textalign","tooltip","text_font_family","force_overlay"],["point","text","xloc","yloc","color","style","textcolor","size","textalign","tooltip","text_font_family","force_overlay"]],Ku={x:"number",y:"number",text:"string",xloc:"string",yloc:"string",color:"string",style:"string",textcolor:"string",size:"string",textalign:"string",tooltip:"string",text_font_family:"string",force_overlay:"boolean",point:"point"};class zu{constructor(e){this.context=e}_labels=[];param(e,i=0,r){return x.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__labels__||(this.context.plots.__labels__={title:"__labels__",data:[],options:{style:"label",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__labels__.data=[{time:e,value:this._labels,options:{style:"label"}}]}_resolve(e){return e==null?e:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_createLabel(e,i,r="",n="bi",a="pr",s="",o="style_label_down",l="",c="normal",u="center",p="",h="default",f=!1){const m=new ei(e,i,this._resolve(r),this._resolve(n),this._resolve(a),this._resolve(s),this._resolve(o),this._resolve(l),this._resolve(c),this._resolve(u),this._resolve(p),this._resolve(h),f);return this._labels.push(m),this._syncToPlot(),m}new(...e){const i=z(e,Hu,Ku);let r,n,a=i.xloc;if(i.point instanceof ne){const s=i.point;s.index!==void 0?(r=s.index,a=a||"bi"):s.time!==void 0?(r=s.time,a=a||"bt"):(r=0,a=a||"bi"),n=s.price}else r=i.x,n=i.y;return this._createLabel(r,n,i.text,a,i.yloc,i.color,i.style,i.textcolor,i.size,i.textalign,i.tooltip,i.text_font_family,i.force_overlay)}any(...e){return this.new(...e)}set_x(e,i){e&&!e._deleted&&(e.x=i)}set_y(e,i){e&&!e._deleted&&(e.y=i)}set_xy(e,i,r){e&&!e._deleted&&(e.x=i,e.y=r)}set_text(e,i){e&&!e._deleted&&(e.text=i)}set_color(e,i){e&&!e._deleted&&(e.color=i)}set_textcolor(e,i){e&&!e._deleted&&(e.textcolor=i)}set_size(e,i){e&&!e._deleted&&(e.size=i)}set_style(e,i){e&&!e._deleted&&(e.style=i)}set_textalign(e,i){e&&!e._deleted&&(e.textalign=i)}set_tooltip(e,i){e&&!e._deleted&&(e.tooltip=i)}set_xloc(e,i){e&&!e._deleted&&(e.xloc=i)}set_yloc(e,i){e&&!e._deleted&&(e.yloc=i)}set_point(e,i){e&&!e._deleted&&i&&(i.index!==void 0?(e.x=i.index,e.xloc="bi"):i.time!==void 0&&(e.x=i.time,e.xloc="bt"),e.y=i.price)}get_x(e){return e?e.x:NaN}get_y(e){return e?e.y:NaN}get_text(e){return e?e.text:""}copy(e){if(!e)return;const i=e.copy();return this._labels.push(i),this._syncToPlot(),i}delete(e){e&&(e._deleted=!0)}get all(){return this._labels.filter(e=>!e._deleted)}get style_label_down(){return"style_label_down"}get style_label_up(){return"style_label_up"}get style_label_left(){return"style_label_left"}get style_label_right(){return"style_label_right"}get style_label_lower_left(){return"style_label_lower_left"}get style_label_lower_right(){return"style_label_lower_right"}get style_label_upper_left(){return"style_label_upper_left"}get style_label_upper_right(){return"style_label_upper_right"}get style_label_center(){return"style_label_center"}get style_circle(){return"style_circle"}get style_square(){return"style_square"}get style_diamond(){return"style_diamond"}get style_flag(){return"style_flag"}get style_arrowup(){return"style_arrowup"}get style_arrowdown(){return"style_arrowdown"}get style_cross(){return"style_cross"}get style_xcross(){return"style_xcross"}get style_triangleup(){return"style_triangleup"}get style_triangledown(){return"style_triangledown"}get style_none(){return"style_none"}get style_text_outline(){return"style_text_outline"}}let Gu=0;class ti{id;x1;y1;x2;y2;xloc;extend;color;style;width;force_overlay;_deleted;constructor(e,i,r,n,a="bi",s="none",o="",l="style_solid",c=1,u=!1){this.id=Gu++,this.x1=e,this.y1=i,this.x2=r,this.y2=n,this.xloc=a,this.extend=s,this.color=o,this.style=l,this.width=c,this.force_overlay=u,this._deleted=!1}delete(){this._deleted=!0}copy(){return new ti(this.x1,this.y1,this.x2,this.y2,this.xloc,this.extend,this.color,this.style,this.width,this.force_overlay)}toPlotData(){return{id:this.id,x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2,xloc:this.xloc,extend:this.extend,color:this.color,style:this.style,width:this.width,force_overlay:this.force_overlay}}}const Yu=[["x1","y1","x2","y2","xloc","extend","color","style","width","force_overlay"],["first_point","second_point","xloc","extend","color","style","width","force_overlay"]],Qu={x1:"number",y1:"number",x2:"number",y2:"number",xloc:"string",extend:"string",color:"string",style:"string",width:"number",force_overlay:"boolean",first_point:"point",second_point:"point"};class Xu{constructor(e){this.context=e}_lines=[];param(e,i=0,r){return x.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__lines__||(this.context.plots.__lines__={title:"__lines__",data:[],options:{style:"drawing_line",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__lines__.data=[{time:e,value:this._lines,options:{style:"drawing_line"}}]}_resolvePoint(e){return e.index!==void 0?{x:e.index,xloc:"bi"}:e.time!==void 0?{x:e.time,xloc:"bt"}:{x:0,xloc:"bi"}}_resolve(e){return e==null?e:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_createLine(e,i,r,n,a="bi",s="none",o="",l="style_solid",c=1,u=!1){const p=new ti(e,i,r,n,a,this._resolve(s),this._resolve(o),this._resolve(l),this._resolve(c)||1,u);return this._lines.push(p),this._syncToPlot(),p}new(...e){const i=z(e,Yu,Qu);let r,n,a,s,o=i.xloc;if(i.first_point instanceof ne){const l=i.first_point,c=i.second_point,u=this._resolvePoint(l);r=u.x,n=l.price,o=o||u.xloc,c instanceof ne?(a=this._resolvePoint(c).x,s=c.price):(a=0,s=NaN)}else r=i.x1,n=i.y1,a=i.x2,s=i.y2;return this._createLine(r,n,a,s,o,i.extend,i.color,i.style,i.width,i.force_overlay)}any(...e){return this.new(...e)}set_x1(e,i){e&&!e._deleted&&(e.x1=i)}set_y1(e,i){e&&!e._deleted&&(e.y1=i)}set_x2(e,i){e&&!e._deleted&&(e.x2=i)}set_y2(e,i){e&&!e._deleted&&(e.y2=i)}set_xy1(e,i,r){e&&!e._deleted&&(e.x1=i,e.y1=r)}set_xy2(e,i,r){e&&!e._deleted&&(e.x2=i,e.y2=r)}set_color(e,i){e&&!e._deleted&&(e.color=this._resolve(i))}set_width(e,i){e&&!e._deleted&&(e.width=this._resolve(i)||1)}set_style(e,i){e&&!e._deleted&&(e.style=this._resolve(i))}set_extend(e,i){e&&!e._deleted&&(e.extend=this._resolve(i))}set_xloc(e,i,r,n){e&&!e._deleted&&(e.x1=i,e.x2=r,e.xloc=n)}set_first_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.x1=r.x,e.y1=i.price,e.xloc=r.xloc}}set_second_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.x2=r.x,e.y2=i.price,e.xloc=r.xloc}}get_x1(e){return e?e.x1:NaN}get_y1(e){return e?e.y1:NaN}get_x2(e){return e?e.x2:NaN}get_y2(e){return e?e.y2:NaN}get_price(e,i){if(!e||e._deleted)return NaN;if(e.xloc!=="bi")return NaN;const r=e.x2-e.x1;return r===0?e.y1:e.y1+(i-e.x1)/r*(e.y2-e.y1)}copy(e){if(!e)return;const i=e.copy();return this._lines.push(i),this._syncToPlot(),i}delete(e){e&&(e._deleted=!0)}get all(){return this._lines.filter(e=>!e._deleted)}get style_solid(){return"style_solid"}get style_dotted(){return"style_dotted"}get style_dashed(){return"style_dashed"}get style_arrow_left(){return"style_arrow_left"}get style_arrow_right(){return"style_arrow_right"}get style_arrow_both(){return"style_arrow_both"}}let Zu=0;class ii{id;left;top;right;bottom;xloc;extend;border_color;border_style;border_width;bgcolor;text;text_color;text_size;text_halign;text_valign;text_wrap;text_font_family;text_formatting;force_overlay;_deleted;constructor(e,i,r,n,a="bi",s="none",o="#2962ff",l="style_solid",c=1,u="#2962ff",p="",h="#000000",f="auto",m="center",y="center",_="wrap_none",v="default",S="format_none",b=!1){this.id=Zu++,this.left=e,this.top=i,this.right=r,this.bottom=n,this.xloc=a,this.extend=s,this.border_color=o,this.border_style=l,this.border_width=c,this.bgcolor=u,this.text=p,this.text_color=h,this.text_size=f,this.text_halign=m,this.text_valign=y,this.text_wrap=_,this.text_font_family=v,this.text_formatting=S,this.force_overlay=b,this._deleted=!1}delete(){this._deleted=!0}copy(){return new ii(this.left,this.top,this.right,this.bottom,this.xloc,this.extend,this.border_color,this.border_style,this.border_width,this.bgcolor,this.text,this.text_color,this.text_size,this.text_halign,this.text_valign,this.text_wrap,this.text_font_family,this.text_formatting,this.force_overlay)}}const Ju=[["left","top","right","bottom","border_color","border_width","border_style","extend","xloc","bgcolor","text","text_size","text_color","text_halign","text_valign","text_wrap","text_font_family","force_overlay"],["top_left","bottom_right","border_color","border_width","border_style","extend","xloc","bgcolor","text","text_size","text_color","text_halign","text_valign","text_wrap","text_font_family","force_overlay"]],eh={left:"number",top:"number",right:"number",bottom:"number",top_left:"point",bottom_right:"point",border_color:"string",border_width:"number",border_style:"string",extend:"string",xloc:"string",bgcolor:"string",text:"string",text_size:"string",text_color:"string",text_halign:"string",text_valign:"string",text_wrap:"string",text_font_family:"string",force_overlay:"boolean"};class th{constructor(e){this.context=e}_boxes=[];param(e,i=0,r){return x.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__boxes__||(this.context.plots.__boxes__={title:"__boxes__",data:[],options:{style:"drawing_box",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__boxes__.data=[{time:e,value:this._boxes,options:{style:"drawing_box"}}]}_resolvePoint(e){return e.index!==void 0?{x:e.index,xloc:"bi"}:e.time!==void 0?{x:e.time,xloc:"bt"}:{x:0,xloc:"bi"}}_resolve(e){return e==null?e:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_createBox(e,i,r,n,a="bi",s="none",o="#2962ff",l="style_solid",c=1,u="#2962ff",p="",h="#000000",f="auto",m="center",y="center",_="wrap_none",v="default",S="format_none",b=!1){const E=new ii(e,i,r,n,a,this._resolve(s),this._resolve(o)||"#2962ff",this._resolve(l)||"style_solid",this._resolve(c)??1,this._resolve(u)||"#2962ff",this._resolve(p)||"",this._resolve(h)||"#000000",this._resolve(f)||"auto",this._resolve(m)||"center",this._resolve(y)||"center",this._resolve(_)||"wrap_none",this._resolve(v)||"default",this._resolve(S)||"format_none",b);return this._boxes.push(E),this._syncToPlot(),E}new(...e){const i=z(e,Ju,eh);let r,n,a,s,o=i.xloc;if(i.top_left instanceof ne){const l=i.top_left,c=i.bottom_right,u=this._resolvePoint(l);r=u.x,n=l.price,o=o||u.xloc,c instanceof ne?(a=this._resolvePoint(c).x,s=c.price):(a=0,s=NaN)}else r=this._resolve(i.left),n=this._resolve(i.top),a=this._resolve(i.right),s=this._resolve(i.bottom);return this._createBox(r,n,a,s,o,i.extend,i.border_color,i.border_style,i.border_width,i.bgcolor,i.text,i.text_color,i.text_size,i.text_halign,i.text_valign,i.text_wrap,i.text_font_family,void 0,i.force_overlay)}any(...e){return this.new(...e)}set_left(e,i){e&&!e._deleted&&(e.left=i)}set_right(e,i){e&&!e._deleted&&(e.right=i)}set_top(e,i){e&&!e._deleted&&(e.top=i)}set_bottom(e,i){e&&!e._deleted&&(e.bottom=i)}set_lefttop(e,i,r){e&&!e._deleted&&(e.left=i,e.top=r)}set_rightbottom(e,i,r){e&&!e._deleted&&(e.right=i,e.bottom=r)}set_top_left_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.left=r.x,e.top=i.price,e.xloc=r.xloc}}set_bottom_right_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.right=r.x,e.bottom=i.price,e.xloc=r.xloc}}set_xloc(e,i,r,n){e&&!e._deleted&&(e.left=i,e.right=r,e.xloc=n)}set_bgcolor(e,i){e&&!e._deleted&&(e.bgcolor=this._resolve(i))}set_border_color(e,i){e&&!e._deleted&&(e.border_color=this._resolve(i))}set_border_width(e,i){e&&!e._deleted&&(e.border_width=this._resolve(i)??1)}set_border_style(e,i){e&&!e._deleted&&(e.border_style=this._resolve(i))}set_extend(e,i){e&&!e._deleted&&(e.extend=this._resolve(i))}set_text(e,i){e&&!e._deleted&&(e.text=this._resolve(i)||"")}set_text_color(e,i){e&&!e._deleted&&(e.text_color=this._resolve(i))}set_text_size(e,i){e&&!e._deleted&&(e.text_size=this._resolve(i))}set_text_halign(e,i){e&&!e._deleted&&(e.text_halign=this._resolve(i))}set_text_valign(e,i){e&&!e._deleted&&(e.text_valign=this._resolve(i))}set_text_wrap(e,i){e&&!e._deleted&&(e.text_wrap=this._resolve(i))}set_text_font_family(e,i){e&&!e._deleted&&(e.text_font_family=this._resolve(i))}set_text_formatting(e,i){e&&!e._deleted&&(e.text_formatting=this._resolve(i))}get_left(e){return e?e.left:NaN}get_right(e){return e?e.right:NaN}get_top(e){return e?e.top:NaN}get_bottom(e){return e?e.bottom:NaN}copy(e){if(!e)return;const i=e.copy();return this._boxes.push(i),this._syncToPlot(),i}delete(e){e&&(e._deleted=!0)}get all(){return this._boxes.filter(e=>!e._deleted)}}let ih=0;class rh{id;line1;line2;color;_deleted;constructor(e,i,r){this.id=ih++,this.line1=e,this.line2=i,this.color=r,this._deleted=!1}delete(){this._deleted=!0}}class nh{constructor(e){this.context=e}_linefills=[];param(e,i=0,r){return x.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__linefills__||(this.context.plots.__linefills__={title:"__linefills__",data:[],options:{style:"linefill",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__linefills__.data=[{time:e,value:this._linefills,options:{style:"linefill"}}]}_resolve(e){return e==null?e:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}new(e,i,r){const n=this._resolve(r)||"",a=new rh(e,i,n);return this._linefills.push(a),this._syncToPlot(),a}any(...e){return this.new(e[0],e[1],e[2])}set_color(e,i){e&&!e._deleted&&(e.color=this._resolve(i)||"")}get_line1(e){return e?e.line1:void 0}get_line2(e){return e?e.line2:void 0}delete(e){e&&(e._deleted=!0)}get all(){return this._linefills.filter(e=>!e._deleted)}}let sh=0;class ah{id;points;curved;closed;xloc;line_color;fill_color;line_style;line_width;force_overlay;_deleted;constructor(e,i=!1,r=!1,n="bi",a="#2962ff",s="",o="style_solid",l=1,c=!1){this.id=sh++,this.points=e,this.curved=i,this.closed=r,this.xloc=n,this.line_color=a,this.fill_color=s,this.line_style=o,this.line_width=l,this.force_overlay=c,this._deleted=!1}delete(){this._deleted=!0}}class oh{constructor(e){this.context=e}_polylines=[];param(e,i=0,r){return x.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__polylines__||(this.context.plots.__polylines__={title:"__polylines__",data:[],options:{style:"drawing_polyline",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__polylines__.data=[{time:e,value:this._polylines,options:{style:"drawing_polyline"}}]}_resolve(e){return e==null?e:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_extractPoints(e){const i=e&&e.array?e.array:e;return Array.isArray(i)?i.filter(r=>r instanceof ne):[]}new(...e){const i=e[0];let r=!1,n=!1,a="bi",s="#2962ff",o="",l="style_solid",c=1,u=!1;if(e.length===2&&e[1]&&typeof e[1]=="object"&&!Array.isArray(e[1])&&("curved"in e[1]||"closed"in e[1]||"line_color"in e[1]||"fill_color"in e[1]||"line_style"in e[1]||"line_width"in e[1])){const f=e[1];r=f.curved??r,n=f.closed??n,a=f.xloc??a,s=f.line_color??s,o=f.fill_color??o,l=f.line_style??l,c=f.line_width??c,u=f.force_overlay??u}else r=e[1]??r,n=e[2]??n,a=e[3]??a,s=e[4]??s,o=e[5]??o,l=e[6]??l,c=e[7]??c,u=e[8]??u;const p=this._extractPoints(i),h=new ah(p,this._resolve(r)??!1,this._resolve(n)??!1,this._resolve(a)||"bi",this._resolve(s)||"#2962ff",this._resolve(o)||"",this._resolve(l)||"style_solid",this._resolve(c)||1,this._resolve(u)??!1);return this._polylines.push(h),this._syncToPlot(),h}any(...e){return this.new(...e)}delete(e){e&&(e._deleted=!0)}get all(){return this._polylines.filter(e=>!e._deleted)}}let lh=0;class ch{id;position;columns;rows;bgcolor;frame_color;frame_width;border_color;border_width;force_overlay;_deleted;cells;merges;constructor(e="top_right",i=1,r=1,n="",a="",s=0,o="",l=0,c=!1){this.id=lh++,this.position=e,this.columns=i,this.rows=r,this.bgcolor=n,this.frame_color=a,this.frame_width=s,this.border_color=o,this.border_width=l,this.force_overlay=c,this._deleted=!1,this.merges=[],this.cells=[];for(let u=0;u<r;u++){this.cells[u]=[];for(let p=0;p<i;p++)this.cells[u][p]=null}}delete(){this._deleted=!0}setCell(e,i,r){if(i<0||i>=this.rows||e<0||e>=this.columns)return;const n=this.cells[i][e];if(n&&n._merged&&n._merge_parent){const[s,o]=n._merge_parent;this.setCell(s,o,r);return}const a=n||this._defaultCell();Object.assign(a,r),this.cells[i][e]=a}getCell(e,i){return i<0||i>=this.rows||e<0||e>=this.columns?null:this.cells[i][e]}clearCell(e,i){i<0||i>=this.rows||e<0||e>=this.columns||(this.cells[i][e]=null)}_defaultCell(){return{text:"",width:0,height:0,text_color:"#000000",text_halign:"center",text_valign:"center",text_size:"normal",bgcolor:"",tooltip:"",text_font_family:"default",_merged:!1,_merge_parent:null}}}class uh{constructor(e){this.context=e}_tables=[];param(e,i=0,r){return x.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__tables__||(this.context.plots.__tables__={title:"__tables__",data:[],options:{style:"table",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__tables__.data=[{time:e,value:this._tables,options:{style:"table"}}]}_resolve(e){return e==null?e:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}new(...e){let i="top_right",r=1,n=1,a="",s="",o=0,l="",c=0,u=!1;const p=e[e.length-1];if(p&&typeof p=="object"&&!Array.isArray(p)&&("bgcolor"in p||"frame_color"in p||"border_color"in p||"position"in p||"columns"in p||"rows"in p)){const f=p,m=e.slice(0,-1);i=m[0]??f.position??i,r=m[1]??f.columns??r,n=m[2]??f.rows??n,a=f.bgcolor??a,s=f.frame_color??s,o=f.frame_width??o,l=f.border_color??l,c=f.border_width??c,u=f.force_overlay??u}else i=e[0]??i,r=e[1]??r,n=e[2]??n,a=e[3]??a,s=e[4]??s,o=e[5]??o,l=e[6]??l,c=e[7]??c,u=e[8]??u;const h=new ch(this._resolve(i)||"top_right",this._resolve(r)||1,this._resolve(n)||1,this._resolve(a)||"",this._resolve(s)||"",this._resolve(o)||0,this._resolve(l)||"",this._resolve(c)||0,this._resolve(u)??!1);return this._tables.push(h),this._syncToPlot(),h}any(...e){return this.new(...e)}cell(...e){let i,r,n,a="",s=0,o=0,l="#000000",c="center",u="center",p="normal",h="",f="",m="default";const y=e[e.length-1];if(y&&typeof y=="object"&&!Array.isArray(y)&&("text"in y||"bgcolor"in y||"text_color"in y||"text_size"in y||"text_halign"in y||"tooltip"in y||"column"in y||"row"in y)){const b=y,E=e.slice(0,-1);i=E[0],r=E.length>1?E[1]:b.column??0,n=E.length>2?E[2]:b.row??0,a=E[3]??b.text??a,s=E[4]??b.width??s,o=E[5]??b.height??o,l=E[6]??b.text_color??l,c=E[7]??b.text_halign??c,u=E[8]??b.text_valign??u,p=E[9]??b.text_size??p,h=E[10]??b.bgcolor??h,f=E[11]??b.tooltip??f,m=E[12]??b.text_font_family??m}else i=e[0],r=e[1]??0,n=e[2]??0,a=e[3]??a,s=e[4]??s,o=e[5]??o,l=e[6]??l,c=e[7]??c,u=e[8]??u,p=e[9]??p,h=e[10]??h,f=e[11]??f,m=e[12]??m;const _=this._resolve(i);if(!_||_._deleted)return;const v=this._resolve(r)??0,S=this._resolve(n)??0;_.setCell(v,S,{text:this._resolveText(this._resolve(a)),width:this._resolve(s)||0,height:this._resolve(o)||0,text_color:this._resolve(l)||"#000000",text_halign:this._resolve(c)||"center",text_valign:this._resolve(u)||"center",text_size:this._resolve(p)||"normal",bgcolor:this._resolve(h)||"",tooltip:this._resolveText(this._resolve(f)),text_font_family:this._resolve(m)||"default"}),this._syncToPlot()}delete(e){e&&(e._deleted=!0)}clear(...e){let i,r,n,a,s;const o=e[e.length-1];if(o&&typeof o=="object"&&!Array.isArray(o)&&("start_column"in o||"start_row"in o||"end_column"in o)){const f=o;i=e[0],r=e.length>2?e[1]:f.start_column??0,n=e.length>3?e[2]:f.start_row??0,a=f.end_column??(e.length>4?e[3]:r),s=f.end_row??(e.length>5?e[4]:n)}else i=e[0],r=e[1]??0,n=e[2]??0,a=e[3]??r,s=e[4]??n;const l=this._resolve(i);if(!l||l._deleted)return;const c=this._resolve(r)??0,u=this._resolve(n)??0,p=this._resolve(a)??c,h=this._resolve(s)??u;for(let f=u;f<=h;f++)for(let m=c;m<=p;m++)l.clearCell(m,f);this._syncToPlot()}merge_cells(...e){let i,r,n,a,s;const o=e[e.length-1];if(o&&typeof o=="object"&&!Array.isArray(o)&&("start_column"in o||"start_row"in o||"end_column"in o)){const f=o;i=e[0],r=e.length>2?e[1]:f.start_column??0,n=e.length>3?e[2]:f.start_row??0,a=f.end_column??(e.length>4?e[3]:0),s=f.end_row??(e.length>5?e[4]:0)}else i=e[0],r=e[1]??0,n=e[2]??0,a=e[3]??0,s=e[4]??0;const l=this._resolve(i);if(!l||l._deleted)return;const c=this._resolve(r)??0,u=this._resolve(n)??0,p=this._resolve(a)??0,h=this._resolve(s)??0;for(let f=u;f<=h;f++)for(let m=c;m<=p;m++)f===u&&m===c||l.setCell(m,f,{_merged:!0,_merge_parent:[c,u]});l.merges.push({startCol:c,startRow:u,endCol:p,endRow:h}),this._syncToPlot()}cell_set_text(e,i,r,n){this._setCellProp(e,i,r,"text",n,!0)}cell_set_bgcolor(e,i,r,n){this._setCellProp(e,i,r,"bgcolor",n)}cell_set_text_color(e,i,r,n){this._setCellProp(e,i,r,"text_color",n)}cell_set_text_size(e,i,r,n){this._setCellProp(e,i,r,"text_size",n)}cell_set_height(e,i,r,n){this._setCellProp(e,i,r,"height",n)}cell_set_width(e,i,r,n){this._setCellProp(e,i,r,"width",n)}cell_set_tooltip(e,i,r,n){this._setCellProp(e,i,r,"tooltip",n,!0)}cell_set_text_halign(e,i,r,n){this._setCellProp(e,i,r,"text_halign",n)}cell_set_text_valign(e,i,r,n){this._setCellProp(e,i,r,"text_valign",n)}cell_set_text_font_family(e,i,r,n){this._setCellProp(e,i,r,"text_font_family",n)}set_position(e,i){const r=this._resolve(e);!r||r._deleted||(r.position=this._resolve(i)||r.position,this._syncToPlot())}set_bgcolor(e,i){const r=this._resolve(e);!r||r._deleted||(r.bgcolor=this._resolve(i)||"",this._syncToPlot())}set_border_color(e,i){const r=this._resolve(e);!r||r._deleted||(r.border_color=this._resolve(i)||"",this._syncToPlot())}set_border_width(e,i){const r=this._resolve(e);!r||r._deleted||(r.border_width=this._resolve(i)||0,this._syncToPlot())}set_frame_color(e,i){const r=this._resolve(e);!r||r._deleted||(r.frame_color=this._resolve(i)||"",this._syncToPlot())}set_frame_width(e,i){const r=this._resolve(e);!r||r._deleted||(r.frame_width=this._resolve(i)||0,this._syncToPlot())}get all(){return this._tables.filter(e=>!e._deleted)}_setCellProp(e,i,r,n,a,s=!1){const o=this._resolve(e);if(!o||o._deleted)return;const l=this._resolve(i)??0,c=this._resolve(r)??0,u=this._resolve(a);o.setCell(l,c,{[n]:s?this._resolveText(u):u}),this._syncToPlot()}_resolveText(e){return e==null||e!==e?"":String(e)}}class Ze{data={open:new x([]),high:new x([]),low:new x([]),close:new x([]),volume:new x([]),hl2:new x([]),hlc3:new x([]),ohlc4:new x([]),hlcc4:new x([])};indicator;cache={};taState={};isSecondaryContext=!1;NA=NaN;lang;length=0;pine;static _deprecationWarningsShown=new Set;idx=0;params={};const={};var={};let={};lctx=new Map;result=void 0;plots={};marketData;source;tickerId;timeframe="";limit;sDate;eDate;fullContext;pineTSCode;inputs={};constructor({marketData:e,source:i,tickerId:r,timeframe:n,limit:a,sDate:s,eDate:o,fullContext:l,inputs:c}){this.marketData=e,this.source=i,this.tickerId=r,this.timeframe=n,this.limit=a,this.sDate=s,this.eDate=o,this.fullContext=l||this,this.inputs=c||{};const u=new il(this),p={Type:u.Type.bind(u),na:new tl,color:u.color,nz:u.nz.bind(u),indicator:u.indicator.bind(u),fixnan:u.fixnan.bind(u),alertcondition:u.alertcondition.bind(u),timestamp:u.timestamp.bind(u),time:new Ai(this,"openTime"),time_close:new Ai(this,"closeTime"),dayofmonth:new Re(this,Me.dayofmonth),dayofweek:new Re(this,Me.dayofweek),hour:new Re(this,Me.hour),minute:new Re(this,Me.minute),month:new Re(this,Me.month),second:new Re(this,Me.second),weekofyear:new Re(this,Me.weekofyear),year:new Re(this,Me.year),bool:u.bool.bind(u),int:u.int.bind(u),float:u.float.bind(u),string:u.string.bind(u)},h=this;this.pine={input:new Cl(this),ta:new Eu(this),math:new sc(this),request:new uc(this),array:new Da(this),map:new Ha(this),matrix:new Ko(this),syminfo:null,timeframe:new Iu(this),barstate:new zo(this),get bar_index(){return h.idx},get last_bar_index(){return h.data.close.length-1},get last_bar_time(){return h.data.openTime.get(h.data.openTime.length-1)},get timenow(){return new Date().getTime()},get time_tradingday(){const M=x.from(h.data.openTime).get(0);if(isNaN(M))return NaN;const $=h.pine?.syminfo?.timezone||"UTC",q=yt(M,$);return Date.UTC(q.year,q.month-1,q.day,0,0,0)},get inputs(){return h.inputs},log:new Nu(this),str:new Cu(this),...p,...xa};const f=p.dayofweek;Object.assign(f,{sunday:1,monday:2,tuesday:3,wednesday:4,thursday:5,friday:6,saturday:7}),this.pine.dayofweek=f;const m=new ju(this),y=new Wu(this),_=new $u(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(y,["any","style_dashed","style_solid","style_dotted","param"],"hline"),this.bindContextObject(_,["any","param"],"fill");const v=new Uu(this);this.pine.chart={param:v.param.bind(v),bg_color:v.bg_color.bind(v),fg_color:v.fg_color.bind(v),is_standard:v.is_standard.bind(v),is_heikinashi:v.is_heikinashi.bind(v),is_kagi:v.is_kagi.bind(v),is_linebreak:v.is_linebreak.bind(v),is_pnf:v.is_pnf.bind(v),is_range:v.is_range.bind(v),is_renko:v.is_renko.bind(v),point:v.point};const S=new zu(this);this.bindContextObject(S,["any","new","param","set_x","set_y","set_xy","set_text","set_color","set_textcolor","set_size","set_style","set_textalign","set_tooltip","set_point","set_xloc","set_yloc","get_x","get_y","get_text","copy","delete","style_label_down","style_label_up","style_label_left","style_label_right","style_label_lower_left","style_label_lower_right","style_label_upper_left","style_label_upper_right","style_label_center","style_circle","style_square","style_diamond","style_flag","style_arrowup","style_arrowdown","style_cross","style_xcross","style_triangleup","style_triangledown","style_none","style_text_outline"],"label"),Object.defineProperty(this.pine.label,"all",{get:()=>S.all});const b=new Xu(this);this.bindContextObject(b,["any","new","param","set_x1","set_y1","set_x2","set_y2","set_xy1","set_xy2","set_color","set_width","set_style","set_extend","set_xloc","set_first_point","set_second_point","get_x1","get_y1","get_x2","get_y2","get_price","copy","delete","style_solid","style_dotted","style_dashed","style_arrow_left","style_arrow_right","style_arrow_both"],"line"),Object.defineProperty(this.pine.line,"all",{get:()=>b.all});const E=new th(this);this.bindContextObject(E,["any","new","param","copy","delete","set_left","set_right","set_top","set_bottom","set_lefttop","set_rightbottom","set_top_left_point","set_bottom_right_point","set_bgcolor","set_border_color","set_border_width","set_border_style","set_extend","set_xloc","set_text","set_text_color","set_text_size","set_text_halign","set_text_valign","set_text_wrap","set_text_font_family","set_text_formatting","get_left","get_right","get_top","get_bottom"],"box"),Object.defineProperty(this.pine.box,"all",{get:()=>E.all});const N=new nh(this);this.bindContextObject(N,["any","new","param","set_color","get_line1","get_line2","delete"],"linefill"),Object.defineProperty(this.pine.linefill,"all",{get:()=>N.all});const T=new oh(this);this.bindContextObject(T,["any","new","param","delete"],"polyline"),Object.defineProperty(this.pine.polyline,"all",{get:()=>T.all});const P=new uh(this);this.bindContextObject(P,["any","new","param","cell","delete","clear","merge_cells","cell_set_text","cell_set_bgcolor","cell_set_text_color","cell_set_text_size","cell_set_height","cell_set_width","cell_set_tooltip","cell_set_text_halign","cell_set_text_valign","cell_set_text_font_family","set_position","set_bgcolor","set_border_color","set_border_width","set_frame_color","set_frame_width"],"table"),Object.defineProperty(this.pine.table,"all",{get:()=>P.all})}bindContextObject(e,i,r=""){r&&!this.pine[r]&&(this.pine[r]={});const n=r?this.pine[r]:this.pine;for(const a of i)typeof e[a]=="function"?n[a]=e[a].bind(e):n[a]=e[a]}init(e,i,r=0){let n;return i instanceof x?n=i.get(0):Array.isArray(i)?Array.isArray(i[0])?n=i[0]:n=i[i.length-1+r]:n=i,e?e instanceof x?(e.data[e.data.length-1]=n,e):Array.isArray(e)?(e[e.length-1]=n,new x(e)):new x([n]):new x([n])}initVar(e,i){if(e)return e;typeof i=="function"&&(i=i());let r;return i instanceof x?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 x([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 x?i?new x(e.data,e.offset+i):e:!Array.isArray(e)&&typeof e=="object"?e:(this.params[r]||(this.params[r]=[]),Array.isArray(e)?new x(e,i||0):(this.params[r].length===0?this.params[r].push(e):this.params[r][this.params[r].length-1]=e,new x(this.params[r],0)))}get(e,i){if(e instanceof x)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 x){e.set(0,i);return}if(Array.isArray(e)){e.length>0?e[e.length-1]=i:e.push(i);return}}_callStack=[];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}`;Ze._deprecationWarningsShown.has(r)||(Ze._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`))}}class qt{source;inputs;constructor(e,i={}){this.source=e,this.inputs=i}}class ri{constructor(e,i,r,n,a,s){this.source=e,this.tickerId=i,this.timeframe=r,this.limit=n,this.sDate=a,this.eDate=s,this._readyPromise=new Promise(o=>{this.loadMarketData(e,i,r,n,a,s).then(l=>{const c=l;this.data=c;const u=c.map(N=>N.open),p=c.map(N=>N.close),h=c.map(N=>N.high),f=c.map(N=>N.low),m=c.map(N=>N.volume),y=c.map(N=>(N.high+N.low+N.close)/3),_=c.map(N=>(N.high+N.low)/2),v=c.map(N=>(N.high+N.low+N.open+N.close)/4),S=c.map(N=>(N.high+N.low+N.close+N.close)/4),b=c.map(N=>N.openTime),E=c.map(N=>N.closeTime);this.open=u,this.close=p,this.high=h,this.low=f,this.volume=m,this.hl2=_,this.hlc3=y,this.ohlc4=v,this.hlcc4=S,this.openTime=b,this.closeTime=E,e&&e.getSymbolInfo?e.getSymbolInfo(i).then(N=>{this._syminfo=N,this._ready=!0,o(!0)}).catch(N=>{console.warn("Failed to get symbol info, using default values:",N),this._ready=!0,o(!0)}):(this._ready=!0,o(!0))})})}data=[];open=[];high=[];low=[];close=[];volume=[];hl2=[];hlc3=[];ohlc4=[];hlcc4=[];openTime=[];closeTime=[];_readyPromise=null;_ready=!1;_debugSettings={ln:!1,debug:!1};_transpiledCode=null;get transpiledCode(){return this._transpiledCode}_isSecondaryContext=!1;markAsSecondary(){this._isSecondaryContext=!0}_syminfo;setDebugSettings({ln:e,debug:i}){this._debugSettings.ln=e,this._debugSettings.debug=i}async loadMarketData(e,i,r,n,a,s){return Array.isArray(e)?e:e.getMarketData(i,r,n,a,s)}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 n,a={};if(e instanceof qt?(n=e.source,a=e.inputs||{}):n=e,r&&r>0){const s=typeof this.eDate>"u"&&!Array.isArray(this.source);return this._runPaginated(n,a,i,r,s)}else return this._runComplete(n,a,i)}stream(e,i={}){const{live:r=!0,interval:n=1e3}=i,a=i.pageSize||this.data.length;let s,o={};e instanceof qt?(s=e.source,o=e.inputs||{}):s=e;const l={data:[],error:[]};let c=!1;const u=(f,...m)=>{l[f]&&l[f].forEach(y=>y(...m))},p=(f,m)=>{l[f]||(l[f]=[]),l[f].push(m)},h=()=>{c=!0};return(async()=>{try{const f=typeof this.eDate>"u"&&!Array.isArray(this.source)&&r,m=this._runPaginated(s,o,void 0,a,f);for await(const y of m){if(c)break;if(y===null){await new Promise(_=>setTimeout(_,n));continue}if(u("data",y),f&&!c){const _=y.marketData[y.idx];_&&_.closeTime<Date.now()||await new Promise(v=>setTimeout(v,n))}}}catch(f){u("error",f)}})(),{on:p,stop:h}}async _runComplete(e,i,r){await this.ready(),r||(r=this.data.length);const n=this._initializeContext(e,i,this._isSecondaryContext);return this._transpiledCode=this._transpileCode(e),await this._executeIterations(n,this._transpiledCode,this.data.length-r,this.data.length),n}async*_runPaginated(e,i,r,n,a=!1){await this.ready(),r||(r=this.data.length);const s=this._initializeContext(e,i,this._isSecondaryContext);this._transpiledCode=this._transpileCode(e);let o=this.data.length-r;for(;;){const l=this.data.length-o;if(l>0){const p=Math.min(l,n),h=this._getResultLength(s.result);await this._executeIterations(s,this._transpiledCode,o,o+p),o+=p,yield this._createPageContext(s,h);continue}if(!a||Array.isArray(this.source))break;const{newCandles:c,updatedLastCandle:u}=await this._updateMarketData();if(c===0&&!u){yield null;continue}this._removeLastResult(s),o=this.data.length-(c+1),s.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 Ze({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 n in e.result)Array.isArray(e.result[n])?r.result[n]=e.result[n].slice(i):r.result[n]=e.result[n]}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,n=this.data[r].openTime;try{const a=await i.getMarketData(this.tickerId,this.timeframe,void 0,n,e);if(!a||a.length===0)return{newCandles:0,updatedLastCandle:!1};let s=!1,o=0;for(let l=0;l<a.length;l++){const c=a[l];c.openTime===n?(this._replaceCandle(r,c),s=!0):c.openTime>n&&(this._appendCandle(c),o++)}return{newCandles:o,updatedLastCandle:s}}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 n in e.result)Array.isArray(e.result[n])&&e.result[n].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=n=>{for(let a of i)if(n[a])for(let s in n[a]){const o=n[a][s];o instanceof x?o.data.pop():Array.isArray(o)&&o.pop()}};r(e),e.lctx&&e.lctx.forEach(n=>r(n))}_initializeContext(e,i={},r=!1){const n=new Ze({marketData:this.data,source:this.source,tickerId:this.tickerId,timeframe:this.timeframe,limit:this.limit,sDate:this.sDate,eDate:this.eDate,inputs:i});return n.pine.syminfo=this._syminfo,n.pineTSCode=e,n.isSecondaryContext=r,n.data.close=new x([]),n.data.open=new x([]),n.data.high=new x([]),n.data.low=new x([]),n.data.volume=new x([]),n.data.hl2=new x([]),n.data.hlc3=new x([]),n.data.ohlc4=new x([]),n.data.hlcc4=new x([]),n.data.openTime=new x([]),n.data.closeTime=new x([]),n.length=this.data.length,n}_transpileCode(e){return Ds.bind(this)(e,this._debugSettings)}async _executeIterations(e,i,r,n){const a=["const","var","let","params"];for(let s=r;s<n;s++){e.idx=s,e.data.close.data.push(this.close[s]),e.data.open.data.push(this.open[s]),e.data.high.data.push(this.high[s]),e.data.low.data.push(this.low[s]),e.data.volume.data.push(this.volume[s]),e.data.hl2.data.push(this.hl2[s]),e.data.hlc3.data.push(this.hlc3[s]),e.data.ohlc4.data.push(this.ohlc4[s]),e.data.hlcc4.data.push(this.hlcc4[s]),e.data.openTime.data.push(this.openTime[s]),e.data.closeTime.data.push(this.closeTime[s]);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 u;o[c]instanceof x?u=o[c].get(0):Array.isArray(o[c])?u=o[c][o[c].length-1]:u=o[c],e.result[c].push(u)}}else Array.isArray(e.result)||(e.result=[]),e.result.push(o);const l=c=>{for(let u of a)if(c[u])for(let p in c[u]){const h=c[u][p];if(h instanceof x){const f=h.get(0);h.data.push(f)}else if(Array.isArray(h)){const f=h[h.length-1];h.push(f)}}};l(e),e.lctx&&e.lctx.forEach(c=>l(c))}}}const Rt="https://api.binance.com/api/v3",Li="https://api.binance.us/api/v3",Mt={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 hh{cache;cacheDuration;constructor(e=300*1e3){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 ph{cacheManager;activeApiUrl=null;constructor(){this.cacheManager=new hh(300*1e3)}async getBaseUrl(){if(this.activeApiUrl)return this.activeApiUrl;try{const e=new AbortController,i=setTimeout(()=>e.abort(),5e3),r=await fetch(`${Rt}/ping`,{signal:e.signal});if(clearTimeout(i),r.ok)return this.activeApiUrl=Rt,this.activeApiUrl}catch{}try{const e=new AbortController,i=setTimeout(()=>e.abort(),5e3),r=await fetch(`${Li}/ping`,{signal:e.signal});if(clearTimeout(i),r.ok)return this.activeApiUrl=Li,this.activeApiUrl}catch{}return Rt}async getMarketDataInterval(e,i,r,n){try{const a=Mt[i.toUpperCase()];if(!a)return console.error(`Unsupported timeframe: ${i}`),[];const s={"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=[],l=r;const c=n,u=s[a];if(!u)return console.error(`Duration not defined for interval: ${a}`),[];for(;l<c;){const p=Math.min(l+1e3*u,c),h=await this.getMarketData(e,i,1e3,l,p);if(h.length===0)break;o=o.concat(h),l=h[h.length-1].closeTime+1}return o}catch(a){return console.error("Error in getMarketDataInterval:",a),[]}}async getMarketDataBackwards(e,i,r,n){let a=r,s=[],o=n,l=0;const c=Math.ceil(r/1e3)+5;for(;a>0&&l<c;){l++;const u=Math.min(a,1e3),p=await this.getMarketData(e,i,u,void 0,o);if(p.length===0||(s=p.concat(s),a-=p.length,o=p[0].openTime-1,p.length<u))break}return s}async getMarketData(e,i,r,n,a){try{const s=a!==void 0,o={tickerId:e,timeframe:i,limit:r,sDate:n,eDate:a};if(s){const h=this.cacheManager.get(o);if(h)return h}const l=Mt[i.toUpperCase()];if(!l)return console.error(`Unsupported timeframe: ${i}`),[];if(this.shouldPaginate(i,r,n,a)){if(n&&a){const h=await this.getMarketDataInterval(e,i,n,a),f=r?h.slice(0,r):h;return this.cacheManager.set(o,f),f}else if(r&&r>1e3){const h=await this.getMarketDataBackwards(e,i,r,a);return this.cacheManager.set(o,h),h}}let c=`${await this.getBaseUrl()}/klines?symbol=${e}&interval=${l}`;r&&(c+=`&limit=${Math.min(r,1e3)}`),n&&(c+=`&startTime=${n}`),a&&(c+=`&endTime=${a}`);const u=await fetch(c);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);const p=(await u.json()).map(h=>({openTime:parseInt(h[0]),open:parseFloat(h[1]),high:parseFloat(h[2]),low:parseFloat(h[3]),close:parseFloat(h[4]),volume:parseFloat(h[5]),closeTime:parseInt(h[6]),quoteAssetVolume:parseFloat(h[7]),numberOfTrades:parseInt(h[8]),takerBuyBaseAssetVolume:parseFloat(h[9]),takerBuyQuoteAssetVolume:parseFloat(h[10]),ignore:h[11]}));return s&&this.cacheManager.set(o,p),p}catch(s){return console.error("Error in binance.klines:",s),[]}}shouldPaginate(e,i,r,n){if(i&&i>1e3)return!0;if(r&&n){const a=Mt[e.toUpperCase()],s={"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(s)return Math.ceil((n-r)/s)>1e3}return!1}async getSymbolInfo(e){try{let i="crypto",r=await this.getBaseUrl(),n=e,a="";e.endsWith(".P")?(i="futures",n=e.replace(".P",""),r="https://fapi.binance.com/fapi/v1",a="Perpetual"):e.includes("_")&&(i="futures",n=e,r="https://dapi.binance.com/dapi/v1",a="Delivery");const s=i==="crypto"?`${r}/exchangeInfo?symbol=${n}`:`${r}/exchangeInfo`,o=await fetch(s);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);const l=(await o.json()).symbols;if(!l||l.length===0)return console.error(`Symbol ${e} not found`),null;const c=i==="futures"?l.find(b=>b.symbol===n):l[0];if(!c)return console.error(`Symbol ${n} not found in exchange info`),null;const u=c.filters?.find(b=>b.filterType==="PRICE_FILTER"),p=c.filters?.find(b=>b.filterType==="LOT_SIZE"),h=u?parseFloat(u.tickSize):.01,f=p?parseFloat(p.minQty):0,m=Math.round(1/h),y=c.baseAsset,_=c.quoteAsset,v=a?` ${a}`:"",S=`${y} / ${_}${v}`;return{ticker:e,tickerid:`BINANCE:${e}`,prefix:"BINANCE",root:y,description:S,type:i,main_tickerid:`BINANCE:${e}`,current_contract:a,isin:"",basecurrency:y,currency:_,timezone:"Etc/UTC",country:"",mintick:h,pricescale:m,minmove:1,pointvalue:c.contractSize||1,mincontract:f,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}}configure(e){}}const fh=Jr.fileURLToPath(typeof document>"u"?new(require("url")).URL("file:"+__filename).href:document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||new URL("pinets.min.cjs",document.baseURI).href),dh=rt.dirname(fh);class mh{dataCache=new Map;exchangeInfoCache={};dataDirectory;constructor(e){if(e)this.dataDirectory=e;else{const i=rt.resolve(dh,"../../../");this.dataDirectory=rt.join(i,"tests","compatibility","_data")}}configure({dataDirectory:e}){e&&(this.dataDirectory=e)}getDataFileName(e,i,r,n){return r&&n?`${e}-${i}-${r}-${n}.json`:null}loadDataFromFile(e){const i=`file:${e}`;if(this.dataCache.has(i))return this.dataCache.get(i);const r=rt.join(this.dataDirectory,e);if(!Ye.existsSync(r))throw new Error(`Mock data file not found: ${r}`);const n=Ye.readFileSync(r,"utf-8"),a=JSON.parse(n);return this.dataCache.set(i,a),a}findDataFile(e,i,r,n){if(!Ye.existsSync(this.dataDirectory))return null;const a=Ye.readdirSync(this.dataDirectory).filter(l=>l.endsWith(".json"));if(r&&n){const l=`${e}-${i}-${r}-${n}.json`;if(a.includes(l))return l}const s=new RegExp(`^${e}-${i}-(\\d+)-(\\d+)\\.json$`),o=a.filter(l=>s.test(l)).map(l=>{const c=l.match(s);return{file:l,startTime:parseInt(c[1]),endTime:parseInt(c[2])}}).sort((l,c)=>c.endTime-l.endTime);if(o.length===0)return null;if(r&&n){const l=o.find(c=>c.startTime<=r&&c.endTime>=n);if(l)return l.file}return o[0].file}filterData(e,i,r,n){let a=e;return(i||r)&&(a=e.filter(s=>{const o=!i||s.openTime>=i,l=!r||s.openTime<=r;return o&&l})),a.sort((s,o)=>s.openTime-o.openTime),n&&n>0&&(a=a.slice(0,n)),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,n,a){try{const s=this.normalizeTimeframe(i),o=this.findDataFile(e,s,n,a);if(!o)return console.warn(`No mock data file found for ${e} ${s}. Searched in: ${this.dataDirectory}`),[];const l=this.loadDataFromFile(o);return this.filterData(l,n,a,r)}catch(s){return console.error("Error in MockProvider.getMarketData:",s),[]}}loadExchangeInfo(e){if(this.exchangeInfoCache[e])return this.exchangeInfoCache[e];const i=e==="spot"?"api-exchangeInfo.json":"fapi-exchangeInfo.json",r=rt.join(this.dataDirectory,i);if(!Ye.existsSync(r))return console.warn(`Exchange info file not found: ${r}`),null;try{const n=Ye.readFileSync(r,"utf-8"),a=JSON.parse(n);return this.exchangeInfoCache[e]=a,a}catch(n){return console.error(`Error loading exchange info from ${i}:`,n),null}}async getSymbolInfo(e){try{let i="crypto",r=e,n="";e.endsWith(".P")?(i="futures",r=e.replace(".P",""),n="Perpetual"):e.includes("_")&&(i="futures",r=e,n="Delivery");const a=this.loadExchangeInfo(i==="futures"?"futures":"spot");if(!a||!a.symbols)return console.error(`Exchange info not available for ${i}`),null;const s=a.symbols.find(_=>_.symbol===r);if(!s)return console.error(`Symbol ${r} not found in ${i} exchange info`),null;const o=s.filters?.find(_=>_.filterType==="PRICE_FILTER"),l=s.filters?.find(_=>_.filterType==="LOT_SIZE"),c=o?parseFloat(o.tickSize):.01,u=l?parseFloat(l.minQty):0,p=Math.round(1/c),h=s.baseAsset,f=s.quoteAsset,m=n?` ${n}`:"",y=`${h} / ${f}${m}`;return{ticker:e,tickerid:`BINANCE:${e}`,prefix:"BINANCE",root:h,description:y,type:i,main_tickerid:`BINANCE:${e}`,current_contract:n,isin:"",basecurrency:h,currency:f,timezone:"Etc/UTC",country:"",mintick:c,pricescale:p,minmove:1,pointvalue:s.contractSize||1,mincontract:u,session:"24x7",volumetype:"base",expiration_date:s.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 gh=typeof process<"u"&&process.versions&&process.versions.node;let vt=null;if(gh)try{vt=new mh}catch{vt=null}const xh={Binance:new ph,...vt?{Mock:vt}:{}};exports.Context=Ze;exports.Indicator=qt;exports.PineTS=ri;exports.Provider=xh;
126
138
  //# sourceMappingURL=pinets.min.cjs.map