ellipsis-js-util
Version:
Tools for using the ellipsis drive js api
2 lines • 708 kB
JavaScript
/*! For license information please see ellipsis-js-util.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.EllipsisUtil=t():e.EllipsisUtil=t()}(self,(()=>(()=>{var e={452:function(e,t,r){var n;e.exports=(n=r(8249),r(8269),r(8214),r(888),r(5109),function(){var e=n,t=e.lib.BlockCipher,r=e.algo,i=[],a=[],o=[],s=[],u=[],c=[],l=[],f=[],p=[],m=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var r=0,n=0;for(t=0;t<256;t++){var h=n^n<<1^n<<2^n<<3^n<<4;h=h>>>8^255&h^99,i[r]=h,a[h]=r;var d=e[r],g=e[d],v=e[g],y=257*e[h]^16843008*h;o[r]=y<<24|y>>>8,s[r]=y<<16|y>>>16,u[r]=y<<8|y>>>24,c[r]=y,y=16843009*v^65537*g^257*d^16843008*r,l[h]=y<<24|y>>>8,f[h]=y<<16|y>>>16,p[h]=y<<8|y>>>24,m[h]=y,r?(r=d^e[e[e[v^d]]],n^=e[e[n]]):r=n=1}}();var h=[0,1,2,4,8,16,32,64,128,27,54],d=r.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,n=4*((this._nRounds=r+6)+1),a=this._keySchedule=[],o=0;o<n;o++)o<r?a[o]=t[o]:(c=a[o-1],o%r?r>6&&o%r==4&&(c=i[c>>>24]<<24|i[c>>>16&255]<<16|i[c>>>8&255]<<8|i[255&c]):(c=i[(c=c<<8|c>>>24)>>>24]<<24|i[c>>>16&255]<<16|i[c>>>8&255]<<8|i[255&c],c^=h[o/r|0]<<24),a[o]=a[o-r]^c);for(var s=this._invKeySchedule=[],u=0;u<n;u++){if(o=n-u,u%4)var c=a[o];else c=a[o-4];s[u]=u<4||o<=4?c:l[i[c>>>24]]^f[i[c>>>16&255]]^p[i[c>>>8&255]]^m[i[255&c]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,s,u,c,i)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,l,f,p,m,a),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,i,a,o,s){for(var u=this._nRounds,c=e[t]^r[0],l=e[t+1]^r[1],f=e[t+2]^r[2],p=e[t+3]^r[3],m=4,h=1;h<u;h++){var d=n[c>>>24]^i[l>>>16&255]^a[f>>>8&255]^o[255&p]^r[m++],g=n[l>>>24]^i[f>>>16&255]^a[p>>>8&255]^o[255&c]^r[m++],v=n[f>>>24]^i[p>>>16&255]^a[c>>>8&255]^o[255&l]^r[m++],y=n[p>>>24]^i[c>>>16&255]^a[l>>>8&255]^o[255&f]^r[m++];c=d,l=g,f=v,p=y}d=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[f>>>8&255]<<8|s[255&p])^r[m++],g=(s[l>>>24]<<24|s[f>>>16&255]<<16|s[p>>>8&255]<<8|s[255&c])^r[m++],v=(s[f>>>24]<<24|s[p>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^r[m++],y=(s[p>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&f])^r[m++],e[t]=d,e[t+1]=g,e[t+2]=v,e[t+3]=y},keySize:8});e.AES=t._createHelper(d)}(),n.AES)},7407:function(e,t,r){var n;e.exports=(n=r(8249),r(8269),r(8214),r(888),r(5109),function(){var e=n,t=e.lib.BlockCipher,r=e.algo;const i=16,a=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],o=[[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946],[1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055],[3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504],[976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462]];var s={pbox:[],sbox:[]};function u(e,t){let r=t>>24&255,n=t>>16&255,i=t>>8&255,a=255&t,o=e.sbox[0][r]+e.sbox[1][n];return o^=e.sbox[2][i],o+=e.sbox[3][a],o}function c(e,t,r){let n,a=t,o=r;for(let t=0;t<i;++t)a^=e.pbox[t],o=u(e,a)^o,n=a,a=o,o=n;return n=a,a=o,o=n,o^=e.pbox[i],a^=e.pbox[i+1],{left:a,right:o}}var l=r.Blowfish=t.extend({_doReset:function(){if(this._keyPriorReset!==this._key){var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4;!function(e,t,r){for(let t=0;t<4;t++){e.sbox[t]=[];for(let r=0;r<256;r++)e.sbox[t][r]=o[t][r]}let n=0;for(let o=0;o<i+2;o++)e.pbox[o]=a[o]^t[n],n++,n>=r&&(n=0);let s=0,u=0,l=0;for(let t=0;t<i+2;t+=2)l=c(e,s,u),s=l.left,u=l.right,e.pbox[t]=s,e.pbox[t+1]=u;for(let t=0;t<4;t++)for(let r=0;r<256;r+=2)l=c(e,s,u),s=l.left,u=l.right,e.sbox[t][r]=s,e.sbox[t][r+1]=u}(s,t,r)}},encryptBlock:function(e,t){var r=c(s,e[t],e[t+1]);e[t]=r.left,e[t+1]=r.right},decryptBlock:function(e,t){var r=function(e,t,r){let n,a=t,o=r;for(let t=i+1;t>1;--t)a^=e.pbox[t],o=u(e,a)^o,n=a,a=o,o=n;return n=a,a=o,o=n,o^=e.pbox[1],a^=e.pbox[0],{left:a,right:o}}(s,e[t],e[t+1]);e[t]=r.left,e[t+1]=r.right},blockSize:2,keySize:4,ivSize:2});e.Blowfish=t._createHelper(l)}(),n.Blowfish)},5109:function(e,t,r){var n,i,a,o,s,u,c,l,f,p,m,h,d,g,v,y,x,b,w;e.exports=(n=r(8249),r(888),void(n.lib.Cipher||(i=n,a=i.lib,o=a.Base,s=a.WordArray,u=a.BufferedBlockAlgorithm,c=i.enc,c.Utf8,l=c.Base64,f=i.algo.EvpKDF,p=a.Cipher=u.extend({cfg:o.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){u.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?w:x}return function(t){return{encrypt:function(r,n,i){return e(n).encrypt(t,r,n,i)},decrypt:function(r,n,i){return e(n).decrypt(t,r,n,i)}}}}()}),a.StreamCipher=p.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),m=i.mode={},h=a.BlockCipherMode=o.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),d=m.CBC=function(){var e=h.extend();function t(e,t,r){var n,i=this._iv;i?(n=i,this._iv=void 0):n=this._prevBlock;for(var a=0;a<r;a++)e[t+a]^=n[a]}return e.Encryptor=e.extend({processBlock:function(e,r){var n=this._cipher,i=n.blockSize;t.call(this,e,r,i),n.encryptBlock(e,r),this._prevBlock=e.slice(r,r+i)}}),e.Decryptor=e.extend({processBlock:function(e,r){var n=this._cipher,i=n.blockSize,a=e.slice(r,r+i);n.decryptBlock(e,r),t.call(this,e,r,i),this._prevBlock=a}}),e}(),g=(i.pad={}).Pkcs7={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,a=[],o=0;o<n;o+=4)a.push(i);var u=s.create(a,n);e.concat(u)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},a.BlockCipher=p.extend({cfg:p.cfg.extend({mode:d,padding:g}),reset:function(){var e;p.reset.call(this);var t=this.cfg,r=t.iv,n=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=n.createEncryptor:(e=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,r&&r.words):(this._mode=e.call(n,this,r&&r.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4}),v=a.CipherParams=o.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),y=(i.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext,r=e.salt;return(r?s.create([1398893684,1701076831]).concat(r).concat(t):t).toString(l)},parse:function(e){var t,r=l.parse(e),n=r.words;return 1398893684==n[0]&&1701076831==n[1]&&(t=s.create(n.slice(2,4)),n.splice(0,4),r.sigBytes-=16),v.create({ciphertext:r,salt:t})}},x=a.SerializableCipher=o.extend({cfg:o.extend({format:y}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var i=e.createEncryptor(r,n),a=i.finalize(t),o=i.cfg;return v.create({ciphertext:a,key:r,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),b=(i.kdf={}).OpenSSL={execute:function(e,t,r,n,i){if(n||(n=s.random(8)),i)a=f.create({keySize:t+r,hasher:i}).compute(e,n);else var a=f.create({keySize:t+r}).compute(e,n);var o=s.create(a.words.slice(t),4*r);return a.sigBytes=4*t,v.create({key:a,iv:o,salt:n})}},w=a.PasswordBasedCipher=x.extend({cfg:x.cfg.extend({kdf:b}),encrypt:function(e,t,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,e.keySize,e.ivSize,n.salt,n.hasher);n.iv=i.iv;var a=x.encrypt.call(this,e,t,i.key,n);return a.mixIn(i),a},decrypt:function(e,t,r,n){n=this.cfg.extend(n),t=this._parse(t,n.format);var i=n.kdf.execute(r,e.keySize,e.ivSize,t.salt,n.hasher);return n.iv=i.iv,x.decrypt.call(this,e,t,i.key,n)}}))))},8249:function(e,t,r){var n;e.exports=(n=n||function(e,t){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(n=globalThis.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==r.g&&r.g.crypto&&(n=r.g.crypto),!n)try{n=r(2480)}catch(e){}var i=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),o={},s=o.lib={},u=s.Base={extend:function(e){var t=a(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=s.WordArray=u.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||f).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var a=0;a<i;a++){var o=r[a>>>2]>>>24-a%4*8&255;t[n+a>>>2]|=o<<24-(n+a)%4*8}else for(var s=0;s<i;s+=4)t[n+s>>>2]=r[s>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=u.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(i());return new c.init(t,e)}}),l=o.enc={},f=l.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var a=t[i>>>2]>>>24-i%4*8&255;n.push((a>>>4).toString(16)),n.push((15&a).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new c.init(r,t/2)}},p=l.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var a=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(a))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new c.init(r,t)}},m=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(p.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return p.parse(unescape(encodeURIComponent(e)))}},h=s.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=m.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,i=n.words,a=n.sigBytes,o=this.blockSize,s=a/(4*o),u=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*o,l=e.min(4*u,a);if(u){for(var f=0;f<u;f+=o)this._doProcessBlock(i,f);r=i.splice(0,u),n.sigBytes-=l}return new c.init(r,l)},clone:function(){var e=u.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),d=(s.Hasher=h.extend({cfg:u.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new d.HMAC.init(e,r).finalize(t)}}}),o.algo={});return o}(Math),n)},8269:function(e,t,r){var n,i,a;e.exports=(n=r(8249),a=(i=n).lib.WordArray,i.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],a=0;a<r;a+=3)for(var o=(t[a>>>2]>>>24-a%4*8&255)<<16|(t[a+1>>>2]>>>24-(a+1)%4*8&255)<<8|t[a+2>>>2]>>>24-(a+2)%4*8&255,s=0;s<4&&a+.75*s<r;s++)i.push(n.charAt(o>>>6*(3-s)&63));var u=n.charAt(64);if(u)for(;i.length%4;)i.push(u);return i.join("")},parse:function(e){var t=e.length,r=this._map,n=this._reverseMap;if(!n){n=this._reverseMap=[];for(var i=0;i<r.length;i++)n[r.charCodeAt(i)]=i}var o=r.charAt(64);if(o){var s=e.indexOf(o);-1!==s&&(t=s)}return function(e,t,r){for(var n=[],i=0,o=0;o<t;o++)if(o%4){var s=r[e.charCodeAt(o-1)]<<o%4*2|r[e.charCodeAt(o)]>>>6-o%4*2;n[i>>>2]|=s<<24-i%4*8,i++}return a.create(n,i)}(e,t,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},n.enc.Base64)},3786:function(e,t,r){var n,i,a;e.exports=(n=r(8249),a=(i=n).lib.WordArray,i.enc.Base64url={stringify:function(e,t){void 0===t&&(t=!0);var r=e.words,n=e.sigBytes,i=t?this._safe_map:this._map;e.clamp();for(var a=[],o=0;o<n;o+=3)for(var s=(r[o>>>2]>>>24-o%4*8&255)<<16|(r[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|r[o+2>>>2]>>>24-(o+2)%4*8&255,u=0;u<4&&o+.75*u<n;u++)a.push(i.charAt(s>>>6*(3-u)&63));var c=i.charAt(64);if(c)for(;a.length%4;)a.push(c);return a.join("")},parse:function(e,t){void 0===t&&(t=!0);var r=e.length,n=t?this._safe_map:this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o<n.length;o++)i[n.charCodeAt(o)]=o}var s=n.charAt(64);if(s){var u=e.indexOf(s);-1!==u&&(r=u)}return function(e,t,r){for(var n=[],i=0,o=0;o<t;o++)if(o%4){var s=r[e.charCodeAt(o-1)]<<o%4*2|r[e.charCodeAt(o)]>>>6-o%4*2;n[i>>>2]|=s<<24-i%4*8,i++}return a.create(n,i)}(e,r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"},n.enc.Base64url)},298:function(e,t,r){var n;e.exports=(n=r(8249),function(){var e=n,t=e.lib.WordArray,r=e.enc;function i(e){return e<<8&4278255360|e>>>8&16711935}r.Utf16=r.Utf16BE={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i+=2){var a=t[i>>>2]>>>16-i%4*8&65535;n.push(String.fromCharCode(a))}return n.join("")},parse:function(e){for(var r=e.length,n=[],i=0;i<r;i++)n[i>>>1]|=e.charCodeAt(i)<<16-i%2*16;return t.create(n,2*r)}},r.Utf16LE={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],a=0;a<r;a+=2){var o=i(t[a>>>2]>>>16-a%4*8&65535);n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var r=e.length,n=[],a=0;a<r;a++)n[a>>>1]|=i(e.charCodeAt(a)<<16-a%2*16);return t.create(n,2*r)}}}(),n.enc.Utf16)},888:function(e,t,r){var n,i,a,o,s,u,c,l;e.exports=(l=r(8249),r(2783),r(9824),a=(i=(n=l).lib).Base,o=i.WordArray,u=(s=n.algo).MD5,c=s.EvpKDF=a.extend({cfg:a.extend({keySize:4,hasher:u,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r,n=this.cfg,i=n.hasher.create(),a=o.create(),s=a.words,u=n.keySize,c=n.iterations;s.length<u;){r&&i.update(r),r=i.update(e).finalize(t),i.reset();for(var l=1;l<c;l++)r=i.finalize(r),i.reset();a.concat(r)}return a.sigBytes=4*u,a}}),n.EvpKDF=function(e,t,r){return c.create(r).compute(e,t)},l.EvpKDF)},2209:function(e,t,r){var n,i,a,o;e.exports=(o=r(8249),r(5109),i=(n=o).lib.CipherParams,a=n.enc.Hex,n.format.Hex={stringify:function(e){return e.ciphertext.toString(a)},parse:function(e){var t=a.parse(e);return i.create({ciphertext:t})}},o.format.Hex)},9824:function(e,t,r){var n,i,a;e.exports=(i=(n=r(8249)).lib.Base,a=n.enc.Utf8,void(n.algo.HMAC=i.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=a.parse(t));var r=e.blockSize,n=4*r;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),s=i.words,u=o.words,c=0;c<r;c++)s[c]^=1549556828,u[c]^=909522486;i.sigBytes=o.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}})))},1354:function(e,t,r){var n;e.exports=(n=r(8249),r(4938),r(4433),r(298),r(8269),r(3786),r(8214),r(2783),r(2153),r(7792),r(34),r(7460),r(3327),r(706),r(9824),r(2112),r(888),r(5109),r(8568),r(4242),r(9968),r(7660),r(1148),r(3615),r(2807),r(1077),r(6475),r(6991),r(2209),r(452),r(4253),r(1857),r(4454),r(3974),r(7407),n)},4433:function(e,t,r){var n;e.exports=(n=r(8249),function(){if("function"==typeof ArrayBuffer){var e=n.lib.WordArray,t=e.init,r=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,n=[],i=0;i<r;i++)n[i>>>2]|=e[i]<<24-i%4*8;t.call(this,n,r)}else t.apply(this,arguments)};r.prototype=e}}(),n.lib.WordArray)},8214:function(e,t,r){var n;e.exports=(n=r(8249),function(e){var t=n,r=t.lib,i=r.WordArray,a=r.Hasher,o=t.algo,s=[];!function(){for(var t=0;t<64;t++)s[t]=4294967296*e.abs(e.sin(t+1))|0}();var u=o.MD5=a.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var a=this._hash.words,o=e[t+0],u=e[t+1],m=e[t+2],h=e[t+3],d=e[t+4],g=e[t+5],v=e[t+6],y=e[t+7],x=e[t+8],b=e[t+9],w=e[t+10],D=e[t+11],N=e[t+12],E=e[t+13],A=e[t+14],S=e[t+15],C=a[0],M=a[1],F=a[2],T=a[3];C=c(C,M,F,T,o,7,s[0]),T=c(T,C,M,F,u,12,s[1]),F=c(F,T,C,M,m,17,s[2]),M=c(M,F,T,C,h,22,s[3]),C=c(C,M,F,T,d,7,s[4]),T=c(T,C,M,F,g,12,s[5]),F=c(F,T,C,M,v,17,s[6]),M=c(M,F,T,C,y,22,s[7]),C=c(C,M,F,T,x,7,s[8]),T=c(T,C,M,F,b,12,s[9]),F=c(F,T,C,M,w,17,s[10]),M=c(M,F,T,C,D,22,s[11]),C=c(C,M,F,T,N,7,s[12]),T=c(T,C,M,F,E,12,s[13]),F=c(F,T,C,M,A,17,s[14]),C=l(C,M=c(M,F,T,C,S,22,s[15]),F,T,u,5,s[16]),T=l(T,C,M,F,v,9,s[17]),F=l(F,T,C,M,D,14,s[18]),M=l(M,F,T,C,o,20,s[19]),C=l(C,M,F,T,g,5,s[20]),T=l(T,C,M,F,w,9,s[21]),F=l(F,T,C,M,S,14,s[22]),M=l(M,F,T,C,d,20,s[23]),C=l(C,M,F,T,b,5,s[24]),T=l(T,C,M,F,A,9,s[25]),F=l(F,T,C,M,h,14,s[26]),M=l(M,F,T,C,x,20,s[27]),C=l(C,M,F,T,E,5,s[28]),T=l(T,C,M,F,m,9,s[29]),F=l(F,T,C,M,y,14,s[30]),C=f(C,M=l(M,F,T,C,N,20,s[31]),F,T,g,4,s[32]),T=f(T,C,M,F,x,11,s[33]),F=f(F,T,C,M,D,16,s[34]),M=f(M,F,T,C,A,23,s[35]),C=f(C,M,F,T,u,4,s[36]),T=f(T,C,M,F,d,11,s[37]),F=f(F,T,C,M,y,16,s[38]),M=f(M,F,T,C,w,23,s[39]),C=f(C,M,F,T,E,4,s[40]),T=f(T,C,M,F,o,11,s[41]),F=f(F,T,C,M,h,16,s[42]),M=f(M,F,T,C,v,23,s[43]),C=f(C,M,F,T,b,4,s[44]),T=f(T,C,M,F,N,11,s[45]),F=f(F,T,C,M,S,16,s[46]),C=p(C,M=f(M,F,T,C,m,23,s[47]),F,T,o,6,s[48]),T=p(T,C,M,F,y,10,s[49]),F=p(F,T,C,M,A,15,s[50]),M=p(M,F,T,C,g,21,s[51]),C=p(C,M,F,T,N,6,s[52]),T=p(T,C,M,F,h,10,s[53]),F=p(F,T,C,M,w,15,s[54]),M=p(M,F,T,C,u,21,s[55]),C=p(C,M,F,T,x,6,s[56]),T=p(T,C,M,F,S,10,s[57]),F=p(F,T,C,M,v,15,s[58]),M=p(M,F,T,C,E,21,s[59]),C=p(C,M,F,T,d,6,s[60]),T=p(T,C,M,F,D,10,s[61]),F=p(F,T,C,M,m,15,s[62]),M=p(M,F,T,C,b,21,s[63]),a[0]=a[0]+C|0,a[1]=a[1]+M|0,a[2]=a[2]+F|0,a[3]=a[3]+T|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var a=e.floor(n/4294967296),o=n;r[15+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),r[14+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),t.sigBytes=4*(r.length+1),this._process();for(var s=this._hash,u=s.words,c=0;c<4;c++){var l=u[c];u[c]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return s},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}});function c(e,t,r,n,i,a,o){var s=e+(t&r|~t&n)+i+o;return(s<<a|s>>>32-a)+t}function l(e,t,r,n,i,a,o){var s=e+(t&n|r&~n)+i+o;return(s<<a|s>>>32-a)+t}function f(e,t,r,n,i,a,o){var s=e+(t^r^n)+i+o;return(s<<a|s>>>32-a)+t}function p(e,t,r,n,i,a,o){var s=e+(r^(t|~n))+i+o;return(s<<a|s>>>32-a)+t}t.MD5=a._createHelper(u),t.HmacMD5=a._createHmacHelper(u)}(Math),n.MD5)},8568:function(e,t,r){var n;e.exports=(n=r(8249),r(5109),n.mode.CFB=function(){var e=n.lib.BlockCipherMode.extend();function t(e,t,r,n){var i,a=this._iv;a?(i=a.slice(0),this._iv=void 0):i=this._prevBlock,n.encryptBlock(i,0);for(var o=0;o<r;o++)e[t+o]^=i[o]}return e.Encryptor=e.extend({processBlock:function(e,r){var n=this._cipher,i=n.blockSize;t.call(this,e,r,i,n),this._prevBlock=e.slice(r,r+i)}}),e.Decryptor=e.extend({processBlock:function(e,r){var n=this._cipher,i=n.blockSize,a=e.slice(r,r+i);t.call(this,e,r,i,n),this._prevBlock=a}}),e}(),n.mode.CFB)},9968:function(e,t,r){var n;e.exports=(n=r(8249),r(5109),n.mode.CTRGladman=function(){var e=n.lib.BlockCipherMode.extend();function t(e){if(255==(e>>24&255)){var t=e>>16&255,r=e>>8&255,n=255&e;255===t?(t=0,255===r?(r=0,255===n?n=0:++n):++r):++t,e=0,e+=t<<16,e+=r<<8,e+=n}else e+=1<<24;return e}var r=e.Encryptor=e.extend({processBlock:function(e,r){var n=this._cipher,i=n.blockSize,a=this._iv,o=this._counter;a&&(o=this._counter=a.slice(0),this._iv=void 0),function(e){0===(e[0]=t(e[0]))&&(e[1]=t(e[1]))}(o);var s=o.slice(0);n.encryptBlock(s,0);for(var u=0;u<i;u++)e[r+u]^=s[u]}});return e.Decryptor=r,e}(),n.mode.CTRGladman)},4242:function(e,t,r){var n,i,a;e.exports=(a=r(8249),r(5109),a.mode.CTR=(i=(n=a.lib.BlockCipherMode.extend()).Encryptor=n.extend({processBlock:function(e,t){var r=this._cipher,n=r.blockSize,i=this._iv,a=this._counter;i&&(a=this._counter=i.slice(0),this._iv=void 0);var o=a.slice(0);r.encryptBlock(o,0),a[n-1]=a[n-1]+1|0;for(var s=0;s<n;s++)e[t+s]^=o[s]}}),n.Decryptor=i,n),a.mode.CTR)},1148:function(e,t,r){var n,i;e.exports=(i=r(8249),r(5109),i.mode.ECB=((n=i.lib.BlockCipherMode.extend()).Encryptor=n.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),n.Decryptor=n.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),n),i.mode.ECB)},7660:function(e,t,r){var n,i,a;e.exports=(a=r(8249),r(5109),a.mode.OFB=(i=(n=a.lib.BlockCipherMode.extend()).Encryptor=n.extend({processBlock:function(e,t){var r=this._cipher,n=r.blockSize,i=this._iv,a=this._keystream;i&&(a=this._keystream=i.slice(0),this._iv=void 0),r.encryptBlock(a,0);for(var o=0;o<n;o++)e[t+o]^=a[o]}}),n.Decryptor=i,n),a.mode.OFB)},3615:function(e,t,r){var n;e.exports=(n=r(8249),r(5109),n.pad.AnsiX923={pad:function(e,t){var r=e.sigBytes,n=4*t,i=n-r%n,a=r+i-1;e.clamp(),e.words[a>>>2]|=i<<24-a%4*8,e.sigBytes+=i},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},n.pad.Ansix923)},2807:function(e,t,r){var n;e.exports=(n=r(8249),r(5109),n.pad.Iso10126={pad:function(e,t){var r=4*t,i=r-e.sigBytes%r;e.concat(n.lib.WordArray.random(i-1)).concat(n.lib.WordArray.create([i<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},n.pad.Iso10126)},1077:function(e,t,r){var n;e.exports=(n=r(8249),r(5109),n.pad.Iso97971={pad:function(e,t){e.concat(n.lib.WordArray.create([2147483648],1)),n.pad.ZeroPadding.pad(e,t)},unpad:function(e){n.pad.ZeroPadding.unpad(e),e.sigBytes--}},n.pad.Iso97971)},6991:function(e,t,r){var n;e.exports=(n=r(8249),r(5109),n.pad.NoPadding={pad:function(){},unpad:function(){}},n.pad.NoPadding)},6475:function(e,t,r){var n;e.exports=(n=r(8249),r(5109),n.pad.ZeroPadding={pad:function(e,t){var r=4*t;e.clamp(),e.sigBytes+=r-(e.sigBytes%r||r)},unpad:function(e){var t=e.words,r=e.sigBytes-1;for(r=e.sigBytes-1;r>=0;r--)if(t[r>>>2]>>>24-r%4*8&255){e.sigBytes=r+1;break}}},n.pad.ZeroPadding)},2112:function(e,t,r){var n,i,a,o,s,u,c,l,f;e.exports=(f=r(8249),r(2153),r(9824),a=(i=(n=f).lib).Base,o=i.WordArray,u=(s=n.algo).SHA256,c=s.HMAC,l=s.PBKDF2=a.extend({cfg:a.extend({keySize:4,hasher:u,iterations:25e4}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r=this.cfg,n=c.create(r.hasher,e),i=o.create(),a=o.create([1]),s=i.words,u=a.words,l=r.keySize,f=r.iterations;s.length<l;){var p=n.update(t).finalize(a);n.reset();for(var m=p.words,h=m.length,d=p,g=1;g<f;g++){d=n.finalize(d),n.reset();for(var v=d.words,y=0;y<h;y++)m[y]^=v[y]}i.concat(p),u[0]++}return i.sigBytes=4*l,i}}),n.PBKDF2=function(e,t,r){return l.create(r).compute(e,t)},f.PBKDF2)},3974:function(e,t,r){var n;e.exports=(n=r(8249),r(8269),r(8214),r(888),r(5109),function(){var e=n,t=e.lib.StreamCipher,r=e.algo,i=[],a=[],o=[],s=r.RabbitLegacy=t.extend({_doReset:function(){var e=this._key.words,t=this.cfg.iv,r=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],n=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var i=0;i<4;i++)u.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(t){var a=t.words,o=a[0],s=a[1],c=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),l=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=c>>>16|4294901760&l,p=l<<16|65535&c;for(n[0]^=c,n[1]^=f,n[2]^=l,n[3]^=p,n[4]^=c,n[5]^=f,n[6]^=l,n[7]^=p,i=0;i<4;i++)u.call(this)}},_doProcessBlock:function(e,t){var r=this._X;u.call(this),i[0]=r[0]^r[5]>>>16^r[3]<<16,i[1]=r[2]^r[7]>>>16^r[5]<<16,i[2]=r[4]^r[1]>>>16^r[7]<<16,i[3]=r[6]^r[3]>>>16^r[1]<<16;for(var n=0;n<4;n++)i[n]=16711935&(i[n]<<8|i[n]>>>24)|4278255360&(i[n]<<24|i[n]>>>8),e[t+n]^=i[n]},blockSize:4,ivSize:2});function u(){for(var e=this._X,t=this._C,r=0;r<8;r++)a[r]=t[r];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<a[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<a[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<a[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<a[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<a[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<a[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<a[6]>>>0?1:0)|0,this._b=t[7]>>>0<a[7]>>>0?1:0,r=0;r<8;r++){var n=e[r]+t[r],i=65535&n,s=n>>>16,u=((i*i>>>17)+i*s>>>15)+s*s,c=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=u^c}e[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,e[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,e[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,e[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,e[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,e[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,e[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,e[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.RabbitLegacy=t._createHelper(s)}(),n.RabbitLegacy)},4454:function(e,t,r){var n;e.exports=(n=r(8249),r(8269),r(8214),r(888),r(5109),function(){var e=n,t=e.lib.StreamCipher,r=e.algo,i=[],a=[],o=[],s=r.Rabbit=t.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,r=0;r<4;r++)e[r]=16711935&(e[r]<<8|e[r]>>>24)|4278255360&(e[r]<<24|e[r]>>>8);var n=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],i=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];for(this._b=0,r=0;r<4;r++)u.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(t){var a=t.words,o=a[0],s=a[1],c=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),l=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=c>>>16|4294901760&l,p=l<<16|65535&c;for(i[0]^=c,i[1]^=f,i[2]^=l,i[3]^=p,i[4]^=c,i[5]^=f,i[6]^=l,i[7]^=p,r=0;r<4;r++)u.call(this)}},_doProcessBlock:function(e,t){var r=this._X;u.call(this),i[0]=r[0]^r[5]>>>16^r[3]<<16,i[1]=r[2]^r[7]>>>16^r[5]<<16,i[2]=r[4]^r[1]>>>16^r[7]<<16,i[3]=r[6]^r[3]>>>16^r[1]<<16;for(var n=0;n<4;n++)i[n]=16711935&(i[n]<<8|i[n]>>>24)|4278255360&(i[n]<<24|i[n]>>>8),e[t+n]^=i[n]},blockSize:4,ivSize:2});function u(){for(var e=this._X,t=this._C,r=0;r<8;r++)a[r]=t[r];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<a[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<a[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<a[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<a[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<a[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<a[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<a[6]>>>0?1:0)|0,this._b=t[7]>>>0<a[7]>>>0?1:0,r=0;r<8;r++){var n=e[r]+t[r],i=65535&n,s=n>>>16,u=((i*i>>>17)+i*s>>>15)+s*s,c=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=u^c}e[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,e[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,e[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,e[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,e[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,e[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,e[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,e[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.Rabbit=t._createHelper(s)}(),n.Rabbit)},1857:function(e,t,r){var n;e.exports=(n=r(8249),r(8269),r(8214),r(888),r(5109),function(){var e=n,t=e.lib.StreamCipher,r=e.algo,i=r.RC4=t.extend({_doReset:function(){for(var e=this._key,t=e.words,r=e.sigBytes,n=this._S=[],i=0;i<256;i++)n[i]=i;i=0;for(var a=0;i<256;i++){var o=i%r,s=t[o>>>2]>>>24-o%4*8&255;a=(a+n[i]+s)%256;var u=n[i];n[i]=n[a],n[a]=u}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=a.call(this)},keySize:8,ivSize:0});function a(){for(var e=this._S,t=this._i,r=this._j,n=0,i=0;i<4;i++){r=(r+e[t=(t+1)%256])%256;var a=e[t];e[t]=e[r],e[r]=a,n|=e[(e[t]+e[r])%256]<<24-8*i}return this._i=t,this._j=r,n}e.RC4=t._createHelper(i);var o=r.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)a.call(this)}});e.RC4Drop=t._createHelper(o)}(),n.RC4)},706:function(e,t,r){var n;e.exports=(n=r(8249),function(e){var t=n,r=t.lib,i=r.WordArray,a=r.Hasher,o=t.algo,s=i.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),u=i.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),c=i.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),l=i.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),f=i.create([0,1518500249,1859775393,2400959708,2840853838]),p=i.create([1352829926,1548603684,1836072691,2053994217,0]),m=o.RIPEMD160=a.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var a,o,m,b,w,D,N,E,A,S,C,M=this._hash.words,F=f.words,T=p.words,_=s.words,B=u.words,O=c.words,k=l.words;for(D=a=M[0],N=o=M[1],E=m=M[2],A=b=M[3],S=w=M[4],r=0;r<80;r+=1)C=a+e[t+_[r]]|0,C+=r<16?h(o,m,b)+F[0]:r<32?d(o,m,b)+F[1]:r<48?g(o,m,b)+F[2]:r<64?v(o,m,b)+F[3]:y(o,m,b)+F[4],C=(C=x(C|=0,O[r]))+w|0,a=w,w=b,b=x(m,10),m=o,o=C,C=D+e[t+B[r]]|0,C+=r<16?y(N,E,A)+T[0]:r<32?v(N,E,A)+T[1]:r<48?g(N,E,A)+T[2]:r<64?d(N,E,A)+T[3]:h(N,E,A)+T[4],C=(C=x(C|=0,k[r]))+S|0,D=S,S=A,A=x(E,10),E=N,N=C;C=M[1]+m+A|0,M[1]=M[2]+b+S|0,M[2]=M[3]+w+D|0,M[3]=M[4]+a+N|0,M[4]=M[0]+o+E|0,M[0]=C},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),e.sigBytes=4*(t.length+1),this._process();for(var i=this._hash,a=i.words,o=0;o<5;o++){var s=a[o];a[o]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}return i},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}});function h(e,t,r){return e^t^r}function d(e,t,r){return e&t|~e&r}function g(e,t,r){return(e|~t)^r}function v(e,t,r){return e&r|t&~r}function y(e,t,r){return e^(t|~r)}function x(e,t){return e<<t|e>>>32-t}t.RIPEMD160=a._createHelper(m),t.HmacRIPEMD160=a._createHmacHelper(m)}(Math),n.RIPEMD160)},2783:function(e,t,r){var n,i,a,o,s,u,c,l;e.exports=(i=(n=l=r(8249)).lib,a=i.WordArray,o=i.Hasher,s=n.algo,u=[],c=s.SHA1=o.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],a=r[2],o=r[3],s=r[4],c=0;c<80;c++){if(c<16)u[c]=0|e[t+c];else{var l=u[c-3]^u[c-8]^u[c-14]^u[c-16];u[c]=l<<1|l>>>31}var f=(n<<5|n>>>27)+s+u[c];f+=c<20?1518500249+(i&a|~i&o):c<40?1859775393+(i^a^o):c<60?(i&a|i&o|a&o)-1894007588:(i^a^o)-899497514,s=o,o=a,a=i<<30|i>>>2,i=n,n=f}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+a|0,r[3]=r[3]+o|0,r[4]=r[4]+s|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}}),n.SHA1=o._createHelper(c),n.HmacSHA1=o._createHmacHelper(c),l.SHA1)},7792:function(e,t,r){var n,i,a,o,s,u;e.exports=(u=r(8249),r(2153),i=(n=u).lib.WordArray,a=n.algo,o=a.SHA256,s=a.SHA224=o.extend({_doReset:function(){this._hash=new i.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var e=o._doFinalize.call(this);return e.sigBytes-=4,e}}),n.SHA224=o._createHelper(s),n.HmacSHA224=o._createHmacHelper(s),u.SHA224)},2153:function(e,t,r){var n;e.exports=(n=r(8249),function(e){var t=n,r=t.lib,i=r.WordArray,a=r.Hasher,o=t.algo,s=[],u=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var n=2,i=0;i<64;)t(n)&&(i<8&&(s[i]=r(e.pow(n,.5))),u[i]=r(e.pow(n,1/3)),i++),n++}();var c=[],l=o.SHA256=a.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],a=r[2],o=r[3],s=r[4],l=r[5],f=r[6],p=r[7],m=0;m<64;m++){if(m<16)c[m]=0|e[t+m];else{var h=c[m-15],d=(h<<25|h>>>7)^(h<<14|h>>>18)^h>>>3,g=c[m-2],v=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;c[m]=d+c[m-7]+v+c[m-16]}var y=n&i^n&a^i&a,x=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),b=p+((s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25))+(s&l^~s&f)+u[m]+c[m];p=f,f=l,l=s,s=o+b|0,o=a,a=i,i=n,n=b+(x+y)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+a|0,r[3]=r[3]+o|0,r[4]=r[4]+s|0,r[5]=r[5]+l|0,r[6]=r[6]+f|0,r[7]=r[7]+p|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=a._createHelper(l),t.HmacSHA256=a._createHmacHelper(l)}(Math),n.SHA256)},3327:function(e,t,r){var n;e.exports=(n=r(8249),r(4938),function(e){var t=n,r=t.lib,i=r.WordArray,a=r.Hasher,o=t.x64.Word,s=t.algo,u=[],c=[],l=[];!function(){for(var e=1,t=0,r=0;r<24;r++){u[e+5*t]=(r+1)*(r+2)/2%64;var n=(2*e+3*t)%5;e=t%5,t=n}for(e=0;e<5;e++)for(t=0;t<5;t++)c[e+5*t]=t+(2*e+3*t)%5*5;for(var i=1,a=0;a<24;a++){for(var s=0,f=0,p=0;p<7;p++){if(1&i){var m=(1<<p)-1;m<32?f^=1<<m:s^=1<<m-32}128&i?i=i<<1^113:i<<=1}l[a]=o.create(s,f)}}();var f=[];!function(){for(var e=0;e<25;e++)f[e]=o.create()}();var p=s.SHA3=a.extend({cfg:a.cfg.extend({outputLength:512}),_doReset:function(){for(var e=this._state=[],t=0;t<25;t++)e[t]=new o.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(e,t){for(var r=this._state,n=this.blockSize/2,i=0;i<n;i++){var a=e[t+2*i],o=e[t+2*i+1];a=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),o=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),(M=r[i]).high^=o,M.low^=a}for(var s=0;s<24;s++){for(var p=0;p<5;p++){for(var m=0,h=0,d=0;d<5;d++)m^=(M=r[p+5*d]).high,h^=M.low;var g=f[p];g.high=m,g.low=h}for(p=0;p<5;p++){var v=f[(p+4)%5],y=f[(p+1)%5],x=y.high,b=y.low;for(m=v.high^(x<<1|b>>>31),h=v.low^(b<<1|x>>>31),d=0;d<5;d++)(M=r[p+5*d]).high^=m,M.low^=h}for(var w=1;w<25;w++){var D=(M=r[w]).high,N=M.low,E=u[w];E<32?(m=D<<E|N>>>32-E,h=N<<E|D>>>32-E):(m=N<<E-32|D>>>64-E,h=D<<E-32|N>>>64-E);var A=f[c[w]];A.high=m,A.low=h}var S=f[0],C=r[0];for(S.high=C.high,S.low=C.low,p=0;p<5;p++)for(d=0;d<5;d++){var M=r[w=p+5*d],F=f[w],T=f[(p+1)%5+5*d],_=f[(p+2)%5+5*d];M.high=F.high^~T.high&_.high,M.low=F.low^~T.low&_.low}M=r[0];var B=l[s];M.high^=B.high,M.low^=B.low}},_doFinalize:function(){var t=this._data,r=t.words,n=(this._nDataBytes,8*t.sigBytes),a=32*this.blockSize;r[n>>>5]|=1<<24-n%32,r[(e.ceil((n+1)/a)*a>>>5)-1]|=128,t.sigBytes=4*r.length,this._process();for(var o=this._state,s=this.cfg.outputLength/8,u=s/8,c=[],l=0;l<u;l++){var f=o[l],p=f.high,m=f.low;p=16711935&(p<<8|p>>>24)|4278255360&(p<<24|p>>>8),m=16711935&(m<<8|m>>>24)|4278255360&(m<<24|m>>>8),c.push(m),c.push(p)}return new i.init(c,s)},clone:function(){for(var e=a.clone.call(this),t=e._state=this._state.slice(0),r=0;r<25;r++)t[r]=t[r].clone();return e}});t.SHA3=a._createHelper(p),t.HmacSHA3=a._createHmacHelper(p)}(Math),n.SHA3)},7460:function(e,t,r){var n,i,a,o,s,u,c,l;e.exports=(l=r(8249),r(4938),r(34),i=(n=l).x64,a=i.Word,o=i.WordArray,s=n.algo,u=s.SHA512,c=s.SHA384=u.extend({_doReset:function(){this._hash=new o.init([new a.init(3418070365,3238371032),new a.init(1654270250,914150663),new a.init(2438529370,812702999),new a.init(355462360,4144912697),new a.init(1731405415,4290775857),new a.init(2394180231,1750603025),new a.init(3675008525,1694076839),new a.init(1203062813,3204075428)])},_doFinalize:function(){var e=u._doFinalize.call(this);return e.sigBytes-=16,e}}),n.SHA384=u._createHelper(c),n.HmacSHA384=u._createHmacHelper(c),l.SHA384)},34:function(e,t,r){var n;e.exports=(n=r(8249),r(4938),function(){var e=n,t=e.lib.Hasher,r=e.x64,i=r.Word,a=r.WordArray,o=e.algo;function s(){return i.create.apply(i,arguments)}var u=[s(1116352408,3609767458),s(1899447441,602891725),s(3049323471,3964484399),s(3921009573,2173295548),s(961987163,4081628472),s(1508970993,3053834265),s(2453635748,2937671579),s(2870763221,3664609560),s(3624381080,2734883394),s(310598401,1164996542),s(607225278,1323610764),s(1426881987,3590304994),s(1925078388,4068182383),s(2162078206,991336113),s(2614888103,633803317),s(3248222580,3479774868),s(3835390401,2666613458),s(4022224774,944711139),s(264347078,2341262773),s(604807628,2007800933),s(770255983,1495990901),s(1249150122,1856431235),s(1555081692,3175218132),s(1996064986,2198950837),s(2554220882,3999719339),s(2821834349,766784016),s(2952996808,2566594879),s(3210313671,3203337956),s(3336571891,1034457026),s(3584528711,2466948901),s(113926993,3758326383),s(338241895,168717936),s(666307205,1188179964),s(773529912,1546045734),s(1294757372,1522805485),s(1396182291,2643833823),s(1695183700,2343527390),s(1986661051,1014477480),s(2177026350,1206759142),s(2456956037,344077627),s(2730485921,1290863460),s(2820302411,3158454273),s(3259730800,3505952657),s(3345764771,106217008),s(3516065817,3606008344),s(3600352804,1432725776),s(4094571909,1467031594),s(275423344,851169720),s(430227734,3100823752),s(506948616,1363258195),s(659060556,3750685593),s(883997877,3785050280),s(958139571,3318307427),s(1322822218,3812723403),s(1537002063,2003034995),s(1747873779,3602036899),s(1955562222,1575990012),s(2024104815,1125592928),s(2227730452,2716904306),s(2361852424,442776044),s(2428436474,593698344),s(2756734187,3733110249),s(3204031479,2999351573),s(3329325298,3815920427),s(3391569614,3928383900),s(3515267271,566280711),s(3940187606,3454069534),s(4118630271,4000239992),s(116418474,1914138554),s(174292421,2731055270),s(289380356,3203993006),s(460393269,320620315),s(685471733,587496836),s(852142971,1086792851),s(1017036298,365543100),s(1126000580,2618297676),s(1288033470,3409855158),s(1501505948,4234509866),s(1607167915,987167468),s(1816402316,1246189591)],c=[];!function(){for(var e=0;e<80;e++)c[e]=s()}();var l=o.SHA512=t.extend({_doReset:function(){this._hash=new a.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],a=r[2],o=r[3],s=r[4],l=r[5],f=r[6],p=r[7],m=n.high,h=n.low,d=i.high,g=i.low,v=a.high,y=a.low,x=o.high,b=o.low,w=s.high,D=s.low,N=l.high,E=l.low,A=f.high,S=f.low,C=p.high,M=p.low,F=m,T=h,_=d,B=g,O=v,k=y,z=x,I=b,q=w,R=D,P=N,j=E,U=A,L=S,H=C,$=M,G=0;G<80;G++){var W,V,Z=c[G];if(G<16)V=Z.high=0|e[t+2*G],W=Z.low=0|e[t+2*G+1];else{var Y=c[G-15],J=Y.high,X=Y.low,Q=(J>>>1|X<<31)^(J>>>8|X<<24)^J>>>7,K=(X>>>1|J<<31)^(X>>>8|J<<24)^(X>>>7|J<<25),ee=c[G-2],te=ee.high,re=ee.low,ne=(te>>>19|re<<13)^(te<<3|re>>>29)^te>>>6,ie=(re>>>19|te<<13)^(re<<3|te>>>29)^(re>>>6|te<<26),ae=c[G-7],oe=ae.high,se=ae.low,ue=c[G-16],ce=ue.high,le=ue.low;V=(V=(V=Q+oe+((W=K+se)>>>0<K>>>0?1:0))+ne+((W+=ie)>>>0<ie>>>0?1:0))+ce+((W+=le)>>>0<le>>>0?1:0),Z.high=V,Z.low=W}var fe,pe=q&P^~q&U,me=R&j^~R&L,he=F&_^F&O^_&O,de=T&B^T&k^B&k,ge=(F>>>28|T<<4)^(F<<30|T>>>2)^(F<<25|T>>>7),ve=(T>>>28|F<<4)^(T<<30|F>>>2)^(T<<25|F>>>7),ye=(q>>>14|R<<18)^(q>>>18|R<<14)^(q<<23|R>>>9),xe=(R>>>14|q<<18)^(R>>>18|q<<14)^(R<<23|q>>>9),be=u[G],we=be.high,De=be.low,Ne=H+ye+((fe=$+xe)>>>0<$>>>0?1:0),Ee=ve+de;H=U,$=L,U=P,L=j,P=q,j=R,q=z+(Ne=(Ne=(Ne=Ne+pe+((fe+=me)>>>0<me>>>0?1:0))+we+((fe+=De)>>>0<De>>>0?1:0))+V+((fe+=W)>>>0<W>>>0?1:0))+((R=I+fe|0)>>>0<I>>>0?1:0)|0,z=O,I=k,O=_,k=B,_=F,B=T,F=Ne+(ge+he+(Ee>>>0<ve>>>0?1:0))+((T=fe+Ee|0)>>>0<fe>>>0?1:0)|0}h=n.low=h+T,n.high=m+F+(h>>>0<T>>>0?1:0),g=i.low=g+B,i.high=d+_+(g>>>0<B>>>0?1:0),y=a.low=y+k,a.high=v+O+(y>>>0<k>>>0?1:0),b=o.low=b+I,o.high=x+z+(b>>>0<I>>>0?1:0),D=s.low=D+R,s.high=w+q+(D>>>0<R>>>0?1:0),E=l.low=E+j,l.high=N+P+(E>>>0<j>>>0?1:0),S=f.low=S+L,f.high=A+U+(S>>>0<L>>>0?1:0),M=p.low=M+$,p.high=C+H+(M>>>0<$>>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[30+(n+128>>>10<<5)]=Math.floor(r/4294967296),t[31+(n+128>>>10<<5)]=r,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=t.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32});e.SHA512=t._createHelper(l),e.HmacSHA512=t._createHmacHelper(l)}(),n.SHA512)},4253:function(e,t,r){var n;e.exports=(n=r(8249),r(8269),r(8214),r(888),r(5109),function(){var e=n,t=e.lib,r=t.WordArray,i=t.BlockCipher,a=e.algo,o=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],s=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],u=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],c=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],l=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],f=a.DES=i.extend({_doReset:function(){for(var e=this._key.words,t=[],r=0;r<56;r++){var n=o[r]-1;t[r]=e[n>>>5]>>>31-n%32&1}for(var i=this._subKeys=[],a=0;a<16;a++){var c=i[a]=[],l=u[a];for(r=0;r<24;r++)c[r/6|0]|=t[(s[r]-1+l)%28]<<31-r%6,c[4+(r/6|0)]|=t[28+(s[r+24]-1+l)%28]<<31-r%6;for(c[0]=c[0]<<1|c[0]>>>31,r=1;r<7;r++)c[r]=c[r]>>>4*(r-1)+3;c[7]=c[7]<<5|c[7]>>>27}var f=this._invSubKeys=[];for(r=0;r<16;r++)f[r]=i[15-r]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._subKeys)},decryptBlock:function(e,t){this._doCryptBlock(e,t,this._invSubKeys)},_doCryptBlock:function(e,t,r){this._lBlock=e[t],this._rBlock=e[t+1],p.call(this,4,252645135),p.call(this,16,65535),m.call(this,2,858993459),m.call(this,8,16711935),p.call(this,1,1431655765);for(var n=0;n<16;n++){for(var i=r[n],a=this._lBlock,o=this._rBlock,s=0,u=0;u<8;u++)s|=c[u][((o^i[u])&l[u])>>>0];this._lBlock=o,this._rBlock=a^s}var f=this._lBlock;this._lBlock=this._rBlock,this._rBlock=f,p.call(this,1,1431655765),m.call(this,8,16711935),m.call(this,2,858993459),p.call(this,16,65535),p.call(this,4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function p(e,t){var r=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=r,this._lBlock^=r<<e}function m(e,t){var r=(this._rBlock>>>e^this._lBlock)&t;this._lBlock^=r,this._rBlock^=r<<e}e.DES=i._createHelper(f);var h=a.TripleDES=i.extend({_doReset:function(){var e=this._key.words;if(2!==e.length&&4!==e.length&&e.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var t=e.slice(0,2),n=e.length<4?e.slice(0,2):e.slice(2,4),i=e.length<6?e.slice(0,2):e.slice(4,6);this._des1=f.createEncryptor(r.create(t)),this._des2=f.createEncryptor(r.create(n)),this._des3=f.createEncryptor(r.create(i))},encryptBlock:function(e,t){this._des1.encryptBlock(e,t),this._des2.decryptBlock(e,t),this._des3.encryptBlock(e,t)},decryptBlock:function(e,t){this._des3.decryptBlock(e,t),this._des2.encryptBlock(e,t),this._des1.decryptBlock(e,t)},keySize:6,ivSize:2,blockSize:2});e.TripleDES=i._createHelper(h)}(),n.TripleDES)},4938:function(e,t,r){var n,i,a,o,s,u;e.exports=(n=r(8249),a=(i=n).lib,o=a.Base,s=a.WordArray,(u=i.x64={}).Word=o.extend({init:function(e,t){this.high=e,this.low=t}}),u.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:8*e.length},toX32:function(){for(var e=this.words,t=e.length,r=[],n=0;n<t;n++){var i=e[n];r.push(i.high),r.push(i.low)}return s.create(r,this.sigBytes)},clone:function(){for(var e=o.clone.call(this),t=e.words=this.words.slice(0),r=t.length,n=0;n<r;n++)t[n]=t[n].clone();return e}}),n)},7928:e=>{"use strict";var t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},r={"{":"\\{","}":"\\}","\\":"\\textbackslash{}","#":"\\#",$:"\\$","%":"\\%","&":"\\&","^":"\\textasciicircum{}",_:"\\_","~":"\\textasciitilde{}"},n={"–":"\\--","—":"\\---"," ":"~","\t":"\\qquad{}","\r\n":"\\newline{}","\n":"\\newline{}"},i=function(e,r){return t({},e,r)};e.exports=function(e){for(var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=a.preserveFormatting,s=void 0!==o&&o,u=a.escapeMapFn,c=void 0===u?i:u,l=String(e),f="",p=c(t({},r),s?t({},n):{}),m=Object.keys(p),h=function(){var e=!1;m.forEach((function(t,r){e||l.length>=t.length&&l.slice(0,t.length)===t&&(f+=p[m[r]],l=l.slice(t.length,l.length),e=!0)})),e||(f+=l.slice(0,1),l=l.slice(1,l.length))};l;)h();return f}},3228:e=>{e.exports=function e(t,r){"use strict";var n,i,a=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,o=/(^[ ]*|[ ]*$)/g,s=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,u=/^0x[0-9a-f]+$/i,c=/^0/,l=function(t){return e.insensitive&&(""+t).toLowerCase()||""+t},f=l(t).replace(o,"")||"",p=l(r).replace(o,"")||"",m=f.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),h=p.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),d=parseInt(f.match(u),16)||1!==m.length&&f.match(s)&&Date.parse(f),g=parseInt(p.match(u),16)||d&&p.match(s)&&Date.parse(p)||null;if(g){if(d<g)return-1;if(d>g)return 1}for(var v=0,y=Math.max(m.length,h.length);v<y;v++){if(n=!(m[v]||"").match(c)&&parseFloat(m[v])||m[v]||0,i=!(h[v]||"").match(c)&&parseFloat(h[v])||h[v]||0,isNaN(n)!==isNaN(i))return isNaN(n)?1:-1;if(typeof n!=typeof i&&(n+="",i+=""),n<i)return-1;if(n>i)return 1}return 0}},6377:(e,t,r)=>{var n=r(4832),i=r(8652),a=r(801),o=r(2030),s=r(3618),u=r(9049),c=r(1971);c.alea=n,c.xor128=i,c.xorwow=a,c.xorshift7=o,c.xor4096=s,c.tychei=u,e.exports=c},4832:function(e,t,r){var n;!function(e,i,a){function o(e){var t,r=this,n=(t=4022871197,function(e){e=String(e);for(var r=0;r<e.length;r++){var n=.02519603282416938*(t+=e.charCodeAt(r));n-=t=n>>>0,t=(n*=t)>>>0,t+=4294967296*(n-=t)}return 2.3283064365386963e-10*(t>>>0)});r.next=function(){var e=2091639*r.s0+2.3283064365386963e-10*r.c;return r.s0=r.s1,r.s1=r.s2,r.s2=e-(r.c=0|e)},r.c=1,r.s0=n(" "),r.s1=n(" "),r.s2=n(" "),r.s0-=n(e),r.s0<0&&(r.s0+=1),r.s1-=n(e),r.s1<0&&(r.s1+=1),r.s2-=n(e),r.s2<0&&(r.s2+=1),n=null}function s(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function u(e,t){var r=new o(e),n=t&&t.state,i=r.next;return i.int32=function(){return 4294967296*r.next()|0},i.double=function(){return i()+11102230246251565e-32*(2097152*i()|0)},i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.alea=u}(0,e=r.nmd(e),r.amdD)},9049:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.next=function(){var e=t.b,r=t.c,n=t.d,i=t.a;return e=e<<25^e>>>7^r,r=r-n|0,n=n<<24^n>>>8^i,i=i-e|0,t.b=e=e<<20^e>>>12^r,t.c=r=r-n|0,t.d=n<<16^r>>>16^i,t.a=i-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):r+=e;for(var n=0;n<r.length+20;n++)t.b^=0|r.charCodeAt(n),t.next()}function s(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function u(e,t){var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.tychei=u}(0,e=r.nmd(e),r.amdD)},8652:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:r+=e;for(var n=0;n<r.length+64;n++)t.x^=0|r.charCodeAt(n),t.next()}function s(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function u(e,t){var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xor128=u}(0,e=r.nmd(e),r.amdD)},3618:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this;t.next=function(){var e,r,n=t.w,i=t.X,a=t.i;return t.w=n=n+1640531527|0,r=i[a+34&127],e=i[a=a+1&127],r^=r<<13,e^=e<<17,r^=r>>>15,e^=e>>>12,r=i[a]=r^e,t.i=a,r+(n^n>>>16)|0},function(e,t){var r,n,i,a,o,s=[],u=128;for(t===(0|t)?(n=t,t=null):(t+="\0",n=0,u=Math.max(u,t.length)),i=0,a=-32;a<u;++a)t&&(n^=t.charCodeAt((a+32)%t.length)),0===a&&(o=n),n^=n<<10,n^=n>>>15,n^=n<<4,n^=n>>>13,a>=0&&(o=o+1640531527|0,i=0==(r=s[127&a]^=n+o)?i+1:0);for(i>=128&&(s[127&(t&&t.length||0)]=-1),i=127,a=512;a>0;--a)n=s[i+34&127],r=s[i=i+1&127],n^=n<<13,r^=r<<17,n^=n>>>15,r^=r>>>12,s[i]=n^r;e.w=o,e.X=s,e.i=i}(t,e)}function s(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function u(e,t){null==e&&(e=+new Date);var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&(n.X&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xor4096=u}(0,e=r.nmd(e),r.amdD)},2030:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this;t.next=function(){var e,r,n=t.x,i=t.i;return e=n[i],r=(e^=e>>>7)^e<<24,r^=(e=n[i+1&7])^e>>>10,r^=(e=n[i+3&7])^e>>>3,r^=(e=n[i+4&7])^e<<7,e=n[i+7&7],r^=(e^=e<<13)^e<<9,n[i]=r,t.i=i+1&7,r},function(e,t){var r,n=[];if(t===(0|t))n[0]=t;else for(t=""+t,r=0;r<t.length;++r)n[7&r]=n[7&r]<<15^t.charCodeAt(r)+n[r+1&7]<<13;for(;n.length<8;)n.push(0);for(r=0;r<8&&0===n[r];++r);for(8==r?n[7]=-1:n[r],e.x=n,e.i=0,r=256;r>0;--r)e.next()}(t,e)}function s(e,t){return t.x=e.x.slice(),t.i=e.i,t}function u(e,t){null==e&&(e=+new Date);var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&(n.x&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xorshift7=u}(0,e=r.nmd(e),r.amdD)},801:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:r+=e;for(var n=0;n<r.length+64;n++)t.x^=0|r.charCodeAt(n),n==r.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function s(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function u(e,t){var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xorwow=u}(0,e=r.nmd(e),r.amdD)},1971:function(e,t,r){var n;!function(i,a,o){var s,u=256,c=o.pow(u,6),l=o.pow(2,52),f=2*l,p=u-1;function m(e,t,r){var n=[],p=v(g((t=1==t?{entropy:!0}:t||{}).entropy?[e,y(a)]:null==e?function(){try{var e;return s&&(e=s.randomBytes)?e=e(u):(e=new Uint8Array(u),(i.crypto||i.msCrypto).getRandomValues(e)),y(e)}catch(e){var t=i.navigator,r=t&&t.plugins;return[+new Date,i,r,i.screen,y(a)]}}():e,3),n),m=new h(n),x=function(){for(var e=m.g(6),t=c,r=0;e<l;)e=(e+r)*u,t*=u,r=m.g(1);for(;e>=f;)e/=2,t/=2,r>>>=1;return(e+r)/t};return x.int32=function(){return 0|m.g(4)},x.quick=function(){return m.g(4)/4294967296},x.double=x,v(y(m.S),a),(t.pass||r||function(e,t,r,n){return n&&(n.S&&d(n,m),e.state=function(){return d(m,{})}),r?(o.random=e,t):e})(x,p,"global"in t?t.global:this==o,t.state)}function h(e){var t,r=e.length,n=this,i=0,a=n.i=n.j=0,o=n.S=[];for(r||(e=[r++]);i<u;)o[i]=i++;for(i=0;i<u;i++)o[i]=o[a=p&a+e[i%r]+(t=o[i])],o[a]=t;(n.g=function(e){for(var t,r=0,i=n.i,a=n.j,o=n.S;e--;)t=o[i=p&i+1],r=r*u+o[p&(o[i]=o[a=p&a+t])+(o[a]=t)];return n.i=i,n.j=a,r})(u)}function d(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function g(e,t){var r,n=[],i=typeof e;if(t&&"object"==i)for(r in e)try{n.push(g(e[r],t-1))}catch(e){}return n.length?n:"string"==i?e:e+"\0"}function v(e,t){for(var r,n=e+"",i=0;i<n.length;)t[p&i]=p&(r^=19*t[p&i])+n.charCodeAt(i++);return y(t)}function y(e){return String.fromCharCode.apply(0,e)}if(v(o.random(),a),e.exports){e.exports=m;try{s=r(5042)}catch(e){}}else void 0===(n=function(){return m}.call(t,r,t,e))||(e.exports=n)}("undefined"!=typeof self?self:this,[],Math)},4279:e=>{function t(){}t.prototype={on:function(e,t,r){var n=this.e||(this.e={});return(n[e]||(n[e]=[])).push({fn:t,ctx:r}),this},once:function(e,t,r){var n=this;function i(){n.off(e,i),t.apply(r,arguments)}return i._=t,this.on(e,i,r)},emit:function(e){for(var t=[].slice.call(arguments,1),r=((this.e||(this.e={}))[e]||[]).slice(),n=0,i=r.length;n<i;n++)r[n].fn.apply(r[n].ctx,t);return this},off:function(e,t){var r=this.e||(this.e={}),n=r[e],i=[];if(n&&t)for(var a=0,o=n.length;a<o;a++)n[a].fn!==t&&n[a].fn._!==t&&i.push(n[a]);return i.length?r[e]=i:delete r[e],this}},e.exports=t,e.exports.TinyEmitter=t},2480:()=>{},5042:()=>{},4814:function(e){e.exports=function(){"use strict";function e(){return!0}function t(){return!1}function r(){}const n="Argument is not a typed-function.";return function i(){function a(e){return"object"==typeof e&&null!==e&&e.constructor===Object}const o=[{name:"number",test:function(e){return"number"==typeof e}},{name:"string",test:function(e){return"string"==typeof e}},{name:"boolean",test:function(e){return"boolean"==typeof e}},{name:"Function",test:function(e){return"function"==typeof e}},{name:"Array",test:Array.isArray},{name:"Date",test:function(e){return e instanceof Date}},{name:"RegExp",test:function(e){return e instanceof RegExp}},{name:"Object",test:a},{name:"null",test:function(e){return null===e}},{name:"undefined",test:function(e){return void 0===e}}],s={name:"any",test:e,isAny:!0};let u,c,l=0,f={createCount:0};function p(e){const t=u.get(e);if(t)return t;let r='Unknown type "'+e+'"';const n=e.toLowerCase();let i;for(i of c)if(i.toLowerCase()===n){r+='. Did you mean "'+i+'" ?';break}throw new TypeError(r)}function m(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"any";const r=t?p(t).index:c.length,n=[];for(let t=0;t<e.length;++t){if(!e[t]||"string"!=typeof e[t].name||"function"!=typeof e[t].test)throw new TypeError("Object with properties {name: string, test: function} expected");const i=e[t].name;if(u.has(i))throw new TypeError('Duplicate type name "'+i+'"');n.push(i),u.set(i,{name:i,test:e[t].test,isAny:e[t].isAny,index:r+t,conversionsTo:[]})}const i=c.slice(r);c=c.slice(0,r).concat(n).concat(i);for(let e=r+n.length;e<c.length;++e)u.get(c[e]).index=e}function h(){u=new Map,c=[],l=0,m([s],!1)}function d(e){const t=c.filter((t=>{const r=u.get(t);return!r.isAny&&r.test(e)}));return t.length?t:["any"]}function g(e){return e&&"function"==typeof e&&"_typedFunctionData"in e}function v(e,t,r){if(!g(e))throw new TypeError(n);const i=r&&r.exact,a=D(Array.isArray(t)?t.join(","):t),o=y(a);if(!i||o in e.signatures){const t=e._typedFunctionData.signatureMap.get(o);if(t)return t}const s=a.length;let u,c;if(i){let t;for(t in u=[],e.signatures)u.push(e._typedFunctionData.signatureMap.get(t))}else u=e._typedFunctionData.signatures;for(let e=0;e<s;++e){const t=a[e],r=[];let n;for(n of u){const i=S(n.params,e);if(i&&(!t.restParam||i.restParam)){if(!i.hasAny){const e=w(i);if(t.types.some((t=>!e.has(t.name))))continue}r.push(n)}}if(u=r,0===u.length)break}for(c of u)if(c.params.length<=s)return c;throw new TypeError("Signature not found (signature: "+(e.name||"unnamed")+"("+y(a,", ")+"))")}function y(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:",";return e.map((e=>e.name)).join(t)}function x(e){const t=0===e.indexOf("..."),r=(t?e.length>3?e.slice(3):"any":e).split("|").map((e=>p(e.trim())));let n=!1,i=t?"...":"";return{types:r.map((function(e){return n=e.isAny||n,i+=e.name+"|",{name:e.name,typeIndex:e.index,test:e.test,isAny:e.isAny,conversion:null,conversionIndex:-1}})),name:i.slice(0,-1),hasAny:n,hasConversion:!1,restParam:t}}function b(e){const t=function(e){if(0===e.length)return[];const t=e.map(p);e.length>1&&t.sort(((e,t)=>e.index-t.index));let r=t[0].conversionsTo;if(1===e.length)return r;r=r.concat([]);const n=new Set(e);for(let e=1;e<t.length;++e){let i;for(i of t[e].conversionsTo)n.has(i.from)||(r.push(i),n.add(i.from))}return r}(e.types.map((e=>e.name)));let r=e.hasAny,n=e.name;const i=t.map((function(e){const t=p(e.from);return r=t.isAny||r,n+="|"+e.from,{name:e.from,typeIndex:t.index,test:t.test,isAny:t.isAny,conversion:e,conversionIndex:e.index}}));return{types:e.types.concat(i),name:n,hasAny:r,hasConversion:i.length>0,restParam:e.restParam}}function w(e){return e.typeSet||(e.typeSet=new Set,e.types.forEach((t=>e.typeSet.add(t.name)))),e.typeSet}function D(e){const t=[];if("string"!=typeof e)throw new TypeError("Signatures must be strings");const r=e.trim();if(""===r)return t;const n=r.split(",");for(let e=0;e<n.length;++e){const r=x(n[e].trim());if(r.restParam&&e!==n.length-1)throw new SyntaxError('Unexpected rest parameter "'+n[e]+'": only allowed for the last parameter');if(0===r.types.length)return null;t.push(r)}return t}function N(e){const t=$(e);return!!t&&t.restParam}function E(t){if(t&&0!==t.types.length){if(1===t.types.length)return p(t.types[0].name).test;if(2===t.types.length){const e=p(t.types[0].name).test,r=p(t.types[1].name).test;return function(t){return e(t)||r(t)}}{const e=t.types.map((function(e){return p(e.name).test}));return function(t){for(let r=0;r<e.length;r++)if(e[r](t))return!0;return!1}}}return e}function A(e){let t,r,n;if(N(e)){t=H(e).map(E);const r=t.length,n=E($(e)),i=function(e){for(let t=r;t<e.length;t++)if(!n(e[t]))return!1;return!0};return function(e){for(let r=0;r<t.length;r++)if(!t[r](e[r]))return!1;return i(e)&&e.length>=r+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(r=E(e[0]),function(e){return r(e[0])&&1===e.length}):2===e.length?(r=E(e[0]),n=E(e[1]),function(e){return r(e[0])&&n(e[1])&&2===e.length}):(t=e.map(E),function(e){for(let r=0;r<t.length;r++)if(!t[r](e[r]))return!1;return e.length===t.length})}function S(e,t){return t<e.length?e[t]:N(e)?$(e):null}function C(e,t){const r=S(e,t);return r?w(r):new Set}function M(e){return null===e.conversion||void 0===e.conversion}function F(e,t){const r=new Set;return e.forEach((e=>{const n=C(e.params,t);let i;for(i of n)r.add(i)})),r.has("any")?["any"]:Array.from(r)}function T(e,t,r){let n,i;const a=e||"unnamed";let o,s=r;for(o=0;o<t.length;o++){const e=[];if(s.forEach((r=>{const n=E(S(r.params,o));(o<r.params.length||N(r.params))&&n(t[o])&&e.push(r)})),0===e.length){if(i=F(s,o),i.length>0){const e=d(t[o]);return n=new TypeError("Unexpected type of argument in function "+a+" (expected: "+i.join(" or ")+", actual: "+e.join(" | ")+", index: "+o+")"),n.data={category:"wrongType",fn:a,index:o,actual:e,expected:i},n}}else s=e}const u=s.map((function(e){return N(e.params)?1/0:e.params.length}));if(t.length<Math.min.apply(null,u))return i=F(s,o),n=new TypeError("Too few arguments in function "+a+" (expected: "+i.join(" or ")+", index: "+t.length+")"),n.data={category:"tooFewArgs",fn:a,index:t.length,expected:i},n;const c=Math.max.apply(null,u);if(t.length>c)return n=new TypeError("Too many arguments in function "+a+" (expected: "+c+", actual: "+t.length+")"),n.data={category:"tooManyArgs",fn:a,index:t.length,expectedLength:c},n;const l=[];for(let e=0;e<t.length;++e)l.push(d(t[e]).join("|"));return n=new TypeError('Arguments of type "'+l.join(", ")+'" do not match any of the defined signatures of function '+a+"."),n.data={category:"mismatch",actual:l},n}function _(e){let t=c.length+1;for(let r=0;r<e.types.length;r++)M(e.types[r])&&(t=Math.min(t,e.types[r].typeIndex));return t}function B(e){let t=l+1;for(let r=0;r<e.types.length;r++)M(e.types[r])||(t=Math.min(t,e.types[r].conversionIndex));return t}function O(e,t){if(e.hasAny){if(!t.hasAny)return 1}else if(t.hasAny)return-1;if(e.restParam){if(!t.restParam)return 1}else if(t.restParam)return-1;if(e.hasConversion){if(!t.hasConversion)return 1}else if(t.hasConversion)return-1;const r=_(e)-_(t);if(r<0)return-1;if(r>0)return 1;const n=B(e)-B(t);return n<0?-1:n>0?1:0}function k(e,t){const r=e.params,n=t.params,i=$(r),a=$(n),o=N(r),s=N(n);if(o&&i.hasAny){if(!s||!a.hasAny)return 1}else if(s&&a.hasAny)return-1;let u,c=0,l=0;for(u of r)u.hasAny&&++c,u.hasConversion&&++l;let f=0,p=0;for(u of n)u.hasAny&&++f,u.hasConversion&&++p;if(c!==f)return c-f;if(o&&i.hasConversion){if(!s||!a.hasConversion)return 1}else if(s&&a.hasConversion)return-1;if(l!==p)return l-p;if(o){if(!s)return 1}else if(s)return-1;const m=(r.length-n.length)*(o?-1:1);if(0!==m)return m;const h=[];let d,g=0;for(let e=0;e<r.length;++e){const t=O(r[e],n[e]);h.push(t),g+=t}if(0!==g)return g;for(d of h)if(0!==d)return d;return 0}function z(e,t){let r=t;if(e.some((e=>e.hasConversion))){const n=N(e),i=e.map(I);r=function(){const e=[],r=n?arguments.length-1:arguments.length;for(let t=0;t<r;t++)e[t]=i[t](arguments[t]);return n&&(e[r]=arguments[r].map(i[r])),t.apply(this,e)}}let n=r;if(N(e)){const t=e.length-1;n=function(){return r.apply(this,G(arguments,0,t).concat([G(arguments,t)]))}}return n}function I(e){let t,r,n,i;const a=[],o=[];switch(e.types.forEach((function(e){e.conversion&&(a.push(p(e.conversion.from).test),o.push(e.conversion.convert))})),o.length){case 0:return function(e){return e};case 1:return t=a[0],n=o[0],function(e){return t(e)?n(e):e};case 2:return t=a[0],r=a[1],n=o[0],i=o[1],function(e){return t(e)?n(e):r(e)?i(e):e};default:return function(e){for(let t=0;t<o.length;t++)if(a[t](e))return o[t](e);return e}}}function q(e){return function e(t,r,n){if(r<t.length){const o=t[r];let s=[];if(o.restParam){const e=o.types.filter(M);e.length<o.types.length&&s.push({types:e,name:"..."+e.map((e=>e.name)).join("|"),hasAny:e.some((e=>e.isAny)),hasConversion:!1,restParam:!0}),s.push(o)}else s=o.types.map((function(e){return{types:[e],name:e.name,hasAny:e.isAny,hasConversion:e.conversion,restParam:!1}}));return i=s,a=function(i){return e(t,r+1,n.concat([i]))},Array.prototype.concat.apply([],i.map(a))}var i,a;return[n]}(e,0,[])}function R(e,t){const r=Math.max(e.length,t.length);for(let n=0;n<r;n++){const r=C(e,n),i=C(t,n);let a,o=!1;for(a of i)if(r.has(a)){o=!0;break}if(!o)return!1}const n=e.length,i=t.length,a=N(e),o=N(t);return a?o?n===i:i>=n:o?n>=i:n===i}function P(e,t,r){const n=[];let i;for(i of e){let e=r[i];if("number"!=typeof e)throw new TypeError('No definition for referenced signature "'+i+'"');if(e=t[e],"function"!=typeof e)return!1;n.push(e)}return n}function j(e,t,r){const n=function(e){return e.map((e=>Y(e)?V(e.referToSelf.callback):Z(e)?W(e.referTo.references,e.referTo.callback):e))}(e),i=new Array(n.length).fill(!1);let a=!0;for(;a;){a=!1;let e=!0;for(let o=0;o<n.length;++o){if(i[o])continue;const s=n[o];if(Y(s))n[o]=s.referToSelf.callback(r),n[o].referToSelf=s.referToSelf,i[o]=!0,e=!1;else if(Z(s)){const r=P(s.referTo.references,n,t);r?(n[o]=s.referTo.callback.apply(this,r),n[o].referTo=s.referTo,i[o]=!0,e=!1):a=!0}}if(e&&a)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return n}function U(e,n){if(f.createCount++,0===Object.keys(n).length)throw new SyntaxError("No signatures provided");f.warnAgainstDeprecatedThis&&function(e){const t=/\bthis(\(|\.signatures\b)/;Object.keys(e).forEach((r=>{const n=e[r];if(t.test(n.toString()))throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")}))}(n);const i=[],a=[],o={},s=[];let u;for(u in n){if(!Object.prototype.hasOwnProperty.call(n,u))continue;const e=D(u);if(!e)continue;i.forEach((function(t){if(R(t,e))throw new TypeError('Conflicting signatures "'+y(t)+'" and "'+y(e)+'".')})),i.push(e);const t=a.length;a.push(n[u]);const r=e.map(b);let c;for(c of q(r)){const e=y(c);s.push({params:c,name:e,fn:t}),c.every((e=>!e.hasConversion))&&(o[e]=t)}}s.sort(k);const c=j(a,o,se);let l;for(l in o)Object.prototype.hasOwnProperty.call(o,l)&&(o[l]=c[o[l]]);const p=[],m=new Map;for(l of s)m.has(l.name)||(l.fn=c[l.fn],p.push(l),m.set(l.name,l));const h=p[0]&&p[0].params.length<=2&&!N(p[0].params),d=p[1]&&p[1].params.length<=2&&!N(p[1].params),g=p[2]&&p[2].params.length<=2&&!N(p[2].params),v=p[3]&&p[3].params.length<=2&&!N(p[3].params),x=p[4]&&p[4].params.length<=2&&!N(p[4].params),w=p[5]&&p[5].params.length<=2&&!N(p[5].params),S=h&&d&&g&&v&&x&&w;for(let e=0;e<p.length;++e)p[e].test=A(p[e].params);const C=h?E(p[0].params[0]):t,M=d?E(p[1].params[0]):t,F=g?E(p[2].params[0]):t,T=v?E(p[3].params[0]):t,_=x?E(p[4].params[0]):t,B=w?E(p[5].params[0]):t,O=h?E(p[0].params[1]):t,I=d?E(p[1].params[1]):t,P=g?E(p[2].params[1]):t,U=v?E(p[3].params[1]):t,L=x?E(p[4].params[1]):t,H=w?E(p[5].params[1]):t;for(let e=0;e<p.length;++e)p[e].implementation=z(p[e].params,p[e].fn);const $=h?p[0].implementation:r,G=d?p[1].implementation:r,W=g?p[2].implementation:r,V=v?p[3].implementation:r,Z=x?p[4].implementation:r,Y=w?p[5].implementation:r,J=h?p[0].params.length:-1,X=d?p[1].params.length:-1,Q=g?p[2].params.length:-1,K=v?p[3].params.length:-1,ee=x?p[4].params.length:-1,te=w?p[5].params.length:-1,re=S?6:0,ne=p.length,ie=p.map((e=>e.test)),ae=p.map((e=>e.implementation)),oe=function(){for(let e=re;e<ne;e++)if(ie[e](arguments))return ae[e].apply(this,arguments);return f.onMismatch(e,arguments,p)};function se(e,t){return arguments.length===J&&C(e)&&O(t)?$.apply(this,arguments):arguments.length===X&&M(e)&&I(t)?G.apply(this,arguments):arguments.length===Q&&F(e)&&P(t)?W.apply(this,arguments):arguments.length===K&&T(e)&&U(t)?V.apply(this,arguments):arguments.length===ee&&_(e)&&L(t)?Z.apply(this,arguments):arguments.length===te&&B(e)&&H(t)?Y.apply(this,arguments):oe.apply(this,arguments)}try{Object.defineProperty(se,"name",{value:e})}catch(e){}return se.signatures=o,se._typedFunctionData={signatures:p,signatureMap:m},se}function L(e,t,r){throw T(e,t,r)}function H(e){return G(e,0,e.length-1)}function $(e){return e[e.length-1]}function G(e,t,r){return Array.prototype.slice.call(e,t,r)}function W(e,t){return{referTo:{references:e,callback:t}}}function V(e){if("function"!=typeof e)throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:e}}}function Z(e){return e&&"object"==typeof e.referTo&&Array.isArray(e.referTo.references)&&"function"==typeof e.referTo.callback}function Y(e){return e&&"object"==typeof e.referToSelf&&"function"==typeof e.referToSelf.callback}function J(e,t){if(!e)return t;if(t&&t!==e){const r=new Error("Function names do not match (expected: "+e+", actual: "+t+")");throw r.data={actual:t,expected:e},r}return e}function X(e){let t;for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(g(e[r])||"string"==typeof e[r].signature)&&(t=J(t,e[r].name));return t}function Q(e,t){let r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)){if(r in e&&t[r]!==e[r]){const n=new Error('Signature "'+r+'" is defined twice');throw n.data={signature:r,sourceFunction:t[r],destFunction:e[r]},n}e[r]=t[r]}}h(),m(o);const K=f;function ee(e){if(!e||"string"!=typeof e.from||"string"!=typeof e.to||"function"!=typeof e.convert)throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(e.to===e.from)throw new SyntaxError('Illegal to define conversion from "'+e.from+'" to itself.')}return f=function(e){const t="string"==typeof e;let r=t?e:"";const n={};for(let e=t?1:0;e<arguments.length;++e){const i=arguments[e];let o,s={};if("function"==typeof i?(o=i.name,"string"==typeof i.signature?s[i.signature]=i:g(i)&&(s=i.signatures)):a(i)&&(s=i,t||(o=X(i))),0===Object.keys(s).length){const t=new TypeError("Argument to 'typed' at index "+e+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw t.data={index:e,argument:i},t}t||(r=J(r,o)),Q(n,s)}return U(r||"",n)},f.create=i,f.createCount=K.createCount,f.onMismatch=L,f.throwMismatchError=L,f.createError=T,f.clear=h,f.clearConversions=function(){let e;for(e of c)u.get(e).conversionsTo=[];l=0},f.addTypes=m,f._findType=p,f.referTo=function(){const e=H(arguments).map((e=>y(D(e)))),t=$(arguments);if("function"!=typeof t)throw new TypeError("Callback function expected as last argument");return W(e,t)},f.referToSelf=V,f.convert=function(e,t){const r=p(t);if(r.test(e))return e;const n=r.conversionsTo;if(0===n.length)throw new Error("There are no conversions to "+t+" defined.");for(let t=0;t<n.length;t++)if(p(n[t].from).test(e))return n[t].convert(e);throw new Error("Cannot convert "+e+" to "+t)},f.findSignature=v,f.find=function(e,t,r){return v(e,t,r).implementation},f.isTypedFunction=g,f.warnAgainstDeprecatedThis=!0,f.addType=function(e,t){let r="any";!1!==t&&u.has("Object")&&(r="Object"),f.addTypes([e],r)},f.addConversion=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{override:!1};ee(e);const r=p(e.to),n=r.conversionsTo.find((t=>t.from===e.from));if(n){if(!t||!t.override)throw new Error('There is already a conversion from "'+e.from+'" to "'+r.name+'"');f.removeConversion({from:n.from,to:e.to,convert:n.convert})}r.conversionsTo.push({from:e.from,convert:e.convert,index:l++})},f.addConversions=function(e,t){e.forEach((e=>f.addConversion(e,t)))},f.removeConversion=function(e){ee(e);const t=p(e.to),r=function(e,t){for(let r=0;r<e.length;r++)if(t(e[r]))return e[r]}(t.conversionsTo,(t=>t.from===e.from));if(!r)throw new Error("Attempt to remove nonexistent conversion from "+e.from+" to "+e.to);if(r.convert!==e.convert)throw new Error("Conversion to remove does not match existing conversion");const n=t.conversionsTo.indexOf(r);t.conversionsTo.splice(n,1)},f.resolve=function(e,t){if(!g(e))throw new TypeError(n);const r=e._typedFunctionData.signatures;for(let e=0;e<r.length;++e)if(r[e].test(t))return r[e];return null},f}()}()}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var a=t[n]={id:n,loaded:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.loaded=!0,a.exports}r.amdD=function(){throw new Error("define cannot be used indirect")},r.amdO={},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var n={};return(()=>{"use strict";r.r(n),r.d(n,{EllipsisApi:()=>c,RasterLayerUtil:()=>i,VectorLayerUtil:()=>t});var e={};r.r(e),r.d(e,{createAbs:()=>za,createAccessorNode:()=>Up,createAcos:()=>rf,createAcosh:()=>Df,createAcot:()=>Ef,createAcoth:()=>Sf,createAcsc:()=>Mf,createAcsch:()=>Tf,createAdd:()=>Cp,createAddScalar:()=>ja,createAnd:()=>Jc,createAndTransform:()=>iy,createApply:()=>qa,createApplyTransform:()=>Fv,createArg:()=>Ns,createArrayNode:()=>Hp,createAsec:()=>Bf,createAsech:()=>kf,createAsin:()=>If,createAsinh:()=>qf,createAssignmentNode:()=>Jp,createAtan:()=>Rf,createAtan2:()=>jf,createAtanh:()=>Lf,createAtomicMass:()=>ov,createAvogadro:()=>sv,createBellNumbers:()=>Od,createBigNumberClass:()=>Qr,createBigint:()=>Wi,createBignumber:()=>Xi,createBin:()=>sc,createBitAnd:()=>ds,createBitAndTransform:()=>oy,createBitNot:()=>vs,createBitOr:()=>xs,createBitOrTransform:()=>sy,createBitXor:()=>Ds,createBlockNode:()=>Qp,createBohrMagneton:()=>jg,createBohrRadius:()=>Wg,createBoltzmann:()=>uv,createBoolean:()=>Ji,createCatalan:()=>zd,createCbrt:()=>$a,createCeil:()=>Xa,createChain:()=>fh,createChainClass:()=>ih,createClassicalElectronRadius:()=>Vg,createClone:()=>pi,createColumn:()=>Ps,createColumnTransform:()=>Tv,createCombinations:()=>Jh,createCombinationsWithRep:()=>Kh,createCompare:()=>Qc,createCompareNatural:()=>rl,createCompareText:()=>al,createCompile:()=>_m,createComplex:()=>Qi,createComplexClass:()=>un,createComposition:()=>qd,createConcat:()=>qs,createConcatTransform:()=>Wv,createConditionalNode:()=>em,createConductanceQuantum:()=>Ug,createConj:()=>As,createConstantNode:()=>cm,createCorr:()=>Wh,createCos:()=>$f,createCosh:()=>Wf,createCot:()=>Vf,createCoth:()=>Yf,createCoulomb:()=>Rg,createCount:()=>Us,createCreateUnit:()=>ef,createCross:()=>Hs,createCsc:()=>Jf,createCsch:()=>Qf,createCtranspose:()=>Iu,createCube:()=>Ka,createCumSum:()=>Oh,createCumSumTransform:()=>Kv,createDeepEqual:()=>El,createDenseMatrixClass:()=>li,createDerivative:()=>Kd,createDet:()=>ph,createDeuteronMass:()=>Kg,createDiag:()=>Gs,createDiff:()=>uu,createDiffTransform:()=>Zv,createDistance:()=>Fh,createDivide:()=>Ch,createDivideScalar:()=>xc,createDot:()=>Bp,createDotDivide:()=>Bc,createDotMultiply:()=>Xo,createDotPow:()=>Tc,createE:()=>yg,createEfimovFactor:()=>av,createEigs:()=>gh,createElectricConstant:()=>Ig,createElectronMass:()=>Zg,createElementaryCharge:()=>Pg,createEqual:()=>sl,createEqualScalar:()=>Hi,createEqualText:()=>ll,createErf:()=>Wu,createEvaluate:()=>Om,createExp:()=>eo,createExpm:()=>yh,createExpm1:()=>ro,createFactorial:()=>pd,createFalse:()=>pg,createFaraday:()=>cv,createFermiCoupling:()=>Yg,createFft:()=>Pu,createFibonacciHeapClass:()=>ql,createFilter:()=>Ws,createFilterTransform:()=>zv,createFineStructure:()=>Jg,createFirstRadiation:()=>lv,createFix:()=>oo,createFlatten:()=>Ys,createFloor:()=>lo,createForEach:()=>Xs,createForEachTransform:()=>Iv,createFormat:()=>oc,createFraction:()=>Ki,createFractionClass:()=>xn,createFreqz:()=>ag,createFunctionAssignmentNode:()=>fm,createFunctionNode:()=>Cm,createGamma:()=>ud,createGasConstant:()=>pv,createGcd:()=>So,createGetMatrixDataType:()=>eu,createGravitationConstant:()=>Bg,createGravity:()=>wv,createHartreeEnergy:()=>Xg,createHasNumericValue:()=>Bi,createHelp:()=>ch,createHelpClass:()=>nh,createHex:()=>cc,createHypot:()=>Fp,createI:()=>Sg,createIdentity:()=>ru,createIfft:()=>Uu,createIm:()=>Ss,createImmutableDenseMatrixClass:()=>kl,createIndex:()=>zp,createIndexClass:()=>zl,createIndexNode:()=>mm,createIndexTransform:()=>qv,createInfinity:()=>hg,createIntersect:()=>Th,createInv:()=>mh,createInverseConductanceQuantum:()=>Lg,createInvmod:()=>Zo,createIsInteger:()=>wi,createIsNaN:()=>Ri,createIsNegative:()=>Mi,createIsNumeric:()=>Ti,createIsPositive:()=>ki,createIsPrime:()=>gc,createIsZero:()=>Ii,createKldivergence:()=>hd,createKlitzing:()=>Gg,createKron:()=>iu,createLN10:()=>wg,createLN2:()=>bg,createLOG10E:()=>Ng,createLOG2E:()=>Dg,createLarger:()=>yl,createLargerEq:()=>wl,createLcm:()=>Mo,createLeafCount:()=>Pd,createLeftShift:()=>Gc,createLgamma:()=>ld,createLog:()=>Ec,createLog10:()=>To,createLog1p:()=>Sc,createLog2:()=>Bo,createLoschmidt:()=>fv,createLsolve:()=>zc,createLsolveAll:()=>Pc,createLup:()=>qm,createLusolve:()=>eh,createLyap:()=>Sh,createMad:()=>Rh,createMagneticConstant:()=>zg,createMagneticFluxQuantum:()=>Hg,createMap:()=>ou,createMapTransform:()=>Rv,createMatrix:()=>ta,createMatrixClass:()=>wn,createMatrixFromColumns:()=>sa,createMatrixFromFunction:()=>na,createMatrixFromRows:()=>aa,createMax:()=>Bl,createMaxTransform:()=>jv,createMean:()=>zh,createMeanTransform:()=>Uv,createMedian:()=>qh,createMin:()=>Ol,createMinTransform:()=>Lv,createMod:()=>yo,createMode:()=>tc,createMolarMass:()=>xv,createMolarMassC12:()=>bv,createMolarPlanckConstant:()=>mv,createMolarVolume:()=>hv,createMultinomial:()=>gd,createMultiply:()=>zo,createMultiplyScalar:()=>Oo,createNaN:()=>dg,createNeutronMass:()=>ev,createNode:()=>qp,createNorm:()=>_p,createNot:()=>Os,createNthRoot:()=>qo,createNthRoots:()=>Mc,createNuclearMagneton:()=>$g,createNull:()=>mg,createNumber:()=>Gi,createNumeric:()=>vc,createObjectNode:()=>dm,createOct:()=>uc,createOnes:()=>cu,createOperatorNode:()=>ym,createOr:()=>ks,createOrTransform:()=>ay,createParenthesisNode:()=>bm,createParse:()=>Fm,createParser:()=>Im,createParserClass:()=>km,createPartitionSelect:()=>Fl,createPermutations:()=>yd,createPhi:()=>xg,createPi:()=>gg,createPickRandom:()=>Ed,createPinv:()=>dh,createPlanckCharge:()=>Av,createPlanckConstant:()=>Og,createPlanckLength:()=>Dv,createPlanckMass:()=>Nv,createPlanckTemperature:()=>Sv,createPlanckTime:()=>Ev,createPolynomialRoot:()=>rh,createPow:()=>bc,createPrint:()=>pc,createPrintTransform:()=>ny,createProd:()=>ic,createProtonMass:()=>Qg,createQr:()=>Rm,createQuantileSeq:()=>Hh,createQuantileSeqTransform:()=>Xv,createQuantumOfCirculation:()=>tv,createRandom:()=>Cd,createRandomInt:()=>Fd,createRange:()=>hu,createRangeClass:()=>bn,createRangeNode:()=>Dm,createRangeTransform:()=>Hv,createRationalize:()=>tg,createRe:()=>Cs,createReducedPlanckConstant:()=>kg,createRelationalNode:()=>Em,createReplacer:()=>sg,createReshape:()=>gu,createResize:()=>vu,createResolve:()=>Yd,createResultSet:()=>dt,createReviver:()=>og,createRightArithShift:()=>Vc,createRightLogShift:()=>Yc,createRotate:()=>xu,createRotationMatrix:()=>wu,createRound:()=>Nc,createRow:()=>Du,createRowTransform:()=>$v,createRydberg:()=>rv,createSQRT1_2:()=>Eg,createSQRT2:()=>Ag,createSackurTetrode:()=>dv,createSchur:()=>Eh,createSec:()=>Kf,createSech:()=>tp,createSecondRadiation:()=>gv,createSetCartesian:()=>up,createSetDifference:()=>lp,createSetDistinct:()=>pp,createSetIntersect:()=>hp,createSetIsSubset:()=>gp,createSetMultiplicity:()=>yp,createSetPowerset:()=>bp,createSetSize:()=>Dp,createSetSymDifference:()=>Ep,createSetUnion:()=>Sp,createSign:()=>Po,createSimplify:()=>Gd,createSimplifyConstant:()=>Wd,createSimplifyCore:()=>Zd,createSin:()=>rp,createSinh:()=>ip,createSize:()=>Eu,createSlu:()=>Xm,createSmaller:()=>pl,createSmallerEq:()=>dl,createSolveODE:()=>Gu,createSort:()=>_l,createSpaClass:()=>Rl,createSparse:()=>Ql,createSparseMatrixClass:()=>$i,createSpeedOfLight:()=>_g,createSplitUnit:()=>ca,createSqrt:()=>jo,createSqrtm:()=>bh,createSquare:()=>Lo,createSqueeze:()=>Su,createStd:()=>$h,createStdTransform:()=>Yv,createStefanBoltzmann:()=>vv,createStirlingS2:()=>_d,createString:()=>Zi,createSubset:()=>Mu,createSubsetTransform:()=>Gv,createSubtract:()=>$o,createSubtractScalar:()=>La,createSum:()=>_h,createSumTransform:()=>Jv,createSylvester:()=>Dh,createSymbolNode:()=>Am,createSymbolicEqual:()=>Xd,createTan:()=>ap,createTanh:()=>op,createTau:()=>vg,createThomsonCrossSection:()=>nv,createTo:()=>hc,createTrace:()=>Op,createTranspose:()=>ku,createTrue:()=>fg,createTypeOf:()=>ji,createTyped:()=>ct,createUnaryMinus:()=>Ba,createUnaryPlus:()=>ka,createUnequal:()=>Sl,createUnitClass:()=>Zl,createUnitFunction:()=>Jl,createUppercaseE:()=>Mg,createUppercasePi:()=>Cg,createUsolve:()=>qc,createUsolveAll:()=>Uc,createVacuumImpedance:()=>qg,createVariance:()=>Uh,createVarianceTransform:()=>ty,createVersion:()=>Fg,createWeakMixingAngle:()=>iv,createWienDisplacement:()=>yv,createXgcd:()=>Wo,createXor:()=>zs,createZeros:()=>Ru,createZeta:()=>Ku,createZpk2tf:()=>ng});var t={};r.r(t),r.d(t,{EllipsisVectorLayerBase:()=>p,evaluateExpression:()=>dy,getFeatureStyling:()=>py,getVectorLayerColor:()=>gy,parseHex:()=>fy});var i={};r.r(i),r.d(i,{getLayerId:()=>by,getSlippyMapUrl:()=>yy,getSlippyMapUrlWithDefaults:()=>xy});let a="https://api.ellipsis-drive.com/v3";function o(e,t){const r=Error.call(this,t);this.name="API Error",this.message=r.message,this.stack=r.stack,this.status=e}function s(e,t=!1){Object.entries(e).forEach((([t,r])=>{"object"==typeof r&&(e[t]=JSON.stringify(r)),null==r&&delete e[t]}));const r=new URLSearchParams(e).toString();return t?r:""===r?"":"?"+r}async function u(e,t,r,n,i){let u={"Content-Type":"application/json"};n&&(u.Authorization=`Bearer ${n.token}`);const c="HEAD"===e||"GET"===e||"DELETE"===e,l=s(c?{mapId:n?.mapId,...r}:{mapId:n?.mapId}),f=`${i??a}${t}${l}`;let p=null,m=!1,h=!1,d={method:e,headers:u};return r&&!c&&(d.body=JSON.stringify(r)),await fetch(f,d).then((e=>{e.ok||429===e.status&&alert("You made too many calls to this map and won't be able to use it for another minute. Contact the owner of this map to give you more bandwidth."),p=e;let t=e.headers.get("Content-Type");return t?(m=t.includes("text"),h=t.includes("application/json")):m=!0,h?e.json():m?e.text():e.blob()})).then((e=>{if(200===p.status)return e;throw new o(p.status,m?e:e.message)}))}const c={setApiUrl:e=>a=e,apiUrl:a,getApiUrl:()=>a,post:(e,t,r)=>u("POST",e,t,r),get:(e,t,r)=>u("GET",e,t,r),login:(e,t)=>u("POST","/account/login",{username:e,password:t}),getPath:(e,t)=>u("GET",`/path/${e}`,void 0,t),getInfo:(e,t)=>getPath(e,t)};class l extends Error{constructor(e){super(e),this.name="EllipsisVectorLayerError"}}class f{static defaultOptions={loadAll:!1,pageSize:1e3,chunkSize:10,maxMbPerTile:32,maxRenderTiles:100,maxTilesInCache:500,maxFeaturesPerTile:1e4,fetchInterval:0};static optionModifiers={pageSize:e=>Math.min(1e3,e),maxMbPerTile:e=>1e6*e,debug:e=>e?e=>console.log(e):()=>{}};loadingState={loadInterrupters:[],loadingTimeout:void 0,cache:{},featuresInTileCache:{},nextPageStart:Array(6),oldTiles:[],isLoading:!1,updateLock:!1,missedCall:!1};info={layerInfo:void 0,style:void 0};tiles=[];zoom=1;loadOptions={styleKeys:void 0,onEachFeature:void 0};getMapBounds=()=>console.error("get map bounds not implemented");updateView=()=>console.error("update view not implemented");constructor(e={}){if(e.pathId||(e.pathId=e.blockId||e.mapId,e.pathId&&console.warn("We recommended to use the property name pathId instead of mapId or blockId to identify ellipsis drive maps to reduce confusion with other libraries.")),!e.pathId)throw new l("You did not specify a path ID.");!e.timestampId&&e.layerId&&(e.timestampId=e.layerId,console.warn("We recommended to use the property name timestampId instead of layerId to identify ellipsis drive timestamps.")),Object.keys(f.defaultOptions).forEach((t=>{null==e[t]&&(e[t]=f.defaultOptions[t])})),Object.keys(f.optionModifiers).forEach((t=>e[t]=f.optionModifiers[t](e[t]))),this.options={},Object.keys(e).forEach((t=>this.options[t]=e[t])),this.id=`${this.options.pathId}_${this.options.timestampId}`}getLayerInfo=()=>this.info.layerInfo;getTilesAbove=e=>{const t=e.zoom;let r=e.zoom,n=[];for(;r>=0;){const i={zoom:r,tileX:Math.floor(e.tileX/2**(t-r)),tileY:Math.floor(e.tileY/2**(t-r))};n.push(i),r-=1}return n};getFeatures=()=>{let e=this.tiles.map((e=>this.getTilesAbove(e)));e=e.flat(),e=[...e,...this.loadingState.oldTiles];let t=e.map((e=>this.getTileId(e)));e=e.filter(((e,r,n)=>t.indexOf(this.getTileId(e))===r)),e.length>this.options.maxRenderTiles&&(e=e.slice(0,this.options.maxRenderTiles)),this.loadingState.oldTiles=e;const r={};return e.flatMap((e=>{const t=this.loadingState.featuresInTileCache[this.getTileId(e)]?.featureIds;return t?t.map((e=>{const t=this.loadingState.cache[e];return t&&t&&!r[e]?(r[e]=!0,t):null})).filter((e=>e)):[]}))};clearLayer=async()=>{await this.awaitNotLoading(),this.loadingState.cache={},this.loadingState.featuresInTileCache={},this.loadingState.nextPageStart=Array(6)};update=async()=>{if(this.loadingState.updateLock)return;this.options.debug("update.."),this.info.layerInfo||(this.loadingState.updateLock=!0,await this.fetchLayerInfo(),this.loadingState.updateLock=!1,this.options.debug("fetched layer info:"),this.options.debug(this.info.layerInfo),this.options.debug("fetched style info:"),this.options.debug(this.info.style));const e=this.getMapBounds();if(!e)return;const t=this.options.loadAll?0:this.options.maxZoom??this.options.zoom??this.info.layerInfo.zoom;this.zoom=Math.max(Math.min(t,e.zoom-2),0),this.tiles=this.boundsToTiles(e.bounds,this.zoom),this.load((()=>{this.updateView()}),this.options.fetchInterval)};load=async(e,t)=>{if(this.loadingState.loadingTimeout)return;if(this.loadingState.isLoading)return void(this.loadingState.missedCall=!0);this.loadingState.missedCall=!1,this.options.debug("load"),this.loadingState.isLoading=!0;const r=await this.requestTileGeoJsons();return this.loadingState.isLoading=!1,this.loadingState.loadInterrupters.length?(this.loadingState.loadingTimeout=void 0,this.loadingState.loadInterrupters.forEach((e=>e())),void(this.loadingState.loadInterrupters=[])):r||this.loadingState.missedCall?(this.options.debug("loaded new data, page start: "+this.loadingState.nextPageStart),e(),void(this.loadingState.loadingTimeout=setTimeout((()=>{this.loadingState.loadingTimeout=void 0,this.load(e,t)}),t))):(this.options.debug("did not cache new data"),void this.ensureMaxCacheSize())};awaitNotLoading=e=>new Promise(((t,r)=>this.loadingState.loadingTimeout||this.loadingState.isLoading?this.loadingState.isLoading?this.loadingState.loadInterrupters.push((()=>t())):this.loadingState.loadingTimeout?(clearTimeout(this.loadingState.loadingTimeout),this.loadingState.loadingTimeout=void 0,e?t():setTimeout((()=>t()),this.options.fetchInterval)):void r():t()));ensureMaxCacheSize=()=>{};comparePageStarts=(e,t)=>{let r=e;return t&&(!e||(!e.value||t.value>=e.value)&&t.featureId>e.featureId)&&(r=t),r};getPageStart=e=>{let t=this.loadingState.featuresInTileCache[this.getTileId(e)].nextPageStart;const r=this.getTilesAbove(e);for(let e=0;e<r.length;e++){const n=this.getTileId(r[e]);this.loadingState.featuresInTileCache&&this.loadingState.featuresInTileCache[n]&&this.loadingState.featuresInTileCache[n].nextPageStart&&(t=this.comparePageStarts(t,this.loadingState.featuresInTileCache[n].nextPageStart))}return t};getStyle=()=>{const e=this.options.style?"string"==typeof this.options.style?this.info.pathStyles.find((e=>e.id===this.options.style)):this.options.style:this.info.pathStyles.find((e=>e.default));if(!e)throw new l("Given style not found");return e};requestTileGeoJsons=async()=>{const e=Date.now(),t=this.tiles.map((e=>{const t=this.getTileId(e);if(this.loadingState.featuresInTileCache[t]?.done)return null;if(!this.loadingState.featuresInTileCache[t])return{tileId:e};const r=this.getPageStart(e);return r&&this.loadingState.featuresInTileCache[t].amount<=this.options.maxFeaturesPerTile&&this.loadingState.featuresInTileCache[t].size<=this.options.maxMbPerTile||this.options.loadAll&&r?{tileId:e,pageStart:r}:null})).filter((e=>e));if(0===t.length)return!1;const r={zipTheResponse:!0,pageSize:this.options.pageSize,style:this.options.style},n=this.getStyle();let i=[];const a=this.options.chunkSize;for(let e=0;e<t.length;e+=a){r.tiles=t.slice(e,e+a);try{let e;this.options.loadAll&&!r.tiles[0].pageStart?(e=await c.get(`/path/${this.options.pathId}/vector/timestamp/${this.info.layerInfo.id}/compressedListFeatures`,r,{token:this.options.token}),e.nextPageStart=e.nextPageStart?{featureId:e.nextPageStart}:null,e=[e]):e=await c.get(`/path/${this.options.pathId}/vector/timestamp/${this.info.layerInfo.id}/featuresByTiles`,r,{token:this.options.token}),i=i.concat(e)}catch(e){return console.error("an error occured with getting tile features"),console.error(e),!1}}for(let r=0;r<t.length;r++){const a=this.getTileId(t[r].tileId);this.loadingState.featuresInTileCache[a]||(this.loadingState.featuresInTileCache[a]={size:0,amount:0,featureIds:[],nextPageStart:null}),this.options.filter&&(i[r].result.features=i[r].result.features.filter((e=>dy(this.options.filter,e.properties)))),this.options.manipulateCoords&&(i[r].result.features=i[r].result.features.map((e=>this.options.manipulateCoords(e)))),i[r].result.features=i[r].result.features.map((e=>(e.properties.color=gy(e.properties,n),e)));const o=this.loadingState.featuresInTileCache[a];o.date=e,o.size=o.size+i[r].size,o.amount=o.amount+i[r].result.features.length,o.nextPageStart=i[r].nextPageStart,o.done=!i[r].nextPageStart,i[r].result.features&&i[r].result.features.forEach((e=>{this.compileStyle(e),this.loadOptions.onEachFeature&&this.loadOptions.onEachFeature(e)})),o.featureIds.push(...i[r].result.features.map((e=>e.properties.id))),i[r].result.features.forEach((e=>{const t=e.properties.id;this.loadingState.cache[t]||(this.loadingState.cache[t]=e)}))}return!0};fetchLayerInfo=async()=>{const e=await c.getPath(this.options.pathId,{token:this.options.token});if(!e?.vector?.timestamps?.length)throw new l(`Specified path "${this.options.pathId}" does not contain any data.`);if(e.trashed&&console.warn("Path is trashed."),"vector"!==e.type)throw new l("Path info type is not vector.");const t=e.vector.timestamps;this.info.pathStyles=e.vector.styles;const r=t?.reverse().find((e=>!e.trashed&&!e.availability.blocked&&"active"===e.status));if(!this.options.timestampId&&r)this.info.layerInfo=r,this.options.debug(`No timestamp ID specified. Picked default ${r.id}`);else{const e=t.find((e=>e.id===this.options.timestampId));if(e)this.info.layerInfo=e;else if(!e&&r)this.info.layerInfo=r,this.options.debug(`No correct timestamp ID specified. Picked default ${r.id}`);else if(!e&&!r)throw new l(`Specified timestamp with id=${this.options.timestampId} does not exist and the path has no default timestamp to use as a fallback.`)}};recompileStyles=()=>{this.getFeatures().forEach((e=>this.compileStyle(e)))};compileStyle=e=>{const t=this.getStyle();let r=py(e,t,e.properties);e.properties.compiledStyle=r};getTileId=e=>`${e.zoom}_${e.tileX}_${e.tileY}`;boundsToTiles=(e,t)=>{const r=Math.max(e.xMin,-180),n=Math.min(e.xMax,180),i=Math.max(e.yMin,-85),a=Math.min(e.yMax,85),o=Math.pow(2,t),s=o/360,u=Math.PI,c=2*u,l=u/4,f=Math.floor((r+180)*s),p=Math.floor((n+180)*s),m=Math.floor(o/c*(u-Math.log(Math.tan(l+a/360*u)))),h=Math.floor(o/c*(u-Math.log(Math.tan(l+i/360*u))));let d=[];for(let e=Math.max(0,f-1);e<=Math.min(2**t-1,p+1);e++)for(let r=Math.max(0,m-1);r<=Math.min(2**t-1,h+1);r++)d.push({zoom:t,tileX:e,tileY:r});return d}}const p=f;function m(){return m=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},m.apply(null,arguments)}var h=r(4814);function d(e,t,r,n){if(!(this instanceof d))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=t,this.min=r,this.max=n,this.message="Wrong number of arguments in function "+e+" ("+t+" provided, "+r+(null!=n?"-"+n:"")+" expected)",this.stack=(new Error).stack}function g(e,t,r){if(!(this instanceof g))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=t,this.relation=r,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=(new Error).stack}function v(e,t,r){if(!(this instanceof v))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=r),void 0!==this.min&&this.index<this.min?this.message="Index out of range ("+this.index+" < "+this.min+")":void 0!==this.max&&this.index>=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}function y(e,t){if(b(e,t))return e[t];if("function"==typeof e[t]&&w(e,t))throw new Error('Cannot access method "'+t+'" as a property');throw new Error('No access to property "'+t+'"')}function x(e,t,r){if(b(e,t))return e[t]=r,r;throw new Error('No access to property "'+t+'"')}function b(e,t){return!(!function(e){return"object"==typeof e&&e&&e.constructor===Object}(e)&&!Array.isArray(e)||!Ce(D,t)&&(t in Object.prototype||t in Function.prototype))}function w(e,t){return!(null==e||"function"!=typeof e[t]||Ce(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e)||!Ce(N,t)&&(t in Object.prototype||t in Function.prototype))}d.prototype=new Error,d.prototype.constructor=Error,d.prototype.name="ArgumentsError",d.prototype.isArgumentsError=!0,g.prototype=new RangeError,g.prototype.constructor=RangeError,g.prototype.name="DimensionError",g.prototype.isDimensionError=!0,v.prototype=new RangeError,v.prototype.constructor=RangeError,v.prototype.name="IndexError",v.prototype.isIndexError=!0;var D={length:!0,name:!0},N={toString:!0,valueOf:!0,toLocaleString:!0};class E{constructor(e){this.wrappedObject=e,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).filter((e=>this.has(e))).values()}get(e){return y(this.wrappedObject,e)}set(e,t){return x(this.wrappedObject,e,t),this}has(e){return b(this.wrappedObject,e)&&e in this.wrappedObject}entries(){return S(this.keys(),(e=>[e,this.get(e)]))}forEach(e){for(var t of this.keys())e(this.get(t),t,this)}delete(e){b(this.wrappedObject,e)&&delete this.wrappedObject[e]}clear(){for(var e of this.keys())this.delete(e)}get size(){return Object.keys(this.wrappedObject).length}}class A{constructor(e,t,r){this.a=e,this.b=t,this.bKeys=r,this[Symbol.iterator]=this.entries}get(e){return this.bKeys.has(e)?this.b.get(e):this.a.get(e)}set(e,t){return this.bKeys.has(e)?this.b.set(e,t):this.a.set(e,t),this}has(e){return this.b.has(e)||this.a.has(e)}keys(){return new Set([...this.a.keys(),...this.b.keys()])[Symbol.iterator]()}entries(){return S(this.keys(),(e=>[e,this.get(e)]))}forEach(e){for(var t of this.keys())e(this.get(t),t,this)}delete(e){return this.bKeys.has(e)?this.b.delete(e):this.a.delete(e)}clear(){this.a.clear(),this.b.clear()}get size(){return[...this.keys()].length}}function S(e,t){return{next:()=>{var r=e.next();return r.done?r:{value:t(r.value),done:!1}}}}function C(){return new Map}function M(e){if(!e)return C();if(J(e))return e;if(Y(e))return new E(e);throw new Error("createMap can create maps from objects or Maps")}function F(e){return"number"==typeof e}function T(e){return!(!e||"object"!=typeof e||"function"!=typeof e.constructor)&&(!0===e.isBigNumber&&"object"==typeof e.constructor.prototype&&!0===e.constructor.prototype.isBigNumber||"function"==typeof e.constructor.isDecimal&&!0===e.constructor.isDecimal(e))}function _(e){return"bigint"==typeof e}function B(e){return e&&"object"==typeof e&&!0===Object.getPrototypeOf(e).isComplex||!1}function O(e){return e&&"object"==typeof e&&!0===Object.getPrototypeOf(e).isFraction||!1}function k(e){return e&&!0===e.constructor.prototype.isUnit||!1}function z(e){return"string"==typeof e}var I=Array.isArray;function q(e){return e&&!0===e.constructor.prototype.isMatrix||!1}function R(e){return Array.isArray(e)||q(e)}function P(e){return e&&e.isDenseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function j(e){return e&&e.isSparseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function U(e){return e&&!0===e.constructor.prototype.isRange||!1}function L(e){return e&&!0===e.constructor.prototype.isIndex||!1}function H(e){return"boolean"==typeof e}function $(e){return e&&!0===e.constructor.prototype.isResultSet||!1}function G(e){return e&&!0===e.constructor.prototype.isHelp||!1}function W(e){return"function"==typeof e}function V(e){return e instanceof Date}function Z(e){return e instanceof RegExp}function Y(e){return!(!e||"object"!=typeof e||e.constructor!==Object||B(e)||O(e))}function J(e){return!!e&&(e instanceof Map||e instanceof E||"function"==typeof e.set&&"function"==typeof e.get&&"function"==typeof e.keys&&"function"==typeof e.has)}function X(e){return J(e)&&J(e.a)&&J(e.b)}function Q(e){return J(e)&&Y(e.wrappedObject)}function K(e){return null===e}function ee(e){return void 0===e}function te(e){return e&&!0===e.isAccessorNode&&!0===e.constructor.prototype.isNode||!1}function re(e){return e&&!0===e.isArrayNode&&!0===e.constructor.prototype.isNode||!1}function ne(e){return e&&!0===e.isAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function ie(e){return e&&!0===e.isBlockNode&&!0===e.constructor.prototype.isNode||!1}function ae(e){return e&&!0===e.isConditionalNode&&!0===e.constructor.prototype.isNode||!1}function oe(e){return e&&!0===e.isConstantNode&&!0===e.constructor.prototype.isNode||!1}function se(e){return oe(e)||me(e)&&1===e.args.length&&oe(e.args[0])&&"-+~".includes(e.op)}function ue(e){return e&&!0===e.isFunctionAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function ce(e){return e&&!0===e.isFunctionNode&&!0===e.constructor.prototype.isNode||!1}function le(e){return e&&!0===e.isIndexNode&&!0===e.constructor.prototype.isNode||!1}function fe(e){return e&&!0===e.isNode&&!0===e.constructor.prototype.isNode||!1}function pe(e){return e&&!0===e.isObjectNode&&!0===e.constructor.prototype.isNode||!1}function me(e){return e&&!0===e.isOperatorNode&&!0===e.constructor.prototype.isNode||!1}function he(e){return e&&!0===e.isParenthesisNode&&!0===e.constructor.prototype.isNode||!1}function de(e){return e&&!0===e.isRangeNode&&!0===e.constructor.prototype.isNode||!1}function ge(e){return e&&!0===e.isRelationalNode&&!0===e.constructor.prototype.isNode||!1}function ve(e){return e&&!0===e.isSymbolNode&&!0===e.constructor.prototype.isNode||!1}function ye(e){return e&&!0===e.constructor.prototype.isChain||!1}function xe(e){var t=typeof e;return"object"===t?null===e?"null":T(e)?"BigNumber":e.constructor&&e.constructor.name?e.constructor.name:"Object":t}function be(e){var t=typeof e;if("number"===t||"bigint"===t||"string"===t||"boolean"===t||null==e)return e;if("function"==typeof e.clone)return e.clone();if(Array.isArray(e))return e.map((function(e){return be(e)}));if(e instanceof Date)return new Date(e.valueOf());if(T(e))return e;if(Y(e))return function(e,t){var r={};for(var n in e)Ce(e,n)&&(r[n]=t(e[n]));return r}(e,be);if("function"===t)return e;throw new TypeError("Cannot clone: unknown type of value (value: ".concat(e,")"))}function we(e,t){for(var r in t)Ce(t,r)&&(e[r]=t[r]);return e}function De(e,t){if(Array.isArray(t))throw new TypeError("Arrays are not supported by deepExtend");for(var r in t)if(Ce(t,r)&&!(r in Object.prototype)&&!(r in Function.prototype))if(t[r]&&t[r].constructor===Object)void 0===e[r]&&(e[r]={}),e[r]&&e[r].constructor===Object?De(e[r],t[r]):e[r]=t[r];else{if(Array.isArray(t[r]))throw new TypeError("Arrays are not supported by deepExtend");e[r]=t[r]}return e}function Ne(e,t){var r,n,i;if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(n=0,i=e.length;n<i;n++)if(!Ne(e[n],t[n]))return!1;return!0}if("function"==typeof e)return e===t;if(e instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(r in e)if(!(r in t)||!Ne(e[r],t[r]))return!1;for(r in t)if(!(r in e))return!1;return!0}return e===t}function Ee(e){var t={};return Ae(e,t),t}function Ae(e,t){for(var r in e)if(Ce(e,r)){var n=e[r];"object"==typeof n&&null!==n?Ae(n,t):t[r]=n}}function Se(e,t,r){var n,i=!0;Object.defineProperty(e,t,{get:function(){return i&&(n=r(),i=!1),n},set:function(e){n=e,i=!1},configurable:!0,enumerable:!0})}function Ce(e,t){return e&&Object.hasOwnProperty.call(e,t)}function Me(e,t,r,n){function i(n){var i=function(e,t){for(var r={},n=0;n<t.length;n++){var i=t[n],a=e[i];void 0!==a&&(r[i]=a)}return r}(n,t.map(Te));return function(e,t,r){if(!t.filter((e=>!function(e){return e&&"?"===e[0]}(e))).every((e=>void 0!==r[e]))){var n=t.filter((e=>void 0===r[e]));throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(n.map((e=>'"'.concat(e,'"'))).join(", "),"."))}}(e,t,n),r(i)}return i.isFactory=!0,i.fn=e,i.dependencies=t.slice().sort(),n&&(i.meta=n),i}function Fe(e){return"function"==typeof e&&"string"==typeof e.fn&&Array.isArray(e.dependencies)}function Te(e){return e&&"?"===e[0]?e.slice(1):e}var _e=r(4279),Be={relTol:1e-12,absTol:1e-15,matrix:"Matrix",number:"number",numberFallback:"number",precision:64,predictable:!1,randomSeed:null},Oe=["Matrix","Array"],ke=["number","BigNumber","Fraction"];function ze(e,t){function r(n){if(n){if(void 0!==n.epsilon){console.warn('Warning: The configuration option "epsilon" is deprecated. Use "relTol" and "absTol" instead.');var i=be(n);return i.relTol=n.epsilon,i.absTol=.001*n.epsilon,delete i.epsilon,r(i)}var a=be(e);Ie(n,"matrix",Oe),Ie(n,"number",ke),De(e,n);var o=be(e),s=be(n);return t("config",o,a,s),o}return be(e)}return r.MATRIX_OPTIONS=Oe,r.NUMBER_OPTIONS=ke,Object.keys(Be).forEach((t=>{Object.defineProperty(r,t,{get:()=>e[t],enumerable:!0,configurable:!0})})),r}function Ie(e,t,r){void 0===e[t]||r.includes(e[t])||console.warn('Warning: Unknown value "'+e[t]+'" for configuration option "'+t+'". Available options: '+r.map((e=>JSON.stringify(e))).join(", ")+".")}function qe(e){return"boolean"==typeof e||!!isFinite(e)&&e===Math.round(e)}function Re(e,t){return"bigint"!==t.number||/^-?\d+$/.test(e)?t.number:t.numberFallback}var Pe=Math.sign||function(e){return e>0?1:e<0?-1:0},je=Math.log2||function(e){return Math.log(e)/Math.LN2},Ue=Math.log10||function(e){return Math.log(e)/Math.LN10},Le=Math.log1p||function(e){return Math.log(e+1)},He=Math.cbrt||function(e){if(0===e)return e;var t,r=e<0;return r&&(e=-e),t=isFinite(e)?(e/((t=Math.exp(Math.log(e)/3))*t)+2*t)/3:e,r?-t:t},$e=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function Ge(e,t,r){var n={2:"0b",8:"0o",16:"0x"}[t],i="";if(r){if(r<1)throw new Error("size must be in greater than 0");if(!qe(r))throw new Error("size must be an integer");if(e>2**(r-1)-1||e<-(2**(r-1)))throw new Error("Value must be in range [-2^".concat(r-1,", 2^").concat(r-1,"-1]"));if(!qe(e))throw new Error("Value must be an integer");e<0&&(e+=2**r),i="i".concat(r)}var a="";return e<0&&(e=-e,a="-"),"".concat(a).concat(n).concat(e.toString(t)).concat(i)}function We(e,t){if("function"==typeof t)return t(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var{notation:r,precision:n,wordSize:i}=Ve(t);switch(r){case"fixed":return Ye(e,n);case"exponential":return Je(e,n);case"engineering":return function(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=Xe(Ze(e),t),n=r.exponent,i=r.coefficients,a=n%3==0?n:n<0?n-3-n%3:n-n%3;if(F(t))for(;t>i.length||n-a+1>i.length;)i.push(0);else for(var o=Math.abs(n-a)-(i.length-1),s=0;s<o;s++)i.push(0);for(var u=Math.abs(n-a),c=1;u>0;)c++,u--;var l=i.slice(c).join(""),f=F(t)&&l.length||l.match(/[1-9]/)?"."+l:"",p=i.slice(0,c).join("")+f+"e"+(n>=0?"+":"")+a.toString();return r.sign+p}(e,n);case"bin":return Ge(e,2,i);case"oct":return Ge(e,8,i);case"hex":return Ge(e,16,i);case"auto":return function(e,t,r){if(isNaN(e)||!isFinite(e))return String(e);var n=st(null==r?void 0:r.lowerExp,-3),i=st(null==r?void 0:r.upperExp,5),a=Ze(e),o=t?Xe(a,t):a;if(o.exponent<n||o.exponent>=i)return Je(e,t);var s=o.coefficients,u=o.exponent;s.length<t&&(s=s.concat(Qe(t-s.length))),s=s.concat(Qe(u-s.length+1+(s.length<t?t-s.length:0)));var c=u>0?u:0;return c<(s=Qe(-u).concat(s)).length-1&&s.splice(c+1,0,"."),o.sign+s.join("")}(e,n,t).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t}));default:throw new Error('Unknown notation "'+r+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function Ve(e){var t,r,n="auto";if(void 0!==e)if(F(e))t=e;else if(T(e))t=e.toNumber();else{if(!Y(e))throw new Error("Unsupported type of options, number, BigNumber, or object expected");void 0!==e.precision&&(t=ot(e.precision,(()=>{throw new Error('Option "precision" must be a number or BigNumber')}))),void 0!==e.wordSize&&(r=ot(e.wordSize,(()=>{throw new Error('Option "wordSize" must be a number or BigNumber')}))),e.notation&&(n=e.notation)}return{notation:n,precision:t,wordSize:r}}function Ze(e){var t=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+e);var r=t[1],n=t[2],i=parseFloat(t[4]||"0"),a=n.indexOf(".");i+=-1!==a?a-1:n.length-1;var o=n.replace(".","").replace(/^0*/,(function(e){return i-=e.length,""})).replace(/0*$/,"").split("").map((function(e){return parseInt(e)}));return 0===o.length&&(o.push(0),i++),{sign:r,coefficients:o,exponent:i}}function Ye(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=Ze(e),n="number"==typeof t?Xe(r,r.exponent+1+t):r,i=n.coefficients,a=n.exponent+1,o=a+(t||0);return i.length<o&&(i=i.concat(Qe(o-i.length))),a<0&&(i=Qe(1-a).concat(i),a=1),a<i.length&&i.splice(a,0,0===a?"0.":"."),n.sign+i.join("")}function Je(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=Ze(e),n=t?Xe(r,t):r,i=n.coefficients,a=n.exponent;i.length<t&&(i=i.concat(Qe(t-i.length)));var o=i.shift();return n.sign+o+(i.length>0?"."+i.join(""):"")+"e"+(a>=0?"+":"")+a}function Xe(e,t){for(var r={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},n=r.coefficients;t<=0;)n.unshift(0),r.exponent++,t++;if(n.length>t&&n.splice(t,n.length-t)[0]>=5){var i=t-1;for(n[i]++;10===n[i];)n.pop(),0===i&&(n.unshift(0),r.exponent++,i++),n[--i]++}return r}function Qe(e){for(var t=[],r=0;r<e;r++)t.push(0);return t}function Ke(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e-8,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(r<=0)throw new Error("Relative tolerance must be greater than 0");if(n<0)throw new Error("Absolute tolerance must be at least 0");return!isNaN(e)&&!isNaN(t)&&(isFinite(e)&&isFinite(t)?e===t||Math.abs(e-t)<=Math.max(r*Math.max(Math.abs(e),Math.abs(t)),n):e===t)}Number.EPSILON;var et=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)},tt=Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},rt=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2},nt=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2},it=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2},at=Math.tanh||function(e){var t=Math.exp(2*e);return(t-1)/(t+1)};function ot(e,t){return F(e)?e:T(e)?e.toNumber():void t()}function st(e,t){return F(e)?e:T(e)?e.toNumber():t}var ut=function(){return ut=h.create,h},ct=Me("typed",["?BigNumber","?Complex","?DenseMatrix","?Fraction"],(function(e){var{BigNumber:t,Complex:r,DenseMatrix:n,Fraction:i}=e,a=ut();return a.clear(),a.addTypes([{name:"number",test:F},{name:"Complex",test:B},{name:"BigNumber",test:T},{name:"bigint",test:_},{name:"Fraction",test:O},{name:"Unit",test:k},{name:"identifier",test:e=>z&&/^(?:[A-Za-z\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\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\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\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\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\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\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-\uA6E5\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]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC4\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[0-9A-Za-z\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\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\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\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\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\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\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-\uA6E5\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]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC4\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])*$/.test(e)},{name:"string",test:z},{name:"Chain",test:ye},{name:"Array",test:I},{name:"Matrix",test:q},{name:"DenseMatrix",test:P},{name:"SparseMatrix",test:j},{name:"Range",test:U},{name:"Index",test:L},{name:"boolean",test:H},{name:"ResultSet",test:$},{name:"Help",test:G},{name:"function",test:W},{name:"Date",test:V},{name:"RegExp",test:Z},{name:"null",test:K},{name:"undefined",test:ee},{name:"AccessorNode",test:te},{name:"ArrayNode",test:re},{name:"AssignmentNode",test:ne},{name:"BlockNode",test:ie},{name:"ConditionalNode",test:ae},{name:"ConstantNode",test:oe},{name:"FunctionNode",test:ce},{name:"FunctionAssignmentNode",test:ue},{name:"IndexNode",test:le},{name:"Node",test:fe},{name:"ObjectNode",test:pe},{name:"OperatorNode",test:me},{name:"ParenthesisNode",test:he},{name:"RangeNode",test:de},{name:"RelationalNode",test:ge},{name:"SymbolNode",test:ve},{name:"Map",test:J},{name:"Object",test:Y}]),a.addConversions([{from:"number",to:"BigNumber",convert:function(e){if(t||lt(e),e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new t(e)}},{from:"number",to:"Complex",convert:function(e){return r||ft(e),new r(e,0)}},{from:"BigNumber",to:"Complex",convert:function(e){return r||ft(e),new r(e.toNumber(),0)}},{from:"bigint",to:"number",convert:function(e){if(e>Number.MAX_SAFE_INTEGER)throw new TypeError("Cannot implicitly convert bigint to number: value exceeds the max safe integer value (value: "+e+")");return Number(e)}},{from:"bigint",to:"BigNumber",convert:function(e){return t||lt(e),new t(e.toString())}},{from:"bigint",to:"Fraction",convert:function(e){return i||pt(e),new i(e.toString())}},{from:"Fraction",to:"BigNumber",convert:function(e){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(e){return r||ft(e),new r(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){i||pt(e);var t=new i(e);if(t.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return t}},{from:"string",to:"number",convert:function(e){var t=Number(e);if(isNaN(t))throw new Error('Cannot convert "'+e+'" to a number');return t}},{from:"string",to:"BigNumber",convert:function(e){t||lt(e);try{return new t(e)}catch(t){throw new Error('Cannot convert "'+e+'" to BigNumber')}}},{from:"string",to:"bigint",convert:function(e){try{return BigInt(e)}catch(t){throw new Error('Cannot convert "'+e+'" to BigInt')}}},{from:"string",to:"Fraction",convert:function(e){i||pt(e);try{return new i(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(e){r||ft(e);try{return new r(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return t||lt(e),new t(+e)}},{from:"boolean",to:"bigint",convert:function(e){return BigInt(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return i||pt(e),new i(+e)}},{from:"boolean",to:"string",convert:function(e){return String(e)}},{from:"Array",to:"Matrix",convert:function(e){return n||function(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}(),new n(e)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}]),a.onMismatch=(e,t,r)=>{var n=a.createError(e,t,r);if(["wrongType","mismatch"].includes(n.data.category)&&1===t.length&&R(t[0])&&r.some((e=>!e.params.includes(",")))){var i=new TypeError("Function '".concat(e,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(e,")'."));throw i.data=n.data,i}throw n},a.onMismatch=(e,t,r)=>{var n=a.createError(e,t,r);if(["wrongType","mismatch"].includes(n.data.category)&&1===t.length&&R(t[0])&&r.some((e=>!e.params.includes(",")))){var i=new TypeError("Function '".concat(e,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(e,")'."));throw i.data=n.data,i}throw n},a}));function lt(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function ft(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function pt(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var mt,ht,dt=Me("ResultSet",[],(()=>{function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=t||[]}return e.prototype.type="ResultSet",e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return"["+this.entries.map(String).join(", ")+"]"},e.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},e.fromJSON=function(t){return new e(t.entries)},e}),{isClass:!0}),gt=9e15,vt=1e9,yt="0123456789abcdef",xt="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",bt="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",wt={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-gt,maxE:gt,crypto:!1},Dt=!0,Nt="[DecimalError] ",Et=Nt+"Invalid argument: ",At=Nt+"Precision limit exceeded",St=Nt+"crypto unavailable",Ct="[object Decimal]",Mt=Math.floor,Ft=Math.pow,Tt=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,_t=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Bt=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Ot=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,kt=1e7,zt=7,It=xt.length-1,qt=bt.length-1,Rt={toStringTag:Ct};function Pt(e){var t,r,n,i=e.length-1,a="",o=e[0];if(i>0){for(a+=o,t=1;t<i;t++)n=e[t]+"",(r=zt-n.length)&&(a+=Jt(r)),a+=n;o=e[t],(r=zt-(n=o+"").length)&&(a+=Jt(r))}else if(0===o)return"0";for(;o%10==0;)o/=10;return a+o}function jt(e,t,r){if(e!==~~e||e<t||e>r)throw Error(Et+e)}function Ut(e,t,r,n){var i,a,o,s;for(a=e[0];a>=10;a/=10)--t;return--t<0?(t+=zt,i=0):(i=Math.ceil((t+1)/zt),t%=zt),a=Ft(10,zt-t),s=e[i]%a|0,null==n?t<3?(0==t?s=s/100|0:1==t&&(s=s/10|0),o=r<4&&99999==s||r>3&&49999==s||5e4==s||0==s):o=(r<4&&s+1==a||r>3&&s+1==a/2)&&(e[i+1]/a/100|0)==Ft(10,t-2)-1||(s==a/2||0==s)&&0==(e[i+1]/a/100|0):t<4?(0==t?s=s/1e3|0:1==t?s=s/100|0:2==t&&(s=s/10|0),o=(n||r<4)&&9999==s||!n&&r>3&&4999==s):o=((n||r<4)&&s+1==a||!n&&r>3&&s+1==a/2)&&(e[i+1]/a/1e3|0)==Ft(10,t-3)-1,o}function Lt(e,t,r){for(var n,i,a=[0],o=0,s=e.length;o<s;){for(i=a.length;i--;)a[i]*=t;for(a[0]+=yt.indexOf(e.charAt(o++)),n=0;n<a.length;n++)a[n]>r-1&&(void 0===a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/r|0,a[n]%=r)}return a.reverse()}Rt.absoluteValue=Rt.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),$t(e)},Rt.ceil=function(){return $t(new this.constructor(this),this.e+1,2)},Rt.clampedTo=Rt.clamp=function(e,t){var r=this,n=r.constructor;if(e=new n(e),t=new n(t),!e.s||!t.s)return new n(NaN);if(e.gt(t))throw Error(Et+t);return r.cmp(e)<0?e:r.cmp(t)>0?t:new n(r)},Rt.comparedTo=Rt.cmp=function(e){var t,r,n,i,a=this,o=a.d,s=(e=new a.constructor(e)).d,u=a.s,c=e.s;if(!o||!s)return u&&c?u!==c?u:o===s?0:!o^u<0?1:-1:NaN;if(!o[0]||!s[0])return o[0]?u:s[0]?-c:0;if(u!==c)return u;if(a.e!==e.e)return a.e>e.e^u<0?1:-1;for(t=0,r=(n=o.length)<(i=s.length)?n:i;t<r;++t)if(o[t]!==s[t])return o[t]>s[t]^u<0?1:-1;return n===i?0:n>i^u<0?1:-1},Rt.cosine=Rt.cos=function(){var e,t,r=this,n=r.constructor;return r.d?r.d[0]?(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+zt,n.rounding=1,r=function(e,t){var r,n,i;if(t.isZero())return t;(n=t.d.length)<32?i=(1/or(4,r=Math.ceil(n/3))).toString():(r=16,i="2.3283064365386962890625e-10"),e.precision+=r,t=ar(e,1,t.times(i),new e(1));for(var a=r;a--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=r,t}(n,sr(n,r)),n.precision=e,n.rounding=t,$t(2==ht||3==ht?r.neg():r,e,t,!0)):new n(1):new n(NaN)},Rt.cubeRoot=Rt.cbrt=function(){var e,t,r,n,i,a,o,s,u,c,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(Dt=!1,(a=l.s*Ft(l.s*l,1/3))&&Math.abs(a)!=1/0?n=new f(a.toString()):(r=Pt(l.d),(a=((e=l.e)-r.length+1)%3)&&(r+=1==a||-2==a?"0":"00"),a=Ft(r,1/3),e=Mt((e+1)/3)-(e%3==(e<0?-1:2)),(n=new f(r=a==1/0?"5e"+e:(r=a.toExponential()).slice(0,r.indexOf("e")+1)+e)).s=l.s),o=(e=f.precision)+3;;)if(c=(u=(s=n).times(s).times(s)).plus(l),n=Ht(c.plus(l).times(s),c.plus(u),o+2,1),Pt(s.d).slice(0,o)===(r=Pt(n.d)).slice(0,o)){if("9999"!=(r=r.slice(o-3,o+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||($t(n,e+1,1),t=!n.times(n).times(n).eq(l));break}if(!i&&($t(s,e+1,0),s.times(s).times(s).eq(l))){n=s;break}o+=4,i=1}return Dt=!0,$t(n,e,f.rounding,t)},Rt.decimalPlaces=Rt.dp=function(){var e,t=this.d,r=NaN;if(t){if(r=((e=t.length-1)-Mt(this.e/zt))*zt,e=t[e])for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r},Rt.dividedBy=Rt.div=function(e){return Ht(this,new this.constructor(e))},Rt.dividedToIntegerBy=Rt.divToInt=function(e){var t=this.constructor;return $t(Ht(this,new t(e),0,1,1),t.precision,t.rounding)},Rt.equals=Rt.eq=function(e){return 0===this.cmp(e)},Rt.floor=function(){return $t(new this.constructor(this),this.e+1,3)},Rt.greaterThan=Rt.gt=function(e){return this.cmp(e)>0},Rt.greaterThanOrEqualTo=Rt.gte=function(e){var t=this.cmp(e);return 1==t||0===t},Rt.hyperbolicCosine=Rt.cosh=function(){var e,t,r,n,i,a=this,o=a.constructor,s=new o(1);if(!a.isFinite())return new o(a.s?1/0:NaN);if(a.isZero())return s;r=o.precision,n=o.rounding,o.precision=r+Math.max(a.e,a.sd())+4,o.rounding=1,(i=a.d.length)<32?t=(1/or(4,e=Math.ceil(i/3))).toString():(e=16,t="2.3283064365386962890625e-10"),a=ar(o,1,a.times(t),new o(1),!0);for(var u,c=e,l=new o(8);c--;)u=a.times(a),a=s.minus(u.times(l.minus(u.times(l))));return $t(a,o.precision=r,o.rounding=n,!0)},Rt.hyperbolicSine=Rt.sinh=function(){var e,t,r,n,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.precision,r=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,(n=i.d.length)<3)i=ar(a,2,i,i,!0);else{e=(e=1.4*Math.sqrt(n))>16?16:0|e,i=ar(a,2,i=i.times(1/or(5,e)),i,!0);for(var o,s=new a(5),u=new a(16),c=new a(20);e--;)o=i.times(i),i=i.times(s.plus(o.times(u.times(o).plus(c))))}return a.precision=t,a.rounding=r,$t(i,t,r,!0)},Rt.hyperbolicTangent=Rt.tanh=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+7,n.rounding=1,Ht(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)},Rt.inverseCosine=Rt.acos=function(){var e,t=this,r=t.constructor,n=t.abs().cmp(1),i=r.precision,a=r.rounding;return-1!==n?0===n?t.isNeg()?Zt(r,i,a):new r(0):new r(NaN):t.isZero()?Zt(r,i+4,a).times(.5):(r.precision=i+6,r.rounding=1,t=t.asin(),e=Zt(r,i+4,a).times(.5),r.precision=i,r.rounding=a,e.minus(t))},Rt.inverseHyperbolicCosine=Rt.acosh=function(){var e,t,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(e=n.precision,t=n.rounding,n.precision=e+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,Dt=!1,r=r.times(r).minus(1).sqrt().plus(r),Dt=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)},Rt.inverseHyperbolicSine=Rt.asinh=function(){var e,t,r=this,n=r.constructor;return!r.isFinite()||r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,Dt=!1,r=r.times(r).plus(1).sqrt().plus(r),Dt=!0,n.precision=e,n.rounding=t,r.ln())},Rt.inverseHyperbolicTangent=Rt.atanh=function(){var e,t,r,n,i=this,a=i.constructor;return i.isFinite()?i.e>=0?new a(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=a.precision,t=a.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?$t(new a(i),e,t,!0):(a.precision=r=n-i.e,i=Ht(i.plus(1),new a(1).minus(i),r+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=t,i.times(.5))):new a(NaN)},Rt.inverseSine=Rt.asin=function(){var e,t,r,n,i=this,a=i.constructor;return i.isZero()?new a(i):(t=i.abs().cmp(1),r=a.precision,n=a.rounding,-1!==t?0===t?((e=Zt(a,r+4,n).times(.5)).s=i.s,e):new a(NaN):(a.precision=r+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=r,a.rounding=n,i.times(2)))},Rt.inverseTangent=Rt.atan=function(){var e,t,r,n,i,a,o,s,u,c=this,l=c.constructor,f=l.precision,p=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&f+4<=qt)return(o=Zt(l,f+4,p).times(.25)).s=c.s,o}else{if(!c.s)return new l(NaN);if(f+4<=qt)return(o=Zt(l,f+4,p).times(.5)).s=c.s,o}for(l.precision=s=f+10,l.rounding=1,e=r=Math.min(28,s/zt+2|0);e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(Dt=!1,t=Math.ceil(s/zt),n=1,u=c.times(c),o=new l(c),i=c;-1!==e;)if(i=i.times(u),a=o.minus(i.div(n+=2)),i=i.times(u),void 0!==(o=a.plus(i.div(n+=2))).d[t])for(e=t;o.d[e]===a.d[e]&&e--;);return r&&(o=o.times(2<<r-1)),Dt=!0,$t(o,l.precision=f,l.rounding=p,!0)},Rt.isFinite=function(){return!!this.d},Rt.isInteger=Rt.isInt=function(){return!!this.d&&Mt(this.e/zt)>this.d.length-2},Rt.isNaN=function(){return!this.s},Rt.isNegative=Rt.isNeg=function(){return this.s<0},Rt.isPositive=Rt.isPos=function(){return this.s>0},Rt.isZero=function(){return!!this.d&&0===this.d[0]},Rt.lessThan=Rt.lt=function(e){return this.cmp(e)<0},Rt.lessThanOrEqualTo=Rt.lte=function(e){return this.cmp(e)<1},Rt.logarithm=Rt.log=function(e){var t,r,n,i,a,o,s,u,c=this,l=c.constructor,f=l.precision,p=l.rounding;if(null==e)e=new l(10),t=!0;else{if(r=(e=new l(e)).d,e.s<0||!r||!r[0]||e.eq(1))return new l(NaN);t=e.eq(10)}if(r=c.d,c.s<0||!r||!r[0]||c.eq(1))return new l(r&&!r[0]?-1/0:1!=c.s?NaN:r?0:1/0);if(t)if(r.length>1)a=!0;else{for(i=r[0];i%10==0;)i/=10;a=1!==i}if(Dt=!1,o=tr(c,s=f+5),n=t?Vt(l,s+10):tr(e,s),Ut((u=Ht(o,n,s,1)).d,i=f,p))do{if(o=tr(c,s+=10),n=t?Vt(l,s+10):tr(e,s),u=Ht(o,n,s,1),!a){+Pt(u.d).slice(i+1,i+15)+1==1e14&&(u=$t(u,f+1,0));break}}while(Ut(u.d,i+=10,p));return Dt=!0,$t(u,f,p)},Rt.minus=Rt.sub=function(e){var t,r,n,i,a,o,s,u,c,l,f,p,m=this,h=m.constructor;if(e=new h(e),!m.d||!e.d)return m.s&&e.s?m.d?e.s=-e.s:e=new h(e.d||m.s!==e.s?m:NaN):e=new h(NaN),e;if(m.s!=e.s)return e.s=-e.s,m.plus(e);if(c=m.d,p=e.d,s=h.precision,u=h.rounding,!c[0]||!p[0]){if(p[0])e.s=-e.s;else{if(!c[0])return new h(3===u?-0:0);e=new h(m)}return Dt?$t(e,s,u):e}if(r=Mt(e.e/zt),l=Mt(m.e/zt),c=c.slice(),a=l-r){for((f=a<0)?(t=c,a=-a,o=p.length):(t=p,r=l,o=c.length),a>(n=Math.max(Math.ceil(s/zt),o)+2)&&(a=n,t.length=1),t.reverse(),n=a;n--;)t.push(0);t.reverse()}else{for((f=(n=c.length)<(o=p.length))&&(o=n),n=0;n<o;n++)if(c[n]!=p[n]){f=c[n]<p[n];break}a=0}for(f&&(t=c,c=p,p=t,e.s=-e.s),o=c.length,n=p.length-o;n>0;--n)c[o++]=0;for(n=p.length;n>a;){if(c[--n]<p[n]){for(i=n;i&&0===c[--i];)c[i]=kt-1;--c[i],c[n]+=kt}c[n]-=p[n]}for(;0===c[--o];)c.pop();for(;0===c[0];c.shift())--r;return c[0]?(e.d=c,e.e=Wt(c,r),Dt?$t(e,s,u):e):new h(3===u?-0:0)},Rt.modulo=Rt.mod=function(e){var t,r=this,n=r.constructor;return e=new n(e),!r.d||!e.s||e.d&&!e.d[0]?new n(NaN):!e.d||r.d&&!r.d[0]?$t(new n(r),n.precision,n.rounding):(Dt=!1,9==n.modulo?(t=Ht(r,e.abs(),0,3,1)).s*=e.s:t=Ht(r,e,0,n.modulo,1),t=t.times(e),Dt=!0,r.minus(t))},Rt.naturalExponential=Rt.exp=function(){return er(this)},Rt.naturalLogarithm=Rt.ln=function(){return tr(this)},Rt.negated=Rt.neg=function(){var e=new this.constructor(this);return e.s=-e.s,$t(e)},Rt.plus=Rt.add=function(e){var t,r,n,i,a,o,s,u,c,l,f=this,p=f.constructor;if(e=new p(e),!f.d||!e.d)return f.s&&e.s?f.d||(e=new p(e.d||f.s===e.s?f:NaN)):e=new p(NaN),e;if(f.s!=e.s)return e.s=-e.s,f.minus(e);if(c=f.d,l=e.d,s=p.precision,u=p.rounding,!c[0]||!l[0])return l[0]||(e=new p(f)),Dt?$t(e,s,u):e;if(a=Mt(f.e/zt),n=Mt(e.e/zt),c=c.slice(),i=a-n){for(i<0?(r=c,i=-i,o=l.length):(r=l,n=a,o=c.length),i>(o=(a=Math.ceil(s/zt))>o?a+1:o+1)&&(i=o,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for((o=c.length)-(i=l.length)<0&&(i=o,r=l,l=c,c=r),t=0;i;)t=(c[--i]=c[i]+l[i]+t)/kt|0,c[i]%=kt;for(t&&(c.unshift(t),++n),o=c.length;0==c[--o];)c.pop();return e.d=c,e.e=Wt(c,n),Dt?$t(e,s,u):e},Rt.precision=Rt.sd=function(e){var t,r=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(Et+e);return r.d?(t=Yt(r.d),e&&r.e+1>t&&(t=r.e+1)):t=NaN,t},Rt.round=function(){var e=this,t=e.constructor;return $t(new t(e),e.e+1,t.rounding)},Rt.sine=Rt.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+zt,n.rounding=1,r=function(e,t){var r,n=t.d.length;if(n<3)return t.isZero()?t:ar(e,2,t,t);r=(r=1.4*Math.sqrt(n))>16?16:0|r,t=ar(e,2,t=t.times(1/or(5,r)),t);for(var i,a=new e(5),o=new e(16),s=new e(20);r--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}(n,sr(n,r)),n.precision=e,n.rounding=t,$t(ht>2?r.neg():r,e,t,!0)):new n(NaN)},Rt.squareRoot=Rt.sqrt=function(){var e,t,r,n,i,a,o=this,s=o.d,u=o.e,c=o.s,l=o.constructor;if(1!==c||!s||!s[0])return new l(!c||c<0&&(!s||s[0])?NaN:s?o:1/0);for(Dt=!1,0==(c=Math.sqrt(+o))||c==1/0?(((t=Pt(s)).length+u)%2==0&&(t+="0"),c=Math.sqrt(t),u=Mt((u+1)/2)-(u<0||u%2),n=new l(t=c==1/0?"5e"+u:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+u)):n=new l(c.toString()),r=(u=l.precision)+3;;)if(n=(a=n).plus(Ht(o,a,r+2,1)).times(.5),Pt(a.d).slice(0,r)===(t=Pt(n.d)).slice(0,r)){if("9999"!=(t=t.slice(r-3,r+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||($t(n,u+1,1),e=!n.times(n).eq(o));break}if(!i&&($t(a,u+1,0),a.times(a).eq(o))){n=a;break}r+=4,i=1}return Dt=!0,$t(n,u,l.rounding,e)},Rt.tangent=Rt.tan=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+10,n.rounding=1,(r=r.sin()).s=1,r=Ht(r,new n(1).minus(r.times(r)).sqrt(),e+10,0),n.precision=e,n.rounding=t,$t(2==ht||4==ht?r.neg():r,e,t,!0)):new n(NaN)},Rt.times=Rt.mul=function(e){var t,r,n,i,a,o,s,u,c,l=this,f=l.constructor,p=l.d,m=(e=new f(e)).d;if(e.s*=l.s,!(p&&p[0]&&m&&m[0]))return new f(!e.s||p&&!p[0]&&!m||m&&!m[0]&&!p?NaN:p&&m?0*e.s:e.s/0);for(r=Mt(l.e/zt)+Mt(e.e/zt),(u=p.length)<(c=m.length)&&(a=p,p=m,m=a,o=u,u=c,c=o),a=[],n=o=u+c;n--;)a.push(0);for(n=c;--n>=0;){for(t=0,i=u+n;i>n;)s=a[i]+m[n]*p[i-n-1]+t,a[i--]=s%kt|0,t=s/kt|0;a[i]=(a[i]+t)%kt|0}for(;!a[--o];)a.pop();return t?++r:a.shift(),e.d=a,e.e=Wt(a,r),Dt?$t(e,f.precision,f.rounding):e},Rt.toBinary=function(e,t){return ur(this,2,e,t)},Rt.toDecimalPlaces=Rt.toDP=function(e,t){var r=this,n=r.constructor;return r=new n(r),void 0===e?r:(jt(e,0,vt),void 0===t?t=n.rounding:jt(t,0,8),$t(r,e+r.e+1,t))},Rt.toExponential=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=Gt(n,!0):(jt(e,0,vt),void 0===t?t=i.rounding:jt(t,0,8),r=Gt(n=$t(new i(n),e+1,t),!0,e+1)),n.isNeg()&&!n.isZero()?"-"+r:r},Rt.toFixed=function(e,t){var r,n,i=this,a=i.constructor;return void 0===e?r=Gt(i):(jt(e,0,vt),void 0===t?t=a.rounding:jt(t,0,8),r=Gt(n=$t(new a(i),e+i.e+1,t),!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r},Rt.toFraction=function(e){var t,r,n,i,a,o,s,u,c,l,f,p,m=this,h=m.d,d=m.constructor;if(!h)return new d(m);if(c=r=new d(1),n=u=new d(0),o=(a=(t=new d(n)).e=Yt(h)-m.e-1)%zt,t.d[0]=Ft(10,o<0?zt+o:o),null==e)e=a>0?t:c;else{if(!(s=new d(e)).isInt()||s.lt(c))throw Error(Et+s);e=s.gt(t)?a>0?t:c:s}for(Dt=!1,s=new d(Pt(h)),l=d.precision,d.precision=a=h.length*zt*2;f=Ht(s,t,0,1,1),1!=(i=r.plus(f.times(n))).cmp(e);)r=n,n=i,i=c,c=u.plus(f.times(i)),u=i,i=t,t=s.minus(f.times(i)),s=i;return i=Ht(e.minus(r),n,0,1,1),u=u.plus(i.times(c)),r=r.plus(i.times(n)),u.s=c.s=m.s,p=Ht(c,n,a,1).minus(m).abs().cmp(Ht(u,r,a,1).minus(m).abs())<1?[c,n]:[u,r],d.precision=l,Dt=!0,p},Rt.toHexadecimal=Rt.toHex=function(e,t){return ur(this,16,e,t)},Rt.toNearest=function(e,t){var r=this,n=r.constructor;if(r=new n(r),null==e){if(!r.d)return r;e=new n(1),t=n.rounding}else{if(e=new n(e),void 0===t?t=n.rounding:jt(t,0,8),!r.d)return e.s?r:e;if(!e.d)return e.s&&(e.s=r.s),e}return e.d[0]?(Dt=!1,r=Ht(r,e,0,t,1).times(e),Dt=!0,$t(r)):(e.s=r.s,r=e),r},Rt.toNumber=function(){return+this},Rt.toOctal=function(e,t){return ur(this,8,e,t)},Rt.toPower=Rt.pow=function(e){var t,r,n,i,a,o,s=this,u=s.constructor,c=+(e=new u(e));if(!(s.d&&e.d&&s.d[0]&&e.d[0]))return new u(Ft(+s,c));if((s=new u(s)).eq(1))return s;if(n=u.precision,a=u.rounding,e.eq(1))return $t(s,n,a);if((t=Mt(e.e/zt))>=e.d.length-1&&(r=c<0?-c:c)<=9007199254740991)return i=Xt(u,s,r,n),e.s<0?new u(1).div(i):$t(i,n,a);if((o=s.s)<0){if(t<e.d.length-1)return new u(NaN);if(0==(1&e.d[t])&&(o=1),0==s.e&&1==s.d[0]&&1==s.d.length)return s.s=o,s}return(t=0!=(r=Ft(+s,c))&&isFinite(r)?new u(r+"").e:Mt(c*(Math.log("0."+Pt(s.d))/Math.LN10+s.e+1)))>u.maxE+1||t<u.minE-1?new u(t>0?o/0:0):(Dt=!1,u.rounding=s.s=1,r=Math.min(12,(t+"").length),(i=er(e.times(tr(s,n+r)),n)).d&&Ut((i=$t(i,n+5,1)).d,n,a)&&(t=n+10,+Pt((i=$t(er(e.times(tr(s,t+r)),t),t+5,1)).d).slice(n+1,n+15)+1==1e14&&(i=$t(i,n+1,0))),i.s=o,Dt=!0,u.rounding=a,$t(i,n,a))},Rt.toPrecision=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=Gt(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(jt(e,1,vt),void 0===t?t=i.rounding:jt(t,0,8),r=Gt(n=$t(new i(n),e,t),e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+r:r},Rt.toSignificantDigits=Rt.toSD=function(e,t){var r=this.constructor;return void 0===e?(e=r.precision,t=r.rounding):(jt(e,1,vt),void 0===t?t=r.rounding:jt(t,0,8)),$t(new r(this),e,t)},Rt.toString=function(){var e=this,t=e.constructor,r=Gt(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r},Rt.truncated=Rt.trunc=function(){return $t(new this.constructor(this),this.e+1,1)},Rt.valueOf=Rt.toJSON=function(){var e=this,t=e.constructor,r=Gt(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};var Ht=function(){function e(e,t,r){var n,i=0,a=e.length;for(e=e.slice();a--;)n=e[a]*t+i,e[a]=n%r|0,i=n/r|0;return i&&e.unshift(i),e}function t(e,t,r,n){var i,a;if(r!=n)a=r>n?1:-1;else for(i=a=0;i<r;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]<t[r]?1:0,e[r]=i*n+e[r]-t[r];for(;!e[0]&&e.length>1;)e.shift()}return function(n,i,a,o,s,u){var c,l,f,p,m,h,d,g,v,y,x,b,w,D,N,E,A,S,C,M,F=n.constructor,T=n.s==i.s?1:-1,_=n.d,B=i.d;if(!(_&&_[0]&&B&&B[0]))return new F(n.s&&i.s&&(_?!B||_[0]!=B[0]:B)?_&&0==_[0]||!B?0*T:T/0:NaN);for(u?(m=1,l=n.e-i.e):(u=kt,m=zt,l=Mt(n.e/m)-Mt(i.e/m)),C=B.length,A=_.length,y=(v=new F(T)).d=[],f=0;B[f]==(_[f]||0);f++);if(B[f]>(_[f]||0)&&l--,null==a?(D=a=F.precision,o=F.rounding):D=s?a+(n.e-i.e)+1:a,D<0)y.push(1),h=!0;else{if(D=D/m+2|0,f=0,1==C){for(p=0,B=B[0],D++;(f<A||p)&&D--;f++)N=p*u+(_[f]||0),y[f]=N/B|0,p=N%B|0;h=p||f<A}else{for((p=u/(B[0]+1)|0)>1&&(B=e(B,p,u),_=e(_,p,u),C=B.length,A=_.length),E=C,b=(x=_.slice(0,C)).length;b<C;)x[b++]=0;(M=B.slice()).unshift(0),S=B[0],B[1]>=u/2&&++S;do{p=0,(c=t(B,x,C,b))<0?(w=x[0],C!=b&&(w=w*u+(x[1]||0)),(p=w/S|0)>1?(p>=u&&(p=u-1),1==(c=t(d=e(B,p,u),x,g=d.length,b=x.length))&&(p--,r(d,C<g?M:B,g,u))):(0==p&&(c=p=1),d=B.slice()),(g=d.length)<b&&d.unshift(0),r(x,d,b,u),-1==c&&(c=t(B,x,C,b=x.length))<1&&(p++,r(x,C<b?M:B,b,u)),b=x.length):0===c&&(p++,x=[0]),y[f++]=p,c&&x[0]?x[b++]=_[E]||0:(x=[_[E]],b=1)}while((E++<A||void 0!==x[0])&&D--);h=void 0!==x[0]}y[0]||y.shift()}if(1==m)v.e=l,mt=h;else{for(f=1,p=y[0];p>=10;p/=10)f++;v.e=f+l*m-1,$t(v,s?a+v.e+1:a,o,h)}return v}}();function $t(e,t,r,n){var i,a,o,s,u,c,l,f,p,m=e.constructor;e:if(null!=t){if(!(f=e.d))return e;for(i=1,s=f[0];s>=10;s/=10)i++;if((a=t-i)<0)a+=zt,o=t,u=(l=f[p=0])/Ft(10,i-o-1)%10|0;else if((p=Math.ceil((a+1)/zt))>=(s=f.length)){if(!n)break e;for(;s++<=p;)f.push(0);l=u=0,i=1,o=(a%=zt)-zt+1}else{for(l=s=f[p],i=1;s>=10;s/=10)i++;u=(o=(a%=zt)-zt+i)<0?0:l/Ft(10,i-o-1)%10|0}if(n=n||t<0||void 0!==f[p+1]||(o<0?l:l%Ft(10,i-o-1)),c=r<4?(u||n)&&(0==r||r==(e.s<0?3:2)):u>5||5==u&&(4==r||n||6==r&&(a>0?o>0?l/Ft(10,i-o):0:f[p-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,c?(t-=e.e+1,f[0]=Ft(10,(zt-t%zt)%zt),e.e=-t||0):f[0]=e.e=0,e;if(0==a?(f.length=p,s=1,p--):(f.length=p+1,s=Ft(10,zt-a),f[p]=o>0?(l/Ft(10,i-o)%Ft(10,o)|0)*s:0),c)for(;;){if(0==p){for(a=1,o=f[0];o>=10;o/=10)a++;for(o=f[0]+=s,s=1;o>=10;o/=10)s++;a!=s&&(e.e++,f[0]==kt&&(f[0]=1));break}if(f[p]+=s,f[p]!=kt)break;f[p--]=0,s=1}for(a=f.length;0===f[--a];)f.pop()}return Dt&&(e.e>m.maxE?(e.d=null,e.e=NaN):e.e<m.minE&&(e.e=0,e.d=[0])),e}function Gt(e,t,r){if(!e.isFinite())return rr(e);var n,i=e.e,a=Pt(e.d),o=a.length;return t?(r&&(n=r-o)>0?a=a.charAt(0)+"."+a.slice(1)+Jt(n):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(e.e<0?"e":"e+")+e.e):i<0?(a="0."+Jt(-i-1)+a,r&&(n=r-o)>0&&(a+=Jt(n))):i>=o?(a+=Jt(i+1-o),r&&(n=r-i-1)>0&&(a=a+"."+Jt(n))):((n=i+1)<o&&(a=a.slice(0,n)+"."+a.slice(n)),r&&(n=r-o)>0&&(i+1===o&&(a+="."),a+=Jt(n))),a}function Wt(e,t){var r=e[0];for(t*=zt;r>=10;r/=10)t++;return t}function Vt(e,t,r){if(t>It)throw Dt=!0,r&&(e.precision=r),Error(At);return $t(new e(xt),t,1,!0)}function Zt(e,t,r){if(t>qt)throw Error(At);return $t(new e(bt),t,r,!0)}function Yt(e){var t=e.length-1,r=t*zt+1;if(t=e[t]){for(;t%10==0;t/=10)r--;for(t=e[0];t>=10;t/=10)r++}return r}function Jt(e){for(var t="";e--;)t+="0";return t}function Xt(e,t,r,n){var i,a=new e(1),o=Math.ceil(n/zt+4);for(Dt=!1;;){if(r%2&&cr((a=a.times(t)).d,o)&&(i=!0),0===(r=Mt(r/2))){r=a.d.length-1,i&&0===a.d[r]&&++a.d[r];break}cr((t=t.times(t)).d,o)}return Dt=!0,a}function Qt(e){return 1&e.d[e.d.length-1]}function Kt(e,t,r){for(var n,i=new e(t[0]),a=0;++a<t.length;){if(!(n=new e(t[a])).s){i=n;break}i[r](n)&&(i=n)}return i}function er(e,t){var r,n,i,a,o,s,u,c=0,l=0,f=0,p=e.constructor,m=p.rounding,h=p.precision;if(!e.d||!e.d[0]||e.e>17)return new p(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(Dt=!1,u=h):u=t,s=new p(.03125);e.e>-2;)e=e.times(s),f+=5;for(u+=n=Math.log(Ft(2,f))/Math.LN10*2+5|0,r=a=o=new p(1),p.precision=u;;){if(a=$t(a.times(e),u,1),r=r.times(++l),Pt((s=o.plus(Ht(a,r,u,1))).d).slice(0,u)===Pt(o.d).slice(0,u)){for(i=f;i--;)o=$t(o.times(o),u,1);if(null!=t)return p.precision=h,o;if(!(c<3&&Ut(o.d,u-n,m,c)))return $t(o,p.precision=h,m,Dt=!0);p.precision=u+=10,r=a=s=new p(1),l=0,c++}o=s}}function tr(e,t){var r,n,i,a,o,s,u,c,l,f,p,m=1,h=e,d=h.d,g=h.constructor,v=g.rounding,y=g.precision;if(h.s<0||!d||!d[0]||!h.e&&1==d[0]&&1==d.length)return new g(d&&!d[0]?-1/0:1!=h.s?NaN:d?0:h);if(null==t?(Dt=!1,l=y):l=t,g.precision=l+=10,n=(r=Pt(d)).charAt(0),!(Math.abs(a=h.e)<15e14))return c=Vt(g,l+2,y).times(a+""),h=tr(new g(n+"."+r.slice(1)),l-10).plus(c),g.precision=y,null==t?$t(h,y,v,Dt=!0):h;for(;n<7&&1!=n||1==n&&r.charAt(1)>3;)n=(r=Pt((h=h.times(e)).d)).charAt(0),m++;for(a=h.e,n>1?(h=new g("0."+r),a++):h=new g(n+"."+r.slice(1)),f=h,u=o=h=Ht(h.minus(1),h.plus(1),l,1),p=$t(h.times(h),l,1),i=3;;){if(o=$t(o.times(p),l,1),Pt((c=u.plus(Ht(o,new g(i),l,1))).d).slice(0,l)===Pt(u.d).slice(0,l)){if(u=u.times(2),0!==a&&(u=u.plus(Vt(g,l+2,y).times(a+""))),u=Ht(u,new g(m),l,1),null!=t)return g.precision=y,u;if(!Ut(u.d,l-10,v,s))return $t(u,g.precision=y,v,Dt=!0);g.precision=l+=10,c=o=h=Ht(f.minus(1),f.plus(1),l,1),p=$t(h.times(h),l,1),i=s=1}u=c,i+=2}}function rr(e){return String(e.s*e.s/0)}function nr(e,t){var r,n,i;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;48===t.charCodeAt(n);n++);for(i=t.length;48===t.charCodeAt(i-1);--i);if(t=t.slice(n,i)){if(i-=n,e.e=r=r-n-1,e.d=[],n=(r+1)%zt,r<0&&(n+=zt),n<i){for(n&&e.d.push(+t.slice(0,n)),i-=zt;n<i;)e.d.push(+t.slice(n,n+=zt));t=t.slice(n),n=zt-t.length}else n-=i;for(;n--;)t+="0";e.d.push(+t),Dt&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function ir(e,t){var r,n,i,a,o,s,u,c,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),Ot.test(t))return nr(e,t)}else if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(_t.test(t))r=16,t=t.toLowerCase();else if(Tt.test(t))r=2;else{if(!Bt.test(t))throw Error(Et+t);r=8}for((a=t.search(/p/i))>0?(u=+t.slice(a+1),t=t.substring(2,a)):t=t.slice(2),o=(a=t.indexOf("."))>=0,n=e.constructor,o&&(a=(s=(t=t.replace(".","")).length)-a,i=Xt(n,new n(r),a,2*a)),a=l=(c=Lt(t,r,kt)).length-1;0===c[a];--a)c.pop();return a<0?new n(0*e.s):(e.e=Wt(c,l),e.d=c,Dt=!1,o&&(e=Ht(e,i,4*s)),u&&(e=e.times(Math.abs(u)<54?Ft(2,u):Jr.pow(2,u))),Dt=!0,e)}function ar(e,t,r,n,i){var a,o,s,u,c=e.precision,l=Math.ceil(c/zt);for(Dt=!1,u=r.times(r),s=new e(n);;){if(o=Ht(s.times(u),new e(t++*t++),c,1),s=i?n.plus(o):n.minus(o),n=Ht(o.times(u),new e(t++*t++),c,1),void 0!==(o=s.plus(n)).d[l]){for(a=l;o.d[a]===s.d[a]&&a--;);if(-1==a)break}a=s,s=n,n=o,o=a}return Dt=!0,o.d.length=l+1,o}function or(e,t){for(var r=e;--t;)r*=e;return r}function sr(e,t){var r,n=t.s<0,i=Zt(e,e.precision,1),a=i.times(.5);if((t=t.abs()).lte(a))return ht=n?4:1,t;if((r=t.divToInt(i)).isZero())ht=n?3:2;else{if((t=t.minus(r.times(i))).lte(a))return ht=Qt(r)?n?2:3:n?4:1,t;ht=Qt(r)?n?1:4:n?3:2}return t.minus(i).abs()}function ur(e,t,r,n){var i,a,o,s,u,c,l,f,p,m=e.constructor,h=void 0!==r;if(h?(jt(r,1,vt),void 0===n?n=m.rounding:jt(n,0,8)):(r=m.precision,n=m.rounding),e.isFinite()){for(h?(i=2,16==t?r=4*r-3:8==t&&(r=3*r-2)):i=t,(o=(l=Gt(e)).indexOf("."))>=0&&(l=l.replace(".",""),(p=new m(1)).e=l.length-o,p.d=Lt(Gt(p),10,i),p.e=p.d.length),a=u=(f=Lt(l,10,i)).length;0==f[--u];)f.pop();if(f[0]){if(o<0?a--:((e=new m(e)).d=f,e.e=a,f=(e=Ht(e,p,r,n,0,i)).d,a=e.e,c=mt),o=f[r],s=i/2,c=c||void 0!==f[r+1],c=n<4?(void 0!==o||c)&&(0===n||n===(e.s<0?3:2)):o>s||o===s&&(4===n||c||6===n&&1&f[r-1]||n===(e.s<0?8:7)),f.length=r,c)for(;++f[--r]>i-1;)f[r]=0,r||(++a,f.unshift(1));for(u=f.length;!f[u-1];--u);for(o=0,l="";o<u;o++)l+=yt.charAt(f[o]);if(h){if(u>1)if(16==t||8==t){for(o=16==t?4:3,--u;u%o;u++)l+="0";for(u=(f=Lt(l,i,t)).length;!f[u-1];--u);for(o=1,l="1.";o<u;o++)l+=yt.charAt(f[o])}else l=l.charAt(0)+"."+l.slice(1);l=l+(a<0?"p":"p+")+a}else if(a<0){for(;++a;)l="0"+l;l="0."+l}else if(++a>u)for(a-=u;a--;)l+="0";else a<u&&(l=l.slice(0,a)+"."+l.slice(a))}else l=h?"0p+0":"0";l=(16==t?"0x":2==t?"0b":8==t?"0o":"")+l}else l=rr(e);return e.s<0?"-"+l:l}function cr(e,t){if(e.length>t)return e.length=t,!0}function lr(e){return new this(e).abs()}function fr(e){return new this(e).acos()}function pr(e){return new this(e).acosh()}function mr(e,t){return new this(e).plus(t)}function hr(e){return new this(e).asin()}function dr(e){return new this(e).asinh()}function gr(e){return new this(e).atan()}function vr(e){return new this(e).atanh()}function yr(e,t){e=new this(e),t=new this(t);var r,n=this.precision,i=this.rounding,a=n+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(r=t.s<0?Zt(this,n,i):new this(0)).s=e.s:!e.d||t.isZero()?(r=Zt(this,a,1).times(.5)).s=e.s:t.s<0?(this.precision=a,this.rounding=1,r=this.atan(Ht(e,t,a,1)),t=Zt(this,a,1),this.precision=n,this.rounding=i,r=e.s<0?r.minus(t):r.plus(t)):r=this.atan(Ht(e,t,a,1)):(r=Zt(this,a,1).times(t.s>0?.25:.75)).s=e.s:r=new this(NaN),r}function xr(e){return new this(e).cbrt()}function br(e){return $t(e=new this(e),e.e+1,2)}function wr(e,t,r){return new this(e).clamp(t,r)}function Dr(e){if(!e||"object"!=typeof e)throw Error(Nt+"Object expected");var t,r,n,i=!0===e.defaults,a=["precision",1,vt,"rounding",0,8,"toExpNeg",-gt,0,"toExpPos",0,gt,"maxE",0,gt,"minE",-gt,0,"modulo",0,9];for(t=0;t<a.length;t+=3)if(r=a[t],i&&(this[r]=wt[r]),void 0!==(n=e[r])){if(!(Mt(n)===n&&n>=a[t+1]&&n<=a[t+2]))throw Error(Et+r+": "+n);this[r]=n}if(r="crypto",i&&(this[r]=wt[r]),void 0!==(n=e[r])){if(!0!==n&&!1!==n&&0!==n&&1!==n)throw Error(Et+r+": "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(St);this[r]=!0}else this[r]=!1}return this}function Nr(e){return new this(e).cos()}function Er(e){return new this(e).cosh()}function Ar(e,t){return new this(e).div(t)}function Sr(e){return new this(e).exp()}function Cr(e){return $t(e=new this(e),e.e+1,3)}function Mr(){var e,t,r=new this(0);for(Dt=!1,e=0;e<arguments.length;)if((t=new this(arguments[e++])).d)r.d&&(r=r.plus(t.times(t)));else{if(t.s)return Dt=!0,new this(1/0);r=t}return Dt=!0,r.sqrt()}function Fr(e){return e instanceof Jr||e&&e.toStringTag===Ct||!1}function Tr(e){return new this(e).ln()}function _r(e,t){return new this(e).log(t)}function Br(e){return new this(e).log(2)}function Or(e){return new this(e).log(10)}function kr(){return Kt(this,arguments,"lt")}function zr(){return Kt(this,arguments,"gt")}function Ir(e,t){return new this(e).mod(t)}function qr(e,t){return new this(e).mul(t)}function Rr(e,t){return new this(e).pow(t)}function Pr(e){var t,r,n,i,a=0,o=new this(1),s=[];if(void 0===e?e=this.precision:jt(e,1,vt),n=Math.ceil(e/zt),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(n));a<n;)(i=t[a])>=429e7?t[a]=crypto.getRandomValues(new Uint32Array(1))[0]:s[a++]=i%1e7;else{if(!crypto.randomBytes)throw Error(St);for(t=crypto.randomBytes(n*=4);a<n;)(i=t[a]+(t[a+1]<<8)+(t[a+2]<<16)+((127&t[a+3])<<24))>=214e7?crypto.randomBytes(4).copy(t,a):(s.push(i%1e7),a+=4);a=n/4}else for(;a<n;)s[a++]=1e7*Math.random()|0;for(n=s[--a],e%=zt,n&&e&&(i=Ft(10,zt-e),s[a]=(n/i|0)*i);0===s[a];a--)s.pop();if(a<0)r=0,s=[0];else{for(r=-1;0===s[0];r-=zt)s.shift();for(n=1,i=s[0];i>=10;i/=10)n++;n<zt&&(r-=zt-n)}return o.e=r,o.d=s,o}function jr(e){return $t(e=new this(e),e.e+1,this.rounding)}function Ur(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function Lr(e){return new this(e).sin()}function Hr(e){return new this(e).sinh()}function $r(e){return new this(e).sqrt()}function Gr(e,t){return new this(e).sub(t)}function Wr(){var e=0,t=arguments,r=new this(t[e]);for(Dt=!1;r.s&&++e<t.length;)r=r.plus(t[e]);return Dt=!0,$t(r,this.precision,this.rounding)}function Vr(e){return new this(e).tan()}function Zr(e){return new this(e).tanh()}function Yr(e){return $t(e=new this(e),e.e+1,1)}Rt[Symbol.for("nodejs.util.inspect.custom")]=Rt.toString,Rt[Symbol.toStringTag]="Decimal";var Jr=Rt.constructor=function e(t){var r,n,i;function a(e){var t,r,n,i=this;if(!(i instanceof a))return new a(e);if(i.constructor=a,Fr(e))return i.s=e.s,void(Dt?!e.d||e.e>a.maxE?(i.e=NaN,i.d=null):e.e<a.minE?(i.e=0,i.d=[0]):(i.e=e.e,i.d=e.d.slice()):(i.e=e.e,i.d=e.d?e.d.slice():e.d));if("number"==(n=typeof e)){if(0===e)return i.s=1/e<0?-1:1,i.e=0,void(i.d=[0]);if(e<0?(e=-e,i.s=-1):i.s=1,e===~~e&&e<1e7){for(t=0,r=e;r>=10;r/=10)t++;return void(Dt?t>a.maxE?(i.e=NaN,i.d=null):t<a.minE?(i.e=0,i.d=[0]):(i.e=t,i.d=[e]):(i.e=t,i.d=[e]))}return 0*e!=0?(e||(i.s=NaN),i.e=NaN,void(i.d=null)):nr(i,e.toString())}if("string"!==n)throw Error(Et+e);return 45===(r=e.charCodeAt(0))?(e=e.slice(1),i.s=-1):(43===r&&(e=e.slice(1)),i.s=1),Ot.test(e)?nr(i,e):ir(i,e)}if(a.prototype=Rt,a.ROUND_UP=0,a.ROUND_DOWN=1,a.ROUND_CEIL=2,a.ROUND_FLOOR=3,a.ROUND_HALF_UP=4,a.ROUND_HALF_DOWN=5,a.ROUND_HALF_EVEN=6,a.ROUND_HALF_CEIL=7,a.ROUND_HALF_FLOOR=8,a.EUCLID=9,a.config=a.set=Dr,a.clone=e,a.isDecimal=Fr,a.abs=lr,a.acos=fr,a.acosh=pr,a.add=mr,a.asin=hr,a.asinh=dr,a.atan=gr,a.atanh=vr,a.atan2=yr,a.cbrt=xr,a.ceil=br,a.clamp=wr,a.cos=Nr,a.cosh=Er,a.div=Ar,a.exp=Sr,a.floor=Cr,a.hypot=Mr,a.ln=Tr,a.log=_r,a.log10=Or,a.log2=Br,a.max=kr,a.min=zr,a.mod=Ir,a.mul=qr,a.pow=Rr,a.random=Pr,a.round=jr,a.sign=Ur,a.sin=Lr,a.sinh=Hr,a.sqrt=$r,a.sub=Gr,a.sum=Wr,a.tan=Vr,a.tanh=Zr,a.trunc=Yr,void 0===t&&(t={}),t&&!0!==t.defaults)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],r=0;r<i.length;)t.hasOwnProperty(n=i[r++])||(t[n]=this[n]);return a.config(t),a}(wt);xt=new Jr(xt),bt=new Jr(bt);const Xr=Jr;var Qr=Me("BigNumber",["?on","config"],(e=>{var{on:t,config:r}=e,n=Xr.clone({precision:r.precision,modulo:Xr.EUCLID});return n.prototype=Object.create(n.prototype),n.prototype.type="BigNumber",n.prototype.isBigNumber=!0,n.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},n.fromJSON=function(e){return new n(e.value)},t&&t("config",(function(e,t){e.precision!==t.precision&&n.config({precision:e.precision})})),n}),{isClass:!0});const Kr=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:.5*(Math.exp(e)+Math.exp(-e))},en=Math.sinh||function(e){return Math.abs(e)<1e-9?e:.5*(Math.exp(e)-Math.exp(-e))},tn=function(e,t){return(e=Math.abs(e))<(t=Math.abs(t))&&([e,t]=[t,e]),e<1e8?Math.sqrt(e*e+t*t):(t/=e,e*Math.sqrt(1+t*t))},rn=function(){throw SyntaxError("Invalid Param")};function nn(e,t){const r=Math.abs(e),n=Math.abs(t);return 0===e?Math.log(n):0===t?Math.log(r):r<3e3&&n<3e3?.5*Math.log(e*e+t*t):(e*=.5,t*=.5,.5*Math.log(e*e+t*t)+Math.LN2)}const an={re:0,im:0},on=function(e,t){const r=an;if(null==e)r.re=r.im=0;else if(void 0!==t)r.re=e,r.im=t;else switch(typeof e){case"object":if("im"in e&&"re"in e)r.re=e.re,r.im=e.im;else if("abs"in e&&"arg"in e){if(!isFinite(e.abs)&&isFinite(e.arg))return sn.INFINITY;r.re=e.abs*Math.cos(e.arg),r.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!isFinite(e.r)&&isFinite(e.phi))return sn.INFINITY;r.re=e.r*Math.cos(e.phi),r.im=e.r*Math.sin(e.phi)}else 2===e.length?(r.re=e[0],r.im=e[1]):rn();break;case"string":r.im=r.re=0;const t=e.replace(/_/g,"").match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g);let n=1,i=0;null===t&&rn();for(let e=0;e<t.length;e++){const a=t[e];" "===a||"\t"===a||"\n"===a||("+"===a?n++:"-"===a?i++:"i"===a||"I"===a?(n+i===0&&rn()," "===t[e+1]||isNaN(t[e+1])?r.im+=parseFloat((i%2?"-":"")+"1"):(r.im+=parseFloat((i%2?"-":"")+t[e+1]),e++),n=i=0):((n+i===0||isNaN(a))&&rn(),"i"===t[e+1]||"I"===t[e+1]?(r.im+=parseFloat((i%2?"-":"")+a),e++):r.re+=parseFloat((i%2?"-":"")+a),n=i=0))}n+i>0&&rn();break;case"number":r.im=0,r.re=e;break;default:rn()}return isNaN(r.re)||isNaN(r.im),r};function sn(e,t){if(!(this instanceof sn))return new sn(e,t);const r=on(e,t);this.re=r.re,this.im=r.im}sn.prototype={re:0,im:0,sign:function(){const e=tn(this.re,this.im);return new sn(this.re/e,this.im/e)},add:function(e,t){const r=on(e,t),n=this.isInfinite(),i=!(isFinite(r.re)&&isFinite(r.im));return n||i?n&&i?sn.NAN:sn.INFINITY:new sn(this.re+r.re,this.im+r.im)},sub:function(e,t){const r=on(e,t),n=this.isInfinite(),i=!(isFinite(r.re)&&isFinite(r.im));return n||i?n&&i?sn.NAN:sn.INFINITY:new sn(this.re-r.re,this.im-r.im)},mul:function(e,t){const r=on(e,t),n=this.isInfinite(),i=!(isFinite(r.re)&&isFinite(r.im)),a=0===this.re&&0===this.im,o=0===r.re&&0===r.im;return n&&o||i&&a?sn.NAN:n||i?sn.INFINITY:0===r.im&&0===this.im?new sn(this.re*r.re,0):new sn(this.re*r.re-this.im*r.im,this.re*r.im+this.im*r.re)},div:function(e,t){const r=on(e,t),n=this.isInfinite(),i=!(isFinite(r.re)&&isFinite(r.im)),a=0===this.re&&0===this.im,o=0===r.re&&0===r.im;if(a&&o||n&&i)return sn.NAN;if(o||n)return sn.INFINITY;if(a||i)return sn.ZERO;if(0===r.im)return new sn(this.re/r.re,this.im/r.re);if(Math.abs(r.re)<Math.abs(r.im)){const e=r.re/r.im,t=r.re*e+r.im;return new sn((this.re*e+this.im)/t,(this.im*e-this.re)/t)}{const e=r.im/r.re,t=r.im*e+r.re;return new sn((this.re+this.im*e)/t,(this.im-this.re*e)/t)}},pow:function(e,t){const r=on(e,t),n=0===this.re&&0===this.im;if(0===r.re&&0===r.im)return sn.ONE;if(0===r.im){if(0===this.im&&this.re>0)return new sn(Math.pow(this.re,r.re),0);if(0===this.re)switch((r.re%4+4)%4){case 0:return new sn(Math.pow(this.im,r.re),0);case 1:return new sn(0,Math.pow(this.im,r.re));case 2:return new sn(-Math.pow(this.im,r.re),0);case 3:return new sn(0,-Math.pow(this.im,r.re))}}if(n&&r.re>0)return sn.ZERO;const i=Math.atan2(this.im,this.re),a=nn(this.re,this.im);let o=Math.exp(r.re*a-r.im*i),s=r.im*a+r.re*i;return new sn(o*Math.cos(s),o*Math.sin(s))},sqrt:function(){const e=this.re,t=this.im;if(0===t)return e>=0?new sn(Math.sqrt(e),0):new sn(0,Math.sqrt(-e));const r=tn(e,t);let n=Math.sqrt(.5*(r+Math.abs(e))),i=Math.abs(t)/(2*n);return e>=0?new sn(n,t<0?-i:i):new sn(i,t<0?-n:n)},exp:function(){const e=Math.exp(this.re);return 0===this.im?new sn(e,0):new sn(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){const e=this.re,t=this.im;return new sn(Math.expm1(e)*Math.cos(t)+function(e){const t=Math.PI/4;if(-t>e||e>t)return Math.cos(e)-1;const r=e*e;return r*(r*(r*(r*(r*(r*(r*(r/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-.5)}(t),Math.exp(e)*Math.sin(t))},log:function(){const e=this.re,t=this.im;return 0===t&&e>0?new sn(Math.log(e),0):new sn(nn(e,t),Math.atan2(t,e))},abs:function(){return tn(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){const e=this.re,t=this.im;return new sn(Math.sin(e)*Kr(t),Math.cos(e)*en(t))},cos:function(){const e=this.re,t=this.im;return new sn(Math.cos(e)*Kr(t),-Math.sin(e)*en(t))},tan:function(){const e=2*this.re,t=2*this.im,r=Math.cos(e)+Kr(t);return new sn(Math.sin(e)/r,en(t)/r)},cot:function(){const e=2*this.re,t=2*this.im,r=Math.cos(e)-Kr(t);return new sn(-Math.sin(e)/r,en(t)/r)},sec:function(){const e=this.re,t=this.im,r=.5*Kr(2*t)+.5*Math.cos(2*e);return new sn(Math.cos(e)*Kr(t)/r,Math.sin(e)*en(t)/r)},csc:function(){const e=this.re,t=this.im,r=.5*Kr(2*t)-.5*Math.cos(2*e);return new sn(Math.sin(e)*Kr(t)/r,-Math.cos(e)*en(t)/r)},asin:function(){const e=this.re,t=this.im,r=new sn(t*t-e*e+1,-2*e*t).sqrt(),n=new sn(r.re-t,r.im+e).log();return new sn(n.im,-n.re)},acos:function(){const e=this.re,t=this.im,r=new sn(t*t-e*e+1,-2*e*t).sqrt(),n=new sn(r.re-t,r.im+e).log();return new sn(Math.PI/2-n.im,n.re)},atan:function(){const e=this.re,t=this.im;if(0===e){if(1===t)return new sn(0,1/0);if(-1===t)return new sn(0,-1/0)}const r=e*e+(1-t)*(1-t),n=new sn((1-t*t-e*e)/r,-2*e/r).log();return new sn(-.5*n.im,.5*n.re)},acot:function(){const e=this.re,t=this.im;if(0===t)return new sn(Math.atan2(1,e),0);const r=e*e+t*t;return 0!==r?new sn(e/r,-t/r).atan():new sn(0!==e?e/0:0,0!==t?-t/0:0).atan()},asec:function(){const e=this.re,t=this.im;if(0===e&&0===t)return new sn(0,1/0);const r=e*e+t*t;return 0!==r?new sn(e/r,-t/r).acos():new sn(0!==e?e/0:0,0!==t?-t/0:0).acos()},acsc:function(){const e=this.re,t=this.im;if(0===e&&0===t)return new sn(Math.PI/2,1/0);const r=e*e+t*t;return 0!==r?new sn(e/r,-t/r).asin():new sn(0!==e?e/0:0,0!==t?-t/0:0).asin()},sinh:function(){const e=this.re,t=this.im;return new sn(en(e)*Math.cos(t),Kr(e)*Math.sin(t))},cosh:function(){const e=this.re,t=this.im;return new sn(Kr(e)*Math.cos(t),en(e)*Math.sin(t))},tanh:function(){const e=2*this.re,t=2*this.im,r=Kr(e)+Math.cos(t);return new sn(en(e)/r,Math.sin(t)/r)},coth:function(){const e=2*this.re,t=2*this.im,r=Kr(e)-Math.cos(t);return new sn(en(e)/r,-Math.sin(t)/r)},csch:function(){const e=this.re,t=this.im,r=Math.cos(2*t)-Kr(2*e);return new sn(-2*en(e)*Math.cos(t)/r,2*Kr(e)*Math.sin(t)/r)},sech:function(){const e=this.re,t=this.im,r=Math.cos(2*t)+Kr(2*e);return new sn(2*Kr(e)*Math.cos(t)/r,-2*en(e)*Math.sin(t)/r)},asinh:function(){let e=this.im;this.im=-this.re,this.re=e;const t=this.asin();return this.re=-this.im,this.im=e,e=t.re,t.re=-t.im,t.im=e,t},acosh:function(){const e=this.acos();if(e.im<=0){const t=e.re;e.re=-e.im,e.im=t}else{const t=e.im;e.im=-e.re,e.re=t}return e},atanh:function(){const e=this.re,t=this.im,r=e>1&&0===t,n=1-e,i=1+e,a=n*n+t*t,o=0!==a?new sn((i*n-t*t)/a,(t*n+i*t)/a):new sn(-1!==e?e/0:0,0!==t?t/0:0),s=o.re;return o.re=nn(o.re,o.im)/2,o.im=Math.atan2(o.im,s)/2,r&&(o.im=-o.im),o},acoth:function(){const e=this.re,t=this.im;if(0===e&&0===t)return new sn(0,Math.PI/2);const r=e*e+t*t;return 0!==r?new sn(e/r,-t/r).atanh():new sn(0!==e?e/0:0,0!==t?-t/0:0).atanh()},acsch:function(){const e=this.re,t=this.im;if(0===t)return new sn(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);const r=e*e+t*t;return 0!==r?new sn(e/r,-t/r).asinh():new sn(0!==e?e/0:0,0!==t?-t/0:0).asinh()},asech:function(){const e=this.re,t=this.im;if(this.isZero())return sn.INFINITY;const r=e*e+t*t;return 0!==r?new sn(e/r,-t/r).acosh():new sn(0!==e?e/0:0,0!==t?-t/0:0).acosh()},inverse:function(){if(this.isZero())return sn.INFINITY;if(this.isInfinite())return sn.ZERO;const e=this.re,t=this.im,r=e*e+t*t;return new sn(e/r,-t/r)},conjugate:function(){return new sn(this.re,-this.im)},neg:function(){return new sn(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new sn(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new sn(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new sn(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){const r=on(e,t);return Math.abs(r.re-this.re)<=sn.EPSILON&&Math.abs(r.im-this.im)<=sn.EPSILON},clone:function(){return new sn(this.re,this.im)},toString:function(){let e=this.re,t=this.im,r="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<sn.EPSILON&&(e=0),Math.abs(t)<sn.EPSILON&&(t=0),0===t?r+e:(0!==e?(r+=e,r+=" ",t<0?(t=-t,r+="-"):r+="+",r+=" "):t<0&&(t=-t,r+="-"),1!==t&&(r+=t),r+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return 0===this.im?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return 0===this.im&&0===this.re},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!this.isFinite()}},sn.ZERO=new sn(0,0),sn.ONE=new sn(1,0),sn.I=new sn(0,1),sn.PI=new sn(Math.PI,0),sn.E=new sn(Math.E,0),sn.INFINITY=new sn(1/0,1/0),sn.NAN=new sn(NaN,NaN),sn.EPSILON=1e-15;var un=Me("Complex",[],(()=>(Object.defineProperty(sn,"name",{value:"Complex"}),sn.prototype.constructor=sn,sn.prototype.type="Complex",sn.prototype.isComplex=!0,sn.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},sn.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},sn.prototype.format=function(e){var t=this.im,r=this.re,n=We(this.re,e),i=We(this.im,e),a=F(e)?e:e?e.precision:null;if(null!==a){var o=Math.pow(10,-a);Math.abs(r/t)<o&&(r=0),Math.abs(t/r)<o&&(t=0)}return 0===t?n:0===r?1===t?"i":-1===t?"-i":i+"i":t<0?-1===t?n+" - i":n+" - "+i.substring(1)+"i":1===t?n+" + i":n+" + "+i+"i"},sn.fromPolar=function(e){switch(arguments.length){case 1:var t=arguments[0];if("object"==typeof t)return sn(t);throw new TypeError("Input has to be an object with r and phi keys.");case 2:var r=arguments[0],n=arguments[1];if(F(r)){if(k(n)&&n.hasBase("ANGLE")&&(n=n.toNumber("rad")),F(n))return new sn({r,phi:n});throw new TypeError("Phi is not a number nor an angle unit.")}throw new TypeError("Radius r is not a number.");default:throw new SyntaxError("Wrong number of arguments in function fromPolar")}},sn.prototype.valueOf=sn.prototype.toString,sn.fromJSON=function(e){return new sn(e)},sn.compare=function(e,t){return e.re>t.re?1:e.re<t.re?-1:e.im>t.im?1:e.im<t.im?-1:0},sn)),{isClass:!0}),cn={s:1,n:0,d:1};function ln(e,t){if(isNaN(e=parseInt(e,10)))throw vn();return e*t}function fn(e,t){if(0===t)throw gn();var r=Object.create(dn.prototype);r.s=e<0?-1:1;var n=hn(e=e<0?-e:e,t);return r.n=e/n,r.d=t/n,r}function pn(e){for(var t={},r=e,n=2,i=4;i<=r;){for(;r%n==0;)r/=n,t[n]=(t[n]||0)+1;i+=1+2*n++}return r!==e?r>1&&(t[r]=(t[r]||0)+1):t[e]=(t[e]||0)+1,t}var mn=function(e,t){var r,n=0,i=1,a=1,o=0,s=0,u=0,c=1,l=1,f=0,p=1,m=1,h=1,d=1e7;if(null==e);else if(void 0!==t){if(a=(n=e)*(i=t),n%1!=0||i%1!=0)throw yn()}else switch(typeof e){case"object":if("d"in e&&"n"in e)n=e.n,i=e.d,"s"in e&&(n*=e.s);else{if(!(0 in e))throw vn();n=e[0],1 in e&&(i=e[1])}a=n*i;break;case"number":if(e<0&&(a=e,e=-e),e%1==0)n=e;else if(e>0){for(e>=1&&(e/=l=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)));p<=d&&h<=d;){if(e===(r=(f+m)/(p+h))){p+h<=d?(n=f+m,i=p+h):h>p?(n=m,i=h):(n=f,i=p);break}e>r?(f+=m,p+=h):(m+=f,h+=p),p>d?(n=m,i=h):(n=f,i=p)}n*=l}else(isNaN(e)||isNaN(t))&&(i=n=NaN);break;case"string":if(null===(p=e.match(/\d+|./g)))throw vn();if("-"===p[f]?(a=-1,f++):"+"===p[f]&&f++,p.length===f+1?s=ln(p[f++],a):"."===p[f+1]||"."===p[f]?("."!==p[f]&&(o=ln(p[f++],a)),(1+ ++f===p.length||"("===p[f+1]&&")"===p[f+3]||"'"===p[f+1]&&"'"===p[f+3])&&(s=ln(p[f],a),c=Math.pow(10,p[f].length),f++),("("===p[f]&&")"===p[f+2]||"'"===p[f]&&"'"===p[f+2])&&(u=ln(p[f+1],a),l=Math.pow(10,p[f+1].length)-1,f+=3)):"/"===p[f+1]||":"===p[f+1]?(s=ln(p[f],a),c=ln(p[f+2],1),f+=3):"/"===p[f+3]&&" "===p[f+1]&&(o=ln(p[f],a),s=ln(p[f+2],a),c=ln(p[f+4],1),f+=5),p.length<=f){a=n=u+(i=c*l)*o+l*s;break}default:throw vn()}if(0===i)throw gn();cn.s=a<0?-1:1,cn.n=Math.abs(n),cn.d=Math.abs(i)};function hn(e,t){if(!e)return t;if(!t)return e;for(;;){if(!(e%=t))return t;if(!(t%=e))return e}}function dn(e,t){if(mn(e,t),!(this instanceof dn))return fn(cn.s*cn.n,cn.d);e=hn(cn.d,cn.n),this.s=cn.s,this.n=cn.n/e,this.d=cn.d/e}var gn=function(){return new Error("Division by Zero")},vn=function(){return new Error("Invalid argument")},yn=function(){return new Error("Parameters must be integer")};dn.prototype={s:1,n:0,d:1,abs:function(){return fn(this.n,this.d)},neg:function(){return fn(-this.s*this.n,this.d)},add:function(e,t){return mn(e,t),fn(this.s*this.n*cn.d+cn.s*this.d*cn.n,this.d*cn.d)},sub:function(e,t){return mn(e,t),fn(this.s*this.n*cn.d-cn.s*this.d*cn.n,this.d*cn.d)},mul:function(e,t){return mn(e,t),fn(this.s*cn.s*this.n*cn.n,this.d*cn.d)},div:function(e,t){return mn(e,t),fn(this.s*cn.s*this.n*cn.d,this.d*cn.n)},clone:function(){return fn(this.s*this.n,this.d)},mod:function(e,t){if(isNaN(this.n)||isNaN(this.d))return new dn(NaN);if(void 0===e)return fn(this.s*this.n%this.d,1);if(mn(e,t),0===cn.n&&0===this.d)throw gn();return fn(this.s*(cn.d*this.n)%(cn.n*this.d),cn.d*this.d)},gcd:function(e,t){return mn(e,t),fn(hn(cn.n,this.n)*hn(cn.d,this.d),cn.d*this.d)},lcm:function(e,t){return mn(e,t),0===cn.n&&0===this.n?fn(0,1):fn(cn.n*this.n,hn(cn.n,this.n)*hn(cn.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new dn(NaN):fn(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new dn(NaN):fn(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new dn(NaN):fn(Math.round(e*this.s*this.n/this.d),e)},roundTo:function(e,t){return mn(e,t),fn(this.s*Math.round(this.n*cn.d/(this.d*cn.n))*cn.n,cn.d)},inverse:function(){return fn(this.s*this.d,this.n)},pow:function(e,t){if(mn(e,t),1===cn.d)return cn.s<0?fn(Math.pow(this.s*this.d,cn.n),Math.pow(this.n,cn.n)):fn(Math.pow(this.s*this.n,cn.n),Math.pow(this.d,cn.n));if(this.s<0)return null;var r=pn(this.n),n=pn(this.d),i=1,a=1;for(var o in r)if("1"!==o){if("0"===o){i=0;break}if(r[o]*=cn.n,r[o]%cn.d!=0)return null;r[o]/=cn.d,i*=Math.pow(o,r[o])}for(var o in n)if("1"!==o){if(n[o]*=cn.n,n[o]%cn.d!=0)return null;n[o]/=cn.d,a*=Math.pow(o,n[o])}return cn.s<0?fn(a,i):fn(i,a)},equals:function(e,t){return mn(e,t),this.s*this.n*cn.d==cn.s*cn.n*this.d},compare:function(e,t){mn(e,t);var r=this.s*this.n*cn.d-cn.s*cn.n*this.d;return(0<r)-(r<0)},simplify:function(e){if(isNaN(this.n)||isNaN(this.d))return this;e=e||.001;for(var t=this.abs(),r=t.toContinued(),n=1;n<r.length;n++){for(var i=fn(r[n-1],1),a=n-2;a>=0;a--)i=i.inverse().add(r[a]);if(Math.abs(i.sub(t).valueOf())<e)return i.mul(this.s)}return this},divisible:function(e,t){return mn(e,t),!(!(cn.n*this.d)||this.n*cn.d%(cn.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(e){var t,r="",n=this.n,i=this.d;return this.s<0&&(r+="-"),1===i?r+=n:(e&&(t=Math.floor(n/i))>0&&(r+=t,r+=" ",n%=i),r+=n,r+="/",r+=i),r},toLatex:function(e){var t,r="",n=this.n,i=this.d;return this.s<0&&(r+="-"),1===i?r+=n:(e&&(t=Math.floor(n/i))>0&&(r+=t,n%=i),r+="\\frac{",r+=n,r+="}{",r+=i,r+="}"),r},toContinued:function(){var e,t=this.n,r=this.d,n=[];if(isNaN(t)||isNaN(r))return n;do{n.push(Math.floor(t/r)),e=t%r,t=r,r=e}while(1!==t);return n},toString:function(e){var t=this.n,r=this.d;if(isNaN(t)||isNaN(r))return"NaN";e=e||15;var n=function(e,t){for(;t%2==0;t/=2);for(;t%5==0;t/=5);if(1===t)return 0;for(var r=10%t,n=1;1!==r;n++)if(r=10*r%t,n>2e3)return 0;return n}(0,r),i=function(e,t,r){for(var n=1,i=function(e,t,r){for(var n=1;t>0;e=e*e%r,t>>=1)1&t&&(n=n*e%r);return n}(10,r,t),a=0;a<300;a++){if(n===i)return a;n=10*n%t,i=10*i%t}return 0}(0,r,n),a=this.s<0?"-":"";if(a+=t/r|0,t%=r,(t*=10)&&(a+="."),n){for(var o=i;o--;)a+=t/r|0,t%=r,t*=10;for(a+="(",o=n;o--;)a+=t/r|0,t%=r,t*=10;a+=")"}else for(o=e;t&&o--;)a+=t/r|0,t%=r,t*=10;return a}};var xn=Me("Fraction",[],(()=>(Object.defineProperty(dn,"name",{value:"Fraction"}),dn.prototype.constructor=dn,dn.prototype.type="Fraction",dn.prototype.isFraction=!0,dn.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},dn.fromJSON=function(e){return new dn(e)},dn)),{isClass:!0}),bn=Me("Range",[],(()=>{function e(t,r,n){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var i=null!=t,a=null!=r,o=null!=n;if(i)if(T(t))t=t.toNumber();else if("number"!=typeof t)throw new TypeError("Parameter start must be a number");if(a)if(T(r))r=r.toNumber();else if("number"!=typeof r)throw new TypeError("Parameter end must be a number");if(o)if(T(n))n=n.toNumber();else if("number"!=typeof n)throw new TypeError("Parameter step must be a number");this.start=i?parseFloat(t):0,this.end=a?parseFloat(r):0,this.step=o?parseFloat(n):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(t){if("string"!=typeof t)return null;var r=t.split(":").map((function(e){return parseFloat(e)}));if(r.some((function(e){return isNaN(e)})))return null;switch(r.length){case 2:return new e(r[0],r[1]);case 3:return new e(r[0],r[2],r[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var e=0,t=this.start,r=this.step,n=this.end-t;return Pe(r)===Pe(n)?e=Math.ceil(n/r):0===n&&(e=0),isNaN(e)&&(e=0),[e]},e.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},e.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},e.prototype.forEach=function(e){var t=this.start,r=this.step,n=this.end,i=0;if(r>0)for(;t<n;)e(t,[i],this),t+=r,i++;else if(r<0)for(;t>n;)e(t,[i],this),t+=r,i++},e.prototype.map=function(e){var t=[];return this.forEach((function(r,n,i){t[n[0]]=e(r,n,i)})),t},e.prototype.toArray=function(){var e=[];return this.forEach((function(t,r){e[r[0]]=t})),e},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(e){var t=We(this.start,e);return 1!==this.step&&(t+=":"+We(this.step,e)),t+":"+We(this.end,e)},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},e.fromJSON=function(t){return new e(t.start,t.end,t.step)},e}),{isClass:!0}),wn=Me("Matrix",[],(()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(e,t,r){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(e,t,r){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e}),{isClass:!0});function Dn(e,t,r){var n=new(0,e.constructor)(2),i="";if(r){if(r<1)throw new Error("size must be in greater than 0");if(!qe(r))throw new Error("size must be an integer");if(e.greaterThan(n.pow(r-1).sub(1))||e.lessThan(n.pow(r-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(r-1,", 2^").concat(r-1,"-1]"));if(!e.isInteger())throw new Error("Value must be an integer");e.lessThan(0)&&(e=e.add(n.pow(r))),i="i".concat(r)}switch(t){case 2:return"".concat(e.toBinary()).concat(i);case 8:return"".concat(e.toOctal()).concat(i);case 16:return"".concat(e.toHexadecimal()).concat(i);default:throw new Error("Base ".concat(t," not supported "))}}function Nn(e,t){return void 0!==t?e.toExponential(t-1):e.toExponential()}function En(e,t){return F(e)?e:T(e)?e.toNumber():t}function An(e,t){var r=e.length-t.length,n=e.length;return e.substring(r,n)===t}function Sn(e,t){var r=function(e,t){return"number"==typeof e?We(e,t):T(e)?function(e,t){if("function"==typeof t)return t(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var{notation:r,precision:n,wordSize:i}=Ve(t);switch(r){case"fixed":return function(e,t){return e.toFixed(t)}(e,n);case"exponential":return Nn(e,n);case"engineering":return function(e,t){var r=e.e,n=r%3==0?r:r<0?r-3-r%3:r-r%3,i=e.mul(Math.pow(10,-n)).toPrecision(t);return i.includes("e")&&(i=new(0,e.constructor)(i).toFixed()),i+"e"+(r>=0?"+":"")+n.toString()}(e,n);case"bin":return Dn(e,2,i);case"oct":return Dn(e,8,i);case"hex":return Dn(e,16,i);case"auto":var a=En(null==t?void 0:t.lowerExp,-3),o=En(null==t?void 0:t.upperExp,5);if(e.isZero())return"0";var s=e.toSignificantDigits(n),u=s.e;return(u>=a&&u<o?s.toFixed():Nn(e,n)).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t}));default:throw new Error('Unknown notation "'+r+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}(e,t):function(e){return e&&"object"==typeof e&&"number"==typeof e.s&&"number"==typeof e.n&&"number"==typeof e.d||!1}(e)?t&&"decimal"===t.fraction?e.toString():e.s*e.n+"/"+e.d:Array.isArray(e)?Tn(e,t):z(e)?Cn(e):"function"==typeof e?e.syntax?String(e.syntax):"function":e&&"object"==typeof e?"function"==typeof e.format?e.format(t):e&&e.toString(t)!=={}.toString()?e.toString(t):"{"+Object.keys(e).map((r=>Cn(r)+": "+Sn(e[r],t))).join(", ")+"}":String(e)}(e,t);return t&&"object"==typeof t&&"truncate"in t&&r.length>t.truncate?r.substring(0,t.truncate-3)+"...":r}function Cn(e){for(var t=String(e),r="",n=0;n<t.length;){var i=t.charAt(n);r+=i in Mn?Mn[i]:i,n++}return'"'+r+'"'}var Mn={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"};function Fn(e){var t=String(e);return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function Tn(e,t){if(Array.isArray(e)){for(var r="[",n=e.length,i=0;i<n;i++)0!==i&&(r+=", "),r+=Tn(e[i],t);return r+"]"}return Sn(e,t)}function _n(e,t){if(!z(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+xe(e)+", index: 0)");if(!z(t))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+xe(t)+", index: 1)");return e===t?0:e>t?1:-1}function Bn(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function On(e,t,r){var n,i=e.length;if(i!==t[r])throw new g(i,t[r]);if(r<t.length-1){var a=r+1;for(n=0;n<i;n++){var o=e[n];if(!Array.isArray(o))throw new g(t.length-1,t.length,"<");On(e[n],t,a)}}else for(n=0;n<i;n++)if(Array.isArray(e[n]))throw new g(t.length+1,t.length,">")}function kn(e,t){if(0===t.length){if(Array.isArray(e))throw new g(e.length,0)}else On(e,t,0)}function zn(e,t){var r=e.isMatrix?e._size:Bn(e);t._sourceSize.forEach(((e,t)=>{if(null!==e&&e!==r[t])throw new g(e,r[t])}))}function In(e,t){if(void 0!==e){if(!F(e)||!qe(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&e>=t)throw new v(e,t)}}function qn(e){for(var t=0;t<e._dimensions.length;++t){var r=e._dimensions[t];if(r._data&&I(r._data)){if(0===r._size[0])return!0}else if(r.isRange){if(r.start===r.end)return!0}else if(z(r)&&0===r.length)return!0}return!1}function Rn(e,t,r){if(!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");return t.forEach((function(e){if(!F(e)||!qe(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Sn(t)+")")})),(F(e)||T(e))&&(e=[e]),Pn(e,t,0,void 0!==r?r:0),e}function Pn(e,t,r,n){var i,a,o=e.length,s=t[r],u=Math.min(o,s);if(e.length=s,r<t.length-1){var c=r+1;for(i=0;i<u;i++)a=e[i],Array.isArray(a)||(a=[a],e[i]=a),Pn(a,t,c,n);for(i=u;i<s;i++)a=[],e[i]=a,Pn(a,t,c,n)}else{for(i=0;i<u;i++)for(;Array.isArray(e[i]);)e[i]=e[i][0];for(i=u;i<s;i++)e[i]=n}}function jn(e,t){var r=Vn(e),n=r.length;if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new g(0,n,"!=");var i=Ln(t=Un(t,n));if(n!==i)throw new g(i,n,"!=");try{return function(e,t){for(var r,n=e,i=t.length-1;i>0;i--){var a=t[i];r=[];for(var o=n.length/a,s=0;s<o;s++)r.push(n.slice(s*a,(s+1)*a));n=r}return n}(r,t)}catch(e){if(e instanceof g)throw new g(i,n,"!=");throw e}}function Un(e,t){var r=Ln(e),n=e.slice(),i=e.indexOf(-1);if(e.indexOf(-1,i+1)>=0)throw new Error("More than one wildcard in sizes");if(i>=0){if(t%r!=0)throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-r);n[i]=-t/r}return n}function Ln(e){return e.reduce(((e,t)=>e*t),1)}function Hn(e,t){for(var r=t||Bn(e);Array.isArray(e)&&1===e.length;)e=e[0],r.shift();for(var n=r.length;1===r[n-1];)n--;return n<r.length&&(e=$n(e,n,0),r.length=n),e}function $n(e,t,r){var n,i;if(r<t){var a=r+1;for(n=0,i=e.length;n<i;n++)e[n]=$n(e[n],t,a)}else for(;Array.isArray(e);)e=e[0];return e}function Gn(e,t,r,n){var i=n||Bn(e);if(r)for(var a=0;a<r;a++)e=[e],i.unshift(1);for(e=Wn(e,t,0);i.length<t;)i.push(1);return e}function Wn(e,t,r){var n,i;if(Array.isArray(e)){var a=r+1;for(n=0,i=e.length;n<i;n++)e[n]=Wn(e[n],t,a)}else for(var o=r;o<t;o++)e=[e];return e}function Vn(e){if(!Array.isArray(e))return e;var t=[];return e.forEach((function e(r){Array.isArray(r)?r.forEach(e):t.push(r)})),t}function Zn(e,t){return Array.prototype.map.call(e,t)}function Yn(e,t){Array.prototype.forEach.call(e,t)}function Jn(e,t){if(1!==Bn(e).length)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,(e=>t.test(e)))}function Xn(e,t){return Array.prototype.join.call(e,t)}function Qn(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;var t=[],r=0;t[0]={value:e[0],identifier:0};for(var n=1;n<e.length;n++)e[n]===e[n-1]?r++:r=0,t.push({value:e[n],identifier:r});return t}function Kn(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;for(var t=[],r=0;r<e.length;r++)t.push(e[r].value);return t}function ei(e,t){for(var r,n=0,i=0;i<e.length;i++){var a=e[i],o=Array.isArray(a);if(0===i&&o&&(n=a.length),o&&a.length!==n)return;var s=o?ei(a,t):t(a);if(void 0===r)r=s;else if(r!==s)return"mixed"}return r}function ti(e,t,r,n){if(n<r){if(e.length!==t.length)throw new g(e.length,t.length);for(var i=[],a=0;a<e.length;a++)i[a]=ti(e[a],t[a],r,n+1);return i}return e.concat(t)}function ri(){var e=Array.prototype.slice.call(arguments,0,-1),t=Array.prototype.slice.call(arguments,-1);if(1===e.length)return e[0];if(e.length>1)return e.slice(1).reduce((function(e,r){return ti(e,r,t,0)}),e[0]);throw new Error("Wrong number of arguments in function concat")}function ni(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];for(var n=t.map((e=>e.length)),i=Math.max(...n),a=new Array(i).fill(null),o=0;o<t.length;o++)for(var s=t[o],u=n[o],c=0;c<u;c++){var l=i-u+c;s[c]>a[l]&&(a[l]=s[c])}for(var f=0;f<t.length;f++)ii(t[f],a);return a}function ii(e,t){for(var r=t.length,n=e.length,i=0;i<n;i++){var a=r-n+i;if(e[i]<t[a]&&e[i]>1||e[i]>t[a])throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(e,") not possible to broadcast dimension ").concat(n," with size ").concat(e[i]," to size ").concat(t[a]))}}function ai(e,t){var r=Bn(e);if(Ne(r,t))return e;ii(r,t);var n,i,a,o=ni(r,t),s=o.length,u=[...Array(s-r.length).fill(1),...r],c=function(e){return m([],e)}(e);r.length<s&&(r=Bn(c=jn(c,u)));for(var l=0;l<s;l++)r[l]<o[l]&&(n=c,i=o[l],a=l,r=Bn(c=ri(...Array(i).fill(n),a)));return c}function oi(e,t){if(!Array.isArray(e))throw new Error("Array expected");var r=Bn(e);if(t.length!==r.length)throw new g(t.length,r.length);for(var n=0;n<t.length;n++)In(t[n],r[n]);return t.reduce(((e,t)=>e[t]),e)}function si(e,t,r,n){return Array.isArray(e)?e.map((function(e,i){return si(e,t.concat(i),r,n)})):n(e,t,r)}function ui(e,t,r){if(h.isTypedFunction(e)){var n=(t.isMatrix?t.size():Bn(t)).map((()=>0)),i=t.isMatrix?t.get(n):oi(t,n),a=1===Object.keys(e.signatures).length,o=function(e,t,r,n){for(var i=[t,r,n],a=3;a>0;a--){var o=i.slice(0,a);if(null!==h.resolve(e,o))return a}}(e,i,n,t),s=a?Object.values(e.signatures)[0]:e;return o>=1&&o<=3?function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return ci(s,n.slice(0,o),r,e.name)}:function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return ci(s,n,r,e.name)}}return e}function ci(e,t,r,n){try{return e(...t)}catch(e){!function(e,t,r,n){var i;if(e instanceof TypeError&&"wrongType"===(null===(i=e.data)||void 0===i?void 0:i.category)){var a=[];throw a.push("value: ".concat(xe(t[0]))),t.length>=2&&a.push("index: ".concat(xe(t[1]))),t.length>=3&&a.push("array: ".concat(xe(t[2]))),new TypeError("Function ".concat(r," cannot apply callback arguments ")+"".concat(n,"(").concat(a.join(", "),") at index ").concat(JSON.stringify(t[1])))}throw new TypeError("Function ".concat(r," cannot apply callback arguments ")+"to function ".concat(n,": ").concat(e.message))}(e,t,r,n)}}var li=Me("DenseMatrix",["Matrix"],(e=>{var{Matrix:t}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!z(t))throw new Error("Invalid datatype: "+t);if(q(e))"DenseMatrix"===e.type?(this._data=be(e._data),this._size=be(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&I(e.data)&&I(e.size))this._data=e.data,this._size=e.size,kn(this._data,this._size),this._datatype=t||e.datatype;else if(I(e))this._data=s(e),this._size=Bn(this._data),kn(this._data,this._size),this._datatype=t;else{if(e)throw new TypeError("Unsupported type of data ("+xe(e)+")");this._data=[],this._size=[0],this._datatype=t}}function n(e,t,r,i){var a=i===r-1,o=t.dimension(i);return a?o.map((function(t){return In(t,e.length),e[t]})).valueOf():o.map((function(a){return In(a,e.length),n(e[a],t,r,i+1)})).valueOf()}function i(e,t,r,n,a){var o=a===n-1,s=t.dimension(a);o?s.forEach((function(t,n){In(t),e[t]=r[n[0]]})):s.forEach((function(o,s){In(o),i(e[o],t,r[s[0]],n,a+1)}))}function a(e,t,r){if(0===t.length){for(var n=e._data;I(n);)n=n[0];return n}return e._size=t.slice(0),e._data=Rn(e._data,e._size,r),e}function o(e,t,r){for(var n=e._size.slice(0),i=!1;n.length<t.length;)n.push(0),i=!0;for(var o=0,s=t.length;o<s;o++)t[o]>n[o]&&(n[o]=t[o],i=!0);i&&a(e,n,r)}function s(e){return q(e)?s(e.valueOf()):I(e)?e.map(s):e}return r.prototype=new t,r.prototype.createDenseMatrix=function(e,t){return new r(e,t)},Object.defineProperty(r,"name",{value:"DenseMatrix"}),r.prototype.constructor=r,r.prototype.type="DenseMatrix",r.prototype.isDenseMatrix=!0,r.prototype.getDataType=function(){return ei(this._data,xe)},r.prototype.storage=function(){return"dense"},r.prototype.datatype=function(){return this._datatype},r.prototype.create=function(e,t){return new r(e,t)},r.prototype.subset=function(e,t,a){switch(arguments.length){case 1:return function(e,t){if(!L(t))throw new TypeError("Invalid index");if(t.isScalar())return e.get(t.min());var i=t.size();if(i.length!==e._size.length)throw new g(i.length,e._size.length);for(var a=t.min(),o=t.max(),s=0,u=e._size.length;s<u;s++)In(a[s],e._size[s]),In(o[s],e._size[s]);return new r(n(e._data,t,i.length,0),e._datatype)}(this,e);case 2:case 3:return function(e,t,r,n){if(!t||!0!==t.isIndex)throw new TypeError("Invalid index");var a,s=t.size(),u=t.isScalar();if(q(r)?(a=r.size(),r=r.valueOf()):a=Bn(r),u){if(0!==a.length)throw new TypeError("Scalar expected");e.set(t.min(),r,n)}else{if(!Ne(a,s))try{a=Bn(r=0===a.length?ai([r],s):ai(r,s))}catch(e){}if(s.length<e._size.length)throw new g(s.length,e._size.length,"<");if(a.length<s.length){for(var c=0,l=0;1===s[c]&&1===a[c];)c++;for(;1===s[c];)l++,c++;r=Gn(r,s.length,l,a)}if(!Ne(s,a))throw new g(s,a,">");var f=t.max().map((function(e){return e+1}));o(e,f,n);var p=s.length;i(e._data,t,r,p,0)}return e}(this,e,t,a);default:throw new SyntaxError("Wrong number of arguments")}},r.prototype.get=function(e){return oi(this._data,e)},r.prototype.set=function(e,t,r){if(!I(e))throw new TypeError("Array expected");if(e.length<this._size.length)throw new g(e.length,this._size.length,"<");var n,i,a,s=e.map((function(e){return e+1}));o(this,s,r);var u=this._data;for(n=0,i=e.length-1;n<i;n++)In(a=e[n],u.length),u=u[a];return In(a=e[e.length-1],u.length),u[a]=t,this},r.prototype.resize=function(e,t,r){if(!R(e))throw new TypeError("Array or Matrix expected");var n=e.valueOf().map((e=>Array.isArray(e)&&1===e.length?e[0]:e));return a(r?this.clone():this,n,t)},r.prototype.reshape=function(e,t){var r=t?this.clone():this;r._data=jn(r._data,e);var n=r._size.reduce(((e,t)=>e*t));return r._size=Un(e,n),r},r.prototype.clone=function(){return new r({data:be(this._data),size:be(this._size),datatype:this._datatype})},r.prototype.size=function(){return this._size.slice(0)},r.prototype._forEach=function(e){var t=this,r=t.size();if(1!==r.length){var n=Array(r.length).fill(0),i=Array(r.length-1),a=i.length-1;i[0]=t._data[0];for(var o=0;o<a;o++)i[o+1]=i[o][0];for(n[a]=-1;;){var s=void 0;for(s=a;s>=0;s--){if(n[s]++,n[s]!==r[s]){i[s]=0===s?t._data[n[s]]:i[s-1][n[s]];for(var u=s;u<a;u++)i[u+1]=i[u][0];for(var c=0;c<r[i.length];c++)n[i.length]=c,e(i[a],c,n.slice(0));break}n[s]=0}if(-1===s)break}}else for(var l=0;l<r[0];l++)e(t._data,l,[l])},r.prototype.map=function(e){var t=this,n=new r(t),i=ui(e,t._data,"map");return n._forEach((function(e,r,n){e[r]=i(e[r],n,t)})),n},r.prototype.forEach=function(e){var t=this,r=ui(e,t._data,"map");t._forEach((function(e,n,i){r(e[n],i,t)}))},r.prototype[Symbol.iterator]=function*(){var e=function*(t,r){if(I(t))for(var n=0;n<t.length;n++)yield*e(t[n],r.concat(n));else yield{value:t,index:r}};yield*e(this._data,[])},r.prototype.rows=function(){var e=[];if(2!==this.size().length)throw new TypeError("Rows can only be returned for a 2D matrix.");var t=this._data;for(var n of t)e.push(new r([n],this._datatype));return e},r.prototype.columns=function(){var e=this,t=[],n=this.size();if(2!==n.length)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var i=this._data,a=function(n){var a=i.map((e=>[e[n]]));t.push(new r(a,e._datatype))},o=0;o<n[1];o++)a(o);return t},r.prototype.toArray=function(){return be(this._data)},r.prototype.valueOf=function(){return this._data},r.prototype.format=function(e){return Sn(this._data,e)},r.prototype.toString=function(){return Sn(this._data)},r.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},r.prototype.diagonal=function(e){if(e){if(T(e)&&(e=e.toNumber()),!F(e)||!qe(e))throw new TypeError("The parameter k must be an integer number")}else e=0;for(var t=e>0?e:0,n=e<0?-e:0,i=this._size[0],a=this._size[1],o=Math.min(i-n,a-t),s=[],u=0;u<o;u++)s[u]=this._data[u+n][u+t];return new r({data:s,size:[o],datatype:this._datatype})},r.diagonal=function(e,t,n,i){if(!I(e))throw new TypeError("Array expected, size parameter");if(2!==e.length)throw new Error("Only two dimensions matrix are supported");if(e=e.map((function(e){if(T(e)&&(e=e.toNumber()),!F(e)||!qe(e)||e<1)throw new Error("Size values must be positive integers");return e})),n){if(T(n)&&(n=n.toNumber()),!F(n)||!qe(n))throw new TypeError("The parameter k must be an integer number")}else n=0;var a,o=n>0?n:0,s=n<0?-n:0,u=e[0],c=e[1],l=Math.min(u-s,c-o);if(I(t)){if(t.length!==l)throw new Error("Invalid value array length");a=function(e){return t[e]}}else if(q(t)){var f=t.size();if(1!==f.length||f[0]!==l)throw new Error("Invalid matrix length");a=function(e){return t.get([e])}}else a=function(){return t};i||(i=T(a(0))?a(0).mul(0):0);var p=[];if(e.length>0){p=Rn(p,e,i);for(var m=0;m<l;m++)p[m+s][m+o]=a(m)}return new r({data:p,size:[u,c]})},r.fromJSON=function(e){return new r(e)},r.prototype.swapRows=function(e,t){if(!(F(e)&&qe(e)&&F(t)&&qe(t)))throw new Error("Row index must be positive integers");if(2!==this._size.length)throw new Error("Only two dimensional matrix is supported");return In(e,this._size[0]),In(t,this._size[0]),r._swapRows(e,t,this._data),this},r._swapRows=function(e,t,r){var n=r[e];r[e]=r[t],r[t]=n},r}),{isClass:!0}),fi="clone",pi=Me(fi,["typed"],(e=>{var{typed:t}=e;return t(fi,{any:be})}));function mi(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r<i;r++){var o=[];for(t=0;t<n;t++)o.push(e[t][r]);a.push(o)}return a}function hi(e){for(var t=0;t<e.length;t++)if(R(e[t]))return!0;return!1}function di(e,t){q(e)&&(e=e.valueOf());for(var r=0,n=e.length;r<n;r++){var i=e[r];Array.isArray(i)?di(i,t):t(i)}}function gi(e,t,r){return e&&"function"==typeof e.map?e.map((function(e){return gi(e,t,r)})):t(e)}function vi(e,t,r){var n=Array.isArray(e)?Bn(e):e.size();if(t<0||t>=n.length)throw new v(t,n.length);return q(e)?e.create(yi(e.valueOf(),t,r),e.datatype()):yi(e,t,r)}function yi(e,t,r){var n,i,a,o;if(t<=0){if(Array.isArray(e[0])){for(o=mi(e),i=[],n=0;n<o.length;n++)i[n]=yi(o[n],t-1,r);return i}for(a=e[0],n=1;n<e.length;n++)a=r(a,e[n]);return a}for(i=[],n=0;n<e.length;n++)i[n]=yi(e[n],t-1,r);return i}function xi(e,t,r,n,i,a,o,s,u,c,l){var f,p,m,h,d=e._values,g=e._index,v=e._ptr;if(n)for(p=v[t],m=v[t+1],f=p;f<m;f++)r[h=g[f]]!==a?(r[h]=a,o.push(h),c?(n[h]=u?s(d[f],l):s(l,d[f]),i[h]=a):n[h]=d[f]):(n[h]=u?s(d[f],n[h]):s(n[h],d[f]),i[h]=a);else for(p=v[t],m=v[t+1],f=p;f<m;f++)r[h=g[f]]!==a?(r[h]=a,o.push(h)):i[h]=a}var bi="isInteger",wi=Me(bi,["typed"],(e=>{var{typed:t}=e;return t(bi,{number:qe,BigNumber:function(e){return e.isInt()},bigint:function(e){return!0},Fraction:function(e){return 1===e.d&&isFinite(e.n)},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),Di="number";function Ni(e){return e<0}function Ei(e){return e>0}function Ai(e){return Number.isNaN(e)}function Si(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e-9,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(r<=0)throw new Error("Relative tolerance must be greater than 0");if(n<0)throw new Error("Absolute tolerance must be at least 0");return!e.isNaN()&&!t.isNaN()&&(e.isFinite()&&t.isFinite()?!!e.eq(t)||e.minus(t).abs().lte(e.constructor.max(e.constructor.max(e.abs(),t.abs()).mul(r),n)):e.eq(t))}Ni.signature=Di,Ei.signature=Di,Ai.signature=Di;var Ci="isNegative",Mi=Me(Ci,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(Ci,{number:e=>!Ke(e,0,r.relTol,r.absTol)&&Ni(e),BigNumber:e=>!Si(e,new e.constructor(0),r.relTol,r.absTol)&&e.isNeg()&&!e.isZero()&&!e.isNaN(),bigint:e=>e<0n,Fraction:e=>e.s<0,Unit:t.referToSelf((e=>r=>t.find(e,r.valueType())(r.value))),"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),Fi="isNumeric",Ti=Me(Fi,["typed"],(e=>{var{typed:t}=e;return t(Fi,{"number | BigNumber | bigint | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),_i="hasNumericValue",Bi=Me(_i,["typed","isNumeric"],(e=>{var{typed:t,isNumeric:r}=e;return t(_i,{boolean:()=>!0,string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return r(e)}})})),Oi="isPositive",ki=Me(Oi,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(Oi,{number:e=>!Ke(e,0,r.relTol,r.absTol)&&Ei(e),BigNumber:e=>!(Si(e,new e.constructor(0),r.relTol,r.absTol)||e.isNeg()||e.isZero()||e.isNaN()),bigint:e=>e>0n,Fraction:e=>e.s>0&&e.n>0,Unit:t.referToSelf((e=>r=>t.find(e,r.valueType())(r.value))),"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),zi="isZero",Ii=Me(zi,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return t(zi,{"number | BigNumber | Complex | Fraction":e=>r(e,0),bigint:e=>0n===e,Unit:t.referToSelf((e=>r=>t.find(e,r.valueType())(r.value))),"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),qi="isNaN",Ri=Me(qi,["typed"],(e=>{var{typed:t}=e;return t(qi,{number:Ai,BigNumber:function(e){return e.isNaN()},bigint:function(e){return!1},Fraction:function(e){return!1},Complex:function(e){return e.isNaN()},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),Pi="typeOf",ji=Me(Pi,["typed"],(e=>{var{typed:t}=e;return t(Pi,{any:xe})})),Ui=Me("compareUnits",["typed"],(e=>{var{typed:t}=e;return{"Unit, Unit":t.referToSelf((e=>(r,n)=>{if(!r.equalBase(n))throw new Error("Cannot compare units with different base");return t.find(e,[r.valueType(),n.valueType()])(r.value,n.value)}))}})),Li="equalScalar",Hi=Me(Li,["typed","config"],(e=>{var{typed:t,config:r}=e,n=Ui({typed:t});return t(Li,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return Ke(e,t,r.relTol,r.absTol)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||Si(e,t,r.relTol,r.absTol)},"bigint, bigint":function(e,t){return e===t},"Fraction, Fraction":function(e,t){return e.equals(t)},"Complex, Complex":function(e,t){return function(e,t,r,n){return Ke(e.re,t.re,r,n)&&Ke(e.im,t.im,r,n)}(e,t,r.relTol,r.absTol)}},n)})),$i=(Me(Li,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(Li,{"number, number":function(e,t){return Ke(e,t,r.relTol,r.absTol)}})})),Me("SparseMatrix",["typed","equalScalar","Matrix"],(e=>{var{typed:t,equalScalar:r,Matrix:n}=e;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!z(t))throw new Error("Invalid datatype: "+t);if(q(e))!function(e,t,r){"SparseMatrix"===t.type?(e._values=t._values?be(t._values):void 0,e._index=be(t._index),e._ptr=be(t._ptr),e._size=be(t._size),e._datatype=r||t._datatype):a(e,t.valueOf(),r||t._datatype)}(this,e,t);else if(e&&I(e.index)&&I(e.ptr)&&I(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=t||e.datatype;else if(I(e))a(this,e,t);else{if(e)throw new TypeError("Unsupported type of data ("+xe(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=t}}function a(e,n,i){e._values=[],e._index=[],e._ptr=[],e._datatype=i;var a=n.length,o=0,s=r,u=0;if(z(i)&&(s=t.find(r,[i,i])||r,u=t.convert(0,i)),a>0){var c=0;do{e._ptr.push(e._index.length);for(var l=0;l<a;l++){var f=n[l];if(I(f)){if(0===c&&o<f.length&&(o=f.length),c<f.length){var p=f[c];s(p,u)||(e._values.push(p),e._index.push(l))}}else 0===c&&o<1&&(o=1),s(f,u)||(e._values.push(f),e._index.push(l))}c++}while(c<o)}e._ptr.push(e._index.length),e._size=[a,o]}function o(e,t,r,n){if(r-t==0)return r;for(var i=t;i<r;i++)if(n[i]===e)return i;return t}function s(e,t,r,n,i,a,o){i.splice(e,0,n),a.splice(e,0,t);for(var s=r+1;s<o.length;s++)o[s]++}function u(e,n,i,a){var o=a||0,s=r,u=0;z(e._datatype)&&(s=t.find(r,[e._datatype,e._datatype])||r,u=t.convert(0,e._datatype),o=t.convert(o,e._datatype));var c,l,f,p=!s(o,u),m=e._size[0],h=e._size[1];if(i>h){for(l=h;l<i;l++)if(e._ptr[l]=e._values.length,p)for(c=0;c<m;c++)e._values.push(o),e._index.push(c);e._ptr[i]=e._values.length}else i<h&&(e._ptr.splice(i+1,h-i),e._values.splice(e._ptr[i],e._values.length),e._index.splice(e._ptr[i],e._index.length));if(h=i,n>m){if(p){var d=0;for(l=0;l<h;l++){e._ptr[l]=e._ptr[l]+d,f=e._ptr[l+1]+d;var g=0;for(c=m;c<n;c++,g++)e._values.splice(f+g,0,o),e._index.splice(f+g,0,c),d++}e._ptr[h]=e._values.length}}else if(n<m){var v=0;for(l=0;l<h;l++){e._ptr[l]=e._ptr[l]-v;var y=e._ptr[l],x=e._ptr[l+1]-v;for(f=y;f<x;f++)(c=e._index[f])>n-1&&(e._values.splice(f,1),e._index.splice(f,1),v++)}e._ptr[l]=e._values.length}return e._size[0]=n,e._size[1]=i,e}function c(e,t,r,n,i){var a,o,s=n[0],u=n[1],c=[];for(a=0;a<s;a++)for(c[a]=[],o=0;o<u;o++)c[a][o]=0;for(o=0;o<u;o++)for(var l=r[o],f=r[o+1],p=l;p<f;p++)c[a=t[p]][o]=e?i?be(e[p]):e[p]:1;return c}return i.prototype=new n,i.prototype.createSparseMatrix=function(e,t){return new i(e,t)},Object.defineProperty(i,"name",{value:"SparseMatrix"}),i.prototype.constructor=i,i.prototype.type="SparseMatrix",i.prototype.isSparseMatrix=!0,i.prototype.getDataType=function(){return ei(this._values,xe)},i.prototype.storage=function(){return"sparse"},i.prototype.datatype=function(){return this._datatype},i.prototype.create=function(e,t){return new i(e,t)},i.prototype.density=function(){var e=this._size[0],t=this._size[1];return 0!==e&&0!==t?this._index.length/(e*t):0},i.prototype.subset=function(e,t,r){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return function(e,t){if(!L(t))throw new TypeError("Invalid index");if(t.isScalar())return e.get(t.min());var r,n,a,o,s=t.size();if(s.length!==e._size.length)throw new g(s.length,e._size.length);var u=t.min(),c=t.max();for(r=0,n=e._size.length;r<n;r++)In(u[r],e._size[r]),In(c[r],e._size[r]);var l=e._values,f=e._index,p=e._ptr,m=t.dimension(0),h=t.dimension(1),d=[],v=[];m.forEach((function(e,t){v[e]=t[0],d[e]=!0}));var y=l?[]:void 0,x=[],b=[];return h.forEach((function(e){for(b.push(x.length),a=p[e],o=p[e+1];a<o;a++)r=f[a],!0===d[r]&&(x.push(v[r]),y&&y.push(l[a]))})),b.push(x.length),new i({values:y,index:x,ptr:b,size:s,datatype:e._datatype})}(this,e);case 2:case 3:return function(e,t,r,n){if(!t||!0!==t.isIndex)throw new TypeError("Invalid index");var i,a=t.size(),o=t.isScalar();if(q(r)?(i=r.size(),r=r.toArray()):i=Bn(r),o){if(0!==i.length)throw new TypeError("Scalar expected");e.set(t.min(),r,n)}else{if(1!==a.length&&2!==a.length)throw new g(a.length,e._size.length,"<");if(i.length<a.length){for(var s=0,u=0;1===a[s]&&1===i[s];)s++;for(;1===a[s];)u++,s++;r=Gn(r,a.length,u,i)}if(!Ne(a,i))throw new g(a,i,">");if(1===a.length)t.dimension(0).forEach((function(t,i){In(t),e.set([t,0],r[i[0]],n)}));else{var c=t.dimension(0),l=t.dimension(1);c.forEach((function(t,i){In(t),l.forEach((function(a,o){In(a),e.set([t,a],r[i[0]][o[0]],n)}))}))}}return e}(this,e,t,r);default:throw new SyntaxError("Wrong number of arguments")}},i.prototype.get=function(e){if(!I(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new g(e.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var t=e[0],r=e[1];In(t,this._size[0]),In(r,this._size[1]);var n=o(t,this._ptr[r],this._ptr[r+1],this._index);return n<this._ptr[r+1]&&this._index[n]===t?this._values[n]:0},i.prototype.set=function(e,n,i){if(!I(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new g(e.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var a=e[0],c=e[1],l=this._size[0],f=this._size[1],p=r,m=0;z(this._datatype)&&(p=t.find(r,[this._datatype,this._datatype])||r,m=t.convert(0,this._datatype)),(a>l-1||c>f-1)&&(u(this,Math.max(a+1,l),Math.max(c+1,f),i),l=this._size[0],f=this._size[1]),In(a,l),In(c,f);var h=o(a,this._ptr[c],this._ptr[c+1],this._index);return h<this._ptr[c+1]&&this._index[h]===a?p(n,m)?function(e,t,r,n,i){r.splice(e,1),n.splice(e,1);for(var a=t+1;a<i.length;a++)i[a]--}(h,c,this._values,this._index,this._ptr):this._values[h]=n:p(n,m)||s(h,a,c,n,this._values,this._index,this._ptr),this},i.prototype.resize=function(e,t,r){if(!R(e))throw new TypeError("Array or Matrix expected");var n=e.valueOf().map((e=>Array.isArray(e)&&1===e.length?e[0]:e));if(2!==n.length)throw new Error("Only two dimensions matrix are supported");return n.forEach((function(e){if(!F(e)||!qe(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Sn(n)+")")})),u(r?this.clone():this,n[0],n[1],t)},i.prototype.reshape=function(e,t){if(!I(e))throw new TypeError("Array expected");if(2!==e.length)throw new Error("Sparse matrices can only be reshaped in two dimensions");e.forEach((function(t){if(!F(t)||!qe(t)||t<=-2||0===t)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Sn(e)+")")}));var r=this._size[0]*this._size[1];if(r!==(e=Un(e,r))[0]*e[1])throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var n=t?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return n;for(var i=[],a=0;a<n._ptr.length;a++)for(var u=0;u<n._ptr[a+1]-n._ptr[a];u++)i.push(a);for(var c=n._values.slice(),l=n._index.slice(),f=0;f<n._index.length;f++){var p=l[f],m=i[f],h=p*n._size[1]+m;i[f]=h%e[1],l[f]=Math.floor(h/e[1])}n._values.length=0,n._index.length=0,n._ptr.length=e[1]+1,n._size=e.slice();for(var d=0;d<n._ptr.length;d++)n._ptr[d]=0;for(var g=0;g<c.length;g++){var v=l[g],y=i[g],x=c[g];s(o(v,n._ptr[y],n._ptr[y+1],n._index),v,y,x,n._values,n._index,n._ptr)}return n},i.prototype.clone=function(){return new i({values:this._values?be(this._values):void 0,index:be(this._index),ptr:be(this._ptr),size:be(this._size),datatype:this._datatype})},i.prototype.size=function(){return this._size.slice(0)},i.prototype.map=function(e,n){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var a=this,o=this._size[0],s=this._size[1],u=ui(e,a,"map");return function(e,n,o,s,c,l,f){var p=[],m=[],h=[],d=r,g=0;z(e._datatype)&&(d=t.find(r,[e._datatype,e._datatype])||r,g=t.convert(0,e._datatype));for(var v=function(e,t,r){var n=function(e,t,r){return u(e,[t,r],a)}(e,t,r);d(n,g)||(p.push(n),m.push(t))},y=0;y<=c;y++){h.push(p.length);var x=e._ptr[y],b=e._ptr[y+1];if(f)for(var w=x;w<b;w++){var D=e._index[w];D>=0&&D<=o&&v(e._values[w],D-0,y-0)}else{for(var N={},E=x;E<b;E++)N[e._index[E]]=e._values[E];for(var A=0;A<=o;A++)v(A in N?N[A]:0,A-0,y-0)}}return h.push(p.length),new i({values:p,index:m,ptr:h,size:[o-0+1,c-0+1]})}(this,0,o-1,0,s-1,0,n)},i.prototype.forEach=function(e,t){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var r=this,n=this._size[0],i=this._size[1],a=ui(e,r,"forEach"),o=0;o<i;o++){var s=this._ptr[o],u=this._ptr[o+1];if(t)for(var c=s;c<u;c++){var l=this._index[c];a(this._values[c],[l,o],r)}else{for(var f={},p=s;p<u;p++)f[this._index[p]]=this._values[p];for(var m=0;m<n;m++)a(m in f?f[m]:0,[m,o],r)}}},i.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var e=this._size[1],t=0;t<e;t++)for(var r=this._ptr[t],n=this._ptr[t+1],i=r;i<n;i++){var a=this._index[i];yield{value:this._values[i],index:[a,t]}}},i.prototype.toArray=function(){return c(this._values,this._index,this._ptr,this._size,!0)},i.prototype.valueOf=function(){return c(this._values,this._index,this._ptr,this._size,!1)},i.prototype.format=function(e){for(var t=this._size[0],r=this._size[1],n=this.density(),i="Sparse Matrix ["+Sn(t,e)+" x "+Sn(r,e)+"] density: "+Sn(n,e)+"\n",a=0;a<r;a++)for(var o=this._ptr[a],s=this._ptr[a+1],u=o;u<s;u++)i+="\n ("+Sn(this._index[u],e)+", "+Sn(a,e)+") ==> "+(this._values?Sn(this._values[u],e):"X");return i},i.prototype.toString=function(){return Sn(this.toArray())},i.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},i.prototype.diagonal=function(e){if(e){if(T(e)&&(e=e.toNumber()),!F(e)||!qe(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var t=e>0?e:0,r=e<0?-e:0,n=this._size[0],a=this._size[1],o=Math.min(n-r,a-t),s=[],u=[],c=[];c[0]=0;for(var l=t;l<a&&s.length<o;l++)for(var f=this._ptr[l],p=this._ptr[l+1],m=f;m<p;m++){var h=this._index[m];if(h===l-t+r){s.push(this._values[m]),u[s.length-1]=h-r;break}}return c.push(s.length),new i({values:s,index:u,ptr:c,size:[o,1]})},i.fromJSON=function(e){return new i(e)},i.diagonal=function(e,n,a,o,s){if(!I(e))throw new TypeError("Array expected, size parameter");if(2!==e.length)throw new Error("Only two dimensions matrix are supported");if(e=e.map((function(e){if(T(e)&&(e=e.toNumber()),!F(e)||!qe(e)||e<1)throw new Error("Size values must be positive integers");return e})),a){if(T(a)&&(a=a.toNumber()),!F(a)||!qe(a))throw new TypeError("The parameter k must be an integer number")}else a=0;var u=r,c=0;z(s)&&(u=t.find(r,[s,s])||r,c=t.convert(0,s));var l,f=a>0?a:0,p=a<0?-a:0,m=e[0],h=e[1],d=Math.min(m-p,h-f);if(I(n)){if(n.length!==d)throw new Error("Invalid value array length");l=function(e){return n[e]}}else if(q(n)){var g=n.size();if(1!==g.length||g[0]!==d)throw new Error("Invalid matrix length");l=function(e){return n.get([e])}}else l=function(){return n};for(var v=[],y=[],x=[],b=0;b<h;b++){x.push(v.length);var w=b-f;if(w>=0&&w<d){var D=l(w);u(D,c)||(y.push(w+p),v.push(D))}}return x.push(v.length),new i({values:v,index:y,ptr:x,size:[m,h]})},i.prototype.swapRows=function(e,t){if(!(F(e)&&qe(e)&&F(t)&&qe(t)))throw new Error("Row index must be positive integers");if(2!==this._size.length)throw new Error("Only two dimensional matrix is supported");return In(e,this._size[0]),In(t,this._size[0]),i._swapRows(e,t,this._size[1],this._values,this._index,this._ptr),this},i._forEachRow=function(e,t,r,n,i){for(var a=n[e],o=n[e+1],s=a;s<o;s++)i(r[s],t[s])},i._swapRows=function(e,t,r,n,i,a){for(var s=0;s<r;s++){var u=a[s],c=a[s+1],l=o(e,u,c,i),f=o(t,u,c,i);if(l<c&&f<c&&i[l]===e&&i[f]===t){if(n){var p=n[l];n[l]=n[f],n[f]=p}}else if(l<c&&i[l]===e&&(f>=c||i[f]!==t)){var m=n?n[l]:void 0;i.splice(f,0,t),n&&n.splice(f,0,m),i.splice(f<=l?l+1:l,1),n&&n.splice(f<=l?l+1:l,1)}else if(f<c&&i[f]===t&&(l>=c||i[l]!==e)){var h=n?n[f]:void 0;i.splice(l,0,e),n&&n.splice(l,0,h),i.splice(l<=f?f+1:f,1),n&&n.splice(l<=f?f+1:f,1)}}},i}),{isClass:!0})),Gi=Me("number",["typed"],(e=>{var{typed:t}=e,r=t("number",{"":function(){return 0},number:function(e){return e},string:function(e){if("NaN"===e)return NaN;var t,r,n=(r=(t=e).match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/))?{input:t,radix:{"0b":2,"0o":8,"0x":16}[r[1]],integerPart:r[2],fractionalPart:r[3]}:null;if(n)return function(e){for(var t=parseInt(e.integerPart,e.radix),r=0,n=0;n<e.fractionalPart.length;n++)r+=parseInt(e.fractionalPart[n],e.radix)/Math.pow(e.radix,n+1);var i=t+r;if(isNaN(i))throw new SyntaxError('String "'+e.input+'" is not a valid number');return i}(n);var i=0,a=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);a&&(i=Number(a[2]),e=a[1]);var o=Number(e);if(isNaN(o))throw new SyntaxError('String "'+e+'" is not a valid number');if(a){if(o>2**i-1)throw new SyntaxError('String "'.concat(e,'" is out of range'));o>=2**(i-1)&&(o-=2**i)}return o},BigNumber:function(e){return e.toNumber()},bigint:function(e){return Number(e)},Fraction:function(e){return e.valueOf()},Unit:t.referToSelf((e=>t=>{var r=t.clone();return r.value=e(t.value),r})),null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))});return r.fromJSON=function(e){return parseFloat(e.value)},r})),Wi=Me("bigint",["typed"],(e=>{var{typed:t}=e,r=t("bigint",{"":function(){return 0n},bigint:function(e){return e},number:function(e){return BigInt(e.toFixed())},BigNumber:function(e){return BigInt(e.round().toString())},Fraction:function(e){return BigInt(e.valueOf().toFixed())},"string | boolean":function(e){return BigInt(e)},null:function(e){return 0n},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))});return r.fromJSON=function(e){return BigInt(e.value)},r})),Vi="string",Zi=Me(Vi,["typed"],(e=>{var{typed:t}=e;return t(Vi,{"":function(){return""},number:We,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e))),any:function(e){return String(e)}})})),Yi="boolean",Ji=Me(Yi,["typed"],(e=>{var{typed:t}=e;return t(Yi,{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(e){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;var r=Number(e);if(""!==e&&!isNaN(r))return!!r;throw new Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),Xi=Me("bignumber",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("bignumber",{"":function(){return new r(0)},number:function(e){return new r(e+"")},string:function(e){var t=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(t){var n=t[2],i=r(t[1]),a=new r(2).pow(Number(n));if(i.gt(a.sub(1)))throw new SyntaxError('String "'.concat(e,'" is out of range'));var o=new r(2).pow(Number(n)-1);return i.gte(o)?i.sub(a):i}return new r(e)},BigNumber:function(e){return e},bigint:function(e){return new r(e.toString())},Unit:t.referToSelf((e=>t=>{var r=t.clone();return r.value=e(t.value),r})),Fraction:function(e){return new r(e.n).div(e.d).times(e.s)},null:function(e){return new r(0)},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),Qi=Me("complex",["typed","Complex"],(e=>{var{typed:t,Complex:r}=e;return t("complex",{"":function(){return r.ZERO},number:function(e){return new r(e,0)},"number, number":function(e,t){return new r(e,t)},"BigNumber, BigNumber":function(e,t){return new r(e.toNumber(),t.toNumber())},Fraction:function(e){return new r(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return r(e)},null:function(e){return r(0)},Object:function(e){if("re"in e&&"im"in e)return new r(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new r(e);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),Ki=Me("fraction",["typed","Fraction"],(e=>{var{typed:t,Fraction:r}=e;return t("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw new Error(e+" cannot be represented as a fraction");return new r(e)},string:function(e){return new r(e)},"number, number":function(e,t){return new r(e,t)},null:function(e){return new r(0)},BigNumber:function(e){return new r(e.toString())},bigint:function(e){return new r(e.toString())},Fraction:function(e){return e},Unit:t.referToSelf((e=>t=>{var r=t.clone();return r.value=e(t.value),r})),Object:function(e){return new r(e)},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),ea="matrix",ta=Me(ea,["typed","Matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,Matrix:r,DenseMatrix:n,SparseMatrix:i}=e;return t(ea,{"":function(){return a([])},string:function(e){return a([],e)},"string, string":function(e,t){return a([],e,t)},Array:function(e){return a(e)},Matrix:function(e){return a(e,e.storage())},"Array | Matrix, string":a,"Array | Matrix, string, string":a});function a(e,t,r){if("dense"===t||"default"===t||void 0===t)return new n(e,r);if("sparse"===t)return new i(e,r);throw new TypeError("Unknown matrix type "+JSON.stringify(t)+".")}})),ra="matrixFromFunction",na=Me(ra,["typed","matrix","isZero"],(e=>{var{typed:t,matrix:r,isZero:n}=e;return t(ra,{"Array | Matrix, function, string, string":function(e,t,r,n){return i(e,t,r,n)},"Array | Matrix, function, string":function(e,t,r){return i(e,t,r)},"Matrix, function":function(e,t){return i(e,t,"dense")},"Array, function":function(e,t){return i(e,t,"dense").toArray()},"Array | Matrix, string, function":function(e,t,r){return i(e,r,t)},"Array | Matrix, string, string, function":function(e,t,r,n){return i(e,n,t,r)}});function i(e,t,i,a){var o;return(o=void 0!==a?r(i,a):r(i)).resize(e),o.forEach((function(e,r){var i=t(r);n(i)||o.set(r,i)})),o}})),ia="matrixFromRows",aa=Me(ia,["typed","matrix","flatten","size"],(e=>{var{typed:t,matrix:r,flatten:n,size:i}=e;return t(ia,{"...Array":function(e){return a(e)},"...Matrix":function(e){return r(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one row is needed to construct a matrix.");var t=o(e[0]),r=[];for(var i of e){var a=o(i);if(a!==t)throw new TypeError("The vectors had different length: "+(0|t)+" ≠ "+(0|a));r.push(n(i))}return r}function o(e){var t=i(e);if(1===t.length)return t[0];if(2===t.length){if(1===t[0])return t[1];if(1===t[1])return t[0];throw new TypeError("At least one of the arguments is not a vector.")}throw new TypeError("Only one- or two-dimensional vectors are supported.")}})),oa="matrixFromColumns",sa=Me(oa,["typed","matrix","flatten","size"],(e=>{var{typed:t,matrix:r,flatten:n,size:i}=e;return t(oa,{"...Array":function(e){return a(e)},"...Matrix":function(e){return r(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one column is needed to construct a matrix.");for(var t=o(e[0]),r=[],i=0;i<t;i++)r[i]=[];for(var a of e){var s=o(a);if(s!==t)throw new TypeError("The vectors had different length: "+(0|t)+" ≠ "+(0|s));for(var u=n(a),c=0;c<t;c++)r[c].push(u[c])}return r}function o(e){var t=i(e);if(1===t.length)return t[0];if(2===t.length){if(1===t[0])return t[1];if(1===t[1])return t[0];throw new TypeError("At least one of the arguments is not a vector.")}throw new TypeError("Only one- or two-dimensional vectors are supported.")}})),ua="splitUnit",ca=Me(ua,["typed"],(e=>{var{typed:t}=e;return t(ua,{"Unit, Array":function(e,t){return e.splitUnit(t)}})})),la="number",fa="number, number";function pa(e){return Math.abs(e)}function ma(e,t){return e+t}function ha(e,t){return e-t}function da(e,t){return e*t}function ga(e){return-e}function va(e){return e}function ya(e){return He(e)}function xa(e){return e*e*e}function ba(e){return Math.exp(e)}function wa(e){return $e(e)}function Da(e,t){if(!qe(e)||!qe(t))throw new Error("Parameters in function lcm must be integer numbers");if(0===e||0===t)return 0;for(var r,n=e*t;0!==t;)t=e%(r=t),e=r;return Math.abs(n/e)}function Na(e){return Ue(e)}function Ea(e){return je(e)}function Aa(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,r=t<0;if(r&&(t=-t),0===t)throw new Error("Root must be non-zero");if(e<0&&Math.abs(t)%2!=1)throw new Error("Root must be odd when a is negative.");if(0===e)return r?1/0:0;if(!isFinite(e))return r?0:e;var n=Math.pow(Math.abs(e),1/t);return n=e<0?-n:n,r?1/n:n}function Sa(e){return Pe(e)}function Ca(e){return e*e}function Ma(e,t){var r,n,i,a=0,o=1,s=1,u=0;if(!qe(e)||!qe(t))throw new Error("Parameters in function xgcd must be integer numbers");for(;t;)i=e-(n=Math.floor(e/t))*t,r=a,a=o-n*a,o=r,r=s,s=u-n*s,u=r,e=t,t=i;return e<0?[-e,-o,-u]:[e,e?o:0,u]}function Fa(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:Math.pow(e,t)}function Ta(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!qe(t)||t<0||t>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(Ye(e,t))}pa.signature=la,ma.signature=fa,ha.signature=fa,da.signature=fa,ga.signature=la,va.signature=la,ya.signature=la,xa.signature=la,ba.signature=la,wa.signature=la,Da.signature=fa,Na.signature=la,Ea.signature=la,Sa.signature=la,Ca.signature=la,Ma.signature=fa,Fa.signature=fa;var _a="unaryMinus",Ba=Me(_a,["typed"],(e=>{var{typed:t}=e;return t(_a,{number:ga,"Complex | BigNumber | Fraction":e=>e.neg(),bigint:e=>-e,Unit:t.referToSelf((e=>r=>{var n=r.clone();return n.value=t.find(e,n.valueType())(r.value),n})),"Array | Matrix":t.referToSelf((e=>t=>gi(t,e,!0)))})})),Oa="unaryPlus",ka=Me(Oa,["typed","config","numeric"],(e=>{var{typed:t,config:r,numeric:n}=e;return t(Oa,{number:va,Complex:function(e){return e},BigNumber:function(e){return e},bigint:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e,!0))),boolean:function(e){return n(e?1:0,r.number)},string:function(e){return n(e,Re(e,r))}})})),za=Me("abs",["typed"],(e=>{var{typed:t}=e;return t("abs",{number:pa,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),bigint:e=>e<0n?-e:e,"Array | Matrix":t.referToSelf((e=>t=>gi(t,e,!0)))})})),Ia="apply",qa=Me(Ia,["typed","isInteger"],(e=>{var{typed:t,isInteger:r}=e;return t(Ia,{"Array | Matrix, number | BigNumber, function":function(e,t,n){if(!r(t))throw new TypeError("Integer number expected for dimension");var i=Array.isArray(e)?Bn(e):e.size();if(t<0||t>=i.length)throw new v(t,i.length);return q(e)?e.create(Ra(e.valueOf(),t,n),e.datatype()):Ra(e,t,n)}})}));function Ra(e,t,r){var n,i,a;if(t<=0){if(Array.isArray(e[0])){for(a=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r<i;r++){var o=[];for(t=0;t<n;t++)o.push(e[t][r]);a.push(o)}return a}(e),i=[],n=0;n<a.length;n++)i[n]=Ra(a[n],t-1,r);return i}return r(e)}for(i=[],n=0;n<e.length;n++)i[n]=Ra(e[n],t-1,r);return i}var Pa="addScalar",ja=Me(Pa,["typed"],(e=>{var{typed:t}=e;return t(Pa,{"number, number":ma,"Complex, Complex":function(e,t){return e.add(t)},"BigNumber, BigNumber":function(e,t){return e.plus(t)},"bigint, bigint":function(e,t){return e+t},"Fraction, Fraction":function(e,t){return e.add(t)},"Unit, Unit":t.referToSelf((e=>(r,n)=>{if(null===r.value||void 0===r.value)throw new Error("Parameter x contains a unit with undefined value");if(null===n.value||void 0===n.value)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var i=r.clone();return i.value=t.find(e,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i}))})})),Ua="subtractScalar",La=Me(Ua,["typed"],(e=>{var{typed:t}=e;return t(Ua,{"number, number":ha,"Complex, Complex":function(e,t){return e.sub(t)},"BigNumber, BigNumber":function(e,t){return e.minus(t)},"bigint, bigint":function(e,t){return e-t},"Fraction, Fraction":function(e,t){return e.sub(t)},"Unit, Unit":t.referToSelf((e=>(r,n)=>{if(null===r.value||void 0===r.value)throw new Error("Parameter x contains a unit with undefined value");if(null===n.value||void 0===n.value)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var i=r.clone();return i.value=t.find(e,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i}))})})),Ha="cbrt",$a=Me(Ha,["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],(e=>{var{config:t,typed:r,isNegative:n,unaryMinus:i,matrix:a,Complex:o,BigNumber:s,Fraction:u}=e;return r(Ha,{number:ya,Complex:c,"Complex, boolean":c,BigNumber:function(e){return e.cbrt()},Unit:function(e){if(e.value&&B(e.value)){var t=e.clone();return t.value=1,(t=t.pow(1/3)).value=c(e.value),t}var r,a=n(e.value);a&&(e.value=i(e.value)),r=T(e.value)?new s(1).div(3):O(e.value)?new u(1,3):1/3;var o=e.pow(r);return a&&(o.value=i(o.value)),o}});function c(e,r){var n=e.arg()/3,i=e.abs(),s=new o(ya(i),0).mul(new o(0,n).exp());if(r){var u=[s,new o(ya(i),0).mul(new o(0,n+2*Math.PI/3).exp()),new o(ya(i),0).mul(new o(0,n-2*Math.PI/3).exp())];return"Array"===t.matrix?u:a(u)}return s}})),Ga=Me("matAlgo11xS0s",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=r,d=0,g=i;"string"==typeof l&&(f=l,h=t.find(r,[f,f]),d=t.convert(0,f),n=t.convert(n,f),g=t.find(i,[f,f]));for(var v=[],y=[],x=[],b=0;b<m;b++){x[b]=y.length;for(var w=u[b],D=u[b+1],N=w;N<D;N++){var E=s[N],A=a?g(n,o[N]):g(o[N],n);h(A,d)||(y.push(E),v.push(A))}}return x[m]=y.length,e.createSparseMatrix({values:v,index:y,ptr:x,size:[p,m],datatype:f})}})),Wa=Me("matAlgo12xSfs",["typed","DenseMatrix"],(e=>{var{typed:t,DenseMatrix:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=i;"string"==typeof l&&(f=l,n=t.convert(n,f),h=t.find(i,[f,f]));for(var d=[],g=[],v=[],y=0;y<m;y++){for(var x=y+1,b=u[y],w=u[y+1],D=b;D<w;D++){var N=s[D];g[N]=o[D],v[N]=x}for(var E=0;E<p;E++)0===y&&(d[E]=[]),v[E]===x?d[E][y]=a?h(n,g[E]):h(g[E],n):d[E][y]=a?h(n,0):h(0,n)}return new r({data:d,size:[p,m],datatype:f})}})),Va=Me("matAlgo14xDs",["typed"],(e=>{var{typed:t}=e;return function(e,n,i,a){var o,s=e._data,u=e._size,c=e._datatype,l=i;"string"==typeof c&&(o=c,n=t.convert(n,o),l=t.find(i,[o,o]));var f=u.length>0?r(l,0,u,u[0],s,n,a):[];return e.createDenseMatrix({data:f,size:be(u),datatype:o})};function r(e,t,n,i,a,o,s){var u=[];if(t===n.length-1)for(var c=0;c<i;c++)u[c]=s?e(o,a[c]):e(a[c],o);else for(var l=0;l<i;l++)u[l]=r(e,t+1,n,n[t+1],a[l],o,s);return u}})),Za="ceil",Ya=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],Ja=Me(Za,["typed","config","round"],(e=>{var{typed:t,config:r,round:n}=e;return t(Za,{number:function(e){return Ke(e,n(e),r.relTol,r.absTol)?n(e):Math.ceil(e)},"number, number":function(e,t){if(Ke(e,n(e,t),r.relTol,r.absTol))return n(e,t);var[i,a]="".concat(e,"e").split("e"),o=Math.ceil(Number("".concat(i,"e").concat(Number(a)+t)));return[i,a]="".concat(o,"e").split("e"),Number("".concat(i,"e").concat(Number(a)-t))}})})),Xa=Me(Za,Ya,(e=>{var{typed:t,config:r,round:n,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s}=e,u=Ga({typed:t,equalScalar:a}),c=Wa({typed:t,DenseMatrix:s}),l=Va({typed:t}),f=Ja({typed:t,config:r,round:n});return t("ceil",{number:f.signatures.number,"number,number":f.signatures["number,number"],Complex:function(e){return e.ceil()},"Complex, number":function(e,t){return e.ceil(t)},"Complex, BigNumber":function(e,t){return e.ceil(t.toNumber())},BigNumber:function(e){return Si(e,n(e),r.relTol,r.absTol)?n(e):e.ceil()},"BigNumber, BigNumber":function(e,t){return Si(e,n(e,t),r.relTol,r.absTol)?n(e,t):e.toDecimalPlaces(t.toNumber(),Xr.ROUND_CEIL)},Fraction:function(e){return e.ceil()},"Fraction, number":function(e,t){return e.ceil(t)},"Fraction, BigNumber":function(e,t){return e.ceil(t.toNumber())},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e,!0))),"Array, number | BigNumber":t.referToSelf((e=>(t,r)=>gi(t,(t=>e(t,r)),!0))),"SparseMatrix, number | BigNumber":t.referToSelf((e=>(t,r)=>u(t,r,e,!1))),"DenseMatrix, number | BigNumber":t.referToSelf((e=>(t,r)=>l(t,r,e,!1))),"number | Complex | Fraction | BigNumber, Array":t.referToSelf((e=>(t,r)=>l(i(r),t,e,!0).valueOf())),"number | Complex | Fraction | BigNumber, Matrix":t.referToSelf((e=>(t,r)=>a(t,0)?o(r.size(),r.storage()):"dense"===r.storage()?l(r,t,e,!0):c(r,t,e,!0)))})})),Qa="cube",Ka=Me(Qa,["typed"],(e=>{var{typed:t}=e;return t(Qa,{number:xa,Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},bigint:function(e){return e*e*e},Fraction:function(e){return e.pow(3)},Unit:function(e){return e.pow(3)}})})),eo=Me("exp",["typed"],(e=>{var{typed:t}=e;return t("exp",{number:ba,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()}})})),to="expm1",ro=Me(to,["typed","Complex"],(e=>{var{typed:t,Complex:r}=e;return t(to,{number:wa,Complex:function(e){var t=Math.exp(e.re);return new r(t*Math.cos(e.im)-1,t*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)}})})),no="fix",io=["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],ao=Me(no,["typed","ceil","floor"],(e=>{var{typed:t,ceil:r,floor:n}=e;return t(no,{number:function(e){return e>0?n(e):r(e)},"number, number":function(e,t){return e>0?n(e,t):r(e,t)}})})),oo=Me(no,io,(e=>{var{typed:t,Complex:r,matrix:n,ceil:i,floor:a,equalScalar:o,zeros:s,DenseMatrix:u}=e,c=Wa({typed:t,DenseMatrix:u}),l=Va({typed:t}),f=ao({typed:t,ceil:i,floor:a});return t("fix",{number:f.signatures.number,"number, number | BigNumber":f.signatures["number,number"],Complex:function(e){return new r(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},"Complex, number":function(e,t){return new r(e.re>0?a(e.re,t):i(e.re,t),e.im>0?a(e.im,t):i(e.im,t))},"Complex, BigNumber":function(e,t){var n=t.toNumber();return new r(e.re>0?a(e.re,n):i(e.re,n),e.im>0?a(e.im,n):i(e.im,n))},BigNumber:function(e){return e.isNegative()?i(e):a(e)},"BigNumber, number | BigNumber":function(e,t){return e.isNegative()?i(e,t):a(e,t)},Fraction:function(e){return e.s<0?e.ceil():e.floor()},"Fraction, number | BigNumber":function(e,t){return e.s<0?i(e,t):a(e,t)},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e,!0))),"Array | Matrix, number | BigNumber":t.referToSelf((e=>(t,r)=>gi(t,(t=>e(t,r)),!0))),"number | Complex | Fraction | BigNumber, Array":t.referToSelf((e=>(t,r)=>l(n(r),t,e,!0).valueOf())),"number | Complex | Fraction | BigNumber, Matrix":t.referToSelf((e=>(t,r)=>o(t,0)?s(r.size(),r.storage()):"dense"===r.storage()?l(r,t,e,!0):c(r,t,e,!0)))})})),so="floor",uo=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],co=Me(so,["typed","config","round"],(e=>{var{typed:t,config:r,round:n}=e;return t(so,{number:function(e){return Ke(e,n(e),r.relTol,r.absTol)?n(e):Math.floor(e)},"number, number":function(e,t){if(Ke(e,n(e,t),r.relTol,r.absTol))return n(e,t);var[i,a]="".concat(e,"e").split("e"),o=Math.floor(Number("".concat(i,"e").concat(Number(a)+t)));return[i,a]="".concat(o,"e").split("e"),Number("".concat(i,"e").concat(Number(a)-t))}})})),lo=Me(so,uo,(e=>{var{typed:t,config:r,round:n,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s}=e,u=Ga({typed:t,equalScalar:a}),c=Wa({typed:t,DenseMatrix:s}),l=Va({typed:t}),f=co({typed:t,config:r,round:n});return t("floor",{number:f.signatures.number,"number,number":f.signatures["number,number"],Complex:function(e){return e.floor()},"Complex, number":function(e,t){return e.floor(t)},"Complex, BigNumber":function(e,t){return e.floor(t.toNumber())},BigNumber:function(e){return Si(e,n(e),r.relTol,r.absTol)?n(e):e.floor()},"BigNumber, BigNumber":function(e,t){return Si(e,n(e,t),r.relTol,r.absTol)?n(e,t):e.toDecimalPlaces(t.toNumber(),Xr.ROUND_FLOOR)},Fraction:function(e){return e.floor()},"Fraction, number":function(e,t){return e.floor(t)},"Fraction, BigNumber":function(e,t){return e.floor(t.toNumber())},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e,!0))),"Array, number | BigNumber":t.referToSelf((e=>(t,r)=>gi(t,(t=>e(t,r)),!0))),"SparseMatrix, number | BigNumber":t.referToSelf((e=>(t,r)=>u(t,r,e,!1))),"DenseMatrix, number | BigNumber":t.referToSelf((e=>(t,r)=>l(t,r,e,!1))),"number | Complex | Fraction | BigNumber, Array":t.referToSelf((e=>(t,r)=>l(i(r),t,e,!0).valueOf())),"number | Complex | Fraction | BigNumber, Matrix":t.referToSelf((e=>(t,r)=>a(t,0)?o(r.size(),r.storage()):"dense"===r.storage()?l(r,t,e,!0):c(r,t,e,!0)))})})),fo=Me("matAlgo02xDS0",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i,a){var o=e._data,s=e._size,u=e._datatype||e.getDataType(),c=n._values,l=n._index,f=n._ptr,p=n._size,m=n._datatype||void 0===n._data?n._datatype:n.getDataType();if(s.length!==p.length)throw new g(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h,d=s[0],v=s[1],y=r,x=0,b=i;"string"==typeof u&&u===m&&"mixed"!==u&&(h=u,y=t.find(r,[h,h]),x=t.convert(0,h),b=t.find(i,[h,h]));for(var w=[],D=[],N=[],E=0;E<v;E++){N[E]=D.length;for(var A=f[E],S=f[E+1],C=A;C<S;C++){var M=l[C],F=a?b(c[C],o[M][E]):b(o[M][E],c[C]);y(F,x)||(D.push(M),w.push(F))}}return N[v]=D.length,n.createSparseMatrix({values:w,index:D,ptr:N,size:[d,v],datatype:u===e._datatype&&m===n._datatype?h:void 0})}})),po=Me("matAlgo03xDSf",["typed"],(e=>{var{typed:t}=e;return function(e,r,n,i){var a=e._data,o=e._size,s=e._datatype||e.getDataType(),u=r._values,c=r._index,l=r._ptr,f=r._size,p=r._datatype||void 0===r._data?r._datatype:r.getDataType();if(o.length!==f.length)throw new g(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m,h=o[0],d=o[1],v=0,y=n;"string"==typeof s&&s===p&&"mixed"!==s&&(m=s,v=t.convert(0,m),y=t.find(n,[m,m]));for(var x=[],b=0;b<h;b++)x[b]=[];for(var w=[],D=[],N=0;N<d;N++){for(var E=N+1,A=l[N],S=l[N+1],C=A;C<S;C++){var M=c[C];w[M]=i?y(u[C],a[M][N]):y(a[M][N],u[C]),D[M]=E}for(var F=0;F<h;F++)D[F]===E?x[F][N]=w[F]:x[F][N]=i?y(v,a[F][N]):y(a[F][N],v)}return e.createDenseMatrix({data:x,size:[h,d],datatype:s===e._datatype&&p===r._datatype?m:void 0})}})),mo=Me("matAlgo05xSfSf",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype||void 0===e._data?e._datatype:e.getDataType(),l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype||void 0===n._data?n._datatype:n.getDataType();if(u.length!==m.length)throw new g(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,v=u[0],y=u[1],x=r,b=0,w=i;"string"==typeof c&&c===h&&"mixed"!==c&&(d=c,x=t.find(r,[d,d]),b=t.convert(0,d),w=t.find(i,[d,d]));var D,N,E,A,S=a&&l?[]:void 0,C=[],M=[],F=S?[]:void 0,T=S?[]:void 0,_=[],B=[];for(N=0;N<y;N++){M[N]=C.length;var O=N+1;for(E=s[N],A=s[N+1];E<A;E++)D=o[E],C.push(D),_[D]=O,F&&(F[D]=a[E]);for(E=p[N],A=p[N+1];E<A;E++)_[D=f[E]]!==O&&C.push(D),B[D]=O,T&&(T[D]=l[E]);if(S)for(E=M[N];E<C.length;){var k=_[D=C[E]],z=B[D];if(k===O||z===O){var I=w(k===O?F[D]:b,z===O?T[D]:b);x(I,b)?C.splice(E,1):(S.push(I),E++)}}}return M[y]=C.length,e.createSparseMatrix({values:S,index:C,ptr:M,size:[v,y],datatype:c===e._datatype&&h===n._datatype?d:void 0})}})),ho=Me("matAlgo13xDD",["typed"],(e=>{var{typed:t}=e;return function(e,n,i){var a,o=e._data,s=e._size,u=e._datatype,c=n._data,l=n._size,f=n._datatype,p=[];if(s.length!==l.length)throw new g(s.length,l.length);for(var m=0;m<s.length;m++){if(s[m]!==l[m])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+l+")");p[m]=s[m]}var h=i;"string"==typeof u&&u===f&&(a=u,h=t.find(i,[a,a]));var d=p.length>0?r(h,0,p,p[0],o,c):[];return e.createDenseMatrix({data:d,size:p,datatype:a})};function r(e,t,n,i,a,o){var s=[];if(t===n.length-1)for(var u=0;u<i;u++)s[u]=e(a[u],o[u]);else for(var c=0;c<i;c++)s[c]=r(e,t+1,n,n[t+1],a[c],o[c]);return s}}));function go(e,t){if(Ne(e.size(),t.size()))return[e,t];var r=ni(e.size(),t.size());return[e,t].map((e=>function(e,t){return Ne(e.size(),t)?e:e.create(ai(e.valueOf(),t),e.datatype())}(e,r)))}var vo=Me("matrixAlgorithmSuite",["typed","matrix"],(e=>{var{typed:t,matrix:r}=e,n=ho({typed:t}),i=Va({typed:t});return function(e){var a,o=e.elop,s=e.SD||e.DS;o?(a={"DenseMatrix, DenseMatrix":(e,t)=>n(...go(e,t),o),"Array, Array":(e,t)=>n(...go(r(e),r(t)),o).valueOf(),"Array, DenseMatrix":(e,t)=>n(...go(r(e),t),o),"DenseMatrix, Array":(e,t)=>n(...go(e,r(t)),o)},e.SS&&(a["SparseMatrix, SparseMatrix"]=(t,r)=>e.SS(...go(t,r),o,!1)),e.DS&&(a["DenseMatrix, SparseMatrix"]=(t,r)=>e.DS(...go(t,r),o,!1),a["Array, SparseMatrix"]=(t,n)=>e.DS(...go(r(t),n),o,!1)),s&&(a["SparseMatrix, DenseMatrix"]=(e,t)=>s(...go(t,e),o,!0),a["SparseMatrix, Array"]=(e,t)=>s(...go(r(t),e),o,!0))):(a={"DenseMatrix, DenseMatrix":t.referToSelf((e=>(t,r)=>n(...go(t,r),e))),"Array, Array":t.referToSelf((e=>(t,i)=>n(...go(r(t),r(i)),e).valueOf())),"Array, DenseMatrix":t.referToSelf((e=>(t,i)=>n(...go(r(t),i),e))),"DenseMatrix, Array":t.referToSelf((e=>(t,i)=>n(...go(t,r(i)),e)))},e.SS&&(a["SparseMatrix, SparseMatrix"]=t.referToSelf((t=>(r,n)=>e.SS(...go(r,n),t,!1)))),e.DS&&(a["DenseMatrix, SparseMatrix"]=t.referToSelf((t=>(r,n)=>e.DS(...go(r,n),t,!1))),a["Array, SparseMatrix"]=t.referToSelf((t=>(n,i)=>e.DS(...go(r(n),i),t,!1)))),s&&(a["SparseMatrix, DenseMatrix"]=t.referToSelf((e=>(t,r)=>s(...go(r,t),e,!0))),a["SparseMatrix, Array"]=t.referToSelf((e=>(t,n)=>s(...go(r(n),t),e,!0)))));var u=e.scalar||"any";(e.Ds||e.Ss)&&(o?(a["DenseMatrix,"+u]=(e,t)=>i(e,t,o,!1),a[u+", DenseMatrix"]=(e,t)=>i(t,e,o,!0),a["Array,"+u]=(e,t)=>i(r(e),t,o,!1).valueOf(),a[u+", Array"]=(e,t)=>i(r(t),e,o,!0).valueOf()):(a["DenseMatrix,"+u]=t.referToSelf((e=>(t,r)=>i(t,r,e,!1))),a[u+", DenseMatrix"]=t.referToSelf((e=>(t,r)=>i(r,t,e,!0))),a["Array,"+u]=t.referToSelf((e=>(t,n)=>i(r(t),n,e,!1).valueOf())),a[u+", Array"]=t.referToSelf((e=>(t,n)=>i(r(n),t,e,!0).valueOf()))));var c=void 0!==e.sS?e.sS:e.Ss;return o?(e.Ss&&(a["SparseMatrix,"+u]=(t,r)=>e.Ss(t,r,o,!1)),c&&(a[u+", SparseMatrix"]=(e,t)=>c(t,e,o,!0))):(e.Ss&&(a["SparseMatrix,"+u]=t.referToSelf((t=>(r,n)=>e.Ss(r,n,t,!1)))),c&&(a[u+", SparseMatrix"]=t.referToSelf((e=>(t,r)=>c(r,t,e,!0))))),o&&o.signatures&&we(a,o.signatures),a}})),yo=Me("mod",["typed","config","round","matrix","equalScalar","zeros","DenseMatrix","concat"],(e=>{var{typed:t,config:r,round:n,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s,concat:u}=e,c=lo({typed:t,config:r,round:n,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s}),l=fo({typed:t,equalScalar:a}),f=po({typed:t}),p=mo({typed:t,equalScalar:a}),m=Ga({typed:t,equalScalar:a}),h=Wa({typed:t,DenseMatrix:s});return t("mod",{"number, number":function(e,t){return 0===t?e:e-t*c(e/t)},"BigNumber, BigNumber":function(e,t){return t.isZero()?e:e.sub(t.mul(c(e.div(t))))},"bigint, bigint":function(e,t){if(0n===t)return e;if(e<0){var r=e%t;return 0n===r?r:r+t}return e%t},"Fraction, Fraction":function(e,t){return t.equals(0)?e:e.sub(t.mul(c(e.div(t))))}},vo({typed:t,matrix:i,concat:u})({SS:p,DS:f,SD:l,Ss:m,sS:h}))})),xo=Me("matAlgo01xDSid",["typed"],(e=>{var{typed:t}=e;return function(e,r,n,i){var a=e._data,o=e._size,s=e._datatype||e.getDataType(),u=r._values,c=r._index,l=r._ptr,f=r._size,p=r._datatype||void 0===r._data?r._datatype:r.getDataType();if(o.length!==f.length)throw new g(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m,h,d=o[0],v=o[1],y="string"==typeof s&&"mixed"!==s&&s===p?s:void 0,x=y?t.find(n,[y,y]):n,b=[];for(m=0;m<d;m++)b[m]=[];var w=[],D=[];for(h=0;h<v;h++){for(var N=h+1,E=l[h],A=l[h+1],S=E;S<A;S++)w[m=c[S]]=i?x(u[S],a[m][h]):x(a[m][h],u[S]),D[m]=N;for(m=0;m<d;m++)D[m]===N?b[m][h]=w[m]:b[m][h]=a[m][h]}return e.createDenseMatrix({data:b,size:[d,v],datatype:s===e._datatype&&p===r._datatype?y:void 0})}})),bo=Me("matAlgo04xSidSid",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype||void 0===e._data?e._datatype:e.getDataType(),l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype||void 0===n._data?n._datatype:n.getDataType();if(u.length!==m.length)throw new g(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,v=u[0],y=u[1],x=r,b=0,w=i;"string"==typeof c&&c===h&&"mixed"!==c&&(d=c,x=t.find(r,[d,d]),b=t.convert(0,d),w=t.find(i,[d,d]));var D,N,E,A,S,C=a&&l?[]:void 0,M=[],F=[],T=a&&l?[]:void 0,_=a&&l?[]:void 0,B=[],O=[];for(N=0;N<y;N++){F[N]=M.length;var k=N+1;for(A=s[N],S=s[N+1],E=A;E<S;E++)D=o[E],M.push(D),B[D]=k,T&&(T[D]=a[E]);for(A=p[N],S=p[N+1],E=A;E<S;E++)if(B[D=f[E]]===k){if(T){var z=w(T[D],l[E]);x(z,b)?B[D]=null:T[D]=z}}else M.push(D),O[D]=k,_&&(_[D]=l[E]);if(T&&_)for(E=F[N];E<M.length;)B[D=M[E]]===k?(C[E]=T[D],E++):O[D]===k?(C[E]=_[D],E++):M.splice(E,1)}return F[y]=M.length,e.createSparseMatrix({values:C,index:M,ptr:F,size:[v,y],datatype:c===e._datatype&&h===n._datatype?d:void 0})}})),wo=Me("matAlgo10xSids",["typed","DenseMatrix"],(e=>{var{typed:t,DenseMatrix:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=i;"string"==typeof l&&(f=l,n=t.convert(n,f),h=t.find(i,[f,f]));for(var d=[],g=[],v=[],y=0;y<m;y++){for(var x=y+1,b=u[y],w=u[y+1],D=b;D<w;D++){var N=s[D];g[N]=o[D],v[N]=x}for(var E=0;E<p;E++)0===y&&(d[E]=[]),v[E]===x?d[E][y]=a?h(n,g[E]):h(g[E],n):d[E][y]=n}return new r({data:d,size:[p,m],datatype:f})}})),Do=["typed","config","round","matrix","equalScalar","zeros","BigNumber","DenseMatrix","concat"],No="number | BigNumber | Fraction | Matrix | Array",Eo="".concat(No,", ").concat(No,", ...").concat(No);function Ao(e){return!e.some((e=>Array.isArray(e)))}var So=Me("gcd",Do,(e=>{var{typed:t,matrix:r,config:n,round:i,equalScalar:a,zeros:o,BigNumber:s,DenseMatrix:u,concat:c}=e,l=yo({typed:t,config:n,round:i,matrix:r,equalScalar:a,zeros:o,DenseMatrix:u,concat:c}),f=xo({typed:t}),p=bo({typed:t,equalScalar:a}),m=wo({typed:t,DenseMatrix:u});return t("gcd",{"number, number":function(e,t){if(!qe(e)||!qe(t))throw new Error("Parameters in function gcd must be integer numbers");for(var r;0!==t;)r=l(e,t),e=t,t=r;return e<0?-e:e},"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var r=new s(0);!t.isZero();){var n=l(e,t);e=t,t=n}return e.lt(r)?e.neg():e},"Fraction, Fraction":(e,t)=>e.gcd(t)},vo({typed:t,matrix:r,concat:c})({SS:p,DS:f,Ss:m}),{[Eo]:t.referToSelf((e=>(t,r,n)=>{for(var i=e(t,r),a=0;a<n.length;a++)i=e(i,n[a]);return i})),Array:t.referToSelf((e=>t=>{if(1===t.length&&Array.isArray(t[0])&&Ao(t[0]))return e(...t[0]);if(Ao(t))return e(...t);throw new d("gcd() supports only 1d matrices!")})),Matrix:t.referToSelf((e=>t=>e(t.toArray())))})})),Co=Me("matAlgo06xS0S0",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._size,s=e._datatype||void 0===e._data?e._datatype:e.getDataType(),u=n._values,c=n._size,l=n._datatype||void 0===n._data?n._datatype:n.getDataType();if(o.length!==c.length)throw new g(o.length,c.length);if(o[0]!==c[0]||o[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+c+")");var f,p=o[0],m=o[1],h=r,d=0,v=i;"string"==typeof s&&s===l&&"mixed"!==s&&(f=s,h=t.find(r,[f,f]),d=t.convert(0,f),v=t.find(i,[f,f]));for(var y=a&&u?[]:void 0,x=[],b=[],w=y?[]:void 0,D=[],N=[],E=0;E<m;E++){b[E]=x.length;var A=E+1;if(xi(e,E,D,w,N,A,x,v),xi(n,E,D,w,N,A,x,v),w)for(var S=b[E];S<x.length;){var C=x[S];if(N[C]===A){var M=w[C];h(M,d)?x.splice(S,1):(y.push(M),S++)}else x.splice(S,1)}else for(var F=b[E];F<x.length;)N[x[F]]!==A?x.splice(F,1):F++}return b[m]=x.length,e.createSparseMatrix({values:y,index:x,ptr:b,size:[p,m],datatype:s===e._datatype&&l===n._datatype?f:void 0})}})),Mo=Me("lcm",["typed","matrix","equalScalar","concat"],(e=>{var{typed:t,matrix:r,equalScalar:n,concat:i}=e,a=fo({typed:t,equalScalar:n}),o=Co({typed:t,equalScalar:n}),s=Ga({typed:t,equalScalar:n}),u=vo({typed:t,matrix:r,concat:i}),c="number | BigNumber | Fraction | Matrix | Array",l={};return l["".concat(c,", ").concat(c,", ...").concat(c)]=t.referToSelf((e=>(t,r,n)=>{for(var i=e(t,r),a=0;a<n.length;a++)i=e(i,n[a]);return i})),t("lcm",{"number, number":Da,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(e.isZero())return e;if(t.isZero())return t;for(var r=e.times(t);!t.isZero();){var n=t;t=e.mod(n),e=n}return r.div(e).abs()},"Fraction, Fraction":(e,t)=>e.lcm(t)},u({SS:o,DS:a,Ss:s}),l)})),Fo="log10",To=Me(Fo,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(Fo,{number:function(e){return e>=0||r.predictable?Na(e):new n(e,0).log().div(Math.LN10)},Complex:function(e){return new n(e).log().div(Math.LN10)},BigNumber:function(e){return!e.isNegative()||r.predictable?e.log():new n(e.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),_o="log2",Bo=Me(_o,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(_o,{number:function(e){return e>=0||r.predictable?Ea(e):i(new n(e,0))},Complex:i,BigNumber:function(e){return!e.isNegative()||r.predictable?e.log(2):i(new n(e.toNumber(),0))},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))});function i(e){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new n(Math.log2?Math.log2(t):Math.log(t)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}})),Oo=Me("multiplyScalar",["typed"],(e=>{var{typed:t}=e;return t("multiplyScalar",{"number, number":da,"Complex, Complex":function(e,t){return e.mul(t)},"BigNumber, BigNumber":function(e,t){return e.times(t)},"bigint, bigint":function(e,t){return e*t},"Fraction, Fraction":function(e,t){return e.mul(t)},"number | Fraction | BigNumber | Complex, Unit":(e,t)=>t.multiply(e),"Unit, number | Fraction | BigNumber | Complex | Unit":(e,t)=>e.multiply(t)})})),ko="multiply",zo=Me(ko,["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],(e=>{var{typed:t,matrix:r,addScalar:n,multiplyScalar:i,equalScalar:a,dot:o}=e,s=Ga({typed:t,equalScalar:a}),u=Va({typed:t});function c(e,t){switch(e.length){case 1:switch(t.length){case 1:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;case 2:switch(t.length){case 1:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+t[0]+")");break;case 2:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}}var l=t("_multiplyMatrixVector",{"DenseMatrix, any":function(e,r){var a,o=e._data,s=e._size,u=e._datatype||e.getDataType(),c=r._data,l=r._datatype||r.getDataType(),f=s[0],p=s[1],m=n,h=i;u&&l&&u===l&&"string"==typeof u&&"mixed"!==u&&(a=u,m=t.find(n,[a,a]),h=t.find(i,[a,a]));for(var d=[],g=0;g<f;g++){for(var v=o[g],y=h(v[0],c[0]),x=1;x<p;x++)y=m(y,h(v[x],c[x]));d[g]=y}return e.createDenseMatrix({data:d,size:[f],datatype:u===e._datatype&&l===r._datatype?a:void 0})},"SparseMatrix, any":function(e,r){var o=e._values,s=e._index,u=e._ptr,c=e._datatype||void 0===e._data?e._datatype:e.getDataType();if(!o)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var l,f=r._data,p=r._datatype||r.getDataType(),m=e._size[0],h=r._size[0],d=[],g=[],v=[],y=n,x=i,b=a,w=0;c&&p&&c===p&&"string"==typeof c&&"mixed"!==c&&(l=c,y=t.find(n,[l,l]),x=t.find(i,[l,l]),b=t.find(a,[l,l]),w=t.convert(0,l));var D=[],N=[];v[0]=0;for(var E=0;E<h;E++){var A=f[E];if(!b(A,w))for(var S=u[E],C=u[E+1],M=S;M<C;M++){var F=s[M];N[F]?D[F]=y(D[F],x(A,o[M])):(N[F]=!0,g.push(F),D[F]=x(A,o[M]))}}for(var T=g.length,_=0;_<T;_++){var B=g[_];d[_]=D[B]}return v[1]=g.length,e.createSparseMatrix({values:d,index:g,ptr:v,size:[m,1],datatype:c===e._datatype&&p===r._datatype?l:void 0})}}),f=t("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":function(e,r){var a,o=e._data,s=e._size,u=e._datatype||e.getDataType(),c=r._data,l=r._size,f=r._datatype||r.getDataType(),p=s[0],m=s[1],h=l[1],d=n,g=i;u&&f&&u===f&&"string"==typeof u&&"mixed"!==u&&"mixed"!==u&&(a=u,d=t.find(n,[a,a]),g=t.find(i,[a,a]));for(var v=[],y=0;y<p;y++){var x=o[y];v[y]=[];for(var b=0;b<h;b++){for(var w=g(x[0],c[0][b]),D=1;D<m;D++)w=d(w,g(x[D],c[D][b]));v[y][b]=w}}return e.createDenseMatrix({data:v,size:[p,h],datatype:u===e._datatype&&f===r._datatype?a:void 0})},"DenseMatrix, SparseMatrix":function(e,r){var o=e._data,s=e._size,u=e._datatype||e.getDataType(),c=r._values,l=r._index,f=r._ptr,p=r._size,m=r._datatype||void 0===r._data?r._datatype:r.getDataType();if(!c)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var h,d=s[0],g=p[1],v=n,y=i,x=a,b=0;u&&m&&u===m&&"string"==typeof u&&"mixed"!==u&&(h=u,v=t.find(n,[h,h]),y=t.find(i,[h,h]),x=t.find(a,[h,h]),b=t.convert(0,h));for(var w=[],D=[],N=[],E=r.createSparseMatrix({values:w,index:D,ptr:N,size:[d,g],datatype:u===e._datatype&&m===r._datatype?h:void 0}),A=0;A<g;A++){N[A]=D.length;var S=f[A],C=f[A+1];if(C>S)for(var M=0,F=0;F<d;F++){for(var T=F+1,_=void 0,B=S;B<C;B++){var O=l[B];M!==T?(_=y(o[F][O],c[B]),M=T):_=v(_,y(o[F][O],c[B]))}M!==T||x(_,b)||(D.push(F),w.push(_))}}return N[g]=D.length,E},"SparseMatrix, DenseMatrix":function(e,r){var o=e._values,s=e._index,u=e._ptr,c=e._datatype||void 0===e._data?e._datatype:e.getDataType();if(!o)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var l,f=r._data,p=r._datatype||r.getDataType(),m=e._size[0],h=r._size[0],d=r._size[1],g=n,v=i,y=a,x=0;c&&p&&c===p&&"string"==typeof c&&"mixed"!==c&&(l=c,g=t.find(n,[l,l]),v=t.find(i,[l,l]),y=t.find(a,[l,l]),x=t.convert(0,l));for(var b=[],w=[],D=[],N=e.createSparseMatrix({values:b,index:w,ptr:D,size:[m,d],datatype:c===e._datatype&&p===r._datatype?l:void 0}),E=[],A=[],S=0;S<d;S++){D[S]=w.length;for(var C=S+1,M=0;M<h;M++){var F=f[M][S];if(!y(F,x))for(var T=u[M],_=u[M+1],B=T;B<_;B++){var O=s[B];A[O]!==C?(A[O]=C,w.push(O),E[O]=v(F,o[B])):E[O]=g(E[O],v(F,o[B]))}}for(var k=D[S],z=w.length,I=k;I<z;I++){var q=w[I];b[I]=E[q]}}return D[d]=w.length,N},"SparseMatrix, SparseMatrix":function(e,r){var a,o=e._values,s=e._index,u=e._ptr,c=e._datatype||void 0===e._data?e._datatype:e.getDataType(),l=r._values,f=r._index,p=r._ptr,m=r._datatype||void 0===r._data?r._datatype:r.getDataType(),h=e._size[0],d=r._size[1],g=o&&l,v=n,y=i;c&&m&&c===m&&"string"==typeof c&&"mixed"!==c&&(a=c,v=t.find(n,[a,a]),y=t.find(i,[a,a]));for(var x,b,w,D,N,E,A,S,C=g?[]:void 0,M=[],F=[],T=e.createSparseMatrix({values:C,index:M,ptr:F,size:[h,d],datatype:c===e._datatype&&m===r._datatype?a:void 0}),_=g?[]:void 0,B=[],O=0;O<d;O++){F[O]=M.length;var k=O+1;for(N=p[O],E=p[O+1],D=N;D<E;D++)if(S=f[D],g)for(b=u[S],w=u[S+1],x=b;x<w;x++)B[A=s[x]]!==k?(B[A]=k,M.push(A),_[A]=y(l[D],o[x])):_[A]=v(_[A],y(l[D],o[x]));else for(b=u[S],w=u[S+1],x=b;x<w;x++)B[A=s[x]]!==k&&(B[A]=k,M.push(A));if(g)for(var z=F[O],I=M.length,q=z;q<I;q++){var R=M[q];C[q]=_[R]}}return F[d]=M.length,T}});return t(ko,i,{"Array, Array":t.referTo("Matrix, Matrix",(e=>(t,n)=>{c(Bn(t),Bn(n));var i=e(r(t),r(n));return q(i)?i.valueOf():i})),"Matrix, Matrix":function(e,r){var a=e.size(),s=r.size();return c(a,s),1===a.length?1===s.length?function(e,t,r){if(0===r)throw new Error("Cannot multiply two empty vectors");return o(e,t)}(e,r,a[0]):function(e,r){if("dense"!==r.storage())throw new Error("Support for SparseMatrix not implemented");return function(e,r){var a,o=e._data,s=e._size,u=e._datatype||e.getDataType(),c=r._data,l=r._size,f=r._datatype||r.getDataType(),p=s[0],m=l[1],h=n,d=i;u&&f&&u===f&&"string"==typeof u&&"mixed"!==u&&(a=u,h=t.find(n,[a,a]),d=t.find(i,[a,a]));for(var g=[],v=0;v<m;v++){for(var y=d(o[0],c[0][v]),x=1;x<p;x++)y=h(y,d(o[x],c[x][v]));g[v]=y}return e.createDenseMatrix({data:g,size:[m],datatype:u===e._datatype&&f===r._datatype?a:void 0})}(e,r)}(e,r):1===s.length?l(e,r):f(e,r)},"Matrix, Array":t.referTo("Matrix,Matrix",(e=>(t,n)=>e(t,r(n)))),"Array, Matrix":t.referToSelf((e=>(t,n)=>e(r(t,n.storage()),n))),"SparseMatrix, any":function(e,t){return s(e,t,i,!1)},"DenseMatrix, any":function(e,t){return u(e,t,i,!1)},"any, SparseMatrix":function(e,t){return s(t,e,i,!0)},"any, DenseMatrix":function(e,t){return u(t,e,i,!0)},"Array, any":function(e,t){return u(r(e),t,i,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,i,!0).valueOf()},"any, any":i,"any, any, ...any":t.referToSelf((e=>(t,r,n)=>{for(var i=e(t,r),a=0;a<n.length;a++)i=e(i,n[a]);return i}))})})),Io="nthRoot",qo=Me(Io,["typed","matrix","equalScalar","BigNumber","concat"],(e=>{var{typed:t,matrix:r,equalScalar:n,BigNumber:i,concat:a}=e,o=xo({typed:t}),s=fo({typed:t,equalScalar:n}),u=Co({typed:t,equalScalar:n}),c=Ga({typed:t,equalScalar:n}),l=vo({typed:t,matrix:r,concat:a});function f(){throw new Error("Complex number not supported in function nthRoot. Use nthRoots instead.")}return t(Io,{number:Aa,"number, number":Aa,BigNumber:e=>p(e,new i(2)),"BigNumber, BigNumber":p,Complex:f,"Complex, number":f,Array:t.referTo("DenseMatrix,number",(e=>t=>e(r(t),2).valueOf())),DenseMatrix:t.referTo("DenseMatrix,number",(e=>t=>e(t,2))),SparseMatrix:t.referTo("SparseMatrix,number",(e=>t=>e(t,2))),"SparseMatrix, SparseMatrix":t.referToSelf((e=>(t,r)=>{if(1===r.density())return u(t,r,e);throw new Error("Root must be non-zero")})),"DenseMatrix, SparseMatrix":t.referToSelf((e=>(t,r)=>{if(1===r.density())return o(t,r,e,!1);throw new Error("Root must be non-zero")})),"Array, SparseMatrix":t.referTo("DenseMatrix,SparseMatrix",(e=>(t,n)=>e(r(t),n))),"number | BigNumber, SparseMatrix":t.referToSelf((e=>(t,r)=>{if(1===r.density())return c(r,t,e,!0);throw new Error("Root must be non-zero")}))},l({scalar:"number | BigNumber",SD:s,Ss:c,sS:!1}));function p(e,t){var r=i.precision,n=i.clone({precision:r+2}),a=new i(0),o=new n(1),s=t.isNegative();if(s&&(t=t.neg()),t.isZero())throw new Error("Root must be non-zero");if(e.isNegative()&&!t.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(e.isZero())return s?new n(1/0):0;if(!e.isFinite())return s?a:e;var u=e.abs().pow(o.div(t));return u=e.isNeg()?u.neg():u,new i((s?o.div(u):u).toPrecision(r))}})),Ro="sign",Po=Me(Ro,["typed","BigNumber","Fraction","complex"],(e=>{var{typed:t,BigNumber:r,complex:n,Fraction:i}=e;return t(Ro,{number:Sa,Complex:function(e){return 0===e.im?n(Sa(e.re)):e.sign()},BigNumber:function(e){return new r(e.cmp(0))},bigint:function(e){return e>0n?1n:e<0n?-1n:0n},Fraction:function(e){return new i(e.s,1)},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e,!0))),Unit:t.referToSelf((e=>r=>{if(!r._isDerived()&&0!==r.units[0].unit.offset)throw new TypeError("sign is ambiguous for units with offset");return t.find(e,r.valueType())(r.value)}))})})),jo=Me("sqrt",["config","typed","Complex"],(e=>{var{config:t,typed:r,Complex:n}=e;return r("sqrt",{number:i,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.sqrt():i(e.toNumber())},Unit:function(e){return e.pow(.5)}});function i(e){return isNaN(e)?NaN:e>=0||t.predictable?Math.sqrt(e):new n(e,0).sqrt()}})),Uo="square",Lo=Me(Uo,["typed"],(e=>{var{typed:t}=e;return t(Uo,{number:Ca,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},bigint:function(e){return e*e},Fraction:function(e){return e.mul(e)},Unit:function(e){return e.pow(2)}})})),Ho="subtract",$o=Me(Ho,["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],(e=>{var{typed:t,matrix:r,equalScalar:n,subtractScalar:i,unaryMinus:a,DenseMatrix:o,concat:s}=e,u=xo({typed:t}),c=po({typed:t}),l=mo({typed:t,equalScalar:n}),f=wo({typed:t,DenseMatrix:o}),p=Wa({typed:t,DenseMatrix:o}),m=vo({typed:t,matrix:r,concat:s});return t(Ho,{"any, any":i},m({elop:i,SS:l,DS:u,SD:c,Ss:p,sS:f}))})),Go="xgcd",Wo=Me(Go,["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t(Go,{"number, number":function(e,t){var i=Ma(e,t);return"Array"===r.matrix?i:n(i)},"BigNumber, BigNumber":function(e,t){var a,o,s,u,c=new i(0),l=new i(1),f=c,p=l,m=l,h=c;if(!e.isInt()||!t.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!t.isZero();)o=e.div(t).floor(),s=e.mod(t),a=f,f=p.minus(o.times(f)),p=a,a=m,m=h.minus(o.times(m)),h=a,e=t,t=s;return u=e.lt(c)?[e.neg(),p.neg(),h.neg()]:[e,e.isZero()?0:p,h],"Array"===r.matrix?u:n(u)}})})),Vo="invmod",Zo=Me(Vo,["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],(e=>{var{typed:t,config:r,BigNumber:n,xgcd:i,equal:a,smaller:o,mod:s,add:u,isInteger:c}=e;return t(Vo,{"number, number":l,"BigNumber, BigNumber":l});function l(e,t){if(!c(e)||!c(t))throw new Error("Parameters in function invmod must be integer numbers");if(e=s(e,t),a(t,0))throw new Error("Divisor must be non zero");var r=i(e,t);r=r.valueOf();var[l,f]=r;return a(l,n(1))?(f=s(f,t),o(f,n(0))&&(f=u(f,t)),f):NaN}})),Yo=Me("matAlgo09xS0Sf",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype||void 0===e._data?e._datatype:e.getDataType(),l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype||void 0===n._data?n._datatype:n.getDataType();if(u.length!==m.length)throw new g(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,v=u[0],y=u[1],x=r,b=0,w=i;"string"==typeof c&&c===h&&"mixed"!==c&&(d=c,x=t.find(r,[d,d]),b=t.convert(0,d),w=t.find(i,[d,d]));var D,N,E,A,S,C=a&&l?[]:void 0,M=[],F=[],T=C?[]:void 0,_=[];for(N=0;N<y;N++){F[N]=M.length;var B=N+1;if(T)for(A=p[N],S=p[N+1],E=A;E<S;E++)_[D=f[E]]=B,T[D]=l[E];for(A=s[N],S=s[N+1],E=A;E<S;E++)if(D=o[E],T){var O=_[D]===B?T[D]:b,k=w(a[E],O);x(k,b)||(M.push(D),C.push(k))}else M.push(D)}return F[y]=M.length,e.createSparseMatrix({values:C,index:M,ptr:F,size:[v,y],datatype:c===e._datatype&&h===n._datatype?d:void 0})}})),Jo="dotMultiply",Xo=Me(Jo,["typed","matrix","equalScalar","multiplyScalar","concat"],(e=>{var{typed:t,matrix:r,equalScalar:n,multiplyScalar:i,concat:a}=e,o=fo({typed:t,equalScalar:n}),s=Yo({typed:t,equalScalar:n}),u=Ga({typed:t,equalScalar:n}),c=vo({typed:t,matrix:r,concat:a});return t(Jo,c({elop:i,SS:s,DS:o,Ss:u}))}));function Qo(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitAnd");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero()||t.eq(-1)||e.eq(t))return e;if(t.isZero()||e.eq(-1))return t;if(!e.isFinite()||!t.isFinite()){if(!e.isFinite()&&!t.isFinite())return e.isNegative()===t.isNegative()?e:new r(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new r(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new r(0):e}return ts(e,t,(function(e,t){return e&t}))}function Ko(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var t=e.constructor,r=t.precision;t.config({precision:1e9});var n=e.plus(new t(1));return n.s=-n.s||null,t.config({precision:r}),n}function es(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitOr");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);var n=new r(-1);return e.isZero()||t.eq(n)||e.eq(t)?t:t.isZero()||e.eq(n)?e:e.isFinite()&&t.isFinite()?ts(e,t,(function(e,t){return e|t})):!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?n:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e}function ts(e,t,r){var n,i,a,o,s,u=e.constructor,c=+(e.s<0),l=+(t.s<0);if(c){n=rs(Ko(e));for(var f=0;f<n.length;++f)n[f]^=1}else n=rs(e);if(l){i=rs(Ko(t));for(var p=0;p<i.length;++p)i[p]^=1}else i=rs(t);n.length<=i.length?(a=n,o=i,s=c):(a=i,o=n,s=l);var m=a.length,h=o.length,d=1^r(c,l),g=new u(1^d),v=new u(1),y=new u(2),x=u.precision;for(u.config({precision:1e9});m>0;)r(a[--m],o[--h])===d&&(g=g.plus(v)),v=v.times(y);for(;h>0;)r(s,o[--h])===d&&(g=g.plus(v)),v=v.times(y);return u.config({precision:x}),0===d&&(g.s=-g.s),g}function rs(e){for(var t=e.d,r=t[0]+"",n=1;n<t.length;++n){for(var i=t[n]+"",a=7-i.length;a--;)i="0"+i;r+=i}for(var o=r.length;"0"===r.charAt(o);)o--;var s=e.e,u=r.slice(0,o+1||1),c=u.length;if(s>0)if(++s>c)for(s-=c;s--;)u+="0";else s<c&&(u=u.slice(0,s)+"."+u.slice(s));for(var l=[0],f=0;f<u.length;){for(var p=l.length;p--;)l[p]*=10;l[0]+=parseInt(u.charAt(f++));for(var m=0;m<l.length;++m)l[m]>1&&(null!==l[m+1]&&void 0!==l[m+1]||(l[m+1]=0),l[m+1]+=l[m]>>1,l[m]&=1)}return l.reverse()}function ns(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new r(0);var n=new r(-1);return e.eq(n)?Ko(t):t.eq(n)?Ko(e):e.isFinite()&&t.isFinite()?ts(e,t,(function(e,t){return e^t})):e.isFinite()||t.isFinite()?new r(e.isNegative()===t.isNegative()?1/0:-1/0):n}function is(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:e.isFinite()||t.isFinite()?t.lt(55)?e.times(Math.pow(2,t.toNumber())+""):e.times(new r(2).pow(t)):new r(NaN)}function as(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(Math.pow(2,t.toNumber())+"").floor():e.div(new r(2).pow(t)).floor():e.isNegative()?new r(-1):e.isFinite()?new r(0):new r(NaN)}var os="number, number";function ss(e,t){if(!qe(e)||!qe(t))throw new Error("Integers expected in function bitAnd");return e&t}function us(e){if(!qe(e))throw new Error("Integer expected in function bitNot");return~e}function cs(e,t){if(!qe(e)||!qe(t))throw new Error("Integers expected in function bitOr");return e|t}function ls(e,t){if(!qe(e)||!qe(t))throw new Error("Integers expected in function bitXor");return e^t}function fs(e,t){if(!qe(e)||!qe(t))throw new Error("Integers expected in function leftShift");return e<<t}function ps(e,t){if(!qe(e)||!qe(t))throw new Error("Integers expected in function rightArithShift");return e>>t}function ms(e,t){if(!qe(e)||!qe(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}ss.signature=os,us.signature="number",cs.signature=os,ls.signature=os,fs.signature=os,ps.signature=os,ms.signature=os;var hs="bitAnd",ds=Me(hs,["typed","matrix","equalScalar","concat"],(e=>{var{typed:t,matrix:r,equalScalar:n,concat:i}=e,a=fo({typed:t,equalScalar:n}),o=Co({typed:t,equalScalar:n}),s=Ga({typed:t,equalScalar:n}),u=vo({typed:t,matrix:r,concat:i});return t(hs,{"number, number":ss,"BigNumber, BigNumber":Qo,"bigint, bigint":(e,t)=>e&t},u({SS:o,DS:a,Ss:s}))})),gs="bitNot",vs=Me(gs,["typed"],(e=>{var{typed:t}=e;return t(gs,{number:us,BigNumber:Ko,bigint:e=>~e,"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),ys="bitOr",xs=Me(ys,["typed","matrix","equalScalar","DenseMatrix","concat"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i,concat:a}=e,o=xo({typed:t}),s=bo({typed:t,equalScalar:n}),u=wo({typed:t,DenseMatrix:i}),c=vo({typed:t,matrix:r,concat:a});return t(ys,{"number, number":cs,"BigNumber, BigNumber":es,"bigint, bigint":(e,t)=>e|t},c({SS:s,DS:o,Ss:u}))})),bs=Me("matAlgo07xSSf",["typed","DenseMatrix"],(e=>{var{typed:t,DenseMatrix:r}=e;return function(e,i,a){var o=e._size,s=e._datatype||void 0===e._data?e._datatype:e.getDataType(),u=i._size,c=i._datatype||void 0===i._data?i._datatype:i.getDataType();if(o.length!==u.length)throw new g(o.length,u.length);if(o[0]!==u[0]||o[1]!==u[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+u+")");var l,f,p,m=o[0],h=o[1],d=0,v=a;"string"==typeof s&&s===c&&"mixed"!==s&&(l=s,d=t.convert(0,l),v=t.find(a,[l,l]));var y=[];for(f=0;f<m;f++)y[f]=[];var x=[],b=[],w=[],D=[];for(p=0;p<h;p++){var N=p+1;for(n(e,p,w,x,N),n(i,p,D,b,N),f=0;f<m;f++){var E=w[f]===N?x[f]:d,A=D[f]===N?b[f]:d;y[f][p]=v(E,A)}}return new r({data:y,size:[m,h],datatype:s===e._datatype&&c===i._datatype?l:void 0})};function n(e,t,r,n,i){for(var a=e._values,o=e._index,s=e._ptr,u=s[t],c=s[t+1];u<c;u++){var l=o[u];r[l]=i,n[l]=a[u]}}})),ws="bitXor",Ds=Me(ws,["typed","matrix","DenseMatrix","concat"],(e=>{var{typed:t,matrix:r,DenseMatrix:n,concat:i}=e,a=po({typed:t}),o=bs({typed:t,DenseMatrix:n}),s=Wa({typed:t,DenseMatrix:n}),u=vo({typed:t,matrix:r,concat:i});return t(ws,{"number, number":ls,"BigNumber, BigNumber":ns,"bigint, bigint":(e,t)=>e^t},u({SS:o,DS:a,Ss:s}))})),Ns=Me("arg",["typed"],(e=>{var{typed:t}=e;return t("arg",{number:function(e){return Math.atan2(0,e)},BigNumber:function(e){return e.constructor.atan2(0,e)},Complex:function(e){return e.arg()},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),Es="conj",As=Me(Es,["typed"],(e=>{var{typed:t}=e;return t(Es,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),Ss=Me("im",["typed"],(e=>{var{typed:t}=e;return t("im",{number:()=>0,"BigNumber | Fraction":e=>e.mul(0),Complex:e=>e.im,"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),Cs=Me("re",["typed"],(e=>{var{typed:t}=e;return t("re",{"number | BigNumber | Fraction":e=>e,Complex:e=>e.re,"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),Ms="number, number";function Fs(e){return!e}function Ts(e,t){return!(!e&&!t)}function _s(e,t){return!!e!=!!t}function Bs(e,t){return!(!e||!t)}Fs.signature="number",Ts.signature=Ms,_s.signature=Ms,Bs.signature=Ms;var Os=Me("not",["typed"],(e=>{var{typed:t}=e;return t("not",{"null | undefined":()=>!0,number:Fs,Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},bigint:e=>!e,Unit:t.referToSelf((e=>r=>t.find(e,r.valueType())(r.value))),"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),ks=Me("or",["typed","matrix","equalScalar","DenseMatrix","concat"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i,concat:a}=e,o=po({typed:t}),s=mo({typed:t,equalScalar:n}),u=Wa({typed:t,DenseMatrix:i}),c=vo({typed:t,matrix:r,concat:a});return t("or",{"number, number":Ts,"Complex, Complex":function(e,t){return 0!==e.re||0!==e.im||0!==t.re||0!==t.im},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!e.isNaN()||!t.isZero()&&!t.isNaN()},"bigint, bigint":Ts,"Unit, Unit":t.referToSelf((e=>(t,r)=>e(t.value||0,r.value||0)))},c({SS:s,DS:o,Ss:u}))})),zs=Me("xor",["typed","matrix","DenseMatrix","concat"],(e=>{var{typed:t,matrix:r,DenseMatrix:n,concat:i}=e,a=po({typed:t}),o=bs({typed:t,DenseMatrix:n}),s=Wa({typed:t,DenseMatrix:n}),u=vo({typed:t,matrix:r,concat:i});return t("xor",{"number, number":_s,"Complex, Complex":function(e,t){return(0!==e.re||0!==e.im)!=(0!==t.re||0!==t.im)},"bigint, bigint":_s,"BigNumber, BigNumber":function(e,t){return(!e.isZero()&&!e.isNaN())!=(!t.isZero()&&!t.isNaN())},"Unit, Unit":t.referToSelf((e=>(t,r)=>e(t.value||0,r.value||0)))},u({SS:o,DS:a,Ss:s}))})),Is="concat",qs=Me(Is,["typed","matrix","isInteger"],(e=>{var{typed:t,matrix:r,isInteger:n}=e;return t(Is,{"...Array | Matrix | number | BigNumber":function(e){var t,i,a=e.length,o=-1,s=!1,u=[];for(t=0;t<a;t++){var c=e[t];if(q(c)&&(s=!0),F(c)||T(c)){if(t!==a-1)throw new Error("Dimension must be specified as last argument");if(i=o,o=c.valueOf(),!n(o))throw new TypeError("Integer number expected for dimension");if(o<0||t>0&&o>i)throw new v(o,i+1)}else{var l=be(c).valueOf(),f=Bn(l);if(u[t]=l,i=o,o=f.length-1,t>0&&o!==i)throw new g(i+1,o+1)}}if(0===u.length)throw new SyntaxError("At least one matrix expected");for(var p=u.shift();u.length;)p=ri(p,u.shift(),o);return s?r(p):p},"...string":function(e){return e.join("")}})})),Rs="column",Ps=Me(Rs,["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e;return t(Rs,{"Matrix, number":a,"Array, number":function(e,t){return a(n(be(e)),t).valueOf()}});function a(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");In(t,e.size()[1]);var a=i(0,e.size()[0]),o=new r(a,t),s=e.subset(o);return q(s)?s:n([[s]])}})),js="count",Us=Me(js,["typed","size","prod"],(e=>{var{typed:t,size:r,prod:n}=e;return t(js,{string:function(e){return e.length},"Matrix | Array":function(e){return n(r(e))}})})),Ls="cross",Hs=Me(Ls,["typed","matrix","subtract","multiply"],(e=>{var{typed:t,matrix:r,subtract:n,multiply:i}=e;return t(Ls,{"Matrix, Matrix":function(e,t){return r(a(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(a(e.toArray(),t))},"Array, Matrix":function(e,t){return r(a(e,t.toArray()))},"Array, Array":a});function a(e,t){var r=Math.max(Bn(e).length,Bn(t).length);e=Hn(e),t=Hn(t);var a=Bn(e),o=Bn(t);if(1!==a.length||1!==o.length||3!==a[0]||3!==o[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+a.join(", ")+"], B = ["+o.join(", ")+"])");var s=[n(i(e[1],t[2]),i(e[2],t[1])),n(i(e[2],t[0]),i(e[0],t[2])),n(i(e[0],t[1]),i(e[1],t[0]))];return r>1?[s]:s}})),$s="diag",Gs=Me($s,["typed","matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:r,DenseMatrix:n,SparseMatrix:i}=e;return t($s,{Array:function(e){return a(e,0,Bn(e),null)},"Array, number":function(e,t){return a(e,t,Bn(e),null)},"Array, BigNumber":function(e,t){return a(e,t.toNumber(),Bn(e),null)},"Array, string":function(e,t){return a(e,0,Bn(e),t)},"Array, number, string":function(e,t,r){return a(e,t,Bn(e),r)},"Array, BigNumber, string":function(e,t,r){return a(e,t.toNumber(),Bn(e),r)},Matrix:function(e){return a(e,0,e.size(),e.storage())},"Matrix, number":function(e,t){return a(e,t,e.size(),e.storage())},"Matrix, BigNumber":function(e,t){return a(e,t.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,t){return a(e,0,e.size(),t)},"Matrix, number, string":function(e,t,r){return a(e,t,e.size(),r)},"Matrix, BigNumber, string":function(e,t,r){return a(e,t.toNumber(),e.size(),r)}});function a(e,t,a,o){if(!qe(t))throw new TypeError("Second parameter in function diag must be an integer");var s=t>0?t:0,u=t<0?-t:0;switch(a.length){case 1:return function(e,t,r,a,o,s){var u=[a+o,a+s];if(r&&"sparse"!==r&&"dense"!==r)throw new TypeError("Unknown matrix type ".concat(r,'"'));var c="sparse"===r?i.diagonal(u,e,t):n.diagonal(u,e,t);return null!==r?c:c.valueOf()}(e,t,o,a[0],u,s);case 2:return function(e,t,n,i,a,o){if(q(e)){var s=e.diagonal(t);return null!==n?n!==s.storage()?r(s,n):s:s.valueOf()}for(var u=Math.min(i[0]-a,i[1]-o),c=[],l=0;l<u;l++)c[l]=e[l+a][l+o];return null!==n?r(c):c}(e,t,o,a,u,s)}throw new RangeError("Matrix for function diag must be 2 dimensional")}})),Ws=Me("filter",["typed"],(e=>{var{typed:t}=e;return t("filter",{"Array, function":Vs,"Matrix, function":function(e,t){return e.create(Vs(e.valueOf(),t),e.datatype())},"Array, RegExp":Jn,"Matrix, RegExp":function(e,t){return e.create(Jn(e.valueOf(),t),e.datatype())}})}));function Vs(e,t){var r=ui(t,e,"filter");return function(e,t){if(1!==Bn(e).length)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,(function(e,t,n){return r(e,[t],n)}))}(e)}var Zs="flatten",Ys=Me(Zs,["typed"],(e=>{var{typed:t}=e;return t(Zs,{Array:function(e){return Vn(e)},Matrix:function(e){return e.create(Vn(e.toArray()),e.datatype())}})})),Js="forEach",Xs=Me(Js,["typed"],(e=>{var{typed:t}=e;return t(Js,{"Array, function":Qs,"Matrix, function":function(e,t){e.forEach(t)}})}));function Qs(e,t){si(e,[],e,ui(t,e,Js))}var Ks="getMatrixDataType",eu=Me(Ks,["typed"],(e=>{var{typed:t}=e;return t(Ks,{Array:function(e){return ei(e,xe)},Matrix:function(e){return e.getDataType()}})})),tu="identity",ru=Me(tu,["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,config:r,matrix:n,BigNumber:i,DenseMatrix:a,SparseMatrix:o}=e;return t(tu,{"":function(){return"Matrix"===r.matrix?n([]):[]},string:function(e){return n(e)},"number | BigNumber":function(e){return u(e,e,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, string":function(e,t){return u(e,e,t)},"number | BigNumber, number | BigNumber":function(e,t){return u(e,t,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(e,t,r){return u(e,t,r)},Array:function(e){return s(e)},"Array, string":function(e,t){return s(e,t)},Matrix:function(e){return s(e.valueOf(),e.storage())},"Matrix, string":function(e,t){return s(e.valueOf(),t)}});function s(e,t){switch(e.length){case 0:return t?n(t):[];case 1:return u(e[0],e[0],t);case 2:return u(e[0],e[1],t);default:throw new Error("Vector containing two values expected")}}function u(e,t,r){var n=T(e)||T(t)?i:null;if(T(e)&&(e=e.toNumber()),T(t)&&(t=t.toNumber()),!qe(e)||e<1)throw new Error("Parameters in function identity must be positive integers");if(!qe(t)||t<1)throw new Error("Parameters in function identity must be positive integers");var s=n?new i(1):1,u=n?new n(0):0,c=[e,t];if(r){if("sparse"===r)return o.diagonal(c,s,0,u);if("dense"===r)return a.diagonal(c,s,0,u);throw new TypeError('Unknown matrix type "'.concat(r,'"'))}for(var l=Rn([],c,u),f=e<t?e:t,p=0;p<f;p++)l[p][p]=s;return l}})),nu="kron",iu=Me(nu,["typed","matrix","multiplyScalar"],(e=>{var{typed:t,matrix:r,multiplyScalar:n}=e;return t(nu,{"Matrix, Matrix":function(e,t){return r(i(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(i(e.toArray(),t))},"Array, Matrix":function(e,t){return r(i(e,t.toArray()))},"Array, Array":i});function i(e,t){if(1===Bn(e).length&&(e=[e]),1===Bn(t).length&&(t=[t]),Bn(e).length>2||Bn(t).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(e.length)+", y = "+JSON.stringify(t.length)+")");var r=[],i=[];return e.map((function(e){return t.map((function(t){return i=[],r.push(i),e.map((function(e){return t.map((function(t){return i.push(n(e,t))}))}))}))}))&&r}})),au="map",ou=Me(au,["typed"],(e=>{var{typed:t}=e;return t(au,{"Array, function":r,"Matrix, function":function(e,t){return e.map(t)},"Array|Matrix, Array|Matrix, ...Array|Matrix|function":(e,n,i)=>function(e,n){if("function"!=typeof n)throw new Error("Last argument must be a callback function");var i,a=e[0].isMatrix,o=ni(...e.map((e=>e.isMatrix?e.size():Bn(e)))),s=a?(e,t)=>e.get(t):oi,u=a?e.map((t=>t.isMatrix?t.create(ai(t.toArray(),o),t.datatype()):e[0].create(ai(t.valueOf(),o)))):e.map((e=>e.isMatrix?ai(e.toArray(),o):ai(e,o)));if(t.isTypedFunction(n)){var c=o.map((()=>0)),l=u.map((e=>s(e,c))),f=function(e,r,n,i){return null!==t.resolve(e,[...r,n,...i])?2:null!==t.resolve(e,[...r,n])?1:(t.resolve(e,r),0)}(n,l,c,u);i=d(f)}else{var p=e.length,m=function(e,t){return e.length>t+1?2:e.length===t+1?1:0}(n,p);i=d(m)}var h=(e,t)=>i([e,...u.slice(1).map((e=>s(e,t)))],t);return a?u[0].map(h):r(u[0],h);function d(e){switch(e){case 0:return e=>n(...e);case 1:return(e,t)=>n(...e,t);case 2:return(e,t)=>n(...e,t,...u)}}}([e,n,...i.slice(0,i.length-1)],i[i.length-1])});function r(e,t){return si(e,[],e,ui(t,e,au))}})),su="diff",uu=Me(su,["typed","matrix","subtract","number"],(e=>{var{typed:t,matrix:r,subtract:n,number:i}=e;return t(su,{"Array | Matrix":function(e){return q(e)?r(o(e.toArray())):o(e)},"Array | Matrix, number":function(e,t){if(!qe(t))throw new RangeError("Dimension must be a whole number");return q(e)?r(a(e.toArray(),t)):a(e,t)},"Array, BigNumber":t.referTo("Array,number",(e=>(t,r)=>e(t,i(r)))),"Matrix, BigNumber":t.referTo("Matrix,number",(e=>(t,r)=>e(t,i(r))))});function a(e,t){if(q(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError("Array/Matrix does not have that many dimensions");if(t>0){var r=[];return e.forEach((e=>{r.push(a(e,t-1))})),r}if(0===t)return o(e);throw RangeError("Cannot have negative dimension")}function o(e){for(var t=[],r=e.length,n=1;n<r;n++)t.push(s(e[n-1],e[n]));return t}function s(e,t){q(e)&&(e=e.toArray()),q(t)&&(t=t.toArray());var r=Array.isArray(e),i=Array.isArray(t);if(r&&i)return function(e,t){if(e.length!==t.length)throw RangeError("Not all sub-arrays have the same length");for(var r=[],n=e.length,i=0;i<n;i++)r.push(s(e[i],t[i]));return r}(e,t);if(!r&&!i)return n(t,e);throw TypeError("Cannot calculate difference between 1 array and 1 non-array")}})),cu=Me("ones",["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t("ones",{"":function(){return"Array"===r.matrix?a([]):a([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return a(e,t)}return"Array"===r.matrix?a(e):a(e,"default")},Array:a,Matrix:function(e){var t=e.storage();return a(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return a(e.valueOf(),t)}});function a(e,t){var r=function(e){var t=!1;return e.forEach((function(e,r,n){T(e)&&(t=!0,n[r]=e.toNumber())})),t}(e),a=r?new i(1):1;if(function(e){e.forEach((function(e){if("number"!=typeof e||!qe(e)||e<0)throw new Error("Parameters in function ones must be positive integers")}))}(e),t){var o=n(t);return e.length>0?o.resize(e,a):o}var s=[];return e.length>0?Rn(s,e,a):s}}));function lu(){throw new Error('No "bignumber" implementation available')}function fu(){throw new Error('No "fraction" implementation available')}function pu(){throw new Error('No "matrix" implementation available')}var mu="range",hu=Me(mu,["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq","add","isPositive"],(e=>{var{typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u,add:c,isPositive:l}=e;return t(mu,{string:p,"string, boolean":p,"number, number":function(e,t){return f(m(e,t,1,!1))},"number, number, number":function(e,t,r){return f(m(e,t,r,!1))},"number, number, boolean":function(e,t,r){return f(m(e,t,1,r))},"number, number, number, boolean":function(e,t,r,n){return f(m(e,t,r,n))},"BigNumber, BigNumber":function(e,t){return f(m(e,t,new(0,e.constructor)(1),!1))},"BigNumber, BigNumber, BigNumber":function(e,t,r){return f(m(e,t,r,!1))},"BigNumber, BigNumber, boolean":function(e,t,r){return f(m(e,t,new(0,e.constructor)(1),r))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,r,n){return f(m(e,t,r,n))},"Unit, Unit, Unit":function(e,t,r){return f(m(e,t,r,!1))},"Unit, Unit, Unit, boolean":function(e,t,r,n){return f(m(e,t,r,n))}});function f(e){return"Matrix"===r.matrix?n?n(e):pu():e}function p(e,t){var n=function(e){var t=e.split(":").map((function(e){return Number(e)}));if(t.some((function(e){return isNaN(e)})))return null;switch(t.length){case 2:return{start:t[0],end:t[1],step:1};case 3:return{start:t[0],end:t[2],step:t[1]};default:return null}}(e);if(!n)throw new SyntaxError('String "'+e+'" is no valid range');return"BigNumber"===r.number?(void 0===i&&lu(),f(m(i(n.start),i(n.end),i(n.step)))):f(m(n.start,n.end,n.step,t))}function m(e,t,r,n){for(var i=[],f=l(r)?n?o:a:n?u:s,p=e;f(p,t);)i.push(p),p=c(p,r);return i}})),du="reshape",gu=Me(du,["typed","isInteger","matrix"],(e=>{var{typed:t,isInteger:r}=e;return t(du,{"Matrix, Array":function(e,t){return e.reshape(t,!0)},"Array, Array":function(e,t){return t.forEach((function(e){if(!r(e))throw new TypeError("Invalid size for dimension: "+e)})),jn(e,t)}})})),vu=Me("resize",["config","matrix"],(e=>{var{config:t,matrix:r}=e;return function(e,n,i){if(2!==arguments.length&&3!==arguments.length)throw new d("resize",arguments.length,2,3);if(q(n)&&(n=n.valueOf()),T(n[0])&&(n=n.map((function(e){return T(e)?e.toNumber():e}))),q(e))return e.resize(n,i,!0);if("string"==typeof e)return function(e,t,r){if(void 0!==r){if("string"!=typeof r||1!==r.length)throw new TypeError("Single character expected as defaultValue")}else r=" ";if(1!==t.length)throw new g(t.length,1);var n=t[0];if("number"!=typeof n||!qe(n))throw new TypeError("Invalid size, must contain positive integers (size: "+Sn(t)+")");if(e.length>n)return e.substring(0,n);if(e.length<n){for(var i=e,a=0,o=n-e.length;a<o;a++)i+=r;return i}return e}(e,n,i);var a=!Array.isArray(e)&&"Array"!==t.matrix;if(0===n.length){for(;Array.isArray(e);)e=e[0];return be(e)}Array.isArray(e)||(e=[e]);var o=Rn(e=be(e),n,i);return a?r(o):o}})),yu="rotate",xu=Me(yu,["typed","multiply","rotationMatrix"],(e=>{var{typed:t,multiply:r,rotationMatrix:n}=e;return t(yu,{"Array , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),r(n(t),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),r(n(t),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),r(n(t,a),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),r(n(t,a),e)}});function i(e,t){var r=Array.isArray(e)?Bn(e):e.size();if(r.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(t));if(2===r.length&&1!==r[1])throw new RangeError("Vector must be of dimensions 1x".concat(t));if(r[0]!==t)throw new RangeError("Vector must be of dimensions 1x".concat(t))}})),bu="rotationMatrix",wu=Me(bu,["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],(e=>{var{typed:t,config:r,multiplyScalar:n,addScalar:i,unaryMinus:a,norm:o,BigNumber:s,matrix:u,DenseMatrix:c,SparseMatrix:l,cos:f,sin:p}=e;return t(bu,{"":function(){return"Matrix"===r.matrix?u([]):[]},string:function(e){return u(e)},"number | BigNumber | Complex | Unit":function(e){return m(e,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(e,t){return m(e,t)},"number | BigNumber | Complex | Unit, Array":function(e,t){var r=u(t);return h(r),v(e,r,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,t){h(t);var n=t.storage()||("Matrix"===r.matrix?"dense":void 0);return v(e,t,n)},"number | BigNumber | Complex | Unit, Array, string":function(e,t,r){var n=u(t);return h(n),v(e,n,r)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,t,r){return h(t),v(e,t,r)}});function m(e,t){var r=T(e)?new s(-1):-1,i=f(e),a=p(e);return g([[i,n(r,a)],[a,i]],t)}function h(e){var t=e.size();if(t.length<1||3!==t[0])throw new RangeError("Vector must be of dimensions 1x3")}function d(e){return e.reduce(((e,t)=>n(e,t)))}function g(e,t){if(t){if("sparse"===t)return new l(e);if("dense"===t)return new c(e);throw new TypeError('Unknown matrix type "'.concat(t,'"'))}return e}function v(e,t,r){var n=o(t);if(0===n)throw new RangeError("Rotation around zero vector");var u=T(e)?s:null,c=u?new u(1):1,l=u?new u(-1):-1,m=u?new u(t.get([0])/n):t.get([0])/n,h=u?new u(t.get([1])/n):t.get([1])/n,v=u?new u(t.get([2])/n):t.get([2])/n,y=f(e),x=i(c,a(y)),b=p(e);return g([[i(y,d([m,m,x])),i(d([m,h,x]),d([l,v,b])),i(d([m,v,x]),d([h,b]))],[i(d([m,h,x]),d([v,b])),i(y,d([h,h,x])),i(d([h,v,x]),d([l,m,b]))],[i(d([m,v,x]),d([l,h,b])),i(d([h,v,x]),d([m,b])),i(y,d([v,v,x]))]],r)}})),Du=Me("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e;return t("row",{"Matrix, number":a,"Array, number":function(e,t){return a(n(be(e)),t).valueOf()}});function a(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");In(t,e.size()[0]);var a=i(0,e.size()[1]),o=new r(t,a),s=e.subset(o);return q(s)?s:n([[s]])}})),Nu="size",Eu=Me(Nu,["typed","config","?matrix"],(e=>{var{typed:t,config:r,matrix:n}=e;return t(Nu,{Matrix:function(e){return e.create(e.size(),"number")},Array:Bn,string:function(e){return"Array"===r.matrix?[e.length]:n([e.length],"dense","number")},"number | Complex | BigNumber | Unit | boolean | null":function(e){return"Array"===r.matrix?[]:n?n([],"dense","number"):pu()}})})),Au="squeeze",Su=Me(Au,["typed"],(e=>{var{typed:t}=e;return t(Au,{Array:function(e){return Hn(be(e))},Matrix:function(e){var t=Hn(e.toArray());return Array.isArray(t)?e.create(t,e.datatype()):t},any:function(e){return be(e)}})})),Cu="subset",Mu=Me(Cu,["typed","matrix","zeros","add"],(e=>{var{typed:t,matrix:r,zeros:n,add:i}=e;return t(Cu,{"Matrix, Index":function(e,t){return qn(t)?r():(zn(e,t),e.subset(t))},"Array, Index":t.referTo("Matrix, Index",(function(e){return function(t,n){var i=e(r(t),n);return n.isScalar()?i:i.valueOf()}})),"Object, Index":_u,"string, Index":Fu,"Matrix, Index, any, any":function(e,t,r,a){return qn(t)?e:(zn(e,t),e.clone().subset(t,function(e,t){if("string"==typeof e)throw new Error("can't boradcast a string");if(t._isScalar)return e;var r=t.size();if(!r.every((e=>e>0)))return e;try{return i(e,n(r))}catch(t){return e}}(r,t),a))},"Array, Index, any, any":t.referTo("Matrix, Index, any, any",(function(e){return function(t,n,i,a){var o=e(r(t),n,i,a);return o.isMatrix?o.valueOf():o}})),"Array, Index, any":t.referTo("Matrix, Index, any, any",(function(e){return function(t,n,i){return e(r(t),n,i,void 0).valueOf()}})),"Matrix, Index, any":t.referTo("Matrix, Index, any, any",(function(e){return function(t,r,n){return e(t,r,n,void 0)}})),"string, Index, string":Tu,"string, Index, string, string":Tu,"Object, Index, any":Bu})}));function Fu(e,t){if(!L(t))throw new TypeError("Index expected");if(qn(t))return"";if(zn(Array.from(e),t),1!==t.size().length)throw new g(t.size().length,1);var r=e.length;In(t.min()[0],r),In(t.max()[0],r);var n=t.dimension(0),i="";return n.forEach((function(t){i+=e.charAt(t)})),i}function Tu(e,t,r,n){if(!t||!0!==t.isIndex)throw new TypeError("Index expected");if(qn(t))return e;if(zn(Array.from(e),t),1!==t.size().length)throw new g(t.size().length,1);if(void 0!==n){if("string"!=typeof n||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";var i=t.dimension(0);if(i.size()[0]!==r.length)throw new g(i.size()[0],r.length);var a=e.length;In(t.min()[0]),In(t.max()[0]);for(var o=[],s=0;s<a;s++)o[s]=e.charAt(s);if(i.forEach((function(e,t){o[e]=r.charAt(t[0])})),o.length>a)for(var u=a-1,c=o.length;u<c;u++)o[u]||(o[u]=n);return o.join("")}function _u(e,t){if(!qn(t)){if(1!==t.size().length)throw new g(t.size(),1);var r=t.dimension(0);if("string"!=typeof r)throw new TypeError("String expected as index to retrieve an object property");return y(e,r)}}function Bu(e,t,r){if(qn(t))return e;if(1!==t.size().length)throw new g(t.size(),1);var n=t.dimension(0);if("string"!=typeof n)throw new TypeError("String expected as index to retrieve an object property");var i=be(e);return x(i,n,r),i}var Ou="transpose",ku=Me(Ou,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t(Ou,{Array:e=>n(r(e)).valueOf(),Matrix:n,any:be});function n(e){var t,r=e.size();switch(r.length){case 1:t=e.clone();break;case 2:var n=r[0],i=r[1];if(0===i)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+Sn(r)+")");switch(e.storage()){case"dense":t=function(e,t,r){for(var n,i=e._data,a=[],o=0;o<r;o++){n=a[o]=[];for(var s=0;s<t;s++)n[s]=be(i[s][o])}return e.createDenseMatrix({data:a,size:[r,t],datatype:e._datatype})}(e,n,i);break;case"sparse":t=function(e,t,r){for(var n,i,a,o=e._values,s=e._index,u=e._ptr,c=o?[]:void 0,l=[],f=[],p=[],m=0;m<t;m++)p[m]=0;for(n=0,i=s.length;n<i;n++)p[s[n]]++;for(var h=0,d=0;d<t;d++)f.push(h),h+=p[d],p[d]=f[d];for(f.push(h),a=0;a<r;a++)for(var g=u[a],v=u[a+1],y=g;y<v;y++){var x=p[s[y]]++;l[x]=a,o&&(c[x]=be(o[y]))}return e.createSparseMatrix({values:c,index:l,ptr:f,size:[r,t],datatype:e._datatype})}(e,n,i)}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+Sn(r)+")")}return t}})),zu="ctranspose",Iu=Me(zu,["typed","transpose","conj"],(e=>{var{typed:t,transpose:r,conj:n}=e;return t(zu,{any:function(e){return n(r(e))}})})),qu="zeros",Ru=Me(qu,["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t(qu,{"":function(){return"Array"===r.matrix?a([]):a([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return a(e,t)}return"Array"===r.matrix?a(e):a(e,"default")},Array:a,Matrix:function(e){var t=e.storage();return a(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return a(e.valueOf(),t)}});function a(e,t){var r=function(e){var t=!1;return e.forEach((function(e,r,n){T(e)&&(t=!0,n[r]=e.toNumber())})),t}(e),a=r?new i(0):0;if(function(e){e.forEach((function(e){if("number"!=typeof e||!qe(e)||e<0)throw new Error("Parameters in function zeros must be positive integers")}))}(e),t){var o=n(t);return e.length>0?o.resize(e,a):o}var s=[];return e.length>0?Rn(s,e,a):s}})),Pu=Me("fft",["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i","dotDivide","conj","pow","ceil","log2"],(e=>{var{typed:t,matrix:r,addScalar:n,multiplyScalar:i,divideScalar:a,exp:o,tau:s,i:u,dotDivide:c,conj:l,pow:f,ceil:p,log2:m}=e;return t("fft",{Array:h,Matrix:function(e){return e.create(h(e.valueOf()),e.datatype())}});function h(e){var t=Bn(e);return 1===t.length?g(e,t[0]):d(e.map((e=>h(e,t.slice(1)))),0)}function d(e,t){var r=Bn(e);if(0!==t)return new Array(r[0]).fill(0).map(((r,n)=>d(e[n],t-1)));if(1===r.length)return g(e);function n(e){var t=Bn(e);return new Array(t[1]).fill(0).map(((r,n)=>new Array(t[0]).fill(0).map(((t,r)=>e[r][n]))))}return n(d(n(e),1))}function g(e){var t=e.length;if(1===t)return[e[0]];if(t%2==0){for(var r=[...g(e.filter(((e,t)=>t%2==0))),...g(e.filter(((e,t)=>t%2==1)))],d=0;d<t/2;d++){var v=r[d],y=i(r[d+t/2],o(i(i(s,u),a(-d,t))));r[d]=n(v,y),r[d+t/2]=n(v,i(-1,y))}return r}return function(e){for(var t=e.length,r=o(a(i(-1,i(u,s)),t)),n=[],d=1-t;d<t;d++)n.push(f(r,a(f(d,2),2)));for(var v=f(2,p(m(t+t-1))),y=[...new Array(t).fill(0).map(((r,a)=>i(e[a],n[t-1+a]))),...new Array(v-t).fill(0)],x=[...new Array(t+t-1).fill(0).map(((e,t)=>a(1,n[t]))),...new Array(v-(t+t-1)).fill(0)],b=g(y),w=g(x),D=new Array(v).fill(0).map(((e,t)=>i(b[t],w[t]))),N=c(l(h(l(D))),v),E=[],A=t-1;A<t+t-1;A++)E.push(i(N[A],n[A]));return E}(e)}})),ju="ifft",Uu=Me(ju,["typed","fft","dotDivide","conj"],(e=>{var{typed:t,fft:r,dotDivide:n,conj:i}=e;return t(ju,{"Array | Matrix":function(e){var t=q(e)?e.size():Bn(e);return n(i(r(i(e))),t.reduce(((e,t)=>e*t),1))}})}));function Lu(e){return Lu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Lu(e)}function Hu(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=Lu(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=Lu(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Lu(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function $u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}var Gu=Me("solveODE",["typed","add","subtract","multiply","divide","max","map","abs","isPositive","isNegative","larger","smaller","matrix","bignumber","unaryMinus"],(e=>{var{typed:t,add:r,subtract:n,multiply:i,divide:a,max:o,map:s,abs:u,isPositive:c,isNegative:l,larger:f,smaller:p,matrix:m,bignumber:h,unaryMinus:d}=e;function g(e){return function(t,m,g,v){if(2!==m.length||!m.every(b)&&!m.every(k))throw new Error('"tspan" must be an Array of two numeric values or two units [tStart, tEnd]');var y=m[0],x=m[1],w=f(x,y),D=v.firstStep;if(void 0!==D&&!c(D))throw new Error('"firstStep" must be positive');var N=v.maxStep;if(void 0!==N&&!c(N))throw new Error('"maxStep" must be positive');var E=v.minStep;if(E&&l(E))throw new Error('"minStep" must be positive or zero');var A=[y,x,D,E,N].filter((e=>void 0!==e));if(!A.every(b)&&!A.every(k))throw new Error('Inconsistent type of "t" dependant variables');for(var S=v.tol?v.tol:1e-4,C=v.minDelta?v.minDelta:.2,M=v.maxDelta?v.maxDelta:5,F=v.maxIter?v.maxIter:1e4,_=[y,x,...g,N,E].some(T),[B,O,z,I]=_?[h(e.a),h(e.c),h(e.b),h(e.bp)]:[e.a,e.c,e.b,e.bp],q=D?w?D:d(D):a(n(x,y),1),R=[y],P=[g],j=n(z,I),U=0,L=0,H=function(e){return e?p:f}(w),$=function(e){var t=e?f:p;return function(e,i,a){var o=r(e,a);return t(o,i)?n(i,e):a}}(w);H(R[U],x);){var G=[];q=$(R[U],x,q),G.push(t(R[U],P[U]));for(var W=1;W<O.length;++W)G.push(t(r(R[U],i(O[W],q)),r(P[U],i(q,B[W],G))));var V=o(u(s(i(j,G),(e=>k(e)?e.value:e))));V<S&&S/V>1/4&&(R.push(r(R[U],q)),P.push(r(P[U],i(q,z,G))),U++);var Z=.84*(S/V)**.2;if(p(Z,C)?Z=C:f(Z,M)&&(Z=M),Z=_?h(Z):Z,q=i(q,Z),N&&f(u(q),N)?q=w?N:d(N):E&&p(u(q),E)&&(q=w?E:d(E)),++L>F)throw new Error("Maximum number of iterations reached, try changing options")}return{t:R,y:P}}}function v(e,t,r,n){return g({a:[[],[.5],[0,3/4],[2/9,1/3,4/9]],c:[null,.5,3/4,1],b:[2/9,1/3,4/9,0],bp:[7/24,1/4,1/3,1/8]})(e,t,r,n)}function y(e,t,r,n){return g({a:[[],[.2],[3/40,9/40],[44/45,-56/15,32/9],[19372/6561,-25360/2187,64448/6561,-212/729],[9017/3168,-355/33,46732/5247,49/176,-5103/18656],[35/384,0,500/1113,125/192,-2187/6784,11/84]],c:[null,.2,.3,.8,8/9,1,1],b:[35/384,0,500/1113,125/192,-2187/6784,11/84,0],bp:[5179/57600,0,7571/16695,393/640,-92097/339200,187/2100,1/40]})(e,t,r,n)}function x(e,t,r,n){var i=n.method?n.method:"RK45",a={RK23:v,RK45:y};if(i.toUpperCase()in a){var o=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?$u(Object(r),!0).forEach((function(t){Hu(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):$u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},n);return delete o.method,a[i.toUpperCase()](e,t,r,o)}var s=Object.keys(a).map((e=>'"'.concat(e,'"'))),u="".concat(s.slice(0,-1).join(", ")," and ").concat(s.slice(-1));throw new Error('Unavailable method "'.concat(i,'". Available methods are ').concat(u))}function b(e){return T(e)||F(e)}function w(e,t,r,n){var i=x(e,t.toArray(),r.toArray(),n);return{t:m(i.t),y:m(i.y)}}return t("solveODE",{"function, Array, Array, Object":x,"function, Matrix, Matrix, Object":w,"function, Array, Array":(e,t,r)=>x(e,t,r,{}),"function, Matrix, Matrix":(e,t,r)=>w(e,t,r,{}),"function, Array, number | BigNumber | Unit":(e,t,r)=>{var n=x(e,t,[r],{});return{t:n.t,y:n.y.map((e=>e[0]))}},"function, Matrix, number | BigNumber | Unit":(e,t,r)=>{var n=x(e,t.toArray(),[r],{});return{t:m(n.t),y:m(n.y.map((e=>e[0])))}},"function, Array, number | BigNumber | Unit, Object":(e,t,r,n)=>{var i=x(e,t,[r],n);return{t:i.t,y:i.y.map((e=>e[0]))}},"function, Matrix, number | BigNumber | Unit, Object":(e,t,r,n)=>{var i=x(e,t.toArray(),[r],n);return{t:m(i.t),y:m(i.y.map((e=>e[0])))}}})})),Wu=Me("erf",["typed"],(e=>{var{typed:t}=e;return t("name",{number:function(e){var t=Math.abs(e);return t>=Xu?Pe(e):t<=Vu?Pe(e)*function(e){var t,r=e*e,n=Yu[0][4]*r,i=r;for(t=0;t<3;t+=1)n=(n+Yu[0][t])*r,i=(i+Ju[0][t])*r;return e*(n+Yu[0][3])/(i+Ju[0][3])}(t):t<=4?Pe(e)*(1-function(e){var t,r=Yu[1][8]*e,n=e;for(t=0;t<7;t+=1)r=(r+Yu[1][t])*e,n=(n+Ju[1][t])*e;var i=(r+Yu[1][7])/(n+Ju[1][7]),a=parseInt(16*e)/16,o=(e-a)*(e+a);return Math.exp(-a*a)*Math.exp(-o)*i}(t)):Pe(e)*(1-function(e){var t,r=1/(e*e),n=Yu[2][5]*r,i=r;for(t=0;t<4;t+=1)n=(n+Yu[2][t])*r,i=(i+Ju[2][t])*r;var a=r*(n+Yu[2][4])/(i+Ju[2][4]);a=(Zu-a)/e;var o=(e-(r=parseInt(16*e)/16))*(e+r);return Math.exp(-r*r)*Math.exp(-o)*a}(t))},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),Vu=.46875,Zu=.5641895835477563,Yu=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],Ju=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],Xu=Math.pow(2,53),Qu="zeta",Ku=Me(Qu,["typed","config","multiply","pow","divide","factorial","equal","smallerEq","isNegative","gamma","sin","subtract","add","?Complex","?BigNumber","pi"],(e=>{var{typed:t,config:r,multiply:n,pow:i,divide:a,factorial:o,equal:s,smallerEq:u,isNegative:c,gamma:l,sin:f,subtract:p,add:m,Complex:h,BigNumber:d,pi:g}=e;return t(Qu,{number:e=>v(e,(e=>e),(()=>20)),BigNumber:e=>v(e,(e=>new d(e)),(()=>Math.abs(Math.log10(r.relTol)))),Complex:function(e){return 0===e.re&&0===e.im?new h(-.5):1===e.re?new h(NaN,NaN):e.re===1/0&&0===e.im?new h(1):e.im===1/0||e.re===-1/0?new h(NaN,NaN):y(e,(e=>e),(e=>Math.round(19.5+.9*Math.abs(e.im))),(e=>e.re))}});function v(e,t,r){return s(e,0)?t(-.5):s(e,1)?t(NaN):isFinite(e)?y(e,t,r,(e=>e)):c(e)?t(NaN):t(1)}function y(e,t,r,o){var s=r(e);if(o(e)>-(s-1)/2)return function(e,t,r){for(var o=a(1,n(x(r(0),t),p(1,i(2,p(1,e))))),s=r(0),c=r(1);u(c,t);c=m(c,1))s=m(s,a(n((-1)**(c-1),x(c,t)),i(c,e)));return n(o,s)}(e,t(s),t);var c=n(i(2,e),i(t(g),p(e,1)));return c=n(c,f(n(a(t(g),2),e))),c=n(c,l(p(1,e))),n(c,y(p(1,e),t,r,o))}function x(e,t){for(var r=e,s=e;u(s,t);s=m(s,1)){var c=a(n(o(m(t,p(s,1))),i(4,s)),n(o(p(t,s)),o(n(2,s))));r=m(r,c)}return n(t,r)}})),ec="mode",tc=Me(ec,["typed","isNaN","isNumeric"],(e=>{var{typed:t,isNaN:r,isNumeric:n}=e;return t(ec,{"Array | Matrix":i,"...":function(e){return i(e)}});function i(e){if(0===(e=Vn(e.valueOf())).length)throw new Error("Cannot calculate mode of an empty array");for(var t={},i=[],a=0,o=0;o<e.length;o++){var s=e[o];if(n(s)&&r(s))throw new Error("Cannot calculate mode of an array containing NaN values");s in t||(t[s]=0),t[s]++,t[s]===a?i.push(s):t[s]>a&&(a=t[s],i=[s])}return i}}));function rc(e,t,r){var n;return String(e).includes("Unexpected type")?(n=arguments.length>2?" (type: "+xe(r)+", value: "+JSON.stringify(r)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+n)):String(e).includes("complex numbers")?(n=arguments.length>2?" (type: "+xe(r)+", value: "+JSON.stringify(r)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+n)):e}var nc="prod",ic=Me(nc,["typed","config","multiplyScalar","numeric"],(e=>{var{typed:t,config:r,multiplyScalar:n,numeric:i}=e;return t(nc,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("prod(A, dim) is not yet supported")},"...":function(e){return a(e)}});function a(e){var t;if(di(e,(function(e){try{t=void 0===t?e:n(t,e)}catch(t){throw rc(t,"prod",e)}})),"string"==typeof t&&(t=i(t,Re(t,r))),void 0===t)throw new Error("Cannot calculate prod of an empty array");return t}})),ac="format",oc=Me(ac,["typed"],(e=>{var{typed:t}=e;return t(ac,{any:Sn,"any, Object | function | number | BigNumber":Sn})})),sc=Me("bin",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("bin",{"number | BigNumber":function(e){return r(e,{notation:"bin"})},"number | BigNumber, number | BigNumber":function(e,t){return r(e,{notation:"bin",wordSize:t})}})})),uc=Me("oct",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("oct",{"number | BigNumber":function(e){return r(e,{notation:"oct"})},"number | BigNumber, number | BigNumber":function(e,t){return r(e,{notation:"oct",wordSize:t})}})})),cc=Me("hex",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("hex",{"number | BigNumber":function(e){return r(e,{notation:"hex"})},"number | BigNumber, number | BigNumber":function(e,t){return r(e,{notation:"hex",wordSize:t})}})})),lc=/\$([\w.]+)/g,fc="print",pc=Me(fc,["typed"],(e=>{var{typed:t}=e;return t(fc,{"string, Object | Array":mc,"string, Object | Array, number | Object":mc})}));function mc(e,t,r){return e.replace(lc,(function(e,n){var i=n.split("."),a=t[i.shift()];for(void 0!==a&&a.isMatrix&&(a=a.toArray());i.length&&void 0!==a;){var o=i.shift();a=o?a[o]:a+"."}return void 0!==a?z(a)?a:Sn(a,r):e}))}var hc=Me("to",["typed","matrix","concat"],(e=>{var{typed:t,matrix:r,concat:n}=e;return t("to",{"Unit, Unit | string":(e,t)=>e.to(t)},vo({typed:t,matrix:r,concat:n})({Ds:!0}))})),dc="isPrime",gc=Me(dc,["typed"],(e=>{var{typed:t}=e;return t(dc,{number:function(e){if(e<=3)return e>1;if(e%2==0||e%3==0)return!1;for(var t=5;t*t<=e;t+=6)if(e%t==0||e%(t+2)==0)return!1;return!0},bigint:function(e){if(e<=3n)return e>1n;if(e%2n===0n||e%3n===0n)return!1;for(var t=5n;t*t<=e;t+=6n)if(e%t===0n||e%(t+2n)===0n)return!1;return!0},BigNumber:function(e){if(e.lte(3))return e.gt(1);if(e.mod(2).eq(0)||e.mod(3).eq(0))return!1;if(e.lt(Math.pow(2,32))){for(var t=e.toNumber(),r=5;r*r<=t;r+=6)if(t%r==0||t%(r+2)==0)return!1;return!0}function n(e,t,r){for(var n=1;!t.eq(0);)t.mod(2).eq(0)?(t=t.div(2),e=e.mul(e).mod(r)):(t=t.sub(1),n=e.mul(n).mod(r));return n}for(var i=e.constructor.clone({precision:2*e.toFixed(0).length}),a=0,o=(e=new i(e)).sub(1);o.mod(2).eq(0);)o=o.div(2),a+=1;var s=null;if(e.lt("3317044064679887385961981"))s=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter((t=>t<e));else{var u=Math.min(e.toNumber()-2,Math.floor(2*Math.pow(e.toFixed(0).length*Math.log(10),2)));s=[];for(var c=2;c<=u;c+=1)s.push(u)}for(var l=0;l<s.length;l+=1){var f=s[l],p=n(e.sub(e).add(f),o,e);if(!p.eq(1))for(var m=0,h=p;!h.eq(e.sub(1));m+=1,h=h.mul(h).mod(e))if(m===a-1)return!1}return!0},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),vc=Me("numeric",["number","?bignumber","?fraction"],(e=>{var{number:t,bignumber:r,fraction:n}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},a={number:e=>t(e),BigNumber:r?e=>r(e):lu,bigint:e=>BigInt(e),Fraction:n?e=>n(e):fu};return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"number";if(void 0!==(arguments.length>2?arguments[2]:void 0))throw new SyntaxError("numeric() takes one or two arguments");var r=xe(e);if(!(r in i))throw new TypeError("Cannot convert "+e+' of type "'+r+'"; valid input types are '+Object.keys(i).join(", "));if(!(t in a))throw new TypeError("Cannot convert "+e+' to type "'+t+'"; valid output types are '+Object.keys(a).join(", "));return t===r?e:a[t](e)}})),yc="divideScalar",xc=Me(yc,["typed","numeric"],(e=>{var{typed:t,numeric:r}=e;return t(yc,{"number, number":function(e,t){return e/t},"Complex, Complex":function(e,t){return e.div(t)},"BigNumber, BigNumber":function(e,t){return e.div(t)},"bigint, bigint":function(e,t){return e/t},"Fraction, Fraction":function(e,t){return e.div(t)},"Unit, number | Complex | Fraction | BigNumber | Unit":(e,t)=>e.divide(t),"number | Fraction | Complex | BigNumber, Unit":(e,t)=>t.divideInto(e)})})),bc=Me("pow",["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],(e=>{var{typed:t,config:r,identity:n,multiply:i,matrix:a,inv:o,number:s,fraction:u,Complex:c}=e;return t("pow",{"number, number":l,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(e,t){return t.isInteger()||e>=0||r.predictable?e.pow(t):new c(e.toNumber(),0).pow(t.toNumber(),0)},"bigint, bigint":(e,t)=>e**t,"Fraction, Fraction":function(e,t){var n=e.pow(t);if(null!=n)return n;if(r.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return l(e.valueOf(),t.valueOf())},"Array, number":f,"Array, BigNumber":function(e,t){return f(e,t.toNumber())},"Matrix, number":p,"Matrix, BigNumber":function(e,t){return p(e,t.toNumber())},"Unit, number | BigNumber":function(e,t){return e.pow(t)}});function l(e,t){if(r.predictable&&!qe(t)&&e<0)try{var n=u(t),i=s(n);if((t===i||Math.abs((t-i)/t)<1e-14)&&n.d%2==1)return(n.n%2==0?1:-1)*Math.pow(-e,t)}catch(e){}return r.predictable&&(e<-1&&t===1/0||e>-1&&e<0&&t===-1/0)?NaN:qe(t)||e>=0||r.predictable?Fa(e,t):e*e<1&&t===1/0||e*e>1&&t===-1/0?0:new c(e,0).pow(t,0)}function f(e,t){if(!qe(t))throw new TypeError("For A^b, b must be an integer (value is "+t+")");var r=Bn(e);if(2!==r.length)throw new Error("For A^b, A must be 2 dimensional (A has "+r.length+" dimensions)");if(r[0]!==r[1])throw new Error("For A^b, A must be square (size is "+r[0]+"x"+r[1]+")");if(t<0)try{return f(o(e),-t)}catch(e){if("Cannot calculate inverse, determinant is zero"===e.message)throw new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+t+")");throw e}for(var a=n(r[0]).valueOf(),s=e;t>=1;)1==(1&t)&&(a=i(s,a)),t>>=1,s=i(s,s);return a}function p(e,t){return a(f(e.valueOf(),t))}})),wc="Number of decimals in function round must be an integer",Dc="round",Nc=Me(Dc,["typed","config","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,equalScalar:i,zeros:a,BigNumber:o,DenseMatrix:s}=e,u=Ga({typed:t,equalScalar:i}),c=Wa({typed:t,DenseMatrix:s}),l=Va({typed:t});function f(e){return Math.abs(Ze(e).exponent)}return t(Dc,{number:function(e){var t=Ta(e,f(r.relTol));return Ta(Ke(e,t,r.relTol,r.absTol)?t:e)},"number, number":function(e,t){var n=f(r.relTol);if(t>=n)return Ta(e,t);var i=Ta(e,n);return Ta(Ke(e,i,r.relTol,r.absTol)?i:e,t)},"number, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(wc);return new o(e).toDecimalPlaces(t.toNumber())},Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw new TypeError(wc);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(wc);var r=t.toNumber();return e.round(r)},BigNumber:function(e){var t=new o(e).toDecimalPlaces(f(r.relTol));return(Si(e,t,r.relTol,r.absTol)?t:e).toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(wc);var n=f(r.relTol);if(t>=n)return e.toDecimalPlaces(t.toNumber());var i=e.toDecimalPlaces(n);return(Si(e,i,r.relTol,r.absTol)?i:e).toDecimalPlaces(t.toNumber())},Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw new TypeError(wc);return e.round(t)},"Fraction, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(wc);return e.round(t.toNumber())},"Unit, number, Unit":t.referToSelf((e=>function(t,r,n){var i=t.toNumeric(n);return n.multiply(e(i,r))})),"Unit, BigNumber, Unit":t.referToSelf((e=>(t,r,n)=>e(t,r.toNumber(),n))),"Unit, Unit":t.referToSelf((e=>(t,r)=>e(t,0,r))),"Array | Matrix, number, Unit":t.referToSelf((e=>(t,r,n)=>gi(t,(t=>e(t,r,n)),!0))),"Array | Matrix, BigNumber, Unit":t.referToSelf((e=>(t,r,n)=>e(t,r.toNumber(),n))),"Array | Matrix, Unit":t.referToSelf((e=>(t,r)=>e(t,0,r))),"Array | Matrix":t.referToSelf((e=>t=>gi(t,e,!0))),"SparseMatrix, number | BigNumber":t.referToSelf((e=>(t,r)=>u(t,r,e,!1))),"DenseMatrix, number | BigNumber":t.referToSelf((e=>(t,r)=>l(t,r,e,!1))),"Array, number | BigNumber":t.referToSelf((e=>(t,r)=>l(n(t),r,e,!1).valueOf())),"number | Complex | BigNumber | Fraction, SparseMatrix":t.referToSelf((e=>(t,r)=>i(t,0)?a(r.size(),r.storage()):c(r,t,e,!0))),"number | Complex | BigNumber | Fraction, DenseMatrix":t.referToSelf((e=>(t,r)=>i(t,0)?a(r.size(),r.storage()):l(r,t,e,!0))),"number | Complex | BigNumber | Fraction, Array":t.referToSelf((e=>(t,r)=>l(n(r),t,e,!0).valueOf()))})})),Ec=Me("log",["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,Complex:i}=e;return t("log",{number:function(e){return e>=0||r.predictable?function(e,t){return Math.log(e)}(e):new i(e,0).log()},Complex:function(e){return e.log()},BigNumber:function(e){return!e.isNegative()||r.predictable?e.ln():new i(e.toNumber(),0).log()},"any, any":t.referToSelf((e=>(t,r)=>n(e(t),e(r))))})})),Ac="log1p",Sc=Me(Ac,["typed","config","divideScalar","log","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,log:i,Complex:a}=e;return t(Ac,{number:function(e){return e>=-1||r.predictable?Le(e):o(new a(e,0))},Complex:o,BigNumber:function(e){var t=e.plus(1);return!t.isNegative()||r.predictable?t.ln():o(new a(e.toNumber(),0))},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e))),"any, any":t.referToSelf((e=>(t,r)=>n(e(t),i(r))))});function o(e){var t=e.re+1;return new a(Math.log(Math.sqrt(t*t+e.im*e.im)),Math.atan2(e.im,t))}})),Cc="nthRoots",Mc=Me(Cc,["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,Complex:i}=e,a=[function(e){return new i(e,0)},function(e){return new i(0,e)},function(e){return new i(-e,0)},function(e){return new i(0,-e)}];function o(e,t){if(t<0)throw new Error("Root must be greater than zero");if(0===t)throw new Error("Root must be non-zero");if(t%1!=0)throw new Error("Root must be an integer");if(0===e||0===e.abs())return[new i(0,0)];var r,n="number"==typeof e;(n||0===e.re||0===e.im)&&(r=n?2*+(e<0):0===e.im?2*+(e.re<0):2*+(e.im<0)+1);for(var o=e.arg(),s=e.abs(),u=[],c=Math.pow(s,1/t),l=0;l<t;l++){var f=(r+4*l)/t;f!==Math.round(f)?u.push(new i({r:c,phi:(o+2*Math.PI*l)/t})):u.push(a[f%4](c))}return u}return t(Cc,{Complex:function(e){return o(e,2)},"Complex, number":o})})),Fc="dotPow",Tc=Me(Fc,["typed","equalScalar","matrix","pow","DenseMatrix","concat"],(e=>{var{typed:t,equalScalar:r,matrix:n,pow:i,DenseMatrix:a,concat:o}=e,s=po({typed:t}),u=bs({typed:t,DenseMatrix:a}),c=Ga({typed:t,equalScalar:r}),l=Wa({typed:t,DenseMatrix:a}),f=vo({typed:t,matrix:n,concat:o}),p={};for(var m in i.signatures)Object.prototype.hasOwnProperty.call(i.signatures,m)&&(m.includes("Matrix")||m.includes("Array")||(p[m]=i.signatures[m]));var h=t(p);return t(Fc,f({elop:h,SS:u,DS:s,Ss:c,sS:l}))})),_c="dotDivide",Bc=Me(_c,["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],(e=>{var{typed:t,matrix:r,equalScalar:n,divideScalar:i,DenseMatrix:a,concat:o}=e,s=fo({typed:t,equalScalar:n}),u=po({typed:t}),c=bs({typed:t,DenseMatrix:a}),l=Ga({typed:t,equalScalar:n}),f=Wa({typed:t,DenseMatrix:a}),p=vo({typed:t,matrix:r,concat:o});return t(_c,p({elop:i,SS:c,DS:u,SD:s,Ss:l,sS:f}))}));function Oc(e){var{DenseMatrix:t}=e;return function(e,r,n){var i=e.size();if(2!==i.length)throw new RangeError("Matrix must be two dimensional (size: "+Sn(i)+")");var a=i[0];if(a!==i[1])throw new RangeError("Matrix must be square (size: "+Sn(i)+")");var o=[];if(q(r)){var s=r.size(),u=r._data;if(1===s.length){if(s[0]!==a)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var c=0;c<a;c++)o[c]=[u[c]];return new t({data:o,size:[a,1],datatype:r._datatype})}if(2===s.length){if(s[0]!==a||1!==s[1])throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");if(P(r)){if(n){o=[];for(var l=0;l<a;l++)o[l]=[u[l][0]];return new t({data:o,size:[a,1],datatype:r._datatype})}return r}if(j(r)){for(var f=0;f<a;f++)o[f]=[0];for(var p=r._values,m=r._index,h=r._ptr,d=h[1],g=h[0];g<d;g++)o[m[g]][0]=p[g];return new t({data:o,size:[a,1],datatype:r._datatype})}}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}if(I(r)){var v=Bn(r);if(1===v.length){if(v[0]!==a)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var y=0;y<a;y++)o[y]=[r[y]];return new t({data:o,size:[a,1]})}if(2===v.length){if(v[0]!==a||1!==v[1])throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var x=0;x<a;x++)o[x]=[r[x][0]];return new t({data:o,size:[a,1]})}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}}}var kc="lsolve",zc=Me(kc,["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:s}=e,u=Oc({DenseMatrix:s});return t(kc,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=(t=u(e,t,!0))._data,c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=[],d=0;d<l;d++){var g=r[d][0]||0;if(o(g,0))h[d]=[0];else{for(var v=0,y=[],x=[],b=m[d],w=m[d+1],D=b;D<w;D++){var N=p[D];N===d?v=f[D]:N>d&&(y.push(f[D]),x.push(N))}if(o(v,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var E=n(g,v),A=0,S=x.length;A<S;A++){var C=x[A];r[C]=[a(r[C][0]||0,i(E,y[A]))]}h[d]=[E]}}return new s({data:h,size:[c,1]})}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(r(e),t).valueOf()}});function c(e,t){for(var r=(t=u(e,t,!0))._data,c=e._size[0],l=e._size[1],f=[],p=e._data,m=0;m<l;m++){var h=r[m][0]||0,d=void 0;if(o(h,0))d=0;else{var g=p[m][m];if(o(g,0))throw new Error("Linear system cannot be solved since matrix is singular");d=n(h,g);for(var v=m+1;v<c;v++)r[v]=[a(r[v][0]||0,i(d,p[v][m]))]}f[m]=[d]}return new s({data:f,size:[c,1]})}})),Ic="usolve",qc=Me(Ic,["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:s}=e,u=Oc({DenseMatrix:s});return t(Ic,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=(t=u(e,t,!0))._data,c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=[],d=l-1;d>=0;d--){var g=r[d][0]||0;if(o(g,0))h[d]=[0];else{for(var v=0,y=[],x=[],b=m[d],w=m[d+1]-1;w>=b;w--){var D=p[w];D===d?v=f[w]:D<d&&(y.push(f[w]),x.push(D))}if(o(v,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var N=n(g,v),E=0,A=x.length;E<A;E++){var S=x[E];r[S]=[a(r[S][0],i(N,y[E]))]}h[d]=[N]}}return new s({data:h,size:[c,1]})}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(r(e),t).valueOf()}});function c(e,t){for(var r=(t=u(e,t,!0))._data,c=e._size[0],l=e._size[1],f=[],p=e._data,m=l-1;m>=0;m--){var h=r[m][0]||0,d=void 0;if(o(h,0))d=0;else{var g=p[m][m];if(o(g,0))throw new Error("Linear system cannot be solved since matrix is singular");d=n(h,g);for(var v=m-1;v>=0;v--)r[v]=[a(r[v][0]||0,i(d,p[v][m]))]}f[m]=[d]}return new s({data:f,size:[c,1]})}})),Rc="lsolveAll",Pc=Me(Rc,["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:s}=e,u=Oc({DenseMatrix:s});return t(Rc,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=0;h<l;h++)for(var d=r.length,g=0;g<d;g++){for(var v=r[g],y=[],x=[],b=m[h],w=m[h+1],D=0,N=b;N<w;N++){var E=p[N];E===h?D=f[N]:E>h&&(y.push(f[N]),x.push(E))}if(o(D,0))if(o(v[h],0)){if(0===g){var A=[...v];A[h]=1;for(var S=0,C=x.length;S<C;S++){var M=x[S];A[M]=a(A[M],y[S])}r.push(A)}}else{if(0===g)return[];r.splice(g,1),g-=1,d-=1}else{v[h]=n(v[h],D);for(var F=0,T=x.length;F<T;F++){var _=x[F];v[_]=a(v[_],i(v[h],y[F]))}}}return r.map((e=>new s({data:e.map((e=>[e])),size:[c,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(r(e),t).map((e=>e.valueOf()))}});function c(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1],p=0;p<f;p++)for(var m=r.length,h=0;h<m;h++){var d=r[h];if(o(c[p][p],0))if(o(d[p],0)){if(0===h){var g=[...d];g[p]=1;for(var v=p+1;v<f;v++)g[v]=a(g[v],c[v][p]);r.push(g)}}else{if(0===h)return[];r.splice(h,1),h-=1,m-=1}else{d[p]=n(d[p],c[p][p]);for(var y=p+1;y<f;y++)d[y]=a(d[y],i(d[p],c[y][p]))}}return r.map((e=>new s({data:e.map((e=>[e])),size:[l,1]})))}})),jc="usolveAll",Uc=Me(jc,["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:s}=e,u=Oc({DenseMatrix:s});return t(jc,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=l-1;h>=0;h--)for(var d=r.length,g=0;g<d;g++){for(var v=r[g],y=[],x=[],b=m[h],w=0,D=m[h+1]-1;D>=b;D--){var N=p[D];N===h?w=f[D]:N<h&&(y.push(f[D]),x.push(N))}if(o(w,0))if(o(v[h],0)){if(0===g){var E=[...v];E[h]=1;for(var A=0,S=x.length;A<S;A++){var C=x[A];E[C]=a(E[C],y[A])}r.push(E)}}else{if(0===g)return[];r.splice(g,1),g-=1,d-=1}else{v[h]=n(v[h],w);for(var M=0,F=x.length;M<F;M++){var T=x[M];v[T]=a(v[T],i(v[h],y[M]))}}}return r.map((e=>new s({data:e.map((e=>[e])),size:[c,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(r(e),t).map((e=>e.valueOf()))}});function c(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1]-1;f>=0;f--)for(var p=r.length,m=0;m<p;m++){var h=r[m];if(o(c[f][f],0))if(o(h[f],0)){if(0===m){var d=[...h];d[f]=1;for(var g=f-1;g>=0;g--)d[g]=a(d[g],c[g][f]);r.push(d)}}else{if(0===m)return[];r.splice(m,1),m-=1,p-=1}else{h[f]=n(h[f],c[f][f]);for(var v=f-1;v>=0;v--)h[v]=a(h[v],i(h[f],c[v][f]))}}return r.map((e=>new s({data:e.map((e=>[e])),size:[l,1]})))}})),Lc=Me("matAlgo08xS0Sid",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype||void 0===e._data?e._datatype:e.getDataType(),l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype||void 0===n._data?n._datatype:n.getDataType();if(u.length!==m.length)throw new g(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");if(!a||!l)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var d,v=u[0],y=u[1],x=r,b=0,w=i;"string"==typeof c&&c===h&&"mixed"!==c&&(d=c,x=t.find(r,[d,d]),b=t.convert(0,d),w=t.find(i,[d,d]));for(var D,N,E,A,S=[],C=[],M=[],F=[],T=[],_=0;_<y;_++){M[_]=C.length;var B=_+1;for(N=s[_],E=s[_+1],D=N;D<E;D++)T[A=o[D]]=B,F[A]=a[D],C.push(A);for(N=p[_],E=p[_+1],D=N;D<E;D++)T[A=f[D]]===B&&(F[A]=w(F[A],l[D]));for(D=M[_];D<C.length;){var O=F[A=C[D]];x(O,b)?C.splice(D,1):(S.push(O),D++)}}return M[y]=C.length,e.createSparseMatrix({values:S,index:C,ptr:M,size:[v,y],datatype:c===e._datatype&&h===n._datatype?d:void 0})}})),Hc=Me("useMatrixForArrayScalar",["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return{"Array, number":t.referTo("DenseMatrix, number",(e=>(t,n)=>e(r(t),n).valueOf())),"Array, BigNumber":t.referTo("DenseMatrix, BigNumber",(e=>(t,n)=>e(r(t),n).valueOf())),"number, Array":t.referTo("number, DenseMatrix",(e=>(t,n)=>e(t,r(n)).valueOf())),"BigNumber, Array":t.referTo("BigNumber, DenseMatrix",(e=>(t,n)=>e(t,r(n)).valueOf()))}})),$c="leftShift",Gc=Me($c,["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a,concat:o}=e,s=xo({typed:t}),u=fo({typed:t,equalScalar:n}),c=Lc({typed:t,equalScalar:n}),l=wo({typed:t,DenseMatrix:a}),f=Ga({typed:t,equalScalar:n}),p=Va({typed:t}),m=vo({typed:t,matrix:r,concat:o}),h=Hc({typed:t,matrix:r});return t($c,{"number, number":fs,"BigNumber, BigNumber":is,"bigint, bigint":(e,t)=>e<<t,"SparseMatrix, number | BigNumber":t.referToSelf((e=>(t,r)=>n(r,0)?t.clone():f(t,r,e,!1))),"DenseMatrix, number | BigNumber":t.referToSelf((e=>(t,r)=>n(r,0)?t.clone():p(t,r,e,!1))),"number | BigNumber, SparseMatrix":t.referToSelf((e=>(t,r)=>n(t,0)?i(r.size(),r.storage()):l(r,t,e,!0))),"number | BigNumber, DenseMatrix":t.referToSelf((e=>(t,r)=>n(t,0)?i(r.size(),r.storage()):p(r,t,e,!0)))},h,m({SS:c,DS:s,SD:u}))})),Wc="rightArithShift",Vc=Me(Wc,["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a,concat:o}=e,s=xo({typed:t}),u=fo({typed:t,equalScalar:n}),c=Lc({typed:t,equalScalar:n}),l=wo({typed:t,DenseMatrix:a}),f=Ga({typed:t,equalScalar:n}),p=Va({typed:t}),m=vo({typed:t,matrix:r,concat:o}),h=Hc({typed:t,matrix:r});return t(Wc,{"number, number":ps,"BigNumber, BigNumber":as,"bigint, bigint":(e,t)=>e>>t,"SparseMatrix, number | BigNumber":t.referToSelf((e=>(t,r)=>n(r,0)?t.clone():f(t,r,e,!1))),"DenseMatrix, number | BigNumber":t.referToSelf((e=>(t,r)=>n(r,0)?t.clone():p(t,r,e,!1))),"number | BigNumber, SparseMatrix":t.referToSelf((e=>(t,r)=>n(t,0)?i(r.size(),r.storage()):l(r,t,e,!0))),"number | BigNumber, DenseMatrix":t.referToSelf((e=>(t,r)=>n(t,0)?i(r.size(),r.storage()):p(r,t,e,!0)))},h,m({SS:c,DS:s,SD:u}))})),Zc="rightLogShift",Yc=Me(Zc,["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a,concat:o}=e,s=xo({typed:t}),u=fo({typed:t,equalScalar:n}),c=Lc({typed:t,equalScalar:n}),l=wo({typed:t,DenseMatrix:a}),f=Ga({typed:t,equalScalar:n}),p=Va({typed:t}),m=vo({typed:t,matrix:r,concat:o}),h=Hc({typed:t,matrix:r});return t(Zc,{"number, number":ms,"SparseMatrix, number | BigNumber":t.referToSelf((e=>(t,r)=>n(r,0)?t.clone():f(t,r,e,!1))),"DenseMatrix, number | BigNumber":t.referToSelf((e=>(t,r)=>n(r,0)?t.clone():p(t,r,e,!1))),"number | BigNumber, SparseMatrix":t.referToSelf((e=>(t,r)=>n(t,0)?i(r.size(),r.storage()):l(r,t,e,!0))),"number | BigNumber, DenseMatrix":t.referToSelf((e=>(t,r)=>n(t,0)?i(r.size(),r.storage()):p(r,t,e,!0)))},h,m({SS:c,DS:s,SD:u}))})),Jc=Me("and",["typed","matrix","equalScalar","zeros","not","concat"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,not:a,concat:o}=e,s=fo({typed:t,equalScalar:n}),u=Co({typed:t,equalScalar:n}),c=Ga({typed:t,equalScalar:n}),l=Va({typed:t}),f=vo({typed:t,matrix:r,concat:o});return t("and",{"number, number":Bs,"Complex, Complex":function(e,t){return!(0===e.re&&0===e.im||0===t.re&&0===t.im)},"BigNumber, BigNumber":function(e,t){return!(e.isZero()||t.isZero()||e.isNaN()||t.isNaN())},"bigint, bigint":Bs,"Unit, Unit":t.referToSelf((e=>(t,r)=>e(t.value||0,r.value||0))),"SparseMatrix, any":t.referToSelf((e=>(t,r)=>a(r)?i(t.size(),t.storage()):c(t,r,e,!1))),"DenseMatrix, any":t.referToSelf((e=>(t,r)=>a(r)?i(t.size(),t.storage()):l(t,r,e,!1))),"any, SparseMatrix":t.referToSelf((e=>(t,r)=>a(t)?i(t.size(),t.storage()):c(r,t,e,!0))),"any, DenseMatrix":t.referToSelf((e=>(t,r)=>a(t)?i(t.size(),t.storage()):l(r,t,e,!0))),"Array, any":t.referToSelf((e=>(t,n)=>e(r(t),n).valueOf())),"any, Array":t.referToSelf((e=>(t,n)=>e(t,r(n)).valueOf()))},f({SS:u,DS:s}))})),Xc="compare",Qc=Me(Xc,["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],(e=>{var{typed:t,config:r,equalScalar:n,matrix:i,BigNumber:a,Fraction:o,DenseMatrix:s,concat:u}=e,c=po({typed:t}),l=mo({typed:t,equalScalar:n}),f=Wa({typed:t,DenseMatrix:s}),p=vo({typed:t,matrix:i,concat:u}),m=Ui({typed:t});return t(Xc,Kc({typed:t,config:r}),{"boolean, boolean":function(e,t){return e===t?0:e>t?1:-1},"BigNumber, BigNumber":function(e,t){return Si(e,t,r.relTol,r.absTol)?new a(0):new a(e.cmp(t))},"bigint, bigint":function(e,t){return e===t?0n:e>t?1n:-1n},"Fraction, Fraction":function(e,t){return new o(e.compare(t))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},m,p({SS:l,DS:c,Ss:f}))})),Kc=Me(Xc,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(Xc,{"number, number":function(e,t){return Ke(e,t,r.relTol,r.absTol)?0:e>t?1:-1}})})),el=r(3228),tl="compareNatural",rl=Me(tl,["typed","compare"],(e=>{var{typed:t,compare:r}=e,n=r.signatures["boolean,boolean"];return t(tl,{"any, any":function e(t,o){var s,u=xe(t),c=xe(o);if(!("number"!==u&&"BigNumber"!==u&&"Fraction"!==u||"number"!==c&&"BigNumber"!==c&&"Fraction"!==c))return"0"!==(s=r(t,o)).toString()?s>0?1:-1:el(u,c);var l=["Array","DenseMatrix","SparseMatrix"];if(l.includes(u)||l.includes(c))return 0!==(s=i(e,t,o))?s:el(u,c);if(u!==c)return el(u,c);if("Complex"===u)return function(e,t){return e.re>t.re?1:e.re<t.re?-1:e.im>t.im?1:e.im<t.im?-1:0}(t,o);if("Unit"===u)return t.equalBase(o)?e(t.value,o.value):a(e,t.formatUnits(),o.formatUnits());if("boolean"===u)return n(t,o);if("string"===u)return el(t,o);if("Object"===u)return function(e,t,r){var n=Object.keys(t),i=Object.keys(r);n.sort(el),i.sort(el);var o=a(e,n,i);if(0!==o)return o;for(var s=0;s<n.length;s++){var u=e(t[n[s]],r[i[s]]);if(0!==u)return u}return 0}(e,t,o);if("null"===u)return 0;if("undefined"===u)return 0;throw new TypeError('Unsupported type of value "'+u+'"')}});function i(e,t,r){return j(t)&&j(r)?a(e,t.toJSON().values,r.toJSON().values):j(t)?i(e,t.toArray(),r):j(r)?i(e,t,r.toArray()):P(t)?i(e,t.toJSON().data,r):P(r)?i(e,t,r.toJSON().data):Array.isArray(t)?Array.isArray(r)?a(e,t,r):i(e,t,[r]):i(e,[t],r)}function a(e,t,r){for(var n=0,i=Math.min(t.length,r.length);n<i;n++){var a=e(t[n],r[n]);if(0!==a)return a}return t.length>r.length?1:t.length<r.length?-1:0}})),nl="compareText",il=["typed","matrix","concat"];_n.signature="any, any";var al=Me(nl,il,(e=>{var{typed:t,matrix:r,concat:n}=e,i=vo({typed:t,matrix:r,concat:n});return t(nl,_n,i({elop:_n,Ds:!0}))})),ol="equal",sl=Me(ol,["typed","matrix","equalScalar","DenseMatrix","concat"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i,concat:a}=e,o=po({typed:t}),s=bs({typed:t,DenseMatrix:i}),u=Wa({typed:t,DenseMatrix:i}),c=vo({typed:t,matrix:r,concat:a});return t(ol,ul({typed:t,equalScalar:n}),c({elop:n,SS:s,DS:o,Ss:u}))})),ul=Me(ol,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return t(ol,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:r(e,t)}})})),cl="equalText",ll=Me(cl,["typed","compareText","isZero"],(e=>{var{typed:t,compareText:r,isZero:n}=e;return t(cl,{"any, any":function(e,t){return n(r(e,t))}})})),fl="smaller",pl=Me(fl,["typed","config","matrix","DenseMatrix","concat"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i,concat:a}=e,o=po({typed:t}),s=bs({typed:t,DenseMatrix:i}),u=Wa({typed:t,DenseMatrix:i}),c=vo({typed:t,matrix:n,concat:a}),l=Ui({typed:t});return t(fl,ml({typed:t,config:r}),{"boolean, boolean":(e,t)=>e<t,"BigNumber, BigNumber":function(e,t){return e.lt(t)&&!Si(e,t,r.relTol,r.absTol)},"bigint, bigint":(e,t)=>e<t,"Fraction, Fraction":(e,t)=>-1===e.compare(t),"Complex, Complex":function(e,t){throw new TypeError("No ordering relation is defined for complex numbers")}},l,c({SS:s,DS:o,Ss:u}))})),ml=Me(fl,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(fl,{"number, number":function(e,t){return e<t&&!Ke(e,t,r.relTol,r.absTol)}})})),hl="smallerEq",dl=Me(hl,["typed","config","matrix","DenseMatrix","concat"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i,concat:a}=e,o=po({typed:t}),s=bs({typed:t,DenseMatrix:i}),u=Wa({typed:t,DenseMatrix:i}),c=vo({typed:t,matrix:n,concat:a}),l=Ui({typed:t});return t(hl,gl({typed:t,config:r}),{"boolean, boolean":(e,t)=>e<=t,"BigNumber, BigNumber":function(e,t){return e.lte(t)||Si(e,t,r.relTol,r.absTol)},"bigint, bigint":(e,t)=>e<=t,"Fraction, Fraction":(e,t)=>1!==e.compare(t),"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},l,c({SS:s,DS:o,Ss:u}))})),gl=Me(hl,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(hl,{"number, number":function(e,t){return e<=t||Ke(e,t,r.relTol,r.absTol)}})})),vl="larger",yl=Me(vl,["typed","config","matrix","DenseMatrix","concat"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i,concat:a}=e,o=po({typed:t}),s=bs({typed:t,DenseMatrix:i}),u=Wa({typed:t,DenseMatrix:i}),c=vo({typed:t,matrix:n,concat:a}),l=Ui({typed:t});return t(vl,xl({typed:t,config:r}),{"boolean, boolean":(e,t)=>e>t,"BigNumber, BigNumber":function(e,t){return e.gt(t)&&!Si(e,t,r.relTol,r.absTol)},"bigint, bigint":(e,t)=>e>t,"Fraction, Fraction":(e,t)=>1===e.compare(t),"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},l,c({SS:s,DS:o,Ss:u}))})),xl=Me(vl,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(vl,{"number, number":function(e,t){return e>t&&!Ke(e,t,r.relTol,r.absTol)}})})),bl="largerEq",wl=Me(bl,["typed","config","matrix","DenseMatrix","concat"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i,concat:a}=e,o=po({typed:t}),s=bs({typed:t,DenseMatrix:i}),u=Wa({typed:t,DenseMatrix:i}),c=vo({typed:t,matrix:n,concat:a}),l=Ui({typed:t});return t(bl,Dl({typed:t,config:r}),{"boolean, boolean":(e,t)=>e>=t,"BigNumber, BigNumber":function(e,t){return e.gte(t)||Si(e,t,r.relTol,r.absTol)},"bigint, bigint":function(e,t){return e>=t},"Fraction, Fraction":(e,t)=>-1!==e.compare(t),"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},l,c({SS:s,DS:o,Ss:u}))})),Dl=Me(bl,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(bl,{"number, number":function(e,t){return e>=t||Ke(e,t,r.relTol,r.absTol)}})})),Nl="deepEqual",El=Me(Nl,["typed","equal"],(e=>{var{typed:t,equal:r}=e;return t(Nl,{"any, any":function(e,t){return n(e.valueOf(),t.valueOf())}});function n(e,t){if(Array.isArray(e)){if(Array.isArray(t)){var i=e.length;if(i!==t.length)return!1;for(var a=0;a<i;a++)if(!n(e[a],t[a]))return!1;return!0}return!1}return!Array.isArray(t)&&r(e,t)}})),Al="unequal",Sl=Me(Al,["typed","config","equalScalar","matrix","DenseMatrix","concat"],(e=>{var{typed:t,config:r,equalScalar:n,matrix:i,DenseMatrix:a,concat:o}=e,s=po({typed:t}),u=bs({typed:t,DenseMatrix:a}),c=Wa({typed:t,DenseMatrix:a}),l=vo({typed:t,matrix:i,concat:o});return t(Al,Cl({typed:t,equalScalar:n}),l({elop:function(e,t){return!n(e,t)},SS:u,DS:s,Ss:c}))})),Cl=Me(Al,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return t(Al,{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:!r(e,t)}})})),Ml="partitionSelect",Fl=Me(Ml,["typed","isNumeric","isNaN","compare"],(e=>{var{typed:t,isNumeric:r,isNaN:n,compare:i}=e,a=i,o=(e,t)=>-i(e,t);return t(Ml,{"Array | Matrix, number":function(e,t){return s(e,t,a)},"Array | Matrix, number, string":function(e,t,r){if("asc"===r)return s(e,t,a);if("desc"===r)return s(e,t,o);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":s});function s(e,t,r){if(!qe(t)||t<0)throw new Error("k must be a non-negative integer");if(q(e)){if(e.size().length>1)throw new Error("Only one dimensional matrices supported");return u(e.valueOf(),t,r)}if(Array.isArray(e))return u(e,t,r)}function u(e,t,i){if(t>=e.length)throw new Error("k out of bounds");for(var a=0;a<e.length;a++)if(r(e[a])&&n(e[a]))return e[a];for(var o=0,s=e.length-1;o<s;){for(var u=o,c=s,l=e[Math.floor(Math.random()*(s-o+1))+o];u<c;)if(i(e[u],l)>=0){var f=e[c];e[c]=e[u],e[u]=f,--c}else++u;i(e[u],l)>0&&--u,t<=u?s=u:o=u+1}return e[t]}})),Tl="sort",_l=Me(Tl,["typed","matrix","compare","compareNatural"],(e=>{var{typed:t,matrix:r,compare:n,compareNatural:i}=e,a=n,o=(e,t)=>-n(e,t);return t(Tl,{Array:function(e){return u(e),e.sort(a)},Matrix:function(e){return c(e),r(e.toArray().sort(a),e.storage())},"Array, function":function(e,t){return u(e),e.sort(t)},"Matrix, function":function(e,t){return c(e),r(e.toArray().sort(t),e.storage())},"Array, string":function(e,t){return u(e),e.sort(s(t))},"Matrix, string":function(e,t){return c(e),r(e.toArray().sort(s(t)),e.storage())}});function s(e){if("asc"===e)return a;if("desc"===e)return o;if("natural"===e)return i;throw new Error('String "asc", "desc", or "natural" expected')}function u(e){if(1!==Bn(e).length)throw new Error("One dimensional array expected")}function c(e){if(1!==e.size().length)throw new Error("One dimensional matrix expected")}})),Bl=Me("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:r,numeric:n,larger:i}=e;return t("max",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){return vi(e,t.valueOf(),a)},"...":function(e){if(hi(e))throw new TypeError("Scalar values expected in function max");return o(e)}});function a(e,t){try{return i(e,t)?e:t}catch(e){throw rc(e,"max",t)}}function o(e){var t;if(di(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw rc(t,"max",e)}})),void 0===t)throw new Error("Cannot calculate max of an empty array");return"string"==typeof t&&(t=n(t,Re(t,r))),t}})),Ol=Me("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:r,numeric:n,smaller:i}=e;return t("min",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){return vi(e,t.valueOf(),a)},"...":function(e){if(hi(e))throw new TypeError("Scalar values expected in function min");return o(e)}});function a(e,t){try{return i(e,t)?e:t}catch(e){throw rc(e,"min",t)}}function o(e){var t;if(di(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw rc(t,"min",e)}})),void 0===t)throw new Error("Cannot calculate min of an empty array");return"string"==typeof t&&(t=n(t,Re(t,r))),t}})),kl=Me("ImmutableDenseMatrix",["smaller","DenseMatrix"],(e=>{var{smaller:t,DenseMatrix:r}=e;function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!z(t))throw new Error("Invalid datatype: "+t);if(q(e)||I(e)){var i=new r(e,t);this._data=i._data,this._size=i._size,this._datatype=i._datatype,this._min=null,this._max=null}else if(e&&I(e.data)&&I(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=void 0!==e.min?e.min:null,this._max=void 0!==e.max?e.max:null;else{if(e)throw new TypeError("Unsupported type of data ("+xe(e)+")");this._data=[],this._size=[0],this._datatype=t,this._min=null,this._max=null}}return n.prototype=new r,n.prototype.type="ImmutableDenseMatrix",n.prototype.isImmutableDenseMatrix=!0,n.prototype.subset=function(e){switch(arguments.length){case 1:var t=r.prototype.subset.call(this,e);return q(t)?new n({data:t._data,size:t._size,datatype:t._datatype}):t;case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},n.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},n.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},n.prototype.clone=function(){return new n({data:be(this._data),size:be(this._size),datatype:this._datatype})},n.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.fromJSON=function(e){return new n(e)},n.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},n.prototype.min=function(){if(null===this._min){var e=null;this.forEach((function(r){(null===e||t(r,e))&&(e=r)})),this._min=null!==e?e:void 0}return this._min},n.prototype.max=function(){if(null===this._max){var e=null;this.forEach((function(r){(null===e||t(e,r))&&(e=r)})),this._max=null!==e?e:void 0}return this._max},n}),{isClass:!0}),zl=Me("Index",["ImmutableDenseMatrix","getMatrixDataType"],(e=>{var{ImmutableDenseMatrix:t,getMatrixDataType:r}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._sourceSize=[],this._isScalar=!0;for(var t=0,a=arguments.length;t<a;t++){var o=arguments[t],s=I(o),u=q(o),c=null;if(U(o))this._dimensions.push(o),this._isScalar=!1;else if(s||u){var l=void 0;"boolean"===r(o)?(s&&(l=i(Il(o).valueOf())),u&&(l=i(Il(o._data).valueOf())),c=o.valueOf().length):l=i(o.valueOf()),this._dimensions.push(l);var f=l.size();1===f.length&&1===f[0]&&null===c||(this._isScalar=!1)}else if("number"==typeof o)this._dimensions.push(i([o]));else{if("string"!=typeof o)throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");this._dimensions.push(o)}this._sourceSize.push(c)}}function i(e){for(var r=0,n=e.length;r<n;r++)if("number"!=typeof e[r]||!qe(e[r]))throw new TypeError("Index parameters must be positive integer numbers");return new t(e)}return n.prototype.type="Index",n.prototype.isIndex=!0,n.prototype.clone=function(){var e=new n;return e._dimensions=be(this._dimensions),e._isScalar=this._isScalar,e._sourceSize=this._sourceSize,e},n.create=function(e){var t=new n;return n.apply(t,e),t},n.prototype.size=function(){for(var e=[],t=0,r=this._dimensions.length;t<r;t++){var n=this._dimensions[t];e[t]="string"==typeof n?1:n.size()[0]}return e},n.prototype.max=function(){for(var e=[],t=0,r=this._dimensions.length;t<r;t++){var n=this._dimensions[t];e[t]="string"==typeof n?n:n.max()}return e},n.prototype.min=function(){for(var e=[],t=0,r=this._dimensions.length;t<r;t++){var n=this._dimensions[t];e[t]="string"==typeof n?n:n.min()}return e},n.prototype.forEach=function(e){for(var t=0,r=this._dimensions.length;t<r;t++)e(this._dimensions[t],t,this)},n.prototype.dimension=function(e){return"number"!=typeof e?null:this._dimensions[e]||null},n.prototype.isObjectProperty=function(){return 1===this._dimensions.length&&"string"==typeof this._dimensions[0]},n.prototype.getObjectProperty=function(){return this.isObjectProperty()?this._dimensions[0]:null},n.prototype.isScalar=function(){return this._isScalar},n.prototype.toArray=function(){for(var e=[],t=0,r=this._dimensions.length;t<r;t++){var n=this._dimensions[t];e.push("string"==typeof n?n:n.toArray())}return e},n.prototype.valueOf=n.prototype.toArray,n.prototype.toString=function(){for(var e=[],t=0,r=this._dimensions.length;t<r;t++){var n=this._dimensions[t];"string"==typeof n?e.push(JSON.stringify(n)):e.push(n.toString())}return"["+e.join(", ")+"]"},n.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},n.fromJSON=function(e){return n.create(e.dimensions)},n}),{isClass:!0});function Il(e){var t=[];return e.forEach(((e,r)=>{e&&t.push(r)})),t}var ql=Me("FibonacciHeap",["smaller","larger"],(e=>{var{smaller:t,larger:r}=e,n=1/Math.log((1+Math.sqrt(5))/2);function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}function a(e,t,r){t.left.right=t.right,t.right.left=t.left,r.degree--,r.child===t&&(r.child=t.right),0===r.degree&&(r.child=null),t.left=e,t.right=e.right,e.right=t,t.right.left=t,t.parent=null,t.mark=!1}function o(e,t){var r=t.parent;r&&(t.mark?(a(e,t,r),o(r)):t.mark=!0)}i.prototype.type="FibonacciHeap",i.prototype.isFibonacciHeap=!0,i.prototype.insert=function(e,r){var n={key:e,value:r,degree:0};if(this._minimum){var i=this._minimum;n.left=i,n.right=i.right,i.right=n,n.right.left=n,t(e,i.key)&&(this._minimum=n)}else n.left=n,n.right=n,this._minimum=n;return this._size++,n},i.prototype.size=function(){return this._size},i.prototype.clear=function(){this._minimum=null,this._size=0},i.prototype.isEmpty=function(){return 0===this._size},i.prototype.extractMinimum=function(){var e=this._minimum;if(null===e)return e;for(var i=this._minimum,a=e.degree,o=e.child;a>0;){var u=o.right;o.left.right=o.right,o.right.left=o.left,o.left=i,o.right=i.right,i.right=o,o.right.left=o,o.parent=null,o=u,a--}return e.left.right=e.right,e.right.left=e.left,i=e===e.right?null:function(e,i){var a,o=Math.floor(Math.log(i)*n)+1,u=new Array(o),c=0,l=e;if(l)for(c++,l=l.right;l!==e;)c++,l=l.right;for(;c>0;){for(var f=l.degree,p=l.right;a=u[f];){if(r(l.key,a.key)){var m=a;a=l,l=m}s(a,l),u[f]=null,f++}u[f]=l,l=p,c--}e=null;for(var h=0;h<o;h++)(a=u[h])&&(e?(a.left.right=a.right,a.right.left=a.left,a.left=e,a.right=e.right,e.right=a,a.right.left=a,t(a.key,e.key)&&(e=a)):e=a);return e}(i=e.right,this._size),this._size--,this._minimum=i,e},i.prototype.remove=function(e){this._minimum=function(e,r,n){r.key=-1;var i=r.parent;return i&&t(r.key,i.key)&&(a(e,r,i),o(e,i)),t(r.key,e.key)&&(e=r),e}(this._minimum,e),this.extractMinimum()};var s=function(e,t){e.left.right=e.right,e.right.left=e.left,e.parent=t,t.child?(e.left=t.child,e.right=t.child.right,t.child.right=e,e.right.left=e):(t.child=e,e.right=e,e.left=e),t.degree++,e.mark=!1};return i}),{isClass:!0}),Rl=Me("Spa",["addScalar","equalScalar","FibonacciHeap"],(e=>{var{addScalar:t,equalScalar:r,FibonacciHeap:n}=e;function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new n}return i.prototype.type="Spa",i.prototype.isSpa=!0,i.prototype.set=function(e,t){if(this._values[e])this._values[e].value=t;else{var r=this._heap.insert(e,t);this._values[e]=r}},i.prototype.get=function(e){var t=this._values[e];return t?t.value:0},i.prototype.accumulate=function(e,r){var n=this._values[e];n?n.value=t(n.value,r):(n=this._heap.insert(e,r),this._values[e]=n)},i.prototype.forEach=function(e,t,n){var i=this._heap,a=this._values,o=[],s=i.extractMinimum();for(s&&o.push(s);s&&s.key<=t;)s.key>=e&&(r(s.value,0)||n(s.key,s.value,this)),(s=i.extractMinimum())&&o.push(s);for(var u=0;u<o.length;u++){var c=o[u];a[(s=i.insert(c.key,c.value)).key]=s}},i.prototype.swap=function(e,t){var r=this._values[e],n=this._values[t];if(!r&&n)r=this._heap.insert(e,n.value),this._heap.remove(n),this._values[e]=r,this._values[t]=void 0;else if(r&&!n)n=this._heap.insert(t,r.value),this._heap.remove(r),this._values[t]=n,this._values[e]=void 0;else if(r&&n){var i=r.value;r.value=n.value,n.value=i}},i}),{isClass:!0});function Pl(e){var t=0,r=1,n=Object.create(null),i=Object.create(null),a=0,o=function(e){var o=i[e];if(o&&(delete n[o],delete i[e],--t,r===o)){if(!t)return a=0,void(r=1);for(;!Object.prototype.hasOwnProperty.call(n,++r););}};return e=Math.abs(e),{hit:function(s){var u=i[s],c=++a;if(n[c]=s,i[s]=c,!u){if(++t<=e)return;return s=n[r],o(s),s}if(delete n[u],r===u)for(;!Object.prototype.hasOwnProperty.call(n,++r););},delete:o,clear:function(){t=a=0,r=1,n=Object.create(null),i=Object.create(null)}}}function jl(e){var{hasher:t,limit:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r=null==r?Number.POSITIVE_INFINITY:r,t=null==t?JSON.stringify:t,function n(){"object"!=typeof n.cache&&(n.cache={values:new Map,lru:Pl(r||Number.POSITIVE_INFINITY)});for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];var o=t(i);if(n.cache.values.has(o))return n.cache.lru.hit(o),n.cache.values.get(o);var s=e.apply(e,i);return n.cache.values.set(o,s),n.cache.values.delete(n.cache.lru.hit(o)),s}}var Ul=jl((function(e){return new e(1).exp()}),{hasher:Gl}),Ll=jl((function(e){return new e(1).plus(new e(5).sqrt()).div(2)}),{hasher:Gl}),Hl=jl((function(e){return e.acos(-1)}),{hasher:Gl}),$l=jl((function(e){return Hl(e).times(2)}),{hasher:Gl});function Gl(e){return e[0].precision}function Wl(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Vl(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Wl(Object(r),!0).forEach((function(t){Hu(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Wl(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Zl=Me("Unit",["?on","config","addScalar","subtractScalar","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","number","Complex","BigNumber","Fraction"],(e=>{var t,r,n,{on:i,config:a,addScalar:o,subtractScalar:s,multiplyScalar:u,divideScalar:c,pow:l,abs:f,fix:p,round:h,equal:d,isNumeric:g,format:v,number:y,Complex:x,BigNumber:b,Fraction:w}=e,D=y;function N(e,t){if(!(this instanceof N))throw new Error("Constructor must be called with the new operator");if(null!=e&&!g(e)&&!B(e))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(this.fixPrefix=!1,this.skipAutomaticSimplification=!0,void 0===t)this.units=[],this.dimensions=I.map((e=>0));else if("string"==typeof t){var r=N.parse(t);this.units=r.units,this.dimensions=r.dimensions}else{if(!k(t)||null!==t.value)throw new TypeError("Second parameter in Unit constructor must be a string or valueless Unit");this.fixPrefix=t.fixPrefix,this.skipAutomaticSimplification=t.skipAutomaticSimplification,this.dimensions=t.dimensions.slice(0),this.units=t.units.map((e=>m({},e)))}this.value=this._normalize(e)}function E(){for(;" "===n||"\t"===n;)S()}function A(e){return e>="0"&&e<="9"}function S(){r++,n=t.charAt(r)}function C(e){r=e,n=t.charAt(r)}function M(){var e="",t=r;if("+"===n?S():"-"===n&&(e+=n,S()),!function(e){return e>="0"&&e<="9"||"."===e}(n))return C(t),null;if("."===n){if(e+=n,S(),!A(n))return C(t),null}else{for(;A(n);)e+=n,S();"."===n&&(e+=n,S())}for(;A(n);)e+=n,S();if("E"===n||"e"===n){var i="",a=r;if(i+=n,S(),"+"!==n&&"-"!==n||(i+=n,S()),!A(n))return C(a),e;for(e+=i;A(n);)e+=n,S()}return e}function F(){for(var e="";A(n)||N.isValidAlpha(n);)e+=n,S();var t=e.charAt(0);return N.isValidAlpha(t)?e:null}function T(e){return n===e?(S(),e):null}Object.defineProperty(N,"name",{value:"Unit"}),N.prototype.constructor=N,N.prototype.type="Unit",N.prototype.isUnit=!0,N.parse=function(e,i){if(i=i||{},r=-1,n="","string"!=typeof(t=e))throw new TypeError("Invalid argument in Unit.parse, string expected");var o=new N;o.units=[];var s=1,u=!1;S(),E();var c=M(),l=null;if(c){if("BigNumber"===a.number)l=new b(c);else if("Fraction"===a.number)try{l=new w(c)}catch(e){l=parseFloat(c)}else l=parseFloat(c);E(),T("*")?(s=1,u=!0):T("/")&&(s=-1,u=!0)}for(var f=[],p=1;;){for(E();"("===n;)f.push(s),p*=s,s=1,S(),E();var m;if(!n)break;var h=n;if(null===(m=F()))throw new SyntaxError('Unexpected "'+h+'" in "'+t+'" at index '+r.toString());var d=_(m);if(null===d)throw new SyntaxError('Unit "'+m+'" not found.');var g=s*p;if(E(),T("^")){E();var v=M();if(null===v)throw new SyntaxError('In "'+e+'", "^" must be followed by a floating-point number');g*=v}o.units.push({unit:d.unit,prefix:d.prefix,power:g});for(var y=0;y<I.length;y++)o.dimensions[y]+=(d.unit.dimensions[y]||0)*g;for(E();")"===n;){if(0===f.length)throw new SyntaxError('Unmatched ")" in "'+t+'" at index '+r.toString());p/=f.pop(),S(),E()}if(u=!1,T("*")?(s=1,u=!0):T("/")?(s=-1,u=!0):s=1,d.unit.base){var x=d.unit.base.key;H.auto[x]={unit:d.unit,prefix:d.prefix}}}if(E(),n)throw new SyntaxError('Could not parse: "'+e+'"');if(u)throw new SyntaxError('Trailing characters: "'+e+'"');if(0!==f.length)throw new SyntaxError('Unmatched "(" in "'+t+'"');if(0===o.units.length&&!i.allowNoUnits)throw new SyntaxError('"'+e+'" contains no units');return o.value=void 0!==l?o._normalize(l):null,o},N.prototype.clone=function(){var e=new N;e.fixPrefix=this.fixPrefix,e.skipAutomaticSimplification=this.skipAutomaticSimplification,e.value=be(this.value),e.dimensions=this.dimensions.slice(0),e.units=[];for(var t=0;t<this.units.length;t++)for(var r in e.units[t]={},this.units[t])Ce(this.units[t],r)&&(e.units[t][r]=this.units[t][r]);return e},N.prototype.valueType=function(){return xe(this.value)},N.prototype._isDerived=function(){return 0!==this.units.length&&(this.units.length>1||Math.abs(this.units[0].power-1)>1e-15)},N.prototype._normalize=function(e){if(null==e||0===this.units.length)return e;for(var t=e,r=N._getNumberConverter(xe(e)),n=0;n<this.units.length;n++){var i=r(this.units[n].unit.value),a=r(this.units[n].prefix.value),o=r(this.units[n].power);t=u(t,l(u(i,a),o))}return t},N.prototype._denormalize=function(e,t){if(null==e||0===this.units.length)return e;for(var r=e,n=N._getNumberConverter(xe(e)),i=0;i<this.units.length;i++){var a=n(this.units[i].unit.value),o=n(this.units[i].prefix.value),s=n(this.units[i].power);r=c(r,l(u(a,o),s))}return r};var _=jl((e=>{if(Ce(j,e)){var t=j[e];return{unit:t,prefix:t.prefixes[""]}}for(var r in j)if(Ce(j,r)&&An(e,r)){var n=j[r],i=e.length-r.length,a=e.substring(0,i),o=Ce(n.prefixes,a)?n.prefixes[a]:void 0;if(void 0!==o)return{unit:n,prefix:o}}return null}),{hasher:e=>e[0],limit:100});function O(e){return e.equalBase(q.NONE)&&null!==e.value&&!a.predictable?e.value:e}N.isValuelessUnit=function(e){return null!==_(e)},N.prototype.hasBase=function(e){if("string"==typeof e&&(e=q[e]),!e)return!1;for(var t=0;t<I.length;t++)if(Math.abs((this.dimensions[t]||0)-(e.dimensions[t]||0))>1e-12)return!1;return!0},N.prototype.equalBase=function(e){for(var t=0;t<I.length;t++)if(Math.abs((this.dimensions[t]||0)-(e.dimensions[t]||0))>1e-12)return!1;return!0},N.prototype.equals=function(e){return this.equalBase(e)&&d(this.value,e.value)},N.prototype.multiply=function(e){for(var t=this.clone(),r=k(e)?e:new N(e),n=0;n<I.length;n++)t.dimensions[n]=(this.dimensions[n]||0)+(r.dimensions[n]||0);for(var i=0;i<r.units.length;i++){var a=Vl({},r.units[i]);t.units.push(a)}if(null!==this.value||null!==r.value){var o=null===this.value?this._normalize(1):this.value,s=null===r.value?r._normalize(1):r.value;t.value=u(o,s)}else t.value=null;return k(e)&&(t.skipAutomaticSimplification=!1),O(t)},N.prototype.divideInto=function(e){return new N(e).divide(this)},N.prototype.divide=function(e){for(var t=this.clone(),r=k(e)?e:new N(e),n=0;n<I.length;n++)t.dimensions[n]=(this.dimensions[n]||0)-(r.dimensions[n]||0);for(var i=0;i<r.units.length;i++){var a=Vl(Vl({},r.units[i]),{},{power:-r.units[i].power});t.units.push(a)}if(null!==this.value||null!==r.value){var o=null===this.value?this._normalize(1):this.value,s=null===r.value?r._normalize(1):r.value;t.value=c(o,s)}else t.value=null;return k(e)&&(t.skipAutomaticSimplification=!1),O(t)},N.prototype.pow=function(e){for(var t=this.clone(),r=0;r<I.length;r++)t.dimensions[r]=(this.dimensions[r]||0)*e;for(var n=0;n<t.units.length;n++)t.units[n].power*=e;return null!==t.value?t.value=l(t.value,e):t.value=null,t.skipAutomaticSimplification=!1,O(t)},N.prototype.abs=function(){var e=this.clone();if(null!==e.value)if(e._isDerived()||0===e.units.length||0===e.units[0].unit.offset)e.value=f(e.value);else{var t=e._numberConverter(),r=t(e.units[0].unit.value),n=t(e.units[0].unit.offset),i=u(r,n);e.value=s(f(o(e.value,i)),i)}for(var a in e.units)"VA"!==e.units[a].unit.name&&"VAR"!==e.units[a].unit.name||(e.units[a].unit=j.W);return e},N.prototype.to=function(e){var t,r=null===this.value?this._normalize(1):this.value;if("string"==typeof e)t=N.parse(e);else{if(!k(e))throw new Error("String or Unit expected as parameter");t=e.clone()}if(!this.equalBase(t))throw new Error("Units do not match ('".concat(t.toString(),"' != '").concat(this.toString(),"')"));if(null!==t.value)throw new Error("Cannot convert to a unit with a value");if(null===this.value||this._isDerived()||0===this.units.length||0===t.units.length||this.units[0].unit.offset===t.units[0].unit.offset)t.value=be(r);else{var n=N._getNumberConverter(xe(r)),i=this.units[0].unit.value,a=this.units[0].unit.offset,c=u(i,a),l=t.units[0].unit.value,f=t.units[0].unit.offset,p=u(l,f);t.value=o(r,n(s(c,p)))}return t.fixPrefix=!0,t.skipAutomaticSimplification=!0,t},N.prototype.toNumber=function(e){return D(this.toNumeric(e))},N.prototype.toNumeric=function(e){var t;return(t=e?this.to(e):this.clone())._isDerived()||0===t.units.length?t._denormalize(t.value):t._denormalize(t.value,t.units[0].prefix.value)},N.prototype.toString=function(){return this.format()},N.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.units.length>0?this.formatUnits():null,fixPrefix:this.fixPrefix}},N.fromJSON=function(e){var t,r=new N(e.value,null!==(t=e.unit)&&void 0!==t?t:void 0);return r.fixPrefix=e.fixPrefix||!1,r},N.prototype.valueOf=N.prototype.toString,N.prototype.simplify=function(){var e,t,r=this.clone(),n=[];for(var i in $)if(Ce($,i)&&r.hasBase(q[i])){e=i;break}if("NONE"===e)r.units=[];else if(e&&Ce($,e)&&(t=$[e]),t)r.units=[{unit:t.unit,prefix:t.prefix,power:1}];else{for(var a=!1,o=0;o<I.length;o++){var s=I[o];Math.abs(r.dimensions[o]||0)>1e-12&&(Ce($,s)?n.push({unit:$[s].unit,prefix:$[s].prefix,power:r.dimensions[o]||0}):a=!0)}n.length<r.units.length&&!a&&(r.units=n)}return r},N.prototype.toSI=function(){for(var e=this.clone(),t=[],r=0;r<I.length;r++){var n=I[r];if(Math.abs(e.dimensions[r]||0)>1e-12){if(!Ce(H.si,n))throw new Error("Cannot express custom unit "+n+" in SI units");t.push({unit:H.si[n].unit,prefix:H.si[n].prefix,power:e.dimensions[r]||0})}}return e.units=t,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,null!==this.value?(e.value=null,this.to(e)):e},N.prototype.formatUnits=function(){for(var e="",t="",r=0,n=0,i=0;i<this.units.length;i++)this.units[i].power>0?(r++,e+=" "+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power-1)>1e-15&&(e+="^"+this.units[i].power)):this.units[i].power<0&&n++;if(n>0)for(var a=0;a<this.units.length;a++)this.units[a].power<0&&(r>0?(t+=" "+this.units[a].prefix.name+this.units[a].unit.name,Math.abs(this.units[a].power+1)>1e-15&&(t+="^"+-this.units[a].power)):(t+=" "+this.units[a].prefix.name+this.units[a].unit.name,t+="^"+this.units[a].power));e=e.substr(1),t=t.substr(1),r>1&&n>0&&(e="("+e+")"),n>1&&r>0&&(t="("+t+")");var o=e;return r>0&&n>0&&(o+=" / "),o+t},N.prototype.format=function(e){var t=this.skipAutomaticSimplification||null===this.value?this.clone():this.simplify(),r=!1;for(var n in void 0!==t.value&&null!==t.value&&B(t.value)&&(r=Math.abs(t.value.re)<1e-14),t.units)Ce(t.units,n)&&t.units[n].unit&&("VA"===t.units[n].unit.name&&r?t.units[n].unit=j.VAR:"VAR"!==t.units[n].unit.name||r||(t.units[n].unit=j.VA));1!==t.units.length||t.fixPrefix||Math.abs(t.units[0].power-Math.round(t.units[0].power))<1e-14&&(t.units[0].prefix=t._bestPrefix());var i=t._denormalize(t.value),a=null!==t.value?v(i,e||{}):"",o=t.formatUnits();return t.value&&B(t.value)&&(a="("+a+")"),o.length>0&&a.length>0&&(a+=" "),a+o},N.prototype._bestPrefix=function(){if(1!==this.units.length)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var e=null!==this.value?f(this.value):0,t=f(this.units[0].unit.value),r=this.units[0].prefix;if(0===e)return r;var n=this.units[0].power,i=Math.log(e/Math.pow(r.value*t,n))/Math.LN10-1.2;if(i>-2.200001&&i<1.800001)return r;i=Math.abs(i);var a=this.units[0].unit.prefixes;for(var o in a)if(Ce(a,o)){var s=a[o];if(s.scientific){var u=Math.abs(Math.log(e/Math.pow(s.value*t,n))/Math.LN10-1.2);(u<i||u===i&&s.name.length<r.name.length)&&(r=s,i=u)}}return r},N.prototype.splitUnit=function(e){for(var t=this.clone(),r=[],n=0;n<e.length&&(t=t.to(e[n]),n!==e.length-1);n++){var i=t.toNumeric(),a=h(i),u=new N(d(a,i)?a:p(t.toNumeric()),e[n].toString());r.push(u),t=s(t,u)}for(var c=0,l=0;l<r.length;l++)c=o(c,r[l].value);return d(c,this.value)&&(t.value=0),r.push(t),r};var z={NONE:{"":{name:"",value:1,scientific:!0}},SHORT:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:10,scientific:!1},h:{name:"h",value:100,scientific:!1},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0},R:{name:"R",value:1e27,scientific:!0},Q:{name:"Q",value:1e30,scientific:!0},d:{name:"d",value:.1,scientific:!1},c:{name:"c",value:.01,scientific:!1},m:{name:"m",value:.001,scientific:!0},u:{name:"u",value:1e-6,scientific:!0},n:{name:"n",value:1e-9,scientific:!0},p:{name:"p",value:1e-12,scientific:!0},f:{name:"f",value:1e-15,scientific:!0},a:{name:"a",value:1e-18,scientific:!0},z:{name:"z",value:1e-21,scientific:!0},y:{name:"y",value:1e-24,scientific:!0},r:{name:"r",value:1e-27,scientific:!0},q:{name:"q",value:1e-30,scientific:!0}},LONG:{"":{name:"",value:1,scientific:!0},deca:{name:"deca",value:10,scientific:!1},hecto:{name:"hecto",value:100,scientific:!1},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0},ronna:{name:"ronna",value:1e27,scientific:!0},quetta:{name:"quetta",value:1e30,scientific:!0},deci:{name:"deci",value:.1,scientific:!1},centi:{name:"centi",value:.01,scientific:!1},milli:{name:"milli",value:.001,scientific:!0},micro:{name:"micro",value:1e-6,scientific:!0},nano:{name:"nano",value:1e-9,scientific:!0},pico:{name:"pico",value:1e-12,scientific:!0},femto:{name:"femto",value:1e-15,scientific:!0},atto:{name:"atto",value:1e-18,scientific:!0},zepto:{name:"zepto",value:1e-21,scientific:!0},yocto:{name:"yocto",value:1e-24,scientific:!0},ronto:{name:"ronto",value:1e-27,scientific:!0},quecto:{name:"quecto",value:1e-30,scientific:!0}},SQUARED:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:100,scientific:!1},h:{name:"h",value:1e4,scientific:!1},k:{name:"k",value:1e6,scientific:!0},M:{name:"M",value:1e12,scientific:!0},G:{name:"G",value:1e18,scientific:!0},T:{name:"T",value:1e24,scientific:!0},P:{name:"P",value:1e30,scientific:!0},E:{name:"E",value:1e36,scientific:!0},Z:{name:"Z",value:1e42,scientific:!0},Y:{name:"Y",value:1e48,scientific:!0},R:{name:"R",value:1e54,scientific:!0},Q:{name:"Q",value:1e60,scientific:!0},d:{name:"d",value:.01,scientific:!1},c:{name:"c",value:1e-4,scientific:!1},m:{name:"m",value:1e-6,scientific:!0},u:{name:"u",value:1e-12,scientific:!0},n:{name:"n",value:1e-18,scientific:!0},p:{name:"p",value:1e-24,scientific:!0},f:{name:"f",value:1e-30,scientific:!0},a:{name:"a",value:1e-36,scientific:!0},z:{name:"z",value:1e-42,scientific:!0},y:{name:"y",value:1e-48,scientific:!0},r:{name:"r",value:1e-54,scientific:!0},q:{name:"q",value:1e-60,scientific:!0}},CUBIC:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:1e3,scientific:!1},h:{name:"h",value:1e6,scientific:!1},k:{name:"k",value:1e9,scientific:!0},M:{name:"M",value:1e18,scientific:!0},G:{name:"G",value:1e27,scientific:!0},T:{name:"T",value:1e36,scientific:!0},P:{name:"P",value:1e45,scientific:!0},E:{name:"E",value:1e54,scientific:!0},Z:{name:"Z",value:1e63,scientific:!0},Y:{name:"Y",value:1e72,scientific:!0},R:{name:"R",value:1e81,scientific:!0},Q:{name:"Q",value:1e90,scientific:!0},d:{name:"d",value:.001,scientific:!1},c:{name:"c",value:1e-6,scientific:!1},m:{name:"m",value:1e-9,scientific:!0},u:{name:"u",value:1e-18,scientific:!0},n:{name:"n",value:1e-27,scientific:!0},p:{name:"p",value:1e-36,scientific:!0},f:{name:"f",value:1e-45,scientific:!0},a:{name:"a",value:1e-54,scientific:!0},z:{name:"z",value:1e-63,scientific:!0},y:{name:"y",value:1e-72,scientific:!0},r:{name:"r",value:1e-81,scientific:!0},q:{name:"q",value:1e-90,scientific:!0}},BINARY_SHORT_SI:{"":{name:"",value:1,scientific:!0},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0}},BINARY_SHORT_IEC:{"":{name:"",value:1,scientific:!0},Ki:{name:"Ki",value:1024,scientific:!0},Mi:{name:"Mi",value:Math.pow(1024,2),scientific:!0},Gi:{name:"Gi",value:Math.pow(1024,3),scientific:!0},Ti:{name:"Ti",value:Math.pow(1024,4),scientific:!0},Pi:{name:"Pi",value:Math.pow(1024,5),scientific:!0},Ei:{name:"Ei",value:Math.pow(1024,6),scientific:!0},Zi:{name:"Zi",value:Math.pow(1024,7),scientific:!0},Yi:{name:"Yi",value:Math.pow(1024,8),scientific:!0}},BINARY_LONG_SI:{"":{name:"",value:1,scientific:!0},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0}},BINARY_LONG_IEC:{"":{name:"",value:1,scientific:!0},kibi:{name:"kibi",value:1024,scientific:!0},mebi:{name:"mebi",value:Math.pow(1024,2),scientific:!0},gibi:{name:"gibi",value:Math.pow(1024,3),scientific:!0},tebi:{name:"tebi",value:Math.pow(1024,4),scientific:!0},pebi:{name:"pebi",value:Math.pow(1024,5),scientific:!0},exi:{name:"exi",value:Math.pow(1024,6),scientific:!0},zebi:{name:"zebi",value:Math.pow(1024,7),scientific:!0},yobi:{name:"yobi",value:Math.pow(1024,8),scientific:!0}},BTU:{"":{name:"",value:1,scientific:!0},MM:{name:"MM",value:1e6,scientific:!0}}};z.SHORTLONG=m({},z.SHORT,z.LONG),z.BINARY_SHORT=m({},z.BINARY_SHORT_SI,z.BINARY_SHORT_IEC),z.BINARY_LONG=m({},z.BINARY_LONG_SI,z.BINARY_LONG_IEC);var I=["MASS","LENGTH","TIME","CURRENT","TEMPERATURE","LUMINOUS_INTENSITY","AMOUNT_OF_SUBSTANCE","ANGLE","BIT"],q={NONE:{dimensions:[0,0,0,0,0,0,0,0,0]},MASS:{dimensions:[1,0,0,0,0,0,0,0,0]},LENGTH:{dimensions:[0,1,0,0,0,0,0,0,0]},TIME:{dimensions:[0,0,1,0,0,0,0,0,0]},CURRENT:{dimensions:[0,0,0,1,0,0,0,0,0]},TEMPERATURE:{dimensions:[0,0,0,0,1,0,0,0,0]},LUMINOUS_INTENSITY:{dimensions:[0,0,0,0,0,1,0,0,0]},AMOUNT_OF_SUBSTANCE:{dimensions:[0,0,0,0,0,0,1,0,0]},FORCE:{dimensions:[1,1,-2,0,0,0,0,0,0]},SURFACE:{dimensions:[0,2,0,0,0,0,0,0,0]},VOLUME:{dimensions:[0,3,0,0,0,0,0,0,0]},ENERGY:{dimensions:[1,2,-2,0,0,0,0,0,0]},POWER:{dimensions:[1,2,-3,0,0,0,0,0,0]},PRESSURE:{dimensions:[1,-1,-2,0,0,0,0,0,0]},ELECTRIC_CHARGE:{dimensions:[0,0,1,1,0,0,0,0,0]},ELECTRIC_CAPACITANCE:{dimensions:[-1,-2,4,2,0,0,0,0,0]},ELECTRIC_POTENTIAL:{dimensions:[1,2,-3,-1,0,0,0,0,0]},ELECTRIC_RESISTANCE:{dimensions:[1,2,-3,-2,0,0,0,0,0]},ELECTRIC_INDUCTANCE:{dimensions:[1,2,-2,-2,0,0,0,0,0]},ELECTRIC_CONDUCTANCE:{dimensions:[-1,-2,3,2,0,0,0,0,0]},MAGNETIC_FLUX:{dimensions:[1,2,-2,-1,0,0,0,0,0]},MAGNETIC_FLUX_DENSITY:{dimensions:[1,0,-2,-1,0,0,0,0,0]},FREQUENCY:{dimensions:[0,0,-1,0,0,0,0,0,0]},ANGLE:{dimensions:[0,0,0,0,0,0,0,1,0]},BIT:{dimensions:[0,0,0,0,0,0,0,0,1]}};for(var R in q)Ce(q,R)&&(q[R].key=R);var P={name:"",base:{},value:1,offset:0,dimensions:I.map((e=>0))},j={meter:{name:"meter",base:q.LENGTH,prefixes:z.LONG,value:1,offset:0},inch:{name:"inch",base:q.LENGTH,prefixes:z.NONE,value:.0254,offset:0},foot:{name:"foot",base:q.LENGTH,prefixes:z.NONE,value:.3048,offset:0},yard:{name:"yard",base:q.LENGTH,prefixes:z.NONE,value:.9144,offset:0},mile:{name:"mile",base:q.LENGTH,prefixes:z.NONE,value:1609.344,offset:0},link:{name:"link",base:q.LENGTH,prefixes:z.NONE,value:.201168,offset:0},rod:{name:"rod",base:q.LENGTH,prefixes:z.NONE,value:5.0292,offset:0},chain:{name:"chain",base:q.LENGTH,prefixes:z.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:q.LENGTH,prefixes:z.NONE,value:1e-10,offset:0},m:{name:"m",base:q.LENGTH,prefixes:z.SHORT,value:1,offset:0},in:{name:"in",base:q.LENGTH,prefixes:z.NONE,value:.0254,offset:0},ft:{name:"ft",base:q.LENGTH,prefixes:z.NONE,value:.3048,offset:0},yd:{name:"yd",base:q.LENGTH,prefixes:z.NONE,value:.9144,offset:0},mi:{name:"mi",base:q.LENGTH,prefixes:z.NONE,value:1609.344,offset:0},li:{name:"li",base:q.LENGTH,prefixes:z.NONE,value:.201168,offset:0},rd:{name:"rd",base:q.LENGTH,prefixes:z.NONE,value:5.02921,offset:0},ch:{name:"ch",base:q.LENGTH,prefixes:z.NONE,value:20.1168,offset:0},mil:{name:"mil",base:q.LENGTH,prefixes:z.NONE,value:254e-7,offset:0},m2:{name:"m2",base:q.SURFACE,prefixes:z.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:q.SURFACE,prefixes:z.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:q.SURFACE,prefixes:z.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:q.SURFACE,prefixes:z.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:q.SURFACE,prefixes:z.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:q.SURFACE,prefixes:z.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:q.SURFACE,prefixes:z.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:q.SURFACE,prefixes:z.NONE,value:6.4516e-10,offset:0},acre:{name:"acre",base:q.SURFACE,prefixes:z.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:q.SURFACE,prefixes:z.NONE,value:1e4,offset:0},m3:{name:"m3",base:q.VOLUME,prefixes:z.CUBIC,value:1,offset:0},L:{name:"L",base:q.VOLUME,prefixes:z.SHORT,value:.001,offset:0},l:{name:"l",base:q.VOLUME,prefixes:z.SHORT,value:.001,offset:0},litre:{name:"litre",base:q.VOLUME,prefixes:z.LONG,value:.001,offset:0},cuin:{name:"cuin",base:q.VOLUME,prefixes:z.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:q.VOLUME,prefixes:z.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:q.VOLUME,prefixes:z.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:q.VOLUME,prefixes:z.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:q.VOLUME,prefixes:z.NONE,value:15e-6,offset:0},drop:{name:"drop",base:q.VOLUME,prefixes:z.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:q.VOLUME,prefixes:z.NONE,value:5e-8,offset:0},minim:{name:"minim",base:q.VOLUME,prefixes:z.NONE,value:6.1611519921875e-8,offset:0},fluiddram:{name:"fluiddram",base:q.VOLUME,prefixes:z.NONE,value:36966911953125e-19,offset:0},fluidounce:{name:"fluidounce",base:q.VOLUME,prefixes:z.NONE,value:295735295625e-16,offset:0},gill:{name:"gill",base:q.VOLUME,prefixes:z.NONE,value:.00011829411825,offset:0},cc:{name:"cc",base:q.VOLUME,prefixes:z.NONE,value:1e-6,offset:0},cup:{name:"cup",base:q.VOLUME,prefixes:z.NONE,value:.0002365882365,offset:0},pint:{name:"pint",base:q.VOLUME,prefixes:z.NONE,value:.000473176473,offset:0},quart:{name:"quart",base:q.VOLUME,prefixes:z.NONE,value:.000946352946,offset:0},gallon:{name:"gallon",base:q.VOLUME,prefixes:z.NONE,value:.003785411784,offset:0},beerbarrel:{name:"beerbarrel",base:q.VOLUME,prefixes:z.NONE,value:.117347765304,offset:0},oilbarrel:{name:"oilbarrel",base:q.VOLUME,prefixes:z.NONE,value:.158987294928,offset:0},hogshead:{name:"hogshead",base:q.VOLUME,prefixes:z.NONE,value:.238480942392,offset:0},g:{name:"g",base:q.MASS,prefixes:z.SHORT,value:.001,offset:0},gram:{name:"gram",base:q.MASS,prefixes:z.LONG,value:.001,offset:0},ton:{name:"ton",base:q.MASS,prefixes:z.SHORT,value:907.18474,offset:0},t:{name:"t",base:q.MASS,prefixes:z.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:q.MASS,prefixes:z.LONG,value:1e3,offset:0},grain:{name:"grain",base:q.MASS,prefixes:z.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:q.MASS,prefixes:z.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:q.MASS,prefixes:z.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:q.MASS,prefixes:z.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:q.MASS,prefixes:z.NONE,value:45.359237,offset:0},stick:{name:"stick",base:q.MASS,prefixes:z.NONE,value:.115,offset:0},stone:{name:"stone",base:q.MASS,prefixes:z.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:q.MASS,prefixes:z.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:q.MASS,prefixes:z.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:q.MASS,prefixes:z.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:q.MASS,prefixes:z.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:q.MASS,prefixes:z.NONE,value:45.359237,offset:0},s:{name:"s",base:q.TIME,prefixes:z.SHORT,value:1,offset:0},min:{name:"min",base:q.TIME,prefixes:z.NONE,value:60,offset:0},h:{name:"h",base:q.TIME,prefixes:z.NONE,value:3600,offset:0},second:{name:"second",base:q.TIME,prefixes:z.LONG,value:1,offset:0},sec:{name:"sec",base:q.TIME,prefixes:z.LONG,value:1,offset:0},minute:{name:"minute",base:q.TIME,prefixes:z.NONE,value:60,offset:0},hour:{name:"hour",base:q.TIME,prefixes:z.NONE,value:3600,offset:0},day:{name:"day",base:q.TIME,prefixes:z.NONE,value:86400,offset:0},week:{name:"week",base:q.TIME,prefixes:z.NONE,value:604800,offset:0},month:{name:"month",base:q.TIME,prefixes:z.NONE,value:2629800,offset:0},year:{name:"year",base:q.TIME,prefixes:z.NONE,value:31557600,offset:0},decade:{name:"decade",base:q.TIME,prefixes:z.NONE,value:315576e3,offset:0},century:{name:"century",base:q.TIME,prefixes:z.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:q.TIME,prefixes:z.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:q.FREQUENCY,prefixes:z.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:q.FREQUENCY,prefixes:z.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:q.ANGLE,prefixes:z.SHORT,value:1,offset:0},radian:{name:"radian",base:q.ANGLE,prefixes:z.LONG,value:1,offset:0},deg:{name:"deg",base:q.ANGLE,prefixes:z.SHORT,value:null,offset:0},degree:{name:"degree",base:q.ANGLE,prefixes:z.LONG,value:null,offset:0},grad:{name:"grad",base:q.ANGLE,prefixes:z.SHORT,value:null,offset:0},gradian:{name:"gradian",base:q.ANGLE,prefixes:z.LONG,value:null,offset:0},cycle:{name:"cycle",base:q.ANGLE,prefixes:z.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:q.ANGLE,prefixes:z.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:q.ANGLE,prefixes:z.NONE,value:null,offset:0},A:{name:"A",base:q.CURRENT,prefixes:z.SHORT,value:1,offset:0},ampere:{name:"ampere",base:q.CURRENT,prefixes:z.LONG,value:1,offset:0},K:{name:"K",base:q.TEMPERATURE,prefixes:z.SHORT,value:1,offset:0},degC:{name:"degC",base:q.TEMPERATURE,prefixes:z.SHORT,value:1,offset:273.15},degF:{name:"degF",base:q.TEMPERATURE,prefixes:z.SHORT,value:new w(5,9),offset:459.67},degR:{name:"degR",base:q.TEMPERATURE,prefixes:z.SHORT,value:new w(5,9),offset:0},kelvin:{name:"kelvin",base:q.TEMPERATURE,prefixes:z.LONG,value:1,offset:0},celsius:{name:"celsius",base:q.TEMPERATURE,prefixes:z.LONG,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:q.TEMPERATURE,prefixes:z.LONG,value:new w(5,9),offset:459.67},rankine:{name:"rankine",base:q.TEMPERATURE,prefixes:z.LONG,value:new w(5,9),offset:0},mol:{name:"mol",base:q.AMOUNT_OF_SUBSTANCE,prefixes:z.SHORT,value:1,offset:0},mole:{name:"mole",base:q.AMOUNT_OF_SUBSTANCE,prefixes:z.LONG,value:1,offset:0},cd:{name:"cd",base:q.LUMINOUS_INTENSITY,prefixes:z.SHORT,value:1,offset:0},candela:{name:"candela",base:q.LUMINOUS_INTENSITY,prefixes:z.LONG,value:1,offset:0},N:{name:"N",base:q.FORCE,prefixes:z.SHORT,value:1,offset:0},newton:{name:"newton",base:q.FORCE,prefixes:z.LONG,value:1,offset:0},dyn:{name:"dyn",base:q.FORCE,prefixes:z.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:q.FORCE,prefixes:z.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:q.FORCE,prefixes:z.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:q.FORCE,prefixes:z.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:q.FORCE,prefixes:z.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:q.FORCE,prefixes:z.NONE,value:9.80665,offset:0},J:{name:"J",base:q.ENERGY,prefixes:z.SHORT,value:1,offset:0},joule:{name:"joule",base:q.ENERGY,prefixes:z.LONG,value:1,offset:0},erg:{name:"erg",base:q.ENERGY,prefixes:z.SHORTLONG,value:1e-7,offset:0},Wh:{name:"Wh",base:q.ENERGY,prefixes:z.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:q.ENERGY,prefixes:z.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:q.ENERGY,prefixes:z.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:q.ENERGY,prefixes:z.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:q.POWER,prefixes:z.SHORT,value:1,offset:0},watt:{name:"watt",base:q.POWER,prefixes:z.LONG,value:1,offset:0},hp:{name:"hp",base:q.POWER,prefixes:z.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:q.POWER,prefixes:z.SHORT,value:x.I,offset:0},VA:{name:"VA",base:q.POWER,prefixes:z.SHORT,value:1,offset:0},Pa:{name:"Pa",base:q.PRESSURE,prefixes:z.SHORT,value:1,offset:0},psi:{name:"psi",base:q.PRESSURE,prefixes:z.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:q.PRESSURE,prefixes:z.NONE,value:101325,offset:0},bar:{name:"bar",base:q.PRESSURE,prefixes:z.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:q.PRESSURE,prefixes:z.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:q.PRESSURE,prefixes:z.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:q.PRESSURE,prefixes:z.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:q.PRESSURE,prefixes:z.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:q.ELECTRIC_CHARGE,prefixes:z.LONG,value:1,offset:0},C:{name:"C",base:q.ELECTRIC_CHARGE,prefixes:z.SHORT,value:1,offset:0},farad:{name:"farad",base:q.ELECTRIC_CAPACITANCE,prefixes:z.LONG,value:1,offset:0},F:{name:"F",base:q.ELECTRIC_CAPACITANCE,prefixes:z.SHORT,value:1,offset:0},volt:{name:"volt",base:q.ELECTRIC_POTENTIAL,prefixes:z.LONG,value:1,offset:0},V:{name:"V",base:q.ELECTRIC_POTENTIAL,prefixes:z.SHORT,value:1,offset:0},ohm:{name:"ohm",base:q.ELECTRIC_RESISTANCE,prefixes:z.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:q.ELECTRIC_INDUCTANCE,prefixes:z.LONG,value:1,offset:0},H:{name:"H",base:q.ELECTRIC_INDUCTANCE,prefixes:z.SHORT,value:1,offset:0},siemens:{name:"siemens",base:q.ELECTRIC_CONDUCTANCE,prefixes:z.LONG,value:1,offset:0},S:{name:"S",base:q.ELECTRIC_CONDUCTANCE,prefixes:z.SHORT,value:1,offset:0},weber:{name:"weber",base:q.MAGNETIC_FLUX,prefixes:z.LONG,value:1,offset:0},Wb:{name:"Wb",base:q.MAGNETIC_FLUX,prefixes:z.SHORT,value:1,offset:0},tesla:{name:"tesla",base:q.MAGNETIC_FLUX_DENSITY,prefixes:z.LONG,value:1,offset:0},T:{name:"T",base:q.MAGNETIC_FLUX_DENSITY,prefixes:z.SHORT,value:1,offset:0},b:{name:"b",base:q.BIT,prefixes:z.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:q.BIT,prefixes:z.BINARY_LONG,value:1,offset:0},B:{name:"B",base:q.BIT,prefixes:z.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:q.BIT,prefixes:z.BINARY_LONG,value:8,offset:0}},U={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fldr:"fluiddram",fluiddrams:"fluiddram",floz:"fluidounce",fluidounces:"fluidounce",gi:"gill",gills:"gill",cp:"cup",cups:"cup",pt:"pint",pints:"pint",qt:"quart",quarts:"quart",gal:"gallon",gallons:"gallon",bbl:"beerbarrel",beerbarrels:"beerbarrel",obl:"oilbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",amps:"ampere",amp:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function L(e){if("BigNumber"===e.number){var t=Hl(b);j.rad.value=new b(1),j.deg.value=t.div(180),j.grad.value=t.div(200),j.cycle.value=t.times(2),j.arcsec.value=t.div(648e3),j.arcmin.value=t.div(10800)}else j.rad.value=1,j.deg.value=Math.PI/180,j.grad.value=Math.PI/200,j.cycle.value=2*Math.PI,j.arcsec.value=Math.PI/648e3,j.arcmin.value=Math.PI/10800;j.radian.value=j.rad.value,j.degree.value=j.deg.value,j.gradian.value=j.grad.value}L(a),i&&i("config",(function(e,t){e.number!==t.number&&L(e)}));var H={si:{NONE:{unit:P,prefix:z.NONE[""]},LENGTH:{unit:j.m,prefix:z.SHORT[""]},MASS:{unit:j.g,prefix:z.SHORT.k},TIME:{unit:j.s,prefix:z.SHORT[""]},CURRENT:{unit:j.A,prefix:z.SHORT[""]},TEMPERATURE:{unit:j.K,prefix:z.SHORT[""]},LUMINOUS_INTENSITY:{unit:j.cd,prefix:z.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:j.mol,prefix:z.SHORT[""]},ANGLE:{unit:j.rad,prefix:z.SHORT[""]},BIT:{unit:j.bits,prefix:z.SHORT[""]},FORCE:{unit:j.N,prefix:z.SHORT[""]},ENERGY:{unit:j.J,prefix:z.SHORT[""]},POWER:{unit:j.W,prefix:z.SHORT[""]},PRESSURE:{unit:j.Pa,prefix:z.SHORT[""]},ELECTRIC_CHARGE:{unit:j.C,prefix:z.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:j.F,prefix:z.SHORT[""]},ELECTRIC_POTENTIAL:{unit:j.V,prefix:z.SHORT[""]},ELECTRIC_RESISTANCE:{unit:j.ohm,prefix:z.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:j.H,prefix:z.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:j.S,prefix:z.SHORT[""]},MAGNETIC_FLUX:{unit:j.Wb,prefix:z.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:j.T,prefix:z.SHORT[""]},FREQUENCY:{unit:j.Hz,prefix:z.SHORT[""]}}};H.cgs=JSON.parse(JSON.stringify(H.si)),H.cgs.LENGTH={unit:j.m,prefix:z.SHORT.c},H.cgs.MASS={unit:j.g,prefix:z.SHORT[""]},H.cgs.FORCE={unit:j.dyn,prefix:z.SHORT[""]},H.cgs.ENERGY={unit:j.erg,prefix:z.NONE[""]},H.us=JSON.parse(JSON.stringify(H.si)),H.us.LENGTH={unit:j.ft,prefix:z.NONE[""]},H.us.MASS={unit:j.lbm,prefix:z.NONE[""]},H.us.TEMPERATURE={unit:j.degF,prefix:z.NONE[""]},H.us.FORCE={unit:j.lbf,prefix:z.NONE[""]},H.us.ENERGY={unit:j.BTU,prefix:z.BTU[""]},H.us.POWER={unit:j.hp,prefix:z.NONE[""]},H.us.PRESSURE={unit:j.psi,prefix:z.NONE[""]},H.auto=JSON.parse(JSON.stringify(H.si));var $=H.auto;for(var G in N.setUnitSystem=function(e){if(!Ce(H,e))throw new Error("Unit system "+e+" does not exist. Choices are: "+Object.keys(H).join(", "));$=H[e]},N.getUnitSystem=function(){for(var e in H)if(Ce(H,e)&&H[e]===$)return e},N.typeConverters={BigNumber:function(e){return null!=e&&e.isFraction?new b(e.n).div(e.d).times(e.s):new b(e+"")},Fraction:function(e){return new w(e)},Complex:function(e){return e},number:function(e){return null!=e&&e.isFraction?y(e):e}},N.prototype._numberConverter=function(){var e=N.typeConverters[this.valueType()];if(e)return e;throw new TypeError('Unsupported Unit value type "'+this.valueType()+'"')},N._getNumberConverter=function(e){if(!N.typeConverters[e])throw new TypeError('Unsupported type "'+e+'"');return N.typeConverters[e]},j)if(Ce(j,G)){var W=j[G];W.dimensions=W.base.dimensions}for(var V in U)if(Ce(U,V)){var Z=j[U[V]],Y={};for(var J in Z)Ce(Z,J)&&(Y[J]=Z[J]);Y.name=V,j[V]=Y}return N.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)},N.createUnit=function(e,t){if("object"!=typeof e)throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(t&&t.override)for(var r in e)if(Ce(e,r)&&N.deleteUnit(r),e[r].aliases)for(var n=0;n<e[r].aliases.length;n++)N.deleteUnit(e[r].aliases[n]);var i;for(var a in e)Ce(e,a)&&(i=N.createUnitSingle(a,e[a]));return i},N.createUnitSingle=function(e,t){if(null==t&&(t={}),"string"!=typeof e)throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");if(Ce(j,e))throw new Error('Cannot create unit "'+e+'": a unit with that name already exists');!function(e){for(var t=0;t<e.length;t++){if(n=e.charAt(t),0===t&&!N.isValidAlpha(n))throw new Error('Invalid unit name (must begin with alpha character): "'+e+'"');if(t>0&&!N.isValidAlpha(n)&&!A(n))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+e+'"')}}(e);var r,i,a,o=null,s=[],u=0;if(t&&"Unit"===t.type)o=t.clone();else if("string"==typeof t)""!==t&&(r=t);else{if("object"!=typeof t)throw new TypeError('Cannot create unit "'+e+'" from "'+t.toString()+'": expecting "string" or "Unit" or "Object"');r=t.definition,i=t.prefixes,u=t.offset,a=t.baseName,t.aliases&&(s=t.aliases.valueOf())}if(s)for(var c=0;c<s.length;c++)if(Ce(j,s[c]))throw new Error('Cannot create alias "'+s[c]+'": a unit with that name already exists');if(r&&"string"==typeof r&&!o)try{o=N.parse(r,{allowNoUnits:!0})}catch(t){throw t.message='Could not create unit "'+e+'" from "'+r+'": '+t.message,t}else r&&"Unit"===r.type&&(o=r.clone());s=s||[],u=u||0,i=i&&i.toUpperCase&&z[i.toUpperCase()]||z.NONE;var l={};if(o){l={name:e,value:o.value,dimensions:o.dimensions.slice(0),prefixes:i,offset:u};var f=!1;for(var p in q)if(Ce(q,p)){for(var m=!0,h=0;h<I.length;h++)if(Math.abs((l.dimensions[h]||0)-(q[p].dimensions[h]||0))>1e-12){m=!1;break}if(m){f=!0,l.base=q[p];break}}if(!f){a=a||e+"_STUFF";var d={dimensions:o.dimensions.slice(0)};d.key=a,q[a]=d,$[a]={unit:l,prefix:z.NONE[""]},l.base=q[a]}}else{if(a=a||e+"_STUFF",I.indexOf(a)>=0)throw new Error('Cannot create new base unit "'+e+'": a base unit with that name already exists (and cannot be overridden)');for(var g in I.push(a),q)Ce(q,g)&&(q[g].dimensions[I.length-1]=0);for(var v={dimensions:[]},y=0;y<I.length;y++)v.dimensions[y]=0;v.dimensions[I.length-1]=1,v.key=a,q[a]=v,l={name:e,value:1,dimensions:q[a].dimensions.slice(0),prefixes:i,offset:u,base:q[a]},$[a]={unit:l,prefix:z.NONE[""]}}N.UNITS[e]=l;for(var x=0;x<s.length;x++){var b=s[x],w={};for(var D in l)Ce(l,D)&&(w[D]=l[D]);w.name=b,N.UNITS[b]=w}return delete _.cache,new N(null,e)},N.deleteUnit=function(e){delete N.UNITS[e],delete _.cache},N.PREFIXES=z,N.BASE_DIMENSIONS=I,N.BASE_UNITS=q,N.UNIT_SYSTEMS=H,N.UNITS=j,N}),{isClass:!0}),Yl="unit",Jl=Me(Yl,["typed","Unit"],(e=>{var{typed:t,Unit:r}=e;return t(Yl,{Unit:function(e){return e.clone()},string:function(e){return r.isValuelessUnit(e)?new r(null,e):r.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string | Unit":function(e,t){return new r(e,t)},"number | BigNumber | Fraction":function(e){return new r(e)},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),Xl="sparse",Ql=Me(Xl,["typed","SparseMatrix"],(e=>{var{typed:t,SparseMatrix:r}=e;return t(Xl,{"":function(){return new r([])},string:function(e){return new r([],e)},"Array | Matrix":function(e){return new r(e)},"Array | Matrix, string":function(e,t){return new r(e,t)}})})),Kl="createUnit",ef=Me(Kl,["typed","Unit"],(e=>{var{typed:t,Unit:r}=e;return t(Kl,{"Object, Object":function(e,t){return r.createUnit(e,t)},Object:function(e){return r.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,t,n){var i={};return i[e]=t,r.createUnit(i,n)},"string, Unit | string | Object":function(e,t){var n={};return n[e]=t,r.createUnit(n,{})},string:function(e){var t={};return t[e]={},r.createUnit(t,{})}})})),tf="acos",rf=Me(tf,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(tf,{number:function(e){return e>=-1&&e<=1||r.predictable?Math.acos(e):new n(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()}})})),nf="number";function af(e){return et(e)}function of(e){return Math.atan(1/e)}function sf(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}function uf(e){return Math.asin(1/e)}function cf(e){var t=1/e;return Math.log(t+Math.sqrt(t*t+1))}function lf(e){return Math.acos(1/e)}function ff(e){var t=1/e,r=Math.sqrt(t*t-1);return Math.log(r+t)}function pf(e){return tt(e)}function mf(e){return rt(e)}function hf(e){return 1/Math.tan(e)}function df(e){var t=Math.exp(2*e);return(t+1)/(t-1)}function gf(e){return 1/Math.sin(e)}function vf(e){return 0===e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*Pe(e)}function yf(e){return 1/Math.cos(e)}function xf(e){return 2/(Math.exp(e)+Math.exp(-e))}function bf(e){return it(e)}af.signature=nf,of.signature=nf,sf.signature=nf,uf.signature=nf,cf.signature=nf,lf.signature=nf,ff.signature=nf,pf.signature=nf,mf.signature=nf,hf.signature=nf,df.signature=nf,gf.signature=nf,vf.signature=nf,yf.signature=nf,xf.signature=nf,bf.signature=nf;var wf="acosh",Df=Me(wf,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(wf,{number:function(e){return e>=1||r.predictable?af(e):e<=-1?new n(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new n(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()}})})),Nf="acot",Ef=Me(Nf,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Nf,{number:of,Complex:function(e){return e.acot()},BigNumber:function(e){return new r(1).div(e).atan()}})})),Af="acoth",Sf=Me(Af,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(Af,{number:function(e){return e>=1||e<=-1||r.predictable?sf(e):new n(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new i(1).div(e).atanh()}})})),Cf="acsc",Mf=Me(Cf,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(Cf,{number:function(e){return e<=-1||e>=1||r.predictable?uf(e):new n(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new i(1).div(e).asin()}})})),Ff="acsch",Tf=Me(Ff,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Ff,{number:cf,Complex:function(e){return e.acsch()},BigNumber:function(e){return new r(1).div(e).asinh()}})})),_f="asec",Bf=Me(_f,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(_f,{number:function(e){return e<=-1||e>=1||r.predictable?lf(e):new n(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new i(1).div(e).acos()}})})),Of="asech",kf=Me(Of,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(Of,{number:function(e){if(e<=1&&e>=-1||r.predictable){var t=1/e;if(t>0||r.predictable)return ff(e);var i=Math.sqrt(t*t-1);return new n(Math.log(i-t),Math.PI)}return new n(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new i(1).div(e).acosh()}})})),zf="asin",If=Me(zf,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(zf,{number:function(e){return e>=-1&&e<=1||r.predictable?Math.asin(e):new n(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()}})})),qf=Me("asinh",["typed"],(e=>{var{typed:t}=e;return t("asinh",{number:pf,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()}})})),Rf=Me("atan",["typed"],(e=>{var{typed:t}=e;return t("atan",{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()}})})),Pf="atan2",jf=Me(Pf,["typed","matrix","equalScalar","BigNumber","DenseMatrix","concat"],(e=>{var{typed:t,matrix:r,equalScalar:n,BigNumber:i,DenseMatrix:a,concat:o}=e,s=fo({typed:t,equalScalar:n}),u=po({typed:t}),c=Yo({typed:t,equalScalar:n}),l=Ga({typed:t,equalScalar:n}),f=Wa({typed:t,DenseMatrix:a}),p=vo({typed:t,matrix:r,concat:o});return t(Pf,{"number, number":Math.atan2,"BigNumber, BigNumber":(e,t)=>i.atan2(e,t)},p({scalar:"number | BigNumber",SS:c,DS:u,SD:s,Ss:l,sS:f}))})),Uf="atanh",Lf=Me(Uf,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(Uf,{number:function(e){return e<=1&&e>=-1||r.predictable?mf(e):new n(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()}})})),Hf=Me("trigUnit",["typed"],(e=>{var{typed:t}=e;return{Unit:t.referToSelf((e=>r=>{if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return t.find(e,r.valueType())(r.value)}))}})),$f=Me("cos",["typed"],(e=>{var{typed:t}=e,r=Hf({typed:t});return t("cos",{number:Math.cos,"Complex | BigNumber":e=>e.cos()},r)})),Gf="cosh",Wf=Me(Gf,["typed"],(e=>{var{typed:t}=e;return t(Gf,{number:nt,"Complex | BigNumber":e=>e.cosh()})})),Vf=Me("cot",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("cot",{number:hf,Complex:e=>e.cot(),BigNumber:e=>new r(1).div(e.tan())},Hf({typed:t}))})),Zf="coth",Yf=Me(Zf,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Zf,{number:df,Complex:e=>e.coth(),BigNumber:e=>new r(1).div(e.tanh())})})),Jf=Me("csc",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("csc",{number:gf,Complex:e=>e.csc(),BigNumber:e=>new r(1).div(e.sin())},Hf({typed:t}))})),Xf="csch",Qf=Me(Xf,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Xf,{number:vf,Complex:e=>e.csch(),BigNumber:e=>new r(1).div(e.sinh())})})),Kf=Me("sec",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("sec",{number:yf,Complex:e=>e.sec(),BigNumber:e=>new r(1).div(e.cos())},Hf({typed:t}))})),ep="sech",tp=Me(ep,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(ep,{number:xf,Complex:e=>e.sech(),BigNumber:e=>new r(1).div(e.cosh())})})),rp=Me("sin",["typed"],(e=>{var{typed:t}=e,r=Hf({typed:t});return t("sin",{number:Math.sin,"Complex | BigNumber":e=>e.sin()},r)})),np="sinh",ip=Me(np,["typed"],(e=>{var{typed:t}=e;return t(np,{number:bf,"Complex | BigNumber":e=>e.sinh()})})),ap=Me("tan",["typed"],(e=>{var{typed:t}=e,r=Hf({typed:t});return t("tan",{number:Math.tan,"Complex | BigNumber":e=>e.tan()},r)})),op=Me("tanh",["typed"],(e=>{var{typed:t}=e;return t("tanh",{number:at,"Complex | BigNumber":e=>e.tanh()})})),sp="setCartesian",up=Me(sp,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(sp,{"Array | Matrix, Array | Matrix":function(e,t){var s=[];if(0!==n(r(e),new a(0))&&0!==n(r(t),new a(0))){var u=Vn(Array.isArray(e)?e:e.toArray()).sort(i),c=Vn(Array.isArray(t)?t:t.toArray()).sort(i);s=[];for(var l=0;l<u.length;l++)for(var f=0;f<c.length;f++)s.push([u[l],c[f]])}return Array.isArray(e)&&Array.isArray(t)?s:new o(s)}})})),cp="setDifference",lp=Me(cp,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(cp,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(0===n(r(e),new a(0)))s=[];else{if(0===n(r(t),new a(0)))return Vn(e.toArray());var u,c=Qn(Vn(Array.isArray(e)?e:e.toArray()).sort(i)),l=Qn(Vn(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var f=0;f<c.length;f++){u=!1;for(var p=0;p<l.length;p++)if(0===i(c[f].value,l[p].value)&&c[f].identifier===l[p].identifier){u=!0;break}u||s.push(c[f])}}return Array.isArray(e)&&Array.isArray(t)?Kn(s):new o(Kn(s))}})})),fp="setDistinct",pp=Me(fp,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(fp,{"Array | Matrix":function(e){var t;if(0===n(r(e),new a(0)))t=[];else{var s=Vn(Array.isArray(e)?e:e.toArray()).sort(i);(t=[]).push(s[0]);for(var u=1;u<s.length;u++)0!==i(s[u],s[u-1])&&t.push(s[u])}return Array.isArray(e)?t:new o(t)}})})),mp="setIntersect",hp=Me(mp,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(mp,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(0===n(r(e),new a(0))||0===n(r(t),new a(0)))s=[];else{var u=Qn(Vn(Array.isArray(e)?e:e.toArray()).sort(i)),c=Qn(Vn(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var l=0;l<u.length;l++)for(var f=0;f<c.length;f++)if(0===i(u[l].value,c[f].value)&&u[l].identifier===c[f].identifier){s.push(u[l]);break}}return Array.isArray(e)&&Array.isArray(t)?Kn(s):new o(Kn(s))}})})),dp="setIsSubset",gp=Me(dp,["typed","size","subset","compareNatural","Index"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(dp,{"Array | Matrix, Array | Matrix":function(e,t){if(0===n(r(e),new a(0)))return!0;if(0===n(r(t),new a(0)))return!1;for(var o,s=Qn(Vn(Array.isArray(e)?e:e.toArray()).sort(i)),u=Qn(Vn(Array.isArray(t)?t:t.toArray()).sort(i)),c=0;c<s.length;c++){o=!1;for(var l=0;l<u.length;l++)if(0===i(s[c].value,u[l].value)&&s[c].identifier===u[l].identifier){o=!0;break}if(!1===o)return!1}return!0}})})),vp="setMultiplicity",yp=Me(vp,["typed","size","subset","compareNatural","Index"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(vp,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,t){if(0===n(r(t),new a(0)))return 0;for(var o=Vn(Array.isArray(t)?t:t.toArray()),s=0,u=0;u<o.length;u++)0===i(o[u],e)&&s++;return s}})})),xp="setPowerset",bp=Me(xp,["typed","size","subset","compareNatural","Index"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(xp,{"Array | Matrix":function(e){if(0===n(r(e),new a(0)))return[];for(var t=Vn(Array.isArray(e)?e:e.toArray()).sort(i),s=[],u=0;u.toString(2).length<=t.length;)s.push(o(t,u.toString(2).split("").reverse())),u++;return function(e){for(var t=[],r=e.length-1;r>0;r--)for(var n=0;n<r;n++)e[n].length>e[n+1].length&&(t=e[n],e[n]=e[n+1],e[n+1]=t);return e}(s)}});function o(e,t){for(var r=[],n=0;n<t.length;n++)"1"===t[n]&&r.push(e[n]);return r}})),wp="setSize",Dp=Me(wp,["typed","compareNatural"],(e=>{var{typed:t,compareNatural:r}=e;return t(wp,{"Array | Matrix":function(e){return Array.isArray(e)?Vn(e).length:Vn(e.toArray()).length},"Array | Matrix, boolean":function(e,t){if(!1===t||0===e.length)return Array.isArray(e)?Vn(e).length:Vn(e.toArray()).length;for(var n=Vn(Array.isArray(e)?e:e.toArray()).sort(r),i=1,a=1;a<n.length;a++)0!==r(n[a],n[a-1])&&i++;return i}})})),Np="setSymDifference",Ep=Me(Np,["typed","size","concat","subset","setDifference","Index"],(e=>{var{typed:t,size:r,concat:n,subset:i,setDifference:a,Index:o}=e;return t(Np,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new o(0)))return Vn(t);if(0===i(r(t),new o(0)))return Vn(e);var s=Vn(e),u=Vn(t);return n(a(s,u),a(u,s))}})})),Ap="setUnion",Sp=Me(Ap,["typed","size","concat","subset","setIntersect","setSymDifference","Index"],(e=>{var{typed:t,size:r,concat:n,subset:i,setIntersect:a,setSymDifference:o,Index:s}=e;return t(Ap,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new s(0)))return Vn(t);if(0===i(r(t),new s(0)))return Vn(e);var u=Vn(e),c=Vn(t);return n(o(u,c),a(u,c))}})})),Cp=Me("add",["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],(e=>{var{typed:t,matrix:r,addScalar:n,equalScalar:i,DenseMatrix:a,SparseMatrix:o,concat:s}=e,u=xo({typed:t}),c=bo({typed:t,equalScalar:i}),l=wo({typed:t,DenseMatrix:a}),f=vo({typed:t,matrix:r,concat:s});return t("add",{"any, any":n,"any, any, ...any":t.referToSelf((e=>(t,r,n)=>{for(var i=e(t,r),a=0;a<n.length;a++)i=e(i,n[a]);return i}))},f({elop:n,DS:u,SS:c,Ss:l}))})),Mp="hypot",Fp=Me(Mp,["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],(e=>{var{typed:t,abs:r,addScalar:n,divideScalar:i,multiplyScalar:a,sqrt:o,smaller:s,isPositive:u}=e;return t(Mp,{"... number | BigNumber":c,Array:c,Matrix:e=>c(Vn(e.toArray()))});function c(e){for(var t=0,c=0,l=0;l<e.length;l++){if(B(e[l]))throw new TypeError("Unexpected type of argument to hypot");var f=r(e[l]);s(c,f)?(t=a(t,a(i(c,f),i(c,f))),t=n(t,1),c=f):t=n(t,u(f)?a(i(f,c),i(f,c)):f)}return a(c,o(t))}})),Tp="norm",_p=Me(Tp,["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],(e=>{var{typed:t,abs:r,add:n,pow:i,conj:a,sqrt:o,multiply:s,equalScalar:u,larger:c,smaller:l,matrix:f,ctranspose:p,eigs:m}=e;return t(Tp,{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},boolean:function(e){return Math.abs(e)},Array:function(e){return h(f(e),2)},Matrix:function(e){return h(e,2)},"Array, number | BigNumber | string":function(e,t){return h(f(e),t)},"Matrix, number | BigNumber | string":function(e,t){return h(e,t)}});function h(e,t){var f=e.size();if(1===f.length)return function(e,t){if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=0;return e.forEach((function(e){var n=r(e);c(n,t)&&(t=n)}),!0),t}(e);if(t===Number.NEGATIVE_INFINITY||"-inf"===t)return function(e){var t;return e.forEach((function(e){var n=r(e);t&&!l(n,t)||(t=n)}),!0),t||0}(e);if("fro"===t)return h(e,2);if("number"==typeof t&&!isNaN(t)){if(!u(t,0)){var a=0;return e.forEach((function(e){a=n(i(r(e),t),a)}),!0),i(a,1/t)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}(e,t);if(2===f.length){if(f[0]&&f[1])return function(e,t){if(1===t)return function(e){var t=[],i=0;return e.forEach((function(e,a){var o=a[1],s=n(t[o]||0,r(e));c(s,i)&&(i=s),t[o]=s}),!0),i}(e);if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=[],i=0;return e.forEach((function(e,a){var o=a[0],s=n(t[o]||0,r(e));c(s,i)&&(i=s),t[o]=s}),!0),i}(e);if("fro"===t)return function(e){var t=0;return e.forEach((function(e,r){t=n(t,s(e,a(e)))})),r(o(t))}(e);if(2===t)return function(e){var t=e.size();if(t[0]!==t[1])throw new RangeError("Invalid matrix dimensions");var n=p(e),i=s(n,e),a=m(i).values.toArray(),u=a[a.length-1];return r(o(u))}(e);throw new Error("Unsupported parameter value "+t)}(e,t);throw new RangeError("Invalid matrix dimensions")}}})),Bp=Me("dot",["typed","addScalar","multiplyScalar","conj","size"],(e=>{var{typed:t,addScalar:r,multiplyScalar:n,conj:i,size:a}=e;return t("dot",{"Array | DenseMatrix, Array | DenseMatrix":function(e,a){var u=o(e,a),c=q(e)?e._data:e,l=q(e)?e._datatype||e.getDataType():void 0,f=q(a)?a._data:a,p=q(a)?a._datatype||a.getDataType():void 0,m=2===s(e).length,h=2===s(a).length,d=r,g=n;if(l&&p&&l===p&&"string"==typeof l&&"mixed"!==l){var v=l;d=t.find(r,[v,v]),g=t.find(n,[v,v])}if(!m&&!h){for(var y=g(i(c[0]),f[0]),x=1;x<u;x++)y=d(y,g(i(c[x]),f[x]));return y}if(!m&&h){for(var b=g(i(c[0]),f[0][0]),w=1;w<u;w++)b=d(b,g(i(c[w]),f[w][0]));return b}if(m&&!h){for(var D=g(i(c[0][0]),f[0]),N=1;N<u;N++)D=d(D,g(i(c[N][0]),f[N]));return D}if(m&&h){for(var E=g(i(c[0][0]),f[0][0]),A=1;A<u;A++)E=d(E,g(i(c[A][0]),f[A][0]));return E}},"SparseMatrix, SparseMatrix":function(e,t){o(e,t);for(var i=e._index,a=e._values,s=t._index,u=t._values,c=0,l=r,f=n,p=0,m=0;p<i.length&&m<s.length;){var h=i[p],d=s[m];h<d?p++:h>d?m++:h===d&&(c=l(c,f(a[p],u[m])),p++,m++)}return c}});function o(e,t){var r,n,i=s(e),a=s(t);if(1===i.length)r=i[0];else{if(2!==i.length||1!==i[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+i.join(", ")+")");r=i[0]}if(1===a.length)n=a[0];else{if(2!==a.length||1!==a[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+a.join(", ")+")");n=a[0]}if(r!==n)throw new RangeError("Vectors must have equal length ("+r+" != "+n+")");if(0===r)throw new RangeError("Cannot calculate the dot product of empty vectors");return r}function s(e){return q(e)?e.size():a(e)}})),Op=Me("trace",["typed","matrix","add"],(e=>{var{typed:t,matrix:r,add:n}=e;return t("trace",{Array:function(e){return i(r(e))},SparseMatrix:function(e){var t=e._values,r=e._index,i=e._ptr,a=e._size,o=a[0],s=a[1];if(o===s){var u=0;if(t.length>0)for(var c=0;c<s;c++)for(var l=i[c],f=i[c+1],p=l;p<f;p++){var m=r[p];if(m===c){u=n(u,t[p]);break}if(m>c)break}return u}throw new RangeError("Matrix must be square (size: "+Sn(a)+")")},DenseMatrix:i,any:be});function i(e){var t=e._size,r=e._data;switch(t.length){case 1:if(1===t[0])return be(r[0]);throw new RangeError("Matrix must be square (size: "+Sn(t)+")");case 2:var i=t[0];if(i===t[1]){for(var a=0,o=0;o<i;o++)a=n(a,r[o][o]);return a}throw new RangeError("Matrix must be square (size: "+Sn(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+Sn(t)+")")}}})),kp="index",zp=Me(kp,["typed","Index"],(e=>{var{typed:t,Index:r}=e;return t(kp,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var t=e.map((function(e){return T(e)?e.toNumber():I(e)||q(e)?e.map((function(e){return T(e)?e.toNumber():e})):e})),n=new r;return r.apply(n,t),n}})})),Ip=new Set(["end"]),qp=Me("Node",["mathWithTransform"],(e=>{var{mathWithTransform:t}=e;return class{get type(){return"Node"}get isNode(){return!0}evaluate(e){return this.compile().evaluate(e)}compile(){var e=this._compile(t,{}),r={};return{evaluate:function(t){var n=M(t);return function(e){for(var t of[...Ip])if(e.has(t))throw new Error('Scope contains an illegal symbol, "'+t+'" is a reserved keyword')}(n),e(n,r,null)}}}_compile(e,t){throw new Error("Method _compile must be implemented by type "+this.type)}forEach(e){throw new Error("Cannot run forEach on a Node interface")}map(e){throw new Error("Cannot run map on a Node interface")}_ifNode(e){if(!fe(e))throw new TypeError("Callback function must return a Node");return e}traverse(e){e(this,null,null),function e(t,r){t.forEach((function(t,n,i){r(t,n,i),e(t,r)}))}(this,e)}transform(e){return function t(r,n,i){var a=e(r,n,i);return a!==r?a:r.map(t)}(this,null,null)}filter(e){var t=[];return this.traverse((function(r,n,i){e(r,n,i)&&t.push(r)})),t}clone(){throw new Error("Cannot clone a Node interface")}cloneDeep(){return this.map((function(e){return e.cloneDeep()}))}equals(e){return!!e&&this.type===e.type&&Ne(this,e)}toString(e){var t=this._getCustomString(e);return void 0!==t?t:this._toString(e)}_toString(){throw new Error("_toString not implemented for "+this.type)}toJSON(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)}toHTML(e){var t=this._getCustomString(e);return void 0!==t?t:this._toHTML(e)}_toHTML(){throw new Error("_toHTML not implemented for "+this.type)}toTex(e){var t=this._getCustomString(e);return void 0!==t?t:this._toTex(e)}_toTex(e){throw new Error("_toTex not implemented for "+this.type)}_getCustomString(e){if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":return;case"function":return e.handler(this,e);default:throw new TypeError("Object or function expected as callback")}}getIdentifier(){return this.type}getContent(){return this}}}),{isClass:!0,isNode:!0});function Rp(e){return e&&e.isIndexError?new v(e.index+1,e.min+1,void 0!==e.max?e.max+1:void 0):e}function Pp(e){var{subset:t}=e;return function(e,r){try{if(Array.isArray(e))return t(e,r);if(e&&"function"==typeof e.subset)return e.subset(r);if("string"==typeof e)return t(e,r);if("object"==typeof e){if(!r.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return y(e,r.getObjectProperty())}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Rp(e)}}}var jp="AccessorNode",Up=Me(jp,["subset","Node"],(e=>{var{subset:t,Node:r}=e,n=Pp({subset:t});function i(e){return!(te(e)||re(e)||oe(e)||ce(e)||pe(e)||he(e)||ve(e))}class a extends r{constructor(e,t){if(super(),!fe(e))throw new TypeError('Node expected for parameter "object"');if(!le(t))throw new TypeError('IndexNode expected for parameter "index"');this.object=e,this.index=t}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return jp}get isAccessorNode(){return!0}_compile(e,t){var r=this.object._compile(e,t),i=this.index._compile(e,t);if(this.index.isObjectProperty()){var a=this.index.getObjectProperty();return function(e,t,n){return y(r(e,t,n),a)}}return function(e,t,a){var o=r(e,t,a),s=i(e,t,o);return n(o,s)}}forEach(e){e(this.object,"object",this),e(this.index,"index",this)}map(e){return new a(this._ifNode(e(this.object,"object",this)),this._ifNode(e(this.index,"index",this)))}clone(){return new a(this.object,this.index)}_toString(e){var t=this.object.toString(e);return i(this.object)&&(t="("+t+")"),t+this.index.toString(e)}_toHTML(e){var t=this.object.toHTML(e);return i(this.object)&&(t='<span class="math-parenthesis math-round-parenthesis">(</span>'+t+'<span class="math-parenthesis math-round-parenthesis">)</span>'),t+this.index.toHTML(e)}_toTex(e){var t=this.object.toTex(e);return i(this.object)&&(t="\\left(' + object + '\\right)"),t+this.index.toTex(e)}toJSON(){return{mathjs:jp,object:this.object,index:this.index}}static fromJSON(e){return new a(e.object,e.index)}}return Hu(a,"name",jp),a}),{isClass:!0,isNode:!0}),Lp="ArrayNode",Hp=Me(Lp,["Node"],(e=>{var{Node:t}=e;class r extends t{constructor(e){if(super(),this.items=e||[],!Array.isArray(this.items)||!this.items.every(fe))throw new TypeError("Array containing Nodes expected")}get type(){return Lp}get isArrayNode(){return!0}_compile(e,t){var r=Zn(this.items,(function(r){return r._compile(e,t)}));if("Array"!==e.config.matrix){var n=e.matrix;return function(e,t,i){return n(Zn(r,(function(r){return r(e,t,i)})))}}return function(e,t,n){return Zn(r,(function(r){return r(e,t,n)}))}}forEach(e){for(var t=0;t<this.items.length;t++)e(this.items[t],"items["+t+"]",this)}map(e){for(var t=[],n=0;n<this.items.length;n++)t[n]=this._ifNode(e(this.items[n],"items["+n+"]",this));return new r(t)}clone(){return new r(this.items.slice(0))}_toString(e){return"["+this.items.map((function(t){return t.toString(e)})).join(", ")+"]"}toJSON(){return{mathjs:Lp,items:this.items}}static fromJSON(e){return new r(e.items)}_toHTML(e){return'<span class="math-parenthesis math-square-parenthesis">[</span>'+this.items.map((function(t){return t.toHTML(e)})).join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(e){return function t(r,n){var i=r.some(re)&&!r.every(re),a=n||i,o=a?"&":"\\\\",s=r.map((function(r){return r.items?t(r.items,!n):r.toTex(e)})).join(o);return i||!a||a&&!n?"\\begin{bmatrix}"+s+"\\end{bmatrix}":s}(this.items,!1)}}return Hu(r,"name",Lp),r}),{isClass:!0,isNode:!0}),$p=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{op:"or",associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{op:"xor",associativity:"left",associativeWith:[]}},{"OperatorNode:and":{op:"and",associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{op:"|",associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{op:"^|",associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{op:"&",associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{op:"==",associativity:"left",associativeWith:[]},"OperatorNode:unequal":{op:"!=",associativity:"left",associativeWith:[]},"OperatorNode:smaller":{op:"<",associativity:"left",associativeWith:[]},"OperatorNode:larger":{op:">",associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{op:"<=",associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{op:">=",associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{op:"<<",associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{op:">>",associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{op:">>>",associativity:"left",associativeWith:[]}},{"OperatorNode:to":{op:"to",associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{op:"+",associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{op:"-",associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{op:"*",associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{op:"/",associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{op:".*",associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{op:"./",associativity:"left",associativeWith:[]},"OperatorNode:mod":{op:"mod",associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]}},{"OperatorNode:unaryPlus":{op:"+",associativity:"right"},"OperatorNode:unaryMinus":{op:"-",associativity:"right"},"OperatorNode:bitNot":{op:"~",associativity:"right"},"OperatorNode:not":{op:"not",associativity:"right"}},{"OperatorNode:pow":{op:"^",associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{op:".^",associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{op:"!",associativity:"left"}},{"OperatorNode:ctranspose":{op:"'",associativity:"left"}}];function Gp(e,t){if(!t||"auto"!==t)return e;for(var r=e;he(r);)r=r.content;return r}function Wp(e,t,r,n){var i=e;"keep"!==t&&(i=e.getContent());for(var a=i.getIdentifier(),o=null,s=0;s<$p.length;s++)if(a in $p[s]){o=s;break}if("OperatorNode:multiply"===a&&i.implicit&&"show"!==r){var u=Gp(i.args[0],t);oe(u)&&n&&"OperatorNode:divide"===n.getIdentifier()&&se(Gp(n.args[0],t))||"OperatorNode:divide"===u.getIdentifier()&&se(Gp(u.args[0],t))&&oe(Gp(u.args[1]))||(o+=1)}return o}function Vp(e,t){var r=e;"keep"!==t&&(r=e.getContent());var n=r.getIdentifier(),i=Wp(r,t);if(null===i)return null;var a=$p[i][n];if(Ce(a,"associativity")){if("left"===a.associativity)return"left";if("right"===a.associativity)return"right";throw Error("'"+n+"' has the invalid associativity '"+a.associativity+"'.")}return null}function Zp(e,t,r){var n="keep"!==r?e.getContent():e,i="keep"!==r?e.getContent():t,a=n.getIdentifier(),o=i.getIdentifier(),s=Wp(n,r);if(null===s)return null;var u=$p[s][a];if(Ce(u,"associativeWith")&&u.associativeWith instanceof Array){for(var c=0;c<u.associativeWith.length;c++)if(u.associativeWith[c]===o)return!0;return!1}return null}var Yp="AssignmentNode",Jp=Me(Yp,["subset","?matrix","Node"],(e=>{var{subset:t,matrix:r,Node:n}=e,i=Pp({subset:t}),a=function(e){var{subset:t,matrix:r}=e;return function(e,n,i){try{if(Array.isArray(e))return r(e).subset(n,i).valueOf().forEach(((t,r)=>{e[r]=t})),e;if(e&&"function"==typeof e.subset)return e.subset(n,i);if("string"==typeof e)return t(e,n,i);if("object"==typeof e){if(!n.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return x(e,n.getObjectProperty(),i),e}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Rp(e)}}}({subset:t,matrix:r});function o(e,t,r){t||(t="keep");var n=Wp(e,t,r),i=Wp(e.value,t,r);return"all"===t||null!==i&&i<=n}class s extends n{constructor(e,t,r){if(super(),this.object=e,this.index=r?t:null,this.value=r||t,!ve(e)&&!te(e))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(ve(e)&&"end"===e.name)throw new Error('Cannot assign to symbol "end"');if(this.index&&!le(this.index))throw new TypeError('IndexNode expected as "index"');if(!fe(this.value))throw new TypeError('Node expected as "value"')}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return Yp}get isAssignmentNode(){return!0}_compile(e,t){var r=this.object._compile(e,t),n=this.index?this.index._compile(e,t):null,o=this.value._compile(e,t),s=this.object.name;if(this.index){if(this.index.isObjectProperty()){var u=this.index.getObjectProperty();return function(e,t,n){var i=r(e,t,n),a=o(e,t,n);return x(i,u,a),a}}if(ve(this.object))return function(e,t,i){var u=r(e,t,i),c=o(e,t,i),l=n(e,t,u);return e.set(s,a(u,l,c)),c};var c=this.object.object._compile(e,t);if(this.object.index.isObjectProperty()){var l=this.object.index.getObjectProperty();return function(e,t,r){var i=c(e,t,r),s=y(i,l),u=n(e,t,s),f=o(e,t,r);return x(i,l,a(s,u,f)),f}}var f=this.object.index._compile(e,t);return function(e,t,r){var s=c(e,t,r),u=f(e,t,s),l=i(s,u),p=n(e,t,l),m=o(e,t,r);return a(s,u,a(l,p,m)),m}}if(!ve(this.object))throw new TypeError("SymbolNode expected as object");return function(e,t,r){var n=o(e,t,r);return e.set(s,n),n}}forEach(e){e(this.object,"object",this),this.index&&e(this.index,"index",this),e(this.value,"value",this)}map(e){var t=this._ifNode(e(this.object,"object",this)),r=this.index?this._ifNode(e(this.index,"index",this)):null,n=this._ifNode(e(this.value,"value",this));return new s(t,r,n)}clone(){return new s(this.object,this.index,this.value)}_toString(e){var t=this.object.toString(e),r=this.index?this.index.toString(e):"",n=this.value.toString(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(n="("+n+")"),t+r+" = "+n}toJSON(){return{mathjs:Yp,object:this.object,index:this.index,value:this.value}}static fromJSON(e){return new s(e.object,e.index,e.value)}_toHTML(e){var t=this.object.toHTML(e),r=this.index?this.index.toHTML(e):"",n=this.value.toHTML(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(n='<span class="math-paranthesis math-round-parenthesis">(</span>'+n+'<span class="math-paranthesis math-round-parenthesis">)</span>'),t+r+'<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+n}_toTex(e){var t=this.object.toTex(e),r=this.index?this.index.toTex(e):"",n=this.value.toTex(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(n="\\left(".concat(n,"\\right)")),t+r+"="+n}}return Hu(s,"name",Yp),s}),{isClass:!0,isNode:!0}),Xp="BlockNode",Qp=Me(Xp,["ResultSet","Node"],(e=>{var{ResultSet:t,Node:r}=e;class n extends r{constructor(e){if(super(),!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map((function(e){var t=e&&e.node,r=!e||void 0===e.visible||e.visible;if(!fe(t))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof r)throw new TypeError('Property "visible" must be a boolean');return{node:t,visible:r}}))}get type(){return Xp}get isBlockNode(){return!0}_compile(e,r){var n=Zn(this.blocks,(function(t){return{evaluate:t.node._compile(e,r),visible:t.visible}}));return function(e,r,i){var a=[];return Yn(n,(function(t){var n=t.evaluate(e,r,i);t.visible&&a.push(n)})),new t(a)}}forEach(e){for(var t=0;t<this.blocks.length;t++)e(this.blocks[t].node,"blocks["+t+"].node",this)}map(e){for(var t=[],r=0;r<this.blocks.length;r++){var i=this.blocks[r],a=this._ifNode(e(i.node,"blocks["+r+"].node",this));t[r]={node:a,visible:i.visible}}return new n(t)}clone(){var e=this.blocks.map((function(e){return{node:e.node,visible:e.visible}}));return new n(e)}_toString(e){return this.blocks.map((function(t){return t.node.toString(e)+(t.visible?"":";")})).join("\n")}toJSON(){return{mathjs:Xp,blocks:this.blocks}}static fromJSON(e){return new n(e.blocks)}_toHTML(e){return this.blocks.map((function(t){return t.node.toHTML(e)+(t.visible?"":'<span class="math-separator">;</span>')})).join('<span class="math-separator"><br /></span>')}_toTex(e){return this.blocks.map((function(t){return t.node.toTex(e)+(t.visible?"":";")})).join("\\;\\;\n")}}return Hu(n,"name",Xp),n}),{isClass:!0,isNode:!0}),Kp="ConditionalNode",em=Me(Kp,["Node"],(e=>{var{Node:t}=e;class r extends t{constructor(e,t,r){if(super(),!fe(e))throw new TypeError("Parameter condition must be a Node");if(!fe(t))throw new TypeError("Parameter trueExpr must be a Node");if(!fe(r))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=t,this.falseExpr=r}get type(){return Kp}get isConditionalNode(){return!0}_compile(e,t){var r=this.condition._compile(e,t),n=this.trueExpr._compile(e,t),i=this.falseExpr._compile(e,t);return function(e,t,a){return function(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return!!e;if(e){if(T(e))return!e.isZero();if(B(e))return!(!e.re&&!e.im);if(k(e))return!!e.value}if(null==e)return!1;throw new TypeError('Unsupported type of condition "'+xe(e)+'"')}(r(e,t,a))?n(e,t,a):i(e,t,a)}}forEach(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)}map(e){return new r(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))}clone(){return new r(this.condition,this.trueExpr,this.falseExpr)}_toString(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=Wp(this,t,e&&e.implicit),n=this.condition.toString(e),i=Wp(this.condition,t,e&&e.implicit);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n="("+n+")");var a=this.trueExpr.toString(e),o=Wp(this.trueExpr,t,e&&e.implicit);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a="("+a+")");var s=this.falseExpr.toString(e),u=Wp(this.falseExpr,t,e&&e.implicit);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s="("+s+")"),n+" ? "+a+" : "+s}toJSON(){return{mathjs:Kp,condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}}static fromJSON(e){return new r(e.condition,e.trueExpr,e.falseExpr)}_toHTML(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=Wp(this,t,e&&e.implicit),n=this.condition.toHTML(e),i=Wp(this.condition,t,e&&e.implicit);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n='<span class="math-parenthesis math-round-parenthesis">(</span>'+n+'<span class="math-parenthesis math-round-parenthesis">)</span>');var a=this.trueExpr.toHTML(e),o=Wp(this.trueExpr,t,e&&e.implicit);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a='<span class="math-parenthesis math-round-parenthesis">(</span>'+a+'<span class="math-parenthesis math-round-parenthesis">)</span>');var s=this.falseExpr.toHTML(e),u=Wp(this.falseExpr,t,e&&e.implicit);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),n+'<span class="math-operator math-conditional-operator">?</span>'+a+'<span class="math-operator math-conditional-operator">:</span>'+s}_toTex(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"}}return Hu(r,"name",Kp),r}),{isClass:!0,isNode:!0}),tm=r(7928),rm={Alpha:"A",alpha:"\\alpha",Beta:"B",beta:"\\beta",Gamma:"\\Gamma",gamma:"\\gamma",Delta:"\\Delta",delta:"\\delta",Epsilon:"E",epsilon:"\\epsilon",varepsilon:"\\varepsilon",Zeta:"Z",zeta:"\\zeta",Eta:"H",eta:"\\eta",Theta:"\\Theta",theta:"\\theta",vartheta:"\\vartheta",Iota:"I",iota:"\\iota",Kappa:"K",kappa:"\\kappa",varkappa:"\\varkappa",Lambda:"\\Lambda",lambda:"\\lambda",Mu:"M",mu:"\\mu",Nu:"N",nu:"\\nu",Xi:"\\Xi",xi:"\\xi",Omicron:"O",omicron:"o",Pi:"\\Pi",pi:"\\pi",varpi:"\\varpi",Rho:"P",rho:"\\rho",varrho:"\\varrho",Sigma:"\\Sigma",sigma:"\\sigma",varsigma:"\\varsigma",Tau:"T",tau:"\\tau",Upsilon:"\\Upsilon",upsilon:"\\upsilon",Phi:"\\Phi",phi:"\\phi",varphi:"\\varphi",Chi:"X",chi:"\\chi",Psi:"\\Psi",psi:"\\psi",Omega:"\\Omega",omega:"\\omega",true:"\\mathrm{True}",false:"\\mathrm{False}",i:"i",inf:"\\infty",Inf:"\\infty",infinity:"\\infty",Infinity:"\\infty",oo:"\\infty",lim:"\\lim",undefined:"\\mathbf{?}"},nm={transpose:"^\\top",ctranspose:"^H",factorial:"!",pow:"^",dotPow:".^\\wedge",unaryPlus:"+",unaryMinus:"-",bitNot:"\\~",not:"\\neg",multiply:"\\cdot",divide:"\\frac",dotMultiply:".\\cdot",dotDivide:".:",mod:"\\mod",add:"+",subtract:"-",to:"\\rightarrow",leftShift:"<<",rightArithShift:">>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},im={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(nm.add,"${args[1]}\\right)")},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:"\\left(${args[0]}".concat(nm.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(nm.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(nm.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(nm.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:"\\left(${args[0]}".concat(nm.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(nm.multiply,"${args[1]}\\right)")},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : $y^{args[1]} = {${args[0]}}\\}"},pow:{2:"\\left(${args[0]}\\right)".concat(nm.pow,"{${args[1]}}")},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:"\\left(${args[0]}".concat(nm.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(nm.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(nm.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(nm.bitAnd,"${args[1]}\\right)")},bitNot:{1:nm.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(nm.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(nm.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(nm.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(nm.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(nm.rightLogShift,"${args[1]}\\right)")},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:"\\left(${args[0]}".concat(nm.and,"${args[1]}\\right)")},not:{1:nm.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(nm.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(nm.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(nm.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},pinv:{1:"\\left(${args[0]}\\right)^{+}"},sqrtm:{1:"{${args[0]}}".concat(nm.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(nm.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(nm.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(nm.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(nm.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(nm.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(nm.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(nm.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(nm.unequal,"${args[1]}\\right)")},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:"\\left(${args[0]}".concat(nm.to,"${args[1]}\\right)")},numeric:function(e,t){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},bigint:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(rm.i,"\\cdot\\left(${args[1]}\\right)\\right)")},matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},am={deg:"^\\circ"};function om(e){return tm(e,{preserveFormatting:!0})}function sm(e,t){return(t=void 0!==t&&t)?Ce(am,e)?am[e]:"\\mathrm{"+om(e)+"}":Ce(rm,e)?rm[e]:om(e)}var um="ConstantNode",cm=Me(um,["Node"],(e=>{var{Node:t}=e;class r extends t{constructor(e){super(),this.value=e}get type(){return um}get isConstantNode(){return!0}_compile(e,t){var r=this.value;return function(){return r}}forEach(e){}map(e){return this.clone()}clone(){return new r(this.value)}_toString(e){return Sn(this.value,e)}_toHTML(e){var t=this._toString(e);switch(xe(this.value)){case"number":case"bigint":case"BigNumber":case"Fraction":return'<span class="math-number">'+t+"</span>";case"string":return'<span class="math-string">'+t+"</span>";case"boolean":return'<span class="math-boolean">'+t+"</span>";case"null":return'<span class="math-null-symbol">'+t+"</span>";case"undefined":return'<span class="math-undefined">'+t+"</span>";default:return'<span class="math-symbol">'+t+"</span>"}}toJSON(){return{mathjs:um,value:this.value}}static fromJSON(e){return new r(e.value)}_toTex(e){var t=this._toString(e),r=xe(this.value);switch(r){case"string":return"\\mathtt{"+om(t)+"}";case"number":case"BigNumber":if(!("BigNumber"===r?this.value.isFinite():isFinite(this.value)))return this.value.valueOf()<0?"-\\infty":"\\infty";var n=t.toLowerCase().indexOf("e");return-1!==n?t.substring(0,n)+"\\cdot10^{"+t.substring(n+1)+"}":t;case"bigint":return t.toString();case"Fraction":return this.value.toLatex();default:return t}}}return Hu(r,"name",um),r}),{isClass:!0,isNode:!0}),lm="FunctionAssignmentNode",fm=Me(lm,["typed","Node"],(e=>{var{typed:t,Node:r}=e;function n(e,t,r){var n=Wp(e,t,r),i=Wp(e.expr,t,r);return"all"===t||null!==i&&i<=n}class i extends r{constructor(e,t,r){if(super(),"string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(t))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!fe(r))throw new TypeError('Node expected for parameter "expr"');if(Ip.has(e))throw new Error('Illegal function name, "'+e+'" is a reserved keyword');var n=new Set;for(var i of t){var a="string"==typeof i?i:i.name;if(n.has(a))throw new Error('Duplicate parameter name "'.concat(a,'"'));n.add(a)}this.name=e,this.params=t.map((function(e){return e&&e.name||e})),this.types=t.map((function(e){return e&&e.type||"any"})),this.expr=r}get type(){return lm}get isFunctionAssignmentNode(){return!0}_compile(e,r){var n=Object.create(r);Yn(this.params,(function(e){n[e]=!0}));var i=this.expr._compile(e,n),a=this.name,o=this.params,s=Xn(this.types,","),u=a+"("+Xn(this.params,", ")+")";return function(e,r,n){var c={};c[s]=function(){for(var t=Object.create(r),a=0;a<o.length;a++)t[o[a]]=arguments[a];return i(e,t,n)};var l=t(a,c);return l.syntax=u,e.set(a,l),l}}forEach(e){e(this.expr,"expr",this)}map(e){var t=this._ifNode(e(this.expr,"expr",this));return new i(this.name,this.params.slice(0),t)}clone(){return new i(this.name,this.params.slice(0),this.expr)}_toString(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=this.expr.toString(e);return n(this,t,e&&e.implicit)&&(r="("+r+")"),this.name+"("+this.params.join(", ")+") = "+r}toJSON(){var e=this.types;return{mathjs:lm,name:this.name,params:this.params.map((function(t,r){return{name:t,type:e[r]}})),expr:this.expr}}static fromJSON(e){return new i(e.name,e.params,e.expr)}_toHTML(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",r=[],i=0;i<this.params.length;i++)r.push('<span class="math-symbol math-parameter">'+Fn(this.params[i])+"</span>");var a=this.expr.toHTML(e);return n(this,t,e&&e.implicit)&&(a='<span class="math-parenthesis math-round-parenthesis">(</span>'+a+'<span class="math-parenthesis math-round-parenthesis">)</span>'),'<span class="math-function">'+Fn(this.name)+'</span><span class="math-parenthesis math-round-parenthesis">(</span>'+r.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-round-parenthesis">)</span><span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+a}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=this.expr.toTex(e);return n(this,t,e&&e.implicit)&&(r="\\left(".concat(r,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(sm).join(",")+"\\right)="+r}}return Hu(i,"name",lm),i}),{isClass:!0,isNode:!0}),pm="IndexNode",mm=Me(pm,["Node","size"],(e=>{var{Node:t,size:r}=e;class n extends t{constructor(e,t){if(super(),this.dimensions=e,this.dotNotation=t||!1,!Array.isArray(e)||!e.every(fe))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}get type(){return pm}get isIndexNode(){return!0}_compile(e,t){var n=Zn(this.dimensions,(function(n,i){if(n.filter((e=>e.isSymbolNode&&"end"===e.name)).length>0){var a=Object.create(t);a.end=!0;var o=n._compile(e,a);return function(e,t,n){if(!q(n)&&!I(n)&&!z(n))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+xe(n));var a=r(n).valueOf(),s=Object.create(t);return s.end=a[i],o(e,s,n)}}return n._compile(e,t)})),i=y(e,"index");return function(e,t,r){var a=Zn(n,(function(n){return n(e,t,r)}));return i(...a)}}forEach(e){for(var t=0;t<this.dimensions.length;t++)e(this.dimensions[t],"dimensions["+t+"]",this)}map(e){for(var t=[],r=0;r<this.dimensions.length;r++)t[r]=this._ifNode(e(this.dimensions[r],"dimensions["+r+"]",this));return new n(t,this.dotNotation)}clone(){return new n(this.dimensions.slice(0),this.dotNotation)}isObjectProperty(){return 1===this.dimensions.length&&oe(this.dimensions[0])&&"string"==typeof this.dimensions[0].value}getObjectProperty(){return this.isObjectProperty()?this.dimensions[0].value:null}_toString(e){return this.dotNotation?"."+this.getObjectProperty():"["+this.dimensions.join(", ")+"]"}toJSON(){return{mathjs:pm,dimensions:this.dimensions,dotNotation:this.dotNotation}}static fromJSON(e){return new n(e.dimensions,e.dotNotation)}_toHTML(e){for(var t=[],r=0;r<this.dimensions.length;r++)t[r]=this.dimensions[r].toHTML();return this.dotNotation?'<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">'+Fn(this.getObjectProperty())+"</span>":'<span class="math-parenthesis math-square-parenthesis">[</span>'+t.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'}_toTex(e){var t=this.dimensions.map((function(t){return t.toTex(e)}));return this.dotNotation?"."+this.getObjectProperty():"_{"+t.join(",")+"}"}}return Hu(n,"name",pm),n}),{isClass:!0,isNode:!0}),hm="ObjectNode",dm=Me(hm,["Node"],(e=>{var{Node:t}=e;class r extends t{constructor(e){if(super(),this.properties=e||{},e&&("object"!=typeof e||!Object.keys(e).every((function(t){return fe(e[t])}))))throw new TypeError("Object containing Nodes expected")}get type(){return hm}get isObjectNode(){return!0}_compile(e,t){var r={};for(var n in this.properties)if(Ce(this.properties,n)){var i=Cn(n),a=JSON.parse(i),o=y(this.properties,n);r[a]=o._compile(e,t)}return function(e,t,n){var i={};for(var a in r)Ce(r,a)&&(i[a]=r[a](e,t,n));return i}}forEach(e){for(var t in this.properties)Ce(this.properties,t)&&e(this.properties[t],"properties["+Cn(t)+"]",this)}map(e){var t={};for(var n in this.properties)Ce(this.properties,n)&&(t[n]=this._ifNode(e(this.properties[n],"properties["+Cn(n)+"]",this)));return new r(t)}clone(){var e={};for(var t in this.properties)Ce(this.properties,t)&&(e[t]=this.properties[t]);return new r(e)}_toString(e){var t=[];for(var r in this.properties)Ce(this.properties,r)&&t.push(Cn(r)+": "+this.properties[r].toString(e));return"{"+t.join(", ")+"}"}toJSON(){return{mathjs:hm,properties:this.properties}}static fromJSON(e){return new r(e.properties)}_toHTML(e){var t=[];for(var r in this.properties)Ce(this.properties,r)&&t.push('<span class="math-symbol math-property">'+Fn(r)+'</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>'+this.properties[r].toHTML(e));return'<span class="math-parenthesis math-curly-parenthesis">{</span>'+t.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-curly-parenthesis">}</span>'}_toTex(e){var t=[];for(var r in this.properties)Ce(this.properties,r)&&t.push("\\mathbf{"+r+":} & "+this.properties[r].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}"+t.join("\n")+"\\end{array}\\right\\}"}}return Hu(r,"name",hm),r}),{isClass:!0,isNode:!0});function gm(e,t){return new A(e,new E(t),new Set(Object.keys(t)))}var vm="OperatorNode",ym=Me(vm,["Node"],(e=>{var{Node:t}=e;function r(e,t){var n=e;if("auto"===t)for(;he(n);)n=n.content;return!!oe(n)||!!me(n)&&r(n.args[0],t)}function n(e,t,n,i,a){var o,s=Wp(e,t,n),u=Vp(e,t);if("all"===t||i.length>2&&"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier())return i.map((function(e){switch(e.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}}));switch(i.length){case 0:o=[];break;case 1:var c=Wp(i[0],t,n,e);if(a&&null!==c){var l,f;if("keep"===t?(l=i[0].getIdentifier(),f=e.getIdentifier()):(l=i[0].getContent().getIdentifier(),f=e.getContent().getIdentifier()),!1===$p[s][f].latexLeftParens){o=[!1];break}if(!1===$p[c][l].latexParens){o=[!1];break}}if(null===c){o=[!1];break}if(c<=s){o=[!0];break}o=[!1];break;case 2:var p,m,h=Wp(i[0],t,n,e),d=Zp(e,i[0],t);p=null!==h&&(h===s&&"right"===u&&!d||h<s);var g,v,y,x=Wp(i[1],t,n,e),b=Zp(e,i[1],t);m=null!==x&&(x===s&&"left"===u&&!b||x<s),a&&("keep"===t?(g=e.getIdentifier(),v=e.args[0].getIdentifier(),y=e.args[1].getIdentifier()):(g=e.getContent().getIdentifier(),v=e.args[0].getContent().getIdentifier(),y=e.args[1].getContent().getIdentifier()),null!==h&&(!1===$p[s][g].latexLeftParens&&(p=!1),!1===$p[h][v].latexParens&&(p=!1)),null!==x&&(!1===$p[s][g].latexRightParens&&(m=!1),!1===$p[x][y].latexParens&&(m=!1))),o=[p,m];break;default:"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier()||(o=i.map((function(r){var i=Wp(r,t,n,e),a=Zp(e,r,t),o=Vp(r,t);return null!==i&&(s===i&&u===o&&!a||i<s)})))}if(i.length>=2&&"OperatorNode:multiply"===e.getIdentifier()&&e.implicit&&"all"!==t&&"hide"===n)for(var w=1;w<o.length;++w)!r(i[w],t)||o[w-1]||"keep"===t&&he(i[w-1])||(o[w]=!0);return o}class i extends t{constructor(e,t,r,n,i){if(super(),"string"!=typeof e)throw new TypeError('string expected for parameter "op"');if("string"!=typeof t)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(r)||!r.every(fe))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=!0===n,this.isPercentage=!0===i,this.op=e,this.fn=t,this.args=r||[]}get type(){return vm}get isOperatorNode(){return!0}_compile(e,t){if("string"!=typeof this.fn||!w(e,this.fn))throw e[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var r=y(e,this.fn),n=Zn(this.args,(function(r){return r._compile(e,t)}));if("function"==typeof r&&!0===r.rawArgs){var i=this.args;return function(t,n,a){return r(i,e,gm(t,n))}}if(1===n.length){var a=n[0];return function(e,t,n){return r(a(e,t,n))}}if(2===n.length){var o=n[0],s=n[1];return function(e,t,n){return r(o(e,t,n),s(e,t,n))}}return function(e,t,i){return r.apply(null,Zn(n,(function(r){return r(e,t,i)})))}}forEach(e){for(var t=0;t<this.args.length;t++)e(this.args[t],"args["+t+"]",this)}map(e){for(var t=[],r=0;r<this.args.length;r++)t[r]=this._ifNode(e(this.args[r],"args["+r+"]",this));return new i(this.op,this.fn,t,this.implicit,this.isPercentage)}clone(){return new i(this.op,this.fn,this.args.slice(0),this.implicit,this.isPercentage)}isUnary(){return 1===this.args.length}isBinary(){return 2===this.args.length}_toString(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,t,r,i,!1);if(1===i.length){var o=Vp(this,t),s=i[0].toString(e);a[0]&&(s="("+s+")");var u=/[a-zA-Z]+/.test(this.op);return"right"===o?this.op+(u?" ":"")+s:"left"===o?s+(u?" ":"")+this.op:s+this.op}if(2===i.length){var c=i[0].toString(e),l=i[1].toString(e);return a[0]&&(c="("+c+")"),a[1]&&(l="("+l+")"),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?c+" "+l:c+" "+this.op+" "+l}if(i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var f=i.map((function(t,r){return t=t.toString(e),a[r]&&(t="("+t+")"),t}));return this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?f.join(" "):f.join(" "+this.op+" ")}return this.fn+"("+this.args.join(", ")+")"}toJSON(){return{mathjs:vm,op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}}static fromJSON(e){return new i(e.op,e.fn,e.args,e.implicit,e.isPercentage)}_toHTML(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,t,r,i,!1);if(1===i.length){var o=Vp(this,t),s=i[0].toHTML(e);return a[0]&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),"right"===o?'<span class="math-operator math-unary-operator math-lefthand-unary-operator">'+Fn(this.op)+"</span>"+s:s+'<span class="math-operator math-unary-operator math-righthand-unary-operator">'+Fn(this.op)+"</span>"}if(2===i.length){var u=i[0].toHTML(e),c=i[1].toHTML(e);return a[0]&&(u='<span class="math-parenthesis math-round-parenthesis">(</span>'+u+'<span class="math-parenthesis math-round-parenthesis">)</span>'),a[1]&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?u+'<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'+c:u+'<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Fn(this.op)+"</span>"+c}var l=i.map((function(t,r){return t=t.toHTML(e),a[r]&&(t='<span class="math-parenthesis math-round-parenthesis">(</span>'+t+'<span class="math-parenthesis math-round-parenthesis">)</span>'),t}));return i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())?this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?l.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'):l.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Fn(this.op)+"</span>"):'<span class="math-function">'+Fn(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+l.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,t,r,i,!0),o=nm[this.fn];if(o=void 0===o?this.op:o,1===i.length){var s=Vp(this,t),u=i[0].toTex(e);return a[0]&&(u="\\left(".concat(u,"\\right)")),"right"===s?o+u:u+o}if(2===i.length){var c=i[0],l=c.toTex(e);a[0]&&(l="\\left(".concat(l,"\\right)"));var f,p=i[1].toTex(e);switch(a[1]&&(p="\\left(".concat(p,"\\right)")),f="keep"===t?c.getIdentifier():c.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return o+"{"+l+"}{"+p+"}";case"OperatorNode:pow":switch(l="{"+l+"}",p="{"+p+"}",f){case"ConditionalNode":case"OperatorNode:divide":l="\\left(".concat(l,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&"hide"===r)return l+"~"+p}return l+o+p}if(i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var m=i.map((function(t,r){return t=t.toTex(e),a[r]&&(t="\\left(".concat(t,"\\right)")),t}));return"OperatorNode:multiply"===this.getIdentifier()&&this.implicit&&"hide"===r?m.join("~"):m.join(o)}return"\\mathrm{"+this.fn+"}\\left("+i.map((function(t){return t.toTex(e)})).join(",")+"\\right)"}getIdentifier(){return this.type+":"+this.fn}}return Hu(i,"name",vm),i}),{isClass:!0,isNode:!0}),xm="ParenthesisNode",bm=Me(xm,["Node"],(e=>{var{Node:t}=e;class r extends t{constructor(e){if(super(),!fe(e))throw new TypeError('Node expected for parameter "content"');this.content=e}get type(){return xm}get isParenthesisNode(){return!0}_compile(e,t){return this.content._compile(e,t)}getContent(){return this.content.getContent()}forEach(e){e(this.content,"content",this)}map(e){var t=e(this.content,"content",this);return new r(t)}clone(){return new r(this.content)}_toString(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)}toJSON(){return{mathjs:xm,content:this.content}}static fromJSON(e){return new r(e.content)}_toHTML(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?'<span class="math-parenthesis math-round-parenthesis">(</span>'+this.content.toHTML(e)+'<span class="math-parenthesis math-round-parenthesis">)</span>':this.content.toHTML(e)}_toTex(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)}}return Hu(r,"name",xm),r}),{isClass:!0,isNode:!0}),wm="RangeNode",Dm=Me(wm,["Node"],(e=>{var{Node:t}=e;function r(e,t,r){var n=Wp(e,t,r),i={},a=Wp(e.start,t,r);if(i.start=null!==a&&a<=n||"all"===t,e.step){var o=Wp(e.step,t,r);i.step=null!==o&&o<=n||"all"===t}var s=Wp(e.end,t,r);return i.end=null!==s&&s<=n||"all"===t,i}class n extends t{constructor(e,t,r){if(super(),!fe(e))throw new TypeError("Node expected");if(!fe(t))throw new TypeError("Node expected");if(r&&!fe(r))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=e,this.end=t,this.step=r||null}get type(){return wm}get isRangeNode(){return!0}needsEnd(){return this.filter((function(e){return ve(e)&&"end"===e.name})).length>0}_compile(e,t){var r=e.range,n=this.start._compile(e,t),i=this.end._compile(e,t);if(this.step){var a=this.step._compile(e,t);return function(e,t,o){return r(n(e,t,o),i(e,t,o),a(e,t,o))}}return function(e,t,a){return r(n(e,t,a),i(e,t,a))}}forEach(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)}map(e){return new n(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))}clone(){return new n(this.start,this.end,this.step&&this.step)}_toString(e){var t,n=r(this,e&&e.parenthesis?e.parenthesis:"keep",e&&e.implicit),i=this.start.toString(e);if(n.start&&(i="("+i+")"),t=i,this.step){var a=this.step.toString(e);n.step&&(a="("+a+")"),t+=":"+a}var o=this.end.toString(e);return n.end&&(o="("+o+")"),t+":"+o}toJSON(){return{mathjs:wm,start:this.start,end:this.end,step:this.step}}static fromJSON(e){return new n(e.start,e.end,e.step)}_toHTML(e){var t,n=r(this,e&&e.parenthesis?e.parenthesis:"keep",e&&e.implicit),i=this.start.toHTML(e);if(n.start&&(i='<span class="math-parenthesis math-round-parenthesis">(</span>'+i+'<span class="math-parenthesis math-round-parenthesis">)</span>'),t=i,this.step){var a=this.step.toHTML(e);n.step&&(a='<span class="math-parenthesis math-round-parenthesis">(</span>'+a+'<span class="math-parenthesis math-round-parenthesis">)</span>'),t+='<span class="math-operator math-range-operator">:</span>'+a}var o=this.end.toHTML(e);return n.end&&(o='<span class="math-parenthesis math-round-parenthesis">(</span>'+o+'<span class="math-parenthesis math-round-parenthesis">)</span>'),t+'<span class="math-operator math-range-operator">:</span>'+o}_toTex(e){var t=r(this,e&&e.parenthesis?e.parenthesis:"keep",e&&e.implicit),n=this.start.toTex(e);if(t.start&&(n="\\left(".concat(n,"\\right)")),this.step){var i=this.step.toTex(e);t.step&&(i="\\left(".concat(i,"\\right)")),n+=":"+i}var a=this.end.toTex(e);return t.end&&(a="\\left(".concat(a,"\\right)")),n+":"+a}}return Hu(n,"name",wm),n}),{isClass:!0,isNode:!0}),Nm="RelationalNode",Em=Me(Nm,["Node"],(e=>{var{Node:t}=e,r={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="};class n extends t{constructor(e,t){if(super(),!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(t))throw new TypeError("Parameter params must be an array");if(e.length!==t.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=t}get type(){return Nm}get isRelationalNode(){return!0}_compile(e,t){var r=this,n=this.params.map((r=>r._compile(e,t)));return function(t,i,a){for(var o,s=n[0](t,i,a),u=0;u<r.conditionals.length;u++)if(o=s,s=n[u+1](t,i,a),!y(e,r.conditionals[u])(o,s))return!1;return!0}}forEach(e){this.params.forEach(((t,r)=>e(t,"params["+r+"]",this)),this)}map(e){return new n(this.conditionals.slice(),this.params.map(((t,r)=>this._ifNode(e(t,"params["+r+"]",this))),this))}clone(){return new n(this.conditionals,this.params)}_toString(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",n=Wp(this,t,e&&e.implicit),i=this.params.map((function(r,i){var a=Wp(r,t,e&&e.implicit);return"all"===t||null!==a&&a<=n?"("+r.toString(e)+")":r.toString(e)})),a=i[0],o=0;o<this.conditionals.length;o++)a+=" "+r[this.conditionals[o]],a+=" "+i[o+1];return a}toJSON(){return{mathjs:Nm,conditionals:this.conditionals,params:this.params}}static fromJSON(e){return new n(e.conditionals,e.params)}_toHTML(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",n=Wp(this,t,e&&e.implicit),i=this.params.map((function(r,i){var a=Wp(r,t,e&&e.implicit);return"all"===t||null!==a&&a<=n?'<span class="math-parenthesis math-round-parenthesis">(</span>'+r.toHTML(e)+'<span class="math-parenthesis math-round-parenthesis">)</span>':r.toHTML(e)})),a=i[0],o=0;o<this.conditionals.length;o++)a+='<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Fn(r[this.conditionals[o]])+"</span>"+i[o+1];return a}_toTex(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",r=Wp(this,t,e&&e.implicit),n=this.params.map((function(n,i){var a=Wp(n,t,e&&e.implicit);return"all"===t||null!==a&&a<=r?"\\left("+n.toTex(e)+"\right)":n.toTex(e)})),i=n[0],a=0;a<this.conditionals.length;a++)i+=nm[this.conditionals[a]]+n[a+1];return i}}return Hu(n,"name",Nm),n}),{isClass:!0,isNode:!0}),Am=Me("SymbolNode",["math","?Unit","Node"],(e=>{var{math:t,Unit:r,Node:n}=e;function i(e){return!!r&&r.isValuelessUnit(e)}class a extends n{constructor(e){if(super(),"string"!=typeof e)throw new TypeError('String expected for parameter "name"');this.name=e}get type(){return"SymbolNode"}get isSymbolNode(){return!0}_compile(e,t){var n=this.name;if(!0===t[n])return function(e,t,r){return y(t,n)};if(n in e)return function(t,r,i){return t.has(n)?t.get(n):y(e,n)};var o=i(n);return function(e,t,i){return e.has(n)?e.get(n):o?new r(null,n):a.onUndefinedSymbol(n)}}forEach(e){}map(e){return this.clone()}static onUndefinedSymbol(e){throw new Error("Undefined symbol "+e)}clone(){return new a(this.name)}_toString(e){return this.name}_toHTML(e){var t=Fn(this.name);return"true"===t||"false"===t?'<span class="math-symbol math-boolean">'+t+"</span>":"i"===t?'<span class="math-symbol math-imaginary-symbol">'+t+"</span>":"Infinity"===t?'<span class="math-symbol math-infinity-symbol">'+t+"</span>":"NaN"===t?'<span class="math-symbol math-nan-symbol">'+t+"</span>":"null"===t?'<span class="math-symbol math-null-symbol">'+t+"</span>":"undefined"===t?'<span class="math-symbol math-undefined-symbol">'+t+"</span>":'<span class="math-symbol">'+t+"</span>"}toJSON(){return{mathjs:"SymbolNode",name:this.name}}static fromJSON(e){return new a(e.name)}_toTex(e){var r=!1;void 0===t[this.name]&&i(this.name)&&(r=!0);var n=sm(this.name,r);return"\\"===n[0]?n:" "+n}}return a}),{isClass:!0,isNode:!0}),Sm="FunctionNode",Cm=Me(Sm,["math","Node","SymbolNode"],(e=>{var t,{math:r,Node:n,SymbolNode:i}=e,a=e=>Sn(e,{truncate:78});function o(e,t,r){for(var n,i="",a=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,o=0;null!==(n=a.exec(e));)if(i+=e.substring(o,n.index),o=n.index,"$$"===n[0])i+="$",o++;else{o+=n[0].length;var s=t[n[1]];if(!s)throw new ReferenceError("Template: Property "+n[1]+" does not exist.");if(void 0===n[2])switch(typeof s){case"string":i+=s;break;case"object":if(fe(s))i+=s.toTex(r);else{if(!Array.isArray(s))throw new TypeError("Template: "+n[1]+" has to be a Node, String or array of Nodes");i+=s.map((function(e,t){if(fe(e))return e.toTex(r);throw new TypeError("Template: "+n[1]+"["+t+"] is not a Node.")})).join(",")}break;default:throw new TypeError("Template: "+n[1]+" has to be a Node, String or array of Nodes")}else{if(!fe(s[n[2]]&&s[n[2]]))throw new TypeError("Template: "+n[1]+"["+n[2]+"] is not a Node.");i+=s[n[2]].toTex(r)}}return i+e.slice(o)}class s extends n{constructor(e,t){if(super(),"string"==typeof e&&(e=new i(e)),!fe(e))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(t)||!t.every(fe))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=e,this.args=t||[]}get name(){return this.fn.name||""}get type(){return Sm}get isFunctionNode(){return!0}_compile(e,t){var r=this.args.map((r=>r._compile(e,t)));if(!ve(this.fn)){if(te(this.fn)&&le(this.fn.index)&&this.fn.index.isObjectProperty()){var n=this.fn.object._compile(e,t),i=this.fn.index.getObjectProperty(),o=this.args;return function(t,a,s){var u=n(t,a,s),c=function(e,t){if(!w(e,t))throw new Error('No access to method "'+t+'"');return e[t]}(u,i);if(null!=c&&c.rawArgs)return c(o,e,gm(t,a));var l=r.map((e=>e(t,a,s)));return c.apply(u,l)}}var u=this.fn.toString(),c=this.fn._compile(e,t),l=this.args;return function(t,n,i){var o=c(t,n,i);if("function"!=typeof o)throw new TypeError("Expression '".concat(u,"' did not evaluate to a function; value is:")+"\n ".concat(a(o)));if(o.rawArgs)return o(l,e,gm(t,n));var s=r.map((e=>e(t,n,i)));return o.apply(o,s)}}var f=this.fn.name;if(t[f]){var p=this.args;return function(t,n,i){var o=y(n,f);if("function"!=typeof o)throw new TypeError("Argument '".concat(f,"' was not a function; received: ").concat(a(o)));if(o.rawArgs)return o(p,e,gm(t,n));var s=r.map((e=>e(t,n,i)));return o.apply(o,s)}}var m=f in e?y(e,f):void 0,h="function"==typeof m&&!0===m.rawArgs,d=t=>{var r;if(t.has(f))r=t.get(f);else{if(!(f in e))return s.onUndefinedFunction(f);r=y(e,f)}if("function"==typeof r)return r;throw new TypeError("'".concat(f,"' is not a function; its value is:\n ").concat(a(r)))};if(h){var g=this.args;return function(t,n,i){var a=d(t);return!0===a.rawArgs?a(g,e,gm(t,n)):a(...r.map((e=>e(t,n,i))))}}switch(r.length){case 0:return function(e,t,r){return d(e)()};case 1:return function(e,t,n){return d(e)((0,r[0])(e,t,n))};case 2:return function(e,t,n){var i=d(e),a=r[0],o=r[1];return i(a(e,t,n),o(e,t,n))};default:return function(e,t,n){return d(e)(...r.map((r=>r(e,t,n))))}}}forEach(e){e(this.fn,"fn",this);for(var t=0;t<this.args.length;t++)e(this.args[t],"args["+t+"]",this)}map(e){for(var t=this._ifNode(e(this.fn,"fn",this)),r=[],n=0;n<this.args.length;n++)r[n]=this._ifNode(e(this.args[n],"args["+n+"]",this));return new s(t,r)}clone(){return new s(this.fn,this.args.slice(0))}toString(e){var t,r=this.fn.toString(e);return e&&"object"==typeof e.handler&&Ce(e.handler,r)&&(t=e.handler[r](this,e)),void 0!==t?t:super.toString(e)}_toString(e){var t=this.args.map((function(t){return t.toString(e)}));return(ue(this.fn)?"("+this.fn.toString(e)+")":this.fn.toString(e))+"("+t.join(", ")+")"}toJSON(){return{mathjs:Sm,fn:this.fn,args:this.args}}_toHTML(e){var t=this.args.map((function(t){return t.toHTML(e)}));return'<span class="math-function">'+Fn(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+t.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}toTex(e){var t;return e&&"object"==typeof e.handler&&Ce(e.handler,this.name)&&(t=e.handler[this.name](this,e)),void 0!==t?t:super.toTex(e)}_toTex(e){var t,n,i=this.args.map((function(t){return t.toTex(e)}));switch(im[this.name]&&(t=im[this.name]),!r[this.name]||"function"!=typeof r[this.name].toTex&&"object"!=typeof r[this.name].toTex&&"string"!=typeof r[this.name].toTex||(t=r[this.name].toTex),typeof t){case"function":n=t(this,e);break;case"string":n=o(t,this,e);break;case"object":switch(typeof t[i.length]){case"function":n=t[i.length](this,e);break;case"string":n=o(t[i.length],this,e)}}return void 0!==n?n:o("\\mathrm{${name}}\\left(${args}\\right)",this,e)}getIdentifier(){return this.type+":"+this.name}}return t=s,Hu(s,"name",Sm),Hu(s,"onUndefinedFunction",(function(e){throw new Error("Undefined function "+e)})),Hu(s,"fromJSON",(function(e){return new t(e.fn,e.args)})),s}),{isClass:!0,isNode:!0}),Mm="parse",Fm=Me(Mm,["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],(e=>{var{typed:t,numeric:r,config:n,AccessorNode:i,ArrayNode:a,AssignmentNode:o,BlockNode:s,ConditionalNode:u,ConstantNode:c,FunctionAssignmentNode:l,FunctionNode:f,IndexNode:p,ObjectNode:h,OperatorNode:d,ParenthesisNode:g,RangeNode:v,RelationalNode:y,SymbolNode:x}=e,b=t(Mm,{string:function(e){return q(e,{})},"Array | Matrix":function(e){return w(e,{})},"string, Object":function(e,t){return q(e,void 0!==t.nodes?t.nodes:{})},"Array | Matrix, Object":w});function w(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=void 0!==t.nodes?t.nodes:{};return gi(e,(function(e){if("string"!=typeof e)throw new TypeError("String expected");return q(e,r)}))}var D={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},N={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},E={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},A={true:!0,false:!1,null:null,undefined:void 0},S=["NaN","Infinity"],C={'"':'"',"'":"'","\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function M(e,t){return e.expression.substr(e.index,t)}function F(e){return M(e,1)}function T(e){e.index++}function _(e){return e.expression.charAt(e.index-1)}function B(e){return e.expression.charAt(e.index+1)}function O(e){for(e.tokenType=D.NULL,e.token="",e.comment="";;){if("#"===F(e))for(;"\n"!==F(e)&&""!==F(e);)e.comment+=F(e),T(e);if(!b.isWhitespace(F(e),e.nestingLevel))break;T(e)}if(""!==F(e)){if("\n"===F(e)&&!e.nestingLevel)return e.tokenType=D.DELIMITER,e.token=F(e),void T(e);var t=F(e),r=M(e,2),n=M(e,3);if(3===n.length&&N[n])return e.tokenType=D.DELIMITER,e.token=n,T(e),T(e),void T(e);if(2===r.length&&N[r])return e.tokenType=D.DELIMITER,e.token=r,T(e),void T(e);if(N[t])return e.tokenType=D.DELIMITER,e.token=t,void T(e);if(b.isDigitDot(t)){e.tokenType=D.NUMBER;var i=M(e,2);if("0b"===i||"0o"===i||"0x"===i){for(e.token+=F(e),T(e),e.token+=F(e),T(e);b.isHexDigit(F(e));)e.token+=F(e),T(e);if("."===F(e))for(e.token+=".",T(e);b.isHexDigit(F(e));)e.token+=F(e),T(e);else if("i"===F(e))for(e.token+="i",T(e);b.isDigit(F(e));)e.token+=F(e),T(e);return}if("."===F(e)){if(e.token+=F(e),T(e),!b.isDigit(F(e)))return void(e.tokenType=D.DELIMITER)}else{for(;b.isDigit(F(e));)e.token+=F(e),T(e);b.isDecimalMark(F(e),B(e))&&(e.token+=F(e),T(e))}for(;b.isDigit(F(e));)e.token+=F(e),T(e);if("E"===F(e)||"e"===F(e))if(b.isDigit(B(e))||"-"===B(e)||"+"===B(e)){if(e.token+=F(e),T(e),"+"!==F(e)&&"-"!==F(e)||(e.token+=F(e),T(e)),!b.isDigit(F(e)))throw ae(e,'Digit expected, got "'+F(e)+'"');for(;b.isDigit(F(e));)e.token+=F(e),T(e);if(b.isDecimalMark(F(e),B(e)))throw ae(e,'Digit expected, got "'+F(e)+'"')}else if("."===B(e))throw T(e),ae(e,'Digit expected, got "'+F(e)+'"')}else{if(!b.isAlpha(F(e),_(e),B(e))){for(e.tokenType=D.UNKNOWN;""!==F(e);)e.token+=F(e),T(e);throw ae(e,'Syntax error in part "'+e.token+'"')}for(;b.isAlpha(F(e),_(e),B(e))||b.isDigit(F(e));)e.token+=F(e),T(e);Ce(E,e.token)?e.tokenType=D.DELIMITER:e.tokenType=D.SYMBOL}}else e.tokenType=D.DELIMITER}function k(e){do{O(e)}while("\n"===e.token)}function z(e){e.nestingLevel++}function I(e){e.nestingLevel--}function q(e,t){var r={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:D.NULL,nestingLevel:0,conditionalLevel:null};m(r,{expression:e,extraNodes:t}),O(r);var n=function(e){var t,r,n=[];for(""!==e.token&&"\n"!==e.token&&";"!==e.token&&(t=R(e),e.comment&&(t.comment=e.comment));"\n"===e.token||";"===e.token;)0===n.length&&t&&(r=";"!==e.token,n.push({node:t,visible:r})),O(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&(t=R(e),e.comment&&(t.comment=e.comment),r=";"!==e.token,n.push({node:t,visible:r}));return n.length>0?new s(n):(t||(t=new c(void 0),e.comment&&(t.comment=e.comment)),t)}(r);if(""!==r.token)throw r.tokenType===D.DELIMITER?ue(r,"Unexpected operator "+r.token):ae(r,'Unexpected part "'+r.token+'"');return n}function R(e){var t,r,n,i,a=function(e){for(var t=function(e){for(var t=P(e);"or"===e.token;)k(e),t=new d("or","or",[t,P(e)]);return t}(e);"?"===e.token;){var r=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,k(e);var n=t,i=R(e);if(":"!==e.token)throw ae(e,"False part of conditional expression expected");e.conditionalLevel=null,k(e);var a=R(e);t=new u(n,i,a),e.conditionalLevel=r}return t}(e);if("="===e.token){if(ve(a))return t=a.name,k(e),n=R(e),new o(new x(t),n);if(te(a))return k(e),n=R(e),new o(a.object,a.index,n);if(ce(a)&&ve(a.fn)&&(i=!0,r=[],t=a.name,a.args.forEach((function(e,t){ve(e)?r[t]=e.name:i=!1})),i))return k(e),n=R(e),new l(t,r,n);throw ae(e,"Invalid left hand side of assignment operator =")}return a}function P(e){for(var t=j(e);"xor"===e.token;)k(e),t=new d("xor","xor",[t,j(e)]);return t}function j(e){for(var t=U(e);"and"===e.token;)k(e),t=new d("and","and",[t,U(e)]);return t}function U(e){for(var t=L(e);"|"===e.token;)k(e),t=new d("|","bitOr",[t,L(e)]);return t}function L(e){for(var t=H(e);"^|"===e.token;)k(e),t=new d("^|","bitXor",[t,H(e)]);return t}function H(e){for(var t=$(e);"&"===e.token;)k(e),t=new d("&","bitAnd",[t,$(e)]);return t}function $(e){for(var t=[G(e)],r=[],n={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};Ce(n,e.token);){var i={name:e.token,fn:n[e.token]};r.push(i),k(e),t.push(G(e))}return 1===t.length?t[0]:2===t.length?new d(r[0].name,r[0].fn,t):new y(r.map((e=>e.fn)),t)}function G(e){var t,r,n,i;t=W(e);for(var a={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Ce(a,e.token);)n=a[r=e.token],k(e),i=[t,W(e)],t=new d(r,n,i);return t}function W(e){var t,r,n,i;t=V(e);for(var a={to:"to",in:"to"};Ce(a,e.token);)n=a[r=e.token],k(e),"in"===r&&""===e.token?t=new d("*","multiply",[t,new x("in")],!0):(i=[t,V(e)],t=new d(r,n,i));return t}function V(e){var t,r=[];if(t=":"===e.token?new c(1):Z(e),":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(r.push(t);":"===e.token&&r.length<3;)k(e),")"===e.token||"]"===e.token||","===e.token||""===e.token?r.push(new x("end")):r.push(Z(e));t=3===r.length?new v(r[0],r[2],r[1]):new v(r[0],r[1])}return t}function Z(e){var t,r,n,i;t=Y(e);for(var a={"+":"add","-":"subtract"};Ce(a,e.token);){n=a[r=e.token],k(e);var o=Y(e);i=o.isPercentage?[t,new d("*","multiply",[t,o])]:[t,o],t=new d(r,n,i)}return t}function Y(e){var t,r,n,i;r=t=J(e);for(var a={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};Ce(a,e.token);)i=a[n=e.token],k(e),r=J(e),t=new d(n,i,[t,r]);return t}function J(e){var t,r;for(r=t=X(e);e.tokenType===D.SYMBOL||"in"===e.token&&oe(t)||"in"===e.token&&me(t)&&"unaryMinus"===t.fn&&oe(t.args[0])||!(e.tokenType!==D.NUMBER||oe(r)||me(r)&&"!"!==r.op)||"("===e.token;)r=X(e),t=new d("*","multiply",[t,r],!0);return t}function X(e){for(var t=Q(e),r=t,n=[];"/"===e.token&&se(r);){if(n.push(m({},e)),k(e),e.tokenType!==D.NUMBER){m(e,n.pop());break}if(n.push(m({},e)),k(e),e.tokenType!==D.SYMBOL&&"("!==e.token&&"in"!==e.token){n.pop(),m(e,n.pop());break}m(e,n.pop()),n.pop(),r=Q(e),t=new d("/","divide",[t,r])}return t}function Q(e){var t,r,n,i;t=K(e);for(var a={"%":"mod",mod:"mod"};Ce(a,e.token);)n=a[r=e.token],k(e),"%"===r&&e.tokenType===D.DELIMITER&&"("!==e.token?t=new d("/","divide",[t,new c(100)],!1,!0):(i=[t,K(e)],t=new d(r,n,i));return t}function K(e){var t,i,o,s={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Ce(s,e.token)?(o=s[e.token],t=e.token,k(e),i=[K(e)],new d(t,o,i)):function(e){var t,i,o,s;return t=function(e){var t,i,o;t=function(e){var t=[];if(e.tokenType===D.SYMBOL&&Ce(e.extraNodes,e.token)){var i=e.extraNodes[e.token];if(O(e),"("===e.token){if(t=[],z(e),O(e),")"!==e.token)for(t.push(R(e));","===e.token;)O(e),t.push(R(e));if(")"!==e.token)throw ae(e,"Parenthesis ) expected");I(e),O(e)}return new i(t)}return function(e){var t;return e.tokenType===D.SYMBOL||e.tokenType===D.DELIMITER&&e.token in E?(t=e.token,O(e),ee(e,Ce(A,t)?new c(A[t]):S.includes(t)?new c(r(t,"number")):new x(t))):function(e){var t;return'"'===e.token||"'"===e.token?(t=re(e,e.token),ee(e,new c(t))):function(e){var t,i,o,s;if("["===e.token){if(z(e),O(e),"]"!==e.token){var u=ne(e);if(";"===e.token){for(o=1,i=[u];";"===e.token;)O(e),"]"!==e.token&&(i[o]=ne(e),o++);if("]"!==e.token)throw ae(e,"End of matrix ] expected");I(e),O(e),s=i[0].items.length;for(var l=1;l<o;l++)if(i[l].items.length!==s)throw ue(e,"Column dimensions mismatch ("+i[l].items.length+" !== "+s+")");t=new a(i)}else{if("]"!==e.token)throw ae(e,"End of matrix ] expected");I(e),O(e),t=u}}else I(e),O(e),t=new a([]);return ee(e,t)}return function(e){if("{"===e.token){var t;z(e);var i={};do{if(O(e),"}"!==e.token){if('"'===e.token||"'"===e.token)t=re(e,e.token);else{if(!(e.tokenType===D.SYMBOL||e.tokenType===D.DELIMITER&&e.token in E))throw ae(e,"Symbol or string expected as object key");t=e.token,O(e)}if(":"!==e.token)throw ae(e,"Colon : expected after object key");O(e),i[t]=R(e)}}while(","===e.token);if("}"!==e.token)throw ae(e,"Comma , or bracket } expected after object value");I(e),O(e);var a=new h(i);return ee(e,a)}return function(e){var t;if(e.tokenType===D.NUMBER){t=e.token,O(e);var i=Re(t,n),a=r(t,i);return new c(a)}return function(e){var t;if("("===e.token){if(z(e),O(e),t=R(e),")"!==e.token)throw ae(e,"Parenthesis ) expected");return I(e),O(e),ee(e,t=new g(t))}return function(e){throw""===e.token?ae(e,"Unexpected end of expression"):ae(e,"Value expected")}(e)}(e)}(e)}(e)}(e)}(e)}(e)}(e);for(var s={"!":"factorial","'":"ctranspose"};Ce(s,e.token);)o=s[i=e.token],O(e),t=ee(e,t=new d(i,o,[t]));return t}(e),("^"===e.token||".^"===e.token)&&(o="^"===(i=e.token)?"pow":"dotPow",k(e),s=[t,K(e)],t=new d(i,o,s)),t}(e)}function ee(e,t,r){for(var n;("("===e.token||"["===e.token||"."===e.token)&&(!r||r.includes(e.token));)if(n=[],"("===e.token){if(!ve(t)&&!te(t))return t;if(z(e),O(e),")"!==e.token)for(n.push(R(e));","===e.token;)O(e),n.push(R(e));if(")"!==e.token)throw ae(e,"Parenthesis ) expected");I(e),O(e),t=new f(t,n)}else if("["===e.token){if(z(e),O(e),"]"!==e.token)for(n.push(R(e));","===e.token;)O(e),n.push(R(e));if("]"!==e.token)throw ae(e,"Parenthesis ] expected");I(e),O(e),t=new i(t,new p(n))}else{if(O(e),!(e.tokenType===D.SYMBOL||e.tokenType===D.DELIMITER&&e.token in E))throw ae(e,"Property name expected after dot");n.push(new c(e.token)),O(e),t=new i(t,new p(n,!0))}return t}function re(e,t){for(var r="";""!==F(e)&&F(e)!==t;)if("\\"===F(e)){T(e);var n=F(e),i=C[n];if(void 0!==i)r+=i,e.index+=1;else{if("u"!==n)throw ae(e,"Bad escape character \\".concat(n));var a=e.expression.slice(e.index+1,e.index+5);if(!/^[0-9A-Fa-f]{4}$/.test(a))throw ae(e,"Invalid unicode character \\u".concat(a));r+=String.fromCharCode(parseInt(a,16)),e.index+=5}}else r+=F(e),T(e);if(O(e),e.token!==t)throw ae(e,"End of string ".concat(t," expected"));return O(e),r}function ne(e){for(var t=[R(e)],r=1;","===e.token;)O(e),"]"!==e.token&&";"!==e.token&&(t[r]=R(e),r++);return new a(t)}function ie(e){return e.index-e.token.length+1}function ae(e,t){var r=ie(e),n=new SyntaxError(t+" (char "+r+")");return n.char=r,n}function ue(e,t){var r=ie(e),n=new SyntaxError(t+" (char "+r+")");return n.char=r,n}return b.isAlpha=function(e,t,r){return b.isValidLatinOrGreek(e)||b.isValidMathSymbol(e,r)||b.isValidMathSymbol(t,e)},b.isValidLatinOrGreek=function(e){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(e)},b.isValidMathSymbol=function(e,t){return/^[\uD835]$/.test(e)&&/^[\uDC00-\uDFFF]$/.test(t)&&/^[^\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDFCC\uDFCD]$/.test(t)},b.isWhitespace=function(e,t){return" "===e||"\t"===e||"\n"===e&&t>0},b.isDecimalMark=function(e,t){return"."===e&&"/"!==t&&"*"!==t&&"^"!==t},b.isDigitDot=function(e){return e>="0"&&e<="9"||"."===e},b.isDigit=function(e){return e>="0"&&e<="9"},b.isHexDigit=function(e){return e>="0"&&e<="9"||e>="a"&&e<="f"||e>="A"&&e<="F"},t.addConversion({from:"string",to:"Node",convert:b}),b})),Tm="compile",_m=Me(Tm,["typed","parse"],(e=>{var{typed:t,parse:r}=e;return t(Tm,{string:function(e){return r(e).compile()},"Array | Matrix":function(e){return gi(e,(function(e){return r(e).compile()}))}})})),Bm="evaluate",Om=Me(Bm,["typed","parse"],(e=>{var{typed:t,parse:r}=e;return t(Bm,{string:function(e){var t=C();return r(e).compile().evaluate(t)},"string, Map | Object":function(e,t){return r(e).compile().evaluate(t)},"Array | Matrix":function(e){var t=C();return gi(e,(function(e){return r(e).compile().evaluate(t)}))},"Array | Matrix, Map | Object":function(e,t){return gi(e,(function(e){return r(e).compile().evaluate(t)}))}})})),km=Me("Parser",["evaluate","parse"],(e=>{var{evaluate:t,parse:r}=e;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:C(),writable:!1})}return n.prototype.type="Parser",n.prototype.isParser=!0,n.prototype.evaluate=function(e){return t(e,this.scope)},n.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},n.prototype.getAll=function(){return function(e){if(e instanceof E)return e.wrappedObject;var t={};for(var r of e.keys())x(t,r,e.get(r));return t}(this.scope)},n.prototype.getAllAsMap=function(){return this.scope},n.prototype.set=function(e,t){if(!function(e){if(0===e.length)return!1;for(var t=0;t<e.length;t++){var n=e.charAt(t-1),i=e.charAt(t),a=e.charAt(t+1);if(!(r.isAlpha(i,n,a)||t>0&&r.isDigit(i)))return!1}return!0}(e))throw new Error("Invalid variable name: '".concat(e,"'. Variable names must follow the specified rules."));return this.scope.set(e,t),t},n.prototype.remove=function(e){this.scope.delete(e)},n.prototype.clear=function(){this.scope.clear()},n}),{isClass:!0}),zm="parser",Im=Me(zm,["typed","Parser"],(e=>{var{typed:t,Parser:r}=e;return t(zm,{"":function(){return new r}})})),qm=Me("lup",["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtractScalar","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],(e=>{var{typed:t,matrix:r,abs:n,addScalar:i,divideScalar:a,multiplyScalar:o,subtractScalar:s,larger:u,equalScalar:c,unaryMinus:l,DenseMatrix:f,SparseMatrix:p,Spa:m}=e;return t("lup",{DenseMatrix:function(e){return h(e)},SparseMatrix:function(e){return function(e){var t,r,i,s=e._size[0],f=e._size[1],h=Math.min(s,f),d=e._values,g=e._index,v=e._ptr,y=[],x=[],b=[],w=[s,h],D=[],N=[],E=[],A=[h,f],S=[],C=[];for(t=0;t<s;t++)S[t]=t,C[t]=t;var M=function(){var e=new m;r<s&&(b.push(y.length),y.push(1),x.push(r)),E.push(D.length);var f=v[r],h=v[r+1];for(i=f;i<h;i++)t=g[i],e.set(S[t],d[i]);r>0&&e.forEach(0,r-1,(function(t,r){p._forEachRow(t,y,x,b,(function(n,i){n>t&&e.accumulate(n,l(o(i,r)))}))}));var M,F,T,_,B=r,O=e.get(r),k=n(O);e.forEach(r+1,s-1,(function(e,t){var r=n(t);u(r,k)&&(B=e,k=r,O=t)})),r!==B&&(p._swapRows(r,B,w[1],y,x,b),p._swapRows(r,B,A[1],D,N,E),e.swap(r,B),F=B,T=C[M=r],_=C[F],S[T]=F,S[_]=M,C[M]=_,C[F]=T),e.forEach(0,s-1,(function(e,t){e<=r?(D.push(t),N.push(e)):(t=a(t,O),c(t,0)||(y.push(t),x.push(e)))}))};for(r=0;r<f;r++)M();return E.push(D.length),b.push(y.length),{L:new p({values:y,index:x,ptr:b,size:w}),U:new p({values:D,index:N,ptr:E,size:A}),p:S,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\nP: "+this.p}}}(e)},Array:function(e){var t=h(r(e));return{L:t.L.valueOf(),U:t.U.valueOf(),p:t.p}}});function h(e){var t,r,l,p=e._size[0],m=e._size[1],h=Math.min(p,m),d=be(e._data),g=[],v=[p,h],y=[],x=[h,m],b=[];for(t=0;t<p;t++)b[t]=t;for(r=0;r<m;r++){if(r>0)for(t=0;t<p;t++){var w=Math.min(t,r),D=0;for(l=0;l<w;l++)D=i(D,o(d[t][l],d[l][r]));d[t][r]=s(d[t][r],D)}var N=r,E=0,A=0;for(t=r;t<p;t++){var S=d[t][r],C=n(S);u(C,E)&&(N=t,E=C,A=S)}if(r!==N&&(b[r]=[b[N],b[N]=b[r]][0],f._swapRows(r,N,d)),r<p)for(t=r+1;t<p;t++){var M=d[t][r];c(M,0)||(d[t][r]=a(d[t][r],A))}}for(r=0;r<m;r++)for(t=0;t<p;t++)0===r&&(t<m&&(y[t]=[]),g[t]=[]),t<r?(t<m&&(y[t][r]=d[t][r]),r<p&&(g[t][r]=0)):t!==r?(t<m&&(y[t][r]=0),r<p&&(g[t][r]=d[t][r])):(t<m&&(y[t][r]=d[t][r]),r<p&&(g[t][r]=1));var F=new f({data:g,size:v}),T=new f({data:y,size:x}),_=[];for(t=0,h=b.length;t<h;t++)_[b[t]]=t;return{L:F,U:T,p:_,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\nP: "+this.p}}}})),Rm=Me("qr",["typed","matrix","zeros","identity","isZero","equal","sign","sqrt","conj","unaryMinus","addScalar","divideScalar","multiplyScalar","subtractScalar","complex"],(e=>{var{typed:t,matrix:r,zeros:n,identity:i,isZero:a,equal:o,sign:s,sqrt:u,conj:c,unaryMinus:l,addScalar:f,divideScalar:p,multiplyScalar:h,subtractScalar:d,complex:g}=e;return m(t("qr",{DenseMatrix:function(e){return y(e)},SparseMatrix:function(e){return function(e){throw new Error("qr not implemented for sparse matrices yet")}()},Array:function(e){var t=y(r(e));return{Q:t.Q.valueOf(),R:t.R.valueOf()}}}),{_denseQRimpl:v});function v(e){var t,r,m,g=e._size[0],v=e._size[1],y=i([g],"dense"),x=y._data,b=e.clone(),w=b._data,D=n([g],"");for(m=0;m<Math.min(v,g);++m){var N=w[m][m],E=l(o(N,0)?1:s(N)),A=c(E),S=0;for(t=m;t<g;t++)S=f(S,h(w[t][m],c(w[t][m])));var C=h(E,u(S));if(!a(C)){var M=d(N,C);for(D[m]=1,t=m+1;t<g;t++)D[t]=p(w[t][m],M);var F=l(c(p(M,C))),T=void 0;for(r=m;r<v;r++){for(T=0,t=m;t<g;t++)T=f(T,h(c(D[t]),w[t][r]));for(T=h(T,F),t=m;t<g;t++)w[t][r]=h(d(w[t][r],h(D[t],T)),A)}for(t=0;t<g;t++){for(T=0,r=m;r<g;r++)T=f(T,h(x[t][r],D[r]));for(T=h(T,F),r=m;r<g;++r)x[t][r]=p(d(x[t][r],h(T,c(D[r]))),A)}}}return{Q:y,R:b,toString:function(){return"Q: "+this.Q.toString()+"\nR: "+this.R.toString()}}}function y(e){var t=v(e),r=t.R._data;if(e._data.length>0)for(var n="Complex"===r[0][0].type?g(0):0,i=0;i<r.length;++i)for(var a=0;a<i&&a<(r[0]||[]).length;++a)r[i][a]=n;return t}}));function Pm(e,t,r,n,i,a,o){var s=0;for(r[o]=e;s>=0;){var u=r[o+s],c=r[n+u];-1===c?(s--,a[t++]=u):(r[n+u]=r[i+c],r[o+ ++s]=c)}return t}function jm(e){return-e-2}var Um=Me("csAmd",["add","multiply","transpose"],(e=>{var{add:t,multiply:r,transpose:n}=e;return function(e,o){if(!o||e<=0||e>3)return null;var s=o._size,u=s[0],c=s[1],l=0,f=Math.max(16,10*Math.sqrt(c)),p=function(e,i,a,o,s){var u=n(i);if(1===e&&o===a)return t(i,u);if(2===e){for(var c=u._index,l=u._ptr,f=0,p=0;p<a;p++){var m=l[p];if(l[p]=f,!(l[p+1]-m>s))for(var h=l[p+1];m<h;m++)c[f++]=c[m]}return l[a]=f,i=n(u),r(u,i)}return r(u,i)}(e,o,u,c,f=Math.min(c-2,f));!function(e,t,r){for(var n=e._values,i=e._index,a=e._ptr,o=e._size[1],s=0,u=0;u<o;u++){var c=a[u];for(a[u]=s;c<a[u+1];c++)t(i[c],u,n?n[c]:1,null)&&(i[s]=i[c],n&&(n[s]=n[c]),s++)}a[o]=s,i.splice(s,i.length-s),n&&n.splice(s,n.length-s)}(p,a);for(var m,h,d,g,v,y,x,b,w,D,N,E,A,S,C,M,F=p._index,T=p._ptr,_=T[c],B=[],O=[],k=c+1,z=2*(c+1),I=3*(c+1),q=4*(c+1),R=5*(c+1),P=6*(c+1),j=7*(c+1),U=B,L=function(e,t,r,n,a,o,s,u,c,l,f,p){for(var m=0;m<e;m++)r[0+m]=t[m+1]-t[m];r[0+e]=0;for(var h=0;h<=e;h++)r[a+h]=-1,o[h]=-1,r[s+h]=-1,r[u+h]=-1,r[c+h]=1,r[l+h]=1,r[f+h]=0,r[p+h]=r[0+h];var d=i(0,0,r,l,e);return r[f+e]=-2,t[e]=-1,r[l+e]=0,d}(c,T,O,0,I,U,z,j,k,P,q,R),H=function(e,t,r,n,i,a,o,s,u,c,l){for(var f=0,p=0;p<e;p++){var m=r[n+p];if(0===m)r[i+p]=-2,f++,t[p]=-1,r[a+p]=0;else if(m>o)r[s+p]=0,r[i+p]=-1,f++,t[p]=jm(e),r[s+e]++;else{var h=r[u+m];-1!==h&&(c[h]=p),r[l+p]=r[u+m],r[u+m]=p}}return f}(c,T,O,R,q,P,f,k,I,U,z),$=0;H<c;){for(d=-1;$<c&&-1===(d=O[I+$]);$++);-1!==O[z+d]&&(U[O[z+d]]=-1),O[I+$]=O[z+d];var G=O[q+d],W=O[k+d];H+=W;var V=0;O[k+d]=-W;var Z=T[d],Y=0===G?Z:_,J=Y;for(g=1;g<=G+1;g++){for(g>G?(y=d,x=Z,b=O[0+d]-G):(x=T[y=F[Z++]],b=O[0+y]),v=1;v<=b;v++)(w=O[k+(m=F[x++])])<=0||(V+=w,O[k+m]=-w,F[J++]=m,-1!==O[z+m]&&(U[O[z+m]]=U[m]),-1!==U[m]?O[z+U[m]]=O[z+m]:O[I+O[R+m]]=O[z+m]);y!==d&&(T[y]=jm(d),O[P+y]=0)}for(0!==G&&(_=J),O[R+d]=V,T[d]=Y,O[0+d]=J-Y,O[q+d]=-2,L=i(L,l,O,P,c),D=Y;D<J;D++)if(!((N=O[q+(m=F[D])])<=0)){var X=L-(w=-O[k+m]);for(Z=T[m],E=T[m]+N-1;Z<=E;Z++)O[P+(y=F[Z])]>=L?O[P+y]-=w:0!==O[P+y]&&(O[P+y]=O[R+y]+X)}for(D=Y;D<J;D++){for(A=(E=T[m=F[D]])+O[q+m]-1,S=E,C=0,M=0,Z=E;Z<=A;Z++)if(0!==O[P+(y=F[Z])]){var Q=O[P+y]-L;Q>0?(M+=Q,F[S++]=y,C+=y):(T[y]=jm(d),O[P+y]=0)}O[q+m]=S-E+1;var K=S,ee=E+O[0+m];for(Z=A+1;Z<ee;Z++){var te=O[k+(h=F[Z])];te<=0||(M+=te,F[S++]=h,C+=h)}0===M?(T[m]=jm(d),V-=w=-O[k+m],W+=w,H+=w,O[k+m]=0,O[q+m]=-1):(O[R+m]=Math.min(O[R+m],M),F[S]=F[K],F[K]=F[E],F[E]=d,O[0+m]=S-E+1,C=(C<0?-C:C)%c,O[z+m]=O[j+C],O[j+C]=m,U[m]=C)}for(O[R+d]=V,L=i(L+(l=Math.max(l,V)),l,O,P,c),D=Y;D<J;D++)if(!(O[k+(m=F[D])]>=0))for(m=O[j+(C=U[m])],O[j+C]=-1;-1!==m&&-1!==O[z+m];m=O[z+m],L++){for(b=O[0+m],N=O[q+m],Z=T[m]+1;Z<=T[m]+b-1;Z++)O[P+F[Z]]=L;var re=m;for(h=O[z+m];-1!==h;){var ne=O[0+h]===b&&O[q+h]===N;for(Z=T[h]+1;ne&&Z<=T[h]+b-1;Z++)O[P+F[Z]]!==L&&(ne=0);ne?(T[h]=jm(m),O[k+m]+=O[k+h],O[k+h]=0,O[q+h]=-1,h=O[z+h],O[z+re]=h):(re=h,h=O[z+h])}}for(Z=Y,D=Y;D<J;D++)(w=-O[k+(m=F[D])])<=0||(O[k+m]=w,M=O[R+m]+V-w,-1!==O[I+(M=Math.min(M,c-H-w))]&&(U[O[I+M]]=m),O[z+m]=O[I+M],U[m]=-1,O[I+M]=m,$=Math.min($,M),O[R+m]=M,F[Z++]=m);O[k+d]=W,0==(O[0+d]=Z-Y)&&(T[d]=-1,O[P+d]=0),0!==G&&(_=Z)}for(m=0;m<c;m++)T[m]=jm(T[m]);for(h=0;h<=c;h++)O[I+h]=-1;for(h=c;h>=0;h--)O[k+h]>0||(O[z+h]=O[I+T[h]],O[I+T[h]]=h);for(y=c;y>=0;y--)O[k+y]<=0||-1!==T[y]&&(O[z+y]=O[I+T[y]],O[I+T[y]]=y);for(d=0,m=0;m<=c;m++)-1===T[m]&&(d=Pm(m,d,O,I,z,B,P));return B.splice(B.length-1,1),B};function i(e,t,r,n,i){if(e<2||e+t<0){for(var a=0;a<i;a++)0!==r[n+a]&&(r[n+a]=1);e=2}return e}function a(e,t){return e!==t}}));function Lm(e,t,r,n,i,a,o){var s,u,c,l=0;if(e<=t||r[n+t]<=r[i+e])return-1;r[i+e]=r[n+t];var f=r[a+e];if(r[a+e]=t,-1===f)l=1,c=e;else{for(l=2,c=f;c!==r[o+c];c=r[o+c]);for(s=f;s!==c;s=u)u=r[o+s],r[o+s]=c}return{jleaf:l,q:c}}var Hm=Me("csCounts",["transpose"],(e=>{var{transpose:t}=e;return function(e,r,n,i){if(!e||!r||!n)return null;var a,o,s,u,c,l,f,p=e._size,m=p[0],h=p[1],d=4*h+(i?h+m+1:0),g=[],v=h,y=2*h,x=3*h,b=4*h,w=5*h+1;for(s=0;s<d;s++)g[s]=-1;var D=[],N=t(e),E=N._index,A=N._ptr;for(s=0;s<h;s++)for(D[o=n[s]]=-1===g[x+o]?1:0;-1!==o&&-1===g[x+o];o=r[o])g[x+o]=s;if(i){for(s=0;s<h;s++)g[n[s]]=s;for(a=0;a<m;a++){for(s=h,l=A[a],f=A[a+1],c=l;c<f;c++)s=Math.min(s,g[E[c]]);g[w+a]=g[b+s],g[b+s]=a}}for(a=0;a<h;a++)g[0+a]=a;for(s=0;s<h;s++){for(-1!==r[o=n[s]]&&D[r[o]]--,u=i?g[b+s]:o;-1!==u;u=i?g[w+u]:-1)for(c=A[u];c<A[u+1];c++){var S=Lm(a=E[c],o,g,x,v,y,0);S.jleaf>=1&&D[o]++,2===S.jleaf&&D[S.q]--}-1!==r[o]&&(g[0+o]=r[o])}for(o=0;o<h;o++)-1!==r[o]&&(D[r[o]]+=D[o]);return D}})),$m=Me("csSqr",["add","multiply","transpose"],(e=>{var{add:t,multiply:r,transpose:n}=e,i=Um({add:t,multiply:r,transpose:n}),a=Hm({transpose:n});return function(e,t,r){var n,o=t._ptr,s=t._size[1],u={};if(u.q=i(e,t),e&&!u.q)return null;if(r){var c=e?function(e,t,r,n){for(var i=e._values,a=e._index,o=e._ptr,s=e._size,u=e._datatype,c=s[0],l=s[1],f=null,p=[],m=[],h=0,d=0;d<l;d++){m[d]=h;for(var g=r?r[d]:d,v=o[g],y=o[g+1],x=v;x<y;x++){var b=a[x];p[h]=b,f&&(f[h]=i[x]),h++}}return m[l]=h,e.createSparseMatrix({values:f,index:p,ptr:m,size:[c,l],datatype:u})}(t,0,u.q):t;u.parent=function(e,t){if(!e)return null;var r,n,i=e._index,a=e._ptr,o=e._size,s=o[0],u=o[1],c=[],l=[],f=u;for(r=0;r<s;r++)l[f+r]=-1;for(var p=0;p<u;p++){c[p]=-1,l[0+p]=-1;for(var m=a[p],h=a[p+1],d=m;d<h;d++){var g=i[d];for(r=l[f+g];-1!==r&&r<p;r=n)n=l[0+r],l[0+r]=p,-1===n&&(c[r]=p);l[f+g]=p}}return c}(c);var l=function(e,t){if(!e)return null;var r,n=0,i=[],a=[],o=t,s=2*t;for(r=0;r<t;r++)a[0+r]=-1;for(r=t-1;r>=0;r--)-1!==e[r]&&(a[o+r]=a[0+e[r]],a[0+e[r]]=r);for(r=0;r<t;r++)-1===e[r]&&(n=Pm(r,n,a,0,o,i,s));return i}(u.parent,s);if(u.cp=a(c,u.parent,l,1),c&&u.parent&&u.cp&&function(e,t){var r=e._ptr,n=e._index,i=e._size,a=i[0],o=i[1];t.pinv=[],t.leftmost=[];var s,u,c,l,f,p=t.parent,m=t.pinv,h=t.leftmost,d=[],g=a,v=a+o,y=a+2*o;for(u=0;u<o;u++)d[g+u]=-1,d[v+u]=-1,d[y+u]=0;for(s=0;s<a;s++)h[s]=-1;for(u=o-1;u>=0;u--)for(l=r[u],f=r[u+1],c=l;c<f;c++)h[n[c]]=u;for(s=a-1;s>=0;s--)m[s]=-1,-1!==(u=h[s])&&(0==d[y+u]++&&(d[v+u]=s),d[0+s]=d[g+u],d[g+u]=s);for(t.lnz=0,t.m2=a,u=0;u<o;u++)if(s=d[g+u],t.lnz++,s<0&&(s=t.m2++),m[s]=u,!(--y[u]<=0)){t.lnz+=d[y+u];var x=p[u];-1!==x&&(0===d[y+x]&&(d[v+x]=d[v+u]),d[0+d[v+u]]=d[g+x],d[g+x]=d[0+s],d[y+x]+=d[y+u])}for(s=0;s<a;s++)m[s]<0&&(m[s]=u++);return!0}(c,u))for(u.unz=0,n=0;n<s;n++)u.unz+=u.cp[n]}else u.unz=4*o[s]+s,u.lnz=u.unz;return u}}));function Gm(e,t){return e[t]<0}function Wm(e,t){e[t]=jm(e[t])}function Vm(e){return e<0?jm(e):e}function Zm(e,t,r,n,i){var a,o,s,u=t._index,c=t._ptr,l=t._size[1],f=0;for(n[0]=e;f>=0;){e=n[f];var p=i?i[e]:e;Gm(c,e)||(Wm(c,e),n[l+f]=p<0?0:Vm(c[p]));var m=1;for(o=n[l+f],s=p<0?0:Vm(c[p+1]);o<s;o++)if(!Gm(c,a=u[o])){n[l+f]=o,n[++f]=a,m=0;break}m&&(f--,n[--r]=e)}return r}var Ym=Me("csSpsolve",["divideScalar","multiply","subtract"],(e=>{var{divideScalar:t,multiply:r,subtract:n}=e;return function(e,i,a,o,s,u,c){var l,f,p,m,h=e._values,d=e._index,g=e._ptr,v=e._size[1],y=i._values,x=i._index,b=i._ptr,w=function(e,t,r,n,i){var a,o,s,u=e._ptr,c=e._size,l=t._index,f=t._ptr,p=c[1],m=p;for(o=f[r],s=f[r+1],a=o;a<s;a++){var h=l[a];Gm(u,h)||(m=Zm(h,e,m,n,i))}for(a=m;a<p;a++)Wm(u,n[a]);return m}(e,i,a,o,u);for(l=w;l<v;l++)s[o[l]]=0;for(f=b[a],p=b[a+1],l=f;l<p;l++)s[x[l]]=y[l];for(var D=w;D<v;D++){var N=o[D],E=u?u[N]:N;if(!(E<0))for(f=g[E],p=g[E+1],s[N]=t(s[N],h[c?f:p-1]),l=c?f+1:f,m=c?p:p-1;l<m;l++){var A=d[l];s[A]=n(s[A],r(h[l],s[N]))}}return w}})),Jm=Me("csLu",["abs","divideScalar","multiply","subtract","larger","largerEq","SparseMatrix"],(e=>{var{abs:t,divideScalar:r,multiply:n,subtract:i,larger:a,largerEq:o,SparseMatrix:s}=e,u=Ym({divideScalar:r,multiply:n,subtract:i});return function(e,i,c){if(!e)return null;var l,f=e._size[1],p=100,m=100;i&&(l=i.q,p=i.lnz||p,m=i.unz||m);var h,d,g=[],v=[],y=[],x=new s({values:g,index:v,ptr:y,size:[f,f]}),b=[],w=[],D=[],N=new s({values:b,index:w,ptr:D,size:[f,f]}),E=[],A=[],S=[];for(h=0;h<f;h++)A[h]=0,E[h]=-1,y[h+1]=0;p=0,m=0;for(var C=0;C<f;C++){y[C]=p,D[C]=m;var M=l?l[C]:C,F=u(x,e,M,S,A,E,1),T=-1,_=-1;for(d=F;d<f;d++)if(E[h=S[d]]<0){var B=t(A[h]);a(B,_)&&(_=B,T=h)}else w[m]=E[h],b[m++]=A[h];if(-1===T||_<=0)return null;E[M]<0&&o(t(A[M]),n(_,c))&&(T=M);var O=A[T];for(w[m]=C,b[m++]=O,E[T]=C,v[p]=T,g[p++]=1,d=F;d<f;d++)E[h=S[d]]<0&&(v[p]=h,g[p++]=r(A[h],O)),A[h]=0}for(y[f]=p,D[f]=m,d=0;d<p;d++)v[d]=E[v[d]];return g.splice(p,g.length-p),v.splice(p,v.length-p),b.splice(m,b.length-m),w.splice(m,w.length-m),{L:x,U:N,pinv:E}}})),Xm=Me("slu",["typed","abs","add","multiply","transpose","divideScalar","subtract","larger","largerEq","SparseMatrix"],(e=>{var{typed:t,abs:r,add:n,multiply:i,transpose:a,divideScalar:o,subtract:s,larger:u,largerEq:c,SparseMatrix:l}=e,f=$m({add:n,multiply:i,transpose:a}),p=Jm({abs:r,divideScalar:o,multiply:i,subtract:s,larger:u,largerEq:c,SparseMatrix:l});return t("slu",{"SparseMatrix, number, number":function(e,t,r){if(!qe(t)||t<0||t>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(r<0||r>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var n=f(t,e,!1),i=p(e,n,r);return{L:i.L,U:i.U,p:i.pinv,q:n.q,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\np: "+this.p.toString()+(this.q?"\nq: "+this.q.toString():"")+"\n"}}}})}));function Qm(e,t){var r,n=t.length,i=[];if(e)for(r=0;r<n;r++)i[e[r]]=t[r];else for(r=0;r<n;r++)i[r]=t[r];return i}var Km="lusolve",eh=Me(Km,["typed","matrix","lup","slu","usolve","lsolve","DenseMatrix"],(e=>{var{typed:t,matrix:r,lup:n,slu:i,usolve:a,lsolve:o,DenseMatrix:s}=e,u=Oc({DenseMatrix:s});return t(Km,{"Array, Array | Matrix":function(e,t){e=r(e);var i=n(e);return l(i.L,i.U,i.p,null,t).valueOf()},"DenseMatrix, Array | Matrix":function(e,t){var r=n(e);return l(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){var r=n(e);return l(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,r,n){var a=i(e,r,n);return l(a.L,a.U,a.p,a.q,t)},"Object, Array | Matrix":function(e,t){return l(e.L,e.U,e.p,e.q,t)}});function c(e){if(q(e))return e;if(I(e))return r(e);throw new TypeError("Invalid Matrix LU decomposition")}function l(e,t,r,n,i){e=c(e),t=c(t),r&&((i=u(e,i,!0))._data=Qm(r,i._data));var s=o(e,i),l=a(t,s);return n&&(l._data=Qm(n,l._data)),l}})),th="polynomialRoot",rh=Me(th,["typed","isZero","equalScalar","add","subtract","multiply","divide","sqrt","unaryMinus","cbrt","typeOf","im","re"],(e=>{var{typed:t,isZero:r,equalScalar:n,add:i,subtract:a,multiply:o,divide:s,sqrt:u,unaryMinus:c,cbrt:l,typeOf:f,im:p,re:m}=e;return t(th,{"number|Complex, ...number|Complex":(e,t)=>{for(var h=[e,...t];h.length>0&&r(h[h.length-1]);)h.pop();if(h.length<2)throw new RangeError("Polynomial [".concat(e,", ").concat(t,"] must have a non-zero non-constant coefficient"));switch(h.length){case 2:return[c(s(h[0],h[1]))];case 3:var[d,g,v]=h,y=o(2,v),x=o(g,g),b=o(4,v,d);if(n(x,b))return[s(c(g),y)];var w=u(a(x,b));return[s(a(w,g),y),s(a(c(w),g),y)];case 4:var[D,N,E,A]=h,S=c(o(3,A)),C=o(E,E),M=o(3,A,N),F=i(o(2,E,E,E),o(27,A,A,D)),T=o(9,A,E,N);if(n(C,M)&&n(F,T))return[s(E,S)];var _,B=a(C,M),O=a(F,T),k=i(o(18,A,E,N,D),o(E,E,N,N)),z=i(o(4,E,E,E,D),o(4,A,N,N,N),o(27,A,A,D,D));return n(k,z)?[s(a(o(4,A,E,N),i(o(9,A,A,D),o(E,E,E))),o(A,B)),s(a(o(9,A,D),o(E,N)),o(2,B))]:(_=n(C,M)?O:s(i(O,u(a(o(O,O),o(4,B,B,B)))),2),l(_,!0).toArray().map((e=>s(i(E,e,s(B,e)),S))).map((e=>"Complex"===f(e)&&n(m(e),m(e)+p(e))?m(e):e)));default:throw new RangeError("only implemented for cubic or lower-order polynomials, not ".concat(h))}}})})),nh=Me("Help",["evaluate"],(e=>{var{evaluate:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw new Error('Argument "doc" missing');this.doc=e}return r.prototype.type="Help",r.prototype.isHelp=!0,r.prototype.toString=function(){var e=this.doc||{},r="\n";if(e.name&&(r+="Name: "+e.name+"\n\n"),e.category&&(r+="Category: "+e.category+"\n\n"),e.description&&(r+="Description:\n "+e.description+"\n\n"),e.syntax&&(r+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){r+="Examples:\n";for(var n=!1,i=t("config()"),a={config:e=>(n=!0,t("config(newConfig)",{newConfig:e}))},o=0;o<e.examples.length;o++){var s=e.examples[o];r+=" "+s+"\n";var u=void 0;try{u=t(s,a)}catch(e){u=e}void 0===u||G(u)||(r+=" "+Sn(u,{precision:14})+"\n")}r+="\n",n&&t("config(originalConfig)",{originalConfig:i})}return e.mayThrow&&e.mayThrow.length&&(r+="Throws: "+e.mayThrow.join(", ")+"\n\n"),e.seealso&&e.seealso.length&&(r+="See also: "+e.seealso.join(", ")+"\n"),r},r.prototype.toJSON=function(){var e=be(this.doc);return e.mathjs="Help",e},r.fromJSON=function(e){var t={};return Object.keys(e).filter((e=>"mathjs"!==e)).forEach((r=>{t[r]=e[r]})),new r(t)},r.prototype.valueOf=r.prototype.toString,r}),{isClass:!0}),ih=Me("Chain",["?on","math","typed"],(e=>{var{on:t,math:r,typed:n}=e;function i(e){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");ye(e)?this.value=e.value:this.value=e}function a(e,t){Se(i.prototype,e,(function(){var e=t();if("function"==typeof e)return o(e)}))}function o(e){return function(){if(0===arguments.length)return new i(e(this.value));for(var t=[this.value],r=0;r<arguments.length;r++)t[r+1]=arguments[r];if(n.isTypedFunction(e)){var a=n.resolve(e,t);if(1===a.params.length)throw new Error("chain function "+e.name+" cannot match rest parameter between chain value and additional arguments.");return new i(a.implementation.apply(e,t))}return new i(e.apply(e,t))}}i.prototype.type="Chain",i.prototype.isChain=!0,i.prototype.done=function(){return this.value},i.prototype.valueOf=function(){return this.value},i.prototype.toString=function(){return Sn(this.value)},i.prototype.toJSON=function(){return{mathjs:"Chain",value:this.value}},i.fromJSON=function(e){return new i(e.value)},i.createProxy=function(e,t){if("string"==typeof e)u=e,"function"==typeof(c=t)&&(i.prototype[u]=o(c));else{var r=function(t){Ce(e,t)&&void 0===s[t]&&a(t,(()=>e[t]))};for(var n in e)r(n)}var u,c};var s={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return i.createProxy(r),t&&t("import",(function(e,t,r){r||a(e,t)})),i}),{isClass:!0}),ah={name:"e",category:"Constants",syntax:["e"],description:"Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",examples:["e","e ^ 2","exp(2)","log(e)"],seealso:["exp"]},oh={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]},sh={bignumber:{name:"bignumber",category:"Construction",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","bigint","complex","fraction","index","matrix","string","unit"]},bigint:{name:"bigint",category:"Construction",syntax:["bigint(x)"],description:"Create a bigint, an integer with an arbitrary number of digits, from a number or string.",examples:["123123123123123123 # a large number will lose digits",'bigint("123123123123123123")','bignumber(["1", "3", "5"])'],seealso:["boolean","bignumber","number","complex","fraction","index","matrix","string","unit"]},boolean:{name:"boolean",category:"Construction",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]},complex:{name:"complex",category:"Construction",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]},createUnit:{name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.",examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]},fraction:{name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(matrix)","fraction(num,den)","fraction({n: num, d: den})"],description:"Create a fraction from a number or from integer numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)","fraction({n: 333, d: 53})","fraction([sqrt(9), sqrt(10), sqrt(11)])"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},index:{name:"index",category:"Construction",syntax:["[start]","[start:end]","[start:step:end]","[start1, start 2, ...]","[start1:end1, start2:end2, ...]","[start1:step1:end1, start2:step2:end2, ...]"],description:"Create an index to get or replace a subset of a matrix",examples:["A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[1:2, 1:2] = 1","B = [1, 2, 3]","B[B>1 and B<3]"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]},matrix:{name:"matrix",category:"Construction",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()",'matrix("dense")',"matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])",'matrix([3, 4; 5, 6], "sparse")','matrix([3, 4; 5, 6], "sparse", "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","sparse"]},number:{name:"number",category:"Construction",syntax:["x","number(x)","number(unit, valuelessUnit)"],description:"Create a number or convert a string or boolean into a number.",examples:["2","2e3","4.05","number(2)",'number("7.2")',"number(true)","number([true, false, true, true])",'number(unit("52cm"), "m")'],seealso:["bignumber","bigint","boolean","complex","fraction","index","matrix","string","unit"]},sparse:{name:"sparse",category:"Construction",syntax:["sparse()","sparse([a1, b1, ...; a1, b2, ...])",'sparse([a1, b1, ...; a1, b2, ...], "number")'],description:"Create a sparse matrix.",examples:["sparse()","sparse([3, 4; 5, 6])",'sparse([3, 0; 5, 0], "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","matrix"]},splitUnit:{name:"splitUnit",category:"Construction",syntax:["splitUnit(unit: Unit, parts: Unit[])"],description:"Split a unit in an array of units whose sum is equal to the original unit.",examples:['splitUnit(1 m, ["feet", "inch"])'],seealso:["unit","createUnit"]},string:{name:"string",category:"Construction",syntax:['"text"',"string(x)"],description:"Create a string or convert a value to a string",examples:['"Hello World!"',"string(4.2)","string(3 + 2i)"],seealso:["bignumber","boolean","complex","index","matrix","number","unit"]},unit:{name:"unit",category:"Construction",syntax:["value unit","unit(value, unit)","unit(string)"],description:"Create a unit.",examples:["5.5 mm","3 inch",'unit(7.1, "kilogram")','unit("23 deg")'],seealso:["bignumber","boolean","complex","index","matrix","number","string"]},e:ah,E:ah,false:{name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},i:{name:"i",category:"Constants",syntax:["i"],description:"Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",examples:["i","i * i","sqrt(-1)"],seealso:[]},Infinity:{name:"Infinity",category:"Constants",syntax:["Infinity"],description:"Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",examples:["Infinity","1 / 0"],seealso:[]},LN2:{name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},LN10:{name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},LOG2E:{name:"LOG2E",category:"Constants",syntax:["LOG2E"],description:"Returns the base-2 logarithm of E, approximately equal to 1.442",examples:["LOG2E","log(e, 2)"],seealso:[]},LOG10E:{name:"LOG10E",category:"Constants",syntax:["LOG10E"],description:"Returns the base-10 logarithm of E, approximately equal to 0.434",examples:["LOG10E","log(e, 10)"],seealso:[]},NaN:{name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},null:{name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},pi:oh,PI:oh,phi:{name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["phi"],seealso:[]},SQRT1_2:{name:"SQRT1_2",category:"Constants",syntax:["SQRT1_2"],description:"Returns the square root of 1/2, approximately equal to 0.707",examples:["SQRT1_2","sqrt(1/2)"],seealso:[]},SQRT2:{name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},tau:{name:"tau",category:"Constants",syntax:["tau"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]},true:{name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},version:{name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},speedOfLight:{description:"Speed of light in vacuum",examples:["speedOfLight"]},gravitationConstant:{description:"Newtonian constant of gravitation",examples:["gravitationConstant"]},planckConstant:{description:"Planck constant",examples:["planckConstant"]},reducedPlanckConstant:{description:"Reduced Planck constant",examples:["reducedPlanckConstant"]},magneticConstant:{description:"Magnetic constant (vacuum permeability)",examples:["magneticConstant"]},electricConstant:{description:"Electric constant (vacuum permeability)",examples:["electricConstant"]},vacuumImpedance:{description:"Characteristic impedance of vacuum",examples:["vacuumImpedance"]},coulomb:{description:"Coulomb's constant",examples:["coulomb"]},elementaryCharge:{description:"Elementary charge",examples:["elementaryCharge"]},bohrMagneton:{description:"Bohr magneton",examples:["bohrMagneton"]},conductanceQuantum:{description:"Conductance quantum",examples:["conductanceQuantum"]},inverseConductanceQuantum:{description:"Inverse conductance quantum",examples:["inverseConductanceQuantum"]},magneticFluxQuantum:{description:"Magnetic flux quantum",examples:["magneticFluxQuantum"]},nuclearMagneton:{description:"Nuclear magneton",examples:["nuclearMagneton"]},klitzing:{description:"Von Klitzing constant",examples:["klitzing"]},bohrRadius:{description:"Bohr radius",examples:["bohrRadius"]},classicalElectronRadius:{description:"Classical electron radius",examples:["classicalElectronRadius"]},electronMass:{description:"Electron mass",examples:["electronMass"]},fermiCoupling:{description:"Fermi coupling constant",examples:["fermiCoupling"]},fineStructure:{description:"Fine-structure constant",examples:["fineStructure"]},hartreeEnergy:{description:"Hartree energy",examples:["hartreeEnergy"]},protonMass:{description:"Proton mass",examples:["protonMass"]},deuteronMass:{description:"Deuteron Mass",examples:["deuteronMass"]},neutronMass:{description:"Neutron mass",examples:["neutronMass"]},quantumOfCirculation:{description:"Quantum of circulation",examples:["quantumOfCirculation"]},rydberg:{description:"Rydberg constant",examples:["rydberg"]},thomsonCrossSection:{description:"Thomson cross section",examples:["thomsonCrossSection"]},weakMixingAngle:{description:"Weak mixing angle",examples:["weakMixingAngle"]},efimovFactor:{description:"Efimov factor",examples:["efimovFactor"]},atomicMass:{description:"Atomic mass constant",examples:["atomicMass"]},avogadro:{description:"Avogadro's number",examples:["avogadro"]},boltzmann:{description:"Boltzmann constant",examples:["boltzmann"]},faraday:{description:"Faraday constant",examples:["faraday"]},firstRadiation:{description:"First radiation constant",examples:["firstRadiation"]},loschmidt:{description:"Loschmidt constant at T=273.15 K and p=101.325 kPa",examples:["loschmidt"]},gasConstant:{description:"Gas constant",examples:["gasConstant"]},molarPlanckConstant:{description:"Molar Planck constant",examples:["molarPlanckConstant"]},molarVolume:{description:"Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",examples:["molarVolume"]},sackurTetrode:{description:"Sackur-Tetrode constant at T=1 K and p=101.325 kPa",examples:["sackurTetrode"]},secondRadiation:{description:"Second radiation constant",examples:["secondRadiation"]},stefanBoltzmann:{description:"Stefan-Boltzmann constant",examples:["stefanBoltzmann"]},wienDisplacement:{description:"Wien displacement law constant",examples:["wienDisplacement"]},molarMass:{description:"Molar mass constant",examples:["molarMass"]},molarMassC12:{description:"Molar mass constant of carbon-12",examples:["molarMassC12"]},gravity:{description:"Standard acceleration of gravity (standard acceleration of free-fall on Earth)",examples:["gravity"]},planckLength:{description:"Planck length",examples:["planckLength"]},planckMass:{description:"Planck mass",examples:["planckMass"]},planckTime:{description:"Planck time",examples:["planckTime"]},planckCharge:{description:"Planck charge",examples:["planckCharge"]},planckTemperature:{description:"Planck temperature",examples:["planckTemperature"]},derivative:{name:"derivative",category:"Algebra",syntax:["derivative(expr, variable)","derivative(expr, variable, {simplify: boolean})"],description:"Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",examples:['derivative("2x^3", "x")','derivative("2x^3", "x", {simplify: false})','derivative("2x^2 + 3x + 4", "x")','derivative("sin(2x)", "x")','f = parse("x^2 + x")','x = parse("x")',"df = derivative(f, x)","df.evaluate({x: 3})"],seealso:["simplify","parse","evaluate"]},lsolve:{name:"lsolve",category:"Algebra",syntax:["x=lsolve(L, b)"],description:"Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolveAll","lup","lusolve","usolve","matrix","sparse"]},lsolveAll:{name:"lsolveAll",category:"Algebra",syntax:["x=lsolveAll(L, b)"],description:"Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolve","lup","lusolve","usolve","matrix","sparse"]},lup:{name:"lup",category:"Algebra",syntax:["lup(m)"],description:"Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",examples:["lup([[2, 1], [1, 4]])","lup(matrix([[2, 1], [1, 4]]))","lup(sparse([[2, 1], [1, 4]]))"],seealso:["lusolve","lsolve","usolve","matrix","sparse","slu","qr"]},lusolve:{name:"lusolve",category:"Algebra",syntax:["x=lusolve(A, b)","x=lusolve(lu, b)"],description:"Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lusolve(a, b)"],seealso:["lup","slu","lsolve","usolve","matrix","sparse"]},leafCount:{name:"leafCount",category:"Algebra",syntax:["leafCount(expr)"],description:"Computes the number of leaves in the parse tree of the given expression",examples:['leafCount("e^(i*pi)-1")','leafCount(parse("{a: 22/7, b: 10^(1/2)}"))'],seealso:["simplify"]},polynomialRoot:{name:"polynomialRoot",category:"Algebra",syntax:["x=polynomialRoot(-6, 3)","x=polynomialRoot(4, -4, 1)","x=polynomialRoot(-8, 12, -6, 1)"],description:"Finds the roots of a univariate polynomial given by its coefficients starting from constant, linear, and so on, increasing in degree.",examples:["a = polynomialRoot(-6, 11, -6, 1)"],seealso:["cbrt","sqrt"]},resolve:{name:"resolve",category:"Algebra",syntax:["resolve(node, scope)"],description:"Recursively substitute variables in an expression tree.",examples:['resolve(parse("1 + x"), { x: 7 })','resolve(parse("size(text)"), { text: "Hello World" })','resolve(parse("x + y"), { x: parse("3z") })','resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })'],seealso:["simplify","evaluate"],mayThrow:["ReferenceError"]},simplify:{name:"simplify",category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["simplifyCore","derivative","evaluate","parse","rationalize","resolve"]},simplifyConstant:{name:"simplifyConstant",category:"Algebra",syntax:["simplifyConstant(expr)","simplifyConstant(expr, options)"],description:"Replace constant subexpressions of node with their values.",examples:['simplifyConstant("(3-3)*x")','simplifyConstant(parse("z-cos(tau/8)"))'],seealso:["simplify","simplifyCore","evaluate"]},simplifyCore:{name:"simplifyCore",category:"Algebra",syntax:["simplifyCore(node)"],description:"Perform simple one-pass simplifications on an expression tree.",examples:['simplifyCore(parse("0*x"))','simplifyCore(parse("(x+0)*2"))'],seealso:["simplify","simplifyConstant","evaluate"]},symbolicEqual:{name:"symbolicEqual",category:"Algebra",syntax:["symbolicEqual(expr1, expr2)","symbolicEqual(expr1, expr2, options)"],description:"Returns true if the difference of the expressions simplifies to 0",examples:['symbolicEqual("x*y","y*x")','symbolicEqual("abs(x^2)", "x^2")','symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})'],seealso:["simplify","evaluate"]},rationalize:{name:"rationalize",category:"Algebra",syntax:["rationalize(expr)","rationalize(expr, scope)","rationalize(expr, scope, detailed)"],description:"Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",examples:['rationalize("2x/y - y/(x+1)")','rationalize("2x/y - y/(x+1)", true)'],seealso:["simplify"]},slu:{name:"slu",category:"Algebra",syntax:["slu(A, order, threshold)"],description:"Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",examples:["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],seealso:["lusolve","lsolve","usolve","matrix","sparse","lup","qr"]},usolve:{name:"usolve",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolveAll","lup","lusolve","lsolve","matrix","sparse"]},usolveAll:{name:"usolveAll",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolve","lup","lusolve","lsolve","matrix","sparse"]},qr:{name:"qr",category:"Algebra",syntax:["qr(A)"],description:"Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",examples:["qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])"],seealso:["lup","slu","matrix"]},abs:{name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},add:{name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i","3 cm + 2 inch",'"2.3" + "4"'],seealso:["subtract"]},cbrt:{name:"cbrt",category:"Arithmetic",syntax:["cbrt(x)","cbrt(x, allRoots)"],description:"Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",examples:["cbrt(64)","cube(4)","cbrt(-8)","cbrt(2 + 3i)","cbrt(8i)","cbrt(8i, true)","cbrt(27 m^3)"],seealso:["square","sqrt","cube","multiply"]},ceil:{name:"ceil",category:"Arithmetic",syntax:["ceil(x)"],description:"Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)"],seealso:["floor","fix","round"]},cube:{name:"cube",category:"Arithmetic",syntax:["cube(x)"],description:"Compute the cube of a value. The cube of x is x * x * x.",examples:["cube(2)","2^3","2 * 2 * 2"],seealso:["multiply","square","pow"]},divide:{name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["a = 2 / 3","a * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]},dotDivide:{name:"dotDivide",category:"Operators",syntax:["x ./ y","dotDivide(x, y)"],description:"Divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","dotMultiply","divide"]},dotMultiply:{name:"dotMultiply",category:"Operators",syntax:["x .* y","dotMultiply(x, y)"],description:"Multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","dotDivide"]},dotPow:{name:"dotPow",category:"Operators",syntax:["x .^ y","dotPow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]},exp:{name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["expm","expm1","pow","log"]},expm:{name:"expm",category:"Arithmetic",syntax:["exp(x)"],description:"Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",examples:["expm([[0,2],[0,0]])"],seealso:["exp"]},expm1:{name:"expm1",category:"Arithmetic",syntax:["expm1(x)"],description:"Calculate the value of subtracting 1 from the exponential value.",examples:["expm1(2)","pow(e, 2) - 1","log(expm1(2) + 1)"],seealso:["exp","pow","log"]},fix:{name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]},floor:{name:"floor",category:"Arithmetic",syntax:["floor(x)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)"],seealso:["ceil","fix","round"]},gcd:{name:"gcd",category:"Arithmetic",syntax:["gcd(a, b)","gcd(a, b, c, ...)"],description:"Compute the greatest common divisor.",examples:["gcd(8, 12)","gcd(-4, 6)","gcd(25, 15, -10)"],seealso:["lcm","xgcd"]},hypot:{name:"hypot",category:"Arithmetic",syntax:["hypot(a, b, c, ...)","hypot([a, b, c, ...])"],description:"Calculate the hypotenuse of a list with values.",examples:["hypot(3, 4)","sqrt(3^2 + 4^2)","hypot(-2)","hypot([3, 4, 5])"],seealso:["abs","norm"]},lcm:{name:"lcm",category:"Arithmetic",syntax:["lcm(x, y)"],description:"Compute the least common multiple.",examples:["lcm(4, 6)","lcm(6, 21)","lcm(6, 21, 5)"],seealso:["gcd"]},log:{name:"log",category:"Arithmetic",syntax:["log(x)","log(x, base)"],description:"Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",examples:["log(3.5)","a = log(2.4)","exp(a)","10 ^ 4","log(10000, 10)","log(10000) / log(10)","b = log(1024, 2)","2 ^ b"],seealso:["exp","log1p","log2","log10"]},log2:{name:"log2",category:"Arithmetic",syntax:["log2(x)"],description:"Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",examples:["log2(0.03125)","log2(16)","log2(16) / log2(2)","pow(2, 4)"],seealso:["exp","log1p","log","log10"]},log1p:{name:"log1p",category:"Arithmetic",syntax:["log1p(x)","log1p(x, base)"],description:"Calculate the logarithm of a `value+1`",examples:["log1p(2.5)","exp(log1p(1.4))","pow(10, 4)","log1p(9999, 10)","log1p(9999) / log(10)"],seealso:["exp","log","log2","log10"]},log10:{name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(0.00001)","log10(10000)","10 ^ 4","log(10000) / log(10)","log(10000, 10)"],seealso:["exp","log"]},mod:{name:"mod",category:"Operators",syntax:["x % y","x mod y","mod(x, y)"],description:"Calculates the modulus, the remainder of an integer division.",examples:["7 % 3","11 % 2","10 mod 4","isOdd(x) = x % 2","isOdd(2)","isOdd(3)"],seealso:["divide"]},multiply:{name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["a = 2.1 * 3.4","a / 3.4","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]},norm:{name:"norm",category:"Arithmetic",syntax:["norm(x)","norm(x, p)"],description:"Calculate the norm of a number, vector or matrix.",examples:["abs(-3.5)","norm(-3.5)","norm(3 - 4i)","norm([1, 2, -3], Infinity)","norm([1, 2, -3], -Infinity)","norm([3, 4], 2)","norm([[1, 2], [3, 4]], 1)",'norm([[1, 2], [3, 4]], "inf")','norm([[1, 2], [3, 4]], "fro")']},nthRoot:{name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["nthRoots","pow","sqrt"]},nthRoots:{name:"nthRoots",category:"Arithmetic",syntax:["nthRoots(A)","nthRoots(A, root)"],description:'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',examples:["nthRoots(1)","nthRoots(1, 3)"],seealso:["sqrt","pow","nthRoot"]},pow:{name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3","2*2*2","1 + e ^ (pi * i)","pow([[1, 2], [4, 3]], 2)","pow([[1, 2], [4, 3]], -1)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},round:{name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)","round(unit, valuelessUnit)","round(unit, n, valuelessUnit)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)","round(3.241cm, 2, cm)","round([3.2, 3.8, -4.7])"],seealso:["ceil","floor","fix"]},sign:{name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},sqrt:{name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},sqrtm:{name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[33, 24], [48, 57]])"],seealso:["sqrt","abs","square","multiply"]},square:{name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},subtract:{name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},unaryMinus:{name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},invmod:{name:"invmod",category:"Arithmetic",syntax:["invmod(a, b)"],description:"Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)",examples:["invmod(8, 12)","invmod(7, 13)","invmod(15151, 15122)"],seealso:["gcd","xgcd"]},bitAnd:{name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitNot:{name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitOr:{name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},bitXor:{name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},leftShift:{name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},rightArithShift:{name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},rightLogShift:{name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},bellNumbers:{name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},catalan:{name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},composition:{name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},stirlingS2:{name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},config:{name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},import:{name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number": f(x)=x+x, "string": f(x)=concat(x,x) })',"double(2)",'double("hello")'],seealso:[]},arg:{name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},conj:{name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},re:{name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},im:{name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},evaluate:{name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate(expression, scope)","evaluate([expr1, expr2, expr3, ...])","evaluate([expr1, expr2, expr3, ...], scope)"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(16)")','evaluate("2 inch to cm")','evaluate("sin(x * pi)", { "x": 1/2 })','evaluate(["width=2", "height=4","width*height"])'],seealso:[]},help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},distance:{name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])","distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},intersect:{name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},and:{name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},not:{name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},or:{name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},xor:{name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},concat:{name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},count:{name:"count",category:"Matrix",syntax:["count(x)"],description:"Count the number of elements of a matrix, array or string.",examples:["a = [1, 2; 3, 4; 5, 6]","count(a)","size(a)",'count("hello world")'],seealso:["size"]},cross:{name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},column:{name:"column",category:"Matrix",syntax:["column(x, index)"],description:"Return a column from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","column(A, 1)","column(A, 2)"],seealso:["row","matrixFromColumns"]},ctranspose:{name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},det:{name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diag:{name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diff:{name:"diff",category:"Matrix",syntax:["diff(arr)","diff(arr, dim)"],description:["Create a new matrix or array with the difference of the passed matrix or array.","Dim parameter is optional and used to indicate the dimension of the array/matrix to apply the difference","If no dimension parameter is passed it is assumed as dimension 0","Dimension is zero-based in javascript and one-based in the parser","Arrays must be 'rectangular' meaning arrays like [1, 2]","If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],examples:["A = [1, 2, 4, 7, 0]","diff(A)","diff(A, 1)","B = [[1, 2], [3, 4]]","diff(B)","diff(B, 1)","diff(B, 2)","diff(B, bignumber(2))","diff([[1, 2], matrix([3, 4])], 2)"],seealso:["subtract","partitionSelect"]},dot:{name:"dot",category:"Matrix",syntax:["dot(A, B)","A * B"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]},getMatrixDataType:{name:"getMatrixDataType",category:"Matrix",syntax:["getMatrixDataType(x)"],description:'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',examples:["getMatrixDataType([1, 2, 3])","getMatrixDataType([[5 cm], [2 inch]])",'getMatrixDataType([1, "text"])',"getMatrixDataType([1, bignumber(4)])"],seealso:["matrix","sparse","typeOf"]},identity:{name:"identity",category:"Matrix",syntax:["identity(n)","identity(m, n)","identity([m, n])"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["identity(3)","identity(3, 5)","a = [1, 2, 3; 4, 5, 6]","identity(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},filter:{name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},flatten:{name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]},forEach:{name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["numberOfPets = {}","addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;",'forEach(["Dog","Cat","Cat"], addPet)',"numberOfPets"],seealso:["map","sort","filter"]},inv:{name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","identity","ones","range","size","squeeze","subset","trace","transpose","zeros"]},pinv:{name:"pinv",category:"Matrix",syntax:["pinv(x)"],description:"Calculate the Moore–Penrose inverse of a matrix",examples:["pinv([1, 2; 3, 4])","pinv([[1, 0], [0, 1], [0, 1]])","pinv(4)"],seealso:["inv"]},eigs:{name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and optionally eigenvectors of a square matrix",examples:["eigs([[5, 2.3], [2.3, 1]])","eigs([[1, 2, 3], [4, 5, 6], [7, 8, 9]], { precision: 1e-6, eigenvectors: false })"],seealso:["inv"]},kron:{name:"kron",category:"Matrix",syntax:["kron(x, y)"],description:"Calculates the Kronecker product of 2 matrices or vectors.",examples:["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])","kron([1,1], [2,3,4])"],seealso:["multiply","dot","cross"]},matrixFromFunction:{name:"matrixFromFunction",category:"Matrix",syntax:["matrixFromFunction(size, fn)","matrixFromFunction(size, fn, format)","matrixFromFunction(size, fn, format, datatype)","matrixFromFunction(size, format, fn)","matrixFromFunction(size, format, datatype, fn)"],description:"Create a matrix by evaluating a generating function at each index.",examples:["f(I) = I[1] - I[2]","matrixFromFunction([3,3], f)","g(I) = I[1] - I[2] == 1 ? 4 : 0",'matrixFromFunction([100, 100], "sparse", g)',"matrixFromFunction([5], random)"],seealso:["matrix","matrixFromRows","matrixFromColumns","zeros"]},matrixFromRows:{name:"matrixFromRows",category:"Matrix",syntax:["matrixFromRows(...arr)","matrixFromRows(row1, row2)","matrixFromRows(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual rows.",examples:["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromColumns","matrixFromFunction","zeros"]},matrixFromColumns:{name:"matrixFromColumns",category:"Matrix",syntax:["matrixFromColumns(...arr)","matrixFromColumns(row1, row2)","matrixFromColumns(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual columns.",examples:["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromRows","matrixFromFunction","zeros"]},map:{name:"map",category:"Matrix",syntax:["map(x, callback)","map(x, y, ..., callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array or the matrices/arrays.",examples:["map([1, 2, 3], square)","map([1, 2], [3, 4], f(a,b) = a + b)"],seealso:["filter","forEach"]},ones:{name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","identity","inv","range","size","squeeze","subset","trace","transpose","zeros"]},partitionSelect:{name:"partitionSelect",category:"Matrix",syntax:["partitionSelect(x, k)","partitionSelect(x, k, compare)"],description:"Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",examples:["partitionSelect([5, 10, 1], 2)",'partitionSelect(["C", "B", "A", "D"], 1, compareText)',"arr = [5, 2, 1]","partitionSelect(arr, 0) # returns 1, arr is now: [1, 2, 5]","arr","partitionSelect(arr, 1, 'desc') # returns 2, arr is now: [5, 2, 1]","arr"],seealso:["sort"]},range:{name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"range(1m, 1m, 3m)","a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","identity","inv","ones","size","squeeze","subset","trace","transpose","zeros"]},resize:{name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze","reshape"]},reshape:{name:"reshape",category:"Matrix",syntax:["reshape(x, sizes)"],description:"Reshape a multi dimensional array to fit the specified dimensions.",examples:["reshape([1, 2, 3, 4, 5, 6], [2, 3])","reshape([[1, 2], [3, 4]], [1, 4])","reshape([[1, 2], [3, 4]], [4])","reshape([1, 2, 3, 4], [-1, 2])"],seealso:["size","squeeze","resize"]},rotate:{name:"rotate",category:"Matrix",syntax:["rotate(w, theta)","rotate(w, theta, v)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotate([1, 0], pi / 2)",'rotate(matrix([1, 0]), unit("35deg"))','rotate([1, 0, 0], unit("90deg"), [0, 0, 1])','rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],seealso:["matrix","rotationMatrix"]},rotationMatrix:{name:"rotationMatrix",category:"Matrix",syntax:["rotationMatrix(theta)","rotationMatrix(theta, v)","rotationMatrix(theta, v, format)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotationMatrix(pi / 2)",'rotationMatrix(unit("45deg"), [0, 0, 1])','rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],seealso:["cos","sin"]},row:{name:"row",category:"Matrix",syntax:["row(x, index)"],description:"Return a row from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","row(A, 1)","row(A, 2)"],seealso:["column","matrixFromRows"]},size:{name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","count","det","diag","identity","inv","ones","range","squeeze","subset","trace","transpose","zeros"]},sort:{name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"], "natural")',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},squeeze:{name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","identity","inv","ones","range","size","subset","trace","transpose","zeros"]},subset:{name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation `l:u`. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]","f[[1,2], [1,3]] = [9, 10; 11, 12]","f"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},trace:{name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","transpose","zeros"]},transpose:{name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},zeros:{name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose"]},fft:{name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional Fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},ifft:{name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse Fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},sylvester:{name:"sylvester",category:"Algebra",syntax:["sylvester(A,B,C)"],description:"Solves the real-valued Sylvester equation AX+XB=C for X",examples:["sylvester([[-1, -2], [1, 1]], [[-2, 1], [-1, 2]], [[-3, 2], [3, 0]])","A = [[-1, -2], [1, 1]]; B = [[2, -1], [1, -2]]; C = [[-3, 2], [3, 0]]","sylvester(A, B, C)"],seealso:["schur","lyap"]},schur:{name:"schur",category:"Algebra",syntax:["schur(A)"],description:"Performs a real Schur decomposition of the real matrix A = UTU'",examples:["schur([[1, 0], [-4, 3]])","A = [[1, 0], [-4, 3]]","schur(A)"],seealso:["lyap","sylvester"]},lyap:{name:"lyap",category:"Algebra",syntax:["lyap(A,Q)"],description:"Solves the Continuous-time Lyapunov equation AP+PA'+Q=0 for P",examples:["lyap([[-2, 0], [1, -4]], [[3, 1], [1, 3]])","A = [[-2, 0], [1, -4]]","Q = [[3, 1], [1, 3]]","lyap(A,Q)"],seealso:["schur","sylvester"]},solveODE:{name:"solveODE",category:"Numeric",syntax:["solveODE(func, tspan, y0)","solveODE(func, tspan, y0, options)"],description:"Numerical Integration of Ordinary Differential Equations.",examples:["f(t,y) = y","tspan = [0, 4]","solveODE(f, tspan, 1)","solveODE(f, tspan, [1, 2])",'solveODE(f, tspan, 1, { method:"RK23", maxStep:0.1 })'],seealso:["derivative","simplifyCore"]},combinations:{name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},combinationsWithRep:{name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"],seealso:["combinations","permutations","factorial"]},factorial:{name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},gamma:{name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},kldivergence:{name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},lgamma:{name:"lgamma",category:"Probability",syntax:["lgamma(n)"],description:"Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.",examples:["lgamma(4)","lgamma(1/2)","lgamma(i)","lgamma(complex(1.1, 2))"],seealso:["gamma"]},multinomial:{name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},permutations:{name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},pickRandom:{name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)","pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])","pickRandom([1, 3, 1, 6], 2)","pickRandom([1, 3, 1, 6], [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],seealso:["random","randomInt"]},random:{name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]},randomInt:{name:"randomInt",category:"Probability",syntax:["randomInt(max)","randomInt(min, max)","randomInt(size)","randomInt(size, max)","randomInt(size, min, max)"],description:"Return a random integer number",examples:["randomInt(10, 20)","randomInt([2, 3], 10)"],seealso:["pickRandom","random"]},compare:{name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compareNatural","compareText"]},compareNatural:{name:"compareNatural",category:"Relational",syntax:["compareNatural(x, y)"],description:"Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compareNatural(2, 3)","compareNatural(3, 2)","compareNatural(2, 2)","compareNatural(5cm, 40mm)",'compareNatural("2", "10")',"compareNatural(2 + 3i, 2 + 4i)","compareNatural([1, 2, 4], [1, 2, 3])","compareNatural([1, 5], [1, 2, 3])","compareNatural([1, 2], [1, 2])","compareNatural({a: 2}, {a: 4})"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare","compareText"]},compareText:{name:"compareText",category:"Relational",syntax:["compareText(x, y)"],description:"Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:['compareText("B", "A")','compareText("A", "B")','compareText("A", "A")','compareText("2", "10")','compare("2", "10")',"compare(2, 10)",'compareNatural("2", "10")','compareText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural"]},deepEqual:{name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["deepEqual([1,3,4], [1,3,4])","deepEqual([1,3,4], [1,3])"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]},equal:{name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual","equalText"]},equalText:{name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},larger:{name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},largerEq:{name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},smaller:{name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},smallerEq:{name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 <= 1+1","2 < 1+1","a = 3.2","b = 6-2.8","(a <= b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]},unequal:{name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]},setCartesian:{name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays and the values will be sorted in ascending order before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},setDifference:{name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},setDistinct:{name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},setIntersect:{name:"setIntersect",category:"Set",syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},setIsSubset:{name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},setMultiplicity:{name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]},setPowerset:{name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},setSize:{name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},setSymDifference:{name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setDifference"]},setUnion:{name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},zpk2tf:{name:"zpk2tf",category:"Signal",syntax:["zpk2tf(z, p, k)"],description:"Compute the transfer function of a zero-pole-gain model.",examples:["zpk2tf([1, 2], [-1, -2], 1)","zpk2tf([1, 2], [-1, -2])","zpk2tf([1 - 3i, 2 + 2i], [-1, -2])"],seealso:[]},freqz:{name:"freqz",category:"Signal",syntax:["freqz(b, a)","freqz(b, a, w)"],description:"Calculates the frequency response of a filter given its numerator and denominator coefficients.",examples:["freqz([1, 2], [1, 2, 3])","freqz([1, 2], [1, 2, 3], [0, 1])","freqz([1, 2], [1, 2, 3], 512)"],seealso:[]},erf:{name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},zeta:{name:"zeta",category:"Special",syntax:["zeta(s)"],description:"Compute the Riemann Zeta Function using an infinite series and Riemann's Functional Equation for the entire complex plane",examples:["zeta(0.2)","zeta(-0.5)","zeta(4)"],seealso:[]},cumsum:{name:"cumsum",category:"Statistics",syntax:["cumsum(a, b, c, ...)","cumsum(A)"],description:"Compute the cumulative sum of all values.",examples:["cumsum(2, 3, 4, 1)","cumsum([2, 3, 4, 1])","cumsum([1, 2; 3, 4])","cumsum([1, 2; 3, 4], 1)","cumsum([1, 2; 3, 4], 2)"],seealso:["max","mean","median","min","prod","std","sum","variance"]},mad:{name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dimension)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},mean:{name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dimension)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},median:{name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},min:{name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dimension)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},mode:{name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},prod:{name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},quantileSeq:{name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:"Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probability are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.",examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},std:{name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, dimension)","std(A, normalization)","std(A, dimension, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},sum:{name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)","sum(A, dimension)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},variance:{name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, dimension)","variance(A, normalization)","variance(A, dimension, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},corr:{name:"corr",category:"Statistics",syntax:["corr(A,B)"],description:"Compute the correlation coefficient of a two list with values, For matrices, the matrix correlation coefficient is calculated.",examples:["corr([2, 4, 6, 8],[1, 2, 3, 6])","corr(matrix([[1, 2.2, 3, 4.8, 5], [1, 2, 3, 4, 5]]), matrix([[4, 5.3, 6.6, 7, 8], [1, 2, 3, 4, 5]]))"],seealso:["max","mean","min","median","min","prod","std","sum"]},acos:{name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},acosh:{name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},acot:{name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},acoth:{name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the inverse hyperbolic tangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},acsc:{name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},acsch:{name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the inverse hyperbolic cosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},asec:{name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},asech:{name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},asin:{name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},asinh:{name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},atan:{name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},atanh:{name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},atan2:{name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},cos:{name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},cosh:{name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},cot:{name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},coth:{name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},csc:{name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},csch:{name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},sec:{name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},sech:{name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},sin:{name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},sinh:{name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},tan:{name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},tanh:{name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},to:{name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},clone:{name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables, and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},format:{name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},bin:{name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},oct:{name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},hex:{name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},isNaN:{name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isInteger:{name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isNegative:{name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},isNumeric:{name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},hasNumericValue:{name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},isPositive:{name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isPrime:{name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isZero:{name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},print:{name:"print",category:"Utils",syntax:["print(template, values)","print(template, values, precision)"],description:"Interpolate values into a string template.",examples:['print("Lucy is $age years old", {age: 5})','print("The value of pi is $pi", {pi: pi}, 3)','print("Hello, $user.name!", {user: {name: "John"}})','print("Values: $1, $2, $3", [6, 9, 4])'],seealso:["format"]},typeOf:{name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},numeric:{name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, bigint, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "bigint")','numeric("4", "BigNumber")','numeric("4", "Fraction")','numeric(4, "Fraction")','numeric(fraction(2, 5), "number")'],seealso:["number","bigint","fraction","bignumber","string","format"]}},uh="help",ch=Me(uh,["typed","mathWithTransform","Help"],(e=>{var{typed:t,mathWithTransform:r,Help:n}=e;return t(uh,{any:function(e){var t,i=e;if("string"!=typeof e)for(t in r)if(Ce(r,t)&&e===r[t]){i=t;break}var a=y(sh,i);if(!a){var o="function"==typeof i?i.name:i;throw new Error('No documentation found on "'+o+'"')}return new n(a)}})})),lh="chain",fh=Me(lh,["typed","Chain"],(e=>{var{typed:t,Chain:r}=e;return t(lh,{"":function(){return new r},any:function(e){return new r(e)}})})),ph=Me("det",["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],(e=>{var{typed:t,matrix:r,subtractScalar:n,multiply:i,divideScalar:a,isZero:o,unaryMinus:s}=e;return t("det",{any:function(e){return be(e)},"Array | Matrix":function(e){var t;switch((t=q(e)?e.size():Array.isArray(e)?(e=r(e)).size():[]).length){case 0:return be(e);case 1:if(1===t[0])return be(e.valueOf()[0]);if(0===t[0])return 1;throw new RangeError("Matrix must be square (size: "+Sn(t)+")");case 2:var u=t[0],c=t[1];if(u===c)return function(e,t,r){if(1===t)return be(e[0][0]);if(2===t)return n(i(e[0][0],e[1][1]),i(e[1][0],e[0][1]));for(var u=!1,c=new Array(t).fill(0).map(((e,t)=>t)),l=0;l<t;l++){var f=c[l];if(o(e[f][l])){var p=void 0;for(p=l+1;p<t;p++)if(!o(e[c[p]][l])){f=c[p],c[p]=c[l],c[l]=f,u=!u;break}if(p===t)return e[f][l]}for(var m=e[f][l],h=0===l?1:e[c[l-1]][l-1],d=l+1;d<t;d++)for(var g=c[d],v=l+1;v<t;v++)e[g][v]=a(n(i(e[g][v],m),i(e[g][l],e[f][v])),h)}var y=e[c[t-1]][t-1];return u?s(y):y}(e.clone().valueOf(),u);if(0===c)return 1;throw new RangeError("Matrix must be square (size: "+Sn(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+Sn(t)+")")}}})})),mh=Me("inv",["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],(e=>{var{typed:t,matrix:r,divideScalar:n,addScalar:i,multiply:a,unaryMinus:o,det:s,identity:u,abs:c}=e;return t("inv",{"Array | Matrix":function(e){var t=q(e)?e.size():Bn(e);switch(t.length){case 1:if(1===t[0])return q(e)?r([n(1,e.valueOf()[0])]):[n(1,e[0])];throw new RangeError("Matrix must be square (size: "+Sn(t)+")");case 2:var i=t[0],a=t[1];if(i===a)return q(e)?r(l(e.valueOf(),i,a),e.storage()):l(e,i,a);throw new RangeError("Matrix must be square (size: "+Sn(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+Sn(t)+")")}},any:function(e){return n(1,e)}});function l(e,t,r){var l,f,p,m,h;if(1===t){if(0===(m=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero");return[[n(1,m)]]}if(2===t){var d=s(e);if(0===d)throw Error("Cannot calculate inverse, determinant is zero");return[[n(e[1][1],d),n(o(e[0][1]),d)],[n(o(e[1][0]),d),n(e[0][0],d)]]}var g=e.concat();for(l=0;l<t;l++)g[l]=g[l].concat();for(var v=u(t).valueOf(),y=0;y<r;y++){var x=c(g[y][y]),b=y;for(l=y+1;l<t;)c(g[l][y])>x&&(x=c(g[l][y]),b=l),l++;if(0===x)throw Error("Cannot calculate inverse, determinant is zero");(l=b)!==y&&(h=g[y],g[y]=g[l],g[l]=h,h=v[y],v[y]=v[l],v[l]=h);var w=g[y],D=v[y];for(l=0;l<t;l++){var N=g[l],E=v[l];if(l!==y){if(0!==N[y]){for(p=n(o(N[y]),w[y]),f=y;f<r;f++)N[f]=i(N[f],a(p,w[f]));for(f=0;f<r;f++)E[f]=i(E[f],a(p,D[f]))}}else{for(p=w[y],f=y;f<r;f++)N[f]=n(N[f],p);for(f=0;f<r;f++)E[f]=n(E[f],p)}}}return v}})),hh="pinv",dh=Me(hh,["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],(e=>{var{typed:t,matrix:r,inv:n,deepEqual:i,equal:a,dotDivide:o,dot:s,ctranspose:u,divideScalar:c,multiply:l,add:f,Complex:p}=e;return t(hh,{"Array | Matrix":function(e){var t=q(e)?e.size():Bn(e);switch(t.length){case 1:return d(e)?u(e):1===t[0]?n(e):o(u(e),s(e,e));case 2:if(d(e))return u(e);var i=t[0],a=t[1];if(i===a)try{return n(e)}catch(e){if(!(e instanceof Error&&e.message.match(/Cannot calculate inverse, determinant is zero/)))throw e}return q(e)?r(m(e.valueOf(),i,a),e.storage()):m(e,i,a);default:throw new RangeError("Matrix must be two dimensional (size: "+Sn(t)+")")}},any:function(e){return a(e,0)?be(e):c(1,e)}});function m(e,t,r){var{C:i,F:a}=function(e,t,r){var n=function(e,t,r){for(var n=be(e),i=0,a=0;a<t;a++){if(r<=i)return n;for(var s=a;h(n[s][i]);)if(t===++s&&(s=a,r===++i))return n;[n[s],n[a]]=[n[a],n[s]];for(var u=n[a][i],c=0;c<r;c++)n[a][c]=o(n[a][c],u);for(var p=0;p<t;p++)if(p!==a){u=n[p][i];for(var m=0;m<r;m++)n[p][m]=f(n[p][m],l(-1,l(u,n[a][m])))}i++}return n}(e,t,r);return{C:e.map(((e,r)=>e.filter(((e,r)=>r<t&&!h(s(n[r],n[r])))))),F:n.filter(((e,t)=>!h(s(n[t],n[t]))))}}(e,t,r),c=l(n(l(u(i),i)),u(i)),p=l(u(a),n(l(a,u(a))));return l(p,c)}function h(e){return a(f(e,p(1,1)),f(0,p(1,1)))}function d(e){return i(f(e,p(1,1)),f(l(e,0),p(1,1)))}}));var gh=Me("eigs",["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","divideScalar","inv","bignumber","multiply","add","larger","column","flatten","number","complex","sqrt","diag","size","reshape","qr","usolve","usolveAll","im","re","smaller","matrixFromColumns","dot"],(e=>{var{config:t,typed:r,matrix:n,addScalar:i,subtract:a,equal:o,abs:s,atan:u,cos:c,sin:l,multiplyScalar:f,divideScalar:p,inv:h,bignumber:d,multiply:g,add:v,larger:y,column:x,flatten:b,number:w,complex:D,sqrt:N,diag:E,size:A,reshape:S,qr:C,usolve:M,usolveAll:_,im:k,re:z,smaller:I,matrixFromColumns:q,dot:R}=e,P=function(e){var{config:t,addScalar:r,subtract:n,abs:i,atan:a,cos:o,sin:s,multiplyScalar:u,inv:c,bignumber:l,multiply:f,add:p}=e;function m(e,t,r,n){for(var i=e.length,a=Math.cos(t),o=Math.sin(t),s=Array(i).fill(0),u=Array(i).fill(0),c=0;c<i;c++)s[c]=a*e[c][r]-o*e[c][n],u[c]=o*e[c][r]+a*e[c][n];for(var l=0;l<i;l++)e[l][r]=s[l],e[l][n]=u[l];return e}function h(e,t,i,a){for(var c=e.length,f=o(t),p=s(t),m=Array(c).fill(l(0)),h=Array(c).fill(l(0)),d=0;d<c;d++)m[d]=n(u(f,e[d][i]),u(p,e[d][a])),h[d]=r(u(p,e[d][i]),u(f,e[d][a]));for(var g=0;g<c;g++)e[g][i]=m[g],e[g][a]=h[g];return e}function d(e,t,i,a){for(var c=e.length,m=l(o(t)),h=l(s(t)),d=u(m,m),g=u(h,h),v=Array(c).fill(l(0)),y=Array(c).fill(l(0)),x=f(l(2),m,h,e[i][a]),b=r(n(u(d,e[i][i]),x),u(g,e[a][a])),w=p(u(g,e[i][i]),x,u(d,e[a][a])),D=0;D<c;D++)v[D]=n(u(m,e[i][D]),u(h,e[a][D])),y[D]=r(u(h,e[i][D]),u(m,e[a][D]));e[i][i]=b,e[a][a]=w,e[i][a]=l(0),e[a][i]=l(0);for(var N=0;N<c;N++)N!==i&&N!==a&&(e[i][N]=v[N],e[N][i]=v[N],e[a][N]=y[N],e[N][a]=y[N]);return e}function g(e,t,r,n){for(var i=e.length,a=Math.cos(t),o=Math.sin(t),s=a*a,u=o*o,c=Array(i).fill(0),l=Array(i).fill(0),f=s*e[r][r]-2*a*o*e[r][n]+u*e[n][n],p=u*e[r][r]+2*a*o*e[r][n]+s*e[n][n],m=0;m<i;m++)c[m]=a*e[r][m]-o*e[n][m],l[m]=o*e[r][m]+a*e[n][m];e[r][r]=f,e[n][n]=p,e[r][n]=0,e[n][r]=0;for(var h=0;h<i;h++)h!==r&&h!==n&&(e[r][h]=c[h],e[h][r]=c[h],e[n][h]=l[h],e[h][n]=l[h]);return e}function v(e){for(var t=e.length,r=0,n=[0,1],i=0;i<t;i++)for(var a=i+1;a<t;a++)Math.abs(r)<Math.abs(e[i][a])&&(r=Math.abs(e[i][a]),n=[i,a]);return[n,r]}function y(e){for(var t=e.length,r=0,n=[0,1],a=0;a<t;a++)for(var o=a+1;o<t;o++)i(r)<i(e[a][o])&&(r=i(e[a][o]),n=[a,o]);return[n,r]}function x(e,t,r){var n,a=e.length,o=Array(a);if(r){n=Array(a);for(var s=0;s<a;s++)n[s]=Array(a)}for(var u=0;u<a;u++){for(var c=0,l=e[0],f=0;f<e.length;f++)i(e[f])<i(l)&&(l=e[c=f]);if(o[u]=e.splice(c,1)[0],r)for(var p=0;p<a;p++)n[u][p]=t[p][c],t[p].splice(c,1)}if(!r)return{values:o};var m=n.map(((e,t)=>({value:o[t],vector:e})));return{values:o,eigenvectors:m}}return function(e,r){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.relTol,s=arguments.length>3?arguments[3]:void 0,p=arguments.length>4?arguments[4]:void 0;if("number"===s)return function(e,r,n){var i,a,o=e.length,s=Math.abs(r/o);if(n){a=new Array(o);for(var u=0;u<o;u++)a[u]=Array(o).fill(0),a[u][u]=1}for(var c,l,f,p,h=v(e);Math.abs(h[1])>=Math.abs(s);){var d=h[0][0],y=h[0][1];e=g(e,(c=e[d][d],l=e[y][y],f=e[d][y],p=void 0,p=l-c,i=Math.abs(p)<=t.relTol?Math.PI/4:.5*Math.atan(2*f/(l-c))),d,y),n&&(a=m(a,i,d,y)),h=v(e)}for(var b=Array(o).fill(0),w=0;w<o;w++)b[w]=e[w][w];return x(be(b),a,n)}(e,o,p);if("BigNumber"===s)return function(e,r,o){var s,p,m=e.length,g=i(r/m);if(o){p=new Array(m);for(var v=0;v<m;v++)p[v]=Array(m).fill(0),p[v][v]=1}for(var b,w,D,N,E=y(e);i(E[1])>=i(g);){var A=E[0][0],S=E[0][1];e=d(e,(b=e[A][A],w=e[S][S],D=e[A][S],N=void 0,N=n(w,b),s=i(N)<=t.relTol?l(-1).acos().div(4):u(.5,a(f(2,D,c(N))))),A,S),o&&(p=h(p,s,A,S)),E=y(e)}for(var C=Array(m).fill(0),M=0;M<m;M++)C[M]=e[M][M];return x(be(C),p,o)}(e,o,p);throw TypeError("Unsupported data type: "+s)}}({config:t,addScalar:i,subtract:a,column:x,flatten:b,equal:o,abs:s,atan:u,cos:c,sin:l,multiplyScalar:f,inv:h,bignumber:d,complex:D,multiply:g,add:v}),j=function(e){var{addScalar:t,subtract:r,flatten:n,multiply:i,multiplyScalar:a,divideScalar:o,sqrt:s,abs:u,bignumber:c,diag:l,size:f,reshape:p,inv:m,qr:h,usolve:d,usolveAll:g,equal:v,complex:y,larger:x,smaller:b,matrixFromColumns:w,dot:D}=e;function N(e,t,n,i,a,o,s,l){var f="BigNumber"===l,p="Complex"===l,m=f?c(0):p?y(0):0,h=f?c(1):p?y(1):1;if(b(u(n),s))return[[h,m],[m,h]];if(x(u(r(a,o)),s))return[[r(a,i),r(o,i)],[n,n]];var d=r(e,a),g=r(i,a);return b(u(t),s)&&b(u(g),s)?[[d,h],[n,m]]:[[t,m],[g,h]]}function E(e,t){for(var r=0;r<e.length;r++)e[r].push(...Array(t-e[r].length).fill(0));for(var n=e.length;n<t;n++)e.push(Array(t).fill(0)),e[n][n]=1;return e}function A(e,t,r){for(var n=0;n<e.length;n++)if(r(e[n],t))return n;return-1}function S(e,t,r,n,i){for(var a,o="BigNumber"===i?c(1e3):1e3,s=0;s<5;++s){a=C(t,r,i);try{a=d(e,a)}catch(e){continue}if(x(F(a),o))break}if(s>=5)return null;for(s=0;;){var u=d(e,a);if(b(F(M(a,[u])),n))break;if(++s>=10)return null;a=T(u)}return a}function C(e,t,r){var n="BigNumber"===r,i="Complex"===r,a=Array(e).fill(0).map((e=>2*Math.random()-1));return n&&(a=a.map((e=>c(e)))),i&&(a=a.map((e=>y(e)))),T(a=M(a,t),r)}function M(e,t){var n=f(e);for(var a of t)a=p(a,n),e=r(e,i(o(D(a,e),D(a,a)),a));return e}function F(e){return u(s(D(e,e)))}function T(e,t){var r="Complex"===t,n="BigNumber"===t?c(1):r?y(1):1;return i(o(n,F(e)),e)}return function(e,f,p,d){var w=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],D=function(e,r,n,i,s){var f,p="BigNumber"===i,m="Complex"===i,h=p?c(0):0,d=p?c(1):m?y(1):1,g=p?c(1):1,w=p?c(10):2,D=a(w,w);s&&(f=Array(r).fill(d));for(var N=!1;!N;){N=!0;for(var E=0;E<r;E++){for(var A=h,S=h,C=0;C<r;C++)E!==C&&(A=t(A,u(e[C][E])),S=t(S,u(e[E][C])));if(!v(A,0)&&!v(S,0)){for(var M=g,F=A,T=o(S,w),_=a(S,w);b(F,T);)F=a(F,D),M=a(M,w);for(;x(F,_);)F=o(F,D),M=o(M,w);if(b(o(t(F,S),M),a(t(A,S),.95))){N=!1;for(var B=o(1,M),O=0;O<r;O++)E!==O&&(e[E][O]=a(e[E][O],B),e[O][E]=a(e[O][E],M));s&&(f[E]=a(f[E],B))}}}}return s?l(f):null}(e,f,0,d,w);!function(e,n,i,s,l,f){var p="BigNumber"===s,m="Complex"===s,h=p?c(0):m?y(0):0;p&&(i=c(i));for(var d=0;d<n-2;d++){for(var g=0,v=h,x=d+1;x<n;x++){var w=e[x][d];b(u(v),u(w))&&(v=w,g=x)}if(!b(u(v),i)){if(g!==d+1){var D=e[g];e[g]=e[d+1],e[d+1]=D;for(var N=0;N<n;N++){var E=e[N][g];e[N][g]=e[N][d+1],e[N][d+1]=E}if(l){var A=f[g];f[g]=f[d+1],f[d+1]=A}}for(var S=d+2;S<n;S++){var C=o(e[S][d],v);if(0!==C){for(var M=0;M<n;M++)e[S][M]=r(e[S][M],a(C,e[d+1][M]));for(var F=0;F<n;F++)e[F][d+1]=t(e[F][d+1],a(C,e[F][S]));if(l)for(var T=0;T<n;T++)f[S][T]=r(f[S][T],a(C,f[d+1][T]))}}}}}(e,f,p,d,w,D);var{values:C,C:M}=function(e,n,o,f,p){var m="BigNumber"===f,d="Complex"===f,g=m?c(1):d?y(1):1;m&&(o=c(o));for(var v,x,w,D,A,S,C,M,F=be(e),T=[],_=n,B=[],O=p?l(Array(n).fill(g)):void 0,k=p?l(Array(_).fill(g)):void 0,z=0;z<=100;){z+=1;for(var I=F[_-1][_-1],q=0;q<_;q++)F[q][q]=r(F[q][q],I);var{Q:R,R:P}=h(F);F=i(P,R);for(var j=0;j<_;j++)F[j][j]=t(F[j][j],I);if(p&&(k=i(k,R)),1===_||b(u(F[_-1][_-2]),o)){z=0,T.push(F[_-1][_-1]),p&&(B.unshift([[1]]),E(k,n),O=i(O,k),_>1&&(k=l(Array(_-1).fill(g)))),_-=1,F.pop();for(var U=0;U<_;U++)F[U].pop()}else if(2===_||b(u(F[_-2][_-3]),o)){z=0;var L=(v=F[_-2][_-2],x=F[_-2][_-1],w=F[_-1][_-2],D=F[_-1][_-1],A=void 0,S=void 0,C=void 0,M=void 0,A=t(v,D),S=r(a(v,D),a(x,w)),C=a(A,.5),M=a(s(r(a(A,A),a(4,S))),.5),[t(C,M),r(C,M)]);T.push(...L),p&&(B.unshift(N(F[_-2][_-2],F[_-2][_-1],F[_-1][_-2],F[_-1][_-1],L[0],L[1],o,f)),E(k,n),O=i(O,k),_>2&&(k=l(Array(_-2).fill(g)))),_-=2,F.pop(),F.pop();for(var H=0;H<_;H++)F[H].pop(),F[H].pop()}if(0===_)break}if(T.sort(((e,t)=>+r(u(e),u(t)))),z>100){var $=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+T.join(", "));throw $.values=T,$.vectors=[],$}var G=p?i(O,function(e,t){for(var r=[],n=0;n<t;n++)r[n]=Array(t).fill(0);var i=0;for(var a of e){for(var o=a.length,s=0;s<o;s++)for(var u=0;u<o;u++)r[i+s][i+u]=a[s][u];i+=o}return r}(B,n)):void 0;return{values:T,C:G}}(e,f,p,d,w);if(w){var F=function(e,t,a,o,s,u,f){var p=m(a),h=i(p,e,a),d="BigNumber"===f,x="Complex"===f,b=d?c(0):x?y(0):0,w=d?c(1):x?y(1):1,D=[],N=[];for(var E of s){var C=A(D,E,v);-1===C?(D.push(E),N.push(1)):N[C]+=1}for(var M=[],F=D.length,T=Array(t).fill(b),_=l(Array(t).fill(w)),B=function(){var e=D[O],s=r(h,i(e,_)),c=g(s,T);for(c.shift();c.length<N[O];){var l=S(s,t,c,u,f);if(null===l)break;c.push(l)}var p=i(m(o),a);c=c.map((e=>i(p,e))),M.push(...c.map((t=>({value:e,vector:n(t)}))))},O=0;O<F;O++)B();return M}(e,f,M,D,C,p,d);return{values:C,eigenvectors:F}}return{values:C}}}({config:t,addScalar:i,subtract:a,multiply:g,multiplyScalar:f,flatten:b,divideScalar:p,sqrt:N,abs:s,bignumber:d,diag:E,size:A,reshape:S,qr:C,inv:h,usolve:M,usolveAll:_,equal:o,complex:D,larger:y,smaller:I,matrixFromColumns:q,dot:R});return r("eigs",{Array:function(e){return U(n(e))},"Array, number|BigNumber":function(e,t){return U(n(e),{precision:t})},"Array, Object":(e,t)=>U(n(e),t),Matrix:function(e){return U(e,{matricize:!0})},"Matrix, number|BigNumber":function(e,t){return U(e,{precision:t,matricize:!0})},"Matrix, Object":function(e,t){var r={matricize:!0};return m(r,t),U(e,r)}});function U(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=!("eigenvectors"in i)||i.eigenvectors,u=function(e,t,r){var n=e.toArray(),i=e.size();if(2!==i.length||i[0]!==i[1])throw new RangeError("Matrix must be square (size: ".concat(Sn(i),")"));var o=i[0];if(function(e,t,r){for(var n=0;n<t;n++)for(var i=0;i<t;i++)if(y(d(s(k(e[n][i]))),r))return!1;return!0}(n,o,t)&&(function(e,t){for(var r=0;r<t;r++)for(var n=0;n<t;n++)e[r][n]=z(e[r][n])}(n,o),function(e,t,r){for(var n=0;n<t;n++)for(var i=n;i<t;i++)if(y(d(s(a(e[n][i],e[i][n]))),r))return!1;return!0}(n,o,t))){var u=L(e,n,o);return P(n,o,t,u,r)}var c=L(e,n,o);return j(n,o,t,c,r)}(e,null!==(r=i.precision)&&void 0!==r?r:t.relTol,o);return i.matricize&&(u.values=n(u.values),o&&(u.eigenvectors=u.eigenvectors.map((e=>{var{value:t,vector:r}=e;return{value:t,vector:n(r)}})))),o&&Object.defineProperty(u,"vectors",{enumerable:!1,get:()=>{throw new Error("eigs(M).vectors replaced with eigs(M).eigenvectors")}}),u}function L(e,t,r){var n=e.datatype();if("number"===n||"BigNumber"===n||"Complex"===n)return n;for(var i=!1,a=!1,o=!1,s=0;s<r;s++)for(var u=0;u<r;u++){var c=t[s][u];if(F(c)||O(c))i=!0;else if(T(c))a=!0;else{if(!B(c))throw TypeError("Unsupported type in Matrix: "+xe(c));o=!0}}if(a&&o&&console.warn("Complex BigNumbers not supported, this operation will lose precission."),o){for(var l=0;l<r;l++)for(var f=0;f<r;f++)t[l][f]=D(t[l][f]);return"Complex"}if(a){for(var p=0;p<r;p++)for(var m=0;m<r;m++)t[p][m]=d(t[p][m]);return"BigNumber"}if(i){for(var h=0;h<r;h++)for(var g=0;g<r;g++)t[h][g]=w(t[h][g]);return"number"}throw TypeError("Matrix contains unsupported types only.")}})),vh="expm",yh=Me(vh,["typed","abs","add","identity","inv","multiply"],(e=>{var{typed:t,abs:r,add:n,identity:i,inv:a,multiply:o}=e;return t(vh,{Matrix:function(e){var t=e.size();if(2!==t.length||t[0]!==t[1])throw new RangeError("Matrix must be square (size: "+Sn(t)+")");for(var u=t[0],c=function(e){for(var t=e.size()[0],n=0,i=0;i<t;i++){for(var a=0,o=0;o<t;o++)a+=r(e.get([i,o]));n=Math.max(a,n)}return n}(e),l=function(e,t){for(var r=0;r<30;r++)for(var n=0;n<=r;n++){var i=r-n;if(s(e,n,i)<1e-15)return{q:n,j:i}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}(c),f=l.q,p=l.j,m=o(e,Math.pow(2,-p)),h=i(u),d=i(u),g=1,v=m,y=-1,x=1;x<=f;x++)x>1&&(v=o(v,m),y=-y),h=n(h,o(g=g*(f-x+1)/((2*f-x+1)*x),v)),d=n(d,o(g*y,v));for(var b=o(a(d),h),w=0;w<p;w++)b=o(b,b);return j(e)?e.createSparseMatrix(b):b}});function s(e,t,r){for(var n=1,i=2;i<=t;i++)n*=i;for(var a=n,o=t+1;o<=2*t;o++)a*=o;var s=a*(2*t+1);return 8*Math.pow(e/Math.pow(2,r),2*t)*n*n/(a*s)}})),xh="sqrtm",bh=Me(xh,["typed","abs","add","multiply","map","sqrt","subtract","inv","size","max","identity"],(e=>{var{typed:t,abs:r,add:n,multiply:i,map:a,sqrt:o,subtract:s,inv:u,size:c,max:l,identity:f}=e,p=1e-6;function m(e){var t,a=0,o=e,m=f(c(e));do{var h=o;if(o=i(.5,n(h,u(m))),m=i(.5,n(m,u(h))),(t=l(r(s(o,h))))>p&&++a>1e3)throw new Error("computing square root of matrix: iterative method could not converge")}while(t>p);return o}return t(xh,{"Array | Matrix":function(e){var t=q(e)?e.size():Bn(e);switch(t.length){case 1:if(1===t[0])return a(e,o);throw new RangeError("Matrix must be square (size: "+Sn(t)+")");case 2:if(t[0]===t[1])return m(e);throw new RangeError("Matrix must be square (size: "+Sn(t)+")");default:throw new RangeError("Matrix must be at most two dimensional (size: "+Sn(t)+")")}}})})),wh="sylvester",Dh=Me(wh,["typed","schur","matrixFromColumns","matrix","multiply","range","concat","transpose","index","subset","add","subtract","identity","lusolve","abs"],(e=>{var{typed:t,schur:r,matrixFromColumns:n,matrix:i,multiply:a,range:o,concat:s,transpose:u,index:c,subset:l,add:f,subtract:p,identity:m,lusolve:h,abs:d}=e;return t(wh,{"Matrix, Matrix, Matrix":g,"Array, Matrix, Matrix":function(e,t,r){return g(i(e),t,r)},"Array, Array, Matrix":function(e,t,r){return g(i(e),i(t),r)},"Array, Matrix, Array":function(e,t,r){return g(i(e),t,i(r))},"Matrix, Array, Matrix":function(e,t,r){return g(e,i(t),r)},"Matrix, Array, Array":function(e,t,r){return g(e,i(t),i(r))},"Matrix, Matrix, Array":function(e,t,r){return g(e,t,i(r))},"Array, Array, Array":function(e,t,r){return g(i(e),i(t),i(r)).toArray()}});function g(e,t,g){for(var v=t.size()[0],y=e.size()[0],x=r(e),b=x.T,w=x.U,D=r(a(-1,t)),N=D.T,E=D.U,A=a(a(u(w),g),E),S=o(0,y),C=[],M=(e,t)=>s(e,t,1),F=(e,t)=>s(e,t,0),T=0;T<v;T++)if(T<v-1&&d(l(N,c(T+1,T)))>1e-5){for(var _=F(l(A,c(S,T)),l(A,c(S,T+1))),B=0;B<T;B++)_=f(_,F(a(C[B],l(N,c(B,T))),a(C[B],l(N,c(B,T+1)))));var O=a(m(y),a(-1,l(N,c(T,T)))),k=a(m(y),a(-1,l(N,c(T+1,T)))),z=a(m(y),a(-1,l(N,c(T,T+1)))),I=a(m(y),a(-1,l(N,c(T+1,T+1)))),q=F(M(f(b,O),k),M(z,f(b,I))),R=h(q,_);C[T]=R.subset(c(o(0,y),0)),C[T+1]=R.subset(c(o(y,2*y),0)),T++}else{for(var P=l(A,c(S,T)),j=0;j<T;j++)P=f(P,a(C[j],l(N,c(j,T))));var U=l(N,c(T,T)),L=p(b,a(U,m(y)));C[T]=h(L,P)}var H=i(n(...C));return a(w,a(H,u(E)))}})),Nh="schur",Eh=Me(Nh,["typed","matrix","identity","multiply","qr","norm","subtract"],(e=>{var{typed:t,matrix:r,identity:n,multiply:i,qr:a,norm:o,subtract:s}=e;return t(Nh,{Array:function(e){var t=u(r(e));return{U:t.U.valueOf(),T:t.T.valueOf()}},Matrix:function(e){return u(e)}});function u(e){var t,r=e.size()[0],u=e,c=n(r),l=0;do{t=u;var f=a(u),p=f.Q,m=f.R;if(u=i(m,p),c=i(c,p),l++>100)break}while(o(s(u,t))>1e-4);return{U:c,T:u}}})),Ah="lyap",Sh=Me(Ah,["typed","matrix","sylvester","multiply","transpose"],(e=>{var{typed:t,matrix:r,sylvester:n,multiply:i,transpose:a}=e;return t(Ah,{"Matrix, Matrix":function(e,t){return n(e,a(e),i(-1,t))},"Array, Matrix":function(e,t){return n(r(e),a(r(e)),i(-1,t))},"Matrix, Array":function(e,t){return n(e,a(r(e)),r(i(-1,t)))},"Array, Array":function(e,t){return n(r(e),a(r(e)),r(i(-1,t))).toArray()}})})),Ch=Me("divide",["typed","matrix","multiply","equalScalar","divideScalar","inv"],(e=>{var{typed:t,matrix:r,multiply:n,equalScalar:i,divideScalar:a,inv:o}=e,s=Ga({typed:t,equalScalar:i}),u=Va({typed:t});return t("divide",we({"Array | Matrix, Array | Matrix":function(e,t){return n(e,o(t))},"DenseMatrix, any":function(e,t){return u(e,t,a,!1)},"SparseMatrix, any":function(e,t){return s(e,t,a,!1)},"Array, any":function(e,t){return u(r(e),t,a,!1).valueOf()},"any, Array | Matrix":function(e,t){return n(e,o(t))}},a.signatures))})),Mh="distance",Fh=Me(Mh,["typed","addScalar","subtractScalar","divideScalar","multiplyScalar","deepEqual","sqrt","abs"],(e=>{var{typed:t,addScalar:r,subtractScalar:n,multiplyScalar:i,divideScalar:a,deepEqual:o,sqrt:s,abs:u}=e;return t(Mh,{"Array, Array, Array":function(e,t,r){if(2===e.length&&2===t.length&&2===r.length){if(!l(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!l(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!l(r))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(o(t,r))throw new TypeError("LinePoint1 should not be same with LinePoint2");var a=n(r[1],t[1]),s=n(t[0],r[0]),u=n(i(r[0],t[1]),i(t[0],r[1]));return d(e[0],e[1],a,s,u)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(e,t,r){if(2===Object.keys(e).length&&2===Object.keys(t).length&&2===Object.keys(r).length){if(!l(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!l(t))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!l(r))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if(o(h(t),h(r)))throw new TypeError("LinePoint1 should not be same with LinePoint2");if("pointX"in e&&"pointY"in e&&"lineOnePtX"in t&&"lineOnePtY"in t&&"lineTwoPtX"in r&&"lineTwoPtY"in r){var a=n(r.lineTwoPtY,t.lineOnePtY),s=n(t.lineOnePtX,r.lineTwoPtX),u=n(i(r.lineTwoPtX,t.lineOnePtY),i(t.lineOnePtX,r.lineTwoPtY));return d(e.pointX,e.pointY,a,s,u)}throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(e,t){if(2===e.length&&3===t.length){if(!l(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!f(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return d(e[0],e[1],t[0],t[1],t[2])}if(3===e.length&&6===t.length){if(!f(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!m(t))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return g(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}if(e.length===t.length&&e.length>0){if(!p(e))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!p(t))throw new TypeError("All values of an array should be numbers or BigNumbers");return v(e,t)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,t){if(2===Object.keys(e).length&&3===Object.keys(t).length){if(!l(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!f(t))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"xCoeffLine"in t&&"yCoeffLine"in t&&"constant"in t)return d(e.pointX,e.pointY,t.xCoeffLine,t.yCoeffLine,t.constant);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&6===Object.keys(t).length){if(!f(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!m(t))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"x0"in t&&"y0"in t&&"z0"in t&&"a"in t&&"b"in t&&"c"in t)return g(e.pointX,e.pointY,e.pointZ,t.x0,t.y0,t.z0,t.a,t.b,t.c);throw new TypeError("Key names do not match")}if(2===Object.keys(e).length&&2===Object.keys(t).length){if(!l(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!l(t))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointTwoX"in t&&"pointTwoY"in t)return v([e.pointOneX,e.pointOneY],[t.pointTwoX,t.pointTwoY]);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&3===Object.keys(t).length){if(!f(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!f(t))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointOneZ"in e&&"pointTwoX"in t&&"pointTwoY"in t&&"pointTwoZ"in t)return v([e.pointOneX,e.pointOneY,e.pointOneZ],[t.pointTwoX,t.pointTwoY,t.pointTwoZ]);throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},Array:function(e){if(!function(e){if(2===e[0].length&&c(e[0][0])&&c(e[0][1])){if(e.some((e=>2!==e.length||!c(e[0])||!c(e[1]))))return!1}else{if(!(3===e[0].length&&c(e[0][0])&&c(e[0][1])&&c(e[0][2])))return!1;if(e.some((e=>3!==e.length||!c(e[0])||!c(e[1])||!c(e[2]))))return!1}return!0}(e))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return function(e){for(var t=[],r=[],n=[],i=0;i<e.length-1;i++)for(var a=i+1;a<e.length;a++)2===e[0].length?(r=[e[i][0],e[i][1]],n=[e[a][0],e[a][1]]):3===e[0].length&&(r=[e[i][0],e[i][1],e[i][2]],n=[e[a][0],e[a][1],e[a][2]]),t.push(v(r,n));return t}(e)}});function c(e){return"number"==typeof e||T(e)}function l(e){return e.constructor!==Array&&(e=h(e)),c(e[0])&&c(e[1])}function f(e){return e.constructor!==Array&&(e=h(e)),c(e[0])&&c(e[1])&&c(e[2])}function p(e){return Array.isArray(e)||(e=h(e)),e.every(c)}function m(e){return e.constructor!==Array&&(e=h(e)),c(e[0])&&c(e[1])&&c(e[2])&&c(e[3])&&c(e[4])&&c(e[5])}function h(e){for(var t=Object.keys(e),r=[],n=0;n<t.length;n++)r.push(e[t[n]]);return r}function d(e,t,n,o,c){var l=u(r(r(i(n,e),i(o,t)),c)),f=s(r(i(n,n),i(o,o)));return a(l,f)}function g(e,t,o,u,c,l,f,p,m){var h=[n(i(n(c,t),m),i(n(l,o),p)),n(i(n(l,o),f),i(n(u,e),m)),n(i(n(u,e),p),i(n(c,t),f))];h=s(r(r(i(h[0],h[0]),i(h[1],h[1])),i(h[2],h[2])));var d=s(r(r(i(f,f),i(p,p)),i(m,m)));return a(h,d)}function v(e,t){for(var a=e.length,o=0,u=0,c=0;c<a;c++)u=n(e[c],t[c]),o=r(i(u,u),o);return s(o)}})),Th=Me("intersect",["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],(e=>{var{typed:t,config:r,abs:n,add:i,addScalar:a,matrix:o,multiply:s,multiplyScalar:u,divideScalar:c,subtract:l,smaller:f,equalScalar:p,flatten:m,isZero:h,isNumeric:d}=e;return t("intersect",{"Array, Array, Array":g,"Array, Array, Array, Array":v,"Matrix, Matrix, Matrix":function(e,t,r){var n=g(e.valueOf(),t.valueOf(),r.valueOf());return null===n?null:o(n)},"Matrix, Matrix, Matrix, Matrix":function(e,t,r,n){var i=v(e.valueOf(),t.valueOf(),r.valueOf(),n.valueOf());return null===i?null:o(i)}});function g(e,t,r){if(e=y(e),t=y(t),r=y(r),!b(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!b(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!function(e){return 4===e.length&&d(e[0])&&d(e[1])&&d(e[2])&&d(e[3])}(r))throw new TypeError("Array with 4 numbers expected as third argument");return function(e,t,r,n,i,o,s,f,p,m){var h=u(e,s),d=u(n,s),g=u(t,f),v=u(i,f),y=u(r,p),x=u(o,p),b=l(l(l(m,h),g),y),w=l(l(l(a(a(d,v),x),h),g),y),D=c(b,w);return[a(e,u(D,l(n,e))),a(t,u(D,l(i,t))),a(r,u(D,l(o,r)))]}(e[0],e[1],e[2],t[0],t[1],t[2],r[0],r[1],r[2],r[3])}function v(e,t,o,m){if(e=y(e),t=y(t),o=y(o),m=y(m),2===e.length){if(!x(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!x(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!x(o))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!x(m))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return function(e,t,o,p){var m=e,d=o,g=l(m,t),v=l(d,p),y=l(u(g[0],v[1]),u(v[0],g[1]));if(h(y))return null;if(f(n(y),r.relTol))return null;var x=u(v[0],m[1]),b=u(v[1],m[0]),w=u(v[0],d[1]),D=u(v[1],d[0]),N=c(a(l(l(x,b),w),D),y);return i(s(g,N),m)}(e,t,o,m)}if(3===e.length){if(!b(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!b(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!b(o))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!b(m))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return function(e,t,r,n,i,o,s,f,m,d,g,v){var y=w(e,s,d,s,t,f,g,f,r,m,v,m),x=w(d,s,n,e,g,f,i,t,v,m,o,r),b=w(e,s,n,e,t,f,i,t,r,m,o,r),D=w(d,s,d,s,g,f,g,f,v,m,v,m),N=w(n,e,n,e,i,t,i,t,o,r,o,r),E=l(u(y,x),u(b,D)),A=l(u(N,D),u(x,x));if(h(A))return null;var S=c(E,A),C=c(a(y,u(S,x)),D),M=a(e,u(S,l(n,e))),F=a(t,u(S,l(i,t))),T=a(r,u(S,l(o,r))),_=a(s,u(C,l(d,s))),B=a(f,u(C,l(g,f))),O=a(m,u(C,l(v,m)));return p(M,_)&&p(F,B)&&p(T,O)?[M,F,T]:null}(e[0],e[1],e[2],t[0],t[1],t[2],o[0],o[1],o[2],m[0],m[1],m[2])}throw new TypeError("Arrays with two or thee dimensional points expected")}function y(e){return 1===e.length?e[0]:e.length>1&&Array.isArray(e[0])&&e.every((e=>Array.isArray(e)&&1===e.length))?m(e):e}function x(e){return 2===e.length&&d(e[0])&&d(e[1])}function b(e){return 3===e.length&&d(e[0])&&d(e[1])&&d(e[2])}function w(e,t,r,n,i,o,s,c,f,p,m,h){var d=u(l(e,t),l(r,n)),g=u(l(i,o),l(s,c)),v=u(l(f,p),l(m,h));return a(a(d,g),v)}})),_h=Me("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:r,add:n,numeric:i}=e;return t("sum",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){try{return vi(e,t,n)}catch(e){throw rc(e,"sum")}},"...":function(e){if(hi(e))throw new TypeError("Scalar values expected in function sum");return a(e)}});function a(e){var t;return di(e,(function(e){try{t=void 0===t?e:n(t,e)}catch(t){throw rc(t,"sum",e)}})),void 0===t&&(t=i(0,r.number)),"string"==typeof t&&(t=i(t,Re(t,r))),t}})),Bh="cumsum",Oh=Me(Bh,["typed","add","unaryPlus"],(e=>{var{typed:t,add:r,unaryPlus:n}=e;return t(Bh,{Array:i,Matrix:function(e){return e.create(i(e.valueOf(),e.datatype()))},"Array, number | BigNumber":o,"Matrix, number | BigNumber":function(e,t){return e.create(o(e.valueOf(),t),e.datatype())},"...":function(e){if(hi(e))throw new TypeError("All values expected to be scalar in function cumsum");return i(e)}});function i(e){try{return a(e)}catch(e){throw rc(e,Bh)}}function a(e){if(0===e.length)return[];for(var t=[n(e[0])],i=1;i<e.length;++i)t.push(r(t[i-1],e[i]));return t}function o(e,t){var r=Bn(e);if(t<0||t>=r.length)throw new v(t,r.length);try{return s(e,t)}catch(e){throw rc(e,Bh)}}function s(e,t){var r,n,i;if(t<=0){var o=e[0][0];if(Array.isArray(o)){for(i=mi(e),n=[],r=0;r<i.length;r++)n[r]=s(i[r],t-1);return n}return a(e)}for(n=[],r=0;r<e.length;r++)n[r]=s(e[r],t-1);return n}})),kh="mean",zh=Me(kh,["typed","add","divide"],(e=>{var{typed:t,add:r,divide:n}=e;return t(kh,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,t){try{var i=vi(e,t,r),a=Array.isArray(e)?Bn(e):e.size();return n(i,a[t])}catch(e){throw rc(e,"mean")}},"...":function(e){if(hi(e))throw new TypeError("Scalar values expected in function mean");return i(e)}});function i(e){var t,i=0;if(di(e,(function(e){try{t=void 0===t?e:r(t,e),i++}catch(t){throw rc(t,"mean",e)}})),0===i)throw new Error("Cannot calculate the mean of an empty array");return n(t,i)}})),Ih="median",qh=Me(Ih,["typed","add","divide","compare","partitionSelect"],(e=>{var{typed:t,add:r,divide:n,compare:i,partitionSelect:a}=e;function o(e){try{var t=(e=Vn(e.valueOf())).length;if(0===t)throw new Error("Cannot calculate median of an empty array");if(t%2==0){for(var r=t/2-1,n=a(e,r+1),o=e[r],c=0;c<r;++c)i(e[c],o)>0&&(o=e[c]);return u(o,n)}var l=a(e,(t-1)/2);return s(l)}catch(e){throw rc(e,"median")}}var s=t({"number | BigNumber | Complex | Unit":function(e){return e}}),u=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,t){return n(r(e,t),2)}});return t(Ih,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("median(A, dim) is not yet supported")},"...":function(e){if(hi(e))throw new TypeError("Scalar values expected in function median");return o(e)}})})),Rh=Me("mad",["typed","abs","map","median","subtract"],(e=>{var{typed:t,abs:r,map:n,median:i,subtract:a}=e;return t("mad",{"Array | Matrix":o,"...":function(e){return o(e)}});function o(e){if(0===(e=Vn(e.valueOf())).length)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var t=i(e);return i(n(e,(function(e){return r(a(e,t))})))}catch(e){throw e instanceof TypeError&&e.message.includes("median")?new TypeError(e.message.replace("median","mad")):rc(e,"mad")}}})),Ph="unbiased",jh="variance",Uh=Me(jh,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:r,subtract:n,multiply:i,divide:a,apply:o,isNaN:s}=e;return t(jh,{"Array | Matrix":function(e){return u(e,Ph)},"Array | Matrix, string":u,"Array | Matrix, number | BigNumber":function(e,t){return c(e,t,Ph)},"Array | Matrix, number | BigNumber, string":c,"...":function(e){return u(e,Ph)}});function u(e,t){var o,u=0;if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(di(e,(function(e){try{o=void 0===o?e:r(o,e),u++}catch(t){throw rc(t,"variance",e)}})),0===u)throw new Error("Cannot calculate variance of an empty array");var c=a(o,u);if(o=void 0,di(e,(function(e){var t=n(e,c);o=void 0===o?i(t,t):r(o,i(t,t))})),s(o))return o;switch(t){case"uncorrected":return a(o,u);case"biased":return a(o,u+1);case"unbiased":var l=T(o)?o.mul(0):0;return 1===u?l:a(o,u-1);default:throw new Error('Unknown normalization "'+t+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function c(e,t,r){try{if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return o(e,t,(e=>u(e,r)))}catch(e){throw rc(e,"variance")}}})),Lh="quantileSeq",Hh=Me(Lh,["typed","?bignumber","add","subtract","divide","multiply","partitionSelect","compare","isInteger","smaller","smallerEq","larger"],(e=>{var{typed:t,bignumber:r,add:n,subtract:i,divide:a,multiply:o,partitionSelect:s,compare:u,isInteger:c,smaller:l,smallerEq:f,larger:p}=e,m=qa({typed:t,isInteger:c});return t(Lh,{"Array | Matrix, number | BigNumber":(e,t)=>d(e,t,!1),"Array | Matrix, number | BigNumber, number":(e,t,r)=>h(e,t,!1,r,d),"Array | Matrix, number | BigNumber, boolean":d,"Array | Matrix, number | BigNumber, boolean, number":(e,t,r,n)=>h(e,t,r,n,d),"Array | Matrix, Array | Matrix":(e,t)=>g(e,t,!1),"Array | Matrix, Array | Matrix, number":(e,t,r)=>h(e,t,!1,r,g),"Array | Matrix, Array | Matrix, boolean":g,"Array | Matrix, Array | Matrix, boolean, number":(e,t,r,n)=>h(e,t,r,n,g)});function h(e,t,r,n,i){return m(e,n,(e=>i(e,t,r)))}function d(e,t,i){var o,s=e.valueOf();if(l(t,0))throw new Error("N/prob must be non-negative");if(f(t,1))return F(t)?v(s,t,i):r(v(s,t,i));if(p(t,1)){if(!c(t))throw new Error("N must be a positive integer");if(p(t,4294967295))throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var u=n(t,1);o=[];for(var m=0;l(m,t);m++){var h=a(m+1,u);o.push(v(s,h,i))}return F(t)?o:r(o)}}function g(e,t,r){for(var n=e.valueOf(),i=t.valueOf(),a=[],o=0;o<i.length;++o)a.push(v(n,i[o],r));return a}function v(e,t,r){var a=Vn(e),l=a.length;if(0===l)throw new Error("Cannot calculate quantile of an empty sequence");var f,p,m=F(t)?t*(l-1):t.times(l-1),h=F(t)?Math.floor(m):m.floor().toNumber(),d=F(t)?m%1:m.minus(h);if(c(m))return r?a[m]:s(a,F(t)?m:m.valueOf());if(r)f=a[h],p=a[h+1];else{p=s(a,h+1),f=a[h];for(var g=0;g<h;++g)u(a[g],f)>0&&(f=a[g])}return n(o(f,i(1,d)),o(p,d))}})),$h=Me("std",["typed","map","sqrt","variance"],(e=>{var{typed:t,map:r,sqrt:n,variance:i}=e;return t("std",{"Array | Matrix":a,"Array | Matrix, string":a,"Array | Matrix, number | BigNumber":a,"Array | Matrix, number | BigNumber, string":a,"...":function(e){return a(e)}});function a(e,t){if(0===e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{var a=i.apply(null,arguments);return R(a)?r(a,n):n(a)}catch(e){throw e instanceof TypeError&&e.message.includes(" variance")?new TypeError(e.message.replace(" variance"," std")):e}}})),Gh="corr",Wh=Me(Gh,["typed","matrix","mean","sqrt","sum","add","subtract","multiply","pow","divide"],(e=>{var{typed:t,matrix:r,sqrt:n,sum:i,add:a,subtract:o,multiply:s,pow:u,divide:c}=e;return t(Gh,{"Array, Array":function(e,t){return l(e,t)},"Matrix, Matrix":function(e,t){var n=l(e.toArray(),t.toArray());return Array.isArray(n)?r(n):n}});function l(e,t){var r=[];if(Array.isArray(e[0])&&Array.isArray(t[0])){if(e.length!==t.length)throw new SyntaxError("Dimension mismatch. Array A and B must have the same length.");for(var n=0;n<e.length;n++){if(e[n].length!==t[n].length)throw new SyntaxError("Dimension mismatch. Array A and B must have the same number of elements.");r.push(f(e[n],t[n]))}return r}if(e.length!==t.length)throw new SyntaxError("Dimension mismatch. Array A and B must have the same number of elements.");return f(e,t)}function f(e,t){var r=e.length,l=i(e),f=i(t),p=e.reduce(((e,r,n)=>a(e,s(r,t[n]))),0),m=i(e.map((e=>u(e,2)))),h=i(t.map((e=>u(e,2)))),d=o(s(r,p),s(l,f)),g=n(s(o(s(r,m),u(l,2)),o(s(r,h),u(f,2))));return c(d,g)}}));function Vh(e,t){if(t<e)return 1;if(t===e)return t;var r=t+e>>1;return Vh(e,r)*Vh(r+1,t)}function Zh(e,t){if(!qe(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!qe(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(t>e)throw new TypeError("k must be less than or equal to n");for(var r=e-t,n=1,i=2,a=t<r?t:r,o=t<r?r+1:t+1;o<=e;++o)for(n*=o;i<=a&&n%i==0;)n/=i,++i;return i<=a&&(n/=Vh(i,a)),n}Zh.signature="number, number";var Yh="combinations",Jh=Me(Yh,["typed"],(e=>{var{typed:t}=e;return t(Yh,{"number, number":Zh,"BigNumber, BigNumber":function(e,t){var r,n,i=e.constructor,a=e.minus(t),o=new i(1);if(!Xh(e)||!Xh(t))throw new TypeError("Positive integer value expected in function combinations");if(t.gt(e))throw new TypeError("k must be less than n in function combinations");if(r=o,t.lt(a))for(n=o;n.lte(a);n=n.plus(o))r=r.times(t.plus(n)).dividedBy(n);else for(n=o;n.lte(t);n=n.plus(o))r=r.times(a.plus(n)).dividedBy(n);return r}})}));function Xh(e){return e.isInteger()&&e.gte(0)}var Qh="combinationsWithRep",Kh=Me(Qh,["typed"],(e=>{var{typed:t}=e;return t(Qh,{"number, number":function(e,t){if(!qe(e)||e<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!qe(t)||t<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e<1)throw new TypeError("k must be less than or equal to n + k - 1");return t<e-1?Vh(e,e+t-1)/Vh(1,t):Vh(t+1,e+t-1)/Vh(1,e-1)},"BigNumber, BigNumber":function(e,t){var r,n,i=new(0,e.constructor)(1),a=e.minus(i);if(!ed(e)||!ed(t))throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e.lt(i))throw new TypeError("k must be less than or equal to n + k - 1 in function combinationsWithRep");if(r=i,t.lt(a))for(n=i;n.lte(a);n=n.plus(i))r=r.times(t.plus(n)).dividedBy(n);else for(n=i;n.lte(t);n=n.plus(i))r=r.times(a.plus(n)).dividedBy(n);return r}})}));function ed(e){return e.isInteger()&&e.gte(0)}function td(e){var t;if(qe(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:Vh(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*td(1-e));if(e>=171.35)return 1/0;if(e>85){var r=e*e,n=r*e,i=n*e,a=i*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*r)-139/(51840*n)-571/(2488320*i)+163879/(209018880*a)+5246819/(75246796800*a*e))}--e,t=nd[0];for(var o=1;o<nd.length;++o)t+=nd[o]/(e+o);var s=e+rd+.5;return Math.sqrt(2*Math.PI)*Math.pow(s,e+.5)*Math.exp(-s)*t}td.signature="number";var rd=4.7421875,nd=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],id=.9189385332046728,ad=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function od(e){if(e<0)return NaN;if(0===e)return 1/0;if(!isFinite(e))return e;if(e<.5)return Math.log(Math.PI/Math.sin(Math.PI*e))-od(1-e);for(var t=5+(e-=1)+.5,r=ad[0],n=6;n>=1;n--)r+=ad[n]/(e+n);return id+(e+.5)*Math.log(t)-t+Math.log(r)}od.signature="number";var sd="gamma",ud=Me(sd,["typed","config","multiplyScalar","pow","BigNumber","Complex"],(e=>{var{typed:t,config:r,multiplyScalar:n,pow:i,BigNumber:a,Complex:o}=e;return t(sd,{number:td,Complex:function e(t){if(0===t.im)return td(t.re);if(t.re<.5){var r=new o(1-t.re,-t.im),n=new o(Math.PI*t.re,Math.PI*t.im);return new o(Math.PI).div(n.sin()).div(e(r))}t=new o(t.re-1,t.im);for(var i=new o(nd[0],0),a=1;a<nd.length;++a){var s=new o(nd[a],0);i=i.add(s.div(t.add(a)))}var u=new o(t.re+rd+.5,t.im),c=Math.sqrt(2*Math.PI),l=u.pow(t.add(.5)),f=u.neg().exp();return i.mul(c).mul(l).mul(f)},BigNumber:function(e){if(e.isInteger())return e.isNegative()||e.isZero()?new a(1/0):s(e.minus(1));if(!e.isFinite())return new a(e.isNegative()?NaN:1/0);throw new Error("Integer BigNumber expected")}});function s(e){if(e<8)return new a([1,1,2,6,24,120,720,5040][e]);var t=r.precision+(0|Math.log(e.toNumber())),n=a.clone({precision:t});if(e%2==1)return e.times(s(new a(e-1)));for(var i=e,o=new n(e),u=e.toNumber();i>2;)u+=i-=2,o=o.times(u);return new a(o.toPrecision(a.precision))}})),cd="lgamma",ld=Me(cd,["Complex","typed"],(e=>{var{Complex:t,typed:r}=e,n=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return r(cd,{number:od,Complex:function e(r){if(r.isNaN())return new t(NaN,NaN);if(0===r.im)return new t(od(r.re),0);if(r.re>=7||Math.abs(r.im)>=7)return i(r);if(r.re<=.1){var n=(u=6.283185307179586,(!0^((c=r.im)>0||!(c<0)&&1/c==1/0)?-u:u)*Math.floor(.5*r.re+.25)),o=r.mul(Math.PI).sin().log(),s=e(new t(1-r.re,-r.im));return new t(1.1447298858494002,n).sub(o).sub(s)}return r.im>=0?a(r):a(r.conjugate()).conjugate();var u,c},BigNumber:function(){throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function i(e){for(var r=e.sub(.5).mul(e.log()).sub(e).add(id),i=new t(1,0).div(e),a=i.div(e),o=n[0],s=n[1],u=2*a.re,c=a.re*a.re+a.im*a.im,l=2;l<8;l++){var f=s;s=-c*o+n[l],o=u*o+f}var p=i.mul(a.mul(o).add(s));return r.add(p)}function a(e){var r=0,n=0,a=e;for(e=e.add(1);e.re<=7;){var o=(a=a.mul(e)).im<0?1:0;0!==o&&0===n&&r++,n=o,e=e.add(1)}return i(e).sub(a.log()).sub(new t(0,2*r*Math.PI*1))}})),fd="factorial",pd=Me(fd,["typed","gamma"],(e=>{var{typed:t,gamma:r}=e;return t(fd,{number:function(e){if(e<0)throw new Error("Value must be non-negative");return r(e+1)},BigNumber:function(e){if(e.isNegative())throw new Error("Value must be non-negative");return r(e.plus(1))},"Array | Matrix":t.referToSelf((e=>t=>gi(t,e)))})})),md="kldivergence",hd=Me(md,["typed","matrix","divide","sum","multiply","map","dotDivide","log","isNumeric"],(e=>{var{typed:t,matrix:r,divide:n,sum:i,multiply:a,map:o,dotDivide:s,log:u,isNumeric:c}=e;return t(md,{"Array, Array":function(e,t){return l(r(e),r(t))},"Matrix, Array":function(e,t){return l(e,r(t))},"Array, Matrix":function(e,t){return l(r(e),t)},"Matrix, Matrix":function(e,t){return l(e,t)}});function l(e,t){var r=t.size().length,l=e.size().length;if(r>1)throw new Error("first object must be one dimensional");if(l>1)throw new Error("second object must be one dimensional");if(r!==l)throw new Error("Length of two vectors must be equal");if(0===i(e))throw new Error("Sum of elements in first object must be non zero");if(0===i(t))throw new Error("Sum of elements in second object must be non zero");var f=n(e,i(e)),p=n(t,i(t)),m=i(a(f,o(s(f,p),(e=>u(e)))));return c(m)?m:Number.NaN}})),dd="multinomial",gd=Me(dd,["typed","add","divide","multiply","factorial","isInteger","isPositive"],(e=>{var{typed:t,add:r,divide:n,multiply:i,factorial:a,isInteger:o,isPositive:s}=e;return t(dd,{"Array | Matrix":function(e){var t=0,u=1;return di(e,(function(e){if(!o(e)||!s(e))throw new TypeError("Positive integer value expected in function multinomial");t=r(t,e),u=i(u,a(e))})),n(a(t),u)}})})),vd="permutations",yd=Me(vd,["typed","factorial"],(e=>{var{typed:t,factorial:r}=e;return t(vd,{"number | BigNumber":r,"number, number":function(e,t){if(!qe(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!qe(t)||t<0)throw new TypeError("Positive integer value expected in function permutations");if(t>e)throw new TypeError("second argument k must be less than or equal to first argument n");return Vh(e-t+1,e)},"BigNumber, BigNumber":function(e,t){var r,n;if(!xd(e)||!xd(t))throw new TypeError("Positive integer value expected in function permutations");if(t.gt(e))throw new TypeError("second argument k must be less than or equal to first argument n");for(r=e.mul(0).add(1),n=e.minus(t).plus(1);n.lte(e);n=n.plus(1))r=r.times(n);return r}})}));function xd(e){return e.isInteger()&&e.gte(0)}var bd=r(6377),wd=bd(Date.now());function Dd(e){var t,r;return t=null===(r=e)?wd:bd(String(r)),function(){return t()}}var Nd="pickRandom",Ed=Me(Nd,["typed","config","?on"],(e=>{var{typed:t,config:r,on:n}=e,i=Dd(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(i=Dd(e.randomSeed))})),t(Nd,{"Array | Matrix":function(e){return a(e,{})},"Array | Matrix, Object":function(e,t){return a(e,t)},"Array | Matrix, number":function(e,t){return a(e,{number:t})},"Array | Matrix, Array | Matrix":function(e,t){return a(e,{weights:t})},"Array | Matrix, Array | Matrix, number":function(e,t,r){return a(e,{number:r,weights:t})},"Array | Matrix, number, Array | Matrix":function(e,t,r){return a(e,{number:t,weights:r})}});function a(e,t){var{number:r,weights:n,elementWise:a=!0}=t,o=void 0===r;o&&(r=1);var s=q(e)?e.create:q(n)?n.create:null;e=e.valueOf(),n&&(n=n.valueOf()),!0===a&&(e=Vn(e),n=Vn(n));var u=0;if(void 0!==n){if(n.length!==e.length)throw new Error("Weights must have the same length as possibles");for(var c=0,l=n.length;c<l;c++){if(!F(n[c])||n[c]<0)throw new Error("Weights must be an array of positive numbers");u+=n[c]}}for(var f,p=e.length,m=[];m.length<r;){if(void 0===n)f=e[Math.floor(i()*p)];else for(var h=i()*u,d=0,g=e.length;d<g;d++)if((h-=n[d])<0){f=e[d];break}m.push(f)}return o?m[0]:s?s(m):m}}));function Ad(e,t){var r=[];if((e=e.slice(0)).length>1)for(var n=0,i=e.shift();n<i;n++)r.push(Ad(e,t));else for(var a=0,o=e.shift();a<o;a++)r.push(t());return r}var Sd="random",Cd=Me(Sd,["typed","config","?on"],(e=>{var{typed:t,config:r,on:n}=e,i=Dd(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(i=Dd(e.randomSeed))})),t(Sd,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,t)=>o(e,t),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,t)=>a(e,0,t),"Array | Matrix, number, number":(e,t,r)=>a(e,t,r)});function a(e,t,r){var n=Ad(e.valueOf(),(()=>o(t,r)));return q(e)?e.create(n,"number"):n}function o(e,t){return e+i()*(t-e)}})),Md="randomInt",Fd=Me(Md,["typed","config","?on"],(e=>{var{typed:t,config:r,on:n}=e,i=Dd(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(i=Dd(e.randomSeed))})),t(Md,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,t)=>o(e,t),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,t)=>a(e,0,t),"Array | Matrix, number, number":(e,t,r)=>a(e,t,r)});function a(e,t,r){var n=Ad(e.valueOf(),(()=>o(t,r)));return q(e)?e.create(n,"number"):n}function o(e,t){return Math.floor(e+i()*(t-e))}})),Td="stirlingS2",_d=Me(Td,["typed","addScalar","subtractScalar","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],(e=>{var{typed:t,addScalar:r,subtractScalar:n,multiplyScalar:i,divideScalar:a,pow:o,factorial:s,combinations:u,isNegative:c,isInteger:l,number:f,bignumber:p,larger:m}=e,h=[],d=[];return t(Td,{"number | BigNumber, number | BigNumber":function(e,t){if(!l(e)||c(e)||!l(t)||c(t))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(m(t,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");var n=!(F(e)&&F(t)),a=n?d:h,o=n?p:f,s=f(e),u=f(t);if(a[s]&&a[s].length>u)return a[s][u];for(var g=0;g<=s;++g)if(a[g]||(a[g]=[o(0===g?1:0)]),0!==g)for(var v=a[g],y=a[g-1],x=v.length;x<=g&&x<=u;++x)v[x]=x===g?1:r(i(o(x),y[x]),y[x-1]);return a[s][u]}})})),Bd="bellNumbers",Od=Me(Bd,["typed","addScalar","isNegative","isInteger","stirlingS2"],(e=>{var{typed:t,addScalar:r,isNegative:n,isInteger:i,stirlingS2:a}=e;return t(Bd,{"number | BigNumber":function(e){if(!i(e)||n(e))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var t=0,o=0;o<=e;o++)t=r(t,a(e,o));return t}})})),kd="catalan",zd=Me(kd,["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],(e=>{var{typed:t,addScalar:r,divideScalar:n,multiplyScalar:i,combinations:a,isNegative:o,isInteger:s}=e;return t(kd,{"number | BigNumber":function(e){if(!s(e)||o(e))throw new TypeError("Non-negative integer value expected in function catalan");return n(a(i(e,2),e),r(e,1))}})})),Id="composition",qd=Me(Id,["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],(e=>{var{typed:t,addScalar:r,combinations:n,isPositive:i,isNegative:a,isInteger:o,larger:s}=e;return t(Id,{"number | BigNumber, number | BigNumber":function(e,t){if(!(o(e)&&i(e)&&o(t)&&i(t)))throw new TypeError("Positive integer value expected in function composition");if(s(t,e))throw new TypeError("k must be less than or equal to n in function composition");return n(r(e,-1),r(t,-1))}})})),Rd="leafCount",Pd=Me(Rd,["parse","typed"],(e=>{var{parse:t,typed:r}=e;function n(e){var t=0;return e.forEach((e=>{t+=n(e)})),t||1}return r(Rd,{Node:function(e){return n(e)}})}));function jd(e){return oe(e)||me(e)&&e.isUnary()&&oe(e.args[0])}function Ud(e){return!!oe(e)||!(!ce(e)&&!me(e)||!e.args.every(Ud))||!(!he(e)||!Ud(e.content))}function Ld(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Hd(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ld(Object(r),!0).forEach((function(t){Hu(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ld(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var $d=Me("simplifyUtil",["FunctionNode","OperatorNode","SymbolNode"],(e=>{var{FunctionNode:t,OperatorNode:r,SymbolNode:n}=e,i=!0,a=!1,o="defaultF",s={add:{trivial:i,total:i,commutative:i,associative:i},unaryPlus:{trivial:i,total:i,commutative:i,associative:i},subtract:{trivial:a,total:i,commutative:a,associative:a},multiply:{trivial:i,total:i,commutative:i,associative:i},divide:{trivial:a,total:i,commutative:a,associative:a},paren:{trivial:i,total:i,commutative:i,associative:a},defaultF:{trivial:a,total:i,commutative:a,associative:a}};function u(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:s,n=o;if("string"==typeof e?n=e:me(e)?n=e.fn.toString():ce(e)?n=e.name:he(e)&&(n="paren"),Ce(r,n)){var i=r[n];if(Ce(i,t))return i[t];if(Ce(s,n))return s[n][t]}if(Ce(r,o)){var a=r[o];return Ce(a,t)?a[t]:s[o][t]}if(Ce(s,n)){var u=s[n];if(Ce(u,t))return u[t]}return s[o][t]}function c(e){return u(e,"associative",arguments.length>1&&void 0!==arguments[1]?arguments[1]:s)}function l(e,t){var r,n=[],i=function(e){for(var t=0;t<e.args.length;t++){var a=e.args[t];me(a)&&r===a.op?i(a):n.push(a)}};return c(e,t)?(r=e.op,i(e),n):e.args}function f(e){return me(e)?function(t){try{return new r(e.op,e.fn,t,e.implicit)}catch(e){return console.error(e),[]}}:function(r){return new t(new n(e.name),r)}}return{createMakeNodeFunction:f,hasProperty:u,isCommutative:function(e){return u(e,"commutative",arguments.length>1&&void 0!==arguments[1]?arguments[1]:s)},isAssociative:c,mergeContext:function(e,t){var r=Hd({},e);for(var n in t)Ce(e,n)?r[n]=Hd(Hd({},t[n]),e[n]):r[n]=t[n];return r},flatten:function e(t,r){if(!t.args||0===t.args.length)return t;t.args=l(t,r);for(var n=0;n<t.args.length;n++)e(t.args[n],r)},allChildren:l,unflattenr:function e(t,r){if(t.args&&0!==t.args.length){for(var n=f(t),i=t.args.length,a=0;a<i;a++)e(t.args[a],r);if(i>2&&c(t,r)){for(var o=t.args.pop();t.args.length>0;)o=n([t.args.pop(),o]);t.args=o.args}}},unflattenl:function e(t,r){if(t.args&&0!==t.args.length){for(var n=f(t),i=t.args.length,a=0;a<i;a++)e(t.args[a],r);if(i>2&&c(t,r)){for(var o=t.args.shift();t.args.length>0;)o=n([o,t.args.shift()]);t.args=o.args}}},defaultContext:s,realContext:{divide:{total:a},log:{total:a}},positiveContext:{subtract:{total:a},abs:{trivial:i},log:{total:i}}}})),Gd=Me("simplify",["typed","parse","equal","resolve","simplifyConstant","simplifyCore","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:t,parse:r,equal:n,resolve:i,simplifyConstant:a,simplifyCore:o,AccessorNode:s,ArrayNode:u,ConstantNode:c,FunctionNode:l,IndexNode:f,ObjectNode:p,OperatorNode:m,ParenthesisNode:h,SymbolNode:d}=e,{hasProperty:g,isCommutative:v,isAssociative:y,mergeContext:x,flatten:b,unflattenr:w,unflattenl:D,createMakeNodeFunction:N,defaultContext:E,realContext:A,positiveContext:S}=$d({FunctionNode:l,OperatorNode:m,SymbolNode:d});t.addConversion({from:"Object",to:"Map",convert:M});var F=t("simplify",{Node:z,"Node, Map":(e,t)=>z(e,!1,t),"Node, Map, Object":(e,t,r)=>z(e,!1,t,r),"Node, Array":z,"Node, Array, Map":z,"Node, Array, Map, Object":z});function T(e){return e.transform((function(e){return he(e)?T(e.content):e}))}t.removeConversion({from:"Object",to:"Map",convert:M}),F.defaultContext=E,F.realContext=A,F.positiveContext=S;var _={true:!0,false:!0,e:!0,i:!0,Infinity:!0,LN2:!0,LN10:!0,LOG2E:!0,LOG10E:!0,NaN:!0,phi:!0,pi:!0,SQRT1_2:!0,SQRT2:!0,tau:!0};function B(e,t){var n={};if(e.s){var i=e.s.split("->");if(2!==i.length)throw SyntaxError("Could not parse rule: "+e.s);n.l=i[0],n.r=i[1]}else n.l=e.l,n.r=e.r;for(var a of(n.l=T(r(n.l)),n.r=T(r(n.r)),["imposeContext","repeat","assuming"]))a in e&&(n[a]=e[a]);if(e.evaluate&&(n.evaluate=r(e.evaluate)),y(n.l,t)){var o,s=!v(n.l,t);s&&(o=k());var u=N(n.l),c=k();n.expanded={},n.expanded.l=u([n.l,c]),b(n.expanded.l,t),w(n.expanded.l,t),n.expanded.r=u([n.r,c]),s&&(n.expandedNC1={},n.expandedNC1.l=u([o,n.l]),n.expandedNC1.r=u([o,n.r]),n.expandedNC2={},n.expandedNC2.l=u([o,n.expanded.l]),n.expandedNC2.r=u([o,n.expanded.r]))}return n}F.rules=[o,{l:"log(e)",r:"1"},{s:"n-n1 -> n+-n1",assuming:{subtract:{total:!0}}},{s:"n-n -> 0",assuming:{subtract:{total:!1}}},{s:"-(cl*v) -> v * (-cl)",assuming:{multiply:{commutative:!0},subtract:{total:!0}}},{s:"-(cl*v) -> (-cl) * v",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{s:"-(v*cl) -> v * (-cl)",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{l:"-(n1/n2)",r:"-n1/n2"},{l:"-v",r:"v * (-1)"},{l:"(n1 + n2)*(-1)",r:"n1*(-1) + n2*(-1)",repeat:!0},{l:"n/n1^n2",r:"n*n1^-n2"},{l:"n/n1",r:"n*n1^-1"},{s:"(n1*n2)^n3 -> n1^n3 * n2^n3",assuming:{multiply:{commutative:!0}}},{s:"(n1*n2)^(-1) -> n2^(-1) * n1^(-1)",assuming:{multiply:{commutative:!1}}},{s:"(n ^ n1) ^ n2 -> n ^ (n1 * n2)",assuming:{divide:{total:!0}}},{l:" vd * ( vd * n1 + n2)",r:"vd^2 * n1 + vd * n2"},{s:" vd * (vd^n4 * n1 + n2) -> vd^(1+n4) * n1 + vd * n2",assuming:{divide:{total:!0}}},{s:"vd^n3 * ( vd * n1 + n2) -> vd^(n3+1) * n1 + vd^n3 * n2",assuming:{divide:{total:!0}}},{s:"vd^n3 * (vd^n4 * n1 + n2) -> vd^(n3+n4) * n1 + vd^n3 * n2",assuming:{divide:{total:!0}}},{l:"n*n",r:"n^2"},{s:"n * n^n1 -> n^(n1+1)",assuming:{divide:{total:!0}}},{s:"n^n1 * n^n2 -> n^(n1+n2)",assuming:{divide:{total:!0}}},a,{s:"n+n -> 2*n",assuming:{add:{total:!0}}},{l:"n+-n",r:"0"},{l:"vd*n + vd",r:"vd*(n+1)"},{l:"n3*n1 + n3*n2",r:"n3*(n1+n2)"},{l:"n3^(-n4)*n1 + n3 * n2",r:"n3^(-n4)*(n1 + n3^(n4+1) *n2)"},{l:"n3^(-n4)*n1 + n3^n5 * n2",r:"n3^(-n4)*(n1 + n3^(n4+n5)*n2)"},{s:"n*vd + vd -> (n+1)*vd",assuming:{multiply:{commutative:!1}}},{s:"vd + n*vd -> (1+n)*vd",assuming:{multiply:{commutative:!1}}},{s:"n1*n3 + n2*n3 -> (n1+n2)*n3",assuming:{multiply:{commutative:!1}}},{s:"n^n1 * n -> n^(n1+1)",assuming:{divide:{total:!0},multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3 -> (n1 + n2*n3^(n4 + 1))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3^n5 -> (n1 + n2*n3^(n4 + n5))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{l:"n*cd + cd",r:"(n+1)*cd"},{s:"cd*n + cd -> cd*(n+1)",assuming:{multiply:{commutative:!1}}},{s:"cd + cd*n -> cd*(1+n)",assuming:{multiply:{commutative:!1}}},a,{s:"(-n)*n1 -> -(n*n1)",assuming:{subtract:{total:!0}}},{s:"n1*(-n) -> -(n1*n)",assuming:{subtract:{total:!0},multiply:{commutative:!1}}},{s:"ce+ve -> ve+ce",assuming:{add:{commutative:!0}},imposeContext:{add:{commutative:!1}}},{s:"vd*cd -> cd*vd",assuming:{multiply:{commutative:!0}},imposeContext:{multiply:{commutative:!1}}},{l:"n+-n1",r:"n-n1"},{l:"n+-(n1)",r:"n-(n1)"},{s:"n*(n1^-1) -> n/n1",assuming:{multiply:{commutative:!0}}},{s:"n*n1^-n2 -> n/n1^n2",assuming:{multiply:{commutative:!0}}},{s:"n^-1 -> 1/n",assuming:{multiply:{commutative:!0}}},{l:"n^1",r:"n"},{s:"n*(n1/n2) -> (n*n1)/n2",assuming:{multiply:{associative:!0}}},{s:"n-(n1+n2) -> n-n1-n2",assuming:{addition:{associative:!0,commutative:!0}}},{l:"1*n",r:"n",imposeContext:{multiply:{commutative:!0}}},{s:"n1/(n2/n3) -> (n1*n3)/n2",assuming:{multiply:{associative:!0}}},{l:"n1/(-n2)",r:"-n1/n2"}];var O=0;function k(){return new d("_p"+O++)}function z(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:C(),n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=n.consoleDebug;t=function(e,t){for(var r=[],n=0;n<e.length;n++){var i=e[n],a=void 0,o=typeof i;switch(o){case"string":i={s:i};case"object":a=B(i,t);break;case"function":a=i;break;default:throw TypeError("Unsupported type of rule: "+o)}r.push(a)}return r}(t||F.rules,n.context);for(var o=i(e,r),s={},u=(o=T(o)).toString({parenthesis:"all"});!s[u];){s[u]=!0,O=0;var c=u;a&&console.log("Working on: ",u);for(var l=0;l<t.length;l++){var f="";if("function"==typeof t[l]?(o=t[l](o,n),a&&(f=t[l].name)):(b(o,n.context),o=q(o,t[l],n.context),a&&(f="".concat(t[l].l.toString()," -> ").concat(t[l].r.toString()))),a){var p=o.toString({parenthesis:"all"});p!==c&&(console.log("Applying",f,"produced",p),c=p)}D(o,n.context)}u=o.toString({parenthesis:"all"})}return o}function I(e,t,r){var n=e;if(e)for(var i=0;i<e.length;++i){var a=q(e[i],t,r);a!==e[i]&&(n===e&&(n=e.slice()),n[i]=a)}return n}function q(e,t,r){if(t.assuming)for(var n in t.assuming)for(var i in t.assuming[n])if(g(n,i,r)!==t.assuming[n][i])return e;var a=x(t.imposeContext,r),o=e;if(o instanceof m||o instanceof l){var c=I(o.args,t,r);c!==o.args&&((o=o.clone()).args=c)}else if(o instanceof h){if(o.content){var d=q(o.content,t,r);d!==o.content&&(o=new h(d))}}else if(o instanceof u){var v=I(o.items,t,r);v!==o.items&&(o=new u(v))}else if(o instanceof s){var y=o.object;o.object&&(y=q(o.object,t,r));var b=o.index;o.index&&(b=q(o.index,t,r)),y===o.object&&b===o.index||(o=new s(y,b))}else if(o instanceof f){var w=I(o.dimensions,t,r);w!==o.dimensions&&(o=new f(w))}else if(o instanceof p){var D=!1,N={};for(var E in o.properties)N[E]=q(o.properties[E],t,r),N[E]!==o.properties[E]&&(D=!0);D&&(o=new p(N))}var A=t.r,S=j(t.l,o,a)[0];if(!S&&t.expanded&&(A=t.expanded.r,S=j(t.expanded.l,o,a)[0]),!S&&t.expandedNC1&&(A=t.expandedNC1.r,(S=j(t.expandedNC1.l,o,a)[0])||(A=t.expandedNC2.r,S=j(t.expandedNC2.l,o,a)[0])),S){var C=o.implicit;o=A.clone(),C&&"implicit"in A&&(o.implicit=!0),o=o.transform((function(e){return e.isSymbolNode&&Ce(S.placeholders,e.name)?S.placeholders[e.name].clone():e}))}return t.repeat&&o!==e&&(o=q(o,t,r)),o}function R(e,t){var r={placeholders:{}};if(!e.placeholders&&!t.placeholders)return r;if(!e.placeholders)return t;if(!t.placeholders)return e;for(var n in e.placeholders)if(Ce(e.placeholders,n)&&(r.placeholders[n]=e.placeholders[n],Ce(t.placeholders,n)&&!U(e.placeholders[n],t.placeholders[n])))return null;for(var i in t.placeholders)Ce(t.placeholders,i)&&(r.placeholders[i]=t.placeholders[i]);return r}function P(e,t){var r,n=[];if(0===e.length||0===t.length)return n;for(var i=0;i<e.length;i++)for(var a=0;a<t.length;a++)(r=R(e[i],t[a]))&&n.push(r);return n}function j(e,t,r,i){var a=[{placeholders:{}}];if(e instanceof m&&t instanceof m||e instanceof l&&t instanceof l){if(e instanceof m){if(e.op!==t.op||e.fn!==t.fn)return[]}else if(e instanceof l&&e.name!==t.name)return[];if(!(1===t.args.length&&1===e.args.length||!y(t,r)&&t.args.length===e.args.length||i)){if(t.args.length>=2&&2===e.args.length){for(var o=function(e,t){var r,n,i=[],a=N(e);if(v(e,t))for(var o=0;o<e.args.length;o++)(n=e.args.slice(0)).splice(o,1),r=1===n.length?n[0]:a(n),i.push(a([e.args[o],r]));else for(var s=1;s<e.args.length;s++){var u=e.args[0];s>1&&(u=a(e.args.slice(0,s))),r=1===(n=e.args.slice(s)).length?n[0]:a(n),i.push(a([u,r]))}return i}(t,r),s=[],u=0;u<o.length;u++){var f=j(e,o[u],r,!0);s=s.concat(f)}return s}if(e.args.length>2)throw Error("Unexpected non-binary associative function: "+e.toString());return[]}for(var p=[],h=0;h<e.args.length;h++){var g=j(e.args[h],t.args[h],r);if(0===g.length)break;p.push(g)}if(p.length!==e.args.length){if(!v(t,r)||1===e.args.length)return[];if(e.args.length>2)throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");var x=j(e.args[0],t.args[1],r);if(0===x.length)return[];var b=j(e.args[1],t.args[0],r);if(0===b.length)return[];p=[x,b]}a=function(e){if(0===e.length)return e;for(var t=e.reduce(P),r=[],n={},i=0;i<t.length;i++){var a=JSON.stringify(t[i]);n[a]||(n[a]=!0,r.push(t[i]))}return r}(p)}else if(e instanceof d){if(0===e.name.length)throw new Error("Symbol in rule has 0 length...!?");if(_[e.name]){if(e.name!==t.name)return[]}else switch(e.name[1]>="a"&&e.name[1]<="z"?e.name.substring(0,2):e.name[0]){case"n":case"_p":a[0].placeholders[e.name]=t;break;case"c":case"cl":if(!oe(t))return[];a[0].placeholders[e.name]=t;break;case"v":if(oe(t))return[];a[0].placeholders[e.name]=t;break;case"vl":if(!ve(t))return[];a[0].placeholders[e.name]=t;break;case"cd":if(!jd(t))return[];a[0].placeholders[e.name]=t;break;case"vd":if(jd(t))return[];a[0].placeholders[e.name]=t;break;case"ce":if(!Ud(t))return[];a[0].placeholders[e.name]=t;break;case"ve":if(Ud(t))return[];a[0].placeholders[e.name]=t;break;default:throw new Error("Invalid symbol in rule: "+e.name)}}else{if(!(e instanceof c))return[];if(!n(e.value,t.value))return[]}return a}function U(e,t){if(e instanceof c&&t instanceof c){if(!n(e.value,t.value))return!1}else if(e instanceof d&&t instanceof d){if(e.name!==t.name)return!1}else{if(!(e instanceof m&&t instanceof m||e instanceof l&&t instanceof l))return!1;if(e instanceof m){if(e.op!==t.op||e.fn!==t.fn)return!1}else if(e instanceof l&&e.name!==t.name)return!1;if(e.args.length!==t.args.length)return!1;for(var r=0;r<e.args.length;r++)if(!U(e.args[r],t.args[r]))return!1}return!0}return F})),Wd=Me("simplifyConstant",["typed","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],(e=>{var{typed:t,config:r,mathWithTransform:n,matrix:i,fraction:a,bignumber:o,AccessorNode:s,ArrayNode:u,ConstantNode:c,FunctionNode:l,IndexNode:f,ObjectNode:p,OperatorNode:m,SymbolNode:h}=e,{isCommutative:d,isAssociative:g,allChildren:v,createMakeNodeFunction:y}=$d({FunctionNode:l,OperatorNode:m,SymbolNode:h}),x=t("simplifyConstant",{Node:e=>N(M(e,{})),"Node, Object":function(e,t){return N(M(e,t))}});function b(e){return O(e)?e.valueOf():e instanceof Array?e.map(b):q(e)?i(b(e.valueOf())):e}function w(e,t,r){try{return n[e].apply(null,t)}catch(i){return t=t.map(b),A(n[e].apply(null,t),r)}}var D=t({Fraction:function(e){var t,r=e.s*e.n;return t=r<0?new m("-","unaryMinus",[new c(-r)]):new c(r),1===e.d?t:new m("/","divide",[t,new c(e.d)])},number:function(e){return e<0?S(new c(-e)):new c(e)},BigNumber:function(e){return e<0?S(new c(-e)):new c(e)},bigint:function(e){return e<0n?S(new c(-e)):new c(e)},Complex:function(e){throw new Error("Cannot convert Complex number to Node")},string:function(e){return new c(e)},Matrix:function(e){return new u(e.valueOf().map((e=>D(e))))}});function N(e){return fe(e)?e:D(e)}function E(e,t){if(t&&!1!==t.exactFractions&&isFinite(e)&&a){var r=a(e),n=t&&"number"==typeof t.fractionsLimit?t.fractionsLimit:1/0;if(r.valueOf()===e&&r.n<n&&r.d<n)return r}return e}var A=t({"string, Object":function(e,t){var n=Re(e,r);return"BigNumber"===n?(void 0===o&&lu(),o(e)):"bigint"===n?BigInt(e):"Fraction"===n?(void 0===a&&fu(),a(e)):E(parseFloat(e),t)},"Fraction, Object":function(e,t){return e},"BigNumber, Object":function(e,t){return e},"number, Object":function(e,t){return E(e,t)},"bigint, Object":function(e,t){return e},"Complex, Object":function(e,t){return 0!==e.im?e:E(e.re,t)},"Matrix, Object":function(e,t){return i(E(e.valueOf()))},"Array, Object":function(e,t){return e.map(E)}});function S(e){return new m("-","unaryMinus",[e])}function C(e,t,r,n){var i=t.shift(),a=t.reduce(((t,i)=>{if(!fe(i)){var a=t.pop();if(fe(a))return[a,i];try{return t.push(w(e,[a,i],n)),t}catch(e){t.push(a)}}t.push(N(t.pop()));var o=1===t.length?t[0]:r(t);return[r([o,N(i)])]}),[i]);return 1===a.length?a[0]:r([a[0],D(a[1])])}function M(e,t){switch(e.type){case"SymbolNode":return e;case"ConstantNode":switch(typeof e.value){case"number":case"bigint":return A(e.value,t);case"string":return e.value;default:if(!isNaN(e.value))return A(e.value,t)}return e;case"FunctionNode":if(n[e.name]&&n[e.name].rawArgs)return e;if(!["add","multiply"].includes(e.name)){var r=e.args.map((e=>M(e,t)));if(!r.some(fe))try{return w(e.name,r,t)}catch(e){}if("size"===e.name&&1===r.length&&re(r[0])){for(var a=[],o=r[0];re(o);)a.push(o.items.length),o=o.items[0];return i(a)}return new l(e.name,r.map(N))}case"OperatorNode":var m,h,b=e.fn.toString(),D=y(e);if(me(e)&&e.isUnary())h=fe((m=[M(e.args[0],t)])[0])?D(m):w(b,m,t);else if(g(e,t.context))if(m=(m=v(e,t.context)).map((e=>M(e,t))),d(b,t.context)){for(var E=[],S=[],F=0;F<m.length;F++)fe(m[F])?S.push(m[F]):E.push(m[F]);E.length>1?(h=C(b,E,D,t),S.unshift(h),h=C(b,S,D,t)):h=C(b,m,D,t)}else h=C(b,m,D,t);else h=C(b,m=e.args.map((e=>M(e,t))),D,t);return h;case"ParenthesisNode":return M(e.content,t);case"AccessorNode":return function(e,t,r){if(!le(t))return new s(N(e),N(t));if(re(e)||q(e)){for(var n=Array.from(t.dimensions);n.length>0;)if(oe(n[0])&&"string"!=typeof n[0].value){var a=A(n.shift().value,r);re(e)?e=e.items[a-1]:(e=e.valueOf()[a-1])instanceof Array&&(e=i(e))}else{if(!(n.length>1&&oe(n[1])&&"string"!=typeof n[1].value))break;var o=A(n[1].value,r),l=[],p=re(e)?e.items:e.valueOf();for(var m of p)if(re(m))l.push(m.items[o-1]);else{if(!q(e))break;l.push(m[o-1])}if(l.length!==p.length)break;e=re(e)?new u(l):i(l),n.splice(1,1)}return n.length===t.dimensions.length?new s(N(e),t):n.length>0?(t=new f(n),new s(N(e),t)):e}if(pe(e)&&1===t.dimensions.length&&oe(t.dimensions[0])){var h=t.dimensions[0].value;return h in e.properties?e.properties[h]:new c}return new s(N(e),t)}(M(e.object,t),M(e.index,t),t);case"ArrayNode":var T=e.items.map((e=>M(e,t)));return T.some(fe)?new u(T.map(N)):i(T);case"IndexNode":return new f(e.dimensions.map((e=>x(e,t))));case"ObjectNode":var _={};for(var B in e.properties)_[B]=x(e.properties[B],t);return new p(_);default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(e.type))}}return x})),Vd="simplifyCore",Zd=Me(Vd,["typed","parse","equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:t,parse:r,equal:n,isZero:i,add:a,subtract:o,multiply:s,divide:u,pow:c,AccessorNode:l,ArrayNode:f,ConstantNode:p,FunctionNode:m,IndexNode:h,ObjectNode:d,OperatorNode:g,ParenthesisNode:v,SymbolNode:y}=e,x=new p(0),b=new p(1),w=new p(!0),D=new p(!1);function N(e){return me(e)&&["and","not","or"].includes(e.op)}var{hasProperty:E,isCommutative:A}=$d({FunctionNode:m,OperatorNode:g,SymbolNode:y});function S(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t?t.context:void 0;if(E(e,"trivial",r)){if(ce(e)&&1===e.args.length)return S(e.args[0],t);var a=!1,o=0;if(e.forEach((e=>{1==++o&&(a=S(e,t))})),1===o)return a}var s=e;if(ce(s)){var u=function(e){var t="OperatorNode:"+e;for(var r of $p)if(t in r)return r[t].op;return null}(s.name);if(!u)return new m(S(s.fn),s.args.map((e=>S(e,t))));if(s.args.length>2&&E(s,"associative",r))for(;s.args.length>2;){var c=s.args.pop(),p=s.args.pop();s.args.push(new g(u,s.name,[c,p]))}s=new g(u,s.name,s.args)}if(me(s)&&s.isUnary()){var v=S(s.args[0],t);if("~"===s.op&&me(v)&&v.isUnary()&&"~"===v.op)return v.args[0];if("not"===s.op&&me(v)&&v.isUnary()&&"not"===v.op&&N(v.args[0]))return v.args[0];var y=!0;if("-"===s.op&&me(v)&&(v.isBinary()&&"subtract"===v.fn&&(s=new g("-","subtract",[v.args[1],v.args[0]]),y=!1),v.isUnary()&&"-"===v.op))return v.args[0];if(y)return new g(s.op,s.fn,[v])}if(me(s)&&s.isBinary()){var C=S(s.args[0],t),M=S(s.args[1],t);if("+"===s.op){if(oe(C)&&i(C.value))return M;if(oe(M)&&i(M.value))return C;me(M)&&M.isUnary()&&"-"===M.op&&(M=M.args[0],s=new g("-","subtract",[C,M]))}if("-"===s.op)return me(M)&&M.isUnary()&&"-"===M.op?S(new g("+","add",[C,M.args[0]]),t):oe(C)&&i(C.value)?S(new g("-","unaryMinus",[M])):oe(M)&&i(M.value)?C:new g(s.op,s.fn,[C,M]);if("*"===s.op){if(oe(C)){if(i(C.value))return x;if(n(C.value,1))return M}if(oe(M)){if(i(M.value))return x;if(n(M.value,1))return C;if(A(s,r))return new g(s.op,s.fn,[M,C],s.implicit)}return new g(s.op,s.fn,[C,M],s.implicit)}if("/"===s.op)return oe(C)&&i(C.value)?x:oe(M)&&n(M.value,1)?C:new g(s.op,s.fn,[C,M]);if("^"===s.op&&oe(M)){if(i(M.value))return b;if(n(M.value,1))return C}if("and"===s.op){if(oe(C)){if(!C.value)return D;if(N(M))return M;if(oe(M))return M.value?w:D}if(oe(M)){if(!M.value)return D;if(N(C))return C}}if("or"===s.op){if(oe(C)){if(C.value)return w;if(N(M))return M}if(oe(M)){if(M.value)return w;if(N(C))return C}}return new g(s.op,s.fn,[C,M])}if(me(s))return new g(s.op,s.fn,s.args.map((e=>S(e,t))));if(re(s))return new f(s.items.map((e=>S(e,t))));if(te(s))return new l(S(s.object,t),S(s.index,t));if(le(s))return new h(s.dimensions.map((e=>S(e,t))));if(pe(s)){var F={};for(var T in s.properties)F[T]=S(s.properties[T],t);return new d(F)}return s}return t(Vd,{Node:S,"Node,Object":S})})),Yd=Me("resolve",["typed","parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],(e=>{var{typed:t,parse:r,ConstantNode:n,FunctionNode:i,OperatorNode:a,ParenthesisNode:o}=e;function s(e,t){var u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set;if(!t)return e;if(ve(e)){if(u.has(e.name)){var c=Array.from(u).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(c,"}"))}var l=t.get(e.name);if(fe(l)){var f=new Set(u);return f.add(e.name),s(l,t,f)}return"number"==typeof l?r(String(l)):void 0!==l?new n(l):e}if(me(e)){var p=e.args.map((function(e){return s(e,t,u)}));return new a(e.op,e.fn,p,e.implicit)}if(he(e))return new o(s(e.content,t,u));if(ce(e)){var m=e.args.map((function(e){return s(e,t,u)}));return new i(e.name,m)}return e.map((e=>s(e,t,u)))}return t("resolve",{Node:s,"Node, Map | null | undefined":s,"Node, Object":(e,t)=>s(e,M(t)),"Array | Matrix":t.referToSelf((e=>t=>t.map((t=>e(t))))),"Array | Matrix, null | undefined":t.referToSelf((e=>t=>t.map((t=>e(t))))),"Array, Object":t.referTo("Array,Map",(e=>(t,r)=>e(t,M(r)))),"Matrix, Object":t.referTo("Matrix,Map",(e=>(t,r)=>e(t,M(r)))),"Array | Matrix, Map":t.referToSelf((e=>(t,r)=>t.map((t=>e(t,r)))))})})),Jd="symbolicEqual",Xd=Me(Jd,["parse","simplify","typed","OperatorNode"],(e=>{var{parse:t,simplify:r,typed:n,OperatorNode:i}=e;function a(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=new i("-","subtract",[e,t]),o=r(a,{},n);return oe(o)&&!o.value}return n(Jd,{"Node, Node":a,"Node, Node, Object":a})})),Qd="derivative",Kd=Me(Qd,["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:t,config:r,parse:n,simplify:i,equal:a,isZero:o,numeric:s,ConstantNode:u,FunctionNode:c,OperatorNode:l,ParenthesisNode:f,SymbolNode:p}=e;function m(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{simplify:!0},n={};v(n,e,t.name);var a=y(e,n);return r.simplify?i(a):a}function h(e){var t=n(e);if(!t.isSymbolNode)throw new TypeError("Invalid variable. "+"Cannot parse ".concat(JSON.stringify(e)," into a variable in function derivative"));return t}var d=t(Qd,{"Node, SymbolNode":m,"Node, SymbolNode, Object":m,"Node, string":(e,t)=>m(e,h(t)),"Node, string, Object":(e,t,r)=>m(e,h(t),r)});d._simplify=!0,d.toTex=function(e){return g.apply(null,e.args)};var g=t("_derivTex",{"Node, SymbolNode":function(e,t){return oe(e)&&"string"===xe(e.value)?g(n(e.value).toString(),t.toString(),1):g(e.toTex(),t.toString(),1)},"Node, ConstantNode":function(e,t){if("string"===xe(t.value))return g(e,n(t.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(e,t,r){return g(e.toString(),t.name,r.value)},"string, string, number":function(e,t,r){return(1===r?"{d\\over d"+t+"}":"{d^{"+r+"}\\over d"+t+"^{"+r+"}}")+"\\left[".concat(e,"\\right]")}}),v=t("constTag",{"Object, ConstantNode, string":function(e,t){return e[t]=!0,!0},"Object, SymbolNode, string":function(e,t,r){return t.name!==r&&(e[t]=!0,!0)},"Object, ParenthesisNode, string":function(e,t,r){return v(e,t.content,r)},"Object, FunctionAssignmentNode, string":function(e,t,r){return t.params.includes(r)?v(e,t.expr,r):(e[t]=!0,!0)},"Object, FunctionNode | OperatorNode, string":function(e,t,r){if(t.args.length>0){for(var n=v(e,t.args[0],r),i=1;i<t.args.length;++i)n=v(e,t.args[i],r)&&n;if(n)return e[t]=!0,!0}return!1}}),y=t("_derivative",{"ConstantNode, Object":function(e){return x(0)},"SymbolNode, Object":function(e,t){return void 0!==t[e]?x(0):x(1)},"ParenthesisNode, Object":function(e,t){return new f(y(e.content,t))},"FunctionAssignmentNode, Object":function(e,t){return void 0!==t[e]?x(0):y(e.expr,t)},"FunctionNode, Object":function(e,t){if(void 0!==t[e])return x(0);var r,n,i,a,o=e.args[0],s=!1,u=!1;switch(e.name){case"cbrt":s=!0,n=new l("*","multiply",[x(3),new l("^","pow",[o,new l("/","divide",[x(2),x(3)])])]);break;case"sqrt":case"nthRoot":if(1===e.args.length)s=!0,n=new l("*","multiply",[x(2),new c("sqrt",[o])]);else if(2===e.args.length)return t[r=new l("/","divide",[x(1),e.args[1]])]=t[e.args[1]],y(new l("^","pow",[o,r]),t);break;case"log10":r=x(10);case"log":if(r||1!==e.args.length){if(1===e.args.length&&r||2===e.args.length&&void 0!==t[e.args[1]])n=new l("*","multiply",[o.clone(),new c("log",[r||e.args[1]])]),s=!0;else if(2===e.args.length)return y(new l("/","divide",[new c("log",[o]),new c("log",[e.args[1]])]),t)}else n=o.clone(),s=!0;break;case"pow":if(2===e.args.length)return t[r]=t[e.args[1]],y(new l("^","pow",[o,e.args[1]]),t);break;case"exp":n=new c("exp",[o.clone()]);break;case"sin":n=new c("cos",[o.clone()]);break;case"cos":n=new l("-","unaryMinus",[new c("sin",[o.clone()])]);break;case"tan":n=new l("^","pow",[new c("sec",[o.clone()]),x(2)]);break;case"sec":n=new l("*","multiply",[e,new c("tan",[o.clone()])]);break;case"csc":u=!0,n=new l("*","multiply",[e,new c("cot",[o.clone()])]);break;case"cot":u=!0,n=new l("^","pow",[new c("csc",[o.clone()]),x(2)]);break;case"asin":s=!0,n=new c("sqrt",[new l("-","subtract",[x(1),new l("^","pow",[o.clone(),x(2)])])]);break;case"acos":s=!0,u=!0,n=new c("sqrt",[new l("-","subtract",[x(1),new l("^","pow",[o.clone(),x(2)])])]);break;case"atan":s=!0,n=new l("+","add",[new l("^","pow",[o.clone(),x(2)]),x(1)]);break;case"asec":s=!0,n=new l("*","multiply",[new c("abs",[o.clone()]),new c("sqrt",[new l("-","subtract",[new l("^","pow",[o.clone(),x(2)]),x(1)])])]);break;case"acsc":s=!0,u=!0,n=new l("*","multiply",[new c("abs",[o.clone()]),new c("sqrt",[new l("-","subtract",[new l("^","pow",[o.clone(),x(2)]),x(1)])])]);break;case"acot":s=!0,u=!0,n=new l("+","add",[new l("^","pow",[o.clone(),x(2)]),x(1)]);break;case"sinh":n=new c("cosh",[o.clone()]);break;case"cosh":n=new c("sinh",[o.clone()]);break;case"tanh":n=new l("^","pow",[new c("sech",[o.clone()]),x(2)]);break;case"sech":u=!0,n=new l("*","multiply",[e,new c("tanh",[o.clone()])]);break;case"csch":u=!0,n=new l("*","multiply",[e,new c("coth",[o.clone()])]);break;case"coth":u=!0,n=new l("^","pow",[new c("csch",[o.clone()]),x(2)]);break;case"asinh":s=!0,n=new c("sqrt",[new l("+","add",[new l("^","pow",[o.clone(),x(2)]),x(1)])]);break;case"acosh":s=!0,n=new c("sqrt",[new l("-","subtract",[new l("^","pow",[o.clone(),x(2)]),x(1)])]);break;case"atanh":s=!0,n=new l("-","subtract",[x(1),new l("^","pow",[o.clone(),x(2)])]);break;case"asech":s=!0,u=!0,n=new l("*","multiply",[o.clone(),new c("sqrt",[new l("-","subtract",[x(1),new l("^","pow",[o.clone(),x(2)])])])]);break;case"acsch":s=!0,u=!0,n=new l("*","multiply",[new c("abs",[o.clone()]),new c("sqrt",[new l("+","add",[new l("^","pow",[o.clone(),x(2)]),x(1)])])]);break;case"acoth":s=!0,u=!0,n=new l("-","subtract",[x(1),new l("^","pow",[o.clone(),x(2)])]);break;case"abs":n=new l("/","divide",[new c(new p("abs"),[o.clone()]),o.clone()]);break;default:throw new Error('Cannot process function "'+e.name+'" in derivative: the function is not supported, undefined, or the number of arguments passed to it are not supported')}s?(i="/",a="divide"):(i="*",a="multiply");var f=y(o,t);return u&&(f=new l("-","unaryMinus",[f])),new l(i,a,[f,n])},"OperatorNode, Object":function(e,t){if(void 0!==t[e])return x(0);if("+"===e.op)return new l(e.op,e.fn,e.args.map((function(e){return y(e,t)})));if("-"===e.op){if(e.isUnary())return new l(e.op,e.fn,[y(e.args[0],t)]);if(e.isBinary())return new l(e.op,e.fn,[y(e.args[0],t),y(e.args[1],t)])}if("*"===e.op){var r=e.args.filter((function(e){return void 0!==t[e]}));if(r.length>0){var n=e.args.filter((function(e){return void 0===t[e]})),i=1===n.length?n[0]:new l("*","multiply",n),s=r.concat(y(i,t));return new l("*","multiply",s)}return new l("+","add",e.args.map((function(r){return new l("*","multiply",e.args.map((function(e){return e===r?y(e,t):e.clone()})))})))}if("/"===e.op&&e.isBinary()){var u=e.args[0],f=e.args[1];return void 0!==t[f]?new l("/","divide",[y(u,t),f]):void 0!==t[u]?new l("*","multiply",[new l("-","unaryMinus",[u]),new l("/","divide",[y(f,t),new l("^","pow",[f.clone(),x(2)])])]):new l("/","divide",[new l("-","subtract",[new l("*","multiply",[y(u,t),f.clone()]),new l("*","multiply",[u.clone(),y(f,t)])]),new l("^","pow",[f.clone(),x(2)])])}if("^"===e.op&&e.isBinary()){var p=e.args[0],m=e.args[1];if(void 0!==t[p])return oe(p)&&(o(p.value)||a(p.value,1))?x(0):new l("*","multiply",[e,new l("*","multiply",[new c("log",[p.clone()]),y(m.clone(),t)])]);if(void 0!==t[m]){if(oe(m)){if(o(m.value))return x(0);if(a(m.value,1))return y(p,t)}var h=new l("^","pow",[p.clone(),new l("-","subtract",[m,x(1)])]);return new l("*","multiply",[m.clone(),new l("*","multiply",[y(p,t),h])])}return new l("*","multiply",[new l("^","pow",[p.clone(),m.clone()]),new l("+","add",[new l("*","multiply",[y(p,t),new l("/","divide",[m.clone(),p.clone()])]),new l("*","multiply",[y(m,t),new c("log",[p.clone()])])])])}throw new Error('Cannot process operator "'+e.op+'" in derivative: the operator is not supported, undefined, or the number of arguments passed to it are not supported')}});function x(e,t){return new u(s(e,t||Re(String(e),r)))}return d})),eg="rationalize",tg=Me(eg,["config","typed","equal","isZero","add","subtract","multiply","divide","pow","parse","simplifyConstant","simplifyCore","simplify","?bignumber","?fraction","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode","ParenthesisNode"],(e=>{var{config:t,typed:r,equal:n,isZero:i,add:a,subtract:o,multiply:s,divide:u,pow:c,parse:l,simplifyConstant:f,simplifyCore:p,simplify:m,fraction:h,bignumber:d,mathWithTransform:g,matrix:v,AccessorNode:y,ArrayNode:x,ConstantNode:b,FunctionNode:w,IndexNode:D,ObjectNode:N,OperatorNode:E,SymbolNode:A,ParenthesisNode:S}=e;function C(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=function(){var e=[p,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},f,{l:"n*(n1^-1)",r:"n/n1"},{l:"n*n1^-n2",r:"n/n1^n2"},{l:"n1^-1",r:"1/n1"},{l:"n*(n1/n2)",r:"(n*n1)/n2"},{l:"1*n",r:"n"}],t=[{l:"(-n1)/(-n2)",r:"n1/n2"},{l:"(-n1)*(-n2)",r:"n1*n2"},{l:"n1--n2",r:"n1+n2"},{l:"n1-n2",r:"n1+(-n2)"},{l:"(n1+n2)*n3",r:"(n1*n3 + n2*n3)"},{l:"n1*(n2+n3)",r:"(n1*n2+n1*n3)"},{l:"c1*n + c2*n",r:"(c1+c2)*n"},{l:"c1*n + n",r:"(c1+1)*n"},{l:"c1*n - c2*n",r:"(c1-c2)*n"},{l:"c1*n - n",r:"(c1-1)*n"},{l:"v/c",r:"(1/c)*v"},{l:"v/-c",r:"-(1/c)*v"},{l:"-v*-c",r:"c*v"},{l:"-v*c",r:"-c*v"},{l:"v*-c",r:"-c*v"},{l:"v*c",r:"c*v"},{l:"-(-n1*n2)",r:"(n1*n2)"},{l:"-(n1*n2)",r:"(-n1*n2)"},{l:"-(-n1+n2)",r:"(n1-n2)"},{l:"-(n1+n2)",r:"(-n1-n2)"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"},{l:"-(-n1/n2)",r:"(n1/n2)"},{l:"-(n1/n2)",r:"(-n1/n2)"}],r=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],n={};return n.firstRules=e.concat(t,r),n.distrDivRules=[{l:"(n1/n2 + n3/n4)",r:"((n1*n4 + n3*n2)/(n2*n4))"},{l:"(n1/n2 + n3)",r:"((n1 + n3*n2)/n2)"},{l:"(n1 + n2/n3)",r:"((n1*n3 + n2)/n3)"}],n.sucDivRules=r,n.firstRulesAgain=e.concat(t),n.finalRules=[p,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},f,{l:"n*-n^n1",r:"-n^(n1+1)"},{l:"n*n^n1",r:"n^(n1+1)"},{l:"n^n1*-n^n2",r:"-n^(n1+n2)"},{l:"n^n1*n^n2",r:"n^(n1+n2)"},{l:"n^n1*-n",r:"-n^(n1+1)"},{l:"n^n1*n",r:"n^(n1+1)"},{l:"n^n1/-n",r:"-n^(n1-1)"},{l:"n^n1/n",r:"n^(n1-1)"},{l:"n/-n^n1",r:"-n^(1-n1)"},{l:"n/n^n1",r:"n^(1-n1)"},{l:"n^n1/-n^n2",r:"n^(n1-n2)"},{l:"n^n1/n^n2",r:"n^(n1-n2)"},{l:"n1+(-n2*n3)",r:"n1-n2*n3"},{l:"v*(-c)",r:"-c*v"},{l:"n1+-n2",r:"n1-n2"},{l:"v*c",r:"c*v"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"}],n}(),i=function(e,t,r,n){var i=[],a=m(e,n,t,{exactFractions:!1}),o="+-*"+((r=!!r)?"/":"");!function e(t){var r=t.type;if("FunctionNode"===r)throw new Error("There is an unsolved function call");if("OperatorNode"===r)if("^"===t.op){if("ConstantNode"!==t.args[1].type||!qe(parseFloat(t.args[1].value)))throw new Error("There is a non-integer exponent");e(t.args[0])}else{if(!o.includes(t.op))throw new Error("Operator "+t.op+" invalid in polynomial expression");for(var n=0;n<t.args.length;n++)e(t.args[n])}else if("SymbolNode"===r){var a=t.name;-1===i.indexOf(a)&&i.push(a)}else if("ParenthesisNode"===r)e(t.content);else if("ConstantNode"!==r)throw new Error("type "+r+" is not allowed in polynomial expression")}(a);var s={};return s.expression=a,s.variables=i,s}(e,t,!0,n.firstRules),a=i.variables.length,o={exactFractions:!1},s={exactFractions:!0};if(e=i.expression,a>=1){var u,c;e=M(e);var l,h=!0,d=!1;for(e=m(e,n.firstRules,{},o);c=h?n.distrDivRules:n.sucDivRules,h=!h,(l=(e=m(e,c,{},s)).toString())!==u;)d=!0,u=l;d&&(e=m(e,n.firstRulesAgain,{},o)),e=m(e,n.finalRules,{},o)}var g=[],v={};return"OperatorNode"===e.type&&e.isBinary()&&"/"===e.op?(1===a&&(e.args[0]=F(e.args[0],g),e.args[1]=F(e.args[1])),r&&(v.numerator=e.args[0],v.denominator=e.args[1])):(1===a&&(e=F(e,g)),r&&(v.numerator=e,v.denominator=null)),r?(v.coefficients=g,v.variables=i.variables,v.expression=e,v):e}return r(eg,{Node:C,"Node, boolean":(e,t)=>C(e,{},t),"Node, Object":C,"Node, Object, boolean":C});function M(e,t,r){var n=e.type,i=arguments.length>1;if("OperatorNode"===n&&e.isBinary()){var a,o=!1;if("^"===e.op&&("ParenthesisNode"!==e.args[0].type&&"OperatorNode"!==e.args[0].type||"ConstantNode"!==e.args[1].type||(o=(a=parseFloat(e.args[1].value))>=2&&qe(a))),o){if(a>2){var s=e.args[0],u=new E("^","pow",[e.args[0].cloneDeep(),new b(a-1)]);e=new E("*","multiply",[s,u])}else e=new E("*","multiply",[e.args[0],e.args[0].cloneDeep()]);i&&("content"===r?t.content=e:t.args[r]=e)}}if("ParenthesisNode"===n)M(e.content,e,"content");else if("ConstantNode"!==n&&"SymbolNode"!==n)for(var c=0;c<e.args.length;c++)M(e.args[c],e,c);if(!i)return e}function F(e,t){void 0===t&&(t=[]),t[0]=0;var r=0,n="";!function e(i,a,o){var s=i.type;if("FunctionNode"===s)throw new Error("There is an unsolved function call");if("OperatorNode"===s){if(!"+-*^".includes(i.op))throw new Error("Operator "+i.op+" invalid");if(null!==a){if(("unaryMinus"===i.fn||"pow"===i.fn)&&"add"!==a.fn&&"subtract"!==a.fn&&"multiply"!==a.fn)throw new Error("Invalid "+i.op+" placing");if(("subtract"===i.fn||"add"===i.fn||"multiply"===i.fn)&&"add"!==a.fn&&"subtract"!==a.fn)throw new Error("Invalid "+i.op+" placing");if(("subtract"===i.fn||"add"===i.fn||"unaryMinus"===i.fn)&&0!==o.noFil)throw new Error("Invalid "+i.op+" placing")}"^"!==i.op&&"*"!==i.op||(o.fire=i.op);for(var u=0;u<i.args.length;u++)"unaryMinus"===i.fn&&(o.oper="-"),"+"!==i.op&&"subtract"!==i.fn||(o.fire="",o.cte=1,o.oper=0===u?"+":i.op),o.noFil=u,e(i.args[u],i,o)}else if("SymbolNode"===s){if(i.name!==n&&""!==n)throw new Error("There is more than one variable");if(n=i.name,null===a)return void(t[1]=1);if("^"===a.op&&0!==o.noFil)throw new Error("In power the variable should be the first parameter");if("*"===a.op&&1!==o.noFil)throw new Error("In multiply the variable should be the second parameter");""!==o.fire&&"*"!==o.fire||(r<1&&(t[1]=0),t[1]+=o.cte*("+"===o.oper?1:-1),r=Math.max(1,r))}else{if("ConstantNode"!==s)throw new Error("Type "+s+" is not allowed");var c=parseFloat(i.value);if(null===a)return void(t[0]=c);if("^"===a.op){if(1!==o.noFil)throw new Error("Constant cannot be powered");if(!qe(c)||c<=0)throw new Error("Non-integer exponent is not allowed");for(var l=r+1;l<c;l++)t[l]=0;return c>r&&(t[c]=0),t[c]+=o.cte*("+"===o.oper?1:-1),void(r=Math.max(c,r))}o.cte=c,""===o.fire&&(t[0]+=o.cte*("+"===o.oper?1:-1))}}(e,null,{cte:1,oper:"+",fire:""});for(var i,a=!0,o=r=t.length-1;o>=0;o--)if(0!==t[o]){var s=new b(a?t[o]:Math.abs(t[o])),u=t[o]<0?"-":"+";if(o>0){var c=new A(n);if(o>1){var l=new b(o);c=new E("^","pow",[c,l])}s=-1===t[o]&&a?new E("-","unaryMinus",[c]):1===Math.abs(t[o])?c:new E("*","multiply",[s,c])}i=a?s:"+"===u?new E("+","add",[i,s]):new E("-","subtract",[i,s]),a=!1}return a?new b(0):i}})),rg="zpk2tf",ng=Me(rg,["typed","add","multiply","Complex","number"],(e=>{var{typed:t,add:r,multiply:n,Complex:i,number:a}=e;return t(rg,{"Array,Array,number":function(e,t,r){return o(e,t,r)},"Array,Array":function(e,t){return o(e,t,1)},"Matrix,Matrix,number":function(e,t,r){return o(e.valueOf(),t.valueOf(),r)},"Matrix,Matrix":function(e,t){return o(e.valueOf(),t.valueOf(),1)}});function o(e,t,r){e.some((e=>"BigNumber"===e.type))&&(e=e.map((e=>a(e)))),t.some((e=>"BigNumber"===e.type))&&(t=t.map((e=>a(e))));for(var o=[i(1,0)],u=[i(1,0)],c=0;c<e.length;c++){var l=e[c];"number"==typeof l&&(l=i(l,0)),o=s(o,[i(1,0),i(-l.re,-l.im)])}for(var f=0;f<t.length;f++){var p=t[f];"number"==typeof p&&(p=i(p,0)),u=s(u,[i(1,0),i(-p.re,-p.im)])}for(var m=0;m<o.length;m++)o[m]=n(o[m],r);return[o,u]}function s(e,t){for(var a=[],o=0;o<e.length+t.length-1;o++){a[o]=i(0,0);for(var s=0;s<e.length;s++)o-s>=0&&o-s<t.length&&(a[o]=r(a[o],n(e[s],t[o-s])))}return a}})),ig="freqz",ag=Me(ig,["typed","add","multiply","Complex","divide","matrix"],(e=>{var{typed:t,add:r,multiply:n,Complex:i,divide:a,matrix:o}=e;return t(ig,{"Array, Array":function(e,t){return s(e,t,u(512))},"Array, Array, Array":function(e,t,r){return s(e,t,r)},"Array, Array, number":function(e,t,r){if(r<0)throw new Error("w must be a positive number");return s(e,t,u(r))},"Matrix, Matrix":function(e,t){var r=u(512),{w:n,h:i}=s(e.valueOf(),t.valueOf(),r);return{w:o(n),h:o(i)}},"Matrix, Matrix, Matrix":function(e,t,r){var{h:n}=s(e.valueOf(),t.valueOf(),r.valueOf());return{h:o(n),w:o(r)}},"Matrix, Matrix, number":function(e,t,r){if(r<0)throw new Error("w must be a positive number");var n=u(r),{h:i}=s(e.valueOf(),t.valueOf(),n);return{h:o(i),w:o(n)}}});function s(e,t,o){for(var s=[],u=[],c=0;c<o.length;c++){for(var l=i(0,0),f=i(0,0),p=0;p<e.length;p++)l=r(l,n(e[p],i(Math.cos(-p*o[c]),Math.sin(-p*o[c]))));for(var m=0;m<t.length;m++)f=r(f,n(t[m],i(Math.cos(-m*o[c]),Math.sin(-m*o[c]))));s.push(l),u.push(f)}for(var h=[],d=0;d<s.length;d++)h.push(a(s[d],u[d]));return{h,w:o}}function u(e){for(var t=[],r=0;r<e;r++)t.push(r/e*Math.PI);return t}})),og=Me("reviver",["classes"],(e=>{var{classes:t}=e;return function(e,r){var n=t[r&&r.mathjs];return n&&"function"==typeof n.fromJSON?n.fromJSON(r):r}})),sg=Me("replacer",[],(()=>function(e,t){return"number"!=typeof t||isFinite(t)&&!isNaN(t)?"bigint"==typeof t?{mathjs:"bigint",value:String(t)}:t:{mathjs:"number",value:String(t)}})),ug=Math.PI,cg=2*Math.PI,lg=Math.E,fg=Me("true",[],(()=>!0)),pg=Me("false",[],(()=>!1)),mg=Me("null",[],(()=>null)),hg=Tg("Infinity",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1/0):1/0})),dg=Tg("NaN",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(NaN):NaN})),gg=Tg("pi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?Hl(r):ug})),vg=Tg("tau",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?$l(r):cg})),yg=Tg("e",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?Ul(r):lg})),xg=Tg("phi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?Ll(r):1.618033988749895})),bg=Tg("LN2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(2).ln():Math.LN2})),wg=Tg("LN10",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(10).ln():Math.LN10})),Dg=Tg("LOG2E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1).div(new r(2).ln()):Math.LOG2E})),Ng=Tg("LOG10E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1).div(new r(10).ln()):Math.LOG10E})),Eg=Tg("SQRT1_2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r("0.5").sqrt():Math.SQRT1_2})),Ag=Tg("SQRT2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(2).sqrt():Math.SQRT2})),Sg=Tg("i",["Complex"],(e=>{var{Complex:t}=e;return t.I})),Cg=Me("PI",["pi"],(e=>{var{pi:t}=e;return t})),Mg=Me("E",["e"],(e=>{var{e:t}=e;return t})),Fg=Me("version",[],(()=>"13.2.3"));function Tg(e,t,r){return Me(e,t,r,{recreateOnConfigChange:!0})}var _g=Cv("speedOfLight","299792458","m s^-1"),Bg=Cv("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),Og=Cv("planckConstant","6.62607015e-34","J s"),kg=Cv("reducedPlanckConstant","1.0545718176461565e-34","J s"),zg=Cv("magneticConstant","1.25663706212e-6","N A^-2"),Ig=Cv("electricConstant","8.8541878128e-12","F m^-1"),qg=Cv("vacuumImpedance","376.730313667","ohm"),Rg=Cv("coulomb","8.987551792261171e9","N m^2 C^-2"),Pg=Cv("elementaryCharge","1.602176634e-19","C"),jg=Cv("bohrMagneton","9.2740100783e-24","J T^-1"),Ug=Cv("conductanceQuantum","7.748091729863649e-5","S"),Lg=Cv("inverseConductanceQuantum","12906.403729652257","ohm"),Hg=Cv("magneticFluxQuantum","2.0678338484619295e-15","Wb"),$g=Cv("nuclearMagneton","5.0507837461e-27","J T^-1"),Gg=Cv("klitzing","25812.807459304513","ohm"),Wg=Cv("bohrRadius","5.29177210903e-11","m"),Vg=Cv("classicalElectronRadius","2.8179403262e-15","m"),Zg=Cv("electronMass","9.1093837015e-31","kg"),Yg=Cv("fermiCoupling","1.1663787e-5","GeV^-2"),Jg=Mv("fineStructure",.0072973525693),Xg=Cv("hartreeEnergy","4.3597447222071e-18","J"),Qg=Cv("protonMass","1.67262192369e-27","kg"),Kg=Cv("deuteronMass","3.3435830926e-27","kg"),ev=Cv("neutronMass","1.6749271613e-27","kg"),tv=Cv("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),rv=Cv("rydberg","10973731.568160","m^-1"),nv=Cv("thomsonCrossSection","6.6524587321e-29","m^2"),iv=Mv("weakMixingAngle",.2229),av=Mv("efimovFactor",22.7),ov=Cv("atomicMass","1.66053906660e-27","kg"),sv=Cv("avogadro","6.02214076e23","mol^-1"),uv=Cv("boltzmann","1.380649e-23","J K^-1"),cv=Cv("faraday","96485.33212331001","C mol^-1"),lv=Cv("firstRadiation","3.7417718521927573e-16","W m^2"),fv=Cv("loschmidt","2.686780111798444e25","m^-3"),pv=Cv("gasConstant","8.31446261815324","J K^-1 mol^-1"),mv=Cv("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),hv=Cv("molarVolume","0.022413969545014137","m^3 mol^-1"),dv=Mv("sackurTetrode",-1.16487052358),gv=Cv("secondRadiation","0.014387768775039337","m K"),vv=Cv("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),yv=Cv("wienDisplacement","2.897771955e-3","m K"),xv=Cv("molarMass","0.99999999965e-3","kg mol^-1"),bv=Cv("molarMassC12","11.9999999958e-3","kg mol^-1"),wv=Cv("gravity","9.80665","m s^-2"),Dv=Cv("planckLength","1.616255e-35","m"),Nv=Cv("planckMass","2.176435e-8","kg"),Ev=Cv("planckTime","5.391245e-44","s"),Av=Cv("planckCharge","1.87554603778e-18","C"),Sv=Cv("planckTemperature","1.416785e+32","K");function Cv(e,t,r){return Me(e,["config","Unit","BigNumber"],(e=>{var{config:n,Unit:i,BigNumber:a}=e,o=new i("BigNumber"===n.number?new a(t):parseFloat(t),r);return o.fixPrefix=!0,o}))}function Mv(e,t){return Me(e,["config","BigNumber"],(e=>{var{config:r,BigNumber:n}=e;return"BigNumber"===r.number?new n(t):t}))}var Fv=Me("apply",["typed","isInteger"],(e=>{var{typed:t,isInteger:r}=e,n=qa({typed:t,isInteger:r});return t("apply",{"...any":function(e){var t=e[1];F(t)?e[1]=t-1:T(t)&&(e[1]=t.minus(1));try{return n.apply(null,e)}catch(e){throw Rp(e)}}})}),{isTransformFunction:!0}),Tv=Me("column",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e,a=Ps({typed:t,Index:r,matrix:n,range:i});return t("column",{"...any":function(e){var t=e.length-1,r=e[t];F(r)&&(e[t]=r-1);try{return a.apply(null,e)}catch(e){throw Rp(e)}}})}),{isTransformFunction:!0});function _v(e,t,r){var n=e.filter((function(e){return ve(e)&&!(e.name in t)&&!r.has(e.name)}))[0];if(!n)throw new Error('No undefined variable found in inline expression "'+e+'"');var i=n.name,a=new Map,o=new A(r,a,new Set([i])),s=e.compile();return function(e){return a.set(i,e),s.evaluate(o)}}var Bv=Me("transformCallback",["typed"],(e=>{var{typed:t}=e;return function(e,n){return t.isTypedFunction(e)?r(e,n):Ov(e,e.length,n)};function r(e,n){var i=Object.fromEntries(Object.entries(e.signatures).map((e=>{var[i,a]=e,o=i.split(",").length;return t.isTypedFunction(a)?[i,r(a,n)]:[i,Ov(a,o,n)]})));return"string"==typeof e.name?t(e.name,i):t(i)}}));function Ov(e,t,r){return t===r?e:t===r+1?function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];var a=n.slice(0,r),o=kv(n[r]);return e(...a,o)}:t>r+1?function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];var a=n.slice(0,r),o=kv(n[r]),s=n.slice(r+1);return e(...a,o,...s)}:e}function kv(e){return e.map((e=>e+1))}var zv=Me("filter",["typed"],(e=>{var{typed:t}=e;function r(e,r,i){var a=Ws({typed:t}),o=Bv({typed:t});if(0===e.length)return a();var s=e[0];if(1===e.length)return a(s);var u=e.length-1,c=e[u];return s&&(s=n(s,i)),c&&(c=ve(c)||ue(c)?n(c,i):_v(c,r,i)),a(s,o(c,u))}function n(e,t){return e.compile().evaluate(t)}return r.rawArgs=!0,r}),{isTransformFunction:!0}),Iv=Me("forEach",["typed"],(e=>{var{typed:t}=e,r=Xs({typed:t}),n=Bv({typed:t});function i(e,t,i){if(0===e.length)return r();var o=e[0];if(1===e.length)return r(o);var s=e.length-1,u=e[s];return o&&(o=a(o,i)),u&&(u=ve(u)||ue(u)?a(u,i):_v(u,t,i)),r(o,n(u,s))}function a(e,t){return e.compile().evaluate(t)}return i.rawArgs=!0,i}),{isTransformFunction:!0}),qv=Me("index",["Index","getMatrixDataType"],(e=>{var{Index:t,getMatrixDataType:r}=e;return function(){for(var e=[],n=0,i=arguments.length;n<i;n++){var a=arguments[n];if(U(a))a.start--,a.end-=a.step>0?0:2;else if(a&&!0===a.isSet)a=a.map((function(e){return e-1}));else if(I(a)||q(a))"boolean"!==r(a)&&(a=a.map((function(e){return e-1})));else if(F(a))a--;else if(T(a))a=a.toNumber()-1;else if("string"!=typeof a)throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");e[n]=a}var o=new t;return t.apply(o,e),o}}),{isTransformFunction:!0}),Rv=Me("map",["typed"],(e=>{var{typed:t}=e,r=ou({typed:t}),n=Bv({typed:t});function i(e,t,i){if(0===e.length)return r();if(1===e.length)return r(e[0]);var a=e.length-1,o=e.slice(0,a),s=e[a];return o=o.map((e=>u(e,i))),s&&(s=ve(s)||ue(s)?u(s,i):_v(s,t,i)),r(...o,n(s,a));function u(e,t){return e.compile().evaluate(t)}}return i.rawArgs=!0,i}),{isTransformFunction:!0});function Pv(e){if(2===e.length&&R(e[0])){var t=(e=e.slice())[1];(F(r=t)||T(r))&&(e[1]=function(e){return F(e)?e-1:T(e)?e.minus(1):e}(t))}var r;return e}var jv=Me("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:r,numeric:n,larger:i}=e,a=Bl({typed:t,config:r,numeric:n,larger:i});return t("max",{"...any":function(e){e=Pv(e);try{return a.apply(null,e)}catch(e){throw Rp(e)}}})}),{isTransformFunction:!0}),Uv=Me("mean",["typed","add","divide"],(e=>{var{typed:t,add:r,divide:n}=e,i=zh({typed:t,add:r,divide:n});return t("mean",{"...any":function(e){e=Pv(e);try{return i.apply(null,e)}catch(e){throw Rp(e)}}})}),{isTransformFunction:!0}),Lv=Me("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:r,numeric:n,smaller:i}=e,a=Ol({typed:t,config:r,numeric:n,smaller:i});return t("min",{"...any":function(e){e=Pv(e);try{return a.apply(null,e)}catch(e){throw Rp(e)}}})}),{isTransformFunction:!0}),Hv=Me("range",["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq","add","isPositive"],(e=>{var{typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u,add:c,isPositive:l}=e,f=hu({typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u,add:c,isPositive:l});return t("range",{"...any":function(e){return"boolean"!=typeof e[e.length-1]&&e.push(!0),f.apply(null,e)}})}),{isTransformFunction:!0}),$v=Me("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e,a=Du({typed:t,Index:r,matrix:n,range:i});return t("row",{"...any":function(e){var t=e.length-1,r=e[t];F(r)&&(e[t]=r-1);try{return a.apply(null,e)}catch(e){throw Rp(e)}}})}),{isTransformFunction:!0}),Gv=Me("subset",["typed","matrix","zeros","add"],(e=>{var{typed:t,matrix:r,zeros:n,add:i}=e,a=Mu({typed:t,matrix:r,zeros:n,add:i});return t("subset",{"...any":function(e){try{return a.apply(null,e)}catch(e){throw Rp(e)}}})}),{isTransformFunction:!0}),Wv=Me("concat",["typed","matrix","isInteger"],(e=>{var{typed:t,matrix:r,isInteger:n}=e,i=qs({typed:t,matrix:r,isInteger:n});return t("concat",{"...any":function(e){var t=e.length-1,r=e[t];F(r)?e[t]=r-1:T(r)&&(e[t]=r.minus(1));try{return i.apply(null,e)}catch(e){throw Rp(e)}}})}),{isTransformFunction:!0}),Vv="diff",Zv=Me(Vv,["typed","matrix","subtract","number","bignumber"],(e=>{var{typed:t,matrix:r,subtract:n,number:i,bignumber:a}=e,o=uu({typed:t,matrix:r,subtract:n,number:i,bignumber:a});return t(Vv,{"...any":function(e){e=Pv(e);try{return o.apply(null,e)}catch(e){throw Rp(e)}}})}),{isTransformFunction:!0}),Yv=Me("std",["typed","map","sqrt","variance"],(e=>{var{typed:t,map:r,sqrt:n,variance:i}=e,a=$h({typed:t,map:r,sqrt:n,variance:i});return t("std",{"...any":function(e){e=Pv(e);try{return a.apply(null,e)}catch(e){throw Rp(e)}}})}),{isTransformFunction:!0}),Jv=Me("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:r,add:n,numeric:i}=e,a=_h({typed:t,config:r,add:n,numeric:i});return t("sum",{"...any":function(e){e=Pv(e);try{return a.apply(null,e)}catch(e){throw Rp(e)}}})}),{isTransformFunction:!0}),Xv=Me("quantileSeq",["typed","bignumber","add","subtract","divide","multiply","partitionSelect","compare","isInteger","smaller","smallerEq","larger"],(e=>{var{typed:t,bignumber:r,add:n,subtract:i,divide:a,multiply:o,partitionSelect:s,compare:u,isInteger:c,smaller:l,smallerEq:f,larger:p}=e,m=Hh({typed:t,bignumber:r,add:n,subtract:i,divide:a,multiply:o,partitionSelect:s,compare:u,isInteger:c,smaller:l,smallerEq:f,larger:p});return t("quantileSeq",{"Array | Matrix, number | BigNumber":m,"Array | Matrix, number | BigNumber, number":(e,t,r)=>m(e,t,h(r)),"Array | Matrix, number | BigNumber, boolean":m,"Array | Matrix, number | BigNumber, boolean, number":(e,t,r,n)=>m(e,t,r,h(n)),"Array | Matrix, Array | Matrix":m,"Array | Matrix, Array | Matrix, number":(e,t,r)=>m(e,t,h(r)),"Array | Matrix, Array | Matrix, boolean":m,"Array | Matrix, Array | Matrix, boolean, number":(e,t,r,n)=>m(e,t,r,h(n))});function h(e){return Pv([[],e])[1]}}),{isTransformFunction:!0}),Qv="cumsum",Kv=Me(Qv,["typed","add","unaryPlus"],(e=>{var{typed:t,add:r,unaryPlus:n}=e,i=Oh({typed:t,add:r,unaryPlus:n});return t(Qv,{"...any":function(e){if(2===e.length&&R(e[0])){var t=e[1];F(t)?e[1]=t-1:T(t)&&(e[1]=t.minus(1))}try{return i.apply(null,e)}catch(e){throw Rp(e)}}})}),{isTransformFunction:!0}),ey="variance",ty=Me(ey,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:r,subtract:n,multiply:i,divide:a,apply:o,isNaN:s}=e,u=Uh({typed:t,add:r,subtract:n,multiply:i,divide:a,apply:o,isNaN:s});return t(ey,{"...any":function(e){e=Pv(e);try{return u.apply(null,e)}catch(e){throw Rp(e)}}})}),{isTransformFunction:!0}),ry="print",ny=Me(ry,["typed","matrix","zeros","add"],(e=>{var{typed:t,matrix:r,zeros:n,add:i}=e,a=pc({typed:t,matrix:r,zeros:n,add:i});return t(ry,{"string, Object | Array":function(e,t){return a(o(e),t)},"string, Object | Array, number | Object":function(e,t,r){return a(o(e),t,r)}});function o(e){return e.replace(lc,(e=>"$"+e.slice(1).split(".").map((function(e){return!isNaN(e)&&e.length>0?parseInt(e)-1:e})).join(".")))}}),{isTransformFunction:!0}),iy=Me("and",["typed","matrix","zeros","add","equalScalar","not","concat"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,not:a,concat:o}=e,s=Jc({typed:t,matrix:r,equalScalar:n,zeros:i,not:a,concat:o});function u(e,t,r){var n=e[0].compile().evaluate(r);if(!R(n)&&!s(n,!0))return!1;var i=e[1].compile().evaluate(r);return s(n,i)}return u.rawArgs=!0,u}),{isTransformFunction:!0}),ay=Me("or",["typed","matrix","equalScalar","DenseMatrix","concat"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i,concat:a}=e,o=ks({typed:t,matrix:r,equalScalar:n,DenseMatrix:i,concat:a});function s(e,t,r){var n=e[0].compile().evaluate(r);if(!R(n)&&o(n,!1))return!0;var i=e[1].compile().evaluate(r);return o(n,i)}return s.rawArgs=!0,s}),{isTransformFunction:!0}),oy=Me("bitAnd",["typed","matrix","zeros","add","equalScalar","not","concat"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,not:a,concat:o}=e,s=ds({typed:t,matrix:r,equalScalar:n,zeros:i,not:a,concat:o});function u(e,t,r){var n=e[0].compile().evaluate(r);if(!R(n)){if(isNaN(n))return NaN;if(0===n||!1===n)return 0}var i=e[1].compile().evaluate(r);return s(n,i)}return u.rawArgs=!0,u}),{isTransformFunction:!0}),sy=Me("bitOr",["typed","matrix","equalScalar","DenseMatrix","concat"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i,concat:a}=e,o=xs({typed:t,matrix:r,equalScalar:n,DenseMatrix:i,concat:a});function s(e,t,r){var n=e[0].compile().evaluate(r);if(!R(n)){if(isNaN(n))return NaN;if(-1===n)return-1;if(!0===n)return 1}var i=e[1].compile().evaluate(r);return o(n,i)}return s.rawArgs=!0,s}),{isTransformFunction:!0}),uy=e,cy=r(1354);const ly=function e(t,r){var n=m({},Be,r);if("function"!=typeof Object.create)throw new Error("ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.");var i,a,o=(i={isNumber:F,isComplex:B,isBigNumber:T,isBigInt:_,isFraction:O,isUnit:k,isString:z,isArray:I,isMatrix:q,isCollection:R,isDenseMatrix:P,isSparseMatrix:j,isRange:U,isIndex:L,isBoolean:H,isResultSet:$,isHelp:G,isFunction:W,isDate:V,isRegExp:Z,isObject:Y,isMap:J,isPartitionedMap:X,isObjectWrappingMap:Q,isNull:K,isUndefined:ee,isAccessorNode:te,isArrayNode:re,isAssignmentNode:ne,isBlockNode:ie,isConditionalNode:ae,isConstantNode:oe,isFunctionAssignmentNode:ue,isFunctionNode:ce,isIndexNode:le,isNode:fe,isObjectNode:pe,isOperatorNode:me,isParenthesisNode:he,isRangeNode:de,isRelationalNode:ge,isSymbolNode:ve,isChain:ye},a=new _e,i.on=a.on.bind(a),i.off=a.off.bind(a),i.once=a.once.bind(a),i.emit=a.emit.bind(a),i);o.config=ze(n,o.emit),o.expression={transform:{},mathWithTransform:{config:o.config}};var s={};function u(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return o.typed.apply(o.typed,t)}u.isTypedFunction=h.isTypedFunction;var c=function(e,t,r,n){function i(t,i,o){var s;if(o.wrap&&"function"==typeof i&&(i=function(e){var t=function(){for(var t=[],n=0,i=arguments.length;n<i;n++){var a=arguments[n];t[n]=a&&a.valueOf()}return e.apply(r,t)};return e.transform&&(t.transform=e.transform),t}(i)),"function"==typeof(s=i)&&"string"==typeof s.signature&&(i=e(t,{[i.signature]:i})),e.isTypedFunction(r[t])&&e.isTypedFunction(i))return i=o.override?e(t,i.signatures):e(r[t],i),r[t]=i,delete n[t],a(t,i),void r.emit("import",t,(function(){return i}));if(void 0===r[t]||o.override)return r[t]=i,delete n[t],a(t,i),void r.emit("import",t,(function(){return i}));if(!o.silent)throw new Error('Cannot import "'+t+'": already exists')}function a(e,t){t&&"function"==typeof t.transform?(r.expression.transform[e]=t.transform,u(e)&&(r.expression.mathWithTransform[e]=t.transform)):(delete r.expression.transform[e],u(e)&&(r.expression.mathWithTransform[e]=t))}function o(e){delete r.expression.transform[e],u(e)?r.expression.mathWithTransform[e]=r[e]:delete r.expression.mathWithTransform[e]}function s(t,i){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.fn;if(a.includes("."))throw new Error("Factory name should not contain a nested path. Name: "+JSON.stringify(a));var s=l(t)?r.expression.transform:r,u=a in r.expression.transform,f=Ce(s,a)?s[a]:void 0,p=function(){var n={};t.dependencies.map(Te).forEach((e=>{if(e.includes("."))throw new Error("Factory dependency should not contain a nested path. Name: "+JSON.stringify(e));"math"===e?n.math=r:"mathWithTransform"===e?n.mathWithTransform=r.expression.mathWithTransform:"classes"===e?n.classes=r:n[e]=r[e]}));var o=t(n);if(o&&"function"==typeof o.transform)throw new Error('Transforms cannot be attached to factory functions. Please create a separate function for it with export const path = "expression.transform"');if(void 0===f||i.override)return o;if(e.isTypedFunction(f)&&e.isTypedFunction(o))return e(f,o);if(i.silent)return f;throw new Error('Cannot import "'+a+'": already exists')};t.meta&&!1===t.meta.lazy?(s[a]=p(),f&&u?o(a):(l(t)||c(t))&&Se(r.expression.mathWithTransform,a,(()=>s[a]))):(Se(s,a,p),f&&u?o(a):(l(t)||c(t))&&Se(r.expression.mathWithTransform,a,(()=>s[a]))),n[a]=t,r.emit("import",a,p)}function u(e){return!Ce(f,e)}function c(e){return!(e.fn.includes(".")||Ce(f,e.fn)||e.meta&&e.meta.isClass)}function l(e){return void 0!==e&&void 0!==e.meta&&!0===e.meta.isTransformFunction||!1}var f={expression:!0,type:!0,docs:!0,error:!0,json:!0,chain:!0};return function(e,t){var r=arguments.length;if(1!==r&&2!==r)throw new d("import",r,1,2);t||(t={});var n,a={};for(var o in function e(r,n,i){if(Array.isArray(n))n.forEach((t=>e(r,t)));else if("object"==typeof n)for(var a in n)Ce(n,a)&&e(r,n[a],a);else if(Fe(n)||void 0!==i){var o=Fe(n)?l(n)?n.fn+".transform":n.fn:i;if(Ce(r,o)&&r[o]!==n&&!t.silent)throw new Error('Cannot import "'+o+'" twice');r[o]=n}else if(!t.silent)throw new TypeError("Factory, Object, or Array expected")}(a,e),a)if(Ce(a,o)){var u=a[o];if(Fe(u))s(u,t);else if("function"==typeof(n=u)||"number"==typeof n||"string"==typeof n||"boolean"==typeof n||null===n||k(n)||B(n)||T(n)||O(n)||q(n)||Array.isArray(n))i(o,u,t);else if(!t.silent)throw new TypeError("Factory, Object, or Array expected")}}}(u,0,o,s);return o.import=c,o.on("config",(()=>{Object.values(s).forEach((e=>{e&&e.meta&&e.meta.recreateOnConfigChange&&c(e,{override:!0})}))})),o.create=e.bind(null,t),o.factory=Me,o.import(Object.values(Ee(t))),o.ArgumentsError=d,o.DimensionError=g,o.IndexError=v,o}(uy);ly.import({equal:function(e,t){return e===t}},{override:!0}),ly.import({unequal:function(e,t){return e!==t}},{override:!0});const fy=(e,t)=>{if(!e)return;const r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i.exec(e);let[n,i,a,o]=r.slice(1).map((e=>parseInt(e,16)));return o=isNaN(o)?o=void 0:o/=255,t?{r:n,g:i,b:a,opacity:o}:{color:`#${r.slice(1,4).join("")}`,opacity:o}},py=(e,t,r)=>({radius:gy(r,t,"radius"),weight:gy(r,t,"width"),opacity:t.parameters.alphaMultiplier,fillColor:gy(r,t,"fill"),fillOpacity:t.parameters.alphaMultiplier,color:gy(r,t,"fill"),popupProperty:t.parameters.popupProperty?.text});function my(e){return(256|Math.round(e)).toString(16).slice(1)}function hy(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+(t-e)*(2/3-r)*6:e}function dy(e,t){let r={};if(e.properties){let n=e.properties;const i=[];for(let e=0;e<n.length;e++){let r=t[n[e]];i.push(r)}for(let e=0;e<i.length;e++)r[`property${e+1}`]=i[e]}if(e.values){const t=e.values;for(let e=0;e<t.length;e++)r[`value${e+1}`]=t[e]}let n,i=e.expression.replaceAll(" ","").replaceAll("!=","NE").replaceAll("||","or").replaceAll("&&","and").replaceAll("!","not").replaceAll("NE","!=");try{n=ly.evaluate(i,r)}catch{n=null}return n}function gy(e,t,r="fill"){return function(e,t,r){let n;const i=t.parameters[r];switch(i.type){case"constant":n=i.target[i.target.type];break;case"seededRandom":{let r=dy(i.expressionObject,e);r=r??"",n="#"+function(e){let t=parseInt(e.substring(0,2),16)/255,r=parseInt(e.substring(2,4),16)/255,n=parseInt(e.substring(4,6),16)/255,i=Math.max(t,r,n),a=Math.min(t,r,n),o=(i+a)/2,s=(i+a)/2,u=(i+a)/2;if(i===a)o=0,s=0;else{let e=i-a;switch(s=u>.5?e/(2-i-a):e/(i+a),i){case t:o=(r-n)/e+(r<n?6:0);break;case r:o=(n-t)/e+2;break;case n:o=(t-r)/e+4}o/=6}if(s=.75*s+.25,u=.5*u+.25,0===s)t=u,r=u,n=u;else{let e=u<.5?u*(1+s):u+s-u*s,i=2*u-e;t=255*hy(i,e,o+1/3),r=255*hy(i,e,o),n=255*hy(i,e,o-1/3)}return my(t)+my(r)+my(n)}((0,cy.SHA256)(r.toString()).toString(cy.enc.Hex).substr(-6))+(a=t.parameters.alpha,(256|Math.round(255*a)).toString(16).slice(1));break}case"caseMap":for(let t=0;t<i.caseMap.length;t++){const r=i.caseMap[t];if(dy(r.expressionObject,e)){n=r.target[r.target.type];break}}n||(n=i.defaultTarget[i.defaultTarget.type]);break;case"rangeMap":{const t=dy(i.expressionObject,e);for(let e=0;e<i.rangeMap.length;e++){const r=i.rangeMap[e];if(t<=r.value){n=r.target[r.target.type];break}}n||(n=i.defaultTarget[i.defaultTarget.type]);break}case"valueMap":{const t=dy(i.expressionObject,e);for(let e=0;e<i.valueMap.length;e++){const r=i.valueMap[e];if(t===r.value){n=r.target[r.target.type];break}}n||(n=i.defaultTarget[i.defaultTarget.type]);break}case"expression":n=dy(i.expressionObject,e);break;default:throw Error(`Received invalid fill type in style.parameters.fill.type. Received ${i.type}`)}var a;return n?("fill"===r&&(n=n.slice(0,7)),n):"fill"===r?"#f57c00":"width"===r?5:10}(e,t=function(e){if("v2"===e.method)return e;if(e.parameters.alphaMultiplier=e.parameters.alpha,delete e.parameters.alpha,e.parameters.borderColor&&(e.parameters.borderColor={type:"constant",target:{type:"color",color:e.parameters.borderColor}}),e.parameters.altitude&&(e.parameters.elevation={type:"expression",defaultTarget:{type:"number",number:0},expressionObject:{properties:[e.parameters.altitude.property],values:[],expression:"property1"}},delete e.parameters.altitude),e.parameters.width={type:"constant",target:{type:"number",number:e.parameters.width}},"onProperty"===e.parameters.radius?.method?e.parameters.radius={type:"expression",defaultTarget:{type:"number",number:10},expressionObject:{properties:[e.parameters.radius.parameters.property],values:[],expression:"property1"}}:e.parameters.radius={type:"expression",defaultTarget:{type:"number",number:e.parameters.radius.parameters.value},expressionObject:{properties:[],values:[],expression:e.parameters.radius.parameters.value.toString()}},e.parameters.popupProperty){const t=e.parameters.textColor??"#000000";e.parameters.popOver={color:{type:"constant",target:{type:"color",color:t}},text:{type:"expression",defaultTarget:{type:"string",string:""},expressionObject:{properties:[e.parameters.popupProperty],values:[],expression:"property1"}}},delete e.parameters.popupProperty}let t;e.parameters.defaultColor&&(t={type:"color",color:e.parameters.defaultColor},delete e.parameters.defaultColor),e.parameters.icon&&(t={type:"icon",icon:e.parameters.defaultIcon},delete e.parameters.defaultIcon),e.parameters.pattern&&(t={type:"pattern",pattern:e.parameters.pattern},delete e.parameters.defaultPattern);const r=e=>{let t;return e.color?t={type:"color",color:e.color}:e.pattern?t={type:"pattern",pattern:e.pattern}:e.icon&&(t={type:"icon",icon:e.icon}),t};if("singleColor"===e.method)e.parameters.color&&(e.parameters.fill={type:"constant",target:{type:"color",color:e.parameters.color}},delete e.parameters.color),e.parameters.pattern&&(e.parameters.fill={type:"constant",target:{type:"pattern",color:e.parameters.pattern}},delete e.parameters.pattern),e.parameters.icon&&(e.parameters.fill={type:"constant",target:{type:"icon",color:e.parameters.icon}},delete e.parameters.icon);else if("fromColorProperty"===e.method)delete e.parameters.defaultColor,e.parameters.fill={type:"expression",defaultTarget:t,expressionObject:{properties:["color"],values:[],expression:"property1"}};else if("rules"===e.method){const n=e.parameters.rules.map((e=>{const t=r(e);"="===e.operator&&(e.operator="==");const n=`property1 ${e.operator} ${e.value}`;return{target:t,expressionObject:{properties:[e.property],values:[],expression:n}}}));delete e.parameters.rules,e.parameters.fill={type:"caseMap",defaultTarget:t,caseMap:n}}else if("random"===e.method)e.parameters.fill={type:"seededRandom",expressionObject:{properties:[e.parameters.property],values:[],expression:"property1"}},delete e.parameters.property;else if("transitionPoints"===e.method){const n=e.parameters.transitionPoints.map((e=>{const t=r(e);return{value:e.value,target:t}}));e.parameters.fill={type:"rangeMap",gradient:e.parameters.continuous,expressionObject:{properties:[e.parameters.property],values:[],expression:"property1"},defaultTarget:t,rangeMap:n},delete e.parameters.continuous,delete e.parameters.property,delete e.parameters.transitionPoints}else if("classToColor"===e.method){const n=e.parameters.colorMapping.map((e=>{const t=r(e);return{value:e.value,target:t}}));e.parameters.fill={type:"valueMap",expressionObject:{properties:[e.parameters.property],values:[],expression:"property1"},defaultTarget:t,valueMap:n},delete e.parameters.property,delete e.parameters.colorMapping}else if("formula"===e.method){const n=e.parameters.transitionPoints.map((e=>{const t=r(e);return{value:e.value,target:t}}));e.parameters.fill={type:"rangeMap",gradient:e.parameters.continuous,expressionObject:{properties:e.parameters.properties,values:[],expression:e.parameters.formula},defaultTarget:t,rangeMap:n},delete e.parameters.properties,delete e.parameters.formula,delete e.parameters.continuous,delete e.parameters.transitionPoints}return e.method="v2",e}(t),r)}class vy extends Error{constructor(e){super(e),this.name="EllipsisRasterLayerError"}}const yy=(e={})=>{const t=s({token:e.token,style:e.style??e.layer??e.visualizationId??e.visualization,mask:e.mask,epsg:e.epsg});return`${c.getApiUrl()}/path/${e.pathId??e.blockId}/raster/timestamp/${e.timestampId??e.captureId}/tile/{z}/{x}/{y}${t}`},xy=async(e={})=>{const t={token:e.token,style:e.style,mask:e.mask};let r=e.timestampId;const n=e.pathId;let i=e.zoom;if(!r||!t.style||!i){const e=await c.getPath(n,{token:t.token});if(!e)throw new vy(`Could not fetch data of path with id ${n}`);if("raster"!==e.type)throw new vy("Path is not of type raster");if(!r){if(!e.raster?.timestamps?.length)throw new vy("There are no timestamps in this path");const t=e.raster.timestamps.reverse().find((e=>!e.availability.blocked&&!e.trashed&&"active"===e.status));if(!t)throw new vy("Could not find a valid default timestamp.");r=t.id}if(!i){let t=e.raster.timestamps.find((e=>e.id===r));if(!t)throw new vy("Given timestampId does not exist");i=t.zoom}if(!t.style){const r=e.raster.styles?.find((e=>e.default));if(!r)throw new vy("No default style found");t.style=r.id}}e.epsg&&(t.epsg=e.epsg);let a=`${c.getApiUrl()}/path/${n}/raster/timestamp/${r}/tile/{z}/{x}/{y}${s(t)}`;return{zoom:i,url:a,id:a+"_"+i}},by=(e={})=>`${e.pathId??e.blockId}_${e.timestampId??e.captureId}_${encodeURIComponent(JSON.stringify(e.style))}`})(),n})()));