@hpcc-js/observablehq-compiler 3.1.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4218 -15
- package/dist/index.js.map +1 -7
- package/dist/index.umd.cjs +37 -0
- package/dist/index.umd.cjs.map +1 -0
- package/package.json +17 -13
- package/src/__package__.ts +2 -2
- package/src/compiler.ts +1 -1
- package/src/cst.ts +1 -1
- package/src/index.ts +1 -1
- package/src/observable-shim.ts +2 -0
- package/src/parse.ts +136 -0
- package/src/types.ts +180 -0
- package/src/util.ts +2 -2
- package/src/writer.ts +1 -1
- package/types/compiler.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/types/observable-shim.d.ts +2 -0
- package/types/parse.d.ts +26 -0
- package/types/types.d.ts +165 -0
- package/types/util.d.ts +1 -1
- package/types/writer.d.ts +1 -1
- package/dist/index.css +0 -2
- package/dist/index.css.map +0 -7
package/dist/index.js
CHANGED
|
@@ -1,14 +1,4019 @@
|
|
|
1
|
-
var Ke=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],ie=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],Qe="\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65",se="\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC",Dt={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"},Pt="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",Je={5:Pt,"5module":Pt+" export import",6:Pt+" const class extends export import super"},Ye=/^in(stanceof)?$/,Xe=new RegExp("["+se+"]"),Ze=new RegExp("["+se+Qe+"]");function Vt(t,e){for(var i=65536,s=0;s<e.length;s+=2){if(i+=e[s],i>t)return!1;if(i+=e[s+1],i>=t)return!0}return!1}function j(t,e){return t<65?t===36:t<91?!0:t<97?t===95:t<123?!0:t<=65535?t>=170&&Xe.test(String.fromCharCode(t)):e===!1?!1:Vt(t,ie)}function Y(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&&Ze.test(String.fromCharCode(t)):e===!1?!1:Vt(t,ie)||Vt(t,Ke)}var A=function(t,e){e===void 0&&(e={}),this.label=t,this.keyword=e.keyword,this.beforeExpr=!!e.beforeExpr,this.startsExpr=!!e.startsExpr,this.isLoop=!!e.isLoop,this.isAssign=!!e.isAssign,this.prefix=!!e.prefix,this.postfix=!!e.postfix,this.binop=e.binop||null,this.updateContext=null};function P(t,e){return new A(t,{beforeExpr:!0,binop:e})}var B={beforeExpr:!0},F={startsExpr:!0},Rt={};function C(t,e){return e===void 0&&(e={}),e.keyword=t,Rt[t]=new A(t,e)}var n={num:new A("num",F),regexp:new A("regexp",F),string:new A("string",F),name:new A("name",F),privateId:new A("privateId",F),eof:new A("eof"),bracketL:new A("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new A("]"),braceL:new A("{",{beforeExpr:!0,startsExpr:!0}),braceR:new A("}"),parenL:new A("(",{beforeExpr:!0,startsExpr:!0}),parenR:new A(")"),comma:new A(",",B),semi:new A(";",B),colon:new A(":",B),dot:new A("."),question:new A("?",B),questionDot:new A("?."),arrow:new A("=>",B),template:new A("template"),invalidTemplate:new A("invalidTemplate"),ellipsis:new A("...",B),backQuote:new A("`",F),dollarBraceL:new A("${",{beforeExpr:!0,startsExpr:!0}),eq:new A("=",{beforeExpr:!0,isAssign:!0}),assign:new A("_=",{beforeExpr:!0,isAssign:!0}),incDec:new A("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new A("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:P("||",1),logicalAND:P("&&",2),bitwiseOR:P("|",3),bitwiseXOR:P("^",4),bitwiseAND:P("&",5),equality:P("==/!=/===/!==",6),relational:P("</>/<=/>=",7),bitShift:P("<</>>/>>>",8),plusMin:new A("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:P("%",10),star:P("*",10),slash:P("/",10),starstar:new A("**",{beforeExpr:!0}),coalesce:P("??",1),_break:C("break"),_case:C("case",B),_catch:C("catch"),_continue:C("continue"),_debugger:C("debugger"),_default:C("default",B),_do:C("do",{isLoop:!0,beforeExpr:!0}),_else:C("else",B),_finally:C("finally"),_for:C("for",{isLoop:!0}),_function:C("function",F),_if:C("if"),_return:C("return",B),_switch:C("switch"),_throw:C("throw",B),_try:C("try"),_var:C("var"),_const:C("const"),_while:C("while",{isLoop:!0}),_with:C("with"),_new:C("new",{beforeExpr:!0,startsExpr:!0}),_this:C("this",F),_super:C("super",F),_class:C("class",F),_extends:C("extends",B),_export:C("export"),_import:C("import",F),_null:C("null",F),_true:C("true",F),_false:C("false",F),_in:C("in",{beforeExpr:!0,binop:7}),_instanceof:C("instanceof",{beforeExpr:!0,binop:7}),_typeof:C("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:C("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:C("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},L=/\r\n?|\n|\u2028|\u2029/,ti=new RegExp(L.source,"g");function X(t){return t===10||t===13||t===8232||t===8233}function re(t,e,i){i===void 0&&(i=t.length);for(var s=e;s<i;s++){var r=t.charCodeAt(s);if(X(r))return s<i-1&&r===13&&t.charCodeAt(s+1)===10?s+2:s+1}return-1}var ne=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,N=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,ae=Object.prototype,ei=ae.hasOwnProperty,ii=ae.toString,ot=Object.hasOwn||function(t,e){return ei.call(t,e)},Qt=Array.isArray||function(t){return ii.call(t)==="[object Array]"},Jt=Object.create(null);function W(t){return Jt[t]||(Jt[t]=new RegExp("^(?:"+t.replace(/ /g,"|")+")$"))}function G(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}var si=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,nt=function(t,e){this.line=t,this.column=e};nt.prototype.offset=function(t){return new nt(this.line,this.column+t)};var yt=function(t,e,i){this.start=e,this.end=i,t.sourceFile!==null&&(this.source=t.sourceFile)};function bt(t,e){for(var i=1,s=0;;){var r=re(t,s,e);if(r<0)return new nt(i,e-s);++i,s=r}}var Nt={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},Yt=!1;function ri(t){var e={};for(var i in Nt)e[i]=t&&ot(t,i)?t[i]:Nt[i];if(e.ecmaVersion==="latest"?e.ecmaVersion=1e8:e.ecmaVersion==null?(!Yt&&typeof console=="object"&&console.warn&&(Yt=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
2
|
-
|
|
3
|
-
`,i-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(L).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=n.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=t.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&t.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(at),this.regexpState=null,this.privateNameStack=[]},M={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};w.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};M.inFunction.get=function(){return(this.currentVarScope().flags&Z)>0};M.inGenerator.get=function(){return(this.currentVarScope().flags&oe)>0&&!this.currentVarScope().inClassFieldInit};M.inAsync.get=function(){return(this.currentVarScope().flags&Ot)>0&&!this.currentVarScope().inClassFieldInit};M.canAwait.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var e=this.scopeStack[t];if(e.inClassFieldInit||e.flags&ut)return!1;if(e.flags&Z)return(e.flags&Ot)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};M.allowSuper.get=function(){var t=this.currentThisScope(),e=t.flags,i=t.inClassFieldInit;return(e&Mt)>0||i||this.options.allowSuperOutsideMethod};M.allowDirectSuper.get=function(){return(this.currentThisScope().flags&pe)>0};M.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};M.allowNewDotTarget.get=function(){var t=this.currentThisScope(),e=t.flags,i=t.inClassFieldInit;return(e&(Z|ut))>0||i};M.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&ut)>0};w.extend=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];for(var i=this,s=0;s<t.length;s++)i=t[s](i);return i};w.parse=function(t,e){return new this(e,t).parse()};w.parseExpressionAt=function(t,e,i){var s=new this(i,t,e);return s.nextToken(),s.parseExpression()};w.tokenizer=function(t,e){return new this(e,t)};Object.defineProperties(w.prototype,M);var _=w.prototype,ai=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;_.strictDirective=function(t){if(this.options.ecmaVersion<5)return!1;for(;;){N.lastIndex=t,t+=N.exec(this.input)[0].length;var e=ai.exec(this.input.slice(t));if(!e)return!1;if((e[1]||e[2])==="use strict"){N.lastIndex=t+e[0].length;var i=N.exec(this.input),s=i.index+i[0].length,r=this.input.charAt(s);return r===";"||r==="}"||L.test(i[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(r)||r==="!"&&this.input.charAt(s+1)==="=")}t+=e[0].length,N.lastIndex=t,t+=N.exec(this.input)[0].length,this.input[t]===";"&&t++}};_.eat=function(t){return this.type===t?(this.next(),!0):!1};_.isContextual=function(t){return this.type===n.name&&this.value===t&&!this.containsEsc};_.eatContextual=function(t){return this.isContextual(t)?(this.next(),!0):!1};_.expectContextual=function(t){this.eatContextual(t)||this.unexpected()};_.canInsertSemicolon=function(){return this.type===n.eof||this.type===n.braceR||L.test(this.input.slice(this.lastTokEnd,this.start))};_.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};_.semicolon=function(){!this.eat(n.semi)&&!this.insertSemicolon()&&this.unexpected()};_.afterTrailingComma=function(t,e){if(this.type===t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0};_.expect=function(t){this.eat(t)||this.unexpected()};_.unexpected=function(t){this.raise(t??this.start,"Unexpected token")};var Ct=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};_.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")}};_.checkExpressionErrors=function(t,e){if(!t)return!1;var i=t.shorthandAssign,s=t.doubleProto;if(!e)return i>=0||s>=0;i>=0&&this.raise(i,"Shorthand property assignments are valid only in destructuring patterns"),s>=0&&this.raiseRecoverable(s,"Redefinition of __proto__ property")};_.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")};_.isSimpleAssignTarget=function(t){return t.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(t.expression):t.type==="Identifier"||t.type==="MemberExpression"};var m=w.prototype;m.parseTopLevel=function(t){var e=Object.create(null);for(t.body||(t.body=[]);this.type!==n.eof;){var i=this.parseStatement(null,!0,e);t.body.push(i)}if(this.inModule)for(var s=0,r=Object.keys(this.undefinedExports);s<r.length;s+=1){var a=r[s];this.raiseRecoverable(this.undefinedExports[a].start,"Export '"+a+"' is not defined")}return this.adaptDirectivePrologue(t.body),this.next(),t.sourceType=this.options.sourceType,this.finishNode(t,"Program")};var $t={kind:"loop"},oi={kind:"switch"};m.isLet=function(t){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;N.lastIndex=this.pos;var e=N.exec(this.input),i=this.pos+e[0].length,s=this.input.charCodeAt(i);if(s===91||s===92)return!0;if(t)return!1;if(s===123||s>55295&&s<56320)return!0;if(j(s,!0)){for(var r=i+1;Y(s=this.input.charCodeAt(r),!0);)++r;if(s===92||s>55295&&s<56320)return!0;var a=this.input.slice(i,r);if(!Ye.test(a))return!0}return!1};m.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;N.lastIndex=this.pos;var t=N.exec(this.input),e=this.pos+t[0].length,i;return!L.test(this.input.slice(this.pos,e))&&this.input.slice(e,e+8)==="function"&&(e+8===this.input.length||!(Y(i=this.input.charCodeAt(e+8))||i>55295&&i<56320))};m.parseStatement=function(t,e,i){var s=this.type,r=this.startNode(),a;switch(this.isLet(t)&&(s=n._var,a="let"),s){case n._break:case n._continue:return this.parseBreakContinueStatement(r,s.keyword);case n._debugger:return this.parseDebuggerStatement(r);case n._do:return this.parseDoStatement(r);case n._for:return this.parseForStatement(r);case n._function:return t&&(this.strict||t!=="if"&&t!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(r,!1,!t);case n._class:return t&&this.unexpected(),this.parseClass(r,!0);case n._if:return this.parseIfStatement(r);case n._return:return this.parseReturnStatement(r);case n._switch:return this.parseSwitchStatement(r);case n._throw:return this.parseThrowStatement(r);case n._try:return this.parseTryStatement(r);case n._const:case n._var:return a=a||this.value,t&&a!=="var"&&this.unexpected(),this.parseVarStatement(r,a);case n._while:return this.parseWhileStatement(r);case n._with:return this.parseWithStatement(r);case n.braceL:return this.parseBlock(!0,r);case n.semi:return this.parseEmptyStatement(r);case n._export:case n._import:if(this.options.ecmaVersion>10&&s===n._import){N.lastIndex=this.pos;var o=N.exec(this.input),h=this.pos+o[0].length,u=this.input.charCodeAt(h);if(u===40||u===46)return this.parseExpressionStatement(r,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'")),s===n._import?this.parseImport(r):this.parseExport(r,i);default:if(this.isAsyncFunction())return t&&this.unexpected(),this.next(),this.parseFunctionStatement(r,!0,!t);var p=this.value,l=this.parseExpression();return s===n.name&&l.type==="Identifier"&&this.eat(n.colon)?this.parseLabeledStatement(r,p,l,t):this.parseExpressionStatement(r,l)}};m.parseBreakContinueStatement=function(t,e){var i=e==="break";this.next(),this.eat(n.semi)||this.insertSemicolon()?t.label=null:this.type!==n.name?this.unexpected():(t.label=this.parseIdent(),this.semicolon());for(var s=0;s<this.labels.length;++s){var r=this.labels[s];if((t.label==null||r.name===t.label.name)&&(r.kind!=null&&(i||r.kind==="loop")||t.label&&i))break}return s===this.labels.length&&this.raise(t.start,"Unsyntactic "+e),this.finishNode(t,i?"BreakStatement":"ContinueStatement")};m.parseDebuggerStatement=function(t){return this.next(),this.semicolon(),this.finishNode(t,"DebuggerStatement")};m.parseDoStatement=function(t){return this.next(),this.labels.push($t),t.body=this.parseStatement("do"),this.labels.pop(),this.expect(n._while),t.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(n.semi):this.semicolon(),this.finishNode(t,"DoWhileStatement")};m.parseForStatement=function(t){this.next();var e=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push($t),this.enterScope(0),this.expect(n.parenL),this.type===n.semi)return e>-1&&this.unexpected(e),this.parseFor(t,null);var i=this.isLet();if(this.type===n._var||this.type===n._const||i){var s=this.startNode(),r=i?"let":this.value;return this.next(),this.parseVar(s,!0,r),this.finishNode(s,"VariableDeclaration"),(this.type===n._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&s.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===n._in?e>-1&&this.unexpected(e):t.await=e>-1),this.parseForIn(t,s)):(e>-1&&this.unexpected(e),this.parseFor(t,s))}var a=this.isContextual("let"),o=!1,h=this.containsEsc,u=new Ct,p=this.start,l=e>-1?this.parseExprSubscripts(u,"await"):this.parseExpression(!0,u);return this.type===n._in||(o=this.options.ecmaVersion>=6&&this.isContextual("of"))?(e>-1?(this.type===n._in&&this.unexpected(e),t.await=!0):o&&this.options.ecmaVersion>=8&&(l.start===p&&!h&&l.type==="Identifier"&&l.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(t.await=!1)),a&&o&&this.raise(l.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(l,!1,u),this.checkLValPattern(l),this.parseForIn(t,l)):(this.checkExpressionErrors(u,!0),e>-1&&this.unexpected(e),this.parseFor(t,l))};m.parseFunctionStatement=function(t,e,i){return this.next(),this.parseFunction(t,it|(i?0:Tt),!1,e)};m.parseIfStatement=function(t){return this.next(),t.test=this.parseParenExpression(),t.consequent=this.parseStatement("if"),t.alternate=this.eat(n._else)?this.parseStatement("if"):null,this.finishNode(t,"IfStatement")};m.parseReturnStatement=function(t){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(n.semi)||this.insertSemicolon()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")};m.parseSwitchStatement=function(t){this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(n.braceL),this.labels.push(oi),this.enterScope(0);for(var e,i=!1;this.type!==n.braceR;)if(this.type===n._case||this.type===n._default){var s=this.type===n._case;e&&this.finishNode(e,"SwitchCase"),t.cases.push(e=this.startNode()),e.consequent=[],this.next(),s?e.test=this.parseExpression():(i&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),i=!0,e.test=null),this.expect(n.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")};m.parseThrowStatement=function(t){return this.next(),L.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 ui=[];m.parseCatchClauseParam=function(){var t=this.parseBindingAtom(),e=t.type==="Identifier";return this.enterScope(e?he:0),this.checkLValPattern(t,e?le:$),this.expect(n.parenR),t};m.parseTryStatement=function(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.type===n._catch){var e=this.startNode();this.next(),this.eat(n.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(n._finally)?this.parseBlock():null,!t.handler&&!t.finalizer&&this.raise(t.start,"Missing catch or finally clause"),this.finishNode(t,"TryStatement")};m.parseVarStatement=function(t,e,i){return this.next(),this.parseVar(t,!1,e,i),this.semicolon(),this.finishNode(t,"VariableDeclaration")};m.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push($t),t.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(t,"WhileStatement")};m.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")};m.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,"EmptyStatement")};m.parseLabeledStatement=function(t,e,i,s){for(var r=0,a=this.labels;r<a.length;r+=1){var o=a[r];o.name===e&&this.raise(i.start,"Label '"+e+"' is already declared")}for(var h=this.type.isLoop?"loop":this.type===n._switch?"switch":null,u=this.labels.length-1;u>=0;u--){var p=this.labels[u];if(p.statementStart===t.start)p.statementStart=this.start,p.kind=h;else break}return this.labels.push({name:e,kind:h,statementStart:this.start}),t.body=this.parseStatement(s?s.indexOf("label")===-1?s+"label":s:"label"),this.labels.pop(),t.label=i,this.finishNode(t,"LabeledStatement")};m.parseExpressionStatement=function(t,e){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")};m.parseBlock=function(t,e,i){for(t===void 0&&(t=!0),e===void 0&&(e=this.startNode()),e.body=[],this.expect(n.braceL),t&&this.enterScope(0);this.type!==n.braceR;){var s=this.parseStatement(null);e.body.push(s)}return i&&(this.strict=!1),this.next(),t&&this.exitScope(),this.finishNode(e,"BlockStatement")};m.parseFor=function(t,e){return t.init=e,this.expect(n.semi),t.test=this.type===n.semi?null:this.parseExpression(),this.expect(n.semi),t.update=this.type===n.parenR?null:this.parseExpression(),this.expect(n.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,"ForStatement")};m.parseForIn=function(t,e){var i=this.type===n._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(n.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,i?"ForInStatement":"ForOfStatement")};m.parseVar=function(t,e,i,s){for(t.declarations=[],t.kind=i;;){var r=this.startNode();if(this.parseVarId(r,i),this.eat(n.eq)?r.init=this.parseMaybeAssign(e):!s&&i==="const"&&!(this.type===n._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!s&&r.id.type!=="Identifier"&&!(e&&(this.type===n._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):r.init=null,t.declarations.push(this.finishNode(r,"VariableDeclarator")),!this.eat(n.comma))break}return t};m.parseVarId=function(t,e){t.id=this.parseBindingAtom(),this.checkLValPattern(t.id,e==="var"?Ut:$,!1)};var it=1,Tt=2,fe=4;m.parseFunction=function(t,e,i,s,r){this.initFunction(t),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!s)&&(this.type===n.star&&e&Tt&&this.unexpected(),t.generator=this.eat(n.star)),this.options.ecmaVersion>=8&&(t.async=!!s),e&it&&(t.id=e&fe&&this.type!==n.name?null:this.parseIdent(),t.id&&!(e&Tt)&&this.checkLValSimple(t.id,this.strict||t.generator||t.async?this.treatFunctionsAsVar?Ut:$:ce));var a=this.yieldPos,o=this.awaitPos,h=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(jt(t.async,t.generator)),e&it||(t.id=this.type===n.name?this.parseIdent():null),this.parseFunctionParams(t),this.parseFunctionBody(t,i,!1,r),this.yieldPos=a,this.awaitPos=o,this.awaitIdentPos=h,this.finishNode(t,e&it?"FunctionDeclaration":"FunctionExpression")};m.parseFunctionParams=function(t){this.expect(n.parenL),t.params=this.parseBindingList(n.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};m.parseClass=function(t,e){this.next();var i=this.strict;this.strict=!0,this.parseClassId(t,e),this.parseClassSuper(t);var s=this.enterClassBody(),r=this.startNode(),a=!1;for(r.body=[],this.expect(n.braceL);this.type!==n.braceR;){var o=this.parseClassElement(t.superClass!==null);o&&(r.body.push(o),o.type==="MethodDefinition"&&o.kind==="constructor"?(a&&this.raiseRecoverable(o.start,"Duplicate constructor in the same class"),a=!0):o.key&&o.key.type==="PrivateIdentifier"&&hi(s,o)&&this.raiseRecoverable(o.key.start,"Identifier '#"+o.key.name+"' has already been declared"))}return this.strict=i,this.next(),t.body=this.finishNode(r,"ClassBody"),this.exitClassBody(),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")};m.parseClassElement=function(t){if(this.eat(n.semi))return null;var e=this.options.ecmaVersion,i=this.startNode(),s="",r=!1,a=!1,o="method",h=!1;if(this.eatContextual("static")){if(e>=13&&this.eat(n.braceL))return this.parseClassStaticBlock(i),i;this.isClassElementNameStart()||this.type===n.star?h=!0:s="static"}if(i.static=h,!s&&e>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===n.star)&&!this.canInsertSemicolon()?a=!0:s="async"),!s&&(e>=9||!a)&&this.eat(n.star)&&(r=!0),!s&&!a&&!r){var u=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?o=u:s=u)}if(s?(i.computed=!1,i.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),i.key.name=s,this.finishNode(i.key,"Identifier")):this.parseClassElementName(i),e<13||this.type===n.parenL||o!=="method"||r||a){var p=!i.static&>(i,"constructor"),l=p&&t;p&&o!=="method"&&this.raise(i.key.start,"Constructor can't have get/set modifier"),i.kind=p?"constructor":o,this.parseClassMethod(i,r,a,l)}else this.parseClassField(i);return i};m.isClassElementNameStart=function(){return this.type===n.name||this.type===n.privateId||this.type===n.num||this.type===n.string||this.type===n.bracketL||this.type.keyword};m.parseClassElementName=function(t){this.type===n.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)};m.parseClassMethod=function(t,e,i,s){var r=t.key;t.kind==="constructor"?(e&&this.raise(r.start,"Constructor can't be a generator"),i&&this.raise(r.start,"Constructor can't be an async method")):t.static&>(t,"prototype")&&this.raise(r.start,"Classes may not have a static property named prototype");var a=t.value=this.parseMethod(e,i,s);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")};m.parseClassField=function(t){if(gt(t,"constructor")?this.raise(t.key.start,"Classes can't have a field named 'constructor'"):t.static&>(t,"prototype")&&this.raise(t.key.start,"Classes can't have a static field named 'prototype'"),this.eat(n.eq)){var e=this.currentThisScope(),i=e.inClassFieldInit;e.inClassFieldInit=!0,t.value=this.parseMaybeAssign(),e.inClassFieldInit=i}else t.value=null;return this.semicolon(),this.finishNode(t,"PropertyDefinition")};m.parseClassStaticBlock=function(t){t.body=[];var e=this.labels;for(this.labels=[],this.enterScope(ut|Mt);this.type!==n.braceR;){var i=this.parseStatement(null);t.body.push(i)}return this.next(),this.exitScope(),this.labels=e,this.finishNode(t,"StaticBlock")};m.parseClassId=function(t,e){this.type===n.name?(t.id=this.parseIdent(),e&&this.checkLValSimple(t.id,$,!1)):(e===!0&&this.unexpected(),t.id=null)};m.parseClassSuper=function(t){t.superClass=this.eat(n._extends)?this.parseExprSubscripts(null,!1):null};m.enterClassBody=function(){var t={declared:Object.create(null),used:[]};return this.privateNameStack.push(t),t.declared};m.exitClassBody=function(){var t=this.privateNameStack.pop(),e=t.declared,i=t.used;if(this.options.checkPrivateFields)for(var s=this.privateNameStack.length,r=s===0?null:this.privateNameStack[s-1],a=0;a<i.length;++a){var o=i[a];ot(e,o.name)||(r?r.used.push(o):this.raiseRecoverable(o.start,"Private field '#"+o.name+"' must be declared in an enclosing class"))}};function hi(t,e){var i=e.key.name,s=t[i],r="true";return e.type==="MethodDefinition"&&(e.kind==="get"||e.kind==="set")&&(r=(e.static?"s":"i")+e.kind),s==="iget"&&r==="iset"||s==="iset"&&r==="iget"||s==="sget"&&r==="sset"||s==="sset"&&r==="sget"?(t[i]="true",!1):s?!0:(t[i]=r,!1)}function gt(t,e){var i=t.computed,s=t.key;return!i&&(s.type==="Identifier"&&s.name===e||s.type==="Literal"&&s.value===e)}m.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!==n.string&&this.unexpected(),t.source=this.parseExprAtom(),this.semicolon(),this.finishNode(t,"ExportAllDeclaration")};m.parseExport=function(t,e){if(this.next(),this.eat(n.star))return this.parseExportAllDeclaration(t,e);if(this.eat(n._default))return this.checkExport(e,"default",this.lastTokStart),t.declaration=this.parseExportDefaultDeclaration(),this.finishNode(t,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())t.declaration=this.parseExportDeclaration(t),t.declaration.type==="VariableDeclaration"?this.checkVariableExport(e,t.declaration.declarations):this.checkExport(e,t.declaration.id,t.declaration.id.start),t.specifiers=[],t.source=null;else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==n.string&&this.unexpected(),t.source=this.parseExprAtom();else{for(var i=0,s=t.specifiers;i<s.length;i+=1){var r=s[i];this.checkUnreserved(r.local),this.checkLocalExport(r.local),r.local.type==="Literal"&&this.raise(r.local.start,"A string literal cannot be used as an exported binding without `from`.")}t.source=null}this.semicolon()}return this.finishNode(t,"ExportNamedDeclaration")};m.parseExportDeclaration=function(t){return this.parseStatement(null)};m.parseExportDefaultDeclaration=function(){var t;if(this.type===n._function||(t=this.isAsyncFunction())){var e=this.startNode();return this.next(),t&&this.next(),this.parseFunction(e,it|fe,!1,t)}else if(this.type===n._class){var i=this.startNode();return this.parseClass(i,"nullableID")}else{var s=this.parseMaybeAssign();return this.semicolon(),s}};m.checkExport=function(t,e,i){t&&(typeof e!="string"&&(e=e.type==="Identifier"?e.name:e.value),ot(t,e)&&this.raiseRecoverable(i,"Duplicate export '"+e+"'"),t[e]=!0)};m.checkPatternExport=function(t,e){var i=e.type;if(i==="Identifier")this.checkExport(t,e,e.start);else if(i==="ObjectPattern")for(var s=0,r=e.properties;s<r.length;s+=1){var a=r[s];this.checkPatternExport(t,a)}else if(i==="ArrayPattern")for(var o=0,h=e.elements;o<h.length;o+=1){var u=h[o];u&&this.checkPatternExport(t,u)}else i==="Property"?this.checkPatternExport(t,e.value):i==="AssignmentPattern"?this.checkPatternExport(t,e.left):i==="RestElement"&&this.checkPatternExport(t,e.argument)};m.checkVariableExport=function(t,e){if(t)for(var i=0,s=e;i<s.length;i+=1){var r=s[i];this.checkPatternExport(t,r.id)}};m.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};m.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")};m.parseExportSpecifiers=function(t){var e=[],i=!0;for(this.expect(n.braceL);!this.eat(n.braceR);){if(i)i=!1;else if(this.expect(n.comma),this.afterTrailingComma(n.braceR))break;e.push(this.parseExportSpecifier(t))}return e};m.parseImport=function(t){return this.next(),this.type===n.string?(t.specifiers=ui,t.source=this.parseExprAtom()):(t.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),t.source=this.type===n.string?this.parseExprAtom():this.unexpected()),this.semicolon(),this.finishNode(t,"ImportDeclaration")};m.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,$),this.finishNode(t,"ImportSpecifier")};m.parseImportDefaultSpecifier=function(){var t=this.startNode();return t.local=this.parseIdent(),this.checkLValSimple(t.local,$),this.finishNode(t,"ImportDefaultSpecifier")};m.parseImportNamespaceSpecifier=function(){var t=this.startNode();return this.next(),this.expectContextual("as"),t.local=this.parseIdent(),this.checkLValSimple(t.local,$),this.finishNode(t,"ImportNamespaceSpecifier")};m.parseImportSpecifiers=function(){var t=[],e=!0;if(this.type===n.name&&(t.push(this.parseImportDefaultSpecifier()),!this.eat(n.comma)))return t;if(this.type===n.star)return t.push(this.parseImportNamespaceSpecifier()),t;for(this.expect(n.braceL);!this.eat(n.braceR);){if(e)e=!1;else if(this.expect(n.comma),this.afterTrailingComma(n.braceR))break;t.push(this.parseImportSpecifier())}return t};m.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===n.string){var t=this.parseLiteral(this.value);return si.test(t.value)&&this.raise(t.start,"An export name cannot include a lone surrogate."),t}return this.parseIdent(!0)};m.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)};m.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 R=w.prototype;R.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 s=0,r=t.properties;s<r.length;s+=1){var a=r[s];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};R.toAssignableList=function(t,e){for(var i=t.length,s=0;s<i;s++){var r=t[s];r&&this.toAssignable(r,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};R.parseSpread=function(t){var e=this.startNode();return this.next(),e.argument=this.parseMaybeAssign(!1,t),this.finishNode(e,"SpreadElement")};R.parseRestBinding=function(){var t=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==n.name&&this.unexpected(),t.argument=this.parseBindingAtom(),this.finishNode(t,"RestElement")};R.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case n.bracketL:var t=this.startNode();return this.next(),t.elements=this.parseBindingList(n.bracketR,!0,!0),this.finishNode(t,"ArrayPattern");case n.braceL:return this.parseObj(!0)}return this.parseIdent()};R.parseBindingList=function(t,e,i,s){for(var r=[],a=!0;!this.eat(t);)if(a?a=!1:this.expect(n.comma),e&&this.type===n.comma)r.push(null);else{if(i&&this.afterTrailingComma(t))break;if(this.type===n.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),r.push(o),this.type===n.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(t);break}else r.push(this.parseAssignableListItem(s))}return r};R.parseAssignableListItem=function(t){var e=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(e),e};R.parseBindingListItem=function(t){return t};R.parseMaybeDefault=function(t,e,i){if(i=i||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(n.eq))return i;var s=this.startNodeAt(t,e);return s.left=i,s.right=this.parseMaybeAssign(),this.finishNode(s,"AssignmentPattern")};R.checkLValSimple=function(t,e,i){e===void 0&&(e=mt);var s=e!==mt;switch(t.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(t.name)&&this.raiseRecoverable(t.start,(s?"Binding ":"Assigning to ")+t.name+" in strict mode"),s&&(e===$&&t.name==="let"&&this.raiseRecoverable(t.start,"let is disallowed as a lexically bound name"),i&&(ot(i,t.name)&&this.raiseRecoverable(t.start,"Argument name clash"),i[t.name]=!0),e!==de&&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":s&&this.raiseRecoverable(t.start,"Binding member expression");break;case"ParenthesizedExpression":return s&&this.raiseRecoverable(t.start,"Binding parenthesized expression"),this.checkLValSimple(t.expression,e,i);default:this.raise(t.start,(s?"Binding":"Assigning to")+" rvalue")}};R.checkLValPattern=function(t,e,i){switch(e===void 0&&(e=mt),t.type){case"ObjectPattern":for(var s=0,r=t.properties;s<r.length;s+=1){var a=r[s];this.checkLValInnerPattern(a,e,i)}break;case"ArrayPattern":for(var o=0,h=t.elements;o<h.length;o+=1){var u=h[o];u&&this.checkLValInnerPattern(u,e,i)}break;default:this.checkLValSimple(t,e,i)}};R.checkLValInnerPattern=function(t,e,i){switch(e===void 0&&(e=mt),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 V=function(t,e,i,s,r){this.token=t,this.isExpr=!!e,this.preserveSpace=!!i,this.override=s,this.generator=!!r},k={b_stat:new V("{",!1),b_expr:new V("{",!0),b_tmpl:new V("${",!1),p_stat:new V("(",!1),p_expr:new V("(",!0),q_tmpl:new V("`",!0,!0,function(t){return t.tryReadTemplateToken()}),f_stat:new V("function",!1),f_expr:new V("function",!0),f_expr_gen:new V("function",!0,!1,null,!0),f_gen:new V("function",!1,!1,null,!0)},tt=w.prototype;tt.initialContext=function(){return[k.b_stat]};tt.curContext=function(){return this.context[this.context.length-1]};tt.braceIsBlock=function(t){var e=this.curContext();return e===k.f_expr||e===k.f_stat?!0:t===n.colon&&(e===k.b_stat||e===k.b_expr)?!e.isExpr:t===n._return||t===n.name&&this.exprAllowed?L.test(this.input.slice(this.lastTokEnd,this.start)):t===n._else||t===n.semi||t===n.eof||t===n.parenR||t===n.arrow?!0:t===n.braceL?e===k.b_stat:t===n._var||t===n._const||t===n.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===n.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)};n.parenR.updateContext=n.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var t=this.context.pop();t===k.b_stat&&this.curContext().token==="function"&&(t=this.context.pop()),this.exprAllowed=!t.isExpr};n.braceL.updateContext=function(t){this.context.push(this.braceIsBlock(t)?k.b_stat:k.b_expr),this.exprAllowed=!0};n.dollarBraceL.updateContext=function(){this.context.push(k.b_tmpl),this.exprAllowed=!0};n.parenL.updateContext=function(t){var e=t===n._if||t===n._for||t===n._with||t===n._while;this.context.push(e?k.p_stat:k.p_expr),this.exprAllowed=!0};n.incDec.updateContext=function(){};n._function.updateContext=n._class.updateContext=function(t){t.beforeExpr&&t!==n._else&&!(t===n.semi&&this.curContext()!==k.p_stat)&&!(t===n._return&&L.test(this.input.slice(this.lastTokEnd,this.start)))&&!((t===n.colon||t===n.braceL)&&this.curContext()===k.b_stat)?this.context.push(k.f_expr):this.context.push(k.f_stat),this.exprAllowed=!1};n.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};n.backQuote.updateContext=function(){this.curContext()===k.q_tmpl?this.context.pop():this.context.push(k.q_tmpl),this.exprAllowed=!1};n.star.updateContext=function(t){if(t===n._function){var e=this.context.length-1;this.context[e]===k.f_expr?this.context[e]=k.f_expr_gen:this.context[e]=k.f_gen}this.exprAllowed=!0};n.name.updateContext=function(t){var e=!1;this.options.ecmaVersion>=6&&t!==n.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(e=!0),this.exprAllowed=e};var x=w.prototype;x.checkPropClash=function(t,e,i){if(!(this.options.ecmaVersion>=9&&t.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(t.computed||t.method||t.shorthand))){var s=t.key,r;switch(s.type){case"Identifier":r=s.name;break;case"Literal":r=String(s.value);break;default:return}var a=t.kind;if(this.options.ecmaVersion>=6){r==="__proto__"&&a==="init"&&(e.proto&&(i?i.doubleProto<0&&(i.doubleProto=s.start):this.raiseRecoverable(s.start,"Redefinition of __proto__ property")),e.proto=!0);return}r="$"+r;var o=e[r];if(o){var h;a==="init"?h=this.strict&&o.init||o.get||o.set:h=o.init||o[a],h&&this.raiseRecoverable(s.start,"Redefinition of property")}else o=e[r]={init:!1,get:!1,set:!1};o[a]=!0}};x.parseExpression=function(t,e){var i=this.start,s=this.startLoc,r=this.parseMaybeAssign(t,e);if(this.type===n.comma){var a=this.startNodeAt(i,s);for(a.expressions=[r];this.eat(n.comma);)a.expressions.push(this.parseMaybeAssign(t,e));return this.finishNode(a,"SequenceExpression")}return r};x.parseMaybeAssign=function(t,e,i){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(t);this.exprAllowed=!1}var s=!1,r=-1,a=-1,o=-1;e?(r=e.parenthesizedAssign,a=e.trailingComma,o=e.doubleProto,e.parenthesizedAssign=e.trailingComma=-1):(e=new Ct,s=!0);var h=this.start,u=this.startLoc;(this.type===n.parenL||this.type===n.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=t==="await");var p=this.parseMaybeConditional(t,e);if(i&&(p=i.call(this,p,h,u)),this.type.isAssign){var l=this.startNodeAt(h,u);return l.operator=this.value,this.type===n.eq&&(p=this.toAssignable(p,!1,e)),s||(e.parenthesizedAssign=e.trailingComma=e.doubleProto=-1),e.shorthandAssign>=p.start&&(e.shorthandAssign=-1),this.type===n.eq?this.checkLValPattern(p):this.checkLValSimple(p),l.left=p,this.next(),l.right=this.parseMaybeAssign(t),o>-1&&(e.doubleProto=o),this.finishNode(l,"AssignmentExpression")}else s&&this.checkExpressionErrors(e,!0);return r>-1&&(e.parenthesizedAssign=r),a>-1&&(e.trailingComma=a),p};x.parseMaybeConditional=function(t,e){var i=this.start,s=this.startLoc,r=this.parseExprOps(t,e);if(this.checkExpressionErrors(e))return r;if(this.eat(n.question)){var a=this.startNodeAt(i,s);return a.test=r,a.consequent=this.parseMaybeAssign(),this.expect(n.colon),a.alternate=this.parseMaybeAssign(t),this.finishNode(a,"ConditionalExpression")}return r};x.parseExprOps=function(t,e){var i=this.start,s=this.startLoc,r=this.parseMaybeUnary(e,!1,!1,t);return this.checkExpressionErrors(e)||r.start===i&&r.type==="ArrowFunctionExpression"?r:this.parseExprOp(r,i,s,-1,t)};x.parseExprOp=function(t,e,i,s,r){var a=this.type.binop;if(a!=null&&(!r||this.type!==n._in)&&a>s){var o=this.type===n.logicalOR||this.type===n.logicalAND,h=this.type===n.coalesce;h&&(a=n.logicalAND.binop);var u=this.value;this.next();var p=this.start,l=this.startLoc,v=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,r),p,l,a,r),S=this.buildBinary(e,i,t,v,u,o||h);return(o&&this.type===n.coalesce||h&&(this.type===n.logicalOR||this.type===n.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(S,e,i,s,r)}return t};x.buildBinary=function(t,e,i,s,r,a){s.type==="PrivateIdentifier"&&this.raise(s.start,"Private identifier can only be left side of binary expression");var o=this.startNodeAt(t,e);return o.left=i,o.operator=r,o.right=s,this.finishNode(o,a?"LogicalExpression":"BinaryExpression")};x.parseMaybeUnary=function(t,e,i,s){var r=this.start,a=this.startLoc,o;if(this.isContextual("await")&&this.canAwait)o=this.parseAwait(s),e=!0;else if(this.type.prefix){var h=this.startNode(),u=this.type===n.incDec;h.operator=this.value,h.prefix=!0,this.next(),h.argument=this.parseMaybeUnary(null,!0,u,s),this.checkExpressionErrors(t,!0),u?this.checkLValSimple(h.argument):this.strict&&h.operator==="delete"&&me(h.argument)?this.raiseRecoverable(h.start,"Deleting local variable in strict mode"):h.operator==="delete"&&Lt(h.argument)?this.raiseRecoverable(h.start,"Private fields can not be deleted"):e=!0,o=this.finishNode(h,u?"UpdateExpression":"UnaryExpression")}else if(!e&&this.type===n.privateId)(s||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),o=this.parsePrivateIdent(),this.type!==n._in&&this.unexpected();else{if(o=this.parseExprSubscripts(t,s),this.checkExpressionErrors(t))return o;for(;this.type.postfix&&!this.canInsertSemicolon();){var p=this.startNodeAt(r,a);p.operator=this.value,p.prefix=!1,p.argument=o,this.checkLValSimple(o),this.next(),o=this.finishNode(p,"UpdateExpression")}}if(!i&&this.eat(n.starstar))if(e)this.unexpected(this.lastTokStart);else return this.buildBinary(r,a,o,this.parseMaybeUnary(null,!1,!1,s),"**",!1);else return o};function me(t){return t.type==="Identifier"||t.type==="ParenthesizedExpression"&&me(t.expression)}function Lt(t){return t.type==="MemberExpression"&&t.property.type==="PrivateIdentifier"||t.type==="ChainExpression"&&Lt(t.expression)||t.type==="ParenthesizedExpression"&&Lt(t.expression)}x.parseExprSubscripts=function(t,e){var i=this.start,s=this.startLoc,r=this.parseExprAtom(t,e);if(r.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return r;var a=this.parseSubscripts(r,i,s,!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};x.parseSubscripts=function(t,e,i,s,r){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,o=!1;;){var h=this.parseSubscript(t,e,i,s,a,o,r);if(h.optional&&(o=!0),h===t||h.type==="ArrowFunctionExpression"){if(o){var u=this.startNodeAt(e,i);u.expression=h,h=this.finishNode(u,"ChainExpression")}return h}t=h}};x.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(n.arrow)};x.parseSubscriptAsyncArrow=function(t,e,i,s){return this.parseArrowExpression(this.startNodeAt(t,e),i,!0,s)};x.parseSubscript=function(t,e,i,s,r,a,o){var h=this.options.ecmaVersion>=11,u=h&&this.eat(n.questionDot);s&&u&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var p=this.eat(n.bracketL);if(p||u&&this.type!==n.parenL&&this.type!==n.backQuote||this.eat(n.dot)){var l=this.startNodeAt(e,i);l.object=t,p?(l.property=this.parseExpression(),this.expect(n.bracketR)):this.type===n.privateId&&t.type!=="Super"?l.property=this.parsePrivateIdent():l.property=this.parseIdent(this.options.allowReserved!=="never"),l.computed=!!p,h&&(l.optional=u),t=this.finishNode(l,"MemberExpression")}else if(!s&&this.eat(n.parenL)){var v=new Ct,S=this.yieldPos,D=this.awaitPos,I=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var Q=this.parseExprList(n.parenR,this.options.ecmaVersion>=8,!1,v);if(r&&!u&&this.shouldParseAsyncArrow())return this.checkPatternErrors(v,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=S,this.awaitPos=D,this.awaitIdentPos=I,this.parseSubscriptAsyncArrow(e,i,Q,o);this.checkExpressionErrors(v,!0),this.yieldPos=S||this.yieldPos,this.awaitPos=D||this.awaitPos,this.awaitIdentPos=I||this.awaitIdentPos;var O=this.startNodeAt(e,i);O.callee=t,O.arguments=Q,h&&(O.optional=u),t=this.finishNode(O,"CallExpression")}else if(this.type===n.backQuote){(u||a)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var d=this.startNodeAt(e,i);d.tag=t,d.quasi=this.parseTemplate({isTagged:!0}),t=this.finishNode(d,"TaggedTemplateExpression")}return t};x.parseExprAtom=function(t,e,i){this.type===n.slash&&this.readRegexp();var s,r=this.potentialArrowAt===this.start;switch(this.type){case n._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),s=this.startNode(),this.next(),this.type===n.parenL&&!this.allowDirectSuper&&this.raise(s.start,"super() call outside constructor of a subclass"),this.type!==n.dot&&this.type!==n.bracketL&&this.type!==n.parenL&&this.unexpected(),this.finishNode(s,"Super");case n._this:return s=this.startNode(),this.next(),this.finishNode(s,"ThisExpression");case n.name:var a=this.start,o=this.startLoc,h=this.containsEsc,u=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!h&&u.name==="async"&&!this.canInsertSemicolon()&&this.eat(n._function))return this.overrideContext(k.f_expr),this.parseFunction(this.startNodeAt(a,o),0,!1,!0,e);if(r&&!this.canInsertSemicolon()){if(this.eat(n.arrow))return this.parseArrowExpression(this.startNodeAt(a,o),[u],!1,e);if(this.options.ecmaVersion>=8&&u.name==="async"&&this.type===n.name&&!h&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return u=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(n.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,o),[u],!0,e)}return u;case n.regexp:var p=this.value;return s=this.parseLiteral(p.value),s.regex={pattern:p.pattern,flags:p.flags},s;case n.num:case n.string:return this.parseLiteral(this.value);case n._null:case n._true:case n._false:return s=this.startNode(),s.value=this.type===n._null?null:this.type===n._true,s.raw=this.type.keyword,this.next(),this.finishNode(s,"Literal");case n.parenL:var l=this.start,v=this.parseParenAndDistinguishExpression(r,e);return t&&(t.parenthesizedAssign<0&&!this.isSimpleAssignTarget(v)&&(t.parenthesizedAssign=l),t.parenthesizedBind<0&&(t.parenthesizedBind=l)),v;case n.bracketL:return s=this.startNode(),this.next(),s.elements=this.parseExprList(n.bracketR,!0,!0,t),this.finishNode(s,"ArrayExpression");case n.braceL:return this.overrideContext(k.b_expr),this.parseObj(!1,t);case n._function:return s=this.startNode(),this.next(),this.parseFunction(s,0);case n._class:return this.parseClass(this.startNode(),!1);case n._new:return this.parseNew();case n.backQuote:return this.parseTemplate();case n._import:return this.options.ecmaVersion>=11?this.parseExprImport(i):this.unexpected();default:return this.parseExprAtomDefault()}};x.parseExprAtomDefault=function(){this.unexpected()};x.parseExprImport=function(t){var e=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===n.parenL&&!t)return this.parseDynamicImport(e);if(this.type===n.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()};x.parseDynamicImport=function(t){if(this.next(),t.source=this.parseMaybeAssign(),!this.eat(n.parenR)){var e=this.start;this.eat(n.comma)&&this.eat(n.parenR)?this.raiseRecoverable(e,"Trailing comma is not allowed in import()"):this.unexpected(e)}return this.finishNode(t,"ImportExpression")};x.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")};x.parseLiteral=function(t){var e=this.startNode();return e.value=t,e.raw=this.input.slice(this.start,this.end),e.raw.charCodeAt(e.raw.length-1)===110&&(e.bigint=e.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(e,"Literal")};x.parseParenExpression=function(){this.expect(n.parenL);var t=this.parseExpression();return this.expect(n.parenR),t};x.shouldParseArrow=function(t){return!this.canInsertSemicolon()};x.parseParenAndDistinguishExpression=function(t,e){var i=this.start,s=this.startLoc,r,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var o=this.start,h=this.startLoc,u=[],p=!0,l=!1,v=new Ct,S=this.yieldPos,D=this.awaitPos,I;for(this.yieldPos=0,this.awaitPos=0;this.type!==n.parenR;)if(p?p=!1:this.expect(n.comma),a&&this.afterTrailingComma(n.parenR,!0)){l=!0;break}else if(this.type===n.ellipsis){I=this.start,u.push(this.parseParenItem(this.parseRestBinding())),this.type===n.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else u.push(this.parseMaybeAssign(!1,v,this.parseParenItem));var Q=this.lastTokEnd,O=this.lastTokEndLoc;if(this.expect(n.parenR),t&&this.shouldParseArrow(u)&&this.eat(n.arrow))return this.checkPatternErrors(v,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=S,this.awaitPos=D,this.parseParenArrowList(i,s,u,e);(!u.length||l)&&this.unexpected(this.lastTokStart),I&&this.unexpected(I),this.checkExpressionErrors(v,!0),this.yieldPos=S||this.yieldPos,this.awaitPos=D||this.awaitPos,u.length>1?(r=this.startNodeAt(o,h),r.expressions=u,this.finishNodeAt(r,"SequenceExpression",Q,O)):r=u[0]}else r=this.parseParenExpression();if(this.options.preserveParens){var d=this.startNodeAt(i,s);return d.expression=r,this.finishNode(d,"ParenthesizedExpression")}else return r};x.parseParenItem=function(t){return t};x.parseParenArrowList=function(t,e,i,s){return this.parseArrowExpression(this.startNodeAt(t,e),i,!1,s)};var pi=[];x.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===n.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 s=this.start,r=this.startLoc;return t.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),s,r,!0,!1),this.eat(n.parenL)?t.arguments=this.parseExprList(n.parenR,this.options.ecmaVersion>=8,!1):t.arguments=pi,this.finishNode(t,"NewExpression")};x.parseTemplateElement=function(t){var e=t.isTagged,i=this.startNode();return this.type===n.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),i.value={raw:this.value.replace(/\r\n?/g,`
|
|
4
|
-
|
|
5
|
-
`),cooked:this.value},this.next(),i.tail=this.type===n.backQuote,this.finishNode(i,"TemplateElement")};x.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 s=this.parseTemplateElement({isTagged:e});for(i.quasis=[s];!s.tail;)this.type===n.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(n.dollarBraceL),i.expressions.push(this.parseExpression()),this.expect(n.braceR),i.quasis.push(s=this.parseTemplateElement({isTagged:e}));return this.next(),this.finishNode(i,"TemplateLiteral")};x.isAsyncProp=function(t){return!t.computed&&t.key.type==="Identifier"&&t.key.name==="async"&&(this.type===n.name||this.type===n.num||this.type===n.string||this.type===n.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===n.star)&&!L.test(this.input.slice(this.lastTokEnd,this.start))};x.parseObj=function(t,e){var i=this.startNode(),s=!0,r={};for(i.properties=[],this.next();!this.eat(n.braceR);){if(s)s=!1;else if(this.expect(n.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(n.braceR))break;var a=this.parseProperty(t,e);t||this.checkPropClash(a,r,e),i.properties.push(a)}return this.finishNode(i,t?"ObjectPattern":"ObjectExpression")};x.parseProperty=function(t,e){var i=this.startNode(),s,r,a,o;if(this.options.ecmaVersion>=9&&this.eat(n.ellipsis))return t?(i.argument=this.parseIdent(!1),this.type===n.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===n.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,o=this.startLoc),t||(s=this.eat(n.star)));var h=this.containsEsc;return this.parsePropertyName(i),!t&&!h&&this.options.ecmaVersion>=8&&!s&&this.isAsyncProp(i)?(r=!0,s=this.options.ecmaVersion>=9&&this.eat(n.star),this.parsePropertyName(i)):r=!1,this.parsePropertyValue(i,t,s,r,a,o,e,h),this.finishNode(i,"Property")};x.parseGetterSetter=function(t){t.kind=t.key.name,this.parsePropertyName(t),t.value=this.parseMethod(!1);var e=t.kind==="get"?0:1;if(t.value.params.length!==e){var i=t.value.start;t.kind==="get"?this.raiseRecoverable(i,"getter should have no params"):this.raiseRecoverable(i,"setter should have exactly one param")}else t.kind==="set"&&t.value.params[0].type==="RestElement"&&this.raiseRecoverable(t.value.params[0].start,"Setter cannot use rest params")};x.parsePropertyValue=function(t,e,i,s,r,a,o,h){(i||s)&&this.type===n.colon&&this.unexpected(),this.eat(n.colon)?(t.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),t.kind="init"):this.options.ecmaVersion>=6&&this.type===n.parenL?(e&&this.unexpected(),t.kind="init",t.method=!0,t.value=this.parseMethod(i,s)):!e&&!h&&this.options.ecmaVersion>=5&&!t.computed&&t.key.type==="Identifier"&&(t.key.name==="get"||t.key.name==="set")&&this.type!==n.comma&&this.type!==n.braceR&&this.type!==n.eq?((i||s)&&this.unexpected(),this.parseGetterSetter(t)):this.options.ecmaVersion>=6&&!t.computed&&t.key.type==="Identifier"?((i||s)&&this.unexpected(),this.checkUnreserved(t.key),t.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=r),t.kind="init",e?t.value=this.parseMaybeDefault(r,a,this.copyNode(t.key)):this.type===n.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),t.value=this.parseMaybeDefault(r,a,this.copyNode(t.key))):t.value=this.copyNode(t.key),t.shorthand=!0):this.unexpected()};x.parsePropertyName=function(t){if(this.options.ecmaVersion>=6){if(this.eat(n.bracketL))return t.computed=!0,t.key=this.parseMaybeAssign(),this.expect(n.bracketR),t.key;t.computed=!1}return t.key=this.type===n.num||this.type===n.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};x.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)};x.parseMethod=function(t,e,i){var s=this.startNode(),r=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.initFunction(s),this.options.ecmaVersion>=6&&(s.generator=t),this.options.ecmaVersion>=8&&(s.async=!!e),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(jt(e,s.generator)|Mt|(i?pe:0)),this.expect(n.parenL),s.params=this.parseBindingList(n.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(s,!1,!0,!1),this.yieldPos=r,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(s,"FunctionExpression")};x.parseArrowExpression=function(t,e,i,s){var r=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(jt(i,!1)|ue),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,s),this.yieldPos=r,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(t,"ArrowFunctionExpression")};x.parseFunctionBody=function(t,e,i,s){var r=e&&this.type!==n.braceL,a=this.strict,o=!1;if(r)t.body=this.parseMaybeAssign(s),t.expression=!0,this.checkParams(t,!1);else{var h=this.options.ecmaVersion>=7&&!this.isSimpleParamList(t.params);(!a||h)&&(o=this.strictDirective(this.end),o&&h&&this.raiseRecoverable(t.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var u=this.labels;this.labels=[],o&&(this.strict=!0),this.checkParams(t,!a&&!o&&!e&&!i&&this.isSimpleParamList(t.params)),this.strict&&t.id&&this.checkLValSimple(t.id,de),t.body=this.parseBlock(!1,void 0,o&&!a),t.expression=!1,this.adaptDirectivePrologue(t.body.body),this.labels=u}this.exitScope()};x.isSimpleParamList=function(t){for(var e=0,i=t;e<i.length;e+=1){var s=i[e];if(s.type!=="Identifier")return!1}return!0};x.checkParams=function(t,e){for(var i=Object.create(null),s=0,r=t.params;s<r.length;s+=1){var a=r[s];this.checkLValInnerPattern(a,Ut,e?null:i)}};x.parseExprList=function(t,e,i,s){for(var r=[],a=!0;!this.eat(t);){if(a)a=!1;else if(this.expect(n.comma),e&&this.afterTrailingComma(t))break;var o=void 0;i&&this.type===n.comma?o=null:this.type===n.ellipsis?(o=this.parseSpread(s),s&&this.type===n.comma&&s.trailingComma<0&&(s.trailingComma=this.start)):o=this.parseMaybeAssign(!1,s),r.push(o)}return r};x.checkUnreserved=function(t){var e=t.start,i=t.end,s=t.name;if(this.inGenerator&&s==="yield"&&this.raiseRecoverable(e,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&s==="await"&&this.raiseRecoverable(e,"Cannot use 'await' as identifier inside an async function"),this.currentThisScope().inClassFieldInit&&s==="arguments"&&this.raiseRecoverable(e,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(s==="arguments"||s==="await")&&this.raise(e,"Cannot use "+s+" in class static initialization block"),this.keywords.test(s)&&this.raise(e,"Unexpected keyword '"+s+"'"),!(this.options.ecmaVersion<6&&this.input.slice(e,i).indexOf("\\")!==-1)){var r=this.strict?this.reservedWordsStrict:this.reservedWords;r.test(s)&&(!this.inAsync&&s==="await"&&this.raiseRecoverable(e,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(e,"The keyword '"+s+"' is reserved"))}};x.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};x.parseIdentNode=function(){var t=this.startNode();return this.type===n.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=n.name):this.unexpected(),t};x.parsePrivateIdent=function(){var t=this.startNode();return this.type===n.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};x.parseYield=function(t){this.yieldPos||(this.yieldPos=this.start);var e=this.startNode();return this.next(),this.type===n.semi||this.canInsertSemicolon()||this.type!==n.star&&!this.type.startsExpr?(e.delegate=!1,e.argument=null):(e.delegate=this.eat(n.star),e.argument=this.parseMaybeAssign(t)),this.finishNode(e,"YieldExpression")};x.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 xt=w.prototype;xt.raise=function(t,e){var i=bt(this.input,t);e+=" ("+i.line+":"+i.column+")";var s=new SyntaxError(e);throw s.pos=t,s.loc=i,s.raisedAt=this.pos,s};xt.raiseRecoverable=xt.raise;xt.curPosition=function(){if(this.options.locations)return new nt(this.curLine,this.pos-this.lineStart)};var z=w.prototype,ci=function(t){this.flags=t,this.var=[],this.lexical=[],this.functions=[],this.inClassFieldInit=!1};z.enterScope=function(t){this.scopeStack.push(new ci(t))};z.exitScope=function(){this.scopeStack.pop()};z.treatFunctionsAsVarInScope=function(t){return t.flags&Z||!this.inModule&&t.flags&at};z.declareName=function(t,e,i){var s=!1;if(e===$){var r=this.currentScope();s=r.lexical.indexOf(t)>-1||r.functions.indexOf(t)>-1||r.var.indexOf(t)>-1,r.lexical.push(t),this.inModule&&r.flags&at&&delete this.undefinedExports[t]}else if(e===le){var a=this.currentScope();a.lexical.push(t)}else if(e===ce){var o=this.currentScope();this.treatFunctionsAsVar?s=o.lexical.indexOf(t)>-1:s=o.lexical.indexOf(t)>-1||o.var.indexOf(t)>-1,o.functions.push(t)}else for(var h=this.scopeStack.length-1;h>=0;--h){var u=this.scopeStack[h];if(u.lexical.indexOf(t)>-1&&!(u.flags&he&&u.lexical[0]===t)||!this.treatFunctionsAsVarInScope(u)&&u.functions.indexOf(t)>-1){s=!0;break}if(u.var.push(t),this.inModule&&u.flags&at&&delete this.undefinedExports[t],u.flags&qt)break}s&&this.raiseRecoverable(i,"Identifier '"+t+"' has already been declared")};z.checkLocalExport=function(t){this.scopeStack[0].lexical.indexOf(t.name)===-1&&this.scopeStack[0].var.indexOf(t.name)===-1&&(this.undefinedExports[t.name]=t)};z.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};z.currentVarScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(e.flags&qt)return e}};z.currentThisScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(e.flags&qt&&!(e.flags&ue))return e}};var At=function(t,e,i){this.type="",this.start=e,this.end=0,t.options.locations&&(this.loc=new yt(t,i)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[e,0])},ht=w.prototype;ht.startNode=function(){return new At(this,this.start,this.startLoc)};ht.startNodeAt=function(t,e){return new At(this,t,e)};function ge(t,e,i,s){return t.type=e,t.end=i,this.options.locations&&(t.loc.end=s),this.options.ranges&&(t.range[1]=i),t}ht.finishNode=function(t,e){return ge.call(this,t,e,this.lastTokEnd,this.lastTokEndLoc)};ht.finishNodeAt=function(t,e,i,s){return ge.call(this,t,e,i,s)};ht.copyNode=function(t){var e=new At(this,t.start,this.startLoc);for(var i in t)e[i]=t[i];return e};var xe="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",ve=xe+" Extended_Pictographic",ye=ve,be=ye+" EBase EComp EMod EPres ExtPict",Ce=be,li=Ce,di={9:xe,10:ve,11:ye,12:be,13:Ce,14:li},fi="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",mi={9:"",10:"",11:"",12:"",13:"",14:fi},Xt="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",Ae="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",Ee=Ae+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",ke=Ee+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",we=ke+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Se=we+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",gi=Se+" Hrkt Katakana_Or_Hiragana Kawi Nag_Mundari Nagm Unknown Zzzz",xi={9:Ae,10:Ee,11:ke,12:we,13:Se,14:gi},_e={};function vi(t){var e=_e[t]={binary:W(di[t]+" "+Xt),binaryOfStrings:W(mi[t]),nonBinary:{General_Category:W(Xt),Script:W(xi[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(lt=0,Bt=[9,10,11,12,13,14];lt<Bt.length;lt+=1)Zt=Bt[lt],vi(Zt);var Zt,lt,Bt,f=w.prototype,vt=function(t,e){this.parent=t,this.base=e||this};vt.prototype.separatedFrom=function(t){for(var e=this;e;e=e.parent)for(var i=t;i;i=i.parent)if(e.base===i.base&&e!==i)return!0;return!1};vt.prototype.sibling=function(){return new vt(this.parent,this.base)};var q=function(t){this.parser=t,this.validFlags="gim"+(t.options.ecmaVersion>=6?"uy":"")+(t.options.ecmaVersion>=9?"s":"")+(t.options.ecmaVersion>=13?"d":"")+(t.options.ecmaVersion>=15?"v":""),this.unicodeProperties=_e[t.options.ecmaVersion>=14?14:t.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};q.prototype.reset=function(t,e,i){var s=i.indexOf("v")!==-1,r=i.indexOf("u")!==-1;this.start=t|0,this.source=e+"",this.flags=i,s&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=r&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=r&&this.parser.options.ecmaVersion>=9)};q.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)};q.prototype.at=function(t,e){e===void 0&&(e=!1);var i=this.source,s=i.length;if(t>=s)return-1;var r=i.charCodeAt(t);if(!(e||this.switchU)||r<=55295||r>=57344||t+1>=s)return r;var a=i.charCodeAt(t+1);return a>=56320&&a<=57343?(r<<10)+a-56613888:r};q.prototype.nextIndex=function(t,e){e===void 0&&(e=!1);var i=this.source,s=i.length;if(t>=s)return s;var r=i.charCodeAt(t),a;return!(e||this.switchU)||r<=55295||r>=57344||t+1>=s||(a=i.charCodeAt(t+1))<56320||a>57343?t+1:t+2};q.prototype.current=function(t){return t===void 0&&(t=!1),this.at(this.pos,t)};q.prototype.lookahead=function(t){return t===void 0&&(t=!1),this.at(this.nextIndex(this.pos,t),t)};q.prototype.advance=function(t){t===void 0&&(t=!1),this.pos=this.nextIndex(this.pos,t)};q.prototype.eat=function(t,e){return e===void 0&&(e=!1),this.current(e)===t?(this.advance(e),!0):!1};q.prototype.eatChars=function(t,e){e===void 0&&(e=!1);for(var i=this.pos,s=0,r=t;s<r.length;s+=1){var a=r[s],o=this.at(i,e);if(o===-1||o!==a)return!1;i=this.nextIndex(i,e)}return this.pos=i,!0};f.validateRegExpFlags=function(t){for(var e=t.validFlags,i=t.flags,s=!1,r=!1,a=0;a<i.length;a++){var o=i.charAt(a);e.indexOf(o)===-1&&this.raise(t.start,"Invalid regular expression flag"),i.indexOf(o,a+1)>-1&&this.raise(t.start,"Duplicate regular expression flag"),o==="u"&&(s=!0),o==="v"&&(r=!0)}this.options.ecmaVersion>=15&&s&&r&&this.raise(t.start,"Invalid regular expression flag")};function yi(t){for(var e in t)return!0;return!1}f.validateRegExpPattern=function(t){this.regexp_pattern(t),!t.switchN&&this.options.ecmaVersion>=9&&yi(t.groupNames)&&(t.switchN=!0,this.regexp_pattern(t))};f.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 s=i[e];t.groupNames[s]||t.raise("Invalid named capture referenced")}};f.regexp_disjunction=function(t){var e=this.options.ecmaVersion>=16;for(e&&(t.branchID=new vt(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")};f.regexp_alternative=function(t){for(;t.pos<t.source.length&&this.regexp_eatTerm(t););};f.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};f.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};f.regexp_eatQuantifier=function(t,e){return e===void 0&&(e=!1),this.regexp_eatQuantifierPrefix(t,e)?(t.eat(63),!0):!1};f.regexp_eatQuantifierPrefix=function(t,e){return t.eat(42)||t.eat(43)||t.eat(63)||this.regexp_eatBracedQuantifier(t,e)};f.regexp_eatBracedQuantifier=function(t,e){var i=t.pos;if(t.eat(123)){var s=0,r=-1;if(this.regexp_eatDecimalDigits(t)&&(s=t.lastIntValue,t.eat(44)&&this.regexp_eatDecimalDigits(t)&&(r=t.lastIntValue),t.eat(125)))return r!==-1&&r<s&&!e&&t.raise("numbers out of order in {} quantifier"),!0;t.switchU&&!e&&t.raise("Incomplete quantifier"),t.pos=i}return!1};f.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)};f.regexp_eatReverseSolidusAtomEscape=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatAtomEscape(t))return!0;t.pos=e}return!1};f.regexp_eatUncapturingGroup=function(t){var e=t.pos;if(t.eat(40)){if(t.eat(63)&&t.eat(58)){if(this.regexp_disjunction(t),t.eat(41))return!0;t.raise("Unterminated group")}t.pos=e}return!1};f.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};f.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)};f.regexp_eatInvalidBracedQuantifier=function(t){return this.regexp_eatBracedQuantifier(t,!0)&&t.raise("Nothing to repeat"),!1};f.regexp_eatSyntaxCharacter=function(t){var e=t.current();return Fe(e)?(t.lastIntValue=e,t.advance(),!0):!1};function Fe(t){return t===36||t>=40&&t<=43||t===46||t===63||t>=91&&t<=94||t>=123&&t<=125}f.regexp_eatPatternCharacters=function(t){for(var e=t.pos,i=0;(i=t.current())!==-1&&!Fe(i);)t.advance();return t.pos!==e};f.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};f.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 s=0,r=i;s<r.length;s+=1){var a=r[s];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}};f.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};f.regexp_eatRegExpIdentifierName=function(t){if(t.lastStringValue="",this.regexp_eatRegExpIdentifierStart(t)){for(t.lastStringValue+=G(t.lastIntValue);this.regexp_eatRegExpIdentifierPart(t);)t.lastStringValue+=G(t.lastIntValue);return!0}return!1};f.regexp_eatRegExpIdentifierStart=function(t){var e=t.pos,i=this.options.ecmaVersion>=11,s=t.current(i);return t.advance(i),s===92&&this.regexp_eatRegExpUnicodeEscapeSequence(t,i)&&(s=t.lastIntValue),bi(s)?(t.lastIntValue=s,!0):(t.pos=e,!1)};function bi(t){return j(t,!0)||t===36||t===95}f.regexp_eatRegExpIdentifierPart=function(t){var e=t.pos,i=this.options.ecmaVersion>=11,s=t.current(i);return t.advance(i),s===92&&this.regexp_eatRegExpUnicodeEscapeSequence(t,i)&&(s=t.lastIntValue),Ci(s)?(t.lastIntValue=s,!0):(t.pos=e,!1)};function Ci(t){return Y(t,!0)||t===36||t===95||t===8204||t===8205}f.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)};f.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};f.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};f.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)};f.regexp_eatCControlLetter=function(t){var e=t.pos;if(t.eat(99)){if(this.regexp_eatControlLetter(t))return!0;t.pos=e}return!1};f.regexp_eatZero=function(t){return t.current()===48&&!Et(t.lookahead())?(t.lastIntValue=0,t.advance(),!0):!1};f.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};f.regexp_eatControlLetter=function(t){var e=t.current();return Ie(e)?(t.lastIntValue=e%32,t.advance(),!0):!1};function Ie(t){return t>=65&&t<=90||t>=97&&t<=122}f.regexp_eatRegExpUnicodeEscapeSequence=function(t,e){e===void 0&&(e=!1);var i=t.pos,s=e||t.switchU;if(t.eat(117)){if(this.regexp_eatFixedHexDigits(t,4)){var r=t.lastIntValue;if(s&&r>=55296&&r<=56319){var a=t.pos;if(t.eat(92)&&t.eat(117)&&this.regexp_eatFixedHexDigits(t,4)){var o=t.lastIntValue;if(o>=56320&&o<=57343)return t.lastIntValue=(r-55296)*1024+(o-56320)+65536,!0}t.pos=a,t.lastIntValue=r}return!0}if(s&&t.eat(123)&&this.regexp_eatHexDigits(t)&&t.eat(125)&&Ai(t.lastIntValue))return!0;s&&t.raise("Invalid unicode escape"),t.pos=i}return!1};function Ai(t){return t>=0&&t<=1114111}f.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};f.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 De=0,U=1,T=2;f.regexp_eatCharacterClassEscape=function(t){var e=t.current();if(Ei(e))return t.lastIntValue=-1,t.advance(),U;var i=!1;if(t.switchU&&this.options.ecmaVersion>=9&&((i=e===80)||e===112)){t.lastIntValue=-1,t.advance();var s;if(t.eat(123)&&(s=this.regexp_eatUnicodePropertyValueExpression(t))&&t.eat(125))return i&&s===T&&t.raise("Invalid property name"),s;t.raise("Invalid property name")}return De};function Ei(t){return t===100||t===68||t===115||t===83||t===119||t===87}f.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 s=t.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(t,i,s),U}}if(t.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(t)){var r=t.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(t,r)}return De};f.regexp_validateUnicodePropertyNameAndValue=function(t,e,i){ot(t.unicodeProperties.nonBinary,e)||t.raise("Invalid property name"),t.unicodeProperties.nonBinary[e].test(i)||t.raise("Invalid property value")};f.regexp_validateUnicodePropertyNameOrValue=function(t,e){if(t.unicodeProperties.binary.test(e))return U;if(t.switchV&&t.unicodeProperties.binaryOfStrings.test(e))return T;t.raise("Invalid property name")};f.regexp_eatUnicodePropertyName=function(t){var e=0;for(t.lastStringValue="";Pe(e=t.current());)t.lastStringValue+=G(e),t.advance();return t.lastStringValue!==""};function Pe(t){return Ie(t)||t===95}f.regexp_eatUnicodePropertyValue=function(t){var e=0;for(t.lastStringValue="";ki(e=t.current());)t.lastStringValue+=G(e),t.advance();return t.lastStringValue!==""};function ki(t){return Pe(t)||Et(t)}f.regexp_eatLoneUnicodePropertyNameOrValue=function(t){return this.regexp_eatUnicodePropertyValue(t)};f.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===T&&t.raise("Negated character class may contain strings"),!0}return!1};f.regexp_classContents=function(t){return t.current()===93?U:t.switchV?this.regexp_classSetExpression(t):(this.regexp_nonEmptyClassRanges(t),U)};f.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")}}};f.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||Ne(i))&&t.raise("Invalid class escape"),t.raise("Invalid escape")}t.pos=e}var s=t.current();return s!==93?(t.lastIntValue=s,t.advance(),!0):!1};f.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)};f.regexp_classSetExpression=function(t){var e=U,i;if(!this.regexp_eatClassSetRange(t))if(i=this.regexp_eatClassSetOperand(t)){i===T&&(e=T);for(var s=t.pos;t.eatChars([38,38]);){if(t.current()!==38&&(i=this.regexp_eatClassSetOperand(t))){i!==T&&(e=U);continue}t.raise("Invalid character in character class")}if(s!==t.pos)return e;for(;t.eatChars([45,45]);)this.regexp_eatClassSetOperand(t)||t.raise("Invalid character in character class");if(s!==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===T&&(e=T)}};f.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 s=t.lastIntValue;return i!==-1&&s!==-1&&i>s&&t.raise("Range out of order in character class"),!0}t.pos=e}return!1};f.regexp_eatClassSetOperand=function(t){return this.regexp_eatClassSetCharacter(t)?U:this.regexp_eatClassStringDisjunction(t)||this.regexp_eatNestedClass(t)};f.regexp_eatNestedClass=function(t){var e=t.pos;if(t.eat(91)){var i=t.eat(94),s=this.regexp_classContents(t);if(t.eat(93))return i&&s===T&&t.raise("Negated character class may contain strings"),s;t.pos=e}if(t.eat(92)){var r=this.regexp_eatCharacterClassEscape(t);if(r)return r;t.pos=e}return null};f.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};f.regexp_classStringDisjunctionContents=function(t){for(var e=this.regexp_classString(t);t.eat(124);)this.regexp_classString(t)===T&&(e=T);return e};f.regexp_classString=function(t){for(var e=0;this.regexp_eatClassSetCharacter(t);)e++;return e===1?U:T};f.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()&&wi(i)||Si(i)?!1:(t.advance(),t.lastIntValue=i,!0)};function wi(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 Si(t){return t===40||t===41||t===45||t===47||t>=91&&t<=93||t>=123&&t<=125}f.regexp_eatClassSetReservedPunctuator=function(t){var e=t.current();return _i(e)?(t.lastIntValue=e,t.advance(),!0):!1};function _i(t){return t===33||t===35||t===37||t===38||t===44||t===45||t>=58&&t<=62||t===64||t===96||t===126}f.regexp_eatClassControlLetter=function(t){var e=t.current();return Et(e)||e===95?(t.lastIntValue=e%32,t.advance(),!0):!1};f.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};f.regexp_eatDecimalDigits=function(t){var e=t.pos,i=0;for(t.lastIntValue=0;Et(i=t.current());)t.lastIntValue=10*t.lastIntValue+(i-48),t.advance();return t.pos!==e};function Et(t){return t>=48&&t<=57}f.regexp_eatHexDigits=function(t){var e=t.pos,i=0;for(t.lastIntValue=0;Be(i=t.current());)t.lastIntValue=16*t.lastIntValue+Ve(i),t.advance();return t.pos!==e};function Be(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function Ve(t){return t>=65&&t<=70?10+(t-65):t>=97&&t<=102?10+(t-97):t-48}f.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};f.regexp_eatOctalDigit=function(t){var e=t.current();return Ne(e)?(t.lastIntValue=e-48,t.advance(),!0):(t.lastIntValue=0,!1)};function Ne(t){return t>=48&&t<=55}f.regexp_eatFixedHexDigits=function(t,e){var i=t.pos;t.lastIntValue=0;for(var s=0;s<e;++s){var r=t.current();if(!Be(r))return t.pos=i,!1;t.lastIntValue=16*t.lastIntValue+Ve(r),t.advance()}return!0};var Wt=function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new yt(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},b=w.prototype;b.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 Wt(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};b.getToken=function(){return this.next(),new Wt(this)};typeof Symbol<"u"&&(b[Symbol.iterator]=function(){var t=this;return{next:function(){var e=t.getToken();return{done:e.type===n.eof,value:e}}}});b.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(n.eof);if(t.override)return t.override(this);this.readToken(this.fullCharCodeAtPos())};b.readToken=function(t){return j(t,this.options.ecmaVersion>=6)||t===92?this.readWord():this.getTokenFromCode(t)};b.fullCharCodeAtPos=function(){var t=this.input.charCodeAt(this.pos);if(t<=55295||t>=56320)return t;var e=this.input.charCodeAt(this.pos+1);return e<=56319||e>=57344?t:(t<<10)+e-56613888};b.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 s=void 0,r=e;(s=re(this.input,r,this.pos))>-1;)++this.curLine,r=this.lineStart=s;this.options.onComment&&this.options.onComment(!0,this.input.slice(e+2,i),e,this.pos,t,this.curPosition())};b.skipLineComment=function(t){for(var e=this.pos,i=this.options.onComment&&this.curPosition(),s=this.input.charCodeAt(this.pos+=t);this.pos<this.input.length&&!X(s);)s=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())};b.skipSpace=function(){t:for(;this.pos<this.input.length;){var t=this.input.charCodeAt(this.pos);switch(t){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break t}break;default:if(t>8&&t<14||t>=5760&&ne.test(String.fromCharCode(t)))++this.pos;else break t}}};b.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)};b.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(n.ellipsis)):(++this.pos,this.finishToken(n.dot))};b.readToken_slash=function(){var t=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):t===61?this.finishOp(n.assign,2):this.finishOp(n.slash,1)};b.readToken_mult_modulo_exp=function(t){var e=this.input.charCodeAt(this.pos+1),i=1,s=t===42?n.star:n.modulo;return this.options.ecmaVersion>=7&&t===42&&e===42&&(++i,s=n.starstar,e=this.input.charCodeAt(this.pos+2)),e===61?this.finishOp(n.assign,i+1):this.finishOp(s,i)};b.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(n.assign,3)}return this.finishOp(t===124?n.logicalOR:n.logicalAND,2)}return e===61?this.finishOp(n.assign,2):this.finishOp(t===124?n.bitwiseOR:n.bitwiseAND,1)};b.readToken_caret=function(){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(n.assign,2):this.finishOp(n.bitwiseXOR,1)};b.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||L.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(n.incDec,2):e===61?this.finishOp(n.assign,2):this.finishOp(n.plusMin,1)};b.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(n.assign,i+1):this.finishOp(n.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(n.relational,i))};b.readToken_eq_excl=function(t){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(n.equality,this.input.charCodeAt(this.pos+2)===61?3:2):t===61&&e===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(n.arrow)):this.finishOp(t===61?n.eq:n.prefix,1)};b.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(n.questionDot,2)}if(e===63){if(t>=12){var s=this.input.charCodeAt(this.pos+2);if(s===61)return this.finishOp(n.assign,3)}return this.finishOp(n.coalesce,2)}}return this.finishOp(n.question,1)};b.readToken_numberSign=function(){var t=this.options.ecmaVersion,e=35;if(t>=13&&(++this.pos,e=this.fullCharCodeAtPos(),j(e,!0)||e===92))return this.finishToken(n.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+G(e)+"'")};b.getTokenFromCode=function(t){switch(t){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(n.parenL);case 41:return++this.pos,this.finishToken(n.parenR);case 59:return++this.pos,this.finishToken(n.semi);case 44:return++this.pos,this.finishToken(n.comma);case 91:return++this.pos,this.finishToken(n.bracketL);case 93:return++this.pos,this.finishToken(n.bracketR);case 123:return++this.pos,this.finishToken(n.braceL);case 125:return++this.pos,this.finishToken(n.braceR);case 58:return++this.pos,this.finishToken(n.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(n.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(n.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+G(t)+"'")};b.finishOp=function(t,e){var i=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(t,i)};b.readRegexp=function(){for(var t,e,i=this.pos;;){this.pos>=this.input.length&&this.raise(i,"Unterminated regular expression");var s=this.input.charAt(this.pos);if(L.test(s)&&this.raise(i,"Unterminated regular expression"),t)t=!1;else{if(s==="[")e=!0;else if(s==="]"&&e)e=!1;else if(s==="/"&&!e)break;t=s==="\\"}++this.pos}var r=this.input.slice(i,this.pos);++this.pos;var a=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(a);var h=this.regexpState||(this.regexpState=new q(this));h.reset(i,r,o),this.validateRegExpFlags(h),this.validateRegExpPattern(h);var u=null;try{u=new RegExp(r,o)}catch{}return this.finishToken(n.regexp,{pattern:r,flags:o,value:u})};b.readInt=function(t,e,i){for(var s=this.options.ecmaVersion>=12&&e===void 0,r=i&&this.input.charCodeAt(this.pos)===48,a=this.pos,o=0,h=0,u=0,p=e??1/0;u<p;++u,++this.pos){var l=this.input.charCodeAt(this.pos),v=void 0;if(s&&l===95){r&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),h===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),u===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),h=l;continue}if(l>=97?v=l-97+10:l>=65?v=l-65+10:l>=48&&l<=57?v=l-48:v=1/0,v>=t)break;h=l,o=o*t+v}return s&&h===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:o};function Fi(t,e){return e?parseInt(t,8):parseFloat(t.replace(/_/g,""))}function Te(t){return typeof BigInt!="function"?null:BigInt(t.replace(/_/g,""))}b.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=Te(this.input.slice(e,this.pos)),++this.pos):j(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(n.num,i)};b.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 s=this.input.charCodeAt(this.pos);if(!i&&!t&&this.options.ecmaVersion>=11&&s===110){var r=Te(this.input.slice(e,this.pos));return++this.pos,j(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(n.num,r)}i&&/[89]/.test(this.input.slice(e,this.pos))&&(i=!1),s===46&&!i&&(++this.pos,this.readInt(10),s=this.input.charCodeAt(this.pos)),(s===69||s===101)&&!i&&(s=this.input.charCodeAt(++this.pos),(s===43||s===45)&&++this.pos,this.readInt(10)===null&&this.raise(e,"Invalid number")),j(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var a=Fi(this.input.slice(e,this.pos),i);return this.finishToken(n.num,a)};b.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};b.readString=function(t){for(var e="",i=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var s=this.input.charCodeAt(this.pos);if(s===t)break;s===92?(e+=this.input.slice(i,this.pos),e+=this.readEscapedChar(!1),i=this.pos):s===8232||s===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(X(s)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return e+=this.input.slice(i,this.pos++),this.finishToken(n.string,e)};var Le={};b.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t===Le)this.readInvalidTemplateToken();else throw t}this.inTemplateElement=!1};b.invalidStringToken=function(t,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Le;this.raise(t,e)};b.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===n.template||this.type===n.invalidTemplate)?i===36?(this.pos+=2,this.finishToken(n.dollarBraceL)):(++this.pos,this.finishToken(n.backQuote)):(t+=this.input.slice(e,this.pos),this.finishToken(n.template,t));if(i===92)t+=this.input.slice(e,this.pos),t+=this.readEscapedChar(!0),e=this.pos;else if(X(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+=`
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return G(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 s=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],r=parseInt(s,8);return r>255&&(s=s.slice(0,-1),r=parseInt(s,8)),this.pos+=s.length-1,e=this.input.charCodeAt(this.pos),(s!=="0"||e===56||e===57)&&(this.strict||t)&&this.invalidStringToken(this.pos-1-s.length,t?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(r)}return X(e)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(e)}};b.readHexChar=function(t){var e=this.pos,i=this.readInt(16,t);return i===null&&this.invalidStringToken(e,"Bad character escape sequence"),i};b.readWord1=function(){this.containsEsc=!1;for(var t="",e=!0,i=this.pos,s=this.options.ecmaVersion>=6;this.pos<this.input.length;){var r=this.fullCharCodeAtPos();if(Y(r,s))this.pos+=r<=65535?1:2;else if(r===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 o=this.readCodePoint();(e?j:Y)(o,s)||this.invalidStringToken(a,"Invalid Unicode escape"),t+=G(o),i=this.pos}else break;e=!1}return t+this.input.slice(i,this.pos)};b.readWord=function(){var t=this.readWord1(),e=n.name;return this.keywords.test(t)&&(e=Rt[t]),this.finishToken(e,t)};var Ii="8.13.0";w.acorn={Parser:w,version:Ii,defaultOptions:Nt,Position:nt,SourceLocation:yt,getLineInfo:bt,Node:At,TokenType:A,tokTypes:n,keywordTypes:Rt,TokContext:V,tokContexts:k,isIdentifierChar:Y,isIdentifierStart:j,Token:Wt,isNewLine:X,lineBreak:L,lineBreakG:ti,nonASCIIwhitespace:ne};function Di(t,e,i,s,r){i||(i=c),function a(o,h,u){var p=u||o.type;i[p](o,h,a),e[p]&&e[p](o,h)}(t,s,r)}function st(t,e,i,s,r){var a=[];i||(i=c),function o(h,u,p){var l=p||h.type,v=h!==a[a.length-1];v&&a.push(h),i[l](h,u,o),e[l]&&e[l](h,u||a,a),v&&a.pop()}(t,s,r)}function Pi(t,e){var i=Object.create(e||c);for(var s in t)i[s]=t[s];return i}function Gt(t,e,i){i(t,e)}function H(t,e,i){}var c={};c.Program=c.BlockStatement=c.StaticBlock=function(t,e,i){for(var s=0,r=t.body;s<r.length;s+=1){var a=r[s];i(a,e,"Statement")}};c.Statement=Gt;c.EmptyStatement=H;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=H;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 s=0,r=t.cases;s<r.length;s+=1){var a=r[s];i(a,e)}};c.SwitchCase=function(t,e,i){t.test&&i(t.test,e,"Expression");for(var s=0,r=t.consequent;s<r.length;s+=1){var a=r[s];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=H;c.FunctionDeclaration=function(t,e,i){return i(t,e,"Function")};c.VariableDeclaration=function(t,e,i){for(var s=0,r=t.declarations;s<r.length;s+=1){var a=r[s];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 s=0,r=t.params;s<r.length;s+=1){var a=r[s];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=H;c.MemberPattern=Gt;c.RestElement=function(t,e,i){return i(t.argument,e,"Pattern")};c.ArrayPattern=function(t,e,i){for(var s=0,r=t.elements;s<r.length;s+=1){var a=r[s];a&&i(a,e,"Pattern")}};c.ObjectPattern=function(t,e,i){for(var s=0,r=t.properties;s<r.length;s+=1){var a=r[s];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=Gt;c.ThisExpression=c.Super=c.MetaProperty=H;c.ArrayExpression=function(t,e,i){for(var s=0,r=t.elements;s<r.length;s+=1){var a=r[s];a&&i(a,e,"Expression")}};c.ObjectExpression=function(t,e,i){for(var s=0,r=t.properties;s<r.length;s+=1){var a=r[s];i(a,e)}};c.FunctionExpression=c.ArrowFunctionExpression=c.FunctionDeclaration;c.SequenceExpression=function(t,e,i){for(var s=0,r=t.expressions;s<r.length;s+=1){var a=r[s];i(a,e,"Expression")}};c.TemplateLiteral=function(t,e,i){for(var s=0,r=t.quasis;s<r.length;s+=1){var a=r[s];i(a,e)}for(var o=0,h=t.expressions;o<h.length;o+=1){var u=h[o];i(u,e,"Expression")}};c.TemplateElement=H;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 s=0,r=t.arguments;s<r.length;s+=1){var a=r[s];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){t.declaration&&i(t.declaration,e,t.type==="ExportNamedDeclaration"||t.declaration.id?"Statement":"Expression"),t.source&&i(t.source,e,"Expression")};c.ExportAllDeclaration=function(t,e,i){t.exported&&i(t.exported,e),i(t.source,e,"Expression")};c.ImportDeclaration=function(t,e,i){for(var s=0,r=t.specifiers;s<r.length;s+=1){var a=r[s];i(a,e)}i(t.source,e,"Expression")};c.ImportExpression=function(t,e,i){i(t.source,e,"Expression")};c.ImportSpecifier=c.ImportDefaultSpecifier=c.ImportNamespaceSpecifier=c.Identifier=c.PrivateIdentifier=c.Literal=H;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 s=0,r=t.body;s<r.length;s+=1){var a=r[s];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")};var Re=new Set(["Array","ArrayBuffer","atob","AudioContext","Blob","Boolean","BigInt","btoa","clearInterval","clearTimeout","console","crypto","CustomEvent","DataView","Date","decodeURI","decodeURIComponent","devicePixelRatio","document","encodeURI","encodeURIComponent","Error","escape","eval","fetch","File","FileList","FileReader","Float32Array","Float64Array","Function","Headers","Image","ImageData","Infinity","Int16Array","Int32Array","Int8Array","Intl","isFinite","isNaN","JSON","Map","Math","NaN","Number","navigator","Object","parseFloat","parseInt","performance","Path2D","Promise","Proxy","RangeError","ReferenceError","Reflect","RegExp","cancelAnimationFrame","requestAnimationFrame","Set","setInterval","setTimeout","String","Symbol","SyntaxError","TextDecoder","TextEncoder","this","TypeError","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray","undefined","unescape","URIError","URL","WeakMap","WeakSet","WebSocket","Worker","window"]),rt=Pi({Import(){},ViewExpression(t,e,i){i(t.id,e,"Identifier")},MutableExpression(t,e,i){i(t.id,e,"Identifier")}});function ft(t){return t.type==="FunctionExpression"||t.type==="FunctionDeclaration"||t.type==="ArrowFunctionExpression"||t.type==="Program"}function Bi(t){return t.type==="BlockStatement"||t.type==="ForInStatement"||t.type==="ForOfStatement"||t.type==="ForStatement"||ft(t)}function Vi(t){return t.type==="FunctionExpression"||t.type==="FunctionDeclaration"}function Ni(t,e){let i={type:"Program",body:[t.body]},s=new Map,r=new Set(e),a=[];function o(d,g){let y=s.get(d);return y?y.has(g):!1}function h(d,g){let y=s.get(d);y?y.add(g.name):s.set(d,new Set([g.name]))}function u(d){d.id&&h(d,d.id)}function p(d){d.params.forEach(g=>v(g,d)),d.id&&h(d,d.id)}function l(d){d.param&&v(d.param,d)}function v(d,g){switch(d.type){case"Identifier":h(g,d);break;case"ObjectPattern":d.properties.forEach(y=>v(y,g));break;case"ArrayPattern":d.elements.forEach(y=>y&&v(y,g));break;case"Property":v(d.value,g);break;case"RestElement":v(d.argument,g);break;case"AssignmentPattern":v(d.left,g);break;default:throw new Error("Unrecognized pattern type: "+d.type)}}function S(d){h(i,d.local)}st(i,{VariableDeclaration:(d,g)=>{let y=null;for(let E=g.length-1;E>=0&&y===null;--E)(d.kind==="var"?ft(g[E]):Bi(g[E]))&&(y=g[E]);d.declarations.forEach(E=>v(E.id,y))},FunctionDeclaration:(d,g)=>{let y=null;for(let E=g.length-2;E>=0&&y===null;--E)ft(g[E])&&(y=g[E]);h(y,d.id),p(d)},Function:p,ClassDeclaration:(d,g)=>{let y=null;for(let E=g.length-2;E>=0&&y===null;E--)ft(g[E])&&(y=g[E]);h(y,d.id)},Class:u,CatchClause:l,ImportDefaultSpecifier:S,ImportSpecifier:S,ImportNamespaceSpecifier:S},rt);function D(d,g){let y=d.name;if(y!=="undefined"){for(let E=g.length-2;E>=0;--E){if(y==="arguments"&&Vi(g[E])||o(g[E],y))return;g[E].type==="ViewExpression"&&(d=g[E],y=`viewof ${d.id.name}`),g[E].type==="MutableExpression"&&(d=g[E],y=`mutable ${d.id.name}`)}if(!r.has(y)){if(y==="arguments")throw Object.assign(new SyntaxError("arguments is not allowed"),{node:d});a.push(d)}}}st(i,{VariablePattern:D,Identifier:D},rt);function I(d,g){if(d)switch(d.type){case"Identifier":case"VariablePattern":{for(let y of g)if(o(y,d.name))return;if(g[g.length-2].type==="MutableExpression")return;throw Object.assign(new SyntaxError(`Assignment to constant variable ${d.name}`),{node:d})}case"ArrayPattern":{for(let y of d.elements)I(y,g);return}case"ObjectPattern":{for(let y of d.properties)I(y,g);return}case"Property":{I(d.value,g);return}case"RestElement":{I(d.argument,g);return}}}function Q(d,g){I(d.argument,g)}function O(d,g){I(d.left,g)}return st(i,{AssignmentExpression:O,AssignmentPattern:O,UpdateExpression:Q,ForOfStatement:O,ForInStatement:O},rt),a}function dt(t,e){let i={type:"Program",body:[t.body]},s=new Map,{references:r}=t;return Di(i,{CallExpression:a=>{let{callee:o,arguments:h}=a;if(o.type!=="Identifier"||o.name!==e||r.indexOf(o)<0)return;if(h.length!==1||!(h[0].type==="Literal"&&/^['"]/.test(h[0].raw)||h[0].type==="TemplateLiteral"&&h[0].expressions.length===0))throw Object.assign(new SyntaxError(`${e} requires a single literal string argument`),{node:a});let[u]=h,p=u.type==="Literal"?u.value:u.quasis[0].value.cooked,l={start:u.start,end:u.end};s.has(p)?s.get(p).push(l):s.set(p,[l])}},rt),s}var J=2,Oe=4,Me=8;function Ti(t,{tag:e,raw:i,globals:s,...r}={}){let a;if(e!=null&&t){a=Ri.parse(t,r);let o=Mi.parse(e,r);te(o,e,s),ee(o,e),a.tag=o,a.raw=!!i}else a=zt.parse(t,r);return te(a,t,s),ee(a,t),a}var zt=class qe extends w{constructor(e,...i){super(Object.assign({ecmaVersion:13},e),...i)}enterScope(e){return e&J&&++this.O_function,super.enterScope(e)}exitScope(){return this.currentScope().flags&J&&--this.O_function,super.exitScope()}parseForIn(e,i){return this.O_function===1&&e.await&&(this.O_async=!0),super.parseForIn(e,i)}parseAwait(){return this.O_function===1&&(this.O_async=!0),super.parseAwait()}parseYield(e){return this.O_function===1&&(this.O_generator=!0),super.parseYield(e)}parseImport(e){return this.next(),e.specifiers=this.parseImportSpecifiers(),this.type===n._with&&(this.next(),e.injections=this.parseImportSpecifiers()),this.expectContextual("from"),e.source=this.type===n.string?this.parseExprAtom():this.unexpected(),this.finishNode(e,"ImportDeclaration")}parseImportSpecifiers(){let e=[],i=new Set,s=!0;for(this.expect(n.braceL);!this.eat(n.braceR);){if(s)s=!1;else if(this.expect(n.comma),this.afterTrailingComma(n.braceR))break;let r=this.startNode();r.view=this.eatContextual("viewof"),r.mutable=r.view?!1:this.eatContextual("mutable"),r.imported=this.parseIdent(),this.checkUnreserved(r.imported),this.checkLocal(r.imported),this.eatContextual("as")?(r.local=this.parseIdent(),this.checkUnreserved(r.local),this.checkLocal(r.local)):r.local=r.imported,this.checkLValSimple(r.local,"let"),i.has(r.local.name)&&this.raise(r.local.start,`Identifier '${r.local.name}' has already been declared`),i.add(r.local.name),e.push(this.finishNode(r,"ImportSpecifier"))}return e}parseExprAtom(e){return this.parseMaybeKeywordExpression("viewof","ViewExpression")||this.parseMaybeKeywordExpression("mutable","MutableExpression")||super.parseExprAtom(e)}startCell(){this.O_function=0,this.O_async=!1,this.O_generator=!1,this.strict=!0,this.enterScope(J|Oe|Me)}finishCell(e,i,s){return s&&this.checkLocal(s),e.id=s,e.body=i,e.async=this.O_async,e.generator=this.O_generator,this.exitScope(),this.finishNode(e,"Cell")}parseCell(e,i){let s=new qe({},this.input,this.start),r=s.getToken(),a=null,o=null;return this.startCell(),r.type===n._import&&s.getToken().type!==n.parenL?a=this.parseImport(this.startNode()):r.type!==n.eof&&r.type!==n.semi&&(r.type===n.name&&((r.value==="viewof"||r.value==="mutable")&&(r=s.getToken(),r.type!==n.name&&s.unexpected()),r=s.getToken(),r.type===n.eq&&(o=this.parseMaybeKeywordExpression("viewof","ViewExpression")||this.parseMaybeKeywordExpression("mutable","MutableExpression")||this.parseIdent(),r=s.getToken(),this.expect(n.eq))),r.type===n.braceL?a=this.parseBlock():(a=this.parseExpression(),o===null&&(a.type==="FunctionExpression"||a.type==="ClassExpression")&&(o=a.id))),this.semicolon(),i&&this.expect(n.eof),this.finishCell(e,a,o)}parseTopLevel(e){return this.parseCell(e,!0)}toAssignable(e,i,s){return e.type==="MutableExpression"?e:super.toAssignable(e,i,s)}checkLocal(e){let i=e.id||e;(Re.has(i.name)||i.name==="arguments")&&this.raise(i.start,`Identifier '${i.name}' is reserved`)}checkUnreserved(e){return(e.name==="viewof"||e.name==="mutable")&&this.raise(e.start,`Unexpected keyword '${e.name}'`),super.checkUnreserved(e)}checkLValSimple(e,i,s){return super.checkLValSimple(e.type==="MutableExpression"?e.id:e,i,s)}unexpected(e){this.raise(e??this.start,this.type===n.eof?"Unexpected end of input":"Unexpected token")}parseMaybeKeywordExpression(e,i){if(this.isContextual(e)){let s=this.startNode();return this.next(),s.id=this.parseIdent(),this.finishNode(s,i)}}},Li=new V("`",!0,!0,t=>Oi.call(t)),Ri=class extends zt{constructor(...t){super(...t),this.type=n.backQuote,this.exprAllowed=!1}initialContext(){return[Li]}parseCell(t){this.startCell(),this.type===n.eof&&(this.value="");let e=!0,i=this.startNode();i.expressions=[];let s=this.parseTemplateElement({isTagged:e});for(i.quasis=[s];this.type!==n.eof;)this.expect(n.dollarBraceL),i.expressions.push(this.parseExpression()),this.expect(n.braceR),i.quasis.push(s=this.parseTemplateElement({isTagged:e}));return s.tail=!0,this.next(),this.finishNode(i,"TemplateLiteral"),this.expect(n.eof),this.finishCell(t,i,null)}};function Oi(){t:for(;this.pos<this.input.length;this.pos++)switch(this.input.charCodeAt(this.pos)){case 92:{this.pos<this.input.length-1&&++this.pos;break}case 36:{if(this.input.charCodeAt(this.pos+1)===123){if(this.pos===this.start&&this.type===n.invalidTemplate)return this.pos+=2,this.finishToken(n.dollarBraceL);break t}break}}return this.finishToken(n.invalidTemplate,this.input.slice(this.start,this.pos))}var Mi=class extends w{constructor(t,...e){super(Object.assign({ecmaVersion:12},t),...e)}enterScope(t){return t&J&&++this.O_function,super.enterScope(t)}exitScope(){return this.currentScope().flags&J&&--this.O_function,super.exitScope()}parseForIn(t,e){return this.O_function===1&&t.await&&(this.O_async=!0),super.parseForIn(t,e)}parseAwait(){return this.O_function===1&&(this.O_async=!0),super.parseAwait()}parseYield(t){return this.O_function===1&&(this.O_generator=!0),super.parseYield(t)}parseTopLevel(t){return this.O_function=0,this.O_async=!1,this.O_generator=!1,this.strict=!0,this.enterScope(J|Oe|Me),t.body=this.parseExpression(),t.input=this.input,t.async=this.O_async,t.generator=this.O_generator,this.exitScope(),this.finishNode(t,"CellTag")}};function te(t,e,i=Re){if(!t.body)t.references=[];else if(t.body.type==="ImportDeclaration")t.references=t.body.injections?t.body.injections.map(s=>s.imported):[];else try{t.references=Ni(t,i)}catch(s){if(s.node){let r=bt(e,s.node.start);s.message+=` (${r.line}:${r.column})`,s.pos=s.node.start,s.loc=r,delete s.node}throw s}return t}function ee(t,e){if(t.body&&t.body.type!=="ImportDeclaration")try{t.fileAttachments=dt(t,"FileAttachment"),t.databaseClients=dt(t,"DatabaseClient"),t.secrets=dt(t,"Secret"),t.notificationClients=dt(t,"NotificationClient")}catch(i){if(i.node){let s=bt(e,i.node.start);i.message+=` (${s.line}:${s.column})`,i.pos=i.node.start,i.loc=s,delete i.node}throw i}else t.fileAttachments=new Map,t.databaseClients=new Map,t.secrets=new Map,t.notificationClients=new Map;return t}var is=Symbol("start"),ss=Symbol("modifier"),rs=Symbol("function"),ns=Symbol("name");var qi=class extends zt{parseTopLevel(t){for(t.cells||(t.cells=[]);this.type!==n.eof;){let e=this.parseCell(this.startNode());e.input=this.input,t.cells.push(e)}return this.next(),this.finishNode(t,"Program")}};function kt(t){return qi.parse(t,{ecmaVersion:"latest"}).cells.map(e=>({type:"Cell",text:t.substring(e.start,e.end),start:e.start,end:e.end}))}function wt(t){return Ti(t)}var je=rt;var pt={functionType:Object.getPrototypeOf(function(){}).constructor,asyncFunctionType:Object.getPrototypeOf(async function(){}).constructor,generatorFunctionType:Object.getPrototypeOf(function*(){}).constructor,asyncGeneratorFunctionType:Object.getPrototypeOf(async function*(){}).constructor};function ji(t=!1,e=!1){return!t&&!e?pt.functionType:t&&!e?pt.asyncFunctionType:!t&&e?pt.generatorFunctionType:pt.asyncGeneratorFunctionType}function _t(t,e=!1,i=!1,s=!1,r){if(r!==void 0)return t.patches.sort((a,o)=>o.start-a.start),t.patches.forEach(a=>{r=r.substring(0,a.start)+a.newText+r.substring(a.end)}),new(ji(e,i))(...t.args,s?r.substring(1,r.length-1).trim():`return (
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('@import"https://fonts.googleapis.com/css2?family=Source+Serif+Pro:ital,wght@0,400;0,600;0,700;1,400;1,600;1,700&display=swap";:root{--syntax-normal: #1b1e23;--syntax-comment: #828282;--syntax-number: #20a5ba;--syntax-keyword: #c30771;--syntax-atom: #10a778;--syntax-string: #008ec4;--syntax-error: #ffbedc;--syntax-unknown-variable: #838383;--syntax-known-variable: #005f87;--syntax-matchbracket: #20bbfc;--syntax-key: #6636b4;--mono-fonts: 82%/1.5 Menlo, Consolas, monospace}.observablehq--expanded,.observablehq--collapsed,.observablehq--function,.observablehq--import,.observablehq--string:before,.observablehq--string:after,.observablehq--gray{color:var(--syntax-normal)}.observablehq--collapsed,.observablehq--expanded.observablehq--inspect a{cursor:pointer}.observablehq--field{text-indent:-1em;margin-left:1em}.observablehq--empty{color:var(--syntax_comment)}a[href],.observablehq--keyword,.observablehq--blue{color:#3182bd}.hljs-deletion,.hljs-variable,.observablehq--forbidden,.observablehq--pink{color:#e377c2}.observablehq--orange{color:#e6550d}.observablehq--null,.observablehq--undefined,.observablehq--boolean,.hljs-literal{color:var(--syntax-atom)}.hljs-number,.hljs-regexp,.hljs-bullet,.hljs-link,.observablehq--bigint,.observablehq--number,.observablehq--date,.observablehq--regexp,.observablehq--symbol,.observablehq--green{color:var(--syntax-number)}.observablehq--index,.observablehq--key{color:var(--syntax-key)}.observablehq--prototype-key{color:#aaa}.observablehq--empty{font-style:oblique}.hljs-string,.hljs-meta,.hljs-symbol,.hljs-template-tag,.hljs-template-variable,.hljs-addition,.observablehq--string,.observablehq--purple{color:var(--syntax-string)}.observablehq--error,.observablehq--red{color:#e7040f}.observablehq:empty:after,.observablehq>link:only-child,.observablehq>style:only-child,.observablehq--inspect{font:var(--monospace-font);overflow-x:auto;display:block;padding:4px 0;white-space:pre}.observablehq--error .observablehq--inspect{word-break:break-all;white-space:pre-wrap}:root{--syntax-diff: #24292e;--syntax-diff-bg: #ffffff;--hr: rgba(0, 0, 0, .05);--monospace: Menlo, Consolas, monospace;--monospace-font: 14px/1.5 var(--monospace);--serif: "Source Serif Pro", "Iowan Old Style", "Apple Garamond", "Palatino Linotype", "Times New Roman", "Droid Serif", Times, serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";--sans-serif: -apple-system, BlinkMacSystemFont, "avenir next", avenir, helvetica, "helvetica neue", ubuntu, roboto, noto, "segoe ui", arial, sans-serif}html{font:17px/1.5 var(--serif);-webkit-text-size-adjust:100%;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;color:#1b1e23}body{margin:0 14px}body.fullscreen{margin:0}h1,h2,h3,h4,h5,h6{color:#333;font-weight:700;line-height:1.15;margin-top:0;margin-bottom:.25rem}h2~p,h3~p,h4~p,h2~table,h3~table,h4~table{margin-top:0}.observablehq:first-of-type h1+h2{font-size:20px;font-style:italic;font-weight:400;margin-bottom:1rem}a[href]{text-decoration:none}a[href]:hover{text-decoration:underline}h1 code,h2 code,h3 code,h4 code,h5 code,h6 code{font-size:90%}pre,code,tt{font-family:var(--monospace);font-size:14px;line-height:1.5}img{max-width:calc(100vw - 28px)}p,table,figure,figcaption,h1,h2,h3,h4,h5,h6,.katex-display{max-width:640px}blockquote,ol,ul{max-width:600px}blockquote{margin:1rem 1.5rem}ul,ol{padding-left:28px}hr{height:1px;margin:1rem 0;padding:1rem 0;border:none;background:no-repeat center/100% 1px linear-gradient(to right,var(--hr),var(--hr))}pre{padding:2px 0}.observablehq--md-pre{overflow-x:auto}input:not([type]),input[type=email],input[type=number],input[type=password],input[type=range],input[type=search],input[type=tel],input[type=text],input[type=url]{width:240px}input,canvas,button{vertical-align:middle}button,input,textarea{accent-color:#3b5fc0}table{width:100%;border-collapse:collapse;font:13px/1.2 var(--sans-serif)}table pre,table code,table tt{font-size:inherit;line-height:inherit}th>pre:only-child,td>pre:only-child{margin:0;padding:0}th{color:#111;text-align:left;vertical-align:bottom}td{color:#444;vertical-align:top}th,td{padding:3px 6.5px 3px 0}th:last-child,td:last-child{padding-right:0}tr:not(:last-child){border-bottom:solid 1px #eee}thead tr{border-bottom:solid 1px #ccc}figure,table{margin:1rem 0}figure img{max-width:100%}figcaption{font:small var(--sans-serif);color:var(--syntax-unknown-variable)}.observablehq--caret{margin-right:4px;vertical-align:baseline}.observablehq--field{text-indent:-1rem;margin-left:1rem}.observablehq--prototype-key,.observablehq--empty,.hljs-comment{color:var(--syntax-comment)}.hljs-built_in{color:var(--syntax-known-variable)}.observablehq--unknown{color:var(--syntax-unknown-variable)}.hljs-keyword,.hljs-selector-tag,.hljs-section,.hljs-doctag,.hljs-type,.hljs-tag,.hljs-name,.hljs-selector-id,.hljs-selector-class,.hljs-strong{color:var(--syntax-keyword)}.observablehq{position:relative;margin:17px 0;min-height:1.5rem}.observablehq:before{content:"";position:absolute;left:-14px;top:0;bottom:1px;width:4px;transition:background-color .25s linear}.observablehq--running:before,.observablehq--changed:before{background-color:#a9b0bc;transition:none}.observablehq--error:before{background-color:#e7040f}.observablehq:not(.observablehq--running):empty:after{content:"<detached>";color:var(--syntax-comment);font-style:oblique}.observablehq>link:only-child,.observablehq>style:only-child{visibility:hidden;white-space:nowrap;color:var(--syntax-keyword)}.observablehq>link:only-child:before{content:"<link>";visibility:visible;text-decoration:none;pointer-events:none}.observablehq>style:only-child:before{content:"<style>";visibility:visible}.observablehq--inspect.observablehq--import{white-space:normal}.observablehq--inspect::-webkit-scrollbar{display:none}.observablehq--string-expand{margin-left:6px;padding:2px 6px;border-radius:2px;font-size:80%;background:#eee;color:var(--syntax-normal);cursor:pointer;vertical-align:middle;position:sticky;right:0}.observablehq--string-expand:hover,.observablehq--string-expand:active{background:#ddd}')),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
+
var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 7, 9, 32, 4, 318, 1, 80, 3, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 68, 8, 2, 0, 3, 0, 2, 3, 2, 4, 2, 0, 15, 1, 83, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 7, 19, 58, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 343, 9, 54, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 10, 5350, 0, 7, 14, 11465, 27, 2343, 9, 87, 9, 39, 4, 60, 6, 26, 9, 535, 9, 470, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4178, 9, 519, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 245, 1, 2, 9, 726, 6, 110, 6, 6, 9, 4759, 9, 787719, 239], astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 4, 51, 13, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 39, 27, 10, 22, 251, 41, 7, 1, 17, 2, 60, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 31, 9, 2, 0, 3, 0, 2, 37, 2, 0, 26, 0, 2, 0, 45, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 200, 32, 32, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 26, 3994, 6, 582, 6842, 29, 1763, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 433, 44, 212, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 42, 9, 8936, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 229, 29, 3, 0, 496, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4153, 7, 221, 3, 5761, 15, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 4191], nonASCIIidentifierChars = "·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・", nonASCIIidentifierStartChars = "ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-Ꟑꟑꟓꟕ-ꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ", reservedWords = {
|
|
6
|
+
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",
|
|
7
|
+
5: "class enum extends super const export import",
|
|
8
|
+
6: "enum",
|
|
9
|
+
strict: "implements interface let package private protected public static yield",
|
|
10
|
+
strictBind: "eval arguments"
|
|
11
|
+
}, ecma5AndLessKeywords = "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", keywords$1 = {
|
|
12
|
+
5: ecma5AndLessKeywords,
|
|
13
|
+
"5module": ecma5AndLessKeywords + " export import",
|
|
14
|
+
6: ecma5AndLessKeywords + " const class extends export import super"
|
|
15
|
+
}, keywordRelationalOperator = /^in(stanceof)?$/, nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"), nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
|
|
16
|
+
function isInAstralSet(code, set) {
|
|
17
|
+
for (var pos = 65536, i = 0; i < set.length; i += 2) {
|
|
18
|
+
if (pos += set[i], pos > code)
|
|
19
|
+
return !1;
|
|
20
|
+
if (pos += set[i + 1], pos >= code)
|
|
21
|
+
return !0;
|
|
22
|
+
}
|
|
23
|
+
return !1;
|
|
24
|
+
}
|
|
25
|
+
function isIdentifierStart(code, astral) {
|
|
26
|
+
return code < 65 ? code === 36 : code < 91 ? !0 : code < 97 ? code === 95 : code < 123 ? !0 : code <= 65535 ? code >= 170 && nonASCIIidentifierStart.test(String.fromCharCode(code)) : astral === !1 ? !1 : isInAstralSet(code, astralIdentifierStartCodes);
|
|
27
|
+
}
|
|
28
|
+
function isIdentifierChar(code, astral) {
|
|
29
|
+
return code < 48 ? code === 36 : code < 58 ? !0 : code < 65 ? !1 : code < 91 ? !0 : code < 97 ? code === 95 : code < 123 ? !0 : code <= 65535 ? code >= 170 && nonASCIIidentifier.test(String.fromCharCode(code)) : astral === !1 ? !1 : isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
|
|
30
|
+
}
|
|
31
|
+
var TokenType = function(label, conf) {
|
|
32
|
+
conf === void 0 && (conf = {}), this.label = label, this.keyword = conf.keyword, this.beforeExpr = !!conf.beforeExpr, this.startsExpr = !!conf.startsExpr, this.isLoop = !!conf.isLoop, this.isAssign = !!conf.isAssign, this.prefix = !!conf.prefix, this.postfix = !!conf.postfix, this.binop = conf.binop || null, this.updateContext = null;
|
|
33
|
+
};
|
|
34
|
+
function binop(name, prec) {
|
|
35
|
+
return new TokenType(name, { beforeExpr: !0, binop: prec });
|
|
36
|
+
}
|
|
37
|
+
var beforeExpr = { beforeExpr: !0 }, startsExpr = { startsExpr: !0 }, keywords = {};
|
|
38
|
+
function kw(name, options) {
|
|
39
|
+
return options === void 0 && (options = {}), options.keyword = name, keywords[name] = new TokenType(name, options);
|
|
40
|
+
}
|
|
41
|
+
var types$1 = {
|
|
42
|
+
num: new TokenType("num", startsExpr),
|
|
43
|
+
regexp: new TokenType("regexp", startsExpr),
|
|
44
|
+
string: new TokenType("string", startsExpr),
|
|
45
|
+
name: new TokenType("name", startsExpr),
|
|
46
|
+
privateId: new TokenType("privateId", startsExpr),
|
|
47
|
+
eof: new TokenType("eof"),
|
|
48
|
+
// Punctuation token types.
|
|
49
|
+
bracketL: new TokenType("[", { beforeExpr: !0, startsExpr: !0 }),
|
|
50
|
+
bracketR: new TokenType("]"),
|
|
51
|
+
braceL: new TokenType("{", { beforeExpr: !0, startsExpr: !0 }),
|
|
52
|
+
braceR: new TokenType("}"),
|
|
53
|
+
parenL: new TokenType("(", { beforeExpr: !0, startsExpr: !0 }),
|
|
54
|
+
parenR: new TokenType(")"),
|
|
55
|
+
comma: new TokenType(",", beforeExpr),
|
|
56
|
+
semi: new TokenType(";", beforeExpr),
|
|
57
|
+
colon: new TokenType(":", beforeExpr),
|
|
58
|
+
dot: new TokenType("."),
|
|
59
|
+
question: new TokenType("?", beforeExpr),
|
|
60
|
+
questionDot: new TokenType("?."),
|
|
61
|
+
arrow: new TokenType("=>", beforeExpr),
|
|
62
|
+
template: new TokenType("template"),
|
|
63
|
+
invalidTemplate: new TokenType("invalidTemplate"),
|
|
64
|
+
ellipsis: new TokenType("...", beforeExpr),
|
|
65
|
+
backQuote: new TokenType("`", startsExpr),
|
|
66
|
+
dollarBraceL: new TokenType("${", { beforeExpr: !0, startsExpr: !0 }),
|
|
67
|
+
// Operators. These carry several kinds of properties to help the
|
|
68
|
+
// parser use them properly (the presence of these properties is
|
|
69
|
+
// what categorizes them as operators).
|
|
70
|
+
//
|
|
71
|
+
// `binop`, when present, specifies that this operator is a binary
|
|
72
|
+
// operator, and will refer to its precedence.
|
|
73
|
+
//
|
|
74
|
+
// `prefix` and `postfix` mark the operator as a prefix or postfix
|
|
75
|
+
// unary operator.
|
|
76
|
+
//
|
|
77
|
+
// `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as
|
|
78
|
+
// binary operators with a very low precedence, that should result
|
|
79
|
+
// in AssignmentExpression nodes.
|
|
80
|
+
eq: new TokenType("=", { beforeExpr: !0, isAssign: !0 }),
|
|
81
|
+
assign: new TokenType("_=", { beforeExpr: !0, isAssign: !0 }),
|
|
82
|
+
incDec: new TokenType("++/--", { prefix: !0, postfix: !0, startsExpr: !0 }),
|
|
83
|
+
prefix: new TokenType("!/~", { beforeExpr: !0, prefix: !0, startsExpr: !0 }),
|
|
84
|
+
logicalOR: binop("||", 1),
|
|
85
|
+
logicalAND: binop("&&", 2),
|
|
86
|
+
bitwiseOR: binop("|", 3),
|
|
87
|
+
bitwiseXOR: binop("^", 4),
|
|
88
|
+
bitwiseAND: binop("&", 5),
|
|
89
|
+
equality: binop("==/!=/===/!==", 6),
|
|
90
|
+
relational: binop("</>/<=/>=", 7),
|
|
91
|
+
bitShift: binop("<</>>/>>>", 8),
|
|
92
|
+
plusMin: new TokenType("+/-", { beforeExpr: !0, binop: 9, prefix: !0, startsExpr: !0 }),
|
|
93
|
+
modulo: binop("%", 10),
|
|
94
|
+
star: binop("*", 10),
|
|
95
|
+
slash: binop("/", 10),
|
|
96
|
+
starstar: new TokenType("**", { beforeExpr: !0 }),
|
|
97
|
+
coalesce: binop("??", 1),
|
|
98
|
+
// Keyword token types.
|
|
99
|
+
_break: kw("break"),
|
|
100
|
+
_case: kw("case", beforeExpr),
|
|
101
|
+
_catch: kw("catch"),
|
|
102
|
+
_continue: kw("continue"),
|
|
103
|
+
_debugger: kw("debugger"),
|
|
104
|
+
_default: kw("default", beforeExpr),
|
|
105
|
+
_do: kw("do", { isLoop: !0, beforeExpr: !0 }),
|
|
106
|
+
_else: kw("else", beforeExpr),
|
|
107
|
+
_finally: kw("finally"),
|
|
108
|
+
_for: kw("for", { isLoop: !0 }),
|
|
109
|
+
_function: kw("function", startsExpr),
|
|
110
|
+
_if: kw("if"),
|
|
111
|
+
_return: kw("return", beforeExpr),
|
|
112
|
+
_switch: kw("switch"),
|
|
113
|
+
_throw: kw("throw", beforeExpr),
|
|
114
|
+
_try: kw("try"),
|
|
115
|
+
_var: kw("var"),
|
|
116
|
+
_const: kw("const"),
|
|
117
|
+
_while: kw("while", { isLoop: !0 }),
|
|
118
|
+
_with: kw("with"),
|
|
119
|
+
_new: kw("new", { beforeExpr: !0, startsExpr: !0 }),
|
|
120
|
+
_this: kw("this", startsExpr),
|
|
121
|
+
_super: kw("super", startsExpr),
|
|
122
|
+
_class: kw("class", startsExpr),
|
|
123
|
+
_extends: kw("extends", beforeExpr),
|
|
124
|
+
_export: kw("export"),
|
|
125
|
+
_import: kw("import", startsExpr),
|
|
126
|
+
_null: kw("null", startsExpr),
|
|
127
|
+
_true: kw("true", startsExpr),
|
|
128
|
+
_false: kw("false", startsExpr),
|
|
129
|
+
_in: kw("in", { beforeExpr: !0, binop: 7 }),
|
|
130
|
+
_instanceof: kw("instanceof", { beforeExpr: !0, binop: 7 }),
|
|
131
|
+
_typeof: kw("typeof", { beforeExpr: !0, prefix: !0, startsExpr: !0 }),
|
|
132
|
+
_void: kw("void", { beforeExpr: !0, prefix: !0, startsExpr: !0 }),
|
|
133
|
+
_delete: kw("delete", { beforeExpr: !0, prefix: !0, startsExpr: !0 })
|
|
134
|
+
}, lineBreak = /\r\n?|\n|\u2028|\u2029/, lineBreakG = new RegExp(lineBreak.source, "g");
|
|
135
|
+
function isNewLine(code) {
|
|
136
|
+
return code === 10 || code === 13 || code === 8232 || code === 8233;
|
|
137
|
+
}
|
|
138
|
+
function nextLineBreak(code, from, end) {
|
|
139
|
+
end === void 0 && (end = code.length);
|
|
140
|
+
for (var i = from; i < end; i++) {
|
|
141
|
+
var next = code.charCodeAt(i);
|
|
142
|
+
if (isNewLine(next))
|
|
143
|
+
return i < end - 1 && next === 13 && code.charCodeAt(i + 1) === 10 ? i + 2 : i + 1;
|
|
144
|
+
}
|
|
145
|
+
return -1;
|
|
146
|
+
}
|
|
147
|
+
var nonASCIIwhitespace = /[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/, skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g, ref = Object.prototype, hasOwnProperty = ref.hasOwnProperty, toString = ref.toString, hasOwn = Object.hasOwn || function(obj, propName) {
|
|
148
|
+
return hasOwnProperty.call(obj, propName);
|
|
149
|
+
}, isArray = Array.isArray || function(obj) {
|
|
150
|
+
return toString.call(obj) === "[object Array]";
|
|
151
|
+
}, regexpCache = /* @__PURE__ */ Object.create(null);
|
|
152
|
+
function wordsRegexp(words) {
|
|
153
|
+
return regexpCache[words] || (regexpCache[words] = new RegExp("^(?:" + words.replace(/ /g, "|") + ")$"));
|
|
154
|
+
}
|
|
155
|
+
function codePointToString(code) {
|
|
156
|
+
return code <= 65535 ? String.fromCharCode(code) : (code -= 65536, String.fromCharCode((code >> 10) + 55296, (code & 1023) + 56320));
|
|
157
|
+
}
|
|
158
|
+
var loneSurrogate = /(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/, Position = function(line, col) {
|
|
159
|
+
this.line = line, this.column = col;
|
|
160
|
+
};
|
|
161
|
+
Position.prototype.offset = function(n) {
|
|
162
|
+
return new Position(this.line, this.column + n);
|
|
163
|
+
};
|
|
164
|
+
var SourceLocation = function(p, start, end) {
|
|
165
|
+
this.start = start, this.end = end, p.sourceFile !== null && (this.source = p.sourceFile);
|
|
166
|
+
};
|
|
167
|
+
function getLineInfo(input, offset2) {
|
|
168
|
+
for (var line = 1, cur = 0; ; ) {
|
|
169
|
+
var nextBreak = nextLineBreak(input, cur, offset2);
|
|
170
|
+
if (nextBreak < 0)
|
|
171
|
+
return new Position(line, offset2 - cur);
|
|
172
|
+
++line, cur = nextBreak;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
var defaultOptions = {
|
|
176
|
+
// `ecmaVersion` indicates the ECMAScript version to parse. Must be
|
|
177
|
+
// either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10
|
|
178
|
+
// (2019), 11 (2020), 12 (2021), 13 (2022), 14 (2023), or `"latest"`
|
|
179
|
+
// (the latest version the library supports). This influences
|
|
180
|
+
// support for strict mode, the set of reserved words, and support
|
|
181
|
+
// for new syntax features.
|
|
182
|
+
ecmaVersion: null,
|
|
183
|
+
// `sourceType` indicates the mode the code should be parsed in.
|
|
184
|
+
// Can be either `"script"` or `"module"`. This influences global
|
|
185
|
+
// strict mode and parsing of `import` and `export` declarations.
|
|
186
|
+
sourceType: "script",
|
|
187
|
+
// `onInsertedSemicolon` can be a callback that will be called when
|
|
188
|
+
// a semicolon is automatically inserted. It will be passed the
|
|
189
|
+
// position of the inserted semicolon as an offset, and if
|
|
190
|
+
// `locations` is enabled, it is given the location as a `{line,
|
|
191
|
+
// column}` object as second argument.
|
|
192
|
+
onInsertedSemicolon: null,
|
|
193
|
+
// `onTrailingComma` is similar to `onInsertedSemicolon`, but for
|
|
194
|
+
// trailing commas.
|
|
195
|
+
onTrailingComma: null,
|
|
196
|
+
// By default, reserved words are only enforced if ecmaVersion >= 5.
|
|
197
|
+
// Set `allowReserved` to a boolean value to explicitly turn this on
|
|
198
|
+
// an off. When this option has the value "never", reserved words
|
|
199
|
+
// and keywords can also not be used as property names.
|
|
200
|
+
allowReserved: null,
|
|
201
|
+
// When enabled, a return at the top level is not considered an
|
|
202
|
+
// error.
|
|
203
|
+
allowReturnOutsideFunction: !1,
|
|
204
|
+
// When enabled, import/export statements are not constrained to
|
|
205
|
+
// appearing at the top of the program, and an import.meta expression
|
|
206
|
+
// in a script isn't considered an error.
|
|
207
|
+
allowImportExportEverywhere: !1,
|
|
208
|
+
// By default, await identifiers are allowed to appear at the top-level scope only if ecmaVersion >= 2022.
|
|
209
|
+
// When enabled, await identifiers are allowed to appear at the top-level scope,
|
|
210
|
+
// but they are still not allowed in non-async functions.
|
|
211
|
+
allowAwaitOutsideFunction: null,
|
|
212
|
+
// When enabled, super identifiers are not constrained to
|
|
213
|
+
// appearing in methods and do not raise an error when they appear elsewhere.
|
|
214
|
+
allowSuperOutsideMethod: null,
|
|
215
|
+
// When enabled, hashbang directive in the beginning of file is
|
|
216
|
+
// allowed and treated as a line comment. Enabled by default when
|
|
217
|
+
// `ecmaVersion` >= 2023.
|
|
218
|
+
allowHashBang: !1,
|
|
219
|
+
// By default, the parser will verify that private properties are
|
|
220
|
+
// only used in places where they are valid and have been declared.
|
|
221
|
+
// Set this to false to turn such checks off.
|
|
222
|
+
checkPrivateFields: !0,
|
|
223
|
+
// When `locations` is on, `loc` properties holding objects with
|
|
224
|
+
// `start` and `end` properties in `{line, column}` form (with
|
|
225
|
+
// line being 1-based and column 0-based) will be attached to the
|
|
226
|
+
// nodes.
|
|
227
|
+
locations: !1,
|
|
228
|
+
// A function can be passed as `onToken` option, which will
|
|
229
|
+
// cause Acorn to call that function with object in the same
|
|
230
|
+
// format as tokens returned from `tokenizer().getToken()`. Note
|
|
231
|
+
// that you are not allowed to call the parser from the
|
|
232
|
+
// callback—that will corrupt its internal state.
|
|
233
|
+
onToken: null,
|
|
234
|
+
// A function can be passed as `onComment` option, which will
|
|
235
|
+
// cause Acorn to call that function with `(block, text, start,
|
|
236
|
+
// end)` parameters whenever a comment is skipped. `block` is a
|
|
237
|
+
// boolean indicating whether this is a block (`/* */`) comment,
|
|
238
|
+
// `text` is the content of the comment, and `start` and `end` are
|
|
239
|
+
// character offsets that denote the start and end of the comment.
|
|
240
|
+
// When the `locations` option is on, two more parameters are
|
|
241
|
+
// passed, the full `{line, column}` locations of the start and
|
|
242
|
+
// end of the comments. Note that you are not allowed to call the
|
|
243
|
+
// parser from the callback—that will corrupt its internal state.
|
|
244
|
+
// When this option has an array as value, objects representing the
|
|
245
|
+
// comments are pushed to it.
|
|
246
|
+
onComment: null,
|
|
247
|
+
// Nodes have their start and end characters offsets recorded in
|
|
248
|
+
// `start` and `end` properties (directly on the node, rather than
|
|
249
|
+
// the `loc` object, which holds line/column data. To also add a
|
|
250
|
+
// [semi-standardized][range] `range` property holding a `[start,
|
|
251
|
+
// end]` array with the same numbers, set the `ranges` option to
|
|
252
|
+
// `true`.
|
|
253
|
+
//
|
|
254
|
+
// [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
|
|
255
|
+
ranges: !1,
|
|
256
|
+
// It is possible to parse multiple files into a single AST by
|
|
257
|
+
// passing the tree produced by parsing the first file as
|
|
258
|
+
// `program` option in subsequent parses. This will add the
|
|
259
|
+
// toplevel forms of the parsed file to the `Program` (top) node
|
|
260
|
+
// of an existing parse tree.
|
|
261
|
+
program: null,
|
|
262
|
+
// When `locations` is on, you can pass this to record the source
|
|
263
|
+
// file in every node's `loc` object.
|
|
264
|
+
sourceFile: null,
|
|
265
|
+
// This value, if given, is stored in every node, whether
|
|
266
|
+
// `locations` is on or off.
|
|
267
|
+
directSourceFile: null,
|
|
268
|
+
// When enabled, parenthesized expressions are represented by
|
|
269
|
+
// (non-standard) ParenthesizedExpression nodes
|
|
270
|
+
preserveParens: !1
|
|
271
|
+
}, warnedAboutEcmaVersion = !1;
|
|
272
|
+
function getOptions(opts) {
|
|
273
|
+
var options = {};
|
|
274
|
+
for (var opt in defaultOptions)
|
|
275
|
+
options[opt] = opts && hasOwn(opts, opt) ? opts[opt] : defaultOptions[opt];
|
|
276
|
+
if (options.ecmaVersion === "latest" ? options.ecmaVersion = 1e8 : options.ecmaVersion == null ? (!warnedAboutEcmaVersion && typeof console == "object" && console.warn && (warnedAboutEcmaVersion = !0, console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
277
|
+
Defaulting to 2020, but this will stop working in the future.`)), options.ecmaVersion = 11) : options.ecmaVersion >= 2015 && (options.ecmaVersion -= 2009), options.allowReserved == null && (options.allowReserved = options.ecmaVersion < 5), (!opts || opts.allowHashBang == null) && (options.allowHashBang = options.ecmaVersion >= 14), isArray(options.onToken)) {
|
|
278
|
+
var tokens = options.onToken;
|
|
279
|
+
options.onToken = function(token) {
|
|
280
|
+
return tokens.push(token);
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
return isArray(options.onComment) && (options.onComment = pushComment(options, options.onComment)), options;
|
|
284
|
+
}
|
|
285
|
+
function pushComment(options, array) {
|
|
286
|
+
return function(block, text, start, end, startLoc, endLoc) {
|
|
287
|
+
var comment = {
|
|
288
|
+
type: block ? "Block" : "Line",
|
|
289
|
+
value: text,
|
|
290
|
+
start,
|
|
291
|
+
end
|
|
292
|
+
};
|
|
293
|
+
options.locations && (comment.loc = new SourceLocation(this, startLoc, endLoc)), options.ranges && (comment.range = [start, end]), array.push(comment);
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
var SCOPE_TOP = 1, SCOPE_FUNCTION$1 = 2, SCOPE_ASYNC$1 = 4, SCOPE_GENERATOR$1 = 8, SCOPE_ARROW = 16, SCOPE_SIMPLE_CATCH = 32, SCOPE_SUPER = 64, SCOPE_DIRECT_SUPER = 128, SCOPE_CLASS_STATIC_BLOCK = 256, SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION$1 | SCOPE_CLASS_STATIC_BLOCK;
|
|
297
|
+
function functionFlags(async, generator) {
|
|
298
|
+
return SCOPE_FUNCTION$1 | (async ? SCOPE_ASYNC$1 : 0) | (generator ? SCOPE_GENERATOR$1 : 0);
|
|
299
|
+
}
|
|
300
|
+
var BIND_NONE = 0, BIND_VAR = 1, BIND_LEXICAL = 2, BIND_FUNCTION = 3, BIND_SIMPLE_CATCH = 4, BIND_OUTSIDE = 5, Parser = function(options, input, startPos) {
|
|
301
|
+
this.options = options = getOptions(options), this.sourceFile = options.sourceFile, this.keywords = wordsRegexp(keywords$1[options.ecmaVersion >= 6 ? 6 : options.sourceType === "module" ? "5module" : 5]);
|
|
302
|
+
var reserved = "";
|
|
303
|
+
options.allowReserved !== !0 && (reserved = reservedWords[options.ecmaVersion >= 6 ? 6 : options.ecmaVersion === 5 ? 5 : 3], options.sourceType === "module" && (reserved += " await")), this.reservedWords = wordsRegexp(reserved);
|
|
304
|
+
var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict;
|
|
305
|
+
this.reservedWordsStrict = wordsRegexp(reservedStrict), this.reservedWordsStrictBind = wordsRegexp(reservedStrict + " " + reservedWords.strictBind), this.input = String(input), this.containsEsc = !1, startPos ? (this.pos = startPos, this.lineStart = this.input.lastIndexOf(`
|
|
306
|
+
`, startPos - 1) + 1, this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length) : (this.pos = this.lineStart = 0, this.curLine = 1), this.type = types$1.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 = options.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 = /* @__PURE__ */ Object.create(null), this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === "#!" && this.skipLineComment(2), this.scopeStack = [], this.enterScope(SCOPE_TOP), this.regexpState = null, this.privateNameStack = [];
|
|
307
|
+
}, prototypeAccessors = { inFunction: { configurable: !0 }, inGenerator: { configurable: !0 }, inAsync: { configurable: !0 }, canAwait: { configurable: !0 }, allowSuper: { configurable: !0 }, allowDirectSuper: { configurable: !0 }, treatFunctionsAsVar: { configurable: !0 }, allowNewDotTarget: { configurable: !0 }, inClassStaticBlock: { configurable: !0 } };
|
|
308
|
+
Parser.prototype.parse = function() {
|
|
309
|
+
var node = this.options.program || this.startNode();
|
|
310
|
+
return this.nextToken(), this.parseTopLevel(node);
|
|
311
|
+
};
|
|
312
|
+
prototypeAccessors.inFunction.get = function() {
|
|
313
|
+
return (this.currentVarScope().flags & SCOPE_FUNCTION$1) > 0;
|
|
314
|
+
};
|
|
315
|
+
prototypeAccessors.inGenerator.get = function() {
|
|
316
|
+
return (this.currentVarScope().flags & SCOPE_GENERATOR$1) > 0 && !this.currentVarScope().inClassFieldInit;
|
|
317
|
+
};
|
|
318
|
+
prototypeAccessors.inAsync.get = function() {
|
|
319
|
+
return (this.currentVarScope().flags & SCOPE_ASYNC$1) > 0 && !this.currentVarScope().inClassFieldInit;
|
|
320
|
+
};
|
|
321
|
+
prototypeAccessors.canAwait.get = function() {
|
|
322
|
+
for (var i = this.scopeStack.length - 1; i >= 0; i--) {
|
|
323
|
+
var scope = this.scopeStack[i];
|
|
324
|
+
if (scope.inClassFieldInit || scope.flags & SCOPE_CLASS_STATIC_BLOCK)
|
|
325
|
+
return !1;
|
|
326
|
+
if (scope.flags & SCOPE_FUNCTION$1)
|
|
327
|
+
return (scope.flags & SCOPE_ASYNC$1) > 0;
|
|
328
|
+
}
|
|
329
|
+
return this.inModule && this.options.ecmaVersion >= 13 || this.options.allowAwaitOutsideFunction;
|
|
330
|
+
};
|
|
331
|
+
prototypeAccessors.allowSuper.get = function() {
|
|
332
|
+
var ref2 = this.currentThisScope(), flags = ref2.flags, inClassFieldInit = ref2.inClassFieldInit;
|
|
333
|
+
return (flags & SCOPE_SUPER) > 0 || inClassFieldInit || this.options.allowSuperOutsideMethod;
|
|
334
|
+
};
|
|
335
|
+
prototypeAccessors.allowDirectSuper.get = function() {
|
|
336
|
+
return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0;
|
|
337
|
+
};
|
|
338
|
+
prototypeAccessors.treatFunctionsAsVar.get = function() {
|
|
339
|
+
return this.treatFunctionsAsVarInScope(this.currentScope());
|
|
340
|
+
};
|
|
341
|
+
prototypeAccessors.allowNewDotTarget.get = function() {
|
|
342
|
+
var ref2 = this.currentThisScope(), flags = ref2.flags, inClassFieldInit = ref2.inClassFieldInit;
|
|
343
|
+
return (flags & (SCOPE_FUNCTION$1 | SCOPE_CLASS_STATIC_BLOCK)) > 0 || inClassFieldInit;
|
|
344
|
+
};
|
|
345
|
+
prototypeAccessors.inClassStaticBlock.get = function() {
|
|
346
|
+
return (this.currentVarScope().flags & SCOPE_CLASS_STATIC_BLOCK) > 0;
|
|
347
|
+
};
|
|
348
|
+
Parser.extend = function() {
|
|
349
|
+
for (var plugins = [], len = arguments.length; len--; ) plugins[len] = arguments[len];
|
|
350
|
+
for (var cls = this, i = 0; i < plugins.length; i++)
|
|
351
|
+
cls = plugins[i](cls);
|
|
352
|
+
return cls;
|
|
353
|
+
};
|
|
354
|
+
Parser.parse = function(input, options) {
|
|
355
|
+
return new this(options, input).parse();
|
|
356
|
+
};
|
|
357
|
+
Parser.parseExpressionAt = function(input, pos, options) {
|
|
358
|
+
var parser = new this(options, input, pos);
|
|
359
|
+
return parser.nextToken(), parser.parseExpression();
|
|
360
|
+
};
|
|
361
|
+
Parser.tokenizer = function(input, options) {
|
|
362
|
+
return new this(options, input);
|
|
363
|
+
};
|
|
364
|
+
Object.defineProperties(Parser.prototype, prototypeAccessors);
|
|
365
|
+
var pp$9 = Parser.prototype, literal = /^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;
|
|
366
|
+
pp$9.strictDirective = function(start) {
|
|
367
|
+
if (this.options.ecmaVersion < 5)
|
|
368
|
+
return !1;
|
|
369
|
+
for (; ; ) {
|
|
370
|
+
skipWhiteSpace.lastIndex = start, start += skipWhiteSpace.exec(this.input)[0].length;
|
|
371
|
+
var match = literal.exec(this.input.slice(start));
|
|
372
|
+
if (!match)
|
|
373
|
+
return !1;
|
|
374
|
+
if ((match[1] || match[2]) === "use strict") {
|
|
375
|
+
skipWhiteSpace.lastIndex = start + match[0].length;
|
|
376
|
+
var spaceAfter = skipWhiteSpace.exec(this.input), end = spaceAfter.index + spaceAfter[0].length, next = this.input.charAt(end);
|
|
377
|
+
return next === ";" || next === "}" || lineBreak.test(spaceAfter[0]) && !(/[(`.[+\-/*%<>=,?^&]/.test(next) || next === "!" && this.input.charAt(end + 1) === "=");
|
|
378
|
+
}
|
|
379
|
+
start += match[0].length, skipWhiteSpace.lastIndex = start, start += skipWhiteSpace.exec(this.input)[0].length, this.input[start] === ";" && start++;
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
pp$9.eat = function(type) {
|
|
383
|
+
return this.type === type ? (this.next(), !0) : !1;
|
|
384
|
+
};
|
|
385
|
+
pp$9.isContextual = function(name) {
|
|
386
|
+
return this.type === types$1.name && this.value === name && !this.containsEsc;
|
|
387
|
+
};
|
|
388
|
+
pp$9.eatContextual = function(name) {
|
|
389
|
+
return this.isContextual(name) ? (this.next(), !0) : !1;
|
|
390
|
+
};
|
|
391
|
+
pp$9.expectContextual = function(name) {
|
|
392
|
+
this.eatContextual(name) || this.unexpected();
|
|
393
|
+
};
|
|
394
|
+
pp$9.canInsertSemicolon = function() {
|
|
395
|
+
return this.type === types$1.eof || this.type === types$1.braceR || lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
|
|
396
|
+
};
|
|
397
|
+
pp$9.insertSemicolon = function() {
|
|
398
|
+
if (this.canInsertSemicolon())
|
|
399
|
+
return this.options.onInsertedSemicolon && this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc), !0;
|
|
400
|
+
};
|
|
401
|
+
pp$9.semicolon = function() {
|
|
402
|
+
!this.eat(types$1.semi) && !this.insertSemicolon() && this.unexpected();
|
|
403
|
+
};
|
|
404
|
+
pp$9.afterTrailingComma = function(tokType, notNext) {
|
|
405
|
+
if (this.type === tokType)
|
|
406
|
+
return this.options.onTrailingComma && this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc), notNext || this.next(), !0;
|
|
407
|
+
};
|
|
408
|
+
pp$9.expect = function(type) {
|
|
409
|
+
this.eat(type) || this.unexpected();
|
|
410
|
+
};
|
|
411
|
+
pp$9.unexpected = function(pos) {
|
|
412
|
+
this.raise(pos ?? this.start, "Unexpected token");
|
|
413
|
+
};
|
|
414
|
+
var DestructuringErrors = function() {
|
|
415
|
+
this.shorthandAssign = this.trailingComma = this.parenthesizedAssign = this.parenthesizedBind = this.doubleProto = -1;
|
|
416
|
+
};
|
|
417
|
+
pp$9.checkPatternErrors = function(refDestructuringErrors, isAssign) {
|
|
418
|
+
if (refDestructuringErrors) {
|
|
419
|
+
refDestructuringErrors.trailingComma > -1 && this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element");
|
|
420
|
+
var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;
|
|
421
|
+
parens > -1 && this.raiseRecoverable(parens, isAssign ? "Assigning to rvalue" : "Parenthesized pattern");
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
pp$9.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
|
|
425
|
+
if (!refDestructuringErrors)
|
|
426
|
+
return !1;
|
|
427
|
+
var shorthandAssign = refDestructuringErrors.shorthandAssign, doubleProto = refDestructuringErrors.doubleProto;
|
|
428
|
+
if (!andThrow)
|
|
429
|
+
return shorthandAssign >= 0 || doubleProto >= 0;
|
|
430
|
+
shorthandAssign >= 0 && this.raise(shorthandAssign, "Shorthand property assignments are valid only in destructuring patterns"), doubleProto >= 0 && this.raiseRecoverable(doubleProto, "Redefinition of __proto__ property");
|
|
431
|
+
};
|
|
432
|
+
pp$9.checkYieldAwaitInDefaultParams = function() {
|
|
433
|
+
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");
|
|
434
|
+
};
|
|
435
|
+
pp$9.isSimpleAssignTarget = function(expr) {
|
|
436
|
+
return expr.type === "ParenthesizedExpression" ? this.isSimpleAssignTarget(expr.expression) : expr.type === "Identifier" || expr.type === "MemberExpression";
|
|
437
|
+
};
|
|
438
|
+
var pp$8 = Parser.prototype;
|
|
439
|
+
pp$8.parseTopLevel = function(node) {
|
|
440
|
+
var exports = /* @__PURE__ */ Object.create(null);
|
|
441
|
+
for (node.body || (node.body = []); this.type !== types$1.eof; ) {
|
|
442
|
+
var stmt = this.parseStatement(null, !0, exports);
|
|
443
|
+
node.body.push(stmt);
|
|
444
|
+
}
|
|
445
|
+
if (this.inModule)
|
|
446
|
+
for (var i = 0, list = Object.keys(this.undefinedExports); i < list.length; i += 1) {
|
|
447
|
+
var name = list[i];
|
|
448
|
+
this.raiseRecoverable(this.undefinedExports[name].start, "Export '" + name + "' is not defined");
|
|
449
|
+
}
|
|
450
|
+
return this.adaptDirectivePrologue(node.body), this.next(), node.sourceType = this.options.sourceType, this.finishNode(node, "Program");
|
|
451
|
+
};
|
|
452
|
+
var loopLabel = { kind: "loop" }, switchLabel = { kind: "switch" };
|
|
453
|
+
pp$8.isLet = function(context) {
|
|
454
|
+
if (this.options.ecmaVersion < 6 || !this.isContextual("let"))
|
|
455
|
+
return !1;
|
|
456
|
+
skipWhiteSpace.lastIndex = this.pos;
|
|
457
|
+
var skip = skipWhiteSpace.exec(this.input), next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
|
|
458
|
+
if (nextCh === 91 || nextCh === 92)
|
|
459
|
+
return !0;
|
|
460
|
+
if (context)
|
|
461
|
+
return !1;
|
|
462
|
+
if (nextCh === 123 || nextCh > 55295 && nextCh < 56320)
|
|
463
|
+
return !0;
|
|
464
|
+
if (isIdentifierStart(nextCh, !0)) {
|
|
465
|
+
for (var pos = next + 1; isIdentifierChar(nextCh = this.input.charCodeAt(pos), !0); )
|
|
466
|
+
++pos;
|
|
467
|
+
if (nextCh === 92 || nextCh > 55295 && nextCh < 56320)
|
|
468
|
+
return !0;
|
|
469
|
+
var ident = this.input.slice(next, pos);
|
|
470
|
+
if (!keywordRelationalOperator.test(ident))
|
|
471
|
+
return !0;
|
|
472
|
+
}
|
|
473
|
+
return !1;
|
|
474
|
+
};
|
|
475
|
+
pp$8.isAsyncFunction = function() {
|
|
476
|
+
if (this.options.ecmaVersion < 8 || !this.isContextual("async"))
|
|
477
|
+
return !1;
|
|
478
|
+
skipWhiteSpace.lastIndex = this.pos;
|
|
479
|
+
var skip = skipWhiteSpace.exec(this.input), next = this.pos + skip[0].length, after;
|
|
480
|
+
return !lineBreak.test(this.input.slice(this.pos, next)) && this.input.slice(next, next + 8) === "function" && (next + 8 === this.input.length || !(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 55295 && after < 56320));
|
|
481
|
+
};
|
|
482
|
+
pp$8.parseStatement = function(context, topLevel, exports) {
|
|
483
|
+
var starttype = this.type, node = this.startNode(), kind;
|
|
484
|
+
switch (this.isLet(context) && (starttype = types$1._var, kind = "let"), starttype) {
|
|
485
|
+
case types$1._break:
|
|
486
|
+
case types$1._continue:
|
|
487
|
+
return this.parseBreakContinueStatement(node, starttype.keyword);
|
|
488
|
+
case types$1._debugger:
|
|
489
|
+
return this.parseDebuggerStatement(node);
|
|
490
|
+
case types$1._do:
|
|
491
|
+
return this.parseDoStatement(node);
|
|
492
|
+
case types$1._for:
|
|
493
|
+
return this.parseForStatement(node);
|
|
494
|
+
case types$1._function:
|
|
495
|
+
return context && (this.strict || context !== "if" && context !== "label") && this.options.ecmaVersion >= 6 && this.unexpected(), this.parseFunctionStatement(node, !1, !context);
|
|
496
|
+
case types$1._class:
|
|
497
|
+
return context && this.unexpected(), this.parseClass(node, !0);
|
|
498
|
+
case types$1._if:
|
|
499
|
+
return this.parseIfStatement(node);
|
|
500
|
+
case types$1._return:
|
|
501
|
+
return this.parseReturnStatement(node);
|
|
502
|
+
case types$1._switch:
|
|
503
|
+
return this.parseSwitchStatement(node);
|
|
504
|
+
case types$1._throw:
|
|
505
|
+
return this.parseThrowStatement(node);
|
|
506
|
+
case types$1._try:
|
|
507
|
+
return this.parseTryStatement(node);
|
|
508
|
+
case types$1._const:
|
|
509
|
+
case types$1._var:
|
|
510
|
+
return kind = kind || this.value, context && kind !== "var" && this.unexpected(), this.parseVarStatement(node, kind);
|
|
511
|
+
case types$1._while:
|
|
512
|
+
return this.parseWhileStatement(node);
|
|
513
|
+
case types$1._with:
|
|
514
|
+
return this.parseWithStatement(node);
|
|
515
|
+
case types$1.braceL:
|
|
516
|
+
return this.parseBlock(!0, node);
|
|
517
|
+
case types$1.semi:
|
|
518
|
+
return this.parseEmptyStatement(node);
|
|
519
|
+
case types$1._export:
|
|
520
|
+
case types$1._import:
|
|
521
|
+
if (this.options.ecmaVersion > 10 && starttype === types$1._import) {
|
|
522
|
+
skipWhiteSpace.lastIndex = this.pos;
|
|
523
|
+
var skip = skipWhiteSpace.exec(this.input), next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
|
|
524
|
+
if (nextCh === 40 || nextCh === 46)
|
|
525
|
+
return this.parseExpressionStatement(node, this.parseExpression());
|
|
526
|
+
}
|
|
527
|
+
return this.options.allowImportExportEverywhere || (topLevel || 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'")), starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports);
|
|
528
|
+
// If the statement does not start with a statement keyword or a
|
|
529
|
+
// brace, it's an ExpressionStatement or LabeledStatement. We
|
|
530
|
+
// simply start parsing an expression, and afterwards, if the
|
|
531
|
+
// next token is a colon and the expression was a simple
|
|
532
|
+
// Identifier node, we switch to interpreting it as a label.
|
|
533
|
+
default:
|
|
534
|
+
if (this.isAsyncFunction())
|
|
535
|
+
return context && this.unexpected(), this.next(), this.parseFunctionStatement(node, !0, !context);
|
|
536
|
+
var maybeName = this.value, expr = this.parseExpression();
|
|
537
|
+
return starttype === types$1.name && expr.type === "Identifier" && this.eat(types$1.colon) ? this.parseLabeledStatement(node, maybeName, expr, context) : this.parseExpressionStatement(node, expr);
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
pp$8.parseBreakContinueStatement = function(node, keyword) {
|
|
541
|
+
var isBreak = keyword === "break";
|
|
542
|
+
this.next(), this.eat(types$1.semi) || this.insertSemicolon() ? node.label = null : this.type !== types$1.name ? this.unexpected() : (node.label = this.parseIdent(), this.semicolon());
|
|
543
|
+
for (var i = 0; i < this.labels.length; ++i) {
|
|
544
|
+
var lab = this.labels[i];
|
|
545
|
+
if ((node.label == null || lab.name === node.label.name) && (lab.kind != null && (isBreak || lab.kind === "loop") || node.label && isBreak))
|
|
546
|
+
break;
|
|
547
|
+
}
|
|
548
|
+
return i === this.labels.length && this.raise(node.start, "Unsyntactic " + keyword), this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
|
|
549
|
+
};
|
|
550
|
+
pp$8.parseDebuggerStatement = function(node) {
|
|
551
|
+
return this.next(), this.semicolon(), this.finishNode(node, "DebuggerStatement");
|
|
552
|
+
};
|
|
553
|
+
pp$8.parseDoStatement = function(node) {
|
|
554
|
+
return this.next(), this.labels.push(loopLabel), node.body = this.parseStatement("do"), this.labels.pop(), this.expect(types$1._while), node.test = this.parseParenExpression(), this.options.ecmaVersion >= 6 ? this.eat(types$1.semi) : this.semicolon(), this.finishNode(node, "DoWhileStatement");
|
|
555
|
+
};
|
|
556
|
+
pp$8.parseForStatement = function(node) {
|
|
557
|
+
this.next();
|
|
558
|
+
var awaitAt = this.options.ecmaVersion >= 9 && this.canAwait && this.eatContextual("await") ? this.lastTokStart : -1;
|
|
559
|
+
if (this.labels.push(loopLabel), this.enterScope(0), this.expect(types$1.parenL), this.type === types$1.semi)
|
|
560
|
+
return awaitAt > -1 && this.unexpected(awaitAt), this.parseFor(node, null);
|
|
561
|
+
var isLet = this.isLet();
|
|
562
|
+
if (this.type === types$1._var || this.type === types$1._const || isLet) {
|
|
563
|
+
var init$1 = this.startNode(), kind = isLet ? "let" : this.value;
|
|
564
|
+
return this.next(), this.parseVar(init$1, !0, kind), this.finishNode(init$1, "VariableDeclaration"), (this.type === types$1._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) && init$1.declarations.length === 1 ? (this.options.ecmaVersion >= 9 && (this.type === types$1._in ? awaitAt > -1 && this.unexpected(awaitAt) : node.await = awaitAt > -1), this.parseForIn(node, init$1)) : (awaitAt > -1 && this.unexpected(awaitAt), this.parseFor(node, init$1));
|
|
565
|
+
}
|
|
566
|
+
var startsWithLet = this.isContextual("let"), isForOf = !1, containsEsc = this.containsEsc, refDestructuringErrors = new DestructuringErrors(), initPos = this.start, init = awaitAt > -1 ? this.parseExprSubscripts(refDestructuringErrors, "await") : this.parseExpression(!0, refDestructuringErrors);
|
|
567
|
+
return this.type === types$1._in || (isForOf = this.options.ecmaVersion >= 6 && this.isContextual("of")) ? (awaitAt > -1 ? (this.type === types$1._in && this.unexpected(awaitAt), node.await = !0) : isForOf && this.options.ecmaVersion >= 8 && (init.start === initPos && !containsEsc && init.type === "Identifier" && init.name === "async" ? this.unexpected() : this.options.ecmaVersion >= 9 && (node.await = !1)), startsWithLet && isForOf && this.raise(init.start, "The left-hand side of a for-of loop may not start with 'let'."), this.toAssignable(init, !1, refDestructuringErrors), this.checkLValPattern(init), this.parseForIn(node, init)) : (this.checkExpressionErrors(refDestructuringErrors, !0), awaitAt > -1 && this.unexpected(awaitAt), this.parseFor(node, init));
|
|
568
|
+
};
|
|
569
|
+
pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) {
|
|
570
|
+
return this.next(), this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), !1, isAsync);
|
|
571
|
+
};
|
|
572
|
+
pp$8.parseIfStatement = function(node) {
|
|
573
|
+
return this.next(), node.test = this.parseParenExpression(), node.consequent = this.parseStatement("if"), node.alternate = this.eat(types$1._else) ? this.parseStatement("if") : null, this.finishNode(node, "IfStatement");
|
|
574
|
+
};
|
|
575
|
+
pp$8.parseReturnStatement = function(node) {
|
|
576
|
+
return !this.inFunction && !this.options.allowReturnOutsideFunction && this.raise(this.start, "'return' outside of function"), this.next(), this.eat(types$1.semi) || this.insertSemicolon() ? node.argument = null : (node.argument = this.parseExpression(), this.semicolon()), this.finishNode(node, "ReturnStatement");
|
|
577
|
+
};
|
|
578
|
+
pp$8.parseSwitchStatement = function(node) {
|
|
579
|
+
this.next(), node.discriminant = this.parseParenExpression(), node.cases = [], this.expect(types$1.braceL), this.labels.push(switchLabel), this.enterScope(0);
|
|
580
|
+
for (var cur, sawDefault = !1; this.type !== types$1.braceR; )
|
|
581
|
+
if (this.type === types$1._case || this.type === types$1._default) {
|
|
582
|
+
var isCase = this.type === types$1._case;
|
|
583
|
+
cur && this.finishNode(cur, "SwitchCase"), node.cases.push(cur = this.startNode()), cur.consequent = [], this.next(), isCase ? cur.test = this.parseExpression() : (sawDefault && this.raiseRecoverable(this.lastTokStart, "Multiple default clauses"), sawDefault = !0, cur.test = null), this.expect(types$1.colon);
|
|
584
|
+
} else
|
|
585
|
+
cur || this.unexpected(), cur.consequent.push(this.parseStatement(null));
|
|
586
|
+
return this.exitScope(), cur && this.finishNode(cur, "SwitchCase"), this.next(), this.labels.pop(), this.finishNode(node, "SwitchStatement");
|
|
587
|
+
};
|
|
588
|
+
pp$8.parseThrowStatement = function(node) {
|
|
589
|
+
return this.next(), lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) && this.raise(this.lastTokEnd, "Illegal newline after throw"), node.argument = this.parseExpression(), this.semicolon(), this.finishNode(node, "ThrowStatement");
|
|
590
|
+
};
|
|
591
|
+
var empty$1 = [];
|
|
592
|
+
pp$8.parseCatchClauseParam = function() {
|
|
593
|
+
var param = this.parseBindingAtom(), simple2 = param.type === "Identifier";
|
|
594
|
+
return this.enterScope(simple2 ? SCOPE_SIMPLE_CATCH : 0), this.checkLValPattern(param, simple2 ? BIND_SIMPLE_CATCH : BIND_LEXICAL), this.expect(types$1.parenR), param;
|
|
595
|
+
};
|
|
596
|
+
pp$8.parseTryStatement = function(node) {
|
|
597
|
+
if (this.next(), node.block = this.parseBlock(), node.handler = null, this.type === types$1._catch) {
|
|
598
|
+
var clause = this.startNode();
|
|
599
|
+
this.next(), this.eat(types$1.parenL) ? clause.param = this.parseCatchClauseParam() : (this.options.ecmaVersion < 10 && this.unexpected(), clause.param = null, this.enterScope(0)), clause.body = this.parseBlock(!1), this.exitScope(), node.handler = this.finishNode(clause, "CatchClause");
|
|
600
|
+
}
|
|
601
|
+
return node.finalizer = this.eat(types$1._finally) ? this.parseBlock() : null, !node.handler && !node.finalizer && this.raise(node.start, "Missing catch or finally clause"), this.finishNode(node, "TryStatement");
|
|
602
|
+
};
|
|
603
|
+
pp$8.parseVarStatement = function(node, kind, allowMissingInitializer) {
|
|
604
|
+
return this.next(), this.parseVar(node, !1, kind, allowMissingInitializer), this.semicolon(), this.finishNode(node, "VariableDeclaration");
|
|
605
|
+
};
|
|
606
|
+
pp$8.parseWhileStatement = function(node) {
|
|
607
|
+
return this.next(), node.test = this.parseParenExpression(), this.labels.push(loopLabel), node.body = this.parseStatement("while"), this.labels.pop(), this.finishNode(node, "WhileStatement");
|
|
608
|
+
};
|
|
609
|
+
pp$8.parseWithStatement = function(node) {
|
|
610
|
+
return this.strict && this.raise(this.start, "'with' in strict mode"), this.next(), node.object = this.parseParenExpression(), node.body = this.parseStatement("with"), this.finishNode(node, "WithStatement");
|
|
611
|
+
};
|
|
612
|
+
pp$8.parseEmptyStatement = function(node) {
|
|
613
|
+
return this.next(), this.finishNode(node, "EmptyStatement");
|
|
614
|
+
};
|
|
615
|
+
pp$8.parseLabeledStatement = function(node, maybeName, expr, context) {
|
|
616
|
+
for (var i$1 = 0, list = this.labels; i$1 < list.length; i$1 += 1) {
|
|
617
|
+
var label = list[i$1];
|
|
618
|
+
label.name === maybeName && this.raise(expr.start, "Label '" + maybeName + "' is already declared");
|
|
619
|
+
}
|
|
620
|
+
for (var kind = this.type.isLoop ? "loop" : this.type === types$1._switch ? "switch" : null, i = this.labels.length - 1; i >= 0; i--) {
|
|
621
|
+
var label$1 = this.labels[i];
|
|
622
|
+
if (label$1.statementStart === node.start)
|
|
623
|
+
label$1.statementStart = this.start, label$1.kind = kind;
|
|
624
|
+
else
|
|
625
|
+
break;
|
|
626
|
+
}
|
|
627
|
+
return this.labels.push({ name: maybeName, kind, statementStart: this.start }), node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label"), this.labels.pop(), node.label = expr, this.finishNode(node, "LabeledStatement");
|
|
628
|
+
};
|
|
629
|
+
pp$8.parseExpressionStatement = function(node, expr) {
|
|
630
|
+
return node.expression = expr, this.semicolon(), this.finishNode(node, "ExpressionStatement");
|
|
631
|
+
};
|
|
632
|
+
pp$8.parseBlock = function(createNewLexicalScope, node, exitStrict) {
|
|
633
|
+
for (createNewLexicalScope === void 0 && (createNewLexicalScope = !0), node === void 0 && (node = this.startNode()), node.body = [], this.expect(types$1.braceL), createNewLexicalScope && this.enterScope(0); this.type !== types$1.braceR; ) {
|
|
634
|
+
var stmt = this.parseStatement(null);
|
|
635
|
+
node.body.push(stmt);
|
|
636
|
+
}
|
|
637
|
+
return exitStrict && (this.strict = !1), this.next(), createNewLexicalScope && this.exitScope(), this.finishNode(node, "BlockStatement");
|
|
638
|
+
};
|
|
639
|
+
pp$8.parseFor = function(node, init) {
|
|
640
|
+
return node.init = init, this.expect(types$1.semi), node.test = this.type === types$1.semi ? null : this.parseExpression(), this.expect(types$1.semi), node.update = this.type === types$1.parenR ? null : this.parseExpression(), this.expect(types$1.parenR), node.body = this.parseStatement("for"), this.exitScope(), this.labels.pop(), this.finishNode(node, "ForStatement");
|
|
641
|
+
};
|
|
642
|
+
pp$8.parseForIn = function(node, init) {
|
|
643
|
+
var isForIn = this.type === types$1._in;
|
|
644
|
+
return this.next(), init.type === "VariableDeclaration" && init.declarations[0].init != null && (!isForIn || this.options.ecmaVersion < 8 || this.strict || init.kind !== "var" || init.declarations[0].id.type !== "Identifier") && this.raise(
|
|
645
|
+
init.start,
|
|
646
|
+
(isForIn ? "for-in" : "for-of") + " loop variable declaration may not have an initializer"
|
|
647
|
+
), node.left = init, node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign(), this.expect(types$1.parenR), node.body = this.parseStatement("for"), this.exitScope(), this.labels.pop(), this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement");
|
|
648
|
+
};
|
|
649
|
+
pp$8.parseVar = function(node, isFor, kind, allowMissingInitializer) {
|
|
650
|
+
for (node.declarations = [], node.kind = kind; ; ) {
|
|
651
|
+
var decl = this.startNode();
|
|
652
|
+
if (this.parseVarId(decl, kind), this.eat(types$1.eq) ? decl.init = this.parseMaybeAssign(isFor) : !allowMissingInitializer && kind === "const" && !(this.type === types$1._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) ? this.unexpected() : !allowMissingInitializer && decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of"))) ? this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value") : decl.init = null, node.declarations.push(this.finishNode(decl, "VariableDeclarator")), !this.eat(types$1.comma))
|
|
653
|
+
break;
|
|
654
|
+
}
|
|
655
|
+
return node;
|
|
656
|
+
};
|
|
657
|
+
pp$8.parseVarId = function(decl, kind) {
|
|
658
|
+
decl.id = this.parseBindingAtom(), this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, !1);
|
|
659
|
+
};
|
|
660
|
+
var FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4;
|
|
661
|
+
pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, forInit) {
|
|
662
|
+
this.initFunction(node), (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) && (this.type === types$1.star && statement & FUNC_HANGING_STATEMENT && this.unexpected(), node.generator = this.eat(types$1.star)), this.options.ecmaVersion >= 8 && (node.async = !!isAsync), statement & FUNC_STATEMENT && (node.id = statement & FUNC_NULLABLE_ID && this.type !== types$1.name ? null : this.parseIdent(), node.id && !(statement & FUNC_HANGING_STATEMENT) && this.checkLValSimple(node.id, this.strict || node.generator || node.async ? this.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION));
|
|
663
|
+
var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
|
|
664
|
+
return this.yieldPos = 0, this.awaitPos = 0, this.awaitIdentPos = 0, this.enterScope(functionFlags(node.async, node.generator)), statement & FUNC_STATEMENT || (node.id = this.type === types$1.name ? this.parseIdent() : null), this.parseFunctionParams(node), this.parseFunctionBody(node, allowExpressionBody, !1, forInit), this.yieldPos = oldYieldPos, this.awaitPos = oldAwaitPos, this.awaitIdentPos = oldAwaitIdentPos, this.finishNode(node, statement & FUNC_STATEMENT ? "FunctionDeclaration" : "FunctionExpression");
|
|
665
|
+
};
|
|
666
|
+
pp$8.parseFunctionParams = function(node) {
|
|
667
|
+
this.expect(types$1.parenL), node.params = this.parseBindingList(types$1.parenR, !1, this.options.ecmaVersion >= 8), this.checkYieldAwaitInDefaultParams();
|
|
668
|
+
};
|
|
669
|
+
pp$8.parseClass = function(node, isStatement) {
|
|
670
|
+
this.next();
|
|
671
|
+
var oldStrict = this.strict;
|
|
672
|
+
this.strict = !0, this.parseClassId(node, isStatement), this.parseClassSuper(node);
|
|
673
|
+
var privateNameMap = this.enterClassBody(), classBody = this.startNode(), hadConstructor = !1;
|
|
674
|
+
for (classBody.body = [], this.expect(types$1.braceL); this.type !== types$1.braceR; ) {
|
|
675
|
+
var element = this.parseClassElement(node.superClass !== null);
|
|
676
|
+
element && (classBody.body.push(element), element.type === "MethodDefinition" && element.kind === "constructor" ? (hadConstructor && this.raiseRecoverable(element.start, "Duplicate constructor in the same class"), hadConstructor = !0) : element.key && element.key.type === "PrivateIdentifier" && isPrivateNameConflicted(privateNameMap, element) && this.raiseRecoverable(element.key.start, "Identifier '#" + element.key.name + "' has already been declared"));
|
|
677
|
+
}
|
|
678
|
+
return this.strict = oldStrict, this.next(), node.body = this.finishNode(classBody, "ClassBody"), this.exitClassBody(), this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
|
|
679
|
+
};
|
|
680
|
+
pp$8.parseClassElement = function(constructorAllowsSuper) {
|
|
681
|
+
if (this.eat(types$1.semi))
|
|
682
|
+
return null;
|
|
683
|
+
var ecmaVersion = this.options.ecmaVersion, node = this.startNode(), keyName = "", isGenerator = !1, isAsync = !1, kind = "method", isStatic = !1;
|
|
684
|
+
if (this.eatContextual("static")) {
|
|
685
|
+
if (ecmaVersion >= 13 && this.eat(types$1.braceL))
|
|
686
|
+
return this.parseClassStaticBlock(node), node;
|
|
687
|
+
this.isClassElementNameStart() || this.type === types$1.star ? isStatic = !0 : keyName = "static";
|
|
688
|
+
}
|
|
689
|
+
if (node.static = isStatic, !keyName && ecmaVersion >= 8 && this.eatContextual("async") && ((this.isClassElementNameStart() || this.type === types$1.star) && !this.canInsertSemicolon() ? isAsync = !0 : keyName = "async"), !keyName && (ecmaVersion >= 9 || !isAsync) && this.eat(types$1.star) && (isGenerator = !0), !keyName && !isAsync && !isGenerator) {
|
|
690
|
+
var lastValue = this.value;
|
|
691
|
+
(this.eatContextual("get") || this.eatContextual("set")) && (this.isClassElementNameStart() ? kind = lastValue : keyName = lastValue);
|
|
692
|
+
}
|
|
693
|
+
if (keyName ? (node.computed = !1, node.key = this.startNodeAt(this.lastTokStart, this.lastTokStartLoc), node.key.name = keyName, this.finishNode(node.key, "Identifier")) : this.parseClassElementName(node), ecmaVersion < 13 || this.type === types$1.parenL || kind !== "method" || isGenerator || isAsync) {
|
|
694
|
+
var isConstructor = !node.static && checkKeyName(node, "constructor"), allowsDirectSuper = isConstructor && constructorAllowsSuper;
|
|
695
|
+
isConstructor && kind !== "method" && this.raise(node.key.start, "Constructor can't have get/set modifier"), node.kind = isConstructor ? "constructor" : kind, this.parseClassMethod(node, isGenerator, isAsync, allowsDirectSuper);
|
|
696
|
+
} else
|
|
697
|
+
this.parseClassField(node);
|
|
698
|
+
return node;
|
|
699
|
+
};
|
|
700
|
+
pp$8.isClassElementNameStart = function() {
|
|
701
|
+
return this.type === types$1.name || this.type === types$1.privateId || this.type === types$1.num || this.type === types$1.string || this.type === types$1.bracketL || this.type.keyword;
|
|
702
|
+
};
|
|
703
|
+
pp$8.parseClassElementName = function(element) {
|
|
704
|
+
this.type === types$1.privateId ? (this.value === "constructor" && this.raise(this.start, "Classes can't have an element named '#constructor'"), element.computed = !1, element.key = this.parsePrivateIdent()) : this.parsePropertyName(element);
|
|
705
|
+
};
|
|
706
|
+
pp$8.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper) {
|
|
707
|
+
var key = method.key;
|
|
708
|
+
method.kind === "constructor" ? (isGenerator && this.raise(key.start, "Constructor can't be a generator"), isAsync && this.raise(key.start, "Constructor can't be an async method")) : method.static && checkKeyName(method, "prototype") && this.raise(key.start, "Classes may not have a static property named prototype");
|
|
709
|
+
var value = method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper);
|
|
710
|
+
return method.kind === "get" && value.params.length !== 0 && this.raiseRecoverable(value.start, "getter should have no params"), method.kind === "set" && value.params.length !== 1 && this.raiseRecoverable(value.start, "setter should have exactly one param"), method.kind === "set" && value.params[0].type === "RestElement" && this.raiseRecoverable(value.params[0].start, "Setter cannot use rest params"), this.finishNode(method, "MethodDefinition");
|
|
711
|
+
};
|
|
712
|
+
pp$8.parseClassField = function(field) {
|
|
713
|
+
if (checkKeyName(field, "constructor") ? this.raise(field.key.start, "Classes can't have a field named 'constructor'") : field.static && checkKeyName(field, "prototype") && this.raise(field.key.start, "Classes can't have a static field named 'prototype'"), this.eat(types$1.eq)) {
|
|
714
|
+
var scope = this.currentThisScope(), inClassFieldInit = scope.inClassFieldInit;
|
|
715
|
+
scope.inClassFieldInit = !0, field.value = this.parseMaybeAssign(), scope.inClassFieldInit = inClassFieldInit;
|
|
716
|
+
} else
|
|
717
|
+
field.value = null;
|
|
718
|
+
return this.semicolon(), this.finishNode(field, "PropertyDefinition");
|
|
719
|
+
};
|
|
720
|
+
pp$8.parseClassStaticBlock = function(node) {
|
|
721
|
+
node.body = [];
|
|
722
|
+
var oldLabels = this.labels;
|
|
723
|
+
for (this.labels = [], this.enterScope(SCOPE_CLASS_STATIC_BLOCK | SCOPE_SUPER); this.type !== types$1.braceR; ) {
|
|
724
|
+
var stmt = this.parseStatement(null);
|
|
725
|
+
node.body.push(stmt);
|
|
726
|
+
}
|
|
727
|
+
return this.next(), this.exitScope(), this.labels = oldLabels, this.finishNode(node, "StaticBlock");
|
|
728
|
+
};
|
|
729
|
+
pp$8.parseClassId = function(node, isStatement) {
|
|
730
|
+
this.type === types$1.name ? (node.id = this.parseIdent(), isStatement && this.checkLValSimple(node.id, BIND_LEXICAL, !1)) : (isStatement === !0 && this.unexpected(), node.id = null);
|
|
731
|
+
};
|
|
732
|
+
pp$8.parseClassSuper = function(node) {
|
|
733
|
+
node.superClass = this.eat(types$1._extends) ? this.parseExprSubscripts(null, !1) : null;
|
|
734
|
+
};
|
|
735
|
+
pp$8.enterClassBody = function() {
|
|
736
|
+
var element = { declared: /* @__PURE__ */ Object.create(null), used: [] };
|
|
737
|
+
return this.privateNameStack.push(element), element.declared;
|
|
738
|
+
};
|
|
739
|
+
pp$8.exitClassBody = function() {
|
|
740
|
+
var ref2 = this.privateNameStack.pop(), declared = ref2.declared, used = ref2.used;
|
|
741
|
+
if (this.options.checkPrivateFields)
|
|
742
|
+
for (var len = this.privateNameStack.length, parent = len === 0 ? null : this.privateNameStack[len - 1], i = 0; i < used.length; ++i) {
|
|
743
|
+
var id = used[i];
|
|
744
|
+
hasOwn(declared, id.name) || (parent ? parent.used.push(id) : this.raiseRecoverable(id.start, "Private field '#" + id.name + "' must be declared in an enclosing class"));
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
function isPrivateNameConflicted(privateNameMap, element) {
|
|
748
|
+
var name = element.key.name, curr = privateNameMap[name], next = "true";
|
|
749
|
+
return element.type === "MethodDefinition" && (element.kind === "get" || element.kind === "set") && (next = (element.static ? "s" : "i") + element.kind), curr === "iget" && next === "iset" || curr === "iset" && next === "iget" || curr === "sget" && next === "sset" || curr === "sset" && next === "sget" ? (privateNameMap[name] = "true", !1) : curr ? !0 : (privateNameMap[name] = next, !1);
|
|
750
|
+
}
|
|
751
|
+
function checkKeyName(node, name) {
|
|
752
|
+
var computed = node.computed, key = node.key;
|
|
753
|
+
return !computed && (key.type === "Identifier" && key.name === name || key.type === "Literal" && key.value === name);
|
|
754
|
+
}
|
|
755
|
+
pp$8.parseExportAllDeclaration = function(node, exports) {
|
|
756
|
+
return this.options.ecmaVersion >= 11 && (this.eatContextual("as") ? (node.exported = this.parseModuleExportName(), this.checkExport(exports, node.exported, this.lastTokStart)) : node.exported = null), this.expectContextual("from"), this.type !== types$1.string && this.unexpected(), node.source = this.parseExprAtom(), this.options.ecmaVersion >= 16 && (node.attributes = this.parseWithClause()), this.semicolon(), this.finishNode(node, "ExportAllDeclaration");
|
|
757
|
+
};
|
|
758
|
+
pp$8.parseExport = function(node, exports) {
|
|
759
|
+
if (this.next(), this.eat(types$1.star))
|
|
760
|
+
return this.parseExportAllDeclaration(node, exports);
|
|
761
|
+
if (this.eat(types$1._default))
|
|
762
|
+
return this.checkExport(exports, "default", this.lastTokStart), node.declaration = this.parseExportDefaultDeclaration(), this.finishNode(node, "ExportDefaultDeclaration");
|
|
763
|
+
if (this.shouldParseExportStatement())
|
|
764
|
+
node.declaration = this.parseExportDeclaration(node), node.declaration.type === "VariableDeclaration" ? this.checkVariableExport(exports, node.declaration.declarations) : this.checkExport(exports, node.declaration.id, node.declaration.id.start), node.specifiers = [], node.source = null;
|
|
765
|
+
else {
|
|
766
|
+
if (node.declaration = null, node.specifiers = this.parseExportSpecifiers(exports), this.eatContextual("from"))
|
|
767
|
+
this.type !== types$1.string && this.unexpected(), node.source = this.parseExprAtom(), this.options.ecmaVersion >= 16 && (node.attributes = this.parseWithClause());
|
|
768
|
+
else {
|
|
769
|
+
for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
|
|
770
|
+
var spec = list[i];
|
|
771
|
+
this.checkUnreserved(spec.local), this.checkLocalExport(spec.local), spec.local.type === "Literal" && this.raise(spec.local.start, "A string literal cannot be used as an exported binding without `from`.");
|
|
772
|
+
}
|
|
773
|
+
node.source = null;
|
|
774
|
+
}
|
|
775
|
+
this.semicolon();
|
|
776
|
+
}
|
|
777
|
+
return this.finishNode(node, "ExportNamedDeclaration");
|
|
778
|
+
};
|
|
779
|
+
pp$8.parseExportDeclaration = function(node) {
|
|
780
|
+
return this.parseStatement(null);
|
|
781
|
+
};
|
|
782
|
+
pp$8.parseExportDefaultDeclaration = function() {
|
|
783
|
+
var isAsync;
|
|
784
|
+
if (this.type === types$1._function || (isAsync = this.isAsyncFunction())) {
|
|
785
|
+
var fNode = this.startNode();
|
|
786
|
+
return this.next(), isAsync && this.next(), this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, !1, isAsync);
|
|
787
|
+
} else if (this.type === types$1._class) {
|
|
788
|
+
var cNode = this.startNode();
|
|
789
|
+
return this.parseClass(cNode, "nullableID");
|
|
790
|
+
} else {
|
|
791
|
+
var declaration = this.parseMaybeAssign();
|
|
792
|
+
return this.semicolon(), declaration;
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
pp$8.checkExport = function(exports, name, pos) {
|
|
796
|
+
exports && (typeof name != "string" && (name = name.type === "Identifier" ? name.name : name.value), hasOwn(exports, name) && this.raiseRecoverable(pos, "Duplicate export '" + name + "'"), exports[name] = !0);
|
|
797
|
+
};
|
|
798
|
+
pp$8.checkPatternExport = function(exports, pat) {
|
|
799
|
+
var type = pat.type;
|
|
800
|
+
if (type === "Identifier")
|
|
801
|
+
this.checkExport(exports, pat, pat.start);
|
|
802
|
+
else if (type === "ObjectPattern")
|
|
803
|
+
for (var i = 0, list = pat.properties; i < list.length; i += 1) {
|
|
804
|
+
var prop = list[i];
|
|
805
|
+
this.checkPatternExport(exports, prop);
|
|
806
|
+
}
|
|
807
|
+
else if (type === "ArrayPattern")
|
|
808
|
+
for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
|
|
809
|
+
var elt = list$1[i$1];
|
|
810
|
+
elt && this.checkPatternExport(exports, elt);
|
|
811
|
+
}
|
|
812
|
+
else type === "Property" ? this.checkPatternExport(exports, pat.value) : type === "AssignmentPattern" ? this.checkPatternExport(exports, pat.left) : type === "RestElement" && this.checkPatternExport(exports, pat.argument);
|
|
813
|
+
};
|
|
814
|
+
pp$8.checkVariableExport = function(exports, decls) {
|
|
815
|
+
if (exports)
|
|
816
|
+
for (var i = 0, list = decls; i < list.length; i += 1) {
|
|
817
|
+
var decl = list[i];
|
|
818
|
+
this.checkPatternExport(exports, decl.id);
|
|
819
|
+
}
|
|
820
|
+
};
|
|
821
|
+
pp$8.shouldParseExportStatement = function() {
|
|
822
|
+
return this.type.keyword === "var" || this.type.keyword === "const" || this.type.keyword === "class" || this.type.keyword === "function" || this.isLet() || this.isAsyncFunction();
|
|
823
|
+
};
|
|
824
|
+
pp$8.parseExportSpecifier = function(exports) {
|
|
825
|
+
var node = this.startNode();
|
|
826
|
+
return node.local = this.parseModuleExportName(), node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local, this.checkExport(
|
|
827
|
+
exports,
|
|
828
|
+
node.exported,
|
|
829
|
+
node.exported.start
|
|
830
|
+
), this.finishNode(node, "ExportSpecifier");
|
|
831
|
+
};
|
|
832
|
+
pp$8.parseExportSpecifiers = function(exports) {
|
|
833
|
+
var nodes = [], first = !0;
|
|
834
|
+
for (this.expect(types$1.braceL); !this.eat(types$1.braceR); ) {
|
|
835
|
+
if (first)
|
|
836
|
+
first = !1;
|
|
837
|
+
else if (this.expect(types$1.comma), this.afterTrailingComma(types$1.braceR))
|
|
838
|
+
break;
|
|
839
|
+
nodes.push(this.parseExportSpecifier(exports));
|
|
840
|
+
}
|
|
841
|
+
return nodes;
|
|
842
|
+
};
|
|
843
|
+
pp$8.parseImport = function(node) {
|
|
844
|
+
return this.next(), this.type === types$1.string ? (node.specifiers = empty$1, node.source = this.parseExprAtom()) : (node.specifiers = this.parseImportSpecifiers(), this.expectContextual("from"), node.source = this.type === types$1.string ? this.parseExprAtom() : this.unexpected()), this.options.ecmaVersion >= 16 && (node.attributes = this.parseWithClause()), this.semicolon(), this.finishNode(node, "ImportDeclaration");
|
|
845
|
+
};
|
|
846
|
+
pp$8.parseImportSpecifier = function() {
|
|
847
|
+
var node = this.startNode();
|
|
848
|
+
return node.imported = this.parseModuleExportName(), this.eatContextual("as") ? node.local = this.parseIdent() : (this.checkUnreserved(node.imported), node.local = node.imported), this.checkLValSimple(node.local, BIND_LEXICAL), this.finishNode(node, "ImportSpecifier");
|
|
849
|
+
};
|
|
850
|
+
pp$8.parseImportDefaultSpecifier = function() {
|
|
851
|
+
var node = this.startNode();
|
|
852
|
+
return node.local = this.parseIdent(), this.checkLValSimple(node.local, BIND_LEXICAL), this.finishNode(node, "ImportDefaultSpecifier");
|
|
853
|
+
};
|
|
854
|
+
pp$8.parseImportNamespaceSpecifier = function() {
|
|
855
|
+
var node = this.startNode();
|
|
856
|
+
return this.next(), this.expectContextual("as"), node.local = this.parseIdent(), this.checkLValSimple(node.local, BIND_LEXICAL), this.finishNode(node, "ImportNamespaceSpecifier");
|
|
857
|
+
};
|
|
858
|
+
pp$8.parseImportSpecifiers = function() {
|
|
859
|
+
var nodes = [], first = !0;
|
|
860
|
+
if (this.type === types$1.name && (nodes.push(this.parseImportDefaultSpecifier()), !this.eat(types$1.comma)))
|
|
861
|
+
return nodes;
|
|
862
|
+
if (this.type === types$1.star)
|
|
863
|
+
return nodes.push(this.parseImportNamespaceSpecifier()), nodes;
|
|
864
|
+
for (this.expect(types$1.braceL); !this.eat(types$1.braceR); ) {
|
|
865
|
+
if (first)
|
|
866
|
+
first = !1;
|
|
867
|
+
else if (this.expect(types$1.comma), this.afterTrailingComma(types$1.braceR))
|
|
868
|
+
break;
|
|
869
|
+
nodes.push(this.parseImportSpecifier());
|
|
870
|
+
}
|
|
871
|
+
return nodes;
|
|
872
|
+
};
|
|
873
|
+
pp$8.parseWithClause = function() {
|
|
874
|
+
var nodes = [];
|
|
875
|
+
if (!this.eat(types$1._with))
|
|
876
|
+
return nodes;
|
|
877
|
+
this.expect(types$1.braceL);
|
|
878
|
+
for (var attributeKeys = {}, first = !0; !this.eat(types$1.braceR); ) {
|
|
879
|
+
if (first)
|
|
880
|
+
first = !1;
|
|
881
|
+
else if (this.expect(types$1.comma), this.afterTrailingComma(types$1.braceR))
|
|
882
|
+
break;
|
|
883
|
+
var attr = this.parseImportAttribute(), keyName = attr.key.type === "Identifier" ? attr.key.name : attr.key.value;
|
|
884
|
+
hasOwn(attributeKeys, keyName) && this.raiseRecoverable(attr.key.start, "Duplicate attribute key '" + keyName + "'"), attributeKeys[keyName] = !0, nodes.push(attr);
|
|
885
|
+
}
|
|
886
|
+
return nodes;
|
|
887
|
+
};
|
|
888
|
+
pp$8.parseImportAttribute = function() {
|
|
889
|
+
var node = this.startNode();
|
|
890
|
+
return node.key = this.type === types$1.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never"), this.expect(types$1.colon), this.type !== types$1.string && this.unexpected(), node.value = this.parseExprAtom(), this.finishNode(node, "ImportAttribute");
|
|
891
|
+
};
|
|
892
|
+
pp$8.parseModuleExportName = function() {
|
|
893
|
+
if (this.options.ecmaVersion >= 13 && this.type === types$1.string) {
|
|
894
|
+
var stringLiteral = this.parseLiteral(this.value);
|
|
895
|
+
return loneSurrogate.test(stringLiteral.value) && this.raise(stringLiteral.start, "An export name cannot include a lone surrogate."), stringLiteral;
|
|
896
|
+
}
|
|
897
|
+
return this.parseIdent(!0);
|
|
898
|
+
};
|
|
899
|
+
pp$8.adaptDirectivePrologue = function(statements) {
|
|
900
|
+
for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i)
|
|
901
|
+
statements[i].directive = statements[i].expression.raw.slice(1, -1);
|
|
902
|
+
};
|
|
903
|
+
pp$8.isDirectiveCandidate = function(statement) {
|
|
904
|
+
return this.options.ecmaVersion >= 5 && statement.type === "ExpressionStatement" && statement.expression.type === "Literal" && typeof statement.expression.value == "string" && // Reject parenthesized strings.
|
|
905
|
+
(this.input[statement.start] === '"' || this.input[statement.start] === "'");
|
|
906
|
+
};
|
|
907
|
+
var pp$7 = Parser.prototype;
|
|
908
|
+
pp$7.toAssignable = function(node, isBinding, refDestructuringErrors) {
|
|
909
|
+
if (this.options.ecmaVersion >= 6 && node)
|
|
910
|
+
switch (node.type) {
|
|
911
|
+
case "Identifier":
|
|
912
|
+
this.inAsync && node.name === "await" && this.raise(node.start, "Cannot use 'await' as identifier inside an async function");
|
|
913
|
+
break;
|
|
914
|
+
case "ObjectPattern":
|
|
915
|
+
case "ArrayPattern":
|
|
916
|
+
case "AssignmentPattern":
|
|
917
|
+
case "RestElement":
|
|
918
|
+
break;
|
|
919
|
+
case "ObjectExpression":
|
|
920
|
+
node.type = "ObjectPattern", refDestructuringErrors && this.checkPatternErrors(refDestructuringErrors, !0);
|
|
921
|
+
for (var i = 0, list = node.properties; i < list.length; i += 1) {
|
|
922
|
+
var prop = list[i];
|
|
923
|
+
this.toAssignable(prop, isBinding), prop.type === "RestElement" && (prop.argument.type === "ArrayPattern" || prop.argument.type === "ObjectPattern") && this.raise(prop.argument.start, "Unexpected token");
|
|
924
|
+
}
|
|
925
|
+
break;
|
|
926
|
+
case "Property":
|
|
927
|
+
node.kind !== "init" && this.raise(node.key.start, "Object pattern can't contain getter or setter"), this.toAssignable(node.value, isBinding);
|
|
928
|
+
break;
|
|
929
|
+
case "ArrayExpression":
|
|
930
|
+
node.type = "ArrayPattern", refDestructuringErrors && this.checkPatternErrors(refDestructuringErrors, !0), this.toAssignableList(node.elements, isBinding);
|
|
931
|
+
break;
|
|
932
|
+
case "SpreadElement":
|
|
933
|
+
node.type = "RestElement", this.toAssignable(node.argument, isBinding), node.argument.type === "AssignmentPattern" && this.raise(node.argument.start, "Rest elements cannot have a default value");
|
|
934
|
+
break;
|
|
935
|
+
case "AssignmentExpression":
|
|
936
|
+
node.operator !== "=" && this.raise(node.left.end, "Only '=' operator can be used for specifying default value."), node.type = "AssignmentPattern", delete node.operator, this.toAssignable(node.left, isBinding);
|
|
937
|
+
break;
|
|
938
|
+
case "ParenthesizedExpression":
|
|
939
|
+
this.toAssignable(node.expression, isBinding, refDestructuringErrors);
|
|
940
|
+
break;
|
|
941
|
+
case "ChainExpression":
|
|
942
|
+
this.raiseRecoverable(node.start, "Optional chaining cannot appear in left-hand side");
|
|
943
|
+
break;
|
|
944
|
+
case "MemberExpression":
|
|
945
|
+
if (!isBinding)
|
|
946
|
+
break;
|
|
947
|
+
default:
|
|
948
|
+
this.raise(node.start, "Assigning to rvalue");
|
|
949
|
+
}
|
|
950
|
+
else refDestructuringErrors && this.checkPatternErrors(refDestructuringErrors, !0);
|
|
951
|
+
return node;
|
|
952
|
+
};
|
|
953
|
+
pp$7.toAssignableList = function(exprList, isBinding) {
|
|
954
|
+
for (var end = exprList.length, i = 0; i < end; i++) {
|
|
955
|
+
var elt = exprList[i];
|
|
956
|
+
elt && this.toAssignable(elt, isBinding);
|
|
957
|
+
}
|
|
958
|
+
if (end) {
|
|
959
|
+
var last = exprList[end - 1];
|
|
960
|
+
this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier" && this.unexpected(last.argument.start);
|
|
961
|
+
}
|
|
962
|
+
return exprList;
|
|
963
|
+
};
|
|
964
|
+
pp$7.parseSpread = function(refDestructuringErrors) {
|
|
965
|
+
var node = this.startNode();
|
|
966
|
+
return this.next(), node.argument = this.parseMaybeAssign(!1, refDestructuringErrors), this.finishNode(node, "SpreadElement");
|
|
967
|
+
};
|
|
968
|
+
pp$7.parseRestBinding = function() {
|
|
969
|
+
var node = this.startNode();
|
|
970
|
+
return this.next(), this.options.ecmaVersion === 6 && this.type !== types$1.name && this.unexpected(), node.argument = this.parseBindingAtom(), this.finishNode(node, "RestElement");
|
|
971
|
+
};
|
|
972
|
+
pp$7.parseBindingAtom = function() {
|
|
973
|
+
if (this.options.ecmaVersion >= 6)
|
|
974
|
+
switch (this.type) {
|
|
975
|
+
case types$1.bracketL:
|
|
976
|
+
var node = this.startNode();
|
|
977
|
+
return this.next(), node.elements = this.parseBindingList(types$1.bracketR, !0, !0), this.finishNode(node, "ArrayPattern");
|
|
978
|
+
case types$1.braceL:
|
|
979
|
+
return this.parseObj(!0);
|
|
980
|
+
}
|
|
981
|
+
return this.parseIdent();
|
|
982
|
+
};
|
|
983
|
+
pp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowModifiers) {
|
|
984
|
+
for (var elts = [], first = !0; !this.eat(close); )
|
|
985
|
+
if (first ? first = !1 : this.expect(types$1.comma), allowEmpty && this.type === types$1.comma)
|
|
986
|
+
elts.push(null);
|
|
987
|
+
else {
|
|
988
|
+
if (allowTrailingComma && this.afterTrailingComma(close))
|
|
989
|
+
break;
|
|
990
|
+
if (this.type === types$1.ellipsis) {
|
|
991
|
+
var rest = this.parseRestBinding();
|
|
992
|
+
this.parseBindingListItem(rest), elts.push(rest), this.type === types$1.comma && this.raiseRecoverable(this.start, "Comma is not permitted after the rest element"), this.expect(close);
|
|
993
|
+
break;
|
|
994
|
+
} else
|
|
995
|
+
elts.push(this.parseAssignableListItem(allowModifiers));
|
|
996
|
+
}
|
|
997
|
+
return elts;
|
|
998
|
+
};
|
|
999
|
+
pp$7.parseAssignableListItem = function(allowModifiers) {
|
|
1000
|
+
var elem = this.parseMaybeDefault(this.start, this.startLoc);
|
|
1001
|
+
return this.parseBindingListItem(elem), elem;
|
|
1002
|
+
};
|
|
1003
|
+
pp$7.parseBindingListItem = function(param) {
|
|
1004
|
+
return param;
|
|
1005
|
+
};
|
|
1006
|
+
pp$7.parseMaybeDefault = function(startPos, startLoc, left) {
|
|
1007
|
+
if (left = left || this.parseBindingAtom(), this.options.ecmaVersion < 6 || !this.eat(types$1.eq))
|
|
1008
|
+
return left;
|
|
1009
|
+
var node = this.startNodeAt(startPos, startLoc);
|
|
1010
|
+
return node.left = left, node.right = this.parseMaybeAssign(), this.finishNode(node, "AssignmentPattern");
|
|
1011
|
+
};
|
|
1012
|
+
pp$7.checkLValSimple = function(expr, bindingType, checkClashes) {
|
|
1013
|
+
bindingType === void 0 && (bindingType = BIND_NONE);
|
|
1014
|
+
var isBind = bindingType !== BIND_NONE;
|
|
1015
|
+
switch (expr.type) {
|
|
1016
|
+
case "Identifier":
|
|
1017
|
+
this.strict && this.reservedWordsStrictBind.test(expr.name) && this.raiseRecoverable(expr.start, (isBind ? "Binding " : "Assigning to ") + expr.name + " in strict mode"), isBind && (bindingType === BIND_LEXICAL && expr.name === "let" && this.raiseRecoverable(expr.start, "let is disallowed as a lexically bound name"), checkClashes && (hasOwn(checkClashes, expr.name) && this.raiseRecoverable(expr.start, "Argument name clash"), checkClashes[expr.name] = !0), bindingType !== BIND_OUTSIDE && this.declareName(expr.name, bindingType, expr.start));
|
|
1018
|
+
break;
|
|
1019
|
+
case "ChainExpression":
|
|
1020
|
+
this.raiseRecoverable(expr.start, "Optional chaining cannot appear in left-hand side");
|
|
1021
|
+
break;
|
|
1022
|
+
case "MemberExpression":
|
|
1023
|
+
isBind && this.raiseRecoverable(expr.start, "Binding member expression");
|
|
1024
|
+
break;
|
|
1025
|
+
case "ParenthesizedExpression":
|
|
1026
|
+
return isBind && this.raiseRecoverable(expr.start, "Binding parenthesized expression"), this.checkLValSimple(expr.expression, bindingType, checkClashes);
|
|
1027
|
+
default:
|
|
1028
|
+
this.raise(expr.start, (isBind ? "Binding" : "Assigning to") + " rvalue");
|
|
1029
|
+
}
|
|
1030
|
+
};
|
|
1031
|
+
pp$7.checkLValPattern = function(expr, bindingType, checkClashes) {
|
|
1032
|
+
switch (bindingType === void 0 && (bindingType = BIND_NONE), expr.type) {
|
|
1033
|
+
case "ObjectPattern":
|
|
1034
|
+
for (var i = 0, list = expr.properties; i < list.length; i += 1) {
|
|
1035
|
+
var prop = list[i];
|
|
1036
|
+
this.checkLValInnerPattern(prop, bindingType, checkClashes);
|
|
1037
|
+
}
|
|
1038
|
+
break;
|
|
1039
|
+
case "ArrayPattern":
|
|
1040
|
+
for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) {
|
|
1041
|
+
var elem = list$1[i$1];
|
|
1042
|
+
elem && this.checkLValInnerPattern(elem, bindingType, checkClashes);
|
|
1043
|
+
}
|
|
1044
|
+
break;
|
|
1045
|
+
default:
|
|
1046
|
+
this.checkLValSimple(expr, bindingType, checkClashes);
|
|
1047
|
+
}
|
|
1048
|
+
};
|
|
1049
|
+
pp$7.checkLValInnerPattern = function(expr, bindingType, checkClashes) {
|
|
1050
|
+
switch (bindingType === void 0 && (bindingType = BIND_NONE), expr.type) {
|
|
1051
|
+
case "Property":
|
|
1052
|
+
this.checkLValInnerPattern(expr.value, bindingType, checkClashes);
|
|
1053
|
+
break;
|
|
1054
|
+
case "AssignmentPattern":
|
|
1055
|
+
this.checkLValPattern(expr.left, bindingType, checkClashes);
|
|
1056
|
+
break;
|
|
1057
|
+
case "RestElement":
|
|
1058
|
+
this.checkLValPattern(expr.argument, bindingType, checkClashes);
|
|
1059
|
+
break;
|
|
1060
|
+
default:
|
|
1061
|
+
this.checkLValPattern(expr, bindingType, checkClashes);
|
|
1062
|
+
}
|
|
1063
|
+
};
|
|
1064
|
+
var TokContext = function(token, isExpr, preserveSpace, override, generator) {
|
|
1065
|
+
this.token = token, this.isExpr = !!isExpr, this.preserveSpace = !!preserveSpace, this.override = override, this.generator = !!generator;
|
|
1066
|
+
}, types = {
|
|
1067
|
+
b_stat: new TokContext("{", !1),
|
|
1068
|
+
b_expr: new TokContext("{", !0),
|
|
1069
|
+
b_tmpl: new TokContext("${", !1),
|
|
1070
|
+
p_stat: new TokContext("(", !1),
|
|
1071
|
+
p_expr: new TokContext("(", !0),
|
|
1072
|
+
q_tmpl: new TokContext("`", !0, !0, function(p) {
|
|
1073
|
+
return p.tryReadTemplateToken();
|
|
1074
|
+
}),
|
|
1075
|
+
f_stat: new TokContext("function", !1),
|
|
1076
|
+
f_expr: new TokContext("function", !0),
|
|
1077
|
+
f_expr_gen: new TokContext("function", !0, !1, null, !0),
|
|
1078
|
+
f_gen: new TokContext("function", !1, !1, null, !0)
|
|
1079
|
+
}, pp$6 = Parser.prototype;
|
|
1080
|
+
pp$6.initialContext = function() {
|
|
1081
|
+
return [types.b_stat];
|
|
1082
|
+
};
|
|
1083
|
+
pp$6.curContext = function() {
|
|
1084
|
+
return this.context[this.context.length - 1];
|
|
1085
|
+
};
|
|
1086
|
+
pp$6.braceIsBlock = function(prevType) {
|
|
1087
|
+
var parent = this.curContext();
|
|
1088
|
+
return parent === types.f_expr || parent === types.f_stat ? !0 : prevType === types$1.colon && (parent === types.b_stat || parent === types.b_expr) ? !parent.isExpr : prevType === types$1._return || prevType === types$1.name && this.exprAllowed ? lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) : prevType === types$1._else || prevType === types$1.semi || prevType === types$1.eof || prevType === types$1.parenR || prevType === types$1.arrow ? !0 : prevType === types$1.braceL ? parent === types.b_stat : prevType === types$1._var || prevType === types$1._const || prevType === types$1.name ? !1 : !this.exprAllowed;
|
|
1089
|
+
};
|
|
1090
|
+
pp$6.inGeneratorContext = function() {
|
|
1091
|
+
for (var i = this.context.length - 1; i >= 1; i--) {
|
|
1092
|
+
var context = this.context[i];
|
|
1093
|
+
if (context.token === "function")
|
|
1094
|
+
return context.generator;
|
|
1095
|
+
}
|
|
1096
|
+
return !1;
|
|
1097
|
+
};
|
|
1098
|
+
pp$6.updateContext = function(prevType) {
|
|
1099
|
+
var update, type = this.type;
|
|
1100
|
+
type.keyword && prevType === types$1.dot ? this.exprAllowed = !1 : (update = type.updateContext) ? update.call(this, prevType) : this.exprAllowed = type.beforeExpr;
|
|
1101
|
+
};
|
|
1102
|
+
pp$6.overrideContext = function(tokenCtx) {
|
|
1103
|
+
this.curContext() !== tokenCtx && (this.context[this.context.length - 1] = tokenCtx);
|
|
1104
|
+
};
|
|
1105
|
+
types$1.parenR.updateContext = types$1.braceR.updateContext = function() {
|
|
1106
|
+
if (this.context.length === 1) {
|
|
1107
|
+
this.exprAllowed = !0;
|
|
1108
|
+
return;
|
|
1109
|
+
}
|
|
1110
|
+
var out = this.context.pop();
|
|
1111
|
+
out === types.b_stat && this.curContext().token === "function" && (out = this.context.pop()), this.exprAllowed = !out.isExpr;
|
|
1112
|
+
};
|
|
1113
|
+
types$1.braceL.updateContext = function(prevType) {
|
|
1114
|
+
this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr), this.exprAllowed = !0;
|
|
1115
|
+
};
|
|
1116
|
+
types$1.dollarBraceL.updateContext = function() {
|
|
1117
|
+
this.context.push(types.b_tmpl), this.exprAllowed = !0;
|
|
1118
|
+
};
|
|
1119
|
+
types$1.parenL.updateContext = function(prevType) {
|
|
1120
|
+
var statementParens = prevType === types$1._if || prevType === types$1._for || prevType === types$1._with || prevType === types$1._while;
|
|
1121
|
+
this.context.push(statementParens ? types.p_stat : types.p_expr), this.exprAllowed = !0;
|
|
1122
|
+
};
|
|
1123
|
+
types$1.incDec.updateContext = function() {
|
|
1124
|
+
};
|
|
1125
|
+
types$1._function.updateContext = types$1._class.updateContext = function(prevType) {
|
|
1126
|
+
prevType.beforeExpr && prevType !== types$1._else && !(prevType === types$1.semi && this.curContext() !== types.p_stat) && !(prevType === types$1._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) && !((prevType === types$1.colon || prevType === types$1.braceL) && this.curContext() === types.b_stat) ? this.context.push(types.f_expr) : this.context.push(types.f_stat), this.exprAllowed = !1;
|
|
1127
|
+
};
|
|
1128
|
+
types$1.colon.updateContext = function() {
|
|
1129
|
+
this.curContext().token === "function" && this.context.pop(), this.exprAllowed = !0;
|
|
1130
|
+
};
|
|
1131
|
+
types$1.backQuote.updateContext = function() {
|
|
1132
|
+
this.curContext() === types.q_tmpl ? this.context.pop() : this.context.push(types.q_tmpl), this.exprAllowed = !1;
|
|
1133
|
+
};
|
|
1134
|
+
types$1.star.updateContext = function(prevType) {
|
|
1135
|
+
if (prevType === types$1._function) {
|
|
1136
|
+
var index = this.context.length - 1;
|
|
1137
|
+
this.context[index] === types.f_expr ? this.context[index] = types.f_expr_gen : this.context[index] = types.f_gen;
|
|
1138
|
+
}
|
|
1139
|
+
this.exprAllowed = !0;
|
|
1140
|
+
};
|
|
1141
|
+
types$1.name.updateContext = function(prevType) {
|
|
1142
|
+
var allowed = !1;
|
|
1143
|
+
this.options.ecmaVersion >= 6 && prevType !== types$1.dot && (this.value === "of" && !this.exprAllowed || this.value === "yield" && this.inGeneratorContext()) && (allowed = !0), this.exprAllowed = allowed;
|
|
1144
|
+
};
|
|
1145
|
+
var pp$5 = Parser.prototype;
|
|
1146
|
+
pp$5.checkPropClash = function(prop, propHash, refDestructuringErrors) {
|
|
1147
|
+
if (!(this.options.ecmaVersion >= 9 && prop.type === "SpreadElement") && !(this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand))) {
|
|
1148
|
+
var key = prop.key, name;
|
|
1149
|
+
switch (key.type) {
|
|
1150
|
+
case "Identifier":
|
|
1151
|
+
name = key.name;
|
|
1152
|
+
break;
|
|
1153
|
+
case "Literal":
|
|
1154
|
+
name = String(key.value);
|
|
1155
|
+
break;
|
|
1156
|
+
default:
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1159
|
+
var kind = prop.kind;
|
|
1160
|
+
if (this.options.ecmaVersion >= 6) {
|
|
1161
|
+
name === "__proto__" && kind === "init" && (propHash.proto && (refDestructuringErrors ? refDestructuringErrors.doubleProto < 0 && (refDestructuringErrors.doubleProto = key.start) : this.raiseRecoverable(key.start, "Redefinition of __proto__ property")), propHash.proto = !0);
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
name = "$" + name;
|
|
1165
|
+
var other = propHash[name];
|
|
1166
|
+
if (other) {
|
|
1167
|
+
var redefinition;
|
|
1168
|
+
kind === "init" ? redefinition = this.strict && other.init || other.get || other.set : redefinition = other.init || other[kind], redefinition && this.raiseRecoverable(key.start, "Redefinition of property");
|
|
1169
|
+
} else
|
|
1170
|
+
other = propHash[name] = {
|
|
1171
|
+
init: !1,
|
|
1172
|
+
get: !1,
|
|
1173
|
+
set: !1
|
|
1174
|
+
};
|
|
1175
|
+
other[kind] = !0;
|
|
1176
|
+
}
|
|
1177
|
+
};
|
|
1178
|
+
pp$5.parseExpression = function(forInit, refDestructuringErrors) {
|
|
1179
|
+
var startPos = this.start, startLoc = this.startLoc, expr = this.parseMaybeAssign(forInit, refDestructuringErrors);
|
|
1180
|
+
if (this.type === types$1.comma) {
|
|
1181
|
+
var node = this.startNodeAt(startPos, startLoc);
|
|
1182
|
+
for (node.expressions = [expr]; this.eat(types$1.comma); )
|
|
1183
|
+
node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors));
|
|
1184
|
+
return this.finishNode(node, "SequenceExpression");
|
|
1185
|
+
}
|
|
1186
|
+
return expr;
|
|
1187
|
+
};
|
|
1188
|
+
pp$5.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse) {
|
|
1189
|
+
if (this.isContextual("yield")) {
|
|
1190
|
+
if (this.inGenerator)
|
|
1191
|
+
return this.parseYield(forInit);
|
|
1192
|
+
this.exprAllowed = !1;
|
|
1193
|
+
}
|
|
1194
|
+
var ownDestructuringErrors = !1, oldParenAssign = -1, oldTrailingComma = -1, oldDoubleProto = -1;
|
|
1195
|
+
refDestructuringErrors ? (oldParenAssign = refDestructuringErrors.parenthesizedAssign, oldTrailingComma = refDestructuringErrors.trailingComma, oldDoubleProto = refDestructuringErrors.doubleProto, refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1) : (refDestructuringErrors = new DestructuringErrors(), ownDestructuringErrors = !0);
|
|
1196
|
+
var startPos = this.start, startLoc = this.startLoc;
|
|
1197
|
+
(this.type === types$1.parenL || this.type === types$1.name) && (this.potentialArrowAt = this.start, this.potentialArrowInForAwait = forInit === "await");
|
|
1198
|
+
var left = this.parseMaybeConditional(forInit, refDestructuringErrors);
|
|
1199
|
+
if (afterLeftParse && (left = afterLeftParse.call(this, left, startPos, startLoc)), this.type.isAssign) {
|
|
1200
|
+
var node = this.startNodeAt(startPos, startLoc);
|
|
1201
|
+
return node.operator = this.value, this.type === types$1.eq && (left = this.toAssignable(left, !1, refDestructuringErrors)), ownDestructuringErrors || (refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.doubleProto = -1), refDestructuringErrors.shorthandAssign >= left.start && (refDestructuringErrors.shorthandAssign = -1), this.type === types$1.eq ? this.checkLValPattern(left) : this.checkLValSimple(left), node.left = left, this.next(), node.right = this.parseMaybeAssign(forInit), oldDoubleProto > -1 && (refDestructuringErrors.doubleProto = oldDoubleProto), this.finishNode(node, "AssignmentExpression");
|
|
1202
|
+
} else
|
|
1203
|
+
ownDestructuringErrors && this.checkExpressionErrors(refDestructuringErrors, !0);
|
|
1204
|
+
return oldParenAssign > -1 && (refDestructuringErrors.parenthesizedAssign = oldParenAssign), oldTrailingComma > -1 && (refDestructuringErrors.trailingComma = oldTrailingComma), left;
|
|
1205
|
+
};
|
|
1206
|
+
pp$5.parseMaybeConditional = function(forInit, refDestructuringErrors) {
|
|
1207
|
+
var startPos = this.start, startLoc = this.startLoc, expr = this.parseExprOps(forInit, refDestructuringErrors);
|
|
1208
|
+
if (this.checkExpressionErrors(refDestructuringErrors))
|
|
1209
|
+
return expr;
|
|
1210
|
+
if (this.eat(types$1.question)) {
|
|
1211
|
+
var node = this.startNodeAt(startPos, startLoc);
|
|
1212
|
+
return node.test = expr, node.consequent = this.parseMaybeAssign(), this.expect(types$1.colon), node.alternate = this.parseMaybeAssign(forInit), this.finishNode(node, "ConditionalExpression");
|
|
1213
|
+
}
|
|
1214
|
+
return expr;
|
|
1215
|
+
};
|
|
1216
|
+
pp$5.parseExprOps = function(forInit, refDestructuringErrors) {
|
|
1217
|
+
var startPos = this.start, startLoc = this.startLoc, expr = this.parseMaybeUnary(refDestructuringErrors, !1, !1, forInit);
|
|
1218
|
+
return this.checkExpressionErrors(refDestructuringErrors) || expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, forInit);
|
|
1219
|
+
};
|
|
1220
|
+
pp$5.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, forInit) {
|
|
1221
|
+
var prec = this.type.binop;
|
|
1222
|
+
if (prec != null && (!forInit || this.type !== types$1._in) && prec > minPrec) {
|
|
1223
|
+
var logical = this.type === types$1.logicalOR || this.type === types$1.logicalAND, coalesce = this.type === types$1.coalesce;
|
|
1224
|
+
coalesce && (prec = types$1.logicalAND.binop);
|
|
1225
|
+
var op = this.value;
|
|
1226
|
+
this.next();
|
|
1227
|
+
var startPos = this.start, startLoc = this.startLoc, right = this.parseExprOp(this.parseMaybeUnary(null, !1, !1, forInit), startPos, startLoc, prec, forInit), node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce);
|
|
1228
|
+
return (logical && this.type === types$1.coalesce || coalesce && (this.type === types$1.logicalOR || this.type === types$1.logicalAND)) && this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"), this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, forInit);
|
|
1229
|
+
}
|
|
1230
|
+
return left;
|
|
1231
|
+
};
|
|
1232
|
+
pp$5.buildBinary = function(startPos, startLoc, left, right, op, logical) {
|
|
1233
|
+
right.type === "PrivateIdentifier" && this.raise(right.start, "Private identifier can only be left side of binary expression");
|
|
1234
|
+
var node = this.startNodeAt(startPos, startLoc);
|
|
1235
|
+
return node.left = left, node.operator = op, node.right = right, this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression");
|
|
1236
|
+
};
|
|
1237
|
+
pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forInit) {
|
|
1238
|
+
var startPos = this.start, startLoc = this.startLoc, expr;
|
|
1239
|
+
if (this.isContextual("await") && this.canAwait)
|
|
1240
|
+
expr = this.parseAwait(forInit), sawUnary = !0;
|
|
1241
|
+
else if (this.type.prefix) {
|
|
1242
|
+
var node = this.startNode(), update = this.type === types$1.incDec;
|
|
1243
|
+
node.operator = this.value, node.prefix = !0, this.next(), node.argument = this.parseMaybeUnary(null, !0, update, forInit), this.checkExpressionErrors(refDestructuringErrors, !0), update ? this.checkLValSimple(node.argument) : this.strict && node.operator === "delete" && isLocalVariableAccess(node.argument) ? this.raiseRecoverable(node.start, "Deleting local variable in strict mode") : node.operator === "delete" && isPrivateFieldAccess(node.argument) ? this.raiseRecoverable(node.start, "Private fields can not be deleted") : sawUnary = !0, expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
|
|
1244
|
+
} else if (!sawUnary && this.type === types$1.privateId)
|
|
1245
|
+
(forInit || this.privateNameStack.length === 0) && this.options.checkPrivateFields && this.unexpected(), expr = this.parsePrivateIdent(), this.type !== types$1._in && this.unexpected();
|
|
1246
|
+
else {
|
|
1247
|
+
if (expr = this.parseExprSubscripts(refDestructuringErrors, forInit), this.checkExpressionErrors(refDestructuringErrors))
|
|
1248
|
+
return expr;
|
|
1249
|
+
for (; this.type.postfix && !this.canInsertSemicolon(); ) {
|
|
1250
|
+
var node$1 = this.startNodeAt(startPos, startLoc);
|
|
1251
|
+
node$1.operator = this.value, node$1.prefix = !1, node$1.argument = expr, this.checkLValSimple(expr), this.next(), expr = this.finishNode(node$1, "UpdateExpression");
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
if (!incDec && this.eat(types$1.starstar))
|
|
1255
|
+
if (sawUnary)
|
|
1256
|
+
this.unexpected(this.lastTokStart);
|
|
1257
|
+
else
|
|
1258
|
+
return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, !1, !1, forInit), "**", !1);
|
|
1259
|
+
else
|
|
1260
|
+
return expr;
|
|
1261
|
+
};
|
|
1262
|
+
function isLocalVariableAccess(node) {
|
|
1263
|
+
return node.type === "Identifier" || node.type === "ParenthesizedExpression" && isLocalVariableAccess(node.expression);
|
|
1264
|
+
}
|
|
1265
|
+
function isPrivateFieldAccess(node) {
|
|
1266
|
+
return node.type === "MemberExpression" && node.property.type === "PrivateIdentifier" || node.type === "ChainExpression" && isPrivateFieldAccess(node.expression) || node.type === "ParenthesizedExpression" && isPrivateFieldAccess(node.expression);
|
|
1267
|
+
}
|
|
1268
|
+
pp$5.parseExprSubscripts = function(refDestructuringErrors, forInit) {
|
|
1269
|
+
var startPos = this.start, startLoc = this.startLoc, expr = this.parseExprAtom(refDestructuringErrors, forInit);
|
|
1270
|
+
if (expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")")
|
|
1271
|
+
return expr;
|
|
1272
|
+
var result = this.parseSubscripts(expr, startPos, startLoc, !1, forInit);
|
|
1273
|
+
return refDestructuringErrors && result.type === "MemberExpression" && (refDestructuringErrors.parenthesizedAssign >= result.start && (refDestructuringErrors.parenthesizedAssign = -1), refDestructuringErrors.parenthesizedBind >= result.start && (refDestructuringErrors.parenthesizedBind = -1), refDestructuringErrors.trailingComma >= result.start && (refDestructuringErrors.trailingComma = -1)), result;
|
|
1274
|
+
};
|
|
1275
|
+
pp$5.parseSubscripts = function(base2, startPos, startLoc, noCalls, forInit) {
|
|
1276
|
+
for (var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base2.type === "Identifier" && base2.name === "async" && this.lastTokEnd === base2.end && !this.canInsertSemicolon() && base2.end - base2.start === 5 && this.potentialArrowAt === base2.start, optionalChained = !1; ; ) {
|
|
1277
|
+
var element = this.parseSubscript(base2, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit);
|
|
1278
|
+
if (element.optional && (optionalChained = !0), element === base2 || element.type === "ArrowFunctionExpression") {
|
|
1279
|
+
if (optionalChained) {
|
|
1280
|
+
var chainNode = this.startNodeAt(startPos, startLoc);
|
|
1281
|
+
chainNode.expression = element, element = this.finishNode(chainNode, "ChainExpression");
|
|
1282
|
+
}
|
|
1283
|
+
return element;
|
|
1284
|
+
}
|
|
1285
|
+
base2 = element;
|
|
1286
|
+
}
|
|
1287
|
+
};
|
|
1288
|
+
pp$5.shouldParseAsyncArrow = function() {
|
|
1289
|
+
return !this.canInsertSemicolon() && this.eat(types$1.arrow);
|
|
1290
|
+
};
|
|
1291
|
+
pp$5.parseSubscriptAsyncArrow = function(startPos, startLoc, exprList, forInit) {
|
|
1292
|
+
return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, !0, forInit);
|
|
1293
|
+
};
|
|
1294
|
+
pp$5.parseSubscript = function(base2, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit) {
|
|
1295
|
+
var optionalSupported = this.options.ecmaVersion >= 11, optional = optionalSupported && this.eat(types$1.questionDot);
|
|
1296
|
+
noCalls && optional && this.raise(this.lastTokStart, "Optional chaining cannot appear in the callee of new expressions");
|
|
1297
|
+
var computed = this.eat(types$1.bracketL);
|
|
1298
|
+
if (computed || optional && this.type !== types$1.parenL && this.type !== types$1.backQuote || this.eat(types$1.dot)) {
|
|
1299
|
+
var node = this.startNodeAt(startPos, startLoc);
|
|
1300
|
+
node.object = base2, computed ? (node.property = this.parseExpression(), this.expect(types$1.bracketR)) : this.type === types$1.privateId && base2.type !== "Super" ? node.property = this.parsePrivateIdent() : node.property = this.parseIdent(this.options.allowReserved !== "never"), node.computed = !!computed, optionalSupported && (node.optional = optional), base2 = this.finishNode(node, "MemberExpression");
|
|
1301
|
+
} else if (!noCalls && this.eat(types$1.parenL)) {
|
|
1302
|
+
var refDestructuringErrors = new DestructuringErrors(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
|
|
1303
|
+
this.yieldPos = 0, this.awaitPos = 0, this.awaitIdentPos = 0;
|
|
1304
|
+
var exprList = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, !1, refDestructuringErrors);
|
|
1305
|
+
if (maybeAsyncArrow && !optional && this.shouldParseAsyncArrow())
|
|
1306
|
+
return this.checkPatternErrors(refDestructuringErrors, !1), this.checkYieldAwaitInDefaultParams(), this.awaitIdentPos > 0 && this.raise(this.awaitIdentPos, "Cannot use 'await' as identifier inside an async function"), this.yieldPos = oldYieldPos, this.awaitPos = oldAwaitPos, this.awaitIdentPos = oldAwaitIdentPos, this.parseSubscriptAsyncArrow(startPos, startLoc, exprList, forInit);
|
|
1307
|
+
this.checkExpressionErrors(refDestructuringErrors, !0), this.yieldPos = oldYieldPos || this.yieldPos, this.awaitPos = oldAwaitPos || this.awaitPos, this.awaitIdentPos = oldAwaitIdentPos || this.awaitIdentPos;
|
|
1308
|
+
var node$1 = this.startNodeAt(startPos, startLoc);
|
|
1309
|
+
node$1.callee = base2, node$1.arguments = exprList, optionalSupported && (node$1.optional = optional), base2 = this.finishNode(node$1, "CallExpression");
|
|
1310
|
+
} else if (this.type === types$1.backQuote) {
|
|
1311
|
+
(optional || optionalChained) && this.raise(this.start, "Optional chaining cannot appear in the tag of tagged template expressions");
|
|
1312
|
+
var node$2 = this.startNodeAt(startPos, startLoc);
|
|
1313
|
+
node$2.tag = base2, node$2.quasi = this.parseTemplate({ isTagged: !0 }), base2 = this.finishNode(node$2, "TaggedTemplateExpression");
|
|
1314
|
+
}
|
|
1315
|
+
return base2;
|
|
1316
|
+
};
|
|
1317
|
+
pp$5.parseExprAtom = function(refDestructuringErrors, forInit, forNew) {
|
|
1318
|
+
this.type === types$1.slash && this.readRegexp();
|
|
1319
|
+
var node, canBeArrow = this.potentialArrowAt === this.start;
|
|
1320
|
+
switch (this.type) {
|
|
1321
|
+
case types$1._super:
|
|
1322
|
+
return this.allowSuper || this.raise(this.start, "'super' keyword outside a method"), node = this.startNode(), this.next(), this.type === types$1.parenL && !this.allowDirectSuper && this.raise(node.start, "super() call outside constructor of a subclass"), this.type !== types$1.dot && this.type !== types$1.bracketL && this.type !== types$1.parenL && this.unexpected(), this.finishNode(node, "Super");
|
|
1323
|
+
case types$1._this:
|
|
1324
|
+
return node = this.startNode(), this.next(), this.finishNode(node, "ThisExpression");
|
|
1325
|
+
case types$1.name:
|
|
1326
|
+
var startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc, id = this.parseIdent(!1);
|
|
1327
|
+
if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types$1._function))
|
|
1328
|
+
return this.overrideContext(types.f_expr), this.parseFunction(this.startNodeAt(startPos, startLoc), 0, !1, !0, forInit);
|
|
1329
|
+
if (canBeArrow && !this.canInsertSemicolon()) {
|
|
1330
|
+
if (this.eat(types$1.arrow))
|
|
1331
|
+
return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], !1, forInit);
|
|
1332
|
+
if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types$1.name && !containsEsc && (!this.potentialArrowInForAwait || this.value !== "of" || this.containsEsc))
|
|
1333
|
+
return id = this.parseIdent(!1), (this.canInsertSemicolon() || !this.eat(types$1.arrow)) && this.unexpected(), this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], !0, forInit);
|
|
1334
|
+
}
|
|
1335
|
+
return id;
|
|
1336
|
+
case types$1.regexp:
|
|
1337
|
+
var value = this.value;
|
|
1338
|
+
return node = this.parseLiteral(value.value), node.regex = { pattern: value.pattern, flags: value.flags }, node;
|
|
1339
|
+
case types$1.num:
|
|
1340
|
+
case types$1.string:
|
|
1341
|
+
return this.parseLiteral(this.value);
|
|
1342
|
+
case types$1._null:
|
|
1343
|
+
case types$1._true:
|
|
1344
|
+
case types$1._false:
|
|
1345
|
+
return node = this.startNode(), node.value = this.type === types$1._null ? null : this.type === types$1._true, node.raw = this.type.keyword, this.next(), this.finishNode(node, "Literal");
|
|
1346
|
+
case types$1.parenL:
|
|
1347
|
+
var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow, forInit);
|
|
1348
|
+
return refDestructuringErrors && (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr) && (refDestructuringErrors.parenthesizedAssign = start), refDestructuringErrors.parenthesizedBind < 0 && (refDestructuringErrors.parenthesizedBind = start)), expr;
|
|
1349
|
+
case types$1.bracketL:
|
|
1350
|
+
return node = this.startNode(), this.next(), node.elements = this.parseExprList(types$1.bracketR, !0, !0, refDestructuringErrors), this.finishNode(node, "ArrayExpression");
|
|
1351
|
+
case types$1.braceL:
|
|
1352
|
+
return this.overrideContext(types.b_expr), this.parseObj(!1, refDestructuringErrors);
|
|
1353
|
+
case types$1._function:
|
|
1354
|
+
return node = this.startNode(), this.next(), this.parseFunction(node, 0);
|
|
1355
|
+
case types$1._class:
|
|
1356
|
+
return this.parseClass(this.startNode(), !1);
|
|
1357
|
+
case types$1._new:
|
|
1358
|
+
return this.parseNew();
|
|
1359
|
+
case types$1.backQuote:
|
|
1360
|
+
return this.parseTemplate();
|
|
1361
|
+
case types$1._import:
|
|
1362
|
+
return this.options.ecmaVersion >= 11 ? this.parseExprImport(forNew) : this.unexpected();
|
|
1363
|
+
default:
|
|
1364
|
+
return this.parseExprAtomDefault();
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1367
|
+
pp$5.parseExprAtomDefault = function() {
|
|
1368
|
+
this.unexpected();
|
|
1369
|
+
};
|
|
1370
|
+
pp$5.parseExprImport = function(forNew) {
|
|
1371
|
+
var node = this.startNode();
|
|
1372
|
+
if (this.containsEsc && this.raiseRecoverable(this.start, "Escape sequence in keyword import"), this.next(), this.type === types$1.parenL && !forNew)
|
|
1373
|
+
return this.parseDynamicImport(node);
|
|
1374
|
+
if (this.type === types$1.dot) {
|
|
1375
|
+
var meta = this.startNodeAt(node.start, node.loc && node.loc.start);
|
|
1376
|
+
return meta.name = "import", node.meta = this.finishNode(meta, "Identifier"), this.parseImportMeta(node);
|
|
1377
|
+
} else
|
|
1378
|
+
this.unexpected();
|
|
1379
|
+
};
|
|
1380
|
+
pp$5.parseDynamicImport = function(node) {
|
|
1381
|
+
if (this.next(), node.source = this.parseMaybeAssign(), this.options.ecmaVersion >= 16)
|
|
1382
|
+
this.eat(types$1.parenR) ? node.options = null : (this.expect(types$1.comma), this.afterTrailingComma(types$1.parenR) ? node.options = null : (node.options = this.parseMaybeAssign(), this.eat(types$1.parenR) || (this.expect(types$1.comma), this.afterTrailingComma(types$1.parenR) || this.unexpected())));
|
|
1383
|
+
else if (!this.eat(types$1.parenR)) {
|
|
1384
|
+
var errorPos = this.start;
|
|
1385
|
+
this.eat(types$1.comma) && this.eat(types$1.parenR) ? this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()") : this.unexpected(errorPos);
|
|
1386
|
+
}
|
|
1387
|
+
return this.finishNode(node, "ImportExpression");
|
|
1388
|
+
};
|
|
1389
|
+
pp$5.parseImportMeta = function(node) {
|
|
1390
|
+
this.next();
|
|
1391
|
+
var containsEsc = this.containsEsc;
|
|
1392
|
+
return node.property = this.parseIdent(!0), node.property.name !== "meta" && this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'"), containsEsc && this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters"), this.options.sourceType !== "module" && !this.options.allowImportExportEverywhere && this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module"), this.finishNode(node, "MetaProperty");
|
|
1393
|
+
};
|
|
1394
|
+
pp$5.parseLiteral = function(value) {
|
|
1395
|
+
var node = this.startNode();
|
|
1396
|
+
return node.value = value, node.raw = this.input.slice(this.start, this.end), node.raw.charCodeAt(node.raw.length - 1) === 110 && (node.bigint = node.raw.slice(0, -1).replace(/_/g, "")), this.next(), this.finishNode(node, "Literal");
|
|
1397
|
+
};
|
|
1398
|
+
pp$5.parseParenExpression = function() {
|
|
1399
|
+
this.expect(types$1.parenL);
|
|
1400
|
+
var val = this.parseExpression();
|
|
1401
|
+
return this.expect(types$1.parenR), val;
|
|
1402
|
+
};
|
|
1403
|
+
pp$5.shouldParseArrow = function(exprList) {
|
|
1404
|
+
return !this.canInsertSemicolon();
|
|
1405
|
+
};
|
|
1406
|
+
pp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) {
|
|
1407
|
+
var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8;
|
|
1408
|
+
if (this.options.ecmaVersion >= 6) {
|
|
1409
|
+
this.next();
|
|
1410
|
+
var innerStartPos = this.start, innerStartLoc = this.startLoc, exprList = [], first = !0, lastIsComma = !1, refDestructuringErrors = new DestructuringErrors(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart;
|
|
1411
|
+
for (this.yieldPos = 0, this.awaitPos = 0; this.type !== types$1.parenR; )
|
|
1412
|
+
if (first ? first = !1 : this.expect(types$1.comma), allowTrailingComma && this.afterTrailingComma(types$1.parenR, !0)) {
|
|
1413
|
+
lastIsComma = !0;
|
|
1414
|
+
break;
|
|
1415
|
+
} else if (this.type === types$1.ellipsis) {
|
|
1416
|
+
spreadStart = this.start, exprList.push(this.parseParenItem(this.parseRestBinding())), this.type === types$1.comma && this.raiseRecoverable(
|
|
1417
|
+
this.start,
|
|
1418
|
+
"Comma is not permitted after the rest element"
|
|
1419
|
+
);
|
|
1420
|
+
break;
|
|
1421
|
+
} else
|
|
1422
|
+
exprList.push(this.parseMaybeAssign(!1, refDestructuringErrors, this.parseParenItem));
|
|
1423
|
+
var innerEndPos = this.lastTokEnd, innerEndLoc = this.lastTokEndLoc;
|
|
1424
|
+
if (this.expect(types$1.parenR), canBeArrow && this.shouldParseArrow(exprList) && this.eat(types$1.arrow))
|
|
1425
|
+
return this.checkPatternErrors(refDestructuringErrors, !1), this.checkYieldAwaitInDefaultParams(), this.yieldPos = oldYieldPos, this.awaitPos = oldAwaitPos, this.parseParenArrowList(startPos, startLoc, exprList, forInit);
|
|
1426
|
+
(!exprList.length || lastIsComma) && this.unexpected(this.lastTokStart), spreadStart && this.unexpected(spreadStart), this.checkExpressionErrors(refDestructuringErrors, !0), this.yieldPos = oldYieldPos || this.yieldPos, this.awaitPos = oldAwaitPos || this.awaitPos, exprList.length > 1 ? (val = this.startNodeAt(innerStartPos, innerStartLoc), val.expressions = exprList, this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc)) : val = exprList[0];
|
|
1427
|
+
} else
|
|
1428
|
+
val = this.parseParenExpression();
|
|
1429
|
+
if (this.options.preserveParens) {
|
|
1430
|
+
var par = this.startNodeAt(startPos, startLoc);
|
|
1431
|
+
return par.expression = val, this.finishNode(par, "ParenthesizedExpression");
|
|
1432
|
+
} else
|
|
1433
|
+
return val;
|
|
1434
|
+
};
|
|
1435
|
+
pp$5.parseParenItem = function(item) {
|
|
1436
|
+
return item;
|
|
1437
|
+
};
|
|
1438
|
+
pp$5.parseParenArrowList = function(startPos, startLoc, exprList, forInit) {
|
|
1439
|
+
return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, !1, forInit);
|
|
1440
|
+
};
|
|
1441
|
+
var empty = [];
|
|
1442
|
+
pp$5.parseNew = function() {
|
|
1443
|
+
this.containsEsc && this.raiseRecoverable(this.start, "Escape sequence in keyword new");
|
|
1444
|
+
var node = this.startNode();
|
|
1445
|
+
if (this.next(), this.options.ecmaVersion >= 6 && this.type === types$1.dot) {
|
|
1446
|
+
var meta = this.startNodeAt(node.start, node.loc && node.loc.start);
|
|
1447
|
+
meta.name = "new", node.meta = this.finishNode(meta, "Identifier"), this.next();
|
|
1448
|
+
var containsEsc = this.containsEsc;
|
|
1449
|
+
return node.property = this.parseIdent(!0), node.property.name !== "target" && this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'"), containsEsc && this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters"), this.allowNewDotTarget || this.raiseRecoverable(node.start, "'new.target' can only be used in functions and class static block"), this.finishNode(node, "MetaProperty");
|
|
1450
|
+
}
|
|
1451
|
+
var startPos = this.start, startLoc = this.startLoc;
|
|
1452
|
+
return node.callee = this.parseSubscripts(this.parseExprAtom(null, !1, !0), startPos, startLoc, !0, !1), this.eat(types$1.parenL) ? node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, !1) : node.arguments = empty, this.finishNode(node, "NewExpression");
|
|
1453
|
+
};
|
|
1454
|
+
pp$5.parseTemplateElement = function(ref2) {
|
|
1455
|
+
var isTagged = ref2.isTagged, elem = this.startNode();
|
|
1456
|
+
return this.type === types$1.invalidTemplate ? (isTagged || this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal"), elem.value = {
|
|
1457
|
+
raw: this.value.replace(/\r\n?/g, `
|
|
1458
|
+
`),
|
|
1459
|
+
cooked: null
|
|
1460
|
+
}) : elem.value = {
|
|
1461
|
+
raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, `
|
|
1462
|
+
`),
|
|
1463
|
+
cooked: this.value
|
|
1464
|
+
}, this.next(), elem.tail = this.type === types$1.backQuote, this.finishNode(elem, "TemplateElement");
|
|
1465
|
+
};
|
|
1466
|
+
pp$5.parseTemplate = function(ref2) {
|
|
1467
|
+
ref2 === void 0 && (ref2 = {});
|
|
1468
|
+
var isTagged = ref2.isTagged;
|
|
1469
|
+
isTagged === void 0 && (isTagged = !1);
|
|
1470
|
+
var node = this.startNode();
|
|
1471
|
+
this.next(), node.expressions = [];
|
|
1472
|
+
var curElt = this.parseTemplateElement({ isTagged });
|
|
1473
|
+
for (node.quasis = [curElt]; !curElt.tail; )
|
|
1474
|
+
this.type === types$1.eof && this.raise(this.pos, "Unterminated template literal"), this.expect(types$1.dollarBraceL), node.expressions.push(this.parseExpression()), this.expect(types$1.braceR), node.quasis.push(curElt = this.parseTemplateElement({ isTagged }));
|
|
1475
|
+
return this.next(), this.finishNode(node, "TemplateLiteral");
|
|
1476
|
+
};
|
|
1477
|
+
pp$5.isAsyncProp = function(prop) {
|
|
1478
|
+
return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" && (this.type === types$1.name || this.type === types$1.num || this.type === types$1.string || this.type === types$1.bracketL || this.type.keyword || this.options.ecmaVersion >= 9 && this.type === types$1.star) && !lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
|
|
1479
|
+
};
|
|
1480
|
+
pp$5.parseObj = function(isPattern, refDestructuringErrors) {
|
|
1481
|
+
var node = this.startNode(), first = !0, propHash = {};
|
|
1482
|
+
for (node.properties = [], this.next(); !this.eat(types$1.braceR); ) {
|
|
1483
|
+
if (first)
|
|
1484
|
+
first = !1;
|
|
1485
|
+
else if (this.expect(types$1.comma), this.options.ecmaVersion >= 5 && this.afterTrailingComma(types$1.braceR))
|
|
1486
|
+
break;
|
|
1487
|
+
var prop = this.parseProperty(isPattern, refDestructuringErrors);
|
|
1488
|
+
isPattern || this.checkPropClash(prop, propHash, refDestructuringErrors), node.properties.push(prop);
|
|
1489
|
+
}
|
|
1490
|
+
return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression");
|
|
1491
|
+
};
|
|
1492
|
+
pp$5.parseProperty = function(isPattern, refDestructuringErrors) {
|
|
1493
|
+
var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc;
|
|
1494
|
+
if (this.options.ecmaVersion >= 9 && this.eat(types$1.ellipsis))
|
|
1495
|
+
return isPattern ? (prop.argument = this.parseIdent(!1), this.type === types$1.comma && this.raiseRecoverable(this.start, "Comma is not permitted after the rest element"), this.finishNode(prop, "RestElement")) : (prop.argument = this.parseMaybeAssign(!1, refDestructuringErrors), this.type === types$1.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0 && (refDestructuringErrors.trailingComma = this.start), this.finishNode(prop, "SpreadElement"));
|
|
1496
|
+
this.options.ecmaVersion >= 6 && (prop.method = !1, prop.shorthand = !1, (isPattern || refDestructuringErrors) && (startPos = this.start, startLoc = this.startLoc), isPattern || (isGenerator = this.eat(types$1.star)));
|
|
1497
|
+
var containsEsc = this.containsEsc;
|
|
1498
|
+
return this.parsePropertyName(prop), !isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop) ? (isAsync = !0, isGenerator = this.options.ecmaVersion >= 9 && this.eat(types$1.star), this.parsePropertyName(prop)) : isAsync = !1, this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc), this.finishNode(prop, "Property");
|
|
1499
|
+
};
|
|
1500
|
+
pp$5.parseGetterSetter = function(prop) {
|
|
1501
|
+
prop.kind = prop.key.name, this.parsePropertyName(prop), prop.value = this.parseMethod(!1);
|
|
1502
|
+
var paramCount = prop.kind === "get" ? 0 : 1;
|
|
1503
|
+
if (prop.value.params.length !== paramCount) {
|
|
1504
|
+
var start = prop.value.start;
|
|
1505
|
+
prop.kind === "get" ? this.raiseRecoverable(start, "getter should have no params") : this.raiseRecoverable(start, "setter should have exactly one param");
|
|
1506
|
+
} else
|
|
1507
|
+
prop.kind === "set" && prop.value.params[0].type === "RestElement" && this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params");
|
|
1508
|
+
};
|
|
1509
|
+
pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {
|
|
1510
|
+
(isGenerator || isAsync) && this.type === types$1.colon && this.unexpected(), this.eat(types$1.colon) ? (prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(!1, refDestructuringErrors), prop.kind = "init") : this.options.ecmaVersion >= 6 && this.type === types$1.parenL ? (isPattern && this.unexpected(), prop.kind = "init", prop.method = !0, prop.value = this.parseMethod(isGenerator, isAsync)) : !isPattern && !containsEsc && this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && this.type !== types$1.comma && this.type !== types$1.braceR && this.type !== types$1.eq ? ((isGenerator || isAsync) && this.unexpected(), this.parseGetterSetter(prop)) : this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier" ? ((isGenerator || isAsync) && this.unexpected(), this.checkUnreserved(prop.key), prop.key.name === "await" && !this.awaitIdentPos && (this.awaitIdentPos = startPos), prop.kind = "init", isPattern ? prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key)) : this.type === types$1.eq && refDestructuringErrors ? (refDestructuringErrors.shorthandAssign < 0 && (refDestructuringErrors.shorthandAssign = this.start), prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key))) : prop.value = this.copyNode(prop.key), prop.shorthand = !0) : this.unexpected();
|
|
1511
|
+
};
|
|
1512
|
+
pp$5.parsePropertyName = function(prop) {
|
|
1513
|
+
if (this.options.ecmaVersion >= 6) {
|
|
1514
|
+
if (this.eat(types$1.bracketL))
|
|
1515
|
+
return prop.computed = !0, prop.key = this.parseMaybeAssign(), this.expect(types$1.bracketR), prop.key;
|
|
1516
|
+
prop.computed = !1;
|
|
1517
|
+
}
|
|
1518
|
+
return prop.key = this.type === types$1.num || this.type === types$1.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never");
|
|
1519
|
+
};
|
|
1520
|
+
pp$5.initFunction = function(node) {
|
|
1521
|
+
node.id = null, this.options.ecmaVersion >= 6 && (node.generator = node.expression = !1), this.options.ecmaVersion >= 8 && (node.async = !1);
|
|
1522
|
+
};
|
|
1523
|
+
pp$5.parseMethod = function(isGenerator, isAsync, allowDirectSuper) {
|
|
1524
|
+
var node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
|
|
1525
|
+
return this.initFunction(node), this.options.ecmaVersion >= 6 && (node.generator = isGenerator), this.options.ecmaVersion >= 8 && (node.async = !!isAsync), this.yieldPos = 0, this.awaitPos = 0, this.awaitIdentPos = 0, this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0)), this.expect(types$1.parenL), node.params = this.parseBindingList(types$1.parenR, !1, this.options.ecmaVersion >= 8), this.checkYieldAwaitInDefaultParams(), this.parseFunctionBody(node, !1, !0, !1), this.yieldPos = oldYieldPos, this.awaitPos = oldAwaitPos, this.awaitIdentPos = oldAwaitIdentPos, this.finishNode(node, "FunctionExpression");
|
|
1526
|
+
};
|
|
1527
|
+
pp$5.parseArrowExpression = function(node, params, isAsync, forInit) {
|
|
1528
|
+
var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
|
|
1529
|
+
return this.enterScope(functionFlags(isAsync, !1) | SCOPE_ARROW), this.initFunction(node), this.options.ecmaVersion >= 8 && (node.async = !!isAsync), this.yieldPos = 0, this.awaitPos = 0, this.awaitIdentPos = 0, node.params = this.toAssignableList(params, !0), this.parseFunctionBody(node, !0, !1, forInit), this.yieldPos = oldYieldPos, this.awaitPos = oldAwaitPos, this.awaitIdentPos = oldAwaitIdentPos, this.finishNode(node, "ArrowFunctionExpression");
|
|
1530
|
+
};
|
|
1531
|
+
pp$5.parseFunctionBody = function(node, isArrowFunction, isMethod, forInit) {
|
|
1532
|
+
var isExpression = isArrowFunction && this.type !== types$1.braceL, oldStrict = this.strict, useStrict = !1;
|
|
1533
|
+
if (isExpression)
|
|
1534
|
+
node.body = this.parseMaybeAssign(forInit), node.expression = !0, this.checkParams(node, !1);
|
|
1535
|
+
else {
|
|
1536
|
+
var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params);
|
|
1537
|
+
(!oldStrict || nonSimple) && (useStrict = this.strictDirective(this.end), useStrict && nonSimple && this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list"));
|
|
1538
|
+
var oldLabels = this.labels;
|
|
1539
|
+
this.labels = [], useStrict && (this.strict = !0), this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params)), this.strict && node.id && this.checkLValSimple(node.id, BIND_OUTSIDE), node.body = this.parseBlock(!1, void 0, useStrict && !oldStrict), node.expression = !1, this.adaptDirectivePrologue(node.body.body), this.labels = oldLabels;
|
|
1540
|
+
}
|
|
1541
|
+
this.exitScope();
|
|
1542
|
+
};
|
|
1543
|
+
pp$5.isSimpleParamList = function(params) {
|
|
1544
|
+
for (var i = 0, list = params; i < list.length; i += 1) {
|
|
1545
|
+
var param = list[i];
|
|
1546
|
+
if (param.type !== "Identifier")
|
|
1547
|
+
return !1;
|
|
1548
|
+
}
|
|
1549
|
+
return !0;
|
|
1550
|
+
};
|
|
1551
|
+
pp$5.checkParams = function(node, allowDuplicates) {
|
|
1552
|
+
for (var nameHash = /* @__PURE__ */ Object.create(null), i = 0, list = node.params; i < list.length; i += 1) {
|
|
1553
|
+
var param = list[i];
|
|
1554
|
+
this.checkLValInnerPattern(param, BIND_VAR, allowDuplicates ? null : nameHash);
|
|
1555
|
+
}
|
|
1556
|
+
};
|
|
1557
|
+
pp$5.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) {
|
|
1558
|
+
for (var elts = [], first = !0; !this.eat(close); ) {
|
|
1559
|
+
if (first)
|
|
1560
|
+
first = !1;
|
|
1561
|
+
else if (this.expect(types$1.comma), allowTrailingComma && this.afterTrailingComma(close))
|
|
1562
|
+
break;
|
|
1563
|
+
var elt = void 0;
|
|
1564
|
+
allowEmpty && this.type === types$1.comma ? elt = null : this.type === types$1.ellipsis ? (elt = this.parseSpread(refDestructuringErrors), refDestructuringErrors && this.type === types$1.comma && refDestructuringErrors.trailingComma < 0 && (refDestructuringErrors.trailingComma = this.start)) : elt = this.parseMaybeAssign(!1, refDestructuringErrors), elts.push(elt);
|
|
1565
|
+
}
|
|
1566
|
+
return elts;
|
|
1567
|
+
};
|
|
1568
|
+
pp$5.checkUnreserved = function(ref2) {
|
|
1569
|
+
var start = ref2.start, end = ref2.end, name = ref2.name;
|
|
1570
|
+
if (this.inGenerator && name === "yield" && this.raiseRecoverable(start, "Cannot use 'yield' as identifier inside a generator"), this.inAsync && name === "await" && this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function"), this.currentThisScope().inClassFieldInit && name === "arguments" && this.raiseRecoverable(start, "Cannot use 'arguments' in class field initializer"), this.inClassStaticBlock && (name === "arguments" || name === "await") && this.raise(start, "Cannot use " + name + " in class static initialization block"), this.keywords.test(name) && this.raise(start, "Unexpected keyword '" + name + "'"), !(this.options.ecmaVersion < 6 && this.input.slice(start, end).indexOf("\\") !== -1)) {
|
|
1571
|
+
var re = this.strict ? this.reservedWordsStrict : this.reservedWords;
|
|
1572
|
+
re.test(name) && (!this.inAsync && name === "await" && this.raiseRecoverable(start, "Cannot use keyword 'await' outside an async function"), this.raiseRecoverable(start, "The keyword '" + name + "' is reserved"));
|
|
1573
|
+
}
|
|
1574
|
+
};
|
|
1575
|
+
pp$5.parseIdent = function(liberal) {
|
|
1576
|
+
var node = this.parseIdentNode();
|
|
1577
|
+
return this.next(!!liberal), this.finishNode(node, "Identifier"), liberal || (this.checkUnreserved(node), node.name === "await" && !this.awaitIdentPos && (this.awaitIdentPos = node.start)), node;
|
|
1578
|
+
};
|
|
1579
|
+
pp$5.parseIdentNode = function() {
|
|
1580
|
+
var node = this.startNode();
|
|
1581
|
+
return this.type === types$1.name ? node.name = this.value : this.type.keyword ? (node.name = this.type.keyword, (node.name === "class" || node.name === "function") && (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46) && this.context.pop(), this.type = types$1.name) : this.unexpected(), node;
|
|
1582
|
+
};
|
|
1583
|
+
pp$5.parsePrivateIdent = function() {
|
|
1584
|
+
var node = this.startNode();
|
|
1585
|
+
return this.type === types$1.privateId ? node.name = this.value : this.unexpected(), this.next(), this.finishNode(node, "PrivateIdentifier"), this.options.checkPrivateFields && (this.privateNameStack.length === 0 ? this.raise(node.start, "Private field '#" + node.name + "' must be declared in an enclosing class") : this.privateNameStack[this.privateNameStack.length - 1].used.push(node)), node;
|
|
1586
|
+
};
|
|
1587
|
+
pp$5.parseYield = function(forInit) {
|
|
1588
|
+
this.yieldPos || (this.yieldPos = this.start);
|
|
1589
|
+
var node = this.startNode();
|
|
1590
|
+
return this.next(), this.type === types$1.semi || this.canInsertSemicolon() || this.type !== types$1.star && !this.type.startsExpr ? (node.delegate = !1, node.argument = null) : (node.delegate = this.eat(types$1.star), node.argument = this.parseMaybeAssign(forInit)), this.finishNode(node, "YieldExpression");
|
|
1591
|
+
};
|
|
1592
|
+
pp$5.parseAwait = function(forInit) {
|
|
1593
|
+
this.awaitPos || (this.awaitPos = this.start);
|
|
1594
|
+
var node = this.startNode();
|
|
1595
|
+
return this.next(), node.argument = this.parseMaybeUnary(null, !0, !1, forInit), this.finishNode(node, "AwaitExpression");
|
|
1596
|
+
};
|
|
1597
|
+
var pp$4 = Parser.prototype;
|
|
1598
|
+
pp$4.raise = function(pos, message) {
|
|
1599
|
+
var loc = getLineInfo(this.input, pos);
|
|
1600
|
+
message += " (" + loc.line + ":" + loc.column + ")";
|
|
1601
|
+
var err = new SyntaxError(message);
|
|
1602
|
+
throw err.pos = pos, err.loc = loc, err.raisedAt = this.pos, err;
|
|
1603
|
+
};
|
|
1604
|
+
pp$4.raiseRecoverable = pp$4.raise;
|
|
1605
|
+
pp$4.curPosition = function() {
|
|
1606
|
+
if (this.options.locations)
|
|
1607
|
+
return new Position(this.curLine, this.pos - this.lineStart);
|
|
1608
|
+
};
|
|
1609
|
+
var pp$3 = Parser.prototype, Scope = function(flags) {
|
|
1610
|
+
this.flags = flags, this.var = [], this.lexical = [], this.functions = [], this.inClassFieldInit = !1;
|
|
1611
|
+
};
|
|
1612
|
+
pp$3.enterScope = function(flags) {
|
|
1613
|
+
this.scopeStack.push(new Scope(flags));
|
|
1614
|
+
};
|
|
1615
|
+
pp$3.exitScope = function() {
|
|
1616
|
+
this.scopeStack.pop();
|
|
1617
|
+
};
|
|
1618
|
+
pp$3.treatFunctionsAsVarInScope = function(scope) {
|
|
1619
|
+
return scope.flags & SCOPE_FUNCTION$1 || !this.inModule && scope.flags & SCOPE_TOP;
|
|
1620
|
+
};
|
|
1621
|
+
pp$3.declareName = function(name, bindingType, pos) {
|
|
1622
|
+
var redeclared = !1;
|
|
1623
|
+
if (bindingType === BIND_LEXICAL) {
|
|
1624
|
+
var scope = this.currentScope();
|
|
1625
|
+
redeclared = scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1, scope.lexical.push(name), this.inModule && scope.flags & SCOPE_TOP && delete this.undefinedExports[name];
|
|
1626
|
+
} else if (bindingType === BIND_SIMPLE_CATCH) {
|
|
1627
|
+
var scope$1 = this.currentScope();
|
|
1628
|
+
scope$1.lexical.push(name);
|
|
1629
|
+
} else if (bindingType === BIND_FUNCTION) {
|
|
1630
|
+
var scope$2 = this.currentScope();
|
|
1631
|
+
this.treatFunctionsAsVar ? redeclared = scope$2.lexical.indexOf(name) > -1 : redeclared = scope$2.lexical.indexOf(name) > -1 || scope$2.var.indexOf(name) > -1, scope$2.functions.push(name);
|
|
1632
|
+
} else
|
|
1633
|
+
for (var i = this.scopeStack.length - 1; i >= 0; --i) {
|
|
1634
|
+
var scope$3 = this.scopeStack[i];
|
|
1635
|
+
if (scope$3.lexical.indexOf(name) > -1 && !(scope$3.flags & SCOPE_SIMPLE_CATCH && scope$3.lexical[0] === name) || !this.treatFunctionsAsVarInScope(scope$3) && scope$3.functions.indexOf(name) > -1) {
|
|
1636
|
+
redeclared = !0;
|
|
1637
|
+
break;
|
|
1638
|
+
}
|
|
1639
|
+
if (scope$3.var.push(name), this.inModule && scope$3.flags & SCOPE_TOP && delete this.undefinedExports[name], scope$3.flags & SCOPE_VAR)
|
|
1640
|
+
break;
|
|
1641
|
+
}
|
|
1642
|
+
redeclared && this.raiseRecoverable(pos, "Identifier '" + name + "' has already been declared");
|
|
1643
|
+
};
|
|
1644
|
+
pp$3.checkLocalExport = function(id) {
|
|
1645
|
+
this.scopeStack[0].lexical.indexOf(id.name) === -1 && this.scopeStack[0].var.indexOf(id.name) === -1 && (this.undefinedExports[id.name] = id);
|
|
1646
|
+
};
|
|
1647
|
+
pp$3.currentScope = function() {
|
|
1648
|
+
return this.scopeStack[this.scopeStack.length - 1];
|
|
1649
|
+
};
|
|
1650
|
+
pp$3.currentVarScope = function() {
|
|
1651
|
+
for (var i = this.scopeStack.length - 1; ; i--) {
|
|
1652
|
+
var scope = this.scopeStack[i];
|
|
1653
|
+
if (scope.flags & SCOPE_VAR)
|
|
1654
|
+
return scope;
|
|
1655
|
+
}
|
|
1656
|
+
};
|
|
1657
|
+
pp$3.currentThisScope = function() {
|
|
1658
|
+
for (var i = this.scopeStack.length - 1; ; i--) {
|
|
1659
|
+
var scope = this.scopeStack[i];
|
|
1660
|
+
if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW))
|
|
1661
|
+
return scope;
|
|
1662
|
+
}
|
|
1663
|
+
};
|
|
1664
|
+
var Node = function(parser, pos, loc) {
|
|
1665
|
+
this.type = "", this.start = pos, this.end = 0, parser.options.locations && (this.loc = new SourceLocation(parser, loc)), parser.options.directSourceFile && (this.sourceFile = parser.options.directSourceFile), parser.options.ranges && (this.range = [pos, 0]);
|
|
1666
|
+
}, pp$2 = Parser.prototype;
|
|
1667
|
+
pp$2.startNode = function() {
|
|
1668
|
+
return new Node(this, this.start, this.startLoc);
|
|
1669
|
+
};
|
|
1670
|
+
pp$2.startNodeAt = function(pos, loc) {
|
|
1671
|
+
return new Node(this, pos, loc);
|
|
1672
|
+
};
|
|
1673
|
+
function finishNodeAt(node, type, pos, loc) {
|
|
1674
|
+
return node.type = type, node.end = pos, this.options.locations && (node.loc.end = loc), this.options.ranges && (node.range[1] = pos), node;
|
|
1675
|
+
}
|
|
1676
|
+
pp$2.finishNode = function(node, type) {
|
|
1677
|
+
return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc);
|
|
1678
|
+
};
|
|
1679
|
+
pp$2.finishNodeAt = function(node, type, pos, loc) {
|
|
1680
|
+
return finishNodeAt.call(this, node, type, pos, loc);
|
|
1681
|
+
};
|
|
1682
|
+
pp$2.copyNode = function(node) {
|
|
1683
|
+
var newNode = new Node(this, node.start, this.startLoc);
|
|
1684
|
+
for (var prop in node)
|
|
1685
|
+
newNode[prop] = node[prop];
|
|
1686
|
+
return newNode;
|
|
1687
|
+
};
|
|
1688
|
+
var scriptValuesAddedInUnicode = "Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz", ecma9BinaryProperties = "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", ecma10BinaryProperties = ecma9BinaryProperties + " Extended_Pictographic", ecma11BinaryProperties = ecma10BinaryProperties, ecma12BinaryProperties = ecma11BinaryProperties + " EBase EComp EMod EPres ExtPict", ecma13BinaryProperties = ecma12BinaryProperties, ecma14BinaryProperties = ecma13BinaryProperties, unicodeBinaryProperties = {
|
|
1689
|
+
9: ecma9BinaryProperties,
|
|
1690
|
+
10: ecma10BinaryProperties,
|
|
1691
|
+
11: ecma11BinaryProperties,
|
|
1692
|
+
12: ecma12BinaryProperties,
|
|
1693
|
+
13: ecma13BinaryProperties,
|
|
1694
|
+
14: ecma14BinaryProperties
|
|
1695
|
+
}, ecma14BinaryPropertiesOfStrings = "Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji", unicodeBinaryPropertiesOfStrings = {
|
|
1696
|
+
9: "",
|
|
1697
|
+
10: "",
|
|
1698
|
+
11: "",
|
|
1699
|
+
12: "",
|
|
1700
|
+
13: "",
|
|
1701
|
+
14: ecma14BinaryPropertiesOfStrings
|
|
1702
|
+
}, unicodeGeneralCategoryValues = "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", ecma9ScriptValues = "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", ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd", ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho", ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi", ecma13ScriptValues = ecma12ScriptValues + " Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith", ecma14ScriptValues = ecma13ScriptValues + " " + scriptValuesAddedInUnicode, unicodeScriptValues = {
|
|
1703
|
+
9: ecma9ScriptValues,
|
|
1704
|
+
10: ecma10ScriptValues,
|
|
1705
|
+
11: ecma11ScriptValues,
|
|
1706
|
+
12: ecma12ScriptValues,
|
|
1707
|
+
13: ecma13ScriptValues,
|
|
1708
|
+
14: ecma14ScriptValues
|
|
1709
|
+
}, data = {};
|
|
1710
|
+
function buildUnicodeData(ecmaVersion) {
|
|
1711
|
+
var d = data[ecmaVersion] = {
|
|
1712
|
+
binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + " " + unicodeGeneralCategoryValues),
|
|
1713
|
+
binaryOfStrings: wordsRegexp(unicodeBinaryPropertiesOfStrings[ecmaVersion]),
|
|
1714
|
+
nonBinary: {
|
|
1715
|
+
General_Category: wordsRegexp(unicodeGeneralCategoryValues),
|
|
1716
|
+
Script: wordsRegexp(unicodeScriptValues[ecmaVersion])
|
|
1717
|
+
}
|
|
1718
|
+
};
|
|
1719
|
+
d.nonBinary.Script_Extensions = d.nonBinary.Script, d.nonBinary.gc = d.nonBinary.General_Category, d.nonBinary.sc = d.nonBinary.Script, d.nonBinary.scx = d.nonBinary.Script_Extensions;
|
|
1720
|
+
}
|
|
1721
|
+
for (var i = 0, list = [9, 10, 11, 12, 13, 14]; i < list.length; i += 1) {
|
|
1722
|
+
var ecmaVersion = list[i];
|
|
1723
|
+
buildUnicodeData(ecmaVersion);
|
|
1724
|
+
}
|
|
1725
|
+
var pp$1 = Parser.prototype, BranchID = function(parent, base2) {
|
|
1726
|
+
this.parent = parent, this.base = base2 || this;
|
|
1727
|
+
};
|
|
1728
|
+
BranchID.prototype.separatedFrom = function(alt) {
|
|
1729
|
+
for (var self = this; self; self = self.parent)
|
|
1730
|
+
for (var other = alt; other; other = other.parent)
|
|
1731
|
+
if (self.base === other.base && self !== other)
|
|
1732
|
+
return !0;
|
|
1733
|
+
return !1;
|
|
1734
|
+
};
|
|
1735
|
+
BranchID.prototype.sibling = function() {
|
|
1736
|
+
return new BranchID(this.parent, this.base);
|
|
1737
|
+
};
|
|
1738
|
+
var RegExpValidationState = function(parser) {
|
|
1739
|
+
this.parser = parser, this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "") + (parser.options.ecmaVersion >= 15 ? "v" : ""), this.unicodeProperties = data[parser.options.ecmaVersion >= 14 ? 14 : parser.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 = /* @__PURE__ */ Object.create(null), this.backReferenceNames = [], this.branchID = null;
|
|
1740
|
+
};
|
|
1741
|
+
RegExpValidationState.prototype.reset = function(start, pattern, flags) {
|
|
1742
|
+
var unicodeSets = flags.indexOf("v") !== -1, unicode = flags.indexOf("u") !== -1;
|
|
1743
|
+
this.start = start | 0, this.source = pattern + "", this.flags = flags, unicodeSets && this.parser.options.ecmaVersion >= 15 ? (this.switchU = !0, this.switchV = !0, this.switchN = !0) : (this.switchU = unicode && this.parser.options.ecmaVersion >= 6, this.switchV = !1, this.switchN = unicode && this.parser.options.ecmaVersion >= 9);
|
|
1744
|
+
};
|
|
1745
|
+
RegExpValidationState.prototype.raise = function(message) {
|
|
1746
|
+
this.parser.raiseRecoverable(this.start, "Invalid regular expression: /" + this.source + "/: " + message);
|
|
1747
|
+
};
|
|
1748
|
+
RegExpValidationState.prototype.at = function(i, forceU) {
|
|
1749
|
+
forceU === void 0 && (forceU = !1);
|
|
1750
|
+
var s = this.source, l = s.length;
|
|
1751
|
+
if (i >= l)
|
|
1752
|
+
return -1;
|
|
1753
|
+
var c = s.charCodeAt(i);
|
|
1754
|
+
if (!(forceU || this.switchU) || c <= 55295 || c >= 57344 || i + 1 >= l)
|
|
1755
|
+
return c;
|
|
1756
|
+
var next = s.charCodeAt(i + 1);
|
|
1757
|
+
return next >= 56320 && next <= 57343 ? (c << 10) + next - 56613888 : c;
|
|
1758
|
+
};
|
|
1759
|
+
RegExpValidationState.prototype.nextIndex = function(i, forceU) {
|
|
1760
|
+
forceU === void 0 && (forceU = !1);
|
|
1761
|
+
var s = this.source, l = s.length;
|
|
1762
|
+
if (i >= l)
|
|
1763
|
+
return l;
|
|
1764
|
+
var c = s.charCodeAt(i), next;
|
|
1765
|
+
return !(forceU || this.switchU) || c <= 55295 || c >= 57344 || i + 1 >= l || (next = s.charCodeAt(i + 1)) < 56320 || next > 57343 ? i + 1 : i + 2;
|
|
1766
|
+
};
|
|
1767
|
+
RegExpValidationState.prototype.current = function(forceU) {
|
|
1768
|
+
return forceU === void 0 && (forceU = !1), this.at(this.pos, forceU);
|
|
1769
|
+
};
|
|
1770
|
+
RegExpValidationState.prototype.lookahead = function(forceU) {
|
|
1771
|
+
return forceU === void 0 && (forceU = !1), this.at(this.nextIndex(this.pos, forceU), forceU);
|
|
1772
|
+
};
|
|
1773
|
+
RegExpValidationState.prototype.advance = function(forceU) {
|
|
1774
|
+
forceU === void 0 && (forceU = !1), this.pos = this.nextIndex(this.pos, forceU);
|
|
1775
|
+
};
|
|
1776
|
+
RegExpValidationState.prototype.eat = function(ch, forceU) {
|
|
1777
|
+
return forceU === void 0 && (forceU = !1), this.current(forceU) === ch ? (this.advance(forceU), !0) : !1;
|
|
1778
|
+
};
|
|
1779
|
+
RegExpValidationState.prototype.eatChars = function(chs, forceU) {
|
|
1780
|
+
forceU === void 0 && (forceU = !1);
|
|
1781
|
+
for (var pos = this.pos, i = 0, list = chs; i < list.length; i += 1) {
|
|
1782
|
+
var ch = list[i], current2 = this.at(pos, forceU);
|
|
1783
|
+
if (current2 === -1 || current2 !== ch)
|
|
1784
|
+
return !1;
|
|
1785
|
+
pos = this.nextIndex(pos, forceU);
|
|
1786
|
+
}
|
|
1787
|
+
return this.pos = pos, !0;
|
|
1788
|
+
};
|
|
1789
|
+
pp$1.validateRegExpFlags = function(state) {
|
|
1790
|
+
for (var validFlags = state.validFlags, flags = state.flags, u = !1, v = !1, i = 0; i < flags.length; i++) {
|
|
1791
|
+
var flag = flags.charAt(i);
|
|
1792
|
+
validFlags.indexOf(flag) === -1 && this.raise(state.start, "Invalid regular expression flag"), flags.indexOf(flag, i + 1) > -1 && this.raise(state.start, "Duplicate regular expression flag"), flag === "u" && (u = !0), flag === "v" && (v = !0);
|
|
1793
|
+
}
|
|
1794
|
+
this.options.ecmaVersion >= 15 && u && v && this.raise(state.start, "Invalid regular expression flag");
|
|
1795
|
+
};
|
|
1796
|
+
function hasProp(obj) {
|
|
1797
|
+
for (var _ in obj)
|
|
1798
|
+
return !0;
|
|
1799
|
+
return !1;
|
|
1800
|
+
}
|
|
1801
|
+
pp$1.validateRegExpPattern = function(state) {
|
|
1802
|
+
this.regexp_pattern(state), !state.switchN && this.options.ecmaVersion >= 9 && hasProp(state.groupNames) && (state.switchN = !0, this.regexp_pattern(state));
|
|
1803
|
+
};
|
|
1804
|
+
pp$1.regexp_pattern = function(state) {
|
|
1805
|
+
state.pos = 0, state.lastIntValue = 0, state.lastStringValue = "", state.lastAssertionIsQuantifiable = !1, state.numCapturingParens = 0, state.maxBackReference = 0, state.groupNames = /* @__PURE__ */ Object.create(null), state.backReferenceNames.length = 0, state.branchID = null, this.regexp_disjunction(state), state.pos !== state.source.length && (state.eat(
|
|
1806
|
+
41
|
|
1807
|
+
/* ) */
|
|
1808
|
+
) && state.raise("Unmatched ')'"), (state.eat(
|
|
1809
|
+
93
|
|
1810
|
+
/* ] */
|
|
1811
|
+
) || state.eat(
|
|
1812
|
+
125
|
|
1813
|
+
/* } */
|
|
1814
|
+
)) && state.raise("Lone quantifier brackets")), state.maxBackReference > state.numCapturingParens && state.raise("Invalid escape");
|
|
1815
|
+
for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) {
|
|
1816
|
+
var name = list[i];
|
|
1817
|
+
state.groupNames[name] || state.raise("Invalid named capture referenced");
|
|
1818
|
+
}
|
|
1819
|
+
};
|
|
1820
|
+
pp$1.regexp_disjunction = function(state) {
|
|
1821
|
+
var trackDisjunction = this.options.ecmaVersion >= 16;
|
|
1822
|
+
for (trackDisjunction && (state.branchID = new BranchID(state.branchID, null)), this.regexp_alternative(state); state.eat(
|
|
1823
|
+
124
|
|
1824
|
+
/* | */
|
|
1825
|
+
); )
|
|
1826
|
+
trackDisjunction && (state.branchID = state.branchID.sibling()), this.regexp_alternative(state);
|
|
1827
|
+
trackDisjunction && (state.branchID = state.branchID.parent), this.regexp_eatQuantifier(state, !0) && state.raise("Nothing to repeat"), state.eat(
|
|
1828
|
+
123
|
|
1829
|
+
/* { */
|
|
1830
|
+
) && state.raise("Lone quantifier brackets");
|
|
1831
|
+
};
|
|
1832
|
+
pp$1.regexp_alternative = function(state) {
|
|
1833
|
+
for (; state.pos < state.source.length && this.regexp_eatTerm(state); )
|
|
1834
|
+
;
|
|
1835
|
+
};
|
|
1836
|
+
pp$1.regexp_eatTerm = function(state) {
|
|
1837
|
+
return this.regexp_eatAssertion(state) ? (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state) && state.switchU && state.raise("Invalid quantifier"), !0) : (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) ? (this.regexp_eatQuantifier(state), !0) : !1;
|
|
1838
|
+
};
|
|
1839
|
+
pp$1.regexp_eatAssertion = function(state) {
|
|
1840
|
+
var start = state.pos;
|
|
1841
|
+
if (state.lastAssertionIsQuantifiable = !1, state.eat(
|
|
1842
|
+
94
|
|
1843
|
+
/* ^ */
|
|
1844
|
+
) || state.eat(
|
|
1845
|
+
36
|
|
1846
|
+
/* $ */
|
|
1847
|
+
))
|
|
1848
|
+
return !0;
|
|
1849
|
+
if (state.eat(
|
|
1850
|
+
92
|
|
1851
|
+
/* \ */
|
|
1852
|
+
)) {
|
|
1853
|
+
if (state.eat(
|
|
1854
|
+
66
|
|
1855
|
+
/* B */
|
|
1856
|
+
) || state.eat(
|
|
1857
|
+
98
|
|
1858
|
+
/* b */
|
|
1859
|
+
))
|
|
1860
|
+
return !0;
|
|
1861
|
+
state.pos = start;
|
|
1862
|
+
}
|
|
1863
|
+
if (state.eat(
|
|
1864
|
+
40
|
|
1865
|
+
/* ( */
|
|
1866
|
+
) && state.eat(
|
|
1867
|
+
63
|
|
1868
|
+
/* ? */
|
|
1869
|
+
)) {
|
|
1870
|
+
var lookbehind = !1;
|
|
1871
|
+
if (this.options.ecmaVersion >= 9 && (lookbehind = state.eat(
|
|
1872
|
+
60
|
|
1873
|
+
/* < */
|
|
1874
|
+
)), state.eat(
|
|
1875
|
+
61
|
|
1876
|
+
/* = */
|
|
1877
|
+
) || state.eat(
|
|
1878
|
+
33
|
|
1879
|
+
/* ! */
|
|
1880
|
+
))
|
|
1881
|
+
return this.regexp_disjunction(state), state.eat(
|
|
1882
|
+
41
|
|
1883
|
+
/* ) */
|
|
1884
|
+
) || state.raise("Unterminated group"), state.lastAssertionIsQuantifiable = !lookbehind, !0;
|
|
1885
|
+
}
|
|
1886
|
+
return state.pos = start, !1;
|
|
1887
|
+
};
|
|
1888
|
+
pp$1.regexp_eatQuantifier = function(state, noError) {
|
|
1889
|
+
return noError === void 0 && (noError = !1), this.regexp_eatQuantifierPrefix(state, noError) ? (state.eat(
|
|
1890
|
+
63
|
|
1891
|
+
/* ? */
|
|
1892
|
+
), !0) : !1;
|
|
1893
|
+
};
|
|
1894
|
+
pp$1.regexp_eatQuantifierPrefix = function(state, noError) {
|
|
1895
|
+
return state.eat(
|
|
1896
|
+
42
|
|
1897
|
+
/* * */
|
|
1898
|
+
) || state.eat(
|
|
1899
|
+
43
|
|
1900
|
+
/* + */
|
|
1901
|
+
) || state.eat(
|
|
1902
|
+
63
|
|
1903
|
+
/* ? */
|
|
1904
|
+
) || this.regexp_eatBracedQuantifier(state, noError);
|
|
1905
|
+
};
|
|
1906
|
+
pp$1.regexp_eatBracedQuantifier = function(state, noError) {
|
|
1907
|
+
var start = state.pos;
|
|
1908
|
+
if (state.eat(
|
|
1909
|
+
123
|
|
1910
|
+
/* { */
|
|
1911
|
+
)) {
|
|
1912
|
+
var min = 0, max = -1;
|
|
1913
|
+
if (this.regexp_eatDecimalDigits(state) && (min = state.lastIntValue, state.eat(
|
|
1914
|
+
44
|
|
1915
|
+
/* , */
|
|
1916
|
+
) && this.regexp_eatDecimalDigits(state) && (max = state.lastIntValue), state.eat(
|
|
1917
|
+
125
|
|
1918
|
+
/* } */
|
|
1919
|
+
)))
|
|
1920
|
+
return max !== -1 && max < min && !noError && state.raise("numbers out of order in {} quantifier"), !0;
|
|
1921
|
+
state.switchU && !noError && state.raise("Incomplete quantifier"), state.pos = start;
|
|
1922
|
+
}
|
|
1923
|
+
return !1;
|
|
1924
|
+
};
|
|
1925
|
+
pp$1.regexp_eatAtom = function(state) {
|
|
1926
|
+
return this.regexp_eatPatternCharacters(state) || state.eat(
|
|
1927
|
+
46
|
|
1928
|
+
/* . */
|
|
1929
|
+
) || this.regexp_eatReverseSolidusAtomEscape(state) || this.regexp_eatCharacterClass(state) || this.regexp_eatUncapturingGroup(state) || this.regexp_eatCapturingGroup(state);
|
|
1930
|
+
};
|
|
1931
|
+
pp$1.regexp_eatReverseSolidusAtomEscape = function(state) {
|
|
1932
|
+
var start = state.pos;
|
|
1933
|
+
if (state.eat(
|
|
1934
|
+
92
|
|
1935
|
+
/* \ */
|
|
1936
|
+
)) {
|
|
1937
|
+
if (this.regexp_eatAtomEscape(state))
|
|
1938
|
+
return !0;
|
|
1939
|
+
state.pos = start;
|
|
1940
|
+
}
|
|
1941
|
+
return !1;
|
|
1942
|
+
};
|
|
1943
|
+
pp$1.regexp_eatUncapturingGroup = function(state) {
|
|
1944
|
+
var start = state.pos;
|
|
1945
|
+
if (state.eat(
|
|
1946
|
+
40
|
|
1947
|
+
/* ( */
|
|
1948
|
+
)) {
|
|
1949
|
+
if (state.eat(
|
|
1950
|
+
63
|
|
1951
|
+
/* ? */
|
|
1952
|
+
)) {
|
|
1953
|
+
if (this.options.ecmaVersion >= 16) {
|
|
1954
|
+
var addModifiers = this.regexp_eatModifiers(state), hasHyphen = state.eat(
|
|
1955
|
+
45
|
|
1956
|
+
/* - */
|
|
1957
|
+
);
|
|
1958
|
+
if (addModifiers || hasHyphen) {
|
|
1959
|
+
for (var i = 0; i < addModifiers.length; i++) {
|
|
1960
|
+
var modifier = addModifiers.charAt(i);
|
|
1961
|
+
addModifiers.indexOf(modifier, i + 1) > -1 && state.raise("Duplicate regular expression modifiers");
|
|
1962
|
+
}
|
|
1963
|
+
if (hasHyphen) {
|
|
1964
|
+
var removeModifiers = this.regexp_eatModifiers(state);
|
|
1965
|
+
!addModifiers && !removeModifiers && state.current() === 58 && state.raise("Invalid regular expression modifiers");
|
|
1966
|
+
for (var i$1 = 0; i$1 < removeModifiers.length; i$1++) {
|
|
1967
|
+
var modifier$1 = removeModifiers.charAt(i$1);
|
|
1968
|
+
(removeModifiers.indexOf(modifier$1, i$1 + 1) > -1 || addModifiers.indexOf(modifier$1) > -1) && state.raise("Duplicate regular expression modifiers");
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
if (state.eat(
|
|
1974
|
+
58
|
|
1975
|
+
/* : */
|
|
1976
|
+
)) {
|
|
1977
|
+
if (this.regexp_disjunction(state), state.eat(
|
|
1978
|
+
41
|
|
1979
|
+
/* ) */
|
|
1980
|
+
))
|
|
1981
|
+
return !0;
|
|
1982
|
+
state.raise("Unterminated group");
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
state.pos = start;
|
|
1986
|
+
}
|
|
1987
|
+
return !1;
|
|
1988
|
+
};
|
|
1989
|
+
pp$1.regexp_eatCapturingGroup = function(state) {
|
|
1990
|
+
if (state.eat(
|
|
1991
|
+
40
|
|
1992
|
+
/* ( */
|
|
1993
|
+
)) {
|
|
1994
|
+
if (this.options.ecmaVersion >= 9 ? this.regexp_groupSpecifier(state) : state.current() === 63 && state.raise("Invalid group"), this.regexp_disjunction(state), state.eat(
|
|
1995
|
+
41
|
|
1996
|
+
/* ) */
|
|
1997
|
+
))
|
|
1998
|
+
return state.numCapturingParens += 1, !0;
|
|
1999
|
+
state.raise("Unterminated group");
|
|
2000
|
+
}
|
|
2001
|
+
return !1;
|
|
2002
|
+
};
|
|
2003
|
+
pp$1.regexp_eatModifiers = function(state) {
|
|
2004
|
+
for (var modifiers = "", ch = 0; (ch = state.current()) !== -1 && isRegularExpressionModifier(ch); )
|
|
2005
|
+
modifiers += codePointToString(ch), state.advance();
|
|
2006
|
+
return modifiers;
|
|
2007
|
+
};
|
|
2008
|
+
function isRegularExpressionModifier(ch) {
|
|
2009
|
+
return ch === 105 || ch === 109 || ch === 115;
|
|
2010
|
+
}
|
|
2011
|
+
pp$1.regexp_eatExtendedAtom = function(state) {
|
|
2012
|
+
return state.eat(
|
|
2013
|
+
46
|
|
2014
|
+
/* . */
|
|
2015
|
+
) || this.regexp_eatReverseSolidusAtomEscape(state) || this.regexp_eatCharacterClass(state) || this.regexp_eatUncapturingGroup(state) || this.regexp_eatCapturingGroup(state) || this.regexp_eatInvalidBracedQuantifier(state) || this.regexp_eatExtendedPatternCharacter(state);
|
|
2016
|
+
};
|
|
2017
|
+
pp$1.regexp_eatInvalidBracedQuantifier = function(state) {
|
|
2018
|
+
return this.regexp_eatBracedQuantifier(state, !0) && state.raise("Nothing to repeat"), !1;
|
|
2019
|
+
};
|
|
2020
|
+
pp$1.regexp_eatSyntaxCharacter = function(state) {
|
|
2021
|
+
var ch = state.current();
|
|
2022
|
+
return isSyntaxCharacter(ch) ? (state.lastIntValue = ch, state.advance(), !0) : !1;
|
|
2023
|
+
};
|
|
2024
|
+
function isSyntaxCharacter(ch) {
|
|
2025
|
+
return ch === 36 || ch >= 40 && ch <= 43 || ch === 46 || ch === 63 || ch >= 91 && ch <= 94 || ch >= 123 && ch <= 125;
|
|
2026
|
+
}
|
|
2027
|
+
pp$1.regexp_eatPatternCharacters = function(state) {
|
|
2028
|
+
for (var start = state.pos, ch = 0; (ch = state.current()) !== -1 && !isSyntaxCharacter(ch); )
|
|
2029
|
+
state.advance();
|
|
2030
|
+
return state.pos !== start;
|
|
2031
|
+
};
|
|
2032
|
+
pp$1.regexp_eatExtendedPatternCharacter = function(state) {
|
|
2033
|
+
var ch = state.current();
|
|
2034
|
+
return ch !== -1 && ch !== 36 && !(ch >= 40 && ch <= 43) && ch !== 46 && ch !== 63 && ch !== 91 && ch !== 94 && ch !== 124 ? (state.advance(), !0) : !1;
|
|
2035
|
+
};
|
|
2036
|
+
pp$1.regexp_groupSpecifier = function(state) {
|
|
2037
|
+
if (state.eat(
|
|
2038
|
+
63
|
|
2039
|
+
/* ? */
|
|
2040
|
+
)) {
|
|
2041
|
+
this.regexp_eatGroupName(state) || state.raise("Invalid group");
|
|
2042
|
+
var trackDisjunction = this.options.ecmaVersion >= 16, known = state.groupNames[state.lastStringValue];
|
|
2043
|
+
if (known)
|
|
2044
|
+
if (trackDisjunction)
|
|
2045
|
+
for (var i = 0, list = known; i < list.length; i += 1) {
|
|
2046
|
+
var altID = list[i];
|
|
2047
|
+
altID.separatedFrom(state.branchID) || state.raise("Duplicate capture group name");
|
|
2048
|
+
}
|
|
2049
|
+
else
|
|
2050
|
+
state.raise("Duplicate capture group name");
|
|
2051
|
+
trackDisjunction ? (known || (state.groupNames[state.lastStringValue] = [])).push(state.branchID) : state.groupNames[state.lastStringValue] = !0;
|
|
2052
|
+
}
|
|
2053
|
+
};
|
|
2054
|
+
pp$1.regexp_eatGroupName = function(state) {
|
|
2055
|
+
if (state.lastStringValue = "", state.eat(
|
|
2056
|
+
60
|
|
2057
|
+
/* < */
|
|
2058
|
+
)) {
|
|
2059
|
+
if (this.regexp_eatRegExpIdentifierName(state) && state.eat(
|
|
2060
|
+
62
|
|
2061
|
+
/* > */
|
|
2062
|
+
))
|
|
2063
|
+
return !0;
|
|
2064
|
+
state.raise("Invalid capture group name");
|
|
2065
|
+
}
|
|
2066
|
+
return !1;
|
|
2067
|
+
};
|
|
2068
|
+
pp$1.regexp_eatRegExpIdentifierName = function(state) {
|
|
2069
|
+
if (state.lastStringValue = "", this.regexp_eatRegExpIdentifierStart(state)) {
|
|
2070
|
+
for (state.lastStringValue += codePointToString(state.lastIntValue); this.regexp_eatRegExpIdentifierPart(state); )
|
|
2071
|
+
state.lastStringValue += codePointToString(state.lastIntValue);
|
|
2072
|
+
return !0;
|
|
2073
|
+
}
|
|
2074
|
+
return !1;
|
|
2075
|
+
};
|
|
2076
|
+
pp$1.regexp_eatRegExpIdentifierStart = function(state) {
|
|
2077
|
+
var start = state.pos, forceU = this.options.ecmaVersion >= 11, ch = state.current(forceU);
|
|
2078
|
+
return state.advance(forceU), ch === 92 && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU) && (ch = state.lastIntValue), isRegExpIdentifierStart(ch) ? (state.lastIntValue = ch, !0) : (state.pos = start, !1);
|
|
2079
|
+
};
|
|
2080
|
+
function isRegExpIdentifierStart(ch) {
|
|
2081
|
+
return isIdentifierStart(ch, !0) || ch === 36 || ch === 95;
|
|
2082
|
+
}
|
|
2083
|
+
pp$1.regexp_eatRegExpIdentifierPart = function(state) {
|
|
2084
|
+
var start = state.pos, forceU = this.options.ecmaVersion >= 11, ch = state.current(forceU);
|
|
2085
|
+
return state.advance(forceU), ch === 92 && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU) && (ch = state.lastIntValue), isRegExpIdentifierPart(ch) ? (state.lastIntValue = ch, !0) : (state.pos = start, !1);
|
|
2086
|
+
};
|
|
2087
|
+
function isRegExpIdentifierPart(ch) {
|
|
2088
|
+
return isIdentifierChar(ch, !0) || ch === 36 || ch === 95 || ch === 8204 || ch === 8205;
|
|
2089
|
+
}
|
|
2090
|
+
pp$1.regexp_eatAtomEscape = function(state) {
|
|
2091
|
+
return this.regexp_eatBackReference(state) || this.regexp_eatCharacterClassEscape(state) || this.regexp_eatCharacterEscape(state) || state.switchN && this.regexp_eatKGroupName(state) ? !0 : (state.switchU && (state.current() === 99 && state.raise("Invalid unicode escape"), state.raise("Invalid escape")), !1);
|
|
2092
|
+
};
|
|
2093
|
+
pp$1.regexp_eatBackReference = function(state) {
|
|
2094
|
+
var start = state.pos;
|
|
2095
|
+
if (this.regexp_eatDecimalEscape(state)) {
|
|
2096
|
+
var n = state.lastIntValue;
|
|
2097
|
+
if (state.switchU)
|
|
2098
|
+
return n > state.maxBackReference && (state.maxBackReference = n), !0;
|
|
2099
|
+
if (n <= state.numCapturingParens)
|
|
2100
|
+
return !0;
|
|
2101
|
+
state.pos = start;
|
|
2102
|
+
}
|
|
2103
|
+
return !1;
|
|
2104
|
+
};
|
|
2105
|
+
pp$1.regexp_eatKGroupName = function(state) {
|
|
2106
|
+
if (state.eat(
|
|
2107
|
+
107
|
|
2108
|
+
/* k */
|
|
2109
|
+
)) {
|
|
2110
|
+
if (this.regexp_eatGroupName(state))
|
|
2111
|
+
return state.backReferenceNames.push(state.lastStringValue), !0;
|
|
2112
|
+
state.raise("Invalid named reference");
|
|
2113
|
+
}
|
|
2114
|
+
return !1;
|
|
2115
|
+
};
|
|
2116
|
+
pp$1.regexp_eatCharacterEscape = function(state) {
|
|
2117
|
+
return this.regexp_eatControlEscape(state) || this.regexp_eatCControlLetter(state) || this.regexp_eatZero(state) || this.regexp_eatHexEscapeSequence(state) || this.regexp_eatRegExpUnicodeEscapeSequence(state, !1) || !state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state) || this.regexp_eatIdentityEscape(state);
|
|
2118
|
+
};
|
|
2119
|
+
pp$1.regexp_eatCControlLetter = function(state) {
|
|
2120
|
+
var start = state.pos;
|
|
2121
|
+
if (state.eat(
|
|
2122
|
+
99
|
|
2123
|
+
/* c */
|
|
2124
|
+
)) {
|
|
2125
|
+
if (this.regexp_eatControlLetter(state))
|
|
2126
|
+
return !0;
|
|
2127
|
+
state.pos = start;
|
|
2128
|
+
}
|
|
2129
|
+
return !1;
|
|
2130
|
+
};
|
|
2131
|
+
pp$1.regexp_eatZero = function(state) {
|
|
2132
|
+
return state.current() === 48 && !isDecimalDigit(state.lookahead()) ? (state.lastIntValue = 0, state.advance(), !0) : !1;
|
|
2133
|
+
};
|
|
2134
|
+
pp$1.regexp_eatControlEscape = function(state) {
|
|
2135
|
+
var ch = state.current();
|
|
2136
|
+
return ch === 116 ? (state.lastIntValue = 9, state.advance(), !0) : ch === 110 ? (state.lastIntValue = 10, state.advance(), !0) : ch === 118 ? (state.lastIntValue = 11, state.advance(), !0) : ch === 102 ? (state.lastIntValue = 12, state.advance(), !0) : ch === 114 ? (state.lastIntValue = 13, state.advance(), !0) : !1;
|
|
2137
|
+
};
|
|
2138
|
+
pp$1.regexp_eatControlLetter = function(state) {
|
|
2139
|
+
var ch = state.current();
|
|
2140
|
+
return isControlLetter(ch) ? (state.lastIntValue = ch % 32, state.advance(), !0) : !1;
|
|
2141
|
+
};
|
|
2142
|
+
function isControlLetter(ch) {
|
|
2143
|
+
return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122;
|
|
2144
|
+
}
|
|
2145
|
+
pp$1.regexp_eatRegExpUnicodeEscapeSequence = function(state, forceU) {
|
|
2146
|
+
forceU === void 0 && (forceU = !1);
|
|
2147
|
+
var start = state.pos, switchU = forceU || state.switchU;
|
|
2148
|
+
if (state.eat(
|
|
2149
|
+
117
|
|
2150
|
+
/* u */
|
|
2151
|
+
)) {
|
|
2152
|
+
if (this.regexp_eatFixedHexDigits(state, 4)) {
|
|
2153
|
+
var lead = state.lastIntValue;
|
|
2154
|
+
if (switchU && lead >= 55296 && lead <= 56319) {
|
|
2155
|
+
var leadSurrogateEnd = state.pos;
|
|
2156
|
+
if (state.eat(
|
|
2157
|
+
92
|
|
2158
|
+
/* \ */
|
|
2159
|
+
) && state.eat(
|
|
2160
|
+
117
|
|
2161
|
+
/* u */
|
|
2162
|
+
) && this.regexp_eatFixedHexDigits(state, 4)) {
|
|
2163
|
+
var trail = state.lastIntValue;
|
|
2164
|
+
if (trail >= 56320 && trail <= 57343)
|
|
2165
|
+
return state.lastIntValue = (lead - 55296) * 1024 + (trail - 56320) + 65536, !0;
|
|
2166
|
+
}
|
|
2167
|
+
state.pos = leadSurrogateEnd, state.lastIntValue = lead;
|
|
2168
|
+
}
|
|
2169
|
+
return !0;
|
|
2170
|
+
}
|
|
2171
|
+
if (switchU && state.eat(
|
|
2172
|
+
123
|
|
2173
|
+
/* { */
|
|
2174
|
+
) && this.regexp_eatHexDigits(state) && state.eat(
|
|
2175
|
+
125
|
|
2176
|
+
/* } */
|
|
2177
|
+
) && isValidUnicode(state.lastIntValue))
|
|
2178
|
+
return !0;
|
|
2179
|
+
switchU && state.raise("Invalid unicode escape"), state.pos = start;
|
|
2180
|
+
}
|
|
2181
|
+
return !1;
|
|
2182
|
+
};
|
|
2183
|
+
function isValidUnicode(ch) {
|
|
2184
|
+
return ch >= 0 && ch <= 1114111;
|
|
2185
|
+
}
|
|
2186
|
+
pp$1.regexp_eatIdentityEscape = function(state) {
|
|
2187
|
+
if (state.switchU)
|
|
2188
|
+
return this.regexp_eatSyntaxCharacter(state) ? !0 : state.eat(
|
|
2189
|
+
47
|
|
2190
|
+
/* / */
|
|
2191
|
+
) ? (state.lastIntValue = 47, !0) : !1;
|
|
2192
|
+
var ch = state.current();
|
|
2193
|
+
return ch !== 99 && (!state.switchN || ch !== 107) ? (state.lastIntValue = ch, state.advance(), !0) : !1;
|
|
2194
|
+
};
|
|
2195
|
+
pp$1.regexp_eatDecimalEscape = function(state) {
|
|
2196
|
+
state.lastIntValue = 0;
|
|
2197
|
+
var ch = state.current();
|
|
2198
|
+
if (ch >= 49 && ch <= 57) {
|
|
2199
|
+
do
|
|
2200
|
+
state.lastIntValue = 10 * state.lastIntValue + (ch - 48), state.advance();
|
|
2201
|
+
while ((ch = state.current()) >= 48 && ch <= 57);
|
|
2202
|
+
return !0;
|
|
2203
|
+
}
|
|
2204
|
+
return !1;
|
|
2205
|
+
};
|
|
2206
|
+
var CharSetNone = 0, CharSetOk = 1, CharSetString = 2;
|
|
2207
|
+
pp$1.regexp_eatCharacterClassEscape = function(state) {
|
|
2208
|
+
var ch = state.current();
|
|
2209
|
+
if (isCharacterClassEscape(ch))
|
|
2210
|
+
return state.lastIntValue = -1, state.advance(), CharSetOk;
|
|
2211
|
+
var negate = !1;
|
|
2212
|
+
if (state.switchU && this.options.ecmaVersion >= 9 && ((negate = ch === 80) || ch === 112)) {
|
|
2213
|
+
state.lastIntValue = -1, state.advance();
|
|
2214
|
+
var result;
|
|
2215
|
+
if (state.eat(
|
|
2216
|
+
123
|
|
2217
|
+
/* { */
|
|
2218
|
+
) && (result = this.regexp_eatUnicodePropertyValueExpression(state)) && state.eat(
|
|
2219
|
+
125
|
|
2220
|
+
/* } */
|
|
2221
|
+
))
|
|
2222
|
+
return negate && result === CharSetString && state.raise("Invalid property name"), result;
|
|
2223
|
+
state.raise("Invalid property name");
|
|
2224
|
+
}
|
|
2225
|
+
return CharSetNone;
|
|
2226
|
+
};
|
|
2227
|
+
function isCharacterClassEscape(ch) {
|
|
2228
|
+
return ch === 100 || ch === 68 || ch === 115 || ch === 83 || ch === 119 || ch === 87;
|
|
2229
|
+
}
|
|
2230
|
+
pp$1.regexp_eatUnicodePropertyValueExpression = function(state) {
|
|
2231
|
+
var start = state.pos;
|
|
2232
|
+
if (this.regexp_eatUnicodePropertyName(state) && state.eat(
|
|
2233
|
+
61
|
|
2234
|
+
/* = */
|
|
2235
|
+
)) {
|
|
2236
|
+
var name = state.lastStringValue;
|
|
2237
|
+
if (this.regexp_eatUnicodePropertyValue(state)) {
|
|
2238
|
+
var value = state.lastStringValue;
|
|
2239
|
+
return this.regexp_validateUnicodePropertyNameAndValue(state, name, value), CharSetOk;
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
if (state.pos = start, this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {
|
|
2243
|
+
var nameOrValue = state.lastStringValue;
|
|
2244
|
+
return this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue);
|
|
2245
|
+
}
|
|
2246
|
+
return CharSetNone;
|
|
2247
|
+
};
|
|
2248
|
+
pp$1.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) {
|
|
2249
|
+
hasOwn(state.unicodeProperties.nonBinary, name) || state.raise("Invalid property name"), state.unicodeProperties.nonBinary[name].test(value) || state.raise("Invalid property value");
|
|
2250
|
+
};
|
|
2251
|
+
pp$1.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) {
|
|
2252
|
+
if (state.unicodeProperties.binary.test(nameOrValue))
|
|
2253
|
+
return CharSetOk;
|
|
2254
|
+
if (state.switchV && state.unicodeProperties.binaryOfStrings.test(nameOrValue))
|
|
2255
|
+
return CharSetString;
|
|
2256
|
+
state.raise("Invalid property name");
|
|
2257
|
+
};
|
|
2258
|
+
pp$1.regexp_eatUnicodePropertyName = function(state) {
|
|
2259
|
+
var ch = 0;
|
|
2260
|
+
for (state.lastStringValue = ""; isUnicodePropertyNameCharacter(ch = state.current()); )
|
|
2261
|
+
state.lastStringValue += codePointToString(ch), state.advance();
|
|
2262
|
+
return state.lastStringValue !== "";
|
|
2263
|
+
};
|
|
2264
|
+
function isUnicodePropertyNameCharacter(ch) {
|
|
2265
|
+
return isControlLetter(ch) || ch === 95;
|
|
2266
|
+
}
|
|
2267
|
+
pp$1.regexp_eatUnicodePropertyValue = function(state) {
|
|
2268
|
+
var ch = 0;
|
|
2269
|
+
for (state.lastStringValue = ""; isUnicodePropertyValueCharacter(ch = state.current()); )
|
|
2270
|
+
state.lastStringValue += codePointToString(ch), state.advance();
|
|
2271
|
+
return state.lastStringValue !== "";
|
|
2272
|
+
};
|
|
2273
|
+
function isUnicodePropertyValueCharacter(ch) {
|
|
2274
|
+
return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch);
|
|
2275
|
+
}
|
|
2276
|
+
pp$1.regexp_eatLoneUnicodePropertyNameOrValue = function(state) {
|
|
2277
|
+
return this.regexp_eatUnicodePropertyValue(state);
|
|
2278
|
+
};
|
|
2279
|
+
pp$1.regexp_eatCharacterClass = function(state) {
|
|
2280
|
+
if (state.eat(
|
|
2281
|
+
91
|
|
2282
|
+
/* [ */
|
|
2283
|
+
)) {
|
|
2284
|
+
var negate = state.eat(
|
|
2285
|
+
94
|
|
2286
|
+
/* ^ */
|
|
2287
|
+
), result = this.regexp_classContents(state);
|
|
2288
|
+
return state.eat(
|
|
2289
|
+
93
|
|
2290
|
+
/* ] */
|
|
2291
|
+
) || state.raise("Unterminated character class"), negate && result === CharSetString && state.raise("Negated character class may contain strings"), !0;
|
|
2292
|
+
}
|
|
2293
|
+
return !1;
|
|
2294
|
+
};
|
|
2295
|
+
pp$1.regexp_classContents = function(state) {
|
|
2296
|
+
return state.current() === 93 ? CharSetOk : state.switchV ? this.regexp_classSetExpression(state) : (this.regexp_nonEmptyClassRanges(state), CharSetOk);
|
|
2297
|
+
};
|
|
2298
|
+
pp$1.regexp_nonEmptyClassRanges = function(state) {
|
|
2299
|
+
for (; this.regexp_eatClassAtom(state); ) {
|
|
2300
|
+
var left = state.lastIntValue;
|
|
2301
|
+
if (state.eat(
|
|
2302
|
+
45
|
|
2303
|
+
/* - */
|
|
2304
|
+
) && this.regexp_eatClassAtom(state)) {
|
|
2305
|
+
var right = state.lastIntValue;
|
|
2306
|
+
state.switchU && (left === -1 || right === -1) && state.raise("Invalid character class"), left !== -1 && right !== -1 && left > right && state.raise("Range out of order in character class");
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
};
|
|
2310
|
+
pp$1.regexp_eatClassAtom = function(state) {
|
|
2311
|
+
var start = state.pos;
|
|
2312
|
+
if (state.eat(
|
|
2313
|
+
92
|
|
2314
|
+
/* \ */
|
|
2315
|
+
)) {
|
|
2316
|
+
if (this.regexp_eatClassEscape(state))
|
|
2317
|
+
return !0;
|
|
2318
|
+
if (state.switchU) {
|
|
2319
|
+
var ch$1 = state.current();
|
|
2320
|
+
(ch$1 === 99 || isOctalDigit(ch$1)) && state.raise("Invalid class escape"), state.raise("Invalid escape");
|
|
2321
|
+
}
|
|
2322
|
+
state.pos = start;
|
|
2323
|
+
}
|
|
2324
|
+
var ch = state.current();
|
|
2325
|
+
return ch !== 93 ? (state.lastIntValue = ch, state.advance(), !0) : !1;
|
|
2326
|
+
};
|
|
2327
|
+
pp$1.regexp_eatClassEscape = function(state) {
|
|
2328
|
+
var start = state.pos;
|
|
2329
|
+
if (state.eat(
|
|
2330
|
+
98
|
|
2331
|
+
/* b */
|
|
2332
|
+
))
|
|
2333
|
+
return state.lastIntValue = 8, !0;
|
|
2334
|
+
if (state.switchU && state.eat(
|
|
2335
|
+
45
|
|
2336
|
+
/* - */
|
|
2337
|
+
))
|
|
2338
|
+
return state.lastIntValue = 45, !0;
|
|
2339
|
+
if (!state.switchU && state.eat(
|
|
2340
|
+
99
|
|
2341
|
+
/* c */
|
|
2342
|
+
)) {
|
|
2343
|
+
if (this.regexp_eatClassControlLetter(state))
|
|
2344
|
+
return !0;
|
|
2345
|
+
state.pos = start;
|
|
2346
|
+
}
|
|
2347
|
+
return this.regexp_eatCharacterClassEscape(state) || this.regexp_eatCharacterEscape(state);
|
|
2348
|
+
};
|
|
2349
|
+
pp$1.regexp_classSetExpression = function(state) {
|
|
2350
|
+
var result = CharSetOk, subResult;
|
|
2351
|
+
if (!this.regexp_eatClassSetRange(state)) if (subResult = this.regexp_eatClassSetOperand(state)) {
|
|
2352
|
+
subResult === CharSetString && (result = CharSetString);
|
|
2353
|
+
for (var start = state.pos; state.eatChars(
|
|
2354
|
+
[38, 38]
|
|
2355
|
+
/* && */
|
|
2356
|
+
); ) {
|
|
2357
|
+
if (state.current() !== 38 && (subResult = this.regexp_eatClassSetOperand(state))) {
|
|
2358
|
+
subResult !== CharSetString && (result = CharSetOk);
|
|
2359
|
+
continue;
|
|
2360
|
+
}
|
|
2361
|
+
state.raise("Invalid character in character class");
|
|
2362
|
+
}
|
|
2363
|
+
if (start !== state.pos)
|
|
2364
|
+
return result;
|
|
2365
|
+
for (; state.eatChars(
|
|
2366
|
+
[45, 45]
|
|
2367
|
+
/* -- */
|
|
2368
|
+
); )
|
|
2369
|
+
this.regexp_eatClassSetOperand(state) || state.raise("Invalid character in character class");
|
|
2370
|
+
if (start !== state.pos)
|
|
2371
|
+
return result;
|
|
2372
|
+
} else
|
|
2373
|
+
state.raise("Invalid character in character class");
|
|
2374
|
+
for (; ; )
|
|
2375
|
+
if (!this.regexp_eatClassSetRange(state)) {
|
|
2376
|
+
if (subResult = this.regexp_eatClassSetOperand(state), !subResult)
|
|
2377
|
+
return result;
|
|
2378
|
+
subResult === CharSetString && (result = CharSetString);
|
|
2379
|
+
}
|
|
2380
|
+
};
|
|
2381
|
+
pp$1.regexp_eatClassSetRange = function(state) {
|
|
2382
|
+
var start = state.pos;
|
|
2383
|
+
if (this.regexp_eatClassSetCharacter(state)) {
|
|
2384
|
+
var left = state.lastIntValue;
|
|
2385
|
+
if (state.eat(
|
|
2386
|
+
45
|
|
2387
|
+
/* - */
|
|
2388
|
+
) && this.regexp_eatClassSetCharacter(state)) {
|
|
2389
|
+
var right = state.lastIntValue;
|
|
2390
|
+
return left !== -1 && right !== -1 && left > right && state.raise("Range out of order in character class"), !0;
|
|
2391
|
+
}
|
|
2392
|
+
state.pos = start;
|
|
2393
|
+
}
|
|
2394
|
+
return !1;
|
|
2395
|
+
};
|
|
2396
|
+
pp$1.regexp_eatClassSetOperand = function(state) {
|
|
2397
|
+
return this.regexp_eatClassSetCharacter(state) ? CharSetOk : this.regexp_eatClassStringDisjunction(state) || this.regexp_eatNestedClass(state);
|
|
2398
|
+
};
|
|
2399
|
+
pp$1.regexp_eatNestedClass = function(state) {
|
|
2400
|
+
var start = state.pos;
|
|
2401
|
+
if (state.eat(
|
|
2402
|
+
91
|
|
2403
|
+
/* [ */
|
|
2404
|
+
)) {
|
|
2405
|
+
var negate = state.eat(
|
|
2406
|
+
94
|
|
2407
|
+
/* ^ */
|
|
2408
|
+
), result = this.regexp_classContents(state);
|
|
2409
|
+
if (state.eat(
|
|
2410
|
+
93
|
|
2411
|
+
/* ] */
|
|
2412
|
+
))
|
|
2413
|
+
return negate && result === CharSetString && state.raise("Negated character class may contain strings"), result;
|
|
2414
|
+
state.pos = start;
|
|
2415
|
+
}
|
|
2416
|
+
if (state.eat(
|
|
2417
|
+
92
|
|
2418
|
+
/* \ */
|
|
2419
|
+
)) {
|
|
2420
|
+
var result$1 = this.regexp_eatCharacterClassEscape(state);
|
|
2421
|
+
if (result$1)
|
|
2422
|
+
return result$1;
|
|
2423
|
+
state.pos = start;
|
|
2424
|
+
}
|
|
2425
|
+
return null;
|
|
2426
|
+
};
|
|
2427
|
+
pp$1.regexp_eatClassStringDisjunction = function(state) {
|
|
2428
|
+
var start = state.pos;
|
|
2429
|
+
if (state.eatChars(
|
|
2430
|
+
[92, 113]
|
|
2431
|
+
/* \q */
|
|
2432
|
+
)) {
|
|
2433
|
+
if (state.eat(
|
|
2434
|
+
123
|
|
2435
|
+
/* { */
|
|
2436
|
+
)) {
|
|
2437
|
+
var result = this.regexp_classStringDisjunctionContents(state);
|
|
2438
|
+
if (state.eat(
|
|
2439
|
+
125
|
|
2440
|
+
/* } */
|
|
2441
|
+
))
|
|
2442
|
+
return result;
|
|
2443
|
+
} else
|
|
2444
|
+
state.raise("Invalid escape");
|
|
2445
|
+
state.pos = start;
|
|
2446
|
+
}
|
|
2447
|
+
return null;
|
|
2448
|
+
};
|
|
2449
|
+
pp$1.regexp_classStringDisjunctionContents = function(state) {
|
|
2450
|
+
for (var result = this.regexp_classString(state); state.eat(
|
|
2451
|
+
124
|
|
2452
|
+
/* | */
|
|
2453
|
+
); )
|
|
2454
|
+
this.regexp_classString(state) === CharSetString && (result = CharSetString);
|
|
2455
|
+
return result;
|
|
2456
|
+
};
|
|
2457
|
+
pp$1.regexp_classString = function(state) {
|
|
2458
|
+
for (var count = 0; this.regexp_eatClassSetCharacter(state); )
|
|
2459
|
+
count++;
|
|
2460
|
+
return count === 1 ? CharSetOk : CharSetString;
|
|
2461
|
+
};
|
|
2462
|
+
pp$1.regexp_eatClassSetCharacter = function(state) {
|
|
2463
|
+
var start = state.pos;
|
|
2464
|
+
if (state.eat(
|
|
2465
|
+
92
|
|
2466
|
+
/* \ */
|
|
2467
|
+
))
|
|
2468
|
+
return this.regexp_eatCharacterEscape(state) || this.regexp_eatClassSetReservedPunctuator(state) ? !0 : state.eat(
|
|
2469
|
+
98
|
|
2470
|
+
/* b */
|
|
2471
|
+
) ? (state.lastIntValue = 8, !0) : (state.pos = start, !1);
|
|
2472
|
+
var ch = state.current();
|
|
2473
|
+
return ch < 0 || ch === state.lookahead() && isClassSetReservedDoublePunctuatorCharacter(ch) || isClassSetSyntaxCharacter(ch) ? !1 : (state.advance(), state.lastIntValue = ch, !0);
|
|
2474
|
+
};
|
|
2475
|
+
function isClassSetReservedDoublePunctuatorCharacter(ch) {
|
|
2476
|
+
return ch === 33 || ch >= 35 && ch <= 38 || ch >= 42 && ch <= 44 || ch === 46 || ch >= 58 && ch <= 64 || ch === 94 || ch === 96 || ch === 126;
|
|
2477
|
+
}
|
|
2478
|
+
function isClassSetSyntaxCharacter(ch) {
|
|
2479
|
+
return ch === 40 || ch === 41 || ch === 45 || ch === 47 || ch >= 91 && ch <= 93 || ch >= 123 && ch <= 125;
|
|
2480
|
+
}
|
|
2481
|
+
pp$1.regexp_eatClassSetReservedPunctuator = function(state) {
|
|
2482
|
+
var ch = state.current();
|
|
2483
|
+
return isClassSetReservedPunctuator(ch) ? (state.lastIntValue = ch, state.advance(), !0) : !1;
|
|
2484
|
+
};
|
|
2485
|
+
function isClassSetReservedPunctuator(ch) {
|
|
2486
|
+
return ch === 33 || ch === 35 || ch === 37 || ch === 38 || ch === 44 || ch === 45 || ch >= 58 && ch <= 62 || ch === 64 || ch === 96 || ch === 126;
|
|
2487
|
+
}
|
|
2488
|
+
pp$1.regexp_eatClassControlLetter = function(state) {
|
|
2489
|
+
var ch = state.current();
|
|
2490
|
+
return isDecimalDigit(ch) || ch === 95 ? (state.lastIntValue = ch % 32, state.advance(), !0) : !1;
|
|
2491
|
+
};
|
|
2492
|
+
pp$1.regexp_eatHexEscapeSequence = function(state) {
|
|
2493
|
+
var start = state.pos;
|
|
2494
|
+
if (state.eat(
|
|
2495
|
+
120
|
|
2496
|
+
/* x */
|
|
2497
|
+
)) {
|
|
2498
|
+
if (this.regexp_eatFixedHexDigits(state, 2))
|
|
2499
|
+
return !0;
|
|
2500
|
+
state.switchU && state.raise("Invalid escape"), state.pos = start;
|
|
2501
|
+
}
|
|
2502
|
+
return !1;
|
|
2503
|
+
};
|
|
2504
|
+
pp$1.regexp_eatDecimalDigits = function(state) {
|
|
2505
|
+
var start = state.pos, ch = 0;
|
|
2506
|
+
for (state.lastIntValue = 0; isDecimalDigit(ch = state.current()); )
|
|
2507
|
+
state.lastIntValue = 10 * state.lastIntValue + (ch - 48), state.advance();
|
|
2508
|
+
return state.pos !== start;
|
|
2509
|
+
};
|
|
2510
|
+
function isDecimalDigit(ch) {
|
|
2511
|
+
return ch >= 48 && ch <= 57;
|
|
2512
|
+
}
|
|
2513
|
+
pp$1.regexp_eatHexDigits = function(state) {
|
|
2514
|
+
var start = state.pos, ch = 0;
|
|
2515
|
+
for (state.lastIntValue = 0; isHexDigit(ch = state.current()); )
|
|
2516
|
+
state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch), state.advance();
|
|
2517
|
+
return state.pos !== start;
|
|
2518
|
+
};
|
|
2519
|
+
function isHexDigit(ch) {
|
|
2520
|
+
return ch >= 48 && ch <= 57 || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102;
|
|
2521
|
+
}
|
|
2522
|
+
function hexToInt(ch) {
|
|
2523
|
+
return ch >= 65 && ch <= 70 ? 10 + (ch - 65) : ch >= 97 && ch <= 102 ? 10 + (ch - 97) : ch - 48;
|
|
2524
|
+
}
|
|
2525
|
+
pp$1.regexp_eatLegacyOctalEscapeSequence = function(state) {
|
|
2526
|
+
if (this.regexp_eatOctalDigit(state)) {
|
|
2527
|
+
var n1 = state.lastIntValue;
|
|
2528
|
+
if (this.regexp_eatOctalDigit(state)) {
|
|
2529
|
+
var n2 = state.lastIntValue;
|
|
2530
|
+
n1 <= 3 && this.regexp_eatOctalDigit(state) ? state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue : state.lastIntValue = n1 * 8 + n2;
|
|
2531
|
+
} else
|
|
2532
|
+
state.lastIntValue = n1;
|
|
2533
|
+
return !0;
|
|
2534
|
+
}
|
|
2535
|
+
return !1;
|
|
2536
|
+
};
|
|
2537
|
+
pp$1.regexp_eatOctalDigit = function(state) {
|
|
2538
|
+
var ch = state.current();
|
|
2539
|
+
return isOctalDigit(ch) ? (state.lastIntValue = ch - 48, state.advance(), !0) : (state.lastIntValue = 0, !1);
|
|
2540
|
+
};
|
|
2541
|
+
function isOctalDigit(ch) {
|
|
2542
|
+
return ch >= 48 && ch <= 55;
|
|
2543
|
+
}
|
|
2544
|
+
pp$1.regexp_eatFixedHexDigits = function(state, length) {
|
|
2545
|
+
var start = state.pos;
|
|
2546
|
+
state.lastIntValue = 0;
|
|
2547
|
+
for (var i = 0; i < length; ++i) {
|
|
2548
|
+
var ch = state.current();
|
|
2549
|
+
if (!isHexDigit(ch))
|
|
2550
|
+
return state.pos = start, !1;
|
|
2551
|
+
state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch), state.advance();
|
|
2552
|
+
}
|
|
2553
|
+
return !0;
|
|
2554
|
+
};
|
|
2555
|
+
var Token = function(p) {
|
|
2556
|
+
this.type = p.type, this.value = p.value, this.start = p.start, this.end = p.end, p.options.locations && (this.loc = new SourceLocation(p, p.startLoc, p.endLoc)), p.options.ranges && (this.range = [p.start, p.end]);
|
|
2557
|
+
}, pp = Parser.prototype;
|
|
2558
|
+
pp.next = function(ignoreEscapeSequenceInKeyword) {
|
|
2559
|
+
!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc && this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword), this.options.onToken && this.options.onToken(new Token(this)), this.lastTokEnd = this.end, this.lastTokStart = this.start, this.lastTokEndLoc = this.endLoc, this.lastTokStartLoc = this.startLoc, this.nextToken();
|
|
2560
|
+
};
|
|
2561
|
+
pp.getToken = function() {
|
|
2562
|
+
return this.next(), new Token(this);
|
|
2563
|
+
};
|
|
2564
|
+
typeof Symbol < "u" && (pp[Symbol.iterator] = function() {
|
|
2565
|
+
var this$1$1 = this;
|
|
2566
|
+
return {
|
|
2567
|
+
next: function() {
|
|
2568
|
+
var token = this$1$1.getToken();
|
|
2569
|
+
return {
|
|
2570
|
+
done: token.type === types$1.eof,
|
|
2571
|
+
value: token
|
|
2572
|
+
};
|
|
2573
|
+
}
|
|
2574
|
+
};
|
|
2575
|
+
});
|
|
2576
|
+
pp.nextToken = function() {
|
|
2577
|
+
var curContext = this.curContext();
|
|
2578
|
+
if ((!curContext || !curContext.preserveSpace) && this.skipSpace(), this.start = this.pos, this.options.locations && (this.startLoc = this.curPosition()), this.pos >= this.input.length)
|
|
2579
|
+
return this.finishToken(types$1.eof);
|
|
2580
|
+
if (curContext.override)
|
|
2581
|
+
return curContext.override(this);
|
|
2582
|
+
this.readToken(this.fullCharCodeAtPos());
|
|
2583
|
+
};
|
|
2584
|
+
pp.readToken = function(code) {
|
|
2585
|
+
return isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 ? this.readWord() : this.getTokenFromCode(code);
|
|
2586
|
+
};
|
|
2587
|
+
pp.fullCharCodeAtPos = function() {
|
|
2588
|
+
var code = this.input.charCodeAt(this.pos);
|
|
2589
|
+
if (code <= 55295 || code >= 56320)
|
|
2590
|
+
return code;
|
|
2591
|
+
var next = this.input.charCodeAt(this.pos + 1);
|
|
2592
|
+
return next <= 56319 || next >= 57344 ? code : (code << 10) + next - 56613888;
|
|
2593
|
+
};
|
|
2594
|
+
pp.skipBlockComment = function() {
|
|
2595
|
+
var startLoc = this.options.onComment && this.curPosition(), start = this.pos, end = this.input.indexOf("*/", this.pos += 2);
|
|
2596
|
+
if (end === -1 && this.raise(this.pos - 2, "Unterminated comment"), this.pos = end + 2, this.options.locations)
|
|
2597
|
+
for (var nextBreak = void 0, pos = start; (nextBreak = nextLineBreak(this.input, pos, this.pos)) > -1; )
|
|
2598
|
+
++this.curLine, pos = this.lineStart = nextBreak;
|
|
2599
|
+
this.options.onComment && this.options.onComment(
|
|
2600
|
+
!0,
|
|
2601
|
+
this.input.slice(start + 2, end),
|
|
2602
|
+
start,
|
|
2603
|
+
this.pos,
|
|
2604
|
+
startLoc,
|
|
2605
|
+
this.curPosition()
|
|
2606
|
+
);
|
|
2607
|
+
};
|
|
2608
|
+
pp.skipLineComment = function(startSkip) {
|
|
2609
|
+
for (var start = this.pos, startLoc = this.options.onComment && this.curPosition(), ch = this.input.charCodeAt(this.pos += startSkip); this.pos < this.input.length && !isNewLine(ch); )
|
|
2610
|
+
ch = this.input.charCodeAt(++this.pos);
|
|
2611
|
+
this.options.onComment && this.options.onComment(
|
|
2612
|
+
!1,
|
|
2613
|
+
this.input.slice(start + startSkip, this.pos),
|
|
2614
|
+
start,
|
|
2615
|
+
this.pos,
|
|
2616
|
+
startLoc,
|
|
2617
|
+
this.curPosition()
|
|
2618
|
+
);
|
|
2619
|
+
};
|
|
2620
|
+
pp.skipSpace = function() {
|
|
2621
|
+
loop: for (; this.pos < this.input.length; ) {
|
|
2622
|
+
var ch = this.input.charCodeAt(this.pos);
|
|
2623
|
+
switch (ch) {
|
|
2624
|
+
case 32:
|
|
2625
|
+
case 160:
|
|
2626
|
+
++this.pos;
|
|
2627
|
+
break;
|
|
2628
|
+
case 13:
|
|
2629
|
+
this.input.charCodeAt(this.pos + 1) === 10 && ++this.pos;
|
|
2630
|
+
case 10:
|
|
2631
|
+
case 8232:
|
|
2632
|
+
case 8233:
|
|
2633
|
+
++this.pos, this.options.locations && (++this.curLine, this.lineStart = this.pos);
|
|
2634
|
+
break;
|
|
2635
|
+
case 47:
|
|
2636
|
+
switch (this.input.charCodeAt(this.pos + 1)) {
|
|
2637
|
+
case 42:
|
|
2638
|
+
this.skipBlockComment();
|
|
2639
|
+
break;
|
|
2640
|
+
case 47:
|
|
2641
|
+
this.skipLineComment(2);
|
|
2642
|
+
break;
|
|
2643
|
+
default:
|
|
2644
|
+
break loop;
|
|
2645
|
+
}
|
|
2646
|
+
break;
|
|
2647
|
+
default:
|
|
2648
|
+
if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch)))
|
|
2649
|
+
++this.pos;
|
|
2650
|
+
else
|
|
2651
|
+
break loop;
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
};
|
|
2655
|
+
pp.finishToken = function(type, val) {
|
|
2656
|
+
this.end = this.pos, this.options.locations && (this.endLoc = this.curPosition());
|
|
2657
|
+
var prevType = this.type;
|
|
2658
|
+
this.type = type, this.value = val, this.updateContext(prevType);
|
|
2659
|
+
};
|
|
2660
|
+
pp.readToken_dot = function() {
|
|
2661
|
+
var next = this.input.charCodeAt(this.pos + 1);
|
|
2662
|
+
if (next >= 48 && next <= 57)
|
|
2663
|
+
return this.readNumber(!0);
|
|
2664
|
+
var next2 = this.input.charCodeAt(this.pos + 2);
|
|
2665
|
+
return this.options.ecmaVersion >= 6 && next === 46 && next2 === 46 ? (this.pos += 3, this.finishToken(types$1.ellipsis)) : (++this.pos, this.finishToken(types$1.dot));
|
|
2666
|
+
};
|
|
2667
|
+
pp.readToken_slash = function() {
|
|
2668
|
+
var next = this.input.charCodeAt(this.pos + 1);
|
|
2669
|
+
return this.exprAllowed ? (++this.pos, this.readRegexp()) : next === 61 ? this.finishOp(types$1.assign, 2) : this.finishOp(types$1.slash, 1);
|
|
2670
|
+
};
|
|
2671
|
+
pp.readToken_mult_modulo_exp = function(code) {
|
|
2672
|
+
var next = this.input.charCodeAt(this.pos + 1), size = 1, tokentype = code === 42 ? types$1.star : types$1.modulo;
|
|
2673
|
+
return this.options.ecmaVersion >= 7 && code === 42 && next === 42 && (++size, tokentype = types$1.starstar, next = this.input.charCodeAt(this.pos + 2)), next === 61 ? this.finishOp(types$1.assign, size + 1) : this.finishOp(tokentype, size);
|
|
2674
|
+
};
|
|
2675
|
+
pp.readToken_pipe_amp = function(code) {
|
|
2676
|
+
var next = this.input.charCodeAt(this.pos + 1);
|
|
2677
|
+
if (next === code) {
|
|
2678
|
+
if (this.options.ecmaVersion >= 12) {
|
|
2679
|
+
var next2 = this.input.charCodeAt(this.pos + 2);
|
|
2680
|
+
if (next2 === 61)
|
|
2681
|
+
return this.finishOp(types$1.assign, 3);
|
|
2682
|
+
}
|
|
2683
|
+
return this.finishOp(code === 124 ? types$1.logicalOR : types$1.logicalAND, 2);
|
|
2684
|
+
}
|
|
2685
|
+
return next === 61 ? this.finishOp(types$1.assign, 2) : this.finishOp(code === 124 ? types$1.bitwiseOR : types$1.bitwiseAND, 1);
|
|
2686
|
+
};
|
|
2687
|
+
pp.readToken_caret = function() {
|
|
2688
|
+
var next = this.input.charCodeAt(this.pos + 1);
|
|
2689
|
+
return next === 61 ? this.finishOp(types$1.assign, 2) : this.finishOp(types$1.bitwiseXOR, 1);
|
|
2690
|
+
};
|
|
2691
|
+
pp.readToken_plus_min = function(code) {
|
|
2692
|
+
var next = this.input.charCodeAt(this.pos + 1);
|
|
2693
|
+
return next === code ? next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 && (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos))) ? (this.skipLineComment(3), this.skipSpace(), this.nextToken()) : this.finishOp(types$1.incDec, 2) : next === 61 ? this.finishOp(types$1.assign, 2) : this.finishOp(types$1.plusMin, 1);
|
|
2694
|
+
};
|
|
2695
|
+
pp.readToken_lt_gt = function(code) {
|
|
2696
|
+
var next = this.input.charCodeAt(this.pos + 1), size = 1;
|
|
2697
|
+
return next === code ? (size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2, this.input.charCodeAt(this.pos + size) === 61 ? this.finishOp(types$1.assign, size + 1) : this.finishOp(types$1.bitShift, size)) : next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 && this.input.charCodeAt(this.pos + 3) === 45 ? (this.skipLineComment(4), this.skipSpace(), this.nextToken()) : (next === 61 && (size = 2), this.finishOp(types$1.relational, size));
|
|
2698
|
+
};
|
|
2699
|
+
pp.readToken_eq_excl = function(code) {
|
|
2700
|
+
var next = this.input.charCodeAt(this.pos + 1);
|
|
2701
|
+
return next === 61 ? this.finishOp(types$1.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2) : code === 61 && next === 62 && this.options.ecmaVersion >= 6 ? (this.pos += 2, this.finishToken(types$1.arrow)) : this.finishOp(code === 61 ? types$1.eq : types$1.prefix, 1);
|
|
2702
|
+
};
|
|
2703
|
+
pp.readToken_question = function() {
|
|
2704
|
+
var ecmaVersion = this.options.ecmaVersion;
|
|
2705
|
+
if (ecmaVersion >= 11) {
|
|
2706
|
+
var next = this.input.charCodeAt(this.pos + 1);
|
|
2707
|
+
if (next === 46) {
|
|
2708
|
+
var next2 = this.input.charCodeAt(this.pos + 2);
|
|
2709
|
+
if (next2 < 48 || next2 > 57)
|
|
2710
|
+
return this.finishOp(types$1.questionDot, 2);
|
|
2711
|
+
}
|
|
2712
|
+
if (next === 63) {
|
|
2713
|
+
if (ecmaVersion >= 12) {
|
|
2714
|
+
var next2$1 = this.input.charCodeAt(this.pos + 2);
|
|
2715
|
+
if (next2$1 === 61)
|
|
2716
|
+
return this.finishOp(types$1.assign, 3);
|
|
2717
|
+
}
|
|
2718
|
+
return this.finishOp(types$1.coalesce, 2);
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
return this.finishOp(types$1.question, 1);
|
|
2722
|
+
};
|
|
2723
|
+
pp.readToken_numberSign = function() {
|
|
2724
|
+
var ecmaVersion = this.options.ecmaVersion, code = 35;
|
|
2725
|
+
if (ecmaVersion >= 13 && (++this.pos, code = this.fullCharCodeAtPos(), isIdentifierStart(code, !0) || code === 92))
|
|
2726
|
+
return this.finishToken(types$1.privateId, this.readWord1());
|
|
2727
|
+
this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
|
|
2728
|
+
};
|
|
2729
|
+
pp.getTokenFromCode = function(code) {
|
|
2730
|
+
switch (code) {
|
|
2731
|
+
// The interpretation of a dot depends on whether it is followed
|
|
2732
|
+
// by a digit or another two dots.
|
|
2733
|
+
case 46:
|
|
2734
|
+
return this.readToken_dot();
|
|
2735
|
+
// Punctuation tokens.
|
|
2736
|
+
case 40:
|
|
2737
|
+
return ++this.pos, this.finishToken(types$1.parenL);
|
|
2738
|
+
case 41:
|
|
2739
|
+
return ++this.pos, this.finishToken(types$1.parenR);
|
|
2740
|
+
case 59:
|
|
2741
|
+
return ++this.pos, this.finishToken(types$1.semi);
|
|
2742
|
+
case 44:
|
|
2743
|
+
return ++this.pos, this.finishToken(types$1.comma);
|
|
2744
|
+
case 91:
|
|
2745
|
+
return ++this.pos, this.finishToken(types$1.bracketL);
|
|
2746
|
+
case 93:
|
|
2747
|
+
return ++this.pos, this.finishToken(types$1.bracketR);
|
|
2748
|
+
case 123:
|
|
2749
|
+
return ++this.pos, this.finishToken(types$1.braceL);
|
|
2750
|
+
case 125:
|
|
2751
|
+
return ++this.pos, this.finishToken(types$1.braceR);
|
|
2752
|
+
case 58:
|
|
2753
|
+
return ++this.pos, this.finishToken(types$1.colon);
|
|
2754
|
+
case 96:
|
|
2755
|
+
if (this.options.ecmaVersion < 6)
|
|
2756
|
+
break;
|
|
2757
|
+
return ++this.pos, this.finishToken(types$1.backQuote);
|
|
2758
|
+
case 48:
|
|
2759
|
+
var next = this.input.charCodeAt(this.pos + 1);
|
|
2760
|
+
if (next === 120 || next === 88)
|
|
2761
|
+
return this.readRadixNumber(16);
|
|
2762
|
+
if (this.options.ecmaVersion >= 6) {
|
|
2763
|
+
if (next === 111 || next === 79)
|
|
2764
|
+
return this.readRadixNumber(8);
|
|
2765
|
+
if (next === 98 || next === 66)
|
|
2766
|
+
return this.readRadixNumber(2);
|
|
2767
|
+
}
|
|
2768
|
+
// Anything else beginning with a digit is an integer, octal
|
|
2769
|
+
// number, or float.
|
|
2770
|
+
case 49:
|
|
2771
|
+
case 50:
|
|
2772
|
+
case 51:
|
|
2773
|
+
case 52:
|
|
2774
|
+
case 53:
|
|
2775
|
+
case 54:
|
|
2776
|
+
case 55:
|
|
2777
|
+
case 56:
|
|
2778
|
+
case 57:
|
|
2779
|
+
return this.readNumber(!1);
|
|
2780
|
+
// Quotes produce strings.
|
|
2781
|
+
case 34:
|
|
2782
|
+
case 39:
|
|
2783
|
+
return this.readString(code);
|
|
2784
|
+
// Operators are parsed inline in tiny state machines. '=' (61) is
|
|
2785
|
+
// often referred to. `finishOp` simply skips the amount of
|
|
2786
|
+
// characters it is given as second argument, and returns a token
|
|
2787
|
+
// of the type given by its first argument.
|
|
2788
|
+
case 47:
|
|
2789
|
+
return this.readToken_slash();
|
|
2790
|
+
case 37:
|
|
2791
|
+
case 42:
|
|
2792
|
+
return this.readToken_mult_modulo_exp(code);
|
|
2793
|
+
case 124:
|
|
2794
|
+
case 38:
|
|
2795
|
+
return this.readToken_pipe_amp(code);
|
|
2796
|
+
case 94:
|
|
2797
|
+
return this.readToken_caret();
|
|
2798
|
+
case 43:
|
|
2799
|
+
case 45:
|
|
2800
|
+
return this.readToken_plus_min(code);
|
|
2801
|
+
case 60:
|
|
2802
|
+
case 62:
|
|
2803
|
+
return this.readToken_lt_gt(code);
|
|
2804
|
+
case 61:
|
|
2805
|
+
case 33:
|
|
2806
|
+
return this.readToken_eq_excl(code);
|
|
2807
|
+
case 63:
|
|
2808
|
+
return this.readToken_question();
|
|
2809
|
+
case 126:
|
|
2810
|
+
return this.finishOp(types$1.prefix, 1);
|
|
2811
|
+
case 35:
|
|
2812
|
+
return this.readToken_numberSign();
|
|
2813
|
+
}
|
|
2814
|
+
this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
|
|
2815
|
+
};
|
|
2816
|
+
pp.finishOp = function(type, size) {
|
|
2817
|
+
var str = this.input.slice(this.pos, this.pos + size);
|
|
2818
|
+
return this.pos += size, this.finishToken(type, str);
|
|
2819
|
+
};
|
|
2820
|
+
pp.readRegexp = function() {
|
|
2821
|
+
for (var escaped, inClass, start = this.pos; ; ) {
|
|
2822
|
+
this.pos >= this.input.length && this.raise(start, "Unterminated regular expression");
|
|
2823
|
+
var ch = this.input.charAt(this.pos);
|
|
2824
|
+
if (lineBreak.test(ch) && this.raise(start, "Unterminated regular expression"), escaped)
|
|
2825
|
+
escaped = !1;
|
|
2826
|
+
else {
|
|
2827
|
+
if (ch === "[")
|
|
2828
|
+
inClass = !0;
|
|
2829
|
+
else if (ch === "]" && inClass)
|
|
2830
|
+
inClass = !1;
|
|
2831
|
+
else if (ch === "/" && !inClass)
|
|
2832
|
+
break;
|
|
2833
|
+
escaped = ch === "\\";
|
|
2834
|
+
}
|
|
2835
|
+
++this.pos;
|
|
2836
|
+
}
|
|
2837
|
+
var pattern = this.input.slice(start, this.pos);
|
|
2838
|
+
++this.pos;
|
|
2839
|
+
var flagsStart = this.pos, flags = this.readWord1();
|
|
2840
|
+
this.containsEsc && this.unexpected(flagsStart);
|
|
2841
|
+
var state = this.regexpState || (this.regexpState = new RegExpValidationState(this));
|
|
2842
|
+
state.reset(start, pattern, flags), this.validateRegExpFlags(state), this.validateRegExpPattern(state);
|
|
2843
|
+
var value = null;
|
|
2844
|
+
try {
|
|
2845
|
+
value = new RegExp(pattern, flags);
|
|
2846
|
+
} catch {
|
|
2847
|
+
}
|
|
2848
|
+
return this.finishToken(types$1.regexp, { pattern, flags, value });
|
|
2849
|
+
};
|
|
2850
|
+
pp.readInt = function(radix, len, maybeLegacyOctalNumericLiteral) {
|
|
2851
|
+
for (var allowSeparators = this.options.ecmaVersion >= 12 && len === void 0, isLegacyOctalNumericLiteral = maybeLegacyOctalNumericLiteral && this.input.charCodeAt(this.pos) === 48, start = this.pos, total = 0, lastCode = 0, i = 0, e = len ?? 1 / 0; i < e; ++i, ++this.pos) {
|
|
2852
|
+
var code = this.input.charCodeAt(this.pos), val = void 0;
|
|
2853
|
+
if (allowSeparators && code === 95) {
|
|
2854
|
+
isLegacyOctalNumericLiteral && this.raiseRecoverable(this.pos, "Numeric separator is not allowed in legacy octal numeric literals"), lastCode === 95 && this.raiseRecoverable(this.pos, "Numeric separator must be exactly one underscore"), i === 0 && this.raiseRecoverable(this.pos, "Numeric separator is not allowed at the first of digits"), lastCode = code;
|
|
2855
|
+
continue;
|
|
2856
|
+
}
|
|
2857
|
+
if (code >= 97 ? val = code - 97 + 10 : code >= 65 ? val = code - 65 + 10 : code >= 48 && code <= 57 ? val = code - 48 : val = 1 / 0, val >= radix)
|
|
2858
|
+
break;
|
|
2859
|
+
lastCode = code, total = total * radix + val;
|
|
2860
|
+
}
|
|
2861
|
+
return allowSeparators && lastCode === 95 && this.raiseRecoverable(this.pos - 1, "Numeric separator is not allowed at the last of digits"), this.pos === start || len != null && this.pos - start !== len ? null : total;
|
|
2862
|
+
};
|
|
2863
|
+
function stringToNumber(str, isLegacyOctalNumericLiteral) {
|
|
2864
|
+
return isLegacyOctalNumericLiteral ? parseInt(str, 8) : parseFloat(str.replace(/_/g, ""));
|
|
2865
|
+
}
|
|
2866
|
+
function stringToBigInt(str) {
|
|
2867
|
+
return typeof BigInt != "function" ? null : BigInt(str.replace(/_/g, ""));
|
|
2868
|
+
}
|
|
2869
|
+
pp.readRadixNumber = function(radix) {
|
|
2870
|
+
var start = this.pos;
|
|
2871
|
+
this.pos += 2;
|
|
2872
|
+
var val = this.readInt(radix);
|
|
2873
|
+
return val == null && this.raise(this.start + 2, "Expected number in radix " + radix), this.options.ecmaVersion >= 11 && this.input.charCodeAt(this.pos) === 110 ? (val = stringToBigInt(this.input.slice(start, this.pos)), ++this.pos) : isIdentifierStart(this.fullCharCodeAtPos()) && this.raise(this.pos, "Identifier directly after number"), this.finishToken(types$1.num, val);
|
|
2874
|
+
};
|
|
2875
|
+
pp.readNumber = function(startsWithDot) {
|
|
2876
|
+
var start = this.pos;
|
|
2877
|
+
!startsWithDot && this.readInt(10, void 0, !0) === null && this.raise(start, "Invalid number");
|
|
2878
|
+
var octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48;
|
|
2879
|
+
octal && this.strict && this.raise(start, "Invalid number");
|
|
2880
|
+
var next = this.input.charCodeAt(this.pos);
|
|
2881
|
+
if (!octal && !startsWithDot && this.options.ecmaVersion >= 11 && next === 110) {
|
|
2882
|
+
var val$1 = stringToBigInt(this.input.slice(start, this.pos));
|
|
2883
|
+
return ++this.pos, isIdentifierStart(this.fullCharCodeAtPos()) && this.raise(this.pos, "Identifier directly after number"), this.finishToken(types$1.num, val$1);
|
|
2884
|
+
}
|
|
2885
|
+
octal && /[89]/.test(this.input.slice(start, this.pos)) && (octal = !1), next === 46 && !octal && (++this.pos, this.readInt(10), next = this.input.charCodeAt(this.pos)), (next === 69 || next === 101) && !octal && (next = this.input.charCodeAt(++this.pos), (next === 43 || next === 45) && ++this.pos, this.readInt(10) === null && this.raise(start, "Invalid number")), isIdentifierStart(this.fullCharCodeAtPos()) && this.raise(this.pos, "Identifier directly after number");
|
|
2886
|
+
var val = stringToNumber(this.input.slice(start, this.pos), octal);
|
|
2887
|
+
return this.finishToken(types$1.num, val);
|
|
2888
|
+
};
|
|
2889
|
+
pp.readCodePoint = function() {
|
|
2890
|
+
var ch = this.input.charCodeAt(this.pos), code;
|
|
2891
|
+
if (ch === 123) {
|
|
2892
|
+
this.options.ecmaVersion < 6 && this.unexpected();
|
|
2893
|
+
var codePos = ++this.pos;
|
|
2894
|
+
code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos), ++this.pos, code > 1114111 && this.invalidStringToken(codePos, "Code point out of bounds");
|
|
2895
|
+
} else
|
|
2896
|
+
code = this.readHexChar(4);
|
|
2897
|
+
return code;
|
|
2898
|
+
};
|
|
2899
|
+
pp.readString = function(quote) {
|
|
2900
|
+
for (var out = "", chunkStart = ++this.pos; ; ) {
|
|
2901
|
+
this.pos >= this.input.length && this.raise(this.start, "Unterminated string constant");
|
|
2902
|
+
var ch = this.input.charCodeAt(this.pos);
|
|
2903
|
+
if (ch === quote)
|
|
2904
|
+
break;
|
|
2905
|
+
ch === 92 ? (out += this.input.slice(chunkStart, this.pos), out += this.readEscapedChar(!1), chunkStart = this.pos) : ch === 8232 || ch === 8233 ? (this.options.ecmaVersion < 10 && this.raise(this.start, "Unterminated string constant"), ++this.pos, this.options.locations && (this.curLine++, this.lineStart = this.pos)) : (isNewLine(ch) && this.raise(this.start, "Unterminated string constant"), ++this.pos);
|
|
2906
|
+
}
|
|
2907
|
+
return out += this.input.slice(chunkStart, this.pos++), this.finishToken(types$1.string, out);
|
|
2908
|
+
};
|
|
2909
|
+
var INVALID_TEMPLATE_ESCAPE_ERROR = {};
|
|
2910
|
+
pp.tryReadTemplateToken = function() {
|
|
2911
|
+
this.inTemplateElement = !0;
|
|
2912
|
+
try {
|
|
2913
|
+
this.readTmplToken();
|
|
2914
|
+
} catch (err) {
|
|
2915
|
+
if (err === INVALID_TEMPLATE_ESCAPE_ERROR)
|
|
2916
|
+
this.readInvalidTemplateToken();
|
|
2917
|
+
else
|
|
2918
|
+
throw err;
|
|
2919
|
+
}
|
|
2920
|
+
this.inTemplateElement = !1;
|
|
2921
|
+
};
|
|
2922
|
+
pp.invalidStringToken = function(position, message) {
|
|
2923
|
+
if (this.inTemplateElement && this.options.ecmaVersion >= 9)
|
|
2924
|
+
throw INVALID_TEMPLATE_ESCAPE_ERROR;
|
|
2925
|
+
this.raise(position, message);
|
|
2926
|
+
};
|
|
2927
|
+
pp.readTmplToken = function() {
|
|
2928
|
+
for (var out = "", chunkStart = this.pos; ; ) {
|
|
2929
|
+
this.pos >= this.input.length && this.raise(this.start, "Unterminated template");
|
|
2930
|
+
var ch = this.input.charCodeAt(this.pos);
|
|
2931
|
+
if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123)
|
|
2932
|
+
return this.pos === this.start && (this.type === types$1.template || this.type === types$1.invalidTemplate) ? ch === 36 ? (this.pos += 2, this.finishToken(types$1.dollarBraceL)) : (++this.pos, this.finishToken(types$1.backQuote)) : (out += this.input.slice(chunkStart, this.pos), this.finishToken(types$1.template, out));
|
|
2933
|
+
if (ch === 92)
|
|
2934
|
+
out += this.input.slice(chunkStart, this.pos), out += this.readEscapedChar(!0), chunkStart = this.pos;
|
|
2935
|
+
else if (isNewLine(ch)) {
|
|
2936
|
+
switch (out += this.input.slice(chunkStart, this.pos), ++this.pos, ch) {
|
|
2937
|
+
case 13:
|
|
2938
|
+
this.input.charCodeAt(this.pos) === 10 && ++this.pos;
|
|
2939
|
+
case 10:
|
|
2940
|
+
out += `
|
|
2941
|
+
`;
|
|
2942
|
+
break;
|
|
2943
|
+
default:
|
|
2944
|
+
out += String.fromCharCode(ch);
|
|
2945
|
+
break;
|
|
2946
|
+
}
|
|
2947
|
+
this.options.locations && (++this.curLine, this.lineStart = this.pos), chunkStart = this.pos;
|
|
2948
|
+
} else
|
|
2949
|
+
++this.pos;
|
|
2950
|
+
}
|
|
2951
|
+
};
|
|
2952
|
+
pp.readInvalidTemplateToken = function() {
|
|
2953
|
+
for (; this.pos < this.input.length; this.pos++)
|
|
2954
|
+
switch (this.input[this.pos]) {
|
|
2955
|
+
case "\\":
|
|
2956
|
+
++this.pos;
|
|
2957
|
+
break;
|
|
2958
|
+
case "$":
|
|
2959
|
+
if (this.input[this.pos + 1] !== "{")
|
|
2960
|
+
break;
|
|
2961
|
+
// fall through
|
|
2962
|
+
case "`":
|
|
2963
|
+
return this.finishToken(types$1.invalidTemplate, this.input.slice(this.start, this.pos));
|
|
2964
|
+
case "\r":
|
|
2965
|
+
this.input[this.pos + 1] === `
|
|
2966
|
+
` && ++this.pos;
|
|
2967
|
+
// fall through
|
|
2968
|
+
case `
|
|
2969
|
+
`:
|
|
2970
|
+
case "\u2028":
|
|
2971
|
+
case "\u2029":
|
|
2972
|
+
++this.curLine, this.lineStart = this.pos + 1;
|
|
2973
|
+
break;
|
|
2974
|
+
}
|
|
2975
|
+
this.raise(this.start, "Unterminated template");
|
|
2976
|
+
};
|
|
2977
|
+
pp.readEscapedChar = function(inTemplate) {
|
|
2978
|
+
var ch = this.input.charCodeAt(++this.pos);
|
|
2979
|
+
switch (++this.pos, ch) {
|
|
2980
|
+
case 110:
|
|
2981
|
+
return `
|
|
2982
|
+
`;
|
|
2983
|
+
// 'n' -> '\n'
|
|
2984
|
+
case 114:
|
|
2985
|
+
return "\r";
|
|
2986
|
+
// 'r' -> '\r'
|
|
2987
|
+
case 120:
|
|
2988
|
+
return String.fromCharCode(this.readHexChar(2));
|
|
2989
|
+
// 'x'
|
|
2990
|
+
case 117:
|
|
2991
|
+
return codePointToString(this.readCodePoint());
|
|
2992
|
+
// 'u'
|
|
2993
|
+
case 116:
|
|
2994
|
+
return " ";
|
|
2995
|
+
// 't' -> '\t'
|
|
2996
|
+
case 98:
|
|
2997
|
+
return "\b";
|
|
2998
|
+
// 'b' -> '\b'
|
|
2999
|
+
case 118:
|
|
3000
|
+
return "\v";
|
|
3001
|
+
// 'v' -> '\u000b'
|
|
3002
|
+
case 102:
|
|
3003
|
+
return "\f";
|
|
3004
|
+
// 'f' -> '\f'
|
|
3005
|
+
case 13:
|
|
3006
|
+
this.input.charCodeAt(this.pos) === 10 && ++this.pos;
|
|
3007
|
+
// '\r\n'
|
|
3008
|
+
case 10:
|
|
3009
|
+
return this.options.locations && (this.lineStart = this.pos, ++this.curLine), "";
|
|
3010
|
+
case 56:
|
|
3011
|
+
case 57:
|
|
3012
|
+
if (this.strict && this.invalidStringToken(
|
|
3013
|
+
this.pos - 1,
|
|
3014
|
+
"Invalid escape sequence"
|
|
3015
|
+
), inTemplate) {
|
|
3016
|
+
var codePos = this.pos - 1;
|
|
3017
|
+
this.invalidStringToken(
|
|
3018
|
+
codePos,
|
|
3019
|
+
"Invalid escape sequence in template string"
|
|
3020
|
+
);
|
|
3021
|
+
}
|
|
3022
|
+
default:
|
|
3023
|
+
if (ch >= 48 && ch <= 55) {
|
|
3024
|
+
var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0], octal = parseInt(octalStr, 8);
|
|
3025
|
+
return octal > 255 && (octalStr = octalStr.slice(0, -1), octal = parseInt(octalStr, 8)), this.pos += octalStr.length - 1, ch = this.input.charCodeAt(this.pos), (octalStr !== "0" || ch === 56 || ch === 57) && (this.strict || inTemplate) && this.invalidStringToken(
|
|
3026
|
+
this.pos - 1 - octalStr.length,
|
|
3027
|
+
inTemplate ? "Octal literal in template string" : "Octal literal in strict mode"
|
|
3028
|
+
), String.fromCharCode(octal);
|
|
3029
|
+
}
|
|
3030
|
+
return isNewLine(ch) ? (this.options.locations && (this.lineStart = this.pos, ++this.curLine), "") : String.fromCharCode(ch);
|
|
3031
|
+
}
|
|
3032
|
+
};
|
|
3033
|
+
pp.readHexChar = function(len) {
|
|
3034
|
+
var codePos = this.pos, n = this.readInt(16, len);
|
|
3035
|
+
return n === null && this.invalidStringToken(codePos, "Bad character escape sequence"), n;
|
|
3036
|
+
};
|
|
3037
|
+
pp.readWord1 = function() {
|
|
3038
|
+
this.containsEsc = !1;
|
|
3039
|
+
for (var word = "", first = !0, chunkStart = this.pos, astral = this.options.ecmaVersion >= 6; this.pos < this.input.length; ) {
|
|
3040
|
+
var ch = this.fullCharCodeAtPos();
|
|
3041
|
+
if (isIdentifierChar(ch, astral))
|
|
3042
|
+
this.pos += ch <= 65535 ? 1 : 2;
|
|
3043
|
+
else if (ch === 92) {
|
|
3044
|
+
this.containsEsc = !0, word += this.input.slice(chunkStart, this.pos);
|
|
3045
|
+
var escStart = this.pos;
|
|
3046
|
+
this.input.charCodeAt(++this.pos) !== 117 && this.invalidStringToken(this.pos, "Expecting Unicode escape sequence \\uXXXX"), ++this.pos;
|
|
3047
|
+
var esc = this.readCodePoint();
|
|
3048
|
+
(first ? isIdentifierStart : isIdentifierChar)(esc, astral) || this.invalidStringToken(escStart, "Invalid Unicode escape"), word += codePointToString(esc), chunkStart = this.pos;
|
|
3049
|
+
} else
|
|
3050
|
+
break;
|
|
3051
|
+
first = !1;
|
|
3052
|
+
}
|
|
3053
|
+
return word + this.input.slice(chunkStart, this.pos);
|
|
3054
|
+
};
|
|
3055
|
+
pp.readWord = function() {
|
|
3056
|
+
var word = this.readWord1(), type = types$1.name;
|
|
3057
|
+
return this.keywords.test(word) && (type = keywords[word]), this.finishToken(type, word);
|
|
3058
|
+
};
|
|
3059
|
+
var version = "8.14.0";
|
|
3060
|
+
Parser.acorn = {
|
|
3061
|
+
Parser,
|
|
3062
|
+
version,
|
|
3063
|
+
defaultOptions,
|
|
3064
|
+
Position,
|
|
3065
|
+
SourceLocation,
|
|
3066
|
+
getLineInfo,
|
|
3067
|
+
Node,
|
|
3068
|
+
TokenType,
|
|
3069
|
+
tokTypes: types$1,
|
|
3070
|
+
keywordTypes: keywords,
|
|
3071
|
+
TokContext,
|
|
3072
|
+
tokContexts: types,
|
|
3073
|
+
isIdentifierChar,
|
|
3074
|
+
isIdentifierStart,
|
|
3075
|
+
Token,
|
|
3076
|
+
isNewLine,
|
|
3077
|
+
lineBreak,
|
|
3078
|
+
lineBreakG,
|
|
3079
|
+
nonASCIIwhitespace
|
|
3080
|
+
};
|
|
3081
|
+
function simple(node, visitors, baseVisitor, state, override) {
|
|
3082
|
+
baseVisitor || (baseVisitor = base), function c(node2, st, override2) {
|
|
3083
|
+
var type = override2 || node2.type;
|
|
3084
|
+
baseVisitor[type](node2, st, c), visitors[type] && visitors[type](node2, st);
|
|
3085
|
+
}(node, state, override);
|
|
3086
|
+
}
|
|
3087
|
+
function ancestor(node, visitors, baseVisitor, state, override) {
|
|
3088
|
+
var ancestors = [];
|
|
3089
|
+
baseVisitor || (baseVisitor = base), function c(node2, st, override2) {
|
|
3090
|
+
var type = override2 || node2.type, isNew = node2 !== ancestors[ancestors.length - 1];
|
|
3091
|
+
isNew && ancestors.push(node2), baseVisitor[type](node2, st, c), visitors[type] && visitors[type](node2, st || ancestors, ancestors), isNew && ancestors.pop();
|
|
3092
|
+
}(node, state, override);
|
|
3093
|
+
}
|
|
3094
|
+
function make(funcs, baseVisitor) {
|
|
3095
|
+
var visitor = Object.create(base);
|
|
3096
|
+
for (var type in funcs)
|
|
3097
|
+
visitor[type] = funcs[type];
|
|
3098
|
+
return visitor;
|
|
3099
|
+
}
|
|
3100
|
+
function skipThrough(node, st, c) {
|
|
3101
|
+
c(node, st);
|
|
3102
|
+
}
|
|
3103
|
+
function ignore(_node, _st, _c) {
|
|
3104
|
+
}
|
|
3105
|
+
var base = {};
|
|
3106
|
+
base.Program = base.BlockStatement = base.StaticBlock = function(node, st, c) {
|
|
3107
|
+
for (var i = 0, list = node.body; i < list.length; i += 1) {
|
|
3108
|
+
var stmt = list[i];
|
|
3109
|
+
c(stmt, st, "Statement");
|
|
3110
|
+
}
|
|
3111
|
+
};
|
|
3112
|
+
base.Statement = skipThrough;
|
|
3113
|
+
base.EmptyStatement = ignore;
|
|
3114
|
+
base.ExpressionStatement = base.ParenthesizedExpression = base.ChainExpression = function(node, st, c) {
|
|
3115
|
+
return c(node.expression, st, "Expression");
|
|
3116
|
+
};
|
|
3117
|
+
base.IfStatement = function(node, st, c) {
|
|
3118
|
+
c(node.test, st, "Expression"), c(node.consequent, st, "Statement"), node.alternate && c(node.alternate, st, "Statement");
|
|
3119
|
+
};
|
|
3120
|
+
base.LabeledStatement = function(node, st, c) {
|
|
3121
|
+
return c(node.body, st, "Statement");
|
|
3122
|
+
};
|
|
3123
|
+
base.BreakStatement = base.ContinueStatement = ignore;
|
|
3124
|
+
base.WithStatement = function(node, st, c) {
|
|
3125
|
+
c(node.object, st, "Expression"), c(node.body, st, "Statement");
|
|
3126
|
+
};
|
|
3127
|
+
base.SwitchStatement = function(node, st, c) {
|
|
3128
|
+
c(node.discriminant, st, "Expression");
|
|
3129
|
+
for (var i = 0, list = node.cases; i < list.length; i += 1) {
|
|
3130
|
+
var cs = list[i];
|
|
3131
|
+
c(cs, st);
|
|
3132
|
+
}
|
|
3133
|
+
};
|
|
3134
|
+
base.SwitchCase = function(node, st, c) {
|
|
3135
|
+
node.test && c(node.test, st, "Expression");
|
|
3136
|
+
for (var i = 0, list = node.consequent; i < list.length; i += 1) {
|
|
3137
|
+
var cons = list[i];
|
|
3138
|
+
c(cons, st, "Statement");
|
|
3139
|
+
}
|
|
3140
|
+
};
|
|
3141
|
+
base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function(node, st, c) {
|
|
3142
|
+
node.argument && c(node.argument, st, "Expression");
|
|
3143
|
+
};
|
|
3144
|
+
base.ThrowStatement = base.SpreadElement = function(node, st, c) {
|
|
3145
|
+
return c(node.argument, st, "Expression");
|
|
3146
|
+
};
|
|
3147
|
+
base.TryStatement = function(node, st, c) {
|
|
3148
|
+
c(node.block, st, "Statement"), node.handler && c(node.handler, st), node.finalizer && c(node.finalizer, st, "Statement");
|
|
3149
|
+
};
|
|
3150
|
+
base.CatchClause = function(node, st, c) {
|
|
3151
|
+
node.param && c(node.param, st, "Pattern"), c(node.body, st, "Statement");
|
|
3152
|
+
};
|
|
3153
|
+
base.WhileStatement = base.DoWhileStatement = function(node, st, c) {
|
|
3154
|
+
c(node.test, st, "Expression"), c(node.body, st, "Statement");
|
|
3155
|
+
};
|
|
3156
|
+
base.ForStatement = function(node, st, c) {
|
|
3157
|
+
node.init && c(node.init, st, "ForInit"), node.test && c(node.test, st, "Expression"), node.update && c(node.update, st, "Expression"), c(node.body, st, "Statement");
|
|
3158
|
+
};
|
|
3159
|
+
base.ForInStatement = base.ForOfStatement = function(node, st, c) {
|
|
3160
|
+
c(node.left, st, "ForInit"), c(node.right, st, "Expression"), c(node.body, st, "Statement");
|
|
3161
|
+
};
|
|
3162
|
+
base.ForInit = function(node, st, c) {
|
|
3163
|
+
node.type === "VariableDeclaration" ? c(node, st) : c(node, st, "Expression");
|
|
3164
|
+
};
|
|
3165
|
+
base.DebuggerStatement = ignore;
|
|
3166
|
+
base.FunctionDeclaration = function(node, st, c) {
|
|
3167
|
+
return c(node, st, "Function");
|
|
3168
|
+
};
|
|
3169
|
+
base.VariableDeclaration = function(node, st, c) {
|
|
3170
|
+
for (var i = 0, list = node.declarations; i < list.length; i += 1) {
|
|
3171
|
+
var decl = list[i];
|
|
3172
|
+
c(decl, st);
|
|
3173
|
+
}
|
|
3174
|
+
};
|
|
3175
|
+
base.VariableDeclarator = function(node, st, c) {
|
|
3176
|
+
c(node.id, st, "Pattern"), node.init && c(node.init, st, "Expression");
|
|
3177
|
+
};
|
|
3178
|
+
base.Function = function(node, st, c) {
|
|
3179
|
+
node.id && c(node.id, st, "Pattern");
|
|
3180
|
+
for (var i = 0, list = node.params; i < list.length; i += 1) {
|
|
3181
|
+
var param = list[i];
|
|
3182
|
+
c(param, st, "Pattern");
|
|
3183
|
+
}
|
|
3184
|
+
c(node.body, st, node.expression ? "Expression" : "Statement");
|
|
3185
|
+
};
|
|
3186
|
+
base.Pattern = function(node, st, c) {
|
|
3187
|
+
node.type === "Identifier" ? c(node, st, "VariablePattern") : node.type === "MemberExpression" ? c(node, st, "MemberPattern") : c(node, st);
|
|
3188
|
+
};
|
|
3189
|
+
base.VariablePattern = ignore;
|
|
3190
|
+
base.MemberPattern = skipThrough;
|
|
3191
|
+
base.RestElement = function(node, st, c) {
|
|
3192
|
+
return c(node.argument, st, "Pattern");
|
|
3193
|
+
};
|
|
3194
|
+
base.ArrayPattern = function(node, st, c) {
|
|
3195
|
+
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
|
3196
|
+
var elt = list[i];
|
|
3197
|
+
elt && c(elt, st, "Pattern");
|
|
3198
|
+
}
|
|
3199
|
+
};
|
|
3200
|
+
base.ObjectPattern = function(node, st, c) {
|
|
3201
|
+
for (var i = 0, list = node.properties; i < list.length; i += 1) {
|
|
3202
|
+
var prop = list[i];
|
|
3203
|
+
prop.type === "Property" ? (prop.computed && c(prop.key, st, "Expression"), c(prop.value, st, "Pattern")) : prop.type === "RestElement" && c(prop.argument, st, "Pattern");
|
|
3204
|
+
}
|
|
3205
|
+
};
|
|
3206
|
+
base.Expression = skipThrough;
|
|
3207
|
+
base.ThisExpression = base.Super = base.MetaProperty = ignore;
|
|
3208
|
+
base.ArrayExpression = function(node, st, c) {
|
|
3209
|
+
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
|
3210
|
+
var elt = list[i];
|
|
3211
|
+
elt && c(elt, st, "Expression");
|
|
3212
|
+
}
|
|
3213
|
+
};
|
|
3214
|
+
base.ObjectExpression = function(node, st, c) {
|
|
3215
|
+
for (var i = 0, list = node.properties; i < list.length; i += 1) {
|
|
3216
|
+
var prop = list[i];
|
|
3217
|
+
c(prop, st);
|
|
3218
|
+
}
|
|
3219
|
+
};
|
|
3220
|
+
base.FunctionExpression = base.ArrowFunctionExpression = base.FunctionDeclaration;
|
|
3221
|
+
base.SequenceExpression = function(node, st, c) {
|
|
3222
|
+
for (var i = 0, list = node.expressions; i < list.length; i += 1) {
|
|
3223
|
+
var expr = list[i];
|
|
3224
|
+
c(expr, st, "Expression");
|
|
3225
|
+
}
|
|
3226
|
+
};
|
|
3227
|
+
base.TemplateLiteral = function(node, st, c) {
|
|
3228
|
+
for (var i = 0, list = node.quasis; i < list.length; i += 1) {
|
|
3229
|
+
var quasi = list[i];
|
|
3230
|
+
c(quasi, st);
|
|
3231
|
+
}
|
|
3232
|
+
for (var i$1 = 0, list$1 = node.expressions; i$1 < list$1.length; i$1 += 1) {
|
|
3233
|
+
var expr = list$1[i$1];
|
|
3234
|
+
c(expr, st, "Expression");
|
|
3235
|
+
}
|
|
3236
|
+
};
|
|
3237
|
+
base.TemplateElement = ignore;
|
|
3238
|
+
base.UnaryExpression = base.UpdateExpression = function(node, st, c) {
|
|
3239
|
+
c(node.argument, st, "Expression");
|
|
3240
|
+
};
|
|
3241
|
+
base.BinaryExpression = base.LogicalExpression = function(node, st, c) {
|
|
3242
|
+
c(node.left, st, "Expression"), c(node.right, st, "Expression");
|
|
3243
|
+
};
|
|
3244
|
+
base.AssignmentExpression = base.AssignmentPattern = function(node, st, c) {
|
|
3245
|
+
c(node.left, st, "Pattern"), c(node.right, st, "Expression");
|
|
3246
|
+
};
|
|
3247
|
+
base.ConditionalExpression = function(node, st, c) {
|
|
3248
|
+
c(node.test, st, "Expression"), c(node.consequent, st, "Expression"), c(node.alternate, st, "Expression");
|
|
3249
|
+
};
|
|
3250
|
+
base.NewExpression = base.CallExpression = function(node, st, c) {
|
|
3251
|
+
if (c(node.callee, st, "Expression"), node.arguments)
|
|
3252
|
+
for (var i = 0, list = node.arguments; i < list.length; i += 1) {
|
|
3253
|
+
var arg = list[i];
|
|
3254
|
+
c(arg, st, "Expression");
|
|
3255
|
+
}
|
|
3256
|
+
};
|
|
3257
|
+
base.MemberExpression = function(node, st, c) {
|
|
3258
|
+
c(node.object, st, "Expression"), node.computed && c(node.property, st, "Expression");
|
|
3259
|
+
};
|
|
3260
|
+
base.ExportNamedDeclaration = base.ExportDefaultDeclaration = function(node, st, c) {
|
|
3261
|
+
node.declaration && c(node.declaration, st, node.type === "ExportNamedDeclaration" || node.declaration.id ? "Statement" : "Expression"), node.source && c(node.source, st, "Expression");
|
|
3262
|
+
};
|
|
3263
|
+
base.ExportAllDeclaration = function(node, st, c) {
|
|
3264
|
+
node.exported && c(node.exported, st), c(node.source, st, "Expression");
|
|
3265
|
+
};
|
|
3266
|
+
base.ImportDeclaration = function(node, st, c) {
|
|
3267
|
+
for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
|
|
3268
|
+
var spec = list[i];
|
|
3269
|
+
c(spec, st);
|
|
3270
|
+
}
|
|
3271
|
+
c(node.source, st, "Expression");
|
|
3272
|
+
};
|
|
3273
|
+
base.ImportExpression = function(node, st, c) {
|
|
3274
|
+
c(node.source, st, "Expression");
|
|
3275
|
+
};
|
|
3276
|
+
base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.PrivateIdentifier = base.Literal = ignore;
|
|
3277
|
+
base.TaggedTemplateExpression = function(node, st, c) {
|
|
3278
|
+
c(node.tag, st, "Expression"), c(node.quasi, st, "Expression");
|
|
3279
|
+
};
|
|
3280
|
+
base.ClassDeclaration = base.ClassExpression = function(node, st, c) {
|
|
3281
|
+
return c(node, st, "Class");
|
|
3282
|
+
};
|
|
3283
|
+
base.Class = function(node, st, c) {
|
|
3284
|
+
node.id && c(node.id, st, "Pattern"), node.superClass && c(node.superClass, st, "Expression"), c(node.body, st);
|
|
3285
|
+
};
|
|
3286
|
+
base.ClassBody = function(node, st, c) {
|
|
3287
|
+
for (var i = 0, list = node.body; i < list.length; i += 1) {
|
|
3288
|
+
var elt = list[i];
|
|
3289
|
+
c(elt, st);
|
|
3290
|
+
}
|
|
3291
|
+
};
|
|
3292
|
+
base.MethodDefinition = base.PropertyDefinition = base.Property = function(node, st, c) {
|
|
3293
|
+
node.computed && c(node.key, st, "Expression"), node.value && c(node.value, st, "Expression");
|
|
3294
|
+
};
|
|
3295
|
+
const defaultGlobals = /* @__PURE__ */ new Set([
|
|
3296
|
+
"Array",
|
|
3297
|
+
"ArrayBuffer",
|
|
3298
|
+
"atob",
|
|
3299
|
+
"AudioContext",
|
|
3300
|
+
"Blob",
|
|
3301
|
+
"Boolean",
|
|
3302
|
+
"BigInt",
|
|
3303
|
+
"btoa",
|
|
3304
|
+
"clearInterval",
|
|
3305
|
+
"clearTimeout",
|
|
3306
|
+
"console",
|
|
3307
|
+
"crypto",
|
|
3308
|
+
"CustomEvent",
|
|
3309
|
+
"DataView",
|
|
3310
|
+
"Date",
|
|
3311
|
+
"decodeURI",
|
|
3312
|
+
"decodeURIComponent",
|
|
3313
|
+
"devicePixelRatio",
|
|
3314
|
+
"document",
|
|
3315
|
+
"encodeURI",
|
|
3316
|
+
"encodeURIComponent",
|
|
3317
|
+
"Error",
|
|
3318
|
+
"escape",
|
|
3319
|
+
"eval",
|
|
3320
|
+
"fetch",
|
|
3321
|
+
"File",
|
|
3322
|
+
"FileList",
|
|
3323
|
+
"FileReader",
|
|
3324
|
+
"Float32Array",
|
|
3325
|
+
"Float64Array",
|
|
3326
|
+
"Function",
|
|
3327
|
+
"Headers",
|
|
3328
|
+
"Image",
|
|
3329
|
+
"ImageData",
|
|
3330
|
+
"Infinity",
|
|
3331
|
+
"Int16Array",
|
|
3332
|
+
"Int32Array",
|
|
3333
|
+
"Int8Array",
|
|
3334
|
+
"Intl",
|
|
3335
|
+
"isFinite",
|
|
3336
|
+
"isNaN",
|
|
3337
|
+
"JSON",
|
|
3338
|
+
"Map",
|
|
3339
|
+
"Math",
|
|
3340
|
+
"NaN",
|
|
3341
|
+
"Number",
|
|
3342
|
+
"navigator",
|
|
3343
|
+
"Object",
|
|
3344
|
+
"parseFloat",
|
|
3345
|
+
"parseInt",
|
|
3346
|
+
"performance",
|
|
3347
|
+
"Path2D",
|
|
3348
|
+
"Promise",
|
|
3349
|
+
"Proxy",
|
|
3350
|
+
"RangeError",
|
|
3351
|
+
"ReferenceError",
|
|
3352
|
+
"Reflect",
|
|
3353
|
+
"RegExp",
|
|
3354
|
+
"cancelAnimationFrame",
|
|
3355
|
+
"requestAnimationFrame",
|
|
3356
|
+
"Set",
|
|
3357
|
+
"setInterval",
|
|
3358
|
+
"setTimeout",
|
|
3359
|
+
"String",
|
|
3360
|
+
"Symbol",
|
|
3361
|
+
"SyntaxError",
|
|
3362
|
+
"TextDecoder",
|
|
3363
|
+
"TextEncoder",
|
|
3364
|
+
"this",
|
|
3365
|
+
"TypeError",
|
|
3366
|
+
"Uint16Array",
|
|
3367
|
+
"Uint32Array",
|
|
3368
|
+
"Uint8Array",
|
|
3369
|
+
"Uint8ClampedArray",
|
|
3370
|
+
"undefined",
|
|
3371
|
+
"unescape",
|
|
3372
|
+
"URIError",
|
|
3373
|
+
"URL",
|
|
3374
|
+
"WeakMap",
|
|
3375
|
+
"WeakSet",
|
|
3376
|
+
"WebSocket",
|
|
3377
|
+
"Worker",
|
|
3378
|
+
"window"
|
|
3379
|
+
]), ohqWalk = make({
|
|
3380
|
+
Import() {
|
|
3381
|
+
},
|
|
3382
|
+
ViewExpression(node, st, c) {
|
|
3383
|
+
c(node.id, st, "Identifier");
|
|
3384
|
+
},
|
|
3385
|
+
MutableExpression(node, st, c) {
|
|
3386
|
+
c(node.id, st, "Identifier");
|
|
3387
|
+
}
|
|
3388
|
+
});
|
|
3389
|
+
function isScope(node) {
|
|
3390
|
+
return node.type === "FunctionExpression" || node.type === "FunctionDeclaration" || node.type === "ArrowFunctionExpression" || node.type === "Program";
|
|
3391
|
+
}
|
|
3392
|
+
function isBlockScope(node) {
|
|
3393
|
+
return node.type === "BlockStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "ForStatement" || isScope(node);
|
|
3394
|
+
}
|
|
3395
|
+
function declaresArguments(node) {
|
|
3396
|
+
return node.type === "FunctionExpression" || node.type === "FunctionDeclaration";
|
|
3397
|
+
}
|
|
3398
|
+
function findReferences(cell, globals) {
|
|
3399
|
+
const ast = { type: "Program", body: [cell.body] }, locals = /* @__PURE__ */ new Map(), globalSet = new Set(globals), references = [];
|
|
3400
|
+
function hasLocal(node, name) {
|
|
3401
|
+
const l = locals.get(node);
|
|
3402
|
+
return l ? l.has(name) : !1;
|
|
3403
|
+
}
|
|
3404
|
+
function declareLocal(node, id) {
|
|
3405
|
+
const l = locals.get(node);
|
|
3406
|
+
l ? l.add(id.name) : locals.set(node, /* @__PURE__ */ new Set([id.name]));
|
|
3407
|
+
}
|
|
3408
|
+
function declareClass(node) {
|
|
3409
|
+
node.id && declareLocal(node, node.id);
|
|
3410
|
+
}
|
|
3411
|
+
function declareFunction(node) {
|
|
3412
|
+
node.params.forEach((param) => declarePattern(param, node)), node.id && declareLocal(node, node.id);
|
|
3413
|
+
}
|
|
3414
|
+
function declareCatchClause(node) {
|
|
3415
|
+
node.param && declarePattern(node.param, node);
|
|
3416
|
+
}
|
|
3417
|
+
function declarePattern(node, parent) {
|
|
3418
|
+
switch (node.type) {
|
|
3419
|
+
case "Identifier":
|
|
3420
|
+
declareLocal(parent, node);
|
|
3421
|
+
break;
|
|
3422
|
+
case "ObjectPattern":
|
|
3423
|
+
node.properties.forEach((node2) => declarePattern(node2, parent));
|
|
3424
|
+
break;
|
|
3425
|
+
case "ArrayPattern":
|
|
3426
|
+
node.elements.forEach((node2) => node2 && declarePattern(node2, parent));
|
|
3427
|
+
break;
|
|
3428
|
+
case "Property":
|
|
3429
|
+
declarePattern(node.value, parent);
|
|
3430
|
+
break;
|
|
3431
|
+
case "RestElement":
|
|
3432
|
+
declarePattern(node.argument, parent);
|
|
3433
|
+
break;
|
|
3434
|
+
case "AssignmentPattern":
|
|
3435
|
+
declarePattern(node.left, parent);
|
|
3436
|
+
break;
|
|
3437
|
+
default:
|
|
3438
|
+
throw new Error("Unrecognized pattern type: " + node.type);
|
|
3439
|
+
}
|
|
3440
|
+
}
|
|
3441
|
+
function declareModuleSpecifier(node) {
|
|
3442
|
+
declareLocal(ast, node.local);
|
|
3443
|
+
}
|
|
3444
|
+
ancestor(
|
|
3445
|
+
ast,
|
|
3446
|
+
{
|
|
3447
|
+
VariableDeclaration: (node, parents) => {
|
|
3448
|
+
let parent = null;
|
|
3449
|
+
for (let i = parents.length - 1; i >= 0 && parent === null; --i)
|
|
3450
|
+
(node.kind === "var" ? isScope(parents[i]) : isBlockScope(parents[i])) && (parent = parents[i]);
|
|
3451
|
+
node.declarations.forEach((declaration) => declarePattern(declaration.id, parent));
|
|
3452
|
+
},
|
|
3453
|
+
FunctionDeclaration: (node, parents) => {
|
|
3454
|
+
let parent = null;
|
|
3455
|
+
for (let i = parents.length - 2; i >= 0 && parent === null; --i)
|
|
3456
|
+
isScope(parents[i]) && (parent = parents[i]);
|
|
3457
|
+
declareLocal(parent, node.id), declareFunction(node);
|
|
3458
|
+
},
|
|
3459
|
+
Function: declareFunction,
|
|
3460
|
+
ClassDeclaration: (node, parents) => {
|
|
3461
|
+
let parent = null;
|
|
3462
|
+
for (let i = parents.length - 2; i >= 0 && parent === null; i--)
|
|
3463
|
+
isScope(parents[i]) && (parent = parents[i]);
|
|
3464
|
+
declareLocal(parent, node.id);
|
|
3465
|
+
},
|
|
3466
|
+
Class: declareClass,
|
|
3467
|
+
CatchClause: declareCatchClause,
|
|
3468
|
+
ImportDefaultSpecifier: declareModuleSpecifier,
|
|
3469
|
+
ImportSpecifier: declareModuleSpecifier,
|
|
3470
|
+
ImportNamespaceSpecifier: declareModuleSpecifier
|
|
3471
|
+
},
|
|
3472
|
+
ohqWalk
|
|
3473
|
+
);
|
|
3474
|
+
function identifier(node, parents) {
|
|
3475
|
+
let name = node.name;
|
|
3476
|
+
if (name !== "undefined") {
|
|
3477
|
+
for (let i = parents.length - 2; i >= 0; --i) {
|
|
3478
|
+
if (name === "arguments" && declaresArguments(parents[i]) || hasLocal(parents[i], name))
|
|
3479
|
+
return;
|
|
3480
|
+
parents[i].type === "ViewExpression" && (node = parents[i], name = `viewof ${node.id.name}`), parents[i].type === "MutableExpression" && (node = parents[i], name = `mutable ${node.id.name}`);
|
|
3481
|
+
}
|
|
3482
|
+
if (!globalSet.has(name)) {
|
|
3483
|
+
if (name === "arguments")
|
|
3484
|
+
throw Object.assign(new SyntaxError("arguments is not allowed"), { node });
|
|
3485
|
+
references.push(node);
|
|
3486
|
+
}
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
ancestor(
|
|
3490
|
+
ast,
|
|
3491
|
+
{
|
|
3492
|
+
VariablePattern: identifier,
|
|
3493
|
+
Identifier: identifier
|
|
3494
|
+
},
|
|
3495
|
+
ohqWalk
|
|
3496
|
+
);
|
|
3497
|
+
function checkConst(node, parents) {
|
|
3498
|
+
if (node)
|
|
3499
|
+
switch (node.type) {
|
|
3500
|
+
case "Identifier":
|
|
3501
|
+
case "VariablePattern": {
|
|
3502
|
+
for (const parent of parents)
|
|
3503
|
+
if (hasLocal(parent, node.name))
|
|
3504
|
+
return;
|
|
3505
|
+
if (parents[parents.length - 2].type === "MutableExpression")
|
|
3506
|
+
return;
|
|
3507
|
+
throw Object.assign(new SyntaxError(`Assignment to constant variable ${node.name}`), { node });
|
|
3508
|
+
}
|
|
3509
|
+
case "ArrayPattern": {
|
|
3510
|
+
for (const element of node.elements)
|
|
3511
|
+
checkConst(element, parents);
|
|
3512
|
+
return;
|
|
3513
|
+
}
|
|
3514
|
+
case "ObjectPattern": {
|
|
3515
|
+
for (const property of node.properties)
|
|
3516
|
+
checkConst(property, parents);
|
|
3517
|
+
return;
|
|
3518
|
+
}
|
|
3519
|
+
case "Property": {
|
|
3520
|
+
checkConst(node.value, parents);
|
|
3521
|
+
return;
|
|
3522
|
+
}
|
|
3523
|
+
case "RestElement": {
|
|
3524
|
+
checkConst(node.argument, parents);
|
|
3525
|
+
return;
|
|
3526
|
+
}
|
|
3527
|
+
}
|
|
3528
|
+
}
|
|
3529
|
+
function checkConstArgument(node, parents) {
|
|
3530
|
+
checkConst(node.argument, parents);
|
|
3531
|
+
}
|
|
3532
|
+
function checkConstLeft(node, parents) {
|
|
3533
|
+
checkConst(node.left, parents);
|
|
3534
|
+
}
|
|
3535
|
+
return ancestor(
|
|
3536
|
+
ast,
|
|
3537
|
+
{
|
|
3538
|
+
AssignmentExpression: checkConstLeft,
|
|
3539
|
+
AssignmentPattern: checkConstLeft,
|
|
3540
|
+
UpdateExpression: checkConstArgument,
|
|
3541
|
+
ForOfStatement: checkConstLeft,
|
|
3542
|
+
ForInStatement: checkConstLeft
|
|
3543
|
+
},
|
|
3544
|
+
ohqWalk
|
|
3545
|
+
), references;
|
|
3546
|
+
}
|
|
3547
|
+
function findFeatures(cell, featureName) {
|
|
3548
|
+
const ast = { type: "Program", body: [cell.body] }, features = /* @__PURE__ */ new Map(), { references } = cell;
|
|
3549
|
+
return simple(
|
|
3550
|
+
ast,
|
|
3551
|
+
{
|
|
3552
|
+
CallExpression: (node) => {
|
|
3553
|
+
const { callee, arguments: args } = node;
|
|
3554
|
+
if (callee.type !== "Identifier" || callee.name !== featureName || references.indexOf(callee) < 0) return;
|
|
3555
|
+
if (args.length !== 1 || !(args[0].type === "Literal" && /^['"]/.test(args[0].raw) || args[0].type === "TemplateLiteral" && args[0].expressions.length === 0))
|
|
3556
|
+
throw Object.assign(new SyntaxError(`${featureName} requires a single literal string argument`), { node });
|
|
3557
|
+
const [arg] = args, name = arg.type === "Literal" ? arg.value : arg.quasis[0].value.cooked, location = { start: arg.start, end: arg.end };
|
|
3558
|
+
features.has(name) ? features.get(name).push(location) : features.set(name, [location]);
|
|
3559
|
+
}
|
|
3560
|
+
},
|
|
3561
|
+
ohqWalk
|
|
3562
|
+
), features;
|
|
3563
|
+
}
|
|
3564
|
+
const SCOPE_FUNCTION = 2, SCOPE_ASYNC = 4, SCOPE_GENERATOR = 8;
|
|
3565
|
+
function parseCell$2(input, { tag, raw, globals, ...options } = {}) {
|
|
3566
|
+
let cell;
|
|
3567
|
+
if (tag != null && input) {
|
|
3568
|
+
cell = TemplateCellParser.parse(input, options);
|
|
3569
|
+
const parsedTag = CellTagParser.parse(tag, options);
|
|
3570
|
+
parseReferences(parsedTag, tag, globals), parseFeatures(parsedTag, tag), cell.tag = parsedTag, cell.raw = !!raw;
|
|
3571
|
+
} else
|
|
3572
|
+
cell = CellParser.parse(input, options);
|
|
3573
|
+
return parseReferences(cell, input, globals), parseFeatures(cell, input), cell;
|
|
3574
|
+
}
|
|
3575
|
+
class CellParser extends Parser {
|
|
3576
|
+
constructor(options, ...args) {
|
|
3577
|
+
super(Object.assign({ ecmaVersion: 13 }, options), ...args);
|
|
3578
|
+
}
|
|
3579
|
+
enterScope(flags) {
|
|
3580
|
+
return flags & SCOPE_FUNCTION && ++this.O_function, super.enterScope(flags);
|
|
3581
|
+
}
|
|
3582
|
+
exitScope() {
|
|
3583
|
+
return this.currentScope().flags & SCOPE_FUNCTION && --this.O_function, super.exitScope();
|
|
3584
|
+
}
|
|
3585
|
+
parseForIn(node, init) {
|
|
3586
|
+
return this.O_function === 1 && node.await && (this.O_async = !0), super.parseForIn(node, init);
|
|
3587
|
+
}
|
|
3588
|
+
parseAwait() {
|
|
3589
|
+
return this.O_function === 1 && (this.O_async = !0), super.parseAwait();
|
|
3590
|
+
}
|
|
3591
|
+
parseYield(noIn) {
|
|
3592
|
+
return this.O_function === 1 && (this.O_generator = !0), super.parseYield(noIn);
|
|
3593
|
+
}
|
|
3594
|
+
parseImport(node) {
|
|
3595
|
+
return this.next(), node.specifiers = this.parseImportSpecifiers(), this.type === types$1._with && (this.next(), node.injections = this.parseImportSpecifiers()), this.expectContextual("from"), node.source = this.type === types$1.string ? this.parseExprAtom() : this.unexpected(), this.finishNode(node, "ImportDeclaration");
|
|
3596
|
+
}
|
|
3597
|
+
parseImportSpecifiers() {
|
|
3598
|
+
const nodes = [], identifiers = /* @__PURE__ */ new Set();
|
|
3599
|
+
let first = !0;
|
|
3600
|
+
for (this.expect(types$1.braceL); !this.eat(types$1.braceR); ) {
|
|
3601
|
+
if (first)
|
|
3602
|
+
first = !1;
|
|
3603
|
+
else if (this.expect(types$1.comma), this.afterTrailingComma(types$1.braceR)) break;
|
|
3604
|
+
const node = this.startNode();
|
|
3605
|
+
node.view = this.eatContextual("viewof"), node.mutable = node.view ? !1 : this.eatContextual("mutable"), node.imported = this.parseIdent(), this.checkUnreserved(node.imported), this.checkLocal(node.imported), this.eatContextual("as") ? (node.local = this.parseIdent(), this.checkUnreserved(node.local), this.checkLocal(node.local)) : node.local = node.imported, this.checkLValSimple(node.local, "let"), identifiers.has(node.local.name) && this.raise(node.local.start, `Identifier '${node.local.name}' has already been declared`), identifiers.add(node.local.name), nodes.push(this.finishNode(node, "ImportSpecifier"));
|
|
3606
|
+
}
|
|
3607
|
+
return nodes;
|
|
3608
|
+
}
|
|
3609
|
+
parseExprAtom(refDestructuringErrors) {
|
|
3610
|
+
return this.parseMaybeKeywordExpression("viewof", "ViewExpression") || this.parseMaybeKeywordExpression("mutable", "MutableExpression") || super.parseExprAtom(refDestructuringErrors);
|
|
3611
|
+
}
|
|
3612
|
+
startCell() {
|
|
3613
|
+
this.O_function = 0, this.O_async = !1, this.O_generator = !1, this.strict = !0, this.enterScope(SCOPE_FUNCTION | SCOPE_ASYNC | SCOPE_GENERATOR);
|
|
3614
|
+
}
|
|
3615
|
+
finishCell(node, body, id) {
|
|
3616
|
+
return id && this.checkLocal(id), node.id = id, node.body = body, node.async = this.O_async, node.generator = this.O_generator, this.exitScope(), this.finishNode(node, "Cell");
|
|
3617
|
+
}
|
|
3618
|
+
parseCell(node, eof) {
|
|
3619
|
+
const lookahead2 = new CellParser({}, this.input, this.start);
|
|
3620
|
+
let token = lookahead2.getToken(), body = null, id = null;
|
|
3621
|
+
return this.startCell(), token.type === types$1._import && lookahead2.getToken().type !== types$1.parenL ? body = this.parseImport(this.startNode()) : token.type !== types$1.eof && token.type !== types$1.semi && (token.type === types$1.name && ((token.value === "viewof" || token.value === "mutable") && (token = lookahead2.getToken(), token.type !== types$1.name && lookahead2.unexpected()), token = lookahead2.getToken(), token.type === types$1.eq && (id = this.parseMaybeKeywordExpression("viewof", "ViewExpression") || this.parseMaybeKeywordExpression("mutable", "MutableExpression") || this.parseIdent(), token = lookahead2.getToken(), this.expect(types$1.eq))), token.type === types$1.braceL ? body = this.parseBlock() : (body = this.parseExpression(), id === null && (body.type === "FunctionExpression" || body.type === "ClassExpression") && (id = body.id))), this.semicolon(), eof && this.expect(types$1.eof), this.finishCell(node, body, id);
|
|
3622
|
+
}
|
|
3623
|
+
parseTopLevel(node) {
|
|
3624
|
+
return this.parseCell(node, !0);
|
|
3625
|
+
}
|
|
3626
|
+
toAssignable(node, isBinding, refDestructuringErrors) {
|
|
3627
|
+
return node.type === "MutableExpression" ? node : super.toAssignable(node, isBinding, refDestructuringErrors);
|
|
3628
|
+
}
|
|
3629
|
+
checkLocal(id) {
|
|
3630
|
+
const node = id.id || id;
|
|
3631
|
+
(defaultGlobals.has(node.name) || node.name === "arguments") && this.raise(node.start, `Identifier '${node.name}' is reserved`);
|
|
3632
|
+
}
|
|
3633
|
+
checkUnreserved(node) {
|
|
3634
|
+
return (node.name === "viewof" || node.name === "mutable") && this.raise(node.start, `Unexpected keyword '${node.name}'`), super.checkUnreserved(node);
|
|
3635
|
+
}
|
|
3636
|
+
checkLValSimple(expr, bindingType, checkClashes) {
|
|
3637
|
+
return super.checkLValSimple(
|
|
3638
|
+
expr.type === "MutableExpression" ? expr.id : expr,
|
|
3639
|
+
bindingType,
|
|
3640
|
+
checkClashes
|
|
3641
|
+
);
|
|
3642
|
+
}
|
|
3643
|
+
unexpected(pos) {
|
|
3644
|
+
this.raise(
|
|
3645
|
+
pos ?? this.start,
|
|
3646
|
+
this.type === types$1.eof ? "Unexpected end of input" : "Unexpected token"
|
|
3647
|
+
);
|
|
3648
|
+
}
|
|
3649
|
+
parseMaybeKeywordExpression(keyword, type) {
|
|
3650
|
+
if (this.isContextual(keyword)) {
|
|
3651
|
+
const node = this.startNode();
|
|
3652
|
+
return this.next(), node.id = this.parseIdent(), this.finishNode(node, type);
|
|
3653
|
+
}
|
|
3654
|
+
}
|
|
3655
|
+
}
|
|
3656
|
+
const o_tmpl = new TokContext(
|
|
3657
|
+
"`",
|
|
3658
|
+
// token
|
|
3659
|
+
!0,
|
|
3660
|
+
// isExpr
|
|
3661
|
+
!0,
|
|
3662
|
+
// preserveSpace
|
|
3663
|
+
(parser) => readTemplateToken.call(parser)
|
|
3664
|
+
// override
|
|
3665
|
+
);
|
|
3666
|
+
class TemplateCellParser extends CellParser {
|
|
3667
|
+
constructor(...args) {
|
|
3668
|
+
super(...args), this.type = types$1.backQuote, this.exprAllowed = !1;
|
|
3669
|
+
}
|
|
3670
|
+
initialContext() {
|
|
3671
|
+
return [o_tmpl];
|
|
3672
|
+
}
|
|
3673
|
+
parseCell(node) {
|
|
3674
|
+
this.startCell(), this.type === types$1.eof && (this.value = "");
|
|
3675
|
+
const isTagged = !0, body = this.startNode();
|
|
3676
|
+
body.expressions = [];
|
|
3677
|
+
let curElt = this.parseTemplateElement({ isTagged });
|
|
3678
|
+
for (body.quasis = [curElt]; this.type !== types$1.eof; )
|
|
3679
|
+
this.expect(types$1.dollarBraceL), body.expressions.push(this.parseExpression()), this.expect(types$1.braceR), body.quasis.push(curElt = this.parseTemplateElement({ isTagged }));
|
|
3680
|
+
return curElt.tail = !0, this.next(), this.finishNode(body, "TemplateLiteral"), this.expect(types$1.eof), this.finishCell(node, body, null);
|
|
3681
|
+
}
|
|
3682
|
+
}
|
|
3683
|
+
function readTemplateToken() {
|
|
3684
|
+
out: for (; this.pos < this.input.length; this.pos++)
|
|
3685
|
+
switch (this.input.charCodeAt(this.pos)) {
|
|
3686
|
+
case 92: {
|
|
3687
|
+
this.pos < this.input.length - 1 && ++this.pos;
|
|
3688
|
+
break;
|
|
3689
|
+
}
|
|
3690
|
+
case 36: {
|
|
3691
|
+
if (this.input.charCodeAt(this.pos + 1) === 123) {
|
|
3692
|
+
if (this.pos === this.start && this.type === types$1.invalidTemplate)
|
|
3693
|
+
return this.pos += 2, this.finishToken(types$1.dollarBraceL);
|
|
3694
|
+
break out;
|
|
3695
|
+
}
|
|
3696
|
+
break;
|
|
3697
|
+
}
|
|
3698
|
+
}
|
|
3699
|
+
return this.finishToken(types$1.invalidTemplate, this.input.slice(this.start, this.pos));
|
|
3700
|
+
}
|
|
3701
|
+
class CellTagParser extends Parser {
|
|
3702
|
+
constructor(options, ...args) {
|
|
3703
|
+
super(Object.assign({ ecmaVersion: 12 }, options), ...args);
|
|
3704
|
+
}
|
|
3705
|
+
enterScope(flags) {
|
|
3706
|
+
return flags & SCOPE_FUNCTION && ++this.O_function, super.enterScope(flags);
|
|
3707
|
+
}
|
|
3708
|
+
exitScope() {
|
|
3709
|
+
return this.currentScope().flags & SCOPE_FUNCTION && --this.O_function, super.exitScope();
|
|
3710
|
+
}
|
|
3711
|
+
parseForIn(node, init) {
|
|
3712
|
+
return this.O_function === 1 && node.await && (this.O_async = !0), super.parseForIn(node, init);
|
|
3713
|
+
}
|
|
3714
|
+
parseAwait() {
|
|
3715
|
+
return this.O_function === 1 && (this.O_async = !0), super.parseAwait();
|
|
3716
|
+
}
|
|
3717
|
+
parseYield(noIn) {
|
|
3718
|
+
return this.O_function === 1 && (this.O_generator = !0), super.parseYield(noIn);
|
|
3719
|
+
}
|
|
3720
|
+
parseTopLevel(node) {
|
|
3721
|
+
return this.O_function = 0, this.O_async = !1, this.O_generator = !1, this.strict = !0, this.enterScope(SCOPE_FUNCTION | SCOPE_ASYNC | SCOPE_GENERATOR), node.body = this.parseExpression(), node.input = this.input, node.async = this.O_async, node.generator = this.O_generator, this.exitScope(), this.finishNode(node, "CellTag");
|
|
3722
|
+
}
|
|
3723
|
+
}
|
|
3724
|
+
function parseReferences(cell, input, globals = defaultGlobals) {
|
|
3725
|
+
if (!cell.body)
|
|
3726
|
+
cell.references = [];
|
|
3727
|
+
else if (cell.body.type === "ImportDeclaration")
|
|
3728
|
+
cell.references = cell.body.injections ? cell.body.injections.map((i) => i.imported) : [];
|
|
3729
|
+
else
|
|
3730
|
+
try {
|
|
3731
|
+
cell.references = findReferences(cell, globals);
|
|
3732
|
+
} catch (error) {
|
|
3733
|
+
if (error.node) {
|
|
3734
|
+
const loc = getLineInfo(input, error.node.start);
|
|
3735
|
+
error.message += ` (${loc.line}:${loc.column})`, error.pos = error.node.start, error.loc = loc, delete error.node;
|
|
3736
|
+
}
|
|
3737
|
+
throw error;
|
|
3738
|
+
}
|
|
3739
|
+
return cell;
|
|
3740
|
+
}
|
|
3741
|
+
function parseFeatures(cell, input) {
|
|
3742
|
+
if (cell.body && cell.body.type !== "ImportDeclaration")
|
|
3743
|
+
try {
|
|
3744
|
+
cell.fileAttachments = findFeatures(cell, "FileAttachment"), cell.databaseClients = findFeatures(cell, "DatabaseClient"), cell.secrets = findFeatures(cell, "Secret"), cell.notificationClients = findFeatures(cell, "NotificationClient");
|
|
3745
|
+
} catch (error) {
|
|
3746
|
+
if (error.node) {
|
|
3747
|
+
const loc = getLineInfo(input, error.node.start);
|
|
3748
|
+
error.message += ` (${loc.line}:${loc.column})`, error.pos = error.node.start, error.loc = loc, delete error.node;
|
|
3749
|
+
}
|
|
3750
|
+
throw error;
|
|
3751
|
+
}
|
|
3752
|
+
else
|
|
3753
|
+
cell.fileAttachments = /* @__PURE__ */ new Map(), cell.databaseClients = /* @__PURE__ */ new Map(), cell.secrets = /* @__PURE__ */ new Map(), cell.notificationClients = /* @__PURE__ */ new Map();
|
|
3754
|
+
return cell;
|
|
3755
|
+
}
|
|
3756
|
+
class ModuleParser extends CellParser {
|
|
3757
|
+
parseTopLevel(node) {
|
|
3758
|
+
for (node.cells || (node.cells = []); this.type !== types$1.eof; ) {
|
|
3759
|
+
const cell = this.parseCell(this.startNode());
|
|
3760
|
+
cell.input = this.input, node.cells.push(cell);
|
|
3761
|
+
}
|
|
3762
|
+
return this.next(), this.finishNode(node, "Program");
|
|
3763
|
+
}
|
|
3764
|
+
}
|
|
3765
|
+
function splitModule(input) {
|
|
3766
|
+
return ModuleParser.parse(input, { ecmaVersion: "latest" }).cells.map((cell) => ({
|
|
3767
|
+
type: "Cell",
|
|
3768
|
+
text: input.substring(cell.start, cell.end),
|
|
3769
|
+
start: cell.start,
|
|
3770
|
+
end: cell.end
|
|
3771
|
+
}));
|
|
3772
|
+
}
|
|
3773
|
+
function parseCell$1(input) {
|
|
3774
|
+
return parseCell$2(input);
|
|
3775
|
+
}
|
|
3776
|
+
const walk = ohqWalk, FuncTypes = {
|
|
3777
|
+
functionType: Object.getPrototypeOf(function() {
|
|
3778
|
+
}).constructor,
|
|
3779
|
+
asyncFunctionType: Object.getPrototypeOf(async function() {
|
|
3780
|
+
}).constructor,
|
|
3781
|
+
generatorFunctionType: Object.getPrototypeOf(function* () {
|
|
3782
|
+
}).constructor,
|
|
3783
|
+
asyncGeneratorFunctionType: Object.getPrototypeOf(async function* () {
|
|
3784
|
+
}).constructor
|
|
3785
|
+
};
|
|
3786
|
+
function funcType(async = !1, generator = !1) {
|
|
3787
|
+
return !async && !generator ? FuncTypes.functionType : async && !generator ? FuncTypes.asyncFunctionType : !async && generator ? FuncTypes.generatorFunctionType : FuncTypes.asyncGeneratorFunctionType;
|
|
3788
|
+
}
|
|
3789
|
+
function createFunction(refs, async = !1, generator = !1, blockStatement = !1, body) {
|
|
3790
|
+
if (body !== void 0)
|
|
3791
|
+
return refs.patches.sort((l, r) => r.start - l.start), refs.patches.forEach((r) => {
|
|
3792
|
+
body = body.substring(0, r.start) + r.newText + body.substring(r.end);
|
|
3793
|
+
}), new (funcType(async, generator))(...refs.args, blockStatement ? body.substring(1, body.length - 1).trim() : `return (
|
|
3794
|
+
${body}
|
|
3795
|
+
);`);
|
|
3796
|
+
}
|
|
3797
|
+
function join(baseURL, relativeURL) {
|
|
3798
|
+
return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
|
|
3799
|
+
}
|
|
3800
|
+
const isRelativePath = (path) => path[0] === ".", fixRelativeUrl = (path, basePath) => isRelativePath(path) ? join(basePath, path) : path;
|
|
3801
|
+
async function obfuscatedImport(url) {
|
|
3802
|
+
return new FuncTypes.asyncFunctionType("url", "return import(url)")(url);
|
|
3803
|
+
}
|
|
3804
|
+
function encodeBacktick(str) {
|
|
3805
|
+
return str.split("`").join("\\`");
|
|
3806
|
+
}
|
|
3807
|
+
function createParsedOJS(ojs, offset2, inlineMD) {
|
|
3808
|
+
let cell, error;
|
|
3809
|
+
try {
|
|
3810
|
+
cell = parseCell$1(ojs);
|
|
3811
|
+
} catch (e) {
|
|
3812
|
+
error = e;
|
|
3813
|
+
}
|
|
3814
|
+
return {
|
|
3815
|
+
ojs,
|
|
3816
|
+
offset: offset2,
|
|
3817
|
+
inlineMD,
|
|
3818
|
+
cell,
|
|
3819
|
+
error
|
|
3820
|
+
};
|
|
3821
|
+
}
|
|
3822
|
+
function splitOmd(_) {
|
|
3823
|
+
const retVal = [], re = /(```(?:\s|\S)[\s\S]*?```)/g;
|
|
3824
|
+
let prevOffset = 0, match = re.exec(_);
|
|
3825
|
+
for (; match !== null; ) {
|
|
3826
|
+
match.index > prevOffset && retVal.push(createParsedOJS(_.substring(prevOffset, match.index), prevOffset, !0));
|
|
3827
|
+
const outer = match[0];
|
|
3828
|
+
if (outer.indexOf("``` ") === 0 || outer.indexOf("```\n") === 0 || outer.indexOf("```\r\n") === 0) {
|
|
3829
|
+
const inner = outer.substring(3, outer.length - 3);
|
|
3830
|
+
retVal.push(createParsedOJS(inner, match.index + 3, !1));
|
|
3831
|
+
} else
|
|
3832
|
+
retVal.push(createParsedOJS(outer, match.index, !0));
|
|
3833
|
+
prevOffset = match.index + match[0].length, match = re.exec(_);
|
|
3834
|
+
}
|
|
3835
|
+
return _.length > prevOffset && retVal.push(createParsedOJS(_.substring(prevOffset, _.length), prevOffset, !0)), retVal;
|
|
3836
|
+
}
|
|
3837
|
+
function ojs2notebook(ojs) {
|
|
3838
|
+
const cells = splitModule(ojs);
|
|
3839
|
+
return {
|
|
3840
|
+
files: [],
|
|
3841
|
+
nodes: cells.map((cell, idx) => ({
|
|
3842
|
+
id: idx,
|
|
3843
|
+
mode: "js",
|
|
3844
|
+
value: cell.text,
|
|
3845
|
+
start: cell.start,
|
|
3846
|
+
end: cell.end
|
|
3847
|
+
}))
|
|
3848
|
+
};
|
|
3849
|
+
}
|
|
3850
|
+
function omd2notebook(omd) {
|
|
3851
|
+
const cells = splitOmd(omd);
|
|
3852
|
+
return {
|
|
3853
|
+
files: [],
|
|
3854
|
+
nodes: cells.map((cell, idx) => ({
|
|
3855
|
+
id: idx,
|
|
3856
|
+
mode: cell.inlineMD ? "md" : "js",
|
|
3857
|
+
value: cell.ojs,
|
|
3858
|
+
start: cell.offset,
|
|
3859
|
+
end: cell.offset + cell.ojs.length
|
|
3860
|
+
}))
|
|
3861
|
+
};
|
|
3862
|
+
}
|
|
3863
|
+
function fetchEx(url, proxyPrefix = "https://api.codetabs.com/v1/proxy/?quest=", proxyPostfix = "") {
|
|
3864
|
+
const matches = url.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n?]+)/img);
|
|
3865
|
+
if (!matches || matches.length === 0)
|
|
3866
|
+
throw new Error(`Invalid URL: ${url}`);
|
|
3867
|
+
return fetch(url, { headers: { origin: matches[0], referer: url } }).then((response) => {
|
|
3868
|
+
if (response.ok) return response;
|
|
3869
|
+
throw new Error("CORS?");
|
|
3870
|
+
}).catch((e) => (url = `${proxyPrefix}${url}${proxyPostfix}`, fetch(url, { headers: { origin: matches[0], referer: url } })));
|
|
3871
|
+
}
|
|
3872
|
+
function download(impUrl, proxyPrefix, proxyPostfix) {
|
|
3873
|
+
const isShared = impUrl.indexOf("https://observablehq.com/d") === 0;
|
|
3874
|
+
return fetchEx(impUrl.replace(`https://observablehq.com/${isShared ? "d/" : ""}`, "https://api.observablehq.com/document/"), proxyPrefix, proxyPostfix).then((r) => r.json());
|
|
3875
|
+
}
|
|
3876
|
+
function calcRefs(cellAst, cellStr) {
|
|
3877
|
+
if (cellAst.references === void 0) return { inputs: [], args: [], patches: [] };
|
|
3878
|
+
const dedup = {};
|
|
3879
|
+
cellAst.references.forEach((r) => dedup[cellStr.substring(r.start, r.end)] = !0);
|
|
3880
|
+
const retVal = {
|
|
3881
|
+
inputs: Object.keys(dedup),
|
|
3882
|
+
args: Object.keys(dedup).map((r) => r.split(" ").join("_")),
|
|
3883
|
+
patches: []
|
|
3884
|
+
}, pushPatch = (node, newText) => {
|
|
3885
|
+
var _a, _b;
|
|
3886
|
+
return retVal.patches.push({ start: node.start - (((_a = cellAst.body) == null ? void 0 : _a.start) ?? 0), end: node.end - (((_b = cellAst.body) == null ? void 0 : _b.start) ?? 0), newText });
|
|
3887
|
+
};
|
|
3888
|
+
return cellAst.body && ancestor(cellAst.body, {
|
|
3889
|
+
Identifier(node) {
|
|
3890
|
+
cellStr.substring(node.start, node.end);
|
|
3891
|
+
},
|
|
3892
|
+
MutableExpression(node) {
|
|
3893
|
+
const newText = cellStr.substring(node.start, node.end).split(" ").join("_") + ".value";
|
|
3894
|
+
pushPatch(node, newText);
|
|
3895
|
+
},
|
|
3896
|
+
ViewExpression(node) {
|
|
3897
|
+
const newText = cellStr.substring(node.start, node.end).split(" ").join("_");
|
|
3898
|
+
pushPatch(node, newText);
|
|
3899
|
+
},
|
|
3900
|
+
ThisExpression(node, ancestors) {
|
|
3901
|
+
cellStr.substring(node.start, node.end) === "this" && !ancestors.find((n) => n.type === "FunctionExpression") && pushPatch(node, "((this === globalThis || this === globalThis.window)? undefined : this?.valueOf())");
|
|
3902
|
+
}
|
|
3903
|
+
}, walk), retVal;
|
|
3904
|
+
}
|
|
3905
|
+
function parseImportDeclaration(cellAst) {
|
|
3906
|
+
var _a, _b;
|
|
3907
|
+
return {
|
|
3908
|
+
type: "import",
|
|
3909
|
+
src: cellAst.body.source.value,
|
|
3910
|
+
specifiers: ((_a = cellAst.body.specifiers) == null ? void 0 : _a.map((spec) => {
|
|
3911
|
+
var _a2;
|
|
3912
|
+
return {
|
|
3913
|
+
view: spec.view,
|
|
3914
|
+
name: spec.imported.name,
|
|
3915
|
+
alias: (_a2 = spec.local) != null && _a2.name && spec.imported.name !== spec.local.name ? spec.local.name : spec.imported.name
|
|
3916
|
+
};
|
|
3917
|
+
})) ?? [],
|
|
3918
|
+
injections: ((_b = cellAst.body.injections) == null ? void 0 : _b.map((inj) => {
|
|
3919
|
+
var _a2;
|
|
3920
|
+
return {
|
|
3921
|
+
name: inj.imported.name,
|
|
3922
|
+
alias: ((_a2 = inj.local) == null ? void 0 : _a2.name) ?? inj.imported.name
|
|
3923
|
+
};
|
|
3924
|
+
})) ?? []
|
|
3925
|
+
};
|
|
3926
|
+
}
|
|
3927
|
+
function parseViewExpression(cellStr, cellAst, refs, bodyStr) {
|
|
3928
|
+
var _a, _b;
|
|
3929
|
+
const id = cellAst.id && cellStr.substring(cellAst.id.start, cellAst.id.end);
|
|
3930
|
+
return {
|
|
3931
|
+
type: "viewof",
|
|
3932
|
+
variable: {
|
|
3933
|
+
type: "variable",
|
|
3934
|
+
id,
|
|
3935
|
+
inputs: refs.inputs,
|
|
3936
|
+
func: createFunction(refs, cellAst.async, cellAst.generator, cellAst.body.type === "BlockStatement", bodyStr)
|
|
3937
|
+
},
|
|
3938
|
+
variableValue: {
|
|
3939
|
+
type: "variable",
|
|
3940
|
+
id: (_b = (_a = cellAst == null ? void 0 : cellAst.id) == null ? void 0 : _a.id) == null ? void 0 : _b.name,
|
|
3941
|
+
inputs: ["Generators", id],
|
|
3942
|
+
func: (G, _) => G.input(_)
|
|
3943
|
+
}
|
|
3944
|
+
};
|
|
3945
|
+
}
|
|
3946
|
+
function parseMutableExpression(cellStr, cellAst, refs, bodyStr) {
|
|
3947
|
+
var _a, _b;
|
|
3948
|
+
const id = cellAst.id && cellStr.substring(cellAst.id.start, cellAst.id.end), initialValueId = (_b = (_a = cellAst == null ? void 0 : cellAst.id) == null ? void 0 : _a.id) == null ? void 0 : _b.name, initialId = `initial ${initialValueId}`;
|
|
3949
|
+
return {
|
|
3950
|
+
type: "mutable",
|
|
3951
|
+
initial: {
|
|
3952
|
+
type: "variable",
|
|
3953
|
+
id: initialId,
|
|
3954
|
+
inputs: refs.inputs,
|
|
3955
|
+
func: createFunction(refs, cellAst.async, cellAst.generator, cellAst.body.type === "BlockStatement", bodyStr)
|
|
3956
|
+
},
|
|
3957
|
+
variable: {
|
|
3958
|
+
type: "variable",
|
|
3959
|
+
id,
|
|
3960
|
+
inputs: ["Mutable", initialId],
|
|
3961
|
+
func: (M, _) => new M(_)
|
|
3962
|
+
},
|
|
3963
|
+
variableValue: {
|
|
3964
|
+
type: "variable",
|
|
3965
|
+
id: initialValueId,
|
|
3966
|
+
inputs: [id],
|
|
3967
|
+
func: (_) => _.generator
|
|
3968
|
+
}
|
|
3969
|
+
};
|
|
3970
|
+
}
|
|
3971
|
+
function parseVariableExpression(cellStr, cellAst, refs, bodyStr) {
|
|
3972
|
+
var _a, _b;
|
|
3973
|
+
return {
|
|
3974
|
+
type: "variable",
|
|
3975
|
+
id: cellAst.id && cellStr.substring((_a = cellAst.id) == null ? void 0 : _a.start, (_b = cellAst.id) == null ? void 0 : _b.end),
|
|
3976
|
+
inputs: refs.inputs,
|
|
3977
|
+
func: createFunction(refs, cellAst.async, cellAst.generator, cellAst.body.type === "BlockStatement", bodyStr)
|
|
3978
|
+
};
|
|
3979
|
+
}
|
|
3980
|
+
function parseCell(cellStr, baseUrl) {
|
|
3981
|
+
var _a, _b;
|
|
3982
|
+
const cellAst = parseCell$1(cellStr);
|
|
3983
|
+
let bodyStr = cellAst.body && cellStr.substring(cellAst.body.start, cellAst.body.end);
|
|
3984
|
+
switch ((_a = cellAst.body) == null ? void 0 : _a.type) {
|
|
3985
|
+
case "ImportDeclaration":
|
|
3986
|
+
return parseImportDeclaration(cellAst);
|
|
3987
|
+
case "ImportExpression":
|
|
3988
|
+
switch (cellAst.body.source.type) {
|
|
3989
|
+
case "Literal":
|
|
3990
|
+
bodyStr = `import("${fixRelativeUrl("" + cellAst.body.source.value, baseUrl)}")`;
|
|
3991
|
+
break;
|
|
3992
|
+
default:
|
|
3993
|
+
console.error("Unexpected import value");
|
|
3994
|
+
}
|
|
3995
|
+
}
|
|
3996
|
+
const refs = calcRefs(cellAst, cellStr);
|
|
3997
|
+
switch ((_b = cellAst.id) == null ? void 0 : _b.type) {
|
|
3998
|
+
case "ViewExpression":
|
|
3999
|
+
return parseViewExpression(cellStr, cellAst, refs, bodyStr);
|
|
4000
|
+
case "MutableExpression":
|
|
4001
|
+
return parseMutableExpression(cellStr, cellAst, refs, bodyStr);
|
|
4002
|
+
default:
|
|
4003
|
+
return parseVariableExpression(cellStr, cellAst, refs, bodyStr);
|
|
4004
|
+
}
|
|
4005
|
+
}
|
|
4006
|
+
class Writer {
|
|
4007
|
+
constructor() {
|
|
4008
|
+
__publicField(this, "_files", []);
|
|
4009
|
+
__publicField(this, "_imports", []);
|
|
4010
|
+
__publicField(this, "_functions", []);
|
|
4011
|
+
__publicField(this, "_defines", []);
|
|
4012
|
+
__publicField(this, "_defineUid", 0);
|
|
4013
|
+
__publicField(this, "_functionUid", 0);
|
|
4014
|
+
}
|
|
4015
|
+
toString() {
|
|
4016
|
+
return `${this._imports.join(`
|
|
12
4017
|
`)}
|
|
13
4018
|
|
|
14
4019
|
${this._functions.join(`
|
|
@@ -20,7 +4025,7 @@ export default function define(runtime, observer) {
|
|
|
20
4025
|
|
|
21
4026
|
function toString() { return this.url; }
|
|
22
4027
|
const fileAttachments = new Map([
|
|
23
|
-
${this._files.map(
|
|
4028
|
+
${this._files.map((f) => `["${f.name}", { url: new URL("${f.url}"), mimeType: ${JSON.stringify(f.mime_type)}, toString }]`).join(`,
|
|
24
4029
|
`)}
|
|
25
4030
|
]);
|
|
26
4031
|
main.builtin("FileAttachment", runtime.fileAttachments(name => fileAttachments.get(name)));
|
|
@@ -30,7 +4035,205 @@ export default function define(runtime, observer) {
|
|
|
30
4035
|
|
|
31
4036
|
return main;
|
|
32
4037
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
4038
|
+
`;
|
|
4039
|
+
}
|
|
4040
|
+
files(files) {
|
|
4041
|
+
this._files = [...this._files, ...files];
|
|
4042
|
+
}
|
|
4043
|
+
import(url) {
|
|
4044
|
+
this._imports.push(`import define${++this._defineUid} from "${url}"; `);
|
|
4045
|
+
}
|
|
4046
|
+
importDefine(imp) {
|
|
4047
|
+
const impInjections = imp.injections ?? [], injections = impInjections.map((inj) => inj.name === inj.alias ? `"${inj.name}"` : `{name: "${inj.name}", alias: "${inj.alias}"}`), derive = impInjections.length ? `.derive([${injections.join(", ")}], main)` : "";
|
|
4048
|
+
this._defines.push(`const child${this._defineUid} = runtime.module(define${this._defineUid})${derive};`), (imp.specifiers ?? []).forEach((s) => {
|
|
4049
|
+
this._defines.push(`main.import("${s.name}"${s.alias && s.alias !== s.name ? `, "${s.alias}"` : ""}, child${this._defineUid}); `);
|
|
4050
|
+
});
|
|
4051
|
+
}
|
|
4052
|
+
function(variable) {
|
|
4053
|
+
var _a, _b;
|
|
4054
|
+
let id = variable.id ?? `${++this._functionUid}`;
|
|
4055
|
+
const idParts = id.split(" ");
|
|
4056
|
+
return id = `_${idParts[idParts.length - 1]}`, this._functions.push(`${(_b = (_a = variable.func) == null ? void 0 : _a.toString()) == null ? void 0 : _b.replace("anonymous", `${id}`)}`), id;
|
|
4057
|
+
}
|
|
4058
|
+
define(variable, observable = !0, inlineFunc = !1, funcId) {
|
|
4059
|
+
var _a;
|
|
4060
|
+
funcId = funcId ?? variable.id;
|
|
4061
|
+
const observe = observable ? `.variable(observer(${variable.id ? JSON.stringify(variable.id) : ""}))` : "", id = variable.id ? `${JSON.stringify(variable.id)}, ` : "", variableInputs = variable.inputs ?? [], inputs = variableInputs.length ? `[${variableInputs.map((i) => JSON.stringify(i)).join(", ")}], ` : "", func = inlineFunc ? (_a = variable.func) == null ? void 0 : _a.toString() : funcId;
|
|
4062
|
+
this._defines.push(`main${observe}.define(${id}${inputs}${func});`);
|
|
4063
|
+
}
|
|
4064
|
+
error(msg) {
|
|
4065
|
+
}
|
|
4066
|
+
}
|
|
4067
|
+
async function importFile(relativePath, baseUrl) {
|
|
4068
|
+
const path = fixRelativeUrl(relativePath, baseUrl), content = await fetchEx(path).then((r) => r.text());
|
|
4069
|
+
let notebook2;
|
|
4070
|
+
relativePath.endsWith(".ojsnb") ? notebook2 = JSON.parse(content) : relativePath.endsWith(".ojs") ? notebook2 = ojs2notebook(content) : relativePath.endsWith(".omd") ? notebook2 = omd2notebook(content) : (console.warn(`Unknown file type: ${relativePath}, assuming .ojsnb`), notebook2 = JSON.parse(content));
|
|
4071
|
+
const retVal = compile(notebook2, { baseUrl });
|
|
4072
|
+
return retVal.delete = () => {
|
|
4073
|
+
}, retVal.write = (w) => {
|
|
4074
|
+
w.import(path);
|
|
4075
|
+
}, retVal;
|
|
4076
|
+
}
|
|
4077
|
+
async function importCompiledNotebook(partial) {
|
|
4078
|
+
const url = `https://api.observablehq.com/${partial[0] === "@" ? partial : `d/${partial}`}.js?v=3`;
|
|
4079
|
+
let impMod = {
|
|
4080
|
+
default: function(runtime, inspector) {
|
|
4081
|
+
}
|
|
4082
|
+
};
|
|
4083
|
+
try {
|
|
4084
|
+
impMod = await obfuscatedImport(url);
|
|
4085
|
+
} catch {
|
|
4086
|
+
}
|
|
4087
|
+
const retVal = impMod.default;
|
|
4088
|
+
return retVal.delete = () => {
|
|
4089
|
+
}, retVal.write = (w) => {
|
|
4090
|
+
w.import(url);
|
|
4091
|
+
}, retVal;
|
|
4092
|
+
}
|
|
4093
|
+
async function importNotebook(partial) {
|
|
4094
|
+
const url = `https://api.observablehq.com/document/${partial}`, notebook2 = fetchEx(url).then((r) => r.json()).catch((e) => {
|
|
4095
|
+
console.error(url), console.error(e);
|
|
4096
|
+
}), retVal = compile(await notebook2);
|
|
4097
|
+
return retVal.delete = () => {
|
|
4098
|
+
}, retVal.write = (w) => {
|
|
4099
|
+
w.import(url);
|
|
4100
|
+
}, retVal;
|
|
4101
|
+
}
|
|
4102
|
+
async function createModule(node, parsed, text, { baseUrl, importMode }) {
|
|
4103
|
+
const otherModule = isRelativePath(parsed.src) ? await importFile(parsed.src, baseUrl ?? "") : importMode === "recursive" ? await importNotebook(parsed.src) : await importCompiledNotebook(parsed.src), importVariables = [], variables = [];
|
|
4104
|
+
parsed.specifiers.forEach((spec) => {
|
|
4105
|
+
const viewof = spec.view ? "viewof " : "";
|
|
4106
|
+
importVariables.push(createImportVariable(viewof + spec.name, viewof + spec.alias)), spec.view && importVariables.push(createImportVariable(spec.name, spec.alias));
|
|
4107
|
+
});
|
|
4108
|
+
const retVal = (runtime, main, inspector) => {
|
|
4109
|
+
let mod = runtime.module(otherModule);
|
|
4110
|
+
return parsed.injections.length && (mod = mod.derive(parsed.injections, main)), variables.forEach((v) => v(main, inspector)), importVariables.forEach((v) => v(main, mod)), mod;
|
|
4111
|
+
};
|
|
4112
|
+
return retVal.importVariables = importVariables, retVal.variables = variables, retVal.delete = () => {
|
|
4113
|
+
importVariables.forEach((v) => v.delete()), variables.forEach((v) => v.delete()), otherModule.delete();
|
|
4114
|
+
}, retVal.write = (w) => {
|
|
4115
|
+
otherModule.write(w), w.importDefine(parsed);
|
|
4116
|
+
}, retVal;
|
|
4117
|
+
}
|
|
4118
|
+
function createVariable(node, inspect, name, inputs, definition, inline = !1) {
|
|
4119
|
+
let i, v;
|
|
4120
|
+
const retVal = (module, inspector) => {
|
|
4121
|
+
if (inspect && inspector && (i = inspector(name, node.id)), v = module.variable(i), arguments.length > 1)
|
|
4122
|
+
try {
|
|
4123
|
+
v.define(name, inputs, definition);
|
|
4124
|
+
} catch (e) {
|
|
4125
|
+
console.error(e == null ? void 0 : e.message);
|
|
4126
|
+
}
|
|
4127
|
+
if (node.pinned) {
|
|
4128
|
+
v = inspector ? module.variable(inspector(name, node.id)) : module.variable();
|
|
4129
|
+
try {
|
|
4130
|
+
v.define(void 0, ["md"], (md) => md`\`\`\`js
|
|
4131
|
+
${node.value}
|
|
4132
|
+
\`\`\``);
|
|
4133
|
+
} catch (e) {
|
|
4134
|
+
console.error(e == null ? void 0 : e.message);
|
|
4135
|
+
}
|
|
4136
|
+
}
|
|
4137
|
+
return v;
|
|
4138
|
+
};
|
|
4139
|
+
return retVal.delete = () => {
|
|
4140
|
+
var _a;
|
|
4141
|
+
try {
|
|
4142
|
+
(_a = i == null ? void 0 : i._node) == null || _a.remove();
|
|
4143
|
+
} catch {
|
|
4144
|
+
}
|
|
4145
|
+
i = void 0;
|
|
4146
|
+
try {
|
|
4147
|
+
v == null || v.delete();
|
|
4148
|
+
} catch {
|
|
4149
|
+
}
|
|
4150
|
+
v = void 0;
|
|
4151
|
+
}, retVal.write = (w) => {
|
|
4152
|
+
if (inline)
|
|
4153
|
+
w.define({ id: name, inputs, func: definition }, inspect, !0);
|
|
4154
|
+
else {
|
|
4155
|
+
const id = w.function({ id: name, func: definition });
|
|
4156
|
+
w.define({ id: name, inputs, func: definition }, inspect, !1, id);
|
|
4157
|
+
}
|
|
4158
|
+
}, retVal;
|
|
4159
|
+
}
|
|
4160
|
+
function createImportVariable(name, alias) {
|
|
4161
|
+
let v;
|
|
4162
|
+
const retVal = (main, otherModule) => {
|
|
4163
|
+
v = main.variable(), alias === void 0 ? v.import(name, otherModule) : v.import(name, alias, otherModule);
|
|
4164
|
+
};
|
|
4165
|
+
return retVal.delete = () => {
|
|
4166
|
+
v == null || v.delete();
|
|
4167
|
+
}, retVal;
|
|
4168
|
+
}
|
|
4169
|
+
async function createCell(node, options) {
|
|
4170
|
+
const modules = [], variables = [];
|
|
4171
|
+
try {
|
|
4172
|
+
const text = node.mode && node.mode !== "js" ? `${node.mode}\`${encodeBacktick(node.value)}\`` : node.value, parsedModule = splitModule(text);
|
|
4173
|
+
for (const cell of parsedModule) {
|
|
4174
|
+
const parsed = parseCell(cell.text, options.baseUrl ?? "");
|
|
4175
|
+
switch (parsed.type) {
|
|
4176
|
+
case "import":
|
|
4177
|
+
modules.push(await createModule(node, parsed, cell.text, options));
|
|
4178
|
+
break;
|
|
4179
|
+
case "viewof":
|
|
4180
|
+
variables.push(createVariable(node, !0, parsed.variable.id, parsed.variable.inputs, parsed.variable.func)), variables.push(createVariable(node, !1, parsed.variableValue.id, parsed.variableValue.inputs, parsed.variableValue.func, !0));
|
|
4181
|
+
break;
|
|
4182
|
+
case "mutable":
|
|
4183
|
+
variables.push(createVariable(node, !1, parsed.initial.id, parsed.initial.inputs, parsed.initial.func)), variables.push(createVariable(node, !1, parsed.variable.id, parsed.variable.inputs, parsed.variable.func)), variables.push(createVariable(node, !0, parsed.variableValue.id, parsed.variableValue.inputs, parsed.variableValue.func, !0));
|
|
4184
|
+
break;
|
|
4185
|
+
case "variable":
|
|
4186
|
+
variables.push(createVariable(node, !0, parsed.id, parsed.inputs, parsed.func));
|
|
4187
|
+
break;
|
|
4188
|
+
}
|
|
4189
|
+
}
|
|
4190
|
+
} catch (e) {
|
|
4191
|
+
variables.push(createVariable(node, !0, void 0, [], e.message ?? "Unkown error"));
|
|
4192
|
+
}
|
|
4193
|
+
const retVal = (runtime, main, inspector) => {
|
|
4194
|
+
modules.forEach((imp) => imp(runtime, main, inspector)), variables.forEach((v) => v(main, inspector));
|
|
4195
|
+
};
|
|
4196
|
+
return retVal.id = node.id, retVal.modules = modules, retVal.variables = variables, retVal.delete = () => {
|
|
4197
|
+
variables.forEach((v) => v.delete()), modules.forEach((mod) => mod.delete());
|
|
4198
|
+
}, retVal.write = (w) => {
|
|
4199
|
+
modules.forEach((imp) => imp.write(w)), variables.forEach((v) => v.write(w));
|
|
4200
|
+
}, retVal;
|
|
4201
|
+
}
|
|
4202
|
+
function createFile(file, options) {
|
|
4203
|
+
function toString2() {
|
|
4204
|
+
return globalThis.url ?? "";
|
|
4205
|
+
}
|
|
4206
|
+
return [file.name, { url: new URL(fixRelativeUrl(file.url, options.baseUrl ?? "")), mimeType: file.mime_type, toString: toString2 }];
|
|
4207
|
+
}
|
|
4208
|
+
function notebook(_files = [], _cells = [], { baseUrl = ".", importMode = "precompiled" } = {}) {
|
|
4209
|
+
const files = _files.map((f) => createFile(f, { baseUrl, importMode })), fileAttachments = new Map(files), cells = new Map(_cells.map((c) => [c.id, c])), retVal = (runtime, inspector) => {
|
|
4210
|
+
const main = runtime.module();
|
|
4211
|
+
return main.builtin("FileAttachment", runtime.fileAttachments((name) => fileAttachments.get(name) ?? { url: new URL(fixRelativeUrl(name, baseUrl)), mimeType: null })), main.builtin("fetchEx", fetchEx), cells.forEach((cell) => {
|
|
4212
|
+
cell(runtime, main, inspector);
|
|
4213
|
+
}), main;
|
|
4214
|
+
};
|
|
4215
|
+
return retVal.fileAttachments = fileAttachments, retVal.cells = cells, retVal.set = async (n) => {
|
|
4216
|
+
const cell = await createCell(n, { baseUrl, importMode });
|
|
4217
|
+
return retVal.delete(cell.id), cells.set(cell.id, cell), cell;
|
|
4218
|
+
}, retVal.get = (id) => cells.get(id), retVal.delete = (id) => {
|
|
4219
|
+
const cell = cells.get(id);
|
|
4220
|
+
return cell ? (cell.delete(), cells.delete(id)) : !1;
|
|
4221
|
+
}, retVal.clear = () => {
|
|
4222
|
+
cells.forEach((cell) => cell.delete()), cells.clear();
|
|
4223
|
+
}, retVal.write = (w) => {
|
|
4224
|
+
w.files(_files), cells.forEach((cell) => cell.write(w));
|
|
4225
|
+
}, retVal.toString = (w = new Writer()) => (retVal.write(w), w.toString().trim()), retVal;
|
|
4226
|
+
}
|
|
4227
|
+
async function compile(notebookOrOjs, { baseUrl = ".", importMode = "precompiled" } = {}) {
|
|
4228
|
+
const ojsNotebook = typeof notebookOrOjs == "string" ? ojs2notebook(notebookOrOjs) : notebookOrOjs, _cells = await Promise.all(ojsNotebook.nodes.map((n) => createCell(n, { baseUrl, importMode })));
|
|
4229
|
+
return notebook(ojsNotebook.files, _cells, { baseUrl, importMode });
|
|
4230
|
+
}
|
|
4231
|
+
export {
|
|
4232
|
+
Writer,
|
|
4233
|
+
compile,
|
|
4234
|
+
download,
|
|
4235
|
+
notebook,
|
|
4236
|
+
ojs2notebook,
|
|
4237
|
+
omd2notebook
|
|
4238
|
+
};
|
|
36
4239
|
//# sourceMappingURL=index.js.map
|